/* VideoPlayer version 1.3.0 */ !(function (t, e) { "object" == typeof exports && "undefined" != typeof module ? (module.exports = e()) : "function" == typeof define && define.amd ? define(e) : ((t = "undefined" != typeof globalThis ? globalThis : t || self).VideoPlayer = e()); })(this, function () { "use strict"; var t = "undefined" != typeof document ? document.currentScript : null; function e(t, e, n) { if ("function" == typeof t ? t === e : t.has(e)) return arguments.length < 3 ? e : n; throw new TypeError("Private element is not present on this object"); } function n(t, e, n) { return ( (e = A(e)), (function (t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return (function (t) { if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t; })(t); })(t, s() ? Reflect.construct(e, n || [], A(t).constructor) : e.apply(t, n)) ); } function r(t, n) { return t.get(e(t, n)); } function a(t, n, i) { return t.set(e(t, n), i), i; } function s() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () { })); } catch (t) { } return (s = function () { return !!t; })(); } function o(t, e) { var n = Object.keys(t); if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(t); e && (i = i.filter(function (e) { return Object.getOwnPropertyDescriptor(t, e).enumerable; })), n.push.apply(n, i); } return n; } function l(t) { for (var e = 1; e < arguments.length; e++) { var n = null != arguments[e] ? arguments[e] : {}; e % 2 ? o(Object(n), !0).forEach(function (e) { g(t, e, n[e]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : o(Object(n)).forEach(function (e) { Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e)); }); } return t; } function d() { d = function () { return e; }; var t, e = {}, n = Object.prototype, i = n.hasOwnProperty, r = Object.defineProperty || function (t, e, n) { t[e] = n.value; }, a = "function" == typeof Symbol ? Symbol : {}, s = a.iterator || "@@iterator", o = a.asyncIterator || "@@asyncIterator", l = a.toStringTag || "@@toStringTag"; function c(t, e, n) { return Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { c({}, ""); } catch (t) { c = function (t, e, n) { return (t[e] = n); }; } function u(t, e, n, i) { var a = e && e.prototype instanceof A ? e : A, s = Object.create(a.prototype), o = new R(i || []); return r(s, "_invoke", { value: k(t, n, o) }), s; } function h(t, e, n) { try { return { type: "normal", arg: t.call(e, n) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = u; var p = "suspendedStart", f = "suspendedYield", m = "executing", g = "completed", y = {}; function A() { } function v() { } function b() { } var E = {}; c(E, s, function () { return this; }); var w = Object.getPrototypeOf, x = w && w(w(D([]))); x && x !== n && i.call(x, s) && (E = x); var S = (b.prototype = A.prototype = Object.create(E)); function _(t) { ["next", "throw", "return"].forEach(function (e) { c(t, e, function (t) { return this._invoke(e, t); }); }); } function T(t, e) { function n(r, a, s, o) { var l = h(t[r], t, a); if ("throw" !== l.type) { var d = l.arg, c = d.value; return c && "object" == typeof c && i.call(c, "__await") ? e.resolve(c.__await).then( function (t) { n("next", t, s, o); }, function (t) { n("throw", t, s, o); } ) : e.resolve(c).then( function (t) { (d.value = t), s(d); }, function (t) { return n("throw", t, s, o); } ); } o(l.arg); } var a; r(this, "_invoke", { value: function (t, i) { function r() { return new e(function (e, r) { n(t, i, e, r); }); } return (a = a ? a.then(r, r) : r()); } }); } function k(e, n, i) { var r = p; return function (a, s) { if (r === m) throw Error("Generator is already running"); if (r === g) { if ("throw" === a) throw s; return { value: t, done: !0 }; } for (i.method = a, i.arg = s; ;) { var o = i.delegate; if (o) { var l = C(o, i); if (l) { if (l === y) continue; return l; } } if ("next" === i.method) i.sent = i._sent = i.arg; else if ("throw" === i.method) { if (r === p) throw ((r = g), i.arg); i.dispatchException(i.arg); } else "return" === i.method && i.abrupt("return", i.arg); r = m; var d = h(e, n, i); if ("normal" === d.type) { if (((r = i.done ? g : f), d.arg === y)) continue; return { value: d.arg, done: i.done }; } "throw" === d.type && ((r = g), (i.method = "throw"), (i.arg = d.arg)); } }; } function C(e, n) { var i = n.method, r = e.iterator[i]; if (r === t) return ( (n.delegate = null), ("throw" === i && e.iterator.return && ((n.method = "return"), (n.arg = t), C(e, n), "throw" === n.method)) || ("return" !== i && ((n.method = "throw"), (n.arg = new TypeError("The iterator does not provide a '" + i + "' method")))), y ); var a = h(r, e.iterator, n.arg); if ("throw" === a.type) return (n.method = "throw"), (n.arg = a.arg), (n.delegate = null), y; var s = a.arg; return s ? s.done ? ((n[e.resultName] = s.value), (n.next = e.nextLoc), "return" !== n.method && ((n.method = "next"), (n.arg = t)), (n.delegate = null), y) : s : ((n.method = "throw"), (n.arg = new TypeError("iterator result is not an object")), (n.delegate = null), y); } function L(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && ((e.finallyLoc = t[2]), (e.afterLoc = t[3])), this.tryEntries.push(e); } function I(t) { var e = t.completion || {}; (e.type = "normal"), delete e.arg, (t.completion = e); } function R(t) { (this.tryEntries = [{ tryLoc: "root" }]), t.forEach(L, this), this.reset(!0); } function D(e) { if (e || "" === e) { var n = e[s]; if (n) return n.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var r = -1, a = function n() { for (; ++r < e.length;) if (i.call(e, r)) return (n.value = e[r]), (n.done = !1), n; return (n.value = t), (n.done = !0), n; }; return (a.next = a); } } throw new TypeError(typeof e + " is not iterable"); } return ( (v.prototype = b), r(S, "constructor", { value: b, configurable: !0 }), r(b, "constructor", { value: v, configurable: !0 }), (v.displayName = c(b, l, "GeneratorFunction")), (e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === v || "GeneratorFunction" === (e.displayName || e.name)); }), (e.mark = function (t) { return ( Object.setPrototypeOf ? Object.setPrototypeOf(t, b) : ((t.__proto__ = b), c(t, l, "GeneratorFunction")), (t.prototype = Object.create(S)), t ); }), (e.awrap = function (t) { return { __await: t }; }), _(T.prototype), c(T.prototype, o, function () { return this; }), (e.AsyncIterator = T), (e.async = function (t, n, i, r, a) { void 0 === a && (a = Promise); var s = new T(u(t, n, i, r), a); return e.isGeneratorFunction(n) ? s : s.next().then(function (t) { return t.done ? t.value : s.next(); }); }), _(S), c(S, l, "Generator"), c(S, s, function () { return this; }), c(S, "toString", function () { return "[object Generator]"; }), (e.keys = function (t) { var e = Object(t), n = []; for (var i in e) n.push(i); return ( n.reverse(), function t() { for (; n.length;) { var i = n.pop(); if (i in e) return (t.value = i), (t.done = !1), t; } return (t.done = !0), t; } ); }), (e.values = D), (R.prototype = { constructor: R, reset: function (e) { if ( ((this.prev = 0), (this.next = 0), (this.sent = this._sent = t), (this.done = !1), (this.delegate = null), (this.method = "next"), (this.arg = t), this.tryEntries.forEach(I), !e) ) for (var n in this) "t" === n.charAt(0) && i.call(this, n) && !isNaN(+n.slice(1)) && (this[n] = t); }, stop: function () { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function (e) { if (this.done) throw e; var n = this; function r(i, r) { return (o.type = "throw"), (o.arg = e), (n.next = i), r && ((n.method = "next"), (n.arg = t)), !!r; } for (var a = this.tryEntries.length - 1; a >= 0; --a) { var s = this.tryEntries[a], o = s.completion; if ("root" === s.tryLoc) return r("end"); if (s.tryLoc <= this.prev) { var l = i.call(s, "catchLoc"), d = i.call(s, "finallyLoc"); if (l && d) { if (this.prev < s.catchLoc) return r(s.catchLoc, !0); if (this.prev < s.finallyLoc) return r(s.finallyLoc); } else if (l) { if (this.prev < s.catchLoc) return r(s.catchLoc, !0); } else { if (!d) throw Error("try statement without catch or finally"); if (this.prev < s.finallyLoc) return r(s.finallyLoc); } } } }, abrupt: function (t, e) { for (var n = this.tryEntries.length - 1; n >= 0; --n) { var r = this.tryEntries[n]; if (r.tryLoc <= this.prev && i.call(r, "finallyLoc") && this.prev < r.finallyLoc) { var a = r; break; } } a && ("break" === t || "continue" === t) && a.tryLoc <= e && e <= a.finallyLoc && (a = null); var s = a ? a.completion : {}; return ( (s.type = t), (s.arg = e), a ? ((this.method = "next"), (this.next = a.finallyLoc), y) : this.complete(s) ); }, complete: function (t, e) { if ("throw" === t.type) throw t.arg; return ( "break" === t.type || "continue" === t.type ? (this.next = t.arg) : "return" === t.type ? ((this.rval = this.arg = t.arg), (this.method = "return"), (this.next = "end")) : "normal" === t.type && e && (this.next = e), y ); }, finish: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n.finallyLoc === t) return this.complete(n.completion, n.afterLoc), I(n), y; } }, catch: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n.tryLoc === t) { var i = n.completion; if ("throw" === i.type) { var r = i.arg; I(n); } return r; } } throw Error("illegal catch attempt"); }, delegateYield: function (e, n, i) { return ( (this.delegate = { iterator: D(e), resultName: n, nextLoc: i }), "next" === this.method && (this.arg = t), y ); } }), e ); } function c(t) { var e = (function (t, e) { if ("object" != typeof t || !t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); })(t, "string"); return "symbol" == typeof e ? e : e + ""; } function u(t) { return ( (u = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t; }), u(t) ); } function h(t, e, n, i, r, a, s) { try { var o = t[a](s), l = o.value; } catch (t) { return void n(t); } o.done ? e(l) : Promise.resolve(l).then(i, r); } function p(t) { return function () { var e = this, n = arguments; return new Promise(function (i, r) { var a = t.apply(e, n); function s(t) { h(a, i, r, s, o, "next", t); } function o(t) { h(a, i, r, s, o, "throw", t); } s(void 0); }); }; } function f(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); } function m(t, e, n) { return ( e && (function (t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty(t, c(i.key), i); } })(t.prototype, e), Object.defineProperty(t, "prototype", { writable: !1 }), t ); } function g(t, e, n) { return ( (e = c(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : (t[e] = n), t ); } function y(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); (t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } })), Object.defineProperty(t, "prototype", { writable: !1 }), e && v(t, e); } function A(t) { return ( (A = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }), A(t) ); } function v(t, e) { return ( (v = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return (t.__proto__ = e), t; }), v(t, e) ); } function b(t, e) { return ( (function (t) { if (Array.isArray(t)) return t; })(t) || (function (t, e) { var n = null == t ? null : ("undefined" != typeof Symbol && t[Symbol.iterator]) || t["@@iterator"]; if (null != n) { var i, r, a, s, o = [], l = !0, d = !1; try { if (((a = (n = n.call(t)).next), 0 === e)); else for (; !(l = (i = a.call(n)).done) && (o.push(i.value), o.length !== e); l = !0); } catch (t) { (d = !0), (r = t); } finally { try { if (!l && null != n.return && ((s = n.return()), Object(s) !== s)) return; } finally { if (d) throw r; } } return o; } })(t, e) || w(t, e) || (function () { throw new TypeError( "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ); })() ); } function E(t) { return ( (function (t) { if (Array.isArray(t)) return x(t); })(t) || (function (t) { if (("undefined" != typeof Symbol && null != t[Symbol.iterator]) || null != t["@@iterator"]) return Array.from(t); })(t) || w(t) || (function () { throw new TypeError( "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ); })() ); } function w(t, e) { if (t) { if ("string" == typeof t) return x(t, e); var n = Object.prototype.toString.call(t).slice(8, -1); return ( "Object" === n && t.constructor && (n = t.constructor.name), "Map" === n || "Set" === n ? Array.from(t) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? x(t, e) : void 0 ); } } function x(t, e) { (null == e || e > t.length) && (e = t.length); for (var n = 0, i = new Array(e); n < e; n++) i[n] = t[n]; return i; } function S(t, e) { if (e.has(t)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } function _(t, e, n) { S(t, e), e.set(t, n); } var T = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}; function k(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } var C = { exports: {} }; !(function (t, e) { !(function (n, i) { var r = "function", a = "undefined", s = "object", o = "string", l = "major", d = "model", c = "name", h = "type", p = "vendor", f = "version", m = "architecture", g = "console", y = "mobile", A = "tablet", v = "smarttv", b = "wearable", E = "embedded", w = "Amazon", x = "Apple", S = "ASUS", _ = "BlackBerry", T = "Browser", k = "Chrome", C = "Firefox", L = "Google", I = "Huawei", R = "LG", D = "Microsoft", B = "Motorola", P = "Opera", U = "Samsung", F = "Sharp", O = "Sony", M = "Xiaomi", N = "Zebra", z = "Facebook", G = "Chromium OS", j = "Mac OS", H = function (t) { for (var e = {}, n = 0; n < t.length; n++) e[t[n].toUpperCase()] = t[n]; return e; }, Y = function (t, e) { return u(t) === o && -1 !== $(e).indexOf($(t)); }, $ = function (t) { return t.toLowerCase(); }, K = function (t, e) { if (u(t) === o) return (t = t.replace(/^\s\s*/, "")), u(e) === a ? t : t.substring(0, 500); }, q = function (t, e) { for (var n, a, o, l, d, c, h = 0; h < e.length && !d;) { var p = e[h], f = e[h + 1]; for (n = a = 0; n < p.length && !d && p[n];) if ((d = p[n++].exec(t))) for (o = 0; o < f.length; o++) (c = d[++a]), u((l = f[o])) === s && l.length > 0 ? 2 === l.length ? u(l[1]) == r ? (this[l[0]] = l[1].call(this, c)) : (this[l[0]] = l[1]) : 3 === l.length ? u(l[1]) !== r || (l[1].exec && l[1].test) ? (this[l[0]] = c ? c.replace(l[1], l[2]) : i) : (this[l[0]] = c ? l[1].call(this, c, l[2]) : i) : 4 === l.length && (this[l[0]] = c ? l[3].call(this, c.replace(l[1], l[2])) : i) : (this[l] = c || i); h += 2; } }, V = function (t, e) { for (var n in e) if (u(e[n]) === s && e[n].length > 0) { for (var r = 0; r < e[n].length; r++) if (Y(e[n][r], t)) return "?" === n ? i : n; } else if (Y(e[n], t)) return "?" === n ? i : n; return t; }, W = { ME: "4.90", "NT 3.11": "NT3.51", "NT 4.0": "NT4.0", 2e3: "NT 5.0", XP: ["NT 5.1", "NT 5.2"], Vista: "NT 6.0", 7: "NT 6.1", 8: "NT 6.2", 8.1: "NT 6.3", 10: ["NT 6.4", "NT 10.0"], RT: "ARM" }, Q = { browser: [ [/\b(?:crmo|crios)\/([\w\.]+)/i], [f, [c, "Chrome"]], [/edg(?:e|ios|a)?\/([\w\.]+)/i], [f, [c, "Edge"]], [ /(opera mini)\/([-\w\.]+)/i, /(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i, /(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i ], [c, f], [/opios[\/ ]+([\w\.]+)/i], [f, [c, P + " Mini"]], [/\bopr\/([\w\.]+)/i], [f, [c, P]], [/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i], [f, [c, "Baidu"]], [ /(kindle)\/([\w\.]+)/i, /(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i, /(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i, /(?:ms|\()(ie) ([\w\.]+)/i, /(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i, /(heytap|ovi)browser\/([\d\.]+)/i, /(weibo)__([\d\.]+)/i ], [c, f], [/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i], [f, [c, "UC" + T]], [/microm.+\bqbcore\/([\w\.]+)/i, /\bqbcore\/([\w\.]+).+microm/i, /micromessenger\/([\w\.]+)/i], [f, [c, "WeChat"]], [/konqueror\/([\w\.]+)/i], [f, [c, "Konqueror"]], [/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i], [f, [c, "IE"]], [/ya(?:search)?browser\/([\w\.]+)/i], [f, [c, "Yandex"]], [/slbrowser\/([\w\.]+)/i], [f, [c, "Smart Lenovo " + T]], [/(avast|avg)\/([\w\.]+)/i], [[c, /(.+)/, "$1 Secure " + T], f], [/\bfocus\/([\w\.]+)/i], [f, [c, C + " Focus"]], [/\bopt\/([\w\.]+)/i], [f, [c, P + " Touch"]], [/coc_coc\w+\/([\w\.]+)/i], [f, [c, "Coc Coc"]], [/dolfin\/([\w\.]+)/i], [f, [c, "Dolphin"]], [/coast\/([\w\.]+)/i], [f, [c, P + " Coast"]], [/miuibrowser\/([\w\.]+)/i], [f, [c, "MIUI " + T]], [/fxios\/([-\w\.]+)/i], [f, [c, C]], [/\bqihu|(qi?ho?o?|360)browser/i], [[c, "360 " + T]], [/(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i], [[c, /(.+)/, "$1 " + T], f], [/samsungbrowser\/([\w\.]+)/i], [f, [c, U + " Internet"]], [/(comodo_dragon)\/([\w\.]+)/i], [[c, /_/g, " "], f], [/metasr[\/ ]?([\d\.]+)/i], [f, [c, "Sogou Explorer"]], [/(sogou)mo\w+\/([\d\.]+)/i], [[c, "Sogou Mobile"], f], [ /(electron)\/([\w\.]+) safari/i, /(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, /m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i ], [c, f], [/(lbbrowser)/i, /\[(linkedin)app\]/i], [c], [/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i], [[c, z], f], [ /(Klarna)\/([\w\.]+)/i, /(kakao(?:talk|story))[\/ ]([\w\.]+)/i, /(naver)\(.*?(\d+\.[\w\.]+).*\)/i, /safari (line)\/([\w\.]+)/i, /\b(line)\/([\w\.]+)\/iab/i, /(alipay)client\/([\w\.]+)/i, /(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i ], [c, f], [/\bgsa\/([\w\.]+) .*safari\//i], [f, [c, "GSA"]], [/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i], [f, [c, "TikTok"]], [/headlesschrome(?:\/([\w\.]+)| )/i], [f, [c, k + " Headless"]], [/ wv\).+(chrome)\/([\w\.]+)/i], [[c, k + " WebView"], f], [/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i], [f, [c, "Android " + T]], [/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i], [c, f], [/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i], [f, [c, "Mobile Safari"]], [/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i], [f, c], [/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i], [ c, [ f, V, { "1.0": "/8", 1.2: "/1", 1.3: "/3", "2.0": "/412", "2.0.2": "/416", "2.0.3": "/417", "2.0.4": "/419", "?": "/" } ] ], [/(webkit|khtml)\/([\w\.]+)/i], [c, f], [/(navigator|netscape\d?)\/([-\w\.]+)/i], [[c, "Netscape"], f], [/mobile vr; rv:([\w\.]+)\).+firefox/i], [f, [c, C + " Reality"]], [ /ekiohf.+(flow)\/([\w\.]+)/i, /(swiftfox)/i, /(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i, /(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i, /(firefox)\/([\w\.]+)/i, /(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i, /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i, /(links) \(([\w\.]+)/i, /panasonic;(viera)/i ], [c, f], [/(cobalt)\/([\w\.]+)/i], [c, [f, /master.|lts./, ""]] ], cpu: [ [/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i], [[m, "amd64"]], [/(ia32(?=;))/i], [[m, $]], [/((?:i[346]|x)86)[;\)]/i], [[m, "ia32"]], [/\b(aarch64|arm(v?8e?l?|_?64))\b/i], [[m, "arm64"]], [/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i], [[m, "armhf"]], [/windows (ce|mobile); ppc;/i], [[m, "arm"]], [/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i], [[m, /ower/, "", $]], [/(sun4\w)[;\)]/i], [[m, "sparc"]], [ /((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i ], [[m, $]] ], device: [ [/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i], [d, [p, U], [h, A]], [/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i, /samsung[- ]([-\w]+)/i, /sec-(sgh\w+)/i], [d, [p, U], [h, y]], [/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i], [d, [p, x], [h, y]], [/\((ipad);[-\w\),; ]+apple/i, /applecoremedia\/[\w\.]+ \((ipad)/i, /\b(ipad)\d\d?,\d\d?[;\]].+ios/i], [d, [p, x], [h, A]], [/(macintosh);/i], [d, [p, x]], [/\b(sh-?[altvz]?\d\d[a-ekm]?)/i], [d, [p, F], [h, y]], [/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i], [d, [p, I], [h, A]], [/(?:huawei|honor)([-\w ]+)[;\)]/i, /\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i], [d, [p, I], [h, y]], [ /\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i, /\b; (\w+) build\/hm\1/i, /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i, /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i, /oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i, /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i ], [ [d, /_/g, " "], [p, M], [h, y] ], [/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i, /\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i], [ [d, /_/g, " "], [p, M], [h, A] ], [/; (\w+) bui.+ oppo/i, /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i], [d, [p, "OPPO"], [h, y]], [/vivo (\w+)(?: bui|\))/i, /\b(v[12]\d{3}\w?[at])(?: bui|;)/i], [d, [p, "Vivo"], [h, y]], [/\b(rmx[1-3]\d{3})(?: bui|;|\))/i], [d, [p, "Realme"], [h, y]], [ /\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i, /\bmot(?:orola)?[- ](\w*)/i, /((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i ], [d, [p, B], [h, y]], [/\b(mz60\d|xoom[2 ]{0,2}) build\//i], [d, [p, B], [h, A]], [/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i], [d, [p, R], [h, A]], [ /(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i, /\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i, /\blg-?([\d\w]+) bui/i ], [d, [p, R], [h, y]], [/(ideatab[-\w ]+)/i, /lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i], [d, [p, "Lenovo"], [h, A]], [/(?:maemo|nokia).*(n900|lumia \d+)/i, /nokia[-_ ]?([-\w\.]*)/i], [ [d, /_/g, " "], [p, "Nokia"], [h, y] ], [/(pixel c)\b/i], [d, [p, L], [h, A]], [/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i], [d, [p, L], [h, y]], [ /droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i ], [d, [p, O], [h, y]], [/sony tablet [ps]/i, /\b(?:sony)?sgp\w+(?: bui|\))/i], [ [d, "Xperia Tablet"], [p, O], [h, A] ], [/ (kb2005|in20[12]5|be20[12][59])\b/i, /(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i], [d, [p, "OnePlus"], [h, y]], [/(alexa)webm/i, /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i, /(kf[a-z]+)( bui|\)).+silk\//i], [d, [p, w], [h, A]], [/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i], [ [d, /(.+)/g, "Fire Phone $1"], [p, w], [h, y] ], [/(playbook);[-\w\),; ]+(rim)/i], [d, p, [h, A]], [/\b((?:bb[a-f]|st[hv])100-\d)/i, /\(bb10; (\w+)/i], [d, [p, _], [h, y]], [/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i], [d, [p, S], [h, A]], [/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i], [d, [p, S], [h, y]], [/(nexus 9)/i], [d, [p, "HTC"], [h, A]], [ /(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i, /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i, /(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i ], [p, [d, /_/g, " "], [h, y]], [/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i], [d, [p, "Acer"], [h, A]], [/droid.+; (m[1-5] note) bui/i, /\bmz-([-\w]{2,})/i], [d, [p, "Meizu"], [h, y]], [/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i], [d, [p, "Ulefone"], [h, y]], [ /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i, /(hp) ([\w ]+\w)/i, /(asus)-?(\w+)/i, /(microsoft); (lumia[\w ]+)/i, /(lenovo)[-_ ]?([-\w]+)/i, /(jolla)/i, /(oppo) ?([\w ]+) bui/i ], [p, d, [h, y]], [ /(kobo)\s(ereader|touch)/i, /(archos) (gamepad2?)/i, /(hp).+(touchpad(?!.+tablet)|tablet)/i, /(kindle)\/([\w\.]+)/i, /(nook)[\w ]+build\/(\w+)/i, /(dell) (strea[kpr\d ]*[\dko])/i, /(le[- ]+pan)[- ]+(\w{1,9}) bui/i, /(trinity)[- ]*(t\d{3}) bui/i, /(gigaset)[- ]+(q\w{1,9}) bui/i, /(vodafone) ([\w ]+)(?:\)| bui)/i ], [p, d, [h, A]], [/(surface duo)/i], [d, [p, D], [h, A]], [/droid [\d\.]+; (fp\du?)(?: b|\))/i], [d, [p, "Fairphone"], [h, y]], [/(u304aa)/i], [d, [p, "AT&T"], [h, y]], [/\bsie-(\w*)/i], [d, [p, "Siemens"], [h, y]], [/\b(rct\w+) b/i], [d, [p, "RCA"], [h, A]], [/\b(venue[\d ]{2,7}) b/i], [d, [p, "Dell"], [h, A]], [/\b(q(?:mv|ta)\w+) b/i], [d, [p, "Verizon"], [h, A]], [/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i], [d, [p, "Barnes & Noble"], [h, A]], [/\b(tm\d{3}\w+) b/i], [d, [p, "NuVision"], [h, A]], [/\b(k88) b/i], [d, [p, "ZTE"], [h, A]], [/\b(nx\d{3}j) b/i], [d, [p, "ZTE"], [h, y]], [/\b(gen\d{3}) b.+49h/i], [d, [p, "Swiss"], [h, y]], [/\b(zur\d{3}) b/i], [d, [p, "Swiss"], [h, A]], [/\b((zeki)?tb.*\b) b/i], [d, [p, "Zeki"], [h, A]], [/\b([yr]\d{2}) b/i, /\b(dragon[- ]+touch |dt)(\w{5}) b/i], [[p, "Dragon Touch"], d, [h, A]], [/\b(ns-?\w{0,9}) b/i], [d, [p, "Insignia"], [h, A]], [/\b((nxa|next)-?\w{0,9}) b/i], [d, [p, "NextBook"], [h, A]], [/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i], [[p, "Voice"], d, [h, y]], [/\b(lvtel\-)?(v1[12]) b/i], [[p, "LvTel"], d, [h, y]], [/\b(ph-1) /i], [d, [p, "Essential"], [h, y]], [/\b(v(100md|700na|7011|917g).*\b) b/i], [d, [p, "Envizen"], [h, A]], [/\b(trio[-\w\. ]+) b/i], [d, [p, "MachSpeed"], [h, A]], [/\btu_(1491) b/i], [d, [p, "Rotor"], [h, A]], [/(shield[\w ]+) b/i], [d, [p, "Nvidia"], [h, A]], [/(sprint) (\w+)/i], [p, d, [h, y]], [/(kin\.[onetw]{3})/i], [ [d, /\./g, " "], [p, D], [h, y] ], [/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i], [d, [p, N], [h, A]], [/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i], [d, [p, N], [h, y]], [/smart-tv.+(samsung)/i], [p, [h, v]], [/hbbtv.+maple;(\d+)/i], [ [d, /^/, "SmartTV"], [p, U], [h, v] ], [/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i], [ [p, R], [h, v] ], [/(apple) ?tv/i], [p, [d, x + " TV"], [h, v]], [/crkey/i], [ [d, k + "cast"], [p, L], [h, v] ], [/droid.+aft(\w+)( bui|\))/i], [d, [p, w], [h, v]], [/\(dtv[\);].+(aquos)/i, /(aquos-tv[\w ]+)\)/i], [d, [p, F], [h, v]], [/(bravia[\w ]+)( bui|\))/i], [d, [p, O], [h, v]], [/(mitv-\w{5}) bui/i], [d, [p, M], [h, v]], [/Hbbtv.*(technisat) (.*);/i], [p, d, [h, v]], [/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, /hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i], [ [p, K], [d, K], [h, v] ], [/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i], [[h, v]], [/(ouya)/i, /(nintendo) ([wids3utch]+)/i], [p, d, [h, g]], [/droid.+; (shield) bui/i], [d, [p, "Nvidia"], [h, g]], [/(playstation [345portablevi]+)/i], [d, [p, O], [h, g]], [/\b(xbox(?: one)?(?!; xbox))[\); ]/i], [d, [p, D], [h, g]], [/((pebble))app/i], [p, d, [h, b]], [/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i], [d, [p, x], [h, b]], [/droid.+; (glass) \d/i], [d, [p, L], [h, b]], [/droid.+; (wt63?0{2,3})\)/i], [d, [p, N], [h, b]], [/(quest( 2| pro)?)/i], [d, [p, z], [h, b]], [/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i], [p, [h, E]], [/(aeobc)\b/i], [d, [p, w], [h, E]], [/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i], [d, [h, y]], [/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i], [d, [h, A]], [/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i], [[h, A]], [/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i], [[h, y]], [/(android[-\w\. ]{0,9});.+buil/i], [d, [p, "Generic"]] ], engine: [ [/windows.+ edge\/([\w\.]+)/i], [f, [c, "EdgeHTML"]], [/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i], [f, [c, "Blink"]], [ /(presto)\/([\w\.]+)/i, /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i, /ekioh(flow)\/([\w\.]+)/i, /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i, /(icab)[\/ ]([23]\.[\d\.]+)/i, /\b(libweb)/i ], [c, f], [/rv\:([\w\.]{1,9})\b.+(gecko)/i], [f, c] ], os: [ [/microsoft (windows) (vista|xp)/i], [c, f], [/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i], [c, [f, V, W]], [ /windows nt 6\.2; (arm)/i, /windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i, /(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i ], [ [f, V, W], [c, "Windows"] ], [ /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, /(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i, /cfnetwork\/.+darwin/i ], [ [f, /_/g, "."], [c, "iOS"] ], [/(mac os x) ?([\w\. ]*)/i, /(macintosh|mac_powerpc\b)(?!.+haiku)/i], [ [c, j], [f, /_/g, "."] ], [/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i], [f, c], [ /(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i, /(blackberry)\w*\/([\w\.]*)/i, /(tizen|kaios)[\/ ]([\w\.]+)/i, /\((series40);/i ], [c, f], [/\(bb(10);/i], [f, [c, _]], [/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i], [f, [c, "Symbian"]], [/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i], [f, [c, C + " OS"]], [/web0s;.+rt(tv)/i, /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i], [f, [c, "webOS"]], [/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i], [f, [c, "watchOS"]], [/crkey\/([\d\.]+)/i], [f, [c, k + "cast"]], [/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i], [[c, G], f], [ /panasonic;(viera)/i, /(netrange)mmh/i, /(nettv)\/(\d+\.[\w\.]+)/i, /(nintendo|playstation) ([wids345portablevuch]+)/i, /(xbox); +xbox ([^\);]+)/i, /\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, /(mint)[\/\(\) ]?(\w*)/i, /(mageia|vectorlinux)[; ]/i, /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i, /(hurd|linux) ?([\w\.]*)/i, /(gnu) ?([\w\.]*)/i, /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i, /(haiku) (\w+)/i ], [c, f], [/(sunos) ?([\w\.\d]*)/i], [[c, "Solaris"], f], [ /((?:open)?solaris)[-\/ ]?([\w\.]*)/i, /(aix) ((\d)(?=\.|\)| )[\w\.])*/i, /\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i, /(unix) ?([\w\.]*)/i ], [c, f] ] }, X = function t(e, g) { if ((u(e) === s && ((g = e), (e = i)), !(this instanceof t))) return new t(e, g).getResult(); var v = u(n) !== a && n.navigator ? n.navigator : i, b = e || (v && v.userAgent ? v.userAgent : ""), E = v && v.userAgentData ? v.userAgentData : i, w = g ? (function (t, e) { var n = {}; for (var i in t) e[i] && e[i].length % 2 == 0 ? (n[i] = e[i].concat(t[i])) : (n[i] = t[i]); return n; })(Q, g) : Q, x = v && v.userAgent == b; return ( (this.getBrowser = function () { var t, e = {}; return ( (e[c] = i), (e[f] = i), q.call(e, b, w.browser), (e[l] = u((t = e[f])) === o ? t.replace(/[^\d\.]/g, "").split(".")[0] : i), x && v && v.brave && u(v.brave.isBrave) == r && (e[c] = "Brave"), e ); }), (this.getCPU = function () { var t = {}; return (t[m] = i), q.call(t, b, w.cpu), t; }), (this.getDevice = function () { var t = {}; return ( (t[p] = i), (t[d] = i), (t[h] = i), q.call(t, b, w.device), x && !t[h] && E && E.mobile && (t[h] = y), x && "Macintosh" == t[d] && v && u(v.standalone) !== a && v.maxTouchPoints && v.maxTouchPoints > 2 && ((t[d] = "iPad"), (t[h] = A)), t ); }), (this.getEngine = function () { var t = {}; return (t[c] = i), (t[f] = i), q.call(t, b, w.engine), t; }), (this.getOS = function () { var t = {}; return ( (t[c] = i), (t[f] = i), q.call(t, b, w.os), x && !t[c] && E && "Unknown" != E.platform && (t[c] = E.platform.replace(/chrome os/i, G).replace(/macos/i, j)), t ); }), (this.getResult = function () { return { ua: this.getUA(), browser: this.getBrowser(), engine: this.getEngine(), os: this.getOS(), device: this.getDevice(), cpu: this.getCPU() }; }), (this.getUA = function () { return b; }), (this.setUA = function (t) { return (b = u(t) === o && t.length > 500 ? K(t, 500) : t), this; }), this.setUA(b), this ); }; (X.VERSION = "1.0.37"), (X.BROWSER = H([c, f, l])), (X.CPU = H([m])), (X.DEVICE = H([d, p, h, g, y, v, A, b, E])), (X.ENGINE = X.OS = H([c, f])), t.exports && (e = t.exports = X), (e.UAParser = X); var J = u(n) !== a && (n.jQuery || n.Zepto); if (J && !J.ua) { var Z = new X(); (J.ua = Z.getResult()), (J.ua.get = function () { return Z.getUA(); }), (J.ua.set = function (t) { Z.setUA(t); var e = Z.getResult(); for (var n in e) J.ua[n] = e[n]; }); } })("object" === ("undefined" == typeof window ? "undefined" : u(window)) ? window : T); })(C, C.exports); var L, I = new (k(C.exports))().getResult(), R = function () { return { hasVideoDecode: !!window.VideoDecoder, hasAudioContext: !!window.AudioContext, system: "" .concat(I.device.vendor, "->") .concat(I.device.model, "->") .concat(I.device.type, ":") .concat(I.os.name, "(") .concat(I.os.version, ")"), browser: "".concat(I.browser.name, "(").concat(I.browser.version, ")") }; }, D = I.browser.name.toLowerCase(); I.browser.version, I.os.name; var B = !(null === (L = I.device) || void 0 === L || !L.type), P = "Apple" === I.device.vendor && B, U = ["UCBrowser", "Quark", "Chrome WebView", "Vivo Browser"]; P && (U.push("baidu"), U.push("qqbrowser")); var F = B && ["UCBrowser", "Quark", "baidu", "qqbrowser", "Chrome WebView", "Vivo Browser"].some(function (t) { return D.includes(t.toLowerCase()); }), O = B && U.some(function (t) { return D.includes(t.toLowerCase()); }), M = "M3U8", N = "CANVAS", z = function () { return O && window.VideoDecoder && window.AudioContext ? N : M; }, G = { exports: {} }; !(function (t, e) { self, (t.exports = (function () { var t = { 916: function (t, e, n) { var i = n(471); t.exports = function (t) { var e, r = "", a = (t = t || {}).video, s = t.options, o = i.$escape, l = t.tran, d = t.icons, c = t.index, u = i.$each; return ( t.$value, t.$index, (r += '
\n".concat(t, "
"); }) .join(""); t.container.innerHTML = r; } t.events.trigger("subtitle_change"); }; } } }, { key: "show", value: function () { this.container.classList.remove("dplayer-subtitle-hide"), this.events.trigger("subtitle_show"); } }, { key: "hide", value: function () { this.container.classList.add("dplayer-subtitle-hide"), this.events.trigger("subtitle_hide"); } }, { key: "toggle", value: function () { this.container.classList.contains("dplayer-subtitle-hide") ? this.show() : this.hide(); } } ]), n && Yn(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Kn = $n; function qn(t) { return ( (qn = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), qn(t) ); } function Vn(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== qn(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== qn(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === qn(r) ? r : String(r)), i ); } var r; } var Wn = (function () { function t(e) { var n = this; !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.player = e), this.player.template.mask.addEventListener("click", function () { n.hide(); }), this.player.template.subtitlesButton.addEventListener("click", function () { n.adaptiveHeight(), n.show(); }); for ( var i = this.player.template.subtitlesItem.length - 1, r = function (t) { n.player.template.subtitlesItem[t].addEventListener("click", function () { n.hide(), n.player.options.subtitle.index !== t && ((n.player.template.subtitle.innerHTML = ""), (n.player.template.subtrack.src = n.player.template.subtitlesItem[t].dataset.subtitle), (n.player.options.subtitle.index = t), n.player.template.subtitle.classList.contains( "dplayer-subtitle-hide" ) && n.subContainerShow()); }); }, a = 0; a < i; a++ ) r(a); this.player.template.subtitlesItem[i].addEventListener("click", function () { n.hide(), n.player.options.subtitle.index !== i && ((n.player.template.subtitle.innerHTML = ""), (n.player.template.subtrack.src = ""), (n.player.options.subtitle.index = i), n.subContainerHide()); }); } var e, n; return ( (e = t), (n = [ { key: "subContainerShow", value: function () { this.player.template.subtitle.classList.remove("dplayer-subtitle-hide"), this.player.events.trigger("subtitle_show"); } }, { key: "subContainerHide", value: function () { this.player.template.subtitle.classList.add("dplayer-subtitle-hide"), this.player.events.trigger("subtitle_hide"); } }, { key: "hide", value: function () { this.player.template.subtitlesBox.classList.remove("dplayer-subtitles-box-open"), this.player.template.mask.classList.remove("dplayer-mask-show"), (this.player.controller.disableAutoHide = !1); } }, { key: "show", value: function () { this.player.template.subtitlesBox.classList.add("dplayer-subtitles-box-open"), this.player.template.mask.classList.add("dplayer-mask-show"), (this.player.controller.disableAutoHide = !0); } }, { key: "adaptiveHeight", value: function () { var t = 30 * this.player.template.subtitlesItem.length + 14, e = 0.8 * this.player.template.videoWrap.offsetHeight; t >= e - 50 ? ((this.player.template.subtitlesBox.style.bottom = "8px"), (this.player.template.subtitlesBox.style["max-height"] = e - 8 + "px")) : ((this.player.template.subtitlesBox.style.bottom = "50px"), (this.player.template.subtitlesBox.style["max-height"] = e - 50 + "px")); } } ]) && Vn(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Qn = Wn; function Xn(t) { return ( (Xn = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), Xn(t) ); } function Jn(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== Xn(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== Xn(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === Xn(r) ? r : String(r)), i ); } var r; } var Zn = (function () { function t(e) { !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.elements = {}), (this.elements.volume = e.volumeBar), (this.elements.played = e.playedBar), (this.elements.loaded = e.loadedBar), (this.elements.danmaku = e.danmakuOpacityBar); } var e, n; return ( (e = t), (n = [ { key: "set", value: function (t, e, n) { (e = Math.max(e, 0)), (e = Math.min(e, 1)), (this.elements[t].style[n] = 100 * e + "%"); } }, { key: "get", value: function (t) { return parseFloat(this.elements[t].style.width) / 100; } } ]) && Jn(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), ti = Zn; function ei(t) { return ( (ei = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), ei(t) ); } function ni(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== ei(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== ei(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === ei(r) ? r : String(r)), i ); } var r; } var ii = (function () { function t(e) { !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.player = e), (window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (t) { window.setTimeout(t, 1e3 / 60); }), (this.types = ["loading", "info", "fps"]), this.init(); } var e, n; return ( (e = t), (n = [ { key: "init", value: function () { var t = this; this.types.map(function (e) { return "fps" !== e && t["init".concat(e, "Checker")](), e; }); } }, { key: "initloadingChecker", value: function () { var t = this, e = 0, n = 0, i = !1; this.loadingChecker = setInterval(function () { t.enableloadingChecker && ((n = t.player.video.currentTime), i || n !== e || t.player.video.paused || (t.player.container.classList.add("dplayer-loading"), (i = !0)), i && n > e && !t.player.video.paused && (t.player.container.classList.remove("dplayer-loading"), (i = !1)), (e = n)); }, 100); } }, { key: "initfpsChecker", value: function () { var t = this; window.requestAnimationFrame(function () { if (t.enablefpsChecker) if ((t.initfpsChecker(), t.fpsStart)) { t.fpsIndex++; var e = new Date(); e - t.fpsStart > 1e3 && (t.player.infoPanel.fps((t.fpsIndex / (e - t.fpsStart)) * 1e3), (t.fpsStart = new Date()), (t.fpsIndex = 0)); } else (t.fpsStart = new Date()), (t.fpsIndex = 0); else (t.fpsStart = 0), (t.fpsIndex = 0); }); } }, { key: "initinfoChecker", value: function () { var t = this; this.infoChecker = setInterval(function () { t.enableinfoChecker && t.player.infoPanel.update(); }, 1e3); } }, { key: "enable", value: function (t) { (this["enable".concat(t, "Checker")] = !0), "fps" === t && this.initfpsChecker(); } }, { key: "disable", value: function (t) { this["enable".concat(t, "Checker")] = !1; } }, { key: "destroy", value: function () { var t = this; this.types.map(function (e) { return ( (t["enable".concat(e, "Checker")] = !1), t["".concat(e, "Checker")] && clearInterval(t["".concat(e, "Checker")]), e ); }); } } ]) && ni(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), ri = ii; function ai(t) { return ( (ai = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), ai(t) ); } function si(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== ai(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== ai(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === ai(r) ? r : String(r)), i ); } var r; } var oi = (function () { function t(e) { var n = this; !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.container = e), this.container.addEventListener("animationend", function () { n.container.classList.remove("dplayer-bezel-transition"); }); } var e, n; return ( (e = t), (n = [ { key: "switch", value: function (t) { (this.container.innerHTML = t), this.container.classList.add("dplayer-bezel-transition"); } } ]) && si(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(); function li(t) { return ( (li = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), li(t) ); } function di(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== li(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== li(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === li(r) ? r : String(r)), i ); } var r; } var ci = (function () { function t(e) { !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.container = e.container), (this.barWidth = e.barWidth), (this.container.style.backgroundImage = "url('".concat(e.url, "')")), (this.events = e.events); } var e, n; return ( (e = t), (n = [ { key: "resize", value: function (t, e, n) { (this.container.style.width = "".concat(t, "px")), (this.container.style.height = "".concat(e, "px")), (this.container.style.top = "".concat(2 - e, "px")), (this.barWidth = n); } }, { key: "show", value: function () { (this.container.style.display = "block"), this.events && this.events.trigger("thumbnails_show"); } }, { key: "move", value: function (t) { (this.container.style.backgroundPosition = "-".concat( 160 * (Math.ceil((t / this.barWidth) * 100) - 1), "px 0" )), (this.container.style.left = "".concat( Math.min( Math.max(t - this.container.offsetWidth / 2, -10), this.barWidth - 150 ), "px" )); } }, { key: "hide", value: function () { (this.container.style.display = "none"), this.events && this.events.trigger("thumbnails_hide"); } } ]) && di(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), ui = ci; function hi(t) { return ( (hi = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), hi(t) ); } function pi(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== hi(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== hi(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === hi(r) ? r : String(r)), i ); } var r; } var fi, mi = !0, gi = !1, yi = (function () { function t(e) { !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.player = e), (this.autoHideTimer = 0), B.isMobile || ((this.setAutoHideHandler = this.setAutoHide.bind(this)), this.player.container.addEventListener("mousemove", this.setAutoHideHandler), this.player.container.addEventListener("click", this.setAutoHideHandler), this.player.on("play", this.setAutoHideHandler), this.player.on("pause", this.setAutoHideHandler)), this.initPlayButton(), this.initThumbnails(), this.initPlayedBar(), this.initFullButton(), this.initQualityButton(), this.initScreenshotButton(), this.player.options.subtitle && "string" == typeof this.player.options.subtitle.url && this.initSubtitleButton(), this.initHighlights(), this.initAirplayButton(), this.initChromecastButton(), B.isMobile || this.initVolumeButton(); } var e, n; return ( (e = t), (n = [ { key: "initPlayButton", value: function () { var t = this; this.player.template.playButton.addEventListener("click", function () { t.player.toggle(); }), this.player.template.mobilePlayButton.addEventListener("click", function () { t.player.toggle(); }), B.isMobile ? (this.player.template.videoWrap.addEventListener("click", function () { t.toggle(); }), this.player.template.controllerMask.addEventListener( "click", function () { t.toggle(); } )) : this.player.options.preventClickToggle || (this.player.template.videoWrap.addEventListener("click", function () { t.player.toggle(); }), this.player.template.controllerMask.addEventListener( "click", function () { t.player.toggle(); } )); } }, { key: "initHighlights", value: function () { var t = this; this.player.on("durationchange", function () { if ( 1 !== t.player.video.duration && t.player.video.duration !== 1 / 0 && t.player.options.highlight ) { var e = t.player.template.playedBarWrap.querySelectorAll( ".dplayer-highlight" ); [].slice.call(e, 0).forEach(function (e) { t.player.template.playedBarWrap.removeChild(e); }); for (var n = 0; n < t.player.options.highlight.length; n++) if ( t.player.options.highlight[n].text && t.player.options.highlight[n].time ) { var i = document.createElement("div"); i.classList.add("dplayer-highlight"), (i.style.left = (t.player.options.highlight[n].time / t.player.video.duration) * 100 + "%"), (i.innerHTML = '' + t.player.options.highlight[n].text + ""), t.player.template.playedBarWrap.insertBefore( i, t.player.template.playedBarTime ); } } }); } }, { key: "initThumbnails", value: function () { var t = this; this.player.options.video.thumbnails && ((this.thumbnails = new ui({ container: this.player.template.barPreview, barWidth: this.player.template.barWrap.offsetWidth, url: this.player.options.video.thumbnails, events: this.player.events })), this.player.on("loadedmetadata", function () { t.thumbnails.resize( 160, (t.player.video.videoHeight / t.player.video.videoWidth) * 160, t.player.template.barWrap.offsetWidth ); })); } }, { key: "initPlayedBar", value: function () { var t = this, e = function (e) { var n = ((e.clientX || e.changedTouches[0].clientX) - B.getBoundingClientRectViewLeft( t.player.template.playedBarWrap )) / t.player.template.playedBarWrap.clientWidth; (n = Math.max(n, 0)), (n = Math.min(n, 1)), t.player.bar.set("played", n, "width"), (t.player.template.ptime.innerHTML = B.secondToTime( n * t.player.video.duration )); }, n = function n(i) { document.removeEventListener(B.nameMap.dragEnd, n), document.removeEventListener(B.nameMap.dragMove, e); var r = ((i.clientX || i.changedTouches[0].clientX) - B.getBoundingClientRectViewLeft( t.player.template.playedBarWrap )) / t.player.template.playedBarWrap.clientWidth; (r = Math.max(r, 0)), (r = Math.min(r, 1)), t.player.bar.set("played", r, "width"), t.player.seek(t.player.bar.get("played") * t.player.video.duration), t.player.timer.enable("progress"); }; this.player.template.playedBarWrap.addEventListener( B.nameMap.dragStart, function () { t.player.timer.disable("progress"), document.addEventListener(B.nameMap.dragMove, e), document.addEventListener(B.nameMap.dragEnd, n); } ), this.player.template.playedBarWrap.addEventListener( B.nameMap.dragMove, function (e) { if (t.player.video.duration) { var n = t.player.template.playedBarWrap.getBoundingClientRect() .left, i = (e.clientX || e.changedTouches[0].clientX) - n; if (i < 0 || i > t.player.template.playedBarWrap.offsetWidth) return; var r = t.player.video.duration * (i / t.player.template.playedBarWrap.offsetWidth); B.isMobile && t.thumbnails && t.thumbnails.show(), t.thumbnails && t.thumbnails.move(i), (t.player.template.playedBarTime.style.left = "".concat( i - (r >= 3600 ? 25 : 20), "px" )), (t.player.template.playedBarTime.innerText = B.secondToTime(r)), t.player.template.playedBarTime.classList.remove("hidden"); } } ), this.player.template.playedBarWrap.addEventListener( B.nameMap.dragEnd, function () { B.isMobile && t.thumbnails && t.thumbnails.hide(); } ), B.isMobile || (this.player.template.playedBarWrap.addEventListener( "mouseenter", function () { t.player.video.duration && (t.thumbnails && t.thumbnails.show(), t.player.template.playedBarTime.classList.remove("hidden")); } ), this.player.template.playedBarWrap.addEventListener( "mouseleave", function () { t.player.video.duration && (t.thumbnails && t.thumbnails.hide(), t.player.template.playedBarTime.classList.add("hidden")); } )); } }, { key: "initFullButton", value: function () { var t = this; this.player.template.browserFullButton.addEventListener("click", function () { t.player.fullScreen.toggle("browser"); }), this.player.template.webFullButton.addEventListener("click", function () { t.player.fullScreen.toggle("web"); }); } }, { key: "initVolumeButton", value: function () { var t = this, e = function (e) { var n = e || window.event, i = ((n.clientX || n.changedTouches[0].clientX) - B.getBoundingClientRectViewLeft( t.player.template.volumeBarWrap ) - 5.5) / 35; t.player.volume(i); }, n = function n() { document.removeEventListener(B.nameMap.dragEnd, n), document.removeEventListener(B.nameMap.dragMove, e), t.player.template.volumeButton.classList.remove( "dplayer-volume-active" ); }; this.player.template.volumeBarWrapWrap.addEventListener("click", function (e) { var n = e || window.event, i = ((n.clientX || n.changedTouches[0].clientX) - B.getBoundingClientRectViewLeft(t.player.template.volumeBarWrap) - 5.5) / 35; t.player.volume(i); }), this.player.template.volumeBarWrapWrap.addEventListener( B.nameMap.dragStart, function () { document.addEventListener(B.nameMap.dragMove, e), document.addEventListener(B.nameMap.dragEnd, n), t.player.template.volumeButton.classList.add( "dplayer-volume-active" ); } ), this.player.template.volumeButtonIcon.addEventListener("click", function () { t.player.video.muted ? ((t.player.video.muted = !1), t.player.switchVolumeIcon(), t.player.bar.set("volume", t.player.volume(), "width")) : ((t.player.video.muted = !0), (t.player.template.volumeIcon.innerHTML = En.volumeOff), t.player.bar.set("volume", 0, "width")); }); } }, { key: "initQualityButton", value: function () { var t = this; this.player.options.video.quality && this.player.template.qualityList.addEventListener("click", function (e) { e.target.classList.contains("dplayer-quality-item") && t.player.switchQuality(e.target.dataset.index); }); } }, { key: "initScreenshotButton", value: function () { var t = this; this.player.options.screenshot && this.player.template.camareButton.addEventListener("click", function () { var e, n = document.createElement("canvas"); (n.width = t.player.video.videoWidth), (n.height = t.player.video.videoHeight), n.getContext("2d").drawImage(t.player.video, 0, 0, n.width, n.height), n.toBlob(function (n) { e = URL.createObjectURL(n); var i = document.createElement("a"); (i.href = e), (i.download = "DPlayer.png"), (i.style.display = "none"), document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(e), t.player.events.trigger("screenshot", e); }); }); } }, { key: "initAirplayButton", value: function () { this.player.options.airplay && (window.WebKitPlaybackTargetAvailabilityEvent ? this.player.video.addEventListener( "webkitplaybacktargetavailabilitychanged", function (t) { "available" === t.availability ? (this.template.airplayButton.disable = !1) : (this.template.airplayButton.disable = !0), this.template.airplayButton.addEventListener( "click", function () { this.video.webkitShowPlaybackTargetPicker(); }.bind(this) ); }.bind(this.player) ) : (this.player.template.airplayButton.style.display = "none")); } }, { key: "initChromecast", value: function () { var t = window.document.createElement("script"); t.setAttribute("type", "text/javascript"), t.setAttribute( "src", "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1" ), window.document.body.appendChild(t), (window.__onGCastApiAvailable = function (t) { if (t) { var e = new (fi = window.chrome.cast).SessionRequest( fi.media.DEFAULT_MEDIA_RECEIVER_APP_ID ), n = new fi.ApiConfig( e, function () { }, function (t) { t === fi.ReceiverAvailability.AVAILABLE && console.log("chromecast: ", t); } ); fi.initialize(n, function () { }); } }); } }, { key: "initChromecastButton", value: function () { var t = this; if (this.player.options.chromecast) { mi && ((mi = !1), this.initChromecast()); var e = function (e, n) { t.currentMedia = n; }, n = function (t) { console.error("Error launching media", t); }; this.player.template.chromecastButton.addEventListener("click", function () { gi ? ((gi = !1), t.currentMedia.stop(), t.session.stop(), t.initChromecast()) : ((gi = !0), fi.requestSession( function (i) { var r, a, s; (t.session = i), (r = t.player.options.video.url), (a = new fi.media.MediaInfo(r)), (s = new fi.media.LoadRequest(a)), t.session ? t.session .loadMedia(s, e.bind(t, "loadMedia"), n) .play() : window.open(r); }, function (e) { "cancel" === e.code ? (t.session = void 0) : console.error("Error selecting a cast device", e); } )); }); } } }, { key: "initSubtitleButton", value: function () { var t = this; this.player.events.on("subtitle_show", function () { (t.player.template.subtitleButton.dataset.balloon = t.player.tran("hide-subs")), (t.player.template.subtitleButtonInner.style.opacity = ""), t.player.user.set("subtitle", 1); }), this.player.events.on("subtitle_hide", function () { (t.player.template.subtitleButton.dataset.balloon = t.player.tran("show-subs")), (t.player.template.subtitleButtonInner.style.opacity = "0.4"), t.player.user.set("subtitle", 0); }), this.player.template.subtitleButton.addEventListener("click", function () { t.player.subtitle.toggle(); }); } }, { key: "setAutoHide", value: function () { var t = this; this.show(), clearTimeout(this.autoHideTimer), (this.autoHideTimer = setTimeout(function () { !t.player.video.played.length || t.player.paused || t.disableAutoHide || t.hide(); }, 3e3)); } }, { key: "show", value: function () { this.player.container.classList.remove("dplayer-hide-controller"); } }, { key: "hide", value: function () { this.player.container.classList.add("dplayer-hide-controller"), this.player.setting.hide(), this.player.comment && this.player.comment.hide(); } }, { key: "isShow", value: function () { return !this.player.container.classList.contains("dplayer-hide-controller"); } }, { key: "toggle", value: function () { this.isShow() ? this.hide() : this.show(); } }, { key: "destroy", value: function () { B.isMobile || (this.player.container.removeEventListener( "mousemove", this.setAutoHideHandler ), this.player.container.removeEventListener("click", this.setAutoHideHandler)), clearTimeout(this.autoHideTimer); } } ]) && pi(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Ai = yi; function vi(t) { return ( (vi = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), vi(t) ); } function bi(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== vi(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== vi(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === vi(r) ? r : String(r)), i ); } var r; } var Ei = (function () { function t(e) { var n = this; !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.player = e), this.player.template.mask.addEventListener("click", function () { n.hide(); }), this.player.template.settingButton.addEventListener("click", function () { n.show(); }), (this.loop = this.player.options.loop), (this.player.template.loopToggle.checked = this.loop), this.player.template.loop.addEventListener("click", function () { (n.player.template.loopToggle.checked = !n.player.template.loopToggle.checked), n.player.template.loopToggle.checked ? (n.loop = !0) : (n.loop = !1), n.hide(); }), (this.showDanmaku = this.player.user.get("danmaku")), this.showDanmaku || (this.player.danmaku && this.player.danmaku.hide()), (this.player.template.showDanmakuToggle.checked = this.showDanmaku), this.player.template.showDanmaku.addEventListener("click", function () { (n.player.template.showDanmakuToggle.checked = !n.player.template.showDanmakuToggle.checked), n.player.template.showDanmakuToggle.checked ? ((n.showDanmaku = !0), n.player.danmaku.show()) : ((n.showDanmaku = !1), n.player.danmaku.hide()), n.player.user.set("danmaku", n.showDanmaku ? 1 : 0), n.hide(); }), (this.unlimitDanmaku = this.player.user.get("unlimited")), (this.player.template.unlimitDanmakuToggle.checked = this.unlimitDanmaku), this.player.template.unlimitDanmaku.addEventListener("click", function () { (n.player.template.unlimitDanmakuToggle.checked = !n.player.template.unlimitDanmakuToggle.checked), n.player.template.unlimitDanmakuToggle.checked ? ((n.unlimitDanmaku = !0), n.player.danmaku.unlimit(!0)) : ((n.unlimitDanmaku = !1), n.player.danmaku.unlimit(!1)), n.player.user.set("unlimited", n.unlimitDanmaku ? 1 : 0), n.hide(); }), this.player.template.speed.addEventListener("click", function () { n.player.template.settingBox.classList.add("dplayer-setting-box-narrow"), n.player.template.settingBox.classList.add("dplayer-setting-box-speed"); }); for ( var i = function (t) { n.player.template.speedItem[t].addEventListener("click", function () { n.player.speed(n.player.template.speedItem[t].dataset.speed), n.hide(); }); }, r = 0; r < this.player.template.speedItem.length; r++ ) i(r); if (this.player.danmaku) { this.player.on("danmaku_opacity", function (t) { n.player.bar.set("danmaku", t, "width"), n.player.user.set("opacity", t); }), this.player.danmaku.opacity(this.player.user.get("opacity")); var a = function (t) { var e = t || window.event, i = ((e.clientX || e.changedTouches[0].clientX) - B.getBoundingClientRectViewLeft( n.player.template.danmakuOpacityBarWrap )) / 130; (i = Math.max(i, 0)), (i = Math.min(i, 1)), n.player.danmaku.opacity(i); }, s = function t() { document.removeEventListener(B.nameMap.dragEnd, t), document.removeEventListener(B.nameMap.dragMove, a), n.player.template.danmakuOpacityBox.classList.remove( "dplayer-setting-danmaku-active" ); }; this.player.template.danmakuOpacityBarWrapWrap.addEventListener("click", function (t) { var e = t || window.event, i = ((e.clientX || e.changedTouches[0].clientX) - B.getBoundingClientRectViewLeft( n.player.template.danmakuOpacityBarWrap )) / 130; (i = Math.max(i, 0)), (i = Math.min(i, 1)), n.player.danmaku.opacity(i); }), this.player.template.danmakuOpacityBarWrapWrap.addEventListener( B.nameMap.dragStart, function () { document.addEventListener(B.nameMap.dragMove, a), document.addEventListener(B.nameMap.dragEnd, s), n.player.template.danmakuOpacityBox.classList.add( "dplayer-setting-danmaku-active" ); } ); } } var e, n; return ( (e = t), (n = [ { key: "hide", value: function () { var t = this; this.player.template.settingBox.classList.remove("dplayer-setting-box-open"), this.player.template.mask.classList.remove("dplayer-mask-show"), setTimeout(function () { t.player.template.settingBox.classList.remove( "dplayer-setting-box-narrow" ), t.player.template.settingBox.classList.remove( "dplayer-setting-box-speed" ); }, 300), (this.player.controller.disableAutoHide = !1); } }, { key: "show", value: function () { this.player.template.settingBox.classList.add("dplayer-setting-box-open"), this.player.template.mask.classList.add("dplayer-mask-show"), (this.player.controller.disableAutoHide = !0); } } ]) && bi(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), wi = Ei; function xi(t) { return ( (xi = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), xi(t) ); } function Si(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== xi(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== xi(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === xi(r) ? r : String(r)), i ); } var r; } var _i = (function () { function t(e) { var n = this; !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.player = e), this.player.template.mask.addEventListener("click", function () { n.hide(); }), this.player.template.commentButton.addEventListener("click", function () { n.show(); }), this.player.template.commentSettingButton.addEventListener("click", function () { n.toggleSetting(); }), this.player.template.commentColorSettingBox.addEventListener("click", function () { if (n.player.template.commentColorSettingBox.querySelector("input:checked+span")) { var t = n.player.template.commentColorSettingBox.querySelector("input:checked").value; (n.player.template.commentSettingFill.style.fill = t), (n.player.template.commentInput.style.color = t), (n.player.template.commentSendFill.style.fill = t); } }), this.player.template.commentInput.addEventListener("click", function () { n.hideSetting(); }), this.player.template.commentInput.addEventListener("keydown", function (t) { 13 === (t || window.event).keyCode && n.send(); }), this.player.template.commentSendButton.addEventListener("click", function () { n.send(); }); } var e, n; return ( (e = t), (n = [ { key: "show", value: function () { (this.player.controller.disableAutoHide = !0), this.player.template.controller.classList.add("dplayer-controller-comment"), this.player.template.mask.classList.add("dplayer-mask-show"), this.player.container.classList.add("dplayer-show-controller"), this.player.template.commentInput.focus(); } }, { key: "hide", value: function () { this.player.template.controller.classList.remove("dplayer-controller-comment"), this.player.template.mask.classList.remove("dplayer-mask-show"), this.player.container.classList.remove("dplayer-show-controller"), (this.player.controller.disableAutoHide = !1), this.hideSetting(); } }, { key: "showSetting", value: function () { this.player.template.commentSettingBox.classList.add( "dplayer-comment-setting-open" ); } }, { key: "hideSetting", value: function () { this.player.template.commentSettingBox.classList.remove( "dplayer-comment-setting-open" ); } }, { key: "toggleSetting", value: function () { this.player.template.commentSettingBox.classList.contains( "dplayer-comment-setting-open" ) ? this.hideSetting() : this.showSetting(); } }, { key: "send", value: function () { var t = this; this.player.template.commentInput.blur(), this.player.template.commentInput.value.replace(/^\s+|\s+$/g, "") ? this.player.danmaku.send( { text: this.player.template.commentInput.value, color: B.color2Number( this.player.container.querySelector( ".dplayer-comment-setting-color input:checked" ).value ), type: parseInt( this.player.container.querySelector( ".dplayer-comment-setting-type input:checked" ).value ) }, function () { (t.player.template.commentInput.value = ""), t.hide(); } ) : this.player.notice(this.player.tran("please-input-danmaku")); } } ]) && Si(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Ti = _i; function ki(t) { return ( (ki = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), ki(t) ); } function Ci(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== ki(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== ki(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === ki(r) ? r : String(r)), i ); } var r; } var Li = (function () { function t(e) { !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.player = e), (this.doHotKeyHandler = this.doHotKey.bind(this)), (this.cancelFullScreenHandler = this.cancelFullScreen.bind(this)), this.player.options.hotkey && document.addEventListener("keydown", this.doHotKeyHandler), document.addEventListener("keydown", this.cancelFullScreenHandler); } var e, n; return ( (e = t), (n = [ { key: "doHotKey", value: function (t) { if (this.player.focus) { var e = document.activeElement.tagName.toUpperCase(), n = document.activeElement.getAttribute("contenteditable"); if ("INPUT" !== e && "TEXTAREA" !== e && "" !== n && "true" !== n) { var i, r = t || window.event; switch (r.keyCode) { case 32: r.preventDefault(), this.player.toggle(); break; case 37: if ((r.preventDefault(), this.player.options.live)) break; this.player.seek(this.player.video.currentTime - 5), this.player.controller.setAutoHide(); break; case 39: if ((r.preventDefault(), this.player.options.live)) break; this.player.seek(this.player.video.currentTime + 5), this.player.controller.setAutoHide(); break; case 38: r.preventDefault(), (i = this.player.volume() + 0.1), this.player.volume(i); break; case 40: r.preventDefault(), (i = this.player.volume() - 0.1), this.player.volume(i); } } } } }, { key: "cancelFullScreen", value: function (t) { 27 === (t || window.event).keyCode && this.player.fullScreen.isFullScreen("web") && this.player.fullScreen.cancel("web"); } }, { key: "destroy", value: function () { this.player.options.hotkey && document.removeEventListener("keydown", this.doHotKeyHandler), document.removeEventListener("keydown", this.cancelFullScreenHandler); } } ]) && Ci(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Ii = Li; function Ri(t) { return ( (Ri = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), Ri(t) ); } function Di(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== Ri(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== Ri(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === Ri(r) ? r : String(r)), i ); } var r; } var Bi = (function () { function t(e) { var n = this; !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.player = e), (this.shown = !1), Array.prototype.slice.call(this.player.template.menuItem).forEach(function (t, e) { n.player.options.contextmenu[e].click && t.addEventListener("click", function () { n.player.options.contextmenu[e].click(n.player), n.hide(); }); }), (this.contextmenuHandler = function (t) { if (n.shown) n.hide(); else { var e = t || window.event; e.preventDefault(); var i = n.player.container.getBoundingClientRect(); n.show(e.clientX - i.left, e.clientY - i.top), n.player.template.mask.addEventListener("click", function () { n.hide(); }); } }), this.player.container.addEventListener("contextmenu", this.contextmenuHandler); } var e, n; return ( (e = t), (n = [ { key: "show", value: function (t, e) { this.player.template.menu.classList.add("dplayer-menu-show"); var n = this.player.container.getBoundingClientRect(); t + this.player.template.menu.offsetWidth >= n.width ? ((this.player.template.menu.style.right = n.width - t + "px"), (this.player.template.menu.style.left = "initial")) : ((this.player.template.menu.style.left = t + "px"), (this.player.template.menu.style.right = "initial")), e + this.player.template.menu.offsetHeight >= n.height ? ((this.player.template.menu.style.bottom = n.height - e + "px"), (this.player.template.menu.style.top = "initial")) : ((this.player.template.menu.style.top = e + "px"), (this.player.template.menu.style.bottom = "initial")), this.player.template.mask.classList.add("dplayer-mask-show"), (this.shown = !0), this.player.events.trigger("contextmenu_show"); } }, { key: "hide", value: function () { this.player.template.mask.classList.remove("dplayer-mask-show"), this.player.template.menu.classList.remove("dplayer-menu-show"), (this.shown = !1), this.player.events.trigger("contextmenu_hide"); } }, { key: "destroy", value: function () { this.player.container.removeEventListener("contextmenu", this.contextmenuHandler); } } ]) && Di(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Pi = Bi; function Ui(t) { return ( (Ui = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), Ui(t) ); } function Fi(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty( t, ((r = (function (t, e) { if ("object" !== Ui(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== Ui(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(i.key)), "symbol" === Ui(r) ? r : String(r)), i ); } var r; } var Oi = (function () { function t(e) { var n = this; !(function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.container = e.template.infoPanel), (this.template = e.template), (this.video = e.video), (this.player = e), this.template.infoPanelClose.addEventListener("click", function () { n.hide(); }); } var e, n; return ( (e = t), (n = [ { key: "show", value: function () { (this.beginTime = Date.now()), this.update(), this.player.timer.enable("info"), this.player.timer.enable("fps"), this.container.classList.remove("dplayer-info-panel-hide"); } }, { key: "hide", value: function () { this.player.timer.disable("info"), this.player.timer.disable("fps"), this.container.classList.add("dplayer-info-panel-hide"); } }, { key: "triggle", value: function () { this.container.classList.contains("dplayer-info-panel-hide") ? this.show() : this.hide(); } }, { key: "update", value: function () { (this.template.infoVersion.innerHTML = "v" .concat("1.27.1", " ") .concat("v1.27.0-12-g4f61091")), (this.template.infoType.innerHTML = this.player.type), (this.template.infoUrl.innerHTML = this.player.options.video.url), (this.template.infoResolution.innerHTML = "" .concat(this.player.video.videoWidth, " x ") .concat(this.player.video.videoHeight)), (this.template.infoDuration.innerHTML = this.player.video.duration), this.player.options.danmaku && ((this.template.infoDanmakuId.innerHTML = this.player.options.danmaku.id), (this.template.infoDanmakuApi.innerHTML = this.player.options.danmaku.api), (this.template.infoDanmakuAmount.innerHTML = this.player.danmaku.dan.length)); } }, { key: "fps", value: function (t) { this.template.infoFPS.innerHTML = "".concat(t.toFixed(1)); } } ]) && Fi(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Mi = Oi, Ni = n(568), zi = n.n(Ni); function Gi(t) { return ( (Gi = "function" == typeof Symbol && "symbol" == u(Symbol.iterator) ? function (t) { return u(t); } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : u(t); }), Gi(t) ); } function ji(t, e) { var n = Object.keys(t); if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(t); e && (i = i.filter(function (e) { return Object.getOwnPropertyDescriptor(t, e).enumerable; })), n.push.apply(n, i); } return n; } function Hi(t, e, n) { return ( (e = $i(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : (t[e] = n), t ); } function Yi(t, e) { for (var n = 0; n < e.length; n++) { var i = e[n]; (i.enumerable = i.enumerable || !1), (i.configurable = !0), "value" in i && (i.writable = !0), Object.defineProperty(t, $i(i.key), i); } } function $i(t) { var e = (function (t, e) { if ("object" !== Gi(t) || null === t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, "string"); if ("object" !== Gi(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(t); })(t); return "symbol" === Gi(e) ? e : String(e); } var Ki = 0, qi = [], Vi = (function () { function t(e) { var n = this; (function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); })(this, t), (this.options = (function (t) { var e = { container: t.element || document.getElementsByClassName("dplayer")[0], live: !1, autoplay: !1, theme: "#b7daff", loop: !1, lang: (navigator.language || navigator.browserLanguage).toLowerCase(), screenshot: !1, airplay: !0, chromecast: !1, hotkey: !0, preload: "metadata", volume: 0.7, playbackSpeed: [0.5, 0.75, 1, 1.25, 1.5, 2], apiBackend: Be, video: {}, contextmenu: [], mutex: !0, pluginOptions: { hls: {}, flv: {}, dash: {}, webtorrent: {} }, preventClickToggle: !1 }; for (var n in e) e.hasOwnProperty(n) && !t.hasOwnProperty(n) && (t[n] = e[n]); return ( t.video && !t.video.type && (t.video.type = "auto"), "object" === Pe(t.danmaku) && t.danmaku && !t.danmaku.user && (t.danmaku.user = "DIYgod"), t.subtitle && (!t.subtitle.type && (t.subtitle.type = "webvtt"), !t.subtitle.fontSize && (t.subtitle.fontSize = "20px"), !t.subtitle.bottom && (t.subtitle.bottom = "40px"), !t.subtitle.color && (t.subtitle.color = "#fff")), t.video.quality && (t.video.url = t.video.quality[t.video.defaultQuality].url), t.lang && (t.lang = t.lang.toLowerCase()), (t.contextmenu = t.contextmenu.concat([ { key: "video-info", click: function (t) { t.infoPanel.triggle(); } }, { key: "about-author", link: "https://diygod.me" }, { text: "DPlayer v".concat("1.27.1"), link: "https://github.com/MoePlayer/DPlayer" } ])), t ); })( (function (t) { for (var e = 1; e < arguments.length; e++) { var n = null != arguments[e] ? arguments[e] : {}; e % 2 ? ji(Object(n), !0).forEach(function (e) { Hi(t, e, n[e]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ji(Object(n)).forEach(function (e) { Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e)); }); } return t; })({ preload: "webtorrent" === e.video.type ? "none" : "metadata" }, e) )), this.options.video.quality && ((this.qualityIndex = this.options.video.defaultQuality), (this.quality = this.options.video.quality[this.options.video.defaultQuality])), (this.tran = new Ue(this.options.lang).tran), (this.events = new Pn()), (this.user = new jn(this)), (this.container = this.options.container), (this.noticeList = {}), this.container.classList.add("dplayer"), this.options.danmaku || this.container.classList.add("dplayer-no-danmaku"), this.options.live ? this.container.classList.add("dplayer-live") : this.container.classList.remove("dplayer-live"), B.isMobile && this.container.classList.add("dplayer-mobile"), (this.arrow = this.container.offsetWidth <= 500), this.arrow && this.container.classList.add("dplayer-arrow"), this.options.subtitle && Array.isArray(this.options.subtitle.url) && (this.options.subtitle.url.push({ subtitle: "", lang: "off" }), this.options.subtitle.defaultSubtitle && ("string" == typeof this.options.subtitle.defaultSubtitle ? (this.options.subtitle.index = this.options.subtitle.url.findIndex( function (t) { return ( t.lang === n.options.subtitle.defaultSubtitle || t.name === n.options.subtitle.defaultSubtitle ); } )) : "number" == typeof this.options.subtitle.defaultSubtitle && (this.options.subtitle.index = this.options.subtitle.defaultSubtitle)), (-1 === this.options.subtitle.index || !this.options.subtitle.index || this.options.subtitle.index > this.options.subtitle.url.length - 1) && (this.options.subtitle.index = this.options.subtitle.url.findIndex(function (t) { return t.lang === n.options.lang; })), -1 === this.options.subtitle.index && (this.options.subtitle.index = this.options.subtitle.url.length - 1)), (this.template = new kn({ container: this.container, options: this.options, index: Ki, tran: this.tran })), (this.video = this.template.video), (this.bar = new ti(this.template)), (this.bezel = new oi(this.template.bezel)), (this.fullScreen = new Mn(this)), (this.controller = new Ai(this)), this.options.danmaku && ((this.danmaku = new Rn({ player: this, container: this.template.danmaku, opacity: this.user.get("opacity"), callback: function () { setTimeout(function () { (n.template.danmakuLoading.style.display = "none"), n.options.autoplay && n.play(); }, 0); }, error: function (t) { n.notice(t); }, apiBackend: this.options.apiBackend, borderColor: this.options.theme, height: this.arrow ? 24 : 30, time: function () { return n.video.currentTime; }, unlimited: this.user.get("unlimited"), api: { id: this.options.danmaku.id, address: this.options.danmaku.api, token: this.options.danmaku.token, maximum: this.options.danmaku.maximum, addition: this.options.danmaku.addition, user: this.options.danmaku.user, speedRate: this.options.danmaku.speedRate }, events: this.events, tran: function (t) { return n.tran(t); } })), (this.comment = new Ti(this))), (this.setting = new wi(this)), (this.plugins = {}), (this.docClickFun = function () { n.focus = !1; }), (this.containerClickFun = function () { n.focus = !0; }), document.addEventListener("click", this.docClickFun, !0), this.container.addEventListener("click", this.containerClickFun, !0), (this.paused = !0), (this.timer = new ri(this)), (this.hotkey = new Ii(this)), (this.contextmenu = new Pi(this)), this.initVideo( this.video, (this.quality && this.quality.type) || this.options.video.type ), (this.infoPanel = new Mi(this)), !this.danmaku && this.options.autoplay && this.play(), Ki++, qi.push(this); } var e, n, i; return ( (e = t), (n = [ { key: "seek", value: function (t) { (t = Math.max(t, 0)), this.video.duration && (t = Math.min(t, this.video.duration)), this.video.currentTime < t ? this.notice( "".concat( this.tran("ff").replace( "%s", (t - this.video.currentTime).toFixed(0) ) ) ) : this.video.currentTime > t && this.notice( "".concat( this.tran("rew").replace( "%s", (this.video.currentTime - t).toFixed(0) ) ) ), (this.video.currentTime = t), this.danmaku && this.danmaku.seek(), this.bar.set("played", t / this.video.duration, "width"), (this.template.ptime.innerHTML = B.secondToTime(t)); } }, { key: "play", value: function (t) { var e = this; if ( ((this.paused = !1), this.video.paused && !B.isMobile && this.bezel.switch(En.play), (this.template.playButton.innerHTML = En.pause), (this.template.mobilePlayButton.innerHTML = En.pause), t || R.resolve(this.video.play()) .catch(function () { e.pause(); }) .then(function () { }), this.timer.enable("loading"), this.container.classList.remove("dplayer-paused"), this.container.classList.add("dplayer-playing"), this.danmaku && this.danmaku.play(), this.options.mutex) ) for (var n = 0; n < qi.length; n++) this !== qi[n] && qi[n].pause(); } }, { key: "pause", value: function (t) { (this.paused = !0), this.container.classList.remove("dplayer-loading"), this.video.paused || B.isMobile || this.bezel.switch(En.pause), (this.template.playButton.innerHTML = En.play), (this.template.mobilePlayButton.innerHTML = En.play), t || this.video.pause(), this.timer.disable("loading"), this.container.classList.remove("dplayer-playing"), this.container.classList.add("dplayer-paused"), this.danmaku && this.danmaku.pause(); } }, { key: "switchVolumeIcon", value: function () { this.volume() >= 0.95 ? (this.template.volumeIcon.innerHTML = En.volumeUp) : this.volume() > 0 ? (this.template.volumeIcon.innerHTML = En.volumeDown) : (this.template.volumeIcon.innerHTML = En.volumeOff); } }, { key: "volume", value: function (t, e, n) { if (((t = parseFloat(t)), !isNaN(t))) { (t = Math.max(t, 0)), (t = Math.min(t, 1)), this.bar.set("volume", t, "width"); var i = "".concat((100 * t).toFixed(0), "%"); (this.template.volumeBarWrapWrap.dataset.balloon = i), e || this.user.set("volume", t), n || this.notice( "" .concat(this.tran("volume"), " ") .concat((100 * t).toFixed(0), "%"), void 0, void 0, "volume" ), (this.video.volume = t), this.video.muted && (this.video.muted = !1), this.switchVolumeIcon(); } return this.video.volume; } }, { key: "toggle", value: function () { this.video.paused ? this.play() : this.pause(); } }, { key: "on", value: function (t, e) { this.events.on(t, e); } }, { key: "switchVideo", value: function (t, e) { this.pause(), (this.video.poster = t.pic ? t.pic : ""), (this.video.src = t.url), this.initMSE(this.video, t.type || "auto"), e && ((this.template.danmakuLoading.style.display = "block"), this.bar.set("played", 0, "width"), this.bar.set("loaded", 0, "width"), (this.template.ptime.innerHTML = "00:00"), (this.template.danmaku.innerHTML = ""), this.danmaku && this.danmaku.reload({ id: e.id, address: e.api, token: e.token, maximum: e.maximum, addition: e.addition, user: e.user })); } }, { key: "initMSE", value: function (t, e) { var n = this; if ( ((this.type = e), this.options.video.customType && this.options.video.customType[e]) ) "[object Function]" === Object.prototype.toString.call(this.options.video.customType[e]) ? this.options.video.customType[e](this.video, this) : console.error("Illegal customType: ".concat(e)); else switch ( ("auto" === this.type && (/m3u8(#|\?|$)/i.exec(t.src) ? (this.type = "hls") : /.flv(#|\?|$)/i.exec(t.src) ? (this.type = "flv") : /.mpd(#|\?|$)/i.exec(t.src) ? (this.type = "dash") : (this.type = "normal")), "hls" === this.type && (t.canPlayType("application/x-mpegURL") || t.canPlayType("application/vnd.apple.mpegURL")) && (this.type = "normal"), this.type) ) { case "hls": if (window.Hls) if (window.Hls.isSupported()) { var i = this.options.pluginOptions.hls, r = new window.Hls(i); (this.plugins.hls = r), r.loadSource(t.src), r.attachMedia(t), this.events.on("destroy", function () { r.destroy(), delete n.plugins.hls; }); } else this.notice("Error: Hls is not supported."); else this.notice("Error: Can't find Hls."); break; case "flv": if (window.flvjs) if (window.flvjs.isSupported()) { var a = window.flvjs.createPlayer( Object.assign( this.options.pluginOptions.flv.mediaDataSource || {}, { type: "flv", url: t.src } ), this.options.pluginOptions.flv.config ); (this.plugins.flvjs = a), a.attachMediaElement(t), a.load(), this.events.on("destroy", function () { a.unload(), a.detachMediaElement(), a.destroy(), delete n.plugins.flvjs; }); } else this.notice("Error: flvjs is not supported."); else this.notice("Error: Can't find flvjs."); break; case "dash": if (window.dashjs) { var s = window.dashjs .MediaPlayer() .create() .initialize(t, t.src, !1), o = this.options.pluginOptions.dash; s.updateSettings(o), (this.plugins.dash = s), this.events.on("destroy", function () { window.dashjs.MediaPlayer().reset(), delete n.plugins.dash; }); } else this.notice("Error: Can't find dashjs."); break; case "webtorrent": if (window.WebTorrent) if (window.WebTorrent.WEBRTC_SUPPORT) { this.container.classList.add("dplayer-loading"); var l = this.options.pluginOptions.webtorrent, d = new window.WebTorrent(l); this.plugins.webtorrent = d; var c = t.src; (t.src = ""), (t.preload = "metadata"), t.addEventListener( "durationchange", function () { return n.container.classList.remove( "dplayer-loading" ); }, { once: !0 } ), d.add(c, function (t) { t.files .find(function (t) { return t.name.endsWith(".mp4"); }) .renderTo(n.video, { autoplay: n.options.autoplay, controls: !1 }); }), this.events.on("destroy", function () { d.remove(c), d.destroy(), delete n.plugins.webtorrent; }); } else this.notice("Error: Webtorrent is not supported."); else this.notice("Error: Can't find Webtorrent."); } } }, { key: "initVideo", value: function (t, e) { var n = this; this.initMSE(t, e), this.on("durationchange", function () { 1 !== t.duration && t.duration !== 1 / 0 && (n.template.dtime.innerHTML = B.secondToTime(t.duration)); }), this.on("progress", function () { var e = t.buffered.length ? t.buffered.end(t.buffered.length - 1) / t.duration : 0; n.bar.set("loaded", e, "width"); }), this.on("error", function () { n.video.error && n.tran && n.notice && "webtorrent" !== n.type && n.notice(n.tran("video-failed")); }), this.on("ended", function () { n.bar.set("played", 1, "width"), n.setting.loop ? (n.seek(0), n.play()) : n.pause(), n.danmaku && (n.danmaku.danIndex = 0); }), this.on("play", function () { n.paused && n.play(!0); }), this.on("pause", function () { n.paused || n.pause(!0); }), this.on("timeupdate", function () { n.bar.set("played", n.video.currentTime / n.video.duration, "width"); var t = B.secondToTime(n.video.currentTime); n.template.ptime.innerHTML !== t && (n.template.ptime.innerHTML = t); }); for ( var i = function (e) { t.addEventListener(n.events.videoEvents[e], function (t) { n.events.trigger(n.events.videoEvents[e], t); }); }, r = 0; r < this.events.videoEvents.length; r++ ) i(r); this.volume(this.user.get("volume"), !0, !0), this.options.subtitle && ((this.subtitle = new Kn( this.template.subtitle, this.video, this.options.subtitle, this.events )), Array.isArray(this.options.subtitle.url) && (this.subtitles = new Qn(this)), this.user.get("subtitle") || this.subtitle.hide()); } }, { key: "switchQuality", value: function (t) { var e = this; if ( ((t = "string" == typeof t ? parseInt(t) : t), this.qualityIndex !== t && !this.switchingQuality) ) { (this.prevIndex = this.qualityIndex), (this.qualityIndex = t), (this.switchingQuality = !0), (this.quality = this.options.video.quality[t]), (this.template.qualityButton.innerHTML = this.quality.name); var n = this.video.paused; this.video.pause(); var i = zi()({ current: !1, pic: null, screenshot: this.options.screenshot, preload: "auto", url: this.quality.url, subtitle: this.options.subtitle }), r = new DOMParser().parseFromString(i, "text/html").body.firstChild; this.template.videoWrap.insertBefore( r, this.template.videoWrap.getElementsByTagName("div")[0] ), (this.prevVideo = this.video), (this.video = r), this.initVideo(this.video, this.quality.type || this.options.video.type), this.seek(this.prevVideo.currentTime), this.notice( "".concat( this.tran("switching-quality").replace("%q", this.quality.name) ), -1, void 0, "switch-quality" ), this.events.trigger("quality_start", this.quality), this.on("canplay", function () { if (e.prevVideo) { if (e.video.currentTime !== e.prevVideo.currentTime) return void e.seek(e.prevVideo.currentTime); e.template.videoWrap.removeChild(e.prevVideo), e.video.classList.add("dplayer-video-current"), n || e.video.play(), (e.prevVideo = null), e.notice( "".concat( e .tran("switched-quality") .replace("%q", e.quality.name) ), void 0, void 0, "switch-quality" ), (e.switchingQuality = !1), e.events.trigger("quality_end"); } }), this.on("error", function () { e.video.error && e.prevVideo && (e.template.videoWrap.removeChild(e.video), (e.video = e.prevVideo), n || e.video.play(), (e.qualityIndex = e.prevIndex), (e.quality = e.options.video.quality[e.qualityIndex]), (e.noticeTime = setTimeout(function () { (e.template.notice.style.opacity = 0), e.events.trigger("notice_hide"); }, 3e3)), (e.prevVideo = null), (e.switchingQuality = !1)); }); } } }, { key: "notice", value: function (t) { var e, n, i, r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 2e3, a = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0.8, s = arguments.length > 3 ? arguments[3] : void 0; if ( (s && ((e = document.getElementById("dplayer-notice-".concat(s))) && (e.innerHTML = t), this.noticeList[s] && (clearTimeout(this.noticeList[s]), (this.noticeList[s] = null))), !e) ) { var o = kn.NewNotice(t, a, s); this.template.noticeList.appendChild(o), (e = o); } this.events.trigger("notice_show", e), r > 0 && (this.noticeList[s] = setTimeout( ((n = e), (i = this), function () { n.addEventListener("animationend", function () { i.template.noticeList.removeChild(n); }), n.classList.add("remove-notice"), i.events.trigger("notice_hide"), (i.noticeList[s] = null); }), r )); } }, { key: "resize", value: function () { this.danmaku && this.danmaku.resize(), this.controller.thumbnails && this.controller.thumbnails.resize( 160, (this.video.videoHeight / this.video.videoWidth) * 160, this.template.barWrap.offsetWidth ), this.events.trigger("resize"); } }, { key: "speed", value: function (t) { this.video.playbackRate = t; } }, { key: "destroy", value: function () { qi.splice(qi.indexOf(this), 1), this.pause(), document.removeEventListener("click", this.docClickFun, !0), this.container.removeEventListener("click", this.containerClickFun, !0), this.fullScreen.destroy(), this.hotkey.destroy(), this.contextmenu.destroy(), this.controller.destroy(), this.timer.destroy(), (this.video.src = ""), (this.container.innerHTML = ""), this.events.trigger("destroy"); } } ]), (i = [ { key: "version", get: function () { return "1.27.1"; } } ]), n && Yi(e.prototype, n), i && Yi(e, i), Object.defineProperty(e, "prototype", { writable: !1 }), t ); })(), Wi = Vi; console.log( "\n" .concat(" %c DPlayer v", "1.27.1", " ") .concat("v1.27.0-12-g4f61091", " %c https://dplayer.diygod.dev ", "\n", "\n"), "color: #fadfa3; background: #030307; padding:5px 0;", "background: #fadfa3; padding:5px 0;" ); var Qi = Wi; })(), i.default ); })()); })(G); var j = k(G.exports); function H(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } var Y = { exports: {} }; !(function (t, e) { var n, i, r, a, s; (n = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/), (i = /^(?=([^\/?#]*))\1([^]*)$/), (r = /(?:\/|^)\.(?=\/)/g), (a = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g), (s = { buildAbsoluteURL: function (t, e, n) { if (((n = n || {}), (t = t.trim()), !(e = e.trim()))) { if (!n.alwaysNormalize) return t; var r = s.parseURL(t); if (!r) throw new Error("Error trying to parse base URL."); return (r.path = s.normalizePath(r.path)), s.buildURLFromParts(r); } var a = s.parseURL(e); if (!a) throw new Error("Error trying to parse relative URL."); if (a.scheme) return n.alwaysNormalize ? ((a.path = s.normalizePath(a.path)), s.buildURLFromParts(a)) : e; var o = s.parseURL(t); if (!o) throw new Error("Error trying to parse base URL."); if (!o.netLoc && o.path && "/" !== o.path[0]) { var l = i.exec(o.path); (o.netLoc = l[1]), (o.path = l[2]); } o.netLoc && !o.path && (o.path = "/"); var d = { scheme: o.scheme, netLoc: a.netLoc, path: null, params: a.params, query: a.query, fragment: a.fragment }; if (!a.netLoc && ((d.netLoc = o.netLoc), "/" !== a.path[0])) if (a.path) { var c = o.path, u = c.substring(0, c.lastIndexOf("/") + 1) + a.path; d.path = s.normalizePath(u); } else (d.path = o.path), a.params || ((d.params = o.params), a.query || (d.query = o.query)); return ( null === d.path && (d.path = n.alwaysNormalize ? s.normalizePath(a.path) : a.path), s.buildURLFromParts(d) ); }, parseURL: function (t) { var e = n.exec(t); return e ? { scheme: e[1] || "", netLoc: e[2] || "", path: e[3] || "", params: e[4] || "", query: e[5] || "", fragment: e[6] || "" } : null; }, normalizePath: function (t) { for (t = t.split("").reverse().join("").replace(r, ""); t.length !== (t = t.replace(a, "")).length;); return t.split("").reverse().join(""); }, buildURLFromParts: function (t) { return t.scheme + t.netLoc + t.path + t.params + t.query + t.fragment; } }), (t.exports = s); })(Y); var $ = Y.exports; function K(t, e) { var n = Object.keys(t); if (Object.getOwnPropertySymbols) { var i = Object.getOwnPropertySymbols(t); e && (i = i.filter(function (e) { return Object.getOwnPropertyDescriptor(t, e).enumerable; })), n.push.apply(n, i); } return n; } function q(t) { for (var e = 1; e < arguments.length; e++) { var n = null != arguments[e] ? arguments[e] : {}; e % 2 ? K(Object(n), !0).forEach(function (e) { W(t, e, n[e]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : K(Object(n)).forEach(function (e) { Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e)); }); } return t; } function V(t) { var e = (function (t, e) { if ("object" != typeof t || !t) return t; var n = t[Symbol.toPrimitive]; if (void 0 !== n) { var i = n.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); })(t, "string"); return "symbol" == typeof e ? e : String(e); } function W(t, e, n) { return ( (e = V(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : (t[e] = n), t ); } function Q() { return ( (Q = Object.assign ? Object.assign.bind() : function (t) { for (var e = 1; e < arguments.length; e++) { var n = arguments[e]; for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (t[i] = n[i]); } return t; }), Q.apply(this, arguments) ); } const X = Number.isFinite || function (t) { return "number" == typeof t && isFinite(t); }, J = Number.isSafeInteger || function (t) { return "number" == typeof t && Math.abs(t) <= Z; }, Z = Number.MAX_SAFE_INTEGER || 9007199254740991; let tt = (function (t) { return ( (t.MEDIA_ATTACHING = "hlsMediaAttaching"), (t.MEDIA_ATTACHED = "hlsMediaAttached"), (t.MEDIA_DETACHING = "hlsMediaDetaching"), (t.MEDIA_DETACHED = "hlsMediaDetached"), (t.BUFFER_RESET = "hlsBufferReset"), (t.BUFFER_CODECS = "hlsBufferCodecs"), (t.BUFFER_CREATED = "hlsBufferCreated"), (t.BUFFER_APPENDING = "hlsBufferAppending"), (t.BUFFER_APPENDED = "hlsBufferAppended"), (t.BUFFER_EOS = "hlsBufferEos"), (t.BUFFER_FLUSHING = "hlsBufferFlushing"), (t.BUFFER_FLUSHED = "hlsBufferFlushed"), (t.MANIFEST_LOADING = "hlsManifestLoading"), (t.MANIFEST_LOADED = "hlsManifestLoaded"), (t.MANIFEST_PARSED = "hlsManifestParsed"), (t.LEVEL_SWITCHING = "hlsLevelSwitching"), (t.LEVEL_SWITCHED = "hlsLevelSwitched"), (t.LEVEL_LOADING = "hlsLevelLoading"), (t.LEVEL_LOADED = "hlsLevelLoaded"), (t.LEVEL_UPDATED = "hlsLevelUpdated"), (t.LEVEL_PTS_UPDATED = "hlsLevelPtsUpdated"), (t.LEVELS_UPDATED = "hlsLevelsUpdated"), (t.AUDIO_TRACKS_UPDATED = "hlsAudioTracksUpdated"), (t.AUDIO_TRACK_SWITCHING = "hlsAudioTrackSwitching"), (t.AUDIO_TRACK_SWITCHED = "hlsAudioTrackSwitched"), (t.AUDIO_TRACK_LOADING = "hlsAudioTrackLoading"), (t.AUDIO_TRACK_LOADED = "hlsAudioTrackLoaded"), (t.SUBTITLE_TRACKS_UPDATED = "hlsSubtitleTracksUpdated"), (t.SUBTITLE_TRACKS_CLEARED = "hlsSubtitleTracksCleared"), (t.SUBTITLE_TRACK_SWITCH = "hlsSubtitleTrackSwitch"), (t.SUBTITLE_TRACK_LOADING = "hlsSubtitleTrackLoading"), (t.SUBTITLE_TRACK_LOADED = "hlsSubtitleTrackLoaded"), (t.SUBTITLE_FRAG_PROCESSED = "hlsSubtitleFragProcessed"), (t.CUES_PARSED = "hlsCuesParsed"), (t.NON_NATIVE_TEXT_TRACKS_FOUND = "hlsNonNativeTextTracksFound"), (t.INIT_PTS_FOUND = "hlsInitPtsFound"), (t.FRAG_LOADING = "hlsFragLoading"), (t.FRAG_LOAD_EMERGENCY_ABORTED = "hlsFragLoadEmergencyAborted"), (t.FRAG_LOADED = "hlsFragLoaded"), (t.FRAG_DECRYPTED = "hlsFragDecrypted"), (t.FRAG_PARSING_INIT_SEGMENT = "hlsFragParsingInitSegment"), (t.FRAG_PARSING_USERDATA = "hlsFragParsingUserdata"), (t.FRAG_PARSING_METADATA = "hlsFragParsingMetadata"), (t.FRAG_PARSED = "hlsFragParsed"), (t.FRAG_BUFFERED = "hlsFragBuffered"), (t.FRAG_CHANGED = "hlsFragChanged"), (t.FPS_DROP = "hlsFpsDrop"), (t.FPS_DROP_LEVEL_CAPPING = "hlsFpsDropLevelCapping"), (t.MAX_AUTO_LEVEL_UPDATED = "hlsMaxAutoLevelUpdated"), (t.ERROR = "hlsError"), (t.DESTROYING = "hlsDestroying"), (t.KEY_LOADING = "hlsKeyLoading"), (t.KEY_LOADED = "hlsKeyLoaded"), (t.LIVE_BACK_BUFFER_REACHED = "hlsLiveBackBufferReached"), (t.BACK_BUFFER_REACHED = "hlsBackBufferReached"), (t.STEERING_MANIFEST_LOADED = "hlsSteeringManifestLoaded"), t ); })({}), et = (function (t) { return ( (t.NETWORK_ERROR = "networkError"), (t.MEDIA_ERROR = "mediaError"), (t.KEY_SYSTEM_ERROR = "keySystemError"), (t.MUX_ERROR = "muxError"), (t.OTHER_ERROR = "otherError"), t ); })({}), nt = (function (t) { return ( (t.KEY_SYSTEM_NO_KEYS = "keySystemNoKeys"), (t.KEY_SYSTEM_NO_ACCESS = "keySystemNoAccess"), (t.KEY_SYSTEM_NO_SESSION = "keySystemNoSession"), (t.KEY_SYSTEM_NO_CONFIGURED_LICENSE = "keySystemNoConfiguredLicense"), (t.KEY_SYSTEM_LICENSE_REQUEST_FAILED = "keySystemLicenseRequestFailed"), (t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED = "keySystemServerCertificateRequestFailed"), (t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED = "keySystemServerCertificateUpdateFailed"), (t.KEY_SYSTEM_SESSION_UPDATE_FAILED = "keySystemSessionUpdateFailed"), (t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED = "keySystemStatusOutputRestricted"), (t.KEY_SYSTEM_STATUS_INTERNAL_ERROR = "keySystemStatusInternalError"), (t.MANIFEST_LOAD_ERROR = "manifestLoadError"), (t.MANIFEST_LOAD_TIMEOUT = "manifestLoadTimeOut"), (t.MANIFEST_PARSING_ERROR = "manifestParsingError"), (t.MANIFEST_INCOMPATIBLE_CODECS_ERROR = "manifestIncompatibleCodecsError"), (t.LEVEL_EMPTY_ERROR = "levelEmptyError"), (t.LEVEL_LOAD_ERROR = "levelLoadError"), (t.LEVEL_LOAD_TIMEOUT = "levelLoadTimeOut"), (t.LEVEL_PARSING_ERROR = "levelParsingError"), (t.LEVEL_SWITCH_ERROR = "levelSwitchError"), (t.AUDIO_TRACK_LOAD_ERROR = "audioTrackLoadError"), (t.AUDIO_TRACK_LOAD_TIMEOUT = "audioTrackLoadTimeOut"), (t.SUBTITLE_LOAD_ERROR = "subtitleTrackLoadError"), (t.SUBTITLE_TRACK_LOAD_TIMEOUT = "subtitleTrackLoadTimeOut"), (t.FRAG_LOAD_ERROR = "fragLoadError"), (t.FRAG_LOAD_TIMEOUT = "fragLoadTimeOut"), (t.FRAG_DECRYPT_ERROR = "fragDecryptError"), (t.FRAG_PARSING_ERROR = "fragParsingError"), (t.FRAG_GAP = "fragGap"), (t.REMUX_ALLOC_ERROR = "remuxAllocError"), (t.KEY_LOAD_ERROR = "keyLoadError"), (t.KEY_LOAD_TIMEOUT = "keyLoadTimeOut"), (t.BUFFER_ADD_CODEC_ERROR = "bufferAddCodecError"), (t.BUFFER_INCOMPATIBLE_CODECS_ERROR = "bufferIncompatibleCodecsError"), (t.BUFFER_APPEND_ERROR = "bufferAppendError"), (t.BUFFER_APPENDING_ERROR = "bufferAppendingError"), (t.BUFFER_STALLED_ERROR = "bufferStalledError"), (t.BUFFER_FULL_ERROR = "bufferFullError"), (t.BUFFER_SEEK_OVER_HOLE = "bufferSeekOverHole"), (t.BUFFER_NUDGE_ON_STALL = "bufferNudgeOnStall"), (t.INTERNAL_EXCEPTION = "internalException"), (t.INTERNAL_ABORTED = "aborted"), (t.UNKNOWN = "unknown"), t ); })({}); const it = function () { }, rt = { trace: it, debug: it, log: it, warn: it, info: it, error: it }; let at = rt; function st(t, ...e) { e.forEach(function (e) { at[e] = t[e] ? t[e].bind(t) : (function (t) { const e = self.console[t]; return e ? e.bind(self.console, `[${t}] >`) : it; })(e); }); } const ot = at, lt = /^(\d+)x(\d+)$/, dt = /(.+?)=(".*?"|.*?)(?:,|$)/g; class ct { constructor(t) { "string" == typeof t && (t = ct.parseAttrList(t)), Q(this, t); } get clientAttrs() { return Object.keys(this).filter(t => "X-" === t.substring(0, 2)); } decimalInteger(t) { const e = parseInt(this[t], 10); return e > Number.MAX_SAFE_INTEGER ? 1 / 0 : e; } hexadecimalInteger(t) { if (this[t]) { let e = (this[t] || "0x").slice(2); e = (1 & e.length ? "0" : "") + e; const n = new Uint8Array(e.length / 2); for (let t = 0; t < e.length / 2; t++) n[t] = parseInt(e.slice(2 * t, 2 * t + 2), 16); return n; } return null; } hexadecimalIntegerAsNumber(t) { const e = parseInt(this[t], 16); return e > Number.MAX_SAFE_INTEGER ? 1 / 0 : e; } decimalFloatingPoint(t) { return parseFloat(this[t]); } optionalFloat(t, e) { const n = this[t]; return n ? parseFloat(n) : e; } enumeratedString(t) { return this[t]; } bool(t) { return "YES" === this[t]; } decimalResolution(t) { const e = lt.exec(this[t]); if (null !== e) return { width: parseInt(e[1], 10), height: parseInt(e[2], 10) }; } static parseAttrList(t) { let e; const n = {}; for (dt.lastIndex = 0; null !== (e = dt.exec(t));) { let t = e[2]; 0 === t.indexOf('"') && t.lastIndexOf('"') === t.length - 1 && (t = t.slice(1, -1)); n[e[1].trim()] = t; } return n; } } function ut(t) { return "SCTE35-OUT" === t || "SCTE35-IN" === t; } class ht { constructor(t, e) { if ( ((this.attr = void 0), (this._startDate = void 0), (this._endDate = void 0), (this._badValueForSameId = void 0), e) ) { const n = e.attr; for (const e in n) if (Object.prototype.hasOwnProperty.call(t, e) && t[e] !== n[e]) { ot.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`), (this._badValueForSameId = e); break; } t = Q(new ct({}), n, t); } if (((this.attr = t), (this._startDate = new Date(t["START-DATE"])), "END-DATE" in this.attr)) { const t = new Date(this.attr["END-DATE"]); X(t.getTime()) && (this._endDate = t); } } get id() { return this.attr.ID; } get class() { return this.attr.CLASS; } get startDate() { return this._startDate; } get endDate() { if (this._endDate) return this._endDate; const t = this.duration; return null !== t ? new Date(this._startDate.getTime() + 1e3 * t) : null; } get duration() { if ("DURATION" in this.attr) { const t = this.attr.decimalFloatingPoint("DURATION"); if (X(t)) return t; } else if (this._endDate) return (this._endDate.getTime() - this._startDate.getTime()) / 1e3; return null; } get plannedDuration() { return "PLANNED-DURATION" in this.attr ? this.attr.decimalFloatingPoint("PLANNED-DURATION") : null; } get endOnNext() { return this.attr.bool("END-ON-NEXT"); } get isValid() { return ( !!this.id && !this._badValueForSameId && X(this.startDate.getTime()) && (null === this.duration || this.duration >= 0) && (!this.endOnNext || !!this.class) ); } } class pt { constructor() { (this.aborted = !1), (this.loaded = 0), (this.retry = 0), (this.total = 0), (this.chunkCount = 0), (this.bwEstimate = 0), (this.loading = { start: 0, first: 0, end: 0 }), (this.parsing = { start: 0, end: 0 }), (this.buffering = { start: 0, first: 0, end: 0 }); } } var ft = "audio", mt = "video", gt = "audiovideo"; class yt { constructor(t) { (this._byteRange = null), (this._url = null), (this.baseurl = void 0), (this.relurl = void 0), (this.elementaryStreams = { [ft]: null, [mt]: null, [gt]: null }), (this.baseurl = t); } setByteRange(t, e) { const n = t.split("@", 2); let i; (i = 1 === n.length ? (null == e ? void 0 : e.byteRangeEndOffset) || 0 : parseInt(n[1])), (this._byteRange = [i, parseInt(n[0]) + i]); } get byteRange() { return this._byteRange ? this._byteRange : []; } get byteRangeStartOffset() { return this.byteRange[0]; } get byteRangeEndOffset() { return this.byteRange[1]; } get url() { return ( !this._url && this.baseurl && this.relurl && (this._url = $.buildAbsoluteURL(this.baseurl, this.relurl, { alwaysNormalize: !0 })), this._url || "" ); } set url(t) { this._url = t; } } class At extends yt { constructor(t, e) { super(e), (this._decryptdata = null), (this.rawProgramDateTime = null), (this.programDateTime = null), (this.tagList = []), (this.duration = 0), (this.sn = 0), (this.levelkeys = void 0), (this.type = void 0), (this.loader = null), (this.keyLoader = null), (this.level = -1), (this.cc = 0), (this.startPTS = void 0), (this.endPTS = void 0), (this.startDTS = void 0), (this.endDTS = void 0), (this.start = 0), (this.deltaPTS = void 0), (this.maxStartPTS = void 0), (this.minEndPTS = void 0), (this.stats = new pt()), (this.data = void 0), (this.bitrateTest = !1), (this.title = null), (this.initSegment = null), (this.endList = void 0), (this.gap = void 0), (this.urlId = 0), (this.type = t); } get decryptdata() { const { levelkeys: t } = this; if (!t && !this._decryptdata) return null; if (!this._decryptdata && this.levelkeys && !this.levelkeys.NONE) { const t = this.levelkeys.identity; if (t) this._decryptdata = t.getDecryptData(this.sn); else { const t = Object.keys(this.levelkeys); if (1 === t.length) return (this._decryptdata = this.levelkeys[t[0]].getDecryptData(this.sn)); } } return this._decryptdata; } get end() { return this.start + this.duration; } get endProgramDateTime() { if (null === this.programDateTime) return null; if (!X(this.programDateTime)) return null; const t = X(this.duration) ? this.duration : 0; return this.programDateTime + 1e3 * t; } get encrypted() { var t; if (null != (t = this._decryptdata) && t.encrypted) return !0; if (this.levelkeys) { const t = Object.keys(this.levelkeys), e = t.length; if (e > 1 || (1 === e && this.levelkeys[t[0]].encrypted)) return !0; } return !1; } setKeyFormat(t) { if (this.levelkeys) { const e = this.levelkeys[t]; e && !this._decryptdata && (this._decryptdata = e.getDecryptData(this.sn)); } } abortRequests() { var t, e; null == (t = this.loader) || t.abort(), null == (e = this.keyLoader) || e.abort(); } setElementaryStreamInfo(t, e, n, i, r, a = !1) { const { elementaryStreams: s } = this, o = s[t]; o ? ((o.startPTS = Math.min(o.startPTS, e)), (o.endPTS = Math.max(o.endPTS, n)), (o.startDTS = Math.min(o.startDTS, i)), (o.endDTS = Math.max(o.endDTS, r))) : (s[t] = { startPTS: e, endPTS: n, startDTS: i, endDTS: r, partial: a }); } clearElementaryStreamInfo() { const { elementaryStreams: t } = this; (t[ft] = null), (t[mt] = null), (t[gt] = null); } } class vt extends yt { constructor(t, e, n, i, r) { super(n), (this.fragOffset = 0), (this.duration = 0), (this.gap = !1), (this.independent = !1), (this.relurl = void 0), (this.fragment = void 0), (this.index = void 0), (this.stats = new pt()), (this.duration = t.decimalFloatingPoint("DURATION")), (this.gap = t.bool("GAP")), (this.independent = t.bool("INDEPENDENT")), (this.relurl = t.enumeratedString("URI")), (this.fragment = e), (this.index = i); const a = t.enumeratedString("BYTERANGE"); a && this.setByteRange(a, r), r && (this.fragOffset = r.fragOffset + r.duration); } get start() { return this.fragment.start + this.fragOffset; } get end() { return this.start + this.duration; } get loaded() { const { elementaryStreams: t } = this; return !!(t.audio || t.video || t.audiovideo); } } class bt { constructor(t) { (this.PTSKnown = !1), (this.alignedSliding = !1), (this.averagetargetduration = void 0), (this.endCC = 0), (this.endSN = 0), (this.fragments = void 0), (this.fragmentHint = void 0), (this.partList = null), (this.dateRanges = void 0), (this.live = !0), (this.ageHeader = 0), (this.advancedDateTime = void 0), (this.updated = !0), (this.advanced = !0), (this.availabilityDelay = void 0), (this.misses = 0), (this.startCC = 0), (this.startSN = 0), (this.startTimeOffset = null), (this.targetduration = 0), (this.totalduration = 0), (this.type = null), (this.url = void 0), (this.m3u8 = ""), (this.version = null), (this.canBlockReload = !1), (this.canSkipUntil = 0), (this.canSkipDateRanges = !1), (this.skippedSegments = 0), (this.recentlyRemovedDateranges = void 0), (this.partHoldBack = 0), (this.holdBack = 0), (this.partTarget = 0), (this.preloadHint = void 0), (this.renditionReports = void 0), (this.tuneInGoal = 0), (this.deltaUpdateFailed = void 0), (this.driftStartTime = 0), (this.driftEndTime = 0), (this.driftStart = 0), (this.driftEnd = 0), (this.encryptedFragments = void 0), (this.playlistParsingError = null), (this.variableList = null), (this.hasVariableRefs = !1), (this.fragments = []), (this.encryptedFragments = []), (this.dateRanges = {}), (this.url = t); } reloaded(t) { if (!t) return (this.advanced = !0), void (this.updated = !0); const e = this.lastPartSn - t.lastPartSn, n = this.lastPartIndex - t.lastPartIndex; (this.updated = this.endSN !== t.endSN || !!n || !!e || !this.live), (this.advanced = this.endSN > t.endSN || e > 0 || (0 === e && n > 0)), this.updated || this.advanced ? (this.misses = Math.floor(0.6 * t.misses)) : (this.misses = t.misses + 1), (this.availabilityDelay = t.availabilityDelay); } get hasProgramDateTime() { return !!this.fragments.length && X(this.fragments[this.fragments.length - 1].programDateTime); } get levelTargetDuration() { return this.averagetargetduration || this.targetduration || 10; } get drift() { const t = this.driftEndTime - this.driftStartTime; if (t > 0) { return (1e3 * (this.driftEnd - this.driftStart)) / t; } return 1; } get edge() { return this.partEnd || this.fragmentEnd; } get partEnd() { var t; return null != (t = this.partList) && t.length ? this.partList[this.partList.length - 1].end : this.fragmentEnd; } get fragmentEnd() { var t; return null != (t = this.fragments) && t.length ? this.fragments[this.fragments.length - 1].end : 0; } get age() { return this.advancedDateTime ? Math.max(Date.now() - this.advancedDateTime, 0) / 1e3 : 0; } get lastPartIndex() { var t; return null != (t = this.partList) && t.length ? this.partList[this.partList.length - 1].index : -1; } get lastPartSn() { var t; return null != (t = this.partList) && t.length ? this.partList[this.partList.length - 1].fragment.sn : this.endSN; } } function Et(t) { return Uint8Array.from(atob(t), t => t.charCodeAt(0)); } function wt(t) { const e = t.split(":"); let n = null; if ("data" === e[0] && 2 === e.length) { const t = e[1].split(";"), i = t[t.length - 1].split(","); if (2 === i.length) { const e = "base64" === i[0], r = i[1]; e ? (t.splice(-1, 1), (n = Et(r))) : (n = (function (t) { const e = xt(t).subarray(0, 16), n = new Uint8Array(16); return n.set(e, 16 - e.length), n; })(r)); } } return n; } function xt(t) { return Uint8Array.from(unescape(encodeURIComponent(t)), t => t.charCodeAt(0)); } const St = "undefined" != typeof self ? self : void 0; var _t = { CLEARKEY: "org.w3.clearkey", FAIRPLAY: "com.apple.fps", PLAYREADY: "com.microsoft.playready", WIDEVINE: "com.widevine.alpha" }, Tt = "org.w3.clearkey", kt = "com.apple.streamingkeydelivery", Ct = "com.microsoft.playready", Lt = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"; function It(t) { switch (t) { case kt: return _t.FAIRPLAY; case Ct: return _t.PLAYREADY; case Lt: return _t.WIDEVINE; case Tt: return _t.CLEARKEY; } } var Rt = "edef8ba979d64acea3c827dcd51d21ed"; function Dt(t) { switch (t) { case _t.FAIRPLAY: return kt; case _t.PLAYREADY: return Ct; case _t.WIDEVINE: return Lt; case _t.CLEARKEY: return Tt; } } function Bt(t) { const { drmSystems: e, widevineLicenseUrl: n } = t, i = e ? [_t.FAIRPLAY, _t.WIDEVINE, _t.PLAYREADY, _t.CLEARKEY].filter(t => !!e[t]) : []; return !i[_t.WIDEVINE] && n && i.push(_t.WIDEVINE), i; } const Pt = null != St && null != (Ut = St.navigator) && Ut.requestMediaKeySystemAccess ? self.navigator.requestMediaKeySystemAccess.bind(self.navigator) : null; var Ut; function Ft(t, e, n) { return Uint8Array.prototype.slice ? t.slice(e, n) : new Uint8Array(Array.prototype.slice.call(t, e, n)); } const Ot = (t, e) => e + 10 <= t.length && 73 === t[e] && 68 === t[e + 1] && 51 === t[e + 2] && t[e + 3] < 255 && t[e + 4] < 255 && t[e + 6] < 128 && t[e + 7] < 128 && t[e + 8] < 128 && t[e + 9] < 128, Mt = (t, e) => e + 10 <= t.length && 51 === t[e] && 68 === t[e + 1] && 73 === t[e + 2] && t[e + 3] < 255 && t[e + 4] < 255 && t[e + 6] < 128 && t[e + 7] < 128 && t[e + 8] < 128 && t[e + 9] < 128, Nt = (t, e) => { const n = e; let i = 0; for (; Ot(t, e);) { i += 10; (i += zt(t, e + 6)), Mt(t, e + 10) && (i += 10), (e += i); } if (i > 0) return t.subarray(n, n + i); }, zt = (t, e) => { let n = 0; return ( (n = (127 & t[e]) << 21), (n |= (127 & t[e + 1]) << 14), (n |= (127 & t[e + 2]) << 7), (n |= 127 & t[e + 3]), n ); }, Gt = (t, e) => Ot(t, e) && zt(t, e + 6) + 10 <= t.length - e, jt = t => { const e = $t(t); for (let t = 0; t < e.length; t++) { const n = e[t]; if (Ht(n)) return Qt(n); } }, Ht = t => t && "PRIV" === t.key && "com.apple.streaming.transportStreamTimestamp" === t.info, Yt = t => { const e = String.fromCharCode(t[0], t[1], t[2], t[3]), n = zt(t, 4); return { type: e, size: n, data: t.subarray(10, 10 + n) }; }, $t = t => { let e = 0; const n = []; for (; Ot(t, e);) { const i = zt(t, e + 6); e += 10; const r = e + i; for (; e + 8 < r;) { const i = Yt(t.subarray(e)), r = Kt(i); r && n.push(r), (e += i.size + 10); } Mt(t, e) && (e += 10); } return n; }, Kt = t => ("PRIV" === t.type ? qt(t) : "W" === t.type[0] ? Wt(t) : Vt(t)), qt = t => { if (t.size < 2) return; const e = Xt(t.data, !0), n = new Uint8Array(t.data.subarray(e.length + 1)); return { key: t.type, info: e, data: n.buffer }; }, Vt = t => { if (t.size < 2) return; if ("TXXX" === t.type) { let e = 1; const n = Xt(t.data.subarray(e), !0); e += n.length + 1; const i = Xt(t.data.subarray(e)); return { key: t.type, info: n, data: i }; } const e = Xt(t.data.subarray(1)); return { key: t.type, data: e }; }, Wt = t => { if ("WXXX" === t.type) { if (t.size < 2) return; let e = 1; const n = Xt(t.data.subarray(e), !0); e += n.length + 1; const i = Xt(t.data.subarray(e)); return { key: t.type, info: n, data: i }; } const e = Xt(t.data); return { key: t.type, data: e }; }, Qt = t => { if (8 === t.data.byteLength) { const e = new Uint8Array(t.data), n = 1 & e[3]; let i = (e[4] << 23) + (e[5] << 15) + (e[6] << 7) + e[7]; return (i /= 45), n && (i += 47721858.84), Math.round(i); } }, Xt = (t, e = !1) => { const n = Zt(); if (n) { const i = n.decode(t); if (e) { const t = i.indexOf("\0"); return -1 !== t ? i.substring(0, t) : i; } return i.replace(/\0/g, ""); } const i = t.length; let r, a, s, o = "", l = 0; for (; l < i;) { if (((r = t[l++]), 0 === r && e)) return o; if (0 !== r && 3 !== r) switch (r >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: o += String.fromCharCode(r); break; case 12: case 13: (a = t[l++]), (o += String.fromCharCode(((31 & r) << 6) | (63 & a))); break; case 14: (a = t[l++]), (s = t[l++]), (o += String.fromCharCode(((15 & r) << 12) | ((63 & a) << 6) | (63 & s))); } } return o; }; let Jt; function Zt() { if (!navigator.userAgent.includes("PlayStation 4")) return Jt || void 0 === self.TextDecoder || (Jt = new self.TextDecoder("utf-8")), Jt; } const te = function (t) { let e = ""; for (let n = 0; n < t.length; n++) { let i = t[n].toString(16); i.length < 2 && (i = "0" + i), (e += i); } return e; }, ee = Math.pow(2, 32) - 1, ne = [].push, ie = { video: 1, audio: 2, id3: 3, text: 4 }; function re(t) { return String.fromCharCode.apply(null, t); } function ae(t, e) { const n = (t[e] << 8) | t[e + 1]; return n < 0 ? 65536 + n : n; } function se(t, e) { const n = le(t, e); return n < 0 ? 4294967296 + n : n; } function oe(t, e) { let n = se(t, e); return (n *= Math.pow(2, 32)), (n += se(t, e + 4)), n; } function le(t, e) { return (t[e] << 24) | (t[e + 1] << 16) | (t[e + 2] << 8) | t[e + 3]; } function de(t, e, n) { (t[e] = n >> 24), (t[e + 1] = (n >> 16) & 255), (t[e + 2] = (n >> 8) & 255), (t[e + 3] = 255 & n); } function ce(t, e) { const n = []; if (!e.length) return n; const i = t.byteLength; for (let r = 0; r < i;) { const a = se(t, r), s = a > 1 ? r + a : i; if (re(t.subarray(r + 4, r + 8)) === e[0]) if (1 === e.length) n.push(t.subarray(r + 8, s)); else { const i = ce(t.subarray(r + 8, s), e.slice(1)); i.length && ne.apply(n, i); } r = s; } return n; } function ue(t) { const e = [], n = t[0]; let i = 8; const r = se(t, i); i += 4; let a = 0, s = 0; 0 === n ? ((a = se(t, i)), (s = se(t, i + 4)), (i += 8)) : ((a = oe(t, i)), (s = oe(t, i + 8)), (i += 16)), (i += 2); let o = t.length + s; const l = ae(t, i); i += 2; for (let n = 0; n < l; n++) { let n = i; const a = se(t, n); n += 4; const s = 2147483647 & a; if (1 === (2147483648 & a) >>> 31) return ot.warn("SIDX has hierarchical references (not supported)"), null; const l = se(t, n); (n += 4), e.push({ referenceSize: s, subsegmentDuration: l, info: { duration: l / r, start: o, end: o + s - 1 } }), (o += s), (n += 4), (i = n); } return { earliestPresentationTime: a, timescale: r, version: n, referencesCount: l, references: e }; } function he(t) { const e = [], n = ce(t, ["moov", "trak"]); for (let t = 0; t < n.length; t++) { const i = n[t], r = ce(i, ["tkhd"])[0]; if (r) { let t = r[0]; const n = se(r, 0 === t ? 12 : 20), a = ce(i, ["mdia", "mdhd"])[0]; if (a) { t = a[0]; const r = se(a, 0 === t ? 12 : 20), s = ce(i, ["mdia", "hdlr"])[0]; if (s) { const t = re(s.subarray(8, 12)), a = { soun: ft, vide: mt }[t]; if (a) { const t = pe(ce(i, ["mdia", "minf", "stbl", "stsd"])[0]); (e[n] = { timescale: r, type: a }), (e[a] = q({ timescale: r, id: n }, t)); } } } } } return ( ce(t, ["moov", "mvex", "trex"]).forEach(t => { const n = se(t, 4), i = e[n]; i && (i.default = { duration: se(t, 12), flags: se(t, 20) }); }), e ); } function pe(t) { const e = t.subarray(8), n = e.subarray(86), i = re(e.subarray(4, 8)); let r = i; const a = "enca" === i || "encv" === i; if (a) { const t = ce(e, [i])[0]; ce(t.subarray("enca" === i ? 28 : 78), ["sinf"]).forEach(t => { const e = ce(t, ["schm"])[0]; if (e) { const n = re(e.subarray(4, 8)); if ("cbcs" === n || "cenc" === n) { const e = ce(t, ["frma"])[0]; e && (r = re(e)); } } }); } switch (r) { case "avc1": case "avc2": case "avc3": case "avc4": { const t = ce(n, ["avcC"])[0]; r += "." + me(t[1]) + me(t[2]) + me(t[3]); break; } case "mp4a": { const t = ce(e, [i])[0], n = ce(t.subarray(28), ["esds"])[0]; if (n && n.length > 12) { let t = 4; if (3 !== n[t++]) break; (t = fe(n, t)), (t += 2); const e = n[t++]; if ((128 & e && (t += 2), 64 & e && (t += n[t++]), 4 !== n[t++])) break; t = fe(n, t); const i = n[t++]; if (64 !== i) break; if (((r += "." + me(i)), (t += 12), 5 !== n[t++])) break; t = fe(n, t); const a = n[t++]; let s = (248 & a) >> 3; 31 === s && (s += 1 + ((7 & a) << 3) + ((224 & n[t]) >> 5)), (r += "." + s); } break; } case "hvc1": case "hev1": { const t = ce(n, ["hvcC"])[0], e = t[1], i = ["", "A", "B", "C"][e >> 6], a = 31 & e, s = se(t, 2), o = (32 & e) >> 5 ? "H" : "L", l = t[12], d = t.subarray(6, 12); (r += "." + i + a), (r += "." + s.toString(16).toUpperCase()), (r += "." + o + l); let c = ""; for (let t = d.length; t--;) { const e = d[t]; if (e || c) { c = "." + e.toString(16).toUpperCase() + c; } } r += c; break; } case "dvh1": case "dvhe": { const t = ce(n, ["dvcC"])[0], e = (t[2] >> 1) & 127, i = ((t[2] << 5) & 32) | ((t[3] >> 3) & 31); r += "." + ge(e) + "." + ge(i); break; } case "vp09": { const t = ce(n, ["vpcC"])[0], e = t[4], i = t[5], a = (t[6] >> 4) & 15; r += "." + ge(e) + "." + ge(i) + "." + ge(a); break; } case "av01": { const t = ce(n, ["av1C"])[0], e = t[1] >>> 5, i = 31 & t[1], a = t[2] >>> 7 ? "H" : "M", s = (64 & t[2]) >> 6, o = (32 & t[2]) >> 5, l = 2 === e && s ? (o ? 12 : 10) : s ? 10 : 8, d = (16 & t[2]) >> 4, c = (8 & t[2]) >> 3, u = (4 & t[2]) >> 2, h = 3 & t[2], p = 1, f = 1, m = 1, g = 0; r += "." + e + "." + ge(i) + a + "." + ge(l) + "." + d + "." + c + u + h + "." + ge(p) + "." + ge(f) + "." + ge(m) + "." + g; break; } } return { codec: r, encrypted: a }; } function fe(t, e) { const n = e + 5; for (; 128 & t[e++] && e < n;); return e; } function me(t) { return ("0" + t.toString(16).toUpperCase()).slice(-2); } function ge(t) { return (t < 10 ? "0" : "") + t; } function ye(t) { const e = ce(t, ["schm"])[0]; if (e) { const n = re(e.subarray(4, 8)); if ("cbcs" === n || "cenc" === n) return ce(t, ["schi", "tenc"])[0]; } return ot.error("[eme] missing 'schm' box"), null; } function Ae(t) { const e = se(t, 0); let n = 8; 1 & e && (n += 4), 4 & e && (n += 4); let i = 0; const r = se(t, 4); for (let a = 0; a < r; a++) { if (256 & e) { (i += se(t, n)), (n += 4); } 512 & e && (n += 4), 1024 & e && (n += 4), 2048 & e && (n += 4); } return i; } function ve(t, e) { const n = new Uint8Array(t.length + e.length); return n.set(t), n.set(e, t.length), n; } function be(t, e) { const n = [], i = e.samples, r = e.timescale, a = e.id; let s = !1; return ( ce(i, ["moof"]).map(o => { const l = o.byteOffset - 8; ce(o, ["traf"]).map(o => { const d = ce(o, ["tfdt"]).map(t => { const e = t[0]; let n = se(t, 4); return 1 === e && ((n *= Math.pow(2, 32)), (n += se(t, 8))), n / r; })[0]; return ( void 0 !== d && (t = d), ce(o, ["tfhd"]).map(d => { const c = se(d, 4), u = 16777215 & se(d, 0); let h = 0; const p = !!(16 & u); let f = 0; const m = !!(32 & u); let g = 8; c === a && (!!(1 & u) && (g += 8), !!(2 & u) && (g += 4), !!(8 & u) && ((h = se(d, g)), (g += 4)), p && ((f = se(d, g)), (g += 4)), m && (g += 4), "video" === e.type && (s = (function (t) { if (!t) return !1; const e = t.indexOf("."), n = e < 0 ? t : t.substring(0, e); return "hvc1" === n || "hev1" === n || "dvh1" === n || "dvhe" === n; })(e.codec)), ce(o, ["trun"]).map(a => { const o = a[0], d = 16777215 & se(a, 0), c = !!(1 & d); let u = 0; const p = !!(4 & d), m = !!(256 & d); let g = 0; const y = !!(512 & d); let A = 0; const v = !!(1024 & d), b = !!(2048 & d); let E = 0; const w = se(a, 4); let x = 8; c && ((u = se(a, x)), (x += 4)), p && (x += 4); let S = u + l; for (let l = 0; l < w; l++) { if ( (m ? ((g = se(a, x)), (x += 4)) : (g = h), y ? ((A = se(a, x)), (x += 4)) : (A = f), v && (x += 4), b && ((E = 0 === o ? se(a, x) : le(a, x)), (x += 4)), e.type === mt) ) { let e = 0; for (; e < A;) { const a = se(i, S); if (((S += 4), Ee(s, i[S]))) { we(i.subarray(S, S + a), s ? 2 : 1, t + E / r, n); } (S += a), (e += a + 4); } } t += g / r; } })); }) ); }); }), n ); } function Ee(t, e) { if (t) { const t = (e >> 1) & 63; return 39 === t || 40 === t; } return 6 === (31 & e); } function we(t, e, n, i) { const r = xe(t); let a = 0; a += e; let s = 0, o = 0, l = 0; for (; a < r.length;) { s = 0; do { if (a >= r.length) break; (l = r[a++]), (s += l); } while (255 === l); o = 0; do { if (a >= r.length) break; (l = r[a++]), (o += l); } while (255 === l); const t = r.length - a; let e = a; if (o < t) a += o; else if (o > t) { ot.error(`Malformed SEI payload. ${o} is too small, only ${t} bytes left to parse.`); break; } if (4 === s) { if (181 === r[e++]) { const t = ae(r, e); if (((e += 2), 49 === t)) { const t = se(r, e); if (((e += 4), 1195456820 === t)) { const t = r[e++]; if (3 === t) { const a = r[e++], o = 64 & a, l = o ? 2 + 3 * (31 & a) : 0, d = new Uint8Array(l); if (o) { d[0] = a; for (let t = 1; t < l; t++) d[t] = r[e++]; } i.push({ type: t, payloadType: s, pts: n, bytes: d }); } } } } } else if (5 === s && o > 16) { const t = []; for (let n = 0; n < 16; n++) { const i = r[e++].toString(16); t.push(1 == i.length ? "0" + i : i), (3 !== n && 5 !== n && 7 !== n && 9 !== n) || t.push("-"); } const a = o - 16, l = new Uint8Array(a); for (let t = 0; t < a; t++) l[t] = r[e++]; i.push({ payloadType: s, pts: n, uuid: t.join(""), userData: Xt(l), userDataBytes: l }); } } } function xe(t) { const e = t.byteLength, n = []; let i = 1; for (; i < e - 2;) 0 === t[i] && 0 === t[i + 1] && 3 === t[i + 2] ? (n.push(i + 2), (i += 2)) : i++; if (0 === n.length) return t; const r = e - n.length, a = new Uint8Array(r); let s = 0; for (i = 0; i < r; s++, i++) s === n[0] && (s++, n.shift()), (a[i] = t[s]); return a; } function Se(t, e, n) { if (16 !== t.byteLength) throw new RangeError("Invalid system id"); let i, r, a; (i = 0), (r = new Uint8Array()), (a = new Uint8Array()); const s = new Uint8Array(4); return ( n && n.byteLength > 0 && new DataView(s.buffer).setUint32(0, n.byteLength, !1), (function (t, ...e) { const n = e.length; let i = 8, r = n; for (; r--;) i += e[r].byteLength; const a = new Uint8Array(i); for ( a[0] = (i >> 24) & 255, a[1] = (i >> 16) & 255, a[2] = (i >> 8) & 255, a[3] = 255 & i, a.set(t, 4), r = 0, i = 8; r < n; r++ ) a.set(e[r], i), (i += e[r].byteLength); return a; })([112, 115, 115, 104], new Uint8Array([0, 0, 0, 0]), t, a, r, s, n || new Uint8Array()) ); } let _e = {}; class Te { static clearKeyUriToKeyIdMap() { _e = {}; } constructor(t, e, n, i = [1], r = null) { (this.uri = void 0), (this.method = void 0), (this.keyFormat = void 0), (this.keyFormatVersions = void 0), (this.encrypted = void 0), (this.isCommonEncryption = void 0), (this.iv = null), (this.key = null), (this.keyId = null), (this.pssh = null), (this.method = t), (this.uri = e), (this.keyFormat = n), (this.keyFormatVersions = i), (this.iv = r), (this.encrypted = !!t && "NONE" !== t), (this.isCommonEncryption = this.encrypted && "AES-128" !== t); } isSupported() { if (this.method) { if ("AES-128" === this.method || "NONE" === this.method) return !0; if ("identity" === this.keyFormat) return "SAMPLE-AES" === this.method; switch (this.keyFormat) { case kt: case Lt: case Ct: case Tt: return -1 !== ["ISO-23001-7", "SAMPLE-AES", "SAMPLE-AES-CENC", "SAMPLE-AES-CTR"].indexOf(this.method); } } return !1; } getDecryptData(t) { if (!this.encrypted || !this.uri) return null; if ("AES-128" === this.method && this.uri && !this.iv) { "number" != typeof t && ("AES-128" !== this.method || this.iv || ot.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`), (t = 0)); const e = (function (t) { const e = new Uint8Array(16); for (let n = 12; n < 16; n++) e[n] = (t >> (8 * (15 - n))) & 255; return e; })(t); return new Te(this.method, this.uri, "identity", this.keyFormatVersions, e); } const e = wt(this.uri); if (e) switch (this.keyFormat) { case Lt: (this.pssh = e), e.length >= 22 && (this.keyId = e.subarray(e.length - 22, e.length - 6)); break; case Ct: { const t = new Uint8Array([154, 4, 240, 121, 152, 64, 66, 134, 171, 146, 230, 91, 224, 136, 95, 149]); this.pssh = Se(t, 0, e); const n = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2), i = String.fromCharCode.apply(null, Array.from(n)), r = i.substring(i.indexOf("<"), i.length), a = new DOMParser().parseFromString(r, "text/xml").getElementsByTagName("KID")[0]; if (a) { const t = a.childNodes[0] ? a.childNodes[0].nodeValue : a.getAttribute("VALUE"); if (t) { const e = Et(t).subarray(0, 16); !(function (t) { const e = function (t, e, n) { const i = t[e]; (t[e] = t[n]), (t[n] = i); }; e(t, 0, 3), e(t, 1, 2), e(t, 4, 5), e(t, 6, 7); })(e), (this.keyId = e); } } break; } default: { let t = e.subarray(0, 16); if (16 !== t.length) { const e = new Uint8Array(16); e.set(t, 16 - t.length), (t = e); } this.keyId = t; break; } } if (!this.keyId || 16 !== this.keyId.byteLength) { let t = _e[this.uri]; if (!t) { const e = Object.keys(_e).length % Number.MAX_SAFE_INTEGER; t = new Uint8Array(16); new DataView(t.buffer, 12, 4).setUint32(0, e), (_e[this.uri] = t); } this.keyId = t; } return this; } } const ke = /\{\$([a-zA-Z0-9-_]+)\}/g; function Ce(t) { return ke.test(t); } function Le(t, e, n) { if (null !== t.variableList || t.hasVariableRefs) for (let i = n.length; i--;) { const r = n[i], a = e[r]; a && (e[r] = Ie(t, a)); } } function Ie(t, e) { if (null !== t.variableList || t.hasVariableRefs) { const n = t.variableList; return e.replace(ke, e => { const i = e.substring(2, e.length - 1), r = null == n ? void 0 : n[i]; return void 0 === r ? (t.playlistParsingError || (t.playlistParsingError = new Error( `Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"` )), e) : r; }); } return e; } function Re(t, e, n) { let i, r, a = t.variableList; if ((a || (t.variableList = a = {}), "QUERYPARAM" in e)) { i = e.QUERYPARAM; try { const t = new self.URL(n).searchParams; if (!t.has(i)) throw new Error(`"${i}" does not match any query parameter in URI: "${n}"`); r = t.get(i); } catch (e) { t.playlistParsingError || (t.playlistParsingError = new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`)); } } else (i = e.NAME), (r = e.VALUE); i in a ? t.playlistParsingError || (t.playlistParsingError = new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)) : (a[i] = r || ""); } function De(t, e, n) { const i = e.IMPORT; if (n && i in n) { let e = t.variableList; e || (t.variableList = e = {}), (e[i] = n[i]); } else t.playlistParsingError || (t.playlistParsingError = new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`)); } function Be(t = !0) { if ("undefined" == typeof self) return; return ((t || !self.MediaSource) && self.ManagedMediaSource) || self.MediaSource || self.WebKitMediaSource; } const Pe = { audio: { a3ds: 1, "ac-3": 0.95, "ac-4": 1, alac: 0.9, alaw: 1, dra1: 1, "dts+": 1, "dts-": 1, dtsc: 1, dtse: 1, dtsh: 1, "ec-3": 0.9, enca: 1, fLaC: 0.9, flac: 0.9, FLAC: 0.9, g719: 1, g726: 1, m4ae: 1, mha1: 1, mha2: 1, mhm1: 1, mhm2: 1, mlpa: 1, mp4a: 1, "raw ": 1, Opus: 1, opus: 1, samr: 1, sawb: 1, sawp: 1, sevc: 1, sqcp: 1, ssmv: 1, twos: 1, ulaw: 1 }, video: { avc1: 1, avc2: 1, avc3: 1, avc4: 1, avcp: 1, av01: 0.8, drac: 1, dva1: 1, dvav: 1, dvh1: 0.7, dvhe: 0.7, encv: 1, hev1: 0.75, hvc1: 0.75, mjp2: 1, mp4v: 1, mvc1: 1, mvc2: 1, mvc3: 1, mvc4: 1, resv: 1, rv60: 1, s263: 1, svc1: 1, svc2: 1, "vc-1": 1, vp08: 1, vp09: 0.9 }, text: { stpp: 1, wvtt: 1 } }; function Ue(t, e, n = !0) { return !t.split(",").some(t => !Fe(t, e, n)); } function Fe(t, e, n = !0) { var i; const r = Be(n); return null != (i = null == r ? void 0 : r.isTypeSupported(Oe(t, e))) && i; } function Oe(t, e) { return `${e}/mp4;codecs="${t}"`; } function Me(t) { if (t) { const e = t.substring(0, 4); return Pe.video[e]; } return 2; } function Ne(t) { return t.split(",").reduce((t, e) => { const n = Pe.video[e]; return n ? (2 * n + t) / (t ? 3 : 2) : (Pe.audio[e] + t) / (t ? 2 : 1); }, 0); } const ze = {}; const Ge = /flac|opus/i; function je(t, e = !0) { return t.replace(Ge, t => (function (t, e = !0) { if (ze[t]) return ze[t]; const n = { flac: ["flac", "fLaC", "FLAC"], opus: ["opus", "Opus"] }[t]; for (let i = 0; i < n.length; i++) if (Fe(n[i], "audio", e)) return (ze[t] = n[i]), n[i]; return t; })(t.toLowerCase(), e) ); } function He(t, e) { return t && "mp4a" !== t ? t : e ? e.split(",")[0] : e; } const Ye = /#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g, $e = /#EXT-X-MEDIA:(.*)/g, Ke = /^#EXT(?:INF|-X-TARGETDURATION):/m, qe = new RegExp( [ /#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source, /(?!#) *(\S[\S ]*)/.source, /#EXT-X-BYTERANGE:*(.+)/.source, /#EXT-X-PROGRAM-DATE-TIME:(.+)/.source, /#.*/.source ].join("|"), "g" ), Ve = new RegExp( [ /#(EXTM3U)/.source, /#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/ .source, /#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source, /#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source, /(#)([^:]*):(.*)/.source, /(#)(.*)(?:.*)\r?\n?/.source ].join("|") ); class We { static findGroup(t, e) { for (let n = 0; n < t.length; n++) { const i = t[n]; if (i.id === e) return i; } } static resolve(t, e) { return $.buildAbsoluteURL(e, t, { alwaysNormalize: !0 }); } static isMediaPlaylist(t) { return Ke.test(t); } static parseMasterPlaylist(t, e) { const n = { contentSteering: null, levels: [], playlistParsingError: null, sessionData: null, sessionKeys: null, startTimeOffset: null, variableList: null, hasVariableRefs: Ce(t) }, i = []; let r; for (Ye.lastIndex = 0; null != (r = Ye.exec(t));) if (r[1]) { var a; const t = new ct(r[1]); Le(n, t, [ "CODECS", "SUPPLEMENTAL-CODECS", "ALLOWED-CPC", "PATHWAY-ID", "STABLE-VARIANT-ID", "AUDIO", "VIDEO", "SUBTITLES", "CLOSED-CAPTIONS", "NAME" ]); const s = Ie(n, r[2]), o = { attrs: t, bitrate: t.decimalInteger("BANDWIDTH") || t.decimalInteger("AVERAGE-BANDWIDTH"), name: t.NAME, url: We.resolve(s, e) }, l = t.decimalResolution("RESOLUTION"); l && ((o.width = l.width), (o.height = l.height)), Je(t.CODECS, o), (null != (a = o.unknownCodecs) && a.length) || i.push(o), n.levels.push(o); } else if (r[3]) { const t = r[3], i = r[4]; switch (t) { case "SESSION-DATA": { const t = new ct(i); Le(n, t, ["DATA-ID", "LANGUAGE", "VALUE", "URI"]); const e = t["DATA-ID"]; e && (null === n.sessionData && (n.sessionData = {}), (n.sessionData[e] = t)); break; } case "SESSION-KEY": { const t = Qe(i, e, n); t.encrypted && t.isSupported() ? (null === n.sessionKeys && (n.sessionKeys = []), n.sessionKeys.push(t)) : ot.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`); break; } case "DEFINE": { const t = new ct(i); Le(n, t, ["NAME", "VALUE", "QUERYPARAM"]), Re(n, t, e); } break; case "CONTENT-STEERING": { const t = new ct(i); Le(n, t, ["SERVER-URI", "PATHWAY-ID"]), (n.contentSteering = { uri: We.resolve(t["SERVER-URI"], e), pathwayId: t["PATHWAY-ID"] || "." }); break; } case "START": n.startTimeOffset = Xe(i); } } const s = i.length > 0 && i.length < n.levels.length; return ( (n.levels = s ? i : n.levels), 0 === n.levels.length && (n.playlistParsingError = new Error("no levels found in manifest")), n ); } static parseMasterPlaylistMedia(t, e, n) { let i; const r = {}, a = n.levels, s = { AUDIO: a.map(t => ({ id: t.attrs.AUDIO, audioCodec: t.audioCodec })), SUBTITLES: a.map(t => ({ id: t.attrs.SUBTITLES, textCodec: t.textCodec })), "CLOSED-CAPTIONS": [] }; let o = 0; for ($e.lastIndex = 0; null !== (i = $e.exec(t));) { const t = new ct(i[1]), a = t.TYPE; if (a) { const i = s[a], l = r[a] || []; (r[a] = l), Le(n, t, [ "URI", "GROUP-ID", "LANGUAGE", "ASSOC-LANGUAGE", "STABLE-RENDITION-ID", "NAME", "INSTREAM-ID", "CHARACTERISTICS", "CHANNELS" ]); const d = t.LANGUAGE, c = t["ASSOC-LANGUAGE"], u = t.CHANNELS, h = t.CHARACTERISTICS, p = t["INSTREAM-ID"], f = { attrs: t, bitrate: 0, id: o++, groupId: t["GROUP-ID"] || "", name: t.NAME || d || "", type: a, default: t.bool("DEFAULT"), autoselect: t.bool("AUTOSELECT"), forced: t.bool("FORCED"), lang: d, url: t.URI ? We.resolve(t.URI, e) : "" }; if ( (c && (f.assocLang = c), u && (f.channels = u), h && (f.characteristics = h), p && (f.instreamId = p), null != i && i.length) ) { const t = We.findGroup(i, f.groupId) || i[0]; Ze(f, t, "audioCodec"), Ze(f, t, "textCodec"); } l.push(f); } } return r; } static parseLevelPlaylist(t, e, n, i, r, a) { const s = new bt(e), o = s.fragments; let l, d, c, u = null, h = 0, p = 0, f = 0, m = 0, g = null, y = new At(i, e), A = -1, v = !1, b = null; for (qe.lastIndex = 0, s.m3u8 = t, s.hasVariableRefs = Ce(t); null !== (l = qe.exec(t));) { v && ((v = !1), (y = new At(i, e)), (y.start = f), (y.sn = h), (y.cc = m), (y.level = n), u && ((y.initSegment = u), (y.rawProgramDateTime = u.rawProgramDateTime), (u.rawProgramDateTime = null), b && (y.setByteRange(b), (b = null)))); const t = l[1]; if (t) { y.duration = parseFloat(t); const e = (" " + l[2]).slice(1); (y.title = e || null), y.tagList.push(e ? ["INF", t, e] : ["INF", t]); } else if (l[3]) { if (X(y.duration)) { (y.start = f), c && nn(y, c, s), (y.sn = h), (y.level = n), (y.cc = m), o.push(y); const t = (" " + l[3]).slice(1); (y.relurl = Ie(s, t)), tn(y, g), (g = y), (f += y.duration), h++, (p = 0), (v = !0); } } else if (l[4]) { const t = (" " + l[4]).slice(1); g ? y.setByteRange(t, g) : y.setByteRange(t); } else if (l[5]) (y.rawProgramDateTime = (" " + l[5]).slice(1)), y.tagList.push(["PROGRAM-DATE-TIME", y.rawProgramDateTime]), -1 === A && (A = o.length); else { if (((l = l[0].match(Ve)), !l)) { ot.warn("No matches on slow regex match for level playlist!"); continue; } for (d = 1; d < l.length && void 0 === l[d]; d++); const t = (" " + l[d]).slice(1), r = (" " + l[d + 1]).slice(1), f = l[d + 2] ? (" " + l[d + 2]).slice(1) : ""; switch (t) { case "PLAYLIST-TYPE": s.type = r.toUpperCase(); break; case "MEDIA-SEQUENCE": h = s.startSN = parseInt(r); break; case "SKIP": { const t = new ct(r); Le(s, t, ["RECENTLY-REMOVED-DATERANGES"]); const e = t.decimalInteger("SKIPPED-SEGMENTS"); if (X(e)) { s.skippedSegments = e; for (let t = e; t--;) o.unshift(null); h += e; } const n = t.enumeratedString("RECENTLY-REMOVED-DATERANGES"); n && (s.recentlyRemovedDateranges = n.split("\t")); break; } case "TARGETDURATION": s.targetduration = Math.max(parseInt(r), 1); break; case "VERSION": s.version = parseInt(r); break; case "INDEPENDENT-SEGMENTS": case "EXTM3U": break; case "ENDLIST": s.live = !1; break; case "#": (r || f) && y.tagList.push(f ? [r, f] : [r]); break; case "DISCONTINUITY": m++, y.tagList.push(["DIS"]); break; case "GAP": (y.gap = !0), y.tagList.push([t]); break; case "BITRATE": y.tagList.push([t, r]); break; case "DATERANGE": { const t = new ct(r); Le(s, t, ["ID", "CLASS", "START-DATE", "END-DATE", "SCTE35-CMD", "SCTE35-OUT", "SCTE35-IN"]), Le(s, t, t.clientAttrs); const e = new ht(t, s.dateRanges[t.ID]); e.isValid || s.skippedSegments ? (s.dateRanges[e.id] = e) : ot.warn(`Ignoring invalid DATERANGE tag: "${r}"`), y.tagList.push(["EXT-X-DATERANGE", r]); break; } case "DEFINE": { const t = new ct(r); Le(s, t, ["NAME", "VALUE", "IMPORT", "QUERYPARAM"]), "IMPORT" in t ? De(s, t, a) : Re(s, t, e); } break; case "DISCONTINUITY-SEQUENCE": m = parseInt(r); break; case "KEY": { const t = Qe(r, e, s); if (t.isSupported()) { if ("NONE" === t.method) { c = void 0; break; } c || (c = {}), c[t.keyFormat] && (c = Q({}, c)), (c[t.keyFormat] = t); } else ot.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${r}"`); break; } case "START": s.startTimeOffset = Xe(r); break; case "MAP": { const t = new ct(r); if ((Le(s, t, ["BYTERANGE", "URI"]), y.duration)) { const r = new At(i, e); en(r, t, n, c), (u = r), (y.initSegment = u), u.rawProgramDateTime && !y.rawProgramDateTime && (y.rawProgramDateTime = u.rawProgramDateTime); } else { const e = y.byteRangeEndOffset; if (e) { const t = y.byteRangeStartOffset; b = `${e - t}@${t}`; } else b = null; en(y, t, n, c), (u = y), (v = !0); } break; } case "SERVER-CONTROL": { const t = new ct(r); (s.canBlockReload = t.bool("CAN-BLOCK-RELOAD")), (s.canSkipUntil = t.optionalFloat("CAN-SKIP-UNTIL", 0)), (s.canSkipDateRanges = s.canSkipUntil > 0 && t.bool("CAN-SKIP-DATERANGES")), (s.partHoldBack = t.optionalFloat("PART-HOLD-BACK", 0)), (s.holdBack = t.optionalFloat("HOLD-BACK", 0)); break; } case "PART-INF": { const t = new ct(r); s.partTarget = t.decimalFloatingPoint("PART-TARGET"); break; } case "PART": { let t = s.partList; t || (t = s.partList = []); const n = p > 0 ? t[t.length - 1] : void 0, i = p++, a = new ct(r); Le(s, a, ["BYTERANGE", "URI"]); const o = new vt(a, y, e, i, n); t.push(o), (y.duration += o.duration); break; } case "PRELOAD-HINT": { const t = new ct(r); Le(s, t, ["URI"]), (s.preloadHint = t); break; } case "RENDITION-REPORT": { const t = new ct(r); Le(s, t, ["URI"]), (s.renditionReports = s.renditionReports || []), s.renditionReports.push(t); break; } default: ot.warn(`line parsed but not handled: ${l}`); } } } g && !g.relurl ? (o.pop(), (f -= g.duration), s.partList && (s.fragmentHint = g)) : s.partList && (tn(y, g), (y.cc = m), (s.fragmentHint = y), c && nn(y, c, s)); const E = o.length, w = o[0], x = o[E - 1]; if (((f += s.skippedSegments * s.targetduration), f > 0 && E && x)) { s.averagetargetduration = f / E; const t = x.sn; (s.endSN = "initSegment" !== t ? t : 0), s.live || (x.endList = !0), w && (s.startCC = w.cc); } else (s.endSN = 0), (s.startCC = 0); return ( s.fragmentHint && (f += s.fragmentHint.duration), (s.totalduration = f), (s.endCC = m), A > 0 && (function (t, e) { let n = t[e]; for (let i = e; i--;) { const e = t[i]; if (!e) return; (e.programDateTime = n.programDateTime - 1e3 * e.duration), (n = e); } })(o, A), s ); } } function Qe(t, e, n) { var i, r; const a = new ct(t); Le(n, a, ["KEYFORMAT", "KEYFORMATVERSIONS", "URI", "IV", "URI"]); const s = null != (i = a.METHOD) ? i : "", o = a.URI, l = a.hexadecimalInteger("IV"), d = a.KEYFORMATVERSIONS, c = null != (r = a.KEYFORMAT) ? r : "identity"; o && a.IV && !l && ot.error(`Invalid IV: ${a.IV}`); const u = o ? We.resolve(o, e) : "", h = (d || "1").split("/").map(Number).filter(Number.isFinite); return new Te(s, u, c, h, l); } function Xe(t) { const e = new ct(t).decimalFloatingPoint("TIME-OFFSET"); return X(e) ? e : null; } function Je(t, e) { let n = (t || "").split(/[ ,]+/).filter(t => t); ["video", "audio", "text"].forEach(t => { const i = n.filter(e => (function (t, e) { const n = Pe[e]; return !!n && !!n[t.slice(0, 4)]; })(e, t) ); i.length && ((e[`${t}Codec`] = i.join(",")), (n = n.filter(t => -1 === i.indexOf(t)))); }), (e.unknownCodecs = n); } function Ze(t, e, n) { const i = e[n]; i && (t[n] = i); } function tn(t, e) { t.rawProgramDateTime ? (t.programDateTime = Date.parse(t.rawProgramDateTime)) : null != e && e.programDateTime && (t.programDateTime = e.endProgramDateTime), X(t.programDateTime) || ((t.programDateTime = null), (t.rawProgramDateTime = null)); } function en(t, e, n, i) { (t.relurl = e.URI), e.BYTERANGE && t.setByteRange(e.BYTERANGE), (t.level = n), (t.sn = "initSegment"), i && (t.levelkeys = i), (t.initSegment = null); } function nn(t, e, n) { t.levelkeys = e; const { encryptedFragments: i } = n; (i.length && i[i.length - 1].levelkeys === e) || !Object.keys(e).some(t => e[t].isCommonEncryption) || i.push(t); } var rn = "manifest", an = "level", sn = "audioTrack", on = "subtitleTrack", ln = "main", dn = "audio", cn = "subtitle"; function un(t) { const { type: e } = t; switch (e) { case sn: return dn; case on: return cn; default: return ln; } } function hn(t, e) { let n = t.url; return (void 0 !== n && 0 !== n.indexOf("data:")) || (n = e.url), n; } class pn { constructor(t) { (this.hls = void 0), (this.loaders = Object.create(null)), (this.variableList = null), (this.hls = t), this.registerListeners(); } startLoad(t) { } stopLoad() { this.destroyInternalLoaders(); } registerListeners() { const { hls: t } = this; t.on(tt.MANIFEST_LOADING, this.onManifestLoading, this), t.on(tt.LEVEL_LOADING, this.onLevelLoading, this), t.on(tt.AUDIO_TRACK_LOADING, this.onAudioTrackLoading, this), t.on(tt.SUBTITLE_TRACK_LOADING, this.onSubtitleTrackLoading, this); } unregisterListeners() { const { hls: t } = this; t.off(tt.MANIFEST_LOADING, this.onManifestLoading, this), t.off(tt.LEVEL_LOADING, this.onLevelLoading, this), t.off(tt.AUDIO_TRACK_LOADING, this.onAudioTrackLoading, this), t.off(tt.SUBTITLE_TRACK_LOADING, this.onSubtitleTrackLoading, this); } createInternalLoader(t) { const e = this.hls.config, n = e.pLoader, i = e.loader, r = new (n || i)(e); return (this.loaders[t.type] = r), r; } getInternalLoader(t) { return this.loaders[t.type]; } resetInternalLoader(t) { this.loaders[t] && delete this.loaders[t]; } destroyInternalLoaders() { for (const t in this.loaders) { const e = this.loaders[t]; e && e.destroy(), this.resetInternalLoader(t); } } destroy() { (this.variableList = null), this.unregisterListeners(), this.destroyInternalLoaders(); } onManifestLoading(t, e) { const { url: n } = e; (this.variableList = null), this.load({ id: null, level: 0, responseType: "text", type: rn, url: n, deliveryDirectives: null }); } onLevelLoading(t, e) { const { id: n, level: i, pathwayId: r, url: a, deliveryDirectives: s } = e; this.load({ id: n, level: i, pathwayId: r, responseType: "text", type: an, url: a, deliveryDirectives: s }); } onAudioTrackLoading(t, e) { const { id: n, groupId: i, url: r, deliveryDirectives: a } = e; this.load({ id: n, groupId: i, level: null, responseType: "text", type: sn, url: r, deliveryDirectives: a }); } onSubtitleTrackLoading(t, e) { const { id: n, groupId: i, url: r, deliveryDirectives: a } = e; this.load({ id: n, groupId: i, level: null, responseType: "text", type: on, url: r, deliveryDirectives: a }); } load(t) { var e; const n = this.hls.config; let i, r = this.getInternalLoader(t); if (r) { const e = r.context; if (e && e.url === t.url && e.level === t.level) return void ot.trace("[playlist-loader]: playlist request ongoing"); ot.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`), r.abort(); } if ( ((i = t.type === rn ? n.manifestLoadPolicy.default : Q({}, n.playlistLoadPolicy.default, { timeoutRetry: null, errorRetry: null })), (r = this.createInternalLoader(t)), X(null == (e = t.deliveryDirectives) ? void 0 : e.part)) ) { let e; if ( (t.type === an && null !== t.level ? (e = this.hls.levels[t.level].details) : t.type === sn && null !== t.id ? (e = this.hls.audioTracks[t.id].details) : t.type === on && null !== t.id && (e = this.hls.subtitleTracks[t.id].details), e) ) { const t = e.partTarget, n = e.targetduration; if (t && n) { const e = 1e3 * Math.max(3 * t, 0.8 * n); i = Q({}, i, { maxTimeToFirstByteMs: Math.min(e, i.maxTimeToFirstByteMs), maxLoadTimeMs: Math.min(e, i.maxTimeToFirstByteMs) }); } } } const a = i.errorRetry || i.timeoutRetry || {}, s = { loadPolicy: i, timeout: i.maxLoadTimeMs, maxRetry: a.maxNumRetry || 0, retryDelay: a.retryDelayMs || 0, maxRetryDelay: a.maxRetryDelayMs || 0 }, o = { onSuccess: (t, e, n, i) => { const r = this.getInternalLoader(n); this.resetInternalLoader(n.type); const a = t.data; 0 === a.indexOf("#EXTM3U") ? ((e.parsing.start = performance.now()), We.isMediaPlaylist(a) ? this.handleTrackOrLevelPlaylist(t, e, n, i || null, r) : this.handleMasterPlaylist(t, e, n, i)) : this.handleManifestParsingError(t, n, new Error("no EXTM3U delimiter"), i || null, e); }, onError: (t, e, n, i) => { this.handleNetworkError(e, n, !1, t, i); }, onTimeout: (t, e, n) => { this.handleNetworkError(e, n, !0, void 0, t); } }; r.load(t, s, o); } handleMasterPlaylist(t, e, n, i) { const r = this.hls, a = t.data, s = hn(t, n), o = We.parseMasterPlaylist(a, s); if (o.playlistParsingError) return void this.handleManifestParsingError(t, n, o.playlistParsingError, i, e); const { contentSteering: l, levels: d, sessionData: c, sessionKeys: u, startTimeOffset: h, variableList: p } = o; this.variableList = p; const { AUDIO: f = [], SUBTITLES: m, "CLOSED-CAPTIONS": g } = We.parseMasterPlaylistMedia(a, s, o); if (f.length) { f.some(t => !t.url) || !d[0].audioCodec || d[0].attrs.AUDIO || (ot.log( "[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one" ), f.unshift({ type: "main", name: "main", groupId: "main", default: !1, autoselect: !1, forced: !1, id: -1, attrs: new ct({}), bitrate: 0, url: "" })); } r.trigger(tt.MANIFEST_LOADED, { levels: d, audioTracks: f, subtitles: m, captions: g, contentSteering: l, url: s, stats: e, networkDetails: i, sessionData: c, sessionKeys: u, startTimeOffset: h, variableList: p }); } handleTrackOrLevelPlaylist(t, e, n, i, r) { const a = this.hls, { id: s, level: o, type: l } = n, d = hn(t, n), c = X(o) ? o : X(s) ? s : 0, u = un(n), h = We.parseLevelPlaylist(t.data, d, c, u, 0, this.variableList); if (l === rn) { const t = { attrs: new ct({}), bitrate: 0, details: h, name: "", url: d }; a.trigger(tt.MANIFEST_LOADED, { levels: [t], audioTracks: [], url: d, stats: e, networkDetails: i, sessionData: null, sessionKeys: null, contentSteering: null, startTimeOffset: null, variableList: null }); } (e.parsing.end = performance.now()), (n.levelDetails = h), this.handlePlaylistLoaded(h, t, e, n, i, r); } handleManifestParsingError(t, e, n, i, r) { this.hls.trigger(tt.ERROR, { type: et.NETWORK_ERROR, details: nt.MANIFEST_PARSING_ERROR, fatal: e.type === rn, url: t.url, err: n, error: n, reason: n.message, response: t, context: e, networkDetails: i, stats: r }); } handleNetworkError(t, e, n = !1, i, r) { let a = `A network ${n ? "timeout" : "error" + (i ? " (status " + i.code + ")" : "")} occurred while loading ${t.type }`; t.type === an ? (a += `: ${t.level} id: ${t.id}`) : (t.type !== sn && t.type !== on) || (a += ` id: ${t.id} group-id: "${t.groupId}"`); const s = new Error(a); ot.warn(`[playlist-loader]: ${a}`); let o = nt.UNKNOWN, l = !1; const d = this.getInternalLoader(t); switch (t.type) { case rn: (o = n ? nt.MANIFEST_LOAD_TIMEOUT : nt.MANIFEST_LOAD_ERROR), (l = !0); break; case an: (o = n ? nt.LEVEL_LOAD_TIMEOUT : nt.LEVEL_LOAD_ERROR), (l = !1); break; case sn: (o = n ? nt.AUDIO_TRACK_LOAD_TIMEOUT : nt.AUDIO_TRACK_LOAD_ERROR), (l = !1); break; case on: (o = n ? nt.SUBTITLE_TRACK_LOAD_TIMEOUT : nt.SUBTITLE_LOAD_ERROR), (l = !1); } d && this.resetInternalLoader(t.type); const c = { type: et.NETWORK_ERROR, details: o, fatal: l, url: t.url, loader: d, context: t, error: s, networkDetails: e, stats: r }; if (i) { const n = (null == e ? void 0 : e.url) || t.url; c.response = q({ url: n, data: void 0 }, i); } this.hls.trigger(tt.ERROR, c); } handlePlaylistLoaded(t, e, n, i, r, a) { const s = this.hls, { type: o, level: l, id: d, groupId: c, deliveryDirectives: u } = i, h = hn(e, i), p = un(i), f = "number" == typeof i.level && p === ln ? l : void 0; if (!t.fragments.length) { const t = new Error("No Segments found in Playlist"); return void s.trigger(tt.ERROR, { type: et.NETWORK_ERROR, details: nt.LEVEL_EMPTY_ERROR, fatal: !1, url: h, error: t, reason: t.message, response: e, context: i, level: f, parent: p, networkDetails: r, stats: n }); } t.targetduration || (t.playlistParsingError = new Error("Missing Target Duration")); const m = t.playlistParsingError; if (m) s.trigger(tt.ERROR, { type: et.NETWORK_ERROR, details: nt.LEVEL_PARSING_ERROR, fatal: !1, url: h, error: m, reason: m.message, response: e, context: i, level: f, parent: p, networkDetails: r, stats: n }); else switch ( (t.live && a && (a.getCacheAge && (t.ageHeader = a.getCacheAge() || 0), (a.getCacheAge && !isNaN(t.ageHeader)) || (t.ageHeader = 0)), o) ) { case rn: case an: s.trigger(tt.LEVEL_LOADED, { details: t, level: f || 0, id: d || 0, stats: n, networkDetails: r, deliveryDirectives: u }); break; case sn: s.trigger(tt.AUDIO_TRACK_LOADED, { details: t, id: d || 0, groupId: c || "", stats: n, networkDetails: r, deliveryDirectives: u }); break; case on: s.trigger(tt.SUBTITLE_TRACK_LOADED, { details: t, id: d || 0, groupId: c || "", stats: n, networkDetails: r, deliveryDirectives: u }); } } } function fn(t, e) { let n; try { n = new Event("addtrack"); } catch (t) { (n = document.createEvent("Event")), n.initEvent("addtrack", !1, !1); } (n.track = t), e.dispatchEvent(n); } function mn(t, e) { const n = t.mode; if (("disabled" === n && (t.mode = "hidden"), t.cues && !t.cues.getCueById(e.id))) try { if ((t.addCue(e), !t.cues.getCueById(e.id))) throw new Error(`addCue is failed for: ${e}`); } catch (n) { ot.debug(`[texttrack-utils]: ${n}`); try { const n = new self.TextTrackCue(e.startTime, e.endTime, e.text); (n.id = e.id), t.addCue(n); } catch (t) { ot.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`); } } "disabled" === n && (t.mode = n); } function gn(t) { const e = t.mode; if (("disabled" === e && (t.mode = "hidden"), t.cues)) for (let e = t.cues.length; e--;) t.removeCue(t.cues[e]); "disabled" === e && (t.mode = e); } function yn(t, e, n, i) { const r = t.mode; if (("disabled" === r && (t.mode = "hidden"), t.cues && t.cues.length > 0)) { const r = (function (t, e, n) { const i = [], r = (function (t, e) { if (e < t[0].startTime) return 0; const n = t.length - 1; if (e > t[n].endTime) return -1; let i = 0, r = n; for (; i <= r;) { const a = Math.floor((r + i) / 2); if (e < t[a].startTime) r = a - 1; else { if (!(e > t[a].startTime && i < n)) return a; i = a + 1; } } return t[i].startTime - e < e - t[r].startTime ? i : r; })(t, e); if (r > -1) for (let a = r, s = t.length; a < s; a++) { const r = t[a]; if (r.startTime >= e && r.endTime <= n) i.push(r); else if (r.startTime > n) return i; } return i; })(t.cues, e, n); for (let e = 0; e < r.length; e++) (i && !i(r[e])) || t.removeCue(r[e]); } "disabled" === r && (t.mode = r); } function An(t) { const e = []; for (let n = 0; n < t.length; n++) { const i = t[n]; ("subtitles" !== i.kind && "captions" !== i.kind) || !i.label || e.push(t[n]); } return e; } var vn = "org.id3", bn = "com.apple.quicktime.HLS", En = "https://aomedia.org/emsg/ID3"; function wn() { if ("undefined" != typeof self) return self.VTTCue || self.TextTrackCue; } function xn(t, e, n, i, r) { let a = new t(e, n, ""); try { (a.value = i), r && (a.type = r); } catch (s) { a = new t(e, n, JSON.stringify(r ? q({ type: r }, i) : i)); } return a; } const Sn = (() => { const t = wn(); try { t && new t(0, Number.POSITIVE_INFINITY, ""); } catch (t) { return Number.MAX_VALUE; } return Number.POSITIVE_INFINITY; })(); function _n(t, e) { return t.getTime() / 1e3 - e; } class Tn { constructor(t) { (this.hls = void 0), (this.id3Track = null), (this.media = null), (this.dateRangeCuesAppended = {}), (this.hls = t), this._registerListeners(); } destroy() { this._unregisterListeners(), (this.id3Track = null), (this.media = null), (this.dateRangeCuesAppended = {}), (this.hls = null); } _registerListeners() { const { hls: t } = this; t.on(tt.MEDIA_ATTACHED, this.onMediaAttached, this), t.on(tt.MEDIA_DETACHING, this.onMediaDetaching, this), t.on(tt.MANIFEST_LOADING, this.onManifestLoading, this), t.on(tt.FRAG_PARSING_METADATA, this.onFragParsingMetadata, this), t.on(tt.BUFFER_FLUSHING, this.onBufferFlushing, this), t.on(tt.LEVEL_UPDATED, this.onLevelUpdated, this); } _unregisterListeners() { const { hls: t } = this; t.off(tt.MEDIA_ATTACHED, this.onMediaAttached, this), t.off(tt.MEDIA_DETACHING, this.onMediaDetaching, this), t.off(tt.MANIFEST_LOADING, this.onManifestLoading, this), t.off(tt.FRAG_PARSING_METADATA, this.onFragParsingMetadata, this), t.off(tt.BUFFER_FLUSHING, this.onBufferFlushing, this), t.off(tt.LEVEL_UPDATED, this.onLevelUpdated, this); } onMediaAttached(t, e) { this.media = e.media; } onMediaDetaching() { this.id3Track && (gn(this.id3Track), (this.id3Track = null), (this.media = null), (this.dateRangeCuesAppended = {})); } onManifestLoading() { this.dateRangeCuesAppended = {}; } createTrack(t) { const e = this.getID3Track(t.textTracks); return (e.mode = "hidden"), e; } getID3Track(t) { if (this.media) { for (let e = 0; e < t.length; e++) { const n = t[e]; if ("metadata" === n.kind && "id3" === n.label) return fn(n, this.media), n; } return this.media.addTextTrack("metadata", "id3"); } } onFragParsingMetadata(t, e) { if (!this.media) return; const { hls: { config: { enableEmsgMetadataCues: n, enableID3MetadataCues: i } } } = this; if (!n && !i) return; const { samples: r } = e; this.id3Track || (this.id3Track = this.createTrack(this.media)); const a = wn(); if (a) for (let t = 0; t < r.length; t++) { const e = r[t].type; if ((e === En && !n) || !i) continue; const s = $t(r[t].data); if (s) { const n = r[t].pts; let i = n + r[t].duration; i > Sn && (i = Sn); i - n <= 0 && (i = n + 0.25); for (let t = 0; t < s.length; t++) { const r = s[t]; if (!Ht(r)) { this.updateId3CueEnds(n, e); const t = xn(a, n, i, r, e); t && this.id3Track.addCue(t); } } } } } updateId3CueEnds(t, e) { var n; const i = null == (n = this.id3Track) ? void 0 : n.cues; if (i) for (let n = i.length; n--;) { const r = i[n]; r.type === e && r.startTime < t && r.endTime === Sn && (r.endTime = t); } } onBufferFlushing(t, { startOffset: e, endOffset: n, type: i }) { const { id3Track: r, hls: a } = this; if (!a) return; const { config: { enableEmsgMetadataCues: s, enableID3MetadataCues: o } } = a; if (r && (s || o)) { let t; (t = "audio" === i ? t => t.type === vn && o : "video" === i ? t => t.type === En && s : t => (t.type === vn && o) || (t.type === En && s)), yn(r, e, n, t); } } onLevelUpdated(t, { details: e }) { if (!this.media || !e.hasProgramDateTime || !this.hls.config.enableDateRangeMetadataCues) return; const { dateRangeCuesAppended: n, id3Track: i } = this, { dateRanges: r } = e, a = Object.keys(r); if (i) { const t = Object.keys(n).filter(t => !a.includes(t)); for (let e = t.length; e--;) { const r = t[e]; Object.keys(n[r].cues).forEach(t => { i.removeCue(n[r].cues[t]); }), delete n[r]; } } const s = e.fragments[e.fragments.length - 1]; if (0 === a.length || !X(null == s ? void 0 : s.programDateTime)) return; this.id3Track || (this.id3Track = this.createTrack(this.media)); const o = s.programDateTime / 1e3 - s.start, l = wn(); for (let t = 0; t < a.length; t++) { const e = a[t], i = r[e], s = _n(i.startDate, o), u = n[e], h = (null == u ? void 0 : u.cues) || {}; let p = (null == u ? void 0 : u.durationKnown) || !1, f = Sn; const m = i.endDate; if (m) (f = _n(m, o)), (p = !0); else if (i.endOnNext && !p) { const t = a.reduce((t, e) => { if (e !== i.id) { const n = r[e]; if (n.class === i.class && n.startDate > i.startDate && (!t || i.startDate < t.startDate)) return n; } return t; }, null); t && ((f = _n(t.startDate, o)), (p = !0)); } const g = Object.keys(i.attr); for (let t = 0; t < g.length; t++) { const n = g[t]; if ( "ID" === (c = n) || "CLASS" === c || "START-DATE" === c || "DURATION" === c || "END-DATE" === c || "END-ON-NEXT" === c ) continue; const r = h[n]; if (r) p && !u.durationKnown && (r.endTime = f); else if (l) { let t = i.attr[n]; ut(n) && ((d = t), (t = Uint8Array.from( d .replace(/^0x/, "") .replace(/([\da-fA-F]{2}) ?/g, "0x$1 ") .replace(/ +$/, "") .split(" ") ).buffer)); const r = xn(l, s, f, { key: n, data: t }, bn); r && ((r.id = e), this.id3Track.addCue(r), (h[n] = r)); } } n[e] = { cues: h, dateRange: i, durationKnown: p }; } var d, c; } } class kn { constructor(t) { (this.hls = void 0), (this.config = void 0), (this.media = null), (this.levelDetails = null), (this.currentTime = 0), (this.stallCount = 0), (this._latency = null), (this.timeupdateHandler = () => this.timeupdate()), (this.hls = t), (this.config = t.config), this.registerListeners(); } get latency() { return this._latency || 0; } get maxLatency() { const { config: t, levelDetails: e } = this; return void 0 !== t.liveMaxLatencyDuration ? t.liveMaxLatencyDuration : e ? t.liveMaxLatencyDurationCount * e.targetduration : 0; } get targetLatency() { const { levelDetails: t } = this; if (null === t) return null; const { holdBack: e, partHoldBack: n, targetduration: i } = t, { liveSyncDuration: r, liveSyncDurationCount: a, lowLatencyMode: s } = this.config, o = this.hls.userConfig; let l = (s && n) || e; (o.liveSyncDuration || o.liveSyncDurationCount || 0 === l) && (l = void 0 !== r ? r : a * i); const d = i; return l + Math.min(1 * this.stallCount, d); } get liveSyncPosition() { const t = this.estimateLiveEdge(), e = this.targetLatency, n = this.levelDetails; if (null === t || null === e || null === n) return null; const i = n.edge, r = t - e - this.edgeStalled, a = i - n.totalduration, s = i - ((this.config.lowLatencyMode && n.partTarget) || n.targetduration); return Math.min(Math.max(a, r), s); } get drift() { const { levelDetails: t } = this; return null === t ? 1 : t.drift; } get edgeStalled() { const { levelDetails: t } = this; if (null === t) return 0; const e = 3 * ((this.config.lowLatencyMode && t.partTarget) || t.targetduration); return Math.max(t.age - e, 0); } get forwardBufferLength() { const { media: t, levelDetails: e } = this; if (!t || !e) return 0; const n = t.buffered.length; return (n ? t.buffered.end(n - 1) : e.edge) - this.currentTime; } destroy() { this.unregisterListeners(), this.onMediaDetaching(), (this.levelDetails = null), (this.hls = this.timeupdateHandler = null); } registerListeners() { this.hls.on(tt.MEDIA_ATTACHED, this.onMediaAttached, this), this.hls.on(tt.MEDIA_DETACHING, this.onMediaDetaching, this), this.hls.on(tt.MANIFEST_LOADING, this.onManifestLoading, this), this.hls.on(tt.LEVEL_UPDATED, this.onLevelUpdated, this), this.hls.on(tt.ERROR, this.onError, this); } unregisterListeners() { this.hls.off(tt.MEDIA_ATTACHED, this.onMediaAttached, this), this.hls.off(tt.MEDIA_DETACHING, this.onMediaDetaching, this), this.hls.off(tt.MANIFEST_LOADING, this.onManifestLoading, this), this.hls.off(tt.LEVEL_UPDATED, this.onLevelUpdated, this), this.hls.off(tt.ERROR, this.onError, this); } onMediaAttached(t, e) { (this.media = e.media), this.media.addEventListener("timeupdate", this.timeupdateHandler); } onMediaDetaching() { this.media && (this.media.removeEventListener("timeupdate", this.timeupdateHandler), (this.media = null)); } onManifestLoading() { (this.levelDetails = null), (this._latency = null), (this.stallCount = 0); } onLevelUpdated(t, { details: e }) { (this.levelDetails = e), e.advanced && this.timeupdate(), !e.live && this.media && this.media.removeEventListener("timeupdate", this.timeupdateHandler); } onError(t, e) { var n; e.details === nt.BUFFER_STALLED_ERROR && (this.stallCount++, null != (n = this.levelDetails) && n.live && ot.warn("[playback-rate-controller]: Stall detected, adjusting target latency")); } timeupdate() { const { media: t, levelDetails: e } = this; if (!t || !e) return; this.currentTime = t.currentTime; const n = this.computeLatency(); if (null === n) return; this._latency = n; const { lowLatencyMode: i, maxLiveSyncPlaybackRate: r } = this.config; if (!i || 1 === r || !e.live) return; const a = this.targetLatency; if (null === a) return; const s = n - a; if (s < Math.min(this.maxLatency, a + e.targetduration) && s > 0.05 && this.forwardBufferLength > 1) { const e = Math.min(2, Math.max(1, r)), n = Math.round((2 / (1 + Math.exp(-0.75 * s - this.edgeStalled))) * 20) / 20; t.playbackRate = Math.min(e, Math.max(1, n)); } else 1 !== t.playbackRate && 0 !== t.playbackRate && (t.playbackRate = 1); } estimateLiveEdge() { const { levelDetails: t } = this; return null === t ? null : t.edge + t.age; } computeLatency() { const t = this.estimateLiveEdge(); return null === t ? null : t - this.currentTime; } } const Cn = ["NONE", "TYPE-0", "TYPE-1", null]; const Ln = ["SDR", "PQ", "HLG"]; var In = "", Rn = "YES", Dn = "v2"; function Bn(t) { const { canSkipUntil: e, canSkipDateRanges: n, age: i } = t; return e && i < e / 2 ? (n ? Dn : Rn) : In; } class Pn { constructor(t, e, n) { (this.msn = void 0), (this.part = void 0), (this.skip = void 0), (this.msn = t), (this.part = e), (this.skip = n); } addDirectives(t) { const e = new self.URL(t); return ( void 0 !== this.msn && e.searchParams.set("_HLS_msn", this.msn.toString()), void 0 !== this.part && e.searchParams.set("_HLS_part", this.part.toString()), this.skip && e.searchParams.set("_HLS_skip", this.skip), e.href ); } } class Un { constructor(t) { (this._attrs = void 0), (this.audioCodec = void 0), (this.bitrate = void 0), (this.codecSet = void 0), (this.url = void 0), (this.frameRate = void 0), (this.height = void 0), (this.id = void 0), (this.name = void 0), (this.videoCodec = void 0), (this.width = void 0), (this.details = void 0), (this.fragmentError = 0), (this.loadError = 0), (this.loaded = void 0), (this.realBitrate = 0), (this.supportedPromise = void 0), (this.supportedResult = void 0), (this._avgBitrate = 0), (this._audioGroups = void 0), (this._subtitleGroups = void 0), (this._urlId = 0), (this.url = [t.url]), (this._attrs = [t.attrs]), (this.bitrate = t.bitrate), t.details && (this.details = t.details), (this.id = t.id || 0), (this.name = t.name), (this.width = t.width || 0), (this.height = t.height || 0), (this.frameRate = t.attrs.optionalFloat("FRAME-RATE", 0)), (this._avgBitrate = t.attrs.decimalInteger("AVERAGE-BANDWIDTH")), (this.audioCodec = t.audioCodec), (this.videoCodec = t.videoCodec), (this.codecSet = [t.videoCodec, t.audioCodec] .filter(t => !!t) .map(t => t.substring(0, 4)) .join(",")), this.addGroupId("audio", t.attrs.AUDIO), this.addGroupId("text", t.attrs.SUBTITLES); } get maxBitrate() { return Math.max(this.realBitrate, this.bitrate); } get averageBitrate() { return this._avgBitrate || this.realBitrate || this.bitrate; } get attrs() { return this._attrs[0]; } get codecs() { return this.attrs.CODECS || ""; } get pathwayId() { return this.attrs["PATHWAY-ID"] || "."; } get videoRange() { return this.attrs["VIDEO-RANGE"] || "SDR"; } get score() { return this.attrs.optionalFloat("SCORE", 0); } get uri() { return this.url[0] || ""; } hasAudioGroup(t) { return Fn(this._audioGroups, t); } hasSubtitleGroup(t) { return Fn(this._subtitleGroups, t); } get audioGroups() { return this._audioGroups; } get subtitleGroups() { return this._subtitleGroups; } addGroupId(t, e) { if (e) if ("audio" === t) { let t = this._audioGroups; t || (t = this._audioGroups = []), -1 === t.indexOf(e) && t.push(e); } else if ("text" === t) { let t = this._subtitleGroups; t || (t = this._subtitleGroups = []), -1 === t.indexOf(e) && t.push(e); } } get urlId() { return 0; } set urlId(t) { } get audioGroupIds() { return this.audioGroups ? [this.audioGroupId] : void 0; } get textGroupIds() { return this.subtitleGroups ? [this.textGroupId] : void 0; } get audioGroupId() { var t; return null == (t = this.audioGroups) ? void 0 : t[0]; } get textGroupId() { var t; return null == (t = this.subtitleGroups) ? void 0 : t[0]; } addFallback() { } } function Fn(t, e) { return !(!e || !t) && -1 !== t.indexOf(e); } function On(t, e) { const n = e.startPTS; if (X(n)) { let i, r = 0; e.sn > t.sn ? ((r = n - t.start), (i = t)) : ((r = t.start - n), (i = e)), i.duration !== r && (i.duration = r); } else if (e.sn > t.sn) { t.cc === e.cc && t.minEndPTS ? (e.start = t.start + (t.minEndPTS - t.start)) : (e.start = t.start + t.duration); } else e.start = Math.max(t.start - e.duration, 0); } function Mn(t, e, n, i, r, a) { i - n <= 0 && (ot.warn("Fragment should have a positive duration", e), (i = n + e.duration), (a = r + e.duration)); let s = n, o = i; const l = e.startPTS, d = e.endPTS; if (X(l)) { const t = Math.abs(l - n); X(e.deltaPTS) ? (e.deltaPTS = Math.max(t, e.deltaPTS)) : (e.deltaPTS = t), (s = Math.max(n, l)), (n = Math.min(n, l)), (r = Math.min(r, e.startDTS)), (o = Math.min(i, d)), (i = Math.max(i, d)), (a = Math.max(a, e.endDTS)); } const c = n - e.start; 0 !== e.start && (e.start = n), (e.duration = i - e.start), (e.startPTS = n), (e.maxStartPTS = s), (e.startDTS = r), (e.endPTS = i), (e.minEndPTS = o), (e.endDTS = a); const u = e.sn; if (!t || u < t.startSN || u > t.endSN) return 0; let h; const p = u - t.startSN, f = t.fragments; for (f[p] = e, h = p; h > 0; h--) On(f[h], f[h - 1]); for (h = p; h < f.length - 1; h++) On(f[h], f[h + 1]); return t.fragmentHint && On(f[f.length - 1], t.fragmentHint), (t.PTSKnown = t.alignedSliding = !0), c; } function Nn(t, e) { let n = null; const i = t.fragments; for (let t = i.length - 1; t >= 0; t--) { const e = i[t].initSegment; if (e) { n = e; break; } } t.fragmentHint && delete t.fragmentHint.endPTS; let r, a = 0; if ( ((function (t, e, n) { const i = e.skippedSegments, r = Math.max(t.startSN, e.startSN) - e.startSN, a = (t.fragmentHint ? 1 : 0) + (i ? e.endSN : Math.min(t.endSN, e.endSN)) - e.startSN, s = e.startSN - t.startSN, o = e.fragmentHint ? e.fragments.concat(e.fragmentHint) : e.fragments, l = t.fragmentHint ? t.fragments.concat(t.fragmentHint) : t.fragments; for (let t = r; t <= a; t++) { const r = l[s + t]; let a = o[t]; i && !a && t < i && (a = e.fragments[t] = r), r && a && n(r, a); } })(t, e, (t, i) => { t.relurl && (a = t.cc - i.cc), X(t.startPTS) && X(t.endPTS) && ((i.start = i.startPTS = t.startPTS), (i.startDTS = t.startDTS), (i.maxStartPTS = t.maxStartPTS), (i.endPTS = t.endPTS), (i.endDTS = t.endDTS), (i.minEndPTS = t.minEndPTS), (i.duration = t.endPTS - t.startPTS), i.duration && (r = i), (e.PTSKnown = e.alignedSliding = !0)), (i.elementaryStreams = t.elementaryStreams), (i.loader = t.loader), (i.stats = t.stats), t.initSegment && ((i.initSegment = t.initSegment), (n = t.initSegment)); }), n) ) { (e.fragmentHint ? e.fragments.concat(e.fragmentHint) : e.fragments).forEach(t => { var e; !t || (t.initSegment && t.initSegment.relurl !== (null == (e = n) ? void 0 : e.relurl)) || (t.initSegment = n); }); } if (e.skippedSegments) if (((e.deltaUpdateFailed = e.fragments.some(t => !t)), e.deltaUpdateFailed)) { ot.warn("[level-helper] Previous playlist missing segments skipped in delta playlist"); for (let t = e.skippedSegments; t--;) e.fragments.shift(); (e.startSN = e.fragments[0].sn), (e.startCC = e.fragments[0].cc); } else e.canSkipDateRanges && (e.dateRanges = (function (t, e, n) { const i = Q({}, t); n && n.forEach(t => { delete i[t]; }); return ( Object.keys(e).forEach(t => { const n = new ht(e[t].attr, i[t]); n.isValid ? (i[t] = n) : ot.warn( `Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[t].attr)}"` ); }), i ); })(t.dateRanges, e.dateRanges, e.recentlyRemovedDateranges)); const s = e.fragments; if (a) { ot.warn("discontinuity sliding from playlist, take drift into account"); for (let t = 0; t < s.length; t++) s[t].cc += a; } e.skippedSegments && (e.startCC = e.fragments[0].cc), (function (t, e, n) { if (t && e) { let i = 0; for (let r = 0, a = t.length; r <= a; r++) { const a = t[r], s = e[r + i]; a && s && a.index === s.index && a.fragment.sn === s.fragment.sn ? n(a, s) : i--; } } })(t.partList, e.partList, (t, e) => { (e.elementaryStreams = t.elementaryStreams), (e.stats = t.stats); }), r ? Mn(e, r, r.startPTS, r.endPTS, r.startDTS, r.endDTS) : zn(t, e), s.length && (e.totalduration = e.edge - s[0].start), (e.driftStartTime = t.driftStartTime), (e.driftStart = t.driftStart); const o = e.advancedDateTime; if (e.advanced && o) { const t = e.edge; e.driftStart || ((e.driftStartTime = o), (e.driftStart = t)), (e.driftEndTime = o), (e.driftEnd = t); } else (e.driftEndTime = t.driftEndTime), (e.driftEnd = t.driftEnd), (e.advancedDateTime = t.advancedDateTime); } function zn(t, e) { const n = e.startSN + e.skippedSegments - t.startSN, i = t.fragments; n < 0 || n >= i.length || Gn(e, i[n].start); } function Gn(t, e) { if (e) { const n = t.fragments; for (let i = t.skippedSegments; i < n.length; i++) n[i].start += e; t.fragmentHint && (t.fragmentHint.start += e); } } function jn(t, e, n) { var i; return null != t && t.details ? Hn(null == (i = t.details) ? void 0 : i.partList, e, n) : null; } function Hn(t, e, n) { if (t) for (let i = t.length; i--;) { const r = t[i]; if (r.index === n && r.fragment.sn === e) return r; } return null; } function Yn(t) { t.forEach((t, e) => { const { details: n } = t; null != n && n.fragments && n.fragments.forEach(t => { t.level = e; }); }); } function $n(t) { switch (t.details) { case nt.FRAG_LOAD_TIMEOUT: case nt.KEY_LOAD_TIMEOUT: case nt.LEVEL_LOAD_TIMEOUT: case nt.MANIFEST_LOAD_TIMEOUT: return !0; } return !1; } function Kn(t, e) { const n = $n(e); return t.default[(n ? "timeout" : "error") + "Retry"]; } function qn(t, e) { const n = "linear" === t.backoff ? 1 : Math.pow(2, e); return Math.min(n * t.retryDelayMs, t.maxRetryDelayMs); } function Vn(t) { return q(q({}, t), { errorRetry: null, timeoutRetry: null }); } function Wn(t, e, n, i) { if (!t) return !1; const r = null == i ? void 0 : i.code, a = e < t.maxNumRetry && ((function (t) { return (0 === t && !1 === navigator.onLine) || (!!t && (t < 400 || t > 499)); })(r) || !!n); return t.shouldRetry ? t.shouldRetry(t, e, n, i, a) : a; } const Qn = function (t, e) { let n = 0, i = t.length - 1, r = null, a = null; for (; n <= i;) { (r = ((n + i) / 2) | 0), (a = t[r]); const s = e(a); if (s > 0) n = r + 1; else { if (!(s < 0)) return a; i = r - 1; } } return null; }; function Xn(t, e, n = 0, i = 0) { let r = null; if (t) { r = e[t.sn - e[0].sn + 1] || null; const i = t.endDTS - n; i > 0 && i < 15e-7 && (n += 15e-7); } else 0 === n && 0 === e[0].start && (r = e[0]); if (r && (!t || t.level === r.level) && 0 === Jn(n, i, r)) return r; const a = Qn(e, Jn.bind(null, n, i)); return !a || (a === t && r) ? r : a; } function Jn(t = 0, e = 0, n) { if (n.start <= t && n.start + n.duration > t) return 0; const i = Math.min(e, n.duration + (n.deltaPTS ? n.deltaPTS : 0)); return n.start + n.duration - i <= t ? 1 : n.start - i > t && n.start ? -1 : 0; } function Zn(t, e, n) { const i = 1e3 * Math.min(e, n.duration + (n.deltaPTS ? n.deltaPTS : 0)); return (n.endProgramDateTime || 0) - i > t; } var ti = 0, ei = 2, ni = 3, ii = 5, ri = 0, ai = 1, si = 2; class oi { constructor(t, e) { (this.hls = void 0), (this.timer = -1), (this.requestScheduled = -1), (this.canLoad = !1), (this.log = void 0), (this.warn = void 0), (this.log = ot.log.bind(ot, `${e}:`)), (this.warn = ot.warn.bind(ot, `${e}:`)), (this.hls = t); } destroy() { this.clearTimer(), (this.hls = this.log = this.warn = null); } clearTimer() { -1 !== this.timer && (self.clearTimeout(this.timer), (this.timer = -1)); } startLoad() { (this.canLoad = !0), (this.requestScheduled = -1), this.loadPlaylist(); } stopLoad() { (this.canLoad = !1), this.clearTimer(); } switchParams(t, e, n) { const i = null == e ? void 0 : e.renditionReports; if (i) { let r = -1; for (let n = 0; n < i.length; n++) { const a = i[n]; let s; try { s = new self.URL(a.URI, e.url).href; } catch (t) { ot.warn(`Could not construct new URL for Rendition Report: ${t}`), (s = a.URI || ""); } if (s === t) { r = n; break; } s === t.substring(0, s.length) && (r = n); } if (-1 !== r) { const t = i[r], a = parseInt(t["LAST-MSN"]) || (null == e ? void 0 : e.lastPartSn); let s = parseInt(t["LAST-PART"]) || (null == e ? void 0 : e.lastPartIndex); if (this.hls.config.lowLatencyMode) { const t = Math.min(e.age - e.partTarget, e.targetduration); s >= 0 && t > e.partTarget && (s += 1); } const o = n && Bn(n); return new Pn(a, s >= 0 ? s : void 0, o); } } } loadPlaylist(t) { -1 === this.requestScheduled && (this.requestScheduled = self.performance.now()); } shouldLoadPlaylist(t) { return this.canLoad && !!t && !!t.url && (!t.details || t.details.live); } shouldReloadPlaylist(t) { return -1 === this.timer && -1 === this.requestScheduled && this.shouldLoadPlaylist(t); } playlistLoaded(t, e, n) { const { details: i, stats: r } = e, a = self.performance.now(), s = r.loading.first ? Math.max(0, a - r.loading.first) : 0; if (((i.advancedDateTime = Date.now() - s), i.live || (null != n && n.live))) { if ( (i.reloaded(n), n && this.log( `live playlist ${t} ${i.advanced ? "REFRESHED " + i.lastPartSn + "-" + i.lastPartIndex : i.updated ? "UPDATED" : "MISSED" }` ), n && i.fragments.length > 0 && Nn(n, i), !this.canLoad || !i.live) ) return; let s, o, l; if (i.canBlockReload && i.endSN && i.advanced) { const t = this.hls.config.lowLatencyMode, r = i.lastPartSn, a = i.endSN, d = i.lastPartIndex, c = r === a; -1 !== d ? ((o = c ? a + 1 : r), (l = c ? (t ? 0 : d) : d + 1)) : (o = a + 1); const u = i.age, h = u + i.ageHeader; let p = Math.min(h - i.partTarget, 1.5 * i.targetduration); if (p > 0) { if (n && p > n.tuneInGoal) this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${p} with playlist age: ${i.age}`), (p = 0); else { const t = Math.floor(p / i.targetduration); if (((o += t), void 0 !== l)) { l += Math.round((p % i.targetduration) / i.partTarget); } this.log( `CDN Tune-in age: ${i.ageHeader}s last advanced ${u.toFixed( 2 )}s goal: ${p} skip sn ${t} to part ${l}` ); } i.tuneInGoal = p; } if (((s = this.getDeliveryDirectives(i, e.deliveryDirectives, o, l)), t || !c)) return void this.loadPlaylist(s); } else (i.canBlockReload || i.canSkipUntil) && (s = this.getDeliveryDirectives(i, e.deliveryDirectives, o, l)); const d = this.hls.mainForwardBufferInfo, c = d ? d.end - d.len : 0, u = (function (t, e = 1 / 0) { let n = 1e3 * t.targetduration; if (t.updated) { const i = t.fragments, r = 4; if (i.length && n * r > e) { const t = 1e3 * i[i.length - 1].duration; t < n && (n = t); } } else n /= 2; return Math.round(n); })(i, 1e3 * (i.edge - c)); i.updated && a > this.requestScheduled + u && (this.requestScheduled = r.loading.start), void 0 !== o && i.canBlockReload ? (this.requestScheduled = r.loading.first + u - (1e3 * i.partTarget || 1e3)) : -1 === this.requestScheduled || this.requestScheduled + u < a ? (this.requestScheduled = a) : this.requestScheduled - a <= 0 && (this.requestScheduled += u); let h = this.requestScheduled - a; (h = Math.max(0, h)), this.log(`reload live playlist ${t} in ${Math.round(h)} ms`), (this.timer = self.setTimeout(() => this.loadPlaylist(s), h)); } else this.clearTimer(); } getDeliveryDirectives(t, e, n, i) { let r = Bn(t); return null != e && e.skip && t.deltaUpdateFailed && ((n = e.msn), (i = e.part), (r = In)), new Pn(n, i, r); } checkRetry(t) { const e = t.details, n = $n(t), i = t.errorAction, { action: r, retryCount: a = 0, retryConfig: s } = i || {}, o = !!i && !!s && (r === ii || (!i.resolved && r === ei)); if (o) { var l; if (((this.requestScheduled = -1), a >= s.maxNumRetry)) return !1; if (n && null != (l = t.context) && l.deliveryDirectives) this.warn(`Retrying playlist loading ${a + 1}/${s.maxNumRetry} after "${e}" without delivery-directives`), this.loadPlaylist(); else { const t = qn(s, a); (this.timer = self.setTimeout(() => this.loadPlaylist(), t)), this.warn(`Retrying playlist loading ${a + 1}/${s.maxNumRetry} after "${e}" in ${t}ms`); } (t.levelRetry = !0), (i.resolved = !0); } return o; } } class li { constructor(t, e = 0, n = 0) { (this.halfLife = void 0), (this.alpha_ = void 0), (this.estimate_ = void 0), (this.totalWeight_ = void 0), (this.halfLife = t), (this.alpha_ = t ? Math.exp(Math.log(0.5) / t) : 0), (this.estimate_ = e), (this.totalWeight_ = n); } sample(t, e) { const n = Math.pow(this.alpha_, t); (this.estimate_ = e * (1 - n) + n * this.estimate_), (this.totalWeight_ += t); } getTotalWeight() { return this.totalWeight_; } getEstimate() { if (this.alpha_) { const t = 1 - Math.pow(this.alpha_, this.totalWeight_); if (t) return this.estimate_ / t; } return this.estimate_; } } class di { constructor(t, e, n, i = 100) { (this.defaultEstimate_ = void 0), (this.minWeight_ = void 0), (this.minDelayMs_ = void 0), (this.slow_ = void 0), (this.fast_ = void 0), (this.defaultTTFB_ = void 0), (this.ttfb_ = void 0), (this.defaultEstimate_ = n), (this.minWeight_ = 0.001), (this.minDelayMs_ = 50), (this.slow_ = new li(t)), (this.fast_ = new li(e)), (this.defaultTTFB_ = i), (this.ttfb_ = new li(t)); } update(t, e) { const { slow_: n, fast_: i, ttfb_: r } = this; n.halfLife !== t && (this.slow_ = new li(t, n.getEstimate(), n.getTotalWeight())), i.halfLife !== e && (this.fast_ = new li(e, i.getEstimate(), i.getTotalWeight())), r.halfLife !== t && (this.ttfb_ = new li(t, r.getEstimate(), r.getTotalWeight())); } sample(t, e) { const n = (t = Math.max(t, this.minDelayMs_)) / 1e3, i = (8 * e) / n; this.fast_.sample(n, i), this.slow_.sample(n, i); } sampleTTFB(t) { const e = t / 1e3, n = Math.sqrt(2) * Math.exp(-Math.pow(e, 2) / 2); this.ttfb_.sample(n, Math.max(t, 5)); } canEstimate() { return this.fast_.getTotalWeight() >= this.minWeight_; } getEstimate() { return this.canEstimate() ? Math.min(this.fast_.getEstimate(), this.slow_.getEstimate()) : this.defaultEstimate_; } getEstimateTTFB() { return this.ttfb_.getTotalWeight() >= this.minWeight_ ? this.ttfb_.getEstimate() : this.defaultTTFB_; } destroy() { } } const ci = { supported: !0, configurations: [], decodingInfoResults: [{ supported: !0, powerEfficient: !0, smooth: !0 }] }, ui = {}; function hi(t, e, n, i, r, a) { const s = t.audioCodec ? t.audioGroups : null, o = null == a ? void 0 : a.audioCodec, l = null == a ? void 0 : a.channels, d = l ? parseInt(l) : o ? 1 / 0 : 2; let c = null; if (null != s && s.length) try { c = 1 === s.length && s[0] ? e.groups[s[0]].channels : s.reduce( (t, n) => { if (n) { const i = e.groups[n]; if (!i) throw new Error(`Audio track group ${n} not found`); Object.keys(i.channels).forEach(e => { t[e] = (t[e] || 0) + i.channels[e]; }); } return t; }, { 2: 0 } ); } catch (t) { return !0; } return ( (void 0 !== t.videoCodec && ((t.width > 1920 && t.height > 1088) || (t.height > 1920 && t.width > 1088) || t.frameRate > Math.max(i, 30) || ("SDR" !== t.videoRange && t.videoRange !== n) || t.bitrate > Math.max(r, 8e6))) || (!!c && X(d) && Object.keys(c).some(t => parseInt(t) > d)) ); } function pi(t, e, n) { const i = t.videoCodec, r = t.audioCodec; if (!i || !r || !n) return Promise.resolve(ci); const a = { width: t.width, height: t.height, bitrate: Math.ceil(Math.max(0.9 * t.bitrate, t.averageBitrate)), framerate: t.frameRate || 30 }, s = t.videoRange; "SDR" !== s && (a.transferFunction = s.toLowerCase()); const o = i.split(",").map(t => ({ type: "media-source", video: q(q({}, a), {}, { contentType: Oe(t, "video") }) })); return ( r && t.audioGroups && t.audioGroups.forEach(t => { var n; t && (null == (n = e.groups[t]) || n.tracks.forEach(e => { if (e.groupId === t) { const t = e.channels || "", n = parseFloat(t); X(n) && n > 2 && o.push.apply( o, r .split(",") .map(t => ({ type: "media-source", audio: { contentType: Oe(t, "audio"), channels: "" + n } })) ); } })); }), Promise.all( o.map(t => { const e = (function (t) { const { audio: e, video: n } = t, i = n || e; if (i) { const t = i.contentType.split('"')[1]; if (n) return `r${n.height}x${n.width}f${Math.ceil(n.framerate)}${n.transferFunction || "sd" }_${t}_${Math.ceil(n.bitrate / 1e5)}`; if (e) return `c${e.channels}${e.spatialRendering ? "s" : "n"}_${t}`; } return ""; })(t); return ui[e] || (ui[e] = n.decodingInfo(t)); }) ) .then(t => ({ supported: !t.some(t => !t.supported), configurations: o, decodingInfoResults: t })) .catch(t => ({ supported: !1, configurations: o, decodingInfoResults: [], error: t })) ); } function fi(t, e) { let n = !1, i = []; return ( t && ((n = "SDR" !== t), (i = [t])), e && ((i = e.allowedVideoRanges || Ln.slice(0)), (n = void 0 !== e.preferHDR ? e.preferHDR : (function () { if ("function" == typeof matchMedia) { const t = matchMedia("(dynamic-range: high)"), e = matchMedia("bad query"); if (t.media !== e.media) return !0 === t.matches; } return !1; })()), (i = n ? i.filter(t => "SDR" !== t) : ["SDR"])), { preferHDR: n, allowedVideoRanges: i } ); } function mi(t, e) { ot.log(`[abr] start candidates with "${t}" ignored because ${e}`); } function gi(t, e, n) { if ("attrs" in t) { const n = e.indexOf(t); if (-1 !== n) return n; } for (let i = 0; i < e.length; i++) { if (yi(t, e[i], n)) return i; } return -1; } function yi(t, e, n) { const { groupId: i, name: r, lang: a, assocLang: s, characteristics: o, default: l } = t, d = t.forced; return ( (void 0 === i || e.groupId === i) && (void 0 === r || e.name === r) && (void 0 === a || e.lang === a) && (void 0 === a || e.assocLang === s) && (void 0 === l || e.default === l) && (void 0 === d || e.forced === d) && (void 0 === o || (function (t, e = "") { const n = t.split(","), i = e.split(","); return n.length === i.length && !n.some(t => -1 === i.indexOf(t)); })(o, e.characteristics)) && (void 0 === n || n(t, e)) ); } function Ai(t, e) { const { audioCodec: n, channels: i } = t; return !( (void 0 !== n && (e.audioCodec || "").substring(0, 4) !== n.substring(0, 4)) || (void 0 !== i && i !== (e.channels || "2")) ); } function vi(t, e, n) { for (let i = e; i; i--) if (n(t[i])) return i; for (let i = e + 1; i < t.length; i++) if (n(t[i])) return i; return -1; } class bi { constructor() { (this._boundTick = void 0), (this._tickTimer = null), (this._tickInterval = null), (this._tickCallCount = 0), (this._boundTick = this.tick.bind(this)); } destroy() { this.onHandlerDestroying(), this.onHandlerDestroyed(); } onHandlerDestroying() { this.clearNextTick(), this.clearInterval(); } onHandlerDestroyed() { } hasInterval() { return !!this._tickInterval; } hasNextTick() { return !!this._tickTimer; } setInterval(t) { return ( !this._tickInterval && ((this._tickCallCount = 0), (this._tickInterval = self.setInterval(this._boundTick, t)), !0) ); } clearInterval() { return !!this._tickInterval && (self.clearInterval(this._tickInterval), (this._tickInterval = null), !0); } clearNextTick() { return !!this._tickTimer && (self.clearTimeout(this._tickTimer), (this._tickTimer = null), !0); } tick() { this._tickCallCount++, 1 === this._tickCallCount && (this.doTick(), this._tickCallCount > 1 && this.tickImmediate(), (this._tickCallCount = 0)); } tickImmediate() { this.clearNextTick(), (this._tickTimer = self.setTimeout(this._boundTick, 0)); } doTick() { } } var Ei = "NOT_LOADED", wi = "APPENDING", xi = "PARTIAL", Si = "OK"; class _i { constructor(t) { (this.activePartLists = Object.create(null)), (this.endListFragments = Object.create(null)), (this.fragments = Object.create(null)), (this.timeRanges = Object.create(null)), (this.bufferPadding = 0.2), (this.hls = void 0), (this.hasGaps = !1), (this.hls = t), this._registerListeners(); } _registerListeners() { const { hls: t } = this; t.on(tt.BUFFER_APPENDED, this.onBufferAppended, this), t.on(tt.FRAG_BUFFERED, this.onFragBuffered, this), t.on(tt.FRAG_LOADED, this.onFragLoaded, this); } _unregisterListeners() { const { hls: t } = this; t.off(tt.BUFFER_APPENDED, this.onBufferAppended, this), t.off(tt.FRAG_BUFFERED, this.onFragBuffered, this), t.off(tt.FRAG_LOADED, this.onFragLoaded, this); } destroy() { this._unregisterListeners(), (this.fragments = this.activePartLists = this.endListFragments = this.timeRanges = null); } getAppendedFrag(t, e) { const n = this.activePartLists[e]; if (n) for (let e = n.length; e--;) { const i = n[e]; if (!i) break; const r = i.end; if (i.start <= t && null !== r && t <= r) return i; } return this.getBufferedFrag(t, e); } getBufferedFrag(t, e) { const { fragments: n } = this, i = Object.keys(n); for (let r = i.length; r--;) { const a = n[i[r]]; if ((null == a ? void 0 : a.body.type) === e && a.buffered) { const e = a.body; if (e.start <= t && t <= e.end) return e; } } return null; } detectEvictedFragments(t, e, n, i) { this.timeRanges && (this.timeRanges[t] = e); const r = (null == i ? void 0 : i.fragment.sn) || -1; Object.keys(this.fragments).forEach(i => { const a = this.fragments[i]; if (!a) return; if (r >= a.body.sn) return; if (!a.buffered && !a.loaded) return void (a.body.type === n && this.removeFragment(a.body)); const s = a.range[t]; s && s.time.some(t => { const n = !this.isTimeBuffered(t.startPTS, t.endPTS, e); return n && this.removeFragment(a.body), n; }); }); } detectPartialFragments(t) { const e = this.timeRanges, { frag: n, part: i } = t; if (!e || "initSegment" === n.sn) return; const r = ki(n), a = this.fragments[r]; if (!a || (a.buffered && n.gap)) return; const s = !n.relurl; if ( (Object.keys(e).forEach(t => { const r = n.elementaryStreams[t]; if (!r) return; const o = e[t], l = s || !0 === r.partial; a.range[t] = this.getBufferedTimes(n, i, l, o); }), (a.loaded = null), Object.keys(a.range).length) ) { a.buffered = !0; (a.body.endList = n.endList || a.body.endList) && (this.endListFragments[a.body.type] = a), Ti(a) || this.removeParts(n.sn - 1, n.type); } else this.removeFragment(a.body); } removeParts(t, e) { const n = this.activePartLists[e]; n && (this.activePartLists[e] = n.filter(e => e.fragment.sn >= t)); } fragBuffered(t, e) { const n = ki(t); let i = this.fragments[n]; !i && e && ((i = this.fragments[n] = { body: t, appendedPTS: null, loaded: null, buffered: !1, range: Object.create(null) }), t.gap && (this.hasGaps = !0)), i && ((i.loaded = null), (i.buffered = !0)); } getBufferedTimes(t, e, n, i) { const r = { time: [], partial: n }, a = t.start, s = t.end, o = t.minEndPTS || s, l = t.maxStartPTS || a; for (let t = 0; t < i.length; t++) { const e = i.start(t) - this.bufferPadding, n = i.end(t) + this.bufferPadding; if (l >= e && o <= n) { r.time.push({ startPTS: Math.max(a, i.start(t)), endPTS: Math.min(s, i.end(t)) }); break; } if (a < n && s > e) { const e = Math.max(a, i.start(t)), n = Math.min(s, i.end(t)); n > e && ((r.partial = !0), r.time.push({ startPTS: e, endPTS: n })); } else if (s <= e) break; } return r; } getPartialFragment(t) { let e, n, i, r = null, a = 0; const { bufferPadding: s, fragments: o } = this; return ( Object.keys(o).forEach(l => { const d = o[l]; d && Ti(d) && ((n = d.body.start - s), (i = d.body.end + s), t >= n && t <= i && ((e = Math.min(t - n, i - t)), a <= e && ((r = d.body), (a = e)))); }), r ); } isEndListAppended(t) { const e = this.endListFragments[t]; return void 0 !== e && (e.buffered || Ti(e)); } getState(t) { const e = ki(t), n = this.fragments[e]; return n ? (n.buffered ? (Ti(n) ? xi : Si) : wi) : Ei; } isTimeBuffered(t, e, n) { let i, r; for (let a = 0; a < n.length; a++) { if (((i = n.start(a) - this.bufferPadding), (r = n.end(a) + this.bufferPadding), t >= i && e <= r)) return !0; if (e <= i) return !1; } return !1; } onFragLoaded(t, e) { const { frag: n, part: i } = e; if ("initSegment" === n.sn || n.bitrateTest) return; const r = i ? null : e, a = ki(n); this.fragments[a] = { body: n, appendedPTS: null, loaded: r, buffered: !1, range: Object.create(null) }; } onBufferAppended(t, e) { const { frag: n, part: i, timeRanges: r } = e; if ("initSegment" === n.sn) return; const a = n.type; if (i) { let t = this.activePartLists[a]; t || (this.activePartLists[a] = t = []), t.push(i); } (this.timeRanges = r), Object.keys(r).forEach(t => { const e = r[t]; this.detectEvictedFragments(t, e, a, i); }); } onFragBuffered(t, e) { this.detectPartialFragments(e); } hasFragment(t) { const e = ki(t); return !!this.fragments[e]; } hasParts(t) { var e; return !(null == (e = this.activePartLists[t]) || !e.length); } removeFragmentsInRange(t, e, n, i, r) { (i && !this.hasGaps) || Object.keys(this.fragments).forEach(a => { const s = this.fragments[a]; if (!s) return; const o = s.body; o.type !== n || (i && !o.gap) || (o.start < e && o.end > t && (s.buffered || r) && this.removeFragment(o)); }); } removeFragment(t) { const e = ki(t); (t.stats.loaded = 0), t.clearElementaryStreamInfo(); const n = this.activePartLists[t.type]; if (n) { const e = t.sn; this.activePartLists[t.type] = n.filter(t => t.fragment.sn !== e); } delete this.fragments[e], t.endList && delete this.endListFragments[t.type]; } removeAllFragments() { (this.fragments = Object.create(null)), (this.endListFragments = Object.create(null)), (this.activePartLists = Object.create(null)), (this.hasGaps = !1); } } function Ti(t) { var e, n, i; return ( t.buffered && (t.body.gap || (null == (e = t.range.video) ? void 0 : e.partial) || (null == (n = t.range.audio) ? void 0 : n.partial) || (null == (i = t.range.audiovideo) ? void 0 : i.partial)) ); } function ki(t) { return `${t.type}_${t.level}_${t.sn}`; } const Ci = { length: 0, start: () => 0, end: () => 0 }; class Li { static isBuffered(t, e) { try { if (t) { const n = Li.getBuffered(t); for (let t = 0; t < n.length; t++) if (e >= n.start(t) && e <= n.end(t)) return !0; } } catch (t) { } return !1; } static bufferInfo(t, e, n) { try { if (t) { const i = Li.getBuffered(t), r = []; let a; for (a = 0; a < i.length; a++) r.push({ start: i.start(a), end: i.end(a) }); return this.bufferedInfo(r, e, n); } } catch (t) { } return { len: 0, start: e, end: e, nextStart: void 0 }; } static bufferedInfo(t, e, n) { (e = Math.max(0, e)), t.sort(function (t, e) { const n = t.start - e.start; return n || e.end - t.end; }); let i = []; if (n) for (let e = 0; e < t.length; e++) { const r = i.length; if (r) { const a = i[r - 1].end; t[e].start - a < n ? t[e].end > a && (i[r - 1].end = t[e].end) : i.push(t[e]); } else i.push(t[e]); } else i = t; let r, a = 0, s = e, o = e; for (let t = 0; t < i.length; t++) { const l = i[t].start, d = i[t].end; if (e + n >= l && e < d) (s = l), (o = d), (a = o - e); else if (e + n < l) { r = l; break; } } return { len: a, start: s || 0, end: o || 0, nextStart: r }; } static getBuffered(t) { try { return t.buffered; } catch (t) { return ot.log("failed to get media.buffered", t), Ci; } } } class Ii { constructor(t, e, n, i = 0, r = -1, a = !1) { (this.level = void 0), (this.sn = void 0), (this.part = void 0), (this.id = void 0), (this.size = void 0), (this.partial = void 0), (this.transmuxing = { start: 0, executeStart: 0, executeEnd: 0, end: 0 }), (this.buffering = { audio: { start: 0, executeStart: 0, executeEnd: 0, end: 0 }, video: { start: 0, executeStart: 0, executeEnd: 0, end: 0 }, audiovideo: { start: 0, executeStart: 0, executeEnd: 0, end: 0 } }), (this.level = t), (this.sn = e), (this.id = n), (this.size = i), (this.part = r), (this.partial = a); } } function Ri(t, e) { for (let i = 0, r = t.length; i < r; i++) { var n; if ((null == (n = t[i]) ? void 0 : n.cc) === e) return t[i]; } return null; } function Di(t, e) { if (t) { const n = t.start + e; (t.start = t.startPTS = n), (t.endPTS = n + t.duration); } } function Bi(t, e) { const n = e.fragments; for (let e = 0, i = n.length; e < i; e++) Di(n[e], t); e.fragmentHint && Di(e.fragmentHint, t), (e.alignedSliding = !0); } function Pi(t, e, n) { e && (!(function (t, e, n) { if ( (function (t, e, n) { return !(!e || !(n.endCC > n.startCC || (t && t.cc < n.startCC))); })(t, n, e) ) { const t = (function (t, e) { const n = t.fragments, i = e.fragments; if (!i.length || !n.length) return void ot.log("No fragments to align"); const r = Ri(n, i[0].cc); if (r && (!r || r.startPTS)) return r; ot.log("No frag in previous level to align on"); })(n, e); t && X(t.start) && (ot.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`), Bi(t.start, e)); } })(t, n, e), !n.alignedSliding && e && Ui(n, e), n.alignedSliding || !e || n.skippedSegments || zn(e, n)); } function Ui(t, e) { if (!t.hasProgramDateTime || !e.hasProgramDateTime) return; const n = t.fragments, i = e.fragments; if (!n.length || !i.length) return; let r, a; const s = Math.min(e.endCC, t.endCC); e.startCC < s && t.startCC < s && ((r = Ri(i, s)), (a = Ri(n, s))), (r && a) || ((r = i[Math.floor(i.length / 2)]), (a = Ri(n, r.cc) || n[Math.floor(n.length / 2)])); const o = r.programDateTime, l = a.programDateTime; if (!o || !l) return; Bi((l - o) / 1e3 - (a.start - r.start), t); } const Fi = Math.pow(2, 17); class Oi { constructor(t) { (this.config = void 0), (this.loader = null), (this.partLoadTimeout = -1), (this.config = t); } destroy() { this.loader && (this.loader.destroy(), (this.loader = null)); } abort() { this.loader && this.loader.abort(); } load(t, e) { const n = t.url; if (!n) return Promise.reject( new zi({ type: et.NETWORK_ERROR, details: nt.FRAG_LOAD_ERROR, fatal: !1, frag: t, error: new Error("Fragment does not have a " + (n ? "part list" : "url")), networkDetails: null }) ); this.abort(); const i = this.config, r = i.fLoader, a = i.loader; return new Promise((s, o) => { if ((this.loader && this.loader.destroy(), t.gap)) { if (t.tagList.some(t => "GAP" === t[0])) return void o(Ni(t)); t.gap = !1; } const l = (this.loader = t.loader = r ? new r(i) : new a(i)), d = Mi(t), c = Vn(i.fragLoadPolicy.default), u = { loadPolicy: c, timeout: c.maxLoadTimeMs, maxRetry: 0, retryDelay: 0, maxRetryDelay: 0, highWaterMark: "initSegment" === t.sn ? 1 / 0 : Fi }; (t.stats = l.stats), l.load(d, u, { onSuccess: (e, n, i, r) => { this.resetLoader(t, l); let a = e.data; i.resetIV && t.decryptdata && ((t.decryptdata.iv = new Uint8Array(a.slice(0, 16))), (a = a.slice(16))), s({ frag: t, part: null, payload: a, networkDetails: r }); }, onError: (e, i, r, a) => { this.resetLoader(t, l), o( new zi({ type: et.NETWORK_ERROR, details: nt.FRAG_LOAD_ERROR, fatal: !1, frag: t, response: q({ url: n, data: void 0 }, e), error: new Error(`HTTP Error ${e.code} ${e.text}`), networkDetails: r, stats: a }) ); }, onAbort: (e, n, i) => { this.resetLoader(t, l), o( new zi({ type: et.NETWORK_ERROR, details: nt.INTERNAL_ABORTED, fatal: !1, frag: t, error: new Error("Aborted"), networkDetails: i, stats: e }) ); }, onTimeout: (e, n, i) => { this.resetLoader(t, l), o( new zi({ type: et.NETWORK_ERROR, details: nt.FRAG_LOAD_TIMEOUT, fatal: !1, frag: t, error: new Error(`Timeout after ${u.timeout}ms`), networkDetails: i, stats: e }) ); }, onProgress: (n, i, r, a) => { e && e({ frag: t, part: null, payload: r, networkDetails: a }); } }); }); } loadPart(t, e, n) { this.abort(); const i = this.config, r = i.fLoader, a = i.loader; return new Promise((s, o) => { if ((this.loader && this.loader.destroy(), t.gap || e.gap)) return void o(Ni(t, e)); const l = (this.loader = t.loader = r ? new r(i) : new a(i)), d = Mi(t, e), c = Vn(i.fragLoadPolicy.default), u = { loadPolicy: c, timeout: c.maxLoadTimeMs, maxRetry: 0, retryDelay: 0, maxRetryDelay: 0, highWaterMark: Fi }; (e.stats = l.stats), l.load(d, u, { onSuccess: (i, r, a, o) => { this.resetLoader(t, l), this.updateStatsFromPart(t, e); const d = { frag: t, part: e, payload: i.data, networkDetails: o }; n(d), s(d); }, onError: (n, i, r, a) => { this.resetLoader(t, l), o( new zi({ type: et.NETWORK_ERROR, details: nt.FRAG_LOAD_ERROR, fatal: !1, frag: t, part: e, response: q({ url: d.url, data: void 0 }, n), error: new Error(`HTTP Error ${n.code} ${n.text}`), networkDetails: r, stats: a }) ); }, onAbort: (n, i, r) => { (t.stats.aborted = e.stats.aborted), this.resetLoader(t, l), o( new zi({ type: et.NETWORK_ERROR, details: nt.INTERNAL_ABORTED, fatal: !1, frag: t, part: e, error: new Error("Aborted"), networkDetails: r, stats: n }) ); }, onTimeout: (n, i, r) => { this.resetLoader(t, l), o( new zi({ type: et.NETWORK_ERROR, details: nt.FRAG_LOAD_TIMEOUT, fatal: !1, frag: t, part: e, error: new Error(`Timeout after ${u.timeout}ms`), networkDetails: r, stats: n }) ); } }); }); } updateStatsFromPart(t, e) { const n = t.stats, i = e.stats, r = i.total; if (((n.loaded += i.loaded), r)) { const i = Math.round(t.duration / e.duration), a = Math.min(Math.round(n.loaded / r), i), s = (i - a) * Math.round(n.loaded / a); n.total = n.loaded + s; } else n.total = Math.max(n.loaded, n.total); const a = n.loading, s = i.loading; a.start ? (a.first += s.first - s.start) : ((a.start = s.start), (a.first = s.first)), (a.end = s.end); } resetLoader(t, e) { (t.loader = null), this.loader === e && (self.clearTimeout(this.partLoadTimeout), (this.loader = null)), e.destroy(); } } function Mi(t, e = null) { const n = e || t, i = { frag: t, part: e, responseType: "arraybuffer", url: n.url, headers: {}, rangeStart: 0, rangeEnd: 0 }, r = n.byteRangeStartOffset, a = n.byteRangeEndOffset; if (X(r) && X(a)) { var s; let e = r, n = a; if ("initSegment" === t.sn && "AES-128" === (null == (s = t.decryptdata) ? void 0 : s.method)) { const t = a - r; t % 16 && (n = a + (16 - (t % 16))), 0 !== r && ((i.resetIV = !0), (e = r - 16)); } (i.rangeStart = e), (i.rangeEnd = n); } return i; } function Ni(t, e) { const n = new Error(`GAP ${t.gap ? "tag" : "attribute"} found`), i = { type: et.MEDIA_ERROR, details: nt.FRAG_GAP, fatal: !1, frag: t, error: n, networkDetails: null }; return e && (i.part = e), ((e || t).stats.aborted = !0), new zi(i); } class zi extends Error { constructor(t) { super(t.error.message), (this.data = void 0), (this.data = t); } } class Gi { constructor(t, e) { (this.subtle = void 0), (this.aesIV = void 0), (this.subtle = t), (this.aesIV = e); } decrypt(t, e) { return this.subtle.decrypt({ name: "AES-CBC", iv: this.aesIV }, e, t); } } class ji { constructor(t, e) { (this.subtle = void 0), (this.key = void 0), (this.subtle = t), (this.key = e); } expandKey() { return this.subtle.importKey("raw", this.key, { name: "AES-CBC" }, !1, ["encrypt", "decrypt"]); } } class Hi { constructor() { (this.rcon = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]), (this.subMix = [new Uint32Array(256), new Uint32Array(256), new Uint32Array(256), new Uint32Array(256)]), (this.invSubMix = [new Uint32Array(256), new Uint32Array(256), new Uint32Array(256), new Uint32Array(256)]), (this.sBox = new Uint32Array(256)), (this.invSBox = new Uint32Array(256)), (this.key = new Uint32Array(0)), (this.ksRows = 0), (this.keySize = 0), (this.keySchedule = void 0), (this.invKeySchedule = void 0), this.initTable(); } uint8ArrayToUint32Array_(t) { const e = new DataView(t), n = new Uint32Array(4); for (let t = 0; t < 4; t++) n[t] = e.getUint32(4 * t); return n; } initTable() { const t = this.sBox, e = this.invSBox, n = this.subMix, i = n[0], r = n[1], a = n[2], s = n[3], o = this.invSubMix, l = o[0], d = o[1], c = o[2], u = o[3], h = new Uint32Array(256); let p = 0, f = 0, m = 0; for (m = 0; m < 256; m++) h[m] = m < 128 ? m << 1 : (m << 1) ^ 283; for (m = 0; m < 256; m++) { let n = f ^ (f << 1) ^ (f << 2) ^ (f << 3) ^ (f << 4); (n = (n >>> 8) ^ (255 & n) ^ 99), (t[p] = n), (e[n] = p); const o = h[p], m = h[o], g = h[m]; let y = (257 * h[n]) ^ (16843008 * n); (i[p] = (y << 24) | (y >>> 8)), (r[p] = (y << 16) | (y >>> 16)), (a[p] = (y << 8) | (y >>> 24)), (s[p] = y), (y = (16843009 * g) ^ (65537 * m) ^ (257 * o) ^ (16843008 * p)), (l[n] = (y << 24) | (y >>> 8)), (d[n] = (y << 16) | (y >>> 16)), (c[n] = (y << 8) | (y >>> 24)), (u[n] = y), p ? ((p = o ^ h[h[h[g ^ o]]]), (f ^= h[h[f]])) : (p = f = 1); } } expandKey(t) { const e = this.uint8ArrayToUint32Array_(t); let n = !0, i = 0; for (; i < e.length && n;) (n = e[i] === this.key[i]), i++; if (n) return; this.key = e; const r = (this.keySize = e.length); if (4 !== r && 6 !== r && 8 !== r) throw new Error("Invalid aes key size=" + r); const a = (this.ksRows = 4 * (r + 6 + 1)); let s, o; const l = (this.keySchedule = new Uint32Array(a)), d = (this.invKeySchedule = new Uint32Array(a)), c = this.sBox, u = this.rcon, h = this.invSubMix, p = h[0], f = h[1], m = h[2], g = h[3]; let y, A; for (s = 0; s < a; s++) s < r ? (y = l[s] = e[s]) : ((A = y), s % r == 0 ? ((A = (A << 8) | (A >>> 24)), (A = (c[A >>> 24] << 24) | (c[(A >>> 16) & 255] << 16) | (c[(A >>> 8) & 255] << 8) | c[255 & A]), (A ^= u[(s / r) | 0] << 24)) : r > 6 && s % r == 4 && (A = (c[A >>> 24] << 24) | (c[(A >>> 16) & 255] << 16) | (c[(A >>> 8) & 255] << 8) | c[255 & A]), (l[s] = y = (l[s - r] ^ A) >>> 0)); for (o = 0; o < a; o++) (s = a - o), (A = 3 & o ? l[s] : l[s - 4]), (d[o] = o < 4 || s <= 4 ? A : p[c[A >>> 24]] ^ f[c[(A >>> 16) & 255]] ^ m[c[(A >>> 8) & 255]] ^ g[c[255 & A]]), (d[o] = d[o] >>> 0); } networkToHostOrderSwap(t) { return (t << 24) | ((65280 & t) << 8) | ((16711680 & t) >> 8) | (t >>> 24); } decrypt(t, e, n) { const i = this.keySize + 6, r = this.invKeySchedule, a = this.invSBox, s = this.invSubMix, o = s[0], l = s[1], d = s[2], c = s[3], u = this.uint8ArrayToUint32Array_(n); let h = u[0], p = u[1], f = u[2], m = u[3]; const g = new Int32Array(t), y = new Int32Array(g.length); let A, v, b, E, w, x, S, _, T, k, C, L, I, R; const D = this.networkToHostOrderSwap; for (; e < g.length;) { for ( T = D(g[e]), k = D(g[e + 1]), C = D(g[e + 2]), L = D(g[e + 3]), w = T ^ r[0], x = L ^ r[1], S = C ^ r[2], _ = k ^ r[3], I = 4, R = 1; R < i; R++ ) (A = o[w >>> 24] ^ l[(x >> 16) & 255] ^ d[(S >> 8) & 255] ^ c[255 & _] ^ r[I]), (v = o[x >>> 24] ^ l[(S >> 16) & 255] ^ d[(_ >> 8) & 255] ^ c[255 & w] ^ r[I + 1]), (b = o[S >>> 24] ^ l[(_ >> 16) & 255] ^ d[(w >> 8) & 255] ^ c[255 & x] ^ r[I + 2]), (E = o[_ >>> 24] ^ l[(w >> 16) & 255] ^ d[(x >> 8) & 255] ^ c[255 & S] ^ r[I + 3]), (w = A), (x = v), (S = b), (_ = E), (I += 4); (A = (a[w >>> 24] << 24) ^ (a[(x >> 16) & 255] << 16) ^ (a[(S >> 8) & 255] << 8) ^ a[255 & _] ^ r[I]), (v = (a[x >>> 24] << 24) ^ (a[(S >> 16) & 255] << 16) ^ (a[(_ >> 8) & 255] << 8) ^ a[255 & w] ^ r[I + 1]), (b = (a[S >>> 24] << 24) ^ (a[(_ >> 16) & 255] << 16) ^ (a[(w >> 8) & 255] << 8) ^ a[255 & x] ^ r[I + 2]), (E = (a[_ >>> 24] << 24) ^ (a[(w >> 16) & 255] << 16) ^ (a[(x >> 8) & 255] << 8) ^ a[255 & S] ^ r[I + 3]), (y[e] = D(A ^ h)), (y[e + 1] = D(E ^ p)), (y[e + 2] = D(b ^ f)), (y[e + 3] = D(v ^ m)), (h = T), (p = k), (f = C), (m = L), (e += 4); } return y.buffer; } } class Yi { constructor(t, { removePKCS7Padding: e = !0 } = {}) { if ( ((this.logEnabled = !0), (this.removePKCS7Padding = void 0), (this.subtle = null), (this.softwareDecrypter = null), (this.key = null), (this.fastAesKey = null), (this.remainderData = null), (this.currentIV = null), (this.currentResult = null), (this.useSoftware = void 0), (this.useSoftware = t.enableSoftwareAES), (this.removePKCS7Padding = e), e) ) try { const t = self.crypto; t && (this.subtle = t.subtle || t.webkitSubtle); } catch (t) { } null === this.subtle && (this.useSoftware = !0); } destroy() { (this.subtle = null), (this.softwareDecrypter = null), (this.key = null), (this.fastAesKey = null), (this.remainderData = null), (this.currentIV = null), (this.currentResult = null); } isSync() { return this.useSoftware; } flush() { const { currentResult: t, remainderData: e } = this; if (!t || e) return this.reset(), null; const n = new Uint8Array(t); return ( this.reset(), this.removePKCS7Padding ? (function (t) { const e = t.byteLength, n = e && new DataView(t.buffer).getUint8(e - 1); return n ? Ft(t, 0, e - n) : t; })(n) : n ); } reset() { (this.currentResult = null), (this.currentIV = null), (this.remainderData = null), this.softwareDecrypter && (this.softwareDecrypter = null); } decrypt(t, e, n) { return this.useSoftware ? new Promise((i, r) => { this.softwareDecrypt(new Uint8Array(t), e, n); const a = this.flush(); a ? i(a.buffer) : r(new Error("[softwareDecrypt] Failed to decrypt data")); }) : this.webCryptoDecrypt(new Uint8Array(t), e, n); } softwareDecrypt(t, e, n) { const { currentIV: i, currentResult: r, remainderData: a } = this; this.logOnce("JS AES decrypt"), a && ((t = ve(a, t)), (this.remainderData = null)); const s = this.getValidChunk(t); if (!s.length) return null; i && (n = i); let o = this.softwareDecrypter; o || (o = this.softwareDecrypter = new Hi()), o.expandKey(e); const l = r; return (this.currentResult = o.decrypt(s.buffer, 0, n)), (this.currentIV = Ft(s, -16).buffer), l || null; } webCryptoDecrypt(t, e, n) { const i = this.subtle; return ( (this.key === e && this.fastAesKey) || ((this.key = e), (this.fastAesKey = new ji(i, e))), this.fastAesKey .expandKey() .then(e => { if (!i) return Promise.reject(new Error("web crypto not initialized")); this.logOnce("WebCrypto AES decrypt"); return new Gi(i, new Uint8Array(n)).decrypt(t.buffer, e); }) .catch( i => ( ot.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${i.name}: ${i.message}`), this.onWebCryptoError(t, e, n) ) ) ); } onWebCryptoError(t, e, n) { (this.useSoftware = !0), (this.logEnabled = !0), this.softwareDecrypt(t, e, n); const i = this.flush(); if (i) return i.buffer; throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data"); } getValidChunk(t) { let e = t; const n = t.length - (t.length % 16); return n !== t.length && ((e = Ft(t, 0, n)), (this.remainderData = Ft(t, n))), e; } logOnce(t) { this.logEnabled && (ot.log(`[decrypter]: ${t}`), (this.logEnabled = !1)); } } const $i = function (t) { let e = ""; const n = t.length; for (let i = 0; i < n; i++) e += `[${t.start(i).toFixed(3)}-${t.end(i).toFixed(3)}]`; return e; }, Ki = "STOPPED", qi = "IDLE", Vi = "KEY_LOADING", Wi = "FRAG_LOADING", Qi = "FRAG_LOADING_WAITING_RETRY", Xi = "WAITING_TRACK", Ji = "PARSING", Zi = "PARSED", tr = "ENDED", er = "ERROR", nr = "WAITING_INIT_PTS", ir = "WAITING_LEVEL"; class rr extends bi { constructor(t, e, n, i, r) { super(), (this.hls = void 0), (this.fragPrevious = null), (this.fragCurrent = null), (this.fragmentTracker = void 0), (this.transmuxer = null), (this._state = Ki), (this.playlistType = void 0), (this.media = null), (this.mediaBuffer = null), (this.config = void 0), (this.bitrateTest = !1), (this.lastCurrentTime = 0), (this.nextLoadPosition = 0), (this.startPosition = 0), (this.startTimeOffset = null), (this.loadedmetadata = !1), (this.retryDate = 0), (this.levels = null), (this.fragmentLoader = void 0), (this.keyLoader = void 0), (this.levelLastLoaded = null), (this.startFragRequested = !1), (this.decrypter = void 0), (this.initPTS = []), (this.onvseeking = null), (this.onvended = null), (this.logPrefix = ""), (this.log = void 0), (this.warn = void 0), (this.playlistType = r), (this.logPrefix = i), (this.log = ot.log.bind(ot, `${i}:`)), (this.warn = ot.warn.bind(ot, `${i}:`)), (this.hls = t), (this.fragmentLoader = new Oi(t.config)), (this.keyLoader = n), (this.fragmentTracker = e), (this.config = t.config), (this.decrypter = new Yi(t.config)), t.on(tt.MANIFEST_LOADED, this.onManifestLoaded, this); } doTick() { this.onTickEnd(); } onTickEnd() { } startLoad(t) { } stopLoad() { this.fragmentLoader.abort(), this.keyLoader.abort(this.playlistType); const t = this.fragCurrent; null != t && t.loader && (t.abortRequests(), this.fragmentTracker.removeFragment(t)), this.resetTransmuxer(), (this.fragCurrent = null), (this.fragPrevious = null), this.clearInterval(), this.clearNextTick(), (this.state = Ki); } _streamEnded(t, e) { if (e.live || t.nextStart || !t.end || !this.media) return !1; const n = e.partList; if (null != n && n.length) { const t = n[n.length - 1]; return Li.isBuffered(this.media, t.start + t.duration / 2); } const i = e.fragments[e.fragments.length - 1].type; return this.fragmentTracker.isEndListAppended(i); } getLevelDetails() { var t; if (this.levels && null !== this.levelLastLoaded) return null == (t = this.levelLastLoaded) ? void 0 : t.details; } onMediaAttached(t, e) { const n = (this.media = this.mediaBuffer = e.media); (this.onvseeking = this.onMediaSeeking.bind(this)), (this.onvended = this.onMediaEnded.bind(this)), n.addEventListener("seeking", this.onvseeking), n.addEventListener("ended", this.onvended); const i = this.config; this.levels && i.autoStartLoad && this.state === Ki && this.startLoad(i.startPosition); } onMediaDetaching() { const t = this.media; null != t && t.ended && (this.log("MSE detaching and video ended, reset startPosition"), (this.startPosition = this.lastCurrentTime = 0)), t && this.onvseeking && this.onvended && (t.removeEventListener("seeking", this.onvseeking), t.removeEventListener("ended", this.onvended), (this.onvseeking = this.onvended = null)), this.keyLoader && this.keyLoader.detach(), (this.media = this.mediaBuffer = null), (this.loadedmetadata = !1), this.fragmentTracker.removeAllFragments(), this.stopLoad(); } onMediaSeeking() { const { config: t, fragCurrent: e, media: n, mediaBuffer: i, state: r } = this, a = n ? n.currentTime : 0, s = Li.bufferInfo(i || n, a, t.maxBufferHole); if ((this.log(`media seeking to ${X(a) ? a.toFixed(3) : a}, state: ${r}`), this.state === tr)) this.resetLoadingState(); else if (e) { const n = t.maxFragLookUpTolerance, i = e.start - n, r = e.start + e.duration + n; if (!s.len || r < s.start || i > s.end) { const t = a > r; (a < i || t) && (t && e.loader && (this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"), e.abortRequests(), this.resetLoadingState()), (this.fragPrevious = null)); } } n && (this.fragmentTracker.removeFragmentsInRange(a, 1 / 0, this.playlistType, !0), (this.lastCurrentTime = a)), this.loadedmetadata || s.len || (this.nextLoadPosition = this.startPosition = a), this.tickImmediate(); } onMediaEnded() { this.startPosition = this.lastCurrentTime = 0; } onManifestLoaded(t, e) { (this.startTimeOffset = e.startTimeOffset), (this.initPTS = []); } onHandlerDestroying() { this.hls.off(tt.MANIFEST_LOADED, this.onManifestLoaded, this), this.stopLoad(), super.onHandlerDestroying(), (this.hls = null); } onHandlerDestroyed() { (this.state = Ki), this.fragmentLoader && this.fragmentLoader.destroy(), this.keyLoader && this.keyLoader.destroy(), this.decrypter && this.decrypter.destroy(), (this.hls = this.log = this.warn = this.decrypter = this.keyLoader = this.fragmentLoader = this.fragmentTracker = null), super.onHandlerDestroyed(); } loadFragment(t, e, n) { this._loadFragForPlayback(t, e, n); } _loadFragForPlayback(t, e, n) { this._doFragLoad(t, e, n, e => { if (this.fragContextChanged(t)) return ( this.warn( `Fragment ${t.sn}${e.part ? " p: " + e.part.index : ""} of level ${t.level } was dropped during download.` ), void this.fragmentTracker.removeFragment(t) ); t.stats.chunkCount++, this._handleFragmentLoadProgress(e); }) .then(e => { if (!e) return; const n = this.state; this.fragContextChanged(t) ? (n === Wi || (!this.fragCurrent && n === Ji)) && (this.fragmentTracker.removeFragment(t), (this.state = qi)) : ("payload" in e && (this.log(`Loaded fragment ${t.sn} of level ${t.level}`), this.hls.trigger(tt.FRAG_LOADED, e)), this._handleFragmentLoadComplete(e)); }) .catch(e => { this.state !== Ki && this.state !== er && (this.warn(e), this.resetFragmentLoading(t)); }); } clearTrackerIfNeeded(t) { var e; const { fragmentTracker: n } = this; if (n.getState(t) === wi) { const e = t.type, i = this.getFwdBufferInfo(this.mediaBuffer, e), r = Math.max(t.duration, i ? i.len : this.config.maxBufferLength); this.reduceMaxBufferLength(r) && n.removeFragment(t); } else 0 === (null == (e = this.mediaBuffer) ? void 0 : e.buffered.length) ? n.removeAllFragments() : n.hasParts(t.type) && (n.detectPartialFragments({ frag: t, part: null, stats: t.stats, id: t.type }), n.getState(t) === xi && n.removeFragment(t)); } checkLiveUpdate(t) { if (t.updated && !t.live) { const e = t.fragments[t.fragments.length - 1]; this.fragmentTracker.detectPartialFragments({ frag: e, part: null, stats: e.stats, id: e.type }); } t.fragments[0] || (t.deltaUpdateFailed = !0); } flushMainBuffer(t, e, n = null) { if (!(t - e)) return; const i = { startOffset: t, endOffset: e, type: n }; this.hls.trigger(tt.BUFFER_FLUSHING, i); } _loadInitSegment(t, e) { this._doFragLoad(t, e) .then(e => { if (!e || this.fragContextChanged(t) || !this.levels) throw new Error("init load aborted"); return e; }) .then(e => { const { hls: n } = this, { payload: i } = e, r = t.decryptdata; if (i && i.byteLength > 0 && null != r && r.key && r.iv && "AES-128" === r.method) { const a = self.performance.now(); return this.decrypter .decrypt(new Uint8Array(i), r.key.buffer, r.iv.buffer) .catch(e => { throw ( (n.trigger(tt.ERROR, { type: et.MEDIA_ERROR, details: nt.FRAG_DECRYPT_ERROR, fatal: !1, error: e, reason: e.message, frag: t }), e) ); }) .then(i => { const r = self.performance.now(); return ( n.trigger(tt.FRAG_DECRYPTED, { frag: t, payload: i, stats: { tstart: a, tdecrypt: r } }), (e.payload = i), this.completeInitSegmentLoad(e) ); }); } return this.completeInitSegmentLoad(e); }) .catch(e => { this.state !== Ki && this.state !== er && (this.warn(e), this.resetFragmentLoading(t)); }); } completeInitSegmentLoad(t) { const { levels: e } = this; if (!e) throw new Error("init load aborted, missing levels"); const n = t.frag.stats; (this.state = qi), (t.frag.data = new Uint8Array(t.payload)), (n.parsing.start = n.buffering.start = self.performance.now()), (n.parsing.end = n.buffering.end = self.performance.now()), this.tick(); } fragContextChanged(t) { const { fragCurrent: e } = this; return !t || !e || t.sn !== e.sn || t.level !== e.level; } fragBufferedComplete(t, e) { var n, i, r, a; const s = this.mediaBuffer ? this.mediaBuffer : this.media; if ( (this.log( `Buffered ${t.type} sn: ${t.sn}${e ? " part: " + e.index : ""} of ${this.playlistType === ln ? "level" : "track" } ${t.level} (frag:[${(null != (n = t.startPTS) ? n : NaN).toFixed(3)}-${(null != (i = t.endPTS) ? i : NaN ).toFixed(3)}] > buffer:${s ? $i(Li.getBuffered(s)) : "(detached)"})` ), "initSegment" !== t.sn) ) { var o; if (t.type !== cn) { const e = t.elementaryStreams; if (!Object.keys(e).some(t => !!e[t])) return void (this.state = qi); } const e = null == (o = this.levels) ? void 0 : o[t.level]; null != e && e.fragmentError && (this.log(`Resetting level fragment error count of ${e.fragmentError} on frag buffered`), (e.fragmentError = 0)); } (this.state = qi), s && (!this.loadedmetadata && t.type == ln && s.buffered.length && (null == (r = this.fragCurrent) ? void 0 : r.sn) === (null == (a = this.fragPrevious) ? void 0 : a.sn) && ((this.loadedmetadata = !0), this.seekToStartPos()), this.tick()); } seekToStartPos() { } _handleFragmentLoadComplete(t) { const { transmuxer: e } = this; if (!e) return; const { frag: n, part: i, partsLoaded: r } = t, a = !r || 0 === r.length || r.some(t => !t), s = new Ii(n.level, n.sn, n.stats.chunkCount + 1, 0, i ? i.index : -1, !a); e.flush(s); } _handleFragmentLoadProgress(t) { } _doFragLoad(t, e, n = null, i) { var r; const a = null == e ? void 0 : e.details; if (!this.levels || !a) throw new Error(`frag load aborted, missing level${a ? "" : " detail"}s`); let s = null; if ( (!t.encrypted || (null != (r = t.decryptdata) && r.key) ? !t.encrypted && a.encryptedFragments.length && this.keyLoader.loadClear(t, a.encryptedFragments) : (this.log( `Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${"[stream-controller]" === this.logPrefix ? "level" : "track" } ${t.level}` ), (this.state = Vi), (this.fragCurrent = t), (s = this.keyLoader.load(t).then(t => { if (!this.fragContextChanged(t.frag)) return this.hls.trigger(tt.KEY_LOADED, t), this.state === Vi && (this.state = qi), t; })), this.hls.trigger(tt.KEY_LOADING, { frag: t }), null === this.fragCurrent && (s = Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))), (n = Math.max(t.start, n || 0)), this.config.lowLatencyMode && "initSegment" !== t.sn) ) { const r = a.partList; if (r && i) { n > t.end && a.fragmentHint && (t = a.fragmentHint); const o = this.getNextPart(r, t, n); if (o > -1) { const l = r[o]; let d; return ( this.log( `Loading part sn: ${t.sn} p: ${l.index} cc: ${t.cc} of playlist [${a.startSN}-${a.endSN }] parts [0-${o}-${r.length - 1}] ${"[stream-controller]" === this.logPrefix ? "level" : "track" }: ${t.level}, target: ${parseFloat(n.toFixed(3))}` ), (this.nextLoadPosition = l.start + l.duration), (this.state = Wi), (d = s ? s .then(n => !n || this.fragContextChanged(n.frag) ? null : this.doFragPartsLoad(t, l, e, i) ) .catch(t => this.handleFragLoadError(t)) : this.doFragPartsLoad(t, l, e, i).catch(t => this.handleFragLoadError(t))), this.hls.trigger(tt.FRAG_LOADING, { frag: t, part: l, targetBufferTime: n }), null === this.fragCurrent ? Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")) : d ); } if (!t.url || this.loadedEndOfParts(r, n)) return Promise.resolve(null); } } this.log( `Loading fragment ${t.sn} cc: ${t.cc} ${a ? "of [" + a.startSN + "-" + a.endSN + "] " : ""}${"[stream-controller]" === this.logPrefix ? "level" : "track" }: ${t.level}, target: ${parseFloat(n.toFixed(3))}` ), X(t.sn) && !this.bitrateTest && (this.nextLoadPosition = t.start + t.duration), (this.state = Wi); const o = this.config.progressive; let l; return ( (l = o && s ? s .then(e => !e || this.fragContextChanged(null == e ? void 0 : e.frag) ? null : this.fragmentLoader.load(t, i) ) .catch(t => this.handleFragLoadError(t)) : Promise.all([this.fragmentLoader.load(t, o ? i : void 0), s]) .then(([t]) => (!o && t && i && i(t), t)) .catch(t => this.handleFragLoadError(t))), this.hls.trigger(tt.FRAG_LOADING, { frag: t, targetBufferTime: n }), null === this.fragCurrent ? Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")) : l ); } doFragPartsLoad(t, e, n, i) { return new Promise((r, a) => { var s; const o = [], l = null == (s = n.details) ? void 0 : s.partList, d = e => { this.fragmentLoader .loadPart(t, e, i) .then(i => { o[e.index] = i; const a = i.part; this.hls.trigger(tt.FRAG_LOADED, i); const s = jn(n, t.sn, e.index + 1) || Hn(l, t.sn, e.index + 1); if (!s) return r({ frag: t, part: a, partsLoaded: o }); d(s); }) .catch(a); }; d(e); }); } handleFragLoadError(t) { if ("data" in t) { const e = t.data; t.data && e.details === nt.INTERNAL_ABORTED ? this.handleFragLoadAborted(e.frag, e.part) : this.hls.trigger(tt.ERROR, e); } else this.hls.trigger(tt.ERROR, { type: et.OTHER_ERROR, details: nt.INTERNAL_EXCEPTION, err: t, error: t, fatal: !0 }); return null; } _handleTransmuxerFlush(t) { const e = this.getCurrentContext(t); if (!e || this.state !== Ji) return void (this.fragCurrent || this.state === Ki || this.state === er || (this.state = qi)); const { frag: n, part: i, level: r } = e, a = self.performance.now(); (n.stats.parsing.end = a), i && (i.stats.parsing.end = a), this.updateLevelTiming(n, i, r, t.partial); } getCurrentContext(t) { const { levels: e, fragCurrent: n } = this, { level: i, sn: r, part: a } = t; if (null == e || !e[i]) return ( this.warn( `Levels object was unset while buffering fragment ${r} of level ${i}. The current chunk will not be buffered.` ), null ); const s = e[i], o = a > -1 ? jn(s, r, a) : null, l = o ? o.fragment : (function (t, e, n) { if (null == t || !t.details) return null; const i = t.details; let r = i.fragments[e - i.startSN]; return r || ((r = i.fragmentHint), r && r.sn === e ? r : e < i.startSN && n && n.sn === e ? n : null); })(s, r, n); return l ? (n && n !== l && (l.stats = n.stats), { frag: l, part: o, level: s }) : null; } bufferFragmentData(t, e, n, i, r) { var a; if (!t || this.state !== Ji) return; const { data1: s, data2: o } = t; let l = s; if ((s && o && (l = ve(s, o)), null == (a = l) || !a.length)) return; const d = { type: t.type, frag: e, part: n, chunkMeta: i, parent: e.type, data: l }; if ((this.hls.trigger(tt.BUFFER_APPENDING, d), t.dropped && t.independent && !n)) { if (r) return; this.flushBufferGap(e); } } flushBufferGap(t) { const e = this.media; if (!e) return; if (!Li.isBuffered(e, e.currentTime)) return void this.flushMainBuffer(0, t.start); const n = e.currentTime, i = Li.bufferInfo(e, n, 0), r = t.duration, a = Math.min(2 * this.config.maxFragLookUpTolerance, 0.25 * r), s = Math.max(Math.min(t.start - a, i.end - a), n + a); t.start - s > a && this.flushMainBuffer(s, t.start); } getFwdBufferInfo(t, e) { const n = this.getLoadPosition(); return X(n) ? this.getFwdBufferInfoAtPos(t, n, e) : null; } getFwdBufferInfoAtPos(t, e, n) { const { config: { maxBufferHole: i } } = this, r = Li.bufferInfo(t, e, i); if (0 === r.len && void 0 !== r.nextStart) { const a = this.fragmentTracker.getBufferedFrag(e, n); if (a && r.nextStart < a.end) return Li.bufferInfo(t, e, Math.max(r.nextStart, i)); } return r; } getMaxBufferLength(t) { const { config: e } = this; let n; return ( (n = t ? Math.max((8 * e.maxBufferSize) / t, e.maxBufferLength) : e.maxBufferLength), Math.min(n, e.maxMaxBufferLength) ); } reduceMaxBufferLength(t) { const e = this.config, n = t || e.maxBufferLength; return ( e.maxMaxBufferLength >= n && ((e.maxMaxBufferLength /= 2), this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`), !0) ); } getAppendedFrag(t, e = ln) { const n = this.fragmentTracker.getAppendedFrag(t, ln); return n && "fragment" in n ? n.fragment : n; } getNextFragment(t, e) { const n = e.fragments, i = n.length; if (!i) return null; const { config: r } = this, a = n[0].start; let s; if (e.live) { const o = r.initialLiveManifestSize; if (i < o) return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${o})`), null; ((!e.PTSKnown && !this.startFragRequested && -1 === this.startPosition) || t < a) && ((s = this.getInitialLiveFragment(e, n)), (this.startPosition = this.nextLoadPosition = s ? this.hls.liveSyncPosition || s.start : t)); } else t <= a && (s = n[0]); if (!s) { const n = r.lowLatencyMode ? e.partEnd : e.fragmentEnd; s = this.getFragmentAtPosition(t, n, e); } return this.mapToInitFragWhenRequired(s); } isLoopLoading(t, e) { const n = this.fragmentTracker.getState(t); return (n === Si || (n === xi && !!t.gap)) && this.nextLoadPosition > e; } getNextFragmentLoopLoading(t, e, n, i, r) { const a = t.gap, s = this.getNextFragment(this.nextLoadPosition, e); if (null === s) return s; if (((t = s), a && t && !t.gap && n.nextStart)) { const e = this.getFwdBufferInfoAtPos(this.mediaBuffer ? this.mediaBuffer : this.media, n.nextStart, i); if (null !== e && n.len + e.len >= r) return this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${t.sn}`), null; } return t; } mapToInitFragWhenRequired(t) { return null == t || !t.initSegment || (null != t && t.initSegment.data) || this.bitrateTest ? t : t.initSegment; } getNextPart(t, e, n) { let i = -1, r = !1, a = !0; for (let s = 0, o = t.length; s < o; s++) { const o = t[s]; if (((a = a && !o.independent), i > -1 && n < o.start)) break; const l = o.loaded; l ? (i = -1) : (r || o.independent || a) && o.fragment === e && (i = s), (r = l); } return i; } loadedEndOfParts(t, e) { const n = t[t.length - 1]; return n && e > n.start && n.loaded; } getInitialLiveFragment(t, e) { const n = this.fragPrevious; let i = null; if (n) { if ( (t.hasProgramDateTime && (this.log(`Live playlist, switching playlist, load frag with same PDT: ${n.programDateTime}`), (i = (function (t, e, n) { if (null === e || !Array.isArray(t) || !t.length || !X(e)) return null; if (e < (t[0].programDateTime || 0)) return null; if (e >= (t[t.length - 1].endProgramDateTime || 0)) return null; n = n || 0; for (let i = 0; i < t.length; ++i) { const r = t[i]; if (Zn(e, n, r)) return r; } return null; })(e, n.endProgramDateTime, this.config.maxFragLookUpTolerance))), !i) ) { const r = n.sn + 1; if (r >= t.startSN && r <= t.endSN) { const a = e[r - t.startSN]; n.cc === a.cc && ((i = a), this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`)); } i || ((i = (function (t, e) { return Qn(t, t => (t.cc < e ? 1 : t.cc > e ? -1 : 0)); })(e, n.cc)), i && this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`)); } } else { const e = this.hls.liveSyncPosition; null !== e && (i = this.getFragmentAtPosition(e, this.bitrateTest ? t.fragmentEnd : t.edge, t)); } return i; } getFragmentAtPosition(t, e, n) { const { config: i } = this; let { fragPrevious: r } = this, { fragments: a, endSN: s } = n; const { fragmentHint: o } = n, l = i.maxFragLookUpTolerance, d = n.partList, c = !!(i.lowLatencyMode && null != d && d.length && o); let u; if ((c && o && !this.bitrateTest && ((a = a.concat(o)), (s = o.sn)), t < e)) { u = Xn(r, a, t, t > e - l ? 0 : l); } else u = a[a.length - 1]; if (u) { const t = u.sn - n.startSN, e = this.fragmentTracker.getState(u); if (((e === Si || (e === xi && u.gap)) && (r = u), r && u.sn === r.sn && (!c || d[0].fragment.sn > u.sn))) { if (r && u.level === r.level) { const e = a[t + 1]; u = u.sn < s && this.fragmentTracker.getState(e) !== Si ? e : null; } } } return u; } synchronizeToLiveEdge(t) { const { config: e, media: n } = this; if (!n) return; const i = this.hls.liveSyncPosition, r = n.currentTime, a = t.fragments[0].start, s = t.edge, o = r >= a - e.maxFragLookUpTolerance && r <= s; if (null !== i && n.duration > i && (r < i || !o)) { const a = void 0 !== e.liveMaxLatencyDuration ? e.liveMaxLatencyDuration : e.liveMaxLatencyDurationCount * t.targetduration; ((!o && n.readyState < 4) || r < s - a) && (this.loadedmetadata || (this.nextLoadPosition = i), n.readyState && (this.warn( `Playback: ${r.toFixed( 3 )} is located too far from the end of live sliding playlist: ${s}, reset currentTime to : ${i.toFixed( 3 )}` ), (n.currentTime = i))); } } alignPlaylists(t, e, n) { const i = t.fragments.length; if (!i) return this.warn("No fragments in live playlist"), 0; const r = t.fragments[0].start, a = !e, s = t.alignedSliding && X(r); if (a || (!s && !r)) { const { fragPrevious: r } = this; Pi(r, n, t); const a = t.fragments[0].start; return ( this.log( `Live playlist sliding: ${a.toFixed(2)} start-sn: ${e ? e.startSN : "na"}->${t.startSN} prev-sn: ${r ? r.sn : "na" } fragments: ${i}` ), a ); } return r; } waitForCdnTuneIn(t) { return t.live && t.canBlockReload && t.partTarget && t.tuneInGoal > Math.max(t.partHoldBack, 3 * t.partTarget); } setStartPosition(t, e) { let n = this.startPosition; if ((n < e && (n = -1), -1 === n || -1 === this.lastCurrentTime)) { const i = null !== this.startTimeOffset, r = i ? this.startTimeOffset : t.startTimeOffset; null !== r && X(r) ? ((n = e + r), r < 0 && (n += t.totalduration), (n = Math.min(Math.max(e, n), e + t.totalduration)), this.log( `Start time offset ${r} found in ${i ? "multivariant" : "media"} playlist, adjust startPosition to ${n}` ), (this.startPosition = n)) : t.live ? (n = this.hls.liveSyncPosition || e) : (this.startPosition = n = 0), (this.lastCurrentTime = n); } this.nextLoadPosition = n; } getLoadPosition() { const { media: t } = this; let e = 0; return this.loadedmetadata && t ? (e = t.currentTime) : this.nextLoadPosition && (e = this.nextLoadPosition), e; } handleFragLoadAborted(t, e) { this.transmuxer && "initSegment" !== t.sn && t.stats.aborted && (this.warn(`Fragment ${t.sn}${e ? " part " + e.index : ""} of level ${t.level} was aborted`), this.resetFragmentLoading(t)); } resetFragmentLoading(t) { (this.fragCurrent && (this.fragContextChanged(t) || this.state === Qi)) || (this.state = qi); } onFragmentOrKeyLoadError(t, e) { if (e.chunkMeta && !e.frag) { const t = this.getCurrentContext(e.chunkMeta); t && (e.frag = t.frag); } const n = e.frag; if (!n || n.type !== t || !this.levels) return; var i; if (this.fragContextChanged(n)) return void this.warn( `Frag load error must match current frag to retry ${n.url} > ${null == (i = this.fragCurrent) ? void 0 : i.url }` ); const r = e.details === nt.FRAG_GAP; r && this.fragmentTracker.fragBuffered(n, !0); const a = e.errorAction, { action: s, retryCount: o = 0, retryConfig: l } = a || {}; if (a && s === ii && l) { this.resetStartWhenNotLoaded(this.levelLastLoaded); const i = qn(l, o); this.warn( `Fragment ${n.sn} of ${t} ${n.level} errored with ${e.details}, retrying loading ${o + 1}/${l.maxNumRetry } in ${i}ms` ), (a.resolved = !0), (this.retryDate = self.performance.now() + i), (this.state = Qi); } else if (l && a) { if ((this.resetFragmentErrors(t), !(o < l.maxNumRetry))) return void ot.warn(`${e.details} reached or exceeded max retry (${o})`); r || s === ni || (a.resolved = !0); } else (null == a ? void 0 : a.action) === ei ? (this.state = ir) : (this.state = er); this.tickImmediate(); } reduceLengthAndFlushBuffer(t) { if (this.state === Ji || this.state === Zi) { const e = t.parent, n = this.getFwdBufferInfo(this.mediaBuffer, e), i = n && n.len > 0.5; i && this.reduceMaxBufferLength(n.len); const r = !i; return ( r && this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`), t.frag && (this.fragmentTracker.removeFragment(t.frag), (this.nextLoadPosition = t.frag.start)), this.resetLoadingState(), r ); } return !1; } resetFragmentErrors(t) { t === dn && (this.fragCurrent = null), this.loadedmetadata || (this.startFragRequested = !1), this.state !== Ki && (this.state = qi); } afterBufferFlushed(t, e, n) { if (!t) return; const i = Li.getBuffered(t); this.fragmentTracker.detectEvictedFragments(e, i, n), this.state === tr && this.resetLoadingState(); } resetLoadingState() { this.log("Reset loading state"), (this.fragCurrent = null), (this.fragPrevious = null), (this.state = qi); } resetStartWhenNotLoaded(t) { if (!this.loadedmetadata) { this.startFragRequested = !1; const e = t ? t.details : null; null != e && e.live ? ((this.startPosition = -1), this.setStartPosition(e, 0), this.resetLoadingState()) : (this.nextLoadPosition = this.startPosition); } } resetWhenMissingContext(t) { this.warn( `The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.` ), this.removeUnbufferedFrags(), this.resetStartWhenNotLoaded(this.levelLastLoaded), this.resetLoadingState(); } removeUnbufferedFrags(t = 0) { this.fragmentTracker.removeFragmentsInRange(t, 1 / 0, this.playlistType, !1, !0); } updateLevelTiming(t, e, n, i) { var r; const a = n.details; if (!a) return void this.warn("level.details undefined"); if ( !Object.keys(t.elementaryStreams).reduce((e, r) => { const s = t.elementaryStreams[r]; if (s) { const o = s.endPTS - s.startPTS; if (o <= 0) return this.warn(`Could not parse fragment ${t.sn} ${r} duration reliably (${o})`), e || !1; const l = i ? 0 : Mn(a, t, s.startPTS, s.endPTS, s.startDTS, s.endDTS); return ( this.hls.trigger(tt.LEVEL_PTS_UPDATED, { details: a, level: n, drift: l, type: r, frag: t, start: s.startPTS, end: s.endPTS }), !0 ); } return e; }, !1) && null === (null == (r = this.transmuxer) ? void 0 : r.error) ) { const e = new Error( `Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing` ); if ( (0 === n.fragmentError && (n.fragmentError++, (t.gap = !0), this.fragmentTracker.removeFragment(t), this.fragmentTracker.fragBuffered(t, !0)), this.warn(e.message), this.hls.trigger(tt.ERROR, { type: et.MEDIA_ERROR, details: nt.FRAG_PARSING_ERROR, fatal: !1, error: e, frag: t, reason: `Found no media in msn ${t.sn} of level "${n.url}"` }), !this.hls) ) return; this.resetTransmuxer(); } (this.state = Zi), this.hls.trigger(tt.FRAG_PARSED, { frag: t, part: e }); } resetTransmuxer() { this.transmuxer && (this.transmuxer.destroy(), (this.transmuxer = null)); } recoverWorkerError(t) { "demuxerWorker" === t.event && (this.fragmentTracker.removeAllFragments(), this.resetTransmuxer(), this.resetStartWhenNotLoaded(this.levelLastLoaded), this.resetLoadingState()); } set state(t) { const e = this._state; e !== t && ((this._state = t), this.log(`${e}->${t}`)); } get state() { return this._state; } } class ar { constructor() { (this.chunks = []), (this.dataLength = 0); } push(t) { this.chunks.push(t), (this.dataLength += t.length); } flush() { const { chunks: t, dataLength: e } = this; let n; return t.length ? ((n = 1 === t.length ? t[0] : (function (t, e) { const n = new Uint8Array(e); let i = 0; for (let e = 0; e < t.length; e++) { const r = t[e]; n.set(r, i), (i += r.length); } return n; })(t, e)), this.reset(), n) : new Uint8Array(0); } reset() { (this.chunks.length = 0), (this.dataLength = 0); } } function sr(t = "", e = 9e4) { return { type: t, id: -1, pid: -1, inputTimeScale: e, sequenceNumber: -1, samples: [], dropped: 0 }; } class or { constructor() { (this._audioTrack = void 0), (this._id3Track = void 0), (this.frameIndex = 0), (this.cachedData = null), (this.basePTS = null), (this.initPTS = null), (this.lastPTS = null); } resetInitSegment(t, e, n, i) { this._id3Track = { type: "id3", id: 3, pid: -1, inputTimeScale: 9e4, sequenceNumber: 0, samples: [], dropped: 0 }; } resetTimeStamp(t) { (this.initPTS = t), this.resetContiguity(); } resetContiguity() { (this.basePTS = null), (this.lastPTS = null), (this.frameIndex = 0); } canParse(t, e) { return !1; } appendFrame(t, e, n) { } demux(t, e) { this.cachedData && ((t = ve(this.cachedData, t)), (this.cachedData = null)); let n, i = Nt(t, 0), r = i ? i.length : 0; const a = this._audioTrack, s = this._id3Track, o = i ? jt(i) : void 0, l = t.length; for ( (null === this.basePTS || (0 === this.frameIndex && X(o))) && ((this.basePTS = lr(o, e, this.initPTS)), (this.lastPTS = this.basePTS)), null === this.lastPTS && (this.lastPTS = this.basePTS), i && i.length > 0 && s.samples.push({ pts: this.lastPTS, dts: this.lastPTS, data: i, type: vn, duration: Number.POSITIVE_INFINITY }); r < l; ) { if (this.canParse(t, r)) { const e = this.appendFrame(a, t, r); e ? (this.frameIndex++, (this.lastPTS = e.sample.pts), (r += e.length), (n = r)) : (r = l); } else Gt(t, r) ? ((i = Nt(t, r)), s.samples.push({ pts: this.lastPTS, dts: this.lastPTS, data: i, type: vn, duration: Number.POSITIVE_INFINITY }), (r += i.length), (n = r)) : r++; if (r === l && n !== l) { const e = Ft(t, n); this.cachedData ? (this.cachedData = ve(this.cachedData, e)) : (this.cachedData = e); } } return { audioTrack: a, videoTrack: sr(), id3Track: s, textTrack: sr() }; } demuxSampleAes(t, e, n) { return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`)); } flush(t) { const e = this.cachedData; return ( e && ((this.cachedData = null), this.demux(e, 0)), { audioTrack: this._audioTrack, videoTrack: sr(), id3Track: this._id3Track, textTrack: sr() } ); } destroy() { } } const lr = (t, e, n) => { if (X(t)) return 90 * t; return 9e4 * e + (n ? (9e4 * n.baseTime) / n.timescale : 0); }; function dr(t, e) { return 255 === t[e] && 240 == (246 & t[e + 1]); } function cr(t, e) { return 1 & t[e + 1] ? 7 : 9; } function ur(t, e) { return ((3 & t[e + 3]) << 11) | (t[e + 4] << 3) | ((224 & t[e + 5]) >>> 5); } function hr(t, e) { return e + 1 < t.length && dr(t, e); } function pr(t, e) { if (hr(t, e)) { const n = cr(t, e); if (e + n >= t.length) return !1; const i = ur(t, e); if (i <= n) return !1; const r = e + i; return r === t.length || hr(t, r); } return !1; } function fr(t, e, n, i, r) { if (!t.samplerate) { const a = (function (t, e, n, i) { let r, a, s, o; const l = navigator.userAgent.toLowerCase(), d = i, c = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350]; r = 1 + ((192 & e[n + 2]) >>> 6); const u = (60 & e[n + 2]) >>> 2; if (!(u > c.length - 1)) return ( (s = (1 & e[n + 2]) << 2), (s |= (192 & e[n + 3]) >>> 6), ot.log(`manifest codec:${i}, ADTS type:${r}, samplingIndex:${u}`), /firefox/i.test(l) ? u >= 6 ? ((r = 5), (o = new Array(4)), (a = u - 3)) : ((r = 2), (o = new Array(2)), (a = u)) : -1 !== l.indexOf("android") ? ((r = 2), (o = new Array(2)), (a = u)) : ((r = 5), (o = new Array(4)), (i && (-1 !== i.indexOf("mp4a.40.29") || -1 !== i.indexOf("mp4a.40.5"))) || (!i && u >= 6) ? (a = u - 3) : (((i && -1 !== i.indexOf("mp4a.40.2") && ((u >= 6 && 1 === s) || /vivaldi/i.test(l))) || (!i && 1 === s)) && ((r = 2), (o = new Array(2))), (a = u))), (o[0] = r << 3), (o[0] |= (14 & u) >> 1), (o[1] |= (1 & u) << 7), (o[1] |= s << 3), 5 === r && ((o[1] |= (14 & a) >> 1), (o[2] = (1 & a) << 7), (o[2] |= 8), (o[3] = 0)), { config: o, samplerate: c[u], channelCount: s, codec: "mp4a.40." + r, manifestCodec: d } ); { const e = new Error(`invalid ADTS sampling index:${u}`); t.emit(tt.ERROR, tt.ERROR, { type: et.MEDIA_ERROR, details: nt.FRAG_PARSING_ERROR, fatal: !0, error: e, reason: e.message }); } })(e, n, i, r); if (!a) return; (t.config = a.config), (t.samplerate = a.samplerate), (t.channelCount = a.channelCount), (t.codec = a.codec), (t.manifestCodec = a.manifestCodec), ot.log(`parsed codec:${t.codec}, rate:${a.samplerate}, channels:${a.channelCount}`); } } function mr(t) { return 9216e4 / t; } function gr(t, e, n, i, r) { const a = i + r * mr(t.samplerate), s = (function (t, e) { const n = cr(t, e); if (e + n <= t.length) { const i = ur(t, e) - n; if (i > 0) return { headerLength: n, frameLength: i }; } })(e, n); let o; if (s) { const { frameLength: i, headerLength: r } = s, l = r + i, d = Math.max(0, n + l - e.length); d ? ((o = new Uint8Array(l - r)), o.set(e.subarray(n + r, e.length), 0)) : (o = e.subarray(n + r, n + l)); const c = { unit: o, pts: a }; return d || t.samples.push(c), { sample: c, length: l, missing: d }; } const l = e.length - n; (o = new Uint8Array(l)), o.set(e.subarray(n, e.length), 0); return { sample: { unit: o, pts: a }, length: l, missing: -1 }; } let yr = null; const Ar = [ 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 ], vr = [44100, 48e3, 32e3, 22050, 24e3, 16e3, 11025, 12e3, 8e3], br = [ [0, 72, 144, 12], [0, 0, 0, 0], [0, 72, 144, 12], [0, 144, 144, 12] ], Er = [0, 1, 1, 4]; function wr(t, e, n, i, r) { if (n + 24 > e.length) return; const a = xr(e, n); if (a && n + a.frameLength <= e.length) { const s = i + r * ((9e4 * a.samplesPerFrame) / a.sampleRate), o = { unit: e.subarray(n, n + a.frameLength), pts: s, dts: s }; return ( (t.config = []), (t.channelCount = a.channelCount), (t.samplerate = a.sampleRate), t.samples.push(o), { sample: o, length: a.frameLength, missing: 0 } ); } } function xr(t, e) { const n = (t[e + 1] >> 3) & 3, i = (t[e + 1] >> 1) & 3, r = (t[e + 2] >> 4) & 15, a = (t[e + 2] >> 2) & 3; if (1 !== n && 0 !== r && 15 !== r && 3 !== a) { const s = (t[e + 2] >> 1) & 1, o = t[e + 3] >> 6, l = 1e3 * Ar[14 * (3 === n ? 3 - i : 3 === i ? 3 : 4) + r - 1], d = vr[3 * (3 === n ? 0 : 2 === n ? 1 : 2) + a], c = 3 === o ? 1 : 2, u = br[n][i], h = Er[i], p = 8 * u * h, f = Math.floor((u * l) / d + s) * h; if (null === yr) { const t = (navigator.userAgent || "").match(/Chrome\/(\d+)/i); yr = t ? parseInt(t[1]) : 0; } return ( !!yr && yr <= 87 && 2 === i && l >= 224e3 && 0 === o && (t[e + 3] = 128 | t[e + 3]), { sampleRate: d, channelCount: c, frameLength: f, samplesPerFrame: p } ); } } function Sr(t, e) { return !(255 !== t[e] || 224 & ~t[e + 1] || !(6 & t[e + 1])); } function _r(t, e) { return e + 1 < t.length && Sr(t, e); } function Tr(t, e) { if (e + 1 < t.length && Sr(t, e)) { const n = 4, i = xr(t, e); let r = n; null != i && i.frameLength && (r = i.frameLength); const a = e + r; return a === t.length || _r(t, a); } return !1; } const kr = /\/emsg[-/]ID3/i; const Cr = (t, e) => { let n = 0, i = 5; e += i; const r = new Uint32Array(1), a = new Uint32Array(1), s = new Uint8Array(1); for (; i > 0;) { s[0] = t[e]; const o = Math.min(i, 8), l = 8 - o; (a[0] = (4278190080 >>> (24 + l)) << l), (r[0] = (s[0] & a[0]) >> l), (n = n ? (n << o) | r[0] : r[0]), (e += 1), (i -= o); } return n; }; class Lr extends or { constructor(t) { super(), (this.observer = void 0), (this.observer = t); } resetInitSegment(t, e, n, i) { super.resetInitSegment(t, e, n, i), (this._audioTrack = { container: "audio/ac-3", type: "audio", id: 2, pid: -1, sequenceNumber: 0, segmentCodec: "ac3", samples: [], manifestCodec: e, duration: i, inputTimeScale: 9e4, dropped: 0 }); } canParse(t, e) { return e + 64 < t.length; } appendFrame(t, e, n) { const i = Ir(t, e, n, this.basePTS, this.frameIndex); if (-1 !== i) { return { sample: t.samples[t.samples.length - 1], length: i, missing: 0 }; } } static probe(t) { if (!t) return !1; const e = Nt(t, 0); if (!e) return !1; const n = e.length; return 11 === t[n] && 119 === t[n + 1] && void 0 !== jt(e) && Cr(t, n) < 16; } } function Ir(t, e, n, i, r) { if (n + 8 > e.length) return -1; if (11 !== e[n] || 119 !== e[n + 1]) return -1; const a = e[n + 4] >> 6; if (a >= 3) return -1; const s = [48e3, 44100, 32e3][a], o = 63 & e[n + 4], l = 2 * [ 64, 69, 96, 64, 70, 96, 80, 87, 120, 80, 88, 120, 96, 104, 144, 96, 105, 144, 112, 121, 168, 112, 122, 168, 128, 139, 192, 128, 140, 192, 160, 174, 240, 160, 175, 240, 192, 208, 288, 192, 209, 288, 224, 243, 336, 224, 244, 336, 256, 278, 384, 256, 279, 384, 320, 348, 480, 320, 349, 480, 384, 417, 576, 384, 418, 576, 448, 487, 672, 448, 488, 672, 512, 557, 768, 512, 558, 768, 640, 696, 960, 640, 697, 960, 768, 835, 1152, 768, 836, 1152, 896, 975, 1344, 896, 976, 1344, 1024, 1114, 1536, 1024, 1115, 1536, 1152, 1253, 1728, 1152, 1254, 1728, 1280, 1393, 1920, 1280, 1394, 1920 ][3 * o + a]; if (n + l > e.length) return -1; const d = e[n + 6] >> 5; let c = 0; 2 === d ? (c += 2) : (1 & d && 1 !== d && (c += 2), 4 & d && (c += 2)); const u = (((e[n + 6] << 8) | e[n + 7]) >> (12 - c)) & 1, h = [2, 1, 2, 3, 3, 4, 4, 5][d] + u, p = e[n + 5] >> 3, f = 7 & e[n + 5], m = new Uint8Array([(a << 6) | (p << 1) | (f >> 2), ((3 & f) << 6) | (d << 3) | (u << 2) | (o >> 4), (o << 4) & 224]), g = i + r * ((1536 / s) * 9e4), y = e.subarray(n, n + l); return (t.config = m), (t.channelCount = h), (t.samplerate = s), t.samples.push({ unit: y, pts: g }), l; } class Rr { constructor() { this.VideoSample = null; } createVideoSample(t, e, n, i) { return { key: t, frame: !1, pts: e, dts: n, units: [], debug: i, length: 0 }; } getLastNalUnit(t) { var e; let n, i = this.VideoSample; if (((i && 0 !== i.units.length) || (i = t[t.length - 1]), null != (e = i) && e.units)) { const t = i.units; n = t[t.length - 1]; } return n; } pushAccessUnit(t, e) { if (t.units.length && t.frame) { if (void 0 === t.pts) { const n = e.samples, i = n.length; if (!i) return void e.dropped++; { const e = n[i - 1]; (t.pts = e.pts), (t.dts = e.dts); } } e.samples.push(t); } t.debug.length && ot.log(t.pts + "/" + t.dts + ":" + t.debug); } } class Dr { constructor(t) { (this.data = void 0), (this.bytesAvailable = void 0), (this.word = void 0), (this.bitsAvailable = void 0), (this.data = t), (this.bytesAvailable = t.byteLength), (this.word = 0), (this.bitsAvailable = 0); } loadWord() { const t = this.data, e = this.bytesAvailable, n = t.byteLength - e, i = new Uint8Array(4), r = Math.min(4, e); if (0 === r) throw new Error("no bytes available"); i.set(t.subarray(n, n + r)), (this.word = new DataView(i.buffer).getUint32(0)), (this.bitsAvailable = 8 * r), (this.bytesAvailable -= r); } skipBits(t) { let e; (t = Math.min(t, 8 * this.bytesAvailable + this.bitsAvailable)), this.bitsAvailable > t ? ((this.word <<= t), (this.bitsAvailable -= t)) : ((e = (t -= this.bitsAvailable) >> 3), (t -= e << 3), (this.bytesAvailable -= e), this.loadWord(), (this.word <<= t), (this.bitsAvailable -= t)); } readBits(t) { let e = Math.min(this.bitsAvailable, t); const n = this.word >>> (32 - e); if ( (t > 32 && ot.error("Cannot read more than 32 bits at a time"), (this.bitsAvailable -= e), this.bitsAvailable > 0) ) this.word <<= e; else { if (!(this.bytesAvailable > 0)) throw new Error("no bits available"); this.loadWord(); } return (e = t - e), e > 0 && this.bitsAvailable ? (n << e) | this.readBits(e) : n; } skipLZ() { let t; for (t = 0; t < this.bitsAvailable; ++t) if (this.word & (2147483648 >>> t)) return (this.word <<= t), (this.bitsAvailable -= t), t; return this.loadWord(), t + this.skipLZ(); } skipUEG() { this.skipBits(1 + this.skipLZ()); } skipEG() { this.skipBits(1 + this.skipLZ()); } readUEG() { const t = this.skipLZ(); return this.readBits(t + 1) - 1; } readEG() { const t = this.readUEG(); return 1 & t ? (1 + t) >>> 1 : -1 * (t >>> 1); } readBoolean() { return 1 === this.readBits(1); } readUByte() { return this.readBits(8); } readUShort() { return this.readBits(16); } readUInt() { return this.readBits(32); } skipScalingList(t) { let e, n = 8, i = 8; for (let r = 0; r < t; r++) 0 !== i && ((e = this.readEG()), (i = (n + e + 256) % 256)), (n = 0 === i ? n : i); } readSPS() { let t, e, n, i = 0, r = 0, a = 0, s = 0; const o = this.readUByte.bind(this), l = this.readBits.bind(this), d = this.readUEG.bind(this), c = this.readBoolean.bind(this), u = this.skipBits.bind(this), h = this.skipEG.bind(this), p = this.skipUEG.bind(this), f = this.skipScalingList.bind(this); o(); const m = o(); if ( (l(5), u(3), o(), p(), 100 === m || 110 === m || 122 === m || 244 === m || 44 === m || 83 === m || 86 === m || 118 === m || 128 === m) ) { const t = d(); if ((3 === t && u(1), p(), p(), u(1), c())) for (e = 3 !== t ? 8 : 12, n = 0; n < e; n++) c() && f(n < 6 ? 16 : 64); } p(); const g = d(); if (0 === g) d(); else if (1 === g) for (u(1), h(), h(), t = d(), n = 0; n < t; n++) h(); p(), u(1); const y = d(), A = d(), v = l(1); 0 === v && u(1), u(1), c() && ((i = d()), (r = d()), (a = d()), (s = d())); let b = [1, 1]; if (c() && c()) { switch (o()) { case 1: b = [1, 1]; break; case 2: b = [12, 11]; break; case 3: b = [10, 11]; break; case 4: b = [16, 11]; break; case 5: b = [40, 33]; break; case 6: b = [24, 11]; break; case 7: b = [20, 11]; break; case 8: b = [32, 11]; break; case 9: b = [80, 33]; break; case 10: b = [18, 11]; break; case 11: b = [15, 11]; break; case 12: b = [64, 33]; break; case 13: b = [160, 99]; break; case 14: b = [4, 3]; break; case 15: b = [3, 2]; break; case 16: b = [2, 1]; break; case 255: b = [(o() << 8) | o(), (o() << 8) | o()]; } } return { width: Math.ceil(16 * (y + 1) - 2 * i - 2 * r), height: (2 - v) * (A + 1) * 16 - (v ? 2 : 4) * (a + s), pixelRatio: b }; } readSliceType() { return this.readUByte(), this.readUEG(), this.readUEG(); } } class Br extends Rr { parseAVCPES(t, e, n, i, r) { const a = this.parseAVCNALu(t, n.data); let s, o = this.VideoSample, l = !1; (n.data = null), o && a.length && !t.audFound && (this.pushAccessUnit(o, t), (o = this.VideoSample = this.createVideoSample(!1, n.pts, n.dts, ""))), a.forEach(i => { var a; switch (i.type) { case 1: { let e = !1; s = !0; const r = i.data; if (l && r.length > 4) { const t = new Dr(r).readSliceType(); (2 !== t && 4 !== t && 7 !== t && 9 !== t) || (e = !0); } var d; if (e) null != (d = o) && d.frame && !o.key && (this.pushAccessUnit(o, t), (o = this.VideoSample = null)); o || (o = this.VideoSample = this.createVideoSample(!0, n.pts, n.dts, "")), (o.frame = !0), (o.key = e); break; } case 5: (s = !0), null != (a = o) && a.frame && !o.key && (this.pushAccessUnit(o, t), (o = this.VideoSample = null)), o || (o = this.VideoSample = this.createVideoSample(!0, n.pts, n.dts, "")), (o.key = !0), (o.frame = !0); break; case 6: (s = !0), we(i.data, 1, n.pts, e.samples); break; case 7: { var c, u; (s = !0), (l = !0); const e = i.data, n = new Dr(e).readSPS(); if ( !t.sps || t.width !== n.width || t.height !== n.height || (null == (c = t.pixelRatio) ? void 0 : c[0]) !== n.pixelRatio[0] || (null == (u = t.pixelRatio) ? void 0 : u[1]) !== n.pixelRatio[1] ) { (t.width = n.width), (t.height = n.height), (t.pixelRatio = n.pixelRatio), (t.sps = [e]), (t.duration = r); const i = e.subarray(1, 4); let a = "avc1."; for (let t = 0; t < 3; t++) { let e = i[t].toString(16); e.length < 2 && (e = "0" + e), (a += e); } t.codec = a; } break; } case 8: (s = !0), (t.pps = [i.data]); break; case 9: (s = !0), (t.audFound = !0), o && this.pushAccessUnit(o, t), (o = this.VideoSample = this.createVideoSample(!1, n.pts, n.dts, "")); break; case 12: s = !0; break; default: (s = !1), o && (o.debug += "unknown NAL " + i.type + " "); } if (o && s) { o.units.push(i); } }), i && o && (this.pushAccessUnit(o, t), (this.VideoSample = null)); } parseAVCNALu(t, e) { const n = e.byteLength; let i = t.naluState || 0; const r = i, a = []; let s, o, l, d = 0, c = -1, u = 0; for (-1 === i && ((c = 0), (u = 31 & e[0]), (i = 0), (d = 1)); d < n;) if (((s = e[d++]), i)) if (1 !== i) if (s) if (1 === s) { if (((o = d - i - 1), c >= 0)) { const t = { data: e.subarray(c, o), type: u }; a.push(t); } else { const n = this.getLastNalUnit(t.samples); n && (r && d <= 4 - r && n.state && (n.data = n.data.subarray(0, n.data.byteLength - r)), o > 0 && ((n.data = ve(n.data, e.subarray(0, o))), (n.state = 0))); } d < n ? ((l = 31 & e[d]), (c = d), (u = l), (i = 0)) : (i = -1); } else i = 0; else i = 3; else i = s ? 0 : 2; else i = s ? 0 : 1; if (c >= 0 && i >= 0) { const t = { data: e.subarray(c, n), type: u, state: i }; a.push(t); } if (0 === a.length) { const n = this.getLastNalUnit(t.samples); n && (n.data = ve(n.data, e)); } return (t.naluState = i), a; } } class Pr { constructor(t, e, n) { (this.keyData = void 0), (this.decrypter = void 0), (this.keyData = n), (this.decrypter = new Yi(e, { removePKCS7Padding: !1 })); } decryptBuffer(t) { return this.decrypter.decrypt(t, this.keyData.key.buffer, this.keyData.iv.buffer); } decryptAacSample(t, e, n) { const i = t[e].unit; if (i.length <= 16) return; const r = i.subarray(16, i.length - (i.length % 16)), a = r.buffer.slice(r.byteOffset, r.byteOffset + r.length); this.decryptBuffer(a).then(r => { const a = new Uint8Array(r); i.set(a, 16), this.decrypter.isSync() || this.decryptAacSamples(t, e + 1, n); }); } decryptAacSamples(t, e, n) { for (; ; e++) { if (e >= t.length) return void n(); if (!(t[e].unit.length < 32) && (this.decryptAacSample(t, e, n), !this.decrypter.isSync())) return; } } getAvcEncryptedData(t) { const e = 16 * Math.floor((t.length - 48) / 160) + 16, n = new Int8Array(e); let i = 0; for (let e = 32; e < t.length - 16; e += 160, i += 16) n.set(t.subarray(e, e + 16), i); return n; } getAvcDecryptedUnit(t, e) { const n = new Uint8Array(e); let i = 0; for (let e = 32; e < t.length - 16; e += 160, i += 16) t.set(n.subarray(i, i + 16), e); return t; } decryptAvcSample(t, e, n, i, r) { const a = xe(r.data), s = this.getAvcEncryptedData(a); this.decryptBuffer(s.buffer).then(s => { (r.data = this.getAvcDecryptedUnit(a, s)), this.decrypter.isSync() || this.decryptAvcSamples(t, e, n + 1, i); }); } decryptAvcSamples(t, e, n, i) { if (t instanceof Uint8Array) throw new Error("Cannot decrypt samples of type Uint8Array"); for (; ; e++, n = 0) { if (e >= t.length) return void i(); const r = t[e].units; for (; !(n >= r.length); n++) { const a = r[n]; if ( !( a.data.length <= 48 || (1 !== a.type && 5 !== a.type) || (this.decryptAvcSample(t, e, n, i, a), this.decrypter.isSync()) ) ) return; } } } } const Ur = 188; class Fr { constructor(t, e, n) { (this.observer = void 0), (this.config = void 0), (this.typeSupported = void 0), (this.sampleAes = null), (this.pmtParsed = !1), (this.audioCodec = void 0), (this.videoCodec = void 0), (this._duration = 0), (this._pmtId = -1), (this._videoTrack = void 0), (this._audioTrack = void 0), (this._id3Track = void 0), (this._txtTrack = void 0), (this.aacOverFlow = null), (this.remainderData = null), (this.videoParser = void 0), (this.observer = t), (this.config = e), (this.typeSupported = n), (this.videoParser = new Br()); } static probe(t) { const e = Fr.syncOffset(t); return e > 0 && ot.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`), -1 !== e; } static syncOffset(t) { const e = t.length; let n = Math.min(940, e - Ur) + 1, i = 0; for (; i < n;) { let r = !1, a = -1, s = 0; for (let o = i; o < e; o += Ur) { if (71 !== t[o] || (e - o !== Ur && 71 !== t[o + Ur])) { if (s) return -1; break; } if ( (s++, -1 === a && ((a = o), 0 !== a && (n = Math.min(a + 18612, t.length - Ur) + 1)), r || (r = 0 === Or(t, o)), r && s > 1 && ((0 === a && s > 2) || o + Ur > n)) ) return a; } i++; } return -1; } static createTrack(t, e) { return { container: "video" === t || "audio" === t ? "video/mp2t" : void 0, type: t, id: ie[t], pid: -1, inputTimeScale: 9e4, sequenceNumber: 0, samples: [], dropped: 0, duration: "audio" === t ? e : void 0 }; } resetInitSegment(t, e, n, i) { (this.pmtParsed = !1), (this._pmtId = -1), (this._videoTrack = Fr.createTrack("video")), (this._audioTrack = Fr.createTrack("audio", i)), (this._id3Track = Fr.createTrack("id3")), (this._txtTrack = Fr.createTrack("text")), (this._audioTrack.segmentCodec = "aac"), (this.aacOverFlow = null), (this.remainderData = null), (this.audioCodec = e), (this.videoCodec = n), (this._duration = i); } resetTimeStamp() { } resetContiguity() { const { _audioTrack: t, _videoTrack: e, _id3Track: n } = this; t && (t.pesData = null), e && (e.pesData = null), n && (n.pesData = null), (this.aacOverFlow = null), (this.remainderData = null); } demux(t, e, n = !1, i = !1) { let r; n || (this.sampleAes = null); const a = this._videoTrack, s = this._audioTrack, o = this._id3Track, l = this._txtTrack; let d = a.pid, c = a.pesData, u = s.pid, h = o.pid, p = s.pesData, f = o.pesData, m = null, g = this.pmtParsed, y = this._pmtId, A = t.length; if ((this.remainderData && ((A = (t = ve(this.remainderData, t)).length), (this.remainderData = null)), A < Ur && !i)) return (this.remainderData = t), { audioTrack: s, videoTrack: a, id3Track: o, textTrack: l }; const v = Math.max(0, Fr.syncOffset(t)); (A -= (A - v) % Ur), A < t.byteLength && !i && (this.remainderData = new Uint8Array(t.buffer, A, t.buffer.byteLength - A)); let b = 0; for (let e = v; e < A; e += Ur) if (71 === t[e]) { const i = !!(64 & t[e + 1]), A = Or(t, e); let b; if ((48 & t[e + 3]) >> 4 > 1) { if (((b = e + 5 + t[e + 4]), b === e + Ur)) continue; } else b = e + 4; switch (A) { case d: i && (c && (r = Gr(c)) && this.videoParser.parseAVCPES(a, l, r, !1, this._duration), (c = { data: [], size: 0 })), c && (c.data.push(t.subarray(b, e + Ur)), (c.size += e + Ur - b)); break; case u: if (i) { if (p && (r = Gr(p))) switch (s.segmentCodec) { case "aac": this.parseAACPES(s, r); break; case "mp3": this.parseMPEGPES(s, r); break; case "ac3": this.parseAC3PES(s, r); } p = { data: [], size: 0 }; } p && (p.data.push(t.subarray(b, e + Ur)), (p.size += e + Ur - b)); break; case h: i && (f && (r = Gr(f)) && this.parseID3PES(o, r), (f = { data: [], size: 0 })), f && (f.data.push(t.subarray(b, e + Ur)), (f.size += e + Ur - b)); break; case 0: i && (b += t[b] + 1), (y = this._pmtId = Mr(t, b)); break; case y: { i && (b += t[b] + 1); const r = Nr(t, b, this.typeSupported, n); (d = r.videoPid), d > 0 && ((a.pid = d), (a.segmentCodec = r.segmentVideoCodec)), (u = r.audioPid), u > 0 && ((s.pid = u), (s.segmentCodec = r.segmentAudioCodec)), (h = r.id3Pid), h > 0 && (o.pid = h), null === m || g || (ot.warn( `MPEG-TS PMT found at ${e} after unknown PID '${m}'. Backtracking to sync byte @${v} to parse all TS packets.` ), (m = null), (e = v - 188)), (g = this.pmtParsed = !0); break; } case 17: case 8191: break; default: m = A; } } else b++; if (b > 0) { const t = new Error(`Found ${b} TS packet/s that do not start with 0x47`); this.observer.emit(tt.ERROR, tt.ERROR, { type: et.MEDIA_ERROR, details: nt.FRAG_PARSING_ERROR, fatal: !1, error: t, reason: t.message }); } (a.pesData = c), (s.pesData = p), (o.pesData = f); const E = { audioTrack: s, videoTrack: a, id3Track: o, textTrack: l }; return i && this.extractRemainingSamples(E), E; } flush() { const { remainderData: t } = this; let e; return ( (this.remainderData = null), (e = t ? this.demux(t, -1, !1, !0) : { videoTrack: this._videoTrack, audioTrack: this._audioTrack, id3Track: this._id3Track, textTrack: this._txtTrack }), this.extractRemainingSamples(e), this.sampleAes ? this.decrypt(e, this.sampleAes) : e ); } extractRemainingSamples(t) { const { audioTrack: e, videoTrack: n, id3Track: i, textTrack: r } = t, a = n.pesData, s = e.pesData, o = i.pesData; let l; if ( (a && (l = Gr(a)) ? (this.videoParser.parseAVCPES(n, r, l, !0, this._duration), (n.pesData = null)) : (n.pesData = a), s && (l = Gr(s))) ) { switch (e.segmentCodec) { case "aac": this.parseAACPES(e, l); break; case "mp3": this.parseMPEGPES(e, l); break; case "ac3": this.parseAC3PES(e, l); } e.pesData = null; } else null != s && s.size && ot.log("last AAC PES packet truncated,might overlap between fragments"), (e.pesData = s); o && (l = Gr(o)) ? (this.parseID3PES(i, l), (i.pesData = null)) : (i.pesData = o); } demuxSampleAes(t, e, n) { const i = this.demux(t, n, !0, !this.config.progressive), r = (this.sampleAes = new Pr(this.observer, this.config, e)); return this.decrypt(i, r); } decrypt(t, e) { return new Promise(n => { const { audioTrack: i, videoTrack: r } = t; i.samples && "aac" === i.segmentCodec ? e.decryptAacSamples(i.samples, 0, () => { r.samples ? e.decryptAvcSamples(r.samples, 0, 0, () => { n(t); }) : n(t); }) : r.samples && e.decryptAvcSamples(r.samples, 0, 0, () => { n(t); }); }); } destroy() { this._duration = 0; } parseAACPES(t, e) { let n = 0; const i = this.aacOverFlow; let r, a, s, o = e.data; if (i) { this.aacOverFlow = null; const e = i.missing, r = i.sample.unit.byteLength; if (-1 === e) o = ve(i.sample.unit, o); else { const a = r - e; i.sample.unit.set(o.subarray(0, e), a), t.samples.push(i.sample), (n = i.missing); } } for (r = n, a = o.length; r < a - 1 && !hr(o, r); r++); if (r !== n) { let t; const e = r < a - 1; t = e ? `AAC PES did not start with ADTS header,offset:${r}` : "No ADTS header found in AAC PES"; const n = new Error(t); if ( (ot.warn(`parsing error: ${t}`), this.observer.emit(tt.ERROR, tt.ERROR, { type: et.MEDIA_ERROR, details: nt.FRAG_PARSING_ERROR, fatal: !1, levelRetry: e, error: n, reason: t }), !e) ) return; } if ((fr(t, this.observer, o, r, this.audioCodec), void 0 !== e.pts)) s = e.pts; else { if (!i) return void ot.warn("[tsdemuxer]: AAC PES unknown PTS"); { const e = mr(t.samplerate); s = i.sample.pts + e; } } let l, d = 0; for (; r < a;) { if (((l = gr(t, o, r, s, d)), (r += l.length), l.missing)) { this.aacOverFlow = l; break; } for (d++; r < a - 1 && !hr(o, r); r++); } } parseMPEGPES(t, e) { const n = e.data, i = n.length; let r = 0, a = 0; const s = e.pts; if (void 0 !== s) for (; a < i;) if (_r(n, a)) { const e = wr(t, n, a, s, r); if (!e) break; (a += e.length), r++; } else a++; else ot.warn("[tsdemuxer]: MPEG PES unknown PTS"); } parseAC3PES(t, e) { { const n = e.data, i = e.pts; if (void 0 === i) return void ot.warn("[tsdemuxer]: AC3 PES unknown PTS"); const r = n.length; let a, s = 0, o = 0; for (; o < r && (a = Ir(t, n, o, i, s++)) > 0;) o += a; } } parseID3PES(t, e) { if (void 0 === e.pts) return void ot.warn("[tsdemuxer]: ID3 PES unknown PTS"); const n = Q({}, e, { type: this._videoTrack ? En : vn, duration: Number.POSITIVE_INFINITY }); t.samples.push(n); } } function Or(t, e) { return ((31 & t[e + 1]) << 8) + t[e + 2]; } function Mr(t, e) { return ((31 & t[e + 10]) << 8) | t[e + 11]; } function Nr(t, e, n, i) { const r = { audioPid: -1, videoPid: -1, id3Pid: -1, segmentVideoCodec: "avc", segmentAudioCodec: "aac" }, a = e + 3 + (((15 & t[e + 1]) << 8) | t[e + 2]) - 4; for (e += 12 + (((15 & t[e + 10]) << 8) | t[e + 11]); e < a;) { const a = Or(t, e), s = ((15 & t[e + 3]) << 8) | t[e + 4]; switch (t[e]) { case 207: if (!i) { zr("ADTS AAC"); break; } case 15: -1 === r.audioPid && (r.audioPid = a); break; case 21: -1 === r.id3Pid && (r.id3Pid = a); break; case 219: if (!i) { zr("H.264"); break; } case 27: -1 === r.videoPid && ((r.videoPid = a), (r.segmentVideoCodec = "avc")); break; case 3: case 4: n.mpeg || n.mp3 ? -1 === r.audioPid && ((r.audioPid = a), (r.segmentAudioCodec = "mp3")) : ot.log("MPEG audio found, not supported in this browser"); break; case 193: if (!i) { zr("AC-3"); break; } case 129: n.ac3 ? -1 === r.audioPid && ((r.audioPid = a), (r.segmentAudioCodec = "ac3")) : ot.log("AC-3 audio found, not supported in this browser"); break; case 6: if (-1 === r.audioPid && s > 0) { let i = e + 5, o = s; for (; o > 2;) { if (106 === t[i]) !0 !== n.ac3 ? ot.log("AC-3 audio found, not supported in this browser for now") : ((r.audioPid = a), (r.segmentAudioCodec = "ac3")); const e = t[i + 1] + 2; (i += e), (o -= e); } } break; case 194: case 135: ot.warn("Unsupported EC-3 in M2TS found"); break; case 36: ot.warn("Unsupported HEVC in M2TS found"); } e += s + 5; } return r; } function zr(t) { ot.log(`${t} with AES-128-CBC encryption found in unencrypted stream`); } function Gr(t) { let e, n, i, r, a, s = 0; const o = t.data; if (!t || 0 === t.size) return null; for (; o[0].length < 19 && o.length > 1;) (o[0] = ve(o[0], o[1])), o.splice(1, 1); e = o[0]; if (1 === (e[0] << 16) + (e[1] << 8) + e[2]) { if (((n = (e[4] << 8) + e[5]), n && n > t.size - 6)) return null; const l = e[7]; 192 & l && ((r = 536870912 * (14 & e[9]) + 4194304 * (255 & e[10]) + 16384 * (254 & e[11]) + 128 * (255 & e[12]) + (254 & e[13]) / 2), 64 & l ? ((a = 536870912 * (14 & e[14]) + 4194304 * (255 & e[15]) + 16384 * (254 & e[16]) + 128 * (255 & e[17]) + (254 & e[18]) / 2), r - a > 54e5 && (ot.warn(`${Math.round((r - a) / 9e4)}s delta between PTS and DTS, align them`), (r = a))) : (a = r)), (i = e[8]); let d = i + 9; if (t.size <= d) return null; t.size -= d; const c = new Uint8Array(t.size); for (let t = 0, n = o.length; t < n; t++) { e = o[t]; let n = e.byteLength; if (d) { if (d > n) { d -= n; continue; } (e = e.subarray(d)), (n -= d), (d = 0); } c.set(e, s), (s += n); } return n && (n -= i + 3), { data: c, pts: r, dts: a, len: n }; } return null; } class jr { static getSilentFrame(t, e) { if ("mp4a.40.2" === t) { if (1 === e) return new Uint8Array([0, 200, 0, 128, 35, 128]); if (2 === e) return new Uint8Array([33, 0, 73, 144, 2, 25, 0, 35, 128]); if (3 === e) return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 142]); if (4 === e) return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 128, 44, 128, 8, 2, 56]); if (5 === e) return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 56]); if (6 === e) return new Uint8Array([ 0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 0, 178, 0, 32, 8, 224 ]); } else { if (1 === e) return new Uint8Array([ 1, 64, 34, 128, 163, 78, 230, 128, 186, 8, 0, 0, 0, 28, 6, 241, 193, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94 ]); if (2 === e) return new Uint8Array([ 1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94 ]); if (3 === e) return new Uint8Array([ 1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94 ]); } } } const Hr = Math.pow(2, 32) - 1; class Yr { static init() { let t; for (t in ((Yr.types = { avc1: [], avcC: [], btrt: [], dinf: [], dref: [], esds: [], ftyp: [], hdlr: [], mdat: [], mdhd: [], mdia: [], mfhd: [], minf: [], moof: [], moov: [], mp4a: [], ".mp3": [], dac3: [], "ac-3": [], mvex: [], mvhd: [], pasp: [], sdtp: [], stbl: [], stco: [], stsc: [], stsd: [], stsz: [], stts: [], tfdt: [], tfhd: [], traf: [], trak: [], trun: [], trex: [], tkhd: [], vmhd: [], smhd: [] }), Yr.types)) Yr.types.hasOwnProperty(t) && (Yr.types[t] = [t.charCodeAt(0), t.charCodeAt(1), t.charCodeAt(2), t.charCodeAt(3)]); const e = new Uint8Array([ 0, 0, 0, 0, 0, 0, 0, 0, 118, 105, 100, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 105, 100, 101, 111, 72, 97, 110, 100, 108, 101, 114, 0 ]), n = new Uint8Array([ 0, 0, 0, 0, 0, 0, 0, 0, 115, 111, 117, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 111, 117, 110, 100, 72, 97, 110, 100, 108, 101, 114, 0 ]); Yr.HDLR_TYPES = { video: e, audio: n }; const i = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 117, 114, 108, 32, 0, 0, 0, 1]), r = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); (Yr.STTS = Yr.STSC = Yr.STCO = r), (Yr.STSZ = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])), (Yr.VMHD = new Uint8Array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0])), (Yr.SMHD = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0])), (Yr.STSD = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1])); const a = new Uint8Array([105, 115, 111, 109]), s = new Uint8Array([97, 118, 99, 49]), o = new Uint8Array([0, 0, 0, 1]); (Yr.FTYP = Yr.box(Yr.types.ftyp, a, o, a, s)), (Yr.DINF = Yr.box(Yr.types.dinf, Yr.box(Yr.types.dref, i))); } static box(t, ...e) { let n = 8, i = e.length; const r = i; for (; i--;) n += e[i].byteLength; const a = new Uint8Array(n); for ( a[0] = (n >> 24) & 255, a[1] = (n >> 16) & 255, a[2] = (n >> 8) & 255, a[3] = 255 & n, a.set(t, 4), i = 0, n = 8; i < r; i++ ) a.set(e[i], n), (n += e[i].byteLength); return a; } static hdlr(t) { return Yr.box(Yr.types.hdlr, Yr.HDLR_TYPES[t]); } static mdat(t) { return Yr.box(Yr.types.mdat, t); } static mdhd(t, e) { e *= t; const n = Math.floor(e / (Hr + 1)), i = Math.floor(e % (Hr + 1)); return Yr.box( Yr.types.mdhd, new Uint8Array([ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, (t >> 24) & 255, (t >> 16) & 255, (t >> 8) & 255, 255 & t, n >> 24, (n >> 16) & 255, (n >> 8) & 255, 255 & n, i >> 24, (i >> 16) & 255, (i >> 8) & 255, 255 & i, 85, 196, 0, 0 ]) ); } static mdia(t) { return Yr.box(Yr.types.mdia, Yr.mdhd(t.timescale, t.duration), Yr.hdlr(t.type), Yr.minf(t)); } static mfhd(t) { return Yr.box(Yr.types.mfhd, new Uint8Array([0, 0, 0, 0, t >> 24, (t >> 16) & 255, (t >> 8) & 255, 255 & t])); } static minf(t) { return "audio" === t.type ? Yr.box(Yr.types.minf, Yr.box(Yr.types.smhd, Yr.SMHD), Yr.DINF, Yr.stbl(t)) : Yr.box(Yr.types.minf, Yr.box(Yr.types.vmhd, Yr.VMHD), Yr.DINF, Yr.stbl(t)); } static moof(t, e, n) { return Yr.box(Yr.types.moof, Yr.mfhd(t), Yr.traf(n, e)); } static moov(t) { let e = t.length; const n = []; for (; e--;) n[e] = Yr.trak(t[e]); return Yr.box.apply(null, [Yr.types.moov, Yr.mvhd(t[0].timescale, t[0].duration)].concat(n).concat(Yr.mvex(t))); } static mvex(t) { let e = t.length; const n = []; for (; e--;) n[e] = Yr.trex(t[e]); return Yr.box.apply(null, [Yr.types.mvex, ...n]); } static mvhd(t, e) { e *= t; const n = Math.floor(e / (Hr + 1)), i = Math.floor(e % (Hr + 1)), r = new Uint8Array([ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, (t >> 24) & 255, (t >> 16) & 255, (t >> 8) & 255, 255 & t, n >> 24, (n >> 16) & 255, (n >> 8) & 255, 255 & n, i >> 24, (i >> 16) & 255, (i >> 8) & 255, 255 & i, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255 ]); return Yr.box(Yr.types.mvhd, r); } static sdtp(t) { const e = t.samples || [], n = new Uint8Array(4 + e.length); let i, r; for (i = 0; i < e.length; i++) (r = e[i].flags), (n[i + 4] = (r.dependsOn << 4) | (r.isDependedOn << 2) | r.hasRedundancy); return Yr.box(Yr.types.sdtp, n); } static stbl(t) { return Yr.box( Yr.types.stbl, Yr.stsd(t), Yr.box(Yr.types.stts, Yr.STTS), Yr.box(Yr.types.stsc, Yr.STSC), Yr.box(Yr.types.stsz, Yr.STSZ), Yr.box(Yr.types.stco, Yr.STCO) ); } static avc1(t) { let e, n, i, r = [], a = []; for (e = 0; e < t.sps.length; e++) (n = t.sps[e]), (i = n.byteLength), r.push((i >>> 8) & 255), r.push(255 & i), (r = r.concat(Array.prototype.slice.call(n))); for (e = 0; e < t.pps.length; e++) (n = t.pps[e]), (i = n.byteLength), a.push((i >>> 8) & 255), a.push(255 & i), (a = a.concat(Array.prototype.slice.call(n))); const s = Yr.box( Yr.types.avcC, new Uint8Array([1, r[3], r[4], r[5], 255, 224 | t.sps.length].concat(r).concat([t.pps.length]).concat(a)) ), o = t.width, l = t.height, d = t.pixelRatio[0], c = t.pixelRatio[1]; return Yr.box( Yr.types.avc1, new Uint8Array([ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (o >> 8) & 255, 255 & o, (l >> 8) & 255, 255 & l, 0, 72, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 1, 18, 100, 97, 105, 108, 121, 109, 111, 116, 105, 111, 110, 47, 104, 108, 115, 46, 106, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 17, 17 ]), s, Yr.box(Yr.types.btrt, new Uint8Array([0, 28, 156, 128, 0, 45, 198, 192, 0, 45, 198, 192])), Yr.box( Yr.types.pasp, new Uint8Array([ d >> 24, (d >> 16) & 255, (d >> 8) & 255, 255 & d, c >> 24, (c >> 16) & 255, (c >> 8) & 255, 255 & c ]) ) ); } static esds(t) { const e = t.config.length; return new Uint8Array( [0, 0, 0, 0, 3, 23 + e, 0, 1, 0, 4, 15 + e, 64, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5] .concat([e]) .concat(t.config) .concat([6, 1, 2]) ); } static audioStsd(t) { const e = t.samplerate; return new Uint8Array([ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, t.channelCount, 0, 16, 0, 0, 0, 0, (e >> 8) & 255, 255 & e, 0, 0 ]); } static mp4a(t) { return Yr.box(Yr.types.mp4a, Yr.audioStsd(t), Yr.box(Yr.types.esds, Yr.esds(t))); } static mp3(t) { return Yr.box(Yr.types[".mp3"], Yr.audioStsd(t)); } static ac3(t) { return Yr.box(Yr.types["ac-3"], Yr.audioStsd(t), Yr.box(Yr.types.dac3, t.config)); } static stsd(t) { return "audio" === t.type ? "mp3" === t.segmentCodec && "mp3" === t.codec ? Yr.box(Yr.types.stsd, Yr.STSD, Yr.mp3(t)) : "ac3" === t.segmentCodec ? Yr.box(Yr.types.stsd, Yr.STSD, Yr.ac3(t)) : Yr.box(Yr.types.stsd, Yr.STSD, Yr.mp4a(t)) : Yr.box(Yr.types.stsd, Yr.STSD, Yr.avc1(t)); } static tkhd(t) { const e = t.id, n = t.duration * t.timescale, i = t.width, r = t.height, a = Math.floor(n / (Hr + 1)), s = Math.floor(n % (Hr + 1)); return Yr.box( Yr.types.tkhd, new Uint8Array([ 1, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, (e >> 24) & 255, (e >> 16) & 255, (e >> 8) & 255, 255 & e, 0, 0, 0, 0, a >> 24, (a >> 16) & 255, (a >> 8) & 255, 255 & a, s >> 24, (s >> 16) & 255, (s >> 8) & 255, 255 & s, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, (i >> 8) & 255, 255 & i, 0, 0, (r >> 8) & 255, 255 & r, 0, 0 ]) ); } static traf(t, e) { const n = Yr.sdtp(t), i = t.id, r = Math.floor(e / (Hr + 1)), a = Math.floor(e % (Hr + 1)); return Yr.box( Yr.types.traf, Yr.box(Yr.types.tfhd, new Uint8Array([0, 0, 0, 0, i >> 24, (i >> 16) & 255, (i >> 8) & 255, 255 & i])), Yr.box( Yr.types.tfdt, new Uint8Array([ 1, 0, 0, 0, r >> 24, (r >> 16) & 255, (r >> 8) & 255, 255 & r, a >> 24, (a >> 16) & 255, (a >> 8) & 255, 255 & a ]) ), Yr.trun(t, n.length + 16 + 20 + 8 + 16 + 8 + 8), n ); } static trak(t) { return (t.duration = t.duration || 4294967295), Yr.box(Yr.types.trak, Yr.tkhd(t), Yr.mdia(t)); } static trex(t) { const e = t.id; return Yr.box( Yr.types.trex, new Uint8Array([ 0, 0, 0, 0, e >> 24, (e >> 16) & 255, (e >> 8) & 255, 255 & e, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]) ); } static trun(t, e) { const n = t.samples || [], i = n.length, r = 12 + 16 * i, a = new Uint8Array(r); let s, o, l, d, c, u; for ( e += 8 + r, a.set( [ "video" === t.type ? 1 : 0, 0, 15, 1, (i >>> 24) & 255, (i >>> 16) & 255, (i >>> 8) & 255, 255 & i, (e >>> 24) & 255, (e >>> 16) & 255, (e >>> 8) & 255, 255 & e ], 0 ), s = 0; s < i; s++ ) (o = n[s]), (l = o.duration), (d = o.size), (c = o.flags), (u = o.cts), a.set( [ (l >>> 24) & 255, (l >>> 16) & 255, (l >>> 8) & 255, 255 & l, (d >>> 24) & 255, (d >>> 16) & 255, (d >>> 8) & 255, 255 & d, (c.isLeading << 2) | c.dependsOn, (c.isDependedOn << 6) | (c.hasRedundancy << 4) | (c.paddingValue << 1) | c.isNonSync, 61440 & c.degradPrio, 15 & c.degradPrio, (u >>> 24) & 255, (u >>> 16) & 255, (u >>> 8) & 255, 255 & u ], 12 + 16 * s ); return Yr.box(Yr.types.trun, a); } static initSegment(t) { Yr.types || Yr.init(); const e = Yr.moov(t); return ve(Yr.FTYP, e); } } (Yr.types = void 0), (Yr.HDLR_TYPES = void 0), (Yr.STTS = void 0), (Yr.STSC = void 0), (Yr.STCO = void 0), (Yr.STSZ = void 0), (Yr.VMHD = void 0), (Yr.SMHD = void 0), (Yr.STSD = void 0), (Yr.FTYP = void 0), (Yr.DINF = void 0); const $r = 9e4; function Kr(t, e, n = 1, i = !1) { const r = t * e * n; return i ? Math.round(r) : r; } function qr(t, e = !1) { return Kr(t, 1e3, 1 / $r, e); } let Vr, Wr = null, Qr = null; class Xr { constructor(t, e, n, i = "") { if ( ((this.observer = void 0), (this.config = void 0), (this.typeSupported = void 0), (this.ISGenerated = !1), (this._initPTS = null), (this._initDTS = null), (this.nextAvcDts = null), (this.nextAudioPts = null), (this.videoSampleDuration = null), (this.isAudioContiguous = !1), (this.isVideoContiguous = !1), (this.videoTrackConfig = void 0), (this.observer = t), (this.config = e), (this.typeSupported = n), (this.ISGenerated = !1), null === Wr) ) { const t = (navigator.userAgent || "").match(/Chrome\/(\d+)/i); Wr = t ? parseInt(t[1]) : 0; } if (null === Qr) { const t = navigator.userAgent.match(/Safari\/(\d+)/i); Qr = t ? parseInt(t[1]) : 0; } } destroy() { this.config = this.videoTrackConfig = this._initPTS = this._initDTS = null; } resetTimeStamp(t) { ot.log("[mp4-remuxer]: initPTS & initDTS reset"), (this._initPTS = this._initDTS = t); } resetNextTimestamp() { ot.log("[mp4-remuxer]: reset next timestamp"), (this.isVideoContiguous = !1), (this.isAudioContiguous = !1); } resetInitSegment() { ot.log("[mp4-remuxer]: ISGenerated flag reset"), (this.ISGenerated = !1), (this.videoTrackConfig = void 0); } getVideoStartPts(t) { let e = !1; const n = t.reduce((t, n) => { const i = n.pts - t; return i < -4294967296 ? ((e = !0), Jr(t, n.pts)) : i > 0 ? t : n.pts; }, t[0].pts); return e && ot.debug("PTS rollover detected"), n; } remux(t, e, n, i, r, a, s, o) { let l, d, c, u, h, p, f = r, m = r; const g = t.pid > -1, y = e.pid > -1, A = e.samples.length, v = t.samples.length > 0, b = (s && A > 0) || A > 1; if (((!g || v) && (!y || b)) || this.ISGenerated || s) { if (this.ISGenerated) { var E, w, x, S; const t = this.videoTrackConfig; !t || (e.width === t.width && e.height === t.height && (null == (E = e.pixelRatio) ? void 0 : E[0]) === (null == (w = t.pixelRatio) ? void 0 : w[0]) && (null == (x = e.pixelRatio) ? void 0 : x[1]) === (null == (S = t.pixelRatio) ? void 0 : S[1])) || this.resetInitSegment(); } else c = this.generateIS(t, e, r, a); const n = this.isVideoContiguous; let i, s = -1; if ( b && ((s = (function (t) { for (let e = 0; e < t.length; e++) if (t[e].key) return e; return -1; })(e.samples)), !n && this.config.forceKeyFrameOnDiscontinuity) ) if (((p = !0), s > 0)) { ot.warn(`[mp4-remuxer]: Dropped ${s} out of ${A} video samples due to a missing keyframe`); const t = this.getVideoStartPts(e.samples); (e.samples = e.samples.slice(s)), (e.dropped += s), (m += (e.samples[0].pts - t) / e.inputTimeScale), (i = m); } else -1 === s && (ot.warn(`[mp4-remuxer]: No keyframe found out of ${A} video samples`), (p = !1)); if (this.ISGenerated) { if (v && b) { const n = this.getVideoStartPts(e.samples), i = (Jr(t.samples[0].pts, n) - n) / e.inputTimeScale; (f += Math.max(0, i)), (m += Math.max(0, -i)); } if (v) { if ( (t.samplerate || (ot.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"), (c = this.generateIS(t, e, r, a))), (d = this.remuxAudio(t, f, this.isAudioContiguous, a, y || b || o === dn ? m : void 0)), b) ) { const i = d ? d.endPTS - d.startPTS : 0; e.inputTimeScale || (ot.warn("[mp4-remuxer]: regenerate InitSegment as video detected"), (c = this.generateIS(t, e, r, a))), (l = this.remuxVideo(e, m, n, i)); } } else b && (l = this.remuxVideo(e, m, n, 0)); l && ((l.firstKeyFrame = s), (l.independent = -1 !== s), (l.firstKeyFramePTS = i)); } } return ( this.ISGenerated && this._initPTS && this._initDTS && (n.samples.length && (h = Zr(n, r, this._initPTS, this._initDTS)), i.samples.length && (u = ta(i, r, this._initPTS))), { audio: d, video: l, initSegment: c, independent: p, text: u, id3: h } ); } generateIS(t, e, n, i) { const r = t.samples, a = e.samples, s = this.typeSupported, o = {}, l = this._initPTS; let d, c, u, h = !l || i, p = "audio/mp4"; if ((h && (d = c = 1 / 0), t.config && r.length)) { switch (((t.timescale = t.samplerate), t.segmentCodec)) { case "mp3": s.mpeg ? ((p = "audio/mpeg"), (t.codec = "")) : s.mp3 && (t.codec = "mp3"); break; case "ac3": t.codec = "ac-3"; } (o.audio = { id: "audio", container: p, codec: t.codec, initSegment: "mp3" === t.segmentCodec && s.mpeg ? new Uint8Array(0) : Yr.initSegment([t]), metadata: { channelCount: t.channelCount } }), h && ((u = t.inputTimeScale), l && u === l.timescale ? (h = !1) : (d = c = r[0].pts - Math.round(u * n))); } if (e.sps && e.pps && a.length) { if ( ((e.timescale = e.inputTimeScale), (o.video = { id: "main", container: "video/mp4", codec: e.codec, initSegment: Yr.initSegment([e]), metadata: { width: e.width, height: e.height } }), h) ) if (((u = e.inputTimeScale), l && u === l.timescale)) h = !1; else { const t = this.getVideoStartPts(a), e = Math.round(u * n); (c = Math.min(c, Jr(a[0].dts, t) - e)), (d = Math.min(d, t - e)); } this.videoTrackConfig = { width: e.width, height: e.height, pixelRatio: e.pixelRatio }; } if (Object.keys(o).length) return ( (this.ISGenerated = !0), h ? ((this._initPTS = { baseTime: d, timescale: u }), (this._initDTS = { baseTime: c, timescale: u })) : (d = u = void 0), { tracks: o, initPTS: d, timescale: u } ); } remuxVideo(t, e, n, i) { const r = t.inputTimeScale, a = t.samples, s = [], o = a.length, l = this._initPTS; let d, c, u = this.nextAvcDts, h = 8, p = this.videoSampleDuration, f = Number.POSITIVE_INFINITY, m = Number.NEGATIVE_INFINITY, g = !1; if (!n || null === u) { const t = e * r, i = a[0].pts - Jr(a[0].dts, a[0].pts); Wr && null !== u && Math.abs(t - i - u) < 15e3 ? (n = !0) : (u = t - i); } const y = (l.baseTime * r) / l.timescale; for (let t = 0; t < o; t++) { const e = a[t]; (e.pts = Jr(e.pts - y, u)), (e.dts = Jr(e.dts - y, u)), e.dts < a[t > 0 ? t - 1 : t].dts && (g = !0); } g && a.sort(function (t, e) { const n = t.dts - e.dts, i = t.pts - e.pts; return n || i; }), (d = a[0].dts), (c = a[a.length - 1].dts); const A = c - d, v = A ? Math.round(A / (o - 1)) : p || t.inputTimeScale / 30; if (n) { const t = d - u, n = t > v, i = t < -1; if ( (n || i) && (n ? ot.warn(`AVC: ${qr(t, !0)} ms (${t}dts) hole between fragments detected at ${e.toFixed(3)}`) : ot.warn(`AVC: ${qr(-t, !0)} ms (${t}dts) overlapping between fragments detected at ${e.toFixed(3)}`), !i || u >= a[0].pts || Wr) ) { d = u; const e = a[0].pts - t; if (n) (a[0].dts = d), (a[0].pts = e); else for (let n = 0; n < a.length && !(a[n].dts > e); n++) (a[n].dts -= t), (a[n].pts -= t); ot.log(`Video: Initial PTS/DTS adjusted: ${qr(e, !0)}/${qr(d, !0)}, delta: ${qr(t, !0)} ms`); } } d = Math.max(0, d); let b = 0, E = 0, w = d; for (let t = 0; t < o; t++) { const e = a[t], n = e.units, i = n.length; let r = 0; for (let t = 0; t < i; t++) r += n[t].data.length; (E += r), (b += i), (e.length = r), e.dts < w ? ((e.dts = w), (w += (v / 4) | 0 || 1)) : (w = e.dts), (f = Math.min(e.pts, f)), (m = Math.max(e.pts, m)); } c = a[o - 1].dts; const x = E + 4 * b + 8; let S; try { S = new Uint8Array(x); } catch (t) { return void this.observer.emit(tt.ERROR, tt.ERROR, { type: et.MUX_ERROR, details: nt.REMUX_ALLOC_ERROR, fatal: !1, error: t, bytes: x, reason: `fail allocating video mdat ${x}` }); } const _ = new DataView(S.buffer); _.setUint32(0, x), S.set(Yr.types.mdat, 4); let T = !1, k = Number.POSITIVE_INFINITY, C = Number.POSITIVE_INFINITY, L = Number.NEGATIVE_INFINITY, I = Number.NEGATIVE_INFINITY; for (let t = 0; t < o; t++) { const e = a[t], n = e.units; let l, d = 0; for (let t = 0, e = n.length; t < e; t++) { const e = n[t], i = e.data, r = e.data.byteLength; _.setUint32(h, r), (h += 4), S.set(i, h), (h += r), (d += 4 + r); } if (t < o - 1) (p = a[t + 1].dts - e.dts), (l = a[t + 1].pts - e.pts); else { const n = this.config, s = t > 0 ? e.dts - a[t - 1].dts : v; if (((l = t > 0 ? e.pts - a[t - 1].pts : v), n.stretchShortVideoTrack && null !== this.nextAudioPts)) { const t = Math.floor(n.maxBufferHole * r), a = (i ? f + i * r : this.nextAudioPts) - e.pts; a > t ? ((p = a - s), p < 0 ? (p = s) : (T = !0), ot.log( `[mp4-remuxer]: It is approximately ${a / 90} ms to the next segment; using duration ${p / 90 } ms for the last video frame.` )) : (p = s); } else p = s; } const c = Math.round(e.pts - e.dts); (k = Math.min(k, p)), (L = Math.max(L, p)), (C = Math.min(C, l)), (I = Math.max(I, l)), s.push(new ea(e.key, p, d, c)); } if (s.length) if (Wr) { if (Wr < 70) { const t = s[0].flags; (t.dependsOn = 2), (t.isNonSync = 0); } } else if (Qr && I - C < L - k && v / L < 0.025 && 0 === s[0].cts) { ot.warn( "Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration." ); let t = d; for (let e = 0, n = s.length; e < n; e++) { const i = t + s[e].duration, r = t + s[e].cts; if (e < n - 1) { const t = i + s[e + 1].cts; s[e].duration = t - r; } else s[e].duration = e ? s[e - 1].duration : v; (s[e].cts = 0), (t = i); } } (p = T || !p ? v : p), (this.nextAvcDts = u = c + p), (this.videoSampleDuration = p), (this.isVideoContiguous = !0); const R = { data1: Yr.moof(t.sequenceNumber++, d, Q({}, t, { samples: s })), data2: S, startPTS: f / r, endPTS: (m + p) / r, startDTS: d / r, endDTS: u / r, type: "video", hasAudio: !1, hasVideo: !0, nb: s.length, dropped: t.dropped }; return (t.samples = []), (t.dropped = 0), R; } getSamplesPerFrame(t) { switch (t.segmentCodec) { case "mp3": return 1152; case "ac3": return 1536; default: return 1024; } } remuxAudio(t, e, n, i, r) { const a = t.inputTimeScale, s = a / (t.samplerate ? t.samplerate : a), o = this.getSamplesPerFrame(t), l = o * s, d = this._initPTS, c = "mp3" === t.segmentCodec && this.typeSupported.mpeg, u = [], h = void 0 !== r; let p = t.samples, f = c ? 0 : 8, m = this.nextAudioPts || -1; const g = e * a, y = (d.baseTime * a) / d.timescale; if ( ((this.isAudioContiguous = n = n || (p.length && m > 0 && ((i && Math.abs(g - m) < 9e3) || Math.abs(Jr(p[0].pts - y, g) - m) < 20 * l))), p.forEach(function (t) { t.pts = Jr(t.pts - y, g); }), !n || m < 0) ) { if (((p = p.filter(t => t.pts >= 0)), !p.length)) return; m = 0 === r ? 0 : i && !h ? Math.max(0, g) : p[0].pts; } if ("aac" === t.segmentCodec) { const e = this.config.maxAudioFramesDrift; for (let n = 0, i = m; n < p.length; n++) { const r = p[n], s = r.pts, o = s - i, d = Math.abs((1e3 * o) / a); if (o <= -e * l && h) 0 === n && (ot.warn( `Audio frame @ ${(s / a).toFixed(3)}s overlaps nextAudioPts by ${Math.round((1e3 * o) / a)} ms.` ), (this.nextAudioPts = m = i = s)); else if (o >= e * l && d < 1e4 && h) { let e = Math.round(o / l); (i = s - e * l), i < 0 && (e--, (i += l)), 0 === n && (this.nextAudioPts = m = i), ot.warn( `[mp4-remuxer]: Injecting ${e} audio frame @ ${(i / a).toFixed(3)}s due to ${Math.round( (1e3 * o) / a )} ms gap.` ); for (let a = 0; a < e; a++) { const e = Math.max(i, 0); let a = jr.getSilentFrame(t.manifestCodec || t.codec, t.channelCount); a || (ot.log( "[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead." ), (a = r.unit.subarray())), p.splice(n, 0, { unit: a, pts: e }), (i += l), n++; } } (r.pts = i), (i += l); } } let A, v = null, b = null, E = 0, w = p.length; for (; w--;) E += p[w].unit.byteLength; for (let e = 0, i = p.length; e < i; e++) { const i = p[e], r = i.unit; let a = i.pts; if (null !== b) { u[e - 1].duration = Math.round((a - b) / s); } else { if ((n && "aac" === t.segmentCodec && (a = m), (v = a), !(E > 0))) return; E += f; try { A = new Uint8Array(E); } catch (t) { return void this.observer.emit(tt.ERROR, tt.ERROR, { type: et.MUX_ERROR, details: nt.REMUX_ALLOC_ERROR, fatal: !1, error: t, bytes: E, reason: `fail allocating audio mdat ${E}` }); } if (!c) { new DataView(A.buffer).setUint32(0, E), A.set(Yr.types.mdat, 4); } } A.set(r, f); const l = r.byteLength; (f += l), u.push(new ea(!0, o, l, 0)), (b = a); } const x = u.length; if (!x) return; const S = u[u.length - 1]; this.nextAudioPts = m = b + s * S.duration; const _ = c ? new Uint8Array(0) : Yr.moof(t.sequenceNumber++, v / s, Q({}, t, { samples: u })); t.samples = []; const T = v / a, k = m / a, C = { data1: _, data2: A, startPTS: T, endPTS: k, startDTS: T, endDTS: k, type: "audio", hasAudio: !0, hasVideo: !1, nb: x }; return (this.isAudioContiguous = !0), C; } remuxEmptyAudio(t, e, n, i) { const r = t.inputTimeScale, a = r / (t.samplerate ? t.samplerate : r), s = this.nextAudioPts, o = this._initDTS, l = (9e4 * o.baseTime) / o.timescale, d = (null !== s ? s : i.startDTS * r) + l, c = i.endDTS * r + l, u = 1024 * a, h = Math.ceil((c - d) / u), p = jr.getSilentFrame(t.manifestCodec || t.codec, t.channelCount); if ((ot.warn("[mp4-remuxer]: remux empty Audio"), !p)) return void ot.trace( "[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec" ); const f = []; for (let t = 0; t < h; t++) { const e = d + t * u; f.push({ unit: p, pts: e, dts: e }); } return (t.samples = f), this.remuxAudio(t, e, n, !1); } } function Jr(t, e) { let n; if (null === e) return t; for (n = e < t ? -8589934592 : 8589934592; Math.abs(t - e) > 4294967296;) t += n; return t; } function Zr(t, e, n, i) { const r = t.samples.length; if (!r) return; const a = t.inputTimeScale; for (let s = 0; s < r; s++) { const r = t.samples[s]; (r.pts = Jr(r.pts - (n.baseTime * a) / n.timescale, e * a) / a), (r.dts = Jr(r.dts - (i.baseTime * a) / i.timescale, e * a) / a); } const s = t.samples; return (t.samples = []), { samples: s }; } function ta(t, e, n) { const i = t.samples.length; if (!i) return; const r = t.inputTimeScale; for (let a = 0; a < i; a++) { const i = t.samples[a]; i.pts = Jr(i.pts - (n.baseTime * r) / n.timescale, e * r) / r; } t.samples.sort((t, e) => t.pts - e.pts); const a = t.samples; return (t.samples = []), { samples: a }; } class ea { constructor(t, e, n, i) { (this.size = void 0), (this.duration = void 0), (this.cts = void 0), (this.flags = void 0), (this.duration = e), (this.size = n), (this.cts = i), (this.flags = { isLeading: 0, isDependedOn: 0, hasRedundancy: 0, degradPrio: 0, dependsOn: t ? 2 : 1, isNonSync: t ? 0 : 1 }); } } function na(t, e) { const n = null == t ? void 0 : t.codec; if (n && n.length > 4) return n; if (e === ft) { if ("ec-3" === n || "ac-3" === n || "alac" === n) return n; if ("fLaC" === n || "Opus" === n) { return je(n, !1); } const t = "mp4a.40.5"; return ot.info(`Parsed audio codec "${n}" or audio object type not handled. Using "${t}"`), t; } return ( ot.warn(`Unhandled video codec "${n}"`), "hvc1" === n || "hev1" === n ? "hvc1.1.6.L120.90" : "av01" === n ? "av01.0.04M.08" : "avc1.42e01e" ); } try { Vr = self.performance.now.bind(self.performance); } catch (t) { ot.debug("Unable to use Performance API on this environment"), (Vr = null == St ? void 0 : St.Date.now); } const ia = [ { demux: class { constructor(t, e) { (this.remainderData = null), (this.timeOffset = 0), (this.config = void 0), (this.videoTrack = void 0), (this.audioTrack = void 0), (this.id3Track = void 0), (this.txtTrack = void 0), (this.config = e); } resetTimeStamp() { } resetInitSegment(t, e, n, i) { const r = (this.videoTrack = sr("video", 1)), a = (this.audioTrack = sr("audio", 1)), s = (this.txtTrack = sr("text", 1)); if (((this.id3Track = sr("id3", 1)), (this.timeOffset = 0), null == t || !t.byteLength)) return; const o = he(t); if (o.video) { const { id: t, timescale: e, codec: n } = o.video; (r.id = t), (r.timescale = s.timescale = e), (r.codec = n); } if (o.audio) { const { id: t, timescale: e, codec: n } = o.audio; (a.id = t), (a.timescale = e), (a.codec = n); } (s.id = ie.text), (r.sampleDuration = 0), (r.duration = a.duration = i); } resetContiguity() { this.remainderData = null; } static probe(t) { return (function (t) { const e = t.byteLength; for (let n = 0; n < e;) { const i = se(t, n); if (i > 8 && 109 === t[n + 4] && 111 === t[n + 5] && 111 === t[n + 6] && 102 === t[n + 7]) return !0; n = i > 1 ? n + i : e; } return !1; })(t); } demux(t, e) { this.timeOffset = e; let n = t; const i = this.videoTrack, r = this.txtTrack; if (this.config.progressive) { this.remainderData && (n = ve(this.remainderData, t)); const e = (function (t) { const e = { valid: null, remainder: null }, n = ce(t, ["moof"]); if (n.length < 2) return (e.remainder = t), e; const i = n[n.length - 1]; return (e.valid = Ft(t, 0, i.byteOffset - 8)), (e.remainder = Ft(t, i.byteOffset - 8)), e; })(n); (this.remainderData = e.remainder), (i.samples = e.valid || new Uint8Array()); } else i.samples = n; const a = this.extractID3Track(i, e); return ( (r.samples = be(e, i)), { videoTrack: i, audioTrack: this.audioTrack, id3Track: a, textTrack: this.txtTrack } ); } flush() { const t = this.timeOffset, e = this.videoTrack, n = this.txtTrack; (e.samples = this.remainderData || new Uint8Array()), (this.remainderData = null); const i = this.extractID3Track(e, this.timeOffset); return (n.samples = be(t, e)), { videoTrack: e, audioTrack: sr(), id3Track: i, textTrack: sr() }; } extractID3Track(t, e) { const n = this.id3Track; if (t.samples.length) { const i = ce(t.samples, ["emsg"]); i && i.forEach(t => { const i = (function (t) { const e = t[0]; let n = "", i = "", r = 0, a = 0, s = 0, o = 0, l = 0, d = 0; if (0 === e) { for (; "\0" !== re(t.subarray(d, d + 1));) (n += re(t.subarray(d, d + 1))), (d += 1); for (n += re(t.subarray(d, d + 1)), d += 1; "\0" !== re(t.subarray(d, d + 1));) (i += re(t.subarray(d, d + 1))), (d += 1); (i += re(t.subarray(d, d + 1))), (d += 1), (r = se(t, 12)), (a = se(t, 16)), (o = se(t, 20)), (l = se(t, 24)), (d = 28); } else if (1 === e) { (d += 4), (r = se(t, d)), (d += 4); const e = se(t, d); d += 4; const a = se(t, d); for ( d += 4, s = 2 ** 32 * e + a, J(s) || ((s = Number.MAX_SAFE_INTEGER), ot.warn( "Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box" )), o = se(t, d), d += 4, l = se(t, d), d += 4; "\0" !== re(t.subarray(d, d + 1)); ) (n += re(t.subarray(d, d + 1))), (d += 1); for (n += re(t.subarray(d, d + 1)), d += 1; "\0" !== re(t.subarray(d, d + 1));) (i += re(t.subarray(d, d + 1))), (d += 1); (i += re(t.subarray(d, d + 1))), (d += 1); } return { schemeIdUri: n, value: i, timeScale: r, presentationTime: s, presentationTimeDelta: a, eventDuration: o, id: l, payload: t.subarray(d, t.byteLength) }; })(t); if (kr.test(i.schemeIdUri)) { const t = X(i.presentationTime) ? i.presentationTime / i.timeScale : e + i.presentationTimeDelta / i.timeScale; let r = 4294967295 === i.eventDuration ? Number.POSITIVE_INFINITY : i.eventDuration / i.timeScale; r <= 0.001 && (r = Number.POSITIVE_INFINITY); const a = i.payload; n.samples.push({ data: a, len: a.byteLength, dts: t, pts: t, type: En, duration: r }); } }); } return n; } demuxSampleAes(t, e, n) { return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption")); } destroy() { } }, remux: class { constructor() { (this.emitInitSegment = !1), (this.audioCodec = void 0), (this.videoCodec = void 0), (this.initData = void 0), (this.initPTS = null), (this.initTracks = void 0), (this.lastEndTime = null); } destroy() { } resetTimeStamp(t) { (this.initPTS = t), (this.lastEndTime = null); } resetNextTimestamp() { this.lastEndTime = null; } resetInitSegment(t, e, n, i) { (this.audioCodec = e), (this.videoCodec = n), this.generateInitSegment( (function (t, e) { if (!t || !e) return t; const n = e.keyId; n && e.isCommonEncryption && ce(t, ["moov", "trak"]).forEach(t => { const e = ce(t, ["mdia", "minf", "stbl", "stsd"])[0].subarray(8); let i = ce(e, ["enca"]); const r = i.length > 0; r || (i = ce(e, ["encv"])), i.forEach(t => { ce(r ? t.subarray(28) : t.subarray(78), ["sinf"]).forEach(t => { const e = ye(t); if (e) { const t = e.subarray(8, 24); t.some(t => 0 !== t) || (ot.log( `[eme] Patching keyId in 'enc${r ? "a" : "v" }>sinf>>tenc' box: ${te(t)} -> ${te(n)}` ), e.set(n, 8)); } }); }); }); return t; })(t, i) ), (this.emitInitSegment = !0); } generateInitSegment(t) { let { audioCodec: e, videoCodec: n } = this; if (null == t || !t.byteLength) return (this.initTracks = void 0), void (this.initData = void 0); const i = (this.initData = he(t)); i.audio && (e = na(i.audio, ft)), i.video && (n = na(i.video, mt)); const r = {}; i.audio && i.video ? (r.audiovideo = { container: "video/mp4", codec: e + "," + n, initSegment: t, id: "main" }) : i.audio ? (r.audio = { container: "audio/mp4", codec: e, initSegment: t, id: "audio" }) : i.video ? (r.video = { container: "video/mp4", codec: n, initSegment: t, id: "main" }) : ot.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."), (this.initTracks = r); } remux(t, e, n, i, r, a) { var s, o; let { initPTS: l, lastEndTime: d } = this; const c = { audio: void 0, video: void 0, text: i, id3: n, initSegment: void 0 }; X(d) || (d = this.lastEndTime = r || 0); const u = e.samples; if (null == u || !u.length) return c; const h = { initPTS: void 0, timescale: 1 }; let p = this.initData; if ( ((null != (s = p) && s.length) || (this.generateInitSegment(u), (p = this.initData)), null == (o = p) || !o.length) ) return ot.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."), c; this.emitInitSegment && ((h.tracks = this.initTracks), (this.emitInitSegment = !1)); const f = (function (t, e) { let n = 0, i = 0, r = 0; const a = ce(t, ["moof", "traf"]); for (let t = 0; t < a.length; t++) { const s = a[t], o = ce(s, ["tfhd"])[0], l = e[se(o, 4)]; if (!l) continue; const d = l.default, c = se(o, 0) | (null == d ? void 0 : d.flags); let u = null == d ? void 0 : d.duration; 8 & c && (u = se(o, 2 & c ? 12 : 8)); const h = l.timescale || 9e4, p = ce(s, ["trun"]); for (let t = 0; t < p.length; t++) (n = Ae(p[t])), !n && u && (n = u * se(p[t], 4)), l.type === mt ? (i += n / h) : l.type === ft && (r += n / h); } if (0 === i && 0 === r) { let e = 1 / 0, n = 0, i = 0; const r = ce(t, ["sidx"]); for (let t = 0; t < r.length; t++) { const a = ue(r[t]); if (null != a && a.references) { e = Math.min(e, a.earliestPresentationTime / a.timescale); const t = a.references.reduce((t, e) => t + e.info.duration || 0, 0); (n = Math.max(n, t + a.earliestPresentationTime / a.timescale)), (i = n - e); } } if (i && X(i)) return i; } return i || r; })(u, p), m = (function (t, e) { return ce(e, ["moof", "traf"]).reduce((e, n) => { const i = ce(n, ["tfdt"])[0], r = i[0], a = ce(n, ["tfhd"]).reduce((e, n) => { const a = se(n, 4), s = t[a]; if (s) { let t = se(i, 4); if (1 === r) { if (t === ee) return ( ot.warn( "[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time" ), e ); (t *= ee + 1), (t += se(i, 8)); } const n = t / (s.timescale || 9e4); if (X(n) && (null === e || n < e)) return n; } return e; }, null); return null !== a && X(a) && (null === e || a < e) ? a : e; }, null); })(p, u), g = null === m ? r : m; ((function (t, e, n, i) { if (null === t) return !0; const r = Math.max(i, 1), a = e - t.baseTime / t.timescale; return Math.abs(a - n) > r; })(l, g, r, f) || (h.timescale !== l.timescale && a)) && ((h.initPTS = g - r), l && 1 === l.timescale && ot.warn("Adjusting initPTS by " + (h.initPTS - l.baseTime)), (this.initPTS = l = { baseTime: h.initPTS, timescale: 1 })); const y = t ? g - l.baseTime / l.timescale : d, A = y + f; !(function (t, e, n) { ce(e, ["moof", "traf"]).forEach(e => { ce(e, ["tfhd"]).forEach(i => { const r = se(i, 4), a = t[r]; if (!a) return; const s = a.timescale || 9e4; ce(e, ["tfdt"]).forEach(t => { const e = t[0], i = n * s; if (i) { let n = se(t, 4); if (0 === e) (n -= i), (n = Math.max(n, 0)), de(t, 4, n); else { (n *= Math.pow(2, 32)), (n += se(t, 8)), (n -= i), (n = Math.max(n, 0)); const e = Math.floor(n / (ee + 1)), r = Math.floor(n % (ee + 1)); de(t, 4, e), de(t, 8, r); } } }); }); }); })(p, u, l.baseTime / l.timescale), f > 0 ? (this.lastEndTime = A) : (ot.warn("Duration parsed from mp4 should be greater than zero"), this.resetNextTimestamp()); const v = !!p.audio, b = !!p.video; let E = ""; v && (E += "audio"), b && (E += "video"); const w = { data1: u, startPTS: y, startDTS: y, endPTS: A, endDTS: A, type: E, hasAudio: v, hasVideo: b, nb: 1, dropped: 0 }; return ( (c.audio = "audio" === w.type ? w : void 0), (c.video = "audio" !== w.type ? w : void 0), (c.initSegment = h), (c.id3 = Zr(n, r, l, l)), i.samples.length && (c.text = ta(i, r, l)), c ); } } }, { demux: Fr, remux: Xr }, { demux: class extends or { constructor(t, e) { super(), (this.observer = void 0), (this.config = void 0), (this.observer = t), (this.config = e); } resetInitSegment(t, e, n, i) { super.resetInitSegment(t, e, n, i), (this._audioTrack = { container: "audio/adts", type: "audio", id: 2, pid: -1, sequenceNumber: 0, segmentCodec: "aac", samples: [], manifestCodec: e, duration: i, inputTimeScale: 9e4, dropped: 0 }); } static probe(t) { if (!t) return !1; const e = Nt(t, 0); let n = (null == e ? void 0 : e.length) || 0; if (Tr(t, n)) return !1; for (let e = t.length; n < e; n++) if (pr(t, n)) return ot.log("ADTS sync word found !"), !0; return !1; } canParse(t, e) { return (function (t, e) { return ( (function (t, e) { return e + 5 < t.length; })(t, e) && dr(t, e) && ur(t, e) <= t.length - e ); })(t, e); } appendFrame(t, e, n) { fr(t, this.observer, e, n, t.manifestCodec); const i = gr(t, e, n, this.basePTS, this.frameIndex); if (i && 0 === i.missing) return i; } }, remux: Xr }, { demux: class extends or { resetInitSegment(t, e, n, i) { super.resetInitSegment(t, e, n, i), (this._audioTrack = { container: "audio/mpeg", type: "audio", id: 2, pid: -1, sequenceNumber: 0, segmentCodec: "mp3", samples: [], manifestCodec: e, duration: i, inputTimeScale: 9e4, dropped: 0 }); } static probe(t) { if (!t) return !1; const e = Nt(t, 0); let n = (null == e ? void 0 : e.length) || 0; if (e && 11 === t[n] && 119 === t[n + 1] && void 0 !== jt(e) && Cr(t, n) <= 16) return !1; for (let e = t.length; n < e; n++) if (Tr(t, n)) return ot.log("MPEG Audio sync word found !"), !0; return !1; } canParse(t, e) { return (function (t, e) { return Sr(t, e) && 4 <= t.length - e; })(t, e); } appendFrame(t, e, n) { if (null !== this.basePTS) return wr(t, e, n, this.basePTS, this.frameIndex); } }, remux: Xr } ]; ia.splice(2, 0, { demux: Lr, remux: Xr }); class ra { constructor(t, e, n, i, r) { (this.async = !1), (this.observer = void 0), (this.typeSupported = void 0), (this.config = void 0), (this.vendor = void 0), (this.id = void 0), (this.demuxer = void 0), (this.remuxer = void 0), (this.decrypter = void 0), (this.probe = void 0), (this.decryptionPromise = null), (this.transmuxConfig = void 0), (this.currentTransmuxState = void 0), (this.observer = t), (this.typeSupported = e), (this.config = n), (this.vendor = i), (this.id = r); } configure(t) { (this.transmuxConfig = t), this.decrypter && this.decrypter.reset(); } push(t, e, n, i) { const r = n.transmuxing; r.executeStart = Vr(); let a = new Uint8Array(t); const { currentTransmuxState: s, transmuxConfig: o } = this; i && (this.currentTransmuxState = i); const { contiguous: l, discontinuity: d, trackSwitch: c, accurateTimeOffset: u, timeOffset: h, initSegmentChange: p } = i || s, { audioCodec: f, videoCodec: m, defaultInitPts: g, duration: y, initSegmentData: A } = o, v = (function (t, e) { let n = null; t.byteLength > 0 && null != (null == e ? void 0 : e.key) && null !== e.iv && null != e.method && (n = e); return n; })(a, e); if (v && "AES-128" === v.method) { const t = this.getDecrypter(); if (!t.isSync()) return ( (this.decryptionPromise = t.webCryptoDecrypt(a, v.key.buffer, v.iv.buffer).then(t => { const e = this.push(t, null, n); return (this.decryptionPromise = null), e; })), this.decryptionPromise ); { let e = t.softwareDecrypt(a, v.key.buffer, v.iv.buffer); if ((n.part > -1 && (e = t.flush()), !e)) return (r.executeEnd = Vr()), aa(n); a = new Uint8Array(e); } } const b = this.needsProbing(d, c); if (b) { const t = this.configureTransmuxer(a); if (t) return ( ot.warn(`[transmuxer] ${t.message}`), this.observer.emit(tt.ERROR, tt.ERROR, { type: et.MEDIA_ERROR, details: nt.FRAG_PARSING_ERROR, fatal: !1, error: t, reason: t.message }), (r.executeEnd = Vr()), aa(n) ); } (d || c || p || b) && this.resetInitSegment(A, f, m, y, e), (d || p || b) && this.resetInitialTimestamp(g), l || this.resetContiguity(); const E = this.transmux(a, v, h, u, n), w = this.currentTransmuxState; return (w.contiguous = !0), (w.discontinuity = !1), (w.trackSwitch = !1), (r.executeEnd = Vr()), E; } flush(t) { const e = t.transmuxing; e.executeStart = Vr(); const { decrypter: n, currentTransmuxState: i, decryptionPromise: r } = this; if (r) return r.then(() => this.flush(t)); const a = [], { timeOffset: s } = i; if (n) { const e = n.flush(); e && a.push(this.push(e, null, t)); } const { demuxer: o, remuxer: l } = this; if (!o || !l) return (e.executeEnd = Vr()), [aa(t)]; const d = o.flush(s); return sa(d) ? d.then(e => (this.flushRemux(a, e, t), a)) : (this.flushRemux(a, d, t), a); } flushRemux(t, e, n) { const { audioTrack: i, videoTrack: r, id3Track: a, textTrack: s } = e, { accurateTimeOffset: o, timeOffset: l } = this.currentTransmuxState; ot.log(`[transmuxer.ts]: Flushed fragment ${n.sn}${n.part > -1 ? " p: " + n.part : ""} of level ${n.level}`); const d = this.remuxer.remux(i, r, a, s, l, o, !0, this.id); t.push({ remuxResult: d, chunkMeta: n }), (n.transmuxing.executeEnd = Vr()); } resetInitialTimestamp(t) { const { demuxer: e, remuxer: n } = this; e && n && (e.resetTimeStamp(t), n.resetTimeStamp(t)); } resetContiguity() { const { demuxer: t, remuxer: e } = this; t && e && (t.resetContiguity(), e.resetNextTimestamp()); } resetInitSegment(t, e, n, i, r) { const { demuxer: a, remuxer: s } = this; a && s && (a.resetInitSegment(t, e, n, i), s.resetInitSegment(t, e, n, r)); } destroy() { this.demuxer && (this.demuxer.destroy(), (this.demuxer = void 0)), this.remuxer && (this.remuxer.destroy(), (this.remuxer = void 0)); } transmux(t, e, n, i, r) { let a; return ( (a = e && "SAMPLE-AES" === e.method ? this.transmuxSampleAes(t, e, n, i, r) : this.transmuxUnencrypted(t, n, i, r)), a ); } transmuxUnencrypted(t, e, n, i) { const { audioTrack: r, videoTrack: a, id3Track: s, textTrack: o } = this.demuxer.demux(t, e, !1, !this.config.progressive); return { remuxResult: this.remuxer.remux(r, a, s, o, e, n, !1, this.id), chunkMeta: i }; } transmuxSampleAes(t, e, n, i, r) { return this.demuxer .demuxSampleAes(t, e, n) .then(t => ({ remuxResult: this.remuxer.remux(t.audioTrack, t.videoTrack, t.id3Track, t.textTrack, n, i, !1, this.id), chunkMeta: r })); } configureTransmuxer(t) { const { config: e, observer: n, typeSupported: i, vendor: r } = this; let a; for (let e = 0, n = ia.length; e < n; e++) { var s; if (null != (s = ia[e].demux) && s.probe(t)) { a = ia[e]; break; } } if (!a) return new Error("Failed to find demuxer by probing fragment data"); const o = this.demuxer, l = this.remuxer, d = a.remux, c = a.demux; (l && l instanceof d) || (this.remuxer = new d(n, e, i, r)), (o && o instanceof c) || ((this.demuxer = new c(n, e, i)), (this.probe = c.probe)); } needsProbing(t, e) { return !this.demuxer || !this.remuxer || t || e; } getDecrypter() { let t = this.decrypter; return t || (t = this.decrypter = new Yi(this.config)), t; } } const aa = t => ({ remuxResult: {}, chunkMeta: t }); function sa(t) { return "then" in t && t.then instanceof Function; } class oa { constructor(t, e, n, i, r) { (this.audioCodec = void 0), (this.videoCodec = void 0), (this.initSegmentData = void 0), (this.duration = void 0), (this.defaultInitPts = void 0), (this.audioCodec = t), (this.videoCodec = e), (this.initSegmentData = n), (this.duration = i), (this.defaultInitPts = r || null); } } class la { constructor(t, e, n, i, r, a) { (this.discontinuity = void 0), (this.contiguous = void 0), (this.accurateTimeOffset = void 0), (this.trackSwitch = void 0), (this.timeOffset = void 0), (this.initSegmentChange = void 0), (this.discontinuity = t), (this.contiguous = e), (this.accurateTimeOffset = n), (this.trackSwitch = i), (this.timeOffset = r), (this.initSegmentChange = a); } } var da = { exports: {} }; !(function (t) { var e = Object.prototype.hasOwnProperty, n = "~"; function i() { } function r(t, e, n) { (this.fn = t), (this.context = e), (this.once = n || !1); } function a(t, e, i, a, s) { if ("function" != typeof i) throw new TypeError("The listener must be a function"); var o = new r(i, a || t, s), l = n ? n + e : e; return ( t._events[l] ? t._events[l].fn ? (t._events[l] = [t._events[l], o]) : t._events[l].push(o) : ((t._events[l] = o), t._eventsCount++), t ); } function s(t, e) { 0 == --t._eventsCount ? (t._events = new i()) : delete t._events[e]; } function o() { (this._events = new i()), (this._eventsCount = 0); } Object.create && ((i.prototype = Object.create(null)), new i().__proto__ || (n = !1)), (o.prototype.eventNames = function () { var t, i, r = []; if (0 === this._eventsCount) return r; for (i in (t = this._events)) e.call(t, i) && r.push(n ? i.slice(1) : i); return Object.getOwnPropertySymbols ? r.concat(Object.getOwnPropertySymbols(t)) : r; }), (o.prototype.listeners = function (t) { var e = n ? n + t : t, i = this._events[e]; if (!i) return []; if (i.fn) return [i.fn]; for (var r = 0, a = i.length, s = new Array(a); r < a; r++) s[r] = i[r].fn; return s; }), (o.prototype.listenerCount = function (t) { var e = n ? n + t : t, i = this._events[e]; return i ? (i.fn ? 1 : i.length) : 0; }), (o.prototype.emit = function (t, e, i, r, a, s) { var o = n ? n + t : t; if (!this._events[o]) return !1; var l, d, c = this._events[o], u = arguments.length; if (c.fn) { switch ((c.once && this.removeListener(t, c.fn, void 0, !0), u)) { case 1: return c.fn.call(c.context), !0; case 2: return c.fn.call(c.context, e), !0; case 3: return c.fn.call(c.context, e, i), !0; case 4: return c.fn.call(c.context, e, i, r), !0; case 5: return c.fn.call(c.context, e, i, r, a), !0; case 6: return c.fn.call(c.context, e, i, r, a, s), !0; } for (d = 1, l = new Array(u - 1); d < u; d++) l[d - 1] = arguments[d]; c.fn.apply(c.context, l); } else { var h, p = c.length; for (d = 0; d < p; d++) switch ((c[d].once && this.removeListener(t, c[d].fn, void 0, !0), u)) { case 1: c[d].fn.call(c[d].context); break; case 2: c[d].fn.call(c[d].context, e); break; case 3: c[d].fn.call(c[d].context, e, i); break; case 4: c[d].fn.call(c[d].context, e, i, r); break; default: if (!l) for (h = 1, l = new Array(u - 1); h < u; h++) l[h - 1] = arguments[h]; c[d].fn.apply(c[d].context, l); } } return !0; }), (o.prototype.on = function (t, e, n) { return a(this, t, e, n, !1); }), (o.prototype.once = function (t, e, n) { return a(this, t, e, n, !0); }), (o.prototype.removeListener = function (t, e, i, r) { var a = n ? n + t : t; if (!this._events[a]) return this; if (!e) return s(this, a), this; var o = this._events[a]; if (o.fn) o.fn !== e || (r && !o.once) || (i && o.context !== i) || s(this, a); else { for (var l = 0, d = [], c = o.length; l < c; l++) (o[l].fn !== e || (r && !o[l].once) || (i && o[l].context !== i)) && d.push(o[l]); d.length ? (this._events[a] = 1 === d.length ? d[0] : d) : s(this, a); } return this; }), (o.prototype.removeAllListeners = function (t) { var e; return ( t ? ((e = n ? n + t : t), this._events[e] && s(this, e)) : ((this._events = new i()), (this._eventsCount = 0)), this ); }), (o.prototype.off = o.prototype.removeListener), (o.prototype.addListener = o.prototype.on), (o.prefixed = n), (o.EventEmitter = o), (t.exports = o); })(da); var ca = H(da.exports); class ua { constructor(t, e, n, i) { (this.error = null), (this.hls = void 0), (this.id = void 0), (this.observer = void 0), (this.frag = null), (this.part = null), (this.useWorker = void 0), (this.workerContext = null), (this.onwmsg = void 0), (this.transmuxer = null), (this.onTransmuxComplete = void 0), (this.onFlush = void 0); const r = t.config; (this.hls = t), (this.id = e), (this.useWorker = !!r.enableWorker), (this.onTransmuxComplete = n), (this.onFlush = i); const a = (t, e) => { ((e = e || {}).frag = this.frag), (e.id = this.id), t === tt.ERROR && (this.error = e.error), this.hls.trigger(t, e); }; (this.observer = new ca()), this.observer.on(tt.FRAG_DECRYPTED, a), this.observer.on(tt.ERROR, a); const s = Be(r.preferManagedMediaSource) || { isTypeSupported: () => !1 }, o = { mpeg: s.isTypeSupported("audio/mpeg"), mp3: s.isTypeSupported('audio/mp4; codecs="mp3"'), ac3: s.isTypeSupported('audio/mp4; codecs="ac-3"') }, l = navigator.vendor; if (this.useWorker && "undefined" != typeof Worker) { if (r.workerPath || "function" == typeof __HLS_WORKER_BUNDLE__) { try { r.workerPath ? (ot.log(`loading Web Worker ${r.workerPath} for "${e}"`), (this.workerContext = (function (t) { const e = new self.URL(t, self.location.href).href; return { worker: new self.Worker(e), scriptURL: e }; })(r.workerPath))) : (ot.log(`injecting Web Worker for "${e}"`), (this.workerContext = (function () { const t = new self.Blob( [ `var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);` ], { type: "text/javascript" } ), e = self.URL.createObjectURL(t); return { worker: new self.Worker(e), objectURL: e }; })())), (this.onwmsg = t => this.onWorkerMessage(t)); const { worker: t } = this.workerContext; t.addEventListener("message", this.onwmsg), (t.onerror = t => { const n = new Error(`${t.message} (${t.filename}:${t.lineno})`); (r.enableWorker = !1), ot.warn(`Error in "${e}" Web Worker, fallback to inline`), this.hls.trigger(tt.ERROR, { type: et.OTHER_ERROR, details: nt.INTERNAL_EXCEPTION, fatal: !1, event: "demuxerWorker", error: n }); }), t.postMessage({ cmd: "init", typeSupported: o, vendor: l, id: e, config: JSON.stringify(r) }); } catch (t) { ot.warn(`Error setting up "${e}" Web Worker, fallback to inline`, t), this.resetWorker(), (this.error = null), (this.transmuxer = new ra(this.observer, o, r, l, e)); } return; } } this.transmuxer = new ra(this.observer, o, r, l, e); } resetWorker() { if (this.workerContext) { const { worker: t, objectURL: e } = this.workerContext; e && self.URL.revokeObjectURL(e), t.removeEventListener("message", this.onwmsg), (t.onerror = null), t.terminate(), (this.workerContext = null); } } destroy() { if (this.workerContext) this.resetWorker(), (this.onwmsg = void 0); else { const t = this.transmuxer; t && (t.destroy(), (this.transmuxer = null)); } const t = this.observer; t && t.removeAllListeners(), (this.frag = null), (this.observer = null), (this.hls = null); } push(t, e, n, i, r, a, s, o, l, d) { var c, u; l.transmuxing.start = self.performance.now(); const { transmuxer: h } = this, p = a ? a.start : r.start, f = r.decryptdata, m = this.frag, g = !(m && r.cc === m.cc), y = !(m && l.level === m.level), A = m ? l.sn - m.sn : -1, v = this.part ? l.part - this.part.index : -1, b = 0 === A && l.id > 1 && l.id === (null == m ? void 0 : m.stats.chunkCount), E = !y && (1 === A || (0 === A && (1 === v || (b && v <= 0)))), w = self.performance.now(); (y || A || 0 === r.stats.parsing.start) && (r.stats.parsing.start = w), !a || (!v && E) || (a.stats.parsing.start = w); const x = !(m && (null == (c = r.initSegment) ? void 0 : c.url) === (null == (u = m.initSegment) ? void 0 : u.url)), S = new la(g, E, o, y, p, x); if (!E || g || x) { ot.log( `[transmuxer-interface, ${r.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${E}\n accurateTimeOffset: ${o}\n timeOffset: ${p}\n initSegmentChange: ${x}` ); const t = new oa(n, i, e, s, d); this.configureTransmuxer(t); } if (((this.frag = r), (this.part = a), this.workerContext)) this.workerContext.worker.postMessage( { cmd: "demux", data: t, decryptdata: f, chunkMeta: l, state: S }, t instanceof ArrayBuffer ? [t] : [] ); else if (h) { const e = h.push(t, f, l, S); sa(e) ? ((h.async = !0), e .then(t => { this.handleTransmuxComplete(t); }) .catch(t => { this.transmuxerError(t, l, "transmuxer-interface push error"); })) : ((h.async = !1), this.handleTransmuxComplete(e)); } } flush(t) { t.transmuxing.start = self.performance.now(); const { transmuxer: e } = this; if (this.workerContext) this.workerContext.worker.postMessage({ cmd: "flush", chunkMeta: t }); else if (e) { let n = e.flush(t); sa(n) || e.async ? (sa(n) || (n = Promise.resolve(n)), n .then(e => { this.handleFlushResult(e, t); }) .catch(e => { this.transmuxerError(e, t, "transmuxer-interface flush error"); })) : this.handleFlushResult(n, t); } } transmuxerError(t, e, n) { this.hls && ((this.error = t), this.hls.trigger(tt.ERROR, { type: et.MEDIA_ERROR, details: nt.FRAG_PARSING_ERROR, chunkMeta: e, fatal: !1, error: t, err: t, reason: n })); } handleFlushResult(t, e) { t.forEach(t => { this.handleTransmuxComplete(t); }), this.onFlush(e); } onWorkerMessage(t) { const e = t.data, n = this.hls; switch (e.event) { case "init": { var i; const t = null == (i = this.workerContext) ? void 0 : i.objectURL; t && self.URL.revokeObjectURL(t); break; } case "transmuxComplete": this.handleTransmuxComplete(e.data); break; case "flush": this.onFlush(e.data); break; case "workerLog": ot[e.data.logType] && ot[e.data.logType](e.data.message); break; default: (e.data = e.data || {}), (e.data.frag = this.frag), (e.data.id = this.id), n.trigger(e.event, e.data); } } configureTransmuxer(t) { const { transmuxer: e } = this; this.workerContext ? this.workerContext.worker.postMessage({ cmd: "configure", config: t }) : e && e.configure(t); } handleTransmuxComplete(t) { (t.chunkMeta.transmuxing.end = self.performance.now()), this.onTransmuxComplete(t); } } function ha(t, e) { if (t.length !== e.length) return !1; for (let n = 0; n < t.length; n++) if (!pa(t[n].attrs, e[n].attrs)) return !1; return !0; } function pa(t, e, n) { const i = t["STABLE-RENDITION-ID"]; return i && !n ? i === e["STABLE-RENDITION-ID"] : !(n || ["LANGUAGE", "NAME", "CHARACTERISTICS", "AUTOSELECT", "DEFAULT", "FORCED", "ASSOC-LANGUAGE"]).some( n => t[n] !== e[n] ); } function fa(t, e) { return ( e.label.toLowerCase() === t.name.toLowerCase() && (!e.language || e.language.toLowerCase() === (t.lang || "").toLowerCase()) ); } class ma { constructor(t) { this.buffered = void 0; const e = (e, n, i) => { if ((n >>>= 0) > i - 1) throw new DOMException( `Failed to execute '${e}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${i})` ); return t[n][e]; }; this.buffered = { get length() { return t.length; }, end: n => e("end", n, t.length), start: n => e("start", n, t.length) }; } } class ga { constructor(t) { (this.buffers = void 0), (this.queues = { video: [], audio: [], audiovideo: [] }), (this.buffers = t); } append(t, e, n) { const i = this.queues[e]; i.push(t), 1 !== i.length || n || this.executeNext(e); } insertAbort(t, e) { this.queues[e].unshift(t), this.executeNext(e); } appendBlocker(t) { let e; const n = new Promise(t => { e = t; }), i = { execute: e, onStart: () => { }, onComplete: () => { }, onError: () => { } }; return this.append(i, t), n; } executeNext(t) { const e = this.queues[t]; if (e.length) { const n = e[0]; try { n.execute(); } catch (e) { ot.warn(`[buffer-operation-queue]: Exception executing "${t}" SourceBuffer operation: ${e}`), n.onError(e); const i = this.buffers[t]; (null != i && i.updating) || this.shiftAndExecuteNext(t); } } } shiftAndExecuteNext(t) { this.queues[t].shift(), this.executeNext(t); } current(t) { return this.queues[t][0]; } } const ya = /(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/; function Aa(t) { const e = t.querySelectorAll("source"); [].slice.call(e).forEach(e => { t.removeChild(e); }); } const va = { 42: 225, 92: 233, 94: 237, 95: 243, 96: 250, 123: 231, 124: 247, 125: 209, 126: 241, 127: 9608, 128: 174, 129: 176, 130: 189, 131: 191, 132: 8482, 133: 162, 134: 163, 135: 9834, 136: 224, 137: 32, 138: 232, 139: 226, 140: 234, 141: 238, 142: 244, 143: 251, 144: 193, 145: 201, 146: 211, 147: 218, 148: 220, 149: 252, 150: 8216, 151: 161, 152: 42, 153: 8217, 154: 9473, 155: 169, 156: 8480, 157: 8226, 158: 8220, 159: 8221, 160: 192, 161: 194, 162: 199, 163: 200, 164: 202, 165: 203, 166: 235, 167: 206, 168: 207, 169: 239, 170: 212, 171: 217, 172: 249, 173: 219, 174: 171, 175: 187, 176: 195, 177: 227, 178: 205, 179: 204, 180: 236, 181: 210, 182: 242, 183: 213, 184: 245, 185: 123, 186: 125, 187: 92, 188: 94, 189: 95, 190: 124, 191: 8764, 192: 196, 193: 228, 194: 214, 195: 246, 196: 223, 197: 165, 198: 164, 199: 9475, 200: 197, 201: 229, 202: 216, 203: 248, 204: 9487, 205: 9491, 206: 9495, 207: 9499 }, ba = function (t) { let e = t; return va.hasOwnProperty(t) && (e = va[t]), String.fromCharCode(e); }, Ea = 15, wa = 100, xa = { 17: 1, 18: 3, 21: 5, 22: 7, 23: 9, 16: 11, 19: 12, 20: 14 }, Sa = { 17: 2, 18: 4, 21: 6, 22: 8, 23: 10, 19: 13, 20: 15 }, _a = { 25: 1, 26: 3, 29: 5, 30: 7, 31: 9, 24: 11, 27: 12, 28: 14 }, Ta = { 25: 2, 26: 4, 29: 6, 30: 8, 31: 10, 27: 13, 28: 15 }, ka = ["white", "green", "blue", "cyan", "red", "yellow", "magenta", "black", "transparent"]; class Ca { constructor() { (this.time = null), (this.verboseLevel = 0); } log(t, e) { if (this.verboseLevel >= t) { const n = "function" == typeof e ? e() : e; ot.log(`${this.time} [${t}] ${n}`); } } } const La = function (t) { const e = []; for (let n = 0; n < t.length; n++) e.push(t[n].toString(16)); return e; }; class Ia { constructor() { (this.foreground = "white"), (this.underline = !1), (this.italics = !1), (this.background = "black"), (this.flash = !1); } reset() { (this.foreground = "white"), (this.underline = !1), (this.italics = !1), (this.background = "black"), (this.flash = !1); } setStyles(t) { const e = ["foreground", "underline", "italics", "background", "flash"]; for (let n = 0; n < e.length; n++) { const i = e[n]; t.hasOwnProperty(i) && (this[i] = t[i]); } } isDefault() { return "white" === this.foreground && !this.underline && !this.italics && "black" === this.background && !this.flash; } equals(t) { return ( this.foreground === t.foreground && this.underline === t.underline && this.italics === t.italics && this.background === t.background && this.flash === t.flash ); } copy(t) { (this.foreground = t.foreground), (this.underline = t.underline), (this.italics = t.italics), (this.background = t.background), (this.flash = t.flash); } toString() { return ( "color=" + this.foreground + ", underline=" + this.underline + ", italics=" + this.italics + ", background=" + this.background + ", flash=" + this.flash ); } } class Ra { constructor() { (this.uchar = " "), (this.penState = new Ia()); } reset() { (this.uchar = " "), this.penState.reset(); } setChar(t, e) { (this.uchar = t), this.penState.copy(e); } setPenState(t) { this.penState.copy(t); } equals(t) { return this.uchar === t.uchar && this.penState.equals(t.penState); } copy(t) { (this.uchar = t.uchar), this.penState.copy(t.penState); } isEmpty() { return " " === this.uchar && this.penState.isDefault(); } } class Da { constructor(t) { (this.chars = []), (this.pos = 0), (this.currPenState = new Ia()), (this.cueStartTime = null), (this.logger = void 0); for (let t = 0; t < wa; t++) this.chars.push(new Ra()); this.logger = t; } equals(t) { for (let e = 0; e < wa; e++) if (!this.chars[e].equals(t.chars[e])) return !1; return !0; } copy(t) { for (let e = 0; e < wa; e++) this.chars[e].copy(t.chars[e]); } isEmpty() { let t = !0; for (let e = 0; e < wa; e++) if (!this.chars[e].isEmpty()) { t = !1; break; } return t; } setCursor(t) { this.pos !== t && (this.pos = t), this.pos < 0 ? (this.logger.log(3, "Negative cursor position " + this.pos), (this.pos = 0)) : this.pos > wa && (this.logger.log(3, "Too large cursor position " + this.pos), (this.pos = wa)); } moveCursor(t) { const e = this.pos + t; if (t > 1) for (let t = this.pos + 1; t < e + 1; t++) this.chars[t].setPenState(this.currPenState); this.setCursor(e); } backSpace() { this.moveCursor(-1), this.chars[this.pos].setChar(" ", this.currPenState); } insertChar(t) { t >= 144 && this.backSpace(); const e = ba(t); this.pos >= wa ? this.logger.log( 0, () => "Cannot insert " + t.toString(16) + " (" + e + ") at position " + this.pos + ". Skipping it!" ) : (this.chars[this.pos].setChar(e, this.currPenState), this.moveCursor(1)); } clearFromPos(t) { let e; for (e = t; e < wa; e++) this.chars[e].reset(); } clear() { this.clearFromPos(0), (this.pos = 0), this.currPenState.reset(); } clearToEndOfRow() { this.clearFromPos(this.pos); } getTextString() { const t = []; let e = !0; for (let n = 0; n < wa; n++) { const i = this.chars[n].uchar; " " !== i && (e = !1), t.push(i); } return e ? "" : t.join(""); } setPenStyles(t) { this.currPenState.setStyles(t); this.chars[this.pos].setPenState(this.currPenState); } } class Ba { constructor(t) { (this.rows = []), (this.currRow = 14), (this.nrRollUpRows = null), (this.lastOutputScreen = null), (this.logger = void 0); for (let e = 0; e < Ea; e++) this.rows.push(new Da(t)); this.logger = t; } reset() { for (let t = 0; t < Ea; t++) this.rows[t].clear(); this.currRow = 14; } equals(t) { let e = !0; for (let n = 0; n < Ea; n++) if (!this.rows[n].equals(t.rows[n])) { e = !1; break; } return e; } copy(t) { for (let e = 0; e < Ea; e++) this.rows[e].copy(t.rows[e]); } isEmpty() { let t = !0; for (let e = 0; e < Ea; e++) if (!this.rows[e].isEmpty()) { t = !1; break; } return t; } backSpace() { this.rows[this.currRow].backSpace(); } clearToEndOfRow() { this.rows[this.currRow].clearToEndOfRow(); } insertChar(t) { this.rows[this.currRow].insertChar(t); } setPen(t) { this.rows[this.currRow].setPenStyles(t); } moveCursor(t) { this.rows[this.currRow].moveCursor(t); } setCursor(t) { this.logger.log(2, "setCursor: " + t); this.rows[this.currRow].setCursor(t); } setPAC(t) { this.logger.log(2, () => "pacData = " + JSON.stringify(t)); let e = t.row - 1; if ( (this.nrRollUpRows && e < this.nrRollUpRows - 1 && (e = this.nrRollUpRows - 1), this.nrRollUpRows && this.currRow !== e) ) { for (let t = 0; t < Ea; t++) this.rows[t].clear(); const t = this.currRow + 1 - this.nrRollUpRows, n = this.lastOutputScreen; if (n) { const i = n.rows[t].cueStartTime, r = this.logger.time; if (null !== i && null !== r && i < r) for (let i = 0; i < this.nrRollUpRows; i++) this.rows[e - this.nrRollUpRows + i + 1].copy(n.rows[t + i]); } } this.currRow = e; const n = this.rows[this.currRow]; if (null !== t.indent) { const e = t.indent, i = Math.max(e - 1, 0); n.setCursor(t.indent), (t.color = n.chars[i].penState.foreground); } const i = { foreground: t.color, underline: t.underline, italics: t.italics, background: "black", flash: !1 }; this.setPen(i); } setBkgData(t) { this.logger.log(2, () => "bkgData = " + JSON.stringify(t)), this.backSpace(), this.setPen(t), this.insertChar(32); } setRollUpRows(t) { this.nrRollUpRows = t; } rollUp() { if (null === this.nrRollUpRows) return void this.logger.log(3, "roll_up but nrRollUpRows not set yet"); this.logger.log(1, () => this.getDisplayText()); const t = this.currRow + 1 - this.nrRollUpRows, e = this.rows.splice(t, 1)[0]; e.clear(), this.rows.splice(this.currRow, 0, e), this.logger.log(2, "Rolling up"); } getDisplayText(t) { t = t || !1; const e = []; let n = "", i = -1; for (let n = 0; n < Ea; n++) { const r = this.rows[n].getTextString(); r && ((i = n + 1), t ? e.push("Row " + i + ": '" + r + "'") : e.push(r.trim())); } return e.length > 0 && (n = t ? "[" + e.join(" | ") + "]" : e.join("\n")), n; } getTextAndFormat() { return this.rows; } } class Pa { constructor(t, e, n) { (this.chNr = void 0), (this.outputFilter = void 0), (this.mode = void 0), (this.verbose = void 0), (this.displayedMemory = void 0), (this.nonDisplayedMemory = void 0), (this.lastOutputScreen = void 0), (this.currRollUpRow = void 0), (this.writeScreen = void 0), (this.cueStartTime = void 0), (this.logger = void 0), (this.chNr = t), (this.outputFilter = e), (this.mode = null), (this.verbose = 0), (this.displayedMemory = new Ba(n)), (this.nonDisplayedMemory = new Ba(n)), (this.lastOutputScreen = new Ba(n)), (this.currRollUpRow = this.displayedMemory.rows[14]), (this.writeScreen = this.displayedMemory), (this.mode = null), (this.cueStartTime = null), (this.logger = n); } reset() { (this.mode = null), this.displayedMemory.reset(), this.nonDisplayedMemory.reset(), this.lastOutputScreen.reset(), this.outputFilter.reset(), (this.currRollUpRow = this.displayedMemory.rows[14]), (this.writeScreen = this.displayedMemory), (this.mode = null), (this.cueStartTime = null); } getHandler() { return this.outputFilter; } setHandler(t) { this.outputFilter = t; } setPAC(t) { this.writeScreen.setPAC(t); } setBkgData(t) { this.writeScreen.setBkgData(t); } setMode(t) { t !== this.mode && ((this.mode = t), this.logger.log(2, () => "MODE=" + t), "MODE_POP-ON" === this.mode ? (this.writeScreen = this.nonDisplayedMemory) : ((this.writeScreen = this.displayedMemory), this.writeScreen.reset()), "MODE_ROLL-UP" !== this.mode && ((this.displayedMemory.nrRollUpRows = null), (this.nonDisplayedMemory.nrRollUpRows = null)), (this.mode = t)); } insertChars(t) { for (let e = 0; e < t.length; e++) this.writeScreen.insertChar(t[e]); const e = this.writeScreen === this.displayedMemory ? "DISP" : "NON_DISP"; this.logger.log(2, () => e + ": " + this.writeScreen.getDisplayText(!0)), ("MODE_PAINT-ON" !== this.mode && "MODE_ROLL-UP" !== this.mode) || (this.logger.log(1, () => "DISPLAYED: " + this.displayedMemory.getDisplayText(!0)), this.outputDataUpdate()); } ccRCL() { this.logger.log(2, "RCL - Resume Caption Loading"), this.setMode("MODE_POP-ON"); } ccBS() { this.logger.log(2, "BS - BackSpace"), "MODE_TEXT" !== this.mode && (this.writeScreen.backSpace(), this.writeScreen === this.displayedMemory && this.outputDataUpdate()); } ccAOF() { } ccAON() { } ccDER() { this.logger.log(2, "DER- Delete to End of Row"), this.writeScreen.clearToEndOfRow(), this.outputDataUpdate(); } ccRU(t) { this.logger.log(2, "RU(" + t + ") - Roll Up"), (this.writeScreen = this.displayedMemory), this.setMode("MODE_ROLL-UP"), this.writeScreen.setRollUpRows(t); } ccFON() { this.logger.log(2, "FON - Flash On"), this.writeScreen.setPen({ flash: !0 }); } ccRDC() { this.logger.log(2, "RDC - Resume Direct Captioning"), this.setMode("MODE_PAINT-ON"); } ccTR() { this.logger.log(2, "TR"), this.setMode("MODE_TEXT"); } ccRTD() { this.logger.log(2, "RTD"), this.setMode("MODE_TEXT"); } ccEDM() { this.logger.log(2, "EDM - Erase Displayed Memory"), this.displayedMemory.reset(), this.outputDataUpdate(!0); } ccCR() { this.logger.log(2, "CR - Carriage Return"), this.writeScreen.rollUp(), this.outputDataUpdate(!0); } ccENM() { this.logger.log(2, "ENM - Erase Non-displayed Memory"), this.nonDisplayedMemory.reset(); } ccEOC() { if ((this.logger.log(2, "EOC - End Of Caption"), "MODE_POP-ON" === this.mode)) { const t = this.displayedMemory; (this.displayedMemory = this.nonDisplayedMemory), (this.nonDisplayedMemory = t), (this.writeScreen = this.nonDisplayedMemory), this.logger.log(1, () => "DISP: " + this.displayedMemory.getDisplayText()); } this.outputDataUpdate(!0); } ccTO(t) { this.logger.log(2, "TO(" + t + ") - Tab Offset"), this.writeScreen.moveCursor(t); } ccMIDROW(t) { const e = { flash: !1 }; if (((e.underline = t % 2 == 1), (e.italics = t >= 46), e.italics)) e.foreground = "white"; else { const n = Math.floor(t / 2) - 16, i = ["white", "green", "blue", "cyan", "red", "yellow", "magenta"]; e.foreground = i[n]; } this.logger.log(2, "MIDROW: " + JSON.stringify(e)), this.writeScreen.setPen(e); } outputDataUpdate(t = !1) { const e = this.logger.time; null !== e && this.outputFilter && (null !== this.cueStartTime || this.displayedMemory.isEmpty() ? this.displayedMemory.equals(this.lastOutputScreen) || (this.outputFilter.newCue(this.cueStartTime, e, this.lastOutputScreen), t && this.outputFilter.dispatchCue && this.outputFilter.dispatchCue(), (this.cueStartTime = this.displayedMemory.isEmpty() ? null : e)) : (this.cueStartTime = e), this.lastOutputScreen.copy(this.displayedMemory)); } cueSplitAtTime(t) { this.outputFilter && (this.displayedMemory.isEmpty() || (this.outputFilter.newCue && this.outputFilter.newCue(this.cueStartTime, t, this.displayedMemory), (this.cueStartTime = t))); } } class Ua { constructor(t, e, n) { (this.channels = void 0), (this.currentChannel = 0), (this.cmdHistory = { a: null, b: null }), (this.logger = void 0); const i = (this.logger = new Ca()); this.channels = [null, new Pa(t, e, i), new Pa(t + 1, n, i)]; } getHandler(t) { return this.channels[t].getHandler(); } setHandler(t, e) { this.channels[t].setHandler(e); } addData(t, e) { let n, i, r, a = !1; this.logger.time = t; for (let t = 0; t < e.length; t += 2) if (((i = 127 & e[t]), (r = 127 & e[t + 1]), 0 !== i || 0 !== r)) { if ( (this.logger.log(3, "[" + La([e[t], e[t + 1]]) + "] -> (" + La([i, r]) + ")"), (n = this.parseCmd(i, r)), n || (n = this.parseMidrow(i, r)), n || (n = this.parsePAC(i, r)), n || (n = this.parseBackgroundAttributes(i, r)), !n && ((a = this.parseChars(i, r)), a)) ) { const t = this.currentChannel; if (t && t > 0) { this.channels[t].insertChars(a); } else this.logger.log(2, "No channel found yet. TEXT-MODE?"); } n || a || this.logger.log(2, "Couldn't parse cleaned data " + La([i, r]) + " orig: " + La([e[t], e[t + 1]])); } } parseCmd(t, e) { const { cmdHistory: n } = this; if ( !((20 === t || 28 === t || 21 === t || 29 === t) && e >= 32 && e <= 47) && !((23 === t || 31 === t) && e >= 33 && e <= 35) ) return !1; if (Oa(t, e, n)) return Fa(null, null, n), this.logger.log(3, "Repeated command (" + La([t, e]) + ") is dropped"), !0; const i = 20 === t || 21 === t || 23 === t ? 1 : 2, r = this.channels[i]; return ( 20 === t || 21 === t || 28 === t || 29 === t ? 32 === e ? r.ccRCL() : 33 === e ? r.ccBS() : 34 === e ? r.ccAOF() : 35 === e ? r.ccAON() : 36 === e ? r.ccDER() : 37 === e ? r.ccRU(2) : 38 === e ? r.ccRU(3) : 39 === e ? r.ccRU(4) : 40 === e ? r.ccFON() : 41 === e ? r.ccRDC() : 42 === e ? r.ccTR() : 43 === e ? r.ccRTD() : 44 === e ? r.ccEDM() : 45 === e ? r.ccCR() : 46 === e ? r.ccENM() : 47 === e && r.ccEOC() : r.ccTO(e - 32), Fa(t, e, n), (this.currentChannel = i), !0 ); } parseMidrow(t, e) { let n = 0; if ((17 === t || 25 === t) && e >= 32 && e <= 47) { if (((n = 17 === t ? 1 : 2), n !== this.currentChannel)) return this.logger.log(0, "Mismatch channel in midrow parsing"), !1; const i = this.channels[n]; return !!i && (i.ccMIDROW(e), this.logger.log(3, "MIDROW (" + La([t, e]) + ")"), !0); } return !1; } parsePAC(t, e) { let n; const i = this.cmdHistory; if ( !(((t >= 17 && t <= 23) || (t >= 25 && t <= 31)) && e >= 64 && e <= 127) && !((16 === t || 24 === t) && e >= 64 && e <= 95) ) return !1; if (Oa(t, e, i)) return Fa(null, null, i), !0; const r = t <= 23 ? 1 : 2; n = e >= 64 && e <= 95 ? (1 === r ? xa[t] : _a[t]) : 1 === r ? Sa[t] : Ta[t]; const a = this.channels[r]; return !!a && (a.setPAC(this.interpretPAC(n, e)), Fa(t, e, i), (this.currentChannel = r), !0); } interpretPAC(t, e) { let n; const i = { color: null, italics: !1, indent: null, underline: !1, row: t }; return ( (n = e > 95 ? e - 96 : e - 64), (i.underline = !(1 & ~n)), n <= 13 ? (i.color = ["white", "green", "blue", "cyan", "red", "yellow", "magenta", "white"][Math.floor(n / 2)]) : n <= 15 ? ((i.italics = !0), (i.color = "white")) : (i.indent = 4 * Math.floor((n - 16) / 2)), i ); } parseChars(t, e) { let n, i = null, r = null; if ((t >= 25 ? ((n = 2), (r = t - 8)) : ((n = 1), (r = t)), r >= 17 && r <= 19)) { let t; (t = 17 === r ? e + 80 : 18 === r ? e + 112 : e + 144), this.logger.log(2, "Special char '" + ba(t) + "' in channel " + n), (i = [t]); } else t >= 32 && t <= 127 && (i = 0 === e ? [t] : [t, e]); if (i) { const n = La(i); this.logger.log(3, "Char codes = " + n.join(",")), Fa(t, e, this.cmdHistory); } return i; } parseBackgroundAttributes(t, e) { if (!((16 === t || 24 === t) && e >= 32 && e <= 47) && !((23 === t || 31 === t) && e >= 45 && e <= 47)) return !1; let n; const i = {}; 16 === t || 24 === t ? ((n = Math.floor((e - 32) / 2)), (i.background = ka[n]), e % 2 == 1 && (i.background = i.background + "_semi")) : 45 === e ? (i.background = "transparent") : ((i.foreground = "black"), 47 === e && (i.underline = !0)); const r = t <= 23 ? 1 : 2; return this.channels[r].setBkgData(i), Fa(t, e, this.cmdHistory), !0; } reset() { for (let t = 0; t < Object.keys(this.channels).length; t++) { const e = this.channels[t]; e && e.reset(); } this.cmdHistory = { a: null, b: null }; } cueSplitAtTime(t) { for (let e = 0; e < this.channels.length; e++) { const n = this.channels[e]; n && n.cueSplitAtTime(t); } } } function Fa(t, e, n) { (n.a = t), (n.b = e); } function Oa(t, e, n) { return n.a === t && n.b === e; } class Ma { constructor(t, e) { (this.timelineController = void 0), (this.cueRanges = []), (this.trackName = void 0), (this.startTime = null), (this.endTime = null), (this.screen = null), (this.timelineController = t), (this.trackName = e); } dispatchCue() { null !== this.startTime && (this.timelineController.addCues(this.trackName, this.startTime, this.endTime, this.screen, this.cueRanges), (this.startTime = null)); } newCue(t, e, n) { (null === this.startTime || this.startTime > t) && (this.startTime = t), (this.endTime = e), (this.screen = n), this.timelineController.createCaptionsTrack(this.trackName); } reset() { (this.cueRanges = []), (this.startTime = null); } } var Na = (function () { if (null != St && St.VTTCue) return self.VTTCue; const t = ["", "lr", "rl"], e = ["start", "middle", "end", "left", "right"]; function n(t, e) { if ("string" != typeof e) return !1; if (!Array.isArray(t)) return !1; const n = e.toLowerCase(); return !!~t.indexOf(n) && n; } function i(t) { return n(e, t); } function r(t, ...e) { let n = 1; for (; n < arguments.length; n++) { const e = arguments[n]; for (const n in e) t[n] = e[n]; } return t; } function a(e, a, s) { const o = this, l = { enumerable: !0 }; o.hasBeenReset = !1; let d = "", c = !1, u = e, h = a, p = s, f = null, m = "", g = !0, y = "auto", A = "start", v = 50, b = "middle", E = 50, w = "middle"; Object.defineProperty( o, "id", r({}, l, { get: function () { return d; }, set: function (t) { d = "" + t; } }) ), Object.defineProperty( o, "pauseOnExit", r({}, l, { get: function () { return c; }, set: function (t) { c = !!t; } }) ), Object.defineProperty( o, "startTime", r({}, l, { get: function () { return u; }, set: function (t) { if ("number" != typeof t) throw new TypeError("Start time must be set to a number."); (u = t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "endTime", r({}, l, { get: function () { return h; }, set: function (t) { if ("number" != typeof t) throw new TypeError("End time must be set to a number."); (h = t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "text", r({}, l, { get: function () { return p; }, set: function (t) { (p = "" + t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "region", r({}, l, { get: function () { return f; }, set: function (t) { (f = t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "vertical", r({}, l, { get: function () { return m; }, set: function (e) { const i = (function (e) { return n(t, e); })(e); if (!1 === i) throw new SyntaxError("An invalid or illegal string was specified."); (m = i), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "snapToLines", r({}, l, { get: function () { return g; }, set: function (t) { (g = !!t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "line", r({}, l, { get: function () { return y; }, set: function (t) { if ("number" != typeof t && "auto" !== t) throw new SyntaxError("An invalid number or illegal string was specified."); (y = t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "lineAlign", r({}, l, { get: function () { return A; }, set: function (t) { const e = i(t); if (!e) throw new SyntaxError("An invalid or illegal string was specified."); (A = e), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "position", r({}, l, { get: function () { return v; }, set: function (t) { if (t < 0 || t > 100) throw new Error("Position must be between 0 and 100."); (v = t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "positionAlign", r({}, l, { get: function () { return b; }, set: function (t) { const e = i(t); if (!e) throw new SyntaxError("An invalid or illegal string was specified."); (b = e), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "size", r({}, l, { get: function () { return E; }, set: function (t) { if (t < 0 || t > 100) throw new Error("Size must be between 0 and 100."); (E = t), (this.hasBeenReset = !0); } }) ), Object.defineProperty( o, "align", r({}, l, { get: function () { return w; }, set: function (t) { const e = i(t); if (!e) throw new SyntaxError("An invalid or illegal string was specified."); (w = e), (this.hasBeenReset = !0); } }) ), (o.displayState = void 0); } return ( (a.prototype.getCueAsHTML = function () { return self.WebVTT.convertCueToDOMTree(self, this.text); }), a ); })(); class za { decode(t, e) { if (!t) return ""; if ("string" != typeof t) throw new Error("Error - expected string data."); return decodeURIComponent(encodeURIComponent(t)); } } function Ga(t) { function e(t, e, n, i) { return 3600 * (0 | t) + 60 * (0 | e) + (0 | n) + parseFloat(i || 0); } const n = t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/); return n ? (parseFloat(n[2]) > 59 ? e(n[2], n[3], 0, n[4]) : e(n[1], n[2], n[3], n[4])) : null; } class ja { constructor() { this.values = Object.create(null); } set(t, e) { this.get(t) || "" === e || (this.values[t] = e); } get(t, e, n) { return n ? (this.has(t) ? this.values[t] : e[n]) : this.has(t) ? this.values[t] : e; } has(t) { return t in this.values; } alt(t, e, n) { for (let i = 0; i < n.length; ++i) if (e === n[i]) { this.set(t, e); break; } } integer(t, e) { /^-?\d+$/.test(e) && this.set(t, parseInt(e, 10)); } percent(t, e) { if (/^([\d]{1,3})(\.[\d]*)?%$/.test(e)) { const n = parseFloat(e); if (n >= 0 && n <= 100) return this.set(t, n), !0; } return !1; } } function Ha(t, e, n, i) { const r = i ? t.split(i) : [t]; for (const t in r) { if ("string" != typeof r[t]) continue; const i = r[t].split(n); if (2 !== i.length) continue; e(i[0], i[1]); } } const Ya = new Na(0, 0, ""), $a = "middle" === Ya.align ? "middle" : "center"; function Ka(t, e, n) { const i = t; function r() { const e = Ga(t); if (null === e) throw new Error("Malformed timestamp: " + i); return (t = t.replace(/^[^\sa-zA-Z-]+/, "")), e; } function a() { t = t.replace(/^\s+/, ""); } if ((a(), (e.startTime = r()), a(), "--\x3e" !== t.slice(0, 3))) throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): " + i); (t = t.slice(3)), a(), (e.endTime = r()), a(), (function (t, e) { const i = new ja(); Ha( t, function (t, e) { let r; switch (t) { case "region": for (let r = n.length - 1; r >= 0; r--) if (n[r].id === e) { i.set(t, n[r].region); break; } break; case "vertical": i.alt(t, e, ["rl", "lr"]); break; case "line": (r = e.split(",")), i.integer(t, r[0]), i.percent(t, r[0]) && i.set("snapToLines", !1), i.alt(t, r[0], ["auto"]), 2 === r.length && i.alt("lineAlign", r[1], ["start", $a, "end"]); break; case "position": (r = e.split(",")), i.percent(t, r[0]), 2 === r.length && i.alt("positionAlign", r[1], ["start", $a, "end", "line-left", "line-right", "auto"]); break; case "size": i.percent(t, e); break; case "align": i.alt(t, e, ["start", $a, "end", "left", "right"]); } }, /:/, /\s/ ), (e.region = i.get("region", null)), (e.vertical = i.get("vertical", "")); let r = i.get("line", "auto"); "auto" === r && -1 === Ya.line && (r = -1), (e.line = r), (e.lineAlign = i.get("lineAlign", "start")), (e.snapToLines = i.get("snapToLines", !0)), (e.size = i.get("size", 100)), (e.align = i.get("align", $a)); let a = i.get("position", "auto"); "auto" === a && 50 === Ya.position && (a = "start" === e.align || "left" === e.align ? 0 : "end" === e.align || "right" === e.align ? 100 : 50), (e.position = a); })(t, e); } function qa(t) { return t.replace(/') .concat(t.text || "", "
") : "", "\n\n" ) ), n.addEventListener("click", function (t) { t.stopPropagation(); }), (e.style.overflow = "hidden"), e.appendChild(n); } } var Th = "M3U8", kh = (function () { return m( function t(e) { var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; f(this, t), g(this, "version", "1.3.0"), g(this, "playerType", Th), (this.el = e), (this.eventList = []), (this.options = Object.assign({}, n, { playerType: this.playerType })), console.log("options", n); var i = new To({ debug: n.debug }); (this.$logger = i), i.log("VideoPlayerClass init", e, this.options); var r = So(); (this.$emitter = r), (this.$reporter = new ju({ logger: i, emitter: r })), this.options.prefixAd && this.options.prefixAd.list ? this.playAd() : this.createPlayer(this.options), i.log("VideoPlayer::created::version", this.version); }, [ { key: "getReportInfo", value: function () { var t = R(); return ( (t.player = "DPlayer"), (t.playerType = this.playerType), (t.events = this.$reporter.reports), t ); } }, { key: "playAd", value: ((n = p( d().mark(function t() { var e, n, i, r, a, s, o, l, c, u, h = this; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if ( ((n = this.options.prefixAd), (i = n.list), (r = void 0 === i ? [] : i), (a = n.time), (s = void 0 === a ? 5 : a), null == this.adCountdown && (this.adCountdown = s), console.log("list::", r), r.length) ) { t.next = 6; break; } return this.createPlayer(this.options), t.abrupt("return"); case 6: return ( (o = r.shift()), (t.next = 9), this.createPlayer({ src: o.src, autoplay: !0, muted: !0, isAD: !0 }) ); case 9: null !== (e = this.dplayer) && void 0 !== e && e.video && (F || ((this.dplayer.video.muted = !0), setTimeout(function () { h.dplayer.play(); }, 1e3))), ((l = document.createElement("a")).style.opacity = "100%"), (l.style.width = "100%"), (l.style.height = "100%"), (l.style.position = "absolute"), (l.style.top = "0"), (l.target = "_blank"), (l.href = o.link), (c = document.createElement("span")), ((u = document.querySelector(this.el)).style.position = "relative"), (c.style.padding = "3px 5px"), (c.style.display = "flex"), (c.style.justifyContent = "center"), (c.style.alignItems = "center"), (c.style.margin = "10px"), (c.style.height = "30px"), (c.style.borderRadius = "10px"), (c.style.background = "grey"), c.addEventListener( "click", p( d().mark(function t() { return d().wrap(function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (!(h.adCountdown > 0)) { t.next = 3; break; } return ( h.$emitter.emit("skip-ads", !1), t.abrupt("return") ); case 3: (r.length = 0), h.$emitter.emit("skip-ads", !0), h.createPlayer(h.options); case 6: case "end": return t.stop(); } }, t); }) ) ), (c.style.color = "white"), (c.style.zIndex = "99999"), (c.style.position = "absolute"), (c.style.top = "0"), (c.style.right = "0"), (c.style.cursor = "pointer"), (c.className = "close-button"), F && ((c.style.top = "-45px"), (u.style.overflow = "visible")), u.append(c), u.append(l), this.$emitter.on("ended", function () { h.$logger.log("ad::ended"), (h.dplayer.events.events.error = []), h.playAd(); }), console.log("adTimer::", this.adTimer), this.adTimer && clearInterval(this.adTimer), (c.innerText = "".concat( this.adCountdown > 0 ? this.adCountdown + "s | " : "", "跳过广告" )), (this.adTimer = setInterval(function () { (h.adCountdown -= 1), (c.innerText = "".concat( h.adCountdown > 0 ? h.adCountdown + "s | " : "", "跳过广告" )), h.adCountdown <= 0 && clearInterval(h.adTimer); }, 1e3)); case 45: case "end": return t.stop(); } }, t, this ); }) )), function () { return n.apply(this, arguments); }) }, { key: "createPlayer", value: ((e = p( d().mark(function t(e) { var n, i, r, a, s, o = this; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: return (t.next = 2), this.destroy(); case 2: return ( (n = this.el), e.isAD && this.$emitter.on("error", function (t) { o.$logger.log("ad::error", t), o.playAd(); }), this.$emitter.on("*", function (t, e) { o.$logger.log("reporter::", t, e), o.$reporter.add({ event: t }); }), (i = new bh({ emitter: this.$emitter, logger: this.$logger })), (t.next = 8), i.getResolution(e.src) ); case 8: (r = t.sent), this.$logger.log("getResolution", r), (a = { container: document.querySelector("".concat(n)), autoplay: e.autoplay, loop: e.loop, video: { url: e.src, pic: e.poster, type: "customHls", customType: { customHls: function (t, e) { if (!P && xo.isSupported()) { console.log("Hls.isSupported"); var n = new xo(); n.loadSource(t.src), n.attachMedia(t); } } } } }), e.muted && (a.volume = 0), r && (r.length > 1 ? ((a.video.quality = r), (a.video.defaultQuality = 0)) : (a.video.url = r[0].url)), (this.dplayer = new j(a)), (e.controls && !e.isAD) || (document.querySelector(".dplayer-controller-mask").remove(), document.querySelector(".dplayer-controller").remove()), (s = document.querySelector(".dplayer-play-icon")) && ((s.style.display = "inline-block"), (document.querySelector( ".dplayer-controller" ).style.zIndex = 100)), this.initDPlayerEvnets(this.dplayer), e.isAD || (this.$logger.log("renderAdvertisement", this.el, this.options), _h({ el: this.el, adList: this.options.adList, player: this })); case 20: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return e.apply(this, arguments); }) }, { key: "initDPlayerEvnets", value: function (t) { var e = this; if ((console.log("initDPlayerEvnets", t, this.eventList), t)) { [ "canplay", "canplaythrough", "durationchange", "ended", "error", "loadeddata", "loadedmetadata", "loadstart", "pause", "play", "playing", "progress", "ratechange", "seeked", "seeking", "volumechange", "waiting", "fullscreen" ].forEach(function (n) { t.on(n, function (t) { e.$emitter.emit(n, t); }); }), this.eventList.forEach(function (t) { e.$emitter.on(t.eventType, t.cb); }); } } }, { key: "getVideo", value: function () { if (this.dplayer) return this.dplayer.video; } }, { key: "on", value: function (t, e) { if (!t || !tl(e)) throw new Error("on方法参数有误"); this.eventList.push({ eventType: t, cb: e }); } }, { key: "off", value: function (t, e) { if (!t || !tl(e)) throw new Error("on方法参数有误"); var n = Du(this.eventList, ["cb", e]); n >= 0 && this.eventList.splice(n, 1); } }, { key: "destroy", value: ((t = p( d().mark(function t() { var e; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: this.$emitter.all.clear(), null === (e = this.dplayer) || void 0 === e || e.destroy(), clearInterval(this.adTimer), this.$logger.log("destroy"); case 4: case "end": return t.stop(); } }, t, this ); }) )), function () { return t.apply(this, arguments); }) } ] ); var t, e, n; })(); g(kh, "isSupported", function () { return !F; }), g(kh, "getPlayerType", function () { return Th; }), g(kh, "getDevice", function () { return I; }); !(function (t) { var e, n, r = ((e = new Date()), (n = 4), { setLogLevel: function (t) { n = t == this.debug ? 1 : t == this.info ? 2 : t == this.warn ? 3 : (this.error, 4); }, debug: function (t, i) { void 0 === console.debug && (console.debug = console.log), 1 >= n && console.debug("[" + r.getDurationString(new Date() - e, 1e3) + "]", "[" + t + "]", i); }, log: function (t, e) { this.debug(t.msg); }, info: function (t, i) { 2 >= n && console.info("[" + r.getDurationString(new Date() - e, 1e3) + "]", "[" + t + "]", i); }, warn: function (t, i) { 3 >= n && console.warn("[" + r.getDurationString(new Date() - e, 1e3) + "]", "[" + t + "]", i); }, error: function (t, i) { 4 >= n && console.error("[" + r.getDurationString(new Date() - e, 1e3) + "]", "[" + t + "]", i); } }); (r.getDurationString = function (t, e) { var n; function i(t, e) { for (var n = ("" + t).split("."); n[0].length < e;) n[0] = "0" + n[0]; return n.join("."); } t < 0 ? ((n = !0), (t = -t)) : (n = !1); var r = t / (e || 1), a = Math.floor(r / 3600); r -= 3600 * a; var s = Math.floor(r / 60), o = 1e3 * (r -= 60 * s); return ( (o -= 1e3 * (r = Math.floor(r))), (o = Math.floor(o)), (n ? "-" : "") + a + ":" + i(s, 2) + ":" + i(r, 2) + "." + i(o, 3) ); }), (r.printRanges = function (t) { var e = t.length; if (e > 0) { for (var n = "", i = 0; i < e; i++) i > 0 && (n += ","), (n += "[" + r.getDurationString(t.start(i)) + "," + r.getDurationString(t.end(i)) + "]"); return n; } return "(empty)"; }), (t.Log = r); var a = function (t) { if (!(t instanceof ArrayBuffer)) throw "Needs an array buffer"; (this.buffer = t), (this.dataview = new DataView(t)), (this.position = 0); }; (a.prototype.getPosition = function () { return this.position; }), (a.prototype.getEndPosition = function () { return this.buffer.byteLength; }), (a.prototype.getLength = function () { return this.buffer.byteLength; }), (a.prototype.seek = function (t) { var e = Math.max(0, Math.min(this.buffer.byteLength, t)); return (this.position = isNaN(e) || !isFinite(e) ? 0 : e), !0; }), (a.prototype.isEos = function () { return this.getPosition() >= this.getEndPosition(); }), (a.prototype.readAnyInt = function (t, e) { var n = 0; if (this.position + t <= this.buffer.byteLength) { switch (t) { case 1: n = e ? this.dataview.getInt8(this.position) : this.dataview.getUint8(this.position); break; case 2: n = e ? this.dataview.getInt16(this.position) : this.dataview.getUint16(this.position); break; case 3: if (e) throw "No method for reading signed 24 bits values"; (n = this.dataview.getUint8(this.position) << 16), (n |= this.dataview.getUint8(this.position + 1) << 8), (n |= this.dataview.getUint8(this.position + 2)); break; case 4: n = e ? this.dataview.getInt32(this.position) : this.dataview.getUint32(this.position); break; case 8: if (e) throw "No method for reading signed 64 bits values"; (n = this.dataview.getUint32(this.position) << 32), (n |= this.dataview.getUint32(this.position + 4)); break; default: throw "readInt method not implemented for size: " + t; } return (this.position += t), n; } throw "Not enough bytes in buffer"; }), (a.prototype.readUint8 = function () { return this.readAnyInt(1, !1); }), (a.prototype.readUint16 = function () { return this.readAnyInt(2, !1); }), (a.prototype.readUint24 = function () { return this.readAnyInt(3, !1); }), (a.prototype.readUint32 = function () { return this.readAnyInt(4, !1); }), (a.prototype.readUint64 = function () { return this.readAnyInt(8, !1); }), (a.prototype.readString = function (t) { if (this.position + t <= this.buffer.byteLength) { for (var e = "", n = 0; n < t; n++) e += String.fromCharCode(this.readUint8()); return e; } throw "Not enough bytes in buffer"; }), (a.prototype.readCString = function () { for (var t = []; ;) { var e = this.readUint8(); if (0 === e) break; t.push(e); } return String.fromCharCode.apply(null, t); }), (a.prototype.readInt8 = function () { return this.readAnyInt(1, !0); }), (a.prototype.readInt16 = function () { return this.readAnyInt(2, !0); }), (a.prototype.readInt32 = function () { return this.readAnyInt(4, !0); }), (a.prototype.readInt64 = function () { return this.readAnyInt(8, !1); }), (a.prototype.readUint8Array = function (t) { for (var e = new Uint8Array(t), n = 0; n < t; n++) e[n] = this.readUint8(); return e; }), (a.prototype.readInt16Array = function (t) { for (var e = new Int16Array(t), n = 0; n < t; n++) e[n] = this.readInt16(); return e; }), (a.prototype.readUint16Array = function (t) { for (var e = new Int16Array(t), n = 0; n < t; n++) e[n] = this.readUint16(); return e; }), (a.prototype.readUint32Array = function (t) { for (var e = new Uint32Array(t), n = 0; n < t; n++) e[n] = this.readUint32(); return e; }), (a.prototype.readInt32Array = function (t) { for (var e = new Int32Array(t), n = 0; n < t; n++) e[n] = this.readInt32(); return e; }), (t.MP4BoxStream = a); var s = function t(e, n, i) { (this._byteOffset = n || 0), e instanceof ArrayBuffer ? (this.buffer = e) : "object" == u(e) ? ((this.dataView = e), n && (this._byteOffset += n)) : (this.buffer = new ArrayBuffer(e || 0)), (this.position = 0), (this.endianness = null == i ? t.LITTLE_ENDIAN : i); }; ((s.prototype = {}).getPosition = function () { return this.position; }), (s.prototype._realloc = function (t) { if (this._dynamicSize) { var e = this._byteOffset + this.position + t, n = this._buffer.byteLength; if (e <= n) e > this._byteLength && (this._byteLength = e); else { for (n < 1 && (n = 1); e > n;) n *= 2; var i = new ArrayBuffer(n), r = new Uint8Array(this._buffer); new Uint8Array(i, 0, r.length).set(r), (this.buffer = i), (this._byteLength = e); } } }), (s.prototype._trimAlloc = function () { if (this._byteLength != this._buffer.byteLength) { var t = new ArrayBuffer(this._byteLength), e = new Uint8Array(t), n = new Uint8Array(this._buffer, 0, e.length); e.set(n), (this.buffer = t); } }), (s.BIG_ENDIAN = !1), (s.LITTLE_ENDIAN = !0), (s.prototype._byteLength = 0), Object.defineProperty(s.prototype, "byteLength", { get: function () { return this._byteLength - this._byteOffset; } }), Object.defineProperty(s.prototype, "buffer", { get: function () { return this._trimAlloc(), this._buffer; }, set: function (t) { (this._buffer = t), (this._dataView = new DataView(this._buffer, this._byteOffset)), (this._byteLength = this._buffer.byteLength); } }), Object.defineProperty(s.prototype, "byteOffset", { get: function () { return this._byteOffset; }, set: function (t) { (this._byteOffset = t), (this._dataView = new DataView(this._buffer, this._byteOffset)), (this._byteLength = this._buffer.byteLength); } }), Object.defineProperty(s.prototype, "dataView", { get: function () { return this._dataView; }, set: function (t) { (this._byteOffset = t.byteOffset), (this._buffer = t.buffer), (this._dataView = new DataView(this._buffer, this._byteOffset)), (this._byteLength = this._byteOffset + t.byteLength); } }), (s.prototype.seek = function (t) { var e = Math.max(0, Math.min(this.byteLength, t)); this.position = isNaN(e) || !isFinite(e) ? 0 : e; }), (s.prototype.isEof = function () { return this.position >= this._byteLength; }), (s.prototype.mapUint8Array = function (t) { this._realloc(1 * t); var e = new Uint8Array(this._buffer, this.byteOffset + this.position, t); return (this.position += 1 * t), e; }), (s.prototype.readInt32Array = function (t, e) { t = null == t ? this.byteLength - this.position / 4 : t; var n = new Int32Array(t); return ( s.memcpy(n.buffer, 0, this.buffer, this.byteOffset + this.position, t * n.BYTES_PER_ELEMENT), s.arrayToNative(n, null == e ? this.endianness : e), (this.position += n.byteLength), n ); }), (s.prototype.readInt16Array = function (t, e) { t = null == t ? this.byteLength - this.position / 2 : t; var n = new Int16Array(t); return ( s.memcpy(n.buffer, 0, this.buffer, this.byteOffset + this.position, t * n.BYTES_PER_ELEMENT), s.arrayToNative(n, null == e ? this.endianness : e), (this.position += n.byteLength), n ); }), (s.prototype.readInt8Array = function (t) { t = null == t ? this.byteLength - this.position : t; var e = new Int8Array(t); return ( s.memcpy(e.buffer, 0, this.buffer, this.byteOffset + this.position, t * e.BYTES_PER_ELEMENT), (this.position += e.byteLength), e ); }), (s.prototype.readUint32Array = function (t, e) { t = null == t ? this.byteLength - this.position / 4 : t; var n = new Uint32Array(t); return ( s.memcpy(n.buffer, 0, this.buffer, this.byteOffset + this.position, t * n.BYTES_PER_ELEMENT), s.arrayToNative(n, null == e ? this.endianness : e), (this.position += n.byteLength), n ); }), (s.prototype.readUint16Array = function (t, e) { t = null == t ? this.byteLength - this.position / 2 : t; var n = new Uint16Array(t); return ( s.memcpy(n.buffer, 0, this.buffer, this.byteOffset + this.position, t * n.BYTES_PER_ELEMENT), s.arrayToNative(n, null == e ? this.endianness : e), (this.position += n.byteLength), n ); }), (s.prototype.readUint8Array = function (t) { t = null == t ? this.byteLength - this.position : t; var e = new Uint8Array(t); return ( s.memcpy(e.buffer, 0, this.buffer, this.byteOffset + this.position, t * e.BYTES_PER_ELEMENT), (this.position += e.byteLength), e ); }), (s.prototype.readFloat64Array = function (t, e) { t = null == t ? this.byteLength - this.position / 8 : t; var n = new Float64Array(t); return ( s.memcpy(n.buffer, 0, this.buffer, this.byteOffset + this.position, t * n.BYTES_PER_ELEMENT), s.arrayToNative(n, null == e ? this.endianness : e), (this.position += n.byteLength), n ); }), (s.prototype.readFloat32Array = function (t, e) { t = null == t ? this.byteLength - this.position / 4 : t; var n = new Float32Array(t); return ( s.memcpy(n.buffer, 0, this.buffer, this.byteOffset + this.position, t * n.BYTES_PER_ELEMENT), s.arrayToNative(n, null == e ? this.endianness : e), (this.position += n.byteLength), n ); }), (s.prototype.readInt32 = function (t) { var e = this._dataView.getInt32(this.position, null == t ? this.endianness : t); return (this.position += 4), e; }), (s.prototype.readInt16 = function (t) { var e = this._dataView.getInt16(this.position, null == t ? this.endianness : t); return (this.position += 2), e; }), (s.prototype.readInt8 = function () { var t = this._dataView.getInt8(this.position); return (this.position += 1), t; }), (s.prototype.readUint32 = function (t) { var e = this._dataView.getUint32(this.position, null == t ? this.endianness : t); return (this.position += 4), e; }), (s.prototype.readUint16 = function (t) { var e = this._dataView.getUint16(this.position, null == t ? this.endianness : t); return (this.position += 2), e; }), (s.prototype.readUint8 = function () { var t = this._dataView.getUint8(this.position); return (this.position += 1), t; }), (s.prototype.readFloat32 = function (t) { var e = this._dataView.getFloat32(this.position, null == t ? this.endianness : t); return (this.position += 4), e; }), (s.prototype.readFloat64 = function (t) { var e = this._dataView.getFloat64(this.position, null == t ? this.endianness : t); return (this.position += 8), e; }), (s.endianness = new Int8Array(new Int16Array([1]).buffer)[0] > 0), (s.memcpy = function (t, e, n, i, r) { var a = new Uint8Array(t, e, r), s = new Uint8Array(n, i, r); a.set(s); }), (s.arrayToNative = function (t, e) { return e == this.endianness ? t : this.flipArrayEndianness(t); }), (s.nativeToEndian = function (t, e) { return this.endianness == e ? t : this.flipArrayEndianness(t); }), (s.flipArrayEndianness = function (t) { for ( var e = new Uint8Array(t.buffer, t.byteOffset, t.byteLength), n = 0; n < t.byteLength; n += t.BYTES_PER_ELEMENT ) for (var i = n + t.BYTES_PER_ELEMENT - 1, r = n; i > r; i--, r++) { var a = e[r]; (e[r] = e[i]), (e[i] = a); } return t; }), (s.prototype.failurePosition = 0), (String.fromCharCodeUint8 = function (t) { for (var e = [], n = 0; n < t.length; n++) e[n] = t[n]; return String.fromCharCode.apply(null, e); }), (s.prototype.readString = function (t, e) { return null == e || "ASCII" == e ? String.fromCharCodeUint8.apply(null, [this.mapUint8Array(null == t ? this.byteLength - this.position : t)]) : new TextDecoder(e).decode(this.mapUint8Array(t)); }), (s.prototype.readCString = function (t) { var e = this.byteLength - this.position, n = new Uint8Array(this._buffer, this._byteOffset + this.position), i = e; null != t && (i = Math.min(t, e)); for (var r = 0; r < i && 0 !== n[r]; r++); var a = String.fromCharCodeUint8.apply(null, [this.mapUint8Array(r)]); return null != t ? (this.position += i - r) : r != e && (this.position += 1), a; }); var o = Math.pow(2, 32); (s.prototype.readInt64 = function () { return this.readInt32() * o + this.readUint32(); }), (s.prototype.readUint64 = function () { return this.readUint32() * o + this.readUint32(); }), (s.prototype.readInt64 = function () { return this.readUint32() * o + this.readUint32(); }), (s.prototype.readUint24 = function () { return (this.readUint8() << 16) + (this.readUint8() << 8) + this.readUint8(); }), (t.DataStream = s), (s.prototype.save = function (t) { var e = new Blob([this.buffer]); if (!window.URL || !URL.createObjectURL) throw "DataStream.save: Can't create object URL."; var n = window.URL.createObjectURL(e), i = document.createElement("a"); document.body.appendChild(i), i.setAttribute("href", n), i.setAttribute("download", t), i.setAttribute("target", "_self"), i.click(), window.URL.revokeObjectURL(n); }), (s.prototype._dynamicSize = !0), Object.defineProperty(s.prototype, "dynamicSize", { get: function () { return this._dynamicSize; }, set: function (t) { t || this._trimAlloc(), (this._dynamicSize = t); } }), (s.prototype.shift = function (t) { var e = new ArrayBuffer(this._byteLength - t), n = new Uint8Array(e), i = new Uint8Array(this._buffer, t, n.length); n.set(i), (this.buffer = e), (this.position -= t); }), (s.prototype.writeInt32Array = function (t, e) { if ( (this._realloc(4 * t.length), t instanceof Int32Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapInt32Array(t.length, e); else for (var n = 0; n < t.length; n++) this.writeInt32(t[n], e); }), (s.prototype.writeInt16Array = function (t, e) { if ( (this._realloc(2 * t.length), t instanceof Int16Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapInt16Array(t.length, e); else for (var n = 0; n < t.length; n++) this.writeInt16(t[n], e); }), (s.prototype.writeInt8Array = function (t) { if ( (this._realloc(1 * t.length), t instanceof Int8Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapInt8Array(t.length); else for (var e = 0; e < t.length; e++) this.writeInt8(t[e]); }), (s.prototype.writeUint32Array = function (t, e) { if ( (this._realloc(4 * t.length), t instanceof Uint32Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapUint32Array(t.length, e); else for (var n = 0; n < t.length; n++) this.writeUint32(t[n], e); }), (s.prototype.writeUint16Array = function (t, e) { if ( (this._realloc(2 * t.length), t instanceof Uint16Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapUint16Array(t.length, e); else for (var n = 0; n < t.length; n++) this.writeUint16(t[n], e); }), (s.prototype.writeUint8Array = function (t) { if ( (this._realloc(1 * t.length), t instanceof Uint8Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapUint8Array(t.length); else for (var e = 0; e < t.length; e++) this.writeUint8(t[e]); }), (s.prototype.writeFloat64Array = function (t, e) { if ( (this._realloc(8 * t.length), t instanceof Float64Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapFloat64Array(t.length, e); else for (var n = 0; n < t.length; n++) this.writeFloat64(t[n], e); }), (s.prototype.writeFloat32Array = function (t, e) { if ( (this._realloc(4 * t.length), t instanceof Float32Array && this.byteOffset + (this.position % t.BYTES_PER_ELEMENT) === 0) ) s.memcpy(this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength), this.mapFloat32Array(t.length, e); else for (var n = 0; n < t.length; n++) this.writeFloat32(t[n], e); }), (s.prototype.writeInt32 = function (t, e) { this._realloc(4), this._dataView.setInt32(this.position, t, null == e ? this.endianness : e), (this.position += 4); }), (s.prototype.writeInt16 = function (t, e) { this._realloc(2), this._dataView.setInt16(this.position, t, null == e ? this.endianness : e), (this.position += 2); }), (s.prototype.writeInt8 = function (t) { this._realloc(1), this._dataView.setInt8(this.position, t), (this.position += 1); }), (s.prototype.writeUint32 = function (t, e) { this._realloc(4), this._dataView.setUint32(this.position, t, null == e ? this.endianness : e), (this.position += 4); }), (s.prototype.writeUint16 = function (t, e) { this._realloc(2), this._dataView.setUint16(this.position, t, null == e ? this.endianness : e), (this.position += 2); }), (s.prototype.writeUint8 = function (t) { this._realloc(1), this._dataView.setUint8(this.position, t), (this.position += 1); }), (s.prototype.writeFloat32 = function (t, e) { this._realloc(4), this._dataView.setFloat32(this.position, t, null == e ? this.endianness : e), (this.position += 4); }), (s.prototype.writeFloat64 = function (t, e) { this._realloc(8), this._dataView.setFloat64(this.position, t, null == e ? this.endianness : e), (this.position += 8); }), (s.prototype.writeUCS2String = function (t, e, n) { null == n && (n = t.length); for (var i = 0; i < t.length && i < n; i++) this.writeUint16(t.charCodeAt(i), e); for (; i < n; i++) this.writeUint16(0); }), (s.prototype.writeString = function (t, e, n) { var i = 0; if (null == e || "ASCII" == e) if (null != n) { var r = Math.min(t.length, n); for (i = 0; i < r; i++) this.writeUint8(t.charCodeAt(i)); for (; i < n; i++) this.writeUint8(0); } else for (i = 0; i < t.length; i++) this.writeUint8(t.charCodeAt(i)); else this.writeUint8Array(new TextEncoder(e).encode(t.substring(0, n))); }), (s.prototype.writeCString = function (t, e) { var n = 0; if (null != e) { var i = Math.min(t.length, e); for (n = 0; n < i; n++) this.writeUint8(t.charCodeAt(n)); for (; n < e; n++) this.writeUint8(0); } else { for (n = 0; n < t.length; n++) this.writeUint8(t.charCodeAt(n)); this.writeUint8(0); } }), (s.prototype.writeStruct = function (t, e) { for (var n = 0; n < t.length; n += 2) { var i = t[n + 1]; this.writeType(i, e[t[n]], e); } }), (s.prototype.writeType = function (t, e, n) { var i; if ("function" == typeof t) return t(this, e); if ("object" == u(t) && !(t instanceof Array)) return t.set(this, e, n); var r = null, a = "ASCII", o = this.position; switch ( ("string" == typeof t && /:/.test(t) && ((i = t.split(":")), (t = i[0]), (r = parseInt(i[1]))), "string" == typeof t && /,/.test(t) && ((i = t.split(",")), (t = i[0]), (a = parseInt(i[1]))), t) ) { case "uint8": this.writeUint8(e); break; case "int8": this.writeInt8(e); break; case "uint16": this.writeUint16(e, this.endianness); break; case "int16": this.writeInt16(e, this.endianness); break; case "uint32": this.writeUint32(e, this.endianness); break; case "int32": this.writeInt32(e, this.endianness); break; case "float32": this.writeFloat32(e, this.endianness); break; case "float64": this.writeFloat64(e, this.endianness); break; case "uint16be": this.writeUint16(e, s.BIG_ENDIAN); break; case "int16be": this.writeInt16(e, s.BIG_ENDIAN); break; case "uint32be": this.writeUint32(e, s.BIG_ENDIAN); break; case "int32be": this.writeInt32(e, s.BIG_ENDIAN); break; case "float32be": this.writeFloat32(e, s.BIG_ENDIAN); break; case "float64be": this.writeFloat64(e, s.BIG_ENDIAN); break; case "uint16le": this.writeUint16(e, s.LITTLE_ENDIAN); break; case "int16le": this.writeInt16(e, s.LITTLE_ENDIAN); break; case "uint32le": this.writeUint32(e, s.LITTLE_ENDIAN); break; case "int32le": this.writeInt32(e, s.LITTLE_ENDIAN); break; case "float32le": this.writeFloat32(e, s.LITTLE_ENDIAN); break; case "float64le": this.writeFloat64(e, s.LITTLE_ENDIAN); break; case "cstring": this.writeCString(e, r); break; case "string": this.writeString(e, a, r); break; case "u16string": this.writeUCS2String(e, this.endianness, r); break; case "u16stringle": this.writeUCS2String(e, s.LITTLE_ENDIAN, r); break; case "u16stringbe": this.writeUCS2String(e, s.BIG_ENDIAN, r); break; default: if (3 == t.length) { for (var l = t[1], d = 0; d < e.length; d++) this.writeType(l, e[d]); break; } this.writeStruct(t, e); } null != r && ((this.position = o), this._realloc(r), (this.position = o + r)); }), (s.prototype.writeUint64 = function (t) { var e = Math.floor(t / o); this.writeUint32(e), this.writeUint32(4294967295 & t); }), (s.prototype.writeUint24 = function (t) { this.writeUint8((16711680 & t) >> 16), this.writeUint8((65280 & t) >> 8), this.writeUint8(255 & t); }), (s.prototype.adjustUint32 = function (t, e) { var n = this.position; this.seek(t), this.writeUint32(e), this.seek(n); }), (s.prototype.mapInt32Array = function (t, e) { this._realloc(4 * t); var n = new Int32Array(this._buffer, this.byteOffset + this.position, t); return s.arrayToNative(n, null == e ? this.endianness : e), (this.position += 4 * t), n; }), (s.prototype.mapInt16Array = function (t, e) { this._realloc(2 * t); var n = new Int16Array(this._buffer, this.byteOffset + this.position, t); return s.arrayToNative(n, null == e ? this.endianness : e), (this.position += 2 * t), n; }), (s.prototype.mapInt8Array = function (t) { this._realloc(1 * t); var e = new Int8Array(this._buffer, this.byteOffset + this.position, t); return (this.position += 1 * t), e; }), (s.prototype.mapUint32Array = function (t, e) { this._realloc(4 * t); var n = new Uint32Array(this._buffer, this.byteOffset + this.position, t); return s.arrayToNative(n, null == e ? this.endianness : e), (this.position += 4 * t), n; }), (s.prototype.mapUint16Array = function (t, e) { this._realloc(2 * t); var n = new Uint16Array(this._buffer, this.byteOffset + this.position, t); return s.arrayToNative(n, null == e ? this.endianness : e), (this.position += 2 * t), n; }), (s.prototype.mapFloat64Array = function (t, e) { this._realloc(8 * t); var n = new Float64Array(this._buffer, this.byteOffset + this.position, t); return s.arrayToNative(n, null == e ? this.endianness : e), (this.position += 8 * t), n; }), (s.prototype.mapFloat32Array = function (t, e) { this._realloc(4 * t); var n = new Float32Array(this._buffer, this.byteOffset + this.position, t); return s.arrayToNative(n, null == e ? this.endianness : e), (this.position += 4 * t), n; }); var l = function (t) { (this.buffers = []), (this.bufferIndex = -1), t && (this.insertBuffer(t), (this.bufferIndex = 0)); }; ((l.prototype = new s(new ArrayBuffer(), 0, s.BIG_ENDIAN)).initialized = function () { var t; return ( this.bufferIndex > -1 || (this.buffers.length > 0 ? 0 === (t = this.buffers[0]).fileStart ? ((this.buffer = t), (this.bufferIndex = 0), r.debug("MultiBufferStream", "Stream ready for parsing"), !0) : (r.warn("MultiBufferStream", "The first buffer should have a fileStart of 0"), this.logBufferLevel(), !1) : (r.warn("MultiBufferStream", "No buffer to start parsing from"), this.logBufferLevel(), !1)) ); }), (ArrayBuffer.concat = function (t, e) { r.debug("ArrayBuffer", "Trying to create a new buffer of size: " + (t.byteLength + e.byteLength)); var n = new Uint8Array(t.byteLength + e.byteLength); return n.set(new Uint8Array(t), 0), n.set(new Uint8Array(e), t.byteLength), n.buffer; }), (l.prototype.reduceBuffer = function (t, e, n) { var i; return ( (i = new Uint8Array(n)).set(new Uint8Array(t, e, n)), (i.buffer.fileStart = t.fileStart + e), (i.buffer.usedBytes = 0), i.buffer ); }), (l.prototype.insertBuffer = function (t) { for (var e = !0, n = 0; n < this.buffers.length; n++) { var i = this.buffers[n]; if (t.fileStart <= i.fileStart) { if (t.fileStart === i.fileStart) { if (t.byteLength > i.byteLength) { this.buffers.splice(n, 1), n--; continue; } r.warn( "MultiBufferStream", "Buffer (fileStart: " + t.fileStart + " - Length: " + t.byteLength + ") already appended, ignoring" ); } else t.fileStart + t.byteLength <= i.fileStart || (t = this.reduceBuffer(t, 0, i.fileStart - t.fileStart)), r.debug( "MultiBufferStream", "Appending new buffer (fileStart: " + t.fileStart + " - Length: " + t.byteLength + ")" ), this.buffers.splice(n, 0, t), 0 === n && (this.buffer = t); e = !1; break; } if (t.fileStart < i.fileStart + i.byteLength) { var a = i.fileStart + i.byteLength - t.fileStart, s = t.byteLength - a; if (!(s > 0)) { e = !1; break; } t = this.reduceBuffer(t, a, s); } } e && (r.debug( "MultiBufferStream", "Appending new buffer (fileStart: " + t.fileStart + " - Length: " + t.byteLength + ")" ), this.buffers.push(t), 0 === n && (this.buffer = t)); }), (l.prototype.logBufferLevel = function (t) { var e, n, i, a, s, o = [], l = ""; for (i = 0, a = 0, e = 0; e < this.buffers.length; e++) (n = this.buffers[e]), 0 === e ? ((s = {}), o.push(s), (s.start = n.fileStart), (s.end = n.fileStart + n.byteLength), (l += "[" + s.start + "-")) : s.end === n.fileStart ? (s.end = n.fileStart + n.byteLength) : (((s = {}).start = n.fileStart), (l += o[o.length - 1].end - 1 + "], [" + s.start + "-"), (s.end = n.fileStart + n.byteLength), o.push(s)), (i += n.usedBytes), (a += n.byteLength); o.length > 0 && (l += s.end - 1 + "]"); var d = t ? r.info : r.debug; 0 === this.buffers.length ? d("MultiBufferStream", "No more buffer in memory") : d( "MultiBufferStream", this.buffers.length + " stored buffer(s) (" + i + "/" + a + " bytes), continuous ranges: " + l ); }), (l.prototype.cleanBuffers = function () { var t, e; for (t = 0; t < this.buffers.length; t++) (e = this.buffers[t]).usedBytes === e.byteLength && (r.debug("MultiBufferStream", "Removing buffer #" + t), this.buffers.splice(t, 1), t--); }), (l.prototype.mergeNextBuffer = function () { var t; if (this.bufferIndex + 1 < this.buffers.length) { if ((t = this.buffers[this.bufferIndex + 1]).fileStart === this.buffer.fileStart + this.buffer.byteLength) { var e = this.buffer.byteLength, n = this.buffer.usedBytes, i = this.buffer.fileStart; return ( (this.buffers[this.bufferIndex] = ArrayBuffer.concat(this.buffer, t)), (this.buffer = this.buffers[this.bufferIndex]), this.buffers.splice(this.bufferIndex + 1, 1), (this.buffer.usedBytes = n), (this.buffer.fileStart = i), r.debug( "ISOFile", "Concatenating buffer for box parsing (length: " + e + "->" + this.buffer.byteLength + ")" ), !0 ); } return !1; } return !1; }), (l.prototype.findPosition = function (t, e, n) { var i, a = null, s = -1; for (i = !0 === t ? 0 : this.bufferIndex; i < this.buffers.length && (a = this.buffers[i]).fileStart <= e;) (s = i), n && (a.fileStart + a.byteLength <= e ? (a.usedBytes = a.byteLength) : (a.usedBytes = e - a.fileStart), this.logBufferLevel()), i++; return -1 !== s && (a = this.buffers[s]).fileStart + a.byteLength >= e ? (r.debug("MultiBufferStream", "Found position in existing buffer #" + s), s) : -1; }), (l.prototype.findEndContiguousBuf = function (t) { var e, n, i, r = void 0 !== t ? t : this.bufferIndex; if (((n = this.buffers[r]), this.buffers.length > r + 1)) for ( e = r + 1; e < this.buffers.length && (i = this.buffers[e]).fileStart === n.fileStart + n.byteLength; e++ ) n = i; return n.fileStart + n.byteLength; }), (l.prototype.getEndFilePositionAfter = function (t) { var e = this.findPosition(!0, t, !1); return -1 !== e ? this.findEndContiguousBuf(e) : t; }), (l.prototype.addUsedBytes = function (t) { (this.buffer.usedBytes += t), this.logBufferLevel(); }), (l.prototype.setAllUsedBytes = function () { (this.buffer.usedBytes = this.buffer.byteLength), this.logBufferLevel(); }), (l.prototype.seek = function (t, e, n) { var i; return -1 !== (i = this.findPosition(e, t, n)) ? ((this.buffer = this.buffers[i]), (this.bufferIndex = i), (this.position = t - this.buffer.fileStart), r.debug("MultiBufferStream", "Repositioning parser at buffer position: " + this.position), !0) : (r.debug("MultiBufferStream", "Position " + t + " not found in buffered data"), !1); }), (l.prototype.getPosition = function () { if (-1 === this.bufferIndex || null === this.buffers[this.bufferIndex]) throw "Error accessing position in the MultiBufferStream"; return this.buffers[this.bufferIndex].fileStart + this.position; }), (l.prototype.getLength = function () { return this.byteLength; }), (l.prototype.getEndPosition = function () { if (-1 === this.bufferIndex || null === this.buffers[this.bufferIndex]) throw "Error accessing position in the MultiBufferStream"; return this.buffers[this.bufferIndex].fileStart + this.byteLength; }), (t.MultiBufferStream = l); var d = function () { var t = []; (t[3] = "ES_Descriptor"), (t[4] = "DecoderConfigDescriptor"), (t[5] = "DecoderSpecificInfo"), (t[6] = "SLConfigDescriptor"), (this.getDescriptorName = function (e) { return t[e]; }); var e = this, n = {}; return ( (this.parseOneDescriptor = function (e) { var i, a, s, o = 0; for (i = e.readUint8(), s = e.readUint8(); 128 & s;) (o = (127 & s) << 7), (s = e.readUint8()); return ( (o += 127 & s), r.debug( "MPEG4DescriptorParser", "Found " + (t[i] || "Descriptor " + i) + ", size " + o + " at position " + e.getPosition() ), (a = t[i] ? new n[t[i]](o) : new n.Descriptor(o)).parse(e), a ); }), (n.Descriptor = function (t, e) { (this.tag = t), (this.size = e), (this.descs = []); }), (n.Descriptor.prototype.parse = function (t) { this.data = t.readUint8Array(this.size); }), (n.Descriptor.prototype.findDescriptor = function (t) { for (var e = 0; e < this.descs.length; e++) if (this.descs[e].tag == t) return this.descs[e]; return null; }), (n.Descriptor.prototype.parseRemainingDescriptors = function (t) { for (var n = t.position; t.position < n + this.size;) { var i = e.parseOneDescriptor(t); this.descs.push(i); } }), (n.ES_Descriptor = function (t) { n.Descriptor.call(this, 3, t); }), (n.ES_Descriptor.prototype = new n.Descriptor()), (n.ES_Descriptor.prototype.parse = function (t) { if ( ((this.ES_ID = t.readUint16()), (this.flags = t.readUint8()), (this.size -= 3), 128 & this.flags ? ((this.dependsOn_ES_ID = t.readUint16()), (this.size -= 2)) : (this.dependsOn_ES_ID = 0), 64 & this.flags) ) { var e = t.readUint8(); (this.URL = t.readString(e)), (this.size -= e + 1); } else this.URL = ""; 32 & this.flags ? ((this.OCR_ES_ID = t.readUint16()), (this.size -= 2)) : (this.OCR_ES_ID = 0), this.parseRemainingDescriptors(t); }), (n.ES_Descriptor.prototype.getOTI = function (t) { var e = this.findDescriptor(4); return e ? e.oti : 0; }), (n.ES_Descriptor.prototype.getAudioConfig = function (t) { var e = this.findDescriptor(4); if (!e) return null; var n = e.findDescriptor(5); if (n && n.data) { var i = (248 & n.data[0]) >> 3; return 31 === i && n.data.length >= 2 && (i = 32 + ((7 & n.data[0]) << 3) + ((224 & n.data[1]) >> 5)), i; } return null; }), (n.DecoderConfigDescriptor = function (t) { n.Descriptor.call(this, 4, t); }), (n.DecoderConfigDescriptor.prototype = new n.Descriptor()), (n.DecoderConfigDescriptor.prototype.parse = function (t) { (this.oti = t.readUint8()), (this.streamType = t.readUint8()), (this.bufferSize = t.readUint24()), (this.maxBitrate = t.readUint32()), (this.avgBitrate = t.readUint32()), (this.size -= 13), this.parseRemainingDescriptors(t); }), (n.DecoderSpecificInfo = function (t) { n.Descriptor.call(this, 5, t); }), (n.DecoderSpecificInfo.prototype = new n.Descriptor()), (n.SLConfigDescriptor = function (t) { n.Descriptor.call(this, 6, t); }), (n.SLConfigDescriptor.prototype = new n.Descriptor()), this ); }; t.MPEG4DescriptorParser = d; var c = { ERR_INVALID_DATA: -1, ERR_NOT_ENOUGH_DATA: 0, OK: 1, BASIC_BOXES: ["mdat", "idat", "free", "skip", "meco", "strk"], FULL_BOXES: ["hmhd", "nmhd", "iods", "xml ", "bxml", "ipro", "mere"], CONTAINER_BOXES: [ ["moov", ["trak", "pssh"]], ["trak"], ["edts"], ["mdia"], ["minf"], ["dinf"], ["stbl", ["sgpd", "sbgp"]], ["mvex", ["trex"]], ["moof", ["traf"]], ["traf", ["trun", "sgpd", "sbgp"]], ["vttc"], ["tref"], ["iref"], ["mfra", ["tfra"]], ["meco"], ["hnti"], ["hinf"], ["strk"], ["strd"], ["sinf"], ["rinf"], ["schi"], ["trgr"], ["udta", ["kind"]], ["iprp", ["ipma"]], ["ipco"], ["grpl"], ["j2kH"], ["etyp", ["tyco"]] ], boxCodes: [], fullBoxCodes: [], containerBoxCodes: [], sampleEntryCodes: {}, sampleGroupEntryCodes: [], trackGroupTypes: [], UUIDBoxes: {}, UUIDs: [], initialize: function () { (c.FullBox.prototype = new c.Box()), (c.ContainerBox.prototype = new c.Box()), (c.SampleEntry.prototype = new c.Box()), (c.TrackGroupTypeBox.prototype = new c.FullBox()), c.BASIC_BOXES.forEach(function (t) { c.createBoxCtor(t); }), c.FULL_BOXES.forEach(function (t) { c.createFullBoxCtor(t); }), c.CONTAINER_BOXES.forEach(function (t) { c.createContainerBoxCtor(t[0], null, t[1]); }); }, Box: function (t, e, n) { (this.type = t), (this.size = e), (this.uuid = n); }, FullBox: function (t, e, n) { c.Box.call(this, t, e, n), (this.flags = 0), (this.version = 0); }, ContainerBox: function (t, e, n) { c.Box.call(this, t, e, n), (this.boxes = []); }, SampleEntry: function (t, e, n, i) { c.ContainerBox.call(this, t, e), (this.hdr_size = n), (this.start = i); }, SampleGroupEntry: function (t) { this.grouping_type = t; }, TrackGroupTypeBox: function (t, e) { c.FullBox.call(this, t, e); }, createBoxCtor: function (t, e) { c.boxCodes.push(t), (c[t + "Box"] = function (e) { c.Box.call(this, t, e); }), (c[t + "Box"].prototype = new c.Box()), e && (c[t + "Box"].prototype.parse = e); }, createFullBoxCtor: function (t, e) { (c[t + "Box"] = function (e) { c.FullBox.call(this, t, e); }), (c[t + "Box"].prototype = new c.FullBox()), (c[t + "Box"].prototype.parse = function (t) { this.parseFullHeader(t), e && e.call(this, t); }); }, addSubBoxArrays: function (t) { if (t) { this.subBoxNames = t; for (var e = t.length, n = 0; n < e; n++) this[t[n] + "s"] = []; } }, createContainerBoxCtor: function (t, e, n) { (c[t + "Box"] = function (e) { c.ContainerBox.call(this, t, e), c.addSubBoxArrays.call(this, n); }), (c[t + "Box"].prototype = new c.ContainerBox()), e && (c[t + "Box"].prototype.parse = e); }, createMediaSampleEntryCtor: function (t, e, n) { (c.sampleEntryCodes[t] = []), (c[t + "SampleEntry"] = function (t, e) { c.SampleEntry.call(this, t, e), c.addSubBoxArrays.call(this, n); }), (c[t + "SampleEntry"].prototype = new c.SampleEntry()), e && (c[t + "SampleEntry"].prototype.parse = e); }, createSampleEntryCtor: function (t, e, n, i) { c.sampleEntryCodes[t].push(e), (c[e + "SampleEntry"] = function (n) { c[t + "SampleEntry"].call(this, e, n), c.addSubBoxArrays.call(this, i); }), (c[e + "SampleEntry"].prototype = new c[t + "SampleEntry"]()), n && (c[e + "SampleEntry"].prototype.parse = n); }, createEncryptedSampleEntryCtor: function (t, e, n) { c.createSampleEntryCtor.call(this, t, e, n, ["sinf"]); }, createSampleGroupCtor: function (t, e) { (c[t + "SampleGroupEntry"] = function (e) { c.SampleGroupEntry.call(this, t, e); }), (c[t + "SampleGroupEntry"].prototype = new c.SampleGroupEntry()), e && (c[t + "SampleGroupEntry"].prototype.parse = e); }, createTrackGroupCtor: function (t, e) { (c[t + "TrackGroupTypeBox"] = function (e) { c.TrackGroupTypeBox.call(this, t, e); }), (c[t + "TrackGroupTypeBox"].prototype = new c.TrackGroupTypeBox()), e && (c[t + "TrackGroupTypeBox"].prototype.parse = e); }, createUUIDBox: function (t, e, n, i) { c.UUIDs.push(t), (c.UUIDBoxes[t] = function (i) { e ? c.FullBox.call(this, "uuid", i, t) : n ? c.ContainerBox.call(this, "uuid", i, t) : c.Box.call(this, "uuid", i, t); }), (c.UUIDBoxes[t].prototype = e ? new c.FullBox() : n ? new c.ContainerBox() : new c.Box()), i && (c.UUIDBoxes[t].prototype.parse = e ? function (t) { this.parseFullHeader(t), i && i.call(this, t); } : i); } }; c.initialize(), (c.TKHD_FLAG_ENABLED = 1), (c.TKHD_FLAG_IN_MOVIE = 2), (c.TKHD_FLAG_IN_PREVIEW = 4), (c.TFHD_FLAG_BASE_DATA_OFFSET = 1), (c.TFHD_FLAG_SAMPLE_DESC = 2), (c.TFHD_FLAG_SAMPLE_DUR = 8), (c.TFHD_FLAG_SAMPLE_SIZE = 16), (c.TFHD_FLAG_SAMPLE_FLAGS = 32), (c.TFHD_FLAG_DUR_EMPTY = 65536), (c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF = 131072), (c.TRUN_FLAGS_DATA_OFFSET = 1), (c.TRUN_FLAGS_FIRST_FLAG = 4), (c.TRUN_FLAGS_DURATION = 256), (c.TRUN_FLAGS_SIZE = 512), (c.TRUN_FLAGS_FLAGS = 1024), (c.TRUN_FLAGS_CTS_OFFSET = 2048), (c.Box.prototype.add = function (t) { return this.addBox(new c[t + "Box"]()); }), (c.Box.prototype.addBox = function (t) { return this.boxes.push(t), this[t.type + "s"] ? this[t.type + "s"].push(t) : (this[t.type] = t), t; }), (c.Box.prototype.set = function (t, e) { return (this[t] = e), this; }), (c.Box.prototype.addEntry = function (t, e) { var n = e || "entries"; return this[n] || (this[n] = []), this[n].push(t), this; }), (t.BoxParser = c), (c.parseUUID = function (t) { return c.parseHex16(t); }), (c.parseHex16 = function (t) { for (var e = "", n = 0; n < 16; n++) { var i = t.readUint8().toString(16); e += 1 === i.length ? "0" + i : i; } return e; }), (c.parseOneBox = function (t, e, n) { var i, a, s, o = t.getPosition(), l = 0; if (t.getEndPosition() - o < 8) return ( r.debug("BoxParser", "Not enough data in stream to parse the type and size of the box"), { code: c.ERR_NOT_ENOUGH_DATA } ); if (n && n < 8) return ( r.debug("BoxParser", "Not enough bytes left in the parent box to parse a new box"), { code: c.ERR_NOT_ENOUGH_DATA } ); var d = t.readUint32(), u = t.readString(4), h = u; if ( (r.debug("BoxParser", "Found box of type '" + u + "' and size " + d + " at position " + o), (l = 8), "uuid" == u) ) { if (t.getEndPosition() - t.getPosition() < 16 || n - l < 16) return ( t.seek(o), r.debug("BoxParser", "Not enough bytes left in the parent box to parse a UUID box"), { code: c.ERR_NOT_ENOUGH_DATA } ); (l += 16), (h = s = c.parseUUID(t)); } if (1 == d) { if (t.getEndPosition() - t.getPosition() < 8 || (n && n - l < 8)) return ( t.seek(o), r.warn("BoxParser", 'Not enough data in stream to parse the extended size of the "' + u + '" box'), { code: c.ERR_NOT_ENOUGH_DATA } ); (d = t.readUint64()), (l += 8); } else if (0 === d) if (n) d = n; else if ("mdat" !== u) return ( r.error("BoxParser", "Unlimited box size not supported for type: '" + u + "'"), (i = new c.Box(u, d)), { code: c.OK, box: i, size: i.size } ); return 0 !== d && d < l ? (r.error("BoxParser", "Box of type " + u + " has an invalid size " + d + " (too small to be a box)"), { code: c.ERR_NOT_ENOUGH_DATA, type: u, size: d, hdr_size: l, start: o }) : 0 !== d && n && d > n ? (r.error("BoxParser", "Box of type '" + u + "' has a size " + d + " greater than its container size " + n), { code: c.ERR_NOT_ENOUGH_DATA, type: u, size: d, hdr_size: l, start: o }) : 0 !== d && o + d > t.getEndPosition() ? (t.seek(o), r.info("BoxParser", "Not enough data in stream to parse the entire '" + u + "' box"), { code: c.ERR_NOT_ENOUGH_DATA, type: u, size: d, hdr_size: l, start: o }) : e ? { code: c.OK, type: u, size: d, hdr_size: l, start: o } : (c[u + "Box"] ? (i = new c[u + "Box"](d)) : "uuid" !== u ? (r.warn("BoxParser", "Unknown box type: '" + u + "'"), ((i = new c.Box(u, d)).has_unparsed_data = !0)) : c.UUIDBoxes[s] ? (i = new c.UUIDBoxes[s](d)) : (r.warn("BoxParser", "Unknown uuid type: '" + s + "'"), ((i = new c.Box(u, d)).uuid = s), (i.has_unparsed_data = !0)), (i.hdr_size = l), (i.start = o), i.write === c.Box.prototype.write && "mdat" !== i.type && (r.info( "BoxParser", "'" + h + "' box writing not yet implemented, keeping unparsed data in memory for later write" ), i.parseDataAndRewind(t)), i.parse(t), (a = t.getPosition() - (i.start + i.size)) < 0 ? (r.warn( "BoxParser", "Parsing of box '" + h + "' did not read the entire indicated box data size (missing " + -a + " bytes), seeking forward" ), t.seek(i.start + i.size)) : a > 0 && (r.error( "BoxParser", "Parsing of box '" + h + "' read " + a + " more bytes than the indicated box data size, seeking backwards" ), 0 !== i.size && t.seek(i.start + i.size)), { code: c.OK, box: i, size: i.size }); }), (c.Box.prototype.parse = function (t) { "mdat" != this.type ? (this.data = t.readUint8Array(this.size - this.hdr_size)) : 0 === this.size ? t.seek(t.getEndPosition()) : t.seek(this.start + this.size); }), (c.Box.prototype.parseDataAndRewind = function (t) { (this.data = t.readUint8Array(this.size - this.hdr_size)), (t.position -= this.size - this.hdr_size); }), (c.FullBox.prototype.parseDataAndRewind = function (t) { this.parseFullHeader(t), (this.data = t.readUint8Array(this.size - this.hdr_size)), (this.hdr_size -= 4), (t.position -= this.size - this.hdr_size); }), (c.FullBox.prototype.parseFullHeader = function (t) { (this.version = t.readUint8()), (this.flags = t.readUint24()), (this.hdr_size += 4); }), (c.FullBox.prototype.parse = function (t) { this.parseFullHeader(t), (this.data = t.readUint8Array(this.size - this.hdr_size)); }), (c.ContainerBox.prototype.parse = function (t) { for (var e, n; t.getPosition() < this.start + this.size;) { if ((e = c.parseOneBox(t, !1, this.size - (t.getPosition() - this.start))).code !== c.OK) return; if (((n = e.box), this.boxes.push(n), this.subBoxNames && -1 != this.subBoxNames.indexOf(n.type))) this[this.subBoxNames[this.subBoxNames.indexOf(n.type)] + "s"].push(n); else { var i = "uuid" !== n.type ? n.type : n.uuid; this[i] ? r.warn("Box of type " + i + " already stored in field of this type") : (this[i] = n); } } }), (c.Box.prototype.parseLanguage = function (t) { this.language = t.readUint16(); var e = []; (e[0] = (this.language >> 10) & 31), (e[1] = (this.language >> 5) & 31), (e[2] = 31 & this.language), (this.languageString = String.fromCharCode(e[0] + 96, e[1] + 96, e[2] + 96)); }), (c.SAMPLE_ENTRY_TYPE_VISUAL = "Visual"), (c.SAMPLE_ENTRY_TYPE_AUDIO = "Audio"), (c.SAMPLE_ENTRY_TYPE_HINT = "Hint"), (c.SAMPLE_ENTRY_TYPE_METADATA = "Metadata"), (c.SAMPLE_ENTRY_TYPE_SUBTITLE = "Subtitle"), (c.SAMPLE_ENTRY_TYPE_SYSTEM = "System"), (c.SAMPLE_ENTRY_TYPE_TEXT = "Text"), (c.SampleEntry.prototype.parseHeader = function (t) { t.readUint8Array(6), (this.data_reference_index = t.readUint16()), (this.hdr_size += 8); }), (c.SampleEntry.prototype.parse = function (t) { this.parseHeader(t), (this.data = t.readUint8Array(this.size - this.hdr_size)); }), (c.SampleEntry.prototype.parseDataAndRewind = function (t) { this.parseHeader(t), (this.data = t.readUint8Array(this.size - this.hdr_size)), (this.hdr_size -= 8), (t.position -= this.size - this.hdr_size); }), (c.SampleEntry.prototype.parseFooter = function (t) { c.ContainerBox.prototype.parse.call(this, t); }), c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_HINT), c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA), c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE), c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SYSTEM), c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_TEXT), c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, function (t) { var e; this.parseHeader(t), t.readUint16(), t.readUint16(), t.readUint32Array(3), (this.width = t.readUint16()), (this.height = t.readUint16()), (this.horizresolution = t.readUint32()), (this.vertresolution = t.readUint32()), t.readUint32(), (this.frame_count = t.readUint16()), (e = Math.min(31, t.readUint8())), (this.compressorname = t.readString(e)), e < 31 && t.readString(31 - e), (this.depth = t.readUint16()), t.readUint16(), this.parseFooter(t); }), c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, function (t) { this.parseHeader(t), t.readUint32Array(2), (this.channel_count = t.readUint16()), (this.samplesize = t.readUint16()), t.readUint16(), t.readUint16(), (this.samplerate = t.readUint32() / 65536), this.parseFooter(t); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "avc1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "avc2"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "avc3"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "avc4"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "av01"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "dav1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "hvc1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "hev1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "hvt1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "lhe1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "dvh1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "dvhe"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "vvc1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "vvi1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "vvs1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "vvcN"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "vp08"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "vp09"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "avs3"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "j2ki"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "mjp2"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "mjpg"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "uncv"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "mp4a"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "ac-3"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "ac-4"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "ec-3"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "Opus"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "mha1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "mha2"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "mhm1"), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "mhm2"), c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL, "encv"), c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO, "enca"), c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE, "encu"), c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SYSTEM, "encs"), c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_TEXT, "enct"), c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA, "encm"), c.createBoxCtor("a1lx", function (t) { var e = 16 * (1 + (1 & (1 & t.readUint8()))); this.layer_size = []; for (var n = 0; n < 3; n++) this.layer_size[n] = 16 == e ? t.readUint16() : t.readUint32(); }), c.createBoxCtor("a1op", function (t) { this.op_index = t.readUint8(); }), c.createFullBoxCtor("auxC", function (t) { this.aux_type = t.readCString(); var e = this.size - this.hdr_size - (this.aux_type.length + 1); this.aux_subtype = t.readUint8Array(e); }), c.createBoxCtor("av1C", function (t) { var e = t.readUint8(); if ((e >> 7) & !1) r.error("av1C marker problem"); else if (((this.version = 127 & e), 1 === this.version)) if ( ((e = t.readUint8()), (this.seq_profile = (e >> 5) & 7), (this.seq_level_idx_0 = 31 & e), (e = t.readUint8()), (this.seq_tier_0 = (e >> 7) & 1), (this.high_bitdepth = (e >> 6) & 1), (this.twelve_bit = (e >> 5) & 1), (this.monochrome = (e >> 4) & 1), (this.chroma_subsampling_x = (e >> 3) & 1), (this.chroma_subsampling_y = (e >> 2) & 1), (this.chroma_sample_position = 3 & e), (e = t.readUint8()), (this.reserved_1 = (e >> 5) & 7), 0 === this.reserved_1) ) { if ( ((this.initial_presentation_delay_present = (e >> 4) & 1), 1 === this.initial_presentation_delay_present) ) this.initial_presentation_delay_minus_one = 15 & e; else if (((this.reserved_2 = 15 & e), 0 !== this.reserved_2)) return void r.error("av1C reserved_2 parsing problem"); var n = this.size - this.hdr_size - 4; this.configOBUs = t.readUint8Array(n); } else r.error("av1C reserved_1 parsing problem"); else r.error("av1C version " + this.version + " not supported"); }), c.createBoxCtor("avcC", function (t) { var e, n; for ( this.configurationVersion = t.readUint8(), this.AVCProfileIndication = t.readUint8(), this.profile_compatibility = t.readUint8(), this.AVCLevelIndication = t.readUint8(), this.lengthSizeMinusOne = 3 & t.readUint8(), this.nb_SPS_nalus = 31 & t.readUint8(), n = this.size - this.hdr_size - 6, this.SPS = [], e = 0; e < this.nb_SPS_nalus; e++ ) (this.SPS[e] = {}), (this.SPS[e].length = t.readUint16()), (this.SPS[e].nalu = t.readUint8Array(this.SPS[e].length)), (n -= 2 + this.SPS[e].length); for (this.nb_PPS_nalus = t.readUint8(), n--, this.PPS = [], e = 0; e < this.nb_PPS_nalus; e++) (this.PPS[e] = {}), (this.PPS[e].length = t.readUint16()), (this.PPS[e].nalu = t.readUint8Array(this.PPS[e].length)), (n -= 2 + this.PPS[e].length); n > 0 && (this.ext = t.readUint8Array(n)); }), c.createBoxCtor("btrt", function (t) { (this.bufferSizeDB = t.readUint32()), (this.maxBitrate = t.readUint32()), (this.avgBitrate = t.readUint32()); }), c.createFullBoxCtor("ccst", function (t) { var e = t.readUint8(); (this.all_ref_pics_intra = !(128 & ~e)), (this.intra_pred_used = !(64 & ~e)), (this.max_ref_per_pic = (63 & e) >> 2), t.readUint24(); }), c.createBoxCtor("cdef", function (t) { var e; for ( this.channel_count = t.readUint16(), this.channel_indexes = [], this.channel_types = [], this.channel_associations = [], e = 0; e < this.channel_count; e++ ) this.channel_indexes.push(t.readUint16()), this.channel_types.push(t.readUint16()), this.channel_associations.push(t.readUint16()); }), c.createBoxCtor("clap", function (t) { (this.cleanApertureWidthN = t.readUint32()), (this.cleanApertureWidthD = t.readUint32()), (this.cleanApertureHeightN = t.readUint32()), (this.cleanApertureHeightD = t.readUint32()), (this.horizOffN = t.readUint32()), (this.horizOffD = t.readUint32()), (this.vertOffN = t.readUint32()), (this.vertOffD = t.readUint32()); }), c.createBoxCtor("clli", function (t) { (this.max_content_light_level = t.readUint16()), (this.max_pic_average_light_level = t.readUint16()); }), c.createFullBoxCtor("cmex", function (t) { 1 & this.flags && (this.pos_x = t.readInt32()), 2 & this.flags && (this.pos_y = t.readInt32()), 4 & this.flags && (this.pos_z = t.readInt32()), 8 & this.flags && (0 == this.version ? 16 & this.flags ? ((this.quat_x = t.readInt32()), (this.quat_y = t.readInt32()), (this.quat_z = t.readInt32())) : ((this.quat_x = t.readInt16()), (this.quat_y = t.readInt16()), (this.quat_z = t.readInt16())) : this.version), 32 & this.flags && (this.id = t.readUint32()); }), c.createFullBoxCtor("cmin", function (t) { (this.focal_length_x = t.readInt32()), (this.principal_point_x = t.readInt32()), (this.principal_point_y = t.readInt32()), 1 & this.flags && ((this.focal_length_y = t.readInt32()), (this.skew_factor = t.readInt32())); }), c.createBoxCtor("cmpd", function (t) { for ( this.component_count = t.readUint16(), this.component_types = [], this.component_type_urls = [], i = 0; i < this.component_count; i++ ) { var e = t.readUint16(); this.component_types.push(e), e >= 32768 && this.component_type_urls.push(t.readCString()); } }), c.createFullBoxCtor("co64", function (t) { var e, n; if (((e = t.readUint32()), (this.chunk_offsets = []), 0 === this.version)) for (n = 0; n < e; n++) this.chunk_offsets.push(t.readUint64()); }), c.createFullBoxCtor("CoLL", function (t) { (this.maxCLL = t.readUint16()), (this.maxFALL = t.readUint16()); }), c.createBoxCtor("colr", function (t) { if (((this.colour_type = t.readString(4)), "nclx" === this.colour_type)) { (this.colour_primaries = t.readUint16()), (this.transfer_characteristics = t.readUint16()), (this.matrix_coefficients = t.readUint16()); var e = t.readUint8(); this.full_range_flag = e >> 7; } else ("rICC" === this.colour_type || "prof" === this.colour_type) && (this.ICC_profile = t.readUint8Array(this.size - 4)); }), c.createFullBoxCtor("cprt", function (t) { this.parseLanguage(t), (this.notice = t.readCString()); }), c.createFullBoxCtor("cslg", function (t) { 0 === this.version && ((this.compositionToDTSShift = t.readInt32()), (this.leastDecodeToDisplayDelta = t.readInt32()), (this.greatestDecodeToDisplayDelta = t.readInt32()), (this.compositionStartTime = t.readInt32()), (this.compositionEndTime = t.readInt32())); }), c.createFullBoxCtor("ctts", function (t) { var e, n; if (((e = t.readUint32()), (this.sample_counts = []), (this.sample_offsets = []), 0 === this.version)) for (n = 0; n < e; n++) { this.sample_counts.push(t.readUint32()); var i = t.readInt32(); i < 0 && r.warn("BoxParser", "ctts box uses negative values without using version 1"), this.sample_offsets.push(i); } else if (1 == this.version) for (n = 0; n < e; n++) this.sample_counts.push(t.readUint32()), this.sample_offsets.push(t.readInt32()); }), c.createBoxCtor("dac3", function (t) { var e = t.readUint8(), n = t.readUint8(), i = t.readUint8(); (this.fscod = e >> 6), (this.bsid = (e >> 1) & 31), (this.bsmod = ((1 & e) << 2) | ((n >> 6) & 3)), (this.acmod = (n >> 3) & 7), (this.lfeon = (n >> 2) & 1), (this.bit_rate_code = (3 & n) | ((i >> 5) & 7)); }), c.createBoxCtor("dec3", function (t) { var e = t.readUint16(); (this.data_rate = e >> 3), (this.num_ind_sub = 7 & e), (this.ind_subs = []); for (var n = 0; n < this.num_ind_sub + 1; n++) { var i = {}; this.ind_subs.push(i); var r = t.readUint8(), a = t.readUint8(), s = t.readUint8(); (i.fscod = r >> 6), (i.bsid = (r >> 1) & 31), (i.bsmod = ((1 & r) << 4) | ((a >> 4) & 15)), (i.acmod = (a >> 1) & 7), (i.lfeon = 1 & a), (i.num_dep_sub = (s >> 1) & 15), i.num_dep_sub > 0 && (i.chan_loc = ((1 & s) << 8) | t.readUint8()); } }), c.createFullBoxCtor("dfLa", function (t) { var e = [], n = [ "STREAMINFO", "PADDING", "APPLICATION", "SEEKTABLE", "VORBIS_COMMENT", "CUESHEET", "PICTURE", "RESERVED" ]; for (this.parseFullHeader(t); ;) { var i = t.readUint8(), r = Math.min(127 & i, n.length - 1); if ( (r ? t.readUint8Array(t.readUint24()) : (t.readUint8Array(13), (this.samplerate = t.readUint32() >> 12), t.readUint8Array(20)), e.push(n[r]), 128 & i) ) break; } this.numMetadataBlocks = e.length + " (" + e.join(", ") + ")"; }), c.createBoxCtor("dimm", function (t) { this.bytessent = t.readUint64(); }), c.createBoxCtor("dmax", function (t) { this.time = t.readUint32(); }), c.createBoxCtor("dmed", function (t) { this.bytessent = t.readUint64(); }), c.createBoxCtor("dOps", function (t) { if ( ((this.Version = t.readUint8()), (this.OutputChannelCount = t.readUint8()), (this.PreSkip = t.readUint16()), (this.InputSampleRate = t.readUint32()), (this.OutputGain = t.readInt16()), (this.ChannelMappingFamily = t.readUint8()), 0 !== this.ChannelMappingFamily) ) { (this.StreamCount = t.readUint8()), (this.CoupledCount = t.readUint8()), (this.ChannelMapping = []); for (var e = 0; e < this.OutputChannelCount; e++) this.ChannelMapping[e] = t.readUint8(); } }), c.createFullBoxCtor("dref", function (t) { var e, n; this.entries = []; for (var i = t.readUint32(), r = 0; r < i; r++) { if ((e = c.parseOneBox(t, !1, this.size - (t.getPosition() - this.start))).code !== c.OK) return; (n = e.box), this.entries.push(n); } }), c.createBoxCtor("drep", function (t) { this.bytessent = t.readUint64(); }), c.createFullBoxCtor("elng", function (t) { this.extended_language = t.readString(this.size - this.hdr_size); }), c.createFullBoxCtor("elst", function (t) { this.entries = []; for (var e = t.readUint32(), n = 0; n < e; n++) { var i = {}; this.entries.push(i), 1 === this.version ? ((i.segment_duration = t.readUint64()), (i.media_time = t.readInt64())) : ((i.segment_duration = t.readUint32()), (i.media_time = t.readInt32())), (i.media_rate_integer = t.readInt16()), (i.media_rate_fraction = t.readInt16()); } }), c.createFullBoxCtor("emsg", function (t) { 1 == this.version ? ((this.timescale = t.readUint32()), (this.presentation_time = t.readUint64()), (this.event_duration = t.readUint32()), (this.id = t.readUint32()), (this.scheme_id_uri = t.readCString()), (this.value = t.readCString())) : ((this.scheme_id_uri = t.readCString()), (this.value = t.readCString()), (this.timescale = t.readUint32()), (this.presentation_time_delta = t.readUint32()), (this.event_duration = t.readUint32()), (this.id = t.readUint32())); var e = this.size - this.hdr_size - (16 + (this.scheme_id_uri.length + 1) + (this.value.length + 1)); 1 == this.version && (e -= 4), (this.message_data = t.readUint8Array(e)); }), (c.createEntityToGroupCtor = function (t, e) { (c[t + "Box"] = function (e) { c.FullBox.call(this, t, e); }), (c[t + "Box"].prototype = new c.FullBox()), (c[t + "Box"].prototype.parse = function (t) { if ((this.parseFullHeader(t), e)) e.call(this, t); else for ( this.group_id = t.readUint32(), this.num_entities_in_group = t.readUint32(), this.entity_ids = [], i = 0; i < this.num_entities_in_group; i++ ) { var n = t.readUint32(); this.entity_ids.push(n); } }); }), c.createEntityToGroupCtor("aebr"), c.createEntityToGroupCtor("afbr"), c.createEntityToGroupCtor("albc"), c.createEntityToGroupCtor("altr"), c.createEntityToGroupCtor("brst"), c.createEntityToGroupCtor("dobr"), c.createEntityToGroupCtor("eqiv"), c.createEntityToGroupCtor("favc"), c.createEntityToGroupCtor("fobr"), c.createEntityToGroupCtor("iaug"), c.createEntityToGroupCtor("pano"), c.createEntityToGroupCtor("slid"), c.createEntityToGroupCtor("ster"), c.createEntityToGroupCtor("tsyn"), c.createEntityToGroupCtor("wbbr"), c.createEntityToGroupCtor("prgr"), c.createFullBoxCtor("esds", function (t) { var e = t.readUint8Array(this.size - this.hdr_size); if (((this.data = e), void 0 !== d)) { var n = new d(); this.esd = n.parseOneDescriptor(new s(e.buffer, 0, s.BIG_ENDIAN)); } }), c.createBoxCtor("fiel", function (t) { (this.fieldCount = t.readUint8()), (this.fieldOrdering = t.readUint8()); }), c.createBoxCtor("frma", function (t) { this.data_format = t.readString(4); }), c.createBoxCtor("ftyp", function (t) { var e = this.size - this.hdr_size; (this.major_brand = t.readString(4)), (this.minor_version = t.readUint32()), (e -= 8), (this.compatible_brands = []); for (var n = 0; e >= 4;) (this.compatible_brands[n] = t.readString(4)), (e -= 4), n++; }), c.createFullBoxCtor("hdlr", function (t) { 0 === this.version && (t.readUint32(), (this.handler = t.readString(4)), t.readUint32Array(3), (this.name = t.readString(this.size - this.hdr_size - 20)), "\0" === this.name[this.name.length - 1] && (this.name = this.name.slice(0, -1))); }), c.createBoxCtor("hvcC", function (t) { var e, n, i, r; (this.configurationVersion = t.readUint8()), (r = t.readUint8()), (this.general_profile_space = r >> 6), (this.general_tier_flag = (32 & r) >> 5), (this.general_profile_idc = 31 & r), (this.general_profile_compatibility = t.readUint32()), (this.general_constraint_indicator = t.readUint8Array(6)), (this.general_level_idc = t.readUint8()), (this.min_spatial_segmentation_idc = 4095 & t.readUint16()), (this.parallelismType = 3 & t.readUint8()), (this.chroma_format_idc = 3 & t.readUint8()), (this.bit_depth_luma_minus8 = 7 & t.readUint8()), (this.bit_depth_chroma_minus8 = 7 & t.readUint8()), (this.avgFrameRate = t.readUint16()), (r = t.readUint8()), (this.constantFrameRate = r >> 6), (this.numTemporalLayers = (13 & r) >> 3), (this.temporalIdNested = (4 & r) >> 2), (this.lengthSizeMinusOne = 3 & r), (this.nalu_arrays = []); var a = t.readUint8(); for (e = 0; e < a; e++) { var s = []; this.nalu_arrays.push(s), (r = t.readUint8()), (s.completeness = (128 & r) >> 7), (s.nalu_type = 63 & r); var o = t.readUint16(); for (n = 0; n < o; n++) { var l = {}; s.push(l), (i = t.readUint16()), (l.data = t.readUint8Array(i)); } } }), c.createFullBoxCtor("iinf", function (t) { var e; 0 === this.version ? (this.entry_count = t.readUint16()) : (this.entry_count = t.readUint32()), (this.item_infos = []); for (var n = 0; n < this.entry_count; n++) { if ((e = c.parseOneBox(t, !1, this.size - (t.getPosition() - this.start))).code !== c.OK) return; "infe" !== e.box.type && r.error("BoxParser", "Expected 'infe' box, got " + e.box.type), (this.item_infos[n] = e.box); } }), c.createFullBoxCtor("iloc", function (t) { var e; (e = t.readUint8()), (this.offset_size = (e >> 4) & 15), (this.length_size = 15 & e), (e = t.readUint8()), (this.base_offset_size = (e >> 4) & 15), 1 === this.version || 2 === this.version ? (this.index_size = 15 & e) : (this.index_size = 0), (this.items = []); var n = 0; if (this.version < 2) n = t.readUint16(); else { if (2 !== this.version) throw "version of iloc box not supported"; n = t.readUint32(); } for (var i = 0; i < n; i++) { var r = {}; if ((this.items.push(r), this.version < 2)) r.item_ID = t.readUint16(); else { if (2 !== this.version) throw "version of iloc box not supported"; r.item_ID = t.readUint16(); } switch ( (1 === this.version || 2 === this.version ? (r.construction_method = 15 & t.readUint16()) : (r.construction_method = 0), (r.data_reference_index = t.readUint16()), this.base_offset_size) ) { case 0: r.base_offset = 0; break; case 4: r.base_offset = t.readUint32(); break; case 8: r.base_offset = t.readUint64(); break; default: throw "Error reading base offset size"; } var a = t.readUint16(); r.extents = []; for (var s = 0; s < a; s++) { var o = {}; if ((r.extents.push(o), 1 === this.version || 2 === this.version)) switch (this.index_size) { case 0: o.extent_index = 0; break; case 4: o.extent_index = t.readUint32(); break; case 8: o.extent_index = t.readUint64(); break; default: throw "Error reading extent index"; } switch (this.offset_size) { case 0: o.extent_offset = 0; break; case 4: o.extent_offset = t.readUint32(); break; case 8: o.extent_offset = t.readUint64(); break; default: throw "Error reading extent index"; } switch (this.length_size) { case 0: o.extent_length = 0; break; case 4: o.extent_length = t.readUint32(); break; case 8: o.extent_length = t.readUint64(); break; default: throw "Error reading extent index"; } } } }), c.createBoxCtor("imir", function (t) { var e = t.readUint8(); (this.reserved = e >> 7), (this.axis = 1 & e); }), c.createFullBoxCtor("infe", function (t) { if ( ((0 !== this.version && 1 !== this.version) || ((this.item_ID = t.readUint16()), (this.item_protection_index = t.readUint16()), (this.item_name = t.readCString()), (this.content_type = t.readCString()), (this.content_encoding = t.readCString())), 1 === this.version) ) return ( (this.extension_type = t.readString(4)), r.warn("BoxParser", "Cannot parse extension type"), void t.seek(this.start + this.size) ); this.version >= 2 && (2 === this.version ? (this.item_ID = t.readUint16()) : 3 === this.version && (this.item_ID = t.readUint32()), (this.item_protection_index = t.readUint16()), (this.item_type = t.readString(4)), (this.item_name = t.readCString()), "mime" === this.item_type ? ((this.content_type = t.readCString()), (this.content_encoding = t.readCString())) : "uri " === this.item_type && (this.item_uri_type = t.readCString())); }), c.createFullBoxCtor("ipma", function (t) { var e, n; for (entry_count = t.readUint32(), this.associations = [], e = 0; e < entry_count; e++) { var i = {}; this.associations.push(i), this.version < 1 ? (i.id = t.readUint16()) : (i.id = t.readUint32()); var r = t.readUint8(); for (i.props = [], n = 0; n < r; n++) { var a = t.readUint8(), s = {}; i.props.push(s), (s.essential = (128 & a) >> 7 == 1), 1 & this.flags ? (s.property_index = ((127 & a) << 8) | t.readUint8()) : (s.property_index = 127 & a); } } }), c.createFullBoxCtor("iref", function (t) { var e, n; for (this.references = []; t.getPosition() < this.start + this.size;) { if ((e = c.parseOneBox(t, !0, this.size - (t.getPosition() - this.start))).code !== c.OK) return; (n = 0 === this.version ? new c.SingleItemTypeReferenceBox(e.type, e.size, e.hdr_size, e.start) : new c.SingleItemTypeReferenceBoxLarge(e.type, e.size, e.hdr_size, e.start)).write === c.Box.prototype.write && "mdat" !== n.type && (r.warn( "BoxParser", n.type + " box writing not yet implemented, keeping unparsed data in memory for later write" ), n.parseDataAndRewind(t)), n.parse(t), this.references.push(n); } }), c.createBoxCtor("irot", function (t) { this.angle = 3 & t.readUint8(); }), c.createFullBoxCtor("ispe", function (t) { (this.image_width = t.readUint32()), (this.image_height = t.readUint32()); }), c.createFullBoxCtor("kind", function (t) { (this.schemeURI = t.readCString()), (this.value = t.readCString()); }), c.createFullBoxCtor("leva", function (t) { var e = t.readUint8(); this.levels = []; for (var n = 0; n < e; n++) { var i = {}; (this.levels[n] = i), (i.track_ID = t.readUint32()); var a = t.readUint8(); switch (((i.padding_flag = a >> 7), (i.assignment_type = 127 & a), i.assignment_type)) { case 0: i.grouping_type = t.readString(4); break; case 1: (i.grouping_type = t.readString(4)), (i.grouping_type_parameter = t.readUint32()); break; case 2: case 3: break; case 4: i.sub_track_id = t.readUint32(); break; default: r.warn("BoxParser", "Unknown leva assignement type"); } } }), c.createBoxCtor("lsel", function (t) { this.layer_id = t.readUint16(); }), c.createBoxCtor("maxr", function (t) { (this.period = t.readUint32()), (this.bytes = t.readUint32()); }), c.createBoxCtor("mdcv", function (t) { (this.display_primaries = []), (this.display_primaries[0] = {}), (this.display_primaries[0].x = t.readUint16()), (this.display_primaries[0].y = t.readUint16()), (this.display_primaries[1] = {}), (this.display_primaries[1].x = t.readUint16()), (this.display_primaries[1].y = t.readUint16()), (this.display_primaries[2] = {}), (this.display_primaries[2].x = t.readUint16()), (this.display_primaries[2].y = t.readUint16()), (this.white_point = {}), (this.white_point.x = t.readUint16()), (this.white_point.y = t.readUint16()), (this.max_display_mastering_luminance = t.readUint32()), (this.min_display_mastering_luminance = t.readUint32()); }), c.createFullBoxCtor("mdhd", function (t) { 1 == this.version ? ((this.creation_time = t.readUint64()), (this.modification_time = t.readUint64()), (this.timescale = t.readUint32()), (this.duration = t.readUint64())) : ((this.creation_time = t.readUint32()), (this.modification_time = t.readUint32()), (this.timescale = t.readUint32()), (this.duration = t.readUint32())), this.parseLanguage(t), t.readUint16(); }), c.createFullBoxCtor("mehd", function (t) { 1 & this.flags && (r.warn("BoxParser", "mehd box incorrectly uses flags set to 1, converting version to 1"), (this.version = 1)), 1 == this.version ? (this.fragment_duration = t.readUint64()) : (this.fragment_duration = t.readUint32()); }), c.createFullBoxCtor("meta", function (t) { (this.boxes = []), c.ContainerBox.prototype.parse.call(this, t); }), c.createFullBoxCtor("mfhd", function (t) { this.sequence_number = t.readUint32(); }), c.createFullBoxCtor("mfro", function (t) { this._size = t.readUint32(); }), c.createFullBoxCtor("mvhd", function (t) { 1 == this.version ? ((this.creation_time = t.readUint64()), (this.modification_time = t.readUint64()), (this.timescale = t.readUint32()), (this.duration = t.readUint64())) : ((this.creation_time = t.readUint32()), (this.modification_time = t.readUint32()), (this.timescale = t.readUint32()), (this.duration = t.readUint32())), (this.rate = t.readUint32()), (this.volume = t.readUint16() >> 8), t.readUint16(), t.readUint32Array(2), (this.matrix = t.readUint32Array(9)), t.readUint32Array(6), (this.next_track_id = t.readUint32()); }), c.createBoxCtor("npck", function (t) { this.packetssent = t.readUint32(); }), c.createBoxCtor("nump", function (t) { this.packetssent = t.readUint64(); }), c.createFullBoxCtor("padb", function (t) { var e = t.readUint32(); this.padbits = []; for (var n = 0; n < Math.floor((e + 1) / 2); n++) this.padbits = t.readUint8(); }), c.createBoxCtor("pasp", function (t) { (this.hSpacing = t.readUint32()), (this.vSpacing = t.readUint32()); }), c.createBoxCtor("payl", function (t) { this.text = t.readString(this.size - this.hdr_size); }), c.createBoxCtor("payt", function (t) { this.payloadID = t.readUint32(); var e = t.readUint8(); this.rtpmap_string = t.readString(e); }), c.createFullBoxCtor("pdin", function (t) { var e = (this.size - this.hdr_size) / 8; (this.rate = []), (this.initial_delay = []); for (var n = 0; n < e; n++) (this.rate[n] = t.readUint32()), (this.initial_delay[n] = t.readUint32()); }), c.createFullBoxCtor("pitm", function (t) { 0 === this.version ? (this.item_id = t.readUint16()) : (this.item_id = t.readUint32()); }), c.createFullBoxCtor("pixi", function (t) { var e; for (this.num_channels = t.readUint8(), this.bits_per_channels = [], e = 0; e < this.num_channels; e++) this.bits_per_channels[e] = t.readUint8(); }), c.createBoxCtor("pmax", function (t) { this.bytes = t.readUint32(); }), c.createFullBoxCtor("prdi", function (t) { if (((this.step_count = t.readUint16()), (this.item_count = []), 2 & this.flags)) for (var e = 0; e < this.step_count; e++) this.item_count[e] = t.readUint16(); }), c.createFullBoxCtor("prft", function (t) { (this.ref_track_id = t.readUint32()), (this.ntp_timestamp = t.readUint64()), 0 === this.version ? (this.media_time = t.readUint32()) : (this.media_time = t.readUint64()); }), c.createFullBoxCtor("pssh", function (t) { if (((this.system_id = c.parseHex16(t)), this.version > 0)) { var e = t.readUint32(); this.kid = []; for (var n = 0; n < e; n++) this.kid[n] = c.parseHex16(t); } var i = t.readUint32(); i > 0 && (this.data = t.readUint8Array(i)); }), c.createFullBoxCtor("clef", function (t) { (this.width = t.readUint32()), (this.height = t.readUint32()); }), c.createFullBoxCtor("enof", function (t) { (this.width = t.readUint32()), (this.height = t.readUint32()); }), c.createFullBoxCtor("prof", function (t) { (this.width = t.readUint32()), (this.height = t.readUint32()); }), c.createContainerBoxCtor("tapt", null, ["clef", "prof", "enof"]), c.createBoxCtor("rtp ", function (t) { (this.descriptionformat = t.readString(4)), (this.sdptext = t.readString(this.size - this.hdr_size - 4)); }), c.createFullBoxCtor("saio", function (t) { 1 & this.flags && ((this.aux_info_type = t.readUint32()), (this.aux_info_type_parameter = t.readUint32())); var e = t.readUint32(); this.offset = []; for (var n = 0; n < e; n++) 0 === this.version ? (this.offset[n] = t.readUint32()) : (this.offset[n] = t.readUint64()); }), c.createFullBoxCtor("saiz", function (t) { 1 & this.flags && ((this.aux_info_type = t.readUint32()), (this.aux_info_type_parameter = t.readUint32())), (this.default_sample_info_size = t.readUint8()); var e = t.readUint32(); if (((this.sample_info_size = []), 0 === this.default_sample_info_size)) for (var n = 0; n < e; n++) this.sample_info_size[n] = t.readUint8(); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA, "mett", function (t) { this.parseHeader(t), (this.content_encoding = t.readCString()), (this.mime_format = t.readCString()), this.parseFooter(t); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA, "metx", function (t) { this.parseHeader(t), (this.content_encoding = t.readCString()), (this.namespace = t.readCString()), (this.schema_location = t.readCString()), this.parseFooter(t); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE, "sbtt", function (t) { this.parseHeader(t), (this.content_encoding = t.readCString()), (this.mime_format = t.readCString()), this.parseFooter(t); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE, "stpp", function (t) { this.parseHeader(t), (this.namespace = t.readCString()), (this.schema_location = t.readCString()), (this.auxiliary_mime_types = t.readCString()), this.parseFooter(t); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE, "stxt", function (t) { this.parseHeader(t), (this.content_encoding = t.readCString()), (this.mime_format = t.readCString()), this.parseFooter(t); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE, "tx3g", function (t) { this.parseHeader(t), (this.displayFlags = t.readUint32()), (this.horizontal_justification = t.readInt8()), (this.vertical_justification = t.readInt8()), (this.bg_color_rgba = t.readUint8Array(4)), (this.box_record = t.readInt16Array(4)), (this.style_record = t.readUint8Array(12)), this.parseFooter(t); }), c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA, "wvtt", function (t) { this.parseHeader(t), this.parseFooter(t); }), c.createSampleGroupCtor("alst", function (t) { var e, n = t.readUint16(); for (this.first_output_sample = t.readUint16(), this.sample_offset = [], e = 0; e < n; e++) this.sample_offset[e] = t.readUint32(); var i = this.description_length - 4 - 4 * n; for (this.num_output_samples = [], this.num_total_samples = [], e = 0; e < i / 4; e++) (this.num_output_samples[e] = t.readUint16()), (this.num_total_samples[e] = t.readUint16()); }), c.createSampleGroupCtor("avll", function (t) { (this.layerNumber = t.readUint8()), (this.accurateStatisticsFlag = t.readUint8()), (this.avgBitRate = t.readUint16()), (this.avgFrameRate = t.readUint16()); }), c.createSampleGroupCtor("avss", function (t) { (this.subSequenceIdentifier = t.readUint16()), (this.layerNumber = t.readUint8()); var e = t.readUint8(); (this.durationFlag = e >> 7), (this.avgRateFlag = (e >> 6) & 1), this.durationFlag && (this.duration = t.readUint32()), this.avgRateFlag && ((this.accurateStatisticsFlag = t.readUint8()), (this.avgBitRate = t.readUint16()), (this.avgFrameRate = t.readUint16())), (this.dependency = []); for (var n = t.readUint8(), i = 0; i < n; i++) { var r = {}; this.dependency.push(r), (r.subSeqDirectionFlag = t.readUint8()), (r.layerNumber = t.readUint8()), (r.subSequenceIdentifier = t.readUint16()); } }), c.createSampleGroupCtor("dtrt", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createSampleGroupCtor("mvif", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createSampleGroupCtor("prol", function (t) { this.roll_distance = t.readInt16(); }), c.createSampleGroupCtor("rap ", function (t) { var e = t.readUint8(); (this.num_leading_samples_known = e >> 7), (this.num_leading_samples = 127 & e); }), c.createSampleGroupCtor("rash", function (t) { if ( ((this.operation_point_count = t.readUint16()), this.description_length !== 2 + (1 === this.operation_point_count ? 2 : 6 * this.operation_point_count) + 9) ) r.warn("BoxParser", "Mismatch in " + this.grouping_type + " sample group length"), (this.data = t.readUint8Array(this.description_length - 2)); else { if (1 === this.operation_point_count) this.target_rate_share = t.readUint16(); else { (this.target_rate_share = []), (this.available_bitrate = []); for (var e = 0; e < this.operation_point_count; e++) (this.available_bitrate[e] = t.readUint32()), (this.target_rate_share[e] = t.readUint16()); } (this.maximum_bitrate = t.readUint32()), (this.minimum_bitrate = t.readUint32()), (this.discard_priority = t.readUint8()); } }), c.createSampleGroupCtor("roll", function (t) { this.roll_distance = t.readInt16(); }), (c.SampleGroupEntry.prototype.parse = function (t) { r.warn("BoxParser", "Unknown Sample Group type: " + this.grouping_type), (this.data = t.readUint8Array(this.description_length)); }), c.createSampleGroupCtor("scif", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createSampleGroupCtor("scnm", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createSampleGroupCtor("seig", function (t) { this.reserved = t.readUint8(); var e = t.readUint8(); (this.crypt_byte_block = e >> 4), (this.skip_byte_block = 15 & e), (this.isProtected = t.readUint8()), (this.Per_Sample_IV_Size = t.readUint8()), (this.KID = c.parseHex16(t)), (this.constant_IV_size = 0), (this.constant_IV = 0), 1 === this.isProtected && 0 === this.Per_Sample_IV_Size && ((this.constant_IV_size = t.readUint8()), (this.constant_IV = t.readUint8Array(this.constant_IV_size))); }), c.createSampleGroupCtor("stsa", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createSampleGroupCtor("sync", function (t) { var e = t.readUint8(); this.NAL_unit_type = 63 & e; }), c.createSampleGroupCtor("tele", function (t) { var e = t.readUint8(); this.level_independently_decodable = e >> 7; }), c.createSampleGroupCtor("tsas", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createSampleGroupCtor("tscl", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createSampleGroupCtor("vipr", function (t) { r.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed"); }), c.createFullBoxCtor("sbgp", function (t) { (this.grouping_type = t.readString(4)), 1 === this.version ? (this.grouping_type_parameter = t.readUint32()) : (this.grouping_type_parameter = 0), (this.entries = []); for (var e = t.readUint32(), n = 0; n < e; n++) { var i = {}; this.entries.push(i), (i.sample_count = t.readInt32()), (i.group_description_index = t.readInt32()); } }), c.createFullBoxCtor("schm", function (t) { (this.scheme_type = t.readString(4)), (this.scheme_version = t.readUint32()), 1 & this.flags && (this.scheme_uri = t.readString(this.size - this.hdr_size - 8)); }), c.createBoxCtor("sdp ", function (t) { this.sdptext = t.readString(this.size - this.hdr_size); }), c.createFullBoxCtor("sdtp", function (t) { var e, n = this.size - this.hdr_size; (this.is_leading = []), (this.sample_depends_on = []), (this.sample_is_depended_on = []), (this.sample_has_redundancy = []); for (var i = 0; i < n; i++) (e = t.readUint8()), (this.is_leading[i] = e >> 6), (this.sample_depends_on[i] = (e >> 4) & 3), (this.sample_is_depended_on[i] = (e >> 2) & 3), (this.sample_has_redundancy[i] = 3 & e); }), c.createFullBoxCtor("senc"), c.createFullBoxCtor("sgpd", function (t) { (this.grouping_type = t.readString(4)), r.debug("BoxParser", "Found Sample Groups of type " + this.grouping_type), 1 === this.version ? (this.default_length = t.readUint32()) : (this.default_length = 0), this.version >= 2 && (this.default_group_description_index = t.readUint32()), (this.entries = []); for (var e = t.readUint32(), n = 0; n < e; n++) { var i; (i = c[this.grouping_type + "SampleGroupEntry"] ? new c[this.grouping_type + "SampleGroupEntry"](this.grouping_type) : new c.SampleGroupEntry(this.grouping_type)), this.entries.push(i), 1 === this.version && 0 === this.default_length ? (i.description_length = t.readUint32()) : (i.description_length = this.default_length), i.write === c.SampleGroupEntry.prototype.write && (r.info( "BoxParser", "SampleGroup for type " + this.grouping_type + " writing not yet implemented, keeping unparsed data in memory for later write" ), (i.data = t.readUint8Array(i.description_length)), (t.position -= i.description_length)), i.parse(t); } }), c.createFullBoxCtor("sidx", function (t) { (this.reference_ID = t.readUint32()), (this.timescale = t.readUint32()), 0 === this.version ? ((this.earliest_presentation_time = t.readUint32()), (this.first_offset = t.readUint32())) : ((this.earliest_presentation_time = t.readUint64()), (this.first_offset = t.readUint64())), t.readUint16(), (this.references = []); for (var e = t.readUint16(), n = 0; n < e; n++) { var i = {}; this.references.push(i); var r = t.readUint32(); (i.reference_type = (r >> 31) & 1), (i.referenced_size = 2147483647 & r), (i.subsegment_duration = t.readUint32()), (r = t.readUint32()), (i.starts_with_SAP = (r >> 31) & 1), (i.SAP_type = (r >> 28) & 7), (i.SAP_delta_time = 268435455 & r); } }), (c.SingleItemTypeReferenceBox = function (t, e, n, i) { c.Box.call(this, t, e), (this.hdr_size = n), (this.start = i); }), (c.SingleItemTypeReferenceBox.prototype = new c.Box()), (c.SingleItemTypeReferenceBox.prototype.parse = function (t) { this.from_item_ID = t.readUint16(); var e = t.readUint16(); this.references = []; for (var n = 0; n < e; n++) (this.references[n] = {}), (this.references[n].to_item_ID = t.readUint16()); }), (c.SingleItemTypeReferenceBoxLarge = function (t, e, n, i) { c.Box.call(this, t, e), (this.hdr_size = n), (this.start = i); }), (c.SingleItemTypeReferenceBoxLarge.prototype = new c.Box()), (c.SingleItemTypeReferenceBoxLarge.prototype.parse = function (t) { this.from_item_ID = t.readUint32(); var e = t.readUint16(); this.references = []; for (var n = 0; n < e; n++) (this.references[n] = {}), (this.references[n].to_item_ID = t.readUint32()); }), c.createFullBoxCtor("SmDm", function (t) { (this.primaryRChromaticity_x = t.readUint16()), (this.primaryRChromaticity_y = t.readUint16()), (this.primaryGChromaticity_x = t.readUint16()), (this.primaryGChromaticity_y = t.readUint16()), (this.primaryBChromaticity_x = t.readUint16()), (this.primaryBChromaticity_y = t.readUint16()), (this.whitePointChromaticity_x = t.readUint16()), (this.whitePointChromaticity_y = t.readUint16()), (this.luminanceMax = t.readUint32()), (this.luminanceMin = t.readUint32()); }), c.createFullBoxCtor("smhd", function (t) { (this.balance = t.readUint16()), t.readUint16(); }), c.createFullBoxCtor("ssix", function (t) { this.subsegments = []; for (var e = t.readUint32(), n = 0; n < e; n++) { var i = {}; this.subsegments.push(i), (i.ranges = []); for (var r = t.readUint32(), a = 0; a < r; a++) { var s = {}; i.ranges.push(s), (s.level = t.readUint8()), (s.range_size = t.readUint24()); } } }), c.createFullBoxCtor("stco", function (t) { var e; if (((e = t.readUint32()), (this.chunk_offsets = []), 0 === this.version)) for (var n = 0; n < e; n++) this.chunk_offsets.push(t.readUint32()); }), c.createFullBoxCtor("stdp", function (t) { var e = (this.size - this.hdr_size) / 2; this.priority = []; for (var n = 0; n < e; n++) this.priority[n] = t.readUint16(); }), c.createFullBoxCtor("sthd"), c.createFullBoxCtor("stri", function (t) { (this.switch_group = t.readUint16()), (this.alternate_group = t.readUint16()), (this.sub_track_id = t.readUint32()); var e = (this.size - this.hdr_size - 8) / 4; this.attribute_list = []; for (var n = 0; n < e; n++) this.attribute_list[n] = t.readUint32(); }), c.createFullBoxCtor("stsc", function (t) { var e, n; if ( ((e = t.readUint32()), (this.first_chunk = []), (this.samples_per_chunk = []), (this.sample_description_index = []), 0 === this.version) ) for (n = 0; n < e; n++) this.first_chunk.push(t.readUint32()), this.samples_per_chunk.push(t.readUint32()), this.sample_description_index.push(t.readUint32()); }), c.createFullBoxCtor("stsd", function (t) { var e, n, i, a; for (this.entries = [], i = t.readUint32(), e = 1; e <= i; e++) { if ((n = c.parseOneBox(t, !0, this.size - (t.getPosition() - this.start))).code !== c.OK) return; c[n.type + "SampleEntry"] ? (((a = new c[n.type + "SampleEntry"](n.size)).hdr_size = n.hdr_size), (a.start = n.start)) : (r.warn("BoxParser", "Unknown sample entry type: " + n.type), (a = new c.SampleEntry(n.type, n.size, n.hdr_size, n.start))), a.write === c.SampleEntry.prototype.write && (r.info( "BoxParser", "SampleEntry " + a.type + " box writing not yet implemented, keeping unparsed data in memory for later write" ), a.parseDataAndRewind(t)), a.parse(t), this.entries.push(a); } }), c.createFullBoxCtor("stsg", function (t) { this.grouping_type = t.readUint32(); var e = t.readUint16(); this.group_description_index = []; for (var n = 0; n < e; n++) this.group_description_index[n] = t.readUint32(); }), c.createFullBoxCtor("stsh", function (t) { var e, n; if ( ((e = t.readUint32()), (this.shadowed_sample_numbers = []), (this.sync_sample_numbers = []), 0 === this.version) ) for (n = 0; n < e; n++) this.shadowed_sample_numbers.push(t.readUint32()), this.sync_sample_numbers.push(t.readUint32()); }), c.createFullBoxCtor("stss", function (t) { var e, n; if (((n = t.readUint32()), 0 === this.version)) for (this.sample_numbers = [], e = 0; e < n; e++) this.sample_numbers.push(t.readUint32()); }), c.createFullBoxCtor("stsz", function (t) { var e; if (((this.sample_sizes = []), 0 === this.version)) for (this.sample_size = t.readUint32(), this.sample_count = t.readUint32(), e = 0; e < this.sample_count; e++) 0 === this.sample_size ? this.sample_sizes.push(t.readUint32()) : (this.sample_sizes[e] = this.sample_size); }), c.createFullBoxCtor("stts", function (t) { var e, n, i; if (((e = t.readUint32()), (this.sample_counts = []), (this.sample_deltas = []), 0 === this.version)) for (n = 0; n < e; n++) this.sample_counts.push(t.readUint32()), (i = t.readInt32()) < 0 && (r.warn( "BoxParser", "File uses negative stts sample delta, using value 1 instead, sync may be lost!" ), (i = 1)), this.sample_deltas.push(i); }), c.createFullBoxCtor("stvi", function (t) { var e = t.readUint32(); (this.single_view_allowed = 3 & e), (this.stereo_scheme = t.readUint32()); var n, i, r = t.readUint32(); for (this.stereo_indication_type = t.readString(r), this.boxes = []; t.getPosition() < this.start + this.size;) { if ((n = c.parseOneBox(t, !1, this.size - (t.getPosition() - this.start))).code !== c.OK) return; (i = n.box), this.boxes.push(i), (this[i.type] = i); } }), c.createBoxCtor("styp", function (t) { c.ftypBox.prototype.parse.call(this, t); }), c.createFullBoxCtor("stz2", function (t) { var e, n; if (((this.sample_sizes = []), 0 === this.version)) if ( ((this.reserved = t.readUint24()), (this.field_size = t.readUint8()), (n = t.readUint32()), 4 === this.field_size) ) for (e = 0; e < n; e += 2) { var i = t.readUint8(); (this.sample_sizes[e] = (i >> 4) & 15), (this.sample_sizes[e + 1] = 15 & i); } else if (8 === this.field_size) for (e = 0; e < n; e++) this.sample_sizes[e] = t.readUint8(); else if (16 === this.field_size) for (e = 0; e < n; e++) this.sample_sizes[e] = t.readUint16(); else r.error("BoxParser", "Error in length field in stz2 box"); }), c.createFullBoxCtor("subs", function (t) { var e, n, i, r; for (i = t.readUint32(), this.entries = [], e = 0; e < i; e++) { var a = {}; if (((this.entries[e] = a), (a.sample_delta = t.readUint32()), (a.subsamples = []), (r = t.readUint16()) > 0)) for (n = 0; n < r; n++) { var s = {}; a.subsamples.push(s), 1 == this.version ? (s.size = t.readUint32()) : (s.size = t.readUint16()), (s.priority = t.readUint8()), (s.discardable = t.readUint8()), (s.codec_specific_parameters = t.readUint32()); } } }), c.createFullBoxCtor("tenc", function (t) { if ((t.readUint8(), 0 === this.version)) t.readUint8(); else { var e = t.readUint8(); (this.default_crypt_byte_block = (e >> 4) & 15), (this.default_skip_byte_block = 15 & e); } (this.default_isProtected = t.readUint8()), (this.default_Per_Sample_IV_Size = t.readUint8()), (this.default_KID = c.parseHex16(t)), 1 === this.default_isProtected && 0 === this.default_Per_Sample_IV_Size && ((this.default_constant_IV_size = t.readUint8()), (this.default_constant_IV = t.readUint8Array(this.default_constant_IV_size))); }), c.createFullBoxCtor("tfdt", function (t) { 1 == this.version ? (this.baseMediaDecodeTime = t.readUint64()) : (this.baseMediaDecodeTime = t.readUint32()); }), c.createFullBoxCtor("tfhd", function (t) { var e = 0; (this.track_id = t.readUint32()), this.size - this.hdr_size > e && this.flags & c.TFHD_FLAG_BASE_DATA_OFFSET ? ((this.base_data_offset = t.readUint64()), (e += 8)) : (this.base_data_offset = 0), this.size - this.hdr_size > e && this.flags & c.TFHD_FLAG_SAMPLE_DESC ? ((this.default_sample_description_index = t.readUint32()), (e += 4)) : (this.default_sample_description_index = 0), this.size - this.hdr_size > e && this.flags & c.TFHD_FLAG_SAMPLE_DUR ? ((this.default_sample_duration = t.readUint32()), (e += 4)) : (this.default_sample_duration = 0), this.size - this.hdr_size > e && this.flags & c.TFHD_FLAG_SAMPLE_SIZE ? ((this.default_sample_size = t.readUint32()), (e += 4)) : (this.default_sample_size = 0), this.size - this.hdr_size > e && this.flags & c.TFHD_FLAG_SAMPLE_FLAGS ? ((this.default_sample_flags = t.readUint32()), (e += 4)) : (this.default_sample_flags = 0); }), c.createFullBoxCtor("tfra", function (t) { (this.track_ID = t.readUint32()), t.readUint24(); var e = t.readUint8(); (this.length_size_of_traf_num = (e >> 4) & 3), (this.length_size_of_trun_num = (e >> 2) & 3), (this.length_size_of_sample_num = 3 & e), (this.entries = []); for (var n = t.readUint32(), i = 0; i < n; i++) 1 === this.version ? ((this.time = t.readUint64()), (this.moof_offset = t.readUint64())) : ((this.time = t.readUint32()), (this.moof_offset = t.readUint32())), (this.traf_number = t["readUint" + 8 * (this.length_size_of_traf_num + 1)]()), (this.trun_number = t["readUint" + 8 * (this.length_size_of_trun_num + 1)]()), (this.sample_number = t["readUint" + 8 * (this.length_size_of_sample_num + 1)]()); }), c.createFullBoxCtor("tkhd", function (t) { 1 == this.version ? ((this.creation_time = t.readUint64()), (this.modification_time = t.readUint64()), (this.track_id = t.readUint32()), t.readUint32(), (this.duration = t.readUint64())) : ((this.creation_time = t.readUint32()), (this.modification_time = t.readUint32()), (this.track_id = t.readUint32()), t.readUint32(), (this.duration = t.readUint32())), t.readUint32Array(2), (this.layer = t.readInt16()), (this.alternate_group = t.readInt16()), (this.volume = t.readInt16() >> 8), t.readUint16(), (this.matrix = t.readInt32Array(9)), (this.width = t.readUint32()), (this.height = t.readUint32()); }), c.createBoxCtor("tmax", function (t) { this.time = t.readUint32(); }), c.createBoxCtor("tmin", function (t) { this.time = t.readUint32(); }), c.createBoxCtor("totl", function (t) { this.bytessent = t.readUint32(); }), c.createBoxCtor("tpay", function (t) { this.bytessent = t.readUint32(); }), c.createBoxCtor("tpyl", function (t) { this.bytessent = t.readUint64(); }), (c.TrackGroupTypeBox.prototype.parse = function (t) { this.parseFullHeader(t), (this.track_group_id = t.readUint32()); }), c.createTrackGroupCtor("msrc"), (c.TrackReferenceTypeBox = function (t, e, n, i) { c.Box.call(this, t, e), (this.hdr_size = n), (this.start = i); }), (c.TrackReferenceTypeBox.prototype = new c.Box()), (c.TrackReferenceTypeBox.prototype.parse = function (t) { this.track_ids = t.readUint32Array((this.size - this.hdr_size) / 4); }), (c.trefBox.prototype.parse = function (t) { for (var e, n; t.getPosition() < this.start + this.size;) { if ((e = c.parseOneBox(t, !0, this.size - (t.getPosition() - this.start))).code !== c.OK) return; (n = new c.TrackReferenceTypeBox(e.type, e.size, e.hdr_size, e.start)).write === c.Box.prototype.write && "mdat" !== n.type && (r.info( "BoxParser", "TrackReference " + n.type + " box writing not yet implemented, keeping unparsed data in memory for later write" ), n.parseDataAndRewind(t)), n.parse(t), this.boxes.push(n); } }), c.createFullBoxCtor("trep", function (t) { for (this.track_ID = t.readUint32(), this.boxes = []; t.getPosition() < this.start + this.size;) { if (((ret = c.parseOneBox(t, !1, this.size - (t.getPosition() - this.start))), ret.code !== c.OK)) return; (box = ret.box), this.boxes.push(box); } }), c.createFullBoxCtor("trex", function (t) { (this.track_id = t.readUint32()), (this.default_sample_description_index = t.readUint32()), (this.default_sample_duration = t.readUint32()), (this.default_sample_size = t.readUint32()), (this.default_sample_flags = t.readUint32()); }), c.createBoxCtor("trpy", function (t) { this.bytessent = t.readUint64(); }), c.createFullBoxCtor("trun", function (t) { var e = 0; if ( ((this.sample_count = t.readUint32()), (e += 4), this.size - this.hdr_size > e && this.flags & c.TRUN_FLAGS_DATA_OFFSET ? ((this.data_offset = t.readInt32()), (e += 4)) : (this.data_offset = 0), this.size - this.hdr_size > e && this.flags & c.TRUN_FLAGS_FIRST_FLAG ? ((this.first_sample_flags = t.readUint32()), (e += 4)) : (this.first_sample_flags = 0), (this.sample_duration = []), (this.sample_size = []), (this.sample_flags = []), (this.sample_composition_time_offset = []), this.size - this.hdr_size > e) ) for (var n = 0; n < this.sample_count; n++) this.flags & c.TRUN_FLAGS_DURATION && (this.sample_duration[n] = t.readUint32()), this.flags & c.TRUN_FLAGS_SIZE && (this.sample_size[n] = t.readUint32()), this.flags & c.TRUN_FLAGS_FLAGS && (this.sample_flags[n] = t.readUint32()), this.flags & c.TRUN_FLAGS_CTS_OFFSET && (0 === this.version ? (this.sample_composition_time_offset[n] = t.readUint32()) : (this.sample_composition_time_offset[n] = t.readInt32())); }), c.createFullBoxCtor("tsel", function (t) { this.switch_group = t.readUint32(); var e = (this.size - this.hdr_size - 4) / 4; this.attribute_list = []; for (var n = 0; n < e; n++) this.attribute_list[n] = t.readUint32(); }), c.createFullBoxCtor("txtC", function (t) { this.config = t.readCString(); }), c.createBoxCtor("tyco", function (t) { var e = (this.size - this.hdr_size) / 4; this.compatible_brands = []; for (var n = 0; n < e; n++) this.compatible_brands[n] = t.readString(4); }), c.createFullBoxCtor("udes", function (t) { (this.lang = t.readCString()), (this.name = t.readCString()), (this.description = t.readCString()), (this.tags = t.readCString()); }), c.createFullBoxCtor("uncC", function (t) { var e; for ( this.profile = t.readUint32(), this.component_count = t.readUint16(), this.component_index = [], this.component_bit_depth_minus_one = [], this.component_format = [], this.component_align_size = [], e = 0; e < this.component_count; e++ ) this.component_index.push(t.readUint16()), this.component_bit_depth_minus_one.push(t.readUint8()), this.component_format.push(t.readUint8()), this.component_align_size.push(t.readUint8()); (this.sampling_type = t.readUint8()), (this.interleave_type = t.readUint8()), (this.block_size = t.readUint8()); var n = t.readUint8(); (this.component_little_endian = (n >> 7) & 1), (this.block_pad_lsb = (n >> 6) & 1), (this.block_little_endian = (n >> 5) & 1), (this.block_reversed = (n >> 4) & 1), (this.pad_unknown = (n >> 3) & 1), (this.pixel_size = t.readUint8()), (this.row_align_size = t.readUint32()), (this.tile_align_size = t.readUint32()), (this.num_tile_cols_minus_one = t.readUint32()), (this.num_tile_rows_minus_one = t.readUint32()); }), c.createFullBoxCtor("url ", function (t) { 1 !== this.flags && (this.location = t.readCString()); }), c.createFullBoxCtor("urn ", function (t) { (this.name = t.readCString()), this.size - this.hdr_size - this.name.length - 1 > 0 && (this.location = t.readCString()); }), c.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66", !0, !1, function (t) { this.LiveServerManifest = t .readString(this.size - this.hdr_size) .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); }), c.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3", !0, !1, function (t) { this.system_id = c.parseHex16(t); var e = t.readUint32(); e > 0 && (this.data = t.readUint8Array(e)); }), c.createUUIDBox("a2394f525a9b4f14a2446c427c648df4", !0, !1), c.createUUIDBox("8974dbce7be74c5184f97148f9882554", !0, !1, function (t) { (this.default_AlgorithmID = t.readUint24()), (this.default_IV_size = t.readUint8()), (this.default_KID = c.parseHex16(t)); }), c.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f", !0, !1, function (t) { (this.fragment_count = t.readUint8()), (this.entries = []); for (var e = 0; e < this.fragment_count; e++) { var n = {}, i = 0, r = 0; 1 === this.version ? ((i = t.readUint64()), (r = t.readUint64())) : ((i = t.readUint32()), (r = t.readUint32())), (n.absolute_time = i), (n.absolute_duration = r), this.entries.push(n); } }), c.createUUIDBox("6d1d9b0542d544e680e2141daff757b2", !0, !1, function (t) { 1 === this.version ? ((this.absolute_time = t.readUint64()), (this.duration = t.readUint64())) : ((this.absolute_time = t.readUint32()), (this.duration = t.readUint32())); }), c.createFullBoxCtor("vmhd", function (t) { (this.graphicsmode = t.readUint16()), (this.opcolor = t.readUint16Array(3)); }), c.createFullBoxCtor("vpcC", function (t) { var e; 1 === this.version ? ((this.profile = t.readUint8()), (this.level = t.readUint8()), (e = t.readUint8()), (this.bitDepth = e >> 4), (this.chromaSubsampling = (e >> 1) & 7), (this.videoFullRangeFlag = 1 & e), (this.colourPrimaries = t.readUint8()), (this.transferCharacteristics = t.readUint8()), (this.matrixCoefficients = t.readUint8()), (this.codecIntializationDataSize = t.readUint16()), (this.codecIntializationData = t.readUint8Array(this.codecIntializationDataSize))) : ((this.profile = t.readUint8()), (this.level = t.readUint8()), (e = t.readUint8()), (this.bitDepth = (e >> 4) & 15), (this.colorSpace = 15 & e), (e = t.readUint8()), (this.chromaSubsampling = (e >> 4) & 15), (this.transferFunction = (e >> 1) & 7), (this.videoFullRangeFlag = 1 & e), (this.codecIntializationDataSize = t.readUint16()), (this.codecIntializationData = t.readUint8Array(this.codecIntializationDataSize))); }), c.createBoxCtor("vttC", function (t) { this.text = t.readString(this.size - this.hdr_size); }), c.createFullBoxCtor("vvcC", function (t) { var e, n, i = { held_bits: void 0, num_held_bits: 0, stream_read_1_bytes: function (t) { (this.held_bits = t.readUint8()), (this.num_held_bits = 8); }, stream_read_2_bytes: function (t) { (this.held_bits = t.readUint16()), (this.num_held_bits = 16); }, extract_bits: function (t) { var e = (this.held_bits >> (this.num_held_bits - t)) & ((1 << t) - 1); return (this.num_held_bits -= t), e; } }; if ( (i.stream_read_1_bytes(t), i.extract_bits(5), (this.lengthSizeMinusOne = i.extract_bits(2)), (this.ptl_present_flag = i.extract_bits(1)), this.ptl_present_flag) ) { if ( (i.stream_read_2_bytes(t), (this.ols_idx = i.extract_bits(9)), (this.num_sublayers = i.extract_bits(3)), (this.constant_frame_rate = i.extract_bits(2)), (this.chroma_format_idc = i.extract_bits(2)), i.stream_read_1_bytes(t), (this.bit_depth_minus8 = i.extract_bits(3)), i.extract_bits(5), i.stream_read_2_bytes(t), i.extract_bits(2), (this.num_bytes_constraint_info = i.extract_bits(6)), (this.general_profile_idc = i.extract_bits(7)), (this.general_tier_flag = i.extract_bits(1)), (this.general_level_idc = t.readUint8()), i.stream_read_1_bytes(t), (this.ptl_frame_only_constraint_flag = i.extract_bits(1)), (this.ptl_multilayer_enabled_flag = i.extract_bits(1)), (this.general_constraint_info = new Uint8Array(this.num_bytes_constraint_info)), this.num_bytes_constraint_info) ) { for (e = 0; e < this.num_bytes_constraint_info - 1; e++) { var r = i.extract_bits(6); i.stream_read_1_bytes(t); var a = i.extract_bits(2); this.general_constraint_info[e] = (r << 2) | a; } this.general_constraint_info[this.num_bytes_constraint_info - 1] = i.extract_bits(6); } else i.extract_bits(6); if (this.num_sublayers > 1) { for ( i.stream_read_1_bytes(t), this.ptl_sublayer_present_mask = 0, n = this.num_sublayers - 2; n >= 0; --n ) { var s = i.extract_bits(1); this.ptl_sublayer_present_mask |= s << n; } for (n = this.num_sublayers; n <= 8 && this.num_sublayers > 1; ++n) i.extract_bits(1); for (this.sublayer_level_idc = [], n = this.num_sublayers - 2; n >= 0; --n) this.ptl_sublayer_present_mask & (1 << n) && (this.sublayer_level_idc[n] = t.readUint8()); } if ( ((this.ptl_num_sub_profiles = t.readUint8()), (this.general_sub_profile_idc = []), this.ptl_num_sub_profiles) ) for (e = 0; e < this.ptl_num_sub_profiles; e++) this.general_sub_profile_idc.push(t.readUint32()); (this.max_picture_width = t.readUint16()), (this.max_picture_height = t.readUint16()), (this.avg_frame_rate = t.readUint16()); } this.nalu_arrays = []; var o = t.readUint8(); for (e = 0; e < o; e++) { var l = []; this.nalu_arrays.push(l), i.stream_read_1_bytes(t), (l.completeness = i.extract_bits(1)), i.extract_bits(2), (l.nalu_type = i.extract_bits(5)); var d = 1; for (13 != l.nalu_type && 12 != l.nalu_type && (d = t.readUint16()), n = 0; n < d; n++) { var c = t.readUint16(); l.push({ data: t.readUint8Array(c), length: c }); } } }), c.createFullBoxCtor("vvnC", function (t) { var e = strm.readUint8(); this.lengthSizeMinusOne = 3 & e; }), (c.SampleEntry.prototype.isVideo = function () { return !1; }), (c.SampleEntry.prototype.isAudio = function () { return !1; }), (c.SampleEntry.prototype.isSubtitle = function () { return !1; }), (c.SampleEntry.prototype.isMetadata = function () { return !1; }), (c.SampleEntry.prototype.isHint = function () { return !1; }), (c.SampleEntry.prototype.getCodec = function () { return this.type.replace(".", ""); }), (c.SampleEntry.prototype.getWidth = function () { return ""; }), (c.SampleEntry.prototype.getHeight = function () { return ""; }), (c.SampleEntry.prototype.getChannelCount = function () { return ""; }), (c.SampleEntry.prototype.getSampleRate = function () { return ""; }), (c.SampleEntry.prototype.getSampleSize = function () { return ""; }), (c.VisualSampleEntry.prototype.isVideo = function () { return !0; }), (c.VisualSampleEntry.prototype.getWidth = function () { return this.width; }), (c.VisualSampleEntry.prototype.getHeight = function () { return this.height; }), (c.AudioSampleEntry.prototype.isAudio = function () { return !0; }), (c.AudioSampleEntry.prototype.getChannelCount = function () { return this.channel_count; }), (c.AudioSampleEntry.prototype.getSampleRate = function () { return this.samplerate; }), (c.AudioSampleEntry.prototype.getSampleSize = function () { return this.samplesize; }), (c.SubtitleSampleEntry.prototype.isSubtitle = function () { return !0; }), (c.MetadataSampleEntry.prototype.isMetadata = function () { return !0; }), (c.decimalToHex = function (t, e) { var n = Number(t).toString(16); for (e = null == e ? (e = 2) : e; n.length < e;) n = "0" + n; return n; }), (c.avc1SampleEntry.prototype.getCodec = c.avc2SampleEntry.prototype.getCodec = c.avc3SampleEntry.prototype.getCodec = c.avc4SampleEntry.prototype.getCodec = function () { var t = c.SampleEntry.prototype.getCodec.call(this); return this.avcC ? t + "." + c.decimalToHex(this.avcC.AVCProfileIndication) + c.decimalToHex(this.avcC.profile_compatibility) + c.decimalToHex(this.avcC.AVCLevelIndication) : t; }), (c.hev1SampleEntry.prototype.getCodec = c.hvc1SampleEntry.prototype.getCodec = function () { var t, e = c.SampleEntry.prototype.getCodec.call(this); if (this.hvcC) { switch (((e += "."), this.hvcC.general_profile_space)) { case 0: e += ""; break; case 1: e += "A"; break; case 2: e += "B"; break; case 3: e += "C"; } (e += this.hvcC.general_profile_idc), (e += "."); var n = this.hvcC.general_profile_compatibility, i = 0; for (t = 0; t < 32 && ((i |= 1 & n), 31 != t); t++) (i <<= 1), (n >>= 1); (e += c.decimalToHex(i, 0)), (e += "."), 0 === this.hvcC.general_tier_flag ? (e += "L") : (e += "H"), (e += this.hvcC.general_level_idc); var r = !1, a = ""; for (t = 5; t >= 0; t--) (this.hvcC.general_constraint_indicator[t] || r) && ((a = "." + c.decimalToHex(this.hvcC.general_constraint_indicator[t], 0) + a), (r = !0)); e += a; } return e; }), (c.vvc1SampleEntry.prototype.getCodec = c.vvi1SampleEntry.prototype.getCodec = function () { var t, e = c.SampleEntry.prototype.getCodec.call(this); if (this.vvcC) { (e += "." + this.vvcC.general_profile_idc), this.vvcC.general_tier_flag ? (e += ".H") : (e += ".L"), (e += this.vvcC.general_level_idc); var n = ""; if (this.vvcC.general_constraint_info) { var i, r = [], a = 0; for ( a |= this.vvcC.ptl_frame_only_constraint << 7, a |= this.vvcC.ptl_multilayer_enabled << 6, t = 0; t < this.vvcC.general_constraint_info.length; ++t ) (a |= (this.vvcC.general_constraint_info[t] >> 2) & 63), r.push(a), a && (i = t), (a = (this.vvcC.general_constraint_info[t] >> 2) & 3); if (void 0 === i) n = ".CA"; else { n = ".C"; var s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", o = 0, l = 0; for (t = 0; t <= i; ++t) for (o = (o << 8) | r[t], l += 8; l >= 5;) { (n += s[(o >> (l - 5)) & 31]), (o &= (1 << (l -= 5)) - 1); } l && (n += s[31 & (o <<= 5 - l)]); } } e += n; } return e; }), (c.mp4aSampleEntry.prototype.getCodec = function () { var t = c.SampleEntry.prototype.getCodec.call(this); if (this.esds && this.esds.esd) { var e = this.esds.esd.getOTI(), n = this.esds.esd.getAudioConfig(); return t + "." + c.decimalToHex(e) + (n ? "." + n : ""); } return t; }), (c.stxtSampleEntry.prototype.getCodec = function () { var t = c.SampleEntry.prototype.getCodec.call(this); return this.mime_format ? t + "." + this.mime_format : t; }), (c.vp08SampleEntry.prototype.getCodec = c.vp09SampleEntry.prototype.getCodec = function () { var t = c.SampleEntry.prototype.getCodec.call(this), e = this.vpcC.level; 0 == e && (e = "00"); var n = this.vpcC.bitDepth; return 8 == n && (n = "08"), t + ".0" + this.vpcC.profile + "." + e + "." + n; }), (c.av01SampleEntry.prototype.getCodec = function () { var t, e = c.SampleEntry.prototype.getCodec.call(this), n = this.av1C.seq_level_idx_0; return ( n < 10 && (n = "0" + n), 2 === this.av1C.seq_profile && 1 === this.av1C.high_bitdepth ? (t = 1 === this.av1C.twelve_bit ? "12" : "10") : this.av1C.seq_profile <= 2 && (t = 1 === this.av1C.high_bitdepth ? "10" : "08"), e + "." + this.av1C.seq_profile + "." + n + (this.av1C.seq_tier_0 ? "H" : "M") + "." + t ); }), (c.Box.prototype.writeHeader = function (t, e) { (this.size += 8), this.size > o && (this.size += 8), "uuid" === this.type && (this.size += 16), r.debug( "BoxWriter", "Writing box " + this.type + " of size: " + this.size + " at position " + t.getPosition() + (e || "") ), this.size > o ? t.writeUint32(1) : ((this.sizePosition = t.getPosition()), t.writeUint32(this.size)), t.writeString(this.type, null, 4), "uuid" === this.type && t.writeUint8Array(this.uuid), this.size > o && t.writeUint64(this.size); }), (c.FullBox.prototype.writeHeader = function (t) { (this.size += 4), c.Box.prototype.writeHeader.call(this, t, " v=" + this.version + " f=" + this.flags), t.writeUint8(this.version), t.writeUint24(this.flags); }), (c.Box.prototype.write = function (t) { "mdat" === this.type ? this.data && ((this.size = this.data.length), this.writeHeader(t), t.writeUint8Array(this.data)) : ((this.size = this.data ? this.data.length : 0), this.writeHeader(t), this.data && t.writeUint8Array(this.data)); }), (c.ContainerBox.prototype.write = function (t) { (this.size = 0), this.writeHeader(t); for (var e = 0; e < this.boxes.length; e++) this.boxes[e] && (this.boxes[e].write(t), (this.size += this.boxes[e].size)); r.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size); }), (c.TrackReferenceTypeBox.prototype.write = function (t) { (this.size = 4 * this.track_ids.length), this.writeHeader(t), t.writeUint32Array(this.track_ids); }), (c.avcCBox.prototype.write = function (t) { var e; for (this.size = 7, e = 0; e < this.SPS.length; e++) this.size += 2 + this.SPS[e].length; for (e = 0; e < this.PPS.length; e++) this.size += 2 + this.PPS[e].length; for ( this.ext && (this.size += this.ext.length), this.writeHeader(t), t.writeUint8(this.configurationVersion), t.writeUint8(this.AVCProfileIndication), t.writeUint8(this.profile_compatibility), t.writeUint8(this.AVCLevelIndication), t.writeUint8(this.lengthSizeMinusOne + 252), t.writeUint8(this.SPS.length + 224), e = 0; e < this.SPS.length; e++ ) t.writeUint16(this.SPS[e].length), t.writeUint8Array(this.SPS[e].nalu); for (t.writeUint8(this.PPS.length), e = 0; e < this.PPS.length; e++) t.writeUint16(this.PPS[e].length), t.writeUint8Array(this.PPS[e].nalu); this.ext && t.writeUint8Array(this.ext); }), (c.co64Box.prototype.write = function (t) { var e; for ( this.version = 0, this.flags = 0, this.size = 4 + 8 * this.chunk_offsets.length, this.writeHeader(t), t.writeUint32(this.chunk_offsets.length), e = 0; e < this.chunk_offsets.length; e++ ) t.writeUint64(this.chunk_offsets[e]); }), (c.cslgBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 20), this.writeHeader(t), t.writeInt32(this.compositionToDTSShift), t.writeInt32(this.leastDecodeToDisplayDelta), t.writeInt32(this.greatestDecodeToDisplayDelta), t.writeInt32(this.compositionStartTime), t.writeInt32(this.compositionEndTime); }), (c.cttsBox.prototype.write = function (t) { var e; for ( this.version = 0, this.flags = 0, this.size = 4 + 8 * this.sample_counts.length, this.writeHeader(t), t.writeUint32(this.sample_counts.length), e = 0; e < this.sample_counts.length; e++ ) t.writeUint32(this.sample_counts[e]), 1 === this.version ? t.writeInt32(this.sample_offsets[e]) : t.writeUint32(this.sample_offsets[e]); }), (c.drefBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 4), this.writeHeader(t), t.writeUint32(this.entries.length); for (var e = 0; e < this.entries.length; e++) this.entries[e].write(t), (this.size += this.entries[e].size); r.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size); }), (c.elngBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = this.extended_language.length), this.writeHeader(t), t.writeString(this.extended_language); }), (c.elstBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 4 + 12 * this.entries.length), this.writeHeader(t), t.writeUint32(this.entries.length); for (var e = 0; e < this.entries.length; e++) { var n = this.entries[e]; t.writeUint32(n.segment_duration), t.writeInt32(n.media_time), t.writeInt16(n.media_rate_integer), t.writeInt16(n.media_rate_fraction); } }), (c.emsgBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 16 + this.message_data.length + (this.scheme_id_uri.length + 1) + (this.value.length + 1)), this.writeHeader(t), t.writeCString(this.scheme_id_uri), t.writeCString(this.value), t.writeUint32(this.timescale), t.writeUint32(this.presentation_time_delta), t.writeUint32(this.event_duration), t.writeUint32(this.id), t.writeUint8Array(this.message_data); }), (c.ftypBox.prototype.write = function (t) { (this.size = 8 + 4 * this.compatible_brands.length), this.writeHeader(t), t.writeString(this.major_brand, null, 4), t.writeUint32(this.minor_version); for (var e = 0; e < this.compatible_brands.length; e++) t.writeString(this.compatible_brands[e], null, 4); }), (c.hdlrBox.prototype.write = function (t) { (this.size = 20 + this.name.length + 1), (this.version = 0), (this.flags = 0), this.writeHeader(t), t.writeUint32(0), t.writeString(this.handler, null, 4), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeCString(this.name); }), (c.hvcCBox.prototype.write = function (t) { var e, n; for (this.size = 23, e = 0; e < this.nalu_arrays.length; e++) for (this.size += 3, n = 0; n < this.nalu_arrays[e].length; n++) this.size += 2 + this.nalu_arrays[e][n].data.length; for ( this.writeHeader(t), t.writeUint8(this.configurationVersion), t.writeUint8( (this.general_profile_space << (6 + this.general_tier_flag)) << (5 + this.general_profile_idc) ), t.writeUint32(this.general_profile_compatibility), t.writeUint8Array(this.general_constraint_indicator), t.writeUint8(this.general_level_idc), t.writeUint16(this.min_spatial_segmentation_idc + (15 << 24)), t.writeUint8(this.parallelismType + 252), t.writeUint8(this.chroma_format_idc + 252), t.writeUint8(this.bit_depth_luma_minus8 + 248), t.writeUint8(this.bit_depth_chroma_minus8 + 248), t.writeUint16(this.avgFrameRate), t.writeUint8( (this.constantFrameRate << 6) + (this.numTemporalLayers << 3) + (this.temporalIdNested << 2) + this.lengthSizeMinusOne ), t.writeUint8(this.nalu_arrays.length), e = 0; e < this.nalu_arrays.length; e++ ) for ( t.writeUint8((this.nalu_arrays[e].completeness << 7) + this.nalu_arrays[e].nalu_type), t.writeUint16(this.nalu_arrays[e].length), n = 0; n < this.nalu_arrays[e].length; n++ ) t.writeUint16(this.nalu_arrays[e][n].data.length), t.writeUint8Array(this.nalu_arrays[e][n].data); }), (c.kindBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = this.schemeURI.length + 1 + (this.value.length + 1)), this.writeHeader(t), t.writeCString(this.schemeURI), t.writeCString(this.value); }), (c.mdhdBox.prototype.write = function (t) { (this.size = 20), (this.flags = 0), (this.version = 0), this.writeHeader(t), t.writeUint32(this.creation_time), t.writeUint32(this.modification_time), t.writeUint32(this.timescale), t.writeUint32(this.duration), t.writeUint16(this.language), t.writeUint16(0); }), (c.mehdBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 4), this.writeHeader(t), t.writeUint32(this.fragment_duration); }), (c.mfhdBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 4), this.writeHeader(t), t.writeUint32(this.sequence_number); }), (c.mvhdBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 96), this.writeHeader(t), t.writeUint32(this.creation_time), t.writeUint32(this.modification_time), t.writeUint32(this.timescale), t.writeUint32(this.duration), t.writeUint32(this.rate), t.writeUint16(this.volume << 8), t.writeUint16(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32Array(this.matrix), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(this.next_track_id); }), (c.SampleEntry.prototype.writeHeader = function (t) { (this.size = 8), c.Box.prototype.writeHeader.call(this, t), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint16(this.data_reference_index); }), (c.SampleEntry.prototype.writeFooter = function (t) { for (var e = 0; e < this.boxes.length; e++) this.boxes[e].write(t), (this.size += this.boxes[e].size); r.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size); }), (c.SampleEntry.prototype.write = function (t) { this.writeHeader(t), t.writeUint8Array(this.data), (this.size += this.data.length), r.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size); }), (c.VisualSampleEntry.prototype.write = function (t) { this.writeHeader(t), (this.size += 70), t.writeUint16(0), t.writeUint16(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint16(this.width), t.writeUint16(this.height), t.writeUint32(this.horizresolution), t.writeUint32(this.vertresolution), t.writeUint32(0), t.writeUint16(this.frame_count), t.writeUint8(Math.min(31, this.compressorname.length)), t.writeString(this.compressorname, null, 31), t.writeUint16(this.depth), t.writeInt16(-1), this.writeFooter(t); }), (c.AudioSampleEntry.prototype.write = function (t) { this.writeHeader(t), (this.size += 20), t.writeUint32(0), t.writeUint32(0), t.writeUint16(this.channel_count), t.writeUint16(this.samplesize), t.writeUint16(0), t.writeUint16(0), t.writeUint32(this.samplerate << 16), this.writeFooter(t); }), (c.stppSampleEntry.prototype.write = function (t) { this.writeHeader(t), (this.size += this.namespace.length + 1 + this.schema_location.length + 1 + this.auxiliary_mime_types.length + 1), t.writeCString(this.namespace), t.writeCString(this.schema_location), t.writeCString(this.auxiliary_mime_types), this.writeFooter(t); }), (c.SampleGroupEntry.prototype.write = function (t) { t.writeUint8Array(this.data); }), (c.sbgpBox.prototype.write = function (t) { (this.version = 1), (this.flags = 0), (this.size = 12 + 8 * this.entries.length), this.writeHeader(t), t.writeString(this.grouping_type, null, 4), t.writeUint32(this.grouping_type_parameter), t.writeUint32(this.entries.length); for (var e = 0; e < this.entries.length; e++) { var n = this.entries[e]; t.writeInt32(n.sample_count), t.writeInt32(n.group_description_index); } }), (c.sgpdBox.prototype.write = function (t) { var e, n; for (this.flags = 0, this.size = 12, e = 0; e < this.entries.length; e++) (n = this.entries[e]), 1 === this.version && (0 === this.default_length && (this.size += 4), (this.size += n.data.length)); for ( this.writeHeader(t), t.writeString(this.grouping_type, null, 4), 1 === this.version && t.writeUint32(this.default_length), this.version >= 2 && t.writeUint32(this.default_sample_description_index), t.writeUint32(this.entries.length), e = 0; e < this.entries.length; e++ ) (n = this.entries[e]), 1 === this.version && 0 === this.default_length && t.writeUint32(n.description_length), n.write(t); }), (c.sidxBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 20 + 12 * this.references.length), this.writeHeader(t), t.writeUint32(this.reference_ID), t.writeUint32(this.timescale), t.writeUint32(this.earliest_presentation_time), t.writeUint32(this.first_offset), t.writeUint16(0), t.writeUint16(this.references.length); for (var e = 0; e < this.references.length; e++) { var n = this.references[e]; t.writeUint32((n.reference_type << 31) | n.referenced_size), t.writeUint32(n.subsegment_duration), t.writeUint32((n.starts_with_SAP << 31) | (n.SAP_type << 28) | n.SAP_delta_time); } }), (c.smhdBox.prototype.write = function (t) { (this.version = 0), (this.flags = 1), (this.size = 4), this.writeHeader(t), t.writeUint16(this.balance), t.writeUint16(0); }), (c.stcoBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 4 + 4 * this.chunk_offsets.length), this.writeHeader(t), t.writeUint32(this.chunk_offsets.length), t.writeUint32Array(this.chunk_offsets); }), (c.stscBox.prototype.write = function (t) { var e; for ( this.version = 0, this.flags = 0, this.size = 4 + 12 * this.first_chunk.length, this.writeHeader(t), t.writeUint32(this.first_chunk.length), e = 0; e < this.first_chunk.length; e++ ) t.writeUint32(this.first_chunk[e]), t.writeUint32(this.samples_per_chunk[e]), t.writeUint32(this.sample_description_index[e]); }), (c.stsdBox.prototype.write = function (t) { var e; for ( this.version = 0, this.flags = 0, this.size = 0, this.writeHeader(t), t.writeUint32(this.entries.length), this.size += 4, e = 0; e < this.entries.length; e++ ) this.entries[e].write(t), (this.size += this.entries[e].size); r.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size); }), (c.stshBox.prototype.write = function (t) { var e; for ( this.version = 0, this.flags = 0, this.size = 4 + 8 * this.shadowed_sample_numbers.length, this.writeHeader(t), t.writeUint32(this.shadowed_sample_numbers.length), e = 0; e < this.shadowed_sample_numbers.length; e++ ) t.writeUint32(this.shadowed_sample_numbers[e]), t.writeUint32(this.sync_sample_numbers[e]); }), (c.stssBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 4 + 4 * this.sample_numbers.length), this.writeHeader(t), t.writeUint32(this.sample_numbers.length), t.writeUint32Array(this.sample_numbers); }), (c.stszBox.prototype.write = function (t) { var e, n = !0; if (((this.version = 0), (this.flags = 0), this.sample_sizes.length > 0)) for (e = 0; e + 1 < this.sample_sizes.length;) { if (this.sample_sizes[e + 1] !== this.sample_sizes[0]) { n = !1; break; } e++; } else n = !1; (this.size = 8), n || (this.size += 4 * this.sample_sizes.length), this.writeHeader(t), n ? t.writeUint32(this.sample_sizes[0]) : t.writeUint32(0), t.writeUint32(this.sample_sizes.length), n || t.writeUint32Array(this.sample_sizes); }), (c.sttsBox.prototype.write = function (t) { var e; for ( this.version = 0, this.flags = 0, this.size = 4 + 8 * this.sample_counts.length, this.writeHeader(t), t.writeUint32(this.sample_counts.length), e = 0; e < this.sample_counts.length; e++ ) t.writeUint32(this.sample_counts[e]), t.writeUint32(this.sample_deltas[e]); }), (c.tfdtBox.prototype.write = function (t) { var e = Math.pow(2, 32) - 1; (this.version = this.baseMediaDecodeTime > e ? 1 : 0), (this.flags = 0), (this.size = 4), 1 === this.version && (this.size += 4), this.writeHeader(t), 1 === this.version ? t.writeUint64(this.baseMediaDecodeTime) : t.writeUint32(this.baseMediaDecodeTime); }), (c.tfhdBox.prototype.write = function (t) { (this.version = 0), (this.size = 4), this.flags & c.TFHD_FLAG_BASE_DATA_OFFSET && (this.size += 8), this.flags & c.TFHD_FLAG_SAMPLE_DESC && (this.size += 4), this.flags & c.TFHD_FLAG_SAMPLE_DUR && (this.size += 4), this.flags & c.TFHD_FLAG_SAMPLE_SIZE && (this.size += 4), this.flags & c.TFHD_FLAG_SAMPLE_FLAGS && (this.size += 4), this.writeHeader(t), t.writeUint32(this.track_id), this.flags & c.TFHD_FLAG_BASE_DATA_OFFSET && t.writeUint64(this.base_data_offset), this.flags & c.TFHD_FLAG_SAMPLE_DESC && t.writeUint32(this.default_sample_description_index), this.flags & c.TFHD_FLAG_SAMPLE_DUR && t.writeUint32(this.default_sample_duration), this.flags & c.TFHD_FLAG_SAMPLE_SIZE && t.writeUint32(this.default_sample_size), this.flags & c.TFHD_FLAG_SAMPLE_FLAGS && t.writeUint32(this.default_sample_flags); }), (c.tkhdBox.prototype.write = function (t) { (this.version = 0), (this.size = 80), this.writeHeader(t), t.writeUint32(this.creation_time), t.writeUint32(this.modification_time), t.writeUint32(this.track_id), t.writeUint32(0), t.writeUint32(this.duration), t.writeUint32(0), t.writeUint32(0), t.writeInt16(this.layer), t.writeInt16(this.alternate_group), t.writeInt16(this.volume << 8), t.writeUint16(0), t.writeInt32Array(this.matrix), t.writeUint32(this.width), t.writeUint32(this.height); }), (c.trexBox.prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = 20), this.writeHeader(t), t.writeUint32(this.track_id), t.writeUint32(this.default_sample_description_index), t.writeUint32(this.default_sample_duration), t.writeUint32(this.default_sample_size), t.writeUint32(this.default_sample_flags); }), (c.trunBox.prototype.write = function (t) { (this.version = 0), (this.size = 4), this.flags & c.TRUN_FLAGS_DATA_OFFSET && (this.size += 4), this.flags & c.TRUN_FLAGS_FIRST_FLAG && (this.size += 4), this.flags & c.TRUN_FLAGS_DURATION && (this.size += 4 * this.sample_duration.length), this.flags & c.TRUN_FLAGS_SIZE && (this.size += 4 * this.sample_size.length), this.flags & c.TRUN_FLAGS_FLAGS && (this.size += 4 * this.sample_flags.length), this.flags & c.TRUN_FLAGS_CTS_OFFSET && (this.size += 4 * this.sample_composition_time_offset.length), this.writeHeader(t), t.writeUint32(this.sample_count), this.flags & c.TRUN_FLAGS_DATA_OFFSET && ((this.data_offset_position = t.getPosition()), t.writeInt32(this.data_offset)), this.flags & c.TRUN_FLAGS_FIRST_FLAG && t.writeUint32(this.first_sample_flags); for (var e = 0; e < this.sample_count; e++) this.flags & c.TRUN_FLAGS_DURATION && t.writeUint32(this.sample_duration[e]), this.flags & c.TRUN_FLAGS_SIZE && t.writeUint32(this.sample_size[e]), this.flags & c.TRUN_FLAGS_FLAGS && t.writeUint32(this.sample_flags[e]), this.flags & c.TRUN_FLAGS_CTS_OFFSET && (0 === this.version ? t.writeUint32(this.sample_composition_time_offset[e]) : t.writeInt32(this.sample_composition_time_offset[e])); }), (c["url Box"].prototype.write = function (t) { (this.version = 0), this.location ? ((this.flags = 0), (this.size = this.location.length + 1)) : ((this.flags = 1), (this.size = 0)), this.writeHeader(t), this.location && t.writeCString(this.location); }), (c["urn Box"].prototype.write = function (t) { (this.version = 0), (this.flags = 0), (this.size = this.name.length + 1 + (this.location ? this.location.length + 1 : 0)), this.writeHeader(t), t.writeCString(this.name), this.location && t.writeCString(this.location); }), (c.vmhdBox.prototype.write = function (t) { (this.version = 0), (this.flags = 1), (this.size = 8), this.writeHeader(t), t.writeUint16(this.graphicsmode), t.writeUint16Array(this.opcolor); }), (c.cttsBox.prototype.unpack = function (t) { var e, n, i; for (i = 0, e = 0; e < this.sample_counts.length; e++) for (n = 0; n < this.sample_counts[e]; n++) (t[i].pts = t[i].dts + this.sample_offsets[e]), i++; }), (c.sttsBox.prototype.unpack = function (t) { var e, n, i; for (i = 0, e = 0; e < this.sample_counts.length; e++) for (n = 0; n < this.sample_counts[e]; n++) (t[i].dts = 0 === i ? 0 : t[i - 1].dts + this.sample_deltas[e]), i++; }), (c.stcoBox.prototype.unpack = function (t) { var e; for (e = 0; e < this.chunk_offsets.length; e++) t[e].offset = this.chunk_offsets[e]; }), (c.stscBox.prototype.unpack = function (t) { var e, n, i, r, a; for (r = 0, a = 0, e = 0; e < this.first_chunk.length; e++) for (n = 0; n < (e + 1 < this.first_chunk.length ? this.first_chunk[e + 1] : 1 / 0); n++) for (a++, i = 0; i < this.samples_per_chunk[e]; i++) { if (!t[r]) return; (t[r].description_index = this.sample_description_index[e]), (t[r].chunk_index = a), r++; } }), (c.stszBox.prototype.unpack = function (t) { var e; for (e = 0; e < this.sample_sizes.length; e++) t[e].size = this.sample_sizes[e]; }), (c.DIFF_BOXES_PROP_NAMES = [ "boxes", "entries", "references", "subsamples", "items", "item_infos", "extents", "associations", "subsegments", "ranges", "seekLists", "seekPoints", "esd", "levels" ]), (c.DIFF_PRIMITIVE_ARRAY_PROP_NAMES = [ "compatible_brands", "matrix", "opcolor", "sample_counts", "sample_counts", "sample_deltas", "first_chunk", "samples_per_chunk", "sample_sizes", "chunk_offsets", "sample_offsets", "sample_description_index", "sample_duration" ]), (c.boxEqualFields = function (t, e) { if (t && !e) return !1; var n; for (n in t) if ( !( c.DIFF_BOXES_PROP_NAMES.indexOf(n) > -1 || t[n] instanceof c.Box || e[n] instanceof c.Box || void 0 === t[n] || void 0 === e[n] || "function" == typeof t[n] || "function" == typeof e[n] || (t.subBoxNames && t.subBoxNames.indexOf(n.slice(0, 4)) > -1) || (e.subBoxNames && e.subBoxNames.indexOf(n.slice(0, 4)) > -1) || "data" === n || "start" === n || "size" === n || "creation_time" === n || "modification_time" === n || c.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(n) > -1 || t[n] === e[n] ) ) return !1; return !0; }), (c.boxEqual = function (t, e) { if (!c.boxEqualFields(t, e)) return !1; for (var n = 0; n < c.DIFF_BOXES_PROP_NAMES.length; n++) { var i = c.DIFF_BOXES_PROP_NAMES[n]; if (t[i] && e[i] && !c.boxEqual(t[i], e[i])) return !1; } return !0; }); var h = function () { }; h.prototype.parseSample = function (t) { var e, n = {}; n.resources = []; var i = new a(t.data.buffer); if (t.subsamples && 0 !== t.subsamples.length) { if (((n.documentString = i.readString(t.subsamples[0].size)), t.subsamples.length > 1)) for (e = 1; e < t.subsamples.length; e++) n.resources[e] = i.readUint8Array(t.subsamples[e].size); } else n.documentString = i.readString(t.data.length); return ( "undefined" != typeof DOMParser && (n.document = new DOMParser().parseFromString(n.documentString, "application/xml")), n ); }; var p = function () { }; (p.prototype.parseSample = function (t) { return new a(t.data.buffer).readString(t.data.length); }), (p.prototype.parseConfig = function (t) { var e = new a(t.buffer); return e.readUint32(), e.readCString(); }), (t.XMLSubtitlein4Parser = h), (t.Textin4Parser = p); var f = function (t) { (this.stream = t || new l()), (this.boxes = []), (this.mdats = []), (this.moofs = []), (this.isProgressive = !1), (this.moovStartFound = !1), (this.onMoovStart = null), (this.moovStartSent = !1), (this.onReady = null), (this.readySent = !1), (this.onSegment = null), (this.onSamples = null), (this.onError = null), (this.sampleListBuilt = !1), (this.fragmentedTracks = []), (this.extractedTracks = []), (this.isFragmentationInitialized = !1), (this.sampleProcessingStarted = !1), (this.nextMoofNumber = 0), (this.itemListBuilt = !1), (this.onSidx = null), (this.sidxSent = !1); }; (f.prototype.setSegmentOptions = function (t, e, n) { var i = this.getTrackById(t); if (i) { var r = {}; this.fragmentedTracks.push(r), (r.id = t), (r.user = e), (r.trak = i), (i.nextSample = 0), (r.segmentStream = null), (r.nb_samples = 1e3), (r.rapAlignement = !0), n && (n.nbSamples && (r.nb_samples = n.nbSamples), n.rapAlignement && (r.rapAlignement = n.rapAlignement)); } }), (f.prototype.unsetSegmentOptions = function (t) { for (var e = -1, n = 0; n < this.fragmentedTracks.length; n++) { this.fragmentedTracks[n].id == t && (e = n); } e > -1 && this.fragmentedTracks.splice(e, 1); }), (f.prototype.setExtractionOptions = function (t, e, n) { var i = this.getTrackById(t); if (i) { var r = {}; this.extractedTracks.push(r), (r.id = t), (r.user = e), (r.trak = i), (i.nextSample = 0), (r.nb_samples = 1e3), (r.samples = []), n && n.nbSamples && (r.nb_samples = n.nbSamples); } }), (f.prototype.unsetExtractionOptions = function (t) { for (var e = -1, n = 0; n < this.extractedTracks.length; n++) { this.extractedTracks[n].id == t && (e = n); } e > -1 && this.extractedTracks.splice(e, 1); }), (f.prototype.parse = function () { var t, e; if (!this.restoreParsePosition || this.restoreParsePosition()) for (; ;) { if (this.hasIncompleteMdat && this.hasIncompleteMdat()) { if (this.processIncompleteMdat()) continue; return; } if ( (this.saveParsePosition && this.saveParsePosition(), (t = c.parseOneBox(this.stream, false)).code === c.ERR_NOT_ENOUGH_DATA) ) { if (this.processIncompleteBox) { if (this.processIncompleteBox(t)) continue; return; } return; } var n; switch (((n = "uuid" !== (e = t.box).type ? e.type : e.uuid), this.boxes.push(e), n)) { case "mdat": this.mdats.push(e); break; case "moof": this.moofs.push(e); break; case "moov": (this.moovStartFound = !0), 0 === this.mdats.length && (this.isProgressive = !0); default: void 0 !== this[n] && r.warn("ISOFile", "Duplicate Box of type: " + n + ", overriding previous occurrence"), (this[n] = e); } this.updateUsedBytes && this.updateUsedBytes(e, t); } }), (f.prototype.checkBuffer = function (t) { if (null == t) throw "Buffer must be defined and non empty"; if (void 0 === t.fileStart) throw "Buffer must have a fileStart property"; return 0 === t.byteLength ? (r.warn("ISOFile", "Ignoring empty buffer (fileStart: " + t.fileStart + ")"), this.stream.logBufferLevel(), !1) : (r.info("ISOFile", "Processing buffer (fileStart: " + t.fileStart + ")"), (t.usedBytes = 0), this.stream.insertBuffer(t), this.stream.logBufferLevel(), !!this.stream.initialized() || (r.warn("ISOFile", "Not ready to start parsing"), !1)); }), (f.prototype.appendBuffer = function (t, e) { var n; if (this.checkBuffer(t)) return ( this.parse(), this.moovStartFound && !this.moovStartSent && ((this.moovStartSent = !0), this.onMoovStart && this.onMoovStart()), this.moov ? (this.sampleListBuilt || (this.buildSampleLists(), (this.sampleListBuilt = !0)), this.updateSampleLists(), this.onReady && !this.readySent && ((this.readySent = !0), this.onReady(this.getInfo())), this.processSamples(e), this.nextSeekPosition ? ((n = this.nextSeekPosition), (this.nextSeekPosition = void 0)) : (n = this.nextParsePosition), this.stream.getEndFilePositionAfter && (n = this.stream.getEndFilePositionAfter(n))) : (n = this.nextParsePosition ? this.nextParsePosition : 0), this.sidx && this.onSidx && !this.sidxSent && (this.onSidx(this.sidx), (this.sidxSent = !0)), this.meta && (this.flattenItemInfo && !this.itemListBuilt && (this.flattenItemInfo(), (this.itemListBuilt = !0)), this.processItems && this.processItems(this.onItem)), this.stream.cleanBuffers && (r.info( "ISOFile", "Done processing buffer (fileStart: " + t.fileStart + ") - next buffer to fetch should have a fileStart position of " + n ), this.stream.logBufferLevel(), this.stream.cleanBuffers(), this.stream.logBufferLevel(!0), r.info("ISOFile", "Sample data size in memory: " + this.getAllocatedSampleDataSize())), n ); }), (f.prototype.getInfo = function () { var t, e, n, i, r, a, s = {}, o = new Date("1904-01-01T00:00:00Z").getTime(); if (this.moov) for ( s.hasMoov = !0, s.duration = this.moov.mvhd.duration, s.timescale = this.moov.mvhd.timescale, s.isFragmented = null != this.moov.mvex, s.isFragmented && this.moov.mvex.mehd && (s.fragment_duration = this.moov.mvex.mehd.fragment_duration), s.isProgressive = this.isProgressive, s.hasIOD = null != this.moov.iods, s.brands = [], s.brands.push(this.ftyp.major_brand), s.brands = s.brands.concat(this.ftyp.compatible_brands), s.created = new Date(o + 1e3 * this.moov.mvhd.creation_time), s.modified = new Date(o + 1e3 * this.moov.mvhd.modification_time), s.tracks = [], s.audioTracks = [], s.videoTracks = [], s.subtitleTracks = [], s.metadataTracks = [], s.hintTracks = [], s.otherTracks = [], t = 0; t < this.moov.traks.length; t++ ) { if ( ((a = (n = this.moov.traks[t]).mdia.minf.stbl.stsd.entries[0]), (i = {}), s.tracks.push(i), (i.id = n.tkhd.track_id), (i.name = n.mdia.hdlr.name), (i.references = []), n.tref) ) for (e = 0; e < n.tref.boxes.length; e++) (r = {}), i.references.push(r), (r.type = n.tref.boxes[e].type), (r.track_ids = n.tref.boxes[e].track_ids); n.edts && (i.edits = n.edts.elst.entries), (i.created = new Date(o + 1e3 * n.tkhd.creation_time)), (i.modified = new Date(o + 1e3 * n.tkhd.modification_time)), (i.movie_duration = n.tkhd.duration), (i.movie_timescale = s.timescale), (i.layer = n.tkhd.layer), (i.alternate_group = n.tkhd.alternate_group), (i.volume = n.tkhd.volume), (i.matrix = n.tkhd.matrix), (i.track_width = n.tkhd.width / 65536), (i.track_height = n.tkhd.height / 65536), (i.timescale = n.mdia.mdhd.timescale), (i.cts_shift = n.mdia.minf.stbl.cslg), (i.duration = n.mdia.mdhd.duration), (i.samples_duration = n.samples_duration), (i.codec = a.getCodec()), (i.kind = n.udta && n.udta.kinds.length ? n.udta.kinds[0] : { schemeURI: "", value: "" }), (i.language = n.mdia.elng ? n.mdia.elng.extended_language : n.mdia.mdhd.languageString), (i.nb_samples = n.samples.length), (i.size = n.samples_size), (i.bitrate = (8 * i.size * i.timescale) / i.samples_duration), a.isAudio() ? ((i.type = "audio"), s.audioTracks.push(i), (i.audio = {}), (i.audio.sample_rate = a.getSampleRate()), (i.audio.channel_count = a.getChannelCount()), (i.audio.sample_size = a.getSampleSize())) : a.isVideo() ? ((i.type = "video"), s.videoTracks.push(i), (i.video = {}), (i.video.width = a.getWidth()), (i.video.height = a.getHeight())) : a.isSubtitle() ? ((i.type = "subtitles"), s.subtitleTracks.push(i)) : a.isHint() ? ((i.type = "metadata"), s.hintTracks.push(i)) : a.isMetadata() ? ((i.type = "metadata"), s.metadataTracks.push(i)) : ((i.type = "metadata"), s.otherTracks.push(i)); } else s.hasMoov = !1; if (((s.mime = ""), s.hasMoov && s.tracks)) { for ( s.videoTracks && s.videoTracks.length > 0 ? (s.mime += 'video/mp4; codecs="') : s.audioTracks && s.audioTracks.length > 0 ? (s.mime += 'audio/mp4; codecs="') : (s.mime += 'application/mp4; codecs="'), t = 0; t < s.tracks.length; t++ ) 0 !== t && (s.mime += ","), (s.mime += s.tracks[t].codec); (s.mime += '"; profiles="'), (s.mime += this.ftyp.compatible_brands.join()), (s.mime += '"'); } return s; }), (f.prototype.setNextSeekPositionFromSample = function (t) { t && (this.nextSeekPosition ? (this.nextSeekPosition = Math.min(t.offset + t.alreadyRead, this.nextSeekPosition)) : (this.nextSeekPosition = t.offset + t.alreadyRead)); }), (f.prototype.processSamples = function (t) { var e, n; if (this.sampleProcessingStarted) { if (this.isFragmentationInitialized && null !== this.onSegment) for (e = 0; e < this.fragmentedTracks.length; e++) { var i = this.fragmentedTracks[e]; for (n = i.trak; n.nextSample < n.samples.length && this.sampleProcessingStarted;) { r.debug("ISOFile", "Creating media fragment on track #" + i.id + " for sample " + n.nextSample); var a = this.createFragment(i.id, n.nextSample, i.segmentStream); if (!a) break; if ( ((i.segmentStream = a), n.nextSample++, (n.nextSample % i.nb_samples == 0 || t || n.nextSample >= n.samples.length) && (r.info( "ISOFile", "Sending fragmented data on track #" + i.id + " for samples [" + Math.max(0, n.nextSample - i.nb_samples) + "," + (n.nextSample - 1) + "]" ), r.info("ISOFile", "Sample data size in memory: " + this.getAllocatedSampleDataSize()), this.onSegment && this.onSegment( i.id, i.user, i.segmentStream.buffer, n.nextSample, t || n.nextSample >= n.samples.length ), (i.segmentStream = null), i !== this.fragmentedTracks[e])) ) break; } } if (null !== this.onSamples) for (e = 0; e < this.extractedTracks.length; e++) { var s = this.extractedTracks[e]; for (n = s.trak; n.nextSample < n.samples.length && this.sampleProcessingStarted;) { r.debug("ISOFile", "Exporting on track #" + s.id + " sample #" + n.nextSample); var o = this.getSample(n, n.nextSample); if (!o) { this.setNextSeekPositionFromSample(n.samples[n.nextSample]); break; } if ( (n.nextSample++, s.samples.push(o), (n.nextSample % s.nb_samples == 0 || n.nextSample >= n.samples.length) && (r.debug("ISOFile", "Sending samples on track #" + s.id + " for sample " + n.nextSample), this.onSamples && this.onSamples(s.id, s.user, s.samples), (s.samples = []), s !== this.extractedTracks[e])) ) break; } } } }), (f.prototype.getBox = function (t) { var e = this.getBoxes(t, !0); return e.length ? e[0] : null; }), (f.prototype.getBoxes = function (t, e) { var n = []; return f._sweep.call(this, t, n, e), n; }), (f._sweep = function (t, e, n) { for (var i in (this.type && this.type == t && e.push(this), this.boxes)) { if (e.length && n) return; f._sweep.call(this.boxes[i], t, e, n); } }), (f.prototype.getTrackSamplesInfo = function (t) { var e = this.getTrackById(t); return e ? e.samples : void 0; }), (f.prototype.getTrackSample = function (t, e) { var n = this.getTrackById(t); return this.getSample(n, e); }), (f.prototype.releaseUsedSamples = function (t, e) { var n = 0, i = this.getTrackById(t); i.lastValidSample || (i.lastValidSample = 0); for (var a = i.lastValidSample; a < e; a++) n += this.releaseSample(i, a); r.info( "ISOFile", "Track #" + t + " released samples up to " + e + " (released size: " + n + ", remaining: " + this.samplesDataSize + ")" ), (i.lastValidSample = e); }), (f.prototype.start = function () { (this.sampleProcessingStarted = !0), this.processSamples(!1); }), (f.prototype.stop = function () { this.sampleProcessingStarted = !1; }), (f.prototype.flush = function () { r.info("ISOFile", "Flushing remaining samples"), this.updateSampleLists(), this.processSamples(!0), this.stream.cleanBuffers(), this.stream.logBufferLevel(!0); }), (f.prototype.seekTrack = function (t, e, n) { var i, a, s, o, l = 0, d = 0; if (0 === n.samples.length) return ( r.info( "ISOFile", "No sample in track, cannot seek! Using time " + r.getDurationString(0, 1) + " and offset: 0" ), { offset: 0, time: 0 } ); for (i = 0; i < n.samples.length; i++) { if (((a = n.samples[i]), 0 === i)) (d = 0), (o = a.timescale); else if (a.cts > t * a.timescale) { d = i - 1; break; } e && a.is_sync && (l = i); } for ( e && (d = l), t = n.samples[d].cts, n.nextSample = d; n.samples[d].alreadyRead === n.samples[d].size && n.samples[d + 1]; ) d++; return ( (s = n.samples[d].offset + n.samples[d].alreadyRead), r.info( "ISOFile", "Seeking to " + (e ? "RAP" : "") + " sample #" + n.nextSample + " on track " + n.tkhd.track_id + ", time " + r.getDurationString(t, o) + " and offset: " + s ), { offset: s, time: t / o } ); }), (f.prototype.getTrackDuration = function (t) { var e; return t.samples ? ((e = t.samples[t.samples.length - 1]).cts + e.duration) / e.timescale : 1 / 0; }), (f.prototype.seek = function (t, e) { var n, i, a, s = this.moov, o = { offset: 1 / 0, time: 1 / 0 }; if (this.moov) { for (a = 0; a < s.traks.length; a++) (n = s.traks[a]), t > this.getTrackDuration(n) || ((i = this.seekTrack(t, e, n)).offset < o.offset && (o.offset = i.offset), i.time < o.time && (o.time = i.time)); return ( r.info( "ISOFile", "Seeking at time " + r.getDurationString(o.time, 1) + " needs a buffer with a fileStart position of " + o.offset ), o.offset === 1 / 0 ? (o = { offset: this.nextParsePosition, time: 0 }) : (o.offset = this.stream.getEndFilePositionAfter(o.offset)), r.info("ISOFile", "Adjusted seek position (after checking data already in buffer): " + o.offset), o ); } throw "Cannot seek: moov not received!"; }), (f.prototype.equal = function (t) { for (var e = 0; e < this.boxes.length && e < t.boxes.length;) { var n = this.boxes[e], i = t.boxes[e]; if (!c.boxEqual(n, i)) return !1; e++; } return !0; }), (t.ISOFile = f), (f.prototype.lastBoxStartPosition = 0), (f.prototype.parsingMdat = null), (f.prototype.nextParsePosition = 0), (f.prototype.discardMdatData = !1), (f.prototype.processIncompleteBox = function (t) { var e; return "mdat" === t.type ? ((e = new c[t.type + "Box"](t.size)), (this.parsingMdat = e), this.boxes.push(e), this.mdats.push(e), (e.start = t.start), (e.hdr_size = t.hdr_size), this.stream.addUsedBytes(e.hdr_size), (this.lastBoxStartPosition = e.start + e.size), this.stream.seek(e.start + e.size, !1, this.discardMdatData) ? ((this.parsingMdat = null), !0) : (this.moovStartFound ? (this.nextParsePosition = this.stream.findEndContiguousBuf()) : (this.nextParsePosition = e.start + e.size), !1)) : ("moov" === t.type && ((this.moovStartFound = !0), 0 === this.mdats.length && (this.isProgressive = !0)), !!this.stream.mergeNextBuffer && this.stream.mergeNextBuffer() ? ((this.nextParsePosition = this.stream.getEndPosition()), !0) : (t.type ? this.moovStartFound ? (this.nextParsePosition = this.stream.getEndPosition()) : (this.nextParsePosition = this.stream.getPosition() + t.size) : (this.nextParsePosition = this.stream.getEndPosition()), !1)); }), (f.prototype.hasIncompleteMdat = function () { return null !== this.parsingMdat; }), (f.prototype.processIncompleteMdat = function () { var t; return ( (t = this.parsingMdat), this.stream.seek(t.start + t.size, !1, this.discardMdatData) ? (r.debug("ISOFile", "Found 'mdat' end in buffered data"), (this.parsingMdat = null), !0) : ((this.nextParsePosition = this.stream.findEndContiguousBuf()), !1) ); }), (f.prototype.restoreParsePosition = function () { return this.stream.seek(this.lastBoxStartPosition, !0, this.discardMdatData); }), (f.prototype.saveParsePosition = function () { this.lastBoxStartPosition = this.stream.getPosition(); }), (f.prototype.updateUsedBytes = function (t, e) { this.stream.addUsedBytes && ("mdat" === t.type ? (this.stream.addUsedBytes(t.hdr_size), this.discardMdatData && this.stream.addUsedBytes(t.size - t.hdr_size)) : this.stream.addUsedBytes(t.size)); }), (f.prototype.add = c.Box.prototype.add), (f.prototype.addBox = c.Box.prototype.addBox), (f.prototype.init = function (t) { var e = t || {}; this.add("ftyp") .set("major_brand", (e.brands && e.brands[0]) || "iso4") .set("minor_version", 0) .set("compatible_brands", e.brands || ["iso4"]); var n = this.add("moov"); return ( n .add("mvhd") .set("timescale", e.timescale || 600) .set("rate", e.rate || 65536) .set("creation_time", 0) .set("modification_time", 0) .set("duration", e.duration || 0) .set("volume", e.width ? 0 : 256) .set("matrix", [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824]) .set("next_track_id", 1), n.add("mvex"), this ); }), (f.prototype.addTrack = function (t) { this.moov || this.init(t); var e = t || {}; (e.width = e.width || 320), (e.height = e.height || 320), (e.id = e.id || this.moov.mvhd.next_track_id), (e.type = e.type || "avc1"); var n = this.moov.add("trak"); (this.moov.mvhd.next_track_id = e.id + 1), n .add("tkhd") .set("flags", c.TKHD_FLAG_ENABLED | c.TKHD_FLAG_IN_MOVIE | c.TKHD_FLAG_IN_PREVIEW) .set("creation_time", 0) .set("modification_time", 0) .set("track_id", e.id) .set("duration", e.duration || 0) .set("layer", e.layer || 0) .set("alternate_group", 0) .set("volume", 1) .set("matrix", [0, 0, 0, 0, 0, 0, 0, 0, 0]) .set("width", e.width << 16) .set("height", e.height << 16); var i = n.add("mdia"); i .add("mdhd") .set("creation_time", 0) .set("modification_time", 0) .set("timescale", e.timescale || 1) .set("duration", e.media_duration || 0) .set("language", e.language || "und"), i .add("hdlr") .set("handler", e.hdlr || "vide") .set("name", e.name || "Track created with MP4Box.js"), i.add("elng").set("extended_language", e.language || "fr-FR"); var r = i.add("minf"); if (void 0 !== c[e.type + "SampleEntry"]) { var s = new c[e.type + "SampleEntry"](); s.data_reference_index = 1; var o = ""; for (var l in c.sampleEntryCodes) for (var d = c.sampleEntryCodes[l], u = 0; u < d.length; u++) if (d.indexOf(e.type) > -1) { o = l; break; } switch (o) { case "Visual": if ( (r.add("vmhd").set("graphicsmode", 0).set("opcolor", [0, 0, 0]), s .set("width", e.width) .set("height", e.height) .set("horizresolution", 72 << 16) .set("vertresolution", 72 << 16) .set("frame_count", 1) .set("compressorname", e.type + " Compressor") .set("depth", 24), e.avcDecoderConfigRecord) ) { var h = new c.avcCBox(); h.parse(new a(e.avcDecoderConfigRecord)), s.addBox(h); } else if (e.hevcDecoderConfigRecord) { var p = new c.hvcCBox(); p.parse(new a(e.hevcDecoderConfigRecord)), s.addBox(p); } break; case "Audio": r.add("smhd").set("balance", e.balance || 0), s .set("channel_count", e.channel_count || 2) .set("samplesize", e.samplesize || 16) .set("samplerate", e.samplerate || 65536); break; case "Hint": r.add("hmhd"); break; case "Subtitle": if ((r.add("sthd"), "stpp" === e.type)) s.set("namespace", e.namespace || "nonamespace") .set("schema_location", e.schema_location || "") .set("auxiliary_mime_types", e.auxiliary_mime_types || ""); break; default: r.add("nmhd"); } e.description && s.addBox(e.description), e.description_boxes && e.description_boxes.forEach(function (t) { s.addBox(t); }), r.add("dinf").add("dref").addEntry(new c["url Box"]().set("flags", 1)); var f = r.add("stbl"); return ( f.add("stsd").addEntry(s), f.add("stts").set("sample_counts", []).set("sample_deltas", []), f.add("stsc").set("first_chunk", []).set("samples_per_chunk", []).set("sample_description_index", []), f.add("stco").set("chunk_offsets", []), f.add("stsz").set("sample_sizes", []), this.moov.mvex .add("trex") .set("track_id", e.id) .set("default_sample_description_index", e.default_sample_description_index || 1) .set("default_sample_duration", e.default_sample_duration || 0) .set("default_sample_size", e.default_sample_size || 0) .set("default_sample_flags", e.default_sample_flags || 0), this.buildTrakSampleLists(n), e.id ); } }), (c.Box.prototype.computeSize = function (t) { var e = t || new s(); (e.endianness = s.BIG_ENDIAN), this.write(e); }), (f.prototype.addSample = function (t, e, n) { var i = n || {}, r = {}, a = this.getTrackById(t); if (null !== a) { (r.number = a.samples.length), (r.track_id = a.tkhd.track_id), (r.timescale = a.mdia.mdhd.timescale), (r.description_index = i.sample_description_index ? i.sample_description_index - 1 : 0), (r.description = a.mdia.minf.stbl.stsd.entries[r.description_index]), (r.data = e), (r.size = e.byteLength), (r.alreadyRead = r.size), (r.duration = i.duration || 1), (r.cts = i.cts || 0), (r.dts = i.dts || 0), (r.is_sync = i.is_sync || !1), (r.is_leading = i.is_leading || 0), (r.depends_on = i.depends_on || 0), (r.is_depended_on = i.is_depended_on || 0), (r.has_redundancy = i.has_redundancy || 0), (r.degradation_priority = i.degradation_priority || 0), (r.offset = 0), (r.subsamples = i.subsamples), a.samples.push(r), (a.samples_size += r.size), (a.samples_duration += r.duration), void 0 === a.first_dts && (a.first_dts = i.dts), this.processSamples(); var s = this.createSingleSampleMoof(r); return ( this.addBox(s), s.computeSize(), (s.trafs[0].truns[0].data_offset = s.size + 8), (this.add("mdat").data = new Uint8Array(e)), r ); } }), (f.prototype.createSingleSampleMoof = function (t) { var e = 0; e = t.is_sync ? 1 << 25 : 65536; var n = new c.moofBox(); n.add("mfhd").set("sequence_number", this.nextMoofNumber), this.nextMoofNumber++; var i = n.add("traf"), r = this.getTrackById(t.track_id); return ( i.add("tfhd").set("track_id", t.track_id).set("flags", c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF), i.add("tfdt").set("baseMediaDecodeTime", t.dts - (r.first_dts || 0)), i .add("trun") .set( "flags", c.TRUN_FLAGS_DATA_OFFSET | c.TRUN_FLAGS_DURATION | c.TRUN_FLAGS_SIZE | c.TRUN_FLAGS_FLAGS | c.TRUN_FLAGS_CTS_OFFSET ) .set("data_offset", 0) .set("first_sample_flags", 0) .set("sample_count", 1) .set("sample_duration", [t.duration]) .set("sample_size", [t.size]) .set("sample_flags", [e]) .set("sample_composition_time_offset", [t.cts - t.dts]), n ); }), (f.prototype.lastMoofIndex = 0), (f.prototype.samplesDataSize = 0), (f.prototype.resetTables = function () { var t, e, n, i, r, a; for ( this.initial_duration = this.moov.mvhd.duration, this.moov.mvhd.duration = 0, t = 0; t < this.moov.traks.length; t++ ) { ((e = this.moov.traks[t]).tkhd.duration = 0), (e.mdia.mdhd.duration = 0), ((e.mdia.minf.stbl.stco || e.mdia.minf.stbl.co64).chunk_offsets = []), ((n = e.mdia.minf.stbl.stsc).first_chunk = []), (n.samples_per_chunk = []), (n.sample_description_index = []), ((e.mdia.minf.stbl.stsz || e.mdia.minf.stbl.stz2).sample_sizes = []), ((i = e.mdia.minf.stbl.stts).sample_counts = []), (i.sample_deltas = []), (r = e.mdia.minf.stbl.ctts) && ((r.sample_counts = []), (r.sample_offsets = [])), (a = e.mdia.minf.stbl.stss); var s = e.mdia.minf.stbl.boxes.indexOf(a); -1 != s && (e.mdia.minf.stbl.boxes[s] = null); } }), (f.initSampleGroups = function (t, e, n, i, r) { var a, s, o, l; function d(t, e, n) { (this.grouping_type = t), (this.grouping_type_parameter = e), (this.sbgp = n), (this.last_sample_in_run = -1), (this.entry_index = -1); } for ( e && (e.sample_groups_info = []), t.sample_groups_info || (t.sample_groups_info = []), s = 0; s < n.length; s++ ) { for ( l = n[s].grouping_type + "/" + n[s].grouping_type_parameter, o = new d(n[s].grouping_type, n[s].grouping_type_parameter, n[s]), e && (e.sample_groups_info[l] = o), t.sample_groups_info[l] || (t.sample_groups_info[l] = o), a = 0; a < i.length; a++ ) i[a].grouping_type === n[s].grouping_type && ((o.description = i[a]), (o.description.used = !0)); if (r) for (a = 0; a < r.length; a++) r[a].grouping_type === n[s].grouping_type && ((o.fragment_description = r[a]), (o.fragment_description.used = !0), (o.is_fragment = !0)); } if (e) { if (r) for (s = 0; s < r.length; s++) !r[s].used && r[s].version >= 2 && ((l = r[s].grouping_type + "/0"), ((o = new d(r[s].grouping_type, 0)).is_fragment = !0), e.sample_groups_info[l] || (e.sample_groups_info[l] = o)); } else for (s = 0; s < i.length; s++) !i[s].used && i[s].version >= 2 && ((l = i[s].grouping_type + "/0"), (o = new d(i[s].grouping_type, 0)), t.sample_groups_info[l] || (t.sample_groups_info[l] = o)); }), (f.setSampleGroupProperties = function (t, e, n, i) { var r, a; for (r in ((e.sample_groups = []), i)) { var s; if ( ((e.sample_groups[r] = {}), (e.sample_groups[r].grouping_type = i[r].grouping_type), (e.sample_groups[r].grouping_type_parameter = i[r].grouping_type_parameter), n >= i[r].last_sample_in_run && (i[r].last_sample_in_run < 0 && (i[r].last_sample_in_run = 0), i[r].entry_index++, i[r].entry_index <= i[r].sbgp.entries.length - 1 && (i[r].last_sample_in_run += i[r].sbgp.entries[i[r].entry_index].sample_count)), i[r].entry_index <= i[r].sbgp.entries.length - 1 ? (e.sample_groups[r].group_description_index = i[r].sbgp.entries[i[r].entry_index].group_description_index) : (e.sample_groups[r].group_description_index = -1), 0 !== e.sample_groups[r].group_description_index) ) (s = i[r].fragment_description ? i[r].fragment_description : i[r].description), e.sample_groups[r].group_description_index > 0 ? ((a = e.sample_groups[r].group_description_index > 65535 ? (e.sample_groups[r].group_description_index >> 16) - 1 : e.sample_groups[r].group_description_index - 1), s && a >= 0 && (e.sample_groups[r].description = s.entries[a])) : s && s.version >= 2 && s.default_group_description_index > 0 && (e.sample_groups[r].description = s.entries[s.default_group_description_index - 1]); } }), (f.process_sdtp = function (t, e, n) { e && (t ? ((e.is_leading = t.is_leading[n]), (e.depends_on = t.sample_depends_on[n]), (e.is_depended_on = t.sample_is_depended_on[n]), (e.has_redundancy = t.sample_has_redundancy[n])) : ((e.is_leading = 0), (e.depends_on = 0), (e.is_depended_on = 0), (e.has_redundancy = 0))); }), (f.prototype.buildSampleLists = function () { var t, e; for (t = 0; t < this.moov.traks.length; t++) (e = this.moov.traks[t]), this.buildTrakSampleLists(e); }), (f.prototype.buildTrakSampleLists = function (t) { var e, n, i, r, a, s, o, l, d, c, u, h, p, m, g, y, A, v, b, E, w, x, S, _; if ( ((t.samples = []), (t.samples_duration = 0), (t.samples_size = 0), (n = t.mdia.minf.stbl.stco || t.mdia.minf.stbl.co64), (i = t.mdia.minf.stbl.stsc), (r = t.mdia.minf.stbl.stsz || t.mdia.minf.stbl.stz2), (a = t.mdia.minf.stbl.stts), (s = t.mdia.minf.stbl.ctts), (o = t.mdia.minf.stbl.stss), (l = t.mdia.minf.stbl.stsd), (d = t.mdia.minf.stbl.subs), (h = t.mdia.minf.stbl.stdp), (c = t.mdia.minf.stbl.sbgps), (u = t.mdia.minf.stbl.sgpds), (v = -1), (b = -1), (E = -1), (w = -1), (x = 0), (S = 0), (_ = 0), f.initSampleGroups(t, null, c, u), void 0 !== r) ) { for (e = 0; e < r.sample_sizes.length; e++) { var T = {}; (T.number = e), (T.track_id = t.tkhd.track_id), (T.timescale = t.mdia.mdhd.timescale), (T.alreadyRead = 0), (t.samples[e] = T), (T.size = r.sample_sizes[e]), (t.samples_size += T.size), 0 === e ? ((m = 1), (p = 0), (T.chunk_index = m), (T.chunk_run_index = p), (A = i.samples_per_chunk[p]), (y = 0), (g = p + 1 < i.first_chunk.length ? i.first_chunk[p + 1] - 1 : 1 / 0)) : e < A ? ((T.chunk_index = m), (T.chunk_run_index = p)) : (m++, (T.chunk_index = m), (y = 0), m <= g || (g = ++p + 1 < i.first_chunk.length ? i.first_chunk[p + 1] - 1 : 1 / 0), (T.chunk_run_index = p), (A += i.samples_per_chunk[p])), (T.description_index = i.sample_description_index[T.chunk_run_index] - 1), (T.description = l.entries[T.description_index]), (T.offset = n.chunk_offsets[T.chunk_index - 1] + y), (y += T.size), e > v && (b++, v < 0 && (v = 0), (v += a.sample_counts[b])), e > 0 ? ((t.samples[e - 1].duration = a.sample_deltas[b]), (t.samples_duration += t.samples[e - 1].duration), (T.dts = t.samples[e - 1].dts + t.samples[e - 1].duration)) : (T.dts = 0), s ? (e >= E && (w++, E < 0 && (E = 0), (E += s.sample_counts[w])), (T.cts = t.samples[e].dts + s.sample_offsets[w])) : (T.cts = T.dts), o ? (e == o.sample_numbers[x] - 1 ? ((T.is_sync = !0), x++) : ((T.is_sync = !1), (T.degradation_priority = 0)), d && d.entries[S].sample_delta + _ == e + 1 && ((T.subsamples = d.entries[S].subsamples), (_ += d.entries[S].sample_delta), S++)) : (T.is_sync = !0), f.process_sdtp(t.mdia.minf.stbl.sdtp, T, T.number), (T.degradation_priority = h ? h.priority[e] : 0), d && d.entries[S].sample_delta + _ == e && ((T.subsamples = d.entries[S].subsamples), (_ += d.entries[S].sample_delta)), (c.length > 0 || u.length > 0) && f.setSampleGroupProperties(t, T, e, t.sample_groups_info); } e > 0 && ((t.samples[e - 1].duration = Math.max(t.mdia.mdhd.duration - t.samples[e - 1].dts, 0)), (t.samples_duration += t.samples[e - 1].duration)); } }), (f.prototype.updateSampleLists = function () { var t, e, n, i, r, a, s, o, l, d, u, h, p, m, g; if (void 0 !== this.moov) for (; this.lastMoofIndex < this.moofs.length;) if (((l = this.moofs[this.lastMoofIndex]), this.lastMoofIndex++, "moof" == l.type)) for (d = l, t = 0; t < d.trafs.length; t++) { for ( u = d.trafs[t], h = this.getTrackById(u.tfhd.track_id), p = this.getTrexById(u.tfhd.track_id), i = u.tfhd.flags & c.TFHD_FLAG_SAMPLE_DESC ? u.tfhd.default_sample_description_index : p ? p.default_sample_description_index : 1, r = u.tfhd.flags & c.TFHD_FLAG_SAMPLE_DUR ? u.tfhd.default_sample_duration : p ? p.default_sample_duration : 0, a = u.tfhd.flags & c.TFHD_FLAG_SAMPLE_SIZE ? u.tfhd.default_sample_size : p ? p.default_sample_size : 0, s = u.tfhd.flags & c.TFHD_FLAG_SAMPLE_FLAGS ? u.tfhd.default_sample_flags : p ? p.default_sample_flags : 0, u.sample_number = 0, u.sbgps.length > 0 && f.initSampleGroups(h, u, u.sbgps, h.mdia.minf.stbl.sgpds, u.sgpds), e = 0; e < u.truns.length; e++ ) { var y = u.truns[e]; for (n = 0; n < y.sample_count; n++) { ((m = {}).moof_number = this.lastMoofIndex), (m.number_in_traf = u.sample_number), u.sample_number++, (m.number = h.samples.length), (u.first_sample_index = h.samples.length), h.samples.push(m), (m.track_id = h.tkhd.track_id), (m.timescale = h.mdia.mdhd.timescale), (m.description_index = i - 1), (m.description = h.mdia.minf.stbl.stsd.entries[m.description_index]), (m.size = a), y.flags & c.TRUN_FLAGS_SIZE && (m.size = y.sample_size[n]), (h.samples_size += m.size), (m.duration = r), y.flags & c.TRUN_FLAGS_DURATION && (m.duration = y.sample_duration[n]), (h.samples_duration += m.duration), h.first_traf_merged || n > 0 ? (m.dts = h.samples[h.samples.length - 2].dts + h.samples[h.samples.length - 2].duration) : (u.tfdt ? (m.dts = u.tfdt.baseMediaDecodeTime) : (m.dts = 0), (h.first_traf_merged = !0)), (m.cts = m.dts), y.flags & c.TRUN_FLAGS_CTS_OFFSET && (m.cts = m.dts + y.sample_composition_time_offset[n]), (g = s), y.flags & c.TRUN_FLAGS_FLAGS ? (g = y.sample_flags[n]) : 0 === n && y.flags & c.TRUN_FLAGS_FIRST_FLAG && (g = y.first_sample_flags), (m.is_sync = !((g >> 16) & 1)), (m.is_leading = (g >> 26) & 3), (m.depends_on = (g >> 24) & 3), (m.is_depended_on = (g >> 22) & 3), (m.has_redundancy = (g >> 20) & 3), (m.degradation_priority = 65535 & g); var A = !!(u.tfhd.flags & c.TFHD_FLAG_BASE_DATA_OFFSET), v = !!(u.tfhd.flags & c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF), b = !!(y.flags & c.TRUN_FLAGS_DATA_OFFSET), E = 0; (E = A ? u.tfhd.base_data_offset : v || 0 === e ? d.start : o), (m.offset = 0 === e && 0 === n ? (b ? E + y.data_offset : E) : o), (o = m.offset + m.size), (u.sbgps.length > 0 || u.sgpds.length > 0 || h.mdia.minf.stbl.sbgps.length > 0 || h.mdia.minf.stbl.sgpds.length > 0) && f.setSampleGroupProperties(h, m, m.number_in_traf, u.sample_groups_info); } } if (u.subs) { h.has_fragment_subsamples = !0; var w = u.first_sample_index; for (e = 0; e < u.subs.entries.length; e++) (w += u.subs.entries[e].sample_delta), ((m = h.samples[w - 1]).subsamples = u.subs.entries[e].subsamples); } } }), (f.prototype.getSample = function (t, e) { var n, i = t.samples[e]; if (!this.moov) return null; if (i.data) { if (i.alreadyRead == i.size) return i; } else (i.data = new Uint8Array(i.size)), (i.alreadyRead = 0), (this.samplesDataSize += i.size), r.debug( "ISOFile", "Allocating sample #" + e + " on track #" + t.tkhd.track_id + " of size " + i.size + " (total: " + this.samplesDataSize + ")" ); for (; ;) { var a = this.stream.findPosition(!0, i.offset + i.alreadyRead, !1); if (!(a > -1)) return null; var o = (n = this.stream.buffers[a]).byteLength - (i.offset + i.alreadyRead - n.fileStart); if (i.size - i.alreadyRead <= o) return ( r.debug( "ISOFile", "Getting sample #" + e + " data (alreadyRead: " + i.alreadyRead + " offset: " + (i.offset + i.alreadyRead - n.fileStart) + " read size: " + (i.size - i.alreadyRead) + " full size: " + i.size + ")" ), s.memcpy( i.data.buffer, i.alreadyRead, n, i.offset + i.alreadyRead - n.fileStart, i.size - i.alreadyRead ), (n.usedBytes += i.size - i.alreadyRead), this.stream.logBufferLevel(), (i.alreadyRead = i.size), i ); if (0 === o) return null; r.debug( "ISOFile", "Getting sample #" + e + " partial data (alreadyRead: " + i.alreadyRead + " offset: " + (i.offset + i.alreadyRead - n.fileStart) + " read size: " + o + " full size: " + i.size + ")" ), s.memcpy(i.data.buffer, i.alreadyRead, n, i.offset + i.alreadyRead - n.fileStart, o), (i.alreadyRead += o), (n.usedBytes += o), this.stream.logBufferLevel(); } }), (f.prototype.releaseSample = function (t, e) { var n = t.samples[e]; return n.data ? ((this.samplesDataSize -= n.size), (n.data = null), (n.alreadyRead = 0), n.size) : 0; }), (f.prototype.getAllocatedSampleDataSize = function () { return this.samplesDataSize; }), (f.prototype.getCodecs = function () { var t, e = ""; for (t = 0; t < this.moov.traks.length; t++) { t > 0 && (e += ","), (e += this.moov.traks[t].mdia.minf.stbl.stsd.entries[0].getCodec()); } return e; }), (f.prototype.getTrexById = function (t) { var e; if (!this.moov || !this.moov.mvex) return null; for (e = 0; e < this.moov.mvex.trexs.length; e++) { var n = this.moov.mvex.trexs[e]; if (n.track_id == t) return n; } return null; }), (f.prototype.getTrackById = function (t) { if (void 0 === this.moov) return null; for (var e = 0; e < this.moov.traks.length; e++) { var n = this.moov.traks[e]; if (n.tkhd.track_id == t) return n; } return null; }), (f.prototype.items = []), (f.prototype.itemsDataSize = 0), (f.prototype.flattenItemInfo = function () { var t, e, n, i = this.items, a = this.meta; if (null != a && void 0 !== a.hdlr && void 0 !== a.iinf) { for (t = 0; t < a.iinf.item_infos.length; t++) ((n = {}).id = a.iinf.item_infos[t].item_ID), (i[n.id] = n), (n.ref_to = []), (n.name = a.iinf.item_infos[t].item_name), a.iinf.item_infos[t].protection_index > 0 && (n.protection = a.ipro.protections[a.iinf.item_infos[t].protection_index - 1]), a.iinf.item_infos[t].item_type ? (n.type = a.iinf.item_infos[t].item_type) : (n.type = "mime"), (n.content_type = a.iinf.item_infos[t].content_type), (n.content_encoding = a.iinf.item_infos[t].content_encoding); if (a.iloc) for (t = 0; t < a.iloc.items.length; t++) { var s = a.iloc.items[t]; switch ( ((n = i[s.item_ID]), 0 !== s.data_reference_index && (r.warn("Item storage with reference to other files: not supported"), (n.source = a.dinf.boxes[s.data_reference_index - 1])), s.construction_method) ) { case 0: break; case 1: case 2: r.warn("Item storage with construction_method : not supported"); } for (n.extents = [], n.size = 0, e = 0; e < s.extents.length; e++) (n.extents[e] = {}), (n.extents[e].offset = s.extents[e].extent_offset + s.base_offset), (n.extents[e].length = s.extents[e].extent_length), (n.extents[e].alreadyRead = 0), (n.size += n.extents[e].length); } if ((a.pitm && (i[a.pitm.item_id].primary = !0), a.iref)) for (t = 0; t < a.iref.references.length; t++) { var o = a.iref.references[t]; for (e = 0; e < o.references.length; e++) i[o.from_item_ID].ref_to.push({ type: o.type, id: o.references[e] }); } if (a.iprp) for (var l = 0; l < a.iprp.ipmas.length; l++) { var d = a.iprp.ipmas[l]; for (t = 0; t < d.associations.length; t++) { var c = d.associations[t]; for ( void 0 === (n = i[c.id]).properties && ((n.properties = {}), (n.properties.boxes = [])), e = 0; e < c.props.length; e++ ) { var u = c.props[e]; if (u.property_index > 0 && u.property_index - 1 < a.iprp.ipco.boxes.length) { var h = a.iprp.ipco.boxes[u.property_index - 1]; (n.properties[h.type] = h), n.properties.boxes.push(h); } } } } } }), (f.prototype.getItem = function (t) { var e, n; if (!this.meta) return null; if (!(n = this.items[t]).data && n.size) (n.data = new Uint8Array(n.size)), (n.alreadyRead = 0), (this.itemsDataSize += n.size), r.debug( "ISOFile", "Allocating item #" + t + " of size " + n.size + " (total: " + this.itemsDataSize + ")" ); else if (n.alreadyRead === n.size) return n; for (var i = 0; i < n.extents.length; i++) { var a = n.extents[i]; if (a.alreadyRead !== a.length) { var o = this.stream.findPosition(!0, a.offset + a.alreadyRead, !1); if (!(o > -1)) return null; var l = (e = this.stream.buffers[o]).byteLength - (a.offset + a.alreadyRead - e.fileStart); if (!(a.length - a.alreadyRead <= l)) return ( r.debug( "ISOFile", "Getting item #" + t + " extent #" + i + " partial data (alreadyRead: " + a.alreadyRead + " offset: " + (a.offset + a.alreadyRead - e.fileStart) + " read size: " + l + " full extent size: " + a.length + " full item size: " + n.size + ")" ), s.memcpy(n.data.buffer, n.alreadyRead, e, a.offset + a.alreadyRead - e.fileStart, l), (a.alreadyRead += l), (n.alreadyRead += l), (e.usedBytes += l), this.stream.logBufferLevel(), null ); r.debug( "ISOFile", "Getting item #" + t + " extent #" + i + " data (alreadyRead: " + a.alreadyRead + " offset: " + (a.offset + a.alreadyRead - e.fileStart) + " read size: " + (a.length - a.alreadyRead) + " full extent size: " + a.length + " full item size: " + n.size + ")" ), s.memcpy( n.data.buffer, n.alreadyRead, e, a.offset + a.alreadyRead - e.fileStart, a.length - a.alreadyRead ), (e.usedBytes += a.length - a.alreadyRead), this.stream.logBufferLevel(), (n.alreadyRead += a.length - a.alreadyRead), (a.alreadyRead = a.length); } } return n.alreadyRead === n.size ? n : null; }), (f.prototype.releaseItem = function (t) { var e = this.items[t]; if (e.data) { (this.itemsDataSize -= e.size), (e.data = null), (e.alreadyRead = 0); for (var n = 0; n < e.extents.length; n++) { e.extents[n].alreadyRead = 0; } return e.size; } return 0; }), (f.prototype.processItems = function (t) { for (var e in this.items) { var n = this.items[e]; this.getItem(n.id), t && !n.sent && (t(n), (n.sent = !0), (n.data = null)); } }), (f.prototype.hasItem = function (t) { for (var e in this.items) { var n = this.items[e]; if (n.name === t) return n.id; } return -1; }), (f.prototype.getMetaHandler = function () { return this.meta ? this.meta.hdlr.handler : null; }), (f.prototype.getPrimaryItem = function () { return this.meta && this.meta.pitm ? this.getItem(this.meta.pitm.item_id) : null; }), (f.prototype.itemToFragmentedTrackFile = function (t) { var e = t || {}, n = null; if (null == (n = e.itemId ? this.getItem(e.itemId) : this.getPrimaryItem())) return null; var i = new f(); i.discardMdatData = !1; var r = { type: n.type, description_boxes: n.properties.boxes }; n.properties.ispe && ((r.width = n.properties.ispe.image_width), (r.height = n.properties.ispe.image_height)); var a = i.addTrack(r); return a ? (i.addSample(a, n.data), i) : null; }), (f.prototype.write = function (t) { for (var e = 0; e < this.boxes.length; e++) this.boxes[e].write(t); }), (f.prototype.createFragment = function (t, e, n) { var i = this.getTrackById(t), a = this.getSample(i, e); if (null == a) return this.setNextSeekPositionFromSample(i.samples[e]), null; var o = n || new s(); o.endianness = s.BIG_ENDIAN; var l = this.createSingleSampleMoof(a); l.write(o), (l.trafs[0].truns[0].data_offset = l.size + 8), r.debug("MP4Box", "Adjusting data_offset with new value " + l.trafs[0].truns[0].data_offset), o.adjustUint32(l.trafs[0].truns[0].data_offset_position, l.trafs[0].truns[0].data_offset); var d = new c.mdatBox(); return (d.data = a.data), d.write(o), o; }), (f.writeInitializationSegment = function (t, e, n, i) { var a; r.debug("ISOFile", "Generating initialization segment"); var o = new s(); (o.endianness = s.BIG_ENDIAN), t.write(o); var l = e.add("mvex"); for (n && l.add("mehd").set("fragment_duration", n), a = 0; a < e.traks.length; a++) l.add("trex") .set("track_id", e.traks[a].tkhd.track_id) .set("default_sample_description_index", 1) .set("default_sample_duration", i) .set("default_sample_size", 0) .set("default_sample_flags", 65536); return e.write(o), o.buffer; }), (f.prototype.save = function (t) { var e = new s(); (e.endianness = s.BIG_ENDIAN), this.write(e), e.save(t); }), (f.prototype.getBuffer = function () { var t = new s(); return (t.endianness = s.BIG_ENDIAN), this.write(t), t.buffer; }), (f.prototype.initializeSegmentation = function () { var t, e, n, i; for ( null === this.onSegment && r.warn("MP4Box", "No segmentation callback set!"), this.isFragmentationInitialized || ((this.isFragmentationInitialized = !0), (this.nextMoofNumber = 0), this.resetTables()), e = [], t = 0; t < this.fragmentedTracks.length; t++ ) { var a = new c.moovBox(); (a.mvhd = this.moov.mvhd), a.boxes.push(a.mvhd), (n = this.getTrackById(this.fragmentedTracks[t].id)), a.boxes.push(n), a.traks.push(n), ((i = {}).id = n.tkhd.track_id), (i.user = this.fragmentedTracks[t].user), (i.buffer = f.writeInitializationSegment( this.ftyp, a, this.moov.mvex && this.moov.mvex.mehd ? this.moov.mvex.mehd.fragment_duration : void 0, this.moov.traks[t].samples.length > 0 ? this.moov.traks[t].samples[0].duration : 0 )), e.push(i); } return e; }), (c.Box.prototype.printHeader = function (t) { (this.size += 8), this.size > o && (this.size += 8), "uuid" === this.type && (this.size += 16), t.log(t.indent + "size:" + this.size), t.log(t.indent + "type:" + this.type); }), (c.FullBox.prototype.printHeader = function (t) { (this.size += 4), c.Box.prototype.printHeader.call(this, t), t.log(t.indent + "version:" + this.version), t.log(t.indent + "flags:" + this.flags); }), (c.Box.prototype.print = function (t) { this.printHeader(t); }), (c.ContainerBox.prototype.print = function (t) { this.printHeader(t); for (var e = 0; e < this.boxes.length; e++) if (this.boxes[e]) { var n = t.indent; (t.indent += " "), this.boxes[e].print(t), (t.indent = n); } }), (f.prototype.print = function (t) { t.indent = ""; for (var e = 0; e < this.boxes.length; e++) this.boxes[e] && this.boxes[e].print(t); }), (c.mvhdBox.prototype.print = function (t) { c.FullBox.prototype.printHeader.call(this, t), t.log(t.indent + "creation_time: " + this.creation_time), t.log(t.indent + "modification_time: " + this.modification_time), t.log(t.indent + "timescale: " + this.timescale), t.log(t.indent + "duration: " + this.duration), t.log(t.indent + "rate: " + this.rate), t.log(t.indent + "volume: " + (this.volume >> 8)), t.log(t.indent + "matrix: " + this.matrix.join(", ")), t.log(t.indent + "next_track_id: " + this.next_track_id); }), (c.tkhdBox.prototype.print = function (t) { c.FullBox.prototype.printHeader.call(this, t), t.log(t.indent + "creation_time: " + this.creation_time), t.log(t.indent + "modification_time: " + this.modification_time), t.log(t.indent + "track_id: " + this.track_id), t.log(t.indent + "duration: " + this.duration), t.log(t.indent + "volume: " + (this.volume >> 8)), t.log(t.indent + "matrix: " + this.matrix.join(", ")), t.log(t.indent + "layer: " + this.layer), t.log(t.indent + "alternate_group: " + this.alternate_group), t.log(t.indent + "width: " + this.width), t.log(t.indent + "height: " + this.height); }); var m = { createFile: function (t, e) { var n = void 0 === t || t, i = new f(e); return (i.discardMdatData = !n), i; } }; t.createFile = m.createFile; })({}); var Ch, Lh, Ih = function () { var t; self.onmessage = function (e) { "start" === e.data.event && (self.clearInterval(t), (t = self.setInterval(function () { self.postMessage({}); }, 16.6))), "stop" === e.data.event && self.clearInterval(t); }; }, Rh = new Map(), Dh = 1; ((Ch = new Blob(["(".concat(Ih.toString(), ")()")])), (Lh = URL.createObjectURL(Ch)), new Worker(Lh)).onmessage = function () { Dh += 1; var t, e = (function (t, e) { var n = ("undefined" != typeof Symbol && t[Symbol.iterator]) || t["@@iterator"]; if (!n) { if (Array.isArray(t) || (n = w(t)) || e) { n && (t = n); var i = 0, r = function () { }; return { s: r, n: function () { return i >= t.length ? { done: !0 } : { done: !1, value: t[i++] }; }, e: function (t) { throw t; }, f: r }; } throw new TypeError( "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ); } var a, s = !0, o = !1; return { s: function () { n = n.call(t); }, n: function () { var t = n.next(); return (s = t.done), t; }, e: function (t) { (o = !0), (a = t); }, f: function () { try { s || null == n.return || n.return(); } finally { if (o) throw a; } } }; })(Rh.entries()); try { for (e.s(); !(t = e.n()).done;) { var n = b(t.value, 2), i = n[0], r = n[1]; Dh % i == 0 && r.forEach(function (t) { return t(); }); } } catch (t) { e.e(t); } finally { e.f(); } }; var Bh = new To(), Ph = m(function t() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, n = e.emitter, i = e.logger; f(this, t), g(this, "Logger", Bh), g(this, "Emitter", void 0), n && (this.Emitter = n), i && (this.Logger = i); }), Uh = (function (t) { function e(t) { var i, r = t.emitter, a = t.Player; return ( f(this, e), ((i = n(this, e, [{ emitter: r }])).Player = a), (i.TimerController = a.TimerController), (i.Canvas = a.Canvas), (i.seekTime = null), (i.decodedTime = 0), (i.videoFrames = []), i.Emitter.on(mh, i.playing.bind(i)), i.Emitter.on("videoFrame", i.onVideoFrame.bind(i)), i.Emitter.on("decodeSeek", function (t) { i.Logger.log("decodeSeek", t, i.seekTime), i.seekTime === t && (i.seekTime = null); }), i ); } return ( y(e, t), m(e, [ { key: "seek", value: function (t) { var e = 1e6 * t, n = this.videoFrames.findIndex(function (t) { var n = t.timestamp, i = t.duration; return e >= n && e < n + (i || 5e4); }); if (n >= 0) { for (var i = 0; i < n; i++) { var r, a = this.videoFrames.shift(); a.close ? a.close() : null === (r = a.imageBitmap) || void 0 === r || r.close(); } return this.Logger.log("onSeek::找到视频帧"), void this.Emitter.emit(hh, "video"); } (this.seekTime = t), this.cleanVideoFrames(), this.Player.WorkerController.seek(t); } }, { key: "playing", value: ((a = p( d().mark(function t(e) { var n; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: return (t.next = 2), this.tick(1e6 * this.Player.currentTime); case 2: if ((n = t.sent)) { t.next = 5; break; } return t.abrupt("return"); case 5: if (!n.imageBitmap) { t.next = 10; break; } return (t.next = 8), this.Canvas.drawImage(n); case 8: t.next = 12; break; case 10: return (t.next = 12), this.Canvas.draw(n); case 12: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return a.apply(this, arguments); }) }, { key: "onVideoFrame", value: function (t) { if (null == this.seekTime) { this.videoFrames.push(t); var e = (t.timestamp + t.duration) / 1e6; if (((this.decodedTime = e), !this.Player.videoReady)) { var n = Math.min(1.9, this.Player.duration - this.Player.currentTime); e - this.Player.currentTime >= n && this.Emitter.emit(hh, "video"); } } else { var i; t.close ? t.close() : null === (i = t.imageBitmap) || void 0 === i || i.close(); } } }, { key: "tick", value: ((r = p( d().mark(function t(e) { var n, i, r, a, s; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (0 != this.videoFrames.length) { t.next = 3; break; } return this.Emitter.emit(ch, "video"), t.abrupt("return"); case 3: if ( ((n = this.videoFrames[0]), (i = n.timestamp), (r = n.duration), !(e < i)) ) { t.next = 7; break; } return t.abrupt("return"); case 7: if (!(e > i + r)) { t.next = 12; break; } (this.missCount = (this.missCount || 0) + 1), this.Logger.warn("tick::该帧时间已过", e, i, this.missCount); try { (s = this.videoFrames.shift()).close ? s.close() : null === (a = s.imageBitmap) || void 0 === a || a.close(); } catch (t) { this.Logger.warn("tick::error::", e, i, t); } return t.abrupt("return", this.tick(e)); case 12: return t.abrupt("return", this.videoFrames.shift()); case 13: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return r.apply(this, arguments); }) }, { key: "cleanVideoFrames", value: ((i = p( d().mark(function t() { var e, n, i; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (0 != (e = this.videoFrames.length)) { t.next = 3; break; } return t.abrupt("return"); case 3: for (; e > 0;) (i = this.videoFrames.shift()).close ? i.close() : null === (n = i.imageBitmap) || void 0 === n || n.close(), e--; (this.decodedTime = 0), console.log("cleanVideoFrames", this.videoFrames.length); case 6: case "end": return t.stop(); } }, t, this ); }) )), function () { return i.apply(this, arguments); }) }, { key: "destroy", value: function () { clearInterval(this.onPlayTimer), this.cleanVideoFrames(), (this.Player = null), (this.FrameController = null), (this.TimerController = null), (this.Canvas = null); } } ]) ); var i, r, a; })(Ph), Fh = new WeakMap(), Oh = new WeakMap(), Mh = new WeakMap(), Nh = new WeakMap(), zh = new WeakMap(), Gh = new WeakMap(), jh = new WeakMap(), Hh = new WeakMap(), Yh = new WeakMap(), $h = new WeakMap(), Kh = new WeakMap(), qh = new WeakMap(), Vh = new WeakSet(), Wh = (function (t) { function i(t) { var s, o, l, c = t.Player, u = t.emitter; return ( f(this, i), (s = n(this, i, [{ emitter: u }])), S((o = s), (l = Vh)), l.add(o), _(s, Fh, []), _(s, Oh, null), _(s, Mh, null), _(s, Nh, null), _(s, zh, !1), _(s, Gh, 0), _(s, jh, 0), _(s, Hh, 0), _(s, Yh, null), _(s, $h, 1), _(s, Kh, !1), _(s, qh, {}), g(s, "isFirstPlay", !0), g(s, "temp3", 0), (s.Player = c), s.Emitter.on( "demux-audio", (function () { var t = p( d().mark(function t(n) { var i, o; return d().wrap(function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: return (t.next = 2), e(Vh, s, Qh).call(s, n.aacData.buffer); case 2: if ( ((i = t.sent), (o = { decodedBuffer: i, duration: n.duration, startTime: n.startTime, reallyStartTime: n.reallyStartTime }), r(Fh, s).push(o), !( null !== r(Nh, s) && r(Nh, s) >= n.startTime && r(Nh, s) < n.startTime + n.duration )) ) { t.next = 9; break; } return ( a(jh, s, r(Nh, s) - n.startTime), s.Emitter.emit(hh, "audio"), t.abrupt("return") ); case 9: !s.Player.audioReady && o.startTime >= s.currentTime && s.currentTime < o.startTime + o.duration && (s.Logger.log("audio::正常播放恢复", s.currentTime, s.paused), s.Emitter.emit(hh, "audio")); case 10: case "end": return t.stop(); } }, t); }) ); return function (e) { return t.apply(this, arguments); }; })() ), s.Emitter.on(uh, function (t) { var e; if (r(Fh, s)) { s.pause(), (s.temp3 = 0), r(Mh, s) && ((r(Mh, s).onended = null), r(Mh, s).stop()), a(Nh, s, t), a(Hh, s, t - ((null === (e = r(Oh, s)) || void 0 === e ? void 0 : e.currentTime) || 0)); var n = r(qh, s) || {}, i = n.startTime, o = n.duration; i <= t && t < i + o ? (a(jh, s, r(Nh, s) - i), s.Emitter.emit(hh, "audio")) : r(Fh, s).forEach(function (e, n) { if (e) { var i = e.startTime, o = e.duration; e.decodedBuffer && i <= t && t < i + o && (a(jh, s, r(Nh, s) - i), s.Emitter.emit(hh, "audio")); } }), a(Fh, s, []); } }), s ); } return ( y(i, t), m(i, [ { key: "play", value: ((s = p( d().mark(function t() { var n, i, s = this; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if ( (r(Oh, this) || (a(Oh, this, new AudioContext()), a(Yh, this, r(Oh, this).createGain())), r(Kh, this) || !r(Oh, this).currentTime || !this.paused) ) { t.next = 5; break; } if (null !== r(Nh, this)) { t.next = 5; break; } return r(Oh, this).resume(), t.abrupt("return"); case 5: if (!(this.currentTime >= this.Player.duration - 1)) { t.next = 8; break; } return this.Emitter.emit(gh), t.abrupt("return"); case 8: if (e(Vh, this, Xh).call(this)) { t.next = 10; break; } return t.abrupt("return"); case 10: this.isFirstPlay && (this.muted = this.Player.config.muted), (this.isFirstPlay = !1), r(Mh, this).start(0, r(jh, this)), (i = ((null === (n = r(Oh, this)) || void 0 === n ? void 0 : n.currentTime) || 0) + r(Hh, this)), (this.temp3 = i - r(qh, this).reallyStartTime), this.paused && r(Oh, this).resume(), a(jh, this, 0), a(zh, this, !0), a(Kh, this, !1), (r(Mh, this).onended = p( d().mark(function t() { return d().wrap(function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (!r(Nh, s) && 0 !== r(Nh, s)) { t.next = 2; break; } return t.abrupt("return"); case 2: return (t.next = 4), s.play(); case 4: case "end": return t.stop(); } }, t); }) )), a(Nh, this, null); case 21: case "end": return t.stop(); } }, t, this ); }) )), function () { return s.apply(this, arguments); }) }, { key: "pause", value: function () { var t; "running" === (null === (t = r(Oh, this)) || void 0 === t ? void 0 : t.state) && r(Oh, this) .suspend() .then(function () { }); } }, { key: "reset", value: function () { var t; null === (t = r(Oh, this)) || void 0 === t || t.close(), a(Oh, this, null), a(Yh, this, null), a(Nh, this, null), a(jh, this, 0), a(Hh, this, 0), a(Kh, this, !1); } }, { key: "paused", get: function () { return !r(Oh, this) || "suspended" === r(Oh, this).state; } }, { key: "muted", get: function () { var t; return r(Yh, this) ? 0 === (null === (t = r(Yh, this)) || void 0 === t || null === (t = t.gain) || void 0 === t ? void 0 : t.value) : this.Player.config.muted; }, set: function (t) { var e; null !== (e = r(Yh, this)) && void 0 !== e && e.gain ? (r(Yh, this).gain.value = t ? 0 : 1) : (this.Player.config.muted = t); } }, { key: "currentTime", get: function () { var t; return r(Nh, this) ? r(Nh, this) : ((null === (t = r(Oh, this)) || void 0 === t ? void 0 : t.currentTime) || 0) + r(Hh, this) - this.temp3; } }, { key: "destroy", value: function () { var t, e; r(Fh, this).forEach(function (t) { null != t && t.decodedBuffer && (t.decodedBuffer = null); }), a(Fh, this, []), this.pause(), null === (t = r(Oh, this)) || void 0 === t || t.close(), null === (e = r(Yh, this)) || void 0 === e || e.disconnect(); } } ]) ); var s; })(Ph); function Qh(t) { var e = this; return new Promise(function (n, i) { var a = r(Oh, e) || new AudioContext(), s = t; a.decodeAudioData(s) .then(function (t) { n(t); }) .catch(function (t) { i(t); }); }); } function Xh() { if (r(Fh, this).length) { var t = r(Fh, this).shift(); if ((a(qh, this, t), t)) return ( a(Gh, this, t.startTime + t.duration), a(Mh, this, r(Oh, this).createBufferSource()), (r(Mh, this).buffer = t.decodedBuffer), r(Mh, this).connect(r(Yh, this)), r(Yh, this).connect(r(Oh, this).destination), !0 ); this.paused || (a(Kh, this, !0), this.Emitter.emit(ch, "audio")); } else this.Emitter.emit(ch, "audio"); } var Jh = (function () { return m( function t() { var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, n = e.canvas, i = e.width, r = e.height, a = e.emitter; if ((f(this, t), !n)) throw new Error("缺少canvas参数"); (this.Emitter = a), (this.width = i), (this.height = r), console.log("canvas init", i, r), (this.canvas = n), (this.canvas.width = 1280), (this.canvas.height = 960), (this.canvas.style.width = "100%"), (this.ctx = this.canvas.getContext("2d")); }, [ { key: "draw", value: ((r = p( d().mark(function t(e) { var n, i; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (e) { t.next = 2; break; } return t.abrupt("return"); case 2: return ( (n = e.displayWidth), (i = e.displayHeight), (n == this.canvas.width && i == this.canvas.height) || this.config({ width: n, height: i }), this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.drawImage(e, 0, 0, n, i), (t.next = 9), e.close() ); case 9: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return r.apply(this, arguments); }) }, { key: "getImageBitmap", value: ((i = p( d().mark(function t(e) { var n, i, r, a; return d().wrap(function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (e) { t.next = 2; break; } return t.abrupt("return"); case 2: return ( console.time("getImageBitmap".concat(e.timestamp)), (n = e.displayWidth), (i = e.displayHeight), (r = new OffscreenCanvas(n, i)).getContext("2d").drawImage(e, 0, 0, n, i), (t.next = 10), createImageBitmap(r) ); case 10: return ( (a = t.sent), console.timeEnd("getImageBitmap".concat(e.timestamp)), t.abrupt("return", a) ); case 13: case "end": return t.stop(); } }, t); }) )), function (t) { return i.apply(this, arguments); }) }, { key: "drawVideoFrameAppendBody", value: ((n = p( d().mark(function t(e) { var n, i, r, a; return d().wrap(function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (e) { t.next = 2; break; } return t.abrupt("return"); case 2: return ( (n = e.displayWidth), (i = e.displayHeight), (r = document.createElement("canvas")), (a = r.getContext("2d")), (r.width = n), (r.height = i), console.time("drawImage"), a.clearRect(0, 0, r.width, r.height), (r.style.width = "10%"), (r.style.border = "1px solid blue"), a.drawImage(e, 0, 0, n, i), console.timeEnd("drawImage"), document.getElementById("videoFrame").append(r), (t.next = 17), e.close() ); case 17: case "end": return t.stop(); } }, t); }) )), function (t) { return n.apply(this, arguments); }) }, { key: "drawImage", value: ((e = p( d().mark(function t(e) { var n, i, r; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (e) { t.next = 2; break; } return t.abrupt("return"); case 2: return ( (n = e.imageBitmap), (i = n.width), (r = n.height), (i == this.canvas.width && r == this.canvas.height) || this.config({ width: i, height: r }), this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.drawImage(n, 0, 0, i, r), (t.next = 10), n.close() ); case 10: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return e.apply(this, arguments); }) }, { key: "drawImageAppendBody", value: ((t = p( d().mark(function t(e) { var n, i, r, a, s; return d().wrap(function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (e) { t.next = 2; break; } return t.abrupt("return"); case 2: return ( (n = e.imageBitmap), (i = n.width), (r = n.height), (a = document.createElement("canvas")), (s = a.getContext("2d")), (a.width = i), (a.height = r), console.time("drawImage"), s.clearRect(0, 0, a.width, a.height), (a.style.width = "10%"), console.log("imageBitmap", n), s.drawImage(n, 0, 0, i, r), (s.fillStyle = "red"), (s.font = "250px serif"), s.fillText("".concat(e.timestamp / 1e6), 200, 240), (t.next = 19), n.close() ); case 19: console.timeEnd("drawImage"), document.body.append(a); case 21: case "end": return t.stop(); } }, t); }) )), function (e) { return t.apply(this, arguments); }) }, { key: "config", value: function (t) { var e = t.width, n = t.height; console.log("canvas::config::width: ".concat(e, ", height: ").concat(n)), (this.canvas.width = e), (this.canvas.height = n), this.updateCanvasStyle(), this.Emitter.emit(sh); } }, { key: "updateCanvasStyle", value: function () { var t = this.canvas; t.width / t.height > this.width / this.height ? ((this.canvas.style.width = "100%"), (this.canvas.style.height = "auto")) : ((this.canvas.style.width = "auto"), (this.canvas.style.height = "100%")); } }, { key: "drawImageBySrc", value: function (t) { var e = this; if (t) { var n = new Image(); (n.src = t), (n.onload = function () { var t = n.width, i = n.height; e.config({ width: t, height: i }), e.ctx.drawImage(n, 0, 0, t, i), (n = null); }), (n.onerror = function () { console.warn("视频封面加载失败"); }); } } }, { key: "destroy", value: function () { (this.ctx = null), this.canvas.remove(), (this.canvas = null); } } ] ); var t, e, n, i, r; })(), Zh = (function (t) { function e() { var t, i = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; f(this, e), (t = n(this, e, [{ emitter: i.emitter }])); var r = i.duration, a = void 0 === r ? 0 : r; return ( (t._currentTime = 0), (t.startTime = 0), (t.duration = 1e6 * a || 1 / 0), (t.waiting = !1), (t.paused = !0), (t.raf = null), t ); } return ( y(e, t), m(e, [ { key: "seek", value: function (t) { this.Logger.log("timer::onSeek", this.currentTime, t), this.stopTime(), (this.startTime = performance.now()), (this._currentTime = 1e6 * t); } }, { key: "reset", value: function () { this.Logger.log("timer::reset"), (this._currentTime = 0), (this.startTime = 0), (this.waiting = !1), (this.paused = !0); } }, { key: "run", value: function () { this.stopTime(), this.Emitter.emit(ph), (this.paused = !1), (this.waiting = !1), (this.startTime = performance.now()), this.updateTime(); } }, { key: "stop", value: function () { (this.paused = !0), this.Logger.warn("stop", this._currentTime), this.stopTime(); } }, { key: "stopTime", value: function () { (this.waiting = !0), this.Logger.warn("stopTime", this._currentTime, this.raf), cancelAnimationFrame(this.raf), (this.raf = null); } }, { key: "updateTime", value: function () { if (this.waiting) return ( this.Logger.warn("updateTime::waiting", this.waiting, this._currentTime), void this.stopTime() ); var t = performance.now(), e = 1e3 * (t - this.startTime); if ( ((this._currentTime += e), (this.startTime = t), this.Emitter.emit(mh, this._currentTime), this._currentTime >= this.duration) ) return ( this.Logger.log("playend::", this.currentTime, this.duration), this.Emitter.emit(gh), void this.stop() ); this.raf = requestAnimationFrame(this.updateTime.bind(this)); } }, { key: "currentTime", get: function () { return this._currentTime / 1e6; }, set: function (t) { this._currentTime = 1e6 * t; } }, { key: "ended", get: function () { return this._currentTime >= this.duration; } }, { key: "progress", get: function () { } } ]) ); })(Ph), tp = (function (e) { function i(e) { var r, a = e.emitter, s = e.Player; f(this, i), ((r = n(this, i, [{ emitter: a }])).Player = s); var o = "./worker/PlayerWorker.js"; if (s.config.workerUrl) { o = s.config.workerUrl; var l = location.pathname; if (l.includes(".")) { var d = l.lastIndexOf("/"); l = l.substring(0, d); } var c = l.endsWith("/") ? l : l + "/", u = new URL(o, location.origin + c).href; r.Logger.log("workerUrl::config:format", u), (r.worker = new Worker(u)); } else r.worker = new Worker( new URL( o, "undefined" == typeof document && "undefined" == typeof location ? require("url").pathToFileURL(__filename).href : "undefined" == typeof document ? location.href : (t && t.src) || new URL("VideoPlayer.1.3.0.umd.cjs", document.baseURI).href ), { type: "module" } ); return ( r.Logger.log("workerUrl", o), r.worker.addEventListener("error", function (t) { r.Logger.error("worker::error", t), r.Emitter.emit(yh, { fatal: !0, src: s.config.workerUrl, type: "workerError", data: "null", error: { message: "player worker error: 请检查workerUrl是否有误" } }); }), r.worker.addEventListener("message", function (t) { var e = t.data; r.workerHandler(e); }), r.Emitter.on(ih, function (t) { r.worker.postMessage({ event: ih, data: t }); }), r.Emitter.on(mh, function () { r.worker.postMessage({ event: mh, data: r.Player.currentTime }); }), r.Emitter.on(ph, function () { r.worker.postMessage({ event: ph, data: r.Player.currentTime }); }), r ); } return ( y(i, e), m(i, [ { key: "init", value: function (t) { this.worker.postMessage({ event: "init", data: t }); } }, { key: "workerHandler", value: function () { var t, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, n = e.event, i = e.data; switch (n) { case hh: case rh: case "videoFrame": case "decodeSeek": case "demux-audio": this.Emitter.emit(n, i); break; case "log": (t = this.Logger).log.apply(t, ["worker::"].concat(E(i))); } } }, { key: "changePlaylist", value: function (t) { this.worker.postMessage({ event: oh, data: t }); } }, { key: "seek", value: function (t) { this.worker.postMessage({ event: uh, data: t }); } }, { key: "destroy", value: function () { this.worker.terminate(); } } ]) ); })(Ph), ep = [], np = []; !(function (t, e) { if (t && "undefined" != typeof document) { var n, i = !0 === e.prepend ? "prepend" : "append", r = !0 === e.singleTag, a = "string" == typeof e.container ? document.querySelector(e.container) : document.getElementsByTagName("head")[0]; if (r) { var s = ep.indexOf(a); -1 === s && ((s = ep.push(a) - 1), (np[s] = {})), (n = np[s] && np[s][i] ? np[s][i] : (np[s][i] = o())); } else n = o(); 65279 === t.charCodeAt(0) && (t = t.substring(1)), n.styleSheet ? (n.styleSheet.cssText += t) : n.appendChild(document.createTextNode(t)); } function o() { var t = document.createElement("style"); if ((t.setAttribute("type", "text/css"), e.attributes)) for (var n = Object.keys(e.attributes), r = 0; r < n.length; r++) t.setAttribute(n[r], e.attributes[n[r]]); var s = "prepend" === i ? "afterbegin" : "beforeend"; return a.insertAdjacentElement(s, t), t; } })( '@font-face {\n font-family: "iconfont"; /* Project id 4258961 */\n src: url(\'data:font/woff2;base64,d09GMgABAAAAAAicAAsAAAAAETQAAAhOAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACEQgqTDI81ATYCJAM0CxwABCAFhGcHgUAbfw5RlDBSEtlXCeZmG6TvwTAGNqlQoUt5pIz0i3+ka4P/x/3YuW/bF0NcOqGT8AjREqWSaFoqqZFFk+cNj9v6d6ANRm/WbvP8TYzLxGr4URM3a0WZya4avaiGqyguIsYDz81+83kaeEKBJBIlEmYBh4X7xO758dYZA5Nr2W7LSYGSLbLQrXCVgRKqZ0psYqkEOP7VUQDO//1e/bUu6wKa2QB/1H11zv1RsSqqoGwfDei9RQbwAHdGkKI0C9uMWWoSwSyKt6c/+hgECqsGkpTa1Fzg1xAWFsDcsJlC2VxNcSEBvI5S3hAjGZG4HhqjHgRYJzkGXKQfrxfrgReYEMHOslmPKAC7XNbH9dIGsQHgLsS88TrQ5gYCcGBxZXINZu0Vl4PFFC1Ubb0zgHYBx7Pa9dzV4hrrmuFa5Pr0cMLjelEEXq3thDGuTkZdV8wt7UJ4QpiIf/IARnJBwvFSlVIhg1KAVuGAu5rs1SohdsPKABGwFkByYGMACcDGApIA6wTEAZsBiAe2CJAU2CcUosL7hEKU+KyDFMDqwfvnaqGO2/YDLAGuINkBWPgh4DnqiA238RTTGnUeGcVckbGw594GcYPyCtySh1BLRgYA+fm1uCIXwQWFpHmvgNoWOxDqyHOKMJS7ajuAuY5g9KHVntwFQJUZUASIHb0XhtSiCR532IFekBilPOKmps5xiyz0g9wPJi8jQ06zdsB/SDbygDezDkEXZPC74+FoAoWrW/8kw2AlGux+3dcjQN0H9gIh9eUo/3LZ8naQdYJ0yKf43OLueRlh7rLZzFdQYhbQBtRVnM5A3ba1VPkknXDn5WahJZEQcRJshuyG3opSKZkkt2YPiSDetafH3uIT93pHlBGjdmXEmZud81sbaDTYVrthutyDkDfazQR+en0Tm+hz1DSdGPDGyT2Nuq2dFH8rfQmaIPFh0KcJ+U/JQwJcxcKPUslha3GYCfIzIiUHdlQZYh2zTO43htwihQv29nuN6Ow0Vn9MOReG8rsHjz0on2ChfgjsHuQpN/O3DLH9RxFpOL9muwm/0yfiPaaHOor2livpxOVRHv1P/NJeOmWEJTYX7QIBwv45nP9BdxTEq9rRT/JR3UNqf09O4QFqvWz7zPkZxHvXyoYcT+wxMDemnOk5coO5mp+86Jf+EotDjVMa+kCCHINQ+fk80AUFe1yoURiVC5u22yEctve8eQn3PH+bg4faYwIh+6nX7AS158UahTC5cOigHUKjbQeNIMetzYpYfEzHHYsLCsc2O4xDdodDqItx7NMeDia/a0wmOBzt0V07z9EuwyGN7EIWuLE62OtCpbn9CLUPHbLBKGxLCAGHPIAwj0tl8Keuhw61y7C2uW4C7mEvgfDDIQKE/g92Bl3seB7ucUnBmdMCBcVUzBCNwdjpOqVgZE7zmZg1+f6e2dhzTB9/C5td3HZy1kSfiO+wIkw2XLTXP1zVfdWW6QJeOmn+764Dq3RVvNRJW8zn39eXTKq/k37cxzfybIdqb5QPTU7FmdHeEcmLxjtihCJxRMa6AxnrE4c/j9hJ9QrsRekz/r/68v9bx4e/aLzzPUIx5VeqZ59f86c+D99J9Q7sTTX0H9nZbzSIDoJwYDbMIYoJIJipnNSJgqT8deL5IFucLQjEtwkyHp7T3vjHPplOtm+3sf38sraW+Dt6Q/s40wJYt/r3PNgPXUa7gC9+BWpDj2RlRXGRpZwNdg6OdrqcoqbGJnItTijPyxNTyzXx/1CtNc44W9zRl2F6PinPJHPVBjF3uW55Ht1eB8T646HXQ+2hz0OPifRl/1kHLzWCh6YDM1nZ8/nnly5FyPVkxY1f/FT1Mz77BWRm7hurPUt9bhTVsctid8Uuj90vwa7yVpne5OLxJKh/nAu683HoyosBa+A8GInMhdcEXDyf5uPjzerhQ8zGALVEKwFHY5Q2VaiXkeCiUgcYO98I9DwbJRoPjTvmgQnTNT7lvmU+lO+GvDz/5QHL/JcF7C4MvRF2Q+ZdkmODgyKD9uamLI/VI7pYHYJsdnYbGT8yqNt9442fT/x8ktdtHN1FIVFL8EZbRqAabc8R3Xv0PBkkdMijq/pVRcs7hB79dpd2OKIdHbohK2/5OxPSCRuXX0OuLa/U3kYDgttWaJPuO+XoN2dnSjdVoJ9jVAroXbHvF1yE/ZP94YvZXgdDQP0fgPhhrFS2q/VujNQ3Mu966RmXBtrTCgCAmyQXA05UbALE93OkvkHas42Sm2kv/5cGpDW4Adf6d0+UDtpsbsa/fmvdf/7933n5fpI6HtOz0ogzj8DdSsZ0nBtvI+k7iEEUPxSHwLR1jEogw6PYqd0NeCNk1C41bgMFHwZbR2O7G/PgHc78bTLeUWaZ1ABwqoBx4BEwnxWU1kGCgI2swoIRR5c68KQU58C0ZmRJq6VZpnEPHAIOAo+Ai1lBtwcgQcC3rMJWID9daTowDDORhIUsQPIrkWIDx1KCsKRrzSYLrTRh6nLpSJO5GA5ErVA1qxNIljQNsYe5rBC3WCiEMnEMot1fjaRpDuFNXAlpsCiKLBa+r1JJqfZQGDgGDGNCIljivAUQ+SorFjPgsKihLfXPl41UyIpGMDnSdWoTc8iltSPUFFQO9ASUdepyJW3NyhTCWUhNQSQwEWByXHtXk2ju5SB49UYlSAYWCkU93Ly+lDQU5Yoq5seZPzjK365b9sXqwOTkFZQoVaZchUpVqtXQVltp2mwwkST7m7nIVMyWtkjICp5gC7zMnDW2ZVCUZyZlvXf+3ziK8srPyLrzhNVMykqK2cLKYvY3A8dXevHnhrSVxf3NnANgOrkDuz1pjih41nfjaaISAAA=\') format(\'woff2\'),\n url(\'data:font/woff;base64,d09GRgABAAAAAAroAAsAAAAAETQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADsAAABUIIslek9TLzIAAAFEAAAARAAAAGA8ik1PY21hcAAAAYgAAAC4AAACQvCwPtFnbHlmAAACQAAABjcAAAmMZjPOPmhlYWQAAAh4AAAAMQAAADYnuuaYaGhlYQAACKwAAAAgAAAAJAfdA45obXR4AAAIzAAAABYAAAA0NAH//mxvY2EAAAjkAAAAHAAAABwP/hJAbWF4cAAACQAAAAAfAAAAIAElAKFuYW1lAAAJIAAAAUAAAAJnEKM8sHBvc3QAAApgAAAAhQAAAMBzHFineJxjYGRgYOBiMGCwY2BycfMJYeDLSSzJY5BiYGGAAJA8MpsxJzM9kYEDxgPKsYBpDiBmg4gCACY7BUgAeJxjYGFhYJzAwMrAwNTJdIaBgaEfQjO+ZjBi5ACKMrAyM2AFAWmuKQwHnpW+qmdu+N/AwMB8hwFIMjCiKGICAH9HDVh4nOWSMQ6CQBBF/wIiKoUxxngID2cDJTa0kFBDYSw42g/hBlT4lyEx0SM4m7fJ/OzsbOYvgA2AUNxEBLgXHHx0Ut2ih9gveoS78hOOUgLmLFmzY89paMbHPAPMpFVsV63w2lc41Z+1LriuCwik7vSOWPdG2CLFQR0THY5/6v8v0mV/fjJmhuYG5oZ3iqWhWYKV4d1lbWi+YGt4x9kZ3nX2hqYPTobvNTSGHMFYGP43jA8DyRuCY0SKeJyNVWuIW0UUnkcyc99zk3tz03uzyc1jc9PddBM3m02q1a6vbq0v6qJtRRBbof5oq11a/LMI9YVWqahUofpDBX9UF0rBZ3EVHyhdsSJCqwXBx4/+KAqK1P6QzXom2d1itdUQzj1zzpyZ+b5zZg6KITR/lj5FDRSgUXQL2oEQLhWZ663CjXar3boCN6Miy+IKSDeNRxqtZlTFRc44GF2vARPSIJuVclSRjm4kB9kYw6mev4bbXlqu1w1tgywKPNpbNofxZXtNxzGPq0QQ4gTOO5rvaqT9d+NRNZfUOnWuxfg30rF3VnOy6lHXdzA5CFZ2omud0Vxfm3F8lxASgJOcc32gOYHWyS8Y+fHeKkrS136XW/juUc131NnetkQ91jO+pwWONtMzUgXBT/J1hu6jOsqgNppAkwg5SyTU/8FPfIm78DxaW1GZL5Dgps/jh+HmaOqCfFai50xnRs3CyR4zXNc4oRBDIS75yXRm1UCCWLAKQnGyw2YlIYpkQtr3zqpOmmCux9i33fGMmswpM0AywfiMHEtSuiQyI6ZAzOleUKAuLQSBxdnHzu0CrM4CfRh/iDGxqBzPSDoXzhcH0uj8/Pwb9Gt6E/JRHl0FVQYcCclJKiEhSgqAvNFEM6J1XEqMtIGJGoYplRrmFg6BhO6UMSxlezWu4D81jWmnXirV66WXToGqLcsX1rwQHjp0BD+xXWfhkL5xozmQtJmxbZvBhatnLDD0aW5CsehNlMQ/qZc6r0XDn8QJDQNa87JzaI+Pmwc6x/a7A2kupqZsVegD7v799pCuuVNTrmYMOCjWxfLzApaVcGv+G005YhJADrsM0MC30QIMzYgv2lPnOS6Gbqu9XNjEWbd+/TpBDO4mXL5p8+YvxYC0Dg4NDS5aL73i8osCnYT59oAYf+OzN9eIAZsrCl//3a8/rgEzLBbd07r07opYbnNV5cNPvrgP6p/KS0CnyTcohS5D44C83Wp4LsesGDXHZLJWEy8dBzTFCOC3VmFAA+gSroWjOu66Q5zgrBSPmq1GiD2YWaFoi1HyjXkk5ZYtCmd22lM6pt/v+8nJz1XfM03PV0+oKhVeWn36aUOQtuGXjKoUeGaL/EA0SIj20jbjyrrjSQjGKOm/ohAtZcy9bqQ0okzzVNpRYsou/Oou7ajcryoFWsJ2BLC5aADdDNjkEWUu5XUGfL2M9SB2M7lgjP4PXvKb7hfNiWxfX3bChB0vaTYPKozZnqf0Vyr9Rr9v5tPpTvJimCfNoq9P7Ny+fecEYDUveeDxB65TPM9mTOm/c+ud/UCYUdi0if4P6ACV9ECTaRAcofJIolRIjCQwmp7Gt03fRjbMvU42LLx5f9CX4c1TkQMVPwRzS4twywmX1XGi3fIcWQCyGAQUA13MbR1IxOhYKhemvsAoME+eNIP7hDgpBnPipFUVYhD0nBR7cil8IBXumKsIoTxE0MPcmvv9nBsPn4uC1MCZfqFvke9RFqF4sYZlo4L3snuqkULDgwywUgE6DcO3xA3F0qbCajUkn0rZOazyg9xhBt+miWqIPwxXrAg7V4ZV9gzr8TL/K72L2lDjNdgKVoL2tri4fMHLgFamP4Jdx7CsCoAJegvKguwJ7c77ln04iKLgsG3ha+zwh6tXkhjmmWw2w3GMrLyanJ5bkXTUQ0oU4HymrBxSnc4j1+4uYkLGCWaZtTeuzTAMOsHF3TJNFpxpTwzRB5GCEtCrS2gF9OvVaC1aj25H96D70aNoP+RFNhHZNLi3oC0ppUWlcmGlfWEFkHWbG7xxvDuCdwqGlb8P/9VLd5BYLE7pEzFNUTT+FhO6LvSPeMqyUtZrapBMBsmdeuh5oVcwyr5f9ketwWx2MPtQolYo1ApHnJFyudn/lRqY2eXLs2aguh9rfdk+zauGAuSzei6f05fVizbI641CMW8EI/2JguFPxlgM/gdiis65voEZtq7bivCE8G5VnYzjZJ43lsGty79rZqJMJnpbhIP5/OC+ZGm4VBoedyqtKGo5ml5dVdU1b9V23TD09FU1bIJ82zBNIxhvmIY/fsq0LLPvhhYWRt8N3dr8iD5Lx5COkIpZt2zScBvoo3OqlUxa5KyJ7+3coeiCXi90BTQXUvwX6KWTiAB4nGNgZGBgAGLW8J118fw2Xxm4WRhA4JFfoC+M/v//fwMLA3MjkMvBwAQSBQAjSQrvAAAAeJxjYGRgYG7438AQw8Lw/z8DAwsDA1AEBfACAHXkBHR4nGNhYGBggeP//yEYWQwTAwCTVgQxAAAAAAAAAJgBNAGaAhgChgL+AxIDXAOKA9QEqgTGeJxjYGRgYOBlmMrAxwACTEDMBYQMDP/BfAYAGXgBxwB4nIWRPW7CQBCFn8GQBJQoSqQ0aVYpKBLJ/JRIqVCgp6AHs+ZHttdaL0jUOU2OkBPkCOloc4pIedhDA0W82tlv3r6ZHckA7rCHh/K75y7ZwyWzkiu4wKNwlfqTsE9+Fq6hiZ5wnfqrcAMveBNusmPGDp5/xayFd2EPt/gQruAGn8JV6l/CPvlbuIYH/AjXqf8KNzDxroWbaHnhwOqp03M126lVaNLIpO54jvViE0/tqTzRNl+ZVHWDzlEa6VTbY5t8u+g5F6nImkQNeavj2KjMmrUOXbB0Luu325HoQWgSDGChMYVjnENhhh3jCiEMUkRFdGf5mO4FNohZaf91T+i2yKkfcoUuAnTOXCO60sJ5Ok2OLV/rUXV0K27LmoQ0lFrNSWKy4g883K2phNQDLIuqDH20uaITf1DMkPwB2JNvV3icbUxLDsIgFGRqK7S2Gg/Cxot4BlJAq/RBSkjk9mLrwoWzmW+GVWxDx/5jQIUdajTYg0OgRYcDegw4srNNzsVxMYZkvC8TPX8T8wqKtIg+kb5ayzdB7crSWyu+ipqgUjT9Y6JbnkiOPmQRinGJLqfo19Vcis85d17p0tXBqczYG/CnMGsAAAA=\') format(\'woff\'),\n url(\'data:font/ttf;base64,AAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzI8ik1PAAABjAAAAGBjbWFw8LA+0QAAAiAAAAJCZ2x5ZmYzzj4AAASAAAAJjGhlYWQnuuaYAAAA4AAAADZoaGVhB90DjgAAALwAAAAkaG10eDQB//4AAAHsAAAANGxvY2EP/hJAAAAEZAAAABxtYXhwASUAoQAAARgAAAAgbmFtZRCjPLAAAA4MAAACZ3Bvc3RzHFinAAAQdAAAAMAAAQAAA4D/gABcBAD//wAABAAAAQAAAAAAAAAAAAAAAAAAAA0AAQAAAAEAAAVXuX5fDzz1AAsEAAAAAADiTlFNAAAAAOJOUU3///+ABAADgQAAAAgAAgAAAAAAAAABAAAADQCVAA4AAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAQEAAGQAAUAAAKJAswAAACPAokCzAAAAesAMgEIAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAwOZ16n8DgP+AAAAD3ACAAAAAAQAAAAAAAAAAAAAAAAACBAAAAAQAAAAEAAAABAD//wQA//8EAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAAAAAUAAAADAAAALAAAAAQAAAGiAAEAAAAAAJwAAwABAAAALAADAAoAAAGiAAQAcAAAABIAEAADAALmduaE5o7mnOam5vnokep///8AAOZ15oTmjeab5qbm+eiR6n7//wAAAAAAAAAAAAAAAAAAAAAAAQASABQAFAAWABgAGAAYABgAAAACAAEACQAFAAYAAwAEAAcADAALAAoACAAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAoAAAAAAAAAAMAADmdQAA5nUAAAACAADmdgAA5nYAAAABAADmhAAA5oQAAAAJAADmjQAA5o0AAAAFAADmjgAA5o4AAAAGAADmmwAA5psAAAADAADmnAAA5pwAAAAEAADmpgAA5qYAAAAHAADm+QAA5vkAAAAMAADokQAA6JEAAAALAADqfgAA6n4AAAAKAADqfwAA6n8AAAAIAAAAAAAAAJgBNAGaAhgChgL+AxIDXAOKA9QEqgTGAAQAAP/3A44DDAAaADUAUQBtAAABIyIGFBY7ATI3Njc2PQE0JiIGHQEnJiIGFBcBMzI2NCYrASIHBgcGHQEUFjI2PQEXFjI2NCclJicmKwEiBhQWOwEHBhQWMj8BFRQWMjY9AS4BNxYXFjsBMjY0JisBNzY0JiIPATU0JiIGHQEeAQE6iQ0TEw3VCQIPAgITGhO3ChkUCgI3iQ0TEw3VCQIPAgITGhPICR4SCv4vBwoEB9cNExMNickKEx0JyBQZEwECqAcKBAbWDRMTDYm8ChQZCrwTGRQCAgIaFBkTAgcKBAbWDRMTDYm+ChMaCv4gFBkTAgcKBAfVDRMTDYnJCBIZCvMPAgITGRTIChkTCcmJDRMTDdUCCc0PAgITGRS7ChoTCryJDRMTDdUDCAAAAAAEAAD/9QONAwsAGwA3AFIAcQAAEzI2PQEXFjI2NC8BMzI2NCYrASIHBgcGHQEUFgUiBh0BJyYiBhQfASMiBhQWOwEyNzY3Nj0BNiYlBzU0JiIGHQEUFxYXFjsBMjY0JisBNzY0JgYBNDUVJicmKwEiBhQWOwEHBhQWMj8BFRQWMjY9AScmlQ0TvAkdEwq8hwwUFAzWCAIMCAIUAuINE8kJGhMJyYkMFBQM1ggCDwIDARL+BskTGRQCCAoEBtYMFBQMickJExcCAQcLBAbYDBQUDIm8CRIeCLwTGhMCAQH1FAyJvAgSGQq8ExkUAgYMBAjWDBTqFAyJyQkTGgnJExkUAggKBAbYDBQiyYcMFBQM1ggCDwIDFBkTyQoZEwEBwAEBAg4DAxQZE7wKGRMJvIcMFBQM1gUEAAAD////swPSA00AGQAgAEEAAAEiBwYPASMiBhURFBY7ARcWFxYzMjY1ETQmAy8BIxEzNwE3Ni4BBg8BJy4BBw4BHwEHBhYXFjMyPwEXFjMyNz4BJwH7CgoGCuafIy8vI5/mCgYKChggIUWaH66uuQGKbAsGHy0LV1cNKRIQBgxrawwHDxQLGw5XVw0cChQRCA4DTQMCBcMvI/6pJjHDBQIDHxoDLhYd/QCAGQE0mf7NlBQpFwcPe3sQCQ8LKRSUlBAtCwoUe3sUCgwpEwAE////swPsA00AGQAgADgAUQAAASIHBg8BIyIGFREUFjsBFxYXFjMyNjURNCYDLwEjETM3JSYGBwYWFx4BFAYHDgEXHgEyNjc+ATQmByYGBwYWFx4BFRQGBw4BFx4BMjY3PgE0JgH7CgoGCuafIy8vI5/mCgYKChggIUWaH66uuQFmECgPEAITSVBQSQ8CDAcUERQHWGFhzg8pDxACEyotLSoPAgwHFBEUBzk9PANNAwIFwy8j/qkmMcMFAgMfGgMuFh39AIAZATSZcRACExApD0azxrRFDykQBwgIB1Dc8OFFEAITDykPJmc2OWMnDygQBwkJBzGLm40AAAADAAAAAAOrAtcAFQA6AEYAAAE3NjIWFAcBBiImND8BJy4BPgIWFwUVFAYiJjURNDY7ATc+AR4BFREUDgEmLwEuAT4CFh8BEQcGIwUmNDYyHwEWFAYiJwMAYgwjGQz/AAwjGQxiYggHBhAXFgj+DRkkGRkSccoJGRYNDRYZCdYJCQMPFhcJkJAMDwI3DBkjDCsMGSMMAbxiDBkjDP8ADBkjDGJiCBYXEAYHCEnVEhkZEgEAEhmhCAIKFQz9qgwVCgIIqwcVFxMIBAhzAaRzCsgMIxkMKwwjGQwAAAAAAwAAAAADuQLXABQAKQBOAAABJjQ2MhcWFxYHBgcGIiY0Nz4BNCYHLgE+AhYXHgEUBgcGIiY0Nz4BJgUVFAYiJjURNDY7ATc+AR4BFREUDgEmLwEuAT4CFh8BEQcGIwLxCxkiDVIdHBwdUg0jGQwwNDSoCAYGEBYWCCQnJyQMJBkNIBcX/hIZJBkZEnHKCRkWDQ0WGQnWCQkDDxYXCZCQDA8CcQ0iGQtScGxscFIMGSMNMH2IfUgIFhYQBgYIJF5mXiQNGSQMIVhYA9USGRkSAQASGaEIAgoVDP2qDBUKAgirBxUXEwgECHMBpHMKAAAAAgAAAAADAAKrAAMABwAAJTMRIyERMxEBAKurAVWrVQJW/aoCVgAAAAQAAP/2A6ADCwAJABMAIAAtAAAlIyImNRE0NjsBJREUBi8BETc2FhMmND8BNjIWFA8BBiIDNjIfARYUBiIvASY0AQDNFR4fFcwBABoN2dkNGm8PD9kPKh4P2Q4rDw8qD9kPHioP2Q+AHhUBmRUfbf0nDw8IggIAgwcO/fMPKg/ZDx4qD9kPATEPD9kPKh4P2Q4rAAABAAD/7QO1At8AHQAABSIuAT0BNCYrASImNRE0NjMhMhYVERQGIyEiDwEGAVEFDAgOCnsfKysfAsUfKysf/rAJB6gHEwYMB2sKDysfAcAfLCwf/kAfKwaRBgAAAAIAAP/wA2ADEAAVAC4AAAERFAYnJSYrASImNRE0NjsBMjclNhYTFAYHBiY9ATQ/AT4BNCYvASY9ATQ2Fx4BAoAfEP69DhCwGiYmGrAQDgFDEB/gQjgCBAEHGx0dGwcBBAI4QgLq/SwSEwmuCCYaASAbJQiuCRP+hER0IgECAkYCAQYbR0xHGwYBAkYCAgEidAAAAAAOAAD/gAQAA4EACAARABoAIwAsADUAPgBHAFAAWQBnAHYAhQCUAAAlMjY0JiIGFBYHFjI2NCYiBhQHFjI2NCYiBhQjFjI2NCYiBhQnFjI2NCYiBhQnFjI2NCYiBhQnFjI2NCYiBhQ3FjI2NCYiBhQ3FjI2NCYiBhQ3FjI2NCYiBhQXHgEzMjY0JiMiBgcGFBceATI2NzY0JiciBgcGFBceATI2NzY0JiMiBgcGFBceATI2NzY0JiciBgcGFANtAgQEBQMDigQKCAgKB7UGDwsLDwvBBxUODhUOqQkaEhIaEnALHxYWHxYhDCUZGSUZNQ4qHR0qHYIRLiEhLiG5EzMlJTQk0AkaDR0oKB0NGgkUwgocHRwKFisfDxwKFpILHiAeCxgvIhAeCxhKDCEiIAwaMyQRIQwZcQQGBAQGBJkECAsHBwtWBgwQCwsQCA8WDw8WVAkTGxMTG5YMGCAXFyC4DRsmGxsmtg8fKiAgKo0SIzEjIzFGEyc2JiY2EwoLKzsrCwoWO2wLDAwLF0EuAQ0LF0G2DA0NDBpGMg0MGUbmDQ4ODRxLNgEPDBxLAAEAAP/BA5IDPwALAAAJAQYmNRE0NhcBFhQDhf0JDhISDgL3DQFu/lsICw8DSg8LCP5bCBQAAAAAAAASAN4AAQAAAAAAAAATAAAAAQAAAAAAAQAIABMAAQAAAAAAAgAHABsAAQAAAAAAAwAIACIAAQAAAAAABAAIACoAAQAAAAAABQALADIAAQAAAAAABgAIAD0AAQAAAAAACgArAEUAAQAAAAAACwATAHAAAwABBAkAAAAmAIMAAwABBAkAAQAQAKkAAwABBAkAAgAOALkAAwABBAkAAwAQAMcAAwABBAkABAAQANcAAwABBAkABQAWAOcAAwABBAkABgAQAP0AAwABBAkACgBWAQ0AAwABBAkACwAmAWNDcmVhdGVkIGJ5IGljb25mb250aWNvbmZvbnRSZWd1bGFyaWNvbmZvbnRpY29uZm9udFZlcnNpb24gMS4waWNvbmZvbnRHZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAHIAZQBhAHQAZQBkACAAYgB5ACAAaQBjAG8AbgBmAG8AbgB0AGkAYwBvAG4AZgBvAG4AdABSAGUAZwB1AGwAYQByAGkAYwBvAG4AZgBvAG4AdABpAGMAbwBuAGYAbwBuAHQAVgBlAHIAcwBpAG8AbgAgADEALgAwAGkAYwBvAG4AZgBvAG4AdABHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQECAQMBBAEFAQYBBwEIAQkBCgELAQwBDQEOABFmdWxsc2NyZWVuLXNocmluaxFmdWxsc2NyZWVuLWV4cGFuZAhzb3VuZE9mZgdzb3VuZE9uCXNvdW5kLW9mZghzb3VuZC1vbgVwYXVzZQxqaW5neWluLWNvcHkIcGluZ2x1bjIPc29vdW5kLW1pbi1mdWxsB2xvYWRpbmcEcGxheQAA\') format(\'truetype\');\n}\n\n.iconfont {\n font-family: "iconfont" !important;\n font-size: 16px;\n font-style: normal;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.icon-fullscreen-shrink:before {\n content: "\\e676";\n}\n\n.icon-fullscreen-expand:before {\n content: "\\e675";\n}\n\n.icon-soundOff:before {\n content: "\\e69b";\n}\n\n.icon-soundOn:before {\n content: "\\e69c";\n}\n\n.icon-sound-off:before {\n content: "\\e68d";\n}\n\n.icon-sound-on:before {\n content: "\\e68e";\n}\n\n.icon-pause:before {\n content: "\\e6a6";\n}\n\n.icon-jingyin-copy:before {\n content: "\\ea7f";\n}\n\n.icon-pinglun2:before {\n content: "\\e684";\n}\n\n.icon-soound-min-full:before {\n content: "\\ea7e";\n}\n\n.icon-loading:before {\n content: "\\e891";\n}\n\n.icon-play:before {\n content: "\\e6f9";\n}\n.jy-player {\n background-color: #000;\n position: relative;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n}\n.jy-player .player-controller {\n position: absolute;\n bottom: -100%;\n left: 0;\n width: 100%;\n z-index: 999;\n padding: 10px;\n background-color: rgba(0, 0, 0, 0.5);\n color: #eee;\n transition: bottom 0.3s;\n}\n.jy-player .player-controller .progress {\n position: relative;\n height: 4px;\n background-color: rgba(255, 255, 255, 0.4);\n cursor: pointer;\n overflow: visible;\n --percent: 0;\n}\n.jy-player .player-controller .progress::before {\n content: "";\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: var(--percent, 0);\n background-color: rgba(255, 255, 255, 0.8);\n transition: all 200ms;\n}\n.jy-player .player-controller .progress::after {\n content: "";\n display: none;\n position: absolute;\n top: 50%;\n left: var(--percent, 0);\n height: 10px;\n width: 10px;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n background-color: #ffffff;\n transition: all 200ms;\n}\n.jy-player .player-controller .progress:hover::after {\n display: block;\n}\n.jy-player .player-controller .controller-row {\n margin-top: 10px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n.jy-player .player-controller .controller-row > div {\n display: flex;\n align-items: center;\n}\n.jy-player .player-controller .iconfont {\n font-size: 24px;\n cursor: pointer;\n}\n.jy-player .player-controller .iconfont + .iconfont {\n margin-left: 10px;\n}\n.jy-player .player-controller .video-time {\n margin-left: 10px;\n}\n.jy-player .player-center {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n color: #eee;\n z-index: 10;\n}\n.jy-player .player-center .icon-loading {\n display: block;\n font-size: 48px;\n animation: rotateInfinite 1.2s infinite linear;\n}\n.jy-player .player-center .error-text {\n display: none;\n padding: 15px;\n border-radius: 5px;\n background-color: rgba(0, 0, 0, 0.5);\n}\n.jy-player .player-center .icon-play,\n.jy-player .player-center .icon-pause {\n display: none;\n opacity: 0.6;\n font-size: 64px !important;\n cursor: pointer;\n}\n.jy-player .player-center.loading .icon-play,\n.jy-player .player-center.loading .icon-pause {\n display: none !important;\n}\n.jy-player.active .player-center .icon-pause,\n.jy-player.active .player-center .icon-play {\n display: block;\n}\n.jy-player.active .player-controller {\n display: block;\n bottom: 0;\n}\n@keyframes rotateInfinite {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n', {} ); var ip = { exports: {} }; !(function (t, e) { t.exports = (function (t) { function e(i) { if (n[i]) return n[i].exports; var r = (n[i] = { i: i, l: !1, exports: {} }); return t[i].call(r.exports, r, r.exports, e), (r.l = !0), r.exports; } var n = {}; return ( (e.m = t), (e.c = n), (e.i = function (t) { return t; }), (e.d = function (t, n, i) { e.o(t, n) || Object.defineProperty(t, n, { configurable: !1, enumerable: !0, get: i }); }), (e.n = function (t) { var n = t && t.__esModule ? function () { return t.default; } : function () { return t; }; return e.d(n, "a", n), n; }), (e.o = function (t, e) { return Object.prototype.hasOwnProperty.call(t, e); }), (e.p = ""), e((e.s = 5)) ); })([ function (t, e, n) { function i() { var t = {}, e = !1, n = 0, r = arguments.length; for ( "[object Boolean]" === Object.prototype.toString.call(arguments[0]) && ((e = arguments[0]), n++); n < r; n++ ) !(function (n) { for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e && "[object Object]" === Object.prototype.toString.call(n[r]) ? (t[r] = i(!0, t[r], n[r])) : (t[r] = n[r])); })(arguments[n]); return t; } e.a = i; }, function (t, e) { !(function () { var e = "undefined" != typeof window && void 0 !== window.document ? window.document : {}, n = void 0 !== t && t.exports, i = (function () { for ( var t, n = [ [ "requestFullscreen", "exitFullscreen", "fullscreenElement", "fullscreenEnabled", "fullscreenchange", "fullscreenerror" ], [ "webkitRequestFullscreen", "webkitExitFullscreen", "webkitFullscreenElement", "webkitFullscreenEnabled", "webkitfullscreenchange", "webkitfullscreenerror" ], [ "webkitRequestFullScreen", "webkitCancelFullScreen", "webkitCurrentFullScreenElement", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitfullscreenerror" ], [ "mozRequestFullScreen", "mozCancelFullScreen", "mozFullScreenElement", "mozFullScreenEnabled", "mozfullscreenchange", "mozfullscreenerror" ], [ "msRequestFullscreen", "msExitFullscreen", "msFullscreenElement", "msFullscreenEnabled", "MSFullscreenChange", "MSFullscreenError" ] ], i = 0, r = n.length, a = {}; i < r; i++ ) if ((t = n[i]) && t[1] in e) { for (i = 0; i < t.length; i++) a[n[0][i]] = t[i]; return a; } return !1; })(), r = { change: i.fullscreenchange, error: i.fullscreenerror }, a = { request: function (t, n) { return new Promise( function (r, a) { var s = function () { this.off("change", s), r(); }.bind(this); this.on("change", s); var o = (t = t || e.documentElement)[i.requestFullscreen](n); o instanceof Promise && o.then(s).catch(a); }.bind(this) ); }, exit: function () { return new Promise( function (t, n) { if (this.isFullscreen) { var r = function () { this.off("change", r), t(); }.bind(this); this.on("change", r); var a = e[i.exitFullscreen](); a instanceof Promise && a.then(r).catch(n); } else t(); }.bind(this) ); }, toggle: function (t, e) { return this.isFullscreen ? this.exit() : this.request(t, e); }, onchange: function (t) { this.on("change", t); }, onerror: function (t) { this.on("error", t); }, on: function (t, n) { var i = r[t]; i && e.addEventListener(i, n, !1); }, off: function (t, n) { var i = r[t]; i && e.removeEventListener(i, n, !1); }, raw: i }; i ? (Object.defineProperties(a, { isFullscreen: { get: function () { return Boolean(e[i.fullscreenElement]); } }, element: { enumerable: !0, get: function () { return e[i.fullscreenElement]; } }, isEnabled: { enumerable: !0, get: function () { return Boolean(e[i.fullscreenEnabled]); } } }), n ? (t.exports = a) : (window.screenfull = a)) : n ? (t.exports = { isEnabled: !1 }) : (window.screenfull = { isEnabled: !1 }); })(); }, function (t, e, n) { function i(t, e) { (t.style.position = e.position), (t.style.left = e.left), (t.style.top = e.top), (t.style.width = e.width), (t.style.height = e.height); } function r(t) { var e = t.element; e && (e.classList.remove(t.options.fullscreenClass), (t.options.teleport || t.options.pageOnly) && (t.options.teleport && c && (c.insertBefore(e, d), c.removeChild(d)), e.__styleCache && i(e, e.__styleCache))); } var a = n(1), s = n.n(a), o = n(0), l = { callback: function () { }, fullscreenClass: "fullscreen", pageOnly: !1, teleport: !1 }, d = void 0, c = void 0, u = { options: null, element: null, isFullscreen: !1, isEnabled: s.a.isEnabled, toggle: function (t, e, n) { return void 0 === n ? this.isFullscreen ? this.exit() : this.request(t, e) : n ? this.request(t, e) : this.exit(); }, request: function (t, e) { var a = this; if (this.isFullscreen) return Promise.resolve(); if ( (t || (t = document.body), (this.options = n.i(o.a)({}, l, e)), t === document.body && (this.options.teleport = !1), s.a.isEnabled || (this.options.pageOnly = !0), t.classList.add(this.options.fullscreenClass), this.options.teleport || this.options.pageOnly) ) { var u = t.style, h = u.position, p = u.left, f = u.top, m = u.width, g = u.height; (t.__styleCache = { position: h, left: p, top: f, width: m, height: g }), i(t, { position: "fixed", left: "0", top: "0", width: "100%", height: "100%" }); } if ( (this.options.teleport && (c = t.parentNode) && ((d = document.createComment("fullscreen-token")), c.insertBefore(d, t), document.body.appendChild(t)), this.options.pageOnly) ) { var y = function t(e) { "Escape" === e.key && (document.removeEventListener("keyup", t), a.exit()); }; return ( (this.isFullscreen = !0), (this.element = t), document.removeEventListener("keyup", y), document.addEventListener("keyup", y), this.options.callback && this.options.callback(this.isFullscreen), Promise.resolve() ); } var A = function e() { s.a.isFullscreen || (s.a.off("change", e), r(a)), (a.isFullscreen = s.a.isFullscreen), a.options.teleport ? (a.element = t || null) : (a.element = s.a.element), a.options.callback && a.options.callback(s.a.isFullscreen); }; return s.a.on("change", A), s.a.request(this.options.teleport ? document.body : t); }, exit: function () { return this.isFullscreen ? this.options.pageOnly ? (r(this), (this.isFullscreen = !1), (this.element = null), this.options.callback && this.options.callback(this.isFullscreen), Promise.resolve()) : s.a.exit() : Promise.resolve(); } }; (u.support = u.isEnabled), (u.getState = function () { return u.isFullscreen; }), (u.enter = u.request), (e.a = u); }, function (t, e, n) { function i(t, e) { var n = {}; for (var i in t) e.indexOf(i) >= 0 || (Object.prototype.hasOwnProperty.call(t, i) && (n[i] = t[i])); return n; } var r = n(2), a = n(0), s = function (t, e) { var s = function () { var t = void 0, s = { teleport: e.modifiers.teleport, pageOnly: e.modifiers.pageOnly }; if (e.value) if ("string" == typeof e.value) t = e.value; else { var o = e.value, l = o.target, d = i(o, ["target"]); (t = l), (s = n.i(a.a)(s, d)); } "string" == typeof t && (t = document.querySelector(t)), r.a.toggle(t, s); }; t._onClickFullScreen && t.removeEventListener("click", t._onClickFullScreen), t.addEventListener("click", s), (t._onClickFullScreen = s); }; e.a = s; }, function (t, e, n) { var i = n(7)(n(6), n(8), null, null); t.exports = i.exports; }, function (t, e, n) { Object.defineProperty(e, "__esModule", { value: !0 }); var i = n(4), r = n.n(i), a = n(2), s = n(3), o = n(1), l = n.n(o), d = n(0); n.d(e, "screenfull", function () { return l.a; }), n.d(e, "api", function () { return a.a; }), n.d(e, "directive", function () { return s.a; }), n.d(e, "component", function () { return r.a; }), (e.default = { install: function (t) { var e = (arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}).name || "fullscreen"; t.component(e, n.i(d.a)(r.a, { name: e })), (t.prototype["$" + e] = a.a), t.directive(e, s.a); } }); }, function (t, e, n) { Object.defineProperty(e, "__esModule", { value: !0 }); var i = n(1), r = n.n(i); e.default = { props: { value: { type: Boolean, default: !1 }, fullscreen: { type: Boolean, default: !1 }, exitOnClickWrapper: { type: Boolean, default: !0 }, fullscreenClass: { type: String, default: "fullscreen" }, pageOnly: { type: Boolean, default: !1 }, teleport: { type: Boolean, default: !1 } }, data: function () { return { isFullscreen: !1, isEnabled: !1 }; }, computed: { support: function () { return this.isEnabled; }, isPageOnly: function () { return this.pageOnly || !r.a.isEnabled; }, wrapperStyle: function () { return (this.isPageOnly || this.teleport) && this.isFullscreen ? { position: "fixed", left: "0", top: "0", width: "100%", height: "100%" } : void 0; } }, methods: { toggle: function (t) { void 0 === t ? (this.isFullscreen ? this.exit() : this.request()) : t ? this.request() : this.exit(); }, request: function () { if ( (this.isPageOnly ? ((this.isFullscreen = !0), this.onChangeFullScreen(), document.removeEventListener("keyup", this.keypressCallback), document.addEventListener("keyup", this.keypressCallback)) : (r.a.off("change", this.fullScreenCallback), r.a.on("change", this.fullScreenCallback), r.a.request(this.teleport ? document.body : this.$el)), this.teleport) ) { if (this.$el.parentNode === document.body) return; (this.__parentNode = this.$el.parentNode), (this.__token = document.createComment("fullscreen-token")), this.__parentNode.insertBefore(this.__token, this.$el), document.body.appendChild(this.$el); } }, exit: function () { this.isFullscreen && (this.isPageOnly ? ((this.isFullscreen = !1), this.onChangeFullScreen(), document.removeEventListener("keyup", this.keypressCallback)) : r.a.exit()); }, shadeClick: function (t) { t.target === this.$el && this.exitOnClickWrapper && this.exit(); }, fullScreenCallback: function () { r.a.isFullscreen || r.a.off("change", this.fullScreenCallback), (this.isFullscreen = r.a.isFullscreen), this.onChangeFullScreen(); }, keypressCallback: function (t) { "Escape" === t.key && this.exit(); }, onChangeFullScreen: function () { this.isFullscreen || (this.teleport && this.__parentNode && (this.__parentNode.insertBefore(this.$el, this.__token), this.__parentNode.removeChild(this.__token))), this.$emit("change", this.isFullscreen), this.$emit("update:fullscreen", this.isFullscreen), this.$emit("input", this.isFullscreen); }, enter: function () { this.request(); }, getState: function () { return this.isFullscreen; } }, watch: { value: function (t) { t !== this.isFullscreen && (t ? this.request() : this.exit()); }, fullscreen: function (t) { t !== this.isFullscreen && (t ? this.request() : this.exit()); } }, created: function () { this.isEnabled = r.a.isEnabled; } }; }, function (t, e) { t.exports = function (t, e, n, i) { var r, a = (t = t || {}), s = u(t.default); ("object" !== s && "function" !== s) || ((r = t), (a = t.default)); var o = "function" == typeof a ? a.options : a; if ((e && ((o.render = e.render), (o.staticRenderFns = e.staticRenderFns)), n && (o._scopeId = n), i)) { var l = Object.create(o.computed || null); Object.keys(i).forEach(function (t) { var e = i[t]; l[t] = function () { return e; }; }), (o.computed = l); } return { esModule: r, exports: a, options: o }; }; }, function (t, e) { t.exports = { render: function () { var t, e = this, n = e.$createElement; return (e._self._c || n)( "div", e._b( { ref: "wrapper", class: ((t = {}), (t[e.fullscreenClass] = e.isFullscreen), t), style: e.wrapperStyle, on: { click: function (t) { return e.shadeClick(t); } } }, "div", e.$attrs, !1 ), [e._t("default")], 2 ); }, staticRenderFns: [] }; } ]); })(ip); var rp = ip.exports, ap = function (t) { t = Math.round(t); var e = Math.floor(t % 60), n = Math.floor((t / 60) % 60), i = Math.floor(t / 3600), r = "".concat(n, ":").concat(e.toString().padStart(2, "0")); return i && (r = "".concat(i, ":").concat(r)), r; }, sp = (function (t) { function e(t) { var i, r = t.container, a = t.emitter, s = t.Player; if ((f(this, e), g((i = n(this, e, [{ emitter: a }])), "fullscreen", !1), !r)) throw new Error("container不能为空"); return (i.container = r), (i.Player = s), i.init(), i.registryEvents(), i; } return ( y(e, t), m(e, [ { key: "init", value: function () { var t = this; if ( ((this.loadingEl = document.createElement("span")), this.loadingEl.classList.add("iconfont", "icon-loading"), (this.playerCenter = document.createElement("span")), this.playerCenter.classList.add("player-center", "loading"), this.playerCenter.append(this.loadingEl), (this.errorText = document.createElement("span")), this.errorText.classList.add("error-text"), this.playerCenter.append(this.errorText), this.container.append(this.playerCenter), this.Player.config.controls) ) { (this.controllerWrap = document.createElement("div")), this.controllerWrap.classList.add("player-controller"), (this.progressBar = document.createElement("div")), this.progressBar.classList.add("progress"), this.progressBar.addEventListener("click", function (e) { e.stopPropagation(); var n = e.offsetX, i = e.target.offsetWidth, r = n / i, a = Math.floor(t.Player.duration * r); t.Logger.log("progressBar", n, i, a, r), (t.Player.currentTime = a); var s = t.Player, o = s.currentTime, l = s.duration; t.updateProgress({ currentTime: o, duration: l }); }), (this.progressHandler = document.createElement("div")), this.progressHandler.classList.add("progress-handler"), this.progressBar.append(this.progressHandler), this.controllerWrap.append(this.progressBar), (this.playBtn = document.createElement("span")), this.playBtn.classList.add("iconfont", "icon-play"); var e = function (e) { if ((e.stopPropagation(), t.Player.ended)) { var n = t.Player; n.currentTime; var i = n.duration; return ( t.updatePlayTime({ currentTime: 0, duration: i }), t.updateProgress({ currentTime: 0, duration: i }), void t.Player.play() ); } t.Player.paused ? t.Player.play() : t.Player.pause(); }; (this.centerPlayBtn = this.playBtn.cloneNode()), this.playerCenter.append(this.centerPlayBtn), this.centerPlayBtn.addEventListener("click", e), this.playBtn.addEventListener("click", e), (this.timeView = document.createElement("span")), this.timeView.classList.add("video-time"); var n = document.createElement("div"); n.append(this.playBtn), n.append(this.timeView), (this.muteBtn = document.createElement("span")), this.muteBtn.classList.add("iconfont", "icon-sound-on"), this.muteBtn.addEventListener("click", function (e) { e.stopPropagation(), (t.Player.muted = !t.Player.muted); }), (this.resolutionBtn = document.createElement("span")), this.resolutionBtn.classList.add("video-resolution"), (this.fullscreenBtn = document.createElement("span")), this.fullscreenBtn.classList.add("iconfont", "icon-fullscreen-expand"), this.fullscreenBtn.addEventListener("click", function (e) { e.stopPropagation(), t.toggleFullscreen(); }); var i = document.createElement("div"); i.append(this.muteBtn), i.append(this.fullscreenBtn); var r = document.createElement("div"); r.classList.add("controller-row"), r.append(n), r.append(i), this.controllerWrap.append(r), this.container.append(this.controllerWrap); } } }, { key: "registryEvents", value: function () { var t = this; this.Emitter.on("canplay", function () { t.Logger.log("MediaController::canplay"), (t.loadingEl.style.display = "none"), (t.errorText.style.display = "none"), t.playerCenter.classList.remove("loading"); }), this.Emitter.on("loading", function () { t.Logger.log("MediaController::loading"), (t.loadingEl.style.display = "block"), t.playerCenter.classList.add("loading"); }), this.Emitter.on("error", function (e) { var n, i; if ( (t.Logger.log("MediaController::error", e), Gu(null == e ? void 0 : e.fatal) || (null != e && e.fatal)) ) { var r = null !== (n = null == e || null === (i = e.error) || void 0 === i ? void 0 : i.message) && void 0 !== n ? n : "视频播放失败"; (t.errorText.innerText = r), (t.errorText.style.display = "block"), (t.loadingEl.style.display = "none"); } }), this.Player.config.controls && (this.Emitter.on("DURATIONCHANGE", function () { var e = t.Player, n = e.currentTime, i = e.duration; t.updatePlayTime({ currentTime: n, duration: i }); }), this.Emitter.on("play", function () { t.togglePlayStyle(), t.timer && clearInterval(t.timer), (t.timer = setInterval(function () { var e = t.Player, n = e.currentTime, i = e.duration; t.updatePlayTime({ currentTime: n, duration: i }), t.updateProgress({ currentTime: n, duration: i }); }, 1e3)); }), this.Emitter.on("pause", function () { t.togglePlayStyle(), clearInterval(t.timer); }), this.Emitter.on("ended", function () { t.togglePlayStyle(), clearInterval(t.timer); var e = t.Player; e.currentTime; var n = e.duration; t.updatePlayTime({ currentTime: n, duration: n }), t.updateProgress({ currentTime: n, duration: n }); }), this.Emitter.on("VOLUMECHANGE", this.toggleMutedStyle.bind(this))); } }, { key: "updateProgress", value: function (t) { var e = t.currentTime, n = t.duration, i = (function (t) { var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0; return Math.round(t * Math.pow(10, e + 2)) / Math.pow(10, e) + "%"; })(Math.min(e / n, 1), 2); this.progressBar.style.setProperty("--percent", i); } }, { key: "updatePlayTime", value: function (t) { var e = t.currentTime, n = t.duration; this.timeView.innerText = "".concat(ap(e), " / ").concat(ap(n)); } }, { key: "toggleMutedStyle", value: function () { this.Player.muted ? (this.muteBtn.classList.remove("icon-sound-on"), this.muteBtn.classList.add("icon-sound-off")) : (this.muteBtn.classList.remove("icon-sound-off"), this.muteBtn.classList.add("icon-sound-on")); } }, { key: "togglePlayStyle", value: function () { this.Player.paused || this.Player.ended ? (this.playBtn.classList.remove("icon-pause"), this.playBtn.classList.add("icon-play"), this.centerPlayBtn.classList.remove("icon-pause"), this.centerPlayBtn.classList.add("icon-play")) : (this.playBtn.classList.remove("icon-play"), this.playBtn.classList.add("icon-pause"), this.centerPlayBtn.classList.remove("icon-play"), this.centerPlayBtn.classList.add("icon-pause")); } }, { key: "toggleFullscreen", value: ((i = p( d().mark(function t() { var e, n, i, r = this; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: return ( this.Logger.log("toggleFullscreen"), (e = this.container), this.fullscreen || ((n = e.style.zIndex), (i = window.scrollY)), (t.next = 5), rp.api.toggle(e, { callback: function (t) { (r.fullscreen = t), !rp.api.isEnabled && zIndex && (e.style.zIndex = t ? zIndex : n), t || Gu(i) || window.scrollTo(0, i), t ? (r.fullscreenBtn.classList.remove( "icon-fullscreen-expand" ), r.fullscreenBtn.classList.add( "icon-fullscreen-shrink" )) : (r.fullscreenBtn.classList.remove( "icon-fullscreen-shrink" ), r.fullscreenBtn.classList.add( "icon-fullscreen-expand" )); } }) ); case 5: case "end": return t.stop(); } }, t, this ); }) )), function () { return i.apply(this, arguments); }) } ]) ); var i; })(Ph), op = (function (t) { function e(t) { var i, r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; f(this, e); var a = So(); g((i = n(this, e, [{ emitter: a }])), "config", { src: "", poster: "", autoplay: !0, loop: !1, autoDecode: !0, muted: !1, maxBufferLength: 10, debug: !1, workerUrl: "" }), i.init(r), (i.container = document.getElementById(t)), i.container.classList.add("jy-player", "active"), i.Logger.config({ prefix: "[media-player]::", debug: r.debug }), i.Logger.log("new MediaPlayer", t, i.container, r, i.config), (i.WorkerController = new tp({ emitter: a, Player: i })), i.WorkerController.init({ debug: r.debug, device: I, isMobile: B, isIphone: P }), (i.TimerController = new Zh({ emitter: a, Player: i })), (i.Loader = new bh({ emitter: a, logger: i.Logger })); var s = document.createElement("canvas"); return ( i.container.insertBefore(s, i.container.children[0]), (i.Canvas = new Jh({ canvas: s, emitter: a, width: i.container.offsetWidth, height: i.container.offsetHeight })), i.drawPoster(i.config.poster), (i.VideoController = new Uh({ emitter: a, Player: i })), (i.AudioController = new Wh({ emitter: a, Player: i, muted: r.muted })), (i.MediaController = new sp({ container: i.container, emitter: a, Player: i })), i.registerEvents(), i.getPlayList(), i ); } return ( y(e, t), m(e, [ { key: "init", value: ((s = p( d().mark(function t(e) { return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: (this.levels = []), (this.currentLevel = null), (this._nextLevel = null), (this.duration = 0), (this.destroyed = !1), (this.videoReady = !1), (this.audioReady = !0), (this.loading = !0), (this.seeked = !1), (this.paused = !0), (this.ended = !1), (this.autoplay = e.autoplay), Object.assign(this.config, e); case 13: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return s.apply(this, arguments); }) }, { key: "getPlayList", value: ((a = p( d().mark(function t() { var e, n, i, r, a, s; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: return (t.next = 2), this.Loader.getPlaylist({ src: this.config.src }); case 2: if ((e = t.sent)) { t.next = 5; break; } return t.abrupt("return"); case 5: if (((n = e.playlist), (i = e.duration), !(r = e.levels))) { t.next = 18; break; } return ( (this.levels = r), this.Emitter.emit(ah, jc(r, 5)), (this.currentLevel = 0), (this._nextLevel = 0), (a = r[this.currentLevel].url), (t.next = 14), this.Loader.getPlaylist({ src: a }) ); case 14: (s = t.sent), (i = s.duration), (n = s.playlist), (r[this.currentLevel].playlist = s.playlist); case 18: (this.duration = i), console.log("getPlayList", i), this.Emitter.emit(vh, i), this.Emitter.emit(ih, n); case 22: case "end": return t.stop(); } }, t, this ); }) )), function () { return a.apply(this, arguments); }) }, { key: "registerEvents", value: function () { var t = this; (this.addEventListener = function (e, n) { var i, r = "error" === e ? e : e.toUpperCase(); t.Emitter.on(r, function (a) { (r === i && r === mh) || ((i = r), n({ type: e, target: t, data: a })); }); }), (this.removeEventListener = this.Emitter.off), ["PLAY", "PAUSE", "SEEKED", "WAITING", "VOLUMECHANGE", "ERROR"].forEach(function (e) { t.Emitter.on(e, function (n) { return t.Emitter.emit(e.toLocaleLowerCase(), n); }); }), this.Emitter.on(rh, this.onFirstVideoFrame.bind(this)), this.Emitter.on(ch, this.onLoading.bind(this)), this.Emitter.on(hh, this.onCanplay.bind(this)), this.Emitter.on(gh, this.onEnded.bind(this)), this.Emitter.on(sh, function () { t.Logger.log(sh, t._nextLevel, t.currentLevel), t._nextLevel != t.currentLevel && ((t.currentLevel = t._nextLevel), t.Emitter.emit(dh, t.levels[t.currentLevel].name)); }), (this.containerClickHandler = function () { t.Logger.log("containerClickHandler::"), t.container.classList.toggle("active"); }), this.container.addEventListener("click", this.containerClickHandler), this.container.addEventListener("touchmove", function (t) { t.stopPropagation(), t.preventDefault(); }), document.addEventListener("visibilitychange", this.visibilityHandler.bind(this)); } }, { key: "removeEvents", value: function () { this.Emitter.all.clear(), this.container.removeEventListener("click", this.containerClickHandler), B && document.removeEventListener("visibilitychange", this.visibilityHandler); } }, { key: "visibilityHandler", value: function () { if ((this.Logger.log("visibilitychange", document.hidden), document.hidden)) { if (this.paused) return; this.pause(); } } }, { key: "togglePlay", value: function () { this.Logger.log("togglePlay", this.paused), this.paused ? this.play() : this.pause(); } }, { key: "onFirstVideoFrame", value: function (t) { this.config.poster ? t.close() : this.Canvas.draw(t); } }, { key: "onEnded", value: function () { if ( (this.Logger.log("onEnded"), (this.ended = !0), this.TimerController.stop(), this.AudioController.pause(), this.loop) ) return this.Emitter.emit("ended", { type: "ended", target: this }), void this.seek(0); (this.paused = !0), this.Emitter.emit("ended", { type: "ended", target: this }), this.Emitter.emit("pause", { type: "pause", target: this }); } }, { key: "play", value: function () { this.ended ? this.replay() : this.paused || this.loading ? ((this.paused = !1), this.config.autoDecode || (this.Logger.warn("未开始解码"), this.startDecode()), this.Logger.log("play()::paused:".concat(this.paused)), this.videoReady && this.audioReady ? ((this.loading = !1), this.AudioController.play(), this.TimerController.run()) : this.Logger.warn("音视频尚未就绪", this.loading, this.videoReady, this.audioReady)) : this.Logger.warn("当前视频已在播放中"); } }, { key: "replay", value: function () { this.Logger.log("replay::", this.paused, this.loading), this.TimerController.reset(), this.AudioController.reset(), (this.ended = !1), this.seek(0); } }, { key: "pause", value: function () { var t, e; (this.paused = !0), null === (t = this.TimerController) || void 0 === t || t.stop(), null === (e = this.AudioController) || void 0 === e || e.pause(), this.Emitter.emit(fh); } }, { key: "onLoading", value: function (t) { this.Logger.warn(ch, t, this.currentTime, this.TimerController.currentTime), (this.loading = !0), "video" == t ? (this.videoReady = !1) : (this.audioReady = !1), this.AudioController.pause(), this.TimerController.stopTime(), this.Emitter.emit("loading"); } }, { key: "onCanplay", value: function (t) { if ( ("video" == t ? (this.videoReady = !0) : (this.audioReady = !0), this.Logger.warn( hh, t, "videoReady:".concat(this.videoReady, ", audioReady:").concat(this.audioReady), this.autoplay ), this.videoReady && this.audioReady) ) { if ((this.Emitter.emit("canplay"), this.seeked || this.currentTime || !this.paused)) return ( this.Logger.log("onCanplay::play()", this.seeked, this.paused), (this.seeked = !1), void this.play() ); this.autoplay && (this.Logger.warn("onCanplay::autoplay"), this.play()); } } }, { key: "seek", value: function (t) { (this.seeked = !0), (this.loading = !0), (this.videoReady = !1), (this.audioReady = !1), this.Emitter.emit("loading"), t < this.duration ? (this.ended = !1) : (this.ended = !0), this.TimerController.seek(t), this.VideoController.seek(t), this.Emitter.emit(uh, t); } }, { key: "startDecode", value: function () { this.config.autoDecode = !0; } }, { key: "changeLevel", value: ((r = p( d().mark(function t(e) { var n, i, r; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (((n = this.levels[e]), (i = n.playlist))) { t.next = 8; break; } return (t.next = 5), this.Loader.getPlaylist({ src: n.url }); case 5: (r = t.sent), (i = r.playlist), (n.playlist = r.playlist); case 8: this.WorkerController.changePlaylist(i), this.Emitter.emit(oh, i), this.Emitter.emit(lh, e); case 11: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return r.apply(this, arguments); }) }, { key: "currentTime", get: function () { var t; return this.ended ? this.duration : null === (t = this.AudioController) || void 0 === t ? void 0 : t.currentTime; }, set: function (t) { this.seek(t); } }, { key: "nextLevel", set: function (t) { this.levels.length && this.currentLevel !== t && this._nextLevel !== t && ((this._nextLevel = t), this.changeLevel(t)); } }, { key: "buffered", get: function () { return this.VideoController.decodedTime; } }, { key: "muted", get: function () { var t; return null === (t = this.AudioController) || void 0 === t ? void 0 : t.muted; }, set: function (t) { (this.AudioController.muted = t), this.Emitter.emit(Ah); } }, { key: "loop", get: function () { return this.config.loop; }, set: function (t) { Uu(t) && (this.config.loop = t); } }, { key: "drawPoster", value: function (t) { if (t) try { this.Canvas.drawImageBySrc(t); } catch (t) { this.Logger.warn("drawPoster", t); } } }, { key: "destroy", value: ((i = p( d().mark(function t() { var e, n, i, r; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: (this.destroyed = !0), this.pause(), this.removeEvents(), null === (e = this.WorkerController) || void 0 === e || e.destroy(), null === (n = this.AudioController) || void 0 === n || n.destroy(), null === (i = this.VideoController) || void 0 === i || i.destroy(), null === (r = this.Canvas) || void 0 === r || r.destroy(), (this.TimerController = null), (this.Loader = null), (this.VideoController = null), (this.AudioController = null); case 11: case "end": return t.stop(); } }, t, this ); }) )), function () { return i.apply(this, arguments); }) } ]) ); var i, r, a, s; })(Ph), lp = (function () { return m( function t(e) { var n = this, i = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; f(this, t), g(this, "version", "1.3.0"), g(this, "playerType", N), (this.el = e), (this.eventList = []), (this.options = Object.assign({}, i, { playerType: this.playerType })), console.log("options", this.el, i); var r = new To({ debug: i.debug }); (this.$logger = r), r.log("VideoPlayerClass init", e, this.options); var a = So(); (this.$emitter = a), (this.$reporter = new ju({ logger: r, emitter: a })), a.on("*", function (t, e) { r.log("reporter::", t, e), n.$reporter.add({ event: t }); }), this.options.prefixAd && this.options.prefixAd.list ? this.playAd() : this.createPlayer(this.options), r.log("VideoPlayer::created::version", this.version); }, [ { key: "getReportInfo", value: function () { var t = R(); return ( (t.version = this.version), (t.player = "JYPlayer"), (t.playerType = this.playerType), (t.events = this.$reporter.reports), t ); } }, { key: "playAd", value: ((n = p( d().mark(function t() { var e, n, i, r, a, s, o, c, u, h = this; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if ( ((e = this.options.prefixAd), (n = e.list), (i = void 0 === n ? [] : n), (r = e.time), (a = void 0 === r ? 5 : r), null == this.adCountdown && (this.adCountdown = a), console.log("list::", i), i.length) ) { t.next = 6; break; } return this.createPlayer(this.options), t.abrupt("return"); case 6: return ( (s = i.shift()), (t.next = 9), this.createPlayer( l( l({}, this.options), {}, { src: s.src, autoplay: !0, muted: !0, isAD: !0, controls: !1 } ) ) ); case 9: ((o = document.createElement("a")).style.opacity = "100%"), (o.style.width = "100%"), (o.style.height = "100%"), (o.style.position = "absolute"), (o.style.top = "0"), (o.target = "_blank"), (o.href = s.link), (c = document.createElement("span")), ((u = document.querySelector(this.el)).style.position = "relative"), (c.style.padding = "3px 5px"), (c.style.display = "flex"), (c.style.justifyContent = "center"), (c.style.alignItems = "center"), (c.style.margin = "10px"), (c.style.height = "30px"), (c.style.borderRadius = "10px"), (c.style.background = "grey"), c.addEventListener( "click", p( d().mark(function t() { return d().wrap(function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (!(h.adCountdown > 0)) { t.next = 4; break; } return ( console.log("skip-ads::click"), h.$emitter.emit("skip-ads", !1), t.abrupt("return") ); case 4: (i.length = 0), h.$emitter.emit("skip-ads", !0), h.createPlayer(h.options); case 7: case "end": return t.stop(); } }, t); }) ) ), (c.style.color = "white"), (c.style.zIndex = "99999"), (c.style.position = "absolute"), (c.style.top = "0"), (c.style.right = "0"), (c.style.cursor = "pointer"), (c.className = "close-button"), u.append(c), u.append(o), this.player.addEventListener("ended", function () { h.$logger.log("ad::ended"), h.playAd(); }), this.player.addEventListener("error", function (t) { h.$logger.log("ad::error", t), h.playAd(); }), console.log("adTimer::", this.adTimer), this.adTimer && clearInterval(this.adTimer), (c.innerText = "".concat( this.adCountdown > 0 ? this.adCountdown + "s | " : "", "跳过广告" )), this.$emitter.on("play", function () { h.adTimer = setInterval(function () { (h.adCountdown -= 1), (c.innerText = "".concat( h.adCountdown > 0 ? h.adCountdown + "s | " : "", "跳过广告" )), h.adCountdown <= 0 && clearInterval(h.adTimer); }, 1e3); }); case 44: case "end": return t.stop(); } }, t, this ); }) )), function () { return n.apply(this, arguments); }) }, { key: "createPlayer", value: ((e = p( d().mark(function t(e) { var n; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: (n = this.el), this.destroy(), console.log("createPlayer::", n, e), (this.player = new op(n.replace("#", ""), e)), this.initPlayerEvnets(this.player), e.isAD || (console.log("renderAdvertisement", this.el, this.options), _h({ el: this.el, adList: this.options.adList, player: this })); case 6: case "end": return t.stop(); } }, t, this ); }) )), function (t) { return e.apply(this, arguments); }) }, { key: "initPlayerEvnets", value: function (t) { var e = this; if (t) { [ "canplay", "canplaythrough", "durationchange", "ended", "error", "loadeddata", "loadedmetadata", "loadstart", "pause", "play", "playing", "progress", "ratechange", "seeked", "seeking", "volumechange", "waiting", "fullscreen" ].forEach(function (n) { t.Emitter.on(n, function (t) { e.$emitter.emit(n, t); }); }), this.eventList.forEach(function (t) { e.$emitter.on(t.eventType, t.cb); }); } } }, { key: "startDecode", value: function () { this.player.startDecode && this.player.startDecode(); } }, { key: "getVideo", value: function () { return null; } }, { key: "on", value: function (t, e) { if (!t || !tl(e)) throw new Error("on方法参数有误"); this.$emitter.on(t, e), this.eventList.push({ eventType: t, cb: e }); } }, { key: "off", value: function (t, e) { if (!t || !tl(e)) throw new Error("on方法参数有误"); this.$emitter.off(t, e); var n = Du(this.eventList, ["cb", e]); n >= 0 && this.eventList.splice(n, 1); } }, { key: "destroy", value: ((t = p( d().mark(function t() { var e, n; return d().wrap( function (t) { for (; ;) switch ((t.prev = t.next)) { case 0: if (this.player) { t.next = 2; break; } return t.abrupt("return"); case 2: this.$emitter.all.clear(), null === (e = this.player) || void 0 === e || e.destroy(), null === (n = this.$reporter) || void 0 === n || n.destroy(), clearInterval(this.adTimer), (document.querySelector(this.el).innerHTML = ""), this.$logger.log("destroy", this.app); case 8: case "end": return t.stop(); } }, t, this ); }) )), function () { return t.apply(this, arguments); }) } ] ); var t, e, n; })(), dp = m(function t(e, n) { var i; if ( (f(this, t), g(this, "version", "1.3.0"), g(this, "playerType", M), (this.playerType = n.playerType || z()), console.log("this.playerType", this.playerType), this.playerType === N) ) i = new lp(e, n); else i = new kh(e, n); return i; }); return ( g(dp, "getPlayerType", z), g(dp, "isSupported", function () { return z() != M; }), g(dp, "getDevice", function () { return I; }), dp ); });