UNPKG

@uploadcare/uc-video

Version:

Uploadcare's UCVideo solution for adaptive bitrate streaming

1,591 lines (1,590 loc) 1.3 MB
var nn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function hr(s) { return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s; } function sm(s) { if (Object.prototype.hasOwnProperty.call(s, "__esModule")) return s; var e = s.default; if (typeof e == "function") { var t = function i() { var r = !1; try { r = this instanceof i; } catch { } return r ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments); }; t.prototype = e.prototype; } else t = {}; return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(s).forEach(function(i) { var r = Object.getOwnPropertyDescriptor(s, i); Object.defineProperty(t, i, r.get ? r : { enumerable: !0, get: function() { return s[i]; } }); }), t; } var ha, Gl; function kn() { if (Gl) return ha; Gl = 1; var s; return typeof window < "u" ? s = window : typeof nn < "u" ? s = nn : typeof self < "u" ? s = self : s = {}, ha = s, ha; } var rm = kn(); const w = /* @__PURE__ */ hr(rm), nm = {}, am = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: nm }, Symbol.toStringTag, { value: "Module" })), om = /* @__PURE__ */ sm(am); var fa, Wl; function Sc() { if (Wl) return fa; Wl = 1; var s = typeof nn < "u" ? nn : typeof window < "u" ? window : {}, e = om, t; return typeof document < "u" ? t = document : (t = s["__GLOBAL_DOCUMENT_CACHE@4"], t || (t = s["__GLOBAL_DOCUMENT_CACHE@4"] = e)), fa = t, fa; } var lm = Sc(); const se = /* @__PURE__ */ hr(lm); var Gr = { exports: {} }, pa = { exports: {} }, Xl; function um() { return Xl || (Xl = 1, (function(s) { function e() { return s.exports = e = Object.assign ? Object.assign.bind() : function(t) { for (var i = 1; i < arguments.length; i++) { var r = arguments[i]; for (var n in r) ({}).hasOwnProperty.call(r, n) && (t[n] = r[n]); } return t; }, s.exports.__esModule = !0, s.exports.default = s.exports, e.apply(null, arguments); } s.exports = e, s.exports.__esModule = !0, s.exports.default = s.exports; })(pa)), pa.exports; } var ma, Kl; function cm() { if (Kl) return ma; Kl = 1, ma = e; var s = Object.prototype.toString; function e(t) { if (!t) return !1; var i = s.call(t); return i === "[object Function]" || typeof t == "function" && i !== "[object RegExp]" || typeof window < "u" && // IE8 and below (t === window.setTimeout || t === window.alert || t === window.confirm || t === window.prompt); } return ma; } var ga, Yl; function dm() { if (Yl) return ga; Yl = 1; function s(r, n) { var a = typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"]; if (a) return (a = a.call(r)).next.bind(a); if (Array.isArray(r) || (a = e(r)) || n) { a && (r = a); var l = 0; return function() { return l >= r.length ? { done: !0 } : { done: !1, value: r[l++] }; }; } throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`); } function e(r, n) { if (r) { if (typeof r == "string") return t(r, n); var a = Object.prototype.toString.call(r).slice(8, -1); if (a === "Object" && r.constructor && (a = r.constructor.name), a === "Map" || a === "Set") return Array.from(r); if (a === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)) return t(r, n); } } function t(r, n) { (n == null || n > r.length) && (n = r.length); for (var a = 0, l = new Array(n); a < n; a++) l[a] = r[a]; return l; } var i = /* @__PURE__ */ (function() { function r() { this.typeToInterceptorsMap_ = /* @__PURE__ */ new Map(), this.enabled_ = !1; } var n = r.prototype; return n.getIsEnabled = function() { return this.enabled_; }, n.enable = function() { this.enabled_ = !0; }, n.disable = function() { this.enabled_ = !1; }, n.reset = function() { this.typeToInterceptorsMap_ = /* @__PURE__ */ new Map(), this.enabled_ = !1; }, n.addInterceptor = function(l, c) { this.typeToInterceptorsMap_.has(l) || this.typeToInterceptorsMap_.set(l, /* @__PURE__ */ new Set()); var f = this.typeToInterceptorsMap_.get(l); return f.has(c) ? !1 : (f.add(c), !0); }, n.removeInterceptor = function(l, c) { var f = this.typeToInterceptorsMap_.get(l); return f && f.has(c) ? (f.delete(c), !0) : !1; }, n.clearInterceptorsByType = function(l) { var c = this.typeToInterceptorsMap_.get(l); return c ? (this.typeToInterceptorsMap_.delete(l), this.typeToInterceptorsMap_.set(l, /* @__PURE__ */ new Set()), !0) : !1; }, n.clear = function() { return this.typeToInterceptorsMap_.size ? (this.typeToInterceptorsMap_ = /* @__PURE__ */ new Map(), !0) : !1; }, n.getForType = function(l) { return this.typeToInterceptorsMap_.get(l) || /* @__PURE__ */ new Set(); }, n.execute = function(l, c) { for (var f = this.getForType(l), g = s(f), y; !(y = g()).done; ) { var k = y.value; try { c = k(c); } catch { } } return c; }, r; })(); return ga = i, ga; } var va, Ql; function hm() { if (Ql) return va; Ql = 1; var s = /* @__PURE__ */ (function() { function t() { this.maxAttempts_ = 1, this.delayFactor_ = 0.1, this.fuzzFactor_ = 0.1, this.initialDelay_ = 1e3, this.enabled_ = !1; } var i = t.prototype; return i.getIsEnabled = function() { return this.enabled_; }, i.enable = function() { this.enabled_ = !0; }, i.disable = function() { this.enabled_ = !1; }, i.reset = function() { this.maxAttempts_ = 1, this.delayFactor_ = 0.1, this.fuzzFactor_ = 0.1, this.initialDelay_ = 1e3, this.enabled_ = !1; }, i.getMaxAttempts = function() { return this.maxAttempts_; }, i.setMaxAttempts = function(n) { this.maxAttempts_ = n; }, i.getDelayFactor = function() { return this.delayFactor_; }, i.setDelayFactor = function(n) { this.delayFactor_ = n; }, i.getFuzzFactor = function() { return this.fuzzFactor_; }, i.setFuzzFactor = function(n) { this.fuzzFactor_ = n; }, i.getInitialDelay = function() { return this.initialDelay_; }, i.setInitialDelay = function(n) { this.initialDelay_ = n; }, i.createRetry = function(n) { var a = n === void 0 ? {} : n, l = a.maxAttempts, c = a.delayFactor, f = a.fuzzFactor, g = a.initialDelay; return new e({ maxAttempts: l || this.maxAttempts_, delayFactor: c || this.delayFactor_, fuzzFactor: f || this.fuzzFactor_, initialDelay: g || this.initialDelay_ }); }, t; })(), e = /* @__PURE__ */ (function() { function t(r) { this.maxAttempts_ = r.maxAttempts, this.delayFactor_ = r.delayFactor, this.fuzzFactor_ = r.fuzzFactor, this.currentDelay_ = r.initialDelay, this.currentAttempt_ = 1; } var i = t.prototype; return i.moveToNextAttempt = function() { this.currentAttempt_++; var n = this.currentDelay_ * this.delayFactor_; this.currentDelay_ = this.currentDelay_ + n; }, i.shouldRetry = function() { return this.currentAttempt_ < this.maxAttempts_; }, i.getCurrentDelay = function() { return this.currentDelay_; }, i.getCurrentMinPossibleDelay = function() { return (1 - this.fuzzFactor_) * this.currentDelay_; }, i.getCurrentMaxPossibleDelay = function() { return (1 + this.fuzzFactor_) * this.currentDelay_; }, i.getCurrentFuzzedDelay = function() { var n = this.getCurrentMinPossibleDelay(), a = this.getCurrentMaxPossibleDelay(); return n + Math.random() * (a - n); }, t; })(); return va = s, va; } var ya, Jl; function fm() { if (Jl) return ya; Jl = 1; var s = kn(), e = function(r, n) { return n === void 0 && (n = !1), function(a, l, c) { if (a) { r(a); return; } if (l.statusCode >= 400 && l.statusCode <= 599) { var f = c; if (n) if (s.TextDecoder) { var g = t(l.headers && l.headers["content-type"]); try { f = new TextDecoder(g).decode(c); } catch { } } else f = String.fromCharCode.apply(null, new Uint8Array(c)); r({ cause: f }); return; } r(null, c); }; }; function t(i) { return i === void 0 && (i = ""), i.toLowerCase().split(";").reduce(function(r, n) { var a = n.split("="), l = a[0], c = a[1]; return l.trim() === "charset" ? c.trim() : r; }, "utf-8"); } return ya = e, ya; } var Zl; function pm() { if (Zl) return Gr.exports; Zl = 1; var s = kn(), e = um(), t = cm(), i = dm(), r = hm(); f.httpHandler = fm(), f.requestInterceptorsStorage = new i(), f.responseInterceptorsStorage = new i(), f.retryManager = new r(); var n = function(O) { var _ = {}; return O && O.trim().split(` `).forEach(function(P) { var N = P.indexOf(":"), M = P.slice(0, N).trim().toLowerCase(), j = P.slice(N + 1).trim(); typeof _[M] > "u" ? _[M] = j : Array.isArray(_[M]) ? _[M].push(j) : _[M] = [_[M], j]; }), _; }; Gr.exports = f, Gr.exports.default = f, f.XMLHttpRequest = s.XMLHttpRequest || k, f.XDomainRequest = "withCredentials" in new f.XMLHttpRequest() ? f.XMLHttpRequest : s.XDomainRequest, a(["get", "put", "post", "patch", "head", "delete"], function(C) { f[C === "delete" ? "del" : C] = function(O, _, P) { return _ = c(O, _, P), _.method = C.toUpperCase(), g(_); }; }); function a(C, O) { for (var _ = 0; _ < C.length; _++) O(C[_]); } function l(C) { for (var O in C) if (C.hasOwnProperty(O)) return !1; return !0; } function c(C, O, _) { var P = C; return t(O) ? (_ = O, typeof C == "string" && (P = { uri: C })) : P = e({}, O, { uri: C }), P.callback = _, P; } function f(C, O, _) { return O = c(C, O, _), g(O); } function g(C) { if (typeof C.callback > "u") throw new Error("callback argument missing"); if (C.requestType && f.requestInterceptorsStorage.getIsEnabled()) { var O = { uri: C.uri || C.url, headers: C.headers || {}, body: C.body, metadata: C.metadata || {}, retry: C.retry, timeout: C.timeout }, _ = f.requestInterceptorsStorage.execute(C.requestType, O); C.uri = _.uri, C.headers = _.headers, C.body = _.body, C.metadata = _.metadata, C.retry = _.retry, C.timeout = _.timeout; } var P = !1, N = function(Z, J, te) { P || (P = !0, C.callback(Z, J, te)); }; function M() { F.readyState === 4 && !f.responseInterceptorsStorage.getIsEnabled() && setTimeout(L, 0); } function j() { var W = void 0; if (F.response ? W = F.response : W = F.responseText || y(F), Q) try { W = JSON.parse(W); } catch { } return W; } function z(W) { if (clearTimeout(ie), clearTimeout(C.retryTimeout), W instanceof Error || (W = new Error("" + (W || "Unknown XMLHttpRequest Error"))), W.statusCode = 0, !Y && f.retryManager.getIsEnabled() && C.retry && C.retry.shouldRetry()) { C.retryTimeout = setTimeout(function() { C.retry.moveToNextAttempt(), C.xhr = F, g(C); }, C.retry.getCurrentFuzzedDelay()); return; } if (C.requestType && f.responseInterceptorsStorage.getIsEnabled()) { var Z = { headers: re.headers || {}, body: re.body, responseUrl: F.responseURL, responseType: F.responseType }, J = f.responseInterceptorsStorage.execute(C.requestType, Z); re.body = J.body, re.headers = J.headers; } return N(W, re); } function L() { if (!Y) { var W; clearTimeout(ie), clearTimeout(C.retryTimeout), C.useXDR && F.status === void 0 ? W = 200 : W = F.status === 1223 ? 204 : F.status; var Z = re, J = null; if (W !== 0 ? (Z = { body: j(), statusCode: W, method: E, headers: {}, url: b, rawRequest: F }, F.getAllResponseHeaders && (Z.headers = n(F.getAllResponseHeaders()))) : J = new Error("Internal XMLHttpRequest Error"), C.requestType && f.responseInterceptorsStorage.getIsEnabled()) { var te = { headers: Z.headers || {}, body: Z.body, responseUrl: F.responseURL, responseType: F.responseType }, ee = f.responseInterceptorsStorage.execute(C.requestType, te); Z.body = ee.body, Z.headers = ee.headers; } return N(J, Z, Z.body); } } var F = C.xhr || null; F || (C.cors || C.useXDR ? F = new f.XDomainRequest() : F = new f.XMLHttpRequest()); var $, Y, b = F.url = C.uri || C.url, E = F.method = C.method || "GET", U = C.body || C.data, V = F.headers = C.headers || {}, q = !!C.sync, Q = !1, ie, re = { body: void 0, headers: {}, statusCode: 0, method: E, url: b, rawRequest: F }; if ("json" in C && C.json !== !1 && (Q = !0, V.accept || V.Accept || (V.Accept = "application/json"), E !== "GET" && E !== "HEAD" && (V["content-type"] || V["Content-Type"] || (V["Content-Type"] = "application/json"), U = JSON.stringify(C.json === !0 ? U : C.json))), F.onreadystatechange = M, F.onload = L, F.onerror = z, F.onprogress = function() { }, F.onabort = function() { Y = !0, clearTimeout(C.retryTimeout); }, F.ontimeout = z, F.open(E, b, !q, C.username, C.password), q || (F.withCredentials = !!C.withCredentials), !q && C.timeout > 0 && (ie = setTimeout(function() { if (!Y) { Y = !0, F.abort("timeout"); var W = new Error("XMLHttpRequest timeout"); W.code = "ETIMEDOUT", z(W); } }, C.timeout)), F.setRequestHeader) for ($ in V) V.hasOwnProperty($) && F.setRequestHeader($, V[$]); else if (C.headers && !l(C.headers)) throw new Error("Headers cannot be set on an XDomainRequest object"); return "responseType" in C && (F.responseType = C.responseType), "beforeSend" in C && typeof C.beforeSend == "function" && C.beforeSend(F), F.send(U || null), F; } function y(C) { try { if (C.responseType === "document") return C.responseXML; var O = C.responseXML && C.responseXML.documentElement.nodeName === "parsererror"; if (C.responseType === "" && !O) return C.responseXML; } catch { } return null; } function k() { } return Gr.exports; } var mm = pm(); const Ec = /* @__PURE__ */ hr(mm); var _a = { exports: {} }, ba, eu; function gm() { if (eu) return ba; eu = 1; var s = Sc(), e = Object.create || /* @__PURE__ */ (function() { function b() { } return function(E) { if (arguments.length !== 1) throw new Error("Object.create shim only accepts one parameter."); return b.prototype = E, new b(); }; })(); function t(b, E) { this.name = "ParsingError", this.code = b.code, this.message = E || b.message; } t.prototype = e(Error.prototype), t.prototype.constructor = t, t.Errors = { BadSignature: { code: 0, message: "Malformed WebVTT signature." }, BadTimeStamp: { code: 1, message: "Malformed time stamp." } }; function i(b) { function E(V, q, Q, ie) { return (V | 0) * 3600 + (q | 0) * 60 + (Q | 0) + (ie | 0) / 1e3; } var U = b.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/); return U ? U[3] ? E(U[1], U[2], U[3].replace(":", ""), U[4]) : U[1] > 59 ? E(U[1], U[2], 0, U[4]) : E(0, U[1], U[2], U[4]) : null; } function r() { this.values = e(null); } r.prototype = { // Only accept the first assignment to any key. set: function(b, E) { !this.get(b) && E !== "" && (this.values[b] = E); }, // Return the value for a key, or a default value. // If 'defaultKey' is passed then 'dflt' is assumed to be an object with // a number of possible default values as properties where 'defaultKey' is // the key of the property that will be chosen; otherwise it's assumed to be // a single value. get: function(b, E, U) { return U ? this.has(b) ? this.values[b] : E[U] : this.has(b) ? this.values[b] : E; }, // Check whether we have a value for a key. has: function(b) { return b in this.values; }, // Accept a setting if its one of the given alternatives. alt: function(b, E, U) { for (var V = 0; V < U.length; ++V) if (E === U[V]) { this.set(b, E); break; } }, // Accept a setting if its a valid (signed) integer. integer: function(b, E) { /^-?\d+$/.test(E) && this.set(b, parseInt(E, 10)); }, // Accept a setting if its a valid percentage. percent: function(b, E) { return E.match(/^([\d]{1,3})(\.[\d]*)?%$/) && (E = parseFloat(E), E >= 0 && E <= 100) ? (this.set(b, E), !0) : !1; } }; function n(b, E, U, V) { var q = V ? b.split(V) : [b]; for (var Q in q) if (typeof q[Q] == "string") { var ie = q[Q].split(U); if (ie.length === 2) { var re = ie[0].trim(), W = ie[1].trim(); E(re, W); } } } function a(b, E, U) { var V = b; function q() { var re = i(b); if (re === null) throw new t( t.Errors.BadTimeStamp, "Malformed timestamp: " + V ); return b = b.replace(/^[^\sa-zA-Z-]+/, ""), re; } function Q(re, W) { var Z = new r(); n(re, function(J, te) { switch (J) { case "region": for (var ee = U.length - 1; ee >= 0; ee--) if (U[ee].id === te) { Z.set(J, U[ee].region); break; } break; case "vertical": Z.alt(J, te, ["rl", "lr"]); break; case "line": var fe = te.split(","), me = fe[0]; Z.integer(J, me), Z.percent(J, me) && Z.set("snapToLines", !1), Z.alt(J, me, ["auto"]), fe.length === 2 && Z.alt("lineAlign", fe[1], ["start", "center", "end"]); break; case "position": fe = te.split(","), Z.percent(J, fe[0]), fe.length === 2 && Z.alt("positionAlign", fe[1], ["start", "center", "end"]); break; case "size": Z.percent(J, te); break; case "align": Z.alt(J, te, ["start", "center", "end", "left", "right"]); break; } }, /:/, /\s/), W.region = Z.get("region", null), W.vertical = Z.get("vertical", ""); try { W.line = Z.get("line", "auto"); } catch { } W.lineAlign = Z.get("lineAlign", "start"), W.snapToLines = Z.get("snapToLines", !0), W.size = Z.get("size", 100); try { W.align = Z.get("align", "center"); } catch { W.align = Z.get("align", "middle"); } try { W.position = Z.get("position", "auto"); } catch { W.position = Z.get("position", { start: 0, left: 0, center: 50, middle: 50, end: 100, right: 100 }, W.align); } W.positionAlign = Z.get("positionAlign", { start: "start", left: "start", center: "center", middle: "center", end: "end", right: "end" }, W.align); } function ie() { b = b.replace(/^\s+/, ""); } if (ie(), E.startTime = q(), ie(), b.substr(0, 3) !== "-->") throw new t( t.Errors.BadTimeStamp, "Malformed time stamp (time stamps must be separated by '-->'): " + V ); b = b.substr(3), ie(), E.endTime = q(), ie(), Q(b, E); } var l = s.createElement && s.createElement("textarea"), c = { c: "span", i: "i", b: "b", u: "u", ruby: "ruby", rt: "rt", v: "span", lang: "span" }, f = { white: "rgba(255,255,255,1)", lime: "rgba(0,255,0,1)", cyan: "rgba(0,255,255,1)", red: "rgba(255,0,0,1)", yellow: "rgba(255,255,0,1)", magenta: "rgba(255,0,255,1)", blue: "rgba(0,0,255,1)", black: "rgba(0,0,0,1)" }, g = { v: "title", lang: "lang" }, y = { rt: "ruby" }; function k(b, E) { function U() { if (!E) return null; function me(he) { return E = E.substr(he.length), he; } var ve = E.match(/^([^<]*)(<[^>]*>?)?/); return me(ve[1] ? ve[1] : ve[2]); } function V(me) { return l.innerHTML = me, me = l.textContent, l.textContent = "", me; } function q(me, ve) { return !y[ve.localName] || y[ve.localName] === me.localName; } function Q(me, ve) { var he = c[me]; if (!he) return null; var Ke = b.document.createElement(he), Je = g[me]; return Je && ve && (Ke[Je] = ve.trim()), Ke; } for (var ie = b.document.createElement("div"), re = ie, W, Z = []; (W = U()) !== null; ) { if (W[0] === "<") { if (W[1] === "/") { Z.length && Z[Z.length - 1] === W.substr(2).replace(">", "") && (Z.pop(), re = re.parentNode); continue; } var J = i(W.substr(1, W.length - 2)), te; if (J) { te = b.document.createProcessingInstruction("timestamp", J), re.appendChild(te); continue; } var ee = W.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/); if (!ee || (te = Q(ee[1], ee[3]), !te) || !q(re, te)) continue; if (ee[2]) { var fe = ee[2].split("."); fe.forEach(function(me) { var ve = /^bg_/.test(me), he = ve ? me.slice(3) : me; if (f.hasOwnProperty(he)) { var Ke = ve ? "background-color" : "color", Je = f[he]; te.style[Ke] = Je; } }), te.className = fe.join(" "); } Z.push(ee[1]), re.appendChild(te), re = te; continue; } re.appendChild(b.document.createTextNode(V(W))); } return ie; } var C = [ [1470, 1470], [1472, 1472], [1475, 1475], [1478, 1478], [1488, 1514], [1520, 1524], [1544, 1544], [1547, 1547], [1549, 1549], [1563, 1563], [1566, 1610], [1645, 1647], [1649, 1749], [1765, 1766], [1774, 1775], [1786, 1805], [1807, 1808], [1810, 1839], [1869, 1957], [1969, 1969], [1984, 2026], [2036, 2037], [2042, 2042], [2048, 2069], [2074, 2074], [2084, 2084], [2088, 2088], [2096, 2110], [2112, 2136], [2142, 2142], [2208, 2208], [2210, 2220], [8207, 8207], [64285, 64285], [64287, 64296], [64298, 64310], [64312, 64316], [64318, 64318], [64320, 64321], [64323, 64324], [64326, 64449], [64467, 64829], [64848, 64911], [64914, 64967], [65008, 65020], [65136, 65140], [65142, 65276], [67584, 67589], [67592, 67592], [67594, 67637], [67639, 67640], [67644, 67644], [67647, 67669], [67671, 67679], [67840, 67867], [67872, 67897], [67903, 67903], [67968, 68023], [68030, 68031], [68096, 68096], [68112, 68115], [68117, 68119], [68121, 68147], [68160, 68167], [68176, 68184], [68192, 68223], [68352, 68405], [68416, 68437], [68440, 68466], [68472, 68479], [68608, 68680], [126464, 126467], [126469, 126495], [126497, 126498], [126500, 126500], [126503, 126503], [126505, 126514], [126516, 126519], [126521, 126521], [126523, 126523], [126530, 126530], [126535, 126535], [126537, 126537], [126539, 126539], [126541, 126543], [126545, 126546], [126548, 126548], [126551, 126551], [126553, 126553], [126555, 126555], [126557, 126557], [126559, 126559], [126561, 126562], [126564, 126564], [126567, 126570], [126572, 126578], [126580, 126583], [126585, 126588], [126590, 126590], [126592, 126601], [126603, 126619], [126625, 126627], [126629, 126633], [126635, 126651], [1114109, 1114109] ]; function O(b) { for (var E = 0; E < C.length; E++) { var U = C[E]; if (b >= U[0] && b <= U[1]) return !0; } return !1; } function _(b) { var E = [], U = "", V; if (!b || !b.childNodes) return "ltr"; function q(re, W) { for (var Z = W.childNodes.length - 1; Z >= 0; Z--) re.push(W.childNodes[Z]); } function Q(re) { if (!re || !re.length) return null; var W = re.pop(), Z = W.textContent || W.innerText; if (Z) { var J = Z.match(/^.*(\n|\r)/); return J ? (re.length = 0, J[0]) : Z; } if (W.tagName === "ruby") return Q(re); if (W.childNodes) return q(re, W), Q(re); } for (q(E, b); U = Q(E); ) for (var ie = 0; ie < U.length; ie++) if (V = U.charCodeAt(ie), O(V)) return "rtl"; return "ltr"; } function P(b) { if (typeof b.line == "number" && (b.snapToLines || b.line >= 0 && b.line <= 100)) return b.line; if (!b.track || !b.track.textTrackList || !b.track.textTrackList.mediaElement) return -1; for (var E = b.track, U = E.textTrackList, V = 0, q = 0; q < U.length && U[q] !== E; q++) U[q].mode === "showing" && V++; return ++V * -1; } function N() { } N.prototype.applyStyles = function(b, E) { E = E || this.div; for (var U in b) b.hasOwnProperty(U) && (E.style[U] = b[U]); }, N.prototype.formatStyle = function(b, E) { return b === 0 ? 0 : b + E; }; function M(b, E, U) { N.call(this), this.cue = E, this.cueDiv = k(b, E.text); var V = { color: "rgba(255, 255, 255, 1)", backgroundColor: "rgba(0, 0, 0, 0.8)", position: "relative", left: 0, right: 0, top: 0, bottom: 0, display: "inline", writingMode: E.vertical === "" ? "horizontal-tb" : E.vertical === "lr" ? "vertical-lr" : "vertical-rl", unicodeBidi: "plaintext" }; this.applyStyles(V, this.cueDiv), this.div = b.document.createElement("div"), V = { direction: _(this.cueDiv), writingMode: E.vertical === "" ? "horizontal-tb" : E.vertical === "lr" ? "vertical-lr" : "vertical-rl", unicodeBidi: "plaintext", textAlign: E.align === "middle" ? "center" : E.align, font: U.font, whiteSpace: "pre-line", position: "absolute" }, this.applyStyles(V), this.div.appendChild(this.cueDiv); var q = 0; switch (E.positionAlign) { case "start": case "line-left": q = E.position; break; case "center": q = E.position - E.size / 2; break; case "end": case "line-right": q = E.position - E.size; break; } E.vertical === "" ? this.applyStyles({ left: this.formatStyle(q, "%"), width: this.formatStyle(E.size, "%") }) : this.applyStyles({ top: this.formatStyle(q, "%"), height: this.formatStyle(E.size, "%") }), this.move = function(Q) { this.applyStyles({ top: this.formatStyle(Q.top, "px"), bottom: this.formatStyle(Q.bottom, "px"), left: this.formatStyle(Q.left, "px"), right: this.formatStyle(Q.right, "px"), height: this.formatStyle(Q.height, "px"), width: this.formatStyle(Q.width, "px") }); }; } M.prototype = e(N.prototype), M.prototype.constructor = M; function j(b) { var E, U, V, q; if (b.div) { U = b.div.offsetHeight, V = b.div.offsetWidth, q = b.div.offsetTop; var Q = (Q = b.div.childNodes) && (Q = Q[0]) && Q.getClientRects && Q.getClientRects(); b = b.div.getBoundingClientRect(), E = Q ? Math.max(Q[0] && Q[0].height || 0, b.height / Q.length) : 0; } this.left = b.left, this.right = b.right, this.top = b.top || q, this.height = b.height || U, this.bottom = b.bottom || q + (b.height || U), this.width = b.width || V, this.lineHeight = E !== void 0 ? E : b.lineHeight; } j.prototype.move = function(b, E) { switch (E = E !== void 0 ? E : this.lineHeight, b) { case "+x": this.left += E, this.right += E; break; case "-x": this.left -= E, this.right -= E; break; case "+y": this.top += E, this.bottom += E; break; case "-y": this.top -= E, this.bottom -= E; break; } }, j.prototype.overlaps = function(b) { return this.left < b.right && this.right > b.left && this.top < b.bottom && this.bottom > b.top; }, j.prototype.overlapsAny = function(b) { for (var E = 0; E < b.length; E++) if (this.overlaps(b[E])) return !0; return !1; }, j.prototype.within = function(b) { return this.top >= b.top && this.bottom <= b.bottom && this.left >= b.left && this.right <= b.right; }, j.prototype.overlapsOppositeAxis = function(b, E) { switch (E) { case "+x": return this.left < b.left; case "-x": return this.right > b.right; case "+y": return this.top < b.top; case "-y": return this.bottom > b.bottom; } }, j.prototype.intersectPercentage = function(b) { var E = Math.max(0, Math.min(this.right, b.right) - Math.max(this.left, b.left)), U = Math.max(0, Math.min(this.bottom, b.bottom) - Math.max(this.top, b.top)), V = E * U; return V / (this.height * this.width); }, j.prototype.toCSSCompatValues = function(b) { return { top: this.top - b.top, bottom: b.bottom - this.bottom, left: this.left - b.left, right: b.right - this.right, height: this.height, width: this.width }; }, j.getSimpleBoxPosition = function(b) { var E = b.div ? b.div.offsetHeight : b.tagName ? b.offsetHeight : 0, U = b.div ? b.div.offsetWidth : b.tagName ? b.offsetWidth : 0, V = b.div ? b.div.offsetTop : b.tagName ? b.offsetTop : 0; b = b.div ? b.div.getBoundingClientRect() : b.tagName ? b.getBoundingClientRect() : b; var q = { left: b.left, right: b.right, top: b.top || V, height: b.height || E, bottom: b.bottom || V + (b.height || E), width: b.width || U }; return q; }; function z(b, E, U, V) { function q(he, Ke) { for (var Je, qe = new j(he), Ze = 1, bt = 0; bt < Ke.length; bt++) { for (; he.overlapsOppositeAxis(U, Ke[bt]) || he.within(U) && he.overlapsAny(V); ) he.move(Ke[bt]); if (he.within(U)) return he; var Ye = he.intersectPercentage(U); Ze > Ye && (Je = new j(he), Ze = Ye), he = new j(qe); } return Je || qe; } var Q = new j(E), ie = E.cue, re = P(ie), W = []; if (ie.snapToLines) { var Z; switch (ie.vertical) { case "": W = ["+y", "-y"], Z = "height"; break; case "rl": W = ["+x", "-x"], Z = "width"; break; case "lr": W = ["-x", "+x"], Z = "width"; break; } var J = Q.lineHeight, te = J * Math.round(re), ee = U[Z] + J, fe = W[0]; Math.abs(te) > ee && (te = te < 0 ? -1 : 1, te *= Math.ceil(ee / J) * J), re < 0 && (te += ie.vertical === "" ? U.height : U.width, W = W.reverse()), Q.move(fe, te); } else { var me = Q.lineHeight / U.height * 100; switch (ie.lineAlign) { case "center": re -= me / 2; break; case "end": re -= me; break; } switch (ie.vertical) { case "": E.applyStyles({ top: E.formatStyle(re, "%") }); break; case "rl": E.applyStyles({ left: E.formatStyle(re, "%") }); break; case "lr": E.applyStyles({ right: E.formatStyle(re, "%") }); break; } W = ["+y", "-x", "+x", "-y"], Q = new j(E); } var ve = q(Q, W); E.move(ve.toCSSCompatValues(U)); } function L() { } L.StringDecoder = function() { return { decode: function(b) { if (!b) return ""; if (typeof b != "string") throw new Error("Error - expected string data."); return decodeURIComponent(encodeURIComponent(b)); } }; }, L.convertCueToDOMTree = function(b, E) { return !b || !E ? null : k(b, E); }; var F = 0.05, $ = "sans-serif", Y = "1.5%"; return L.processCues = function(b, E, U) { if (!b || !E || !U) return null; for (; U.firstChild; ) U.removeChild(U.firstChild); var V = b.document.createElement("div"); V.style.position = "absolute", V.style.left = "0", V.style.right = "0", V.style.top = "0", V.style.bottom = "0", V.style.margin = Y, U.appendChild(V); function q(J) { for (var te = 0; te < J.length; te++) if (J[te].hasBeenReset || !J[te].displayState) return !0; return !1; } if (!q(E)) { for (var Q = 0; Q < E.length; Q++) V.appendChild(E[Q].displayState); return; } var ie = [], re = j.getSimpleBoxPosition(V), W = Math.round(re.height * F * 100) / 100, Z = { font: W + "px " + $ }; (function() { for (var J, te, ee = 0; ee < E.length; ee++) te = E[ee], J = new M(b, te, Z), V.appendChild(J.div), z(b, J, re, ie), te.displayState = J.div, ie.push(j.getSimpleBoxPosition(J)); })(); }, L.Parser = function(b, E, U) { U || (U = E, E = {}), E || (E = {}), this.window = b, this.vttjs = E, this.state = "INITIAL", this.buffer = "", this.decoder = U || new TextDecoder("utf8"), this.regionList = []; }, L.Parser.prototype = { // If the error is a ParsingError then report it to the consumer if // possible. If it's not a ParsingError then throw it like normal. reportOrThrowError: function(b) { if (b instanceof t) this.onparsingerror && this.onparsingerror(b); else throw b; }, parse: function(b) { var E = this; b && (E.buffer += E.decoder.decode(b, { stream: !0 })); function U() { for (var J = E.buffer, te = 0; te < J.length && J[te] !== "\r" && J[te] !== ` `; ) ++te; var ee = J.substr(0, te); return J[te] === "\r" && ++te, J[te] === ` ` && ++te, E.buffer = J.substr(te), ee; } function V(J) { var te = new r(); if (n(J, function(fe, me) { switch (fe) { case "id": te.set(fe, me); break; case "width": te.percent(fe, me); break; case "lines": te.integer(fe, me); break; case "regionanchor": case "viewportanchor": var ve = me.split(","); if (ve.length !== 2) break; var he = new r(); if (he.percent("x", ve[0]), he.percent("y", ve[1]), !he.has("x") || !he.has("y")) break; te.set(fe + "X", he.get("x")), te.set(fe + "Y", he.get("y")); break; case "scroll": te.alt(fe, me, ["up"]); break; } }, /=/, /\s/), te.has("id")) { var ee = new (E.vttjs.VTTRegion || E.window.VTTRegion)(); ee.width = te.get("width", 100), ee.lines = te.get("lines", 3), ee.regionAnchorX = te.get("regionanchorX", 0), ee.regionAnchorY = te.get("regionanchorY", 100), ee.viewportAnchorX = te.get("viewportanchorX", 0), ee.viewportAnchorY = te.get("viewportanchorY", 100), ee.scroll = te.get("scroll", ""), E.onregion && E.onregion(ee), E.regionList.push({ id: te.get("id"), region: ee }); } } function q(J) { var te = new r(); n(J, function(ee, fe) { switch (ee) { case "MPEGT": te.integer(ee + "S", fe); break; case "LOCA": te.set(ee + "L", i(fe)); break; } }, /[^\d]:/, /,/), E.ontimestampmap && E.ontimestampmap({ MPEGTS: te.get("MPEGTS"), LOCAL: te.get("LOCAL") }); } function Q(J) { J.match(/X-TIMESTAMP-MAP/) ? n(J, function(te, ee) { te === "X-TIMESTAMP-MAP" && q(ee); }, /=/) : n(J, function(te, ee) { te === "Region" && V(ee); }, /:/); } try { var ie; if (E.state === "INITIAL") { if (!/\r\n|\n/.test(E.buffer)) return this; ie = U(); var re = ie.match(/^WEBVTT([ \t].*)?$/); if (!re || !re[0]) throw new t(t.Errors.BadSignature); E.state = "HEADER"; } for (var W = !1; E.buffer; ) { if (!/\r\n|\n/.test(E.buffer)) return this; switch (W ? W = !1 : ie = U(), E.state) { case "HEADER": /:/.test(ie) ? Q(ie) : ie || (E.state = "ID"); continue; case "NOTE": ie || (E.state = "ID"); continue; case "ID": if (/^NOTE($|[ \t])/.test(ie)) { E.state = "NOTE"; break; } if (!ie) continue; E.cue = new (E.vttjs.VTTCue || E.window.VTTCue)(0, 0, ""); try { E.cue.align = "center"; } catch { E.cue.align = "middle"; } if (E.state = "CUE", ie.indexOf("-->") === -1) { E.cue.id = ie; continue; } // Process line as start of a cue. /*falls through*/ case "CUE": try { a(ie, E.cue, E.regionList); } catch (J) { E.reportOrThrowError(J), E.cue = null, E.state = "BADCUE"; continue; } E.state = "CUETEXT"; continue; case "CUETEXT": var Z = ie.indexOf("-->") !== -1; if (!ie || Z && (W = !0)) { E.oncue && E.oncue(E.cue), E.cue = null, E.state = "ID"; continue; } E.cue.text && (E.cue.text += ` `), E.cue.text += ie.replace(/\u2028/g, ` `).replace(/u2029/g, ` `); continue; case "BADCUE": ie || (E.state = "ID"); continue; } } } catch (J) { E.reportOrThrowError(J), E.state === "CUETEXT" && E.cue && E.oncue && E.oncue(E.cue), E.cue = null, E.state = E.state === "INITIAL" ? "BADWEBVTT" : "BADCUE"; } return this; }, flush: function() { var b = this; try { if (b.buffer += b.decoder.decode(), (b.cue || b.state === "HEADER") && (b.buffer += ` `, b.parse()), b.state === "INITIAL") throw new t(t.Errors.BadSignature); } catch (E) { b.reportOrThrowError(E); } return b.onflush && b.onflush(), this; } }, ba = L, ba; } var Ta, tu; function vm() { if (tu) return Ta; tu = 1; var s = "auto", e = { "": 1, lr: 1, rl: 1 }, t = { start: 1, center: 1, end: 1, left: 1, right: 1, auto: 1, "line-left": 1, "line-right": 1 }; function i(a) { if (typeof a != "string") return !1; var l = e[a.toLowerCase()]; return l ? a.toLowerCase() : !1; } function r(a) { if (typeof a != "string") return !1; var l = t[a.toLowerCase()]; return l ? a.toLowerCase() : !1; } function n(a, l, c) { this.hasBeenReset = !1; var f = "", g = !1, y = a, k = l, C = c, O = null, _ = "", P = !0, N = "auto", M = "start", j = "auto", z = "auto", L = 100, F = "center"; Object.defineProperties(this, { id: { enumerable: !0, get: function() { return f; }, set: function($) { f = "" + $; } }, pauseOnExit: { enumerable: !0, get: function() { return g; }, set: function($) { g = !!$; } }, startTime: { enumerable: !0, get: function() { return y; }, set: function($) { if (typeof $ != "number") throw new TypeError("Start time must be set to a number."); y = $, this.hasBeenReset = !0; } }, endTime: { enumerable: !0, get: function() { return k; }, set: function($) { if (typeof $ != "number") throw new TypeError("End time must be set to a number."); k = $, this.hasBeenReset = !0; } }, text: { enumerable: !0, get: function() { return C; }, set: function($) { C = "" + $, this.hasBeenReset = !0; } }, region: { enumerable: !0, get: function() { return O; }, set: function($) { O = $, this.hasBeenReset = !0; } }, vertical: { enumerable: !0, get: function() { return _; }, set: function($) { var Y = i($); if (Y === !1) throw new SyntaxError("Vertical: an invalid or illegal direction string was specified."); _ = Y, this.hasBeenReset = !0; } }, snapToLines: { enumerable: !0, get: function() { return P; }, set: function($) { P = !!$, this.hasBeenReset = !0; } }, line: { enumerable: !0, get: function() { return N; }, set: function($) { if (typeof $ != "number" && $ !== s) throw new SyntaxError("Line: an invalid number or illegal string was specified."); N = $, this.hasBeenReset = !0; } }, lineAlign: { enumerable: !0, get: function() { return M; }, set: function($) { var Y = r($); Y ? (M = Y, this.hasBeenReset = !0) : console.warn("lineAlign: an invalid or illegal string was specified."); } }, position: { enumerable: !0, get: function() { return j; }, set: function($) { if ($ < 0 || $ > 100) throw new Error("Position must be between 0 and 100."); j = $, this.hasBeenReset = !0; } }, positionAlign: { enumerable: !0, get: function() { return z; }, set: function($) { var Y = r($); Y ? (z = Y, this.hasBeenReset = !0) : console.warn("positionAlign: an invalid or illegal string was specified."); } }, size: { enumerable: !0, get: function() { return L; }, set: function($) { if ($ < 0 || $ > 100) throw new Error("Size must be between 0 and 100."); L = $, this.hasBeenReset = !0; } }, align: { enumerable: !0, get: function() { return F; }, set: function($) { var Y = r($); if (!Y) throw new SyntaxError("align: an invalid or illegal alignment string was specified."); F = Y, this.hasBeenReset = !0; } } }), this.displayState = void 0; } return n.prototype.getCueAsHTML = function() { return WebVTT.convertCueToDOMTree(window, this.text); }, Ta = n, Ta; } var xa, iu; function ym() { if (iu) return xa; iu = 1; var s = { "": !0, up: !0 }; function e(r) { if (typeof r != "string") return !1; var n = s[r.toLowerCase()]; return n ? r.toLowerCase() : !1; } function t(r) { return typeof r == "number" && r >= 0 && r <= 100; } function i() { var r = 100, n = 3, a = 0, l = 100, c = 0, f = 100, g = ""; Object.defineProperties(this, { width: { enumerable: !0, get: function() { return r; }, set: function(y) { if (!t(y)) throw new Error("Width must be between 0 and 100."); r = y; } }, lines: { enumerable: !0, get: function() { return n; }, set: function(y) { if (typeof y != "number") throw new TypeError("Lines must be set to a number."); n = y; } }, regionAnchorY: { enumerable: !0, get: function() { return l; }, set: function(y) { if (!t(y)) throw new Error("RegionAnchorX must be between 0 and 100."); l = y; } }, regionAnchorX: { enumerable: !0, get: function() { return a; }, set: function(y) { if (!t(y)) throw new Error("RegionAnchorY must be between 0 and 100."); a = y; } }, viewportAnchorY: { enumerable: !0, get: function() { return f; }, set: function(y) { if (!t(y)) throw new Error("ViewportAnchorY must be between 0 and 100."); f = y; } }, viewportAnchorX: { enumerable: !0, get: function() { return c; }, set: function(y) { if (!t(y)) throw new Error("ViewportAnchorX must be between 0 and 100."); c = y; } }, scroll: { enumerable: !0, get: function() { return g; }, set: function(y) { var k = e(y); k === !1 ? console.warn("Scroll: an invalid or illegal string was specified.") : g = k; } } }); } return xa = i, xa; } var su; function _m() { if (su) return _a.exports; su = 1; var s = kn(), e = _a.exports = { WebVTT: gm(), VTTCue: vm(), VTTRegion: ym() }; s.vttjs = e, s.WebVTT = e.WebVTT; var t = e.VTTCue, i = e.VTTRegion, r = s.VTTCue, n = s.VTTRegion; return e.shim = function() { s.VTTCue = t, s.VTTRegion = i; }, e.restore = function() { s.VTTCue = r, s.VTTRegion = n; }, s.VTTCue || e.shim(), _a.exports; } var bm = _m(); const ru = /* @__PURE__ */ hr(bm); function Ue() { return Ue = Object.assign ? Object.assign.bind() : function(s) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var i in t) ({}).hasOwnProperty.call(t, i) && (s[i] = t[i]); } return s; }, Ue.apply(null, arguments); } var nu = "https://example.com", In = function(e, t) { if (/^[a-z]+:/i.test(t)) return t; /^data:/.test(e) && (e = w.location && w.location.href || ""); var i = /^\/\//.test(e), r = !w.location && !/\/\//i.test(e); e = new w.URL(e, w.location || nu); var n = new URL(t, e); return r ? n.href.slice(nu.length) : i ? n.href.slice(n.protocol.length) : n.href; }, bo = /* @__PURE__ */ (function() { function s() { this.listeners = {}; } var e = s.prototype; return e.on = function(i, r) { this.listeners[i] || (this.listeners[i] = []), this.listeners[i].push(r); }, e.off = function(i, r) { if (!this.listeners[i]) return !1; var n = this.listeners[i].indexOf(r); return this.listeners[i] = this.listeners[i].slice(0), this.listeners[i].splice(n, 1), n > -1; }, e.trigger = function(i) { var r = this.listeners[i]; if (r) if (arguments.length === 2) for (var n = r.length, a = 0; a < n; ++a) r[a].call(this, arguments[1]); else for (var l = Array.prototype.slice.call(arguments, 1), c = r.length, f = 0; f < c; ++f) r[f].apply(this, l); }, e.dispose = function() { this.listeners = {}; }, e.pipe = function(i) { this.on("data", function(r) { i.push(r); }); }, s; })(), Tm = function(e) { return w.atob ? w.atob(e) : Buffer.from(e, "base64").toString("binary"); }; function Cc(s) { for (var e = Tm(s), t = new Uint8Array(e.length), i = 0; i < e.length; i++) t[i] = e.charCodeAt(i); return t; } class xm extends bo { constructor() { super(), this.buffer = ""; } /** * Add new data to be parsed. * * @param {string} data the text to process */ push(e) { let t; for (this.buffer += e, t = this.buffer.indexOf(` `); t > -1; t = this.buffer.indexOf(` `)) this.trigger("data", this.buffer.substring(0, t)), this.buffer = this.buffer.substring(t + 1); } } const Sm = " ", Sa = function(s) { const e = /([0-9.]*)?@?([0-9.]*)?/.exec(s || ""), t = {}; return e[1] && (t.length = parseInt(e[1], 10)), e[2] && (t.offset = parseInt(e[2], 10)), t; }, Em = function() { const t = "(?:" + "[^=]*" + ")=(?:" + '"[^"]*"|[^,]*' + ")"; return new RegExp("(?:^|,)(" + t + ")"); }, at = function(s) { const e = {}; if (!s) return e; const t = s.split(Em()); let i = t.length, r; for (; i--; ) t[i] !== "" && (r = /([^=]*)=(.*)/.exec(t[i]).slice(1), r[0] = r[0].replace(/^\s+|\s+$/g, ""), r[1] = r[1].replace(/^\s+|\s+$/g, ""), r[1] = r[1].replace(/^['"](.*)['"]$/g, "$1"), e[r[0]] = r[1]); return e; }, au = (s) => { const e = s.split("x"), t = {}; return e[0] && (t.width = parseInt(e[0], 10)), e[1] && (t.height = parseInt(e[1], 10)), t; }; class Cm extends bo { constructor() { super(), this.customParsers = [], this.tagMappers = []; } /**