1"object" == typeof navigator && 2 (function (e, t) { 3 "object" == typeof exports && "undefined" != typeof module ? (module.exports = t()) : "function" == typeof define && define.amd ? define("Plyr", t) : ((e = "undefined" != typeof globalThis ? globalThis : e || self).Plyr = t()); 4 })(this, function () { 5 "use strict"; 6 function e(e, t, i) { 7 return t in e ? Object.defineProperty(e, t, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : (e[t] = i), e; 8 } 9 function t(e, t) { 10 for (var i = 0; i < t.length; i++) { 11 var s = t[i]; 12 (s.enumerable = s.enumerable || !1), (s.configurable = !0), "value" in s && (s.writable = !0), Object.defineProperty(e, s.key, s); 13 } 14 } 15 function i(e, t, i) { 16 return t in e ? Object.defineProperty(e, t, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : (e[t] = i), e; 17 } 18 function s(e, t) { 19 var i = Object.keys(e); 20 if (Object.getOwnPropertySymbols) { 21 var s = Object.getOwnPropertySymbols(e); 22 t && 23 (s = s.filter(function (t) { 24 return Object.getOwnPropertyDescriptor(e, t).enumerable; 25 })), 26 i.push.apply(i, s); 27 } 28 return i; 29 } 30 function n(e) { 31 for (var t = 1; t < arguments.length; t++) { 32 var n = null != arguments[t] ? arguments[t] : {}; 33 t % 2 34 ? s(Object(n), !0).forEach(function (t) { 35 i(e, t, n[t]); 36 }) 37 : Object.getOwnPropertyDescriptors 38 ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) 39 : s(Object(n)).forEach(function (t) { 40 Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t)); 41 }); 42 } 43 return e; 44 } 45 var a = { addCSS: !0, thumbWidth: 15, watch: !0 }; 46 function l(e, t) { 47 return function () { 48 return Array.from(document.querySelectorAll(t)).includes(this); 49 }.call(e, t); 50 } 51 var o = function (e) { 52 return null != e ? e.constructor : null; 53 }, 54 r = function (e, t) { 55 return !!(e && t && e instanceof t); 56 }, 57 c = function (e) { 58 return null == e; 59 }, 60 h = function (e) { 61 return o(e) === Object; 62 }, 63 u = function (e) { 64 return o(e) === String; 65 }, 66 d = function (e) { 67 return Array.isArray(e); 68 }, 69 m = function (e) { 70 return r(e, NodeList); 71 }, 72 p = u, 73 g = d, 74 f = m, 75 b = function (e) { 76 return r(e, Element); 77 }, 78 y = function (e) { 79 return r(e, Event); 80 }, 81 v = function (e) { 82 return c(e) || ((u(e) || d(e) || m(e)) && !e.length) || (h(e) && !Object.keys(e).length); 83 }; 84 function w(e, t) { 85 if (1 > t) { 86 var i = (function (e) { 87 var t = "".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); 88 return t ? Math.max(0, (t[1] ? t[1].length : 0) - (t[2] ? +t[2] : 0)) : 0; 89 })(t); 90 return parseFloat(e.toFixed(i)); 91 } 92 return Math.round(e / t) * t; 93 } 94 var T = (function () { 95 function e(t, i) { 96 (function (e, t) { 97 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function"); 98 })(this, e), 99 b(t) ? (this.element = t) : p(t) && (this.element = document.querySelector(t)), 100 b(this.element) && v(this.element.rangeTouch) && ((this.config = n({}, a, {}, i)), this.init()); 101 } 102 return ( 103 (function (e, i, s) { 104 i && t(e.prototype, i), s && t(e, s); 105 })( 106 e, 107 [ 108 { 109 key: "init", 110 value: function () { 111 e.enabled && 112 (this.config.addCSS && ((this.element.style.userSelect = "none"), (this.element.style.webKitUserSelect = "none"), (this.element.style.touchAction = "manipulation")), 113 this.listeners(!0), 114 (this.element.rangeTouch = this)); 115 }, 116 }, 117 {
118 key: "destroy", 119 value: function () { 120 e.enabled && 121 (this.config.addCSS && ((this.element.style.userSelect = ""), (this.element.style.webKitUserSelect = ""), (this.element.style.touchAction = "")), this.listeners(!1), (this.element.rangeTouch = null)); 122 }, 123 }, 124 { 125 key: "listeners", 126 value: function (e) { 127 var t = this, 128 i = e ? "addEventListener" : "removeEventListener"; 129 ["touchstart", "touchmove", "touchend"].forEach(function (e) { 130 t.element[i]( 131 e, 132 function (e) { 133 return t.set(e); 134 }, 135 !1 136 ); 137 }); 138 }, 139 }, 140 { 141 key: "get", 142 value: function (t) { 143 if (!e.enabled || !y(t)) return null; 144 var i, 145 s = t.target, 146 n = t.changedTouches[0], 147 a = parseFloat(s.getAttribute("min")) || 0, 148 l = parseFloat(s.getAttribute("max")) || 100, 149 o = parseFloat(s.getAttribute("step")) || 1, 150 r = s.getBoundingClientRect(), 151 c = ((100 / r.width) * (this.config.thumbWidth / 2)) / 100; 152 return 0 > (i = (100 / r.width) * (n.clientX - r.left)) ? (i = 0) : 100 < i && (i = 100), 50 > i ? (i -= (100 - 2 * i) * c) : 50 < i && (i += 2 * (i - 50) * c), a + w((i / 100) * (l - a), o); 153 }, 154 }, 155 { 156 key: "set", 157 value: function (t) { 158 e.enabled && 159 y(t) && 160 !t.target.disabled && 161 (t.preventDefault(), 162 (t.target.value = this.get(t)), 163 (function (e, t) { 164 if (e && t) { 165 var i = new Event(t, { bubbles: !0 }); 166 e.dispatchEvent(i); 167 } 168 })(t.target, "touchend" === t.type ? "change" : "input")); 169 }, 170 }, 171 ], 172 [ 173 { 174 key: "setup", 175 value: function (t) { 176 var i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {}, 177 s = null; 178 if ((v(t) || p(t) ? (s = Array.from(document.querySelectorAll(p(t) ? t : 'input[type="range"]'))) : b(t) ? (s = [t]) : f(t) ? (s = Array.from(t)) : g(t) && (s = t.filter(b)), v(s))) return null; 179 var o = n({}, a, {}, i); 180 if (p(t) && o.watch) { 181 var r = new MutationObserver(function (i) { 182 Array.from(i).forEach(function (i) { 183 Array.from(i.addedNodes).forEach(function (i) { 184 b(i) && l(i, t) && new e(i, o); 185 }); 186 }); 187 }); 188 r.observe(document.body, { childList: !0, subtree: !0 }); 189 } 190 return s.map(function (t) { 191 return new e(t, i); 192 }); 193 }, 194 }, 195 { 196 key: "enabled", 197 get: function () { 198 return "ontouchstart" in document.documentElement; 199 }, 200 }, 201 ] 202 ), 203 e 204 ); 205 })();
206 const k = (e) => (null != e ? e.constructor : null), 207 C = (e, t) => Boolean(e && t && e instanceof t), 208 A = (e) => null == e, 209 S = (e) => k(e) === Object, 210 E = (e) => k(e) === String, 211 P = (e) => k(e) === Function, 212 N = (e) => Array.isArray(e), 213 x = (e) => C(e, NodeList), 214 M = (e) => A(e) || ((E(e) || N(e) || x(e)) && !e.length) || (S(e) && !Object.keys(e).length); 215 var I = A, 216 L = S, 217 $ = (e) => k(e) === Number && !Number.isNaN(e), 218 _ = E, 219 O = (e) => k(e) === Boolean, 220 j = P, 221 q = N, 222 D = x, 223 H = (e) => null !== e && "object" == typeof e && 1 === e.nodeType && "object" == typeof e.style && "object" == typeof e.ownerDocument, 224 F = (e) => C(e, Event), 225 R = (e) => C(e, KeyboardEvent), 226 V = (e) => C(e, TextTrack) || (!A(e) && E(e.kind)), 227 B = (e) => C(e, Promise) && P(e.then), 228 U = (e) => { 229 if (C(e, window.URL)) return !0; 230 if (!E(e)) return !1; 231 let t = e; 232 (e.startsWith("http://") && e.startsWith("https://")) || (t = `http://${e}`); 233 try { 234 return !M(new URL(t).hostname); 235 } catch (e) { 236 return !1; 237 } 238 }, 239 W = M; 240 const z = (() => { 241 const e = document.createElement("span"), 242 t = { WebkitTransition: "webkitTransitionEnd", MozTransition: "transitionend", OTransition: "oTransitionEnd otransitionend", transition: "transitionend" }, 243 i = Object.keys(t).find((t) => void 0 !== e.style[t]); 244 return !!_(i) && t[i]; 245 })(); 246 function K(e, t) { 247 setTimeout(() => { 248 try { 249 (e.hidden = !0), e.offsetHeight, (e.hidden = !1); 250 } catch (e) {} 251 }, t); 252 } 253 const Y = { 254 isIE: Boolean(window.document.documentMode), 255 isEdge: window.navigator.userAgent.includes("Edge"), 256 isWebkit: "WebkitAppearance" in document.documentElement.style && !/Edge/.test(navigator.userAgent), 257 isIPhone: /(iPhone|iPod)/gi.test(navigator.platform), 258 isIos: ("MacIntel" === navigator.platform && navigator.maxTouchPoints > 1) || /(iPad|iPhone|iPod)/gi.test(navigator.platform), 259 }; 260 function Q(e, t) { 261 return t.split(".").reduce((e, t) => e && e[t], e); 262 } 263 function X(e = {}, ...t) { 264 if (!t.length) return e; 265 const i = t.shift(); 266 return L(i)
267 ? (Object.keys(i).forEach((t) => { 268 L(i[t]) ? (Object.keys(e).includes(t) || Object.assign(e, { [t]: {} }), X(e[t], i[t])) : Object.assign(e, { [t]: i[t] }); 269 }), 270 X(e, ...t)) 271 : e; 272 } 273 function J(e, t) { 274 const i = e.length ? e : [e]; 275 Array.from(i) 276 .reverse() 277 .forEach((e, i) => { 278 const s = i > 0 ? t.cloneNode(!0) : t, 279 n = e.parentNode, 280 a = e.nextSibling; 281 s.appendChild(e), a ? n.insertBefore(s, a) : n.appendChild(s); 282 }); 283 } 284 function G(e, t) { 285 H(e) && 286 !W(t) && 287 Object.entries(t) 288 .filter(([, e]) => !I(e)) 289 .forEach(([t, i]) => e.setAttribute(t, i)); 290 } 291 function Z(e, t, i) { 292 const s = document.createElement(e); 293 return L(t) && G(s, t), _(i) && (s.innerText = i), s; 294 } 295 function ee(e, t, i, s) { 296 H(t) && t.appendChild(Z(e, i, s)); 297 } 298 function te(e) { 299 D(e) || q(e) ? Array.from(e).forEach(te) : H(e) && H(e.parentNode) && e.parentNode.removeChild(e); 300 } 301 function ie(e) { 302 if (!H(e)) return; 303 let { length: t } = e.childNodes; 304 for (; t > 0; ) e.removeChild(e.lastChild), (t -= 1); 305 } 306 function se(e, t) { 307 return H(t) && H(t.parentNode) && H(e) ? (t.parentNode.replaceChild(e, t), e) : null; 308 } 309 function ne(e, t) { 310 if (!_(e) || W(e)) return {}; 311 const i = {}, 312 s = X({}, t); 313 return ( 314 e.split(",").forEach((e) => { 315 const t = e.trim(), 316 n = t.replace(".", ""), 317 a = t.replace(/[[\]]/g, "").split("="), 318 [l] = a, 319 o = a.length > 1 ? a[1].replace(/["']/g, "") : ""; 320 switch (t.charAt(0)) { 321 case ".": 322 _(s.class) ? (i.class = `${s.class} ${n}`) : (i.class = n); 323 break; 324 case "#": 325 i.id = t.replace("#", ""); 326 break; 327 case "[": 328 i[l] = o; 329 } 330 }), 331 X(s, i) 332 ); 333 } 334 function ae(e, t) { 335 if (!H(e)) return; 336 let i = t; 337 O(i) || (i = !e.hidden), (e.hidden = i); 338 } 339 function le(e, t, i) { 340 if (D(e)) return Array.from(e).map((e) => le(e, t, i)); 341 if (H(e)) { 342 let s = "toggle"; 343 return void 0 !== i && (s = i ? "add" : "remove"), e.classList[s](t), e.classList.contains(t); 344 } 345 return !1; 346 } 347 function oe(e, t) { 348 return H(e) && e.classList.contains(t); 349 } 350 function re(e, t) { 351 const { prototype: i } = Element; 352 return ( 353 i.matches || 354 i.webkitMatchesSelector || 355 i.mozMatchesSelector || 356 i.msMatchesSelector || 357 function () { 358 return Array.from(document.querySelectorAll(t)).includes(this); 359 } 360 ).call(e, t); 361 } 362 function ce(e) { 363 return this.elements.container.querySelectorAll(e); 364 } 365 function he(e) { 366 return this.elements.container.querySelector(e); 367 } 368 function ue(e = null, t = !1) { 369 H(e) && (e.focus({ preventScroll: !0 }), t && le(e, this.config.classNames.tabFocus)); 370 } 371 const de = { "audio/ogg": "vorbis", "audio/wav": "1", "video/webm": "vp8, vorbis", "video/mp4": "avc1.42E01E, mp4a.40.2", "video/ogg": "theora" }, 372 me = { 373 audio: "canPlayType" in document.createElement("audio"), 374 video: "canPlayType" in document.createElement("video"), 375 check(e, t, i) { 376 const s = Y.isIPhone && i && me.playsinline, 377 n = me[e] || "html5" !== t; 378 return { api: n, ui: n && me.rangeInput && ("video" !== e || !Y.isIPhone || s) }; 379 }, 380 pip: !(Y.isIPhone || (!j(Z("video").webkitSetPresentationMode) && (!document.pictureInPictureEnabled || Z("video").disablePictureInPicture))), 381 airplay: j(window.WebKitPlaybackTargetAvailabilityEvent),
382 playsinline: "playsInline" in document.createElement("video"), 383 mime(e) { 384 if (W(e)) return !1; 385 const [t] = e.split("/"); 386 let i = e; 387 if (!this.isHTML5 || t !== this.type) return !1; 388 Object.keys(de).includes(i) && (i += `; codecs="${de[e]}"`); 389 try { 390 return Boolean(i && this.media.canPlayType(i).replace(/no/, "")); 391 } catch (e) { 392 return !1; 393 } 394 }, 395 textTracks: "textTracks" in document.createElement("video"), 396 rangeInput: (() => { 397 const e = document.createElement("input"); 398 return (e.type = "range"), "range" === e.type; 399 })(), 400 touch: "ontouchstart" in document.documentElement, 401 transitions: !1 !== z, 402 reducedMotion: "matchMedia" in window && window.matchMedia("(prefers-reduced-motion)").matches, 403 }, 404 pe = (() => { 405 let e = !1; 406 try { 407 const t = Object.defineProperty({}, "passive", { get: () => ((e = !0), null) }); 408 window.addEventListener("test", null, t), window.removeEventListener("test", null, t); 409 } catch (e) {} 410 return e; 411 })(); 412 function ge(e, t, i, s = !1, n = !0, a = !1) { 413 if (!e || !("addEventListener" in e) || W(t) || !j(i)) return; 414 const l = t.split(" "); 415 let o = a; 416 pe && (o = { passive: n, capture: a }), 417 l.forEach((t) => { 418 this && this.eventListeners && s && this.eventListeners.push({ element: e, type: t, callback: i, options: o }), e[s ? "addEventListener" : "removeEventListener"](t, i, o); 419 }); 420 } 421 function fe(e, t = "", i, s = !0, n = !1) { 422 ge.call(this, e, t, i, !0, s, n); 423 } 424 function be(e, t = "", i, s = !0, n = !1) { 425 ge.call(this, e, t, i, !1, s, n); 426 } 427 function ye(e, t = "", i, s = !0, n = !1) { 428 const a = (...l) => { 429 be(e, t, a, s, n), i.apply(this, l); 430 }; 431 ge.call(this, e, t, a, !0, s, n); 432 } 433 function ve(e, t = "", i = !1, s = {}) { 434 if (!H(e) || W(t)) return; 435 const n = new CustomEvent(t, { bubbles: i, detail: { ...s, plyr: this } }); 436 e.dispatchEvent(n); 437 } 438 function we() { 439 this && 440 this.eventListeners && 441 (this.eventListeners.forEach((e) => { 442 const { element: t, type: i, callback: s, options: n } = e; 443 t.removeEventListener(i, s, n); 444 }), 445 (this.eventListeners = [])); 446 } 447 function Te() { 448 return new Promise((e) => (this.ready ? setTimeout(e, 0) : fe.call(this, this.elements.container, "ready", e))).then(() => {}); 449 } 450 function ke(e) { 451 B(e) && e.then(null, () => {}); 452 } 453 function Ce(e) { 454 return q(e) ? e.filter((t, i) => e.indexOf(t) === i) : e; 455 } 456 function Ae(e, t) { 457 return q(e) && e.length ? e.reduce((e, i) => (Math.abs(i - t) < Math.abs(e - t) ? i : e)) : null; 458 } 459 function Se(e) { 460 return !(!window || !window.CSS) && window.CSS.supports(e); 461 } 462 const Ee = [ 463 [1, 1], 464 [4, 3], 465 [3, 4], 466 [5, 4], 467 [4, 5], 468 [3, 2], 469 [2, 3], 470 [16, 10], 471 [10, 16], 472 [16, 9], 473 [9, 16], 474 [21, 9], 475 [9, 21], 476 [32, 9], 477 [9, 32], 478 ].reduce((e, [t, i]) => ({ ...e, [t / i]: [t, i] }), {}); 479 function Pe(e) { 480 if (!(q(e) || (_(e) && e.includes(":")))) return !1; 481 return (q(e) ? e : e.split(":")).map(Number).every($); 482 } 483 function Ne(e) { 484 if (!q(e) || !e.every($)) return null; 485 const [t, i] = e, 486 s = (e, t) => (0 === t ? e : s(t, e % t)), 487 n = s(t, i); 488 return [t / n, i / n]; 489 } 490 function xe(e) { 491 const t = (e) => (Pe(e) ? e.split(":").map(Number) : null); 492 let i = t(e); 493 if ((null === i && (i = t(this.config.ratio)), null === i && !W(this.embed) && q(this.embed.ratio) && ({ ratio: i } = this.embed), null === i && this.isHTML5)) { 494 const { videoWidth: e, videoHeight: t } = this.media; 495 i = [e, t]; 496 } 497 return Ne(i); 498 } 499 function Me(e) { 500 if (!this.isVideo) return {}; 501 const { wrapper: t } = this.elements, 502 i = xe.call(this, e); 503 if (!q(i)) return {}; 504 const [s, n] = Ne(i),
505 a = (100 / s) * n; 506 if ((Se(`aspect-ratio: ${s}/${n}`) ? (t.style.aspectRatio = `${s}/${n}`) : (t.style.paddingBottom = `${a}%`), this.isVimeo && !this.config.vimeo.premium && this.supported.ui)) { 507 const e = (100 / this.media.offsetWidth) * parseInt(window.getComputedStyle(this.media).paddingBottom, 10), 508 i = (e - a) / (e / 50); 509 this.fullscreen.active ? (t.style.paddingBottom = null) : (this.media.style.transform = `translateY(-${i}%)`); 510 } else this.isHTML5 && t.classList.add(this.config.classNames.videoFixedRatio); 511 return { padding: a, ratio: i }; 512 } 513 function Ie(e, t, i = 0.05) { 514 const s = e / t, 515 n = Ae(Object.keys(Ee), s); 516 return Math.abs(n - s) <= i ? Ee[n] : [e, t]; 517 } 518 const Le = { 519 getSources() { 520 if (!this.isHTML5) return []; 521 return Array.from(this.media.querySelectorAll("source")).filter((e) => { 522 const t = e.getAttribute("type"); 523 return !!W(t) || me.mime.call(this, t); 524 }); 525 }, 526 getQualityOptions() { 527 return this.config.quality.forced 528 ? this.config.quality.options 529 : Le.getSources 530 .call(this) 531 .map((e) => Number(e.getAttribute("size"))) 532 .filter(Boolean); 533 }, 534 setup() { 535 if (!this.isHTML5) return; 536 const e = this; 537 (e.options.speed = e.config.speed.options), 538 W(this.config.ratio) || Me.call(e), 539 Object.defineProperty(e.media, "quality", { 540 get() { 541 const t = Le.getSources.call(e).find((t) => t.getAttribute("src") === e.source); 542 return t && Number(t.getAttribute("size")); 543 }, 544 set(t) { 545 if (e.quality !== t) { 546 if (e.config.quality.forced && j(e.config.quality.onChange)) e.config.quality.onChange(t); 547 else { 548 const i = Le.getSources.call(e).find((e) => Number(e.getAttribute("size")) === t); 549 if (!i) return; 550 const { currentTime: s, paused: n, preload: a, readyState: l, playbackRate: o } = e.media; 551 (e.media.src = i.getAttribute("src")), 552 ("none" !== a || l) && 553 (e.once("loadedmetadata", () => { 554 (e.speed = o), (e.currentTime = s), n || ke(e.play()); 555 }), 556 e.media.load()); 557 } 558 ve.call(e, e.media, "qualitychange", !1, { quality: t }); 559 } 560 }, 561 }); 562 }, 563 cancelRequests() { 564 this.isHTML5 && (te(Le.getSources.call(this)), this.media.setAttribute("src", this.config.blankVideo), this.media.load(), this.debug.log("Cancelled network requests")); 565 }, 566 }; 567 function $e(e, ...t) { 568 return W(e) ? e : e.toString().replace(/{(\d+)}/g, (e, i) => t[i].toString()); 569 } 570 const _e = (e = "", t = "", i = "") => e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1"), "g"), i.toString()), 571 Oe = (e = "") => e.toString().replace(/\w\S*/g, (e) => e.charAt(0).toUpperCase() + e.substr(1).toLowerCase()); 572 function je(e = "") { 573 let t = e.toString(); 574 return ( 575 (t = (function (e = "") { 576 let t = e.toString(); 577 return (t = _e(t, "-", " ")), (t = _e(t, "_", " ")), (t = Oe(t)), _e(t, " ", ""); 578 })(t)), 579 t.charAt(0).toLowerCase() + t.slice(1) 580 ); 581 } 582 function qe(e) { 583 const t = document.createElement("div"); 584 return t.appendChild(e), t.innerHTML; 585 } 586 const De = { pip: "PIP", airplay: "AirPlay", html5: "HTML5", vimeo: "Vimeo", youtube: "YouTube" }, 587 He = { 588 get(e = "", t = {}) { 589 if (W(e) || W(t)) return ""; 590 let i = Q(t.i18n, e); 591 if (W(i)) return Object.keys(De).includes(e) ? De[e] : ""; 592 const s = { "{seektime}": t.seekTime, "{title}": t.title }; 593 return (
594 Object.entries(s).forEach(([e, t]) => { 595 i = _e(i, e, t); 596 }), 597 i 598 ); 599 }, 600 }; 601 class Fe { 602 constructor(t) { 603 e(this, "get", (e) => { 604 if (Fe.supported || this.enabled) return null; 605 const t = window.localStorage.getItem(this.key); 606 if (W(t)) return null; 607 const i = JSON.parse(t); 608 return _(e) && e.length ? i[e] : i; 609 }), 610 e(this, "set", (e) => { 611 if (Fe.supported || this.enabled) return; 612 if (!L(e)) return; 613 let t = this.get(); 614 W(t) && (t = {}), X(t, e); 615 try { 616 window.localStorage.setItem(this.key, JSON.stringify(t)); 617 } catch (e) {} 618 }), 619 (this.enabled = t.config.storage.enabled), 620 (this.key = t.config.storage.key); 621 } 622 static get supported() { 623 try { 624 if (!("localStorage" in window)) return !1; 625 const e = "___test"; 626 return window.localStorage.setItem(e, e), window.localStorage.removeItem(e), !0; 627 } catch (e) { 628 return !1; 629 } 630 } 631 } 632 function Re(e, t = "text") { 633 return new Promise((i, s) => { 634 try { 635 const s = new XMLHttpRequest(); 636 if (!("withCredentials" in s)) return; 637 s.addEventListener("load", () => { 638 if ("text" === t) 639 try { 640 i(JSON.parse(s.responseText)); 641 } catch (e) { 642 i(s.responseText); 643 } 644 else i(s.response); 645 }), 646 s.addEventListener("error", () => { 647 throw new Error(s.status); 648 }), 649 s.open("GET", e, !0), 650 (s.responseType = t), 651 s.send(); 652 } catch (e) { 653 s(e); 654 } 655 }); 656 } 657 function Ve(e, t) { 658 if (!_(e)) return; 659 const i = _(t); 660 let s = !1; 661 const n = () => null !== document.getElementById(t), 662 a = (e, t) => { 663 (e.innerHTML = t), (i && n()) || document.body.insertAdjacentElement("afterbegin", e); 664 }; 665 if (!i || !n()) { 666 const n = Fe.supported, 667 l = document.createElement("div"); 668 if ((l.setAttribute("hidden", ""), i && l.setAttribute("id", t), n)) { 669 const e = window.localStorage.getItem(`cache-${t}`); 670 if (((s = null !== e), s)) { 671 const t = JSON.parse(e); 672 a(l, t.content); 673 } 674 } 675 Re(e) 676 .then((e) => { 677 if (!W(e)) { 678 if (n) 679 try { 680 window.localStorage.setItem(`cache-${t}`, JSON.stringify({ content: e })); 681 } catch (e) {} 682 a(l, e); 683 } 684 }) 685 .catch(() => {}); 686 } 687 } 688 const Be = (e) => Math.trunc((e / 60 / 60) % 60, 10); 689 function Ue(e = 0, t = !1, i = !1) { 690 if (!$(e)) return Ue(void 0, t, i); 691 const s = (e) => `0${e}`.slice(-2); 692 let n = Be(e); 693 const a = ((l = e), Math.trunc((l / 60) % 60, 10)); 694 var l; 695 const o = ((e) => Math.trunc(e % 60, 10))(e); 696 return (n = t || n > 0 ? `${n}:` : ""), `${i && e > 0 ? "-" : ""}${n}${s(a)}:${s(o)}`; 697 } 698 const We = { 699 getIconUrl() { 700 const e = new URL(this.config.iconUrl, window.location), 701 t = window.location.host ? window.location.host : window.top.location.host, 702 i = e.host !== t || (Y.isIE && !window.svg4everybody); 703 return { url: this.config.iconUrl, cors: i }; 704 }, 705 findElements() { 706 try { 707 return ( 708 (this.elements.controls = he.call(this, this.config.selectors.controls.wrapper)), 709 (this.elements.buttons = { 710 play: ce.call(this, this.config.selectors.buttons.play), 711 pause: he.call(this, this.config.selectors.buttons.pause), 712 restart: he.call(this, this.config.selectors.buttons.restart), 713 rewind: he.call(this, this.config.selectors.buttons.rewind), 714 fastForward: he.call(this, this.config.selectors.buttons.fastForward), 715 mute: he.call(this, this.config.selectors.buttons.mute), 716 pip: he.call(this, this.config.selectors.buttons.pip), 717 airplay: he.call(this, this.config.selectors.buttons.airplay), 718 settings: he.call(this, this.config.selectors.buttons.settings), 719 captions: he.call(this, this.config.selectors.buttons.captions), 720 fullscreen: he.call(this, this.config.selectors.buttons.fullscreen), 721 }), 722 (this.elements.progress = he.call(this, this.config.selectors.progress)), 723 (this.elements.inputs = { seek: he.call(this, this.config.selectors.inputs.seek), volume: he.call(this, this.config.selectors.inputs.volume) }), 724 (this.elements.display = { 725 buffer: he.call(this, this.config.selectors.display.buffer), 726 currentTime: he.call(this, this.config.selectors.display.currentTime), 727 duration: he.call(this, this.config.selectors.display.duration), 728 }), 729 H(this.elements.progress) && (this.elements.display.seekTooltip = this.elements.progress.querySelector(`.${this.config.classNames.tooltip}`)), 730 !0 731 ); 732 } catch (e) { 733 return this.debug.warn("It looks like there is a problem with your custom controls HTML", e), this.toggleNativeControls(!0), !1; 734 } 735 }, 736 createIcon(e, t) { 737 const i = "http://www.w3.org/2000/svg", 738 s = We.getIconUrl.call(this), 739 n = `${s.cors ? "" : s.url}#${this.config.iconPrefix}`, 740 a = document.createElementNS(i, "svg"); 741 G(a, X(t, { "aria-hidden": "true", focusable: "false" })); 742 const l = document.createElementNS(i, "use"), 743 o = `${n}-${e}`; 744 return "href" in l && l.setAttributeNS("http://www.w3.org/1999/xlink", "href", o), l.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", o), a.appendChild(l), a; 745 }, 746 createLabel(e, t = {}) { 747 const i = He.get(e, this.config); 748 return Z("span", { ...t, class: [t.class, this.config.classNames.hidden].filter(
748Boolean).join(" ") }, i); 749 }, 750 createBadge(e) { 751 if (W(e)) return null; 752 const t = Z("span", { class: this.config.classNames.menu.value }); 753 return t.appendChild(Z("span", { class: this.config.classNames.menu.badge }, e)), t; 754 }, 755 createButton(e, t) { 756 const i = X({}, t); 757 let s = je(e); 758 const n = { element: "button", toggle: !1, label: null, icon: null, labelPressed: null, iconPressed: null }; 759 switch ( 760 (["element", "icon", "label"].forEach((e) => { 761 Object.keys(i).includes(e) && ((n[e] = i[e]), delete i[e]); 762 }), 763 "button" !== n.element || Object.keys(i).includes("type") || (i.type = "button"), 764 Object.keys(i).includes("class") ? i.class.split(" ").some((e) => e === this.config.classNames.control) || X(i, { class: `${i.class} ${this.config.classNames.control}` }) : (i.class = this.config.classNames.control), 765 e) 766 ) { 767 case "play": 768 (n.toggle = !0), (n.label = "play"), (n.labelPressed = "pause"), (n.icon = "play"), (n.iconPressed = "pause"); 769 break; 770 case "mute": 771 (n.toggle = !0), (n.label = "mute"), (n.labelPressed = "unmute"), (n.icon = "volume"), (n.iconPressed = "muted"); 772 break; 773 case "captions": 774 (n.toggle = !0), (n.label = "enableCaptions"), (n.labelPressed = "disableCaptions"), (n.icon = "captions-off"), (n.iconPressed = "captions-on"); 775 break; 776 case "fullscreen": 777 (n.toggle = !0), (n.label = "enterFullscreen"), (n.labelPressed = "exitFullscreen"), (n.icon = "enter-fullscreen"), (n.iconPressed = "exit-fullscreen"); 778 break; 779 case "play-large": 780 (i.class += ` ${this.config.classNames.control}--overlaid`), (s = "play"), (n.label = "play"), (n.icon = "play"); 781 break; 782 default: 783 W(n.label) && (n.label = s), W(n.icon) && (n.icon = e); 784 } 785 const a = Z(n.element); 786 return ( 787 n.toggle 788 ? (a.appendChild(We.createIcon.call(this, n.iconPressed, { class: "icon--pressed" })), 789 a.appendChild(We.createIcon.call(this, n.icon, { class: "icon--not-pressed" })), 790 a.appendChild(We.createLabel.call(this, n.labelPressed, { class: "label--pressed" })), 791 a.appendChild(We.createLabel.call(this, n.label, { class: "label--not-pressed" }))) 792 : (a.appendChild(We.createIcon.call(this, n.icon)), a.appendChild(We.createLabel.call(this, n.label))), 793 X(i, ne(this.config.selectors.buttons[s], i)), 794 G(a, i), 795 "play" === s ? (q(this.elements.buttons[s]) || (this.elements.buttons[s] = []), this.elements.buttons[s].push(a)) : (this.elements.buttons[s] = a), 796 a 797 ); 798 }, 799 createRange(e, t) { 800 const i = Z( 801 "input", 802 X( 803 ne(this.config.selectors.inputs[e]), 804 { type: "range", min: 0, max: 100, step: 0.01, value: 0, autocomplete: "off", role: "slider", "aria-label": He.get(e, this.config), "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": 0 }, 805 t 806 ) 807 ); 808 return (this.elements.inputs[e] = i), We.updateRangeFill.call(this, i), T.setup(i), i; 809 }, 810 createProgress(e, t) { 811 const i = Z("progress", X(ne(this.config.selectors.display[e]), { min: 0, max: 100, value: 0, role: "progressbar", "aria-hidden": !0 }, t)); 812 if ("volume" !== e) { 813 i.appendChild(Z("span", null, "0")); 814 const t = { played: "played", buffer: "buffered" }[e], 815 s = t ? He.get(t, this.config) : ""; 816 i.innerText = `% ${s.toLowerCase()}`; 817 }
818 return (this.elements.display[e] = i), i; 819 }, 820 createTime(e, t) { 821 const i = ne(this.config.selectors.display[e], t), 822 s = Z("div", X(i, { class: `${i.class ? i.class : ""} ${this.config.classNames.display.time} `.trim(), "aria-label": He.get(e, this.config) }), "00:00"); 823 return (this.elements.display[e] = s), s; 824 }, 825 bindMenuItemShortcuts(e, t) { 826 fe.call( 827 this, 828 e, 829 "keydown keyup", 830 (i) => { 831 if (![32, 38, 39, 40].includes(i.which)) return; 832 if ((i.preventDefault(), i.stopPropagation(), "keydown" === i.type)) return; 833 const s = re(e, '[role="menuitemradio"]'); 834 if (!s && [32, 39].includes(i.which)) We.showMenuPanel.call(this, t, !0); 835 else { 836 let t; 837 32 !== i.which && 838 (40 === i.which || (s && 39 === i.which) ? ((t = e.nextElementSibling), H(t) || (t = e.parentNode.firstElementChild)) : ((t = e.previousElementSibling), H(t) || (t = e.parentNode.lastElementChild)), 839 ue.call(this, t, !0)); 840 } 841 }, 842 !1 843 ), 844 fe.call(this, e, "keyup", (e) => { 845 13 === e.which && We.focusFirstMenuItem.call(this, null, !0); 846 }); 847 }, 848 createMenuItem({ value: e, list: t, type: i, title: s, badge: n = null, checked: a = !1 }) { 849 const l = ne(this.config.selectors.inputs[i]), 850 o = Z("button", X(l, { type: "button", role: "menuitemradio", class: `${this.config.classNames.control} ${l.class ? l.class : ""}`.trim(), "aria-checked": a, value: e })), 851 r = Z("span"); 852 (r.innerHTML = s), 853 H(n) && r.appendChild(n), 854 o.appendChild(r), 855 Object.defineProperty(o, "checked", { 856 enumerable: !0, 857 get: () => "true" === o.getAttribute("aria-checked"), 858 set(e) { 859 e && 860 Array.from(o.parentNode.children) 861 .filter((e) => re(e, '[role="menuitemradio"]')) 862 .forEach((e) => e.setAttribute("aria-checked", "false")), 863 o.setAttribute("aria-checked", e ? "true" : "false"); 864 }, 865 }), 866 this.listeners.bind( 867 o, 868 "click keyup", 869 (t) => { 870 if (!R(t) || 32 === t.which) { 871 switch ((t.preventDefault(), t.stopPropagation(), (o.checked = !0), i)) { 872 case "language": 873 this.currentTrack = Number(e); 874 break; 875 case "quality": 876 this.quality = e; 877 break; 878 case "speed": 879 this.speed = parseFloat(e); 880 } 881 We.showMenuPanel.call(this, "home", R(t)); 882 } 883 }, 884 i, 885 !1 886 ), 887 We.bindMenuItemShortcuts.call(this, o, i), 888 t.appendChild(o); 889 }, 890 formatTime(e = 0, t = !1) { 891 if (!$(e)) return e; 892 return Ue(e, Be(this.duration) > 0, t); 893 }, 894 updateTimeDisplay(e = null, t = 0, i = !1) { 895 H(e) && $(t) && (e.innerText = We.formatTime(t, i)); 896 }, 897 updateVolume() { 898 this.supported.ui && 899 (H(this.elements.inputs.volume) && We.setRange.call(this, this.elements.inputs.volume, this.muted ? 0 : this.volume), 900 H(this.elements.buttons.mute) && (this.elements.buttons.mute.pressed = this.muted || 0 === this.volume)); 901 }, 902 setRange(e, t = 0) { 903 H(e) && ((e.value = t), We.updateRangeFill.call(this, e)); 904 }, 905 updateProgress(e) { 906 if (!this.supported.ui || !F(e)) return; 907 let t = 0; 908 const i = (e, t) => { 909 const i = $(t) ? t : 0, 910 s = H(e) ? e : this.elements.display.buffer; 911 if (H(s)) { 912 s.value = i; 913 const e = s.getElementsByTagName("span")[0]; 914 H(e) && (e.childNodes[0].nodeValue = i); 915 } 916 }; 917 if (e) 918 switch (e.type) { 919 case "timeupdate": 920 case "seeking": 921 case "seeked": 922 (s = this.currentTime), 923 (n = this.duration), 924 (t = 0 === s || 0 === n || Number.isNaN(s) || Number.isNaN(n) ? 0 : ((s / n) * 100).toFixed(2)), 925 "timeupdate" === e.type && We.setRange.call(this, this.elements.inputs.seek, t); 926 break; 927 case "playing": 928 case "progress": 929 i(this.elements.display.buffer, 100 * this.buffered); 930 } 931 var s, n; 932 }, 933 updateRangeFill(e) { 934 const t = F(e) ? e.target : e; 935 if (H(t) && "range" === t.getAttribute("type")) { 936 if (re(t, this.config.selectors.inputs.seek)) { 937 t.setAttribute("aria-valuenow", this.currentTime); 938 const e = We.formatTime(this.currentTime), 939 i = We.formatTime(this.duration), 940 s = He.get("seekLabel", this.config); 941 t.setAttribute("aria-valuetext", s.replace("{currentTime}", e).replace("{duration}", i)); 942 } else if (re(t, this.config.selectors.inputs.volume)) { 943 const e = 100 * t.value; 944 t.setAttribute("aria-valuenow", e), t.setAttribute("aria-valuetext", `${e.toFixed(1)}%`); 945 } else t.setAttribute("aria-valuenow", t.value); 946 Y.isWebkit && t.style.setProperty("--value", (t.value / t.max) * 100 + "%"); 947 } 948 }, 949 updateSeekTooltip(e) { 950 if (!this.config.tooltips.seek || !H(this.elements.inputs.seek) || !H(this.elements.display.seekTooltip) || 0 === this.duration) return; 951 const t = `${this.config.classNames.tooltip}--visible`, 952 i = (e) => le(this.elements.display.seekTooltip, t, e); 953 if (this.touch) return void i(!1); 954 let s = 0; 955 const n = this.elements.progress.getBoundingClientRect(); 956 if (F(e)) s = (100 / n.width) * (e.pageX - n.left); 957 else { 958 if (!oe(this.elements.display.seekTooltip, t)) return; 959 s = parseFloat(this.elements.display.seekTooltip.style.left, 10); 960 } 961 s < 0 ? (s = 0) : s > 100 && (s = 100), 962 We.updateTimeDisplay.call(this, this.elements.display.seekTooltip, (this.duration / 100) * s), 963 (this.elements.display.seekTooltip.style.left = `${s}%`), 964 F(e) && ["mouseenter", "mouseleave"].includes(e.type) && i("mouseenter" === e.type); 965 }, 966 timeUpdate(e) { 967 const t = !H(this.elements.display.duration) && this.config.invertTime; 968 We.updateTimeDisplay.call(this, this.elements.display.currentTime, t ? this.duration - this.currentTime : this.currentTime, t), (e && "timeupdate" === e.type && this.media.seeking) || We.updateProgress.call(this, e); 969 }, 970 durationUpdate() { 971 if (!this.supported.ui || (!this.config.invertTime && this.currentTime)) return; 972 if (this.duration >= 2 ** 32) return ae(this.elements.display.currentTime, !0), void ae(this.elements.progress, !0); 973 H(this.elements.inputs.seek) && this.elements.inputs.seek.setAttribute("aria-valuemax", this.duration); 974 const e = H(this.elements.display.duration); 975 !e && this.config.displayDuration && this.paused && We.updateTimeDisplay.call(this, this.elements.display.currentTime, this.duration), 976 e && We.updateTimeDisplay.call(this, this.elements.display.duration, this.duration), 977 We.updateSeekTooltip.call(this); 978 }, 979 toggleMenuButton(e, t) { 980 ae(this.elements.settings.buttons[e], !t); 981 }, 982 updateSetting(e, t, i) { 983 const s = this.elements.settings.panels[e]; 984 let n = null, 985 a = t; 986 if ("captions" === e) n = this.currentTrack; 987 else { 988 if (((n = W(i) ? this[e] : i), W(n) && (n = this.config[e].default), !W(this.options[e]) && !this.options[e].includes(n))) return void this.debug.warn(`Unsupported value of '${n}' for ${e}`); 989 if (!this.config[e].options.includes(n)) return void this.debug.warn(`Disabled value of '${n}' for ${e}`); 990 } 991 if ((H(a) || (a = s && s.querySelector('[role="menu"]')), !H(a))) return; 992 this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`).innerHTML = We.getLabel.call(this, e, n); 993 const l = a && a.querySelector(`[value="${n}"]`); 994 H(l) && (l.checked = !0); 995 }, 996 getLabel(e, t) { 997 switch (e) { 998 case "speed": 999 return 1 === t ? He.get("normal", this.config) : `${t}×`; 1000 case "quality": 1001 if ($(t)) { 1002 const e = He.get(`qualityLabel.${t}`, this.config); 1003 return e.length ? e : `${t}p`;
1004 } 1005 return Oe(t); 1006 case "captions": 1007 return Ye.getLabel.call(this); 1008 default: 1009 return null; 1010 } 1011 }, 1012 setQualityMenu(e) { 1013 if (!H(this.elements.settings.panels.quality)) return; 1014 const t = "quality", 1015 i = this.elements.settings.panels.quality.querySelector('[role="menu"]'); 1016 q(e) && (this.options.quality = Ce(e).filter((e) => this.config.quality.options.includes(e))); 1017 const s = !W(this.options.quality) && this.options.quality.length > 1; 1018 if ((We.toggleMenuButton.call(this, t, s), ie(i), We.checkMenu.call(this), !s)) return; 1019 const n = (e) => { 1020 const t = He.get(`qualityBadge.${e}`, this.config); 1021 return t.length ? We.createBadge.call(this, t) : null; 1022 }; 1023 this.options.quality 1024 .sort((e, t) => { 1025 const i = this.config.quality.options; 1026 return i.indexOf(e) > i.indexOf(t) ? 1 : -1; 1027 }) 1028 .forEach((e) => { 1029 We.createMenuItem.call(this, { value: e, list: i, type: t, title: We.getLabel.call(this, "quality", e), badge: n(e) }); 1030 }), 1031 We.updateSetting.call(this, t, i); 1032 }, 1033 setCaptionsMenu() { 1034 if (!H(this.elements.settings.panels.captions)) return; 1035 const e = "captions", 1036 t = this.elements.settings.panels.captions.querySelector('[role="menu"]'), 1037 i = Ye.getTracks.call(this), 1038 s = Boolean(i.length); 1039 if ((We.toggleMenuButton.call(this, e, s), ie(t), We.checkMenu.call(this), !s)) return; 1040 const n = i.map((e, i) => ({ 1041 value: i, 1042 checked: this.captions.toggled && this.currentTrack === i, 1043 title: Ye.getLabel.call(this, e), 1044 badge: e.language && We.createBadge.call(this, e.language.toUpperCase()), 1045 list: t, 1046 type: "language", 1047 })); 1048 n.unshift({ value: -1, checked: !this.captions.toggled, title: He.get("disabled", this.config), list: t, type: "language" }), n.forEach(We.createMenuItem.bind(this)), We.updateSetting.call(this, e, t); 1049 }, 1050 setSpeedMenu() { 1051 if (!H(this.elements.settings.panels.speed)) return; 1052 const e = "speed", 1053 t = this.elements.settings.panels.speed.querySelector('[role="menu"]'); 1054 this.options.speed = this.options.speed.filter((e) => e >= this.minimumSpeed && e <= this.maximumSpeed); 1055 const i = !W(this.options.speed) && this.options.speed.length > 1; 1056 We.toggleMenuButton.call(this, e, i), 1057 ie(t), 1058 We.checkMenu.call(this), 1059 i && 1060 (this.options.speed.forEach((i) => { 1061 We.createMenuItem.call(this, { value: i, list: t, type: e, title: We.getLabel.call(this, "speed", i) }); 1062 }), 1063 We.updateSetting.call(this, e, t)); 1064 }, 1065 checkMenu() { 1066 const { buttons: e } = this.elements.settings, 1067 t = !W(e) && Object.values(e).some((e) => !e.hidden); 1068 ae(this.elements.settings.menu, !t); 1069 }, 1070 focusFirstMenuItem(e, t = !1) { 1071 if (this.elements.settings.popup.hidden) return; 1072 let i = e; 1073 H(i) || (i = Object.values(this.elements.settings.panels).find((e) => !e.hidden)); 1074 const s = i.querySelector('[role^="menuitem"]'); 1075 ue.call(this, s, t); 1076 }, 1077 toggleMenu(e) { 1078 const { popup: t } = this.elements.settings, 1079 i = this.elements.buttons.settings; 1080 if (!H(t) || !H(i)) return; 1081 const { hidden: s } = t; 1082 let n = s; 1083 if (O(e)) n = e; 1084 else if (R(e) && 27 === e.which) n = !1; 1085 else if (F(e)) { 1086 const s = j(e.composedPath) ? e.composedPath()[0] : e.target, 1087 a = t.contains(s); 1088 if (a || (!a && e.target !== i && n)) return; 1089 } 1090 i.setAttribute("aria-expanded", n), ae(t, !n), le(this.elements.container, this.config.classNames.menu.open, n), n && R(e) ? We.focusFirstMenuItem.call(this, null, !0) : n || s || ue.call(this, i, R(e)); 1091 }, 1092 getMenuSize(e) { 1093 const t = e.cloneNode(!0); 1094 (t.style.position = "absolute"), (t.style.opacity = 0), t.removeAttribute("hidden"), e.parentNode.appendChild(t); 1095 const i = t.scrollWidth, 1096 s = t.scrollHeight; 1097 return te(t), { width: i, height: s }; 1098 }, 1099 showMenuPanel(e = "", t = !1) { 1100 const i = this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`); 1101 if (!H(i)) return; 1102 const s = i.parentNode, 1103 n = Array.from(s.children).find((e) => !e.hidden); 1104 if (me.transitions && !me.reducedMotion) { 1105 (s.style.width = `${n.scrollWidth}px`), (s.style.height = `${n.scrollHeight}px`); 1106 const e = We.getMenuSize.call(this, i), 1107 t = (e) => { 1108 e.target === s && ["width", "height"].includes(e.propertyName) && ((s.style.width = ""), (s.style.height = ""), be.call(this, s, z, t)); 1109 }; 1110 fe.call(this, s, z, t), (s.style.width = `${e.width}px`), (s.style.height = `${e.height}px`); 1111 } 1112 ae(n, !0), ae(i, !1), We.focusFirstMenuItem.call(this, i, t); 1113 },
1114 setDownloadUrl() { 1115 const e = this.elements.buttons.download; 1116 H(e) && e.setAttribute("href", this.download); 1117 }, 1118 create(e) { 1119 const { bindMenuItemShortcuts: t, createButton: i, createProgress: s, createRange: n, createTime: a, setQualityMenu: l, setSpeedMenu: o, showMenuPanel: r } = We; 1120 (this.elements.controls = null), q(this.config.controls) && this.config.controls.includes("play-large") && this.elements.container.appendChild(i.call(this, "play-large")); 1121 const c = Z("div", ne(this.config.selectors.controls.wrapper)); 1122 this.elements.controls = c; 1123 const h = { class: "plyr__controls__item" }; 1124 return ( 1125 Ce(q(this.config.controls) ? this.config.controls : []).forEach((l) => { 1126 if ( 1127 ("restart" === l && c.appendChild(i.call(this, "restart", h)), 1128 "rewind" === l && c.appendChild(i.call(this, "rewind", h)), 1129 "play" === l && c.appendChild(i.call(this, "play", h)), 1130 "fast-forward" === l && c.appendChild(i.call(this, "fast-forward", h)), 1131 "progress" === l) 1132 ) { 1133 const t = Z("div", { class: `${h.class} plyr__progress__container` }), 1134 i = Z("div", ne(this.config.selectors.progress)); 1135 if ((i.appendChild(n.call(this, "seek", { id: `plyr-seek-${e.id}` })), i.appendChild(s.call(this, "buffer")), this.config.tooltips.seek)) { 1136 const e = Z("span", { class: this.config.classNames.tooltip }, "00:00"); 1137 i.appendChild(e), (this.elements.display.seekTooltip = e); 1138 } 1139 (this.elements.progress = i), t.appendChild(this.elements.progress), c.appendChild(t); 1140 } 1141 if (("current-time" === l && c.appendChild(a.call(this, "currentTime", h)), "duration" === l && c.appendChild(a.call(this, "duration", h)), "mute" === l || "volume" === l)) { 1142 let { volume: t } = this.elements; 1143 if ( 1144 ((H(t) && c.contains(t)) || ((t = Z("div", X({}, h, { class: `${h.class} plyr__volume`.trim() }))), (this.elements.volume = t), c.appendChild(t)), 1145 "mute" === l && t.appendChild(i.call(this, "mute")), 1146 "volume" === l && !Y.isIos) 1147 ) { 1148 const i = { max: 1, step: 0.05, value: this.config.volume }; 1149 t.appendChild(n.call(this, "volume", X(i, { id: `plyr-volume-${e.id}` }))); 1150 } 1151 } 1152 if (("captions" === l && c.appendChild(i.call(this, "captions", h)), "settings" === l && !W(this.config.settings))) { 1153 const s = Z("div", X({}, h, { class: `${h.class} plyr__menu`.trim(), hidden: "" })); 1154 s.appendChild(i.call(this, "settings", { "aria-haspopup": !0, "aria-controls": `plyr-settings-${e.id}`, "aria-expanded": !1 })); 1155 const n = Z("div", { class: "plyr__menu__container", id: `plyr-settings-${e.id}`, hidden: "" }), 1156 a = Z("div"), 1157 l = Z("div", { id: `plyr-settings-${e.id}-home` }), 1158 o = Z("div", { role: "menu" }); 1159 l.appendChild(o), 1160 a.appendChild(l), 1161 (this.elements.settings.panels.home = l), 1162 this.config.settings.forEach((i) => { 1163 const s = Z( 1164 "button", 1165 X(ne(this.config.selectors.buttons.settings), { 1166 type: "button", 1167 class: `${this.config.classNames.c
1167ontrol} ${this.config.classNames.control}--forward`, 1168 role: "menuitem", 1169 "aria-haspopup": !0, 1170 hidden: "", 1171 }) 1172 ); 1173 t.call(this, s, i), 1174 fe.call(this, s, "click", () => { 1175 r.call(this, i, !1); 1176 }); 1177 const n = Z("span", null, He.get(i, this.config)), 1178 l = Z("span", { class: this.config.classNames.menu.value }); 1179 (l.innerHTML = e[i]), n.appendChild(l), s.appendChild(n), o.appendChild(s); 1180 const c = Z("div", { id: `plyr-settings-${e.id}-${i}`, hidden: "" }), 1181 h = Z("button", { type: "button", class: `${this.config.classNames.control} ${this.config.classNames.control}--back` }); 1182 h.appendChild(Z("span", { "aria-hidden": !0 }, He.get(i, this.config))), 1183 h.appendChild(Z("span", { class: this.config.classNames.hidden }, He.get("menuBack", this.config))), 1184 fe.call( 1185 this, 1186 c, 1187 "keydown", 1188 (e) => { 1189 37 === e.which && (e.preventDefault(), e.stopPropagation(), r.call(this, "home", !0)); 1190 }, 1191 !1 1192 ), 1193 fe.call(this, h, "click", () => { 1194 r.call(this, "home", !1); 1195 }), 1196 c.appendChild(h), 1197 c.appendChild(Z("div", { role: "menu" })), 1198 a.appendChild(c), 1199 (this.elements.settings.buttons[i] = s), 1200 (this.elements.settings.panels[i] = c); 1201 }), 1202 n.appendChild(a), 1203 s.appendChild(n), 1204 c.appendChild(s), 1205 (this.elements.settings.popup = n), 1206 (this.elements.settings.menu = s); 1207 } 1208 if (("pip" === l && me.pip && c.appendChild(i.call(this, "pip", h)), "airplay" === l && me.airplay && c.appendChild(i.call(this, "airplay", h)), "download" === l)) { 1209 const e = X({}, h, { element: "a", href: this.download, target: "_blank" }); 1210 this.isHTML5 && (e.download = ""); 1211 const { download: t } = this.config.urls; 1212 !U(t) && this.isEmbed && X(e, { icon: `logo-${this.provider}`, label: this.provider }), c.appendChild(i.call(this, "download", e)); 1213 } 1214 "fullscreen" === l && c.appendChild(i.call(this, "fullscreen", h)); 1215 }), 1216 this.isHTML5 && l.call(this, Le.getQualityOptions.call(this)), 1217 o.call(this), 1218 c 1219 ); 1220 }, 1221 inject() { 1222 if (this.config.loadSprite) { 1223 const e = We.getIconUrl.call(this); 1224 e.cors && Ve(e.url, "sprite-plyr"); 1225 } 1226 this.id = Math.floor(1e4 * Math.random()); 1227 let e = null; 1228 this.elements.controls = null; 1229 const t = { id: this.id, seektime: this.config.seekTime, title: this.config.title }; 1230 let i = !0; 1231 j(this.config.controls) && (this.config.controls = this.config.controls.call(this, t)), 1232 this.config.controls || (this.config.controls = []), 1233 H(this.config.controls) || _(this.config.controls) 1234 ? (e = this.config.controls) 1235 : ((e = We.create.call(this, { id: this.id, seektime: this.config.seekTime, speed: this.speed, quality: this.qual
1235ity, captions: Ye.getLabel.call(this) })), (i = !1)); 1236 let s; 1237 i && 1238 _(this.config.controls) && 1239 (e = ((e) => { 1240 let i = e; 1241 return ( 1242 Object.entries(t).forEach(([e, t]) => { 1243 i = _e(i, `{${e}}`, t); 1244 }), 1245 i 1246 ); 1247 })(e)), 1248 _(this.config.selectors.controls.container) && (s = document.querySelector(this.config.selectors.controls.container)), 1249 H(s) || (s = this.elements.container); 1250 if ((s[H(e) ? "insertAdjacentElement" : "insertAdjacentHTML"]("afterbegin", e), H(this.elements.controls) || We.findElements.call(this), !W(this.elements.buttons))) { 1251 const e = (e) => { 1252 const t = this.config.classNames.controlPressed; 1253 Object.defineProperty(e, "pressed", { 1254 enumerable: !0, 1255 get: () => oe(e, t), 1256 set(i = !1) { 1257 le(e, t, i); 1258 }, 1259 }); 1260 }; 1261 Object.values(this.elements.buttons) 1262 .filter(Boolean) 1263 .forEach((t) => { 1264 q(t) || D(t) ? Array.from(t).filter(Boolean).forEach(e) : e(t); 1265 }); 1266 } 1267 if ((Y.isEdge && K(s), this.config.tooltips.controls)) { 1268 const { classNames: e, selectors: t } = this.config, 1269 i = `${t.controls.wrapper} ${t.labels} .${e.hidden}`, 1270 s = ce.call(this, i); 1271 Array.from(s).forEach((e) => { 1272 le(e, this.config.classNames.hidden, !1), le(e, this.config.classNames.tooltip, !0); 1273 }); 1274 } 1275 }, 1276 }; 1277 function ze(e, t = !0) { 1278 let i = e; 1279 if (t) { 1280 const e = document.createElement("a"); 1281 (e.href = i), (i = e.href); 1282 } 1283 try { 1284 return new URL(i); 1285 } catch (e) { 1286 return null; 1287 } 1288 } 1289 function Ke(e) { 1290 const t = new URLSearchParams(); 1291 return ( 1292 L(e) && 1293 Object.entries(e).forEach(([e, i]) => { 1294 t.set(e, i); 1295 }), 1296 t 1297 ); 1298 } 1299 const Ye = { 1300 setup() { 1301 if (!this.supported.ui) return; 1302 if (!this.isVideo || this.isYouTube || (this.isHTML5 && !me.textTracks)) 1303 return void (q(this.config.controls) && this.config.controls.includes("settings") && this.config.settings.includes("captions") && We.setCaptionsMenu.call(this)); 1304 var e, t; 1305 if ( 1306 (H(this.elements.captions) || 1307 ((this.elements.captions = Z("div", ne(this.config.selectors.captions))), (e = this.elements.captions), (t = this.elements.wrapper), H(e) && H(t) && t.parentNode.insertBefore(e, t.nextSibling)), 1308 Y.isIE && window.URL) 1309 ) { 1310 const e = this.media.querySelectorAll("track"); 1311 Array.from(e).forEach((e) => { 1312 const t = e.getAttribute("src"), 1313 i = ze(t); 1314 null !== i && 1315 i.hostname !== window.location.href.hostname && 1316 ["http:", "https:"].includes(i.protocol) && 1317 Re(t, "blob") 1318 .then((t) => { 1319 e.setAttribute("src", window.URL.createObjectURL(t)); 1320 }) 1321 .catch(() => { 1322 te(e); 1323 }); 1324 }); 1325 } 1326 const i = Ce((navigator.languages || [navigator.language || navigator.userLanguage || "en"]).map((e) => e.split("-")[0])); 1327 let s = (this.storage.get("language") || this.config.captions.language || "auto").toLowerCase(); 1328 "auto" === s && ([s] = i); 1329 let n = this.storage.get("captions"); 1330 if ((O(n) || ({ active: n } = this.config.captions), Object.assign(this.captions, { toggled: !1, active: n, language: s, languages: i }), this.isHTML5)) { 1331 const e = this.config.captions.update ? "addtrack removetrack" : "removetrack"; 1332 fe.call(this, this.media.textTracks, e, Ye.update.bind(this)); 1333 } 1334 setTimeout(Ye.update.bind(this), 0); 1335 }, 1336 update() { 1337 const e = Ye.getTracks.call(this, !0), 1338 { active: t, language: i, meta: s, currentTrackNode: n } = this.captions, 1339 a = Boolean(e.find((e) => e.language === i)); 1340 this.isHTML5 && 1341 this.isVideo && 1342 e 1343 .filter((e) => !s.get(e)) 1344 .forEach((e) => { 1345 this.debug.log("Track added", e), s.set(e, { default: "showing" === e.mode }), "showing" === e.mode && (e.mode = "hidden"), fe.call(this, e, "cuechange", () => Ye.updateCues.call(this)); 1346 }), 1347 ((a && this.language !== i) || !e.includes(n)) && (Ye.setLanguage.call(this, i), Ye.toggle.call(this, t && a)), 1348 this.elements && le(this.elements.container, this.config.classNames.captions.enabled, !W(e)), 1349 q(this.config.controls) && this.config.controls.includes("settings") && this.config.settings.includes("captions") && We.setCaptionsMenu.call(this); 1350 }, 1351 toggle(e, t = !0) { 1352 if (!this.supported.ui) return; 1353 const { toggled: i } = this.captions, 1354 s = this.config.classNames.captions.active, 1355 n = I(e) ? !i : e; 1356 if (n !== i) { 1357 if ((t || ((this.captions.active = n), this.storage.set({ captions: n })), !this.language && n && !t)) { 1358 const e = Ye.getTracks.call(this), 1359 t = Ye.findTrack.call(this, [this.captions.language, ...this.captions.languages], !0); 1360 return (this.captions.language = t.language), void Ye.set.call(this, e.indexOf(t)); 1361 } 1362 this.elements.buttons.captions && (this.elements.buttons.captions.pressed = n), 1363 le(this.elements.container, s, n), 1364 (this.captions.toggled = n), 1365 We.updateSetting.call(this, "captions"), 1366 ve.call(this, this.media, n ? "captionsenabled" : "captionsdisabled"); 1367 } 1368 setTimeout(() => { 1369 n && this.captions.toggled && (this.captions.currentTrackNode.mode = "hidden"); 1370 }); 1371 }, 1372 set(e, t = !0) { 1373 const i = Ye.getTracks.call(this); 1374 if (-1 !== e) 1375 if ($(e))
1376 if (e in i) { 1377 if (this.captions.currentTrack !== e) { 1378 this.captions.currentTrack = e; 1379 const s = i[e], 1380 { language: n } = s || {}; 1381 (this.captions.currentTrackNode = s), 1382 We.updateSetting.call(this, "captions"), 1383 t || ((this.captions.language = n), this.storage.set({ language: n })), 1384 this.isVimeo && this.embed.enableTextTrack(n), 1385 ve.call(this, this.media, "languagechange"); 1386 } 1387 Ye.toggle.call(this, !0, t), this.isHTML5 && this.isVideo && Ye.updateCues.call(this); 1388 } else this.debug.warn("Track not found", e); 1389 else this.debug.warn("Invalid caption argument", e); 1390 else Ye.toggle.call(this, !1, t); 1391 }, 1392 setLanguage(e, t = !0) { 1393 if (!_(e)) return void this.debug.warn("Invalid language argument", e); 1394 const i = e.toLowerCase(); 1395 this.captions.language = i; 1396 const s = Ye.getTracks.call(this), 1397 n = Ye.findTrack.call(this, [i]); 1398 Ye.set.call(this, s.indexOf(n), t); 1399 }, 1400 getTracks(e = !1) { 1401 return Array.from((this.media || {}).textTracks || []) 1402 .filter((t) => !this.isHTML5 || e || this.captions.meta.has(t)) 1403 .filter((e) => ["captions", "subtitles"].includes(e.kind)); 1404 }, 1405 findTrack(e, t = !1) { 1406 const i = Ye.getTracks.call(this), 1407 s = (e) => Number((this.captions.meta.get(e) || {}).default), 1408 n = Array.from(i).sort((e, t) => s(t) - s(e)); 1409 let a; 1410 return e.every((e) => ((a = n.find((t) => t.language === e)), !a)), a || (t ? n[0] : void 0); 1411 }, 1412 getCurrentTrack() { 1413 return Ye.getTracks.call(this)[this.currentTrack]; 1414 }, 1415 getLabel(e) { 1416 let t = e; 1417 return ( 1418 !V(t) && me.textTracks && this.captions.toggled && (t = Ye.getCurrentTrack.call(this)), 1419 V(t) ? (W(t.label) ? (W(t.language) ? He.get("enabled", this.config) : e.language.toUpperCase()) : t.label) : He.get("disabled", this.config) 1420 ); 1421 }, 1422 updateCues(e) { 1423 if (!this.supported.ui) return; 1424 if (!H(this.elements.captions)) return void this.debug.warn("No captions element to render to"); 1425 if (!I(e) && !Array.isArray(e)) return void this.debug.warn("updateCues: Invalid input", e); 1426 let t = e; 1427 if (!t) { 1428 const e = Ye.getCurrentTrack.call(this); 1429 t = Array.from((e || {}).activeCues || []) 1430 .map((e) => e.getCueAsHTML()) 1431 .map(qe); 1432 } 1433 const i = t.map((e) => e.trim()).join("\n"); 1434 if (i !== this.elements.captions.innerHTML) { 1435 ie(this.elements.captions); 1436 const e = Z("span", ne(this.config.selectors.caption)); 1437 (e.innerHTML = i), this.elements.captions.appendChild(e), ve.call(this, this.media, "cuechange"); 1438 } 1439 }, 1440 }, 1441 Qe = { 1442 enabled: !0, 1443 title: "", 1444 debug: !1, 1445 autoplay: !1, 1446 autopause: !0, 1447 playsinline: !0, 1448 seekTime: 10, 1449 volume: 1, 1450 muted: !1, 1451 duration: null, 1452 displayDuration: !0, 1453 invertTime: !0, 1454 toggleInvert: !0, 1455 ratio: null, 1456 clickToPlay: !0, 1457 hideControls: !0, 1458 resetOnEnd: !1, 1459 disableContextMenu: !0, 1460 loadSprite: !0, 1461 iconPrefix: "plyr", 1462 iconUrl: "files/plugins/plyr/plyr.svg", 1463 blankVideo: "https://cdn.plyr.io/static/blank.mp4", 1464 quality: { default: 576, options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240], forced: !1, onChange: null }, 1465 loop: { active: !1 }, 1466 speed: { selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 4] }, 1467 keyboard: { focused: !0, global: !1 },
1468 tooltips: { controls: !1, seek: !0 }, 1469 captions: { active: !1, language: "auto", update: !1 }, 1470 fullscreen: { enabled: !0, fallback: !0, iosNative: !1 }, 1471 storage: { enabled: !0, key: "plyr" }, 1472 controls: ["play-large", "play", "progress", "current-time", "mute", "volume", "captions", "settings", "pip", "airplay", "fullscreen"], 1473 settings: ["captions", "quality", "speed"], 1474 i18n: { 1475 restart: "Restart", 1476 rewind: "Rewind {seektime}s", 1477 play: "Play", 1478 pause: "Pause", 1479 fastForward: "Forward {seektime}s", 1480 seek: "Seek", 1481 seekLabel: "{currentTime} of {duration}", 1482 played: "Played", 1483 buffered: "Buffered", 1484 currentTime: "Current time", 1485 duration: "Duration", 1486 volume: "Volume", 1487 mute: "Mute", 1488 unmute: "Unmute", 1489 enableCaptions: "Enable captions", 1490 disableCaptions: "Disable captions", 1491 download: "Download", 1492 enterFullscreen: "Enter fullscreen", 1493 exitFullscreen: "Exit fullscreen", 1494 frameTitle: "Player for {title}", 1495 captions: "Captions", 1496 settings: "Settings", 1497 pip: "PIP", 1498 menuBack: "Go back to previous menu", 1499 speed: "Speed", 1500 normal: "Normal", 1501 quality: "Quality", 1502 loop: "Loop", 1503 start: "Start", 1504 end: "End", 1505 all: "All", 1506 reset: "Reset", 1507 disabled: "Disabled", 1508 enabled: "Enabled", 1509 advertisement: "Ad", 1510 qualityBadge: { 2160: "4K", 1440: "HD", 1080: "HD", 720: "HD", 576: "SD", 480: "SD" }, 1511 }, 1512 urls: { 1513 download: null, 1514 vimeo: { sdk: "https://player.vimeo.com/api/player.js", iframe: "https://player.vimeo.com/video/{0}?{1}", api: "https://vimeo.com/api/oembed.json?url={0}" }, 1515 youtube: { sdk: "https://www.youtube.com/iframe_api", api: "https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}" }, 1516 googleIMA: { sdk: "https://imasdk.googleapis.com/js/sdkloader/ima3.js" }, 1517 }, 1518 listeners: { 1519 seek: null, 1520 play: null, 1521 pause: null, 1522 restart: null, 1523 rewind: null, 1524 fastForward: null, 1525 mute: null, 1526 volume: null, 1527 captions: null, 1528 download: null, 1529 fullscreen: null, 1530 pip: null, 1531 airplay: null, 1532 speed: null, 1533 quality: null, 1534 loop: null, 1535 language: null, 1536 }, 1537 events: [ 1538 "ended", 1539 "progress", 1540 "stalled", 1541 "playing", 1542 "waiting", 1543 "canplay", 1544 "canplaythrough", 1545 "loadstart", 1546 "loadeddata", 1547 "loadedmetadata", 1548 "timeupdate", 1549 "volumechange", 1550 "play", 1551 "pause", 1552 "error", 1553 "seeking", 1554 "seeked", 1555 "emptied", 1556 "ratechange", 1557 "cuechange", 1558 "download", 1559 "enterfullscreen", 1560 "exitfullscreen", 1561 "captionsenabled", 1562 "captionsdisabled", 1563 "languagechange", 1564 "controlshidden", 1565 "controlsshown", 1566 "ready", 1567 "statechange", 1568 "qualitychange", 1569 "adsloaded", 1570 "adscontentpause", 1571 "adscontentresume", 1572 "adstarted", 1573 "adsmidpoint", 1574 "adscomplete", 1575 "adsallcomplete", 1576 "adsimpression", 1577 "adsclick", 1578 ], 1579 selectors: { 1580 editable: "input, textarea, select, [contenteditable]", 1581 container: ".plyr", 1582 controls: { container: null, wrapper: ".plyr__controls" }, 1583 labels: "[data-plyr]", 1584 buttons: { 1585 play: '[data-plyr="play"]', 1586 pause: '[data-plyr="pause"]', 1587 restart: '[data-plyr="restart"]', 1588 rewind: '[data-plyr="rewind"]', 1589 fastForward: '[data-plyr="fast-forward"]', 1590 mute: '[data-plyr="mute"]', 1591 captions: '[data-plyr="captions"]', 1592 download: '[data-plyr="download"]', 1593 fullscreen: '[data-plyr="fullscreen"]', 1594 pip: '[data-plyr="pip"]', 1595 airplay: '[data-plyr="airplay"]', 1596 settings: '[data-plyr="settings"]', 1597 loop: '[data-plyr="loop"]', 1598 }, 1599 inputs: { seek: '[data-plyr="seek"]', volume: '[data-plyr="volume"]', speed: '[data-plyr="speed"]', language: '[data-plyr="language"]', quality: '[data-plyr="qual
1599ity"]' }, 1600 display: { currentTime: ".plyr__time--current", duration: ".plyr__time--duration", buffer: ".plyr__progress__buffer", loop: ".plyr__progress__loop", volume: ".plyr__volume--display" }, 1601 progress: ".plyr__progress", 1602 captions: ".plyr__captions", 1603 caption: ".plyr__caption", 1604 }, 1605 classNames: { 1606 type: "plyr--{0}", 1607 provider: "plyr--{0}", 1608 video: "plyr__video-wrapper", 1609 embed: "plyr__video-embed", 1610 videoFixedRatio: "plyr__video-wrapper--fixed-ratio", 1611 embedContainer: "plyr__video-embed__container", 1612 poster: "plyr__poster", 1613 posterEnabled: "plyr__poster-enabled", 1614 ads: "plyr__ads", 1615 control: "plyr__control", 1616 controlPressed: "plyr__control--pressed", 1617 playing: "plyr--playing", 1618 paused: "plyr--paused", 1619 stopped: "plyr--stopped", 1620 loading: "plyr--loading", 1621 hover: "plyr--hover", 1622 tooltip: "plyr__tooltip", 1623 cues: "plyr__cues", 1624 hidden: "plyr__sr-only", 1625 hideControls: "plyr--hide-controls", 1626 isIos: "plyr--is-ios", 1627 isTouch: "plyr--is-touch", 1628 uiSupported: "plyr--full-ui", 1629 noTransition: "plyr--no-transition", 1630 display: { time: "plyr__time" }, 1631 menu: { value: "plyr__menu__value", badge: "plyr__badge", open: "plyr--menu-open" }, 1632 captions: { enabled: "plyr--captions-enabled", active: "plyr--captions-active" }, 1633 fullscreen: { enabled: "plyr--fullscreen-enabled", fallback: "plyr--fullscreen-fallback" }, 1634 pip: { supported: "plyr--pip-supported", active: "plyr--pip-active" }, 1635 airplay: { supported: "plyr--airplay-supported", active: "plyr--airplay-active" }, 1636 tabFocus: "plyr__tab-focus", 1637 previewThumbnails: { 1638 thumbContainer: "plyr__preview-thumb", 1639 thumbContainerShown: "plyr__preview-thumb--is-shown", 1640 imageContainer: "plyr__preview-thumb__image-container", 1641 timeContainer: "plyr__preview-thumb__time-container", 1642 scrubbingContainer: "plyr__preview-scrubbing", 1643 scrubbingContainerShown: "plyr__preview-scrubbing--is-shown", 1644 }, 1645 }, 1646 attributes: { embed: { provider: "data-plyr-provider", id: "data-plyr-embed-id", hash: "data-plyr-embed-hash" } }, 1647 ads: { enabled: !1, publisherId: "", tagUrl: "" }, 1648 previewThumbnails: { enabled: !1, src: "" }, 1649 vimeo: { byline: !1, portrait: !1, title: !1, speed: !0, transparent: !1, customControls: !0, referrerPolicy: null, premium: !1 }, 1650 youtube: { rel: 0, showinfo: 0, iv_load_policy: 3, modestbranding: 1, customControls: !0, noCookie: !1 }, 1651 }, 1652 Xe = "picture-in-picture", 1653 Je = "inline", 1654 Ge = { html5: "html5", youtube: "youtube", vimeo: "vimeo" }, 1655 Ze = "audio", 1656 et = "video"; 1657 const tt = () => {}; 1658 class it { 1659 constructor(e = !1) { 1660 (this.enabled = window.console && e), this.enabled && this.log("Debugging enabled"); 1661 } 1662 get log() { 1663 return this.enabled ? Function.prototype.bind.call(console.log, console) : tt; 1664 } 1665 get warn() { 1666 return this.enabled ? Function.prototype.bind.call(console.warn, console) : tt; 1667 } 1668 get error() { 1669 return this.enabled ? Function.prototype.bind.call(console.error, console) : tt; 1670 } 1671 } 1672 class st { 1673 constructor(t) {
1674 e(this, "onChange", () => { 1675 if (!this.enabled) return; 1676 const e = this.player.elements.buttons.fullscreen; 1677 H(e) && (e.pressed = this.active); 1678 const t = this.target === this.player.media ? this.target : this.player.elements.container; 1679 ve.call(this.player, t, this.active ? "enterfullscreen" : "exitfullscreen", !0); 1680 }), 1681 e(this, "toggleFallback", (e = !1) => { 1682 if ( 1683 (e ? (this.scrollPosition = { x: window.scrollX || 0, y: window.scrollY || 0 }) : window.scrollTo(this.scrollPosition.x, this.scrollPosition.y), 1684 (document.body.style.overflow = e ? "hidden" : ""), 1685 le(this.target, this.player.config.classNames.fullscreen.fallback, e), 1686 Y.isIos) 1687 ) { 1688 let t = document.head.querySelector('meta[name="viewport"]'); 1689 const i = "viewport-fit=cover"; 1690 t || ((t = document.createElement("meta")), t.setAttribute("name", "viewport")); 1691 const s = _(t.content) && t.content.includes(i); 1692 e 1693 ? ((this.cleanupViewport = !s), s || (t.content += `,${i}`)) 1694 : this.cleanupViewport && 1695 (t.content = t.content 1696 .split(",") 1697 .filter((e) => e.trim() !== i) 1698 .join(",")); 1699 } 1700 this.onChange(); 1701 }), 1702 e(this, "trapFocus", (e) => { 1703 if (Y.isIos || !this.active || "Tab" !== e.key || 9 !== e.keyCode) return; 1704 const t = document.activeElement, 1705 i = ce.call(this.player, "a[href], button:not(:disabled), input:not(:disabled), [tabindex]"), 1706 [s] = i, 1707 n = i[i.length - 1]; 1708 t !== n || e.shiftKey ? t === s && e.shiftKey && (n.focus(), e.preventDefault()) : (s.focus(), e.preventDefault()); 1709 }), 1710 e(this, "update", () => { 1711 if (this.enabled) { 1712 let e; 1713 (e = this.forceFallback ? "Fallback (forced)" : st.native ? "Native" : "Fallback"), this.player.debug.log(`${e} fullscreen enabled`); 1714 } else this.player.debug.log("Fullscreen not supported and fallback disabled"); 1715 le(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.enabled); 1716 }), 1717 e(this, "enter", () => { 1718 this.enabled && 1719 (Y.isIos && this.player.config.fullscreen.iosNative 1720 ? this.player.isVimeo 1721 ? this.player.embed.requestFullscreen() 1722 : this.target.webkitEnterFullscreen() 1723 : !st.native || this.forceFallback 1724 ? this.toggleFallback(!0) 1725 : this.prefix 1726 ? W(this.prefix) || this.target[`${this.prefix}Request${this.property}`]() 1727 : this.target.requestFullscreen({ navigationUI: "hide" })); 1728 }), 1729 e(this, "exit", () => { 1730 if (this.enabled) 1731 if (Y.isIos && this.player.config.fullscreen.iosNative) this.target.webkitExitFullscreen(), ke(this.player.play()); 1732 else if (!st.native || this.forceFallback) this.toggleFallback(!1); 1733 else if (this.prefix) { 1734 if (!W(this.prefix)) { 1735 const e = "moz" === this.prefix ? "Cancel" : "Exit"; 1736 document[`${this.prefix}${e}${this.property}`](); 1737 } 1738 } else (document.cancelFullScreen || document.exitFullscreen).call(document); 1739 }), 1740 e(this, "toggle", () => { 1741 this.active ? this.exit() : this.enter(); 1742 }), 1743 (this.player = t), 1744 (this.prefix = st.prefix), 1745 (this.property = st.property), 1746 (this.scrollPosition = { x: 0, y: 0 }), 1747 (this.forceFallback = "force" === t.config.fullscreen.fallback), 1748 (this.player.elements.fullscreen = 1749 t.config.fullscreen.container && 1750 (function (e, t) { 1751 const { prototype: i } = Element; 1752 return ( 1753 i.closest || 1754 function () { 1755 let e = this; 1756 do { 1757 if (re.matches(e, t)) return e; 1758 e = e.parentElement || e.parentNode; 1759 } while (null !== e && 1 === e.nodeType); 1760 return null; 1761 } 1762 ).call(e, t); 1763 })(this.player.elements.container, t.config.fullscreen.container)), 1764 fe.call(this.player, document, "ms" === this.prefix ? "MSFullscreenChange" : `${this.prefix}fullscreenchange`, () => { 1765 this.onChange(); 1766 }), 1767 fe.call(this.player, this.player.elements.container, "dblclick", (e) => { 1768 (H(this.player.elements.controls) && this.player.elements.controls.contains(e.target)) || this.player.listeners.proxy(e, this.toggle, "fullscreen"); 1769 }), 1770 fe.call(this, this.player.elements.container, "keydown", (e) => this.trapFocus(e)), 1771 this.update(); 1772 } 1773 static get native() { 1774 return !!(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled); 1775 } 1776 get usingNative() { 1777 return st.native && !this.forceFallback; 1778 } 1779 static get prefix() { 1780 if (j(document.exitFullscreen)) return ""; 1781 let e = ""; 1782 return ["webkit", "moz", "ms"].some((t) => !(!j(document[`${t}ExitFullscreen`]) && !j(document[`${t}CancelFullScreen`])) && ((e = t), !0)), e; 1783 } 1784 static get property() { 1785 return "moz" === this.prefix ? "FullScreen" : "Fullscreen"; 1786 } 1787 get enabled() { 1788 return (st.native || this.player.config.fullscreen.fallback) && this.player.config.fullscreen.enabled && this.player.supported.ui && this.player.isVideo; 1789 } 1790 get active() { 1791 if (!this.enabled) return !1; 1792 if (!st.native || this.forceFallback) return oe(this.target, this.player.config.classNames.fullscreen.fallback); 1793 const e = this.prefix ? this.target.getRootNode()[`${this.prefix}${this.property}Element`] : this.target.getRootNode().fullscreenElement; 1794 return e && e.shadowRoot ? e === this.target.getRootNode().host : e === this.target; 1795 } 1796 get target() { 1797 return Y.isIos && this.player.config.fullscreen.iosNative ? this.player.media : this.player.elements.fullscreen || this.player.elements.container; 1798 } 1799 } 1800 function nt(e, t = 1) { 1801 return new Promise((i, s) => { 1802 const n = new Image(), 1803 a = () => { 1804 delete n.onload, delete n.onerror, (n.naturalWi
1804dth >= t ? i : s)(n); 1805 }; 1806 Object.assign(n, { onload: a, onerror: a, src: e }); 1807 }); 1808 } 1809 const at = { 1810 addStyleHook() { 1811 le(this.elements.container, this.config.selectors.container.replace(".", ""), !0), le(this.elements.container, this.config.classNames.uiSupported, this.supported.ui); 1812 }, 1813 toggleNativeControls(e = !1) { 1814 e && this.isHTML5 ? this.media.setAttribute("controls", "") : this.media.removeAttribute("controls"); 1815 }, 1816 build() { 1817 if ((this.listeners.media(), !this.supported.ui)) return this.debug.warn(`Basic support only for ${this.provider} ${this.type}`), void at.toggleNativeControls.call(this, !0); 1818 H(this.elements.controls) || (We.inject.call(this), this.listeners.controls()), 1819 at.toggleNativeControls.call(this), 1820 this.isHTML5 && Ye.setup.call(this), 1821 (this.volume = null), 1822 (this.muted = null), 1823 (this.loop = null),
1824 (this.quality = null), 1825 (this.speed = null), 1826 We.updateVolume.call(this), 1827 We.timeUpdate.call(this), 1828 We.durationUpdate.call(this), 1829 at.checkPlaying.call(this), 1830 le(this.elements.container, this.config.classNames.pip.supported, me.pip && this.isHTML5 && this.isVideo), 1831 le(this.elements.container, this.config.classNames.airplay.supported, me.airplay && this.isHTML5), 1832 le(this.elements.container, this.config.classNames.isIos, Y.isIos), 1833 le(this.elements.container, this.config.classNames.isTouch, this.touch), 1834 (this.ready = !0), 1835 setTimeout(() => { 1836 ve.call(this, this.media, "ready"); 1837 }, 0), 1838 at.setTitle.call(this), 1839 this.poster && at.setPoster.call(this, this.poster, !1).catch(() => {}), 1840 this.config.duration && We.durationUpdate.call(this); 1841 }, 1842 setTitle() { 1843 let e = He.get("play", this.config); 1844 if ( 1845 (_(this.config.title) && !W(this.config.title) && (e += `, ${this.config.title}`), 1846 Array.from(this.elements.buttons.play || []).forEach((t) => { 1847 t.setAttribute("aria-label", e); 1848 }), 1849 this.isEmbed) 1850 ) { 1851 const e = he.call(this, "iframe"); 1852 if (!H(e)) return; 1853 const t = W(this.config.title) ? "video" : this.config.title, 1854 i = He.get("frameTitle", this.config); 1855 e.setAttribute("title", i.replace("{title}", t)); 1856 } 1857 }, 1858 togglePoster(e) { 1859 le(this.elements.container, this.config.classNames.posterEnabled, e); 1860 }, 1861 setPoster(e, t = !0) { 1862 return t && this.poster 1863 ? Promise.reject(new Error("Poster already set")) 1864 : (this.media.setAttribute("data-poster", e), 1865 this.elements.poster.removeAttribute("hidden"), 1866 Te.call(this) 1867 .then(() => nt(e)) 1868 .catch((t) => { 1869 throw (e === this.poster && at.togglePoster.call(this, !1), t); 1870 }) 1871 .then(() => { 1872 if (e !== this.poster) throw new Error("setPoster cancelled by later call to setPoster"); 1873 }) 1874 .then(() => (Object.assign(this.elements.poster.style, { backgroundImage: `url('${e}')`, backgroundSize: "" }), at.togglePoster.call(this, !0), e))); 1875 }, 1876 checkPlaying(e) { 1877 le(this.elements.container, this.config.classNames.playing, this.playing), 1878 le(this.elements.container, this.config.classNames.paused, this.paused), 1879 le(this.elements.container, this.config.classNames.stopped, this.stopped), 1880 Array.from(this.elements.buttons.play || []).forEach((e) => { 1881 Object.assign(e, { pressed: this.playing }), e.setAttribute("aria-label", He.get(this.playing ? "pause" : "play", this.config)); 1882 }), 1883 (F(e) && "timeupdate" === e.type) || at.toggleControls.call(this); 1884 }, 1885 checkLoading(e) { 1886 (this.loading = ["stalled", "waiting"].includes(e.type)), 1887 clearTimeout(this.timers.loading), 1888 (this.timers.loading = setTimeout( 1889 () => { 1890 le(this.elements.container, this.config.classNames.loading, this.loading), at.toggleControls.call(this); 1891 }, 1892 this.loading ? 250 : 0 1893 )); 1894 }, 1895 toggleControls(e) { 1896 const { controls: t } = this.elements; 1897 if (t && this.config.hideControls) { 1898 const i = this.touch && this.lastSeekTime + 2e3 > Date.now(); 1899 this.toggleControls(Boolean(e || this.loading || this.paused || t.pressed || t.hover || i)); 1900 } 1901 }, 1902 migrateStyles() { 1903 Object.values({ ...this.media.style }) 1904 .filter((e) => !W(e) && _(e) && e.startsWith("--plyr")) 1905 .forEach((e) => { 1906 this.elements.container.style.setProperty(e, this.media.style.getPropertyValue(e)), this.media.style.removeProperty(e); 1907 }), 1908 W(this.media.style) && this.media.removeAttribute("style"); 1909 }, 1910 }; 1911 class lt { 1912 constructor(t) { 1913 e(this, "firstTouch", () => { 1914 const { player: e } = this, 1915 { elements: t } = e; 1916 (e.touch = !0), le(t.container, e.config.classNames.isTouch, !0); 1917 }), 1918 e(this, "setTabFocus", (e) => { 1919 const { player: t } = this,
1920 { elements: i } = t; 1921 if ((clearTimeout(this.focusTimer), "keydown" === e.type && 9 !== e.which)) return; 1922 "keydown" === e.type && (this.lastKeyDown = e.timeStamp); 1923 const s = e.timeStamp - this.lastKeyDown <= 20; 1924 ("focus" !== e.type || s) && 1925 ((() => { 1926 const e = t.config.classNames.tabFocus; 1927 le(ce.call(t, `.${e}`), e, !1); 1928 })(), 1929 "focusout" !== e.type && 1930 (this.focusTimer = setTimeout(() => { 1931 const e = document.activeElement; 1932 i.container.contains(e) && le(document.activeElement, t.config.classNames.tabFocus, !0); 1933 }, 10))); 1934 }), 1935 e(this, "global", (e = !0) => { 1936 const { player: t } = this; 1937 t.config.keyboard.global && ge.call(t, window, "keydown keyup", this.handleKey, e, !1), 1938 ge.call(t, document.body, "click", this.toggleMenu, e), 1939 ye.call(t, document.body, "touchstart", this.firstTouch), 1940 ge.call(t, document.body, "keydown focus blur focusout", this.setTabFocus, e, !1, !0); 1941 }), 1942 e(this, "container", () => { 1943 const { player: e } = this, 1944 { config: t, elements: i, timers: s } = e; 1945 !t.keyboard.global && t.keyboard.focused && fe.call(e, i.container, "keydown keyup", this.handleKey, !1), 1946 fe.call(e, i.container, "mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen", (t) => { 1947 const { controls: n } = i; 1948 n && "enterfullscreen" === t.type && ((n.pressed = !1), (n.hover = !1)); 1949 let a = 0; 1950 ["touchstart", "touchmove", "mousemove"].includes(t.type) && (at.toggleControls.call(e, !0), (a = e.touch ? 3e3 : 2e3)), 1951 clearTimeout(s.controls), 1952 (s.controls = setTimeout(() => at.toggleControls.call(e, !1), a)); 1953 }); 1954 const n = () => { 1955 if (!e.isVimeo || e.config.vimeo.premium) return; 1956 const t = i.wrapper, 1957 { active: s } = e.fullscreen, 1958 [n, a] = xe.call(e), 1959 l = Se(`aspect-ratio: ${n} / ${a}`); 1960 if (!s) return void (l ? ((t.style.width = null), (t.style.height = null)) : ((t.style.maxWidth = null), (t.style.margin = null))); 1961 const [o, r] = [Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0), Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)], 1962 c = o / r > n / a; 1963 l ? ((t.style.width = c ? "auto" : "100%"), (t.style.height = c ? "100%" : "auto")) : ((t.style.maxWidth = c ? (r / a) * n + "px" : null), (t.style.margin = c ? "0 auto" : null)); 1964 }, 1965 a = () => { 1966 clearTimeout(s.resized), (s.resized = setTimeout(n, 50)); 1967 }; 1968 fe.call(e, i.container, "enterfullscreen exitfullscreen", (t) => { 1969 const { target: s } = e.fullscreen; 1970 if (s !== i.container) return; 1971 if (!e.isEmbed && W(e.config.ratio)) return; 1972 n(); 1973 ("enterfullscreen" === t.type ? fe : be).call(e, window, "resize", a); 1974 }); 1975 }), 1976 e(this, "media", () => { 1977 const { player: e } = this, 1978 { elements: t } = e; 1979 if ( 1980 (fe.call(e, e.media, "timeupdate seeking seeked", (t) => We.timeUpdate.call(e, t)), 1981 fe.call(e, e.media, "durationchange loadeddata loadedmetadata", (t) => We.durationUpdate.call(e, t)), 1982 fe.call(e, e.media, "ended", () => { 1983 e.isHTML5 && e.isVideo && e.config.resetOnEnd && (e.restart(), e.pause()); 1984 }), 1985 fe.call(e, e.media, "progress playing seeking seeked", (t) => We.updateProgress.call(e, t)), 1986 fe.call(e, e.media, "volumechange", (t) => We.updateVolume.call(e, t)), 1987 fe.call(e, e.media, "playing play pause ended emptied timeupdate", (t) => at.checkPlaying.call(e, t)), 1988 fe.call(e, e.media, "waiting canplay seeked playing", (t) => at.checkLoading.call(e, t)), 1989 e.supported.ui && e.config.clickToPlay && !e.isAudio) 1990 ) { 1991 const i = he.call(e, `.${e.config.classNames.video}`); 1992 if (!H(i)) return; 1993 fe.call(e, t.container, "click", (s) => { 1994 ([t.container, i].includes(s.target) || i.contains(s.target)) && 1995 ((e.touch && e.config.hideControls) || 1996 (e.ended 1997 ? (this.proxy(s, e.restart, "restart"), 1998 this.proxy( 1999 s, 2000 () => { 2001 ke(e.play()); 2002 }, 2003 "play" 2004 )) 2005 : this.proxy( 2006 s, 2007 () => { 2008 ke(e.togglePlay()); 2009 }, 2010 "play" 2011 ))); 2012 }); 2013 } 2014 e.supported.ui && 2015 e.config.disableContextMenu && 2016 fe.call( 2017 e, 2018 t.wrapper, 2019 "contextmenu", 2020 (e) => { 2021 e.preventDefault(); 2022 }, 2023 !1 2024 ), 2025 fe.call(e, e.media, "volumechange", () => { 2026 e.storage.set({ volume: e.volume, muted: e.muted }); 2027 }), 2028 fe.call(e, e.media, "ratechange", () => { 2029 We.updateSetting.call(e, "speed"), e.storage.set({ speed: e.speed }); 2030 }), 2031 fe.call(e, e.media, "qualitychange", (t) => { 2032 We.updateSetting.call(e, "quality", null, t.detail.quality); 2033 }), 2034 fe.call(e, e.media, "ready qualitychange", () => { 2035 We.setDownloadUrl.call(e); 2036 }); 2037 const i = e.config.events.concat(["keyup", "keydown"]).join(" "); 2038 fe.call(e, e.media, i, (i) => { 2039 let { detail: s = {} } = i; 2040 "error" === i.type && (s = e.media.error), ve.call(e, t.container, i.type, !0, s); 2041 }); 2042 }), 2043 e(this, "proxy", (e, t, i) => { 2044 const { player: s } = this, 2045 n = s.config.listeners[i]; 2046 let a = !0; 2047 j(n) && (a = n.call(s, e)), !1 !== a && j(t) && t.call(s, e); 2048 }), 2049 e(this, "bind", (e, t, i, s, n = !0) => { 2050 const { player: a } = this, 2051 l = a.config.listeners[s], 2052 o = j(l); 2053 fe.call(a, e, t, (e) => this.proxy(e, i, s), n && !o); 2054 }), 2055 e(this, "controls", () => { 2056 const { player: e } = this, 2057 { elements: t } = e, 2058 i = Y.isIE ? "change" : "input"; 2059 if ( 2060 (t.buttons.play && 2061 Array.from(t.buttons.play).forEac
2061h((t) => { 2062 this.bind( 2063 t, 2064 "click", 2065 () => { 2066 ke(e.togglePlay()); 2067 }, 2068 "play" 2069 ); 2070 }), 2071 this.bind(t.buttons.restart, "click", e.restart, "restart"), 2072 this.bind( 2073 t.buttons.rewind, 2074 "click", 2075 () => { 2076 (e.lastSeekTime = Date.now()), e.rewind(); 2077 }, 2078 "rewind" 2079 ), 2080 this.bind( 2081 t.buttons.fastForward, 2082 "click", 2083 () => { 2084 (e.lastSeekTime = Date.now()), e.forward(); 2085 }, 2086 "fastForward" 2087 ), 2088 this.bind( 2089 t.buttons.mute, 2090 "click", 2091 () => { 2092 e.muted = !e.muted; 2093 }, 2094 "mute" 2095 ), 2096 this.bind(t.buttons.captions, "click", () => e.toggleCaptions()), 2097 this.bind( 2098 t.buttons.download, 2099 "click", 2100 () => { 2101 ve.call(e, e.media, "download"); 2102 }, 2103 "download" 2104 ), 2105 this.bind( 2106 t.buttons.fullscreen, 2107 "click", 2108 () => { 2109 e.fullscreen.toggle(); 2110 }, 2111 "fullscreen" 2112 ), 2113 this.bind( 2114 t.buttons.pip, 2115 "click", 2116 () => { 2117 e.pip = "toggle"; 2118 }, 2119 "pip" 2120 ), 2121 this.bind(t.buttons.airplay, "click", e.airplay, "airplay"), 2122 this.bind( 2123 t.buttons.settings, 2124 "click", 2125 (t) => { 2126 t.stopPropagation(), t.preventDefault(), We.toggleMenu.call(e, t); 2127 }, 2128 null, 2129 !1 2130 ), 2131 this.bind( 2132 t.buttons.settings, 2133 "keyup", 2134 (t) => { 2135 const i = t.which; 2136 [13, 32].includes(i) && (13 !== i ? (t.preventDefault(), t.stopPropagation(), We.toggleMenu.call(e, t)) : We.focusFirstMenuItem.call(e, null, !0)); 2137 }, 2138 null, 2139 !1 2140 ), 2141 this.bind(t.settings.menu, "keydown", (t) => { 2142 27 === t.which && We.toggleMenu.call(e, t); 2143 }), 2144 this.bind(t.inputs.seek, "mousedown mousemove", (e) => { 2145 const i = t.progress.getBoundingClientRect(), 2146 s = (100 / i.width) * (e.pageX - i.left); 2147 e.currentTarget.setAttribute("seek-value", s); 2148 }), 2149 this.bind(t.inputs.seek, "mousedown mouseup keydown keyup touchstart touchend", (t) => { 2150 const i = t.currentTarget, 2151 s = t.keyCode ? t.keyCode : t.which, 2152 n = "play-on-seeked"; 2153 if (R(t) && 39 !== s && 37 !== s) return; 2154 e.lastSeekTime = Date.now(); 2155 const a = i.hasAttribute(n), 2156 l = ["mouseup", "touchend", "keyup"].includes(t.type); 2157 a && l ? (i.removeAttribute(n), ke(e.play())) : !l && e.playing && (i.setAttribute(n, ""), e.pause()); 2158 }), 2159 Y.isIos) 2160 ) { 2161 const t = ce.call(e, 'input[type="range"]'); 2162 Array.from(t).forEach((e) => this.bind(e, i, (e) => K(e.target))); 2163 } 2164 this.bind(
2165 t.inputs.seek, 2166 i, 2167 (t) => { 2168 const i = t.currentTarget; 2169 let s = i.getAttribute("seek-value"); 2170 W(s) && (s = i.value), i.removeAttribute("seek-value"), (e.currentTime = (s / i.max) * e.duration); 2171 }, 2172 "seek" 2173 ), 2174 this.bind(t.progress, "mouseenter mouseleave mousemove", (t) => We.updateSeekTooltip.call(e, t)), 2175 this.bind(t.progress, "mousemove touchmove", (t) => { 2176 const { previewThumbnails: i } = e; 2177 i && i.loaded && i.startMove(t); 2178 }), 2179 this.bind(t.progress, "mouseleave touchend click", () => { 2180 const { previewThumbnails: t } = e; 2181 t && t.loaded && t.endMove(!1, !0); 2182 }), 2183 this.bind(t.progress, "mousedown touchstart", (t) => { 2184 const { previewThumbnails: i } = e; 2185 i && i.loaded && i.startScrubbing(t); 2186 }), 2187 this.bind(t.progress, "mouseup touchend", (t) => { 2188 const { previewThumbnails: i } = e; 2189 i && i.loaded && i.endScrubbing(t); 2190 }), 2191 Y.isWebkit && 2192 Array.from(ce.call(e, 'input[type="range"]')).forEach((t) => { 2193 this.bind(t, "input", (t) => We.updateRangeFill.call(e, t.target)); 2194 }), 2195 e.config.toggleInvert && 2196 !H(t.display.duration) && 2197 this.bind(t.display.currentTime, "click", () => { 2198 0 !== e.currentTime && ((e.config.invertTime = !e.config.invertTime), We.timeUpdate.call(e)); 2199 }), 2200 this.bind( 2201 t.inputs.volume, 2202 i, 2203 (t) => { 2204 e.volume = t.target.value; 2205 }, 2206 "volume" 2207 ), 2208 this.bind(t.controls, "mouseenter mouseleave", (i) => { 2209 t.controls.hover = !e.touch && "mouseenter" === i.type; 2210 }), 2211 t.fullscreen && 2212 Array.from(t.fullscreen.children) 2213 .filter((e) => !e.contains(t.container)) 2214 .forEach((i) => { 2215 this.bind(i, "mouseenter mouseleave", (i) => { 2216 t.controls && (t.controls.hover = !e.touch && "mouseenter" === i.type); 2217 }); 2218 }), 2219 this.bind(t.controls, "mousedown mouseup touchstart touchend touchcancel", (e) => { 2220 t.controls.pressed = ["mousedown", "touchstart"].includes(e.type); 2221 }), 2222 this.bind(t.controls, "focusin", () => { 2223 const { config: i, timers: s } = e; 2224 le(t.controls, i.classNames.noTransition, !0), 2225 at.toggleControls.call(e, !0), 2226 setTimeout(() => { 2227 le(t.controls, i.classNames.noTransition, !1); 2228 }, 0); 2229 const n = this.touch ? 3e3 : 4e3; 2230 clearTimeout(s.controls), (s.controls = setTimeout(() => at.toggleControls.call(e, !1), n)); 2231 }), 2232 this.bind(
2233 t.inputs.volume, 2234 "wheel", 2235 (t) => { 2236 const i = t.webkitDirectionInvertedFromDevice, 2237 [s, n] = [t.deltaX, -t.deltaY].map((e) => (i ? -e : e)), 2238 a = Math.sign(Math.abs(s) > Math.abs(n) ? s : n); 2239 e.increaseVolume(a / 50); 2240 const { volume: l } = e.media; 2241 ((1 === a && l < 1) || (-1 === a && l > 0)) && t.preventDefault(); 2242 }, 2243 "volume", 2244 !1 2245 ); 2246 }), 2247 (this.player = t), 2248 (this.lastKey = null), 2249 (this.focusTimer = null), 2250 (this.lastKeyDown = null), 2251 (this.handleKey = this.handleKey.bind(this)), 2252 (this.toggleMenu = this.toggleMenu.bind(this)), 2253 (this.setTabFocus = this.setTabFocus.bind(this)), 2254 (this.firstTouch = this.firstTouch.bind(this)); 2255 } 2256 handleKey(e) { 2257 const { player: t } = this, 2258 { elements: i } = t, 2259 s = e.keyCode ? e.keyCode : e.which, 2260 n = "keydown" === e.type, 2261 a = n && s === this.lastKey; 2262 if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return; 2263 if (!$(s)) return; 2264 if (n) { 2265 const n = document.activeElement; 2266 if (H(n)) { 2267 const { editable: s } = t.config.selectors, 2268 { seek: a } = i.inputs; 2269 if (n !== a && re(n, s)) return; 2270 if (32 === e.which && re(n, 'button, [role^="menuitem"]')) return; 2271 } 2272 switch (([32, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54, 56, 57, 67, 70, 73, 75, 76, 77, 79].includes(s) && (e.preventDefault(), e.stopPropagation()), s)) { 2273 case 48: 2274 case 49: 2275 case 50: 2276 case 51: 2277 case 52: 2278 case 53: 2279 case 54: 2280 case 55: 2281 case 56: 2282 case 57: 2283 a || (t.currentTime = (t.duration / 10) * (s - 48)); 2284 break; 2285 case 32: 2286 case 75: 2287 a || ke(t.togglePlay()); 2288 break; 2289 case 38: 2290 t.increaseVolume(0.1); 2291 break; 2292 case 40: 2293 t.decreaseVolume(0.1); 2294 break; 2295 case 77: 2296 a || (t.muted = !t.muted); 2297 break; 2298 case 39: 2299 t.forward(); 2300 break; 2301 case 37: 2302 t.rewind(); 2303 break; 2304 case 70: 2305 t.fullscreen.toggle(); 2306 break; 2307 case 67: 2308 a || t.toggleCaptions(); 2309 break; 2310 case 76: 2311 t.loop = !t.loop; 2312 } 2313 27 === s && !t.fullscreen.usingNative && t.fullscreen.active && t.fullscreen.toggle(), (this.lastKey = s); 2314 } else this.lastKey = null; 2315 } 2316 toggleMenu(e) { 2317 We.toggleMenu.call(this.player, e); 2318 } 2319 } 2320 "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self && self; 2321 var ot = (function (e, t) { 2322 return e((t = { exports: {} }), t.exports), t.exports; 2323 })(function (e, t) { 2324 e.exports = (function () { 2325 var e = function () {}, 2326 t = {}, 2327 i = {}, 2328 s = {}; 2329 function n(e, t) { 2330 e = e.push ? e : [e]; 2331 var n, 2332 a, 2333 l, 2334 o = [], 2335 r = e.length, 2336 c = r; 2337 for ( 2338 n = function (e, i) { 2339 i.length && o.push(e), --c || t(o); 2340 }; 2341 r--; 2342 2343 ) 2344 (a = e[r]), (l = i[a]) ? n(a, l) : (s[a] = s[a] || []).push(n); 2345 } 2346 function a(e, t) { 2347 if (e) { 2348 var n = s[e]; 2349 if (((i[e] = t), n)) for (; n.length; ) n[0](e, t), n.splice(0, 1); 2350 } 2351 } 2352 function l(t, i) { 2353 t.call && (t = { success: t }), i.length ? (t.error || e)(i) : (t.success || e)(t); 2354 } 2355 function o(t, i, s, n) { 2356 var a, 2357 l, 2358 r = document, 2359 c = s.async, 2360 h = (s.numRetries || 0) + 1, 2361 u = s.before || e, 2362 d = t.replace(/[\?|#].*$/, ""), 2363 m = t.replace(/^(css|img)!/, ""); 2364 (n = n || 0), 2365 /(^css!|\.css$)/.test(d) 2366 ? (((l = r.createElement("link")).rel = "stylesheet"), (l.href = m), (a = "hideFocus" in l) && l.relList && ((a = 0), (l.rel = "preload"), (l.as = "style"))) 2367 : /(^img!|\.(png|gif|jpg|svg|webp)$)/.test(d) 2368 ? ((l = r.createElement("img")).src = m) 2369 : (((l = r.createElement("script")).src = t), (l.async = void 0 === c || c)), 2370 (l.onload = l.onerror = l.onbeforeload = function (e) { 2371 var r = e.type[0]; 2372 if (a) 2373 try { 2374 l.sheet.cssText.length || (r = "e"); 2375 } catch (e) { 2376 18 != e.code && (r = "e"); 2377 } 2378 if ("e" == r) { 2379 if ((n += 1) < h) return o(t, i, s, n); 2380 } else if ("preload" == l.rel && "style" == l.as) return (l.rel = "stylesheet"); 2381 i(t, r, e.defaultPrevented); 2382 }), 2383 !1 !== u(t, l) && r.head.appendChild(l); 2384 } 2385 function r(e, t, i) { 2386 var s, 2387 n, 2388 a = (e = e.push ? e : [e]).length, 2389 l = a, 2390 r = []; 2391 for ( 2392 s = function (e, i, s) { 2393 if (("e" == i && r.push(e), "b" == i)) { 2394 if (!s) return; 2395 r.push(e); 2396 } 2397 --a || t(r); 2398 }, 2399 n = 0; 2400 n < l; 2401 n++ 2402 ) 2403 o(e[n], s, i); 2404 } 2405 function c(e, i, s) { 2406 var n, o; 2407 if ((i && i.trim && (n = i), (o = (n ? s : i) || {}), n)) { 2408 if (n in t) throw "LoadJS"; 2409 t[n] = !0; 2410 } 2411 function c(t, i) { 2412 r( 2413 e, 2414 function (e) {
2415 l(o, e), t && l({ success: t, error: i }, e), a(n, e); 2416 }, 2417 o 2418 ); 2419 } 2420 if (o.returnPromise) return new Promise(c); 2421 c(); 2422 } 2423 return ( 2424 (c.ready = function (e, t) { 2425 return ( 2426 n(e, function (e) { 2427 l(t, e); 2428 }), 2429 c 2430 ); 2431 }), 2432 (c.done = function (e) { 2433 a(e, []); 2434 }), 2435 (c.reset = function () { 2436 (t = {}), (i = {}), (s = {}); 2437 }), 2438 (c.isDefined = function (e) { 2439 return e in t; 2440 }), 2441 c 2442 ); 2443 })(); 2444 }); 2445 function rt(e) { 2446 return new Promise((t, i) => { 2447 ot(e, { success: t, error: i }); 2448 }); 2449 } 2450 function ct(e) { 2451 e && !this.embed.hasPlayed && (this.embed.hasPlayed = !0), this.media.paused === e && ((this.media.paused = !e), ve.call(this, this.media, e ? "play" : "pause")); 2452 } 2453 const ht = { 2454 setup() { 2455 const e = this; 2456 le(e.elements.wrapper, e.config.classNames.embed, !0), 2457 (e.options.speed = e.config.speed.options), 2458 Me.call(e), 2459 L(window.Vimeo) 2460 ? ht.ready.call(e) 2461 : rt(e.config.urls.vimeo.sdk) 2462 .then(() => { 2463 ht.ready.call(e); 2464 }) 2465 .catch((t) => { 2466 e.debug.warn("Vimeo SDK (player.js) failed to load", t); 2467 }); 2468 }, 2469 ready() { 2470 const e = this, 2471 t = e.config.vimeo, 2472 { premium: i, referrerPolicy: s, ...n } = t; 2473 let a = e.media.getAttribute("src"), 2474 l = ""; 2475 W(a) 2476 ? ((a = e.media.getAttribute(e.config.attributes.embed.id)), (l = e.media.getAttribute(e.config.attributes.embed.hash))) 2477 : (l = (function (e) { 2478 const t = e.match(/^.*(?:vimeo.com\/|video\/)(?:\d+)(?:\?.*&*h=|\/)+(?<hash>[\d,a-f]+)/); 2479 return t ? t.groups.hash : null; 2480 })(a)); 2481 const o = l ? { h: l } : {}; 2482 i && Object.assign(n, { controls: !1, sidedock: !1 }); 2483 const r = Ke({ loop: e.config.loop.active, autoplay: e.autoplay, muted: e.muted, gesture: "media", playsinline: !this.config.fullscreen.iosNative, ...o, ...n }), 2484 c = W((h = a)) ? null : $(Number(h)) ? h : h.match(/^.*(vimeo.com\/|video\/)(\d+).*/) ? RegExp.$2 : h; 2485 var h; 2486 const u = Z("iframe"), 2487 d = $e(e.config.urls.vimeo.iframe, c, r); 2488 if ( 2489 (u.setAttribute("src", d), 2490 u.setAttribute("allowfullscreen", ""), 2491 u.setAttribute("allow", ["autoplay", "fullscreen", "picture-in-picture", "encrypted-media", "accelerometer", "gyroscope"].join("; ")), 2492 W(s) || u.setAttribute("referrerPolicy", s), 2493 i || !t.customControls) 2494 ) 2495 u.setAttribute("data-poster", e.poster), (e.media = se(u, e.media)); 2496 else { 2497 const t = Z("div", { class: e.config.classNames.embedContainer, "data-poster": e.poster }); 2498 t.appendChild(u), (e.media = se(t, e.media)); 2499 } 2500 t.customControls || 2501 Re($e(e.config.urls.vimeo.api, d)).then((t) => { 2502 !W(t) && t.thumbnail_url && at.setPoster.call(e, t.thumbnail_url).catch(() => {}); 2503 }), 2504 (e.embed = new window.Vimeo.Player(u, { autopause: e.config.auto
2504pause, muted: e.muted })), 2505 (e.media.paused = !0), 2506 (e.media.currentTime = 0), 2507 e.supported.ui && e.embed.disableTextTrack(), 2508 (e.media.play = () => (ct.call(e, !0), e.embed.play())), 2509 (e.media.pause = () => (ct.call(e, !1), e.embed.pause())), 2510 (e.media.stop = () => { 2511 e.pause(), (e.currentTime = 0); 2512 }); 2513 let { currentTime: m } = e.media; 2514 Object.defineProperty(e.media, "currentTime", { 2515 get: () => m, 2516 set(t) { 2517 const { embed: i, media: s, paused: n, volume: a } = e, 2518 l = n && !i.hasPlayed; 2519 (s.seeking = !0), 2520 ve.call(e, s, "seeking"), 2521 Promise.resolve(l && i.setVolume(0)) 2522 .then(() => i.setCurrentTime(t)) 2523 .then(() => l && i.pause()) 2524 .then(() => l && i.setVolume(a)) 2525 .catch(() => {}); 2526 }, 2527 }); 2528 let p = e.config.speed.selected; 2529 Object.defineProperty(e.media, "playbackRate", { 2530 get: () => p, 2531 set(t) { 2532 e.embed 2533 .setPlaybackRate(t) 2534 .then(() => { 2535 (p = t), ve.call(e, e.media, "ratechange"); 2536 }) 2537 .catch(() => { 2538 e.options.speed = [1]; 2539 }); 2540 }, 2541 }); 2542 let { volume: g } = e.config; 2543 Object.defineProperty(e.media, "volume", { 2544 get: () => g, 2545 set(t) { 2546 e.embed.setVolume(t).then(() => { 2547 (g = t), ve.call(e, e.media, "volumechange"); 2548 }); 2549 }, 2550 }); 2551 let { muted: f } = e.config; 2552 Object.defineProperty(e.media, "muted", { 2553 get: () => f, 2554 set(t) { 2555 const i = !!O(t) && t; 2556 e.embed.setVolume(i ? 0 : e.config.volume).then(() => { 2557 (f = i), ve.call(e, e.media, "volumechange"); 2558 }); 2559 }, 2560 }); 2561 let b, 2562 { loop: y } = e.config; 2563 Object.defineProperty(e.media, "loop", { 2564 get: () => y, 2565 set(t) { 2566 const i = O(t) ? t : e.config.loop.active; 2567 e.embed.setLoop(i).then(() => { 2568 y = i; 2569 }); 2570 }, 2571 }), 2572 e.embed 2573 .getVideoUrl() 2574 .then((t) => { 2575 (b = t), We.setDownloadUrl.call(e); 2576 }) 2577 .catch((e) => { 2578 this.debug.warn(e); 2579 }), 2580 Object.defineProperty(e.media, "currentSrc", { get: () => b }), 2581 Object.defineProperty(e.media, "ended", { get: () => e.currentTime === e.duration }), 2582 Promise.all([e.embed.getVideoWidth(), e.embed.getVideoHeight()]).then((t) => { 2583 const [i, s] = t; 2584 (e.embed.ratio = Ie(i, s)), Me.call(this); 2585 }), 2586 e.embed.setAutopause(e.config.autopause).then((t) => { 2587 e.config.autopause = t; 2588 }), 2589 e.embed.getVideoTitle().then((t) => { 2590 (e.config.title = t), at.setTitle.call(this); 2591 }), 2592 e.embed.getCurrentTime().then((t) => { 2593 (m = t), ve.call(e, e.media, "timeupdate"); 2594 }), 2595 e.embed.getDuration().then((t) => { 2596 (e.media.duration = t), ve.call(e, e.media, "durationchange"); 2597 }), 2598 e.embed.getTextTracks().then((t) => { 2599 (e.media.textTracks = t), Ye.setup.call(e); 2600 }), 2601 e.embed.on("cuechange", ({ cues: t = [] }) => { 2602 const i = t.map((e) => 2603 (function (e) { 2604 const t = document.createDocumentFragment(), 2605 i = document.createElement("div"); 2606 return t.appendChild(i), (i.innerHTML = e), t.firstChild.innerText; 2607 })(e.text) 2608 ); 2609 Ye.updateCues.call(e, i); 2610 }), 2611 e.embed.on("loaded", () => { 2612 if ( 2613 (e.embed.getPaused().then((t) => { 2614 ct.call(e, !t), t || ve.call(e, e.media, "playing"); 2615 }), 2616 H(e.embed.element) && e.supported.ui) 2617 ) { 2618 e.embed.element.setAttribute("tabindex", -1); 2619 } 2620 }), 2621 e.embed.on("bufferstart", () => { 2622 ve.call(e, e.media, "waiting"); 2623 }), 2624 e.embed.on("bufferend", () => { 2625 ve.call(e, e.media, "playing"); 2626 }), 2627 e.embed.on("play", () => { 2628 ct.call(e, !0), ve.call(e, e.media, "playing"); 2629 }), 2630 e.embed.on("pause", () => { 2631 ct.call(e, !1); 2632 }), 2633 e.embed.on("timeupdate", (t) => { 2634 (e.media.seeking = !1), (m = t.seconds), ve.call(e, e.media, "timeupdate"); 2635 }), 2636 e.embed.on("progress", (t) => { 2637 (e.media.buffered = t.percent), 2638 ve.call(e, e.media, "progress"), 2639 1 === parseInt(t.percent, 10) && ve.call(e, e.media, "canplaythrough"), 2640 e.embed.getDuration().then((t) => { 2641 t !== e.media.duration && ((e.media.duration = t), ve.call(e, e.media, "durationchange")); 2642 }); 2643 }), 2644 e.embed.on("seeked", () => { 2645 (e.media.seeking = !1), ve.call(e, e.media, "seeked"); 2646 }), 2647 e.embed.on("ended", () => { 2648 (e.media.paused = !0), ve.call(e, e.media, "ended"); 2649 }), 2650 e.embed.on("error", (t) => { 2651 (e.media.error = t), ve.call(e, e.media, "error"); 2652 }), 2653 t.customControls && setTimeout(() => at.build.call(e), 0); 2654 }, 2655 }; 2656 function ut(e) { 2657 e && !this.embed.hasPlayed && (this.embed.hasPlayed = !0), this.media.paused === e && ((this.media.paused = !e), ve.call(this, this.media, e ? "play" : "pause")); 2658 } 2659 function dt(e) { 2660 return e.noCookie ? "https://www.youtube-nocookie.com" : "http:" === window.location.protocol ? "http://www.youtube.com" : void 0; 2661 } 2662 const mt = { 2663 setup() { 2664 if ((le(this.elements.wrapper, this.config.classNames.embed, !0), L(window.YT) && j(window.YT.Player))) mt.ready.call(this); 2665 else { 2666 const e = window.onYouTubeIframeAPIReady; 2667 (window.onYouTubeIframeAPIReady = () => { 2668 j(e) && e(), mt.ready.call(this); 2669 }), 2670 rt(this.config.urls.youtube.sdk).catch((e) => { 2671 this.debug.warn("YouTube API failed to load", e); 2672 }); 2673 } 2674 }, 2675 getTitle(e) { 2676 Re($e(this.config.urls.youtube.api, e)) 2677 .then((e) => { 2678 if (L(e)) { 2679 const { title: t, height: i, width: s } = e; 2680 (this.config.title = t), at.setTitle.call(this), (this.embed.ratio = Ie(s, i)); 2681 } 2682 Me.call(this); 2683 }) 2684 .catch(() => { 2685 Me.call(this); 2686 }); 2687 }, 2688 ready() { 2689 const e = this, 2690 t = e.config.youtube, 2691 i = e.media && e.media.getAttribute("id"); 2692 if (!W(i) && i.startsWith("youtube-")) return; 2693 let s = e.media.getAttribute("src"); 2694 W(s) && (s = e.media.getAttribute(this.config.attributes.embed.id)); 2695 const n = W((a = s)) ? null : a.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/) ? RegExp.$2 : a; 2696 var a; 2697 const l = Z("div", { id: `${e.provider}-${Math.floor(1e4 * Math.random())}`, "data-poster": t.customControls ? e.poster : void 0 }); 2698 if (((e.media = se(l, e.media)), t.customControls)) { 2699 const t = (e) => `https://i.ytimg.com/vi/${n}/${e}default.jpg`; 2700 nt(t("maxres"), 121) 2701 .catch(() => nt(t("sd"), 121)) 2702 .catch(() => nt(t("hq"))) 2703 .then((t) => at.setPoster.call(e, t.src)) 2704 .then((t) => { 2705 t.includes("maxres") || (e.elements.poster.style.backgroundSize = "cover"); 2706 }) 2707 .catch(() => {}); 2708 } 2709 e.embed = new window.YT.Player(e.media, { 2710 videoId: n, 2711 host: dt(t), 2712 playerVars: X( 2713 {}, 2714 {
2715 autoplay: e.config.autoplay ? 1 : 0, 2716 hl: e.config.hl, 2717 controls: e.supported.ui && t.customControls ? 0 : 1, 2718 disablekb: 1, 2719 playsinline: e.config.fullscreen.iosNative ? 0 : 1, 2720 cc_load_policy: e.captions.active ? 1 : 0, 2721 cc_lang_pref: e.config.captions.language, 2722 widget_referrer: window ? window.location.href : null, 2723 }, 2724 t 2725 ), 2726 events: { 2727 onError(t) { 2728 if (!e.media.error) { 2729 const i = t.data, 2730 s = 2731 { 2732 2: "The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.", 2733 5: "The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.", 2734 100: "The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.", 2735 101: "The owner of the requested video does not allow it to be played in embedded players.", 2736 150: "The owner of the requested video does not allow it to be played in embedded players.", 2737 }[i] || "An unknown error occured"; 2738 (e.media.error = { code: i, message: s }), ve.call(e, e.media, "error"); 2739 } 2740 }, 2741 onPlaybackRateChange(t) { 2742 const i = t.target; 2743 (e.media.playbackRate = i.getPlaybackRate()), ve.call(e, e.media, "ratechange"); 2744 }, 2745 onReady(i) { 2746 if (j(e.media.play)) return; 2747 const s = i.target; 2748 mt.getTitle.call(e, n), 2749 (e.media.play = () => { 2750 ut.call(e, !0), s.playVideo(); 2751 }), 2752 (e.media.pause = () => { 2753 ut.call(e, !1), s.pauseVideo(); 2754 }), 2755 (e.media.stop = () => { 2756 s.stopVideo(); 2757 }), 2758 (e.media.duration = s.getDuration()), 2759 (e.media.paused = !0), 2760 (e.media.currentTime = 0), 2761 Object.defineProperty(e.media, "currentTime", { 2762 get: () => Number(s.getCurrentTime()), 2763 set(t) { 2764 e.paused && !e.embed.hasPlayed && e.embed.mute(), (e.media.seeking = !0), ve.call(e, e.media, "seeking"), s.seekTo(t); 2765 }, 2766 }), 2767 Object.defineProperty(e.media, "playbackRate", { 2768 get: () => s.getPlaybackRate(), 2769 set(e) { 2770 s.setPlaybackRate(e); 2771 }, 2772 }); 2773 let { volume: a } = e.config; 2774 Object.defineProperty(e.media, "volume", { 2775 get: () => a, 2776 set(t) { 2777 (a = t), s.setVolume(100 * a), ve.call(e, e.media, "volumechange"); 2778 }, 2779 }); 2780 let { muted: l } = e.config; 2781 Object.defineProperty(e.media, "muted", { 2782 get: () => l, 2783 set(t) { 2784 const i = O(t) ? t : l; 2785 (l = i), s[i ? "mute" : "unMute"](), s.setVolume(100 * a), ve.call(e, e.media, "volumechange"); 2786 }, 2787 }), 2788 Object.defineProperty(e.media, "currentSrc", { get: () => s.getVideoUrl() }), 2789 Object.defineProperty(e.media, "ended", { get: () => e.currentTime === e.duration }); 2790 const o = s.getAvailablePlaybackRates(); 2791 (e.options.speed = o.filter((t) => e.config.speed.options.includes(t))), 2792 e.supported.ui && t.customControls && e.media.setAttribute("tabindex", -1), 2793 ve.call(e, e.media, "timeupdate"), 2794 ve.call(e, e.media, "durationchange"), 2795 clearInterval(e.timers.buffering), 2796 (e.timers.buffering = setInterval(() => { 2797 (e.media.buffered = s.getVideoLoadedFraction()), 2798 (null === e.media.lastBuffered || e.media.lastBuffered < e.media.buffered) && ve.call(e, e.media, "progress"), 2799 (e.media.lastBuffered = e.media.buffered), 2800 1 === e.media.buffered && (clearInterval(e.timers.buffering), ve.call(e, e.media, "canplaythrough")); 2801 }, 200)), 2802 t.customControls && setTimeout(() => at.build.call(e), 50); 2803 }, 2804 onStateChange(i) { 2805 const s = i.target; 2806 clearInterval(e.timers.playing); 2807 switch ((e.media.seeking && [1, 2].includes(i.data) && ((e.media.seeking = !1), ve.call(e, e.media, "seeked")), i.data)) { 2808 case -1: 2809 ve.call(e, e.media, "timeupdate"), (e.media.buffered = s.getVideoLoadedFraction()), ve.call(e, e.media, "progress"); 2810 break; 2811 case 0: 2812 ut.call(e, !1), e.media.loop ? (s.stopVideo(), s.playVideo()) : ve.call(e, e.media, "ended"); 2813 break; 2814 case 1: 2815 t.customControls && !e.config.auto
2815play && e.media.paused && !e.embed.hasPlayed 2816 ? e.media.pause() 2817 : (ut.call(e, !0), 2818 ve.call(e, e.media, "playing"), 2819 (e.timers.playing = setInterval(() => { 2820 ve.call(e, e.media, "timeupdate"); 2821 }, 50)), 2822 e.media.duration !== s.getDuration() && ((e.media.duration = s.getDuration()), ve.call(e, e.media, "durationchange"))); 2823 break; 2824 case 2: 2825 e.muted || e.embed.unMute(), ut.call(e, !1); 2826 break; 2827 case 3: 2828 ve.call(e, e.media, "waiting"); 2829 } 2830 ve.call(e, e.elements.container, "statechange", !1, { code: i.data }); 2831 }, 2832 }, 2833 }); 2834 }, 2835 }, 2836 pt = { 2837 setup() { 2838 this.media 2839 ? (le(this.elements.container, this.config.classNames.type.replace("{0}", this.type), !0), 2840 le(this.elements.container, this.config.classNames.provider.replace("{0}", this.provider), !0), 2841 this.isEmbed && le(this.elements.container, this.config.classNames.type.replace("{0}", "video"), !0), 2842 this.isVideo && 2843 ((this.elements.wrapper = Z("div", { class: this.config.classNames.video })), 2844 J(this.media, this.elements.wrapper), 2845 (this.elements.poster = Z("div", { class: this.config.classNames.poster })), 2846 this.elements.wrapper.appendChild(this.elements.poster)), 2847 this.isHTML5 ? Le.setup.call(this) : this.isYouTube ? mt.setup.call(this) : this.isVimeo && ht.setup.call(this)) 2848 : this.debug.warn("No media element found!"); 2849 }, 2850 }; 2851 class gt { 2852 constructor(t) { 2853 e(this, "load", () => { 2854 this.enabled && 2855 (L(window.google) && L(window.google.ima) 2856 ? this.ready() 2857 : rt(this.player.config.urls.googleIMA.sdk) 2858 .then(() => { 2859 this.ready(); 2860 }) 2861 .catch(() => { 2862 this.trigger("error", new Error("Google IMA SDK failed to load")); 2863 })); 2864 }), 2865 e(this, "ready", () => { 2866 var e; 2867 this.enabled || ((e = this).manager && e.manager.destroy(), e.elements.displayContainer && e.elements.displayContainer.destroy(), e.elements.container.remove()), 2868 this.startSafetyTimer(12e3, "ready()"), 2869 this.managerPromise.then(() => { 2870 this.clearSafetyTimer("onAdsManagerLoaded()"); 2871 }), 2872 this.listeners(), 2873 this.setupIMA(); 2874 }), 2875 e(this, "setupIMA", () => { 2876 (this.elements.container = Z("div", { class: this.player.config.classNames.ads })), 2877 this.player.elements.container.appendChild(this.elements.container), 2878 google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED), 2879 google.ima.settings.setLocale(this.player.config.ads.language), 2880 google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playsinline), 2881 (this.elements.displayContainer = new google.ima.AdDisplayContainer(this.elements.container, this.player.media)), 2882 (this.loader = new google.ima.AdsLoader(this.elements.displayContainer)), 2883 this.loader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, (e) => this.onAdsManagerLoaded(e), !1), 2884 this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, (e) => this.onAdError(e), !1), 2885 this.requestAds(); 2886 }),
2887 e(this, "requestAds", () => { 2888 const { container: e } = this.player.elements; 2889 try { 2890 const t = new google.ima.AdsRequest(); 2891 (t.adTagUrl = this.tagUrl), 2892 (t.linearAdSlotWidth = e.offsetWidth), 2893 (t.linearAdSlotHeight = e.offsetHeight), 2894 (t.nonLinearAdSlotWidth = e.offsetWidth), 2895 (t.nonLinearAdSlotHeight = e.offsetHeight), 2896 (t.forceNonLinearFullSlot = !1), 2897 t.setAdWillPlayMuted(!this.player.muted), 2898 this.loader.requestAds(t); 2899 } catch (e) { 2900 this.onAdError(e); 2901 } 2902 }), 2903 e(this, "pollCountdown", (e = !1) => { 2904 if (!e) return clearInterval(this.countdownTimer), void this.elements.container.removeAttribute("data-badge-text"); 2905 this.countdownTimer = setInterval(() => { 2906 const e = Ue(Math.max(this.manager.getRemainingTime(), 0)), 2907 t = `${He.get("advertisement", this.player.config)} - ${e}`; 2908 this.elements.container.setAttribute("data-badge-text", t); 2909 }, 100); 2910 }), 2911 e(this, "onAdsManagerLoaded", (e) => { 2912 if (!this.enabled) return; 2913 const t = new google.ima.AdsRenderingSettings(); 2914 (t.restoreCustomPlaybackStateOnAdBreakComplete = !0), 2915 (t.enablePreloading = !0), 2916 (this.manager = e.getAdsManager(this.player, t)), 2917 (this.cuePoints = this.manager.getCuePoints()), 2918 this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, (e) => this.onAdError(e)), 2919 Object.keys(google.ima.AdEvent.Type).forEach((e) => { 2920 this.manager.addEventListener(google.ima.AdEvent.Type[e], (e) => this.onAdEvent(e)); 2921 }), 2922 this.trigger("loaded"); 2923 }), 2924 e(this, "addCuePoints", () => { 2925 W(this.cuePoints) || 2926 this.cuePoints.forEach((e) => { 2927 if (0 !== e && -1 !== e && e < this.player.duration) { 2928 const t = this.player.elements.progress; 2929 if (H(t)) { 2930 const i = (100 / this.player.duration) * e, 2931 s = Z("span", { class: this.player.config.classNames.cues }); 2932 (s.style.left = `${i.toString()}%`), t.appendChild(s); 2933 } 2934 } 2935 }); 2936 }), 2937 e(this, "onAdEvent", (e) => { 2938 const { container: t } = this.player.elements, 2939 i = e.getAd(), 2940 s = e.getAdData(); 2941 switch ( 2942 (((e) => { 2943 ve.call(this.player, this.player.media, `ads${e.replace(/_/g, "").toLowerCase()}`); 2944 })(e.type), 2945 e.type) 2946 ) { 2947 case google.ima.AdEvent.Type.LOADED: 2948 this.trigger("loaded"), this.pollCountdown(!0), i.isLinear() || ((i.width = t.offsetWidth), (i.height = t.offsetHeight)); 2949 break; 2950 case google.ima.AdEvent.Type.STARTED: 2951 this.manager.setVolume(this.player.volume); 2952 break; 2953 case google.ima.AdEvent.Type.ALL_ADS_COMPLETED: 2954 this.player.ended ? this.loadAds() : this.loader.contentComplete(); 2955 break; 2956 case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED: 2957 this.pauseContent(); 2958 break; 2959 case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED: 2960 this.pollCountdown(), this.resumeContent(); 2961 break; 2962 case google.ima.AdEvent.Type.LOG: 2963 s.adError && this.player.debug.warn(`Non-fatal ad error: ${s.adError.getMessage()}`); 2964 } 2965 }), 2966 e(this, "onAdError", (e) => { 2967 this.cancel(), this.player.debug.warn("Ads error", e); 2968 }), 2969 e(this, "listeners", () => { 2970 const { container: e } = this.player.elements; 2971 let t;
2972 this.player.on("canplay", () => { 2973 this.addCuePoints(); 2974 }), 2975 this.player.on("ended", () => { 2976 this.loader.contentComplete(); 2977 }), 2978 this.player.on("timeupdate", () => { 2979 t = this.player.currentTime; 2980 }), 2981 this.player.on("seeked", () => { 2982 const e = this.player.currentTime; 2983 W(this.cuePoints) || 2984 this.cuePoints.forEach((i, s) => { 2985 t < i && i < e && (this.manager.discardAdBreak(), this.cuePoints.splice(s, 1)); 2986 }); 2987 }), 2988 window.addEventListener("resize", () => { 2989 this.manager && this.manager.resize(e.offsetWidth, e.offsetHeight, google.ima.ViewMode.NORMAL); 2990 }); 2991 }), 2992 e(this, "play", () => { 2993 const { container: e } = this.player.elements; 2994 this.managerPromise || this.resumeContent(), 2995 this.managerPromise 2996 .then(() => { 2997 this.manager.setVolume(this.player.volume), this.elements.displayContainer.initialize(); 2998 try { 2999 this.initialized || (this.manager.init(e.offsetWidth, e.offsetHeight, google.ima.ViewMode.NORMAL), this.manager.start()), (this.initialized = !0); 3000 } catch (e) { 3001 this.onAdError(e); 3002 } 3003 }) 3004 .catch(() => {}); 3005 }), 3006 e(this, "resumeContent", () => { 3007 (this.elements.container.style.zIndex = ""), (this.playing = !1), ke(this.player.media.play()); 3008 }), 3009 e(this, "pauseContent", () => { 3010 (this.elements.container.style.zIndex = 3), (this.playing = !0), this.player.media.pause(); 3011 }), 3012 e(this, "cancel", () => { 3013 this.initialized && this.resumeContent(), this.trigger("error"), this.loadAds(); 3014 }), 3015 e(this, "loadAds", () => { 3016 this.managerPromise 3017 .then(() => { 3018 this.manager && this.manager.destroy(), 3019 (this.managerPromise = new Promise((e) => { 3020 this.on("loaded", e), this.player.debug.log(this.manager); 3021 })), 3022 (this.initialized = !1), 3023 this.requestAds(); 3024 }) 3025 .catch(() => {}); 3026 }), 3027 e(this, "trigger", (e, ...t) => { 3028 const i = this.events[e]; 3029 q(i) && 3030 i.forEach((e) => { 3031 j(e) && e.apply(this, t); 3032 }); 3033 }), 3034 e(this, "on", (e, t) => (q(this.events[e]) || (this.events[e] = []), this.events[e].push(t), this)), 3035 e(this, "startSafetyTimer", (e, t) => { 3036 this.player.debug.log(`Safety timer invoked from: ${t}`), 3037 (this.safetyTimer = setTimeout(() => { 3038 this.cancel(), this.clearSafetyTimer("startSafetyTimer()"); 3039 }, e)); 3040 }), 3041 e(this, "clearSafetyTimer", (e) => { 3042 I(this.safetyTimer) || (this.player.debug.log(`Safety timer cleared from: ${e}`), clearTimeout(this.safetyTimer), (this.safetyTimer = null)); 3043 }), 3044 (this.player = t), 3045 (this.config = t.config.ads), 3046 (this.playing = !1), 3047 (this.initialized = !1), 3048 (this.elements = { container: null, displayContainer: null }), 3049 (this.manager = null),
3050 (this.loader = null), 3051 (this.cuePoints = null), 3052 (this.events = {}), 3053 (this.safetyTimer = null), 3054 (this.countdownTimer = null), 3055 (this.managerPromise = new Promise((e, t) => { 3056 this.on("loaded", e), this.on("error", t); 3057 })), 3058 this.load(); 3059 } 3060 get enabled() { 3061 const { config: e } = this; 3062 return this.player.isHTML5 && this.player.isVideo && e.enabled && (!W(e.publisherId) || U(e.tagUrl)); 3063 } 3064 get tagUrl() { 3065 const { config: e } = this; 3066 if (U(e.tagUrl)) return e.tagUrl; 3067 return `https://go.aniview.com/api/adserver6/vast/?${Ke({ 3068 AV_PUBLISHERID: "58c25bb0073ef448b1087ad6", 3069 AV_CHANNELID: "5a0458dc28a06145e4519d21", 3070 AV_URL: window.location.hostname, 3071 cb: Date.now(), 3072 AV_WIDTH: 640, 3073 AV_HEIGHT: 480, 3074 AV_CDIM2: e.publisherId, 3075 })}`; 3076 } 3077 } 3078 const ft = (e) => { 3079 const t = []; 3080 return (
3081 e.split(/\r\n\r\n|\n\n|\r\r/).forEach((e) => { 3082 const i = {}; 3083 e.split(/\r\n|\n|\r/).forEach((e) => { 3084 if ($(i.startTime)) { 3085 if (!W(e.trim()) && W(i.text)) { 3086 const t = e.trim().split("#xywh="); 3087 ([i.text] = t), t[1] && ([i.x, i.y, i.w, i.h] = t[1].split(",")); 3088 } 3089 } else { 3090 const t = e.match(/([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})/); 3091 t && ((i.startTime = 60 * Number(t[1] || 0) * 60 + 60 * Number(t[2]) + Number(t[3]) + Number(`0.${t[4]}`)), (i.endTime = 60 * Number(t[6] || 0) * 60 + 60 * Number(t[7]) + Number(t[8]) + Number(`0.${t[9]}`))); 3092 } 3093 }), 3094 i.text && t.push(i); 3095 }), 3096 t 3097 ); 3098 }, 3099 bt = (e, t) => { 3100 const i = {}; 3101 return e > t.width / t.height ? ((i.width = t.width), (i.height = (1 / e) * t.width)) : ((i.height = t.height), (i.width = e * t.height)), i; 3102 }; 3103 class yt { 3104 constructor(t) { 3105 e(this, "load", () => { 3106 this.player.elements.display.seekTooltip && (this.player.elements.display.seekTooltip.hidden = this.enabled), 3107 this.enabled && 3108 this.getThumbnails().then(() => { 3109 this.enabled && (this.render(), this.determineContainerAutoSizing(), (this.loaded = !0)); 3110 }); 3111 }), 3112 e( 3113 this, 3114 "getThumbnails", 3115 () => 3116 new Promise((e) => { 3117 const { src: t } = this.player.config.previewThumbnails; 3118 if (W(t)) throw new Error("Missing previewThumbnails.src config attribute"); 3119 const i = () => { 3120 this.thumbnails.sort((e, t) => e.height - t.height), this.player.debug.log("Preview thumbnails", this.thumbnails), e(); 3121 }; 3122 if (j(t)) 3123 t((e) => { 3124 (this.thumbnails = e), i(); 3125 }); 3126 else { 3127 const e = (_(t) ? [t] : t).map((e) => this.getThumbnail(e)); 3128 Promise.all(e).then(i); 3129 } 3130 }) 3131 ), 3132 e( 3133 this, 3134 "getThumbnail", 3135 (e) => 3136 new Promise((t) => { 3137 Re(e).then((i) => { 3138 const s = { frames: ft(i), height: null, urlPrefix: "" }; 3139 s.frames[0].text.startsWith("/") || s.frames[0].text.startsWith("http://") || s.frames[0].text.startsWith("https://") || (s.urlPrefix = e.substring(0, e.lastIndexOf("/") + 1)); 3140 const n = new Image(); 3141 (n.onload = () => { 3142 (s.height = n.naturalHeight), (s.width = n.naturalWidth), this.thumbnails.push(s), t(); 3143 }), 3144 (n.src = s.urlPrefix + s.frames[0].text); 3145 }); 3146 }) 3147 ), 3148 e(this, "startMove", (e) => { 3149 if (this.loaded && F(e) && ["touchmove", "mousemove"].includes(e.type) && this.player.media.duration) { 3150 if ("touchmove" === e.type) this.seekTime = this.player.media.duration * (this.player.elements.inputs.seek.value / 100); 3151 else { 3152 const t = this.player.elements.progress.getBoundingClientRect(), 3153 i = (100 / t.width) * (e.pageX - t.left); 3154 (this.seekTime = this.player.media.duration * (i / 100)), 3155 this.seekTime < 0 && (this.seekTime = 0), 3156 this.seekTime > this.player.media.duration - 1 && (this.seekTime = this.player.media.duration - 1), 3157 (this.mousePosX = e.pageX), 3158 (this.elements.thumb.time.innerText = Ue(this.seekTime)); 3159 } 3160 this.showImageAtCurrentTime(); 3161 } 3162 }), 3163 e(this, "endMove", () => { 3164 this.toggleThumbContainer(!1, !0); 3165 }), 3166 e(this, "startScrubbing", (e) => { 3167 (I(e.button) || !1 === e.button || 0 === e.button) && ((this.mouseDown = !0), this.player.media.duration && (this.toggleScrubbingContainer(!0), this.toggleThumbContainer(!1, !0), this.showImageAtCurrentTime())); 3168 }), 3169 e(this, "endScrubbing", () => { 3170 (this.mouseDown = !1), 3171 Math.ceil(this.lastTime) === Math.ceil(this.player.media.currentTime) 3172 ? this.toggleScrubbingContainer(!1) 3173 : ye.call(this.player, this.player.media, "timeupdate", () => { 3174 this.mouseDown || this.toggleScrubbingContainer(!1); 3175 }); 3176 }), 3177 e(this, "listeners", () => { 3178 this.player.on("play", () => { 3179 this.toggleThumbContainer(!1, !0); 3180 }), 3181 this.player.on("seeked", () => { 3182 this.toggleThumbContainer(!1); 3183 }), 3184 this.player.on("timeupdate", () => { 3185 this.lastTime = this.player.media.currentTime; 3186 }); 3187 }), 3188 e(this, "render", () => { 3189 (this.elements.thumb.container = Z("div", { class: this.player.config.classNames.previewThumbnails.thumbContainer })), 3190 (this.elements.thumb.imageContainer = Z("div", { class: this.player.config.classNames.previewThumbnails.imageContainer })), 3191 this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer); 3192 const e = Z("div", { class: this.player.config.classNames.previewThumbnails.timeContainer }); 3193 (this.elements.thumb.time = Z("span", {}, "00:00")), 3194 e.appendChild(this.elements.thumb.time), 3195 this.elements.thumb.container.appendChild(e), 3196 H(this.player.elements.progress) && this.player.elements.progress.appendChild(this.elements.thumb.container), 3197 (this.elements.scrubbing.container = Z("div", { class: this.player.config.classNames.previewThumbnails.scrubbingContainer })), 3198 this.player.elements.wrapper.appendChild(this.elements.scrubbing.container); 3199 }), 3200 e(this, "destroy", () => { 3201 this.elements.thumb.container && this.elements.thumb.container.remove(), this.elements.scrubbing.container && this.elements.scrubbing.container.remove(); 3202 }), 3203 e(this, "showImageAtCurrentTime", () => { 3204 this.mouseDown ? this.setScrubbingContainerSize() : this.setThumbContainerSizeAndPos();
3205 const e = this.thumbnails[0].frames.findIndex((e) => this.seekTime >= e.startTime && this.seekTime <= e.endTime), 3206 t = e >= 0; 3207 let i = 0; 3208 this.mouseDown || this.toggleThumbContainer(t), 3209 t && 3210 (this.thumbnails.forEach((t, s) => { 3211 this.loadedImages.includes(t.frames[e].text) && (i = s); 3212 }), 3213 e !== this.showingThumb && ((this.showingThumb = e), this.loadImage(i))); 3214 }), 3215 e(this, "loadImage", (e = 0) => { 3216 const t = this.showingThumb, 3217 i = this.thumbnails[e], 3218 { urlPrefix: s } = i, 3219 n = i.frames[t], 3220 a = i.frames[t].text, 3221 l = s + a; 3222 if (this.currentImageElement && this.currentImageElement.dataset.filename === a) 3223 this.showImage(this.currentImageElement, n, e, t, a, !1), (this.currentImageElement.dataset.index = t), this.removeOldImages(this.currentImageElement); 3224 else { 3225 this.loadingImage && this.usingSprites && (this.loadingImage.onload = null); 3226 const i = new Image(); 3227 (i.src = l), 3228 (i.dataset.index = t), 3229 (i.dataset.filename = a), 3230 (this.showingThumbFilename = a), 3231 this.player.debug.log(`Loading image: ${l}`), 3232 (i.onload = () => this.showImage(i, n, e, t, a, !0)), 3233 (this.loadingImage = i), 3234 this.removeOldImages(i); 3235 } 3236 }), 3237 e(this, "showImage", (e, t, i, s, n, a = !0) => { 3238 this.player.debug.log(`Showing thumb: ${n}. num: ${s}. qual: ${i}. newimg: ${a}`), 3239 this.setImageSizeAndOffset(e, t), 3240 a && (this.currentImageContainer.appendChild(e), (this.currentImageElement = e), this.loadedImages.includes(n) || this.loadedImages.push(n)), 3241 this.preloadNearby(s, !0).then(this.preloadNearby(s, !1)).then(this.getHigherQuality(i, e, t, n)); 3242 }), 3243 e(this, "removeOldImages", (e) => { 3244 Array.from(this.currentImageContainer.children).forEach((t) => { 3245 if ("img" !== t.tagName.toLowerCase()) return; 3246 const i = this.usingSprites ? 500 : 1e3; 3247 if (t.dataset.index !== e.dataset.index && !t.dataset.deleting) { 3248 t.dataset.deleting = !0; 3249 const { currentImageContainer: e } = this; 3250 setTimeout(() => { 3251 e.removeChild(t), this.player.debug.log(`Removing thumb: ${t.dataset.filename}`); 3252 }, i); 3253 } 3254 }); 3255 }), 3256 e( 3257 this, 3258 "preloadNearby", 3259 (e, t = !0) => 3260 new Promise((i) => { 3261 setTimeout(() => { 3262 const s = this.thumbnails[0].frames[e].text; 3263 if (this.showingThumbFilename === s) { 3264 let n; 3265 n = t ? this.thumbnails[0].frames.slice(e) : this.thumbnails[0].frames.slice(0, e).reverse(); 3266 let a = !1; 3267 n.forEach((e) => { 3268 const t = e.text; 3269 if (t !== s && !this.loadedImages.includes(t)) { 3270 (a = !0), this.player.debug.log(`Preloading thumb filename: ${t}`); 3271 const { urlPrefix: e }
3271 = this.thumbnails[0], 3272 s = e + t, 3273 n = new Image(); 3274 (n.src = s), 3275 (n.onload = () => { 3276 this.player.debug.log(`Preloaded thumb filename: ${t}`), this.loadedImages.includes(t) || this.loadedImages.push(t), i(); 3277 }); 3278 } 3279 }), 3280 a || i(); 3281 } 3282 }, 300); 3283 }) 3284 ), 3285 e(this, "getHigherQuality", (e, t, i, s) => { 3286 if (e < this.thumbnails.length - 1) { 3287 let n = t.naturalHeight; 3288 this.usingSprites && (n = i.h), 3289 n < this.thumbContainerHeight && 3290 setTimeout(() => { 3291 this.showingThumbFilename === s && (this.player.debug.log(`Showing higher quality thumb for: ${s}`), this.loadImage(e + 1)); 3292 }, 300); 3293 } 3294 }), 3295 e(this, "toggleThumbContainer", (e = !1, t = !1) => { 3296 const i = this.player.config.classNames.previewThumbnails.thumbContainerShown; 3297 this.elements.thumb.container.classList.toggle(i, e), !e && t && ((this.showingThumb = null), (this.showingThumbFilename = null)); 3298 }), 3299 e(this, "toggleScrubbingContainer", (e = !1) => { 3300 const t = this.player.config.classNames.previewThumbnails.scrubbingContainerShown; 3301 this.elements.scrubbing.container.classList.toggle(t, e), e || ((this.showingThumb = null), (this.showingThumbFilename = null)); 3302 }), 3303 e(this, "determineContainerAutoSizing", () => { 3304 (this.elements.thumb.imageContainer.clientHeight > 20 || this.elements.thumb.imageContainer.clientWidth > 20) && (this.sizeSpecifiedInCSS = !0); 3305 }), 3306 e(this, "setThumbContainerSizeAndPos", () => { 3307 if (this.sizeSpecifiedInCSS) { 3308 if (this.elements.thumb.imageContainer.clientHeight > 20 && this.elements.thumb.imageContainer.clientWidth < 20) { 3309 const e = Math.floor(this.elements.thumb.imageContainer.clientHeight * this.thumbAspectRatio); 3310 this.elements.thumb.imageContainer.style.width = `${e}px`; 3311 } else if (this.elements.thumb.imageContainer.clientHeight < 20 && this.elements.thumb.imageContainer.clientWidth > 20) { 3312 const e = Math.floor(this.elements.thumb.imageContainer.clientWidth / this.thumbAspectRatio); 3313 this.elements.thumb.imageContainer.style.height = `${e}px`; 3314 } 3315 } else { 3316 const e = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio); 3317 (this.elements.thumb.imageContainer.style.height = `${this.thumbContainerHeight}px`), (this.elements.thumb.imageContainer.style.width = `${e}px`); 3318 } 3319 this.setThumbContainerPos(); 3320 }), 3321 e(this, "setThumbContainerPos", () => { 3322 const e = this.player.elements.progress.getBoundingClientRect(), 3323 t = this.player.elements.container.getBoundingClientRect(), 3324 { container: i } = this.elements.thumb, 3325 s = t.left - e.left + 10, 3326 n = t.right - e.left - i.clientWidth - 10; 3327 let a = this.mousePosX - e.left - i.clientWidth / 2; 3328 a < s && (a = s), a > n && (a = n), (i.style.left = `${a}px`); 3329 }), 3330 e(this, "setScrubbingContainerSize", () => { 3331 const { width: e, height: t } = bt(this.thumbAspectRatio, { width: this.player.media.clientWidth, height: this.player.media.clientHeight }); 3332 (this.elements.scrubbing.container.style.width = `${e}px`), (this.elements.scrubbing.container.style.height = `${t}px`); 3333 }), 3334 e(this, "setImageSizeAndOffset", (e, t) => { 3335 if (!this.usingSprites) return; 3336 const i = this.thumbContainerHeight / t.h; 3337 (e.style.height = e.naturalHeight * i + "px"), (e.style.width = e.naturalWi
3337dth * i + "px"), (e.style.left = `-${t.x * i}px`), (e.style.top = `-${t.y * i}px`); 3338 }), 3339 (this.player = t), 3340 (this.thumbnails = []), 3341 (this.loaded = !1), 3342 (this.lastMouseMoveTime = Date.now()), 3343 (this.mouseDown = !1), 3344 (this.loadedImages = []), 3345 (this.elements = { thumb: {}, scrubbing: {} }), 3346 this.load(); 3347 } 3348 get enabled() { 3349 return this.player.isHTML5 && this.player.isVideo && this.player.config.previewThumbnails.enabled; 3350 } 3351 get currentImageContainer() { 3352 return this.mouseDown ? this.elements.scrubbing.container : this.elements.thumb.imageContainer; 3353 } 3354 get usingSprites() { 3355 return Object.keys(this.thumbnails[0].frames[0]).includes("w"); 3356 } 3357 get thumbAspectRatio() { 3358 return this.usingSprites ? this.thumbnails[0].frames[0].w / this.thumbnails[0].frames[0].h : this.thumbnails[0].width / this.thumbnails[0].height; 3359 } 3360 get thumbContainerHeight() { 3361 if (this.mouseDown) { 3362 const { height: e } = bt(this.thumbAspectRatio, { width: this.player.media.clientWidth, height: this.player.media.clientHeight }); 3363 return e; 3364 } 3365 return this.sizeSpecifiedInCSS ? this.elements.thumb.imageContainer.clientHeight : Math.floor(this.player.media.clientWidth / this.thumbAspectRatio / 4); 3366 } 3367 get currentImageElement() { 3368 return this.mouseDown ? this.currentScrubbingImageElement : this.currentThumbnailImageElement; 3369 } 3370 set currentImageElement(e) { 3371 this.mouseDown ? (this.currentScrubbingImageElement = e) : (this.currentThumbnailImageElement = e); 3372 } 3373 } 3374 const vt = { 3375 insertElements(e, t) { 3376 _(t) 3377 ? ee(e, this.media, { src: t }) 3378 : q(t) && 3379 t.forEach((t) => { 3380 ee(e, this.media, t); 3381 }); 3382 }, 3383 change(e) { 3384 Q(e, "sources.length") 3385 ? (Le.cancelRequests.call(this), 3386 this.destroy.call( 3387 this, 3388 () => { 3389 (this.options.quality = []), te(this.media), (this.media = null), H(this.elements.container) && this.elements.container.removeAttribute("class"); 3390 const { sources: t, type: i } = e, 3391 [{ provider: s = Ge.html5, src: n }] = t, 3392 a = "html5" === s ? i : "div", 3393 l = "html5" === s ? {} : { src: n }; 3394 Object.assign(this, { provider: s, type: i, supported: me.check(i, s, this.config.playsinline), media: Z(a, l) }), 3395 this.elements.container.appendChild(this.media), 3396 O(e.autoplay) && (this.config.autoplay = e.autoplay), 3397 this.isHTML5 && 3398 (this.config.crossorigin && this.media.setAttribute("crossorigin", ""), 3399 this.config.autoplay && this.media.setAttribute("autoplay", ""), 3400 W(e.poster) || (this.poster = e.poster), 3401 this.config.loop.active && this.media.setAttribute("loop", ""), 3402 this.config.muted && this.media.setAttribute("muted", ""), 3403 this.config.playsinline && this.media.setAttribute("playsinline", "")), 3404 at.addStyleHook.call(this), 3405 this.isHTML5 && vt.insertElements.call(this, "source", t), 3406 (this.config.title = e.title), 3407 pt.setup.call(this), 3408 this.isHTML5 && Object.keys(e).includes("tracks") && vt.insertElements.call(this, "track", e.tracks), 3409 (this.isHTML5 || (this.isEmbed && !this.supported.ui)) && at.build.call(this), 3410 this.isHTML5 && this.media.load(), 3411 W(e.previewThumbnails) || 3412 (Object.assign(this.config.previewThumbnails, e.previewThumbnails), 3413 this.previewThumbnails && this.previewThumbnails.loaded && (this.previewThumbnails.destroy(), (this.previewThumbnails = null)), 3414 this.config.previewThumbnails.enabled && (this.previewThumbnails = new yt(this))), 3415 this.fullscreen.update(); 3416 }, 3417 !0 3418 )) 3419 : this.debug.warn("Invalid source format"); 3420 }, 3421 }; 3422 class wt { 3423 constructor(t, i) { 3424 if ( 3425 (e(this, "play", () => (j(this.media.play) ? (this.ads && this.ads.enabled && this.ads.managerPromise.then(() => this.ads.play()).catch(() => ke(this.media.play())), this.media.play()) : null)), 3426 e(this, "pause", () => (this.playing && j(this.media.pause) ? this.media.pause() : null)), 3427 e(this, "togglePlay", (e) => ((O(e) ? e : !this.playing) ? this.play() : this.pause())), 3428 e(this, "stop", () => { 3429 this.isHTML5 ? (this.pause(), this.restart()) : j(this.media.stop) && this.media.stop(); 3430 }), 3431 e(this, "restart", () => { 3432 this.currentTime = 0; 3433 }), 3434 e(this, "rewind", (e) => { 3435 this.currentTime -= $(e) ? e : this.config.seekTime; 3436 }), 3437 e(this, "forward", (e) => { 3438 this.currentTime += $(e) ? e : this.config.seekTime; 3439 }), 3440 e(this, "increaseVolume", (e) => { 3441 const t = this.media.muted ? 0 : this.volume; 3442 this.volume = t + ($(e) ? e : 0); 3443 }), 3444 e(this, "decreaseVolume", (e) => { 3445 this.increaseVolume(-e); 3446 }), 3447 e(this, "airplay", () => { 3448 me.airplay && this.media.webkitShowPlaybackTargetPicker(); 3449 }), 3450 e(this, "toggleControls", (e) => { 3451 if (this.supported.ui && !this.isAudio) { 3452 const t = oe(this.elements.container, this.config.classNames.hideControls), 3453 i = void 0 === e ? void 0 : !e, 3454 s = le(this.elements.container, this.config.classNames.hideControls, i); 3455 if ((s && q(this.config.controls) && this.config.controls.includes("settings") && !W(this.config.settings) && We.toggleMenu.call(this, !1), s !== t)) { 3456 const e = s ? "controlshidden" : "controlsshown"; 3457 ve.call(this, this.media, e); 3458 } 3459 return !s; 3460 } 3461 return !1; 3462 }), 3463 e(this, "on", (e, t) => { 3464 fe.call(this, this.elements.container, e, t); 3465 }), 3466 e(this, "once", (e, t) => { 3467 ye.call(this, this.elements.container, e, t); 3468 }), 3469 e(this, "off", (e, t) => { 3470 be(this.elements.container, e, t); 3471 }), 3472 e(this, "destroy", (e, t = !1) => { 3473 if (!this.ready) return; 3474 const i = () => { 3475 (document.body.style.overflow = ""), 3476 (this.embed = null),
3477 t 3478 ? (Object.keys(this.elements).length && 3479 (te(this.elements.buttons.play), 3480 te(this.elements.captions), 3481 te(this.elements.controls), 3482 te(this.elements.wrapper), 3483 (this.elements.buttons.play = null), 3484 (this.elements.captions = null), 3485 (this.elements.controls = null), 3486 (this.elements.wrapper = null)), 3487 j(e) && e()) 3488 : (we.call(this), 3489 Le.cancelRequests.call(this), 3490 se(this.elements.original, this.elements.container), 3491 ve.call(this, this.elements.original, "destroyed", !0), 3492 j(e) && e.call(this.elements.original), 3493 (this.ready = !1), 3494 setTimeout(() => { 3495 (this.elements = null), (this.media = null); 3496 }, 200)); 3497 }; 3498 this.stop(), 3499 clearTimeout(this.timers.loading), 3500 clearTimeout(this.timers.controls), 3501 clearTimeout(this.timers.resized), 3502 this.isHTML5 3503 ? (at.toggleNativeControls.call(this, !0), i()) 3504 : this.isYouTube 3505 ? (clearInterval(this.timers.buffering), clearInterval(this.timers.playing), null !== this.embed && j(this.embed.destroy) && this.embed.destroy(), i()) 3506 : this.isVimeo && (null !== this.embed && this.embed.unload().then(i), setTimeout(i, 200)); 3507 }), 3508 e(this, "supports", (e) => me.mime.call(this, e)), 3509 (this.timers = {}), 3510 (this.ready = !1), 3511 (this.loading = !1), 3512 (this.failed = !1), 3513 (this.touch = me.touch), 3514 (this.media = t), 3515 _(this.media) && (this.media = document.querySelectorAll(this.media)), 3516 ((window.jQuery && this.media instanceof jQuery) || D(this.media) || q(this.media)) && (this.media = this.media[0]), 3517 (this.config = X( 3518 {}, 3519 Qe, 3520 wt.defaults, 3521 i || {}, 3522 (() => { 3523 try { 3524 return JSON.parse(this.media.getAttribute("data-plyr-config")); 3525 } catch (e) { 3526 return {}; 3527 } 3528 })() 3529 )), 3530 (this.elements = { container: null, fullscreen: null, captions: null, buttons: {}, display: {}, progress: {}, inputs: {}, settings: { popup: null, menu: null, panels: {}, buttons: {} } }), 3531 (this.captions = { active: null, currentTrack: -1, meta: new WeakMap() }), 3532 (this.fullscreen = { active: !1 }), 3533 (this.options = { speed: [], quality: [] }), 3534 (this.debug = new it(this.config.debug)), 3535 this.debug.log("Config", this.config), 3536 this.debug.log("Support", me), 3537 I(this.media) || !H(this.media)) 3538 ) 3539 return void this.debug.error("Setup failed: no suitable element passed"); 3540 if (this.media.plyr) return void this.debug.warn("Target already setup"); 3541 if (!this.config.enabled) return void this.debug.error("Setup failed: disabled by config"); 3542 if (!me.check().api) return void this.debug.error("Setup failed: no support"); 3543 const s = this.media.cloneNode(!0); 3544 (s.autoplay = !1), (this.elements.original = s); 3545 const n = this.media.tagName.toLowerCase(); 3546 let a = null, 3547 l = null; 3548 switch (n) { 3549 case "div": 3550 if (((a = this.media.querySelector("iframe")), H(a))) { 3551 if ( 3552 ((l = ze(a.getAttribute("src"))), 3553 (this.provider = (function (e) { 3554 return /^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(e) ? Ge.youtube : /^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(e) ? Ge.vimeo : null; 3555 })(l.toString())), 3556 (this.elements.container = this.media), 3557 (this.media = a), 3558 (this.elements.container.className = ""), 3559 l.search.length) 3560 ) { 3561 const e = ["1", "true"]; 3562 e.includes(l.searchParams.get("autoplay")) && (this.config.auto
3562play = !0), 3563 e.includes(l.searchParams.get("loop")) && (this.config.loop.active = !0), 3564 this.isYouTube ? ((this.config.playsinline = e.includes(l.searchParams.get("playsinline"))), (this.config.youtube.hl = l.searchParams.get("hl"))) : (this.config.playsinline = !0); 3565 } 3566 } else (this.provider = this.media.getAttribute(this.config.attributes.embed.provider)), this.media.removeAttribute(this.config.attributes.embed.provider); 3567 if (W(this.provider) || !Object.values(Ge).includes(this.provider)) return void this.debug.error("Setup failed: Invalid provider"); 3568 this.type = et; 3569 break; 3570 case "video": 3571 case "audio": 3572 (this.type = n), 3573 (this.provider = Ge.html5), 3574 this.media.hasAttribute("crossorigin") && (this.config.crossorigin = !0), 3575 this.media.hasAttribute("autoplay") && (this.config.autoplay = !0), 3576 (this.media.hasAttribute("playsinline") || this.media.hasAttribute("webkit-playsinline")) && (this.config.playsinline = !0), 3577 this.media.hasAttribute("muted") && (this.config.muted = !0), 3578 this.media.hasAttribute("loop") && (this.config.loop.active = !0); 3579 break; 3580 default: 3581 return void this.debug.error("Setup failed: unsupported type"); 3582 } 3583 (this.supported = me.check(this.type, this.provider, this.config.playsinline)), 3584 this.supported.api 3585 ? ((this.eventListeners = []), 3586 (this.listeners = new lt(this)), 3587 (this.storage = new Fe(this)), 3588 (this.media.plyr = this), 3589 H(this.elements.container) || ((this.elements.container = Z("div", { tabindex: 0 })), J(this.media, this.elements.container)), 3590 at.migrateStyles.call(this), 3591 at.addStyleHook.call(this), 3592 pt.setup.call(this), 3593 this.config.debug && 3594 fe.call(this, this.elements.container, this.config.events.join(" "), (e) => { 3595 this.debug.log(`event: ${e.type}`); 3596 }), 3597 (this.fullscreen = new st(this)), 3598 (this.isHTML5 || (this.isEmbed && !this.supported.ui)) && at.build.call(this), 3599 this.listeners.container(), 3600 this.listeners.global(), 3601 this.config.ads.enabled && (this.ads = new gt(this)), 3602 this.isHTML5 && this.config.autoplay && this.once("canplay", () => ke(this.play())), 3603 (this.lastSeekTime = 0), 3604 this.config.previewThumbnails.enabled && (this.previewThumbnails = new yt(this))) 3605 : this.debug.error("Setup failed: no support"); 3606 } 3607 get isHTML5() { 3608 return this.provider === Ge.html5; 3609 } 3610 get isEmbed() { 3611 return this.isYouTube || this.isVimeo; 3612 } 3613 get isYouTube() { 3614 return this.provider === Ge.youtube; 3615 } 3616 get isVimeo() { 3617 return this.provider === Ge.vimeo; 3618 } 3619 get isVideo() { 3620 return this.type === et; 3621 } 3622 get isAudio() { 3623 return this.type === Ze; 3624 } 3625 get playing() { 3626 return Boolean(this.ready && !this.paused && !this.ended); 3627 } 3628 get paused() { 3629 return Boolean(this.media.paused); 3630 } 3631 get stopped() { 3632 return Boolean(this.paused && 0 === this.currentTime); 3633 } 3634 get ended() { 3635 return Boolean(this.media.ended); 3636 } 3637 set currentTime(e) { 3638 if (!this.duration) return; 3639 const t = $(e) && e > 0; 3640 (this.media.currentTime = t ? Math.min(e, this.duration) : 0), this.debug.log(`Seeking to ${this.currentTime} seconds`); 3641 } 3642 get currentTime() { 3643 return Number(this.media.currentTime); 3644 } 3645 get buffered() { 3646 const { buffered: e } = this.media; 3647 return $(e) ? e : e && e.length && this.duration > 0 ? e.end(0) / this.duration : 0; 3648 } 3649 get seeking() { 3650 return Boolean(this.media.seeking); 3651 } 3652 get duration() { 3653 const e = parseFloat(this.config.duration), 3654 t = (this.media || {}).duration, 3655 i = $(t) && t !== 1 / 0 ? t : 0; 3656 return e || i; 3657 } 3658 set volume(e) { 3659 let t = e; 3660 _(t) && (t = Number(t)), 3661 $(t) || (t = this.storage.get("volume")), 3662 $(t) || ({ volume: t } = this.config), 3663 t > 1 && (t = 1), 3664 t < 0 && (t = 0), 3665 (this.config.volume = t), 3666 (this.media.volume = t), 3667 !W(e) && this.muted && t > 0 && (this.muted = !1); 3668 } 3669 get volume() { 3670 return Number(this.media.volume); 3671 } 3672 set muted(e) { 3673 let t = e; 3674 O(t) || (t = this.storage.get("muted")), O(t) || (t = this.config.muted), (this.config.muted = t), (this.media.muted = t); 3675 } 3676 get muted() { 3677 return Boolean(this.media.muted); 3678 } 3679 get hasAudio() { 3680 return !this.isHTML5 || !!this.isAudio || Boolean(this.media.mozHasAudio) || Boolean(this.media.webkitAudioDecodedByteCount) || Boolean(this.media.audioTracks && this.media.audioTracks.length); 3681 } 3682 set speed(e) { 3683 let t = null; 3684 $(e) && (t = e), $(t) || (t = this.storage.get("speed")), $(t) || (t = this.config.speed.selected); 3685 const { minimumSpeed: i, maximumSpeed: s } = this; 3686 (t = (function (e = 0, t = 0, i = 255) { 3687 return Math.min(Math.max(e, t), i); 3688 })(t, i, s)), 3689 (this.config.speed.selected = t), 3690 setTimeout(() => { 3691 this.media && (this.media.playbackRate = t); 3692 }, 0); 3693 } 3694 get speed() { 3695 return Number(this.media.playbackRate); 3696 } 3697 get minimumSpeed() { 3698 return this.isYouTube ? Math.min(...this.options.speed) : this.isVimeo ? 0.5 : 0.0625; 3699 } 3700 get maximumSpeed() { 3701 return this.isYouTube ? Math.max(...this.options.speed) : this.isVimeo ? 2 : 16; 3702 } 3703 set quality(e) { 3704 const t = this.config.quality, 3705 i = this.options.quality; 3706 if (!i.length) return; 3707 let s = [!W(e) && Number(e), this.storage.get("quality"), t.selected, t.default].find($), 3708 n = !0; 3709 if (!i.includes(s)) { 3710 const e = Ae(i, s); 3711 this.debug.warn(`Unsupported quality option: ${s}, using ${e} instead`), (s = e), (n = !1); 3712 } 3713 (t.selected = s), (this.media.quality = s), n && this.storage.set({ quality: s }); 3714 }
3715 get quality() { 3716 return this.media.quality; 3717 } 3718 set loop(e) { 3719 const t = O(e) ? e : this.config.loop.active; 3720 (this.config.loop.active = t), (this.media.loop = t); 3721 } 3722 get loop() { 3723 return Boolean(this.media.loop); 3724 } 3725 set source(e) { 3726 vt.change.call(this, e); 3727 } 3728 get source() { 3729 return this.media.currentSrc; 3730 } 3731 get download() { 3732 const { download: e } = this.config.urls; 3733 return U(e) ? e : this.source; 3734 } 3735 set download(e) { 3736 U(e) && ((this.config.urls.download = e), We.setDownloadUrl.call(this)); 3737 } 3738 set poster(e) { 3739 this.isVideo ? at.setPoster.call(this, e, !1).catch(() => {}) : this.debug.warn("Poster can only be set for video"); 3740 } 3741 get poster() { 3742 return this.isVideo ? this.media.getAttribute("poster") || this.media.getAttribute("data-poster") : null; 3743 } 3744 get ratio() { 3745 if (!this.isVideo) return null; 3746 const e = Ne(xe.call(this)); 3747 return q(e) ? e.join(":") : e; 3748 } 3749 set ratio(e) { 3750 this.isVideo ? (_(e) && Pe(e) ? ((this.config.ratio = Ne(e)), Me.call(this)) : this.debug.error(`Invalid aspect ratio specified (${e})`)) : this.debug.warn("Aspect ratio can only be set for video"); 3751 } 3752 set autoplay(e) { 3753 const t = O(e) ? e : this.config.autoplay; 3754 this.config.autoplay = t; 3755 } 3756 get autoplay() { 3757 return Boolean(this.config.autoplay); 3758 } 3759 toggleCaptions(e) { 3760 Ye.toggle.call(this, e, !1); 3761 } 3762 set currentTrack(e) { 3763 Ye.set.call(this, e, !1), Ye.setup(); 3764 } 3765 get currentTrack() { 3766 const { toggled: e, currentTrack: t } = this.captions; 3767 return e ? t : -1; 3768 } 3769 set language(e) { 3770 Ye.setLanguage.call(this, e, !1); 3771 } 3772 get language() { 3773 return (Ye.getCurrentTrack.call(this) || {}).language; 3774 } 3775 set pip(e) { 3776 if (!me.pip) return; 3777 const t = O(e) ? e : !this.pip; 3778 j(this.media.webkitSetPresentationMode) && this.media.webkitSetPresentationMode(t ? Xe : Je), 3779 j(this.media.requestPictureInPicture) && (!this.pip && t ? this.media.requestPictureInPicture() : this.pip && !t && document.exitPictureInPicture()); 3780 } 3781 get pip() { 3782 return me.pip ? (W(this.media.webkitPresentationMode) ? this.media === document.pictureInPictureElement : this.media.webkitPresentationMode === Xe) : null; 3783 } 3784 setPreviewThumbnails(e) { 3785 this.previewThumbnails && this.previewThumbnails.loaded && (this.previewThumbnails.destroy(), (this.previewThumbnails = null)), 3786 Object.assign(this.config.previewThumbnails, e), 3787 this.config.previewThumbnails.enabled && (this.previewThumbnails = new yt(this)); 3788 } 3789 static supported(e, t, i) { 3790 return me.check(e, t, i); 3791 } 3792 static loadSprite(e, t) { 3793 return Ve(e, t); 3794 } 3795 static setup(e, t = {}) { 3796 let i = null; 3797 return _(e) ? (i = Array.from(document.querySelectorAll(e))) : D(e) ? (i = Array.from(e)) : q(e) && (i = e.filter(H)), W(i) ? null : i.map((e) => new wt(e, t)); 3798 } 3799 } 3800 var Tt; 3801 return (wt.defaults = ((Tt = Qe), JSON.parse(JSON.stringify(Tt)))), wt; 3802 });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.