1"object" == typeof navigator && 2 (function (e, t) { 3 "object" == typeof exports && "undefined" != typeof module 4 ? (module.exports = t()) 5 : "function" == typeof define && define.amd 6 ? define("Plyr", t) 7 : ((e = 8 "undefined" != typeof globalThis ? globalThis : e || self).Plyr = 9 t()); 10 })(this, function () { 11 "use strict"; 12 function e(e, t, i) { 13 return ( 14 (t = (function (e) { 15 var t = (function (e, t) { 16 if ("object" != typeof e || null === e) return e; 17 var i = e[Symbol.toPrimitive]; 18 if (void 0 !== i) { 19 var s = i.call(e, t || "default"); 20 if ("object" != typeof s) return s; 21 throw new TypeError( 22 "@@toPrimitive must return a primitive value.", 23 ); 24 } 25 return ("string" === t ? String : Number)(e); 26 })(e, "string"); 27 return "symbol" == typeof t ? t : String(t); 28 })(t)) in e 29 ? Object.defineProperty(e, t, { 30 value: i, 31 enumerable: !0, 32 configurable: !0, 33 writable: !0, 34 }) 35 : (e[t] = i), 36 e 37 ); 38 } 39 function t(e, t) { 40 for (var i = 0; i < t.length; i++) { 41 var s = t[i]; 42 ((s.enumerable = s.enumerable || !1), 43 (s.configurable = !0), 44 "value" in s && (s.writable = !0), 45 Object.defineProperty(e, s.key, s)); 46 } 47 } 48 function i(e, t, i) { 49 return ( 50 t in e 51 ? Object.defineProperty(e, t, { 52 value: i, 53 enumerable: !0, 54 configurable: !0, 55 writable: !0, 56 }) 57 : (e[t] = i), 58 e 59 ); 60 } 61 function s(e, t) { 62 var i = Object.keys(e); 63 if (Object.getOwnPropertySymbols) { 64 var s = Object.getOwnPropertySymbols(e); 65 (t && 66 (s = s.filter(function (t) { 67 return Object.getOwnPropertyDescriptor(e, t).enumerable; 68 })), 69 i.push.apply(i, s)); 70 } 71 return i; 72 } 73 function n(e) { 74 for (var t = 1; t < arguments.length; t++) { 75 var n = null != arguments[t] ? arguments[t] : {}; 76 t % 2 77 ? s(Object(n), !0).forEach(function (t) { 78 i(e, t, n[t]); 79 }) 80 : Object.getOwnPropertyDescriptors 81 ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) 82 : s(Object(n)).forEach(function (t) { 83 Object.defineProperty( 84 e, 85 t, 86 Object.getOwnPropertyDescriptor(n, t), 87 ); 88 }); 89 } 90 return e; 91 } 92 var a = { addCSS: !0, thumbWidth: 15, watch: !0 }; 93 var l = function (e) { 94 return null != e ? e.constructor : null; 95 }, 96 r = function (e, t) { 97 return !!(e && t && e instanceof t); 98 }, 99 o = function (e) { 100 return null == e; 101 }, 102 c = function (e) { 103 return l(e) === Object; 104 }, 105 u = function (e) { 106 return l(e) === String; 107 }, 108 h = function (e) { 109 return Array.isArray(e); 110 }, 111 d = function (e) { 112 return r(e, NodeList); 113 }, 114 m = { 115 nullOrUndefined: o, 116 object: c, 117 number: function (e) { 118 return l(e) === Number && !Number.isNaN(e); 119 }, 120 string: u, 121 boolean: function (e) { 122 return l(e) === Boolean; 123 }, 124 function: function (e) { 125 return l(e) === Function; 126 }, 127 array: h, 128 nodeList: d, 129 element: function (e) { 130 return r(e, Element); 131 }, 132 event: function (e) { 133 return r(e, Event); 134 }, 135 empty: function (e) { 136 return ( 137 o(e) || 138 ((u(e) || h(e) || d(e)) && !e.length) || 139 (c(e) && !Object.keys(e).length) 140 ); 141 }, 142 }; 143 function p(e, t) { 144 if (1 > t) { 145 var i = (function (e) { 146 var t = "".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); 147 return t 148 ? Math.max(0, (t[1] ? t[1].length : 0) - (t[2] ? +t[2] : 0)) 149 : 0; 150 })(t); 151 return parseFloat(e.toFixed(i)); 152 } 153 return Math.round(e / t) * t; 154 } 155 var g = (function () { 156 function e(t, i) { 157 ((function (e, t) { 158 if (!(e instanceof t)) 159 throw new TypeError("Cannot call a class as a function"); 160 })(this, e), 161 m.element(t) 162 ? (this.element = t) 163 : m.string(t) && (this.element = document.querySelector(t)), 164 m.element(this.element) && 165 m.empty(this.element.rangeTouch) && 166 ((this.config = n({}, a, {}, i)), this.init())); 167 } 168 return ( 169 (function (e, i, s) { 170 (i && t(e.prototype, i), s && t(e, s)); 171 })( 172 e, 173 [ 174 { 175 key: "init", 176 value: function () { 177 e.enabled && 178 (this.config.addCSS && 179 ((this.element.style.userSelect = "none"), 180 (this.element.style.webKitUserSelect = "none"), 181 (this.element.style.touchAction = "manipulation")), 182 this.listeners(!0), 183 (this.element.rangeTouch = this)); 184 }, 185 }, 186 {
187 key: "destroy", 188 value: function () { 189 e.enabled && 190 (this.config.addCSS && 191 ((this.element.style.userSelect = ""), 192 (this.element.style.webKitUserSelect = ""), 193 (this.element.style.touchAction = "")), 194 this.listeners(!1), 195 (this.element.rangeTouch = null)); 196 }, 197 }, 198 { 199 key: "listeners", 200 value: function (e) { 201 var t = this, 202 i = e ? "addEventListener" : "removeEventListener"; 203 ["touchstart", "touchmove", "touchend"].forEach(function (e) { 204 t.element[i]( 205 e, 206 function (e) { 207 return t.set(e); 208 }, 209 !1, 210 ); 211 }); 212 }, 213 }, 214 { 215 key: "get", 216 value: function (t) { 217 if (!e.enabled || !m.event(t)) return null; 218 var i, 219 s = t.target, 220 n = t.changedTouches[0], 221 a = parseFloat(s.getAttribute("min")) || 0, 222 l = parseFloat(s.getAttribute("max")) || 100, 223 r = parseFloat(s.getAttribute("step")) || 1, 224 o = s.getBoundingClientRect(), 225 c = ((100 / o.width) * (this.config.thumbWidth / 2)) / 100; 226 return ( 227 0 > (i = (100 / o.width) * (n.clientX - o.left)) 228 ? (i = 0) 229 : 100 < i && (i = 100), 230 50 > i 231 ? (i -= (100 - 2 * i) * c) 232 : 50 < i && (i += 2 * (i - 50) * c), 233 a + p((i / 100) * (l - a), r) 234 ); 235 }, 236 }, 237 { 238 key: "set", 239 value: function (t) { 240 e.enabled && 241 m.event(t) && 242 !t.target.disabled && 243 (t.preventDefault(), 244 (t.target.value = this.get(t)), 245 (function (e, t) { 246 if (e && t) { 247 var i = new Event(t, { bubbles: !0 }); 248 e.dispatchEvent(i); 249 } 250 })(t.target, "touchend" === t.type ? "change" : "input")); 251 }, 252 }, 253 ], 254 [ 255 { 256 key: "setup", 257 value: function (t) { 258 var i = 259 1 < arguments.length && void 0 !== arguments[1] 260 ? arguments[1] 261 : {}, 262 s = null; 263 if ( 264 (m.empty(t) || m.string(t) 265 ? (s = Array.from( 266 document.querySelectorAll( 267 m.string(t) ? t : 'input[type="range"]', 268 ), 269 )) 270 : m.element(t) 271 ? (s = [t]) 272 : m.nodeList(t) 273 ? (s = Array.from(t)) 274 : m.array(t) && (s = t.filter(m.element)), 275 m.empty(s)) 276 ) 277 return null; 278 var l = n({}, a, {}, i); 279 if (m.string(t) && l.watch) { 280 var r = new MutationObserver(function (i) { 281 Array.from(i).forEach(function (i) { 282 Array.from(i.addedNodes).forEach(function (i) { 283 m.element(i) && 284 (function (e, t) { 285 return function () { 286 return Array.from( 287 document.querySelectorAll(t), 288 ).includes(this); 289 }.call(e, t); 290 })(i, t) && 291 new e(i, l); 292 }); 293 }); 294 }); 295 r.observe(document.body, { childList: !0, subtree: !0 }); 296 } 297 return s.map(function (t) { 298 return new e(t, i); 299 }); 300 }, 301 }, 302 { 303 key: "enabled", 304 get: function () { 305 return "ontouchstart" in document.documentElement; 306 }, 307 }, 308 ], 309 ), 310 e 311 ); 312 })(); 313 const f = (e) => (null != e ? e.constructor : null),
314 y = (e, t) => Boolean(e && t && e instanceof t), 315 b = (e) => null == e, 316 v = (e) => f(e) === Object, 317 w = (e) => f(e) === String, 318 T = (e) => "function" == typeof e, 319 k = (e) => Array.isArray(e), 320 C = (e) => y(e, NodeList), 321 A = (e) => 322 b(e) || 323 ((w(e) || k(e) || C(e)) && !e.length) || 324 (v(e) && !Object.keys(e).length); 325 var S = { 326 nullOrUndefined: b, 327 object: v, 328 number: (e) => f(e) === Number && !Number.isNaN(e), 329 string: w, 330 boolean: (e) => f(e) === Boolean, 331 function: T, 332 array: k, 333 weakMap: (e) => y(e, WeakMap), 334 nodeList: C, 335 element: (e) => 336 null !== e && 337 "object" == typeof e && 338 1 === e.nodeType && 339 "object" == typeof e.style && 340 "object" == typeof e.ownerDocument, 341 textNode: (e) => f(e) === Text, 342 event: (e) => y(e, Event), 343 keyboardEvent: (e) => y(e, KeyboardEvent), 344 cue: (e) => y(e, window.TextTrackCue) || y(e, window.VTTCue), 345 track: (e) => y(e, TextTrack) || (!b(e) && w(e.kind)), 346 promise: (e) => y(e, Promise) && T(e.then), 347 url: (e) => { 348 if (y(e, window.URL)) return !0; 349 if (!w(e)) return !1; 350 let t = e; 351 (e.startsWith("http://") && e.startsWith("https://")) || 352 (t = `http://${e}`); 353 try { 354 return !A(new URL(t).hostname); 355 } catch (e) { 356 return !1; 357 } 358 }, 359 empty: A, 360 }; 361 const E = (() => { 362 const e = document.createElement("span"), 363 t = { 364 WebkitTransition: "webkitTransitionEnd", 365 MozTransition: "transitionend", 366 OTransition: "oTransitionEnd otransitionend", 367 transition: "transitionend", 368 }, 369 i = Object.keys(t).find((t) => void 0 !== e.style[t]); 370 return !!S.string(i) && t[i]; 371 })(); 372 function P(e, t) { 373 setTimeout(() => { 374 try { 375 ((e.hidden = !0), e.offsetHeight, (e.hidden = !1)); 376 } catch (e) {} 377 }, t); 378 } 379 var M = { 380 isIE: Boolean(window.document.documentMode), 381 isEdge: /Edge/g.test(navigator.userAgent), 382 isWebKit: 383 "WebkitAppearance" in document.documentElement.style && 384 !/Edge/g.test(navigator.userAgent), 385 isIPhone: 386 /iPhone|iPod/gi.test(navigator.userAgent) && 387 navigator.maxTouchPoints > 1, 388 isIPadOS: 389 "MacIntel" === navigator.platform && navigator.maxTouchPoints > 1, 390 isIos: 391 /iPad|iPhone|iPod/gi.test(navigator.userAgent) && 392 navigator.maxTouchPoints > 1, 393 }; 394 function N(e, t) { 395 return t.split(".").reduce((e, t) => e && e[t], e); 396 } 397 function x(e = {}, ...t) { 398 if (!t.length) return e; 399 const i = t.shift(); 400 return S.object(i)
401 ? (Object.keys(i).forEach((t) => { 402 S.object(i[t]) 403 ? (Object.keys(e).includes(t) || Object.assign(e, { [t]: {} }), 404 x(e[t], i[t])) 405 : Object.assign(e, { [t]: i[t] }); 406 }), 407 x(e, ...t)) 408 : e; 409 } 410 function L(e, t) { 411 const i = e.length ? e : [e]; 412 Array.from(i) 413 .reverse() 414 .forEach((e, i) => { 415 const s = i > 0 ? t.cloneNode(!0) : t, 416 n = e.parentNode, 417 a = e.nextSibling; 418 (s.appendChild(e), a ? n.insertBefore(s, a) : n.appendChild(s)); 419 }); 420 } 421 function I(e, t) { 422 S.element(e) && 423 !S.empty(t) && 424 Object.entries(t) 425 .filter(([, e]) => !S.nullOrUndefined(e)) 426 .forEach(([t, i]) => e.setAttribute(t, i)); 427 } 428 function $(e, t, i) { 429 const s = document.createElement(e); 430 return (S.object(t) && I(s, t), S.string(i) && (s.innerText = i), s); 431 } 432 function _(e, t, i, s) { 433 S.element(t) && t.appendChild($(e, i, s)); 434 } 435 function O(e) { 436 S.nodeList(e) || S.array(e) 437 ? Array.from(e).forEach(O) 438 : S.element(e) && 439 S.element(e.parentNode) && 440 e.parentNode.removeChild(e); 441 } 442 function j(e) { 443 if (!S.element(e)) return; 444 let { length: t } = e.childNodes; 445 for (; t > 0; ) (e.removeChild(e.lastChild), (t -= 1)); 446 } 447 function q(e, t) { 448 return S.element(t) && S.element(t.parentNode) && S.element(e) 449 ? (t.parentNode.replaceChild(e, t), e) 450 : null; 451 } 452 function D(e, t) { 453 if (!S.string(e) || S.empty(e)) return {}; 454 const i = {}, 455 s = x({}, t); 456 return ( 457 e.split(",").forEach((e) => { 458 const t = e.trim(), 459 n = t.replace(".", ""), 460 a = t.replace(/[[\]]/g, "").split("="), 461 [l] = a, 462 r = a.length > 1 ? a[1].replace(/["']/g, "") : ""; 463 switch (t.charAt(0)) { 464 case ".": 465 S.string(s.class) ? (i.class = `${s.class} ${n}`) : (i.class = n); 466 break; 467 case "#": 468 i.id = t.replace("#", ""); 469 break; 470 case "[": 471 i[l] = r; 472 } 473 }), 474 x(s, i) 475 ); 476 } 477 function H(e, t) { 478 if (!S.element(e)) return; 479 let i = t; 480 (S.boolean(i) || (i = !e.hidden), (e.hidden = i)); 481 } 482 function R(e, t, i) { 483 if (S.nodeList(e)) return Array.from(e).map((e) => R(e, t, i)); 484 if (S.element(e)) { 485 let s = "toggle"; 486 return ( 487 void 0 !== i && (s = i ? "add" : "remove"), 488 e.classList[s](t), 489 e.classList.contains(t) 490 ); 491 } 492 return !1; 493 } 494 function F(e, t) { 495 return S.element(e) && e.classList.contains(t); 496 } 497 function V(e, t) { 498 const { prototype: i } = Element; 499 return ( 500 i.matches || 501 i.webkitMatchesSelector || 502 i.mozMatchesSelector || 503 i.msMatchesSelector || 504 function () { 505 return Array.from(document.querySelectorAll(t)).includes(this); 506 } 507 ).call(e, t); 508 } 509 function U(e) { 510 return this.elements.container.querySelectorAll(e); 511 } 512 function B(e) { 513 return this.elements.container.querySelector(e); 514 } 515 function W(e = null, t = !1) { 516 S.element(e) && e.focus({ preventScroll: !0, focusVisible: t }); 517 } 518 const z = { 519 "audio/ogg": "vorbis", 520 "audio/wav": "1", 521 "video/webm": "vp8, vorbis", 522 "video/mp4": "avc1.42E01E, mp4a.40.2", 523 "video/ogg": "theora", 524 }, 525 K = { 526 audio: "canPlayType" in document.createElement("audio"), 527 video: "canPlayType" in document.createElement("video"), 528 check(e, t) { 529 const i = K[e] || "html5" !== t; 530 return { api: i, ui: i && K.rangeInput }; 531 }, 532 pip: !( 533 M.isIPhone || 534 (!S.function($("video").webkitSetPresentationMode) && 535 (!document.pictureInPictureEnabled || 536 $("video").disablePictureInPicture)) 537 ), 538 airplay: S.function(window.WebKitPlaybackTargetAvailabilityEvent),
539 playsinline: "playsInline" in document.createElement("video"), 540 mime(e) { 541 if (S.empty(e)) return !1; 542 const [t] = e.split("/"); 543 let i = e; 544 if (!this.isHTML5 || t !== this.type) return !1; 545 Object.keys(z).includes(i) && (i += `; codecs="${z[e]}"`); 546 try { 547 return Boolean(i && this.media.canPlayType(i).replace(/no/, "")); 548 } catch (e) { 549 return !1; 550 } 551 }, 552 textTracks: "textTracks" in document.createElement("video"), 553 rangeInput: (() => { 554 const e = document.createElement("input"); 555 return ((e.type = "range"), "range" === e.type); 556 })(), 557 touch: "ontouchstart" in document.documentElement, 558 transitions: !1 !== E, 559 reducedMotion: 560 "matchMedia" in window && 561 window.matchMedia("(prefers-reduced-motion)").matches, 562 }, 563 Y = (() => { 564 let e = !1; 565 try { 566 const t = Object.defineProperty({}, "passive", { 567 get: () => ((e = !0), null), 568 }); 569 (window.addEventListener("test", null, t), 570 window.removeEventListener("test", null, t)); 571 } catch (e) {} 572 return e; 573 })(); 574 function Q(e, t, i, s = !1, n = !0, a = !1) { 575 if (!e || !("addEventListener" in e) || S.empty(t) || !S.function(i)) 576 return; 577 const l = t.split(" "); 578 let r = a; 579 (Y && (r = { passive: n, capture: a }), 580 l.forEach((t) => { 581 (this && 582 this.eventListeners && 583 s && 584 this.eventListeners.push({ 585 element: e, 586 type: t, 587 callback: i, 588 options: r, 589 }), 590 e[s ? "addEventListener" : "removeEventListener"](t, i, r)); 591 })); 592 } 593 function X(e, t = "", i, s = !0, n = !1) { 594 Q.call(this, e, t, i, !0, s, n); 595 } 596 function J(e, t = "", i, s = !0, n = !1) { 597 Q.call(this, e, t, i, !1, s, n); 598 } 599 function G(e, t = "", i, s = !0, n = !1) { 600 const a = (...l) => { 601 (J(e, t, a, s, n), i.apply(this, l)); 602 }; 603 Q.call(this, e, t, a, !0, s, n); 604 } 605 function Z(e, t = "", i = !1, s = {}) { 606 if (!S.element(e) || S.empty(t)) return; 607 const n = new CustomEvent(t, { 608 bubbles: i, 609 detail: { ...s, plyr: this }, 610 }); 611 e.dispatchEvent(n); 612 } 613 function ee() { 614 this && 615 this.eventListeners && 616 (this.eventListeners.forEach((e) => { 617 const { element: t, type: i, callback: s, options: n } = e; 618 t.removeEventListener(i, s, n); 619 }), 620 (this.eventListeners = [])); 621 } 622 function te() { 623 return new Promise((e) => 624 this.ready 625 ? setTimeout(e, 0) 626 : X.call(this, this.elements.container, "ready", e), 627 ).then(() => {}); 628 } 629 function ie(e) { 630 S.promise(e) && e.then(null, () => {}); 631 } 632 function se(e) { 633 return S.array(e) ? e.filter((t, i) => e.indexOf(t) === i) : e; 634 } 635 function ne(e, t) { 636 return S.array(e) && e.length 637 ? e.reduce((e, i) => (Math.abs(i - t) < Math.abs(e - t) ? i : e)) 638 : null; 639 } 640 function ae(e) { 641 return !(!window || !window.CSS) && window.CSS.supports(e); 642 } 643 const le = [ 644 [1, 1], 645 [4, 3], 646 [3, 4], 647 [5, 4], 648 [4, 5], 649 [3, 2], 650 [2, 3], 651 [16, 10], 652 [10, 16], 653 [16, 9], 654 [9, 16], 655 [21, 9], 656 [9, 21], 657 [32, 9], 658 [9, 32], 659 ].reduce((e, [t, i]) => ({ ...e, [t / i]: [t, i] }), {}); 660 function re(e) { 661 if (!(S.array(e) || (S.string(e) && e.includes(":")))) return !1; 662 return (S.array(e) ? e : e.split(":")).map(Number).every(S.number); 663 } 664 function oe(e) { 665 if (!S.array(e) || !e.every(S.number)) return null; 666 const [t, i] = e, 667 s = (e, t) => (0 === t ? e : s(t, e % t)), 668 n = s(t, i); 669 return [t / n, i / n]; 670 } 671 function ce(e) { 672 const t = (e) => (re(e) ? e.split(":").map(Number) : null); 673 let i = t(e); 674 if ( 675 (null === i && (i = t(this.config.ratio)), 676 null === i && 677 !S.empty(this.embed) && 678 S.array(this.embed.ratio) && 679 ({ ratio: i } = this.embed), 680 null === i && this.isHTML5) 681 ) { 682 const { videoWidth: e, videoHeight: t } = this.media; 683 i = [e, t]; 684 } 685 return oe(i); 686 } 687 function ue(e) { 688 if (!this.isVideo) return {}; 689 const { wrapper: t } = this.elements, 690 i = ce.call(this, e); 691 if (!S.array(i)) return {}; 692 const [s, n] = oe(i),
693 a = (100 / s) * n; 694 if ( 695 (ae(`aspect-ratio: ${s}/${n}`) 696 ? (t.style.aspectRatio = `${s}/${n}`) 697 : (t.style.paddingBottom = `${a}%`), 698 this.isVimeo && !this.config.vimeo.premium && this.supported.ui) 699 ) { 700 const e = 701 (100 / this.media.offsetWidth) * 702 parseInt(window.getComputedStyle(this.media).paddingBottom, 10), 703 i = (e - a) / (e / 50); 704 this.fullscreen.active 705 ? (t.style.paddingBottom = null) 706 : (this.media.style.transform = `translateY(-${i}%)`); 707 } else 708 this.isHTML5 && t.classList.add(this.config.classNames.videoFixedRatio); 709 return { padding: a, ratio: i }; 710 } 711 function he(e, t, i = 0.05) { 712 const s = e / t, 713 n = ne(Object.keys(le), s); 714 return Math.abs(n - s) <= i ? le[n] : [e, t]; 715 } 716 const de = { 717 getSources() { 718 if (!this.isHTML5) return []; 719 return Array.from(this.media.querySelectorAll("source")).filter((e) => { 720 const t = e.getAttribute("type"); 721 return !!S.empty(t) || K.mime.call(this, t); 722 }); 723 }, 724 getQualityOptions() { 725 return this.config.quality.forced 726 ? this.config.quality.options 727 : de.getSources 728 .call(this) 729 .map((e) => Number(e.getAttribute("size"))) 730 .filter(Boolean); 731 }, 732 setup() { 733 if (!this.isHTML5) return; 734 const e = this; 735 ((e.options.speed = e.config.speed.options), 736 S.empty(this.config.ratio) || ue.call(e), 737 Object.defineProperty(e.media, "quality", { 738 get() { 739 const t = de.getSources 740 .call(e) 741 .find((t) => t.getAttribute("src") === e.source); 742 return t && Number(t.getAttribute("size")); 743 }, 744 set(t) { 745 if (e.quality !== t) { 746 if ( 747 e.config.quality.forced && 748 S.function(e.config.quality.onChange) 749 ) 750 e.config.quality.onChange(t); 751 else { 752 const i = de.getSources 753 .call(e) 754 .find((e) => Number(e.getAttribute("size")) === t); 755 if (!i) return; 756 const { 757 currentTime: s, 758 paused: n, 759 preload: a, 760 readyState: l, 761 playbackRate: r, 762 } = e.media; 763 ((e.media.src = i.getAttribute("src")), 764 ("none" !== a || l) && 765 (e.once("loadedmetadata", () => { 766 ((e.speed = r), (e.currentTime = s), n || ie(e.play())); 767 }), 768 e.media.load())); 769 } 770 Z.call(e, e.media, "qualitychange", !1, { quality: t }); 771 } 772 }, 773 })); 774 }, 775 cancelRequests() { 776 this.isHTML5 && 777 (O(de.getSources.call(this)), 778 this.media.setAttribute("src", this.config.blankVideo), 779 this.media.load(), 780 this.debug.log("Cancelled network requests")); 781 }, 782 }; 783 function me(e, ...t) { 784 return S.empty(e) 785 ? e 786 : e.toString().replace(/{(\d+)}/g, (e, i) => t[i].toString()); 787 } 788 const pe = (e = "", t = "", i = "") => 789 e.replace( 790 new RegExp( 791 t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1"), 792 "g", 793 ), 794 i.toString(), 795 ), 796 ge = (e = "") => 797 e 798 .toString() 799 .replace( 800 /\w\S*/g, 801 (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), 802 ); 803 function fe(e = "") { 804 let t = e.toString(); 805 return ( 806 (t = (function (e = "") { 807 let t = e.toString(); 808 return ( 809 (t = pe(t, "-", " ")), 810 (t = pe(t, "_", " ")), 811 (t = ge(t)), 812 pe(t, " ", "") 813 ); 814 })(t)), 815 t.charAt(0).toLowerCase() + t.slice(1) 816 ); 817 } 818 function ye(e) { 819 const t = document.createElement("div"); 820 return (t.appendChild(e), t.innerHTML); 821 } 822 const be = { 823 pip: "PIP", 824 airplay: "AirPlay", 825 html5: "HTML5", 826 vimeo: "Vimeo", 827 youtube: "YouTube", 828 }, 829 ve = { 830 get(e = "", t = {}) { 831 if (S.empty(e) || S.empty(t)) return ""; 832 let i = N(t.i18n, e); 833 if (S.empty(i)) return Object.keys(be).includes(e) ? be[e] : ""; 834 const s = { "{seektime}": t.seekTime, "{title}": t.title }; 835 return (
836 Object.entries(s).forEach(([e, t]) => { 837 i = pe(i, e, t); 838 }), 839 i 840 ); 841 }, 842 }; 843 class we { 844 constructor(t) { 845 (e(this, "get", (e) => { 846 if (!we.supported || !this.enabled) return null; 847 const t = window.localStorage.getItem(this.key); 848 if (S.empty(t)) return null; 849 const i = JSON.parse(t); 850 return S.string(e) && e.length ? i[e] : i; 851 }), 852 e(this, "set", (e) => { 853 if (!we.supported || !this.enabled) return; 854 if (!S.object(e)) return; 855 let t = this.get(); 856 (S.empty(t) && (t = {}), x(t, e)); 857 try { 858 window.localStorage.setItem(this.key, JSON.stringify(t)); 859 } catch (e) {} 860 }), 861 (this.enabled = t.config.storage.enabled), 862 (this.key = t.config.storage.key)); 863 } 864 static get supported() { 865 try { 866 if (!("localStorage" in window)) return !1; 867 const e = "___test"; 868 return ( 869 window.localStorage.setItem(e, e), 870 window.localStorage.removeItem(e), 871 !0 872 ); 873 } catch (e) { 874 return !1; 875 } 876 } 877 } 878 function Te(e, t = "text") { 879 return new Promise((i, s) => { 880 try { 881 const s = new XMLHttpRequest(); 882 if (!("withCredentials" in s)) return; 883 (s.addEventListener("load", () => { 884 if ("text" === t) 885 try { 886 i(JSON.parse(s.responseText)); 887 } catch (e) { 888 i(s.responseText); 889 } 890 else i(s.response); 891 }), 892 s.addEventListener("error", () => { 893 throw new Error(s.status); 894 }), 895 s.open("GET", e, !0), 896 (s.responseType = t), 897 s.send()); 898 } catch (e) { 899 s(e); 900 } 901 }); 902 } 903 function ke(e, t) { 904 if (!S.string(e)) return; 905 const i = "cache", 906 s = S.string(t); 907 let n = !1; 908 const a = () => null !== document.getElementById(t), 909 l = (e, t) => { 910 ((e.innerHTML = t), 911 (s && a()) || document.body.insertAdjacentElement("afterbegin", e)); 912 }; 913 if (!s || !a()) { 914 const a = we.supported, 915 r = document.createElement("div"); 916 if ((r.setAttribute("hidden", ""), s && r.setAttribute("id", t), a)) { 917 const e = window.localStorage.getItem(`${i}-${t}`); 918 if (((n = null !== e), n)) { 919 const t = JSON.parse(e); 920 l(r, t.content); 921 } 922 } 923 Te(e) 924 .then((e) => { 925 if (!S.empty(e)) { 926 if (a) 927 try { 928 window.localStorage.setItem( 929 `${i}-${t}`, 930 JSON.stringify({ content: e }), 931 ); 932 } catch (e) {} 933 l(r, e); 934 } 935 }) 936 .catch(() => {}); 937 } 938 } 939 const Ce = (e) => Math.trunc((e / 60 / 60) % 60, 10), 940 Ae = (e) => Math.trunc((e / 60) % 60, 10), 941 Se = (e) => Math.trunc(e % 60, 10); 942 function Ee(e = 0, t = !1, i = !1) { 943 if (!S.number(e)) return Ee(void 0, t, i); 944 const s = (e) => `0${e}`.slice(-2); 945 let n = Ce(e); 946 const a = Ae(e), 947 l = Se(e); 948 return ( 949 (n = t || n > 0 ? `${n}:` : ""), 950 `${i && e > 0 ? "-" : ""}${n}${s(a)}:${s(l)}` 951 ); 952 } 953 const Pe = { 954 getIconUrl() { 955 const e = new URL(this.config.iconUrl, window.location), 956 t = window.location.host 957 ? window.location.host 958 : window.top.location.host, 959 i = e.host !== t || (M.isIE && !window.svg4everybody); 960 return { url: this.config.iconUrl, cors: i }; 961 }, 962 findElements() { 963 try { 964 return ( 965 (this.elements.controls = B.call( 966 this, 967 this.config.selectors.controls.wrapper, 968 )), 969 (this.elements.buttons = { 970 play: U.call(this, this.config.selectors.buttons.play), 971 pause: B.call(this, this.config.selectors.buttons.pause), 972 restart: B.call(this, this.config.selectors.buttons.restart), 973 rewind: B.call(this, this.config.selectors.buttons.rewind), 974 fastForward: B.call( 975 this, 976 this.config.selectors.buttons.fastForward, 977 ), 978 mute: B.call(this, this.config.selectors.buttons.mute), 979 pip: B.call(this, this.config.selectors.buttons.pip), 980 airplay: B.call(this, this.config.selectors.buttons.airplay), 981 settings: B.call(this, this.config.selectors.buttons.settings), 982 captions: B.call(this, this.config.selectors.buttons.captions), 983 fullscreen: B.call( 984 this, 985 this.config.selectors.buttons.fullscreen, 986 ), 987 }), 988 (this.elements.progress = B.call( 989 this, 990 this.config.selectors.progress, 991 )), 992 (this.elements.inputs = { 993 seek: B.call(this, this.config.selectors.inputs.seek), 994 volume: B.call(this, this.config.selectors.inputs.volume), 995 }), 996 (this.elements.display = { 997 buffer: B.call(this, this.config.selectors.display.buffer), 998 currentTime: B.call( 999 this, 1000 this.config.selectors.display.currentTime, 1001 ),
1002 duration: B.call(this, this.config.selectors.display.duration), 1003 }), 1004 S.element(this.elements.progress) && 1005 (this.elements.display.seekTooltip = 1006 this.elements.progress.querySelector( 1007 `.${this.config.classNames.tooltip}`, 1008 )), 1009 !0 1010 ); 1011 } catch (e) { 1012 return ( 1013 this.debug.warn( 1014 "It looks like there is a problem with your custom controls HTML", 1015 e, 1016 ), 1017 this.toggleNativeControls(!0), 1018 !1 1019 ); 1020 } 1021 }, 1022 createIcon(e, t) { 1023 const i = "http://www.w3.org/2000/svg", 1024 s = Pe.getIconUrl.call(this), 1025 n = `${s.cors ? "" : s.url}#${this.config.iconPrefix}`, 1026 a = document.createElementNS(i, "svg"); 1027 I(a, x(t, { "aria-hidden": "true", focusable: "false" })); 1028 const l = document.createElementNS(i, "use"), 1029 r = `${n}-${e}`; 1030 return ( 1031 "href" in l && 1032 l.setAttributeNS("http://www.w3.org/1999/xlink", "href", r), 1033 l.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", r), 1034 a.appendChild(l), 1035 a 1036 ); 1037 }, 1038 createLabel(e, t = {}) { 1039 const i = ve.get(e, this.config); 1040 return $( 1041 "span", 1042 { 1043 ...t, 1044 class: [t.class, this.config.classNames.hidden] 1045 .filter(Boolean) 1046 .join(" "), 1047 }, 1048 i, 1049 ); 1050 }, 1051 createBadge(e) { 1052 if (S.empty(e)) return null; 1053 const t = $("span", { class: this.config.classNames.menu.value }); 1054 return ( 1055 t.appendChild( 1056 $("span", { class: this.config.classNames.menu.badge }, e), 1057 ), 1058 t 1059 ); 1060 }, 1061 createButton(e, t) { 1062 const i = x({}, t); 1063 let s = fe(e); 1064 const n = { 1065 element: "button", 1066 toggle: !1, 1067 label: null, 1068 icon: null, 1069 labelPressed: null, 1070 iconPressed: null, 1071 }; 1072 switch ( 1073 (["element", "icon", "label"].forEach((e) => { 1074 Object.keys(i).includes(e) && ((n[e] = i[e]), delete i[e]); 1075 }), 1076 "button" !== n.element || 1077 Object.keys(i).includes("type") || 1078 (i.type = "button"), 1079 Object.keys(i).includes("class") 1080 ? i.class 1081 .split(" ") 1082 .some((e) => e === this.config.classNames.control) || 1083 x(i, { class: `${i.class} ${this.config.classNames.control}` }) 1084 : (i.class = this.config.classNames.control), 1085 e) 1086 ) { 1087 case "play": 1088 ((n.toggle = !0), 1089 (n.label = "play"), 1090 (n.labelPressed = "pause"), 1091 (n.icon = "play"), 1092 (n.iconPressed = "pause")); 1093 break; 1094 case "mute": 1095 ((n.toggle = !0), 1096 (n.label = "mute"), 1097 (n.labelPressed = "unmute"), 1098 (n.icon = "volume"), 1099 (n.iconPressed = "muted")); 1100 break; 1101 case "captions": 1102 ((n.toggle = !0), 1103 (n.label = "enableCaptions"), 1104 (n.labelPressed = "disableCaptions"), 1105 (n.icon = "captions-off"), 1106 (n.iconPressed = "captions-on")); 1107 break; 1108 case "fullscreen": 1109 ((n.toggle = !0), 1110 (n.label = "enterFullscreen"), 1111 (n.labelPressed = "exitFullscreen"), 1112 (n.icon = "enter-fullscreen"), 1113 (n.iconPressed = "exit-fullscreen")); 1114 break; 1115 case "play-large": 1116 ((i.class += ` ${this.config.classNames.control}--overlaid`), 1117 (s = "play"), 1118 (n.label = "play"), 1119 (n.icon = "play")); 1120 break; 1121 default: 1122 (S.empty(n.label) && (n.label = s), 1123 S.empty(n.icon) && (n.icon = e)); 1124 } 1125 const a = $(n.element); 1126 return ( 1127 n.toggle 1128 ? (a.appendChild( 1129 Pe.createIcon.call(this, n.iconPressed, { 1130 class: "icon--pressed", 1131 }), 1132 ), 1133 a.appendChild( 1134 Pe.createIcon.call(this, n.icon, { 1135 class: "icon--not-pressed", 1136 }), 1137 ), 1138 a.appendChild( 1139 Pe.createLabel.call(this, n.labelPressed, { 1140 class: "label--pressed", 1141 }), 1142 ), 1143 a.appendChild( 1144 Pe.createLabel.call(this, n.label, { 1145 class: "label--not-pressed", 1146 }), 1147 )) 1148 : (a.appendChild(Pe.createIcon.call(this, n.icon)), 1149 a.appendChild(Pe.createLabel.call(this, n.label))), 1150 x(i, D(this.config.selectors.buttons[s], i)), 1151 I(a, i), 1152 "play" === s 1153 ? (S.array(this.elements.buttons[s]) || 1154 (this.elements.buttons[s] = []), 1155 this.elements.buttons[s].push(a)) 1156 : (this.elements.buttons[s] = a), 1157 a 1158 ); 1159 }, 1160 createRange(e, t) { 1161 const i = $( 1162 "input", 1163 x( 1164 D(this.config.selectors.inputs[e]), 1165 { 1166 type: "range", 1167 min: 0, 1168 max: 100, 1169 step: 0.01, 1170 value: 0, 1171 autocomplete: "off", 1172 role: "slider", 1173 "aria-label": ve.get(e, this.config), 1174 "aria-valuemin": 0, 1175 "aria-valuemax": 100, 1176 "aria-valuenow": 0, 1177 }, 1178 t, 1179 ), 1180 ); 1181 return ( 1182 (this.elements.inputs[e] = i), 1183 Pe.updateRangeFill.call(this, i), 1184 g.setup(i), 1185 i 1186 ); 1187 }, 1188 createProgress(e, t) { 1189 const i = $( 1190 "progress", 1191 x( 1192 D(this.config.selectors.display[e]), 1193 { 1194 min: 0, 1195 max: 100, 1196 value: 0, 1197 role: "progressbar", 1198 "aria-hidden": !0, 1199 }, 1200 t, 1201 ), 1202 ); 1203 if ("volume" !== e) { 1204 i.appendChild($("span", null, "0")); 1205 const t = { played: "played", buffer: "buffered" }[e], 1206 s = t ? ve.get(t, this.config) : ""; 1207 i.innerText = `% ${s.toLowerCase()}`; 1208 }
1209 return ((this.elements.display[e] = i), i); 1210 }, 1211 createTime(e, t) { 1212 const i = D(this.config.selectors.display[e], t), 1213 s = $( 1214 "div", 1215 x(i, { 1216 class: 1217 `${i.class ? i.class : ""} ${this.config.classNames.display.time} `.trim(), 1218 "aria-label": ve.get(e, this.config), 1219 role: "timer", 1220 }), 1221 "00:00", 1222 ); 1223 return ((this.elements.display[e] = s), s); 1224 }, 1225 bindMenuItemShortcuts(e, t) { 1226 (X.call( 1227 this, 1228 e, 1229 "keydown keyup", 1230 (i) => { 1231 if (![" ", "ArrowUp", "ArrowDown", "ArrowRight"].includes(i.key)) 1232 return; 1233 if ((i.preventDefault(), i.stopPropagation(), "keydown" === i.type)) 1234 return; 1235 const s = V(e, '[role="menuitemradio"]'); 1236 if (!s && [" ", "ArrowRight"].includes(i.key)) 1237 Pe.showMenuPanel.call(this, t, !0); 1238 else { 1239 let t; 1240 " " !== i.key && 1241 ("ArrowDown" === i.key || (s && "ArrowRight" === i.key) 1242 ? ((t = e.nextElementSibling), 1243 S.element(t) || (t = e.parentNode.firstElementChild)) 1244 : ((t = e.previousElementSibling), 1245 S.element(t) || (t = e.parentNode.lastElementChild)), 1246 W.call(this, t, !0)); 1247 } 1248 }, 1249 !1, 1250 ), 1251 X.call(this, e, "keyup", (e) => { 1252 "Return" === e.key && Pe.focusFirstMenuItem.call(this, null, !0); 1253 })); 1254 }, 1255 createMenuItem({ 1256 value: e, 1257 list: t, 1258 type: i, 1259 title: s, 1260 badge: n = null, 1261 checked: a = !1, 1262 }) { 1263 const l = D(this.config.selectors.inputs[i]), 1264 r = $( 1265 "button", 1266 x(l, { 1267 type: "button", 1268 role: "menuitemradio", 1269 class: 1270 `${this.config.classNames.control} ${l.class ? l.class : ""}`.trim(), 1271 "aria-checked": a, 1272 value: e, 1273 }), 1274 ), 1275 o = $("span"); 1276 ((o.innerHTML = s), 1277 S.element(n) && o.appendChild(n), 1278 r.appendChild(o), 1279 Object.defineProperty(r, "checked", { 1280 enumerable: !0, 1281 get: () => "true" === r.getAttribute("aria-checked"), 1282 set(e) { 1283 (e && 1284 Array.from(r.parentNode.children) 1285 .filter((e) => V(e, '[role="menuitemradio"]')) 1286 .forEach((e) => e.setAttribute("aria-checked", "false")), 1287 r.setAttribute("aria-checked", e ? "true" : "false")); 1288 }, 1289 }), 1290 this.listeners.bind( 1291 r, 1292 "click keyup", 1293 (t) => { 1294 if (!S.keyboardEvent(t) || " " === t.key) { 1295 switch ( 1296 (t.preventDefault(), t.stopPropagation(), (r.checked = !0), i) 1297 ) { 1298 case "language": 1299 this.currentTrack = Number(e); 1300 break; 1301 case "quality": 1302 this.quality = e; 1303 break; 1304 case "speed": 1305 this.speed = parseFloat(e); 1306 } 1307 Pe.showMenuPanel.call(this, "home", S.keyboardEvent(t)); 1308 } 1309 }, 1310 i, 1311 !1, 1312 ), 1313 Pe.bindMenuItemShortcuts.call(this, r, i), 1314 t.appendChild(r)); 1315 }, 1316 formatTime(e = 0, t = !1) { 1317 if (!S.number(e)) return e; 1318 return Ee(e, Ce(this.duration) > 0, t); 1319 }, 1320 updateTimeDisplay(e = null, t = 0, i = !1) { 1321 S.element(e) && S.number(t) && (e.innerText = Pe.formatTime(t, i)); 1322 }, 1323 updateVolume() { 1324 this.supported.ui && 1325 (S.element(this.elements.inputs.volume) && 1326 Pe.setRange.call( 1327 this, 1328 this.elements.inputs.volume, 1329 this.muted ? 0 : this.volume, 1330 ),
1331 S.element(this.elements.buttons.mute) && 1332 (this.elements.buttons.mute.pressed = 1333 this.muted || 0 === this.volume)); 1334 }, 1335 setRange(e, t = 0) { 1336 S.element(e) && ((e.value = t), Pe.updateRangeFill.call(this, e)); 1337 }, 1338 updateProgress(e) { 1339 if (!this.supported.ui || !S.event(e)) return; 1340 let t = 0; 1341 const i = (e, t) => { 1342 const i = S.number(t) ? t : 0, 1343 s = S.element(e) ? e : this.elements.display.buffer; 1344 if (S.element(s)) { 1345 s.value = i; 1346 const e = s.getElementsByTagName("span")[0]; 1347 S.element(e) && (e.childNodes[0].nodeValue = i); 1348 } 1349 }; 1350 if (e) 1351 switch (e.type) { 1352 case "timeupdate": 1353 case "seeking": 1354 case "seeked": 1355 ((s = this.currentTime), 1356 (n = this.duration), 1357 (t = 1358 0 === s || 0 === n || Number.isNaN(s) || Number.isNaN(n) 1359 ? 0 1360 : ((s / n) * 100).toFixed(2)), 1361 "timeupdate" === e.type && 1362 Pe.setRange.call(this, this.elements.inputs.seek, t)); 1363 break; 1364 case "playing": 1365 case "progress": 1366 i(this.elements.display.buffer, 100 * this.buffered); 1367 } 1368 var s, n; 1369 }, 1370 updateRangeFill(e) { 1371 const t = S.event(e) ? e.target : e; 1372 if (S.element(t) && "range" === t.getAttribute("type")) { 1373 if (V(t, this.config.selectors.inputs.seek)) { 1374 t.setAttribute("aria-valuenow", this.currentTime); 1375 const e = Pe.formatTime(this.currentTime), 1376 i = Pe.formatTime(this.duration), 1377 s = ve.get("seekLabel", this.config); 1378 t.setAttribute( 1379 "aria-valuetext", 1380 s.replace("{currentTime}", e).replace("{duration}", i), 1381 ); 1382 } else if (V(t, this.config.selectors.inputs.volume)) { 1383 const e = 100 * t.value; 1384 (t.setAttribute("aria-valuenow", e), 1385 t.setAttribute("aria-valuetext", `${e.toFixed(1)}%`)); 1386 } else t.setAttribute("aria-valuenow", t.value); 1387 (M.isWebKit || M.isIPadOS) && 1388 t.style.setProperty("--value", (t.value / t.max) * 100 + "%"); 1389 } 1390 }, 1391 updateSeekTooltip(e) { 1392 var t, i; 1393 if ( 1394 !this.config.tooltips.seek || 1395 !S.element(this.elements.inputs.seek) || 1396 !S.element(this.elements.display.seekTooltip) || 1397 0 === this.duration 1398 ) 1399 return; 1400 const s = this.elements.display.seekTooltip, 1401 n = `${this.config.classNames.tooltip}--visible`, 1402 a = (e) => R(s, n, e); 1403 if (this.touch) return void a(!1); 1404 let l = 0; 1405 const r = this.elements.progress.getBoundingClientRect(); 1406 if (S.event(e)) l = (100 / r.width) * (e.pageX - r.left); 1407 else { 1408 if (!F(s, n)) return; 1409 l = parseFloat(s.style.left, 10); 1410 } 1411 l < 0 ? (l = 0) : l > 100 && (l = 100); 1412 const o = (this.duration / 100) * l; 1413 s.innerText = Pe.formatTime(o); 1414 const c = 1415 null === (t = this.config.markers) || 1416 void 0 === t || 1417 null === (i = t.points) || 1418 void 0 === i 1419 ? void 0 1420 : i.find(({ time: e }) => e === Math.round(o)); 1421 (c && s.insertAdjacentHTML("afterbegin", `${c.label}<br>`), 1422 (s.style.left = `${l}%`), 1423 S.event(e) && 1424 ["mouseenter", "mouseleave"].includes(e.type) && 1425 a("mouseenter" === e.type)); 1426 }, 1427 timeUpdate(e) { 1428 const t = 1429 !S.element(this.elements.display.duration) && this.config.invertTime; 1430 (Pe.updateTimeDisplay.call( 1431 this, 1432 this.elements.display.currentTime, 1433 t ? this.duration - this.currentTime : this.currentTime, 1434 t, 1435 ), 1436 (e && "timeupdate" === e.type && this.media.seeking) || 1437 Pe.updateProgress.call(this, e)); 1438 }, 1439 durationUpdate() { 1440 if (!this.supported.ui || (!this.config.invertTime && this.currentTime)) 1441 return; 1442 if (this.duration >= 2 ** 32) 1443 return ( 1444 H(this.elements.display.currentTime, !0), 1445 void H(this.elements.progress, !0) 1446 );
1447 S.element(this.elements.inputs.seek) && 1448 this.elements.inputs.seek.setAttribute( 1449 "aria-valuemax", 1450 this.duration, 1451 ); 1452 const e = S.element(this.elements.display.duration); 1453 (!e && 1454 this.config.displayDuration && 1455 this.paused && 1456 Pe.updateTimeDisplay.call( 1457 this, 1458 this.elements.display.currentTime, 1459 this.duration, 1460 ), 1461 e && 1462 Pe.updateTimeDisplay.call( 1463 this, 1464 this.elements.display.duration, 1465 this.duration, 1466 ), 1467 this.config.markers.enabled && Pe.setMarkers.call(this), 1468 Pe.updateSeekTooltip.call(this)); 1469 }, 1470 toggleMenuButton(e, t) { 1471 H(this.elements.settings.buttons[e], !t); 1472 }, 1473 updateSetting(e, t, i) { 1474 const s = this.elements.settings.panels[e]; 1475 let n = null, 1476 a = t; 1477 if ("captions" === e) n = this.currentTrack; 1478 else { 1479 if ( 1480 ((n = S.empty(i) ? this[e] : i), 1481 S.empty(n) && (n = this.config[e].default), 1482 !S.empty(this.options[e]) && !this.options[e].includes(n)) 1483 ) 1484 return void this.debug.warn(`Unsupported value of '${n}' for ${e}`); 1485 if (!this.config[e].options.includes(n)) 1486 return void this.debug.warn(`Disabled value of '${n}' for ${e}`); 1487 } 1488 if ( 1489 (S.element(a) || (a = s && s.querySelector('[role="menu"]')), 1490 !S.element(a)) 1491 ) 1492 return; 1493 this.elements.settings.buttons[e].querySelector( 1494 `.${this.config.classNames.menu.value}`, 1495 ).innerHTML = Pe.getLabel.call(this, e, n); 1496 const l = a && a.querySelector(`[value="${n}"]`); 1497 S.element(l) && (l.checked = !0); 1498 }, 1499 getLabel(e, t) { 1500 switch (e) { 1501 case "speed": 1502 return 1 === t ? ve.get("normal", this.config) : `${t}×`; 1503 case "quality": 1504 if (S.number(t)) { 1505 const e = ve.get(`qualityLabel.${t}`, this.config); 1506 return e.length ? e : `${t}p`; 1507 } 1508 return ge(t); 1509 case "captions": 1510 return xe.getLabel.call(this); 1511 default: 1512 return null; 1513 } 1514 }, 1515 setQualityMenu(e) { 1516 if (!S.element(this.elements.settings.panels.quality)) return; 1517 const t = "quality", 1518 i = 1519 this.elements.settings.panels.quality.querySelector( 1520 '[role="menu"]', 1521 ); 1522 S.array(e) && 1523 (this.options.quality = se(e).filter((e) => 1524 this.config.quality.options.includes(e), 1525 )); 1526 const s = 1527 !S.empty(this.options.quality) && this.options.quality.length > 1; 1528 if ( 1529 (Pe.toggleMenuButton.call(this, t, s), 1530 j(i), 1531 Pe.checkMenu.call(this), 1532 !s) 1533 ) 1534 return; 1535 const n = (e) => { 1536 const t = ve.get(`qualityBadge.${e}`, this.config); 1537 return t.length ? Pe.createBadge.call(this, t) : null; 1538 }; 1539 (this.options.quality 1540 .sort((e, t) => { 1541 const i = this.config.quality.options; 1542 return i.indexOf(e) > i.indexOf(t) ? 1 : -1; 1543 }) 1544 .forEach((e) => { 1545 Pe.createMenuItem.call(this, { 1546 value: e, 1547 list: i, 1548 type: t, 1549 title: Pe.getLabel.call(this, "quality", e), 1550 badge: n(e), 1551 }); 1552 }), 1553 Pe.updateSetting.call(this, t, i)); 1554 }, 1555 setCaptionsMenu() { 1556 if (!S.element(this.elements.settings.panels.captions)) return; 1557 const e = "captions", 1558 t = 1559 this.elements.settings.panels.captions.querySelector( 1560 '[role="menu"]', 1561 ), 1562 i = xe.getTracks.call(this), 1563 s = Boolean(i.length); 1564 if ( 1565 (Pe.toggleMenuButton.call(this, e, s), 1566 j(t), 1567 Pe.checkMenu.call(this), 1568 !s) 1569 ) 1570 return; 1571 const n = i.map((e, i) => ({ 1572 value: i, 1573 checked: this.captions.toggled && this.currentTrack === i, 1574 title: xe.getLabel.call(this, e), 1575 badge: 1576 e.language && Pe.createBadge.call(this, e.language.toUpperCase()), 1577 list: t, 1578 type: "language", 1579 })); 1580 (n.unshift({ 1581 value: -1, 1582 checked: !this.captions.toggled, 1583 title: ve.get("disabled", this.config), 1584 list: t, 1585 type: "language", 1586 }),
1587 n.forEach(Pe.createMenuItem.bind(this)), 1588 Pe.updateSetting.call(this, e, t)); 1589 }, 1590 setSpeedMenu() { 1591 if (!S.element(this.elements.settings.panels.speed)) return; 1592 const e = "speed", 1593 t = 1594 this.elements.settings.panels.speed.querySelector('[role="menu"]'); 1595 this.options.speed = this.options.speed.filter( 1596 (e) => e >= this.minimumSpeed && e <= this.maximumSpeed, 1597 ); 1598 const i = !S.empty(this.options.speed) && this.options.speed.length > 1; 1599 (Pe.toggleMenuButton.call(this, e, i), 1600 j(t), 1601 Pe.checkMenu.call(this), 1602 i && 1603 (this.options.speed.forEach((i) => { 1604 Pe.createMenuItem.call(this, { 1605 value: i, 1606 list: t, 1607 type: e, 1608 title: Pe.getLabel.call(this, "speed", i), 1609 }); 1610 }), 1611 Pe.updateSetting.call(this, e, t))); 1612 }, 1613 checkMenu() { 1614 const { buttons: e } = this.elements.settings, 1615 t = !S.empty(e) && Object.values(e).some((e) => !e.hidden); 1616 H(this.elements.settings.menu, !t); 1617 }, 1618 focusFirstMenuItem(e, t = !1) { 1619 if (this.elements.settings.popup.hidden) return; 1620 let i = e; 1621 S.element(i) || 1622 (i = Object.values(this.elements.settings.panels).find( 1623 (e) => !e.hidden, 1624 )); 1625 const s = i.querySelector('[role^="menuitem"]'); 1626 W.call(this, s, t); 1627 }, 1628 toggleMenu(e) { 1629 const { popup: t } = this.elements.settings, 1630 i = this.elements.buttons.settings; 1631 if (!S.element(t) || !S.element(i)) return; 1632 const { hidden: s } = t; 1633 let n = s; 1634 if (S.boolean(e)) n = e; 1635 else if (S.keyboardEvent(e) && "Escape" === e.key) n = !1; 1636 else if (S.event(e)) { 1637 const s = S.function(e.composedPath) ? e.composedPath()[0] : e.target, 1638 a = t.contains(s); 1639 if (a || (!a && e.target !== i && n)) return; 1640 } 1641 (i.setAttribute("aria-expanded", n), 1642 H(t, !n), 1643 R(this.elements.container, this.config.classNames.menu.open, n), 1644 n && S.keyboardEvent(e) 1645 ? Pe.focusFirstMenuItem.call(this, null, !0) 1646 : n || s || W.call(this, i, S.keyboardEvent(e))); 1647 }, 1648 getMenuSize(e) { 1649 const t = e.cloneNode(!0); 1650 ((t.style.position = "absolute"), 1651 (t.style.opacity = 0), 1652 t.removeAttribute("hidden"), 1653 e.parentNode.appendChild(t)); 1654 const i = t.scrollWidth, 1655 s = t.scrollHeight; 1656 return (O(t), { width: i, height: s }); 1657 }, 1658 showMenuPanel(e = "", t = !1) { 1659 const i = this.elements.container.querySelector( 1660 `#plyr-settings-${this.id}-${e}`, 1661 ); 1662 if (!S.element(i)) return; 1663 const s = i.parentNode, 1664 n = Array.from(s.children).find((e) => !e.hidden); 1665 if (K.transitions && !K.reducedMotion) { 1666 ((s.style.width = `${n.scrollWidth}px`), 1667 (s.style.height = `${n.scrollHeight}px`)); 1668 const e = Pe.getMenuSize.call(this, i), 1669 t = (e) => { 1670 e.target === s && 1671 ["width", "height"].includes(e.propertyName) && 1672 ((s.style.width = ""), 1673 (s.style.height = ""), 1674 J.call(this, s, E, t)); 1675 }; 1676 (X.call(this, s, E, t), 1677 (s.style.width = `${e.width}px`), 1678 (s.style.height = `${e.height}px`)); 1679 } 1680 (H(n, !0), H(i, !1), Pe.focusFirstMenuItem.call(this, i, t)); 1681 },
1682 setDownloadUrl() { 1683 const e = this.elements.buttons.download; 1684 S.element(e) && e.setAttribute("href", this.download); 1685 }, 1686 create(e) { 1687 const { 1688 bindMenuItemShortcuts: t, 1689 createButton: i, 1690 createProgress: s, 1691 createRange: n, 1692 createTime: a, 1693 setQualityMenu: l, 1694 setSpeedMenu: r, 1695 showMenuPanel: o, 1696 } = Pe; 1697 ((this.elements.controls = null), 1698 S.array(this.config.controls) && 1699 this.config.controls.includes("play-large") && 1700 this.elements.container.appendChild(i.call(this, "play-large"))); 1701 const c = $("div", D(this.config.selectors.controls.wrapper)); 1702 this.elements.controls = c; 1703 const u = { class: "plyr__controls__item" }; 1704 return ( 1705 se(S.array(this.config.controls) ? this.config.controls : []).forEach( 1706 (l) => { 1707 if ( 1708 ("restart" === l && c.appendChild(i.call(this, "restart", u)), 1709 "rewind" === l && c.appendChild(i.call(this, "rewind", u)), 1710 "play" === l && c.appendChild(i.call(this, "play", u)), 1711 "fast-forward" === l && 1712 c.appendChild(i.call(this, "fast-forward", u)), 1713 "progress" === l) 1714 ) { 1715 const t = $("div", { 1716 class: `${u.class} plyr__progress__container`, 1717 }), 1718 i = $("div", D(this.config.selectors.progress)); 1719 if ( 1720 (i.appendChild( 1721 n.call(this, "seek", { id: `plyr-seek-${e.id}` }), 1722 ), 1723 i.appendChild(s.call(this, "buffer")), 1724 this.config.tooltips.seek) 1725 ) { 1726 const e = $( 1727 "span", 1728 { class: this.config.classNames.tooltip }, 1729 "00:00", 1730 ); 1731 (i.appendChild(e), (this.elements.display.seekTooltip = e)); 1732 } 1733 ((this.elements.progress = i), 1734 t.appendChild(this.elements.progress), 1735 c.appendChild(t)); 1736 } 1737 if ( 1738 ("current-time" === l && 1739 c.appendChild(a.call(this, "currentTime", u)), 1740 "duration" === l && c.appendChild(a.call(this, "duration", u)), 1741 "mute" === l || "volume" === l) 1742 ) { 1743 let { volume: t } = this.elements; 1744 if ( 1745 ((S.element(t) && c.contains(t)) || 1746 ((t = $( 1747 "div", 1748 x({}, u, { class: `${u.class} plyr__volume`.trim() }), 1749 )), 1750 (this.elements.volume = t), 1751 c.appendChild(t)), 1752 "mute" === l && t.appendChild(i.call(this, "mute")), 1753 "volume" === l && !M.isIos && !M.isIPadOS) 1754 ) { 1755 const i = { max: 1, step: 0.05, value: this.config.volume }; 1756 t.appendChild( 1757 n.call(this, "volume", x(i, { id: `plyr-volume-${e.id}` })), 1758 ); 1759 } 1760 } 1761 if ( 1762 ("captions" === l && c.appendChild(i.call(this, "captions", u)), 1763 "settings" === l && !S.empty(this.config.settings)) 1764 ) { 1765 const s = $( 1766 "div", 1767 x({}, u, { 1768 class: `${u.class} plyr__menu`.trim(), 1769 hidden: "", 1770 }), 1771 ); 1772 s.appendChild( 1773 i.call(this, "settings", { 1774 "aria-haspopup": !0, 1775 "aria-controls": `plyr-settings-${e.id}`, 1776 "aria-expanded": !1, 1777 }), 1778 ); 1779 const n = $("div", { 1780 class: "plyr__menu__container", 1781 id: `plyr-settings-${e.id}`, 1782 hidden: "", 1783 }), 1784 a = $("div"), 1785 l = $("div", { id: `plyr-settings-${e.id}-home` }), 1786 r = $("div", { role: "menu" }); 1787 (l.appendChild(r), 1788 a.appendChild(l), 1789 (this.elements.settings.panels.home = l),
1790 this.config.settings.forEach((i) => { 1791 const s = $( 1792 "button", 1793 x(D(this.config.selectors.buttons.settings), { 1794 type: "button", 1795 class: `${this.config.classNames.control} ${this.config.classNames.control}--forward`, 1796 role: "menuitem", 1797 "aria-haspopup": !0, 1798 hidden: "", 1799 }), 1800 ); 1801 (t.call(this, s, i), 1802 X.call(this, s, "click", () => { 1803 o.call(this, i, !1); 1804 })); 1805 const n = $("span", null, ve.get(i, this.config)), 1806 l = $("span", { 1807 class: this.config.classNames.menu.value, 1808 }); 1809 ((l.innerHTML = e[i]), 1810 n.appendChild(l), 1811 s.appendChild(n), 1812 r.appendChild(s)); 1813 const c = $("div", { 1814 id: `plyr-settings-${e.id}-${i}`, 1815 hidden: "", 1816 }), 1817 u = $("button", { 1818 type: "button", 1819 class: `${this.config.classNames.control} ${this.config.classNames.control}--back`, 1820 }); 1821 (u.appendChild( 1822 $("span", { "aria-hidden": !0 }, ve.get(i, this.config)), 1823 ), 1824 u.appendChild( 1825 $( 1826 "span", 1827 { class: this.config.classNames.hidden }, 1828 ve.get("menuBack", this.config), 1829 ), 1830 ), 1831 X.call( 1832 this, 1833 c, 1834 "keydown", 1835 (e) => { 1836 "ArrowLeft" === e.key && 1837 (e.preventDefault(), 1838 e.stopPropagation(), 1839 o.call(this, "home", !0)); 1840 }, 1841 !1, 1842 ), 1843 X.call(this, u, "click", () => { 1844 o.call(this, "home", !1); 1845 }), 1846 c.appendChild(u), 1847 c.appendChild($("div", { role: "menu" })), 1848 a.appendChild(c), 1849 (this.elements.settings.buttons[i] = s), 1850 (this.elements.settings.panels[i] = c)); 1851 }), 1852 n.appendChild(a), 1853 s.appendChild(n), 1854 c.appendChild(s), 1855 (this.elements.settings.popup = n), 1856 (this.elements.settings.menu = s)); 1857 } 1858 if ( 1859 ("pip" === l && K.pip && c.appendChild(i.call(this, "pip", u)), 1860 "airplay" === l && 1861 K.airplay && 1862 c.appendChild(i.call(this, "airplay", u)), 1863 "download" === l) 1864 ) { 1865 const e = x({}, u, { 1866 element: "a", 1867 href: this.download, 1868 target: "_blank", 1869 }); 1870 this.isHTML5 && (e.download = ""); 1871 const { download: t } = this.config.urls; 1872 (!S.url(t) && 1873 this.isEmbed && 1874 x(e, { icon: `logo-${this.provider}`, label: this.provider }), 1875 c.appendChild(i.call(this, "download", e))); 1876 } 1877 "fullscreen" === l && 1878 c.appendChild(i.call(this, "fullscreen", u)); 1879 }, 1880 ), 1881 this.isHTML5 && l.call(this, de.getQualityOptions.call(this)), 1882 r.call(this), 1883 c 1884 ); 1885 }, 1886 inject() { 1887 if (this.config.loadSprite) { 1888 const e = Pe.getIconUrl.call(this); 1889 e.cors && ke(e.url, "sprite-plyr"); 1890 } 1891 this.id = Math.floor(1e4 * Math.random()); 1892 let e = null; 1893 this.elements.controls = null; 1894 const t = { 1895 id: this.id, 1896 seektime: this.config.seekTime, 1897 title: this.config.title, 1898 }; 1899 let i = !0; 1900 (S.function(this.config.controls) && 1901 (this.config.controls = this.config.controls.call(this, t)), 1902 this.config.controls || (this.config.controls = []),
1903 S.element(this.config.controls) || S.string(this.config.controls) 1904 ? (e = this.config.controls) 1905 : ((e = Pe.create.call(this, { 1906 id: this.id, 1907 seektime: this.config.seekTime, 1908 speed: this.speed, 1909 quality: this.quality, 1910 captions: xe.getLabel.call(this), 1911 })), 1912 (i = !1))); 1913 let s; 1914 (i && 1915 S.string(this.config.controls) && 1916 (e = ((e) => { 1917 let i = e; 1918 return ( 1919 Object.entries(t).forEach(([e, t]) => { 1920 i = pe(i, `{${e}}`, t); 1921 }), 1922 i 1923 ); 1924 })(e)), 1925 S.string(this.config.selectors.controls.container) && 1926 (s = document.querySelector( 1927 this.config.selectors.controls.container, 1928 )), 1929 S.element(s) || (s = this.elements.container)); 1930 if ( 1931 (s[S.element(e) ? "insertAdjacentElement" : "insertAdjacentHTML"]( 1932 "afterbegin", 1933 e, 1934 ), 1935 S.element(this.elements.controls) || Pe.findElements.call(this), 1936 !S.empty(this.elements.buttons)) 1937 ) { 1938 const e = (e) => { 1939 const t = this.config.classNames.controlPressed; 1940 (e.setAttribute("aria-pressed", "false"), 1941 Object.defineProperty(e, "pressed", { 1942 configurable: !0, 1943 enumerable: !0, 1944 get: () => F(e, t), 1945 set(i = !1) { 1946 (R(e, t, i), 1947 e.setAttribute("aria-pressed", i ? "true" : "false")); 1948 }, 1949 })); 1950 }; 1951 Object.values(this.elements.buttons) 1952 .filter(Boolean) 1953 .forEach((t) => { 1954 S.array(t) || S.nodeList(t) 1955 ? Array.from(t).filter(Boolean).forEach(e) 1956 : e(t); 1957 }); 1958 } 1959 if ((M.isEdge && P(s), this.config.tooltips.controls)) { 1960 const { classNames: e, selectors: t } = this.config, 1961 i = `${t.controls.wrapper} ${t.labels} .${e.hidden}`, 1962 s = U.call(this, i); 1963 Array.from(s).forEach((e) => { 1964 (R(e, this.config.classNames.hidden, !1), 1965 R(e, this.config.classNames.tooltip, !0)); 1966 }); 1967 } 1968 }, 1969 setMediaMetadata() { 1970 try { 1971 "mediaSession" in navigator && 1972 (navigator.mediaSession.metadata = new window.MediaMetadata({ 1973 title: this.config.mediaMetadata.title, 1974 artist: this.config.mediaMetadata.artist, 1975 album: this.config.mediaMetadata.album, 1976 artwork: this.config.mediaMetadata.artwork, 1977 })); 1978 } catch (e) {} 1979 }, 1980 setMarkers() { 1981 var e, t; 1982 if (!this.duration || this.elements.markers) return; 1983 const i = 1984 null === (e = this.config.markers) || 1985 void 0 === e || 1986 null === (t = e.points) || 1987 void 0 === t 1988 ? void 0 1989 : t.filter(({ time: e }) => e > 0 && e < this.duration); 1990 if (null == i || !i.length) return; 1991 const s = document.createDocumentFragment(), 1992 n = document.createDocumentFragment(); 1993 let a = null; 1994 const l = `${this.config.classNames.tooltip}--visible`, 1995 r = (e) => R(a, l, e); 1996 (i.forEach((e) => { 1997 const t = $("span", { class: this.config.classNames.marker }, ""), 1998 i = (e.time / this.duration) * 100 + "%"; 1999 (a && 2000 (t.addEventListener("mouseenter", () => { 2001 e.label || ((a.style.left = i), (a.innerHTML = e.label), r(!0)); 2002 }), 2003 t.addEventListener("mouseleave", () => { 2004 r(!1); 2005 })), 2006 t.addEventListener("click", () => { 2007 this.currentTime = e.time; 2008 }), 2009 (t.style.left = i), 2010 n.appendChild(t)); 2011 }), 2012 s.appendChild(n), 2013 this.config.tooltips.seek || 2014 ((a = $("span", { class: this.config.classNames.tooltip }, "")), 2015 s.appendChild(a)), 2016 (this.elements.markers = { points: n, tip: a }), 2017 this.elements.progress.appendChild(s)); 2018 }, 2019 }; 2020 function Me(e, t = !0) { 2021 let i = e; 2022 if (t) { 2023 const e = document.createElement("a"); 2024 ((e.href = i), (i = e.href)); 2025 }
2026 try { 2027 return new URL(i); 2028 } catch (e) { 2029 return null; 2030 } 2031 } 2032 function Ne(e) { 2033 const t = new URLSearchParams(); 2034 return ( 2035 S.object(e) && 2036 Object.entries(e).forEach(([e, i]) => { 2037 t.set(e, i); 2038 }), 2039 t 2040 ); 2041 } 2042 const xe = { 2043 setup() { 2044 if (!this.supported.ui) return; 2045 if ( 2046 !this.isVideo || 2047 this.isYouTube || 2048 (this.isHTML5 && !K.textTracks) 2049 ) 2050 return void ( 2051 S.array(this.config.controls) && 2052 this.config.controls.includes("settings") && 2053 this.config.settings.includes("captions") && 2054 Pe.setCaptionsMenu.call(this) 2055 ); 2056 var e, t; 2057 if ( 2058 (S.element(this.elements.captions) || 2059 ((this.elements.captions = $( 2060 "div", 2061 D(this.config.selectors.captions), 2062 )), 2063 this.elements.captions.setAttribute("dir", "auto"), 2064 (e = this.elements.captions), 2065 (t = this.elements.wrapper), 2066 S.element(e) && 2067 S.element(t) && 2068 t.parentNode.insertBefore(e, t.nextSibling)), 2069 M.isIE && window.URL) 2070 ) { 2071 const e = this.media.querySelectorAll("track"); 2072 Array.from(e).forEach((e) => { 2073 const t = e.getAttribute("src"), 2074 i = Me(t); 2075 null !== i && 2076 i.hostname !== window.location.href.hostname && 2077 ["http:", "https:"].includes(i.protocol) && 2078 Te(t, "blob") 2079 .then((t) => { 2080 e.setAttribute("src", window.URL.createObjectURL(t)); 2081 }) 2082 .catch(() => { 2083 O(e); 2084 }); 2085 }); 2086 } 2087 const i = se( 2088 ( 2089 navigator.languages || [ 2090 navigator.language || navigator.userLanguage || "en", 2091 ] 2092 ).map((e) => e.split("-")[0]), 2093 ); 2094 let s = ( 2095 this.storage.get("language") || 2096 this.config.captions.language || 2097 "auto" 2098 ).toLowerCase(); 2099 "auto" === s && ([s] = i); 2100 let n = this.storage.get("captions"); 2101 if ( 2102 (S.boolean(n) || ({ active: n } = this.config.captions), 2103 Object.assign(this.captions, { 2104 toggled: !1, 2105 active: n, 2106 language: s, 2107 languages: i, 2108 }), 2109 this.isHTML5) 2110 ) { 2111 const e = this.config.captions.update 2112 ? "addtrack removetrack" 2113 : "removetrack"; 2114 X.call(this, this.media.textTracks, e, xe.update.bind(this)); 2115 } 2116 setTimeout(xe.update.bind(this), 0); 2117 }, 2118 update() { 2119 const e = xe.getTracks.call(this, !0), 2120 { 2121 active: t, 2122 language: i, 2123 meta: s, 2124 currentTrackNode: n, 2125 } = this.captions, 2126 a = Boolean(e.find((e) => e.language === i)); 2127 (this.isHTML5 && 2128 this.isVideo && 2129 e 2130 .filter((e) => !s.get(e)) 2131 .forEach((e) => { 2132 (this.debug.log("Track added", e), 2133 s.set(e, { default: "showing" === e.mode }), 2134 "showing" === e.mode && (e.mode = "hidden"), 2135 X.call(this, e, "cuechange", () => xe.updateCues.call(this))); 2136 }), 2137 ((a && this.language !== i) || !e.includes(n)) && 2138 (xe.setLanguage.call(this, i), xe.toggle.call(this, t && a)), 2139 this.elements && 2140 R( 2141 this.elements.container, 2142 this.config.classNames.captions.enabled, 2143 !S.empty(e), 2144 ), 2145 S.array(this.config.controls) && 2146 this.config.controls.includes("settings") && 2147 this.config.settings.includes("captions") && 2148 Pe.setCaptionsMenu.call(this)); 2149 }, 2150 toggle(e, t = !0) { 2151 if (!this.supported.ui) return; 2152 const { toggled: i } = this.captions, 2153 s = this.config.classNames.captions.active, 2154 n = S.nullOrUndefined(e) ? !i : e; 2155 if (n !== i) { 2156 if ( 2157 (t || 2158 ((this.captions.active = n), this.storage.set({ captions: n })), 2159 !this.language && n && !t) 2160 ) { 2161 const e = xe.getTracks.call(this), 2162 t = xe.findTrack.call( 2163 this, 2164 [this.captions.language, ...this.captions.languages], 2165 !0, 2166 ); 2167 return ( 2168 (this.captions.language = t.language), 2169 void xe.set.call(this, e.indexOf(t)) 2170 ); 2171 } 2172 (this.elements.buttons.captions && 2173 (this.elements.buttons.captions.pressed = n), 2174 R(this.elements.container, s, n), 2175 (this.captions.toggled = n), 2176 Pe.updateSetting.call(this, "captions"), 2177 Z.call( 2178 this, 2179 this.media, 2180 n ? "captionsenabled" : "captionsdisabled", 2181 )); 2182 } 2183 setTimeout(() => { 2184 n && 2185 this.captions.toggled && 2186 (this.captions.currentTrackNode.mode = "hidden"); 2187 }); 2188 }, 2189 set(e, t = !0) { 2190 const i = xe.getTracks.call(this); 2191 if (-1 !== e) 2192 if (S.number(e))
2193 if (e in i) { 2194 if (this.captions.currentTrack !== e) { 2195 this.captions.currentTrack = e; 2196 const s = i[e], 2197 { language: n } = s || {}; 2198 ((this.captions.currentTrackNode = s), 2199 Pe.updateSetting.call(this, "captions"), 2200 t || 2201 ((this.captions.language = n), 2202 this.storage.set({ language: n })), 2203 this.isVimeo && this.embed.enableTextTrack(n), 2204 Z.call(this, this.media, "languagechange")); 2205 } 2206 (xe.toggle.call(this, !0, t), 2207 this.isHTML5 && this.isVideo && xe.updateCues.call(this)); 2208 } else this.debug.warn("Track not found", e); 2209 else this.debug.warn("Invalid caption argument", e); 2210 else xe.toggle.call(this, !1, t); 2211 }, 2212 setLanguage(e, t = !0) { 2213 if (!S.string(e)) 2214 return void this.debug.warn("Invalid language argument", e); 2215 const i = e.toLowerCase(); 2216 this.captions.language = i; 2217 const s = xe.getTracks.call(this), 2218 n = xe.findTrack.call(this, [i]); 2219 xe.set.call(this, s.indexOf(n), t); 2220 }, 2221 getTracks(e = !1) { 2222 return Array.from((this.media || {}).textTracks || []) 2223 .filter((t) => !this.isHTML5 || e || this.captions.meta.has(t)) 2224 .filter((e) => ["captions", "subtitles"].includes(e.kind)); 2225 }, 2226 findTrack(e, t = !1) { 2227 const i = xe.getTracks.call(this), 2228 s = (e) => Number((this.captions.meta.get(e) || {}).default), 2229 n = Array.from(i).sort((e, t) => s(t) - s(e)); 2230 let a; 2231 return ( 2232 e.every((e) => ((a = n.find((t) => t.language === e)), !a)), 2233 a || (t ? n[0] : void 0) 2234 ); 2235 }, 2236 getCurrentTrack() { 2237 return xe.getTracks.call(this)[this.currentTrack]; 2238 }, 2239 getLabel(e) { 2240 let t = e; 2241 return ( 2242 !S.track(t) && 2243 K.textTracks && 2244 this.captions.toggled && 2245 (t = xe.getCurrentTrack.call(this)), 2246 S.track(t) 2247 ? S.empty(t.label) 2248 ? S.empty(t.language) 2249 ? ve.get("enabled", this.config) 2250 : e.language.toUpperCase() 2251 : t.label 2252 : ve.get("disabled", this.config) 2253 ); 2254 }, 2255 updateCues(e) { 2256 if (!this.supported.ui) return; 2257 if (!S.element(this.elements.captions)) 2258 return void this.debug.warn("No captions element to render to"); 2259 if (!S.nullOrUndefined(e) && !Array.isArray(e)) 2260 return void this.debug.warn("updateCues: Invalid input", e); 2261 let t = e; 2262 if (!t) { 2263 const e = xe.getCurrentTrack.call(this); 2264 t = Array.from((e || {}).activeCues || []) 2265 .map((e) => e.getCueAsHTML()) 2266 .map(ye); 2267 } 2268 const i = t.map((e) => e.trim()).join("\n"); 2269 if (i !== this.elements.captions.innerHTML) { 2270 j(this.elements.captions); 2271 const e = $("span", D(this.config.selectors.caption)); 2272 ((e.innerHTML = i), 2273 this.elements.captions.appendChild(e), 2274 Z.call(this, this.media, "cuechange")); 2275 } 2276 }, 2277 }, 2278 Le = { 2279 enabled: !0, 2280 title: "", 2281 debug: !1, 2282 autoplay: !1, 2283 autopause: !0, 2284 playsinline: !0, 2285 seekTime: 10, 2286 volume: 1, 2287 muted: !1, 2288 duration: null, 2289 displayDuration: !0, 2290 invertTime: !0, 2291 toggleInvert: !0, 2292 ratio: null, 2293 clickToPlay: !0, 2294 hideControls: !0, 2295 resetOnEnd: !1, 2296 disableContextMenu: !0, 2297 loadSprite: !0, 2298 iconPrefix: "plyr", 2299 iconUrl: "https://cdn.plyr.io/3.7.8/plyr.svg", 2300 blankVideo: "https://cdn.plyr.io/static/blank.mp4", 2301 quality: { 2302 default: 576, 2303 options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240], 2304 forced: !1, 2305 onChange: null, 2306 }, 2307 loop: { active: !1 }, 2308 speed: { selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 4] }, 2309 keyboard: { focused: !0, global: !1 },
2310 tooltips: { controls: !1, seek: !0 }, 2311 captions: { active: !1, language: "auto", update: !1 }, 2312 fullscreen: { enabled: !0, fallback: !0, iosNative: !1 }, 2313 storage: { enabled: !0, key: "plyr" }, 2314 controls: [ 2315 "play-large", 2316 "play", 2317 "progress", 2318 "current-time", 2319 "mute", 2320 "volume", 2321 "captions", 2322 "settings", 2323 "pip", 2324 "airplay", 2325 "fullscreen", 2326 ], 2327 settings: ["captions", "quality", "speed"], 2328 i18n: { 2329 restart: "Restart", 2330 rewind: "Rewind {seektime}s", 2331 play: "Play", 2332 pause: "Pause", 2333 fastForward: "Forward {seektime}s", 2334 seek: "Seek", 2335 seekLabel: "{currentTime} of {duration}", 2336 played: "Played", 2337 buffered: "Buffered", 2338 currentTime: "Current time", 2339 duration: "Duration", 2340 volume: "Volume", 2341 mute: "Mute", 2342 unmute: "Unmute", 2343 enableCaptions: "Enable captions", 2344 disableCaptions: "Disable captions", 2345 download: "Download", 2346 enterFullscreen: "Enter fullscreen", 2347 exitFullscreen: "Exit fullscreen", 2348 frameTitle: "Player for {title}", 2349 captions: "Captions", 2350 settings: "Settings", 2351 pip: "PIP", 2352 menuBack: "Go back to previous menu", 2353 speed: "Speed", 2354 normal: "Normal", 2355 quality: "Quality", 2356 loop: "Loop", 2357 start: "Start", 2358 end: "End", 2359 all: "All", 2360 reset: "Reset", 2361 disabled: "Disabled", 2362 enabled: "Enabled", 2363 advertisement: "Ad", 2364 qualityBadge: { 2365 2160: "4K", 2366 1440: "HD", 2367 1080: "HD", 2368 720: "HD", 2369 576: "SD", 2370 480: "SD", 2371 }, 2372 }, 2373 urls: { 2374 download: null, 2375 vimeo: { 2376 sdk: "https://player.vimeo.com/api/player.js", 2377 iframe: "https://player.vimeo.com/video/{0}?{1}", 2378 api: "https://vimeo.com/api/oembed.json?url={0}", 2379 }, 2380 youtube: { 2381 sdk: "https://www.youtube.com/iframe_api", 2382 api: "https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}", 2383 }, 2384 googleIMA: { 2385 sdk: "https://imasdk.googleapis.com/js/sdkloader/ima3.js", 2386 }, 2387 }, 2388 listeners: { 2389 seek: null, 2390 play: null, 2391 pause: null, 2392 restart: null, 2393 rewind: null, 2394 fastForward: null, 2395 mute: null, 2396 volume: null, 2397 captions: null, 2398 download: null, 2399 fullscreen: null, 2400 pip: null, 2401 airplay: null, 2402 speed: null, 2403 quality: null, 2404 loop: null, 2405 language: null, 2406 }, 2407 events: [ 2408 "ended", 2409 "progress", 2410 "stalled", 2411 "playing", 2412 "waiting", 2413 "canplay", 2414 "canplaythrough", 2415 "loadstart", 2416 "loadeddata", 2417 "loadedmetadata", 2418 "timeupdate", 2419 "volumechange", 2420 "play", 2421 "pause", 2422 "error", 2423 "seeking", 2424 "seeked", 2425 "emptied", 2426 "ratechange", 2427 "cuechange", 2428 "download", 2429 "enterfullscreen", 2430 "exitfullscreen", 2431 "captionsenabled", 2432 "captionsdisabled", 2433 "languagechange", 2434 "controlshidden", 2435 "controlsshown", 2436 "ready", 2437 "statechange", 2438 "qualitychange", 2439 "adsloaded", 2440 "adscontentpause", 2441 "adscontentresume", 2442 "adstarted", 2443 "adsmidpoint", 2444 "adscomplete", 2445 "adsallcomplete", 2446 "adsimpression", 2447 "adsclick", 2448 ], 2449 selectors: { 2450 editable: "input, textarea, select, [contenteditable]", 2451 container: ".plyr", 2452 controls: { container: null, wrapper: ".plyr__controls" }, 2453 labels: "[data-plyr]", 2454 buttons: { 2455 play: '[data-plyr="play"]', 2456 pause: '[data-plyr="pause"]', 2457 restart: '[data-plyr="restart"]', 2458 rewind: '[data-plyr="rewind"]', 2459 fastForward: '[data-plyr="fast-forward"]', 2460 mute: '[data-plyr="mute"]', 2461 captions: '[data-plyr="captions"]', 2462 download: '[data-plyr="download"]', 2463 fullscreen: '[data-plyr="fullscreen"]', 2464 pip: '[data-plyr="pip"]', 2465 airplay: '[data-plyr="airplay"]', 2466 settings: '[data-plyr="settings"]', 2467 loop: '[data-plyr="loop"]', 2468 }, 2469 inputs: { 2470 seek: '[data-plyr="seek"]', 2471 volume: '[data-plyr="volume"]', 2472 speed: '[data-plyr="speed"]', 2473 language: '[data-plyr="language"]',
2474 quality: '[data-plyr="quality"]', 2475 }, 2476 display: { 2477 currentTime: ".plyr__time--current", 2478 duration: ".plyr__time--duration", 2479 buffer: ".plyr__progress__buffer", 2480 loop: ".plyr__progress__loop", 2481 volume: ".plyr__volume--display", 2482 }, 2483 progress: ".plyr__progress", 2484 captions: ".plyr__captions", 2485 caption: ".plyr__caption", 2486 }, 2487 classNames: { 2488 type: "plyr--{0}", 2489 provider: "plyr--{0}", 2490 video: "plyr__video-wrapper", 2491 embed: "plyr__video-embed", 2492 videoFixedRatio: "plyr__video-wrapper--fixed-ratio", 2493 embedContainer: "plyr__video-embed__container", 2494 poster: "plyr__poster", 2495 posterEnabled: "plyr__poster-enabled", 2496 ads: "plyr__ads", 2497 control: "plyr__control", 2498 controlPressed: "plyr__control--pressed", 2499 playing: "plyr--playing", 2500 paused: "plyr--paused", 2501 stopped: "plyr--stopped", 2502 loading: "plyr--loading", 2503 hover: "plyr--hover", 2504 tooltip: "plyr__tooltip", 2505 cues: "plyr__cues", 2506 marker: "plyr__progress__marker", 2507 hidden: "plyr__sr-only", 2508 hideControls: "plyr--hide-controls", 2509 isTouch: "plyr--is-touch", 2510 uiSupported: "plyr--full-ui", 2511 noTransition: "plyr--no-transition", 2512 display: { time: "plyr__time" }, 2513 menu: { 2514 value: "plyr__menu__value", 2515 badge: "plyr__badge", 2516 open: "plyr--menu-open", 2517 }, 2518 captions: { 2519 enabled: "plyr--captions-enabled", 2520 active: "plyr--captions-active", 2521 }, 2522 fullscreen: { 2523 enabled: "plyr--fullscreen-enabled", 2524 fallback: "plyr--fullscreen-fallback", 2525 }, 2526 pip: { supported: "plyr--pip-supported", active: "plyr--pip-active" }, 2527 airplay: { 2528 supported: "plyr--airplay-supported", 2529 active: "plyr--airplay-active", 2530 }, 2531 previewThumbnails: { 2532 thumbContainer: "plyr__preview-thumb", 2533 thumbContainerShown: "plyr__preview-thumb--is-shown", 2534 imageContainer: "plyr__preview-thumb__image-container", 2535 timeContainer: "plyr__preview-thumb__time-container", 2536 scrubbingContainer: "plyr__preview-scrubbing", 2537 scrubbingContainerShown: "plyr__preview-scrubbing--is-shown", 2538 }, 2539 }, 2540 attributes: { 2541 embed: { 2542 provider: "data-plyr-provider", 2543 id: "data-plyr-embed-id", 2544 hash: "data-plyr-embed-hash", 2545 }, 2546 }, 2547 ads: { enabled: !1, publisherId: "", tagUrl: "" }, 2548 previewThumbnails: { enabled: !1, src: "" }, 2549 vimeo: { 2550 byline: !1, 2551 portrait: !1, 2552 title: !1, 2553 speed: !0, 2554 transparent: !1, 2555 customControls: !0, 2556 referrerPolicy: null, 2557 premium: !1, 2558 }, 2559 youtube: { 2560 rel: 0, 2561 showinfo: 0, 2562 iv_load_policy: 3, 2563 modestbranding: 1, 2564 customControls: !0, 2565 noCookie: !1, 2566 }, 2567 mediaMetadata: { title: "", artist: "", album: "", artwork: [] }, 2568 markers: { enabled: !1, points: [] }, 2569 }, 2570 Ie = "picture-in-picture", 2571 $e = "inline", 2572 _e = { html5: "html5", youtube: "youtube", vimeo: "vimeo" }, 2573 Oe = "audio", 2574 je = "video"; 2575 const qe = () => {}; 2576 class De { 2577 constructor(e = !1) { 2578 ((this.enabled = window.console && e), 2579 this.enabled && this.log("Debugging enabled")); 2580 } 2581 get log() { 2582 return this.enabled 2583 ? Function.prototype.bind.call(console.log, console) 2584 : qe; 2585 } 2586 get warn() { 2587 return this.enabled 2588 ? Function.prototype.bind.call(console.warn, console) 2589 : qe; 2590 } 2591 get error() { 2592 return this.enabled 2593 ? Function.prototype.bind.call(console.error, console) 2594 : qe; 2595 } 2596 } 2597 class He { 2598 constructor(t) {
2599 (e(this, "onChange", () => { 2600 if (!this.supported) return; 2601 const e = this.player.elements.buttons.fullscreen; 2602 S.element(e) && (e.pressed = this.active); 2603 const t = 2604 this.target === this.player.media 2605 ? this.target 2606 : this.player.elements.container; 2607 Z.call( 2608 this.player, 2609 t, 2610 this.active ? "enterfullscreen" : "exitfullscreen", 2611 !0, 2612 ); 2613 }), 2614 e(this, "toggleFallback", (e = !1) => { 2615 if ( 2616 (e 2617 ? (this.scrollPosition = { 2618 x: window.scrollX ?? 0, 2619 y: window.scrollY ?? 0, 2620 }) 2621 : window.scrollTo(this.scrollPosition.x, this.scrollPosition.y), 2622 (document.body.style.overflow = e ? "hidden" : ""), 2623 R( 2624 this.target, 2625 this.player.config.classNames.fullscreen.fallback, 2626 e, 2627 ), 2628 M.isIos) 2629 ) { 2630 let t = document.head.querySelector('meta[name="viewport"]'); 2631 const i = "viewport-fit=cover"; 2632 t || 2633 ((t = document.createElement("meta")), 2634 t.setAttribute("name", "viewport")); 2635 const s = S.string(t.content) && t.content.includes(i); 2636 e 2637 ? ((this.cleanupViewport = !s), s || (t.content += `,${i}`)) 2638 : this.cleanupViewport && 2639 (t.content = t.content 2640 .split(",") 2641 .filter((e) => e.trim() !== i) 2642 .join(",")); 2643 } 2644 this.onChange(); 2645 }), 2646 e(this, "trapFocus", (e) => { 2647 if (M.isIos || M.isIPadOS || !this.active || "Tab" !== e.key) 2648 return; 2649 const t = document.activeElement, 2650 i = U.call( 2651 this.player, 2652 "a[href], button:not(:disabled), input:not(:disabled), [tabindex]", 2653 ), 2654 [s] = i, 2655 n = i[i.length - 1]; 2656 t !== n || e.shiftKey 2657 ? t === s && e.shiftKey && (n.focus(), e.preventDefault()) 2658 : (s.focus(), e.preventDefault()); 2659 }), 2660 e(this, "update", () => { 2661 if (this.supported) { 2662 let e; 2663 ((e = this.forceFallback 2664 ? "Fallback (forced)" 2665 : He.nativeSupported 2666 ? "Native" 2667 : "Fallback"), 2668 this.player.debug.log(`${e} fullscreen enabled`)); 2669 } else 2670 this.player.debug.log( 2671 "Fullscreen not supported and fallback disabled", 2672 ); 2673 R( 2674 this.player.elements.container, 2675 this.player.config.classNames.fullscreen.enabled, 2676 this.supported, 2677 ); 2678 }), 2679 e(this, "enter", () => { 2680 this.supported && 2681 (M.isIos && this.player.config.fullscreen.iosNative 2682 ? this.player.isVimeo 2683 ? this.player.embed.requestFullscreen() 2684 : this.target.webkitEnterFullscreen() 2685 : !He.nativeSupported || this.forceFallback 2686 ? this.toggleFallback(!0) 2687 : this.prefix 2688 ? S.empty(this.prefix) || 2689 this.target[`${this.prefix}Request${this.property}`]() 2690 : this.target.requestFullscreen({ navigationUI: "hide" })); 2691 }), 2692 e(this, "exit", () => { 2693 if (this.supported) 2694 if (M.isIos && this.player.config.fullscreen.iosNative) 2695 (this.player.isVimeo 2696 ? this.player.embed.exitFullscreen() 2697 : this.target.webkitEnterFullscreen(), 2698 ie(this.player.play())); 2699 else if (!He.nativeSupported || this.forceFallback) 2700 this.toggleFallback(!1); 2701 else if (this.prefix) { 2702 if (!S.empty(this.prefix)) { 2703 const e = "moz" === this.prefix ? "Cancel" : "Exit"; 2704 document[`${this.prefix}${e}${this.property}`](); 2705 } 2706 } else 2707 (document.cancelFullScreen || document.exitFullscreen).call( 2708 document, 2709 ); 2710 }), 2711 e(this, "toggle", () => { 2712 this.active ? this.exit() : this.enter(); 2713 }), 2714 (this.player = t), 2715 (this.prefix = He.prefix), 2716 (this.property = He.property), 2717 (this.scrollPosition = { x: 0, y: 0 }), 2718 (this.forceFallback = "force" === t.config.fullscreen.fallback), 2719 (this.player.elements.fullscreen = 2720 t.config.fullscreen.container && 2721 (function (e, t) { 2722 const { prototype: i } = Element; 2723 return ( 2724 i.closest || 2725 function () { 2726 let e = this; 2727 do { 2728 if (V.matches(e, t)) return e; 2729 e = e.parentElement || e.parentNode; 2730 } while (null !== e && 1 === e.nodeType); 2731 return null; 2732 } 2733 ).call(e, t); 2734 })(this.player.elements.container, t.config.fullscreen.container)), 2735 X.call( 2736 this.player, 2737 document, 2738 "ms" === this.prefix 2739 ? "MSFullscreenChange" 2740 : `${this.prefix}fullscreenchange`, 2741 () => { 2742 this.onChange(); 2743 }, 2744 ), 2745 X.call( 2746 this.player, 2747 this.player.elements.container, 2748 "dblclick", 2749 (e) => {
2750 (S.element(this.player.elements.controls) && 2751 this.player.elements.controls.contains(e.target)) || 2752 this.player.listeners.proxy(e, this.toggle, "fullscreen"); 2753 }, 2754 ), 2755 X.call(this, this.player.elements.container, "keydown", (e) => 2756 this.trapFocus(e), 2757 ), 2758 this.update()); 2759 } 2760 static get nativeSupported() { 2761 return !!( 2762 document.fullscreenEnabled || 2763 document.webkitFullscreenEnabled || 2764 document.mozFullScreenEnabled || 2765 document.msFullscreenEnabled 2766 ); 2767 } 2768 get useNative() { 2769 return He.nativeSupported && !this.forceFallback; 2770 } 2771 static get prefix() { 2772 if (S.function(document.exitFullscreen)) return ""; 2773 let e = ""; 2774 return ( 2775 ["webkit", "moz", "ms"].some( 2776 (t) => 2777 !( 2778 !S.function(document[`${t}ExitFullscreen`]) && 2779 !S.function(document[`${t}CancelFullScreen`]) 2780 ) && ((e = t), !0), 2781 ), 2782 e 2783 ); 2784 } 2785 static get property() { 2786 return "moz" === this.prefix ? "FullScreen" : "Fullscreen"; 2787 } 2788 get supported() { 2789 return [ 2790 this.player.config.fullscreen.enabled, 2791 this.player.isVideo, 2792 He.nativeSupported || this.player.config.fullscreen.fallback, 2793 !this.player.isYouTube || 2794 He.nativeSupported || 2795 !M.isIos || 2796 (this.player.config.playsinline && 2797 !this.player.config.fullscreen.iosNative), 2798 ].every(Boolean); 2799 } 2800 get active() { 2801 if (!this.supported) return !1; 2802 if (!He.nativeSupported || this.forceFallback) 2803 return F( 2804 this.target, 2805 this.player.config.classNames.fullscreen.fallback, 2806 ); 2807 const e = this.prefix 2808 ? this.target.getRootNode()[`${this.prefix}${this.property}Element`] 2809 : this.target.getRootNode().fullscreenElement; 2810 return e && e.shadowRoot 2811 ? e === this.target.getRootNode().host 2812 : e === this.target; 2813 } 2814 get target() { 2815 return M.isIos && this.player.config.fullscreen.iosNative 2816 ? this.player.media 2817 : (this.player.elements.fullscreen ?? this.player.elements.container); 2818 } 2819 } 2820 function Re(e, t = 1) { 2821 return new Promise((i, s) => { 2822 const n = new Image(), 2823 a = () => { 2824 (delete n.onload, 2825 delete n.onerror, 2826 (n.naturalWidth >= t ? i : s)(n)); 2827 }; 2828 Object.assign(n, { onload: a, onerror: a, src: e }); 2829 }); 2830 } 2831 const Fe = { 2832 addStyleHook() { 2833 (R( 2834 this.elements.container, 2835 this.config.selectors.container.replace(".", ""), 2836 !0, 2837 ), 2838 R( 2839 this.elements.container, 2840 this.config.classNames.uiSupported, 2841 this.supported.ui, 2842 )); 2843 }, 2844 toggleNativeControls(e = !1) { 2845 e && this.isHTML5 2846 ? this.media.setAttribute("controls", "") 2847 : this.media.removeAttribute("controls"); 2848 }, 2849 build() { 2850 if ((this.listeners.media(), !this.supported.ui)) 2851 return ( 2852 this.debug.warn( 2853 `Basic support only for ${this.provider} ${this.type}`, 2854 ), 2855 void Fe.toggleNativeControls.call(this, !0) 2856 ); 2857 (S.element(this.elements.controls) || 2858 (Pe.inject.call(this), this.listeners.controls()), 2859 Fe.toggleNativeControls.call(this), 2860 this.isHTML5 && xe.setup.call(this), 2861 (this.volume = null), 2862 (this.muted = null), 2863 (this.loop = null),
2864 (this.quality = null), 2865 (this.speed = null), 2866 Pe.updateVolume.call(this), 2867 Pe.timeUpdate.call(this), 2868 Pe.durationUpdate.call(this), 2869 Fe.checkPlaying.call(this), 2870 R( 2871 this.elements.container, 2872 this.config.classNames.pip.supported, 2873 K.pip && this.isHTML5 && this.isVideo, 2874 ), 2875 R( 2876 this.elements.container, 2877 this.config.classNames.airplay.supported, 2878 K.airplay && this.isHTML5, 2879 ), 2880 R( 2881 this.elements.container, 2882 this.config.classNames.isTouch, 2883 this.touch, 2884 ), 2885 (this.ready = !0), 2886 setTimeout(() => { 2887 Z.call(this, this.media, "ready"); 2888 }, 0), 2889 Fe.setTitle.call(this), 2890 this.poster && 2891 Fe.setPoster.call(this, this.poster, !1).catch(() => {}), 2892 this.config.duration && Pe.durationUpdate.call(this), 2893 this.config.mediaMetadata && Pe.setMediaMetadata.call(this)); 2894 }, 2895 setTitle() { 2896 let e = ve.get("play", this.config); 2897 if ( 2898 (S.string(this.config.title) && 2899 !S.empty(this.config.title) && 2900 (e += `, ${this.config.title}`), 2901 Array.from(this.elements.buttons.play || []).forEach((t) => { 2902 t.setAttribute("aria-label", e); 2903 }), 2904 this.isEmbed) 2905 ) { 2906 const e = B.call(this, "iframe"); 2907 if (!S.element(e)) return; 2908 const t = S.empty(this.config.title) ? "video" : this.config.title, 2909 i = ve.get("frameTitle", this.config); 2910 e.setAttribute("title", i.replace("{title}", t)); 2911 } 2912 }, 2913 togglePoster(e) { 2914 R(this.elements.container, this.config.classNames.posterEnabled, e); 2915 }, 2916 setPoster(e, t = !0) { 2917 return t && this.poster 2918 ? Promise.reject(new Error("Poster already set")) 2919 : (this.media.setAttribute("data-poster", e), 2920 this.elements.poster.removeAttribute("hidden"), 2921 te 2922 .call(this) 2923 .then(() => Re(e)) 2924 .catch((t) => { 2925 throw (e === this.poster && Fe.togglePoster.call(this, !1), t); 2926 }) 2927 .then(() => { 2928 if (e !== this.poster) 2929 throw new Error( 2930 "setPoster cancelled by later call to setPoster", 2931 ); 2932 }) 2933 .then( 2934 () => ( 2935 Object.assign(this.elements.poster.style, { 2936 backgroundImage: `url('${e}')`, 2937 backgroundSize: "", 2938 }), 2939 Fe.togglePoster.call(this, !0), 2940 e 2941 ), 2942 )); 2943 }, 2944 checkPlaying(e) { 2945 (R( 2946 this.elements.container, 2947 this.config.classNames.playing, 2948 this.playing, 2949 ), 2950 R( 2951 this.elements.container, 2952 this.config.classNames.paused, 2953 this.paused, 2954 ), 2955 R( 2956 this.elements.container, 2957 this.config.classNames.stopped, 2958 this.stopped, 2959 ), 2960 Array.from(this.elements.buttons.play || []).forEach((e) => { 2961 (Object.assign(e, { pressed: this.playing }), 2962 e.setAttribute( 2963 "aria-label", 2964 ve.get(this.playing ? "pause" : "play", this.config), 2965 )); 2966 }), 2967 (S.event(e) && "timeupdate" === e.type) || 2968 Fe.toggleControls.call(this)); 2969 }, 2970 checkLoading(e) { 2971 ((this.loading = ["stalled", "waiting"].includes(e.type)), 2972 clearTimeout(this.timers.loading), 2973 (this.timers.loading = setTimeout( 2974 () => { 2975 (R( 2976 this.elements.container, 2977 this.config.classNames.loading, 2978 this.loading, 2979 ), 2980 Fe.toggleControls.call(this)); 2981 }, 2982 this.loading ? 250 : 0, 2983 ))); 2984 }, 2985 toggleControls(e) { 2986 const { controls: t } = this.elements; 2987 if (t && this.config.hideControls) { 2988 const i = this.touch && this.lastSeekTime + 2e3 > Date.now(); 2989 this.toggleControls( 2990 Boolean( 2991 e || this.loading || this.paused || t.pressed || t.hover || i, 2992 ), 2993 ); 2994 } 2995 }, 2996 migrateStyles() { 2997 (Object.values({ ...this.media.style }) 2998 .filter((e) => !S.empty(e) && S.string(e) && e.startsWith("--plyr")) 2999 .forEach((e) => { 3000 (this.elements.container.style.setProperty( 3001 e, 3002 this.media.style.getPropertyValue(e), 3003 ), 3004 this.media.style.removeProperty(e)); 3005 }), 3006 S.empty(this.media.style) && this.media.removeAttribute("style")); 3007 }, 3008 }; 3009 class Ve { 3010 constructor(t) { 3011 (e(this, "firstTouch", () => { 3012 const { player: e } = this, 3013 { elements: t } = e; 3014 ((e.touch = !0), R(t.container, e.config.classNames.isTouch, !0)); 3015 }), 3016 e(this, "global", (e = !0) => { 3017 const { player: t } = this; 3018 (t.config.keyboard.global && 3019 Q.call(t, window, "keydown keyup", this.handleKey, e, !1), 3020 Q.call(t, document.body, "click", this.toggleMenu, e), 3021 G.call(t, document.body, "touchstart", this.firstTouch)); 3022 }), 3023 e(this, "container", () => { 3024 const { player: e } = this,
3025 { config: t, elements: i, timers: s } = e; 3026 (!t.keyboard.global && 3027 t.keyboard.focused && 3028 X.call(e, i.container, "keydown keyup", this.handleKey, !1), 3029 X.call( 3030 e, 3031 i.container, 3032 "mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen", 3033 (t) => { 3034 const { controls: n } = i; 3035 n && 3036 "enterfullscreen" === t.type && 3037 ((n.pressed = !1), (n.hover = !1)); 3038 let a = 0; 3039 (["touchstart", "touchmove", "mousemove"].includes(t.type) && 3040 (Fe.toggleControls.call(e, !0), (a = e.touch ? 3e3 : 2e3)), 3041 clearTimeout(s.controls), 3042 (s.controls = setTimeout( 3043 () => Fe.toggleControls.call(e, !1), 3044 a, 3045 ))); 3046 }, 3047 )); 3048 const n = () => { 3049 if (!e.isVimeo || e.config.vimeo.premium) return; 3050 const t = i.wrapper, 3051 { active: s } = e.fullscreen, 3052 [n, a] = ce.call(e), 3053 l = ae(`aspect-ratio: ${n} / ${a}`); 3054 if (!s) 3055 return void (l 3056 ? ((t.style.width = null), (t.style.height = null)) 3057 : ((t.style.maxWidth = null), (t.style.margin = null))); 3058 const [r, o] = [ 3059 Math.max( 3060 document.documentElement.clientWidth || 0, 3061 window.innerWidth || 0, 3062 ), 3063 Math.max( 3064 document.documentElement.clientHeight || 0, 3065 window.innerHeight || 0, 3066 ), 3067 ], 3068 c = r / o > n / a; 3069 l 3070 ? ((t.style.width = c ? "auto" : "100%"), 3071 (t.style.height = c ? "100%" : "auto")) 3072 : ((t.style.maxWidth = c ? (o / a) * n + "px" : null), 3073 (t.style.margin = c ? "0 auto" : null)); 3074 }, 3075 a = () => { 3076 (clearTimeout(s.resized), (s.resized = setTimeout(n, 50))); 3077 }; 3078 X.call(e, i.container, "enterfullscreen exitfullscreen", (t) => { 3079 const { target: s } = e.fullscreen; 3080 if (s !== i.container) return; 3081 if (!e.isEmbed && S.empty(e.config.ratio)) return; 3082 n(); 3083 ("enterfullscreen" === t.type ? X : J).call( 3084 e, 3085 window, 3086 "resize", 3087 a, 3088 ); 3089 }); 3090 }), 3091 e(this, "media", () => { 3092 const { player: e } = this, 3093 { elements: t } = e; 3094 if ( 3095 (X.call(e, e.media, "timeupdate seeking seeked", (t) => 3096 Pe.timeUpdate.call(e, t), 3097 ), 3098 X.call( 3099 e, 3100 e.media, 3101 "durationchange loadeddata loadedmetadata", 3102 (t) => Pe.durationUpdate.call(e, t), 3103 ), 3104 X.call(e, e.media, "ended", () => { 3105 e.isHTML5 && 3106 e.isVideo && 3107 e.config.resetOnEnd && 3108 (e.restart(), e.pause()); 3109 }), 3110 X.call(e, e.media, "progress playing seeking seeked", (t) => 3111 Pe.updateProgress.call(e, t), 3112 ), 3113 X.call(e, e.media, "volumechange", (t) => 3114 Pe.updateVolume.call(e, t), 3115 ), 3116 X.call( 3117 e, 3118 e.media, 3119 "playing play pause ended emptied timeupdate", 3120 (t) => Fe.checkPlaying.call(e, t), 3121 ), 3122 X.call(e, e.media, "waiting canplay seeked playing", (t) => 3123 Fe.checkLoading.call(e, t), 3124 ), 3125 e.supported.ui && e.config.clickToPlay && !e.isAudio) 3126 ) { 3127 const i = B.call(e, `.${e.config.classNames.video}`);
3128 if (!S.element(i)) return; 3129 X.call(e, t.container, "click", (s) => { 3130 ([t.container, i].includes(s.target) || i.contains(s.target)) && 3131 ((e.touch && e.config.hideControls) || 3132 (e.ended 3133 ? (this.proxy(s, e.restart, "restart"), 3134 this.proxy( 3135 s, 3136 () => { 3137 ie(e.play()); 3138 }, 3139 "play", 3140 )) 3141 : this.proxy( 3142 s, 3143 () => { 3144 ie(e.togglePlay()); 3145 }, 3146 "play", 3147 ))); 3148 }); 3149 } 3150 (e.supported.ui && 3151 e.config.disableContextMenu && 3152 X.call( 3153 e, 3154 t.wrapper, 3155 "contextmenu", 3156 (e) => { 3157 e.preventDefault(); 3158 }, 3159 !1, 3160 ), 3161 X.call(e, e.media, "volumechange", () => { 3162 e.storage.set({ volume: e.volume, muted: e.muted }); 3163 }), 3164 X.call(e, e.media, "ratechange", () => { 3165 (Pe.updateSetting.call(e, "speed"), 3166 e.storage.set({ speed: e.speed })); 3167 }), 3168 X.call(e, e.media, "qualitychange", (t) => { 3169 Pe.updateSetting.call(e, "quality", null, t.detail.quality); 3170 }), 3171 X.call(e, e.media, "ready qualitychange", () => { 3172 Pe.setDownloadUrl.call(e); 3173 })); 3174 const i = e.config.events.concat(["keyup", "keydown"]).join(" "); 3175 X.call(e, e.media, i, (i) => { 3176 let { detail: s = {} } = i; 3177 ("error" === i.type && (s = e.media.error), 3178 Z.call(e, t.container, i.type, !0, s)); 3179 }); 3180 }), 3181 e(this, "proxy", (e, t, i) => { 3182 const { player: s } = this, 3183 n = s.config.listeners[i]; 3184 let a = !0; 3185 (S.function(n) && (a = n.call(s, e)), 3186 !1 !== a && S.function(t) && t.call(s, e)); 3187 }), 3188 e(this, "bind", (e, t, i, s, n = !0) => { 3189 const { player: a } = this, 3190 l = a.config.listeners[s], 3191 r = S.function(l); 3192 X.call(a, e, t, (e) => this.proxy(e, i, s), n && !r); 3193 }), 3194 e(this, "controls", () => { 3195 const { player: e } = this, 3196 { elements: t } = e, 3197 i = M.isIE ? "change" : "input"; 3198 if ( 3199 (t.buttons.play && 3200 Array.from(t.buttons.play).forEach((t) => { 3201 this.bind( 3202 t, 3203 "click", 3204 () => { 3205 ie(e.togglePlay()); 3206 }, 3207 "play", 3208 ); 3209 }), 3210 this.bind(t.buttons.restart, "click", e.restart, "restart"), 3211 this.bind( 3212 t.buttons.rewind, 3213 "click", 3214 () => { 3215 ((e.lastSeekTime = Date.now()), e.rewind()); 3216 }, 3217 "rewind", 3218 ), 3219 this.bind( 3220 t.buttons.fastForward, 3221 "click", 3222 () => { 3223 ((e.lastSeekTime = Date.now()), e.forward()); 3224 }, 3225 "fastForward", 3226 ), 3227 this.bind( 3228 t.buttons.mute, 3229 "click", 3230 () => { 3231 e.muted = !e.muted; 3232 }, 3233 "mute", 3234 ), 3235 this.bind(t.buttons.captions, "click", () => e.toggleCaptions()), 3236 this.bind( 3237 t.buttons.download, 3238 "click", 3239 () => { 3240 Z.call(e, e.media, "download"); 3241 }, 3242 "download", 3243 ), 3244 this.bind( 3245 t.buttons.fullscreen, 3246 "click", 3247 () => { 3248 e.fullscreen.toggle(); 3249 }, 3250 "fullscreen", 3251 ), 3252 this.bind( 3253 t.buttons.pip, 3254 "click", 3255 () => { 3256 e.pip = "toggle"; 3257 }, 3258 "pip", 3259 ), 3260 this.bind(t.buttons.airplay, "click", e.airplay, "airplay"), 3261 this.bind( 3262 t.buttons.settings, 3263 "click", 3264 (t) => { 3265 (t.stopPropagation(), 3266 t.preventDefault(), 3267 Pe.toggleMenu.call(e, t)); 3268 }, 3269 null, 3270 !1, 3271 ), 3272 this.bind( 3273 t.buttons.settings, 3274 "keyup", 3275 (t) => { 3276 [" ", "Enter"].includes(t.key) && 3277 ("Enter" !== t.key 3278 ? (t.preventDefault(), 3279 t.stopPropagation(), 3280 Pe.toggleMenu.call(e, t)) 3281 : Pe.focusFirstMenuItem.call(e, null, !0)); 3282 }, 3283 null, 3284 !1, 3285 ), 3286 this.bind(t.settings.menu, "keydown", (t) => { 3287 "Escape" === t.key && Pe.toggleMenu.call(e, t); 3288 }), 3289 this.bind(t.inputs.seek, "mousedown mousemove", (e) => { 3290 const i = t.progress.getBoundingClientRect(), 3291 s = (100 / i.width) * (e.pageX - i.left); 3292 e.currentTarget.setAttribute("seek-value", s); 3293 }), 3294 this.bind(
3295 t.inputs.seek, 3296 "mousedown mouseup keydown keyup touchstart touchend", 3297 (t) => { 3298 const i = t.currentTarget, 3299 s = "play-on-seeked"; 3300 if ( 3301 S.keyboardEvent(t) && 3302 !["ArrowLeft", "ArrowRight"].includes(t.key) 3303 ) 3304 return; 3305 e.lastSeekTime = Date.now(); 3306 const n = i.hasAttribute(s), 3307 a = ["mouseup", "touchend", "keyup"].includes(t.type); 3308 n && a 3309 ? (i.removeAttribute(s), ie(e.play())) 3310 : !a && e.playing && (i.setAttribute(s, ""), e.pause()); 3311 }, 3312 ), 3313 M.isIos) 3314 ) { 3315 const t = U.call(e, 'input[type="range"]'); 3316 Array.from(t).forEach((e) => this.bind(e, i, (e) => P(e.target))); 3317 } 3318 (this.bind( 3319 t.inputs.seek, 3320 i, 3321 (t) => { 3322 const i = t.currentTarget; 3323 let s = i.getAttribute("seek-value"); 3324 (S.empty(s) && (s = i.value), 3325 i.removeAttribute("seek-value"), 3326 (e.currentTime = (s / i.max) * e.duration)); 3327 }, 3328 "seek", 3329 ), 3330 this.bind(t.progress, "mouseenter mouseleave mousemove", (t) => 3331 Pe.updateSeekTooltip.call(e, t), 3332 ), 3333 this.bind(t.progress, "mousemove touchmove", (t) => { 3334 const { previewThumbnails: i } = e; 3335 i && i.loaded && i.startMove(t); 3336 }), 3337 this.bind(t.progress, "mouseleave touchend click", () => { 3338 const { previewThumbnails: t } = e; 3339 t && t.loaded && t.endMove(!1, !0); 3340 }), 3341 this.bind(t.progress, "mousedown touchstart", (t) => { 3342 const { previewThumbnails: i } = e; 3343 i && i.loaded && i.startScrubbing(t); 3344 }), 3345 this.bind(t.progress, "mouseup touchend", (t) => { 3346 const { previewThumbnails: i } = e; 3347 i && i.loaded && i.endScrubbing(t); 3348 }), 3349 M.isWebKit && 3350 Array.from(U.call(e, 'input[type="range"]')).forEach((t) => { 3351 this.bind(t, "input", (t) => 3352 Pe.updateRangeFill.call(e, t.target), 3353 ); 3354 }), 3355 e.config.toggleInvert && 3356 !S.element(t.display.duration) && 3357 this.bind(t.display.currentTime, "click", () => { 3358 0 !== e.currentTime && 3359 ((e.config.invertTime = !e.config.invertTime), 3360 Pe.timeUpdate.call(e)); 3361 }), 3362 this.bind( 3363 t.inputs.volume, 3364 i, 3365 (t) => { 3366 e.volume = t.target.value; 3367 }, 3368 "volume", 3369 ), 3370 this.bind(t.controls, "mouseenter mouseleave", (i) => { 3371 t.controls.hover = !e.touch && "mouseenter" === i.type; 3372 }), 3373 t.fullscreen && 3374 Array.from(t.fullscreen.children) 3375 .filter((e) => !e.contains(t.container)) 3376 .forEach((i) => { 3377 this.bind(i, "mouseenter mouseleave", (i) => { 3378 t.controls && 3379 (t.controls.hover = 3380 !e.touch && "mouseenter" === i.type); 3381 }); 3382 }), 3383 this.bind( 3384 t.controls, 3385 "mousedown mouseup touchstart touchend touchcancel", 3386 (e) => { 3387 t.controls.pressed = ["mousedown", "touchstart"].includes( 3388 e.type, 3389 ); 3390 }, 3391 ), 3392 this.bind(t.controls, "focusin", () => { 3393 const { config: i, timers: s } = e; 3394 (R(t.controls, i.classNames.noTransition, !0), 3395 Fe.toggleControls.call(e, !0), 3396 setTimeout(() => { 3397 R(t.controls, i.classNames.noTransition, !1); 3398 }, 0)); 3399 const n = this.touch ? 3e3 : 4e3; 3400 (clearTimeout(s.controls), 3401 (s.controls = setTimeout( 3402 () => Fe.toggleControls.call(e, !1), 3403 n, 3404 ))); 3405 }), 3406 this.bind(
3407 t.inputs.volume, 3408 "wheel", 3409 (t) => { 3410 const i = t.webkitDirectionInvertedFromDevice, 3411 [s, n] = [t.deltaX, -t.deltaY].map((e) => (i ? -e : e)), 3412 a = Math.sign(Math.abs(s) > Math.abs(n) ? s : n); 3413 e.increaseVolume(a / 50); 3414 const { volume: l } = e.media; 3415 ((1 === a && l < 1) || (-1 === a && l > 0)) && 3416 t.preventDefault(); 3417 }, 3418 "volume", 3419 !1, 3420 )); 3421 }), 3422 (this.player = t), 3423 (this.lastKey = null), 3424 (this.focusTimer = null), 3425 (this.lastKeyDown = null), 3426 (this.handleKey = this.handleKey.bind(this)), 3427 (this.toggleMenu = this.toggleMenu.bind(this)), 3428 (this.firstTouch = this.firstTouch.bind(this))); 3429 } 3430 handleKey(e) { 3431 const { player: t } = this, 3432 { elements: i } = t, 3433 { 3434 key: s, 3435 type: n, 3436 altKey: a, 3437 ctrlKey: l, 3438 metaKey: r, 3439 shiftKey: o, 3440 } = e, 3441 c = "keydown" === n, 3442 u = c && s === this.lastKey; 3443 if (a || l || r || o) return; 3444 if (!s) return; 3445 if (c) { 3446 const n = document.activeElement; 3447 if (S.element(n)) { 3448 const { editable: s } = t.config.selectors, 3449 { seek: a } = i.inputs; 3450 if (n !== a && V(n, s)) return; 3451 if (" " === e.key && V(n, 'button, [role^="menuitem"]')) return; 3452 } 3453 switch ( 3454 ([ 3455 " ", 3456 "ArrowLeft", 3457 "ArrowUp", 3458 "ArrowRight", 3459 "ArrowDown", 3460 "0", 3461 "1", 3462 "2", 3463 "3", 3464 "4", 3465 "5", 3466 "6", 3467 "7", 3468 "8", 3469 "9", 3470 "c", 3471 "f", 3472 "k", 3473 "l", 3474 "m", 3475 ].includes(s) && (e.preventDefault(), e.stopPropagation()), 3476 s) 3477 ) { 3478 case "0": 3479 case "1": 3480 case "2": 3481 case "3": 3482 case "4": 3483 case "5": 3484 case "6": 3485 case "7": 3486 case "8": 3487 case "9": 3488 u || 3489 ((h = parseInt(s, 10)), 3490 (t.currentTime = (t.duration / 10) * h)); 3491 break; 3492 case " ": 3493 case "k": 3494 u || ie(t.togglePlay()); 3495 break; 3496 case "ArrowUp": 3497 t.increaseVolume(0.1); 3498 break; 3499 case "ArrowDown": 3500 t.decreaseVolume(0.1); 3501 break; 3502 case "m": 3503 u || (t.muted = !t.muted); 3504 break; 3505 case "ArrowRight": 3506 t.forward(); 3507 break; 3508 case "ArrowLeft": 3509 t.rewind(); 3510 break; 3511 case "f": 3512 t.fullscreen.toggle(); 3513 break; 3514 case "c": 3515 u || t.toggleCaptions(); 3516 break; 3517 case "l": 3518 t.loop = !t.loop; 3519 } 3520 ("Escape" === s && 3521 !t.fullscreen.usingNative && 3522 t.fullscreen.active && 3523 t.fullscreen.toggle(), 3524 (this.lastKey = s)); 3525 } else this.lastKey = null; 3526 var h; 3527 } 3528 toggleMenu(e) { 3529 Pe.toggleMenu.call(this.player, e); 3530 } 3531 } 3532 "undefined" != typeof globalThis 3533 ? globalThis 3534 : "undefined" != typeof window 3535 ? window 3536 : "undefined" != typeof global 3537 ? global 3538 : "undefined" != typeof self && self; 3539 var Ue = (function (e, t) { 3540 return (e((t = { exports: {} }), t.exports), t.exports); 3541 })(function (e, t) { 3542 e.exports = (function () { 3543 var e = function () {}, 3544 t = {}, 3545 i = {}, 3546 s = {}; 3547 function n(e, t) { 3548 e = e.push ? e : [e]; 3549 var n, 3550 a, 3551 l, 3552 r = [], 3553 o = e.length, 3554 c = o; 3555 for ( 3556 n = function (e, i) { 3557 (i.length && r.push(e), --c || t(r)); 3558 }; 3559 o--; 3560 ) 3561 ((a = e[o]), (l = i[a]) ? n(a, l) : (s[a] = s[a] || []).push(n)); 3562 } 3563 function a(e, t) { 3564 if (e) { 3565 var n = s[e]; 3566 if (((i[e] = t), n)) 3567 for (; n.length; ) (n[0](e, t), n.splice(0, 1)); 3568 } 3569 } 3570 function l(t, i) { 3571 (t.call && (t = { success: t }), 3572 i.length ? (t.error || e)(i) : (t.success || e)(t)); 3573 } 3574 function r(t, i, s, n) { 3575 var a, 3576 l, 3577 o = document, 3578 c = s.async, 3579 u = (s.numRetries || 0) + 1, 3580 h = s.before || e, 3581 d = t.replace(/[\?|#].*$/, ""), 3582 m = t.replace(/^(css|img)!/, ""); 3583 ((n = n || 0), 3584 /(^css!|\.css$)/.test(d) 3585 ? (((l = o.createElement("link")).rel = "stylesheet"), 3586 (l.href = m), 3587 (a = "hideFocus" in l) && 3588 l.relList && 3589 ((a = 0), (l.rel = "preload"), (l.as = "style"))) 3590 : /(^img!|\.(png|gif|jpg|svg|webp)$)/.test(d) 3591 ? ((l = o.createElement("img")).src = m) 3592 : (((l = o.createElement("script")).src = t), 3593 (l.async = void 0 === c || c)), 3594 (l.onload = 3595 l.onerror = 3596 l.onbeforeload = 3597 function (e) { 3598 var o = e.type[0]; 3599 if (a) 3600 try { 3601 l.sheet.cssText.length || (o = "e"); 3602 } catch (e) { 3603 18 != e.code && (o = "e"); 3604 } 3605 if ("e" == o) { 3606 if ((n += 1) < u) return r(t, i, s, n); 3607 } else if ("preload" == l.rel && "style" == l.as) 3608 return (l.rel = "stylesheet"); 3609 i(t, o, e.defaultPrevented); 3610 }), 3611 !1 !== h(t, l) && o.head.appendChild(l)); 3612 } 3613 function o(e, t, i) { 3614 var s, 3615 n, 3616 a = (e = e.push ? e : [e]).length, 3617 l = a, 3618 o = []; 3619 for ( 3620 s = function (e, i, s) { 3621 if (("e" == i && o.push(e), "b" == i)) { 3622 if (!s) return; 3623 o.push(e); 3624 } 3625 --a || t(o); 3626 }, 3627 n = 0; 3628 n < l; 3629 n++ 3630 ) 3631 r(e[n], s, i); 3632 } 3633 function c(e, i, s) { 3634 var n, r; 3635 if ((i && i.trim && (n = i), (r = (n ? s : i) || {}), n)) { 3636 if (n in t) throw "LoadJS"; 3637 t[n] = !0; 3638 } 3639 function c(t, i) { 3640 o( 3641 e, 3642 function (e) { 3643 (l(r, e), t && l({ success: t, error: i }, e), a(n, e)); 3644 }, 3645 r, 3646 ); 3647 } 3648 if (r.returnPromise) return new Promise(c); 3649 c(); 3650 } 3651 return ( 3652 (c.ready = function (e, t) { 3653 return ( 3654 n(e, function (e) { 3655 l(t, e); 3656 }), 3657 c 3658 ); 3659 }), 3660 (c.done = function (e) { 3661 a(e, []); 3662 }), 3663 (c.reset = function () { 3664 ((t = {}), (i = {}), (s = {})); 3665 }), 3666 (c.isDefined = function (e) { 3667 return e in t; 3668 }), 3669 c 3670 ); 3671 })(); 3672 }); 3673 function Be(e) { 3674 return new Promise((t, i) => { 3675 Ue(e, { success: t, error: i }); 3676 }); 3677 } 3678 function We(e) { 3679 (e && !this.embed.hasPlayed && (this.embed.hasPlayed = !0), 3680 this.media.paused === e && 3681 ((this.media.paused = !e), 3682 Z.call(this, this.media, e ? "play" : "pause"))); 3683 } 3684 const ze = { 3685 setup() { 3686 const e = this; 3687 (R(e.elements.wrapper, e.config.classNames.embed, !0), 3688 (e.options.speed = e.config.speed.options), 3689 ue.call(e), 3690 S.object(window.Vimeo) 3691 ? ze.ready.call(e) 3692 : Be(e.config.urls.vimeo.sdk) 3693 .then(() => { 3694 ze.ready.call(e); 3695 }) 3696 .catch((t) => { 3697 e.debug.warn("Vimeo SDK (player.js) failed to load", t); 3698 })); 3699 }, 3700 ready() { 3701 const e = this, 3702 t = e.config.vimeo, 3703 { premium: i, referrerPolicy: s, ...n } = t; 3704 let a = e.media.getAttribute("src"), 3705 l = ""; 3706 S.empty(a) 3707 ? ((a = e.media.getAttribute(e.config.attributes.embed.id)), 3708 (l = e.media.getAttribute(e.config.attributes.embed.hash))) 3709 : (l = (function (e) { 3710 const t = e.match( 3711 /^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/, 3712 ); 3713 return t && 5 === t.length ? t[4] : null; 3714 })(a)); 3715 const r = l ? { h: l } : {}; 3716 i && Object.assign(n, { controls: !1, sidedock: !1 }); 3717 const o = Ne({ 3718 loop: e.config.loop.active, 3719 autoplay: e.autoplay, 3720 muted: e.muted, 3721 gesture: "media", 3722 playsinline: e.config.playsinline, 3723 ...r, 3724 ...n, 3725 }), 3726 c = 3727 ((u = a), 3728 S.empty(u) 3729 ? null 3730 : S.number(Number(u)) 3731 ? u 3732 : u.match(/^.*(vimeo.com\/|video\/)(\d+).*/) 3733 ? RegExp.$2 3734 : u); 3735 var u; 3736 const h = $("iframe"), 3737 d = me(e.config.urls.vimeo.iframe, c, o); 3738 if ( 3739 (h.setAttribute("src", d), 3740 h.setAttribute("allowfullscreen", ""), 3741 h.setAttribute( 3742 "allow", 3743 [ 3744 "autoplay", 3745 "fullscreen", 3746 "picture-in-picture", 3747 "encrypted-media", 3748 "accelerometer", 3749 "gyroscope", 3750 ].join("; "), 3751 ), 3752 S.empty(s) || h.setAttribute("referrerPolicy", s), 3753 i || !t.customControls) 3754 ) 3755 (h.setAttribute("data-poster", e.poster), (e.media = q(h, e.media))); 3756 else { 3757 const t = $("div", { 3758 class: e.config.classNames.embedContainer, 3759 "data-poster": e.poster, 3760 }); 3761 (t.appendChild(h), (e.media = q(t, e.media))); 3762 } 3763 (t.customControls || 3764 Te(me(e.config.urls.vimeo.api, d)).then((t) => { 3765 !S.empty(t) && 3766 t.thumbnail_url && 3767 Fe.setPoster.call(e, t.thumbnail_url).catch(() => {}); 3768 }), 3769 (e.embed = new window.Vimeo.Player(h, {
3770 autopause: e.config.autopause, 3771 muted: e.muted, 3772 })), 3773 (e.media.paused = !0), 3774 (e.media.currentTime = 0), 3775 e.supported.ui && e.embed.disableTextTrack(), 3776 (e.media.play = () => (We.call(e, !0), e.embed.play())), 3777 (e.media.pause = () => (We.call(e, !1), e.embed.pause())), 3778 (e.media.stop = () => { 3779 (e.pause(), (e.currentTime = 0)); 3780 })); 3781 let { currentTime: m } = e.media; 3782 Object.defineProperty(e.media, "currentTime", { 3783 get: () => m, 3784 set(t) { 3785 const { embed: i, media: s, paused: n, volume: a } = e, 3786 l = n && !i.hasPlayed; 3787 ((s.seeking = !0), 3788 Z.call(e, s, "seeking"), 3789 Promise.resolve(l && i.setVolume(0)) 3790 .then(() => i.setCurrentTime(t)) 3791 .then(() => l && i.pause()) 3792 .then(() => l && i.setVolume(a)) 3793 .catch(() => {})); 3794 }, 3795 }); 3796 let p = e.config.speed.selected; 3797 Object.defineProperty(e.media, "playbackRate", { 3798 get: () => p, 3799 set(t) { 3800 e.embed 3801 .setPlaybackRate(t) 3802 .then(() => { 3803 ((p = t), Z.call(e, e.media, "ratechange")); 3804 }) 3805 .catch(() => { 3806 e.options.speed = [1]; 3807 }); 3808 }, 3809 }); 3810 let { volume: g } = e.config; 3811 Object.defineProperty(e.media, "volume", { 3812 get: () => g, 3813 set(t) { 3814 e.embed.setVolume(t).then(() => { 3815 ((g = t), Z.call(e, e.media, "volumechange")); 3816 }); 3817 }, 3818 }); 3819 let { muted: f } = e.config; 3820 Object.defineProperty(e.media, "muted", { 3821 get: () => f, 3822 set(t) { 3823 const i = !!S.boolean(t) && t; 3824 e.embed.setMuted(!!i || e.config.muted).then(() => { 3825 ((f = i), Z.call(e, e.media, "volumechange")); 3826 }); 3827 }, 3828 }); 3829 let y, 3830 { loop: b } = e.config; 3831 (Object.defineProperty(e.media, "loop", { 3832 get: () => b, 3833 set(t) { 3834 const i = S.boolean(t) ? t : e.config.loop.active; 3835 e.embed.setLoop(i).then(() => { 3836 b = i; 3837 }); 3838 }, 3839 }), 3840 e.embed 3841 .getVideoUrl() 3842 .then((t) => { 3843 ((y = t), Pe.setDownloadUrl.call(e)); 3844 }) 3845 .catch((e) => { 3846 this.debug.warn(e); 3847 }), 3848 Object.defineProperty(e.media, "currentSrc", { get: () => y }), 3849 Object.defineProperty(e.media, "ended", { 3850 get: () => e.currentTime === e.duration, 3851 }), 3852 Promise.all([e.embed.getVideoWidth(), e.embed.getVideoHeight()]).then( 3853 (t) => { 3854 const [i, s] = t; 3855 ((e.embed.ratio = he(i, s)), ue.call(this)); 3856 }, 3857 ), 3858 e.embed.setAutopause(e.config.autopause).then((t) => { 3859 e.config.autopause = t; 3860 }), 3861 e.embed.getVideoTitle().then((t) => { 3862 ((e.config.title = t), Fe.setTitle.call(this)); 3863 }), 3864 e.embed.getCurrentTime().then((t) => { 3865 ((m = t), Z.call(e, e.media, "timeupdate")); 3866 }), 3867 e.embed.getDuration().then((t) => { 3868 ((e.media.duration = t), Z.call(e, e.media, "durationchange")); 3869 }), 3870 e.embed.getTextTracks().then((t) => { 3871 ((e.media.textTracks = t), xe.setup.call(e)); 3872 }), 3873 e.embed.on("cuechange", ({ cues: t = [] }) => { 3874 const i = t.map((e) => 3875 (function (e) { 3876 const t = document.createDocumentFragment(), 3877 i = document.createElement("div"); 3878 return ( 3879 t.appendChild(i), 3880 (i.innerHTML = e), 3881 t.firstChild.innerText 3882 ); 3883 })(e.text), 3884 ); 3885 xe.updateCues.call(e, i); 3886 }), 3887 e.embed.on("loaded", () => { 3888 if ( 3889 (e.embed.getPaused().then((t) => { 3890 (We.call(e, !t), t || Z.call(e, e.media, "playing")); 3891 }),
3892 S.element(e.embed.element) && e.supported.ui) 3893 ) { 3894 e.embed.element.setAttribute("tabindex", -1); 3895 } 3896 }), 3897 e.embed.on("bufferstart", () => { 3898 Z.call(e, e.media, "waiting"); 3899 }), 3900 e.embed.on("bufferend", () => { 3901 Z.call(e, e.media, "playing"); 3902 }), 3903 e.embed.on("play", () => { 3904 (We.call(e, !0), Z.call(e, e.media, "playing")); 3905 }), 3906 e.embed.on("pause", () => { 3907 We.call(e, !1); 3908 }), 3909 e.embed.on("timeupdate", (t) => { 3910 ((e.media.seeking = !1), 3911 (m = t.seconds), 3912 Z.call(e, e.media, "timeupdate")); 3913 }), 3914 e.embed.on("progress", (t) => { 3915 ((e.media.buffered = t.percent), 3916 Z.call(e, e.media, "progress"), 3917 1 === parseInt(t.percent, 10) && 3918 Z.call(e, e.media, "canplaythrough"), 3919 e.embed.getDuration().then((t) => { 3920 t !== e.media.duration && 3921 ((e.media.duration = t), 3922 Z.call(e, e.media, "durationchange")); 3923 })); 3924 }), 3925 e.embed.on("seeked", () => { 3926 ((e.media.seeking = !1), Z.call(e, e.media, "seeked")); 3927 }), 3928 e.embed.on("ended", () => { 3929 ((e.media.paused = !0), Z.call(e, e.media, "ended")); 3930 }), 3931 e.embed.on("error", (t) => { 3932 ((e.media.error = t), Z.call(e, e.media, "error")); 3933 }), 3934 t.customControls && setTimeout(() => Fe.build.call(e), 0)); 3935 }, 3936 }; 3937 function Ke(e) { 3938 (e && !this.embed.hasPlayed && (this.embed.hasPlayed = !0), 3939 this.media.paused === e && 3940 ((this.media.paused = !e), 3941 Z.call(this, this.media, e ? "play" : "pause"))); 3942 } 3943 function Ye(e) { 3944 return e.noCookie 3945 ? "https://www.youtube-nocookie.com" 3946 : "http:" === window.location.protocol 3947 ? "http://www.youtube.com" 3948 : void 0; 3949 } 3950 const Qe = { 3951 setup() { 3952 if ( 3953 (R(this.elements.wrapper, this.config.classNames.embed, !0), 3954 S.object(window.YT) && S.function(window.YT.Player)) 3955 ) 3956 Qe.ready.call(this); 3957 else { 3958 const e = window.onYouTubeIframeAPIReady; 3959 ((window.onYouTubeIframeAPIReady = () => { 3960 (S.function(e) && e(), Qe.ready.call(this)); 3961 }), 3962 Be(this.config.urls.youtube.sdk).catch((e) => { 3963 this.debug.warn("YouTube API failed to load", e); 3964 })); 3965 } 3966 }, 3967 getTitle(e) { 3968 Te(me(this.config.urls.youtube.api, e)) 3969 .then((e) => { 3970 if (S.object(e)) { 3971 const { title: t, height: i, width: s } = e; 3972 ((this.config.title = t), 3973 Fe.setTitle.call(this), 3974 (this.embed.ratio = he(s, i))); 3975 } 3976 ue.call(this); 3977 }) 3978 .catch(() => { 3979 ue.call(this); 3980 }); 3981 }, 3982 ready() { 3983 const e = this, 3984 t = e.config.youtube, 3985 i = e.media && e.media.getAttribute("id"); 3986 if (!S.empty(i) && i.startsWith("youtube-")) return; 3987 let s = e.media.getAttribute("src"); 3988 S.empty(s) && 3989 (s = e.media.getAttribute(this.config.attributes.embed.id)); 3990 const n = 3991 ((a = s), 3992 S.empty(a) 3993 ? null 3994 : a.match( 3995 /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/, 3996 ) 3997 ? RegExp.$2 3998 : a); 3999 var a; 4000 const l = $("div", { 4001 id: `${e.provider}-${Math.floor(1e4 * Math.random())}`, 4002 "data-poster": t.customControls ? e.poster : void 0, 4003 }); 4004 if (((e.media = q(l, e.media)), t.customControls)) { 4005 const t = (e) => `https://i.ytimg.com/vi/${n}/${e}default.jpg`; 4006 Re(t("maxres"), 121) 4007 .catch(() => Re(t("sd"), 121)) 4008 .catch(() => Re(t("hq"))) 4009 .then((t) => Fe.setPoster.call(e, t.src)) 4010 .then((t) => { 4011 t.includes("maxres") || 4012 (e.elements.poster.style.backgroundSize = "cover"); 4013 }) 4014 .catch(() => {}); 4015 } 4016 e.embed = new window.YT.Player(e.media, { 4017 videoId: n, 4018 host: Ye(t), 4019 playerVars: x( 4020 {}, 4021 {
4022 autoplay: e.config.autoplay ? 1 : 0, 4023 hl: e.config.hl, 4024 controls: e.supported.ui && t.customControls ? 0 : 1, 4025 disablekb: 1, 4026 playsinline: 4027 e.config.playsinline && !e.config.fullscreen.iosNative 4028 ? 1 4029 : 0, 4030 cc_load_policy: e.captions.active ? 1 : 0, 4031 cc_lang_pref: e.config.captions.language, 4032 widget_referrer: window ? window.location.href : null, 4033 }, 4034 t, 4035 ), 4036 events: { 4037 onError(t) { 4038 if (!e.media.error) { 4039 const i = t.data, 4040 s = 4041 { 4042 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.", 4043 5: "The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.", 4044 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.", 4045 101: "The owner of the requested video does not allow it to be played in embedded players.", 4046 150: "The owner of the requested video does not allow it to be played in embedded players.", 4047 }[i] || "An unknown error occurred"; 4048 ((e.media.error = { code: i, message: s }), 4049 Z.call(e, e.media, "error")); 4050 } 4051 }, 4052 onPlaybackRateChange(t) { 4053 const i = t.target; 4054 ((e.media.playbackRate = i.getPlaybackRate()), 4055 Z.call(e, e.media, "ratechange")); 4056 }, 4057 onReady(i) { 4058 if (S.function(e.media.play)) return; 4059 const s = i.target; 4060 (Qe.getTitle.call(e, n), 4061 (e.media.play = () => { 4062 (Ke.call(e, !0), s.playVideo()); 4063 }), 4064 (e.media.pause = () => { 4065 (Ke.call(e, !1), s.pauseVideo()); 4066 }), 4067 (e.media.stop = () => { 4068 s.stopVideo(); 4069 }), 4070 (e.media.duration = s.getDuration()), 4071 (e.media.paused = !0), 4072 (e.media.currentTime = 0), 4073 Object.defineProperty(e.media, "currentTime", { 4074 get: () => Number(s.getCurrentTime()), 4075 set(t) { 4076 (e.paused && !e.embed.hasPlayed && e.embed.mute(), 4077 (e.media.seeking = !0), 4078 Z.call(e, e.media, "seeking"), 4079 s.seekTo(t)); 4080 }, 4081 }), 4082 Object.defineProperty(e.media, "playbackRate", { 4083 get: () => s.getPlaybackRate(), 4084 set(e) { 4085 s.setPlaybackRate(e); 4086 }, 4087 })); 4088 let { volume: a } = e.config; 4089 Object.defineProperty(e.media, "volume", { 4090 get: () => a, 4091 set(t) { 4092 ((a = t), 4093 s.setVolume(100 * a), 4094 Z.call(e, e.media, "volumechange")); 4095 }, 4096 }); 4097 let { muted: l } = e.config; 4098 (Object.defineProperty(e.media, "muted", { 4099 get: () => l, 4100 set(t) { 4101 const i = S.boolean(t) ? t : l; 4102 ((l = i), 4103 s[i ? "mute" : "unMute"](), 4104 s.setVolume(100 * a), 4105 Z.call(e, e.media, "volumechange")); 4106 }, 4107 }), 4108 Object.defineProperty(e.media, "currentSrc", { 4109 get: () => s.getVideoUrl(), 4110 }), 4111 Object.defineProperty(e.media, "ended", { 4112 get: () => e.currentTime === e.duration, 4113 })); 4114 const r = s.getAvailablePlaybackRates(); 4115 ((e.options.speed = r.filter((t) => 4116 e.config.speed.options.includes(t), 4117 )), 4118 e.supported.ui && 4119 t.customControls && 4120 e.media.setAttribute("tabindex", -1), 4121 Z.call(e, e.media, "timeupdate"), 4122 Z.call(e, e.media, "durationchange"), 4123 clearInterval(e.timers.buffering), 4124 (e.timers.buffering = setInterval(() => { 4125 ((e.media.buffered = s.getVideoLoadedFraction()), 4126 (null === e.media.lastBuffered || 4127 e.media.lastBuffered < e.media.buffered) && 4128 Z.call(e, e.media, "progress"), 4129 (e.media.lastBuffered = e.media.buffered), 4130 1 === e.media.buffered && 4131 (clearInterval(e.timers.buffering), 4132 Z.call(e, e.media, "canplaythrough"))); 4133 }, 200)), 4134 t.customControls && setTimeout(() => Fe.build.call(e), 50)); 4135 }, 4136 onStateChange(i) { 4137 const s = i.target; 4138 clearInterval(e.timers.playing); 4139 switch ( 4140 (e.media.seeking && 4141 [1, 2].includes(i.data) && 4142 ((e.media.seeking = !1), Z.call(e, e.media, "seeked")), 4143 i.data) 4144 ) { 4145 case -1: 4146 (Z.call(e, e.media, "timeupdate"), 4147 (e.media.buffered = s.getVideoLoadedFraction()), 4148 Z.call(e, e.media, "progress")); 4149 break; 4150 case 0: 4151 (Ke.call(e, !1), 4152 e.media.loop 4153 ? (s.stopVideo(), s.playVideo()) 4154 : Z.call(e, e.media, "ended")); 4155 break; 4156 case 1: 4157 t.customControls &&
4158 !e.config.autoplay && 4159 e.media.paused && 4160 !e.embed.hasPlayed 4161 ? e.media.pause() 4162 : (Ke.call(e, !0), 4163 Z.call(e, e.media, "playing"), 4164 (e.timers.playing = setInterval(() => { 4165 Z.call(e, e.media, "timeupdate"); 4166 }, 50)), 4167 e.media.duration !== s.getDuration() && 4168 ((e.media.duration = s.getDuration()), 4169 Z.call(e, e.media, "durationchange"))); 4170 break; 4171 case 2: 4172 (e.muted || e.embed.unMute(), Ke.call(e, !1)); 4173 break; 4174 case 3: 4175 Z.call(e, e.media, "waiting"); 4176 } 4177 Z.call(e, e.elements.container, "statechange", !1, { 4178 code: i.data, 4179 }); 4180 }, 4181 }, 4182 }); 4183 }, 4184 }, 4185 Xe = { 4186 setup() { 4187 this.media 4188 ? (R( 4189 this.elements.container, 4190 this.config.classNames.type.replace("{0}", this.type), 4191 !0, 4192 ), 4193 R( 4194 this.elements.container, 4195 this.config.classNames.provider.replace("{0}", this.provider), 4196 !0, 4197 ), 4198 this.isEmbed && 4199 R( 4200 this.elements.container, 4201 this.config.classNames.type.replace("{0}", "video"), 4202 !0, 4203 ), 4204 this.isVideo && 4205 ((this.elements.wrapper = $("div", { 4206 class: this.config.classNames.video, 4207 })), 4208 L(this.media, this.elements.wrapper), 4209 (this.elements.poster = $("div", { 4210 class: this.config.classNames.poster, 4211 })), 4212 this.elements.wrapper.appendChild(this.elements.poster)), 4213 this.isHTML5 4214 ? de.setup.call(this) 4215 : this.isYouTube 4216 ? Qe.setup.call(this) 4217 : this.isVimeo && ze.setup.call(this)) 4218 : this.debug.warn("No media element found!"); 4219 }, 4220 }; 4221 class Je { 4222 constructor(t) { 4223 (e(this, "load", () => { 4224 this.enabled && 4225 (S.object(window.google) && S.object(window.google.ima) 4226 ? this.ready() 4227 : Be(this.player.config.urls.googleIMA.sdk) 4228 .then(() => { 4229 this.ready(); 4230 }) 4231 .catch(() => { 4232 this.trigger( 4233 "error", 4234 new Error("Google IMA SDK failed to load"), 4235 ); 4236 })); 4237 }), 4238 e(this, "ready", () => { 4239 var e; 4240 (this.enabled || 4241 ((e = this).manager && e.manager.destroy(), 4242 e.elements.displayContainer && 4243 e.elements.displayContainer.destroy(), 4244 e.elements.container.remove()), 4245 this.startSafetyTimer(12e3, "ready()"), 4246 this.managerPromise.then(() => { 4247 this.clearSafetyTimer("onAdsManagerLoaded()"); 4248 }), 4249 this.listeners(), 4250 this.setupIMA()); 4251 }), 4252 e(this, "setupIMA", () => { 4253 ((this.elements.container = $("div", { 4254 class: this.player.config.classNames.ads, 4255 })), 4256 this.player.elements.container.appendChild( 4257 this.elements.container, 4258 ), 4259 google.ima.settings.setVpaidMode( 4260 google.ima.ImaSdkSettings.VpaidMode.ENABLED, 4261 ), 4262 google.ima.settings.setLocale(this.player.config.ads.language), 4263 google.ima.settings.setDisableCustomPlaybackForIOS10Plus( 4264 this.player.config.playsinline, 4265 ), 4266 (this.elements.displayContainer = 4267 new google.ima.AdDisplayContainer( 4268 this.elements.container, 4269 this.player.media, 4270 )), 4271 (this.loader = new google.ima.AdsLoader( 4272 this.elements.displayContainer, 4273 )), 4274 this.loader.addEventListener( 4275 google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, 4276 (e) => this.onAdsManagerLoaded(e), 4277 !1, 4278 ), 4279 this.loader.addEventListener( 4280 google.ima.AdErrorEvent.Type.AD_ERROR, 4281 (e) => this.onAdError(e), 4282 !1, 4283 ), 4284 this.requestAds()); 4285 }),
4286 e(this, "requestAds", () => { 4287 const { container: e } = this.player.elements; 4288 try { 4289 const t = new google.ima.AdsRequest(); 4290 ((t.adTagUrl = this.tagUrl), 4291 (t.linearAdSlotWidth = e.offsetWidth), 4292 (t.linearAdSlotHeight = e.offsetHeight), 4293 (t.nonLinearAdSlotWidth = e.offsetWidth), 4294 (t.nonLinearAdSlotHeight = e.offsetHeight), 4295 (t.forceNonLinearFullSlot = !1), 4296 t.setAdWillPlayMuted(!this.player.muted), 4297 this.loader.requestAds(t)); 4298 } catch (e) { 4299 this.onAdError(e); 4300 } 4301 }), 4302 e(this, "pollCountdown", (e = !1) => { 4303 if (!e) 4304 return ( 4305 clearInterval(this.countdownTimer), 4306 void this.elements.container.removeAttribute("data-badge-text") 4307 ); 4308 this.countdownTimer = setInterval(() => { 4309 const e = Ee(Math.max(this.manager.getRemainingTime(), 0)), 4310 t = `${ve.get("advertisement", this.player.config)} - ${e}`; 4311 this.elements.container.setAttribute("data-badge-text", t); 4312 }, 100); 4313 }), 4314 e(this, "onAdsManagerLoaded", (e) => { 4315 if (!this.enabled) return; 4316 const t = new google.ima.AdsRenderingSettings(); 4317 ((t.restoreCustomPlaybackStateOnAdBreakComplete = !0), 4318 (t.enablePreloading = !0), 4319 (this.manager = e.getAdsManager(this.player, t)), 4320 (this.cuePoints = this.manager.getCuePoints()), 4321 this.manager.addEventListener( 4322 google.ima.AdErrorEvent.Type.AD_ERROR, 4323 (e) => this.onAdError(e), 4324 ), 4325 Object.keys(google.ima.AdEvent.Type).forEach((e) => { 4326 this.manager.addEventListener(google.ima.AdEvent.Type[e], (e) => 4327 this.onAdEvent(e), 4328 ); 4329 }), 4330 this.trigger("loaded")); 4331 }), 4332 e(this, "addCuePoints", () => { 4333 S.empty(this.cuePoints) || 4334 this.cuePoints.forEach((e) => { 4335 if (0 !== e && -1 !== e && e < this.player.duration) { 4336 const t = this.player.elements.progress; 4337 if (S.element(t)) { 4338 const i = (100 / this.player.duration) * e, 4339 s = $("span", { 4340 class: this.player.config.classNames.cues, 4341 }); 4342 ((s.style.left = `${i.toString()}%`), t.appendChild(s)); 4343 } 4344 } 4345 }); 4346 }), 4347 e(this, "onAdEvent", (e) => { 4348 const { container: t } = this.player.elements, 4349 i = e.getAd(), 4350 s = e.getAdData(); 4351 switch ( 4352 (((e) => { 4353 Z.call( 4354 this.player, 4355 this.player.media, 4356 `ads${e.replace(/_/g, "").toLowerCase()}`, 4357 ); 4358 })(e.type), 4359 e.type) 4360 ) { 4361 case google.ima.AdEvent.Type.LOADED: 4362 (this.trigger("loaded"), 4363 this.pollCountdown(!0), 4364 i.isLinear() || 4365 ((i.width = t.offsetWidth), (i.height = t.offsetHeight))); 4366 break; 4367 case google.ima.AdEvent.Type.STARTED: 4368 this.manager.setVolume(this.player.volume); 4369 break; 4370 case google.ima.AdEvent.Type.ALL_ADS_COMPLETED: 4371 this.player.ended 4372 ? this.loadAds() 4373 : this.loader.contentComplete(); 4374 break; 4375 case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED: 4376 this.pauseContent(); 4377 break; 4378 case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED: 4379 (this.pollCountdown(), this.resumeContent()); 4380 break; 4381 case google.ima.AdEvent.Type.LOG: 4382 s.adError && 4383 this.player.debug.warn( 4384 `Non-fatal ad error: ${s.adError.getMessage()}`, 4385 ); 4386 } 4387 }), 4388 e(this, "onAdError", (e) => { 4389 (this.cancel(), this.player.debug.warn("Ads error", e)); 4390 }), 4391 e(this, "listeners", () => { 4392 const { container: e } = this.player.elements; 4393 let t;
4394 (this.player.on("canplay", () => { 4395 this.addCuePoints(); 4396 }), 4397 this.player.on("ended", () => { 4398 this.loader.contentComplete(); 4399 }), 4400 this.player.on("timeupdate", () => { 4401 t = this.player.currentTime; 4402 }), 4403 this.player.on("seeked", () => { 4404 const e = this.player.currentTime; 4405 S.empty(this.cuePoints) || 4406 this.cuePoints.forEach((i, s) => { 4407 t < i && 4408 i < e && 4409 (this.manager.discardAdBreak(), 4410 this.cuePoints.splice(s, 1)); 4411 }); 4412 }), 4413 window.addEventListener("resize", () => { 4414 this.manager && 4415 this.manager.resize( 4416 e.offsetWidth, 4417 e.offsetHeight, 4418 google.ima.ViewMode.NORMAL, 4419 ); 4420 })); 4421 }), 4422 e(this, "play", () => { 4423 const { container: e } = this.player.elements; 4424 (this.managerPromise || this.resumeContent(), 4425 this.managerPromise 4426 .then(() => { 4427 (this.manager.setVolume(this.player.volume), 4428 this.elements.displayContainer.initialize()); 4429 try { 4430 (this.initialized || 4431 (this.manager.init( 4432 e.offsetWidth, 4433 e.offsetHeight, 4434 google.ima.ViewMode.NORMAL, 4435 ), 4436 this.manager.start()), 4437 (this.initialized = !0)); 4438 } catch (e) { 4439 this.onAdError(e); 4440 } 4441 }) 4442 .catch(() => {})); 4443 }), 4444 e(this, "resumeContent", () => { 4445 ((this.elements.container.style.zIndex = ""), 4446 (this.playing = !1), 4447 ie(this.player.media.play())); 4448 }), 4449 e(this, "pauseContent", () => { 4450 ((this.elements.container.style.zIndex = 3), 4451 (this.playing = !0), 4452 this.player.media.pause()); 4453 }), 4454 e(this, "cancel", () => { 4455 (this.initialized && this.resumeContent(), 4456 this.trigger("error"), 4457 this.loadAds()); 4458 }), 4459 e(this, "loadAds", () => { 4460 this.managerPromise 4461 .then(() => { 4462 (this.manager && this.manager.destroy(), 4463 (this.managerPromise = new Promise((e) => { 4464 (this.on("loaded", e), this.player.debug.log(this.manager)); 4465 })), 4466 (this.initialized = !1), 4467 this.requestAds()); 4468 }) 4469 .catch(() => {}); 4470 }), 4471 e(this, "trigger", (e, ...t) => { 4472 const i = this.events[e]; 4473 S.array(i) && 4474 i.forEach((e) => { 4475 S.function(e) && e.apply(this, t); 4476 }); 4477 }), 4478 e( 4479 this, 4480 "on", 4481 (e, t) => ( 4482 S.array(this.events[e]) || (this.events[e] = []), 4483 this.events[e].push(t), 4484 this 4485 ), 4486 ), 4487 e(this, "startSafetyTimer", (e, t) => { 4488 (this.player.debug.log(`Safety timer invoked from: ${t}`), 4489 (this.safetyTimer = setTimeout(() => { 4490 (this.cancel(), this.clearSafetyTimer("startSafetyTimer()")); 4491 }, e))); 4492 }), 4493 e(this, "clearSafetyTimer", (e) => { 4494 S.nullOrUndefined(this.safetyTimer) || 4495 (this.player.debug.log(`Safety timer cleared from: ${e}`), 4496 clearTimeout(this.safetyTimer), 4497 (this.safetyTimer = null)); 4498 }), 4499 (this.player = t), 4500 (this.config = t.config.ads), 4501 (this.playing = !1), 4502 (this.initialized = !1), 4503 (this.elements = { container: null, displayContainer: null }), 4504 (this.manager = null),
4505 (this.loader = null), 4506 (this.cuePoints = null), 4507 (this.events = {}), 4508 (this.safetyTimer = null), 4509 (this.countdownTimer = null), 4510 (this.managerPromise = new Promise((e, t) => { 4511 (this.on("loaded", e), this.on("error", t)); 4512 })), 4513 this.load()); 4514 } 4515 get enabled() { 4516 const { config: e } = this; 4517 return ( 4518 this.player.isHTML5 && 4519 this.player.isVideo && 4520 e.enabled && 4521 (!S.empty(e.publisherId) || S.url(e.tagUrl)) 4522 ); 4523 } 4524 get tagUrl() { 4525 const { config: e } = this; 4526 if (S.url(e.tagUrl)) return e.tagUrl; 4527 return `https://go.aniview.com/api/adserver6/vast/?${Ne({ AV_PUBLISHERID: "58c25bb0073ef448b1087ad6", AV_CHANNELID: "5a0458dc28a06145e4519d21", AV_URL: window.location.hostname, cb: Date.now(), AV_WIDTH: 640, AV_HEIGHT: 480, AV_CDIM2: e.publisherId })}`; 4528 } 4529 } 4530 function Ge(e = 0, t = 0, i = 255) { 4531 return Math.min(Math.max(e, t), i); 4532 } 4533 const Ze = (e) => { 4534 const t = []; 4535 return (
4536 e.split(/\r\n\r\n|\n\n|\r\r/).forEach((e) => { 4537 const i = {}; 4538 (e.split(/\r\n|\n|\r/).forEach((e) => { 4539 if (S.number(i.startTime)) { 4540 if (!S.empty(e.trim()) && S.empty(i.text)) { 4541 const t = e.trim().split("#xywh="); 4542 (([i.text] = t), 4543 t[1] && ([i.x, i.y, i.w, i.h] = t[1].split(","))); 4544 } 4545 } else { 4546 const t = e.match( 4547 /([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})/, 4548 ); 4549 t && 4550 ((i.startTime = 4551 60 * Number(t[1] || 0) * 60 + 4552 60 * Number(t[2]) + 4553 Number(t[3]) + 4554 Number(`0.${t[4]}`)), 4555 (i.endTime = 4556 60 * Number(t[6] || 0) * 60 + 4557 60 * Number(t[7]) + 4558 Number(t[8]) + 4559 Number(`0.${t[9]}`))); 4560 } 4561 }), 4562 i.text && t.push(i)); 4563 }), 4564 t 4565 ); 4566 }, 4567 et = (e, t) => { 4568 const i = {}; 4569 return ( 4570 e > t.width / t.height 4571 ? ((i.width = t.width), (i.height = (1 / e) * t.width)) 4572 : ((i.height = t.height), (i.width = e * t.height)), 4573 i 4574 ); 4575 }; 4576 class tt { 4577 constructor(t) { 4578 (e(this, "load", () => { 4579 (this.player.elements.display.seekTooltip && 4580 (this.player.elements.display.seekTooltip.hidden = this.enabled), 4581 this.enabled && 4582 this.getThumbnails().then(() => { 4583 this.enabled && 4584 (this.render(), 4585 this.determineContainerAutoSizing(), 4586 this.listeners(), 4587 (this.loaded = !0)); 4588 })); 4589 }), 4590 e( 4591 this, 4592 "getThumbnails", 4593 () => 4594 new Promise((e) => { 4595 const { src: t } = this.player.config.previewThumbnails; 4596 if (S.empty(t)) 4597 throw new Error( 4598 "Missing previewThumbnails.src config attribute", 4599 ); 4600 const i = () => { 4601 (this.thumbnails.sort((e, t) => e.height - t.height), 4602 this.player.debug.log( 4603 "Preview thumbnails", 4604 this.thumbnails, 4605 ), 4606 e()); 4607 }; 4608 if (S.function(t)) 4609 t((e) => { 4610 ((this.thumbnails = e), i()); 4611 }); 4612 else { 4613 const e = (S.string(t) ? [t] : t).map((e) => 4614 this.getThumbnail(e), 4615 ); 4616 Promise.all(e).then(i); 4617 } 4618 }), 4619 ), 4620 e( 4621 this, 4622 "getThumbnail", 4623 (e) => 4624 new Promise((t) => { 4625 Te(e).then((i) => { 4626 const s = { frames: Ze(i), height: null, urlPrefix: "" }; 4627 s.frames[0].text.startsWith("/") || 4628 s.frames[0].text.startsWith("http://") || 4629 s.frames[0].text.startsWith("https://") || 4630 (s.urlPrefix = e.substring(0, e.lastIndexOf("/") + 1)); 4631 const n = new Image(); 4632 ((n.onload = () => { 4633 ((s.height = n.naturalHeight), 4634 (s.width = n.naturalWidth), 4635 this.thumbnails.push(s), 4636 t()); 4637 }), 4638 (n.src = s.urlPrefix + s.frames[0].text)); 4639 }); 4640 }), 4641 ), 4642 e(this, "startMove", (e) => { 4643 if ( 4644 this.loaded && 4645 S.event(e) && 4646 ["touchmove", "mousemove"].includes(e.type) && 4647 this.player.media.duration 4648 ) { 4649 if ("touchmove" === e.type) 4650 this.seekTime = 4651 this.player.media.duration * 4652 (this.player.elements.inputs.seek.value / 100); 4653 else { 4654 var t, i; 4655 const s = this.player.elements.progress.getBoundingClientRect(), 4656 n = (100 / s.width) * (e.pageX - s.left); 4657 ((this.seekTime = this.player.media.duration * (n / 100)), 4658 this.seekTime < 0 && (this.seekTime = 0), 4659 this.seekTime > this.player.media.duration - 1 && 4660 (this.seekTime = this.player.media.duration - 1), 4661 (this.mousePosX = e.pageX), 4662 (this.elements.thumb.time.innerText = Ee(this.seekTime))); 4663 const a = 4664 null === (t = this.player.config.markers) || 4665 void 0 === t || 4666 null === (i = t.points) || 4667 void 0 === i 4668 ? void 0 4669 : i.find(({ time: e }) => e === Math.round(this.seekTime)); 4670 a && 4671 this.elements.thumb.time.insertAdjacentHTML( 4672 "afterbegin", 4673 `${a.label}<br>`, 4674 ); 4675 } 4676 this.showImageAtCurrentTime(); 4677 } 4678 }), 4679 e(this, "endMove", () => { 4680 this.toggleThumbContainer(!1, !0); 4681 }), 4682 e(this, "startScrubbing", (e) => { 4683 (S.nullOrUndefined(e.button) || 4684 !1 === e.button || 4685 0 === e.button) && 4686 ((this.mouseDown = !0), 4687 this.player.media.duration && 4688 (this.toggleScrubbingContainer(!0), 4689 this.toggleThumbContainer(!1, !0), 4690 this.showImageAtCurrentTime())); 4691 }), 4692 e(this, "endScrubbing", () => { 4693 ((this.mouseDown = !1), 4694 Math.ceil(this.lastTime) === 4695 Math.ceil(this.player.media.currentTime) 4696 ? this.toggleScrubbingContainer(!1) 4697 : G.call(this.player, this.player.media, "timeupdate", () => { 4698 this.mouseDown || this.toggleScrubbingContainer(!1); 4699 })); 4700 }), 4701 e(this, "listeners", () => { 4702 (this.player.on("play", () => { 4703 this.toggleThumbContainer(!1, !0); 4704 }), 4705 this.player.on("seeked", () => { 4706 this.toggleThumbContainer(!1); 4707 }), 4708 this.player.on("timeupdate", () => { 4709 this.lastTime = this.player.media.currentTime; 4710 })); 4711 }), 4712 e(this, "render", () => { 4713 ((this.elements.thumb.container = $("div", { 4714 class: 4715 this.player.config.classNames.previewThumbnails.thumbContainer, 4716 })), 4717 (this.elements.thumb.imageContainer = $("div", { 4718 class: 4719 this.player.config.classNames.previewThumbnails 4720 .imageContainer, 4721 })), 4722 this.elements.thumb.container.appendChild( 4723 this.elements.thumb.imageContainer, 4724 )); 4725 const e = $("div", { 4726 class: 4727 this.player.config.classNames.previewThumbnails.timeContainer, 4728 }); 4729 ((this.elements.thumb.time = $("span", {}, "00:00")), 4730 e.appendChild(this.elements.thumb.time), 4731 this.elements.thumb.imageContainer.appendChild(e),
4732 S.element(this.player.elements.progress) && 4733 this.player.elements.progress.appendChild( 4734 this.elements.thumb.container, 4735 ), 4736 (this.elements.scrubbing.container = $("div", { 4737 class: 4738 this.player.config.classNames.previewThumbnails 4739 .scrubbingContainer, 4740 })), 4741 this.player.elements.wrapper.appendChild( 4742 this.elements.scrubbing.container, 4743 )); 4744 }), 4745 e(this, "destroy", () => { 4746 (this.elements.thumb.container && 4747 this.elements.thumb.container.remove(), 4748 this.elements.scrubbing.container && 4749 this.elements.scrubbing.container.remove()); 4750 }), 4751 e(this, "showImageAtCurrentTime", () => { 4752 this.mouseDown 4753 ? this.setScrubbingContainerSize() 4754 : this.setThumbContainerSizeAndPos(); 4755 const e = this.thumbnails[0].frames.findIndex( 4756 (e) => 4757 this.seekTime >= e.startTime && this.seekTime <= e.endTime, 4758 ), 4759 t = e >= 0; 4760 let i = 0; 4761 (this.mouseDown || this.toggleThumbContainer(t), 4762 t && 4763 (this.thumbnails.forEach((t, s) => { 4764 this.loadedImages.includes(t.frames[e].text) && (i = s); 4765 }), 4766 e !== this.showingThumb && 4767 ((this.showingThumb = e), this.loadImage(i)))); 4768 }), 4769 e(this, "loadImage", (e = 0) => { 4770 const t = this.showingThumb, 4771 i = this.thumbnails[e], 4772 { urlPrefix: s } = i, 4773 n = i.frames[t], 4774 a = i.frames[t].text, 4775 l = s + a; 4776 if ( 4777 this.currentImageElement && 4778 this.currentImageElement.dataset.filename === a 4779 ) 4780 (this.showImage(this.currentImageElement, n, e, t, a, !1), 4781 (this.currentImageElement.dataset.index = t), 4782 this.removeOldImages(this.currentImageElement)); 4783 else { 4784 this.loadingImage && 4785 this.usingSprites && 4786 (this.loadingImage.onload = null); 4787 const i = new Image(); 4788 ((i.src = l), 4789 (i.dataset.index = t), 4790 (i.dataset.filename = a), 4791 (this.showingThumbFilename = a), 4792 this.player.debug.log(`Loading image: ${l}`), 4793 (i.onload = () => this.showImage(i, n, e, t, a, !0)), 4794 (this.loadingImage = i), 4795 this.removeOldImages(i)); 4796 } 4797 }), 4798 e(this, "showImage", (e, t, i, s, n, a = !0) => { 4799 (this.player.debug.log( 4800 `Showing thumb: ${n}. num: ${s}. qual: ${i}. newimg: ${a}`, 4801 ), 4802 this.setImageSizeAndOffset(e, t), 4803 a && 4804 (this.currentImageContainer.appendChild(e), 4805 (this.currentImageElement = e), 4806 this.loadedImages.includes(n) || this.loadedImages.push(n)), 4807 this.preloadNearby(s, !0) 4808 .then(this.preloadNearby(s, !1)) 4809 .then(this.getHigherQuality(i, e, t, n))); 4810 }), 4811 e(this, "removeOldImages", (e) => { 4812 Array.from(this.currentImageContainer.children).forEach((t) => { 4813 if ("img" !== t.tagName.toLowerCase()) return; 4814 const i = this.usingSprites ? 500 : 1e3; 4815 if (t.dataset.index !== e.dataset.index && !t.dataset.deleting) { 4816 t.dataset.deleting = !0; 4817 const { currentImageContainer: e } = this; 4818 setTimeout(() => { 4819 (e.removeChild(t), 4820 this.player.debug.log( 4821 `Removing thumb: ${t.dataset.filename}`, 4822 )); 4823 }, i); 4824 } 4825 }); 4826 }), 4827 e( 4828 this, 4829 "preloadNearby", 4830 (e, t = !0) => 4831 new Promise((i) => { 4832 setTimeout(() => {
4833 const s = this.thumbnails[0].frames[e].text; 4834 if (this.showingThumbFilename === s) { 4835 let n; 4836 n = t 4837 ? this.thumbnails[0].frames.slice(e) 4838 : this.thumbnails[0].frames.slice(0, e).reverse(); 4839 let a = !1; 4840 (n.forEach((e) => { 4841 const t = e.text; 4842 if (t !== s && !this.loadedImages.includes(t)) { 4843 ((a = !0), 4844 this.player.debug.log( 4845 `Preloading thumb filename: ${t}`, 4846 )); 4847 const { urlPrefix: e } = this.thumbnails[0], 4848 s = e + t, 4849 n = new Image(); 4850 ((n.src = s), 4851 (n.onload = () => { 4852 (this.player.debug.log( 4853 `Preloaded thumb filename: ${t}`, 4854 ), 4855 this.loadedImages.includes(t) || 4856 this.loadedImages.push(t), 4857 i()); 4858 })); 4859 } 4860 }), 4861 a || i()); 4862 } 4863 }, 300); 4864 }), 4865 ), 4866 e(this, "getHigherQuality", (e, t, i, s) => { 4867 if (e < this.thumbnails.length - 1) { 4868 let n = t.naturalHeight; 4869 (this.usingSprites && (n = i.h), 4870 n < this.thumbContainerHeight && 4871 setTimeout(() => { 4872 this.showingThumbFilename === s && 4873 (this.player.debug.log( 4874 `Showing higher quality thumb for: ${s}`, 4875 ), 4876 this.loadImage(e + 1)); 4877 }, 300)); 4878 } 4879 }), 4880 e(this, "toggleThumbContainer", (e = !1, t = !1) => { 4881 const i = 4882 this.player.config.classNames.previewThumbnails 4883 .thumbContainerShown; 4884 (this.elements.thumb.container.classList.toggle(i, e), 4885 !e && 4886 t && 4887 ((this.showingThumb = null), 4888 (this.showingThumbFilename = null))); 4889 }), 4890 e(this, "toggleScrubbingContainer", (e = !1) => { 4891 const t = 4892 this.player.config.classNames.previewThumbnails 4893 .scrubbingContainerShown; 4894 (this.elements.scrubbing.container.classList.toggle(t, e), 4895 e || 4896 ((this.showingThumb = null), 4897 (this.showingThumbFilename = null))); 4898 }), 4899 e(this, "determineContainerAutoSizing", () => { 4900 (this.elements.thumb.imageContainer.clientHeight > 20 || 4901 this.elements.thumb.imageContainer.clientWidth > 20) && 4902 (this.sizeSpecifiedInCSS = !0); 4903 }), 4904 e(this, "setThumbContainerSizeAndPos", () => { 4905 const { imageContainer: e } = this.elements.thumb; 4906 if (this.sizeSpecifiedInCSS) { 4907 if (e.clientHeight > 20 && e.clientWidth < 20) { 4908 const t = Math.floor(e.clientHeight * this.thumbAspectRatio); 4909 e.style.width = `${t}px`; 4910 } else if (e.clientHeight < 20 && e.clientWidth > 20) { 4911 const t = Math.floor(e.clientWidth / this.thumbAspectRatio); 4912 e.style.height = `${t}px`; 4913 } 4914 } else { 4915 const t = Math.floor( 4916 this.thumbContainerHeight * this.thumbAspectRatio, 4917 ); 4918 ((e.style.height = `${this.thumbContainerHeight}px`), 4919 (e.style.width = `${t}px`)); 4920 } 4921 this.setThumbContainerPos(); 4922 }), 4923 e(this, "setThumbContainerPos", () => { 4924 const e = this.player.elements.progress.getBoundingClientRect(), 4925 t = this.player.elements.container.getBoundingClientRect(), 4926 { container: i } = this.elements.thumb, 4927 s = t.left - e.left + 10, 4928 n = t.right - e.left - i.clientWidth - 10, 4929 a = this.mousePosX - e.left - i.clientWidth / 2, 4930 l = Ge(a, s, n); 4931 ((i.style.left = `${l}px`), 4932 i.style.setProperty("--preview-arrow-offset", a - l + "px")); 4933 }), 4934 e(this, "setScrubbingContainerSize", () => { 4935 const { width: e, height: t } = et(this.thumbAspectRatio, { 4936 width: this.player.media.clientWidth, 4937 height: this.player.media.clientHeight, 4938 }); 4939 ((this.elements.scrubbing.container.style.width = `${e}px`), 4940 (this.elements.scrubbing.container.style.height = `${t}px`)); 4941 }), 4942 e(this, "setImageSizeAndOffset", (e, t) => { 4943 if (!this.usingSprites) return; 4944 const i = this.thumbContainerHeight / t.h; 4945 ((e.style.height = e.naturalHeight * i + "px"),
4946 (e.style.width = e.naturalWidth * i + "px"), 4947 (e.style.left = `-${t.x * i}px`), 4948 (e.style.top = `-${t.y * i}px`)); 4949 }), 4950 (this.player = t), 4951 (this.thumbnails = []), 4952 (this.loaded = !1), 4953 (this.lastMouseMoveTime = Date.now()), 4954 (this.mouseDown = !1), 4955 (this.loadedImages = []), 4956 (this.elements = { thumb: {}, scrubbing: {} }), 4957 this.load()); 4958 } 4959 get enabled() { 4960 return ( 4961 this.player.isHTML5 && 4962 this.player.isVideo && 4963 this.player.config.previewThumbnails.enabled 4964 ); 4965 } 4966 get currentImageContainer() { 4967 return this.mouseDown 4968 ? this.elements.scrubbing.container 4969 : this.elements.thumb.imageContainer; 4970 } 4971 get usingSprites() { 4972 return Object.keys(this.thumbnails[0].frames[0]).includes("w"); 4973 } 4974 get thumbAspectRatio() { 4975 return this.usingSprites 4976 ? this.thumbnails[0].frames[0].w / this.thumbnails[0].frames[0].h 4977 : this.thumbnails[0].width / this.thumbnails[0].height; 4978 } 4979 get thumbContainerHeight() { 4980 if (this.mouseDown) { 4981 const { height: e } = et(this.thumbAspectRatio, { 4982 width: this.player.media.clientWidth, 4983 height: this.player.media.clientHeight, 4984 }); 4985 return e; 4986 } 4987 return this.sizeSpecifiedInCSS 4988 ? this.elements.thumb.imageContainer.clientHeight 4989 : Math.floor( 4990 this.player.media.clientWidth / this.thumbAspectRatio / 4, 4991 ); 4992 } 4993 get currentImageElement() { 4994 return this.mouseDown 4995 ? this.currentScrubbingImageElement 4996 : this.currentThumbnailImageElement; 4997 } 4998 set currentImageElement(e) { 4999 this.mouseDown 5000 ? (this.currentScrubbingImageElement = e) 5001 : (this.currentThumbnailImageElement = e); 5002 } 5003 } 5004 const it = { 5005 insertElements(e, t) { 5006 S.string(t) 5007 ? _(e, this.media, { src: t }) 5008 : S.array(t) && 5009 t.forEach((t) => { 5010 _(e, this.media, t); 5011 }); 5012 }, 5013 change(e) { 5014 N(e, "sources.length") 5015 ? (de.cancelRequests.call(this), 5016 this.destroy.call( 5017 this, 5018 () => { 5019 ((this.options.quality = []), 5020 O(this.media), 5021 (this.media = null), 5022 S.element(this.elements.container) && 5023 this.elements.container.removeAttribute("class")); 5024 const { sources: t, type: i } = e, 5025 [{ provider: s = _e.html5, src: n }] = t, 5026 a = "html5" === s ? i : "div", 5027 l = "html5" === s ? {} : { src: n }; 5028 (Object.assign(this, { 5029 provider: s, 5030 type: i, 5031 supported: K.check(i, s, this.config.playsinline), 5032 media: $(a, l), 5033 }), 5034 this.elements.container.appendChild(this.media), 5035 S.boolean(e.autoplay) && (this.config.autoplay = e.autoplay), 5036 this.isHTML5 && 5037 (this.config.crossorigin && 5038 this.media.setAttribute("crossorigin", ""), 5039 this.config.autoplay && 5040 this.media.setAttribute("autoplay", ""), 5041 S.empty(e.poster) || (this.poster = e.poster), 5042 this.config.loop.active && 5043 this.media.setAttribute("loop", ""), 5044 this.config.muted && this.media.setAttribute("muted", ""), 5045 this.config.playsinline && 5046 this.media.setAttribute("playsinline", "")), 5047 Fe.addStyleHook.call(this), 5048 this.isHTML5 && it.insertElements.call(this, "source", t), 5049 (this.config.title = e.title), 5050 Xe.setup.call(this), 5051 this.isHTML5 && 5052 Object.keys(e).includes("tracks") && 5053 it.insertElements.call(this, "track", e.tracks), 5054 (this.isHTML5 || (this.isEmbed && !this.supported.ui)) && 5055 Fe.build.call(this), 5056 this.isHTML5 && this.media.load(), 5057 S.empty(e.previewThumbnails) || 5058 (Object.assign( 5059 this.config.previewThumbnails, 5060 e.previewThumbnails, 5061 ), 5062 this.previewThumbnails && 5063 this.previewThumbnails.loaded && 5064 (this.previewThumbnails.destroy(), 5065 (this.previewThumbnails = null)), 5066 this.config.previewThumbnails.enabled && 5067 (this.previewThumbnails = new tt(this))), 5068 this.fullscreen.update()); 5069 }, 5070 !0, 5071 )) 5072 : this.debug.warn("Invalid source format"); 5073 }, 5074 }; 5075 class st { 5076 constructor(t, i) { 5077 if ( 5078 (e(this, "play", () => 5079 S.function(this.media.play) 5080 ? (this.ads && 5081 this.ads.enabled && 5082 this.ads.managerPromise 5083 .then(() => this.ads.play()) 5084 .catch(() => ie(this.media.play())), 5085 this.media.play()) 5086 : null, 5087 ), 5088 e(this, "pause", () => 5089 this.playing && S.function(this.media.pause) 5090 ? this.media.pause() 5091 : null, 5092 ), 5093 e(this, "togglePlay", (e) => 5094 (S.boolean(e) ? e : !this.playing) ? this.play() : this.pause(), 5095 ), 5096 e(this, "stop", () => { 5097 this.isHTML5 5098 ? (this.pause(), this.restart()) 5099 : S.function(this.media.stop) && this.media.stop(); 5100 }), 5101 e(this, "restart", () => { 5102 this.currentTime = 0; 5103 }), 5104 e(this, "rewind", (e) => { 5105 this.currentTime -= S.number(e) ? e : this.config.seekTime; 5106 }), 5107 e(this, "forward", (e) => { 5108 this.currentTime += S.number(e) ? e : this.config.seekTime; 5109 }), 5110 e(this, "increaseVolume", (e) => { 5111 const t = this.media.muted ? 0 : this.volume; 5112 this.volume = t + (S.number(e) ? e : 0); 5113 }), 5114 e(this, "decreaseVolume", (e) => { 5115 this.increaseVolume(-e); 5116 }), 5117 e(this, "airplay", () => { 5118 K.airplay && this.media.webkitShowPlaybackTargetPicker(); 5119 }), 5120 e(this, "toggleControls", (e) => { 5121 if (this.supported.ui && !this.isAudio) { 5122 const t = F( 5123 this.elements.container, 5124 this.config.classNames.hideControls, 5125 ), 5126 i = void 0 === e ? void 0 : !e, 5127 s = R( 5128 this.elements.container, 5129 this.config.classNames.hideControls, 5130 i, 5131 ); 5132 if ( 5133 (s && 5134 S.array(this.config.controls) && 5135 this.config.controls.includes("settings") && 5136 !S.empty(this.config.settings) && 5137 Pe.toggleMenu.call(this, !1), 5138 s !== t) 5139 ) { 5140 const e = s ? "controlshidden" : "controlsshown"; 5141 Z.call(this, this.media, e); 5142 } 5143 return !s; 5144 } 5145 return !1; 5146 }), 5147 e(this, "on", (e, t) => { 5148 X.call(this, this.elements.container, e, t); 5149 }), 5150 e(this, "once", (e, t) => { 5151 G.call(this, this.elements.container, e, t); 5152 }), 5153 e(this, "off", (e, t) => { 5154 J(this.elements.container, e, t); 5155 }), 5156 e(this, "destroy", (e, t = !1) => { 5157 if (!this.ready) return; 5158 const i = () => { 5159 ((document.body.style.overflow = ""), 5160 (this.embed = null),
5161 t 5162 ? (Object.keys(this.elements).length && 5163 (O(this.elements.buttons.play), 5164 O(this.elements.captions), 5165 O(this.elements.controls), 5166 O(this.elements.wrapper), 5167 (this.elements.buttons.play = null), 5168 (this.elements.captions = null), 5169 (this.elements.controls = null), 5170 (this.elements.wrapper = null)), 5171 S.function(e) && e()) 5172 : (ee.call(this), 5173 de.cancelRequests.call(this), 5174 q(this.elements.original, this.elements.container), 5175 Z.call(this, this.elements.original, "destroyed", !0), 5176 S.function(e) && e.call(this.elements.original), 5177 (this.ready = !1), 5178 setTimeout(() => { 5179 ((this.elements = null), (this.media = null)); 5180 }, 200))); 5181 }; 5182 (this.stop(), 5183 clearTimeout(this.timers.loading), 5184 clearTimeout(this.timers.controls), 5185 clearTimeout(this.timers.resized), 5186 this.isHTML5 5187 ? (Fe.toggleNativeControls.call(this, !0), i()) 5188 : this.isYouTube 5189 ? (clearInterval(this.timers.buffering), 5190 clearInterval(this.timers.playing), 5191 null !== this.embed && 5192 S.function(this.embed.destroy) && 5193 this.embed.destroy(), 5194 i()) 5195 : this.isVimeo && 5196 (null !== this.embed && this.embed.unload().then(i), 5197 setTimeout(i, 200))); 5198 }), 5199 e(this, "supports", (e) => K.mime.call(this, e)), 5200 (this.timers = {}), 5201 (this.ready = !1), 5202 (this.loading = !1), 5203 (this.failed = !1), 5204 (this.touch = K.touch), 5205 (this.media = t), 5206 S.string(this.media) && 5207 (this.media = document.querySelectorAll(this.media)), 5208 ((window.jQuery && this.media instanceof jQuery) || 5209 S.nodeList(this.media) || 5210 S.array(this.media)) && 5211 (this.media = this.media[0]), 5212 (this.config = x( 5213 {}, 5214 Le, 5215 st.defaults, 5216 i || {}, 5217 (() => { 5218 try { 5219 return JSON.parse(this.media.getAttribute("data-plyr-config")); 5220 } catch (e) { 5221 return {}; 5222 } 5223 })(), 5224 )), 5225 (this.elements = { 5226 container: null, 5227 fullscreen: null, 5228 captions: null, 5229 buttons: {}, 5230 display: {}, 5231 progress: {}, 5232 inputs: {}, 5233 settings: { popup: null, menu: null, panels: {}, buttons: {} }, 5234 }), 5235 (this.captions = { 5236 active: null, 5237 currentTrack: -1, 5238 meta: new WeakMap(), 5239 }), 5240 (this.fullscreen = { active: !1 }), 5241 (this.options = { speed: [], quality: [] }), 5242 (this.debug = new De(this.config.debug)), 5243 this.debug.log("Config", this.config), 5244 this.debug.log("Support", K), 5245 S.nullOrUndefined(this.media) || !S.element(this.media)) 5246 ) 5247 return void this.debug.error( 5248 "Setup failed: no suitable element passed", 5249 ); 5250 if (this.media.plyr) 5251 return void this.debug.warn("Target already setup"); 5252 if (!this.config.enabled) 5253 return void this.debug.error("Setup failed: disabled by config"); 5254 if (!K.check().api) 5255 return void this.debug.error("Setup failed: no support"); 5256 const s = this.media.cloneNode(!0); 5257 ((s.autoplay = !1), (this.elements.original = s)); 5258 const n = this.media.tagName.toLowerCase(); 5259 let a = null, 5260 l = null; 5261 switch (n) { 5262 case "div": 5263 if (((a = this.media.querySelector("iframe")), S.element
5263(a))) { 5264 if ( 5265 ((l = Me(a.getAttribute("src"))), 5266 (this.provider = (function (e) { 5267 return /^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test( 5268 e, 5269 ) 5270 ? _e.youtube 5271 : /^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test( 5272 e, 5273 ) 5274 ? _e.vimeo 5275 : null; 5276 })(l.toString())), 5277 (this.elements.container = this.media), 5278 (this.media = a), 5279 (this.elements.container.className = ""), 5280 l.search.length) 5281 ) { 5282 const e = ["1", "true"]; 5283 (e.includes(l.searchParams.get("autoplay")) && 5284 (this.config.autoplay = !0), 5285 e.includes(l.searchParams.get("loop")) && 5286 (this.config.loop.active = !0), 5287 this.isYouTube 5288 ? ((this.config.playsinline = e.includes( 5289 l.searchParams.get("playsinline"), 5290 )), 5291 (this.config.youtube.hl = l.searchParams.get("hl"))) 5292 : (this.config.playsinline = !0)); 5293 } 5294 } else 5295 ((this.provider = this.media.getAttribute( 5296 this.config.attributes.embed.provider, 5297 )), 5298 this.media.removeAttribute( 5299 this.config.attributes.embed.provider, 5300 )); 5301 if ( 5302 S.empty(this.provider) || 5303 !Object.values(_e).includes(this.provider) 5304 ) 5305 return void this.debug.error("Setup failed: Invalid provider"); 5306 this.type = je; 5307 break; 5308 case "video": 5309 case "audio": 5310 ((this.type = n), 5311 (this.provider = _e.html5), 5312 this.media.hasAttribute("crossorigin") && 5313 (this.config.crossorigin = !0), 5314 this.media.hasAttribute("autoplay") && 5315 (this.config.autoplay = !0), 5316 (this.media.hasAttribute("playsinline") || 5317 this.media.hasAttribute("webkit-playsinline")) && 5318 (this.config.playsinline = !0), 5319 this.media.hasAttribute("muted") && (this.config.muted = !0), 5320 this.media.hasAttribute("loop") && 5321 (this.config.loop.active = !0)); 5322 break; 5323 default: 5324 return void this.debug.error("Setup failed: unsupported type"); 5325 } 5326 ((this.supported = K.check(this.type, this.provider)), 5327 this.supported.api 5328 ? ((this.eventListeners = []), 5329 (this.listeners = new Ve(this)), 5330 (this.storage = new we(this)), 5331 (this.media.plyr = this), 5332 S.element(this.elements.container) || 5333 ((this.elements.container = $("div")), 5334 L(this.media, this.elements.container)), 5335 Fe.migrateStyles.call(this), 5336 Fe.addStyleHook.call(this), 5337 Xe.setup.call(this), 5338 this.config.debug && 5339 X.call( 5340 this, 5341 this.elements.container, 5342 this.config.events.join(" "), 5343 (e) => { 5344 this.debug.log(`event: ${e.type}`); 5345 }, 5346 ), 5347 (this.fullscreen = new He(this)), 5348 (this.isHTML5 || (this.isEmbed && !this.supported.ui)) && 5349 Fe.build.call(this), 5350 this.listeners.container(), 5351 this.listeners.global(), 5352 this.config.ads.enabled && (this.ads = new Je(this)), 5353 this.isHTML5 && 5354 this.config.autoplay && 5355 this.once("canplay", () => ie(this.play())), 5356 (this.lastSeekTime = 0), 5357 this.config.previewThumbnails.enabled && 5358 (this.previewThumbnails = new tt(this))) 5359 : this.debug.error("Setup failed: no support")); 5360 } 5361 get isHTML5() { 5362 return this.provider === _e.html5; 5363 } 5364 get isEmbed() { 5365 return this.isYouTube || this.isVimeo; 5366 } 5367 get isYouTube() { 5368 return this.provider === _e.youtube; 5369 } 5370 get isVimeo() { 5371 return this.provider === _e.vimeo; 5372 } 5373 get isVideo() { 5374 return this.type === je; 5375 } 5376 get isAudio() { 5377 return this.type === Oe; 5378 } 5379 get playing() { 5380 return Boolean(this.ready && !this.paused && !this.ended); 5381 } 5382 get paused() { 5383 return Boolean(this.media.paused); 5384 } 5385 get stopped() { 5386 return Boolean(this.paused && 0 === this.currentTime); 5387 } 5388 get ended() { 5389 return Boolean(this.media.ended); 5390 } 5391 set currentTime(e) { 5392 if (!this.duration) return; 5393 const t = S.number(e) && e > 0; 5394 ((this.media.currentTime = t ? Math.min(e, this.duration) : 0), 5395 this.debug.log(`Seeking to ${this.currentTime} seconds`)); 5396 } 5397 get currentTime() { 5398 return Number(this.media.currentTime); 5399 } 5400 get buffered() { 5401 const { buffered: e } = this.media; 5402 return S.number(e) 5403 ? e 5404 : e && e.length && this.duration > 0 5405 ? e.end(0) / this.duration 5406 : 0; 5407 } 5408 get seeking() { 5409 return Boolean(this.media.seeking); 5410 } 5411 get duration() { 5412 const e = parseFloat(this.config.duration), 5413 t = (this.media || {}).duration, 5414 i = S.number(t) && t !== 1 / 0 ? t : 0; 5415 return e || i; 5416 } 5417 set volume(e) { 5418 let t = e; 5419 (S.string(t) && (t = Number(t)), 5420 S.number(t) || (t = this.storage.get("volume")), 5421 S.number(t) || ({ volume: t } = this.config), 5422 t > 1 && (t = 1), 5423 t < 0 && (t = 0), 5424 (this.config.volume = t), 5425 (this.media.volume = t), 5426 !S.empty(e) && this.muted && t > 0 && (this.muted = !1)); 5427 } 5428 get volume() { 5429 return Number(this.media.volume); 5430 } 5431 set muted(e) { 5432 let t = e; 5433 (S.boolean(t) || (t = this.storage.get("muted")), 5434 S.boolean(t) || (t = this.config.muted), 5435 (this.config.muted = t), 5436 (this.media.muted = t)); 5437 } 5438 get muted() { 5439 return Boolean(this.media.muted); 5440 } 5441 get hasAudio() { 5442 return ( 5443 !this.isHTML5 || 5444 !!this.isAudio || 5445 Boolean(this.media.mozHasAudio) || 5446 Boolean(this.media.webkitAudioDecodedByteCount) || 5447 Boolean(this.media.audioTracks && this.media.audioTracks.length) 5448 ); 5449 } 5450 set speed(e) { 5451 let t = null; 5452 (S.number(e) && (t = e), 5453 S.number(t) || (t = this.storage.get("speed")), 5454 S.number(t) || (t = this.config.speed.selected)); 5455 const { minimumSpeed: i, maximumSpeed: s } = this; 5456 ((t = Ge(t, i, s)), 5457 (this.config.speed.selected = t), 5458 setTimeout(() => { 5459 this.media && (this.media.playbackRate = t); 5460 }, 0)); 5461 } 5462 get speed() { 5463 return Number(this.media.playbackRate); 5464 } 5465 get minimumSpeed() { 5466 return this.isYouTube 5467 ? Math.min(...this.options.speed) 5468 : this.isVimeo 5469 ? 0.5 5470 : 0.0625; 5471 } 5472 get maximumSpeed() { 5473 return this.isYouTube 5474 ? Math.max(...this.options.speed) 5475 : this.isVimeo 5476 ? 2 5477 : 16; 5478 } 5479 set quality(e) { 5480 const t = this.config.quality, 5481 i = this.options.quality; 5482 if (!i.length) return; 5483 let s = [ 5484 !S.empty(e) && Number(e), 5485 this.storage.get("quality"), 5486 t.selected, 5487 t.default, 5488 ].find(S.number), 5489 n = !0; 5490 if (!i.includes(s)) { 5491 const e = ne(i, s); 5492 (this.debug.warn( 5493 `Unsupported quality option: ${s}, using ${e} instead`, 5494 ), 5495 (s = e), 5496 (n = !1)); 5497 } 5498 ((t.selected = s), 5499 (this.media.quality = s), 5500 n && this.storage.set({ quality: s })); 5501 }
5502 get quality() { 5503 return this.media.quality; 5504 } 5505 set loop(e) { 5506 const t = S.boolean(e) ? e : this.config.loop.active; 5507 ((this.config.loop.active = t), (this.media.loop = t)); 5508 } 5509 get loop() { 5510 return Boolean(this.media.loop); 5511 } 5512 set source(e) { 5513 it.change.call(this, e); 5514 } 5515 get source() { 5516 return this.media.currentSrc; 5517 } 5518 get download() { 5519 const { download: e } = this.config.urls; 5520 return S.url(e) ? e : this.source; 5521 } 5522 set download(e) { 5523 S.url(e) && 5524 ((this.config.urls.download = e), Pe.setDownloadUrl.call(this)); 5525 } 5526 set poster(e) { 5527 this.isVideo 5528 ? Fe.setPoster.call(this, e, !1).catch(() => {}) 5529 : this.debug.warn("Poster can only be set for video"); 5530 } 5531 get poster() { 5532 return this.isVideo 5533 ? this.media.getAttribute("poster") || 5534 this.media.getAttribute("data-poster") 5535 : null; 5536 } 5537 get ratio() { 5538 if (!this.isVideo) return null; 5539 const e = oe(ce.call(this)); 5540 return S.array(e) ? e.join(":") : e; 5541 } 5542 set ratio(e) { 5543 this.isVideo 5544 ? S.string(e) && re(e) 5545 ? ((this.config.ratio = oe(e)), ue.call(this)) 5546 : this.debug.error(`Invalid aspect ratio specified (${e})`) 5547 : this.debug.warn("Aspect ratio can only be set for video"); 5548 } 5549 set autoplay(e) { 5550 this.config.autoplay = S.boolean(e) ? e : this.config.autoplay; 5551 } 5552 get autoplay() { 5553 return Boolean(this.config.autoplay); 5554 } 5555 toggleCaptions(e) { 5556 xe.toggle.call(this, e, !1); 5557 } 5558 set currentTrack(e) { 5559 (xe.set.call(this, e, !1), xe.setup.call(this)); 5560 } 5561 get currentTrack() { 5562 const { toggled: e, currentTrack: t } = this.captions; 5563 return e ? t : -1; 5564 } 5565 set language(e) { 5566 xe.setLanguage.call(this, e, !1); 5567 } 5568 get language() { 5569 return (xe.getCurrentTrack.call(this) || {}).language; 5570 } 5571 set pip(e) { 5572 if (!K.pip) return; 5573 const t = S.boolean(e) ? e : !this.pip; 5574 (S.function(this.media.webkitSetPresentationMode) && 5575 this.media.webkitSetPresentationMode(t ? Ie : $e), 5576 S.function(this.media.requestPictureInPicture) && 5577 (!this.pip && t 5578 ? this.media.requestPictureInPicture() 5579 : this.pip && !t && document.exitPictureInPicture())); 5580 } 5581 get pip() { 5582 return K.pip 5583 ? S.empty(this.media.webkitPresentationMode) 5584 ? this.media === document.pictureInPictureElement 5585 : this.media.webkitPresentationMode === Ie 5586 : null; 5587 } 5588 setPreviewThumbnails(e) { 5589 (this.previewThumbnails && 5590 this.previewThumbnails.loaded && 5591 (this.previewThumbnails.destroy(), (this.previewThumbnails = null)), 5592 Object.assign(this.config.previewThumbnails, e), 5593 this.config.previewThumbnails.enabled && 5594 (this.previewThumbnails = new tt(this))); 5595 } 5596 static supported(e, t) { 5597 return K.check(e, t); 5598 } 5599 static loadSprite(e, t) { 5600 return ke(e, t); 5601 } 5602 static setup(e, t = {}) { 5603 let i = null; 5604 return ( 5605 S.string(e) 5606 ? (i = Array.from(document.querySelectorAll(e))) 5607 : S.nodeList(e) 5608 ? (i = Array.from(e)) 5609 : S.array(e) && (i = e.filter(S.element)), 5610 S.empty(i) ? null : i.map((e) => new st(e, t)) 5611 ); 5612 } 5613 } 5614 var nt; 5615 return ((st.defaults = ((nt = Le), JSON.parse(JSON.stringify(nt)))), st); 5616 }); 5617//# sourceMappingURL=plyr.js.map
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.