From efb26facd086108421d05af194eec941467540bf Mon Sep 17 00:00:00 2001 From: Arkadii Shvartsman Date: Thu, 5 Oct 2023 21:21:18 +0200 Subject: [PATCH 1/8] hls js as part of OvenPlayer --- demo/test.html | 1311 ++++++++++++++++++++ dist/ovenplayer.js | 2 +- dist/ovenplayer.js.map | 2 +- docs/README.md | 9 +- package-lock.json | 312 +++-- package.json | 3 +- src/js/api/provider/html5/providers/Hls.js | 4 +- 7 files changed, 1505 insertions(+), 138 deletions(-) create mode 100644 demo/test.html diff --git a/demo/test.html b/demo/test.html new file mode 100644 index 00000000..c88195d9 --- /dev/null +++ b/demo/test.html @@ -0,0 +1,1311 @@ + + + + + + + + + OvenPlayer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+
+ + +
+ +
+
+
+
+
+ + + {{playerMessage}} + +
+
+
+ +
+
+
+ +
+
+ +
    +
  • +
    Sources
    + OvenPlayer + {{playerVersion}} + +
  • +
    +

    Test streams with OvenPlayer

    + +
      +
    • + Sub-Second Latency: WebRTC (Signalling Protocol Conforms to the OME + Specification) +
    • +
    • + Low-Latency HLS +
    • +
    +

    To play the stream of OvenMediaEngine, please refer to the following + documents.

    + +
    + + +
+
+
+ +
+
+
    +
  • +
    Player Options
    +
  • +
  • + +
    +
    + +
    General Options
    +
    +
    + + + + + +
    +
    + + + + + +
    +
    + + + + + +
    +
    +
    +
    + +
    WebRTC Options
    +
    +
    + + + + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + + + + +
    +
    + + +
    +
    +
    +
    + +
    HLS Options
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + FairPlay +
    +
    + + +
    +
    + + +
    +
    + Widevine +
    +
    + + +
    +
    +
    +
    +
  • +
  • +
    Demo Options
    +
  • +
  • +
    +
    +
    Reload the player when error occurred
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
  • +
+
+
+
    +
  • +
    Usage
    +
  • +
  • +
    +
    + +
  • +
+
+
+
    +
  • +
    Export permanent link
    +
  • +
  • + +
    +
    + +
    + +
    + +
  • +
+
+
+
+
+
+
+
+
+
+
+ AirenSoft +
+

+ Media Technology Expert Group +

+

+ Our mission is to build a powerful media world by making it easier for everyone to + use all the complex and demanding media technologies of the world. +

+
+ +
+ +
+
OPEN SOURCE PROJECTS
+

+ OvenMediaEngine +

+

+ OvenPlayer +

+

+ OvenLiveKit-Web +

+

+ OvenSpace +

+
+ +
+ +
+
Contact
+

#1203, Twenty First Valley, 157, Yangpyeong-ro, + Yeongdeungpo-gu, Seoul, 07207 Republic of Korea

+

contact@airensoft.com

+

+82-2-6378-5227

+
+
+ +
+ +
+ +
+
+
+
+ © 2022 Copyright: + AirenSoft + Co., Ltd. All rights reserved. +
+
+ +
+ + + + + + + + + + + +
+
+
+
+
+
+
+ + + + + + + + + + + diff --git a/dist/ovenplayer.js b/dist/ovenplayer.js index 4fa01624..4df62414 100644 --- a/dist/ovenplayer.js +++ b/dist/ovenplayer.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.OvenPlayer=t():e.OvenPlayer=t()}(self,(function(){return function(){var e={8445:function(e,t,n){"use strict";n.d(t,{default:function(){return Ar}});var r="0.10.31",o=n(741),i=n.n(o);function a(e){return e?e.replace(/^\s+|\s+$/g,""):""}var A=function(e){if(!e||"rtmp"==e.substr(0,4))return"";var t=function(e){var t="";return/[(,]format=mpd-/i.test(e)?t="mpd":/[(,]format=m3u8-/i.test(e)&&(t="m3u8"),t}(e);return t||((e=e.split("?")[0].split("#")[0]).lastIndexOf(".")>-1?e.substr(e.lastIndexOf(".")+1,e.length).toLowerCase():"")};function s(e){var t=parseInt(e,10);if(!e)return"00:00";var n=Math.floor(t/3600),r=Math.floor((t-3600*n)/60),o=t-3600*n-60*r;return r<10&&(r="0"+r),o<10&&(o="0"+o),n>0?n+":"+r+":"+o:r+":"+o}function c(e,t){if(!e)return 0;if(i().isNumber(e)&&!i().isNaN(e))return e;var n=(e=e.replace(",",".")).split(":"),r=n.length,o=0;if("s"===e.slice(-1))o=parseFloat(e);else if("m"===e.slice(-1))o=60*parseFloat(e);else if("h"===e.slice(-1))o=3600*parseFloat(e);else if(r>1){var a=r-1;4===r&&(t&&(o=parseFloat(n[a])/t),a-=1),o+=parseFloat(n[a]),o+=60*parseFloat(n[a-1]),r>=3&&(o+=3600*parseFloat(n[a-2]))}else o=parseFloat(e);return i().isNaN(o)?0:o}function u(e){var t={},n=e.split("\r\n");1===n.length&&(n=e.split("\n"));var r=1;if(n[0].indexOf(" --\x3e ")>0&&(r=0),n.length>r+1&&n[r+1]){var o=n[r],i=o.indexOf(" --\x3e ");i>0&&(t.start=c(o.substr(0,i)),t.end=c(o.substr(i+5)),t.text=n.slice(r+1).join("\r\n"))}return t}var l=window.VTTCue,f={"":!0,lr:!0,rl:!0},p={start:!0,middle:!0,end:!0,left:!0,right:!0};function d(e){return"string"==typeof e&&!!p[e.toLowerCase()]&&e.toLowerCase()}function g(e){for(var t=1;t100)throw new Error("Position must be between 0 and 100.");C=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"positionAlign",g({},i,{get:function(){return y},set:function(e){var t=d(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(r,"size",g({},i,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"align",g({},i,{get:function(){return w},set:function(e){var t=d(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),r.displayState=void 0,o)return r}).prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)});var h=l,v={"":!0,up:!0};function m(e){return"number"==typeof e&&e>=0&&e<=100}var C=function(){var e=100,t=3,n=0,r=100,o=0,i=100,a="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return e},set:function(t){if(!m(t))throw new Error("Width must be between 0 and 100.");e=t}},lines:{enumerable:!0,get:function(){return t},set:function(e){if("number"!=typeof e)throw new TypeError("Lines must be set to a number.");t=e}},regionAnchorY:{enumerable:!0,get:function(){return r},set:function(e){if(!m(e))throw new Error("RegionAnchorX must be between 0 and 100.");r=e}},regionAnchorX:{enumerable:!0,get:function(){return n},set:function(e){if(!m(e))throw new Error("RegionAnchorY must be between 0 and 100.");n=e}},viewportAnchorY:{enumerable:!0,get:function(){return i},set:function(e){if(!m(e))throw new Error("ViewportAnchorY must be between 0 and 100.");i=e}},viewportAnchorX:{enumerable:!0,get:function(){return o},set:function(e){if(!m(e))throw new Error("ViewportAnchorX must be between 0 and 100.");o=e}},scroll:{enumerable:!0,get:function(){return a},set:function(e){var t=function(e){return"string"==typeof e&&!!v[e.toLowerCase()]&&e.toLowerCase()}(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");a=t}}})},y=function(){};function b(e,t){return void 0===t&&(t=1),"rgba("+[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16),t].join(",")+")"}var w=1;function E(e,t,n){switch(n){case"webvtt.font.color":case"webvtt.font.opacity":var r=Services.prefs.getCharPref("webvtt.font.color"),o=Services.prefs.getIntPref("webvtt.font.opacity")/100;B.fontSet=b(r,o);break;case"webvtt.font.scale":w=Services.prefs.getIntPref("webvtt.font.scale")/100;break;case"webvtt.bg.color":case"webvtt.bg.opacity":var i=Services.prefs.getCharPref("webvtt.bg.color"),a=Services.prefs.getIntPref("webvtt.bg.opacity")/100;B.backgroundSet=b(i,a);break;case"webvtt.edge.color":case"webvtt.edge.type":var A=Services.prefs.getIntPref("webvtt.edge.type"),s=Services.prefs.getCharPref("webvtt.edge.color");B.edgeSet=["","0px 0px ","4px 4px 4px ","-2px -2px ","2px 2px "][A]+b(s)}}if("undefined"!=typeof Services){var B={};["webvtt.font.color","webvtt.font.opacity","webvtt.font.scale","webvtt.bg.color","webvtt.bg.opacity","webvtt.edge.color","webvtt.edge.type"].forEach((function(e){E(0,0,e),Services.prefs.addObserver(e,E,!1)}))}var x=Object.create||function(){function e(){}return function(t){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return e.prototype=t,new e}}();function k(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}function I(e){function t(e,t,n,r){return 3600*(0|e)+60*(0|t)+(0|n)+(0|r)/1e3}var n=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return n?n[3]?t(n[1],n[2],n[3].replace(":",""),n[4]):n[1]>59?t(n[1],n[2],0,n[4]):t(0,n[1],n[2],n[4]):null}function S(){this.values=x(null)}function T(e,t,n,r){var o=r?e.split(r):[e];for(var i in o)if("string"==typeof o[i]){var a=o[i].split(n);2===a.length&&t(a[0],a[1])}}function L(e,t,n){var r=e;function o(){var t=I(e);if(null===t)throw new k(k.Errors.BadTimeStamp,"Malformed timestamp: "+r);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function i(){e=e.replace(/^\s+/,"")}if(i(),t.startTime=o(),i(),"--\x3e"!==e.substr(0,3))throw new k(k.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);e=e.substr(3),i(),t.endTime=o(),i(),function(e,t){var r=new S;T(e,(function(e,t){switch(e){case"region":for(var o=n.length-1;o>=0;o--)if(n[o].id===t){r.set(e,n[o].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":var i=t.split(","),a=i[0];r.integer(e,a),r.percent(e,a)&&r.set("snapToLines",!1),r.alt(e,a,["auto"]),2===i.length&&r.alt("lineAlign",i[1],["start","middle","end"]);break;case"position":i=t.split(","),r.percent(e,i[0]),2===i.length&&r.alt("positionAlign",i[1],["start","middle","end"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start","middle","end","left","right"])}}),/:/,/\s/)}(e)}k.prototype=x(Error.prototype),k.prototype.constructor=k,k.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},S.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,n){for(var r=0;r=0&&t<=100)&&(this.set(e,t),!0)}};var R={"&":"&","<":"<",">":">","‎":"‎","‏":"‏"," ":" "},M={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},O={v:"title",lang:"lang"},Q={rt:"ruby"};function D(e,t){function n(){if(!t)return null;var e,n=t.match(/^([^<]*)(<[^>]+>?)?/);return e=n[1]?n[1]:n[2],t=t.substr(e.length),e}function r(e){return R[e]}function o(e){for(;p=e.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)e=e.replace(p[0],r);return e}function i(e,t){return!Q[t.localName]||Q[t.localName]===e.localName}function a(t,n){var r=M[t];if(!r)return null;var o=e.document.createElement(r);o.localName=r;var i=O[t];return i&&n&&(o[i]=n.trim()),o}for(var A,s=e.document.createElement("div"),c=s,u=[];null!==(A=n());)if("<"!==A[0])c.appendChild(e.document.createTextNode(o(A)));else{if("/"===A[1]){u.length&&u[u.length-1]===A.substr(2).replace(">","")&&(u.pop(),c=c.parentNode);continue}var l,f=I(A.substr(1,A.length-2));if(f){l=e.document.createProcessingInstruction("timestamp",f),c.appendChild(l);continue}var p=A.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!p)continue;if(!(l=a(p[1],p[3])))continue;if(!i(c,l))continue;p[2]&&(l.className=p[2].substr(1).replace("."," ")),u.push(p[1]),c.appendChild(l),c=l}return s}var P=[1470,1472,1475,1478,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1520,1521,1522,1523,1524,1544,1547,1549,1563,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1645,1646,1647,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1765,1766,1774,1775,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1807,1808,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1969,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2e3,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2036,2037,2042,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2074,2084,2088,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2142,2208,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,8207,64285,64287,64288,64289,64290,64291,64292,64293,64294,64295,64296,64298,64299,64300,64301,64302,64303,64304,64305,64306,64307,64308,64309,64310,64312,64313,64314,64315,64316,64318,64320,64321,64323,64324,64326,64327,64328,64329,64330,64331,64332,64333,64334,64335,64336,64337,64338,64339,64340,64341,64342,64343,64344,64345,64346,64347,64348,64349,64350,64351,64352,64353,64354,64355,64356,64357,64358,64359,64360,64361,64362,64363,64364,64365,64366,64367,64368,64369,64370,64371,64372,64373,64374,64375,64376,64377,64378,64379,64380,64381,64382,64383,64384,64385,64386,64387,64388,64389,64390,64391,64392,64393,64394,64395,64396,64397,64398,64399,64400,64401,64402,64403,64404,64405,64406,64407,64408,64409,64410,64411,64412,64413,64414,64415,64416,64417,64418,64419,64420,64421,64422,64423,64424,64425,64426,64427,64428,64429,64430,64431,64432,64433,64434,64435,64436,64437,64438,64439,64440,64441,64442,64443,64444,64445,64446,64447,64448,64449,64467,64468,64469,64470,64471,64472,64473,64474,64475,64476,64477,64478,64479,64480,64481,64482,64483,64484,64485,64486,64487,64488,64489,64490,64491,64492,64493,64494,64495,64496,64497,64498,64499,64500,64501,64502,64503,64504,64505,64506,64507,64508,64509,64510,64511,64512,64513,64514,64515,64516,64517,64518,64519,64520,64521,64522,64523,64524,64525,64526,64527,64528,64529,64530,64531,64532,64533,64534,64535,64536,64537,64538,64539,64540,64541,64542,64543,64544,64545,64546,64547,64548,64549,64550,64551,64552,64553,64554,64555,64556,64557,64558,64559,64560,64561,64562,64563,64564,64565,64566,64567,64568,64569,64570,64571,64572,64573,64574,64575,64576,64577,64578,64579,64580,64581,64582,64583,64584,64585,64586,64587,64588,64589,64590,64591,64592,64593,64594,64595,64596,64597,64598,64599,64600,64601,64602,64603,64604,64605,64606,64607,64608,64609,64610,64611,64612,64613,64614,64615,64616,64617,64618,64619,64620,64621,64622,64623,64624,64625,64626,64627,64628,64629,64630,64631,64632,64633,64634,64635,64636,64637,64638,64639,64640,64641,64642,64643,64644,64645,64646,64647,64648,64649,64650,64651,64652,64653,64654,64655,64656,64657,64658,64659,64660,64661,64662,64663,64664,64665,64666,64667,64668,64669,64670,64671,64672,64673,64674,64675,64676,64677,64678,64679,64680,64681,64682,64683,64684,64685,64686,64687,64688,64689,64690,64691,64692,64693,64694,64695,64696,64697,64698,64699,64700,64701,64702,64703,64704,64705,64706,64707,64708,64709,64710,64711,64712,64713,64714,64715,64716,64717,64718,64719,64720,64721,64722,64723,64724,64725,64726,64727,64728,64729,64730,64731,64732,64733,64734,64735,64736,64737,64738,64739,64740,64741,64742,64743,64744,64745,64746,64747,64748,64749,64750,64751,64752,64753,64754,64755,64756,64757,64758,64759,64760,64761,64762,64763,64764,64765,64766,64767,64768,64769,64770,64771,64772,64773,64774,64775,64776,64777,64778,64779,64780,64781,64782,64783,64784,64785,64786,64787,64788,64789,64790,64791,64792,64793,64794,64795,64796,64797,64798,64799,64800,64801,64802,64803,64804,64805,64806,64807,64808,64809,64810,64811,64812,64813,64814,64815,64816,64817,64818,64819,64820,64821,64822,64823,64824,64825,64826,64827,64828,64829,64848,64849,64850,64851,64852,64853,64854,64855,64856,64857,64858,64859,64860,64861,64862,64863,64864,64865,64866,64867,64868,64869,64870,64871,64872,64873,64874,64875,64876,64877,64878,64879,64880,64881,64882,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64894,64895,64896,64897,64898,64899,64900,64901,64902,64903,64904,64905,64906,64907,64908,64909,64910,64911,64914,64915,64916,64917,64918,64919,64920,64921,64922,64923,64924,64925,64926,64927,64928,64929,64930,64931,64932,64933,64934,64935,64936,64937,64938,64939,64940,64941,64942,64943,64944,64945,64946,64947,64948,64949,64950,64951,64952,64953,64954,64955,64956,64957,64958,64959,64960,64961,64962,64963,64964,64965,64966,64967,65008,65009,65010,65011,65012,65013,65014,65015,65016,65017,65018,65019,65020,65136,65137,65138,65139,65140,65142,65143,65144,65145,65146,65147,65148,65149,65150,65151,65152,65153,65154,65155,65156,65157,65158,65159,65160,65161,65162,65163,65164,65165,65166,65167,65168,65169,65170,65171,65172,65173,65174,65175,65176,65177,65178,65179,65180,65181,65182,65183,65184,65185,65186,65187,65188,65189,65190,65191,65192,65193,65194,65195,65196,65197,65198,65199,65200,65201,65202,65203,65204,65205,65206,65207,65208,65209,65210,65211,65212,65213,65214,65215,65216,65217,65218,65219,65220,65221,65222,65223,65224,65225,65226,65227,65228,65229,65230,65231,65232,65233,65234,65235,65236,65237,65238,65239,65240,65241,65242,65243,65244,65245,65246,65247,65248,65249,65250,65251,65252,65253,65254,65255,65256,65257,65258,65259,65260,65261,65262,65263,65264,65265,65266,65267,65268,65269,65270,65271,65272,65273,65274,65275,65276,67584,67585,67586,67587,67588,67589,67592,67594,67595,67596,67597,67598,67599,67600,67601,67602,67603,67604,67605,67606,67607,67608,67609,67610,67611,67612,67613,67614,67615,67616,67617,67618,67619,67620,67621,67622,67623,67624,67625,67626,67627,67628,67629,67630,67631,67632,67633,67634,67635,67636,67637,67639,67640,67644,67647,67648,67649,67650,67651,67652,67653,67654,67655,67656,67657,67658,67659,67660,67661,67662,67663,67664,67665,67666,67667,67668,67669,67671,67672,67673,67674,67675,67676,67677,67678,67679,67840,67841,67842,67843,67844,67845,67846,67847,67848,67849,67850,67851,67852,67853,67854,67855,67856,67857,67858,67859,67860,67861,67862,67863,67864,67865,67866,67867,67872,67873,67874,67875,67876,67877,67878,67879,67880,67881,67882,67883,67884,67885,67886,67887,67888,67889,67890,67891,67892,67893,67894,67895,67896,67897,67903,67968,67969,67970,67971,67972,67973,67974,67975,67976,67977,67978,67979,67980,67981,67982,67983,67984,67985,67986,67987,67988,67989,67990,67991,67992,67993,67994,67995,67996,67997,67998,67999,68e3,68001,68002,68003,68004,68005,68006,68007,68008,68009,68010,68011,68012,68013,68014,68015,68016,68017,68018,68019,68020,68021,68022,68023,68030,68031,68096,68112,68113,68114,68115,68117,68118,68119,68121,68122,68123,68124,68125,68126,68127,68128,68129,68130,68131,68132,68133,68134,68135,68136,68137,68138,68139,68140,68141,68142,68143,68144,68145,68146,68147,68160,68161,68162,68163,68164,68165,68166,68167,68176,68177,68178,68179,68180,68181,68182,68183,68184,68192,68193,68194,68195,68196,68197,68198,68199,68200,68201,68202,68203,68204,68205,68206,68207,68208,68209,68210,68211,68212,68213,68214,68215,68216,68217,68218,68219,68220,68221,68222,68223,68352,68353,68354,68355,68356,68357,68358,68359,68360,68361,68362,68363,68364,68365,68366,68367,68368,68369,68370,68371,68372,68373,68374,68375,68376,68377,68378,68379,68380,68381,68382,68383,68384,68385,68386,68387,68388,68389,68390,68391,68392,68393,68394,68395,68396,68397,68398,68399,68400,68401,68402,68403,68404,68405,68416,68417,68418,68419,68420,68421,68422,68423,68424,68425,68426,68427,68428,68429,68430,68431,68432,68433,68434,68435,68436,68437,68440,68441,68442,68443,68444,68445,68446,68447,68448,68449,68450,68451,68452,68453,68454,68455,68456,68457,68458,68459,68460,68461,68462,68463,68464,68465,68466,68472,68473,68474,68475,68476,68477,68478,68479,68608,68609,68610,68611,68612,68613,68614,68615,68616,68617,68618,68619,68620,68621,68622,68623,68624,68625,68626,68627,68628,68629,68630,68631,68632,68633,68634,68635,68636,68637,68638,68639,68640,68641,68642,68643,68644,68645,68646,68647,68648,68649,68650,68651,68652,68653,68654,68655,68656,68657,68658,68659,68660,68661,68662,68663,68664,68665,68666,68667,68668,68669,68670,68671,68672,68673,68674,68675,68676,68677,68678,68679,68680,126464,126465,126466,126467,126469,126470,126471,126472,126473,126474,126475,126476,126477,126478,126479,126480,126481,126482,126483,126484,126485,126486,126487,126488,126489,126490,126491,126492,126493,126494,126495,126497,126498,126500,126503,126505,126506,126507,126508,126509,126510,126511,126512,126513,126514,126516,126517,126518,126519,126521,126523,126530,126535,126537,126539,126541,126542,126543,126545,126546,126548,126551,126553,126555,126557,126559,126561,126562,126564,126567,126568,126569,126570,126572,126573,126574,126575,126576,126577,126578,126580,126581,126582,126583,126585,126586,126587,126588,126590,126592,126593,126594,126595,126596,126597,126598,126599,126600,126601,126603,126604,126605,126606,126607,126608,126609,126610,126611,126612,126613,126614,126615,126616,126617,126618,126619,126625,126626,126627,126629,126630,126631,126632,126633,126635,126636,126637,126638,126639,126640,126641,126642,126643,126644,126645,126646,126647,126648,126649,126650,126651,1114109];function F(){}function U(e,t,n){var r="undefined"!=typeof navigator&&/MSIE\s8\.0/.test(navigator.userAgent),o="rgba(255, 255, 255, 1)",i="rgba(0, 0, 0, 0.8)",a="";void 0!==B&&(o=B.fontSet,i=B.backgroundSet,a=B.edgeSet),r&&(o="rgb(255, 255, 255)",i="rgb(0, 0, 0)"),F.call(this),this.cue=t,this.cueDiv=D(e,t.text);var A={color:o,backgroundColor:i,textShadow:a,position:"relative",left:0,right:0,top:0,bottom:0,display:"inline"};r||(A.writingMode=""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",A.unicodeBidi="plaintext"),this.applyStyles(A,this.cueDiv),this.div=e.document.createElement("div"),A={textAlign:"middle"===t.align?"center":t.align,font:n.font,whiteSpace:"pre-line",position:"absolute"},r||(A.direction=function(e){var t,n=[],r="";if(!e||!e.childNodes)return"ltr";function o(e,t){for(var n=t.childNodes.length-1;n>=0;n--)e.push(t.childNodes[n])}function i(e){if(!e||!e.length)return null;var t=e.pop(),n=t.textContent||t.innerText;if(n){var r=n.match(/^.*(\n|\r)/);return r?(e.length=0,r[0]):n}return"ruby"===t.tagName?i(e):t.childNodes?(o(e,t),i(e)):void 0}for(o(n,e);r=i(n);)for(var a=0;a=0&&e.line<=100))return e.line;if(!e.track||!e.track.textTrackList||!e.track.textTrackList.mediaElement)return-1;for(var t=e.track,n=t.textTrackList,r=0,o=0;ol&&(u=u<0?-1:1,u*=Math.ceil(l/c)*c),a<0&&(u+=""===i.vertical?n.height:n.width,A=A.reverse()),o.move(f,u)}else{var p=o.lineHeight/n.height*100;switch(i.lineAlign){case"middle":a-=p/2;break;case"end":a-=p}switch(i.vertical){case"":t.applyStyles({top:t.formatStyle(a,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(a,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(a,"%")})}A=["+y","-x","+x","-y"],o=new N(t)}var d=function(e,t){for(var o,i=new N(e),a=1,A=0;As&&(o=new N(e),a=s),e=new N(i)}return o||i}(o,A);t.move(d.toCSSCompatValues(n))}F.prototype.applyStyles=function(e,t){for(var n in t=t||this.div,e)e.hasOwnProperty(n)&&(t.style[n]=e[n])},F.prototype.formatStyle=function(e,t){return 0===e?0:e+t},U.prototype=x(F.prototype),U.prototype.constructor=U,N.prototype.move=function(e,t){switch(t=void 0!==t?t:this.lineHeight,e){case"+x":this.left+=t,this.right+=t;break;case"-x":this.left-=t,this.right-=t;break;case"+y":this.top+=t,this.bottom+=t;break;case"-y":this.top-=t,this.bottom-=t}},N.prototype.overlaps=function(e){return this.lefte.left&&this.tope.top},N.prototype.overlapsAny=function(e){for(var t=0;t=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right},N.prototype.overlapsOppositeAxis=function(e,t){switch(t){case"+x":return this.lefte.right;case"+y":return this.tope.bottom}},N.prototype.intersectPercentage=function(e){return Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left))*Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top))/(this.height*this.width)},N.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}},N.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,n=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,r=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;return{left:(e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e).left,right:e.right,top:e.top||r,height:e.height||t,bottom:e.bottom||r+(e.height||t),width:e.width||n}},y.StringDecoder=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}},y.convertCueToDOMTree=function(e,t){return e&&t?D(e,t):null},y.processCues=function(e,t,n){if(!e||!t||!n)return null;for(;n.firstChild;)n.removeChild(n.firstChild);var r=e.document.createElement("div");if(r.style.position="absolute",r.style.left="0",r.style.right="0",r.style.top="0",r.style.bottom="0",r.style.margin="1.5%",n.appendChild(r),function(e){for(var t=0;t]*<[a-z]*/g,V=/]+?start[^=]*=[^0-9]*([0-9]*)["^0-9"]*/i,H=/]*>/gi,J=function(e,t){return t=(((t||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join(""),e.replace(/|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(function(e,n){return t.indexOf("<"+n.toLowerCase()+">")>-1?e:""}))},Z=function(e){return e.sort((function(e,t){var n;return 0==(n=e.start-t.start)?e.end-t.end:n}))},K=function(){var e={},t=function(e){return e.map((function(e){return new h(e.start,e.end,e.text)}))};return e.load=function(e,n,r,o){fetch(e.file).then((function(e){e.ok?e.text().then((function(e){var o=[],i=[];if(e.indexOf("WEBVTT")>=0){OvenPlayerConsole.log("WEBVTT LOADED");var A=new j.Parser(window,j.StringDecoder());i=[],A.oncue=function(e){i.push(e)},A.onflush=function(){r(i)},A.parse(e)}else if(e.indexOf("SAMI")>=0){OvenPlayerConsole.log("SAMI LOADED");var s=function(e,t){var n,r,o,i,a,A,s,c,u,l;if(s=function(){var t,n,r,a,s,c,u,f,p,d,g,h,v,m,C,y;for(n=function(e){var n;return(n=new Error(e)).line=u,n.context=t,o.push(n)},u=1,p=[],v={},h=e;d=h.search(),!(f<=0||d<0);)f=h.slice(d+1).search(G)+1,t=f>0?h.slice(d,d+f):h.slice(d),u+=(null!=(m=h.slice(0,d).match(z))?m.length:void 0)||0,_.test(t)&&n("ERROR_BROKEN_TAGS"),h=h.slice(d+f),(null===(g=+(null!=(C=t.match(V))?parseFloat(C[1]/1e3):void 0))||g<0)&&n("ERROR_INVALID_TIME"),(s=i(t))||n("ERROR_INVALID_LANGUAGE"),u+=(null!=(y=t.match(z))?y.length:void 0)||0,t=(t=t.replace(z,"")).replace(H,"\n"),a={start:g,text:"",contents:r=J(t).trim()},s&&(a.text=r),v[s]||(v[s]=[]),a.start&&v[s].push(a);l=l||function(){var e,t,n=window.navigator,r=["language","browserLanguage","systemLanguage","userLanguage"];if(Array.isArray(n.languages))for(e=0;e0&&(c=b.indexOf(l)>-1?v[l]:v[b.filter((function(e){return"undefined"!==e}))[0]],c=Z(c),c=A(c),p=p.concat(c)),Z(p)},i=function(e){var t,r;if(e)for(t in n)if((r=n[t]).reClassName.test(e))return r.lang},A=function(e){var t,n,o;for(t=e.length;t--;)n=e[t],null!=(o=e[t-1])&&(o.end=n.start),n.contents&&" "!==n.contents?(delete e[t].contents,n.end||(n.end=n.start+r)):e.splice(t,1);return e},o=[],n={KRCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KRCC)['\"S]?","i")},KOCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KOCC)['\"S]?","i")},KR:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KR)['\"S]?","i")},ENCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(ENCC)['\"S]?","i")},EGCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EGCC)['\"S]?","i")},EN:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EN)['\"S]?","i")},JPCC:{lang:"ja",reClassName:new RegExp("class[^=]*?=[\"'S]*(JPCC)['\"S]?","i")}},null!=t?t.definedLangs:void 0)for(a in u=t.definedLangs)c=u[a],n[a]=c;return r=(null!=t?t.duration:void 0)||10,l=t.fixedLang,e=e.trim(),{result:s(),errors:o}}(e,{fixedLang:n});i=t(s.result),r(i)}else OvenPlayerConsole.log("SRT LOADED"),o=function(e){var t=[],n=(e=a(e)).split("\r\n\r\n");1===n.length&&(n=e.split("\n\n"));for(var r=0;rGet Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Can not load due to dash.js. Please use the latest dash.js.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Error initializing DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Error initializing HLS.",reason:"Error initializing HLS."},300:{code:300,message:"Can not play due to unknown reasons.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Fetching process aborted by user.",reason:"Fetching process aborted by user."},302:{code:302,message:"Some of the media could not be downloaded due to a network error.",reason:"Error occurred when downloading."},303:{code:303,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"Error occurred when decoding."},304:{code:304,message:"Media playback has been canceled. It looks like your media is corrupted or your browser does not support the features your media uses.",reason:"Media playback not supported."},305:{code:305,message:"Can not load captions due to unknown reasons.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server refused the request."},308:{code:308,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server do not accept the request."},501:{code:501,message:"Connection with low-latency(OME) server failed.",reason:"WebSocket connection failed."},502:{code:502,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC internal error."},510:{code:510,message:"Network connection is unstable. Check the network connection.",reason:"Network is slow."},511:{code:511,message:"Connection with low-latency(OME) terminated unexpectedly.",reason:"Unexpected end of connection."},512:{code:512,message:"Connection with low-latency(OME) server failed.",reason:"Connection timeout."}}}},{lang:"ko",ui:{context:"오븐플레이어에 관하여",controls:{live:"라이브",low_latency_live:"초저지연 라이브",low_latency_p2p:"초저지연 P2P"},playlist:"플레이리스트",setting:{title:"설정",speed:"재생 속도",speedUnit:"x",source:"소스",quality:"품질",audioTrack:"오디오",caption:"자막",display:"표시"}},api:{message:{muted_play:"눌러서 소리 켜기"},error:{100:{code:100,message:"알 수 없는 이유로 로드 할 수 없습니다.",reason:"알 수 없는 이유로 로드 할 수 없습니다."},101:{code:101,message:"지원되는 미디어를 찾지 못해 로드 할 수 없습니다.",reason:"Can not load due to playable media not found."},102:{code:102,message:"플레시 로드가 중단 되었습니다.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"DashJS로 인해 로드 할 수 없습니다. 최신 dash.js를 사용해 주세요.",reason:"dash.js version is old."},104:{code:104,message:"Google IMA 라이브러리가 없어 로드 할 수 없습니다.",reason:"Please check the google ima library."},105:{code:105,message:"DASH 초기화 중 오류가 발생했습니다.",reason:"Error initializing DASH."},106:{code:106,message:"HLS 초기화 중 오류가 발생했습니다.",reason:"Error initializing HLS."},300:{code:300,message:"알 수 없는 이유로 재생할 수 없습니다.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"사용자에 의한 프로세스 중단.",reason:"Fetching process aborted by user."},302:{code:302,message:"네트워크 오류로 인해 일부 미디어를 다운로드 할 수 없습니다.",reason:"Error occurred when downloading."},303:{code:303,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"Error occurred when decoding."},304:{code:304,message:"미디어 재생이 취소되었습니다. 미디어가 손상되었거나 브라우저가 미디어에서 사용하는 기능을 지원하지 않는 것 같습니다.",reason:"Media playback not supported."},305:{code:305,message:"알 수 없는 이유로 자막을 로드 할 수 없습니다.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server cannot or will not process the request."},307:{code:307,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server refused the request."},308:{code:308,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server do not accept the request."},501:{code:501,message:"웹소켓 연결 실패",reason:"WebSocket connection failed."},502:{code:502,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC internal error."},510:{code:510,message:"네트워크 연결이 불안정합니다. 네트워크 연결을 확인하십시오.",reason:"Network is slow."},511:{code:511,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Unexpected end of connection."},512:{code:512,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Connection timeout."}}}},{lang:"pl",ui:{context:"O OvenPlayer",controls:{live:"Transmisja na żywo",low_latency_live:"Transmisja z niskim opóźnieniem",low_latency_p2p:"Transmisja z niskim opóźnieniem P2P"},playlist:"Playlista",setting:{title:"Ustawienia",speed:"Prędkość",speedUnit:"x",source:"Źrodło",quality:"Jakość",audioTrack:"Audio",caption:"Podtytuł",display:"Wyświetlacz"}},api:{message:{muted_play:"Naciśnij tutaj, aby aktywować dźwięk"},error:{100:{code:100,message:"Nie można załadować z nieznanego powodu.",reason:"Can not load due to unknown reasons."},101:{code:101,message:"Nie można załadować, ponieważ nie znaleziono multimediów, który można odtworzyć.",reason:"Can not load due to playable media not found."},102:{code:102,message:"Flash fetching process aborted.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Nie można załadować, ponieważ wersja dash.js jest za stara.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Nie można załadować, nie znaleziono DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Nie można załadować, nie znaleziono hlsjs.",reason:"Error initializing HLS"},300:{code:300,message:"Nie można odtworzyć z nieznanego powodu.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Proces pobierania przerwany przez użytkownika.",reason:"Fetching process aborted by user."},302:{code:302,message:"Nie udało się pobrać niektórych multimediów z powodu błędu sieci.",reason:"Error occurred when downloading."},303:{code:303,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"Error occurred when decoding."},304:{code:304,message:"Odtwarzanie zostało anulowane. Wygląda na to, że plik jest uszkodzony lub Twoja przeglądarka nie obsługuje tego pliku.",reason:"Media playback not supported."},305:{code:305,message:"Nie można wczytać napisów z nieznanego powodu.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server refused the request."},308:{code:308,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server do not accept the request."},501:{code:501,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebSocket connection failed."},502:{code:502,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC internal error."},510:{code:510,message:"Połączenie sieciowe jest niestabilne. Sprawdź swoją sieć.",reason:"Network is slow."},511:{code:511,message:"Połączenie z serwerem niskiego opóźnienia (OME) nieoczekiwanie zakończone.",reason:"Unexpected end of connection."},512:{code:512,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"Connection timeout."}}}}],Ye=function(e){return"subtitles"===e||"captions"===e},Ge=function(e){var t=e,n=[],r=function(e,t,n){var r=0,o=e.length;for(r=0;r1?n:n[0]};return(r=i().isElement(t)||i().every(t,(function(e){return i().isElement(e)}))?t:"document"===t?document:"window"===t?window:o(document,t))?(n.show=function(){r.style.display="block"},n.hide=function(){r.style.display="none"},n.addClass=function(e){r.classList?r.classList.add(e):-1===r.className.split(" ").indexOf(e)&&(r.className+=" "+e)},n.after=function(e){r.insertAdjacentHTML("afterend",e)},n.append=function(e){r.appendChild(e)},n.before=function(e){r.insertAdjacentHTML("beforebegin",e)},n.children=function(){return r.children||[]},n.contains=function(e){return r!==e&&r.contains(e)},n.empty=function(){r.innerHTML=""},n.find=function(t){return e(o(r,t))},n.css=function(e,t){if(!t)return r.style[e];r.length>0?r.forEach((function(n){n.style[e]=t})):r.style[e]=t},n.removeClass=function(e){r.classList?r.classList.remove(e):r.className=r.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")},n.removeAttribute=function(e){r.removeAttribute(e)},n.text=function(e){if(void 0===e)return r.textContent;r.textContent=e},n.html=function(e){r.innerHTML=e},n.hasClass=function(e){return r.classList?r.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(r.name)},n.is=function(e){return r===e},n.offset=function(){var e=r.getBoundingClientRect();return{top:e.top+document.body.scrollTop,left:e.left+document.body.scrollLeft}},n.width=function(){return r.clientWidth},n.height=function(){return r.clientHeight},n.attr=function(e){return r.getAttribute(e)},n.replace=function(e){r.replaceWith(e)},n.remove=function(){r.length>1?r.parentElement.removeChild(r):r.remove()},n.removeChild=function(e){if(e)r.removeChild(e);else for(;r.hasChildNodes();)r.removeChild(r.firstChild)},n.get=function(){return r},n.closest=function(t){r.closest=function(e){var t=r;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null};var n=r.closest(t);return n?e(n):null},n):null}),_e=function(e,t){if(e)return 0==e.indexOf("rtmp:")||"rtmp"==t},Ve=function(e,t){return!!e&&(0===e.indexOf("ws:")||0===e.indexOf("wss:")||"webrtc"===t)},He=function(e,t){if(e)return"hls"===t||"m3u8"===t||"application/vnd.apple.mpegurl"===t||"m3u8"==A(e)},Je=function(e,t){if(e)return"mpd"===t||"dash"===t||"application/dash+xml"===t||"mpd"==A(e)},Ze=function(e){if(!e)return null;var t=null;if("string"==typeof e)t=document.getElementById(e);else{if(!e.nodeType)return null;t=e}return t},Ke=function(){var e={};OvenPlayerConsole.log("SupportChecker loaded.");var t=Y(),n=[{name:"html5",checkSupport:function(e){var n=document.createElement("video");if(!n.canPlayType)return!1;var r=e.file,o=e.type;if(!o)return!1;var i=e.mimeType||{aac:"audio/mp4",mp4:"video/mp4",f4v:"video/mp4",m4v:"video/mp4",mov:"video/mp4",mp3:"audio/mpeg",mpeg:"audio/mpeg",ogv:"video/ogg",ogg:"video/ogg",oga:"video/ogg",vorbis:"video/ogg",webm:"video/webm",f4a:"video/aac",m3u8:"application/vnd.apple.mpegurl",m3u:"application/vnd.apple.mpegurl",hls:"application/vnd.apple.mpegurl"}[o];return!(He(r,o)&&("Microsoft Edge"===t.browser||"Android"===t.os)||_e(r,o)||Ve(r,o)||!i||!n.canPlayType(i))}},{name:"webrtc",checkSupport:function(e){if(!document.createElement("video").canPlayType)return!1;if(_e(t,n))return!1;var t=e.file,n=e.type;return!!Ve(t,n)}},{name:"dash",checkSupport:function(e){var t=e.file,n=e.type;return!_e(t,n)&&!("function"!=typeof(window.MediaSource||window.WebKitMediaSource)||!Je(t,n))}},{name:"hls",checkSupport:function(e){document.createElement("video");var t,n,r,o,i=e.file,a=e.type;return!_e(i,a)&&(t=function(){if("undefined"!=typeof window)return window.MediaSource||window.WebKitMediaSource}(),n=window.SourceBuffer||window.WebKitSourceBuffer,r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),o=!n||n.prototype&&"function"==typeof n.prototype.appendBuffer&&"function"==typeof n.prototype.remove,!!r&&!!o)}},{name:"rtmp",checkSupport:function(e){var n=e.file,r=e.type;return!(!_e(n,r)||!function(){var e=!1;if("ActiveXObject"in window)try{e=!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(t){e=!1}else e=!!navigator.mimeTypes["application/x-shockwave-flash"];return e}()||"Microsoft Edge"===t.browser||"Android"===t.os||"iOS"===t.os||"Safari"===t.browser)}}];return e.findProviderNameBySource=function(e){OvenPlayerConsole.log("SupportChecker : findProviderNameBySource()",e);for(var t=e===Object(e)?e:{},r=0;r0&&void 0!==arguments[0]?arguments[0]:{};ct(this,e),this.id=t.id||null,this.adId=t.adId||null,this.sequence=t.sequence||null,this.apiFramework=t.apiFramework||null,this.trackingEvents={}})),gt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="companion",e.variations=[],e}return st(n)}(dt);function ht(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[];for(var r in t.ASSETURI&&(t.ASSETURI=vt(t.ASSETURI)),t.CONTENTPLAYHEAD&&(t.CONTENTPLAYHEAD=vt(t.CONTENTPLAYHEAD)),t.ERRORCODE&&!/^[0-9]{3}$/.test(t.ERRORCODE)&&(t.ERRORCODE=900),t.CACHEBUSTING=mt(Math.round(1e8*Math.random()).toString()),t.TIMESTAMP=vt((new Date).toISOString()),t.RANDOM=t.random=t.CACHEBUSTING,e){var o=e[r];if("string"==typeof o){for(var i in t){var a=t[i],A="[".concat(i,"]"),s="%%".concat(i,"%%");o=(o=o.replace(A,a)).replace(s,a)}n.push(o)}}return n}function vt(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16))}))}function mt(e){return e.length<8?Ct(0,8-e.length,!1).map((function(e){return"0"})).join("")+e:e}function Ct(e,t,n){for(var r=[],o=ei;o?a++:a--)r.push(a);return r}var yt={track:function(e,t){ht(e,t).forEach((function(e){"undefined"!=typeof window&&null!==window&&((new Image).src=e)}))},resolveURLTemplates:ht,encodeURIComponentRFC3986:vt,leftpad:mt,range:Ct,isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},flatten:function e(t){return t.reduce((function(t,n){return t.concat(Array.isArray(n)?e(n):n)}),[])}},bt=function(e,t){var n=e.childNodes;for(var r in n){var o=n[r];if(o.nodeName===t)return o}},wt=function(e,t){var n=[],r=e.childNodes;for(var o in r){var i=r[o];i.nodeName===t&&n.push(i)}return n},Et=function(e,t){if(!t)return e;if(0===e.indexOf("//")){var n=location.protocol;return"".concat(n).concat(e)}return-1===e.indexOf("://")?"".concat(t.slice(0,t.lastIndexOf("/")),"/").concat(e):e},Bt=function(e){return-1!==["true","TRUE","1"].indexOf(e)},xt=function(e){return e&&(e.textContent||e.text||"").trim()},kt=function(e,t,n){var r=t.getAttribute(e);r&&n.setAttribute(e,r)},It=function(e){if(null==e)return-1;if(yt.isNumeric(e))return parseInt(e);var t=e.split(":");if(3!==t.length)return-1;var n=t[2].split("."),r=parseInt(n[0]);2===n.length&&(r+=parseFloat("0.".concat(n[1])));var o=parseInt(60*t[1]),i=parseInt(60*t[0]*60);return isNaN(i)||isNaN(o)||isNaN(r)||o>3600||r>60?-1:i+o+r},St=function(e){var t=[],n=null;return e.forEach((function(r,o){if(r.sequence&&(r.sequence=parseInt(r.sequence,10)),r.sequence>1){var i=e[o-1];if(i&&i.sequence===r.sequence-1)return void(n&&n.push(r));delete r.sequence}n=[r],t.push(n)})),t},Tt=function(e,t){e.errorURLTemplates=t.errorURLTemplates.concat(e.errorURLTemplates),e.impressionURLTemplates=t.impressionURLTemplates.concat(e.impressionURLTemplates),e.extensions=t.extensions.concat(e.extensions),e.creatives.forEach((function(e){if(t.trackingEvents&&t.trackingEvents[e.type])for(var n in t.trackingEvents[e.type]){var r=t.trackingEvents[e.type][n];e.trackingEvents[n]||(e.trackingEvents[n]=[]),e.trackingEvents[n]=e.trackingEvents[n].concat(r)}})),t.videoClickTrackingURLTemplates&&t.videoClickTrackingURLTemplates.length&&e.creatives.forEach((function(e){"linear"===e.type&&(e.videoClickTrackingURLTemplates=e.videoClickTrackingURLTemplates.concat(t.videoClickTrackingURLTemplates))})),t.videoCustomClickURLTemplates&&t.videoCustomClickURLTemplates.length&&e.creatives.forEach((function(e){"linear"===e.type&&(e.videoCustomClickURLTemplates=e.videoCustomClickURLTemplates.concat(t.videoCustomClickURLTemplates))})),t.videoClickThroughURLTemplate&&e.creatives.forEach((function(e){"linear"===e.type&&null==e.videoClickThroughURLTemplate&&(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate)}))};function Lt(e,t){var n=new gt(t);return wt(e,"Companion").forEach((function(e){var t=new pt;t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.companionClickTrackingURLTemplates=[],wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(n){t.type=n.getAttribute("creativeType")||0,wt(e,"AltText").forEach((function(e){t.altText=xt(e)})),t.staticResource=xt(n)})),wt(e,"TrackingEvents").forEach((function(e){wt(e,"Tracking").forEach((function(e){var n=e.getAttribute("event"),r=xt(e);n&&r&&(null==t.trackingEvents[n]&&(t.trackingEvents[n]=[]),t.trackingEvents[n].push(r))}))})),wt(e,"CompanionClickTracking").forEach((function(e){t.companionClickTrackingURLTemplates.push(xt(e))})),t.companionClickThroughURLTemplate=xt(bt(e,"CompanionClickThrough")),t.companionClickTrackingURLTemplate=xt(bt(e,"CompanionClickTracking")),n.variations.push(t)})),n}var Rt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="linear",e.duration=0,e.skipDelay=null,e.mediaFiles=[],e.videoClickThroughURLTemplate=null,e.videoClickTrackingURLTemplates=[],e.videoCustomClickURLTemplates=[],e.adParameters=null,e.icons=[],e}return st(n)}(dt),Mt=st((function e(){ct(this,e),this.program=null,this.height=0,this.width=0,this.xPosition=0,this.yPosition=0,this.apiFramework=null,this.offset=null,this.duration=0,this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.iconClickThroughURLTemplate=null,this.iconClickTrackingURLTemplates=[],this.iconViewTrackingURLTemplate=null})),Ot=st((function e(){ct(this,e),this.id=null,this.fileURL=null,this.deliveryType="progressive",this.mimeType=null,this.codec=null,this.bitrate=0,this.minBitrate=0,this.maxBitrate=0,this.width=0,this.height=0,this.apiFramework=null,this.scalable=null,this.maintainAspectRatio=null}));function Qt(e,t){var n,r=new Rt(t);r.duration=It(xt(bt(e,"Duration")));var o=e.getAttribute("skipoffset");if(null==o)r.skipDelay=null;else if("%"===o.charAt(o.length-1)&&-1!==r.duration){var i=parseInt(o,10);r.skipDelay=r.duration*(i/100)}else r.skipDelay=It(o);var a=bt(e,"VideoClicks");a&&(r.videoClickThroughURLTemplate=xt(bt(a,"ClickThrough")),wt(a,"ClickTracking").forEach((function(e){r.videoClickTrackingURLTemplates.push(xt(e))})),wt(a,"CustomClick").forEach((function(e){r.videoCustomClickURLTemplates.push(xt(e))})));var A=bt(e,"AdParameters");A&&(r.adParameters=xt(A)),wt(e,"TrackingEvents").forEach((function(e){wt(e,"Tracking").forEach((function(e){var t=e.getAttribute("event"),o=xt(e);if(t&&o){if("progress"===t){if(!(n=e.getAttribute("offset")))return;t="%"===n.charAt(n.length-1)?"progress-".concat(n):"progress-".concat(Math.round(It(n)))}null==r.trackingEvents[t]&&(r.trackingEvents[t]=[]),r.trackingEvents[t].push(o)}}))})),wt(e,"MediaFiles").forEach((function(e){wt(e,"MediaFile").forEach((function(e){var t=new Ot;t.id=e.getAttribute("id"),t.fileURL=xt(e),t.deliveryType=e.getAttribute("delivery"),t.codec=e.getAttribute("codec"),t.mimeType=e.getAttribute("type"),t.apiFramework=e.getAttribute("apiFramework"),t.bitrate=parseInt(e.getAttribute("bitrate")||0),t.minBitrate=parseInt(e.getAttribute("minBitrate")||0),t.maxBitrate=parseInt(e.getAttribute("maxBitrate")||0),t.width=parseInt(e.getAttribute("width")||0),t.height=parseInt(e.getAttribute("height")||0);var n=e.getAttribute("scalable");n&&"string"==typeof n&&("true"===(n=n.toLowerCase())?t.scalable=!0:"false"===n&&(t.scalable=!1));var o=e.getAttribute("maintainAspectRatio");o&&"string"==typeof o&&("true"===(o=o.toLowerCase())?t.maintainAspectRatio=!0:"false"===o&&(t.maintainAspectRatio=!1)),r.mediaFiles.push(t)}))}));var s=bt(e,"Icons");return s&&wt(s,"Icon").forEach((function(e){var t=new Mt;t.program=e.getAttribute("program"),t.height=parseInt(e.getAttribute("height")||0),t.width=parseInt(e.getAttribute("width")||0),t.xPosition=function(e){return-1!==["left","right"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("xPosition")),t.yPosition=function(e){return-1!==["top","bottom"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("yPosition")),t.apiFramework=e.getAttribute("apiFramework"),t.offset=It(e.getAttribute("offset")),t.duration=It(e.getAttribute("duration")),wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=xt(e)}));var n=bt(e,"IconClicks");n&&(t.iconClickThroughURLTemplate=xt(bt(n,"IconClickThrough")),wt(n,"IconClickTracking").forEach((function(e){t.iconClickTrackingURLTemplates.push(xt(e))}))),t.iconViewTrackingURLTemplate=xt(bt(e,"IconViewTracking")),r.icons.push(t)})),r}var Dt,Pt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="nonlinear",e.variations=[],e}return st(n)}(dt),Ft=st((function e(){ct(this,e),this.id=null,this.width=0,this.height=0,this.expandedWidth=0,this.expandedHeight=0,this.scalable=!0,this.maintainAspectRatio=!0,this.minSuggestedDuration=0,this.apiFramework="static",this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.nonlinearClickThroughURLTemplate=null,this.nonlinearClickTrackingURLTemplates=[],this.adParameters=null}));function Ut(e,t){var n=new Pt(t);return wt(e,"TrackingEvents").forEach((function(e){var t,r;wt(e,"Tracking").forEach((function(e){t=e.getAttribute("event"),r=xt(e),t&&r&&(null==n.trackingEvents[t]&&(n.trackingEvents[t]=[]),n.trackingEvents[t].push(r))}))})),wt(e,"NonLinear").forEach((function(e){var t=new Ft;t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.expandedWidth=e.getAttribute("expandedWidth"),t.expandedHeight=e.getAttribute("expandedHeight"),t.scalable=Bt(e.getAttribute("scalable")),t.maintainAspectRatio=Bt(e.getAttribute("maintainAspectRatio")),t.minSuggestedDuration=It(e.getAttribute("minSuggestedDuration")),t.apiFramework=e.getAttribute("apiFramework"),wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=xt(e)}));var r=bt(e,"AdParameters");r&&(t.adParameters=xt(r)),t.nonlinearClickThroughURLTemplate=xt(bt(e,"NonLinearClickThrough")),wt(e,"NonLinearClickTracking").forEach((function(e){t.nonlinearClickTrackingURLTemplates.push(xt(e))})),n.variations.push(t)})),n}function Nt(e){var t=e.childNodes;for(var n in t){var r=t[n];if(-1!==["Wrapper","InLine"].indexOf(r.nodeName)){if(kt("id",e,r),kt("sequence",e,r),"Wrapper"===r.nodeName)return jt(r);if("InLine"===r.nodeName)return Wt(r)}}}function Wt(e){var t=e.childNodes,n=new ut;for(var r in n.id=e.getAttribute("id")||null,n.sequence=e.getAttribute("sequence")||null,t){var o=t[r];switch(o.nodeName){case"Error":n.errorURLTemplates.push(xt(o));break;case"Impression":n.impressionURLTemplates.push(xt(o));break;case"Creatives":wt(o,"Creative").forEach((function(e){var t={id:e.getAttribute("id")||null,adId:Gt(e),sequence:e.getAttribute("sequence")||null,apiFramework:e.getAttribute("apiFramework")||null};for(var r in e.childNodes){var o=e.childNodes[r];switch(o.nodeName){case"Linear":var i=Qt(o,t);i&&n.creatives.push(i);break;case"NonLinearAds":var a=Ut(o,t);a&&n.creatives.push(a);break;case"CompanionAds":var A=Lt(o,t);A&&n.creatives.push(A)}}}));break;case"Extensions":Yt(n.extensions,wt(o,"Extension"));break;case"AdSystem":n.system={value:xt(o),version:o.getAttribute("version")||null};break;case"AdTitle":n.title=xt(o);break;case"Description":n.description=xt(o);break;case"Advertiser":n.advertiser=xt(o);break;case"Pricing":n.pricing={value:xt(o),model:o.getAttribute("model")||null,currency:o.getAttribute("currency")||null};break;case"Survey":n.survey=xt(o)}}return n}function jt(e){var t=Wt(e),n=bt(e,"VASTAdTagURI");if(n?t.nextWrapperURL=xt(n):(n=bt(e,"VASTAdTagURL"))&&(t.nextWrapperURL=xt(bt(n,"URL"))),t.creatives.forEach((function(e){if(-1!==["linear","nonlinear"].indexOf(e.type)){if(e.trackingEvents){t.trackingEvents||(t.trackingEvents={}),t.trackingEvents[e.type]||(t.trackingEvents[e.type]={});var n=function(n){var r=e.trackingEvents[n];t.trackingEvents[e.type][n]||(t.trackingEvents[e.type][n]=[]),r.forEach((function(r){t.trackingEvents[e.type][n].push(r)}))};for(var r in e.trackingEvents)n(r)}e.videoClickTrackingURLTemplates&&(t.videoClickTrackingURLTemplates||(t.videoClickTrackingURLTemplates=[]),e.videoClickTrackingURLTemplates.forEach((function(e){t.videoClickTrackingURLTemplates.push(e)}))),e.videoClickThroughURLTemplate&&(t.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate),e.videoCustomClickURLTemplates&&(t.videoCustomClickURLTemplates||(t.videoCustomClickURLTemplates=[]),e.videoCustomClickURLTemplates.forEach((function(e){t.videoCustomClickURLTemplates.push(e)})))}})),t.nextWrapperURL)return t}function Yt(e,t){t.forEach((function(t){var n=new lt,r=t.attributes,o=t.childNodes;if(t.attributes)for(var i in r){var a=r[i];a.nodeName&&a.nodeValue&&(n.attributes[a.nodeName]=a.nodeValue)}for(var A in o){var s=o[A],c=xt(s);if("#comment"!==s.nodeName&&""!==c){var u=new ft;if(u.name=s.nodeName,u.value=c,s.attributes){var l=s.attributes;for(var f in l){var p=l[f];u.attributes[p.nodeName]=p.nodeValue}}n.children.push(u)}}e.push(n)}))}function Gt(e){return e.getAttribute("AdID")||e.getAttribute("adID")||e.getAttribute("adId")||null}function zt(){}function _t(){_t.init.call(this)}function Vt(e){return void 0===e._maxListeners?_t.defaultMaxListeners:e._maxListeners}function Ht(e,t,n){if(t)e.call(n);else for(var r=e.length,o=tn(e,r),i=0;i0&&a.length>o){a.warned=!0;var A=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");A.name="MaxListenersExceededWarning",A.emitter=e,A.type=t,A.count=a.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(A)}}else a=i[t]=n,++e._eventsCount;return e}function $t(e,t,n){var r=!1;function o(){e.removeListener(t,o),r||(r=!0,n.apply(e,arguments))}return o.listener=n,o}function en(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function tn(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}zt.prototype=Object.create(null),_t.EventEmitter=_t,_t.usingDomains=!1,_t.prototype.domain=void 0,_t.prototype._events=void 0,_t.prototype._maxListeners=void 0,_t.defaultMaxListeners=10,_t.init=function(){this.domain=null,_t.usingDomains&&(!Dt.active||this instanceof Dt.Domain||(this.domain=Dt.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new zt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_t.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_t.prototype.getMaxListeners=function(){return Vt(this)},_t.prototype.emit=function(e){var t,n,r,o,i,a,A,s="error"===e;if(a=this._events)s=s&&null==a.error;else if(!s)return!1;if(A=this.domain,s){if(t=arguments[1],!A){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=A,t.domainThrown=!1,A.emit("error",t),!1}if(!(n=a[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:Ht(n,u,this);break;case 2:Jt(n,u,this,arguments[1]);break;case 3:Zt(n,u,this,arguments[1],arguments[2]);break;case 4:Kt(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i0;)if(n[i]===t||n[i].listener&&n[i].listener===t){a=n[i].listener,o=i;break}if(o<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new zt,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,o=e.length;r0?Reflect.ownKeys(this._events):[]};var nn=function(e,t,n){var r="function"==typeof window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLDOM"):void 0;if(!r)return n(new Error("FlashURLHandler: Microsoft.XMLDOM format not supported"));r.async=!1,request.open("GET",e),request.timeout=t.timeout||0,request.withCredentials=t.withCredentials||!1,request.send(),request.onprogress=function(){},request.onload=function(){r.loadXML(request.responseText),n(null,r)}},rn=function(){return window.XDomainRequest&&(e=new XDomainRequest),!!e;var e},on=function(e,t,n){n(new Error("Please bundle the library for node to use the node urlHandler"))};function an(){try{var e=new window.XMLHttpRequest;return"withCredentials"in e?e:null}catch(e){return console.log("Error in XHRURLHandler support check:",e),null}}var An,sn,cn=function(e,t,n){if("https:"===window.location.protocol&&0===e.indexOf("http://"))return n(new Error("XHRURLHandler: Cannot go from HTTPS to HTTP."));try{var r=an();r.open("GET",e),r.timeout=t.timeout||0,r.withCredentials=t.withCredentials||!1,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.onreadystatechange=function(){4===r.readyState&&(200===r.status?n(null,r.responseXML):n(new Error("XHRURLHandler: ".concat(r.statusText))))},r.send()}catch(e){n(new Error("XHRURLHandler: Unexpected error"))}},un=function(){return!!an()},ln={get:function(e,t,n){return n||("function"==typeof t&&(n=t),t={}),"undefined"==typeof window||null===window?on(e,t,n):un()?cn(e,t,n):rn()?nn(e,t,n):n(new Error("Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler"))}},fn=st((function e(){ct(this,e),this.ads=[],this.errorURLTemplates=[]})),pn={ERRORCODE:900,extensions:[]},dn=function(e){nt(n,e);var t=ot(n);function n(){var e;return ct(this,n),(e=t.call(this)).remainingAds=[],e.parentURLs=[],e.errorURLTemplates=[],e.rootErrorURLTemplates=[],e.maxWrapperDepth=null,e.URLTemplateFilters=[],e.fetchingOptions={},e}return st(n,[{key:"addURLTemplateFilter",value:function(e){"function"==typeof e&&this.URLTemplateFilters.push(e)}},{key:"removeURLTemplateFilter",value:function(){this.URLTemplateFilters.pop()}},{key:"countURLTemplateFilters",value:function(){return this.URLTemplateFilters.length}},{key:"clearURLTemplateFilters",value:function(){this.URLTemplateFilters=[]}},{key:"trackVastError",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o0&&void 0!==arguments[0]?arguments[0]:{};this.rootURL="",this.remainingAds=[],this.parentURLs=[],this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.maxWrapperDepth=e.wrapperLimit||10,this.fetchingOptions={timeout:e.timeout,withCredentials:e.withCredentials},this.urlHandler=e.urlhandler||ln}},{key:"getRemainingAds",value:function(e){var t=this;if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));var n=e?yt.flatten(this.remainingAds):this.remainingAds.shift();return this.errorURLTemplates=[],this.parentURLs=[],this.resolveAds(n,{wrapperDepth:0,originalUrl:this.rootURL}).then((function(e){return t.buildVASTResponse(e)}))}},{key:"getAndParseVAST",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),this.rootURL=e,this.fetchVAST(e).then((function(r){return n.originalUrl=e,n.isRootVAST=!0,t.parse(r,n).then((function(e){return t.buildVASTResponse(e)}))}))}},{key:"parseVAST",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),n.isRootVAST=!0,this.parse(e,n).then((function(e){return t.buildVASTResponse(e)}))}},{key:"buildVASTResponse",value:function(e){var t=new fn;return t.ads=e,t.errorURLTemplates=this.getErrorURLTemplates(),this.completeWrapperResolving(t),t}},{key:"parse",value:function(e,t){var n=t.resolveAll,r=void 0===n||n,o=t.wrapperSequence,i=void 0===o?null:o,a=t.originalUrl,A=void 0===a?null:a,s=t.wrapperDepth,c=void 0===s?0:s,u=t.isRootVAST,l=void 0!==u&&u;if(!e||!e.documentElement||"VAST"!==e.documentElement.nodeName)return Promise.reject(new Error("Invalid VAST XMLDocument"));var f=[],p=e.documentElement.childNodes;for(var d in p){var g=p[d];if("Error"===g.nodeName){var h=xt(g);l?this.rootErrorURLTemplates.push(h):this.errorURLTemplates.push(h)}if("Ad"===g.nodeName){var v=Nt(g);v?f.push(v):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}var m=f.length,C=f[m-1];return 1===m&&null!=i&&C&&!C.sequence&&(C.sequence=i),!1===r&&(this.remainingAds=St(f),f=this.remainingAds.shift()),this.resolveAds(f,{wrapperDepth:c,originalUrl:A})}},{key:"resolveAds",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,r=n.wrapperDepth,o=n.originalUrl,i=[];return t.forEach((function(t){var n=e.resolveWrappers(t,r,o);i.push(n)})),Promise.all(i).then((function(t){var n=yt.flatten(t);if(!n&&e.remainingAds.length>0){var i=e.remainingAds.shift();return e.resolveAds(i,{wrapperDepth:r,originalUrl:o})}return n}))}},{key:"resolveWrappers",value:function(e,t,n){var r=this;return new Promise((function(o,i){if(t++,!e.nextWrapperURL)return delete e.nextWrapperURL,o(e);if(t>=r.maxWrapperDepth||-1!==r.parentURLs.indexOf(e.nextWrapperURL))return e.errorCode=302,delete e.nextWrapperURL,o(e);e.nextWrapperURL=Et(e.nextWrapperURL,n);var a=e.sequence;n=e.nextWrapperURL,r.fetchVAST(e.nextWrapperURL,t,n).then((function(i){return r.parse(i,{originalUrl:n,wrapperSequence:a,wrapperDepth:t}).then((function(t){if(delete e.nextWrapperURL,0===t.length)return e.creatives=[],o(e);t.forEach((function(t){t&&Tt(t,e)})),o(t)}))})).catch((function(t){e.errorCode=301,e.errorMessage=t.message,o(e)}))}))}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;t>=0;t--){var n=e.ads[t];(n.errorCode||0===n.creatives.length)&&(this.trackVastError(n.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:n.errorCode||303},{ERRORMESSAGE:n.errorMessage||""},{extensions:n.extensions},{system:n.system}),e.ads.splice(t,1))}}}]),n}(_t),gn=null,hn={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},vn=function(){function e(){ct(this,e),this.storage=this.initStorage()}return st(e,[{key:"initStorage",value:function(){if(gn)return gn;try{gn="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){gn=null}return gn&&!this.isStorageDisabled(gn)||(gn=hn).clear(),gn}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),mn=function(){function e(t,n,r){ct(this,e),this.cappingFreeLunch=t||0,this.cappingMinimumTimeInterval=n||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new dn,this.storage=r||new vn,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return st(e,[{key:"getParser",value:function(){return this.vastParser}},{key:"lastSuccessfulAd",get:function(){return this.storage.getItem("vast-client-last-successful-ad")},set:function(e){this.storage.setItem("vast-client-last-successful-ad",e)}},{key:"totalCalls",get:function(){return this.storage.getItem("vast-client-total-calls")},set:function(e){this.storage.setItem("vast-client-total-calls",e)}},{key:"totalCallsTimeout",get:function(){return this.storage.getItem("vast-client-total-calls-timeout")},set:function(e){this.storage.setItem("vast-client-total-calls-timeout",e)}},{key:"hasRemainingAds",value:function(){return this.vastParser.remainingAds.length>0}},{key:"getNextAds",value:function(e){return this.vastParser.getRemainingAds(e)}},{key:"get",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Date.now();return(n=Object.assign(this.defaultOptions,n)).hasOwnProperty("resolveAll")||(n.resolveAll=!1),this.totalCallsTimeout=t.totalCalls)return i(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(t.totalCalls,"/").concat(t.cappingFreeLunch)));var a=r-t.lastSuccessfulAd;if(a<0)t.lastSuccessfulAd=0;else if(a3&&void 0!==arguments[3]?arguments[3]:null;for(var A in ct(this,n),(i=t.call(this)).ad=r,i.creative=o,i.variation=a,i.muted=!1,i.impressed=!1,i.skippable=!1,i.trackingEvents={},i._alreadyTriggeredQuartiles={},i.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],i.creative.trackingEvents){var s=i.creative.trackingEvents[A];i.trackingEvents[A]=s.slice(0)}return i.creative instanceof Rt?i._initLinearTracking():i._initVariationTracking(),e&&i.on("start",(function(){e.lastSuccessfulAd=Date.now()})),i}return st(n,[{key:"_initLinearTracking",value:function(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}},{key:"_initVariationTracking",value:function(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(var e in this.variation.trackingEvents){var t=this.variation.trackingEvents[e];this.trackingEvents[e]?this.trackingEvents[e]=this.trackingEvents[e].concat(t.slice(0)):this.trackingEvents[e]=t.slice(0)}this.variation instanceof Ft?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):this.variation instanceof pt&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}},{key:"setDuration",value:function(e){this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}}},{key:"setProgress",value:function(e){var t=this,n=this.skipDelay||-1;if(-1===n||this.skippable||(n>e?this.emit("skip-countdown",n-e):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){var r=[];if(e>0){var o=Math.round(e/this.assetDuration*100);for(var i in r.push("start"),r.push("progress-".concat(o,"%")),r.push("progress-".concat(Math.round(e))),this.quartiles)this.isQuartileReached(i,this.quartiles[i],e)&&(r.push(i),this._alreadyTriggeredQuartiles[i]=!0)}r.forEach((function(e){t.track(e,!0)})),e0&&void 0!==arguments[0]?arguments[0]:null;this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates);var t=this.clickThroughURLTemplate||e;if(t){var n=this.linear?{CONTENTPLAYHEAD:this.progressFormatted()}:{},r=yt.resolveURLTemplates([t],n)[0];this.emit("clickthrough",r)}}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"closeLinear"===e&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close");var n=this.trackingEvents[e],r=this.emitAlwaysEvents.indexOf(e)>-1;n?(this.emit(e,""),this.trackURLs(n)):r&&this.emit(e,""),t&&(delete this.trackingEvents[e],r&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}},{key:"trackURLs",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(t.ASSETURI=this.creative.mediaFiles[0].fileURL),t.CONTENTPLAYHEAD=this.progressFormatted()),yt.track(e,t)}},{key:"progressFormatted",value:function(){var e=parseInt(this.progress),t=e/3600;t.length<2&&(t="0".concat(t));var n=e/60%60;n.length<2&&(n="0".concat(n));var r=e%60;return r.length<2&&(r="0".concat(n)),"".concat(t,":").concat(n,":").concat(r,".").concat(parseInt(100*(this.progress-e)))}}]),n}(_t),yn=function(e,t,n,r){var o,i={},a={started:!1,active:!1,isVideoEnded:!1,lang:n.getLanguage()},A=null,s="",c=null,u="",l="",f=!1,p=n.getBrowser(),d="Android"===p.os||"iOS"===p.os;(o=document.createElement("div")).setAttribute("class","op-ads"),o.setAttribute("id","op-ads"),n.getContainer().append(o),(c=document.createElement("video")).setAttribute("playsinline","true"),c.setAttribute("title","Advertisement"),c.setAttribute("class","op-ads-vast-video"),(l=document.createElement("div")).setAttribute("class","op-ads-button"),(u=document.createElement("div")).setAttribute("class","op-ads-textview"),l.append(u),o.append(c),o.append(l),s=o;var g=new mn,h=null,v=null,m=function(e){console.log(e),c.style.display="none",t.trigger(se,{code:e.code,message:e.message}),a.active=!1,a.started=!0,t.play()};return i.isActive=function(){return a.active},i.started=function(){return a.started},i.play=function(){return a.started?c.play():new Promise((function(o,i){!function s(){t.metaLoaded()?(OvenPlayerConsole.log("VAST : main contents meta loaded."),function(){OvenPlayerConsole.log("VAST : checkAutoplaySupport() ");var n=document.createElement("video");n.setAttribute("playsinline","true"),n.src=Xe,n.load(),c.load(),d&&t.getName()!==le&&e.load();var r=function(e,t){f=e,n.pause(),n.remove()};return new Promise((function(e,t){if(n.play){var o=n.play();void 0!==o?o.then((function(){OvenPlayerConsole.log("VAST : auto play allowed."),r(!0),e()})).catch((function(t){OvenPlayerConsole.log("VAST : auto play failed",t.message),r(!1),e()})):(OvenPlayerConsole.log("VAST : promise not support"),r(!0),e())}else OvenPlayerConsole.log("VAST : !temporarySupportCheckVideo.play"),r(!0),e()}))}().then((function(){n.isAutoStart()&&!f?(OvenPlayerConsole.log("VAST : autoplayAllowed : false"),a.started=!1,i(new Error("autoplayNotAllowed"))):(g.get(r).then((function(n){if(OvenPlayerConsole.log("VAST : initRequest()"),!(v=n.ads[0]))throw{code:401,message:"File not found. Unable to find Linear/MediaFile from URI."};h=new Cn(g,v,v.creatives[0]),OvenPlayerConsole.log("VAST : created ad tracker."),A=function(e,t,n,r,o,i,a){var A={},s={},c=ze(i),u=ze(o),l=ze(e);n.on(Le,(function(t){t.mute?e.muted=!0:(e.muted=!1,e.volume=t.volume/100)}),s);var f=function(){r.active=!1,u.hide(),!r.started||0!==n.getPosition()&&r.isVideoEnded||(l.hide(),n.play()),n.trigger(Ae)},p=function(n){c.hasClass("videoAdUiAction")&&(t.skip(),e.pause(),f())};return i.addEventListener("click",p,!1),A.error=function(){OvenPlayerConsole.log("VAST : listener : error.",e.error),console.log("VAST : listener : error.",e.error);var n={},r=e.error&&e.error.code||0;2===r?(n.code=402,n.message="Timeout of MediaFile URI."):3===r?(n.code=405,n.message="Problem displaying MediaFile. Video player found a MediaFile with supported type but couldn’t display it. MediaFile may include: unsupported codecs, different MIME type than MediaFile@type, unsupported delivery method, etc."):4===r?(n.code=403,n.message="Couldn’t find MediaFile that is supported by this video player, based on the attributes of the MediaFile element."):(n.code=400,n.message="General Linear error. Video player is unable to display the Linear Ad."),t.errorWithCode(n.code),a("405")},A.canplay=function(){},A.ended=function(){t.complete(),f()},A.click=function(e){t.click()},A.play=function(){t.setPaused(!1)},A.pause=function(){t.setPaused(!0)},A.timeupdate=function(r){t.setProgress(r.target.currentTime),n.trigger(Ie,{duration:e.duration,position:e.currentTime})},A.volumechange=function(e){OvenPlayerConsole.log("VAST : listener : Ad Video Volumechange."),t.setMuted(e.target.muted)},A.loadedmetadata=function(){OvenPlayerConsole.log("VAST : listener : Ad CONTENT LOADED ."),ee===n.getState()&&n.pause(),t.trackImpression(),n.trigger(oe,{remaining:e.duration,isLinear:!0}),e.play()},t.on("skip",(function(){OvenPlayerConsole.log("VAST : listener : skipped")})),t.on("mute",(function(){OvenPlayerConsole.log("VAST : listener : muted")})),t.on("unmute",(function(){OvenPlayerConsole.log("VAST : listener : unmuted")})),t.on("resume",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker resumed."),r.started&&n.setState(ie)})),t.on("pause",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker paused."),n.setState(ae)})),t.on("clickthrough",(function(e){OvenPlayerConsole.log("VAST : listener : clickthrough :",e),window.open(e,"_blank")})),t.on("skip-countdown",(function(e){0===e?("ko"===r.lang?c.html("광고 건너뛰기"):c.html("Ad Skip"),c.addClass("videoAdUiAction")):"ko"===r.lang?c.html(parseInt(e)+1+"초 후에 이 광고를 건너뛸 수 있습니다."):c.html("You can skip this ad in "+(parseInt(e)+1))})),t.on("rewind",(function(){OvenPlayerConsole.log("VAST : listener : rewind")})),t.on("start",(function(){OvenPlayerConsole.log("VAST : listener : started"),r.started=!0,r.active=!0,l.show(),u.show(),n.trigger(ke,{isLinear:!0}),n.setState(ie)})),t.on("firstQuartile",(function(){OvenPlayerConsole.log("VAST : listener : firstQuartile")})),t.on("midpoint",(function(){OvenPlayerConsole.log("VAST : listener : midpoint")})),t.on("thirdQuartile",(function(){OvenPlayerConsole.log("VAST : listener : thirdQuartile")})),t.on("creativeView",(function(){OvenPlayerConsole.log("VAST : listener : creativeView")})),Object.keys(A).forEach((function(t){e.removeEventListener(t,A[t]),e.addEventListener(t,A[t])})),s.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),i.removeEventListener("click",p,!1),Object.keys(A).forEach((function(t){e.removeEventListener(t,A[t])}))},s}(c,h,t,a,l,u,m);var r="";v.creatives&&v.creatives.length>0&&v.creatives[0].mediaFiles&&v.creatives[0].mediaFiles.length>0&&v.creatives[0].mediaFiles[0].fileURL&&(r=v.creatives[0].mediaFiles[0].fileURL,OvenPlayerConsole.log("VAST : media url : ",r)),c.src=r,c.volume=e.volume,c.muted=e.muted})).catch((function(e){m(e)})),o())}))):setTimeout(s,100)}()}))},i.pause=function(){c.pause()},i.videoEndedCallback=function(e){e(),a.isVideoEnded=!0},i.destroy=function(){A&&(A.destroy(),A=null),h=null,g=null,s.remove()},i},bn=function(e,t,n){OvenPlayerConsole.log("[Provider] loaded. ");var r={};Ge(r);var o=e.element,i=null,a=null;e.adTagUrl&&(OvenPlayerConsole.log("[Provider] Ad Client - ",t.getAdClient()),(i="vast"===t.getAdClient()?yn(o,r,t,e.adTagUrl):et(o,r,t,e.adTagUrl))||console.log("Can not load due to google ima for Ads.")),a=function(e,t,n,r){var o={};OvenPlayerConsole.log("EventListener loaded.",e,t);var i={},a=-1,A=e;return o.canplay=function(){t.setCanSeek(!0),t.trigger("bufferFull"),OvenPlayerConsole.log("EventListener : on canplay")},o.durationchange=function(){o.progress(),OvenPlayerConsole.log("EventListener : on durationchange"),t.trigger("durationChanged")},o.ended=function(){OvenPlayerConsole.log("EventListener : on ended"),A.pause(),t.getState()!==X&&t.getState()!==q&&t.getState()!==te&&(n?n((function(){t.setState(q)})):t.setState(q))},o.loadeddata=function(){},o.loadedmetadata=function(){var e=t.getSources(),n=t.getCurrentSource(),r=n>-1?e[n].type:"",o={duration:t.isLive()?1/0:A.duration,type:r};t.setMetaLoaded(),OvenPlayerConsole.log("EventListener : on loadedmetadata",o),t.trigger(Me,o)},o.pause=function(){return t.getState()!==q&&t.getState()!==te&&!A.ended&&!A.error&&A.currentTime!==A.duration&&(OvenPlayerConsole.log("EventListener : on pause"),void t.setState($))},o.loadstart=function(){r&&!r.getConfig().showBigPlayButton&&r.getConfig().autoStart&&t.setState(ne)},o.play=function(){a=-1,A.paused||t.getState()===ee||t.setState(ne)},o.playing=function(){OvenPlayerConsole.log("EventListener : on playing"),a<0&&t.setState(ee)},o.progress=function(){var e=A.buffered;if(!e)return!1;var n,r=A.duration,o=A.currentTime,i=(n=(e.length>0?e.end(e.length-1):0)/r,Math.max(Math.min(n,1),0));t.setBuffer(100*i),t.trigger(Se,{bufferPercent:100*i,position:o,duration:r}),OvenPlayerConsole.log("EventListener : on progress",100*i)},o.timeupdate=function(){var e=A.currentTime,n=A.duration;if(!isNaN(n)){if(e>n)return A.pause(),void t.setState(q);var r=t.getSources()[t.getCurrentSource()].sectionStart;r&&eo&&t.getState()===ee)return t.stop(),void t.setState(q);n>9e15&&(n=1/0),t.isSeeking()||A.paused||t.getState()!==re&&t.getState()!==ne&&t.getState()!==ie||function(e,t){return e.toFixed(2)===t.toFixed(2)}(a,e)||(a=-1,t.setState(ee)),r&&r>0&&(e-=r)<0&&(e=0),o&&(n=o),r&&(n-=r),(t.getState()===ee||t.isSeeking())&&t.trigger(Te,{position:e,duration:n})}},o.seeking=function(){t.setSeeking(!0),OvenPlayerConsole.log("EventListener : on seeking",A.currentTime),t.trigger("seek",{position:A.currentTime})},o.seeked=function(){t.isSeeking()&&(OvenPlayerConsole.log("EventListener : on seeked"),t.setSeeking(!1),t.trigger("seeked"))},o.stalled=function(){OvenPlayerConsole.log("EventListener : on stalled")},o.waiting=function(){OvenPlayerConsole.log("EventListener : on waiting",t.getState()),t.isSeeking()?t.setState(ne):t.getState()===ee&&(a=A.currentTime,t.setState(re))},o.volumechange=function(){OvenPlayerConsole.log("EventListener : on volumechange",Math.round(100*A.volume)),t.trigger(Le,{volume:Math.round(100*A.volume),mute:A.muted})},o.error=function(){var e={0:300,1:301,2:302,3:303,4:304}[A.error&&A.error.code||0]||0;OvenPlayerConsole.log("EventListener : on error",e),qe(We.codes[e],t)},Object.keys(o).forEach((function(e){A.removeEventListener(e,o[e]),A.addEventListener(e,o[e])})),i.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),Object.keys(o).forEach((function(e){A.removeEventListener(e,o[e])}))},i}(o,r,i?i.videoEndedCallback:null,t),o.playbackRate=o.defaultPlaybackRate=t.getPlaybackRate();var A=function(i){var a=e.sources[e.currentSource];if(e.framerate=a.framerate,r.setVolume(t.getVolume()),e.framerate||t.setTimecodeMode(!0),n)n(a,i);else{OvenPlayerConsole.log("source loaded : ",a,"lastPlayPosition : "+i);var A=o.src;a.file!==A&&(o.src=a.file,(A||""===A)&&o.load()),r.on(Me,(function(){i>0&&r.seek(i)}))}};return r.getName=function(){return e.name},r.getMse=function(){return e.mse},r.getMediaElement=function(){return e.element},r.canSeek=function(){return e.canSeek},r.setCanSeek=function(t){e.canSeek=t},r.isSeeking=function(){return e.seeking},r.setSeeking=function(t){e.seeking=t},r.setMetaLoaded=function(){e.isLoaded=!0},r.metaLoaded=function(){return e.isLoaded},r.setState=function(t){if(e.state!==t){var n=e.state;if(OvenPlayerConsole.log("Provider : setState()",t),n===ie&&(t===te||t===X))return!1;switch(OvenPlayerConsole.log("Provider : triggerSatatus",t),t){case q:r.trigger("complete");break;case $:r.trigger(ye,{prevState:e.state,newstate:$});break;case ae:r.trigger(ye,{prevState:e.state,newstate:ae});break;case ee:r.trigger(be,{prevState:e.state,newstate:ee});break;case ie:r.trigger(be,{prevState:e.state,newstate:ie})}e.state=t,r.trigger(Ce,{prevstate:n,newstate:e.state})}},r.getState=function(){return e.state},r.setBuffer=function(t){e.buffer=t},r.getBuffer=function(){return e.buffer},r.isLive=function(){return!!e.isLive||o.duration===1/0},r.getDuration=function(){return r.isLive()?1/0:o.duration},r.getDvrWindow=function(){return e.dvrWindow},r.getPosition=function(){return o?o.currentTime:0},r.setVolume=function(e){if(!o)return!1;o.volume=e/100,t.setVolume(e)},r.getVolume=function(){return t.getVolume()},r.setMute=function(e){if(!o)return!1;if(void 0===e){var n=t.isMute();o.muted=!n,t.setMute(!n),r.trigger(Re,{mute:t.isMute()})}else o.muted=e,t.setMute(e),r.trigger(Re,{mute:t.isMute()});return o.muted},r.getMute=function(){return t.isMute()},r.preload=function(n,o){return e.sources=n,e.currentSource=$e(n,t),A(o||0),new Promise((function(e,n){t.isMute()&&r.setMute(!0),t.getVolume()&&r.setVolume(t.getVolume()),e()}))},r.load=function(n){e.sources=n,e.currentSource=$e(n,t),A(0)},r.play=function(){if(OvenPlayerConsole.log("Provider : play()"),!o)return!1;if(r.getState()!==ee)if(i&&i.isActive()||i&&!i.started())i.play().then((function(e){OvenPlayerConsole.log("Provider : ads play success")})).catch((function(e){OvenPlayerConsole.log("Provider : ads play fail",e)}));else{var e=o.play();void 0!==e?e.then((function(){OvenPlayerConsole.log("Provider : video play success")})).catch((function(e){OvenPlayerConsole.log("Provider : video play error",e.message)})):OvenPlayerConsole.log("Provider : video play success (ie)")}},r.pause=function(){if(OvenPlayerConsole.log("Provider : pause()"),!o)return!1;r.getState()===ee?o.pause():r.getState()===ie&&i.pause()},r.seek=function(e){if(!o)return!1;o.currentTime=e},r.setPlaybackRate=function(e){return!!o&&(r.trigger("playbackRateChanged",{playbackRate:e}),o.playbackRate=o.defaultPlaybackRate=e)},r.getPlaybackRate=function(){return o?o.playbackRate:0},r.getSources=function(){return o?e.sources.map((function(e,t){var n={file:e.file,type:e.type,label:e.label,index:t,sectionStart:e.sectionStart,sectionEnd:e.sectionEnd,gridThumbnail:e.gridThumbnail};return e.lowLatency&&(n.lowLatency=e.lowLatency),n})):[]},r.getCurrentSource=function(){return e.currentSource},r.setCurrentSource=function(n,i){if(n>-1&&e.sources&&e.sources.length>n)return OvenPlayerConsole.log("source changed : "+n),e.currentSource=n,t.setSourceIndex(n),r.setState(X),i&&A(o.currentTime||0),e.currentSource},r.getQualityLevels=function(){return o?e.qualityLevels:[]},r.getCurrentQuality=function(){return o?e.currentQuality:null},r.setCurrentQuality=function(e){},r.getAudioTracks=function(){return o?e.audioTracks:[]},r.getCurrentAudioTrack=function(){return o?e.currentAudioTrack:[]},r.setCurrentAudioTrack=function(e){},r.isAutoQuality=function(){},r.setAutoQuality=function(e){},r.getFramerate=function(){return e.framerate},r.setFramerate=function(t){return e.framerate=t},r.seekFrame=function(t){var n=e.framerate,i=(o.currentTime*n+t)/n;i+=1e-5,r.pause(),r.seek(i)},r.stop=function(){if(!o)return!1;for(OvenPlayerConsole.log("CORE : stop() "),o.removeAttribute("preload"),o.removeAttribute("src");o.firstChild;)o.removeChild(o.firstChild);r.pause(),r.setState(X)},r.destroy=function(){if(!o)return!1;r.stop(),a.destroy(),i&&(i.destroy(),i=null),r.off(),OvenPlayerConsole.log("CORE : destroy() player stop, listener, event destroied")},r.super=function(e){var t=r[e];return function(){return t.apply(r,arguments)}},r},wn=function(e,t,n){var r=bn({name:ce,element:e,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:X,buffer:0,framerate:0,currentQuality:-1,qualityLevels:[],currentAudioTrack:-1,audioTracks:[],currentSource:-1,sources:[],adTagUrl:n},t,null),o=r.super("destroy");return OvenPlayerConsole.log("HTML5 PROVIDER LOADED."),r.destroy=function(){OvenPlayerConsole.log("HTML5 : PROVIDER DESTROYED."),o()},r},En=function(e,t,n,r,o,a,A,s){var c={},u={},l=null,f=!1,p=null,d=null,g={},h=!1,v=!1,m=null,C=!1;A.getConfig().webrtcConfig&&!0===A.getConfig().webrtcConfig.recoverPacketLoss&&(v=!0);var y=!0;A.getConfig().webrtcConfig&&!1===A.getConfig().webrtcConfig.generatePublicCandidate&&(y=A.getConfig().webrtcConfig.generatePublicCandidate);var b=Y(),w=null;function E(e){var t=null;return d&&e===d.id?t=d.peerConnection:g[e]&&(t=g[e].peerConnection),t}function B(e){e.statisticsTimer&&clearTimeout(e.statisticsTimer),e.status||(e.status={},e.status.lostPacketsArr=[],e.status.slotLength=8,e.status.prevPacketsLost=0,e.status.avg8Losses=0,e.status.avgMoreThanThresholdCount=0,e.status.threshold=40);var t=e.status.lostPacketsArr,n=e.status.slotLength,r=e.status.prevPacketsLost,o=e.status.avg8Losses,a=e.status.threshold;e.statisticsTimer=setTimeout((function(){if(!e.peerConnection)return!1;e.peerConnection.getStats().then((function(s){s&&A.getConfig().autoFallback&&s&&(s.forEach((function(A){if("inbound-rtp"===A.type&&"video"===A.kind&&!A.isRemote){var s=parseInt(A.packetsLost)-parseInt(r);t.push(parseInt(A.packetsLost)-parseInt(r)),t.length>n&&t.shift(),t.length===n&&(o=i().reduce(t,(function(e,t){return e+t}),0)/n,OvenPlayerConsole.log("Last8 LOST PACKET AVG : "+o,"Current Packet LOST: "+s,"Total Packet Lost: "+A.packetsLost,t),o>a?(e.status.avgMoreThanThresholdCount=e.status.avgMoreThanThresholdCount+1,e.status.avgMoreThanThresholdCount>=60&&(OvenPlayerConsole.log("NETWORK UNSTABLED!!! "),M(We.codes[510]))):e.status.avgMoreThanThresholdCount=0),e.status.prevPacketsLost=A.packetsLost}})),B(e))}))}),2e3)}function x(o,a,s,u,f){var g={};if(A.getConfig().webrtcConfig&&A.getConfig().webrtcConfig.iceServers)g.iceServers=A.getConfig().webrtcConfig.iceServers,A.getConfig().webrtcConfig.iceTransportPolicy&&(g.iceTransportPolicy=A.getConfig().webrtcConfig.iceTransportPolicy);else if(f){g.iceServers=[];for(var m=0;m-1){b=!0;break}if(!b&&y.urls.length>0){var x=i().clone(y.urls[0]),k=S(x);w&&k&&y.urls.push(x.replace(k,w))}y.username=C.username||C.user_name,y.credential=C.credential,g.iceServers.push(y)}g.iceTransportPolicy="relay"}else g=c;OvenPlayerConsole.log("Main Peer Connection Config : ",g);var T=null;try{T=new RTCPeerConnection(g),e.trigger("peerConnectionPrepared",T)}catch(e){var R=We.codes[506];return R.error=e,void M(R)}d={id:o,peerId:a,peerConnection:T},T.setRemoteDescription(new RTCSessionDescription(s)).then((function(){T.createAnswer().then((function(e){var t=function(e){for(var t=e.split("\r\n"),n=-1,r=0;r-1&&t[r].indexOf("opus")>-1){n=t[r].split(" ")[0].split(":")[1];break}return n}(s.sdp);t>-1&&function(e,t){for(var n=e.split("\r\n"),r=!1,o=0;o-1){n[o].indexOf("stereo=1")>-1&&(r=!0);break}return r}(s.sdp,t)&&(e.sdp=function(e,t){for(var n=e.split("\r\n"),r=0;r-1){-1===n[r].indexOf("stereo=1")&&(n[r]=n[r]+";stereo=1");break}return n.join("\r\n")}(e.sdp,t)),OvenPlayerConsole.log("Local SDP",e),O(l,{id:o,peer_id:a,command:"answer",sdp:e}),OvenPlayerConsole.log("create Host Answer : success"),T.setLocalDescription(e).then((function(){})).catch((function(e){var t=We.codes[505];t.error=e,M(t)}))})).catch((function(e){var t=We.codes[504];t.error=e,M(t)}))})).catch((function(e){var t=We.codes[503];t.error=e,M(t)})),u&&L(T,u),T.onicecandidate=function(e){e.candidate&&(OvenPlayerConsole.log("WebRTCLoader send candidate to server : ",e.candidate),O(l,{id:o,peer_id:a,command:"candidate",candidates:[e.candidate]}))},T.onconnectionstatechange=function(e){OvenPlayerConsole.log("[on connection state change]",T.connectionState,e),"connected"===T.connectionState&&r&&r()},T.onicecandidateerror=function(e){},T.onicegatheringstatechange=function(e){},T.oniceconnectionstatechange=function(e){OvenPlayerConsole.log("[on ice connection state change]",T.iceConnectionState,e),"connected"===T.iceConnectionState&&r&&r(),("disconnected"===T.iceConnectionState||"closed"===T.iceConnectionState)&&(h||d&&M(We.codes[511]))},T.ontrack=function(e){if(OvenPlayerConsole.log("stream received."),OvenPlayerConsole.log("Recovery On Packet Loss :",v),v&&B(d),p=e.streams[0],n(e.streams[0]),A.getConfig().webrtcConfig&&A.getConfig().webrtcConfig.playoutDelayHint)for(var t=A.getConfig().webrtcConfig.playoutDelayHint,r=d.peerConnection.getReceivers(),o=0;o0){for(var n in g){var r=g[n].peerConnection;r&&(OvenPlayerConsole.log("Closing client peer connection..."),r.close(),r=null)}g={}}l?(OvenPlayerConsole.log("Closing websocket connection..."),OvenPlayerConsole.log("Send Signaling : Stop."),1===l.readyState&&(h=!0,d&&O(l,{command:"stop",id:d.id}),l.close())):h=!1,l=null,t&&(o&&o(t),a(t,e))}function O(e,t){e&&e.send(JSON.stringify(t))}return w=window.onbeforeunload,window.onbeforeunload=function(e){w&&w(e),OvenPlayerConsole.log("This calls auto when browser closed."),M()},e.setCurrentQuality=function(e){if(!m)return-1;var t=m.renditions[e];return t?(O(l,{command:"change_rendition",id:d.id,rendition_name:t.name,auto:!1}),C=!1,s.currentQuality=e,s.currentQuality):s.currentQuality},e.isAutoQuality=function(){return C},e.setAutoQuality=function(e){O(l,{command:"change_rendition",id:d.id,auto:e}),C=e},u.connect=function(){OvenPlayerConsole.log("WebRTCLoader connecting..."),OvenPlayerConsole.log("WebRTCLoader url : "+t),R()},u.destroy=function(){h=!0,M(),window.onbeforeunload=w,w=null},u},Bn=function(e,t,n){var r={},o=null,i=null,a=null,A=null,s=null,c={name:ue,element:e,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:X,buffer:0,framerate:0,currentQuality:-1,currentSource:-1,qualityLevels:[],sources:[],adTagUrl:n},u=1e4,l=0,f=null,p=!1;function d(){if(Ve(A.file,A.type)){clearTimeout(f),OvenPlayerConsole.log("WEBRTC : onBeforeLoad : ",A),o&&(o.destroy(),o=null);var n=null,i=null;l>0&&(n=function(){clearTimeout(f)},i=function(){clearTimeout(f),performance.now(),p=!0}),o=En(r,A.file,(function(t){if(e.srcObject&&(e.srcObject=null),s&&(s.close(),s=null),e.srcObject=t,t.getAudioTracks().length>0){var n=window.AudioContext||window.webkitAudioContext;(function(e){var t=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent),n=(/iPhone|iPad|iPod/i.test(navigator.userAgent),!1);t&&"suspended"===e.state&&document.addEventListener("touchend",(function(){n||"running"===e.state||(e.resume(),n=!0)}))})(s=new n),s.createMediaStreamSource(t)}}),i,n,qe,t,c),performance.now(),o.connect(),l>0&&(r.once(Ce,(function(e){p||e.newstate===X&&(clearTimeout(f),g())})),r.once(me,(function(){p=!1})),f=setTimeout((function(){if(l>0)p||(g(),d());else{g();var e=We.codes[512];qe(e,r)}l--}),u))}}function g(){o&&(o.destroy(),o=null,e.srcObject=null)}return r=bn(c,t,(function(e){var n=t.getConfig();n.webrtcConfig&&("number"==typeof n.webrtcConfig.connectionTimeout&&n.webrtcConfig.connectionTimeout>0&&(u=n.webrtcConfig.connectionTimeout),"number"==typeof n.webrtcConfig.timeoutMaxRetry&&n.webrtcConfig.timeoutMaxRetry>0&&(l=n.webrtcConfig.timeoutMaxRetry)),A=e,d()})),i=r.super("destroy"),a=r.super("play"),OvenPlayerConsole.log("WEBRTC PROVIDER LOADED."),r.removeStream=function(){e.srcObject=null},r.destroy=function(){clearTimeout(f),g(),OvenPlayerConsole.log("WEBRTC : PROVIDER DESTROYED."),i()},r.play=function(){l>0&&!p&&d(),a()},r},xn=function(e,t,n){var r=t?1e3:1024;if(Math.abs(e)=r&&a=0&&r.seek(t)})),o.on(Hls.Events.LEVEL_SWITCHED,(function(e,t){f.currentQuality=t.level,r.trigger(Qe,{isAuto:o.autoLevelEnabled,currentQuality:f.currentQuality,type:"render"})})),o.on(Hls.Events.AUDIO_TRACK_SWITCHED,(function(e,t){f.currentAudioTrack=t.id,r.trigger(Ne,{currentAudioTrack:f.currentAudioTrack})})),o.on(Hls.Events.LEVEL_UPDATED,(function(e,t){t&&t.details&&(f.dvrWindow=t.details.totalduration)})),o.on(Hls.Events.ERROR,(function(t,n){if(n&&n.networkDetails&&202===n.networkDetails.status)return A&&(clearTimeout(A),A=null),r.setState(ne),void(A=setTimeout((function(){o&&(r.stop(),o.stopLoad(),o.loadSource(e.file))}),1e3));if(n.fatal){var i=302;n&&n.networkDetails&&400===n.networkDetails.status?i=306:n&&n.networkDetails&&403===n.networkDetails.status?i=307:n&&n.networkDetails&&406===n.networkDetails.status&&(i=308);var a=We.codes[i];a.error=n.details,qe(a,r)}})),r.on(Ce,(function(e){s||e.prevstate!==ne||e.newstate!==X||(A&&(clearTimeout(A),A=null),o&&o.stopLoad())}))})),r.setCurrentQuality=function(e){return o.currentLevel=e,f.currentQuality=e,f.currentQuality},r.isAutoQuality=function(){return o.autoLevelEnabled},r.setAutoQuality=function(e){o.currentLevel=e?-1:o.currentLevel},r.setCurrentAudioTrack=function(e){return o.audioTrack=e,f.currentAudioTrack=e,f.currentAudioTrack},r.getDuration=function(){return e.duration},i=r.super("stop"),r.stop=function(){A&&(clearTimeout(A),A=null),o&&o.stopLoad(),i()},a=r.super("destroy"),r.destroy=function(){A&&(clearTimeout(A),A=null),o&&(o.destroy(),r.trigger("hlsDestroyed")),o=null,OvenPlayerConsole.log("HLS : PROVIDER DESTROYED."),a()},OvenPlayerConsole.log("HLS PROVIDER LOADED.")}catch(e){var p=We.codes[106];throw p.error=e,p}return r},Sn=function(e){var t={};Ge(t),OvenPlayerConsole.log("API loaded.");var n=function(e){var t={},n={playlist:[],currentIndex:0},r=Ke();OvenPlayerConsole.log("PlaylistManager loaded.");var o=function(e){if(e&&(e.file||e.host||e.application||e.stream)){var t=Object.assign({},{default:!1},e);t.file=a(""+t.file),t.host&&t.application&&t.stream&&(t.file=t.host+"/"+t.application+"/stream/"+t.stream,delete t.host,delete t.application,delete t.stream);var n=/^[^/]+\/(?:x-)?([^/]+)$/;if(n.test(t.type)&&(t.mimeType=t.type,t.type=t.type.replace(n,"$1")),_e(t.file)?t.type="rtmp":Ve(t.file)?t.type="webrtc":He(t.file,t.type)?t.type="hls":Je(t.file,t.type)?t.type="dash":t.type||(t.type=A(t.file)),t.lowLatency&&(t.lowLatency=t.lowLatency),t.type){switch(t.type){case"m3u8":case"vnd.apple.mpegurl":t.type="hls";break;case"m4a":t.type="aac";break;case"smil":t.type="rtmp"}return Object.keys(t).forEach((function(e){""===t[e]&&delete t[e]})),t}}};return t.initPlaylist=function(e,t){OvenPlayerConsole.log("PlaylistManager setPlaylist() ",e);var a=(i().isArray(e)?e:[e]).map((function(e){i().isArray(e.tracks)||delete e.tracks;var n=Object.assign({},{sources:[],tracks:[],title:""},e);n.sources!==Object(n.sources)||i().isArray(n.sources)||(n.sources=[o(n.sources)]),i().isArray(n.sources)&&0!==n.sources.length||(n.sources=[o(n)]),i().isArray(n.sources)&&0!==n.sources.length||(e.levels?n.sources=e.levels:n.sources=[o(e)]);for(var a=0;a0}))||[];return n.playlist=a,a},t.getPlaylist=function(){return OvenPlayerConsole.log("PlaylistManager getPlaylist() ",n.playlist),n.playlist},t.getCurrentPlayList=function(){return n.playlist[n.currentIndex]?n.playlist[n.currentIndex]:[]},t.getCurrentPlaylistIndex=function(){return n.currentIndex},t.setCurrentPlaylist=function(t){return n.playlist[t]&&(n.currentIndex=t,e.trigger(ge,n.currentIndex)),n.currentIndex},t.getCurrentSources=function(){return n.playlist[n.currentIndex]?(OvenPlayerConsole.log("PlaylistManager getCurrentSources() ",n.playlist[n.currentIndex].sources),n.playlist[n.currentIndex].sources):null},t.getCurrentAdTag=function(){if(n.playlist[n.currentIndex])return n.playlist[n.currentIndex].adTagUrl||""},t}(t),o=function(){var e=Ke(),t={},n={};OvenPlayerConsole.log("ProviderController loaded.");var r=function(e,n){t[e]||(OvenPlayerConsole.log("ProviderController _registerProvider() ",e),t[e]=n)},o={html5:function(){var e=wn;return r(ce,e),{name:ce,provider:e}},webrtc:function(){var e=Bn;return r(ue,e),{name:ue,provider:e}},dash:function(){var e=kn;return r(le,e),{name:le,provider:e}},hls:function(){var e=In;return r(fe,e),{name:fe,provider:e}}};return n.loadProviders=function(t){var n=e.findProviderNamesByPlaylist(t);return OvenPlayerConsole.log("ProviderController loadProviders() ",n),n?Promise.all(n.filter((function(e){return!!o[e]})).map((function(e){return o[e]()}))):Promise.reject(We.codes[101])},n.findByName=function(e){return OvenPlayerConsole.log("ProviderController findByName() ",e),t[e]},n.getProviderBySource=function(t){var r=e.findProviderNameBySource(t);return OvenPlayerConsole.log("ProviderController getProviderBySource() ",r),n.findByName(r)},n.isSameProvider=function(t,n){return OvenPlayerConsole.log("ProviderController isSameProvider() ",e.findProviderNameBySource(t),e.findProviderNameBySource(n)),e.findProviderNameBySource(t)===e.findProviderNameBySource(n)},n}(),s=Y(),c=function(e,t){var n={},r=ze(e),o="";return OvenPlayerConsole.log("MediaManager loaded. browser : ",t),n.createMedia=function(e,t){return n.empty(),i=t.isLoop(),a=t.isAutoStart(),(o=document.createElement("video")).setAttribute("preload","auto"),o.setAttribute("disableremoteplayback",""),o.setAttribute("webkit-playsinline","true"),o.setAttribute("playsinline","true"),i&&o.setAttribute("loop",""),a&&o.setAttribute("autoplay",""),r.append(o),o;var i,a},n.createAdContainer=function(){var e=document.createElement("div");return e.setAttribute("class","op-ads"),r.append(e),e},n.empty=function(){OvenPlayerConsole.log("MediaManager removeElement()"),r.removeChild(o),o=null},n.destroy=function(){r.removeChild(),r=null,o.src=null,o.srcObject=null,o=null},n}(e,s),u="",l="",f="",p=function(e){OvenPlayerConsole.log("runNextPlaylist");var r=e,o=!!n.getPlaylist()[r];l.setSourceIndex(0),l.setVolume(u.getVolume()),o?(n.setCurrentPlaylist(r),d()):t.trigger(he,null)},d=function(e){return o.loadProviders(n.getCurrentPlayList()).then((function(e){if(e.length<1)throw We.codes[101];u&&(u.destroy(),u=null),f&&(f.destroy(),f=null),f=function(e,t){var n={},r=[],o=-1,a=K(),A=!0;OvenPlayerConsole.log("Caption Manager >> ",t);var s=function(e,t){return e.data=t||[],e.name=e.label||e.name||e.language,e.id=function(e,t){var n,o=e.kind||"cc";return n=e.default||e.defaulttrack?"default":e.id||o+t,A&&(c(r.length||0),A=!1),n}(e,r.length),r.push(e),e.id},c=function(t){o=t,e.trigger(Pe,o)};if(e.getConfig().playlist&&e.getConfig().playlist.length>0){var u=e.getConfig().playlist[t];if(u&&u.tracks&&u.tracks.length>0)for(var l=function(t){var n=u.tracks[t];Ye(n.kind)&&!i().findWhere(n,{file:n.file})&&a.load(n,n.lang,(function(e){e&&e.length>0&&s(n,e)}),(function(t){var n=We.codes[305];n.error=t,e.trigger(me,n)}))},f=0;f-1&&r[o]){var a=i().filter(r[o].data,(function(e){return n>=e.startTime&&(!e.endTime||n)<=e.endTime}));a&&a.length>0&&e.trigger(De,a[0])}})),n.flushCaptionList=function(e){r=[],c(e)},n.getCaptionList=function(){return r||[]},n.getCurrentCaption=function(){return o},n.setCurrentCaption=function(e){if(!(e>-2&&e0&&s(t,e)}),(function(t){var n=errors[305];n.error=t,e.trigger(me,n)}))},n.removeCaption=function(e){return e>-1&&e=.25&&e<=4})).map((function(e){return Math.round(4*e)/4}))).indexOf(1)<0&&a.push(1),a.sort(),t.playbackRates=a,t.rtmpBufferTime=t.rtmpBufferTime>10?10:t.rtmpBufferTime,t.rtmpBufferTimeMax=t.rtmpBufferTimeMax>50?50:t.rtmpBufferTimeMax,t.playbackRates.indexOf(t.playbackRate)<0&&(t.playbackRate=1);var A=t.playlist;if(A)i().isArray(A.playlist)&&(t.feedData=A,t.playlist=A.playlist);else{var s=i().pick(t,["title","description","type","image","file","sources","tracks","host","application","stream","adTagUrl"]);t.playlist=[s]}return delete t.duration,t}(e);return{getConfig:function(){return n},getAdClient:function(){return n.adClient},setConfig:function(e,t){n[e]=t},getContainer:function(){return n.mediaContainer},getPlaybackRate:function(){return n.playbackRate},setPlaybackRate:function(e){return n.playbackRate=e,e},getQualityLabel:function(){return n.qualityLabel},setQualityLabel:function(e){n.qualityLabel=e},isCurrentProtocolOnly:function(){return n.currentProtocolOnly},getSourceIndex:function(){return n.sourceIndex},setSourceIndex:function(e){n.sourceIndex=e},setTimecodeMode:function(e){n.timecode!==e&&(n.timecode=e,t.trigger(Fe,e))},isTimecodeMode:function(){return n.timecode},getRtmpBufferTime:function(){return n.rtmpBufferTime},getRtmpBufferTimeMax:function(){return n.rtmpBufferTimeMax},setMute:function(e){n.mute=e},isMute:function(){return n.mute},getVolume:function(){return n.volume},setVolume:function(e){n.volume=e},isLoop:function(){return n.loop},isAutoStart:function(){return n.autoStart},isControls:function(){return n.controls},getPlaybackRates:function(){return n.playbackRates},getBrowser:function(){return n.browser},getSystemText:function(){return n.systemText},getLanguage:function(){return n.lang},getPlaylist:function(){return n.playlist},setPlaylist:function(e){return i().isArray(e)?n.playlist=e:n.playlist=[e],n.playlist}}}(r,t),OvenPlayerConsole.log("API : init()"),OvenPlayerConsole.log("API : init() config : ",l),We.codes=l.getSystemText().api.error,n.initPlaylist(l.getPlaylist(),l),OvenPlayerConsole.log("API : init() sources : ",n.getCurrentSources()),d(),setTimeout((function(){t.trigger(pe)}))},t.getProviderName=function(){return u?u.getName():null},t.getProvider=function(){return u},t.getMseInstance=function(){return u?u.getMse():null},t.getConfig=function(){return OvenPlayerConsole.log("API : getConfig()",l.getConfig()),l.getConfig()},t.getBrowser=function(){return l.getBrowser()},t.setTimecodeMode=function(e){OvenPlayerConsole.log("API : setTimecodeMode()",e),l.setTimecodeMode(e)},t.isTimecodeMode=function(){return OvenPlayerConsole.log("API : isTimecodeMode()"),l.isTimecodeMode()},t.getFramerate=function(){if(OvenPlayerConsole.log("API : getFramerate()"),u)return u.getFramerate()},t.seekFrame=function(e){return u?(OvenPlayerConsole.log("API : seekFrame()",e),u.seekFrame(e)):null},t.getDuration=function(){return u?(OvenPlayerConsole.log("API : getDuration()",u.getDuration()),u.getDuration()):null},t.getDvrWindow=function(){return u?(OvenPlayerConsole.log("API : getDvrWindow()",u.getDvrWindow()),u.getDvrWindow()):null},t.getPosition=function(){return u?(OvenPlayerConsole.log("API : getPosition()",u.getPosition()),u.getPosition()):null},t.getVolume=function(){return u?(OvenPlayerConsole.log("API : getVolume()",u.getVolume()),u.getVolume()):null},t.setVolume=function(e){if(!u)return null;OvenPlayerConsole.log("API : setVolume() "+e),u.setVolume(e)},t.setMute=function(e){return u?(OvenPlayerConsole.log("API : setMute() "+e),u.setMute(e)):null},t.getMute=function(){return u?(OvenPlayerConsole.log("API : getMute() "+u.getMute()),u.getMute()):null},t.load=function(e){return OvenPlayerConsole.log("API : load() ",e),e&&(l.setSourceIndex(0),u&&u.getQualityLevels().length>0&&u.setCurrentQuality(0),"sources"in e?l.setPlaylist(e):l.setPlaylist({sources:e}),n.initPlaylist(l.getPlaylist(),l)),d()},t.play=function(){if(!u)return null;OvenPlayerConsole.log("API : play() "),u.metaLoaded()||l.isAutoStart()?u.play():t.once(Me,(function(){u.play()}))},t.pause=function(){if(!u)return null;OvenPlayerConsole.log("API : pause() "),u.pause()},t.seek=function(e){if(!u)return null;OvenPlayerConsole.log("API : seek() "+e),u.seek(e)},t.setPlaybackRate=function(e){return u?(OvenPlayerConsole.log("API : setPlaybackRate() ",e),u.setPlaybackRate(l.setPlaybackRate(e))):null},t.getPlaybackRate=function(){return u?(OvenPlayerConsole.log("API : getPlaybackRate() ",u.getPlaybackRate()),u.getPlaybackRate()):null},t.getPlaylist=function(){return OvenPlayerConsole.log("API : getPlaylist() ",n.getPlaylist()),n.getPlaylist()},t.getCurrentPlaylist=function(){return OvenPlayerConsole.log("API : getCurrentPlaylist() ",n.getCurrentPlaylistIndex()),n.getCurrentPlaylistIndex()},t.setCurrentPlaylist=function(e){OvenPlayerConsole.log("API : setCurrentPlaylist() ",e),p(e)},t.getSources=function(){return u?(OvenPlayerConsole.log("API : getSources() ",u.getSources()),u.getSources()):null},t.getCurrentSource=function(){return u?(OvenPlayerConsole.log("API : getCurrentSource() ",u.getCurrentSource()),u.getCurrentSource()):null},t.setCurrentSource=function(e){if(!u)return null;OvenPlayerConsole.log("API : setCurrentSource() ",e);var n=u.getPosition();return l.setSourceIndex(e),d(n).then((function(){t.trigger(Oe,{currentSource:e})})),e},t.getQualityLevels=function(){return u?(OvenPlayerConsole.log("API : getQualityLevels() ",u.getQualityLevels()),u.getQualityLevels()):null},t.getCurrentQuality=function(){return u?(OvenPlayerConsole.log("API : getCurrentQuality() ",u.getCurrentQuality()),u.getCurrentQuality()):null},t.setCurrentQuality=function(e){return u?(OvenPlayerConsole.log("API : setCurrentQuality() ",e),u.setCurrentQuality(e)):null},t.getAudioTracks=function(){return u?(OvenPlayerConsole.log("API : getAudioTracks() ",u.getAudioTracks()),u.getAudioTracks()):null},t.getCurrentAudioTrack=function(){return u?(OvenPlayerConsole.log("API : getCurrentAudioTrack() ",u.getCurrentAudioTrack()),u.getCurrentAudioTrack()):null},t.setCurrentAudioTrack=function(e){return u?(OvenPlayerConsole.log("API : setCurrentAudioTrack() ",e),u.setCurrentAudioTrack(e)):null},t.isAutoQuality=function(){return u?(OvenPlayerConsole.log("API : isAutoQuality()"),u.isAutoQuality()):null},t.setAutoQuality=function(e){return u?(OvenPlayerConsole.log("API : setAutoQuality() ",e),u.setAutoQuality(e)):null},t.getCaptionList=function(){return f?(OvenPlayerConsole.log("API : getCaptionList() ",f.getCaptionList()),f.getCaptionList()):null},t.getCurrentCaption=function(){return f?(OvenPlayerConsole.log("API : getCurrentCaption() ",f.getCurrentCaption()),f.getCurrentCaption()):null},t.setCurrentCaption=function(e){if(!f)return null;OvenPlayerConsole.log("API : setCurrentCaption() ",e),f.setCurrentCaption(e)},t.addCaption=function(e){return f?(OvenPlayerConsole.log("API : addCaption() "),f.addCaption(e)):null},t.removeCaption=function(e){return f?(OvenPlayerConsole.log("API : removeCaption() ",e),f.removeCaption(e)):null},t.getBuffer=function(){if(!u)return null;OvenPlayerConsole.log("API : getBuffer() ",u.getBuffer()),u.getBuffer()},t.getState=function(){return u?(OvenPlayerConsole.log("API : getState() ",u.getState()),u.getState()):null},t.stop=function(){if(!u)return null;OvenPlayerConsole.log("API : stop() "),u.stop()},t.remove=function(){OvenPlayerConsole.log("API : remove() "),f&&(f.destroy(),f=null),u&&(u.destroy(),u=null),c&&(c.destroy(),c=null),t.trigger(de),t.off(),o=null,n=null,l=null,OvenPlayerConsole.log("API : remove() - currentProvider, providerController, playlistManager, playerConfig, api event destroed. "),Tn.removePlayer(t)},t.getMediaElement=function(){return u.getMediaElement()},t.getVersion=function(){return r},t},Tn=(sn=(An={}).playerList=[],An.create=function(e,t){window.OvenPlayerConsole&&0!==Object.keys(window.OvenPlayerConsole).length||(window.OvenPlayerConsole={},OvenPlayerConsole.log=function(){});var n=Ze(e),r=Sn(n);return r.init(t),sn.push(r),r},An.getPlayerList=function(){return sn},An.getPlayerByContainerId=function(e){for(var t=0;t
'+(t.isRoot?"":'<')+''+t.title+'
';return i().forEach(t.body,(function(e){n+=Rn(e,t.useCheck)})),n+="
"},Rn=function(e,t){return'
'+(t?'':"")+''+e.title+""+(e.hasNext?'>'+e.description+"":"")+"
"},Mn=function(e,t){return'
')+'
').concat(e.image?""):''," ").concat(e.duration?''.concat(s(e.duration),""):"","
")+'
'.concat(e.title,"
")+"
"},On={TextViewTemplate:function(e){return'
'+"

".concat(e,"

")+'
'},ViewTemplate:function(e,t){return'
")+'
'},HelpersTemplate:function(e,t){return'
'},BigButtonTemplate:function(e,t){return'
'+"".concat(t===ee?'':"")+"".concat(t===$?'':"")+"".concat(t===X?'':"")+"".concat(t===q?'':"")+"
"},ThumbnailTemplate:function(e,t){return'
'+"".concat(t.title?'
'.concat(t.title,"
"):"")+"
"},WaterMarkTemplate:function(e,t){return'
'+"".concat(t.waterMark.image?''):"")+"".concat(t.waterMark.text?''.concat(t.waterMark.text,""):"")+"
"},MessageBoxTemplate:function(e,t){return'
')+'
'+'
'.concat(t.message)+"".concat(t.description?'
'.concat(t.description,"
"):"")+"
"+"".concat(t.iconClass?'
'):"")+"
"},SpinnerTemplate:function(e){return'
'},ContextPanelTemplate:function(e){return'
'+''.concat(e.context," ").concat(r,"")+"
"},CaptionViewerTemplate:function(e){return'
      
'},ControlsTemplate:function(e,t){return'
'+'
'.concat(t?'':"","
")+'
'},VolumeButtonTemplate:function(e){return'
'},ProgressBarTemplate:function(e){return'
00:00
'},PlayButtonTemplate:function(e){return'
'},SettingButtonTemplate:function(e){return''},FrameButtonsTemplate:function(e){return'
'},TimeDisplayTemplate:function(e,t){return'
'+(t.duration===1/0?''+("webrtc"===t.type?t.isP2P?''.concat(e.controls.low_latency_p2p,""):''.concat(e.controls.low_latency_live,""):''.concat(e.controls.live,""))+"":'00:00 / 00:00')+"
"},FullScreenButtonTemplate:function(e){return''},PanelsTemplate:Ln,SpeedPanelTemplate:Ln,SourcePanelTemplate:Ln,QualityPanelTemplate:Ln,AudioTrackPanelTemplate:Ln,CaptionPanelTemplate:Ln,TimeDisplayPanelTemplate:Ln,PlaylistPanelTemplate:function(e,t){return'
'+'
'.concat(e.playlist,'
')+'
'}},Qn=function(e,t,n,r,o,a,A,s){var c,u=i().isElement(e)?ze(e):e,l={},f=null,p={};p.data=r;var d=function(e){var t=document.createElement("div");return t.innerHTML=e,c=ze(t.firstChild),t.firstChild};return n&&n.systemText&&(f=n.systemText.ui),s?u.replace(d(On[t+"Template"](f,r))):u.append(d(On[t+"Template"](f,r))),a&&a(c,p),Object.keys(o).forEach((function(e){var t=e.split(" "),n=t[0].replace(/ /gi,""),r=t[1].replace(/ /gi,""),i="";if(i="document"===r||"window"===r||"body"===r?ze(r):c.find(r)||(c.hasClass(r.replace(".",""))?c:null),!(n&&r&&i))return!1;var a=Object.keys(l).length++,A=function(t){return o[e](t,c,p)};l[a]={name:n,target:r,callback:A};var s=null;n.indexOf("touch")>-1&&(s={passive:!0});var u=i.get().length;if(u>1)for(var f=i.get(),d=0;d1)for(var o=n.get(),i=0;i-1?o=!1:(o=!0,e.find(".op-caption-text").text(""))}),r),t.on(De,(function(t){if(!o&&t&&t.text){var n=t.endTime-t.startTime;i&&clearTimeout(i),e.find(".op-caption-text").html(t.text),n&&(i=setTimeout((function(){e.find(".op-caption-text").text("")}),1e3*n))}}),r)}),(function(n){e.find(".op-caption-text").text(""),t.off(Pe,null,n),t.off(De,null,n)}))}(e,t),t.on(pe,(function(){u&&v(),l&&(r&&r.destroy(),r=function(e,t,n){var r=null,o=null;return Qn(e,"WaterMark",t.getConfig(),n,{},(function(e,n){r=e.find(".op-watermark"),o=e.find(".op-watermark-text");var a=t.getConfig().waterMark,A=a.position||"top-right",s=a.y||"5%",c=a.x||"2.8125%";r.css(A.split("-")[0],s),r.css(A.split("-")[1],c);var u=a.width||"auto",l=a.height||"auto";r.css("width",u),r.css("height",l);var f=a.opacity||.7;r.css("opacity",f),a.text&&a.font&&i().each(a.font,(function(e,t){o.css(t,e)}))}),(function(){}))}(e,t,t.getConfig())),o||(h($),o=!0)}),p),t.on(xe,(function(n){n.message&&(a&&a.destroy(),A&&A.destroy(),c=Dn(e,t,n.message,null,n.timer,n.iconClass,n.onClickCallback,!1),t.once(Re,(function(e){!e.mute&&c&&c.destroy()}),p))}),p),t.on(Ce,(function(e){e&&e.newstate&&(e.newstate===X&&A&&A.destroy(),e.newstate===ee||e.newstate===ie?(f=!1,A&&A.destroy(),a&&a.destroy(),n&&n.destroy(),d||s.show(!1)):e.newstate===q?(s.show(!1),h(e.newstate)):e.newstate===re||e.newstate===ne||"adLoading"===e.newstate?(f=!1,A&&A.destroy(),a&&a.destroy(),s.show(!0)):d||s.show(!1))}),p),t.on(Oe,(function(){u&&v()})),t.on(Qe,(function(e){if(e.currentQuality<0)return!1;e.isAuto?(d=!1,s.show(!1)):"request"===e.type?(g=e.currentQuality,d=!0,s.show(!0)):"render"===e.type&&g===e.currentQuality&&(d=!1,s.show(!1))}),p),t.on(me,(function(n){if(510===n.code&&(f=!0),101===n.code&&0===t.getPlaylist().length&&(f=!0),!f){var r="",o="";a&&a.destroy(),n&&n.code&&n.code>=100&&n.code<1e3?(r=n.message,100===n.code&&(o=n.error.toString())):r="Can not play due to unknown reasons.",OvenPlayerConsole.log("error occured : ",n),function(n,r,o,i,s,c){a&&a.destroy(),A&&A.destroy(),A=Dn(e,t,n,r,null,"op-warning",null,!0)}(r,o)}}),p),t.on(ve,(function(e){var n="Because the network connection is unstable, the following media source will be played.";t.getCurrentSource()+1===t.getQualityLevels().length&&(n="Network connection is unstable. Check the network connection."),OvenPlayerConsole.log(n)}),p),t.on(he,(function(){u&&v()}),p)}),(function(e){t.off(pe,null,e),t.off(Ce,null,e),t.off(xe,null,e),t.off(me,null,e),t.off(ve,null,e),t.off(he,null,e),t.off(ge,null,e)}))},Fn=[],Un=function(){var e={},t=function(){for(var e=0;e1,!0===t.getConfig().hidePlaylistIcon&&(u=!1);var m={"mouseleave .op-controls":function(e,t,n){e.preventDefault(),r.setMouseDown(!1),t.find(".op-volume-slider-container").removeClass("active")},"click .op-playlist-button":function(e,n,r){e.preventDefault(),function(e,t){var n=ze(t.getContainerElement()),r="",o=t.getPlaylist(),i=o.length,a=6,A=0,s=[];function c(e){var n,A,c=Math.ceil(i/a),u=t.getCurrentPlaylist();s=o.slice(e*a,e*a+a),r.find(".op-playlist-body-row").removeChild(),r.find(".op-arrow-left").removeClass("disable"),r.find(".op-arrow-right").removeClass("disable");for(var l=0;l576?a=6:n.width()<=576&&(a=1);var l={"click .btn-close":function(e,t,n){e.preventDefault(),n.destroy()},"click .op-arrow-left":function(e,t,n){e.preventDefault(),ze(e.target).hasClass("disable")||c(--A)},"click .op-arrow-right":function(e,t,n){e.preventDefault(),ze(e.target).hasClass("disable")||c(++A)}};Qn(e,"PlaylistPanel",t.getConfig(),o,l,(function(e,n){r=e,c(A=u()),t.on(Ee,(function(e){"xsmall"===e&&6===a?(a=1,c(A=u())):"small"!==e&&"medium"!==e&&"large"!==e||1!==a||(a=6,c(A=u()))}),n),t.on(ge,(function(e){c(A=u())}),n),e.get().addEventListener("click",(function(e){for(var n=e.target;n;){if(ze(n).hasClass("op-playlist-card"))return void t.setCurrentPlaylist(parseInt(ze(n).attr("data-index")));n=n.parentElement}}),!0)}),(function(e){t.off(Ee,null,e),t.off(ge,null,e)}))}(n,t)}};return Qn(e,"Controls",t.getConfig(),u,m,(function(e,u){function p(n,r){a&&a.destroy(),a=function(e,t,n,r){var o=ze(t.getContainerElement());t.getConfig().disableSeekUI&&e.addClass("op-progressbar-container-disabled");var i=0,a=!1,A=Un(),c="",u=0,l="",f="",p="",d="",g="",h="",v=0,m="",C="",y=t.getBrowser().mobile,b=t.getMediaElement(),w=!1,E=!1;function B(e){var t=l.width(),n=t*e;p.css("width",n+"px"),d.css("left",n+"px");var r=(t-v)*e;g.css("left",r+"px"),i=n}function x(e){var t=l.width()*e;d.css("width",(0===e?e:t-i)+"px")}function k(e){var t=l.width(),n=l.offset().left,r=e.pageX;e.touches&&(r=e.pageX||e.touches[0].clientX);var o=(r-n)/t;return o<0?0:o>1?1:o}function I(){return b.seekable.end(b.seekable.length-1)-b.seekable.start(0)}function S(e,n){if(A.size()>0||-1===e)return m.hide(),void C.hide();if(m.show(),C.show(),w&&!E){var r=t.getDvrWindow()*(1-e);t.isTimecodeMode()?m.text("- "+s(r)):m.text("- "+Math.round(r*t.getFramerate()))}else if(w&&E){var o=I()*(1-e);t.isTimecodeMode()?m.text("- "+s(o)):m.text("- "+Math.round(o*t.getFramerate()))}else{var i=t.getDuration()*e;t.isTimecodeMode()?m.text(s(i)):m.text(Math.round(i*t.getFramerate()))}var a=m.width(),u=l.width(),f=u*e,p=n.pageX-l.offset().left;n.touches&&(p=(n.pageX||n.touches[0].clientX)-l.offset().left);var d=function(e){return p0&&(n+=i),t.seek(n)}r&&r.type===fe&&r.duration===1/0&&(w=!0,t.getProviderName()===ce&&(E=!0));var L={"touchstart .op-progressbar":function(e){if(n)return!1;a=!0;var t=k(e);if(-1===t)return!1;B(t),x(0),T(t)},"touchmove .op-progressbar":function(e){if(a){var t=k(e);if(-1===t)return!1;B(t),x(0),T(t),S(t,e)}},"touchend .op-progressbar":function(e){a&&(a=!1),o.removeClass("op-progressbar-hover"),m.hide(),C.hide()},"mouseenter .op-progressbar":function(e,t,r){e.preventDefault(),y||(n||m.show(),o.addClass("op-progressbar-hover"))},"mouseleave .op-progressbar":function(e,t,n){e.preventDefault(),a=!1,o.removeClass("op-progressbar-hover"),m.hide(),C.hide(),x(0)},"mousedown .op-progressbar":function(e,t,r){if(e.preventDefault(),n||y)return!1;a=!0;var o=k(e);if(-1===o)return!1;B(o),x(0),T(o)},"mousemove .op-progressbar":function(e,t,r){if(e.preventDefault(),!a&&!n&&!y){var o=k(e);x(o),S(o,e)}if(a&&!y){var i=k(e);if(-1===i)return!1;B(i),x(0),T(i),S(i,e)}},"mouseup .op-progressbar":function(e,t,n){e.preventDefault(),a&&!y&&(a=!1,o.removeClass("op-progressbar-hover"))}};return t.getConfig().disableSeekUI&&(L={}),Qn(e,"ProgressBar",t.getConfig(),null,L,(function(e,r){l=e,f=e.find(".op-load-progress"),p=e.find(".op-play-progress"),d=e.find(".op-hover-progress"),g=e.find(".op-progressbar-knob-container"),h=e.find(".op-progressbar-knob"),v=h.width(),m=e.find(".op-progressbar-time"),C=e.find(".op-progressbar-preview"),n?t.on(Ie,(function(e){e&&e.duration&&e.position&&(B(e.position/e.duration),e.duration)}),r):(t.on(Te,(function(e){if(e&&e.duration&&e.position){u=e.duration;var n=e.position/e.duration;if(w&&!E&&(n=(t.getDvrWindow()-(e.duration-e.position))/t.getDvrWindow()),w&&E){var r=I();u=r,n=(r-(r-Math.min(r,e.position)))/r}B(n)}}),r),t.on(Se,(function(e){var t,n;e&&e.bufferPercent&&(t=e.bufferPercent/100,n=l.width()*t,f.css("width",n+"px"))}),r))}),(function(e){n?t.off(Ie,null,e):(t.off(Te,null,e),t.off(Se,null,e))}))}(e.find(".op-progressbar-container"),t,n,r)}function m(){i&&i.destroy(),i=function(e,t){var n=Un(),r={"click .op-setting-button":function(e,r,o){e.preventDefault();var i=r.closest(".op-controls-container");if(n.size()>0)n.clear();else{var a=function(e){var t={id:"panel-"+(new Date).getTime(),title:"Settings",body:[],isRoot:!0,panelType:""},n=e.getConfig();n&&n.systemText&&(Object.keys(jn).forEach((function(e){jn[e]=n.systemText.ui.setting[e]})),t.title=n.systemText.ui.setting.title);var r=e.getSources(),o=r&&r.length>0?r[e.getCurrentSource()]:null,i=e.getQualityLevels(),a=i&&i.length>0?i[e.getCurrentQuality()]:null,A=e.getAudioTracks(),s=A&&A.length>0?A[e.getCurrentAudioTrack()]:null,c=e.getCaptionList(),u=e.getCurrentCaption(),l=e.getFramerate();if(o){var f={title:jn.speed,value:e.getPlaybackRate()+jn.speedUnit,description:e.getPlaybackRate()+jn.speedUnit,panelType:"speed",hasNext:!0};t.body.push(f)}if(r&&r.length>1){var p={title:jn.source,value:o?o.label:"Default",description:o?o.label:"Default",panelType:"source",hasNext:!0};t.body.push(p)}if(i&&i.length>0){var d={title:jn.quality,value:a?a.label:"Default",description:a?a.label:"Default",panelType:"quality",hasNext:!0};t.body.push(d)}if(A&&A.length>0){var g={title:jn.audioTrack,value:s?s.label:"Default",description:s?s.label:"Default",panelType:"audioTrack",hasNext:!0};t.body.push(g)}if(c&&c.length>0){var h={title:jn.caption,value:c[u]?c[u].label:"OFF",description:c[u]?c[u].label:"OFF",panelType:"caption",hasNext:!0};t.body.push(h)}if(l>0){var v={title:jn.display,value:e.isTimecodeMode()?"Play time":"Framecode",description:e.isTimecodeMode()?"Play time":"Framecode",panelType:"display",hasNext:!0};t.body.push(v)}return t}(t);n.add(Wn(i,t,a))}}};return Qn(e,"SettingButton",t.getConfig(),null,r,(function(e,t){}),(function(e){}))}(e.find(".setting-holder"),t)}function C(){c||(c=function(e,t){var n=ze(t.getContainerElement()),r="",o="",i=!1,a=(t.getConfig(),t.getBrowser()),A="iOS"===a.os,s=(a.os,""),c=!1,u={onfullscreenchange:"fullscreenchange",onmozfullscreenchange:"mozfullscreenchange",onwebkitfullscreenchange:"webkitfullscreenchange",MSFullscreenChange:"MSFullscreenChange"};function l(){var e=!1,t=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;return t&&n.get()===t&&(e=!0),e}function f(){OvenPlayerConsole.log("FULLSCREEN STATE : ",l()),l()?(n.addClass("op-fullscreen"),i=!0,r.hide(),o.show()):(n.removeClass("op-fullscreen"),i=!1,r.show(),o.hide())}function p(){OvenPlayerConsole.log("afterFullScreenChangedCallback () "),f(),t.trigger(Be,i)}function d(){i?(n.removeClass("op-fullscreen"),i=!1,r.show(),o.hide()):(n.addClass("op-fullscreen"),i=!0,r.hide(),o.show()),t.trigger(Be,i)}function g(){var e;!i||A&&!l()?function(){var e,r="",o=n.get(),a=n.find("video")?n.find("video").get():o,s=null;if(A){if(a.length>1)for(var u=0;u1)for(var o=0;o9e15&&(n.duration=1/0);var r=t.getSources()[t.getCurrentSource()].sectionStart,o=t.getSources()[t.getCurrentSource()].sectionEnd;o&&(n.duration=o),r&&(n.duration=n.duration-r),function(n){A&&A.destroy(),A=function(e,t,n){var r="",o="",i="",a=t.getMediaElement(),A=!1,c=!1;function u(e){return s(e)}var l={"click .op-live-text":function(e,n,r){e.preventDefault(),t.seek(Number.MAX_SAFE_INTEGER);var o=t.getConfig();if(o.hlsConfig){var i=o.hlsConfig;"number"==typeof i.liveSyncDuration&&(t.getMseInstance().config.liveSyncDuration=i.liveSyncDuration),"number"==typeof i.liveMaxLatencyDuration&&(t.getMseInstance().config.liveMaxLatencyDuration=i.liveMaxLatencyDuration),"number"==typeof i.maxLiveSyncPlaybackRate&&(t.getMseInstance().config.maxLiveSyncPlaybackRate=i.maxLiveSyncPlaybackRate)}}};return Qn(e,"TimeDisplay",t.getConfig(),n,l,(function(e,s){var l=t.isTimecodeMode();r=e.find(".op-time-current"),o=e.find(".op-time-duration"),i=e.find(".op-live-badge"),e.find(".op-live-text"),n&&n.type===fe&&n.duration===1/0&&(A=!0,t.getProviderName()===ce&&(c=!0)),n.duration!==1/0?(l?o.text(u(n.duration)):o.text(Math.round(n.duration*t.getFramerate())+" ("+t.getFramerate()+"fps)"),t.on(Fe,(function(e){(l=e)?o.text(u(n.duration)):o.text(Math.round(n.duration*t.getFramerate())+" ("+t.getFramerate()+"fps)")}),s),t.on(Te,(function(e){l?r.text(u(e.position)):r.text(Math.round(e.position*t.getFramerate()))}),s)):A&&!c?t.on(Te,(function(e){e.duration-e.position>3?i.addClass("op-live-badge-delayed"):i.removeClass("op-live-badge-delayed")}),s):A&&c&&t.on(Te,(function(e){a.seekable.end(a.seekable.length-1)-a.seekable.start(0)-e.position>3?i.addClass("op-live-badge-delayed"):i.removeClass("op-live-badge-delayed")}),s)}),(function(e){t.off(Fe,null,e),t.off(Te,null,e)}))}(e.find(".op-left-controls"),t,n)}(n),C(),t.getFramerate&&t.getFramerate(),n.duration===1/0?(OvenPlayerConsole.log("[[[[LIVE MODE]]]]"),n.type===fe?p(!1,n):a&&a.destroy()):p(!1),l=!0}function b(){A&&A.destroy(),a&&a.destroy(),m(),C(),h.removeClass("linear-ad")}o=function(e,t){var n="",r="",o="",i="",a="",A="",s="",c={"click .op-play-button":function(e,n,r){e.preventDefault();var o=t.getState(),i=t.getPlaylist(),a=t.getCurrentPlaylist();o===X?t.play():o===ee||o===ie?t.pause():o===ne||o===re?t.stop():o===$||o===ae?t.play():o===te?t.setCurrentSource(t.getCurrentSource()):o===q&&i.length===a+1&&(t.seek(0),t.play())},"click .op-seek-button-back":function(e,n,r){var o=t.getConfig().seekControlInterval;o||(o=10);var i=t.getPosition()-o;i<0&&(i=0),t.seek(i)},"click .op-seek-button-forward":function(e,n,r){var o=t.getConfig().seekControlInterval;o||(o=10);var i=t.getPosition()+o;i>t.getDuration()&&(i=t.getDuration()),t.seek(i)}};return Qn(e,"PlayButton",t.getConfig(),null,c,(function(e,c){n=e.find(".op-play-button .op-play"),r=e.find(".op-play-button .op-pause"),o=e.find(".op-play-button .op-replay"),i=e.find(".op-seek-button-back"),a=e.find(".op-seek-button-forward"),A=e.find(".op-seek-back-text"),s=e.find(".op-seek-forward-text"),t.on(Ce,(function(e){var t;e&&e.newstate&&(t=e.newstate,n.hide(),r.hide(),o.hide(),t===ee||t===ie||t===ne||t===re?r.show():t===$||t===ae?n.show():t===q?o.show():n.show())}),c),t.getConfig().showSeekControl||(i.hide(),a.hide());var u=t.getConfig().seekControlInterval;u?(A.text(u),s.text(u)):(A.text(10),s.text(10))}),(function(e){t.off(Ce,null,e)}))}(e.find(".op-left-controls"),t),r=function(e,t){var n="",r="",o="",i="",a="",A="",s="",c=!1,u=0,l="iOS"===t.getBrowser().os||"Android"===t.getBrowser().os;function f(e){t.getMute()&&(e=0),function(e){a.hide(),A.hide(),s.hide(),e>=70?a.show():e<70&&e>0?A.show():0==e?s.show():a.show()}(e);var n=u*e/100;o.css("left",n+"px"),i.css("width",n+"px")}function p(e){var t=((e.pageX||e.touches[0].clientX)-r.offset().left)/70*100;return t<0&&(t=0),t>100&&(t=100),t}var d={"click .op-volume-button":function(e,n,r){e.preventDefault(),l||(0===t.getVolume()?(t.setMute(!1),t.setVolume(100)):t.setMute())},"mouseenter .op-volume-button":function(e,t,r){e.preventDefault(),l||n.addClass("active")},"mouseleave .op-volume-silder":function(e,t,n){e.preventDefault(),c=!1},"mousedown .op-volume-silder":function(e,n,r){e.preventDefault(),c=!0,t.setMute(!1),t.setVolume(p(e))},"mouseup .op-volume-silder":function(e,t,n){e.preventDefault(),c=!1},"mousemove .op-volume-silder":function(e,n,r){if(e.preventDefault(),!c)return!1;t.setVolume(p(e))},"touchstart .op-volume-button":function(e){l&&(t.getMute()?t.setMute(!1):t.setMute(!0))}},g=Qn(e,"VolumeButton",t.getConfig(),null,d,(function(e,c){n=e.find(".op-volume-slider-container"),t.getBrowser().mobile&&n.hide(),r=e.find(".op-volume-silder"),o=e.find(".op-volume-slider-handle"),i=e.find(".op-volume-slider-value"),a=e.find(".op-volume-max"),A=e.find(".op-volume-small"),s=e.find(".op-volume-mute"),u=64,o.css("left",u+"px"),f(t.getVolume()),t.on(pe,(function(){f(t.getVolume())}),c),t.on(Le,(function(e){f(e.volume)}),c),t.on(Re,(function(e){e.mute?f(0):f(t.getVolume())}),c)}),(function(e){t.off(pe,null,e),t.off(Le,null,e),t.off(Re,null,e)}));return g.setMouseDown=function(e){c=e},g}(e.find(".op-left-controls"),t);var w=t.getPlaylist(),E=t.getCurrentPlaylist();w&&w[E]&&w[E].adTagUrl||m(),C(),t.on(pe,(function(){e.show()}),u),t.on(Me,(function(e){n=e.duration,v=e,e.isP2P=f,y(e)}),u),t.on(Te,(function(e){(d||t&&t.getProviderName&&"rtmp"===t.getProviderName())&&!n&&v&&v.duration!==e.duration&&(v=e,y(e))}),u),t.on(Ee,(function(e){h.find(".op-setting-panel")&&h.find(".op-setting-panel").css("max-height",h.height()-h.find(".op-bottom-panel").height()+"px")}),u),t.on(Ue,(function(e){f=e}),u),t.on(be,(function(){if(!l){var n="";t.getSources().length>0&&t.getSources()[t.getCurrentSource()]&&t.getSources()[t.getCurrentSource()].type&&(n=t.getSources()[t.getCurrentSource()].type),y({isP2P:f,duration:t.getDuration(),type:n})}e.show()}),u),t.on(me,(function(t){e.show()}),u),t.on(ke,(function(e){e.isLinear?(h.addClass("linear-ad"),p(!0),A&&A.destroy(),i&&i.destroy(),g&&c&&c.destroy()):h.removeClass("linear-ad")}),u),t.on(Ae,(function(){b()}),u),t.on(se,(function(){b()}),u),t.on(Oe,(function(){b()}),u)}),(function(e){t.off(Me,null,e),t.off(Te,null,e),t.off(Ae,null,e),t.off(ke,null,e),t.off(Ue,null,e),t.off(se,null,e),t.off(Ee,null,e),t.off(Oe,null,e),A&&A.destroy(),o&&o.destroy(),a&&a.destroy(),c&&c.destroy(),r&&r.destroy()}))},Gn=n(5655),zn=n.n(Gn),_n=n(3379),Vn=n.n(_n),Hn=n(7795),Jn=n.n(Hn),Zn=n(569),Kn=n.n(Zn),Xn=n(3565),qn=n.n(Xn),$n=n(9216),er=n.n($n),tr=n(4589),nr=n.n(tr),rr=n(2021),or={};or.styleTagTransform=nr(),or.setAttributes=qn(),or.insert=Kn().bind(null,"head"),or.domAPI=Jn(),or.insertStyleElement=er(),Vn()(rr.Z,or),rr.Z&&rr.Z.locals&&rr.Z.locals;var ir,ar=function(e){var t,n="",r="",o="",i="",a=null,A="",s=X,c=!1,u=Un(),l="",f="",p=null,d={};function g(e,n){if(A&&(clearTimeout(A),A=null),e){if(u.size()>0)return!1;t.addClass("op-autohide")}else t.removeClass("op-autohide"),n&&(A=setTimeout((function(){if(u.size()>0)return!1;t.addClass("op-autohide")}),3e3))}function h(){var e=s;e===X||e===$||e===q?(e===q&&a.seek(0),a.play()):e===ee&&a.pause()}function v(e,t){var n,r=a.getDuration(),o=a.getPosition();n=t?Math.max(o-e,0):Math.min(o+e,r),a.seek(n)}function m(e){var t,n=a.getVolume();t=e?Math.min(n+5,100):Math.max(n-5,0),a.setVolume(t)}function C(){var e=t.width();e<576?(l="xsmall",t.addClass("xsmall"),e<490&&t.addClass("xxsmall")):e<768?(l="small",t.addClass("small")):e<992?(l="medium",t.addClass("medium")):(l="large",t.addClass("large"))}var y={"click .ovenplayer":function(e,t,n){if(a&&a.trigger(we,e),i)return e.preventDefault(),i.destroy(),i=null,!1;if(!ze(e.target).closest(".op-controls-container")&&!ze(e.target).closest(".op-setting-panel")){if(u.size()>0)return e.preventDefault(),u.clear(),!1;a.getDuration()===1/0||a.getBrowser().mobile||h()}},"dblclick .ovenplayer":function(e,t,n){a&&a.getConfig().expandFullScreenUI&&a.toggleFullScreen&&(ze(e.target).closest(".op-controls-container")||ze(e.target).closest(".op-setting-panel")||a.toggleFullScreen())},"touchstart .ovenplayer":function(e,t,n){s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mouseenter .ovenplayer":function(e,t,n){e.preventDefault(),s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mousemove .ovenplayer":function(e,t,n){e.preventDefault(),s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mouseleave .ovenplayer":function(e,t,n){e.preventDefault(),(s===ee||s===X||s===ne||s===ie&&"xsmall"===l)&&g(!0)},"keydown .ovenplayer":function(e,t,n){var r=a.getFramerate();switch(e.keyCode){case 16:e.preventDefault(),c=!0;break;case 32:e.preventDefault(),h();break;case 37:e.preventDefault(),a.getConfig().disableSeekUI||(c&&r?a.seekFrame(-1):v(5,!0));break;case 39:e.preventDefault(),a.getConfig().disableSeekUI||(c&&r?a.seekFrame(1):v(5,!1));break;case 38:e.preventDefault(),m(!0);break;case 40:e.preventDefault(),m(!1)}},"keyup .ovenplayer":function(e,t,n){16===e.keyCode&&(e.preventDefault(),c=!1)},"contextmenu .ovenplayer":function(e,n,r){if(e.stopPropagation(),!ze(e.currentTarget).find("object"))return e.preventDefault(),o=e.pageX,A=e.pageY,i&&(i.destroy(),i=null),i=function(e,t,n){var r=ze(t.getContainerElement()),o={"click .op-context-item":function(e,t,n){e.preventDefault(),window.open("https://github.com/AirenSoft/OvenPlayer","_blank")}};return Qn(e,"ContextPanel",t.getConfig(),n,o,(function(e,t){var o=e.width(),i=e.height(),a=Math.min(n.pageX-r.offset().left,r.width()-o),A=Math.min(n.pageY-r.offset().top,r.height()-i);e.css("left",a+"px"),e.css("top",A+"px")}),(function(){}))}(t,a,{pageX:o,pageY:A}),!1;var o,A}};return(d=Qn(e,"View",null,e.id,y,(function(e,r){t=e,n=r,C(),f=l,p=new(zn())(t.get(),(function(){t.removeClass("large"),t.removeClass("medium"),t.removeClass("small"),t.removeClass("xsmall"),t.removeClass("xxsmall"),C(),l!==f&&(f=l,a&&a.trigger(Ee,f))}))}),(function(){p&&(p.detach(),p=null),o&&(o.destroy(),o=null),r&&(r.destroy(),r=null)}),!0)).getMediaElementContainer=function(){return t.find(".op-media-element-container").get()},d.setApi=function(e){(a=e).getContainerElement=function(){return t.get()},a.getContainerId=function(){return t.get().id},a.on(pe,(function(n){r||(r=Yn(t.find(".op-ui"),e)),i||t.addClass("op-no-controls")})),a.on(me,(function(e){if(a){var t=a.getSources()||[];r&&t.length}})),a.on(de,(function(e){n.destroy()})),a.on(be,(function(n){!r&&i&&(r=Yn(t.find(".op-ui"),e))})),a.on(Ce,(function(e){e&&e.newstate&&(s=e.newstate,e.newstate===ee||e.newstate===ie&&"xsmall"===l?g(!1,!0):g(!1))}));var i=a.getConfig()&&a.getConfig().controls;o=Pn(t.find(".op-ui"),e),r=Yn(t.find(".op-ui"),e);var A=a.getConfig().aspectRatio;if(A&&2===A.split(":").length){var c=1*A.split(":")[0],u=1*A.split(":")[1]/c*100;t.find(".op-ratio").css("padding-bottom",u+"%")}a.showControls=function(e){e?(t.removeClass("op-no-controls"),g(!1,!0)):t.addClass("op-no-controls")}},d},Ar=(ir={},Object.assign(ir,Tn),ir.create=function(e,t){var n=Ze(e),r=ar(n),o=Tn.create(r.getMediaElementContainer(),t);return r.setApi(o),OvenPlayerConsole.log("[OvenPlayer] v.0.10.31"),o},ir)},1001:function(){!function(e){"use strict";if("window"in e&&"document"in e){document.querySelectorAll||(document.querySelectorAll=function(e){var t,n=document.createElement("style"),r=[];for(document.documentElement.firstChild.appendChild(n),document._qsa=[],n.styleSheet.cssText=e+"{x-qsa:expression(document._qsa && document._qsa.push(this))}",window.scrollBy(0,0),n.parentNode.removeChild(n);document._qsa.length;)(t=document._qsa.shift()).style.removeAttribute("x-qsa"),r.push(t);return document._qsa=null,r}),document.querySelector||(document.querySelector=function(e){var t=document.querySelectorAll(e);return t.length?t[0]:null}),document.getElementsByClassName||(document.getElementsByClassName=function(e){return e=String(e).replace(/^|\s+/g,"."),document.querySelectorAll(e)}),e.Node=e.Node||function(){throw TypeError("Illegal constructor")},[["ELEMENT_NODE",1],["ATTRIBUTE_NODE",2],["TEXT_NODE",3],["CDATA_SECTION_NODE",4],["ENTITY_REFERENCE_NODE",5],["ENTITY_NODE",6],["PROCESSING_INSTRUCTION_NODE",7],["COMMENT_NODE",8],["DOCUMENT_NODE",9],["DOCUMENT_TYPE_NODE",10],["DOCUMENT_FRAGMENT_NODE",11],["NOTATION_NODE",12]].forEach((function(t){t[0]in e.Node||(e.Node[t[0]]=t[1])})),e.DOMException=e.DOMException||function(){throw TypeError("Illegal constructor")},[["INDEX_SIZE_ERR",1],["DOMSTRING_SIZE_ERR",2],["HIERARCHY_REQUEST_ERR",3],["WRONG_DOCUMENT_ERR",4],["INVALID_CHARACTER_ERR",5],["NO_DATA_ALLOWED_ERR",6],["NO_MODIFICATION_ALLOWED_ERR",7],["NOT_FOUND_ERR",8],["NOT_SUPPORTED_ERR",9],["INUSE_ATTRIBUTE_ERR",10],["INVALID_STATE_ERR",11],["SYNTAX_ERR",12],["INVALID_MODIFICATION_ERR",13],["NAMESPACE_ERR",14],["INVALID_ACCESS_ERR",15]].forEach((function(t){t[0]in e.DOMException||(e.DOMException[t[0]]=t[1])})),function(){function t(e,t,n){if("function"==typeof t){"DOMContentLoaded"===e&&(e="load");var r=this,o=function(e){e._timeStamp=Date.now(),e._currentTarget=r,t.call(this,e),e._currentTarget=null};this["_"+e+t]=o,this.attachEvent("on"+e,o)}}function n(e,t,n){if("function"==typeof t){"DOMContentLoaded"===e&&(e="load");var r=this["_"+e+t];r&&(this.detachEvent("on"+e,r),this["_"+e+t]=null)}}"Element"in e&&!Element.prototype.addEventListener&&Object.defineProperty&&(Event.CAPTURING_PHASE=1,Event.AT_TARGET=2,Event.BUBBLING_PHASE=3,Object.defineProperties(Event.prototype,{CAPTURING_PHASE:{get:function(){return 1}},AT_TARGET:{get:function(){return 2}},BUBBLING_PHASE:{get:function(){return 3}},target:{get:function(){return this.srcElement}},currentTarget:{get:function(){return this._currentTarget}},eventPhase:{get:function(){return this.srcElement===this.currentTarget?Event.AT_TARGET:Event.BUBBLING_PHASE}},bubbles:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mousemove":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"resize":case"scroll":case"select":case"change":case"submit":case"reset":return!0}return!1}},cancelable:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"submit":return!0}return!1}},timeStamp:{get:function(){return this._timeStamp}},stopPropagation:{value:function(){this.cancelBubble=!0}},preventDefault:{value:function(){this.returnValue=!1}},defaultPrevented:{get:function(){return!1===this.returnValue}}}),[Window,HTMLDocument,Element].forEach((function(e){e.prototype.addEventListener=t,e.prototype.removeEventListener=n})))}(),function(){function t(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}"CustomEvent"in e&&"function"==typeof e.CustomEvent||(t.prototype=e.Event.prototype,e.CustomEvent=t)}(),window.addEvent=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&(e["e"+t+n]=n,e[t+n]=function(){var r=window.event;r.currentTarget=e,r.preventDefault=function(){r.returnValue=!1},r.stopPropagation=function(){r.cancelBubble=!0},r.target=r.srcElement,r.timeStamp=Date.now(),e["e"+t+n].call(this,r)},e.attachEvent("on"+t,e[t+n]))},window.removeEvent=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&(e.detachEvent("on"+t,e[t+n]),e[t+n]=null,e["e"+t+n]=null)},function(){function t(e,t){function n(e){return e.length?e.split(/\s+/g):[]}function r(e,t){var r=n(t),o=r.indexOf(e);return-1!==o&&r.splice(o,1),r.join(" ")}if(Object.defineProperties(this,{length:{get:function(){return n(e[t]).length}},item:{value:function(r){var o=n(e[t]);return 0<=r&&r=0&&t.item(n)!==this;);return n>-1})),window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,n=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do{for(t=n.length;--t>=0&&n.item(t)!==r;);}while(t<0&&(r=r.parentElement));return r});var t={prepend:function(){var e=[].slice.call(arguments);e=o(e),this.insertBefore(e,this.firstChild)},append:function(){var e=[].slice.call(arguments);e=o(e),this.appendChild(e)}};r(e.Document||e.HTMLDocument,t),r(e.DocumentFragment,t),r(e.Element,t);var n={before:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.previousSibling;-1!==e.indexOf(n);)n=n.previousSibling;var r=o(e);t.insertBefore(r,n?n.nextSibling:t.firstChild)}},after:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.nextSibling;-1!==e.indexOf(n);)n=n.nextSibling;var r=o(e);t.insertBefore(r,n)}},replaceWith:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.nextSibling;-1!==e.indexOf(n);)n=n.nextSibling;var r=o(e);this.parentNode===t?t.replaceChild(r,this):t.insertBefore(r,n)}},remove:function(){this.parentNode&&this.parentNode.removeChild(this)}};r(e.DocumentType,n),r(e.Element,n),r(e.CharacterData,n)}function r(e,t){e&&Object.keys(t).forEach((function(n){if(!(n in e)&&!(n in e.prototype))try{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t,n))}catch(r){e[n]=t[n]}}))}function o(e){var t=null;return e=e.map((function(e){return e instanceof Node?e:document.createTextNode(e)})),1===e.length?t=e[0]:(t=document.createDocumentFragment(),e.forEach((function(e){t.appendChild(e)}))),t}}(self)},5655:function(e,t){var n,r;r=this,void 0===(n=function(){return r.returnExportsGlobal=function(){"use strict";var e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){return window.setTimeout(e,20)};function t(){var e,t;this.q=[],this.add=function(e){this.q.push(e)},this.call=function(){for(e=0,t=this.q.length;e
',n.appendChild(n.resizeSensor),"static"==function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null).getPropertyValue(t):e.style[t]}(n,"position")&&(n.style.position="relative");var a=n.resizeSensor.childNodes[0],A=a.childNodes[0],s=n.resizeSensor.childNodes[1],c=function(){A.style.width="100000px",A.style.height="100000px",a.scrollLeft=1e5,a.scrollTop=1e5,s.scrollLeft=1e5,s.scrollTop=1e5};c();var u,l,f,p,d=!1;e((function t(){n.resizedAttached&&(d&&(n.resizedAttached.call(),d=!1),e(t))}));var g=function(){(f=n.offsetWidth)==u&&(p=n.offsetHeight)==l||(d=!0,u=f,l=p),c()},h=function(e,t,n){e.attachEvent?e.attachEvent("on"+t,n):e.addEventListener(t,n)};h(a,"scroll",g),h(s,"scroll",g)}var r=function(e,t){var r=Object.prototype.toString.call(e),o=this._isCollectionTyped="[object Array]"===r||"[object NodeList]"===r||"[object HTMLCollection]"===r||"undefined"!=typeof jQuery&&e instanceof window.jQuery||"undefined"!=typeof Elements&&e instanceof window.Elements;if(this._element=e,o)for(var i=0,a=e.length;i=0&&n<=b}}function Z(e){return function(t){return null==t?void 0:t[e]}}var K=Z("byteLength"),X=J(K),q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/,$=l?function(e){return h?h(e)&&!j(e):X(e)&&q.test(c.call(e))}:H(!1),ee=Z("length");function te(e,t){t=function(e){for(var t={},n=e.length,r=0;r":">",'"':""","'":"'","`":"`"},_e=Ge(ze),Ve=Ge(be(ze)),He=oe.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Je=/(.)^/,Ze={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Ke=/\\|'|\r|\n|\u2028|\u2029/g;function Xe(e){return"\\"+Ze[e]}var qe=/^\s*(\w|\$)+\s*$/,$e=0;function et(e,t,n,r,o){if(!(r instanceof t))return e.apply(n,o);var i=Ie(e.prototype),a=e.apply(i,o);return E(a)?a:i}var tt=w((function(e,t){var n=tt.placeholder;return function r(){for(var o=0,i=t.length,a=Array(i),A=0;A1)ot(A,t-1,n,r),o=r.length;else for(var s=0,c=A.length;s0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}var ut=tt(ct,2);function lt(e,t,n){t=Ne(t,n);for(var r,o=ne(e),i=0,a=o.length;i0?0:o-1;i>=0&&i0?a=i>=0?i:Math.max(i+A,a):A=i>=0?Math.min(i+1,A):i+A+1;else if(n&&i&&A)return r[i=n(r,o)]===o?i:-1;if(o!=o)return(i=t(s.call(r,a,A),V))>=0?i+a:-1;for(i=e>0?a:A-1;i>=0&&i0?0:a-1;for(o||(r=t[i?i[A]:A],A+=e);A>=0&&A=3;return t(e,Pe(n,o,4),r,i)}}var Et=wt(1),Bt=wt(-1);function xt(e,t,n){var r=[];return t=Ne(t,n),yt(e,(function(e,n,o){t(e,n,o)&&r.push(e)})),r}function kt(e,t,n){t=Ne(t,n);for(var r=!rt(e)&&ne(e),o=(r||e).length,i=0;i=0}var Tt=w((function(e,t,n){var r,o;return P(t)?o=t:(t=Le(t),r=t.slice(0,-1),t=t[t.length-1]),bt(e,(function(e){var i=o;if(!i){if(r&&r.length&&(e=Re(e,r)),null==e)return;i=e[t]}return null==i?i:i.apply(e,n)}))}));function Lt(e,t){return bt(e,De(t))}function Rt(e,t,n){var r,o,i=-1/0,A=-1/0;if(null==t||"number"==typeof t&&"object"!=a(e[0])&&null!=e)for(var s=0,c=(e=rt(e)?e:ye(e)).length;si&&(i=r);else t=Ne(t,n),yt(e,(function(e,n,r){((o=t(e,n,r))>A||o===-1/0&&i===-1/0)&&(i=e,A=o)}));return i}function Mt(e,t,n){if(null==t||n)return rt(e)||(e=ye(e)),e[je(e.length-1)];var r=rt(e)?Se(e):ye(e),o=ee(r);t=Math.max(Math.min(t,o),0);for(var i=o-1,a=0;a1&&(r=Pe(r,t[1])),t=se(e)):(r=Nt,t=ot(t,!1,!1),e=Object(e));for(var o=0,i=t.length;o1&&(n=t[1])):(t=bt(ot(t,!1,!1),String),r=function(e,n){return!St(t,n)}),Wt(e,r,n)}));function Yt(e,t,n){return s.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))}function Gt(e,t,n){return null==e||e.length<1?null==t||n?void 0:[]:null==t||n?e[0]:Yt(e,e.length-t)}function zt(e,t,n){return s.call(e,null==t||n?1:t)}var _t=w((function(e,t){return t=ot(t,!0,!0),xt(e,(function(e){return!St(t,e)}))})),Vt=w((function(e,t){return _t(e,t)}));function Ht(e,t,n,r){x(t)||(r=n,n=t,t=!1),null!=n&&(n=Ne(n,r));for(var o=[],i=[],a=0,A=ee(e);at?(r&&(clearTimeout(r),r=null),A=c,a=e.apply(o,i),r||(o=i=null)):r||!1===n.trailing||(r=setTimeout(s,u)),a};return c.cancel=function(){clearTimeout(r),A=0,r=o=i=null},c},debounce:function(e,t,n){var r,o,i,a,A,s=function s(){var c=Ye()-o;t>c?r=setTimeout(s,t-c):(r=null,n||(a=e.apply(A,i)),r||(i=A=null))},c=w((function(c){return A=this,i=c,o=Ye(),r||(r=setTimeout(s,t),n&&(a=e.apply(A,i))),a}));return c.cancel=function(){clearTimeout(r),r=i=A=null},c},wrap:function(e,t){return tt(t,e)},negate:st,compose:function(){var e=arguments,t=e.length-1;return function(){for(var n=t,r=e[t].apply(this,arguments);n--;)r=e[n].call(this,r);return r}},after:function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},before:ct,once:ut,findKey:lt,findIndex:pt,findLastIndex:dt,sortedIndex:gt,indexOf:vt,lastIndexOf:mt,find:Ct,detect:Ct,findWhere:function(e,t){return Ct(e,Qe(t))},each:yt,forEach:yt,map:bt,collect:bt,reduce:Et,foldl:Et,inject:Et,reduceRight:Bt,foldr:Bt,filter:xt,select:xt,reject:function(e,t,n){return xt(e,st(Ne(t)),n)},every:kt,all:kt,some:It,any:It,contains:St,includes:St,include:St,invoke:Tt,pluck:Lt,where:function(e,t){return xt(e,Qe(t))},max:Rt,min:function(e,t,n){var r,o,i=1/0,A=1/0;if(null==t||"number"==typeof t&&"object"!=a(e[0])&&null!=e)for(var s=0,c=(e=rt(e)?e:ye(e)).length;sr||void 0===n)return 1;if(n>8&255]},z=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},_=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},V=function(e){return W(e,23,4)},H=function(e){return W(e,52,8)},J=function(e,t){C(e.prototype,t,{get:function(){return k(this)[t]}})},Z=function(e,t,n,r){var o=d(n),i=k(e);if(o+t>i.byteLength)throw F(T);var a=k(i.buffer).bytes,A=o+i.byteOffset,s=b(a,A,A+t);return r?s:N(s)},K=function(e,t,n,r,o,i){var a=d(n),A=k(e);if(a+t>A.byteLength)throw F(T);for(var s=k(A.buffer).bytes,c=a+A.byteOffset,u=r(+o),l=0;lee;)(q=$[ee++])in R||s(R,q,L[q]);M.constructor=R}v&&h(Q)!==D&&v(Q,D);var te=new O(new R(2)),ne=o(Q.setInt8);te.setInt8(0,2147483648),te.setInt8(1,2147483649),!te.getInt8(0)&&te.getInt8(1)||c(Q,{setInt8:function(e,t){ne(this,e,t<<24>>24)},setUint8:function(e,t){ne(this,e,t<<24>>24)}},{unsafe:!0})}else M=(R=function(e){l(this,M);var t=d(e);I(this,{bytes:U(P(t),0),byteLength:t}),i||(this.byteLength=t)}).prototype,Q=(O=function(e,t,n){l(this,Q),l(e,M);var r=k(e).byteLength,o=f(t);if(o<0||o>r)throw F("Wrong offset");if(o+(n=void 0===n?r-o:p(n))>r)throw F("Wrong length");I(this,{buffer:e,byteLength:n,byteOffset:o}),i||(this.buffer=e,this.byteLength=n,this.byteOffset=o)}).prototype,i&&(J(R,"byteLength"),J(O,"buffer"),J(O,"byteLength"),J(O,"byteOffset")),c(Q,{getInt8:function(e){return Z(this,1,e)[0]<<24>>24},getUint8:function(e){return Z(this,1,e)[0]},getInt16:function(e){var t=Z(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Z(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return _(Z(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return _(Z(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return j(Z(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return j(Z(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){K(this,1,e,Y,t)},setUint8:function(e,t){K(this,1,e,Y,t)},setInt16:function(e,t){K(this,2,e,G,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){K(this,2,e,G,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){K(this,4,e,z,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){K(this,4,e,z,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){K(this,4,e,V,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){K(this,8,e,H,t,arguments.length>2?arguments[2]:void 0)}});w(R,S),w(O,"DataView"),e.exports={ArrayBuffer:R,DataView:O}},1048:function(e,t,n){"use strict";var r=n(7908),o=n(1400),i=n(6244),a=Math.min;e.exports=[].copyWithin||function(e,t){var n=r(this),A=i(n),s=o(e,A),c=o(t,A),u=arguments.length>2?arguments[2]:void 0,l=a((void 0===u?A:o(u,A))-c,A-s),f=1;for(c0;)c in n?n[s]=n[c]:delete n[s],s+=f,c+=f;return n}},1285:function(e,t,n){"use strict";var r=n(7908),o=n(1400),i=n(6244);e.exports=function(e){for(var t=r(this),n=i(t),a=arguments.length,A=o(a>1?arguments[1]:void 0,n),s=a>2?arguments[2]:void 0,c=void 0===s?n:o(s,n);c>A;)t[A++]=e;return t}},8533:function(e,t,n){"use strict";var r=n(2092).forEach,o=n(2133)("forEach");e.exports=o?[].forEach:function(e){return r(this,e,arguments.length>1?arguments[1]:void 0)}},7745:function(e,t,n){var r=n(6244);e.exports=function(e,t){for(var n=0,o=r(t),i=new e(o);o>n;)i[n]=t[n++];return i}},8457:function(e,t,n){"use strict";var r=n(7854),o=n(9974),i=n(6916),a=n(7908),A=n(3411),s=n(7659),c=n(4411),u=n(6244),l=n(6135),f=n(8554),p=n(1246),d=r.Array;e.exports=function(e){var t=a(e),n=c(this),r=arguments.length,g=r>1?arguments[1]:void 0,h=void 0!==g;h&&(g=o(g,r>2?arguments[2]:void 0));var v,m,C,y,b,w,E=p(t),B=0;if(!E||this==d&&s(E))for(v=u(t),m=n?new this(v):d(v);v>B;B++)w=h?g(t[B],B):t[B],l(m,B,w);else for(b=(y=f(t,E)).next,m=n?new this:[];!(C=i(b,y)).done;B++)w=h?A(y,g,[C.value,B],!0):C.value,l(m,B,w);return m.length=B,m}},1318:function(e,t,n){var r=n(5656),o=n(1400),i=n(6244),a=function(e){return function(t,n,a){var A,s=r(t),c=i(s),u=o(a,c);if(e&&n!=n){for(;c>u;)if((A=s[u++])!=A)return!0}else for(;c>u;u++)if((e||u in s)&&s[u]===n)return e||u||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},2092:function(e,t,n){var r=n(9974),o=n(1702),i=n(8361),a=n(7908),A=n(6244),s=n(5417),c=o([].push),u=function(e){var t=1==e,n=2==e,o=3==e,u=4==e,l=6==e,f=7==e,p=5==e||l;return function(d,g,h,v){for(var m,C,y=a(d),b=i(y),w=r(g,h),E=A(b),B=0,x=v||s,k=t?x(d,E):n||f?x(d,0):void 0;E>B;B++)if((p||B in b)&&(C=w(m=b[B],B,y),e))if(t)k[B]=C;else if(C)switch(e){case 3:return!0;case 5:return m;case 6:return B;case 2:c(k,m)}else switch(e){case 4:return!1;case 7:c(k,m)}return l?-1:o||u?u:k}};e.exports={forEach:u(0),map:u(1),filter:u(2),some:u(3),every:u(4),find:u(5),findIndex:u(6),filterReject:u(7)}},6583:function(e,t,n){"use strict";var r=n(2104),o=n(5656),i=n(9303),a=n(6244),A=n(2133),s=Math.min,c=[].lastIndexOf,u=!!c&&1/[1].lastIndexOf(1,-0)<0,l=A("lastIndexOf"),f=u||!l;e.exports=f?function(e){if(u)return r(c,this,arguments)||0;var t=o(this),n=a(t),A=n-1;for(arguments.length>1&&(A=s(A,i(arguments[1]))),A<0&&(A=n+A);A>=0;A--)if(A in t&&t[A]===e)return A||0;return-1}:c},1194:function(e,t,n){var r=n(7293),o=n(5112),i=n(7392),a=o("species");e.exports=function(e){return i>=51||!r((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}},2133:function(e,t,n){"use strict";var r=n(7293);e.exports=function(e,t){var n=[][e];return!!n&&r((function(){n.call(null,t||function(){throw 1},1)}))}},3671:function(e,t,n){var r=n(7854),o=n(9662),i=n(7908),a=n(8361),A=n(6244),s=r.TypeError,c=function(e){return function(t,n,r,c){o(n);var u=i(t),l=a(u),f=A(u),p=e?f-1:0,d=e?-1:1;if(r<2)for(;;){if(p in l){c=l[p],p+=d;break}if(p+=d,e?p<0:f<=p)throw s("Reduce of empty array with no initial value")}for(;e?p>=0:f>p;p+=d)p in l&&(c=n(c,l[p],p,u));return c}};e.exports={left:c(!1),right:c(!0)}},1589:function(e,t,n){var r=n(7854),o=n(1400),i=n(6244),a=n(6135),A=r.Array,s=Math.max;e.exports=function(e,t,n){for(var r=i(e),c=o(t,r),u=o(void 0===n?r:n,r),l=A(s(u-c,0)),f=0;c0;)e[r]=e[--r];r!==i++&&(e[r]=n)}return e},A=function(e,t,n,r){for(var o=t.length,i=n.length,a=0,A=0;a1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!m(this,e)}}),i(p,n?{get:function(e){var t=m(this,e);return t&&t.value},set:function(e,t){return v(this,0===e?0:e,t)}}:{add:function(e){return v(this,e=0===e?0:e,e)}}),l&&r(p,"size",{get:function(){return h(this).size}}),u},setStrong:function(e,t,n){var r=t+" Iterator",o=g(t),i=g(r);c(e,t,(function(e,t){d(this,{type:r,target:e,state:o(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),u(t)}}},9320:function(e,t,n){"use strict";var r=n(1702),o=n(2248),i=n(2423).getWeakData,a=n(9670),A=n(111),s=n(5787),c=n(408),u=n(2092),l=n(2597),f=n(9909),p=f.set,d=f.getterFor,g=u.find,h=u.findIndex,v=r([].splice),m=0,C=function(e){return e.frozen||(e.frozen=new y)},y=function(){this.entries=[]},b=function(e,t){return g(e.entries,(function(e){return e[0]===t}))};y.prototype={get:function(e){var t=b(this,e);if(t)return t[1]},has:function(e){return!!b(this,e)},set:function(e,t){var n=b(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=h(this.entries,(function(t){return t[0]===e}));return~t&&v(this.entries,t,1),!!~t}},e.exports={getConstructor:function(e,t,n,r){var u=e((function(e,o){s(e,f),p(e,{type:t,id:m++,frozen:void 0}),null!=o&&c(o,e[r],{that:e,AS_ENTRIES:n})})),f=u.prototype,g=d(t),h=function(e,t,n){var r=g(e),o=i(a(t),!0);return!0===o?C(r).set(t,n):o[r.id]=n,e};return o(f,{delete:function(e){var t=g(this);if(!A(e))return!1;var n=i(e);return!0===n?C(t).delete(e):n&&l(n,t.id)&&delete n[t.id]},has:function(e){var t=g(this);if(!A(e))return!1;var n=i(e);return!0===n?C(t).has(e):n&&l(n,t.id)}}),o(f,n?{get:function(e){var t=g(this);if(A(e)){var n=i(e);return!0===n?C(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return h(this,e,t)}}:{add:function(e){return h(this,e,!0)}}),u}}},7710:function(e,t,n){"use strict";var r=n(2109),o=n(7854),i=n(1702),a=n(4705),A=n(1320),s=n(2423),c=n(408),u=n(5787),l=n(614),f=n(111),p=n(7293),d=n(7072),g=n(8003),h=n(9587);e.exports=function(e,t,n){var v=-1!==e.indexOf("Map"),m=-1!==e.indexOf("Weak"),C=v?"set":"add",y=o[e],b=y&&y.prototype,w=y,E={},B=function(e){var t=i(b[e]);A(b,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(m&&!f(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return m&&!f(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(m&&!f(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(a(e,!l(y)||!(m||b.forEach&&!p((function(){(new y).entries().next()})))))w=n.getConstructor(t,e,v,C),s.enable();else if(a(e,!0)){var x=new w,k=x[C](m?{}:-0,1)!=x,I=p((function(){x.has(1)})),S=d((function(e){new y(e)})),T=!m&&p((function(){for(var e=new y,t=5;t--;)e[C](t,t);return!e.has(-0)}));S||((w=t((function(e,t){u(e,b);var n=h(new y,e,w);return null!=t&&c(t,n[C],{that:n,AS_ENTRIES:v}),n}))).prototype=b,b.constructor=w),(I||T)&&(B("delete"),B("has"),v&&B("get")),(T||k)&&B(C),m&&b.clear&&delete b.clear}return E[e]=w,r({global:!0,forced:w!=y},E),g(w,e),m||n.setStrong(w,e,v),w}},9920:function(e,t,n){var r=n(2597),o=n(3887),i=n(1236),a=n(3070);e.exports=function(e,t,n){for(var A=o(t),s=a.f,c=i.f,u=0;u"+s+""}},4994:function(e,t,n){"use strict";var r=n(3383).IteratorPrototype,o=n(30),i=n(9114),a=n(8003),A=n(7497),s=function(){return this};e.exports=function(e,t,n,c){var u=t+" Iterator";return e.prototype=o(r,{next:i(+!c,n)}),a(e,u,!1,!0),A[u]=s,e}},8880:function(e,t,n){var r=n(9781),o=n(3070),i=n(9114);e.exports=r?function(e,t,n){return o.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},9114:function(e){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},6135:function(e,t,n){"use strict";var r=n(4948),o=n(3070),i=n(9114);e.exports=function(e,t,n){var a=r(t);a in e?o.f(e,a,i(0,n)):e[a]=n}},5573:function(e,t,n){"use strict";var r=n(7854),o=n(1702),i=n(7293),a=n(6650).start,A=r.RangeError,s=Math.abs,c=Date.prototype,u=c.toISOString,l=o(c.getTime),f=o(c.getUTCDate),p=o(c.getUTCFullYear),d=o(c.getUTCHours),g=o(c.getUTCMilliseconds),h=o(c.getUTCMinutes),v=o(c.getUTCMonth),m=o(c.getUTCSeconds);e.exports=i((function(){return"0385-07-25T07:06:39.999Z"!=u.call(new Date(-50000000000001))}))||!i((function(){u.call(new Date(NaN))}))?function(){if(!isFinite(l(this)))throw A("Invalid time value");var e=this,t=p(e),n=g(e),r=t<0?"-":t>9999?"+":"";return r+a(s(t),r?6:4,0)+"-"+a(v(e)+1,2,0)+"-"+a(f(e),2,0)+"T"+a(d(e),2,0)+":"+a(h(e),2,0)+":"+a(m(e),2,0)+"."+a(n,3,0)+"Z"}:u},8709:function(e,t,n){"use strict";var r=n(7854),o=n(9670),i=n(2140),a=r.TypeError;e.exports=function(e){if(o(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw a("Incorrect hint");return i(this,e)}},654:function(e,t,n){"use strict";var r=n(2109),o=n(6916),i=n(1913),a=n(6530),A=n(614),s=n(4994),c=n(9518),u=n(7674),l=n(8003),f=n(8880),p=n(1320),d=n(5112),g=n(7497),h=n(3383),v=a.PROPER,m=a.CONFIGURABLE,C=h.IteratorPrototype,y=h.BUGGY_SAFARI_ITERATORS,b=d("iterator"),w="keys",E="values",B="entries",x=function(){return this};e.exports=function(e,t,n,a,d,h,k){s(n,t,a);var I,S,T,L=function(e){if(e===d&&D)return D;if(!y&&e in O)return O[e];switch(e){case w:case E:case B:return function(){return new n(this,e)}}return function(){return new n(this)}},R=t+" Iterator",M=!1,O=e.prototype,Q=O[b]||O["@@iterator"]||d&&O[d],D=!y&&Q||L(d),P="Array"==t&&O.entries||Q;if(P&&(I=c(P.call(new e)))!==Object.prototype&&I.next&&(i||c(I)===C||(u?u(I,C):A(I[b])||p(I,b,x)),l(I,R,!0,!0),i&&(g[R]=x)),v&&d==E&&Q&&Q.name!==E&&(!i&&m?f(O,"name",E):(M=!0,D=function(){return o(Q,this)})),d)if(S={values:L(E),keys:h?D:L(w),entries:L(B)},k)for(T in S)(y||M||!(T in O))&&p(O,T,S[T]);else r({target:t,proto:!0,forced:y||M},S);return i&&!k||O[b]===D||p(O,b,D,{name:d}),g[t]=D,S}},7235:function(e,t,n){var r=n(857),o=n(2597),i=n(6061),a=n(3070).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});o(t,e)||a(t,e,{value:i.f(e)})}},9781:function(e,t,n){var r=n(7293);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},317:function(e,t,n){var r=n(7854),o=n(111),i=r.document,a=o(i)&&o(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},3678:function(e){e.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8324:function(e){e.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},8509:function(e,t,n){var r=n(317)("span").classList,o=r&&r.constructor&&r.constructor.prototype;e.exports=o===Object.prototype?void 0:o},8886:function(e,t,n){var r=n(8113).match(/firefox\/(\d+)/i);e.exports=!!r&&+r[1]},7871:function(e){e.exports="object"==typeof window},256:function(e,t,n){var r=n(8113);e.exports=/MSIE|Trident/.test(r)},1528:function(e,t,n){var r=n(8113),o=n(7854);e.exports=/ipad|iphone|ipod/i.test(r)&&void 0!==o.Pebble},8334:function(e,t,n){var r=n(8113);e.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(r)},5268:function(e,t,n){var r=n(4326),o=n(7854);e.exports="process"==r(o.process)},1036:function(e,t,n){var r=n(8113);e.exports=/web0s(?!.*chrome)/i.test(r)},8113:function(e,t,n){var r=n(5005);e.exports=r("navigator","userAgent")||""},7392:function(e,t,n){var r,o,i=n(7854),a=n(8113),A=i.process,s=i.Deno,c=A&&A.versions||s&&s.version,u=c&&c.v8;u&&(o=(r=u.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!o&&a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(o=+r[1]),e.exports=o},8008:function(e,t,n){var r=n(8113).match(/AppleWebKit\/(\d+)\./);e.exports=!!r&&+r[1]},748:function(e){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2914:function(e,t,n){var r=n(7293),o=n(9114);e.exports=!r((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",o(1,7)),7!==e.stack)}))},7762:function(e,t,n){"use strict";var r=n(9781),o=n(7293),i=n(9670),a=n(30),A=n(6277),s=Error.prototype.toString,c=o((function(){if(r){var e=a(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==s.call(e))return!0}return"2: 1"!==s.call({message:1,name:2})||"Error"!==s.call({})}));e.exports=c?function(){var e=i(this),t=A(e.name,"Error"),n=A(e.message);return t?n?t+": "+n:t:n}:s},2109:function(e,t,n){var r=n(7854),o=n(1236).f,i=n(8880),a=n(1320),A=n(3505),s=n(9920),c=n(4705);e.exports=function(e,t){var n,u,l,f,p,d=e.target,g=e.global,h=e.stat;if(n=g?r:h?r[d]||A(d,{}):(r[d]||{}).prototype)for(u in t){if(f=t[u],l=e.noTargetGet?(p=o(n,u))&&p.value:n[u],!c(g?u:d+(h?".":"#")+u,e.forced)&&void 0!==l){if(typeof f==typeof l)continue;s(f,l)}(e.sham||l&&l.sham)&&i(f,"sham",!0),a(n,u,f,e)}}},7293:function(e){e.exports=function(e){try{return!!e()}catch(e){return!0}}},7007:function(e,t,n){"use strict";n(4916);var r=n(1702),o=n(1320),i=n(2261),a=n(7293),A=n(5112),s=n(8880),c=A("species"),u=RegExp.prototype;e.exports=function(e,t,n,l){var f=A(e),p=!a((function(){var t={};return t[f]=function(){return 7},7!=""[e](t)})),d=p&&!a((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[c]=function(){return n},n.flags="",n[f]=/./[f]),n.exec=function(){return t=!0,null},n[f](""),!t}));if(!p||!d||n){var g=r(/./[f]),h=t(f,""[e],(function(e,t,n,o,a){var A=r(e),s=t.exec;return s===i||s===u.exec?p&&!a?{done:!0,value:g(t,n,o)}:{done:!0,value:A(n,t,o)}:{done:!1}}));o(String.prototype,e,h[0]),o(u,f,h[1])}l&&s(u[f],"sham",!0)}},6790:function(e,t,n){"use strict";var r=n(7854),o=n(3157),i=n(6244),a=n(9974),A=r.TypeError,s=function(e,t,n,r,c,u,l,f){for(var p,d,g=c,h=0,v=!!l&&a(l,f);h0&&o(p))d=i(p),g=s(e,t,p,d,g,u-1)-1;else{if(g>=9007199254740991)throw A("Exceed the acceptable array length");e[g]=p}g++}h++}return g};e.exports=s},6677:function(e,t,n){var r=n(7293);e.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},2104:function(e,t,n){var r=n(4374),o=Function.prototype,i=o.apply,a=o.call;e.exports="object"==typeof Reflect&&Reflect.apply||(r?a.bind(i):function(){return a.apply(i,arguments)})},9974:function(e,t,n){var r=n(1702),o=n(9662),i=n(4374),a=r(r.bind);e.exports=function(e,t){return o(e),void 0===t?e:i?a(e,t):function(){return e.apply(t,arguments)}}},4374:function(e,t,n){var r=n(7293);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},7065:function(e,t,n){"use strict";var r=n(7854),o=n(1702),i=n(9662),a=n(111),A=n(2597),s=n(206),c=n(4374),u=r.Function,l=o([].concat),f=o([].join),p={},d=function(e,t,n){if(!A(p,t)){for(var r=[],o=0;o]*>)/g,u=/\$([$&'`]|\d{1,2})/g;e.exports=function(e,t,n,r,l,f){var p=n+e.length,d=r.length,g=u;return void 0!==l&&(l=o(l),g=c),A(f,g,(function(o,A){var c;switch(a(A,0)){case"$":return"$";case"&":return e;case"`":return s(t,0,n);case"'":return s(t,p);case"<":c=l[s(A,1,-1)];break;default:var u=+A;if(0===u)return o;if(u>d){var f=i(u/10);return 0===f?o:f<=d?void 0===r[f-1]?a(A,1):r[f-1]+a(A,1):o}c=r[u-1]}return void 0===c?"":c}))}},7854:function(e,t,n){var r=function(e){return e&&e.Math==Math&&e};e.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},2597:function(e,t,n){var r=n(1702),o=n(7908),i=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return i(o(e),t)}},3501:function(e){e.exports={}},842:function(e,t,n){var r=n(7854);e.exports=function(e,t){var n=r.console;n&&n.error&&(1==arguments.length?n.error(e):n.error(e,t))}},490:function(e,t,n){var r=n(5005);e.exports=r("document","documentElement")},4664:function(e,t,n){var r=n(9781),o=n(7293),i=n(317);e.exports=!r&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},1179:function(e,t,n){var r=n(7854).Array,o=Math.abs,i=Math.pow,a=Math.floor,A=Math.log,s=Math.LN2;e.exports={pack:function(e,t,n){var c,u,l,f=r(n),p=8*n-t-1,d=(1<>1,h=23===t?i(2,-24)-i(2,-77):0,v=e<0||0===e&&1/e<0?1:0,m=0;for((e=o(e))!=e||e===1/0?(u=e!=e?1:0,c=d):(c=a(A(e)/s),e*(l=i(2,-c))<1&&(c--,l*=2),(e+=c+g>=1?h/l:h*i(2,1-g))*l>=2&&(c++,l/=2),c+g>=d?(u=0,c=d):c+g>=1?(u=(e*l-1)*i(2,t),c+=g):(u=e*i(2,g-1)*i(2,t),c=0));t>=8;)f[m++]=255&u,u/=256,t-=8;for(c=c<0;)f[m++]=255&c,c/=256,p-=8;return f[--m]|=128*v,f},unpack:function(e,t){var n,r=e.length,o=8*r-t-1,a=(1<>1,s=o-7,c=r-1,u=e[c--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(0===l)l=1-A;else{if(l===a)return n?NaN:u?-1/0:1/0;n+=i(2,t),l-=A}return(u?-1:1)*n*i(2,l-t)}}},8361:function(e,t,n){var r=n(7854),o=n(1702),i=n(7293),a=n(4326),A=r.Object,s=o("".split);e.exports=i((function(){return!A("z").propertyIsEnumerable(0)}))?function(e){return"String"==a(e)?s(e,""):A(e)}:A},9587:function(e,t,n){var r=n(614),o=n(111),i=n(7674);e.exports=function(e,t,n){var a,A;return i&&r(a=t.constructor)&&a!==n&&o(A=a.prototype)&&A!==n.prototype&&i(e,A),e}},2788:function(e,t,n){var r=n(1702),o=n(614),i=n(5465),a=r(Function.toString);o(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),e.exports=i.inspectSource},8340:function(e,t,n){var r=n(111),o=n(8880);e.exports=function(e,t){r(t)&&"cause"in t&&o(e,"cause",t.cause)}},2423:function(e,t,n){var r=n(2109),o=n(1702),i=n(3501),a=n(111),A=n(2597),s=n(3070).f,c=n(8006),u=n(1156),l=n(2050),f=n(9711),p=n(6677),d=!1,g=f("meta"),h=0,v=function(e){s(e,g,{value:{objectID:"O"+h++,weakData:{}}})},m=e.exports={enable:function(){m.enable=function(){},d=!0;var e=c.f,t=o([].splice),n={};n[g]=1,e(n).length&&(c.f=function(n){for(var r=e(n),o=0,i=r.length;om;m++)if((y=T(e[m]))&&u(h,y))return y;return new g(!1)}r=l(e,v)}for(b=r.next;!(w=i(b,r)).done;){try{y=T(w.value)}catch(e){p(r,"throw",e)}if("object"==typeof y&&y&&u(h,y))return y}return new g(!1)}},9212:function(e,t,n){var r=n(6916),o=n(9670),i=n(8173);e.exports=function(e,t,n){var a,A;o(e);try{if(!(a=i(e,"return"))){if("throw"===t)throw n;return n}a=r(a,e)}catch(e){A=!0,a=e}if("throw"===t)throw n;if(A)throw a;return o(a),n}},3383:function(e,t,n){"use strict";var r,o,i,a=n(7293),A=n(614),s=n(30),c=n(9518),u=n(1320),l=n(5112),f=n(1913),p=l("iterator"),d=!1;[].keys&&("next"in(i=[].keys())?(o=c(c(i)))!==Object.prototype&&(r=o):d=!0),null==r||a((function(){var e={};return r[p].call(e)!==e}))?r={}:f&&(r=s(r)),A(r[p])||u(r,p,(function(){return this})),e.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:d}},7497:function(e){e.exports={}},6244:function(e,t,n){var r=n(7466);e.exports=function(e){return r(e.length)}},6736:function(e){var t=Math.expm1,n=Math.exp;e.exports=!t||t(10)>22025.465794806718||t(10)<22025.465794806718||-2e-17!=t(-2e-17)?function(e){return 0==(e=+e)?e:e>-1e-6&&e<1e-6?e+e*e/2:n(e)-1}:t},6130:function(e,t,n){var r=n(4310),o=Math.abs,i=Math.pow,a=i(2,-52),A=i(2,-23),s=i(2,127)*(2-A),c=i(2,-126);e.exports=Math.fround||function(e){var t,n,i=o(e),u=r(e);return is||n!=n?u*(1/0):u*n}},202:function(e){var t=Math.log,n=Math.LOG10E;e.exports=Math.log10||function(e){return t(e)*n}},6513:function(e){var t=Math.log;e.exports=Math.log1p||function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:t(1+e)}},4310:function(e){e.exports=Math.sign||function(e){return 0==(e=+e)||e!=e?e:e<0?-1:1}},5948:function(e,t,n){var r,o,i,a,A,s,c,u,l=n(7854),f=n(9974),p=n(1236).f,d=n(261).set,g=n(8334),h=n(1528),v=n(1036),m=n(5268),C=l.MutationObserver||l.WebKitMutationObserver,y=l.document,b=l.process,w=l.Promise,E=p(l,"queueMicrotask"),B=E&&E.value;B||(r=function(){var e,t;for(m&&(e=b.domain)&&e.exit();o;){t=o.fn,o=o.next;try{t()}catch(e){throw o?a():i=void 0,e}}i=void 0,e&&e.enter()},g||m||v||!C||!y?!h&&w&&w.resolve?((c=w.resolve(void 0)).constructor=w,u=f(c.then,c),a=function(){u(r)}):m?a=function(){b.nextTick(r)}:(d=f(d,l),a=function(){d(r)}):(A=!0,s=y.createTextNode(""),new C(r).observe(s,{characterData:!0}),a=function(){s.data=A=!A})),e.exports=B||function(e){var t={fn:e,next:void 0};i&&(i.next=t),o||(o=t,a()),i=t}},3366:function(e,t,n){var r=n(7854);e.exports=r.Promise},133:function(e,t,n){var r=n(7392),o=n(7293);e.exports=!!Object.getOwnPropertySymbols&&!o((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},590:function(e,t,n){var r=n(7293),o=n(5112),i=n(1913),a=o("iterator");e.exports=!r((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),i&&!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[a]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))},8536:function(e,t,n){var r=n(7854),o=n(614),i=n(2788),a=r.WeakMap;e.exports=o(a)&&/native code/.test(i(a))},8523:function(e,t,n){"use strict";var r=n(9662),o=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=r(t),this.reject=r(n)};e.exports.f=function(e){return new o(e)}},6277:function(e,t,n){var r=n(1340);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:r(e)}},3929:function(e,t,n){var r=n(7854),o=n(7850),i=r.TypeError;e.exports=function(e){if(o(e))throw i("The method doesn't accept regular expressions");return e}},7023:function(e,t,n){var r=n(7854).isFinite;e.exports=Number.isFinite||function(e){return"number"==typeof e&&r(e)}},2814:function(e,t,n){var r=n(7854),o=n(7293),i=n(1702),a=n(1340),A=n(3111).trim,s=n(1361),c=i("".charAt),u=r.parseFloat,l=r.Symbol,f=l&&l.iterator,p=1/u(s+"-0")!=-1/0||f&&!o((function(){u(Object(f))}));e.exports=p?function(e){var t=A(a(e)),n=u(t);return 0===n&&"-"==c(t,0)?-0:n}:u},3009:function(e,t,n){var r=n(7854),o=n(7293),i=n(1702),a=n(1340),A=n(3111).trim,s=n(1361),c=r.parseInt,u=r.Symbol,l=u&&u.iterator,f=/^[+-]?0x/i,p=i(f.exec),d=8!==c(s+"08")||22!==c(s+"0x16")||l&&!o((function(){c(Object(l))}));e.exports=d?function(e,t){var n=A(a(e));return c(n,t>>>0||(p(f,n)?16:10))}:c},1574:function(e,t,n){"use strict";var r=n(9781),o=n(1702),i=n(6916),a=n(7293),A=n(1956),s=n(5181),c=n(5296),u=n(7908),l=n(8361),f=Object.assign,p=Object.defineProperty,d=o([].concat);e.exports=!f||a((function(){if(r&&1!==f({b:1},f(p({},"a",{enumerable:!0,get:function(){p(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),o="abcdefghijklmnopqrst";return e[n]=7,o.split("").forEach((function(e){t[e]=e})),7!=f({},e)[n]||A(f({},t)).join("")!=o}))?function(e,t){for(var n=u(e),o=arguments.length,a=1,f=s.f,p=c.f;o>a;)for(var g,h=l(arguments[a++]),v=f?d(A(h),f(h)):A(h),m=v.length,C=0;m>C;)g=v[C++],r&&!i(p,h,g)||(n[g]=h[g]);return n}:f},30:function(e,t,n){var r,o=n(9670),i=n(6048),a=n(748),A=n(3501),s=n(490),c=n(317),u=n(6200)("IE_PROTO"),l=function(){},f=function(e){return" @@ -319,9 +319,7 @@ You need to place the `dash.js` first, and then `ovenplayer.js` as shown below: ### Initialize for HLS -If you want to play HLS, you need the [hls.js](https://github.com/video-dev/hls.js). - -You need to place the `hls.js` first, and then `ovenplayer.js` as shown below: +OvenPlayer will use third party to initialize HLS [hls.js](https://github.com/video-dev/hls.js). ```markup @@ -338,9 +336,6 @@ You need to place the `hls.js` first, and then `ovenplayer.js` as shown below:
- - - diff --git a/package-lock.json b/package-lock.json index 23c47965..25d1dae9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,16 @@ { "name": "ovenplayer", - "version": "0.10.27", + "version": "0.10.31", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ovenplayer", - "version": "0.10.26", + "version": "0.10.31", "license": "MIT", "dependencies": { "core-js": "^3.16.3", + "hls.js": "^1.4.12", "whatwg-fetch": "^3.6.2" }, "devDependencies": { @@ -2144,26 +2145,35 @@ } }, "node_modules/browserslist": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz", - "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==", + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", + "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "dependencies": { - "caniuse-lite": "^1.0.30001286", - "electron-to-chromium": "^1.4.17", - "escalade": "^3.1.1", - "node-releases": "^2.0.1", - "picocolors": "^1.0.0" + "caniuse-lite": "^1.0.30001541", + "electron-to-chromium": "^1.4.535", + "node-releases": "^2.0.13", + "update-browserslist-db": "^1.0.13" }, "bin": { "browserslist": "cli.js" }, "engines": { "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" } }, "node_modules/buffer-from": { @@ -2195,14 +2205,24 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001312", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz", - "integrity": "sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ==", + "version": "1.0.30001546", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001546.tgz", + "integrity": "sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==", "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - } + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] }, "node_modules/chalk": { "version": "2.4.2", @@ -2374,28 +2394,18 @@ } }, "node_modules/core-js-compat": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.0.tgz", - "integrity": "sha512-OSXseNPSK2OPJa6GdtkMz/XxeXx8/CJvfhQWTqd6neuUraujcL4jVsjkLQz1OWnax8xVQJnRPe0V2jqNWORA+A==", + "version": "3.33.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.33.0.tgz", + "integrity": "sha512-0w4LcLXsVEuNkIqwjjf9rjCoPhK8uqA4tMRh4Ge26vfLtUutshn+aRJU21I9LCJlh2QQHfisNToLjw1XEJLTWw==", "dev": true, "dependencies": { - "browserslist": "^4.19.1", - "semver": "7.0.0" + "browserslist": "^4.22.1" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" } }, - "node_modules/core-js-compat/node_modules/semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -2437,9 +2447,9 @@ } }, "node_modules/css-loader/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -2539,9 +2549,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.68", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.68.tgz", - "integrity": "sha512-cId+QwWrV8R1UawO6b9BR1hnkJ4EJPCPAr4h315vliHUtVUJDk39Sg1PMNnaWKfj5x+93ssjeJ9LKL6r8LaMiA==", + "version": "1.4.543", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.543.tgz", + "integrity": "sha512-t2ZP4AcGE0iKCCQCBx/K2426crYdxD3YU6l0uK2EO3FZH0pbC4pFz/sZm2ruZsND6hQBTcDWWlo/MLpiOdif5g==", "dev": true }, "node_modules/emojis-list": { @@ -3046,6 +3056,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/hls.js": { + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.4.12.tgz", + "integrity": "sha512-1RBpx2VihibzE3WE9kGoVCtrhhDWTzydzElk/kyRbEOLnb1WIE+3ZabM/L8BqKFTCL3pUy4QzhXgD1Q6Igr1JA==" + }, "node_modules/hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -3374,13 +3389,10 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, "bin": { "json5": "lib/cli.js" }, @@ -3467,9 +3479,9 @@ } }, "node_modules/less/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "optional": true, "bin": { @@ -3510,9 +3522,9 @@ } }, "node_modules/loader-utils/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "dependencies": { "minimist": "^1.2.0" @@ -3681,10 +3693,16 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -3736,9 +3754,9 @@ "dev": true }, "node_modules/node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", "dev": true }, "node_modules/npm-run-path": { @@ -3937,21 +3955,31 @@ } }, "node_modules/postcss": { - "version": "8.4.6", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.6.tgz", - "integrity": "sha512-OovjwIzs9Te46vlEx7+uXB0PLijpwjXGKXjVGGPIGubGpq7uh5Xgf6D6FiJ/SzJMBosHDp6a2hiXOS97iBXcaA==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "dependencies": { - "nanoid": "^3.2.0", + "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, "engines": { "node": "^10 || ^12 || >=14" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" } }, "node_modules/postcss-modules-extract-imports": { @@ -4274,9 +4302,9 @@ } }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -4685,6 +4713,36 @@ "node": ">= 0.8" } }, + "node_modules/update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -6520,16 +6578,15 @@ } }, "browserslist": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz", - "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==", + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", + "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001286", - "electron-to-chromium": "^1.4.17", - "escalade": "^3.1.1", - "node-releases": "^2.0.1", - "picocolors": "^1.0.0" + "caniuse-lite": "^1.0.30001541", + "electron-to-chromium": "^1.4.535", + "node-releases": "^2.0.13", + "update-browserslist-db": "^1.0.13" } }, "buffer-from": { @@ -6555,9 +6612,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001312", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz", - "integrity": "sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ==", + "version": "1.0.30001546", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001546.tgz", + "integrity": "sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==", "dev": true }, "chalk": { @@ -6692,21 +6749,12 @@ "integrity": "sha512-YUdI3fFu4TF/2WykQ2xzSiTQdldLB4KVuL9WeAy5XONZYt5Cun/fpQvctoKbCgvPhmzADeesTk/j2Rdx77AcKQ==" }, "core-js-compat": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.0.tgz", - "integrity": "sha512-OSXseNPSK2OPJa6GdtkMz/XxeXx8/CJvfhQWTqd6neuUraujcL4jVsjkLQz1OWnax8xVQJnRPe0V2jqNWORA+A==", + "version": "3.33.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.33.0.tgz", + "integrity": "sha512-0w4LcLXsVEuNkIqwjjf9rjCoPhK8uqA4tMRh4Ge26vfLtUutshn+aRJU21I9LCJlh2QQHfisNToLjw1XEJLTWw==", "dev": true, "requires": { - "browserslist": "^4.19.1", - "semver": "7.0.0" - }, - "dependencies": { - "semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true - } + "browserslist": "^4.22.1" } }, "cross-spawn": { @@ -6737,9 +6785,9 @@ }, "dependencies": { "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -6805,9 +6853,9 @@ } }, "electron-to-chromium": { - "version": "1.4.68", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.68.tgz", - "integrity": "sha512-cId+QwWrV8R1UawO6b9BR1hnkJ4EJPCPAr4h315vliHUtVUJDk39Sg1PMNnaWKfj5x+93ssjeJ9LKL6r8LaMiA==", + "version": "1.4.543", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.543.tgz", + "integrity": "sha512-t2ZP4AcGE0iKCCQCBx/K2426crYdxD3YU6l0uK2EO3FZH0pbC4pFz/sZm2ruZsND6hQBTcDWWlo/MLpiOdif5g==", "dev": true }, "emojis-list": { @@ -7198,6 +7246,11 @@ "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", "dev": true }, + "hls.js": { + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.4.12.tgz", + "integrity": "sha512-1RBpx2VihibzE3WE9kGoVCtrhhDWTzydzElk/kyRbEOLnb1WIE+3ZabM/L8BqKFTCL3pUy4QzhXgD1Q6Igr1JA==" + }, "hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -7432,13 +7485,10 @@ "dev": true }, "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true }, "kind-of": { "version": "6.0.3", @@ -7482,9 +7532,9 @@ } }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "optional": true }, @@ -7524,9 +7574,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" @@ -7655,9 +7705,9 @@ "dev": true }, "nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", "dev": true }, "needle": { @@ -7697,9 +7747,9 @@ "dev": true }, "node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", "dev": true }, "npm-run-path": { @@ -7841,12 +7891,12 @@ } }, "postcss": { - "version": "8.4.6", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.6.tgz", - "integrity": "sha512-OovjwIzs9Te46vlEx7+uXB0PLijpwjXGKXjVGGPIGubGpq7uh5Xgf6D6FiJ/SzJMBosHDp6a2hiXOS97iBXcaA==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "dev": true, "requires": { - "nanoid": "^3.2.0", + "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } @@ -8095,9 +8145,9 @@ } }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true }, "send": { @@ -8396,6 +8446,16 @@ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "dev": true }, + "update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "requires": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + } + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 84ee0dd0..ebac4966 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ }, "dependencies": { "core-js": "^3.16.3", + "hls.js": "^1.4.12", "whatwg-fetch": "^3.6.2" } -} \ No newline at end of file +} diff --git a/src/js/api/provider/html5/providers/Hls.js b/src/js/api/provider/html5/providers/Hls.js index 0bc97609..242617e8 100644 --- a/src/js/api/provider/html5/providers/Hls.js +++ b/src/js/api/provider/html5/providers/Hls.js @@ -1,6 +1,7 @@ /** * Created by hoho on 2018. 6. 7.. */ +import Hls from "hls.js"; import Provider from "api/provider/html5/Provider"; import { errorTrigger } from "api/provider/utils"; import { @@ -15,7 +16,6 @@ import { PLAYER_AUTH_FAILED_ERROR, PLAYER_NOT_ACCEPTABLE_ERROR, STATE_PLAYING, CONTENT_LEVEL_CHANGED, AUDIO_TRACK_CHANGED } from "api/constants"; - import sizeHumanizer from "utils/sizeHumanizer"; /** @@ -304,4 +304,4 @@ const HlsProvider = function (element, playerConfig, adTagUrl) { }; -export default HlsProvider; \ No newline at end of file +export default HlsProvider; From 583d1d8f124e32438734669bebfda8c14637a26c Mon Sep 17 00:00:00 2001 From: Arkadii Shvartsman Date: Thu, 5 Oct 2023 21:34:11 +0200 Subject: [PATCH 2/8] refactoring --- src/js/api/provider/html5/providers/Hls.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/api/provider/html5/providers/Hls.js b/src/js/api/provider/html5/providers/Hls.js index 242617e8..14f65be7 100644 --- a/src/js/api/provider/html5/providers/Hls.js +++ b/src/js/api/provider/html5/providers/Hls.js @@ -2,6 +2,7 @@ * Created by hoho on 2018. 6. 7.. */ import Hls from "hls.js"; + import Provider from "api/provider/html5/Provider"; import { errorTrigger } from "api/provider/utils"; import { @@ -16,12 +17,14 @@ import { PLAYER_AUTH_FAILED_ERROR, PLAYER_NOT_ACCEPTABLE_ERROR, STATE_PLAYING, CONTENT_LEVEL_CHANGED, AUDIO_TRACK_CHANGED } from "api/constants"; + import sizeHumanizer from "utils/sizeHumanizer"; /** * @brief hlsjs provider extended core. - * @param container player element. + * @param element player element. * @param playerConfig config. + * @param adTagUrl url for ad * */ @@ -241,8 +244,6 @@ const HlsProvider = function (element, playerConfig, adTagUrl) { that.setAutoQuality = (isAuto) => { if (isAuto) { hls.currentLevel = -1; - } else { - hls.currentLevel = hls.currentLevel; } }; From 4f7ea397b1d05e6e1a40b41ee3c496ec6f13afed Mon Sep 17 00:00:00 2001 From: Arkadii Shvartsman Date: Thu, 5 Oct 2023 21:34:34 +0200 Subject: [PATCH 3/8] refactoring --- src/js/api/provider/html5/providers/Hls.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/api/provider/html5/providers/Hls.js b/src/js/api/provider/html5/providers/Hls.js index 14f65be7..00e98d69 100644 --- a/src/js/api/provider/html5/providers/Hls.js +++ b/src/js/api/provider/html5/providers/Hls.js @@ -244,6 +244,8 @@ const HlsProvider = function (element, playerConfig, adTagUrl) { that.setAutoQuality = (isAuto) => { if (isAuto) { hls.currentLevel = -1; + } else { + hls.currentLevel = hls.currentLevel; } }; From ce62026ee90e86d25201b24cfe98fe0f9fee19da Mon Sep 17 00:00:00 2001 From: Arkadii Shvartsman Date: Sat, 14 Oct 2023 17:52:24 +0200 Subject: [PATCH 4/8] fetch null fixer --- dist/ovenplayer.js | 2 +- dist/ovenplayer.js.map | 2 +- src/js/api/media/Manager.js | 2 -- src/js/api/provider/Controller.js | 11 +++++------ 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dist/ovenplayer.js b/dist/ovenplayer.js index 4df62414..bfaf0053 100644 --- a/dist/ovenplayer.js +++ b/dist/ovenplayer.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.OvenPlayer=e():t.OvenPlayer=e()}(self,(function(){return function(){var t={2950:function(t,e,n){"use strict";n.d(e,{default:function(){return rc}});var r="0.10.31",i=n(741),o=n.n(i);function s(t){return t?t.replace(/^\s+|\s+$/g,""):""}var a=function(t){if(!t||"rtmp"==t.substr(0,4))return"";var e=function(t){var e="";return/[(,]format=mpd-/i.test(t)?e="mpd":/[(,]format=m3u8-/i.test(t)&&(e="m3u8"),e}(t);return e||((t=t.split("?")[0].split("#")[0]).lastIndexOf(".")>-1?t.substr(t.lastIndexOf(".")+1,t.length).toLowerCase():"")};function l(t){var e=parseInt(t,10);if(!t)return"00:00";var n=Math.floor(e/3600),r=Math.floor((e-3600*n)/60),i=e-3600*n-60*r;return r<10&&(r="0"+r),i<10&&(i="0"+i),n>0?n+":"+r+":"+i:r+":"+i}function c(t,e){if(!t)return 0;if(o().isNumber(t)&&!o().isNaN(t))return t;var n=(t=t.replace(",",".")).split(":"),r=n.length,i=0;if("s"===t.slice(-1))i=parseFloat(t);else if("m"===t.slice(-1))i=60*parseFloat(t);else if("h"===t.slice(-1))i=3600*parseFloat(t);else if(r>1){var s=r-1;4===r&&(e&&(i=parseFloat(n[s])/e),s-=1),i+=parseFloat(n[s]),i+=60*parseFloat(n[s-1]),r>=3&&(i+=3600*parseFloat(n[s-2]))}else i=parseFloat(t);return o().isNaN(i)?0:i}function u(t){var e={},n=t.split("\r\n");1===n.length&&(n=t.split("\n"));var r=1;if(n[0].indexOf(" --\x3e ")>0&&(r=0),n.length>r+1&&n[r+1]){var i=n[r],o=i.indexOf(" --\x3e ");o>0&&(e.start=c(i.substr(0,o)),e.end=c(i.substr(o+5)),e.text=n.slice(r+1).join("\r\n"))}return e}var A=window.VTTCue,d={"":!0,lr:!0,rl:!0},h={start:!0,middle:!0,end:!0,left:!0,right:!0};function f(t){return"string"==typeof t&&!!h[t.toLowerCase()]&&t.toLowerCase()}function p(t){for(var e=1;e100)throw new Error("Position must be between 0 and 100.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(r,"positionAlign",p({},o,{get:function(){return C},set:function(t){var e=f(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");C=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"size",p({},o,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(r,"align",p({},o,{get:function(){return E},set:function(t){var e=f(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),r.displayState=void 0,i)return r}).prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)});var g=A,m={"":!0,up:!0};function v(t){return"number"==typeof t&&t>=0&&t<=100}var y=function(){var t=100,e=3,n=0,r=100,i=0,o=100,s="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return t},set:function(e){if(!v(e))throw new Error("Width must be between 0 and 100.");t=e}},lines:{enumerable:!0,get:function(){return e},set:function(t){if("number"!=typeof t)throw new TypeError("Lines must be set to a number.");e=t}},regionAnchorY:{enumerable:!0,get:function(){return r},set:function(t){if(!v(t))throw new Error("RegionAnchorX must be between 0 and 100.");r=t}},regionAnchorX:{enumerable:!0,get:function(){return n},set:function(t){if(!v(t))throw new Error("RegionAnchorY must be between 0 and 100.");n=t}},viewportAnchorY:{enumerable:!0,get:function(){return o},set:function(t){if(!v(t))throw new Error("ViewportAnchorY must be between 0 and 100.");o=t}},viewportAnchorX:{enumerable:!0,get:function(){return i},set:function(t){if(!v(t))throw new Error("ViewportAnchorX must be between 0 and 100.");i=t}},scroll:{enumerable:!0,get:function(){return s},set:function(t){var e=function(t){return"string"==typeof t&&!!m[t.toLowerCase()]&&t.toLowerCase()}(t);if(!1===e)throw new SyntaxError("An invalid or illegal string was specified.");s=e}}})},C=function(){};function b(t,e){return void 0===e&&(e=1),"rgba("+[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16),e].join(",")+")"}var E=1;function w(t,e,n){switch(n){case"webvtt.font.color":case"webvtt.font.opacity":var r=Services.prefs.getCharPref("webvtt.font.color"),i=Services.prefs.getIntPref("webvtt.font.opacity")/100;T.fontSet=b(r,i);break;case"webvtt.font.scale":E=Services.prefs.getIntPref("webvtt.font.scale")/100;break;case"webvtt.bg.color":case"webvtt.bg.opacity":var o=Services.prefs.getCharPref("webvtt.bg.color"),s=Services.prefs.getIntPref("webvtt.bg.opacity")/100;T.backgroundSet=b(o,s);break;case"webvtt.edge.color":case"webvtt.edge.type":var a=Services.prefs.getIntPref("webvtt.edge.type"),l=Services.prefs.getCharPref("webvtt.edge.color");T.edgeSet=["","0px 0px ","4px 4px 4px ","-2px -2px ","2px 2px "][a]+b(l)}}if("undefined"!=typeof Services){var T={};["webvtt.font.color","webvtt.font.opacity","webvtt.font.scale","webvtt.bg.color","webvtt.bg.opacity","webvtt.edge.color","webvtt.edge.type"].forEach((function(t){w(0,0,t),Services.prefs.addObserver(t,w,!1)}))}var S=Object.create||function(){function t(){}return function(e){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return t.prototype=e,new t}}();function k(t,e){this.name="ParsingError",this.code=t.code,this.message=e||t.message}function L(t){function e(t,e,n,r){return 3600*(0|t)+60*(0|e)+(0|n)+(0|r)/1e3}var n=t.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return n?n[3]?e(n[1],n[2],n[3].replace(":",""),n[4]):n[1]>59?e(n[1],n[2],0,n[4]):e(0,n[1],n[2],n[4]):null}function x(){this.values=S(null)}function I(t,e,n,r){var i=r?t.split(r):[t];for(var o in i)if("string"==typeof i[o]){var s=i[o].split(n);2===s.length&&e(s[0],s[1])}}function R(t,e,n){var r=t;function i(){var e=L(t);if(null===e)throw new k(k.Errors.BadTimeStamp,"Malformed timestamp: "+r);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function o(){t=t.replace(/^\s+/,"")}if(o(),e.startTime=i(),o(),"--\x3e"!==t.substr(0,3))throw new k(k.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);t=t.substr(3),o(),e.endTime=i(),o(),function(t,e){var r=new x;I(t,(function(t,e){switch(t){case"region":for(var i=n.length-1;i>=0;i--)if(n[i].id===e){r.set(t,n[i].region);break}break;case"vertical":r.alt(t,e,["rl","lr"]);break;case"line":var o=e.split(","),s=o[0];r.integer(t,s),r.percent(t,s)&&r.set("snapToLines",!1),r.alt(t,s,["auto"]),2===o.length&&r.alt("lineAlign",o[1],["start","middle","end"]);break;case"position":o=e.split(","),r.percent(t,o[0]),2===o.length&&r.alt("positionAlign",o[1],["start","middle","end"]);break;case"size":r.percent(t,e);break;case"align":r.alt(t,e,["start","middle","end","left","right"])}}),/:/,/\s/)}(t)}k.prototype=S(Error.prototype),k.prototype.constructor=k,k.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},x.prototype={set:function(t,e){this.get(t)||""===e||(this.values[t]=e)},get:function(t,e,n){return n?this.has(t)?this.values[t]:e[n]:this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,n){for(var r=0;r=0&&e<=100)&&(this.set(t,e),!0)}};var D={"&":"&","<":"<",">":">","‎":"‎","‏":"‏"," ":" "},B={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},P={v:"title",lang:"lang"},M={rt:"ruby"};function O(t,e){function n(){if(!e)return null;var t,n=e.match(/^([^<]*)(<[^>]+>?)?/);return t=n[1]?n[1]:n[2],e=e.substr(t.length),t}function r(t){return D[t]}function i(t){for(;h=t.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)t=t.replace(h[0],r);return t}function o(t,e){return!M[e.localName]||M[e.localName]===t.localName}function s(e,n){var r=B[e];if(!r)return null;var i=t.document.createElement(r);i.localName=r;var o=P[e];return o&&n&&(i[o]=n.trim()),i}for(var a,l=t.document.createElement("div"),c=l,u=[];null!==(a=n());)if("<"!==a[0])c.appendChild(t.document.createTextNode(i(a)));else{if("/"===a[1]){u.length&&u[u.length-1]===a.substr(2).replace(">","")&&(u.pop(),c=c.parentNode);continue}var A,d=L(a.substr(1,a.length-2));if(d){A=t.document.createProcessingInstruction("timestamp",d),c.appendChild(A);continue}var h=a.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!h)continue;if(!(A=s(h[1],h[3])))continue;if(!o(c,A))continue;h[2]&&(A.className=h[2].substr(1).replace("."," ")),u.push(h[1]),c.appendChild(A),c=A}return l}var F=[1470,1472,1475,1478,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1520,1521,1522,1523,1524,1544,1547,1549,1563,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1645,1646,1647,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1765,1766,1774,1775,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1807,1808,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1969,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2e3,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2036,2037,2042,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2074,2084,2088,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2142,2208,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,8207,64285,64287,64288,64289,64290,64291,64292,64293,64294,64295,64296,64298,64299,64300,64301,64302,64303,64304,64305,64306,64307,64308,64309,64310,64312,64313,64314,64315,64316,64318,64320,64321,64323,64324,64326,64327,64328,64329,64330,64331,64332,64333,64334,64335,64336,64337,64338,64339,64340,64341,64342,64343,64344,64345,64346,64347,64348,64349,64350,64351,64352,64353,64354,64355,64356,64357,64358,64359,64360,64361,64362,64363,64364,64365,64366,64367,64368,64369,64370,64371,64372,64373,64374,64375,64376,64377,64378,64379,64380,64381,64382,64383,64384,64385,64386,64387,64388,64389,64390,64391,64392,64393,64394,64395,64396,64397,64398,64399,64400,64401,64402,64403,64404,64405,64406,64407,64408,64409,64410,64411,64412,64413,64414,64415,64416,64417,64418,64419,64420,64421,64422,64423,64424,64425,64426,64427,64428,64429,64430,64431,64432,64433,64434,64435,64436,64437,64438,64439,64440,64441,64442,64443,64444,64445,64446,64447,64448,64449,64467,64468,64469,64470,64471,64472,64473,64474,64475,64476,64477,64478,64479,64480,64481,64482,64483,64484,64485,64486,64487,64488,64489,64490,64491,64492,64493,64494,64495,64496,64497,64498,64499,64500,64501,64502,64503,64504,64505,64506,64507,64508,64509,64510,64511,64512,64513,64514,64515,64516,64517,64518,64519,64520,64521,64522,64523,64524,64525,64526,64527,64528,64529,64530,64531,64532,64533,64534,64535,64536,64537,64538,64539,64540,64541,64542,64543,64544,64545,64546,64547,64548,64549,64550,64551,64552,64553,64554,64555,64556,64557,64558,64559,64560,64561,64562,64563,64564,64565,64566,64567,64568,64569,64570,64571,64572,64573,64574,64575,64576,64577,64578,64579,64580,64581,64582,64583,64584,64585,64586,64587,64588,64589,64590,64591,64592,64593,64594,64595,64596,64597,64598,64599,64600,64601,64602,64603,64604,64605,64606,64607,64608,64609,64610,64611,64612,64613,64614,64615,64616,64617,64618,64619,64620,64621,64622,64623,64624,64625,64626,64627,64628,64629,64630,64631,64632,64633,64634,64635,64636,64637,64638,64639,64640,64641,64642,64643,64644,64645,64646,64647,64648,64649,64650,64651,64652,64653,64654,64655,64656,64657,64658,64659,64660,64661,64662,64663,64664,64665,64666,64667,64668,64669,64670,64671,64672,64673,64674,64675,64676,64677,64678,64679,64680,64681,64682,64683,64684,64685,64686,64687,64688,64689,64690,64691,64692,64693,64694,64695,64696,64697,64698,64699,64700,64701,64702,64703,64704,64705,64706,64707,64708,64709,64710,64711,64712,64713,64714,64715,64716,64717,64718,64719,64720,64721,64722,64723,64724,64725,64726,64727,64728,64729,64730,64731,64732,64733,64734,64735,64736,64737,64738,64739,64740,64741,64742,64743,64744,64745,64746,64747,64748,64749,64750,64751,64752,64753,64754,64755,64756,64757,64758,64759,64760,64761,64762,64763,64764,64765,64766,64767,64768,64769,64770,64771,64772,64773,64774,64775,64776,64777,64778,64779,64780,64781,64782,64783,64784,64785,64786,64787,64788,64789,64790,64791,64792,64793,64794,64795,64796,64797,64798,64799,64800,64801,64802,64803,64804,64805,64806,64807,64808,64809,64810,64811,64812,64813,64814,64815,64816,64817,64818,64819,64820,64821,64822,64823,64824,64825,64826,64827,64828,64829,64848,64849,64850,64851,64852,64853,64854,64855,64856,64857,64858,64859,64860,64861,64862,64863,64864,64865,64866,64867,64868,64869,64870,64871,64872,64873,64874,64875,64876,64877,64878,64879,64880,64881,64882,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64894,64895,64896,64897,64898,64899,64900,64901,64902,64903,64904,64905,64906,64907,64908,64909,64910,64911,64914,64915,64916,64917,64918,64919,64920,64921,64922,64923,64924,64925,64926,64927,64928,64929,64930,64931,64932,64933,64934,64935,64936,64937,64938,64939,64940,64941,64942,64943,64944,64945,64946,64947,64948,64949,64950,64951,64952,64953,64954,64955,64956,64957,64958,64959,64960,64961,64962,64963,64964,64965,64966,64967,65008,65009,65010,65011,65012,65013,65014,65015,65016,65017,65018,65019,65020,65136,65137,65138,65139,65140,65142,65143,65144,65145,65146,65147,65148,65149,65150,65151,65152,65153,65154,65155,65156,65157,65158,65159,65160,65161,65162,65163,65164,65165,65166,65167,65168,65169,65170,65171,65172,65173,65174,65175,65176,65177,65178,65179,65180,65181,65182,65183,65184,65185,65186,65187,65188,65189,65190,65191,65192,65193,65194,65195,65196,65197,65198,65199,65200,65201,65202,65203,65204,65205,65206,65207,65208,65209,65210,65211,65212,65213,65214,65215,65216,65217,65218,65219,65220,65221,65222,65223,65224,65225,65226,65227,65228,65229,65230,65231,65232,65233,65234,65235,65236,65237,65238,65239,65240,65241,65242,65243,65244,65245,65246,65247,65248,65249,65250,65251,65252,65253,65254,65255,65256,65257,65258,65259,65260,65261,65262,65263,65264,65265,65266,65267,65268,65269,65270,65271,65272,65273,65274,65275,65276,67584,67585,67586,67587,67588,67589,67592,67594,67595,67596,67597,67598,67599,67600,67601,67602,67603,67604,67605,67606,67607,67608,67609,67610,67611,67612,67613,67614,67615,67616,67617,67618,67619,67620,67621,67622,67623,67624,67625,67626,67627,67628,67629,67630,67631,67632,67633,67634,67635,67636,67637,67639,67640,67644,67647,67648,67649,67650,67651,67652,67653,67654,67655,67656,67657,67658,67659,67660,67661,67662,67663,67664,67665,67666,67667,67668,67669,67671,67672,67673,67674,67675,67676,67677,67678,67679,67840,67841,67842,67843,67844,67845,67846,67847,67848,67849,67850,67851,67852,67853,67854,67855,67856,67857,67858,67859,67860,67861,67862,67863,67864,67865,67866,67867,67872,67873,67874,67875,67876,67877,67878,67879,67880,67881,67882,67883,67884,67885,67886,67887,67888,67889,67890,67891,67892,67893,67894,67895,67896,67897,67903,67968,67969,67970,67971,67972,67973,67974,67975,67976,67977,67978,67979,67980,67981,67982,67983,67984,67985,67986,67987,67988,67989,67990,67991,67992,67993,67994,67995,67996,67997,67998,67999,68e3,68001,68002,68003,68004,68005,68006,68007,68008,68009,68010,68011,68012,68013,68014,68015,68016,68017,68018,68019,68020,68021,68022,68023,68030,68031,68096,68112,68113,68114,68115,68117,68118,68119,68121,68122,68123,68124,68125,68126,68127,68128,68129,68130,68131,68132,68133,68134,68135,68136,68137,68138,68139,68140,68141,68142,68143,68144,68145,68146,68147,68160,68161,68162,68163,68164,68165,68166,68167,68176,68177,68178,68179,68180,68181,68182,68183,68184,68192,68193,68194,68195,68196,68197,68198,68199,68200,68201,68202,68203,68204,68205,68206,68207,68208,68209,68210,68211,68212,68213,68214,68215,68216,68217,68218,68219,68220,68221,68222,68223,68352,68353,68354,68355,68356,68357,68358,68359,68360,68361,68362,68363,68364,68365,68366,68367,68368,68369,68370,68371,68372,68373,68374,68375,68376,68377,68378,68379,68380,68381,68382,68383,68384,68385,68386,68387,68388,68389,68390,68391,68392,68393,68394,68395,68396,68397,68398,68399,68400,68401,68402,68403,68404,68405,68416,68417,68418,68419,68420,68421,68422,68423,68424,68425,68426,68427,68428,68429,68430,68431,68432,68433,68434,68435,68436,68437,68440,68441,68442,68443,68444,68445,68446,68447,68448,68449,68450,68451,68452,68453,68454,68455,68456,68457,68458,68459,68460,68461,68462,68463,68464,68465,68466,68472,68473,68474,68475,68476,68477,68478,68479,68608,68609,68610,68611,68612,68613,68614,68615,68616,68617,68618,68619,68620,68621,68622,68623,68624,68625,68626,68627,68628,68629,68630,68631,68632,68633,68634,68635,68636,68637,68638,68639,68640,68641,68642,68643,68644,68645,68646,68647,68648,68649,68650,68651,68652,68653,68654,68655,68656,68657,68658,68659,68660,68661,68662,68663,68664,68665,68666,68667,68668,68669,68670,68671,68672,68673,68674,68675,68676,68677,68678,68679,68680,126464,126465,126466,126467,126469,126470,126471,126472,126473,126474,126475,126476,126477,126478,126479,126480,126481,126482,126483,126484,126485,126486,126487,126488,126489,126490,126491,126492,126493,126494,126495,126497,126498,126500,126503,126505,126506,126507,126508,126509,126510,126511,126512,126513,126514,126516,126517,126518,126519,126521,126523,126530,126535,126537,126539,126541,126542,126543,126545,126546,126548,126551,126553,126555,126557,126559,126561,126562,126564,126567,126568,126569,126570,126572,126573,126574,126575,126576,126577,126578,126580,126581,126582,126583,126585,126586,126587,126588,126590,126592,126593,126594,126595,126596,126597,126598,126599,126600,126601,126603,126604,126605,126606,126607,126608,126609,126610,126611,126612,126613,126614,126615,126616,126617,126618,126619,126625,126626,126627,126629,126630,126631,126632,126633,126635,126636,126637,126638,126639,126640,126641,126642,126643,126644,126645,126646,126647,126648,126649,126650,126651,1114109];function _(){}function N(t,e,n){var r="undefined"!=typeof navigator&&/MSIE\s8\.0/.test(navigator.userAgent),i="rgba(255, 255, 255, 1)",o="rgba(0, 0, 0, 0.8)",s="";void 0!==T&&(i=T.fontSet,o=T.backgroundSet,s=T.edgeSet),r&&(i="rgb(255, 255, 255)",o="rgb(0, 0, 0)"),_.call(this),this.cue=e,this.cueDiv=O(t,e.text);var a={color:i,backgroundColor:o,textShadow:s,position:"relative",left:0,right:0,top:0,bottom:0,display:"inline"};r||(a.writingMode=""===e.vertical?"horizontal-tb":"lr"===e.vertical?"vertical-lr":"vertical-rl",a.unicodeBidi="plaintext"),this.applyStyles(a,this.cueDiv),this.div=t.document.createElement("div"),a={textAlign:"middle"===e.align?"center":e.align,font:n.font,whiteSpace:"pre-line",position:"absolute"},r||(a.direction=function(t){var e,n=[],r="";if(!t||!t.childNodes)return"ltr";function i(t,e){for(var n=e.childNodes.length-1;n>=0;n--)t.push(e.childNodes[n])}function o(t){if(!t||!t.length)return null;var e=t.pop(),n=e.textContent||e.innerText;if(n){var r=n.match(/^.*(\n|\r)/);return r?(t.length=0,r[0]):n}return"ruby"===e.tagName?o(t):e.childNodes?(i(t,e),o(t)):void 0}for(i(n,t);r=o(n);)for(var s=0;s=0&&t.line<=100))return t.line;if(!t.track||!t.track.textTrackList||!t.track.textTrackList.mediaElement)return-1;for(var e=t.track,n=e.textTrackList,r=0,i=0;iA&&(u=u<0?-1:1,u*=Math.ceil(A/c)*c),s<0&&(u+=""===o.vertical?n.height:n.width,a=a.reverse()),i.move(d,u)}else{var h=i.lineHeight/n.height*100;switch(o.lineAlign){case"middle":s-=h/2;break;case"end":s-=h}switch(o.vertical){case"":e.applyStyles({top:e.formatStyle(s,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(s,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(s,"%")})}a=["+y","-x","+x","-y"],i=new U(e)}var f=function(t,e){for(var i,o=new U(t),s=1,a=0;al&&(i=new U(t),s=l),t=new U(o)}return i||o}(i,a);e.move(f.toCSSCompatValues(n))}_.prototype.applyStyles=function(t,e){for(var n in e=e||this.div,t)t.hasOwnProperty(n)&&(e.style[n]=t[n])},_.prototype.formatStyle=function(t,e){return 0===t?0:t+e},N.prototype=S(_.prototype),N.prototype.constructor=N,U.prototype.move=function(t,e){switch(e=void 0!==e?e:this.lineHeight,t){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e}},U.prototype.overlaps=function(t){return this.leftt.left&&this.topt.top},U.prototype.overlapsAny=function(t){for(var e=0;e=t.top&&this.bottom<=t.bottom&&this.left>=t.left&&this.right<=t.right},U.prototype.overlapsOppositeAxis=function(t,e){switch(e){case"+x":return this.leftt.right;case"+y":return this.topt.bottom}},U.prototype.intersectPercentage=function(t){return Math.max(0,Math.min(this.right,t.right)-Math.max(this.left,t.left))*Math.max(0,Math.min(this.bottom,t.bottom)-Math.max(this.top,t.top))/(this.height*this.width)},U.prototype.toCSSCompatValues=function(t){return{top:this.top-t.top,bottom:t.bottom-this.bottom,left:this.left-t.left,right:t.right-this.right,height:this.height,width:this.width}},U.getSimpleBoxPosition=function(t){var e=t.div?t.div.offsetHeight:t.tagName?t.offsetHeight:0,n=t.div?t.div.offsetWidth:t.tagName?t.offsetWidth:0,r=t.div?t.div.offsetTop:t.tagName?t.offsetTop:0;return{left:(t=t.div?t.div.getBoundingClientRect():t.tagName?t.getBoundingClientRect():t).left,right:t.right,top:t.top||r,height:t.height||e,bottom:t.bottom||r+(t.height||e),width:t.width||n}},C.StringDecoder=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}},C.convertCueToDOMTree=function(t,e){return t&&e?O(t,e):null},C.processCues=function(t,e,n){if(!t||!e||!n)return null;for(;n.firstChild;)n.removeChild(n.firstChild);var r=t.document.createElement("div");if(r.style.position="absolute",r.style.left="0",r.style.right="0",r.style.top="0",r.style.bottom="0",r.style.margin="1.5%",n.appendChild(r),function(t){for(var e=0;e]*<[a-z]*/g,K=/]+?start[^=]*=[^0-9]*([0-9]*)["^0-9"]*/i,V=/]*>/gi,z=function(t,e){return e=(((e||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join(""),t.replace(/|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(function(t,n){return e.indexOf("<"+n.toLowerCase()+">")>-1?t:""}))},$=function(t){return t.sort((function(t,e){var n;return 0==(n=t.start-e.start)?t.end-e.end:n}))},X=function(){var t={},e=function(t){return t.map((function(t){return new g(t.start,t.end,t.text)}))};return t.load=function(t,n,r,i){fetch(t.file).then((function(t){t.ok?t.text().then((function(t){var i=[],o=[];if(t.indexOf("WEBVTT")>=0){OvenPlayerConsole.log("WEBVTT LOADED");var a=new G.Parser(window,G.StringDecoder());o=[],a.oncue=function(t){o.push(t)},a.onflush=function(){r(o)},a.parse(t)}else if(t.indexOf("SAMI")>=0){OvenPlayerConsole.log("SAMI LOADED");var l=function(t,e){var n,r,i,o,s,a,l,c,u,A;if(l=function(){var e,n,r,s,l,c,u,d,h,f,p,g,m,v,y,C;for(n=function(t){var n;return(n=new Error(t)).line=u,n.context=e,i.push(n)},u=1,h=[],m={},g=t;f=g.search(),!(d<=0||f<0);)d=g.slice(f+1).search(Y)+1,e=d>0?g.slice(f,f+d):g.slice(f),u+=(null!=(v=g.slice(0,f).match(j))?v.length:void 0)||0,H.test(e)&&n("ERROR_BROKEN_TAGS"),g=g.slice(f+d),(null===(p=+(null!=(y=e.match(K))?parseFloat(y[1]/1e3):void 0))||p<0)&&n("ERROR_INVALID_TIME"),(l=o(e))||n("ERROR_INVALID_LANGUAGE"),u+=(null!=(C=e.match(j))?C.length:void 0)||0,e=(e=e.replace(j,"")).replace(V,"\n"),s={start:p,text:"",contents:r=z(e).trim()},l&&(s.text=r),m[l]||(m[l]=[]),s.start&&m[l].push(s);A=A||function(){var t,e,n=window.navigator,r=["language","browserLanguage","systemLanguage","userLanguage"];if(Array.isArray(n.languages))for(t=0;t0&&(c=b.indexOf(A)>-1?m[A]:m[b.filter((function(t){return"undefined"!==t}))[0]],c=$(c),c=a(c),h=h.concat(c)),$(h)},o=function(t){var e,r;if(t)for(e in n)if((r=n[e]).reClassName.test(t))return r.lang},a=function(t){var e,n,i;for(e=t.length;e--;)n=t[e],null!=(i=t[e-1])&&(i.end=n.start),n.contents&&" "!==n.contents?(delete t[e].contents,n.end||(n.end=n.start+r)):t.splice(e,1);return t},i=[],n={KRCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KRCC)['\"S]?","i")},KOCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KOCC)['\"S]?","i")},KR:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KR)['\"S]?","i")},ENCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(ENCC)['\"S]?","i")},EGCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EGCC)['\"S]?","i")},EN:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EN)['\"S]?","i")},JPCC:{lang:"ja",reClassName:new RegExp("class[^=]*?=[\"'S]*(JPCC)['\"S]?","i")}},null!=e?e.definedLangs:void 0)for(s in u=e.definedLangs)c=u[s],n[s]=c;return r=(null!=e?e.duration:void 0)||10,A=e.fixedLang,t=t.trim(),{result:l(),errors:i}}(t,{fixedLang:n});o=e(l.result),r(o)}else OvenPlayerConsole.log("SRT LOADED"),i=function(t){var e=[],n=(t=s(t)).split("\r\n\r\n");1===n.length&&(n=t.split("\n\n"));for(var r=0;rGet Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Can not load due to dash.js. Please use the latest dash.js.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Error initializing DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Error initializing HLS.",reason:"Error initializing HLS."},300:{code:300,message:"Can not play due to unknown reasons.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Fetching process aborted by user.",reason:"Fetching process aborted by user."},302:{code:302,message:"Some of the media could not be downloaded due to a network error.",reason:"Error occurred when downloading."},303:{code:303,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"Error occurred when decoding."},304:{code:304,message:"Media playback has been canceled. It looks like your media is corrupted or your browser does not support the features your media uses.",reason:"Media playback not supported."},305:{code:305,message:"Can not load captions due to unknown reasons.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server refused the request."},308:{code:308,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server do not accept the request."},501:{code:501,message:"Connection with low-latency(OME) server failed.",reason:"WebSocket connection failed."},502:{code:502,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC internal error."},510:{code:510,message:"Network connection is unstable. Check the network connection.",reason:"Network is slow."},511:{code:511,message:"Connection with low-latency(OME) terminated unexpectedly.",reason:"Unexpected end of connection."},512:{code:512,message:"Connection with low-latency(OME) server failed.",reason:"Connection timeout."}}}},{lang:"ko",ui:{context:"오븐플레이어에 관하여",controls:{live:"라이브",low_latency_live:"초저지연 라이브",low_latency_p2p:"초저지연 P2P"},playlist:"플레이리스트",setting:{title:"설정",speed:"재생 속도",speedUnit:"x",source:"소스",quality:"품질",audioTrack:"오디오",caption:"자막",display:"표시"}},api:{message:{muted_play:"눌러서 소리 켜기"},error:{100:{code:100,message:"알 수 없는 이유로 로드 할 수 없습니다.",reason:"알 수 없는 이유로 로드 할 수 없습니다."},101:{code:101,message:"지원되는 미디어를 찾지 못해 로드 할 수 없습니다.",reason:"Can not load due to playable media not found."},102:{code:102,message:"플레시 로드가 중단 되었습니다.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"DashJS로 인해 로드 할 수 없습니다. 최신 dash.js를 사용해 주세요.",reason:"dash.js version is old."},104:{code:104,message:"Google IMA 라이브러리가 없어 로드 할 수 없습니다.",reason:"Please check the google ima library."},105:{code:105,message:"DASH 초기화 중 오류가 발생했습니다.",reason:"Error initializing DASH."},106:{code:106,message:"HLS 초기화 중 오류가 발생했습니다.",reason:"Error initializing HLS."},300:{code:300,message:"알 수 없는 이유로 재생할 수 없습니다.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"사용자에 의한 프로세스 중단.",reason:"Fetching process aborted by user."},302:{code:302,message:"네트워크 오류로 인해 일부 미디어를 다운로드 할 수 없습니다.",reason:"Error occurred when downloading."},303:{code:303,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"Error occurred when decoding."},304:{code:304,message:"미디어 재생이 취소되었습니다. 미디어가 손상되었거나 브라우저가 미디어에서 사용하는 기능을 지원하지 않는 것 같습니다.",reason:"Media playback not supported."},305:{code:305,message:"알 수 없는 이유로 자막을 로드 할 수 없습니다.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server cannot or will not process the request."},307:{code:307,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server refused the request."},308:{code:308,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server do not accept the request."},501:{code:501,message:"웹소켓 연결 실패",reason:"WebSocket connection failed."},502:{code:502,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC internal error."},510:{code:510,message:"네트워크 연결이 불안정합니다. 네트워크 연결을 확인하십시오.",reason:"Network is slow."},511:{code:511,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Unexpected end of connection."},512:{code:512,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Connection timeout."}}}},{lang:"pl",ui:{context:"O OvenPlayer",controls:{live:"Transmisja na żywo",low_latency_live:"Transmisja z niskim opóźnieniem",low_latency_p2p:"Transmisja z niskim opóźnieniem P2P"},playlist:"Playlista",setting:{title:"Ustawienia",speed:"Prędkość",speedUnit:"x",source:"Źrodło",quality:"Jakość",audioTrack:"Audio",caption:"Podtytuł",display:"Wyświetlacz"}},api:{message:{muted_play:"Naciśnij tutaj, aby aktywować dźwięk"},error:{100:{code:100,message:"Nie można załadować z nieznanego powodu.",reason:"Can not load due to unknown reasons."},101:{code:101,message:"Nie można załadować, ponieważ nie znaleziono multimediów, który można odtworzyć.",reason:"Can not load due to playable media not found."},102:{code:102,message:"Flash fetching process aborted.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Nie można załadować, ponieważ wersja dash.js jest za stara.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Nie można załadować, nie znaleziono DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Nie można załadować, nie znaleziono hlsjs.",reason:"Error initializing HLS"},300:{code:300,message:"Nie można odtworzyć z nieznanego powodu.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Proces pobierania przerwany przez użytkownika.",reason:"Fetching process aborted by user."},302:{code:302,message:"Nie udało się pobrać niektórych multimediów z powodu błędu sieci.",reason:"Error occurred when downloading."},303:{code:303,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"Error occurred when decoding."},304:{code:304,message:"Odtwarzanie zostało anulowane. Wygląda na to, że plik jest uszkodzony lub Twoja przeglądarka nie obsługuje tego pliku.",reason:"Media playback not supported."},305:{code:305,message:"Nie można wczytać napisów z nieznanego powodu.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server refused the request."},308:{code:308,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server do not accept the request."},501:{code:501,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebSocket connection failed."},502:{code:502,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC internal error."},510:{code:510,message:"Połączenie sieciowe jest niestabilne. Sprawdź swoją sieć.",reason:"Network is slow."},511:{code:511,message:"Połączenie z serwerem niskiego opóźnienia (OME) nieoczekiwanie zakończone.",reason:"Unexpected end of connection."},512:{code:512,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"Connection timeout."}}}}],Wt=function(t){return"subtitles"===t||"captions"===t},Yt=function(t){var e=t,n=[],r=function(t,e,n){var r=0,i=t.length;for(r=0;r1?n:n[0]};return(r=o().isElement(e)||o().every(e,(function(t){return o().isElement(t)}))?e:"document"===e?document:"window"===e?window:i(document,e))?(n.show=function(){r.style.display="block"},n.hide=function(){r.style.display="none"},n.addClass=function(t){r.classList?r.classList.add(t):-1===r.className.split(" ").indexOf(t)&&(r.className+=" "+t)},n.after=function(t){r.insertAdjacentHTML("afterend",t)},n.append=function(t){r.appendChild(t)},n.before=function(t){r.insertAdjacentHTML("beforebegin",t)},n.children=function(){return r.children||[]},n.contains=function(t){return r!==t&&r.contains(t)},n.empty=function(){r.innerHTML=""},n.find=function(e){return t(i(r,e))},n.css=function(t,e){if(!e)return r.style[t];r.length>0?r.forEach((function(n){n.style[t]=e})):r.style[t]=e},n.removeClass=function(t){r.classList?r.classList.remove(t):r.className=r.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")},n.removeAttribute=function(t){r.removeAttribute(t)},n.text=function(t){if(void 0===t)return r.textContent;r.textContent=t},n.html=function(t){r.innerHTML=t},n.hasClass=function(t){return r.classList?r.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(r.name)},n.is=function(t){return r===t},n.offset=function(){var t=r.getBoundingClientRect();return{top:t.top+document.body.scrollTop,left:t.left+document.body.scrollLeft}},n.width=function(){return r.clientWidth},n.height=function(){return r.clientHeight},n.attr=function(t){return r.getAttribute(t)},n.replace=function(t){r.replaceWith(t)},n.remove=function(){r.length>1?r.parentElement.removeChild(r):r.remove()},n.removeChild=function(t){if(t)r.removeChild(t);else for(;r.hasChildNodes();)r.removeChild(r.firstChild)},n.get=function(){return r},n.closest=function(e){r.closest=function(t){var e=r;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null};var n=r.closest(e);return n?t(n):null},n):null}),Ht=function(t,e){if(t)return 0==t.indexOf("rtmp:")||"rtmp"==e},Kt=function(t,e){return!!t&&(0===t.indexOf("ws:")||0===t.indexOf("wss:")||"webrtc"===e)},Vt=function(t,e){if(t)return"hls"===e||"m3u8"===e||"application/vnd.apple.mpegurl"===e||"m3u8"==a(t)},zt=function(t,e){if(t)return"mpd"===e||"dash"===e||"application/dash+xml"===e||"mpd"==a(t)},$t=function(t){if(!t)return null;var e=null;if("string"==typeof t)e=document.getElementById(t);else{if(!t.nodeType)return null;e=t}return e},Xt=function(){var t={};OvenPlayerConsole.log("SupportChecker loaded.");var e=W(),n=[{name:"html5",checkSupport:function(t){var n=document.createElement("video");if(!n.canPlayType)return!1;var r=t.file,i=t.type;if(!i)return!1;var o=t.mimeType||{aac:"audio/mp4",mp4:"video/mp4",f4v:"video/mp4",m4v:"video/mp4",mov:"video/mp4",mp3:"audio/mpeg",mpeg:"audio/mpeg",ogv:"video/ogg",ogg:"video/ogg",oga:"video/ogg",vorbis:"video/ogg",webm:"video/webm",f4a:"video/aac",m3u8:"application/vnd.apple.mpegurl",m3u:"application/vnd.apple.mpegurl",hls:"application/vnd.apple.mpegurl"}[i];return!(Vt(r,i)&&("Microsoft Edge"===e.browser||"Android"===e.os)||Ht(r,i)||Kt(r,i)||!o||!n.canPlayType(o))}},{name:"webrtc",checkSupport:function(t){if(!document.createElement("video").canPlayType)return!1;if(Ht(e,n))return!1;var e=t.file,n=t.type;return!!Kt(e,n)}},{name:"dash",checkSupport:function(t){var e=t.file,n=t.type;return!Ht(e,n)&&!("function"!=typeof(window.MediaSource||window.WebKitMediaSource)||!zt(e,n))}},{name:"hls",checkSupport:function(t){document.createElement("video");var e,n,r,i,o=t.file,s=t.type;return!Ht(o,s)&&(e=function(){if("undefined"!=typeof window)return window.MediaSource||window.WebKitMediaSource}(),n=window.SourceBuffer||window.WebKitSourceBuffer,r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!n||n.prototype&&"function"==typeof n.prototype.appendBuffer&&"function"==typeof n.prototype.remove,!!r&&!!i)}},{name:"rtmp",checkSupport:function(t){var n=t.file,r=t.type;return!(!Ht(n,r)||!function(){var t=!1;if("ActiveXObject"in window)try{t=!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(e){t=!1}else t=!!navigator.mimeTypes["application/x-shockwave-flash"];return t}()||"Microsoft Edge"===e.browser||"Android"===e.os||"iOS"===e.os||"Safari"===e.browser)}}];return t.findProviderNameBySource=function(t){OvenPlayerConsole.log("SupportChecker : findProviderNameBySource()",t);for(var e=t===Object(t)?t:{},r=0;r0&&void 0!==arguments[0]?arguments[0]:{};ce(this,t),this.id=e.id||null,this.adId=e.adId||null,this.sequence=e.sequence||null,this.apiFramework=e.apiFramework||null,this.trackingEvents={}})),pe=function(t){ne(n,t);var e=ie(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ce(this,n),(t=e.call(this,r)).type="companion",t.variations=[],t}return le(n)}(fe);function ge(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[];for(var r in e.ASSETURI&&(e.ASSETURI=me(e.ASSETURI)),e.CONTENTPLAYHEAD&&(e.CONTENTPLAYHEAD=me(e.CONTENTPLAYHEAD)),e.ERRORCODE&&!/^[0-9]{3}$/.test(e.ERRORCODE)&&(e.ERRORCODE=900),e.CACHEBUSTING=ve(Math.round(1e8*Math.random()).toString()),e.TIMESTAMP=me((new Date).toISOString()),e.RANDOM=e.random=e.CACHEBUSTING,t){var i=t[r];if("string"==typeof i){for(var o in e){var s=e[o],a="[".concat(o,"]"),l="%%".concat(o,"%%");i=(i=i.replace(a,s)).replace(l,s)}n.push(i)}}return n}function me(t){return encodeURIComponent(t).replace(/[!'()*]/g,(function(t){return"%".concat(t.charCodeAt(0).toString(16))}))}function ve(t){return t.length<8?ye(0,8-t.length,!1).map((function(t){return"0"})).join("")+t:t}function ye(t,e,n){for(var r=[],i=to;i?s++:s--)r.push(s);return r}var Ce={track:function(t,e){ge(t,e).forEach((function(t){"undefined"!=typeof window&&null!==window&&((new Image).src=t)}))},resolveURLTemplates:ge,encodeURIComponentRFC3986:me,leftpad:ve,range:ye,isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},flatten:function t(e){return e.reduce((function(e,n){return e.concat(Array.isArray(n)?t(n):n)}),[])}},be=function(t,e){var n=t.childNodes;for(var r in n){var i=n[r];if(i.nodeName===e)return i}},Ee=function(t,e){var n=[],r=t.childNodes;for(var i in r){var o=r[i];o.nodeName===e&&n.push(o)}return n},we=function(t,e){if(!e)return t;if(0===t.indexOf("//")){var n=location.protocol;return"".concat(n).concat(t)}return-1===t.indexOf("://")?"".concat(e.slice(0,e.lastIndexOf("/")),"/").concat(t):t},Te=function(t){return-1!==["true","TRUE","1"].indexOf(t)},Se=function(t){return t&&(t.textContent||t.text||"").trim()},ke=function(t,e,n){var r=e.getAttribute(t);r&&n.setAttribute(t,r)},Le=function(t){if(null==t)return-1;if(Ce.isNumeric(t))return parseInt(t);var e=t.split(":");if(3!==e.length)return-1;var n=e[2].split("."),r=parseInt(n[0]);2===n.length&&(r+=parseFloat("0.".concat(n[1])));var i=parseInt(60*e[1]),o=parseInt(60*e[0]*60);return isNaN(o)||isNaN(i)||isNaN(r)||i>3600||r>60?-1:o+i+r},xe=function(t){var e=[],n=null;return t.forEach((function(r,i){if(r.sequence&&(r.sequence=parseInt(r.sequence,10)),r.sequence>1){var o=t[i-1];if(o&&o.sequence===r.sequence-1)return void(n&&n.push(r));delete r.sequence}n=[r],e.push(n)})),e},Ie=function(t,e){t.errorURLTemplates=e.errorURLTemplates.concat(t.errorURLTemplates),t.impressionURLTemplates=e.impressionURLTemplates.concat(t.impressionURLTemplates),t.extensions=e.extensions.concat(t.extensions),t.creatives.forEach((function(t){if(e.trackingEvents&&e.trackingEvents[t.type])for(var n in e.trackingEvents[t.type]){var r=e.trackingEvents[t.type][n];t.trackingEvents[n]||(t.trackingEvents[n]=[]),t.trackingEvents[n]=t.trackingEvents[n].concat(r)}})),e.videoClickTrackingURLTemplates&&e.videoClickTrackingURLTemplates.length&&t.creatives.forEach((function(t){"linear"===t.type&&(t.videoClickTrackingURLTemplates=t.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates))})),e.videoCustomClickURLTemplates&&e.videoCustomClickURLTemplates.length&&t.creatives.forEach((function(t){"linear"===t.type&&(t.videoCustomClickURLTemplates=t.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates))})),e.videoClickThroughURLTemplate&&t.creatives.forEach((function(t){"linear"===t.type&&null==t.videoClickThroughURLTemplate&&(t.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate)}))};function Re(t,e){var n=new pe(e);return Ee(t,"Companion").forEach((function(t){var e=new he;e.id=t.getAttribute("id")||null,e.width=t.getAttribute("width"),e.height=t.getAttribute("height"),e.companionClickTrackingURLTemplates=[],Ee(t,"HTMLResource").forEach((function(t){e.type=t.getAttribute("creativeType")||"text/html",e.htmlResource=Se(t)})),Ee(t,"IFrameResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.iframeResource=Se(t)})),Ee(t,"StaticResource").forEach((function(n){e.type=n.getAttribute("creativeType")||0,Ee(t,"AltText").forEach((function(t){e.altText=Se(t)})),e.staticResource=Se(n)})),Ee(t,"TrackingEvents").forEach((function(t){Ee(t,"Tracking").forEach((function(t){var n=t.getAttribute("event"),r=Se(t);n&&r&&(null==e.trackingEvents[n]&&(e.trackingEvents[n]=[]),e.trackingEvents[n].push(r))}))})),Ee(t,"CompanionClickTracking").forEach((function(t){e.companionClickTrackingURLTemplates.push(Se(t))})),e.companionClickThroughURLTemplate=Se(be(t,"CompanionClickThrough")),e.companionClickTrackingURLTemplate=Se(be(t,"CompanionClickTracking")),n.variations.push(e)})),n}var De=function(t){ne(n,t);var e=ie(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ce(this,n),(t=e.call(this,r)).type="linear",t.duration=0,t.skipDelay=null,t.mediaFiles=[],t.videoClickThroughURLTemplate=null,t.videoClickTrackingURLTemplates=[],t.videoCustomClickURLTemplates=[],t.adParameters=null,t.icons=[],t}return le(n)}(fe),Be=le((function t(){ce(this,t),this.program=null,this.height=0,this.width=0,this.xPosition=0,this.yPosition=0,this.apiFramework=null,this.offset=null,this.duration=0,this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.iconClickThroughURLTemplate=null,this.iconClickTrackingURLTemplates=[],this.iconViewTrackingURLTemplate=null})),Pe=le((function t(){ce(this,t),this.id=null,this.fileURL=null,this.deliveryType="progressive",this.mimeType=null,this.codec=null,this.bitrate=0,this.minBitrate=0,this.maxBitrate=0,this.width=0,this.height=0,this.apiFramework=null,this.scalable=null,this.maintainAspectRatio=null}));function Me(t,e){var n,r=new De(e);r.duration=Le(Se(be(t,"Duration")));var i=t.getAttribute("skipoffset");if(null==i)r.skipDelay=null;else if("%"===i.charAt(i.length-1)&&-1!==r.duration){var o=parseInt(i,10);r.skipDelay=r.duration*(o/100)}else r.skipDelay=Le(i);var s=be(t,"VideoClicks");s&&(r.videoClickThroughURLTemplate=Se(be(s,"ClickThrough")),Ee(s,"ClickTracking").forEach((function(t){r.videoClickTrackingURLTemplates.push(Se(t))})),Ee(s,"CustomClick").forEach((function(t){r.videoCustomClickURLTemplates.push(Se(t))})));var a=be(t,"AdParameters");a&&(r.adParameters=Se(a)),Ee(t,"TrackingEvents").forEach((function(t){Ee(t,"Tracking").forEach((function(t){var e=t.getAttribute("event"),i=Se(t);if(e&&i){if("progress"===e){if(!(n=t.getAttribute("offset")))return;e="%"===n.charAt(n.length-1)?"progress-".concat(n):"progress-".concat(Math.round(Le(n)))}null==r.trackingEvents[e]&&(r.trackingEvents[e]=[]),r.trackingEvents[e].push(i)}}))})),Ee(t,"MediaFiles").forEach((function(t){Ee(t,"MediaFile").forEach((function(t){var e=new Pe;e.id=t.getAttribute("id"),e.fileURL=Se(t),e.deliveryType=t.getAttribute("delivery"),e.codec=t.getAttribute("codec"),e.mimeType=t.getAttribute("type"),e.apiFramework=t.getAttribute("apiFramework"),e.bitrate=parseInt(t.getAttribute("bitrate")||0),e.minBitrate=parseInt(t.getAttribute("minBitrate")||0),e.maxBitrate=parseInt(t.getAttribute("maxBitrate")||0),e.width=parseInt(t.getAttribute("width")||0),e.height=parseInt(t.getAttribute("height")||0);var n=t.getAttribute("scalable");n&&"string"==typeof n&&("true"===(n=n.toLowerCase())?e.scalable=!0:"false"===n&&(e.scalable=!1));var i=t.getAttribute("maintainAspectRatio");i&&"string"==typeof i&&("true"===(i=i.toLowerCase())?e.maintainAspectRatio=!0:"false"===i&&(e.maintainAspectRatio=!1)),r.mediaFiles.push(e)}))}));var l=be(t,"Icons");return l&&Ee(l,"Icon").forEach((function(t){var e=new Be;e.program=t.getAttribute("program"),e.height=parseInt(t.getAttribute("height")||0),e.width=parseInt(t.getAttribute("width")||0),e.xPosition=function(t){return-1!==["left","right"].indexOf(t)?t:parseInt(t||0)}(t.getAttribute("xPosition")),e.yPosition=function(t){return-1!==["top","bottom"].indexOf(t)?t:parseInt(t||0)}(t.getAttribute("yPosition")),e.apiFramework=t.getAttribute("apiFramework"),e.offset=Le(t.getAttribute("offset")),e.duration=Le(t.getAttribute("duration")),Ee(t,"HTMLResource").forEach((function(t){e.type=t.getAttribute("creativeType")||"text/html",e.htmlResource=Se(t)})),Ee(t,"IFrameResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.iframeResource=Se(t)})),Ee(t,"StaticResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.staticResource=Se(t)}));var n=be(t,"IconClicks");n&&(e.iconClickThroughURLTemplate=Se(be(n,"IconClickThrough")),Ee(n,"IconClickTracking").forEach((function(t){e.iconClickTrackingURLTemplates.push(Se(t))}))),e.iconViewTrackingURLTemplate=Se(be(t,"IconViewTracking")),r.icons.push(e)})),r}var Oe,Fe=function(t){ne(n,t);var e=ie(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ce(this,n),(t=e.call(this,r)).type="nonlinear",t.variations=[],t}return le(n)}(fe),_e=le((function t(){ce(this,t),this.id=null,this.width=0,this.height=0,this.expandedWidth=0,this.expandedHeight=0,this.scalable=!0,this.maintainAspectRatio=!0,this.minSuggestedDuration=0,this.apiFramework="static",this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.nonlinearClickThroughURLTemplate=null,this.nonlinearClickTrackingURLTemplates=[],this.adParameters=null}));function Ne(t,e){var n=new Fe(e);return Ee(t,"TrackingEvents").forEach((function(t){var e,r;Ee(t,"Tracking").forEach((function(t){e=t.getAttribute("event"),r=Se(t),e&&r&&(null==n.trackingEvents[e]&&(n.trackingEvents[e]=[]),n.trackingEvents[e].push(r))}))})),Ee(t,"NonLinear").forEach((function(t){var e=new _e;e.id=t.getAttribute("id")||null,e.width=t.getAttribute("width"),e.height=t.getAttribute("height"),e.expandedWidth=t.getAttribute("expandedWidth"),e.expandedHeight=t.getAttribute("expandedHeight"),e.scalable=Te(t.getAttribute("scalable")),e.maintainAspectRatio=Te(t.getAttribute("maintainAspectRatio")),e.minSuggestedDuration=Le(t.getAttribute("minSuggestedDuration")),e.apiFramework=t.getAttribute("apiFramework"),Ee(t,"HTMLResource").forEach((function(t){e.type=t.getAttribute("creativeType")||"text/html",e.htmlResource=Se(t)})),Ee(t,"IFrameResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.iframeResource=Se(t)})),Ee(t,"StaticResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.staticResource=Se(t)}));var r=be(t,"AdParameters");r&&(e.adParameters=Se(r)),e.nonlinearClickThroughURLTemplate=Se(be(t,"NonLinearClickThrough")),Ee(t,"NonLinearClickTracking").forEach((function(t){e.nonlinearClickTrackingURLTemplates.push(Se(t))})),n.variations.push(e)})),n}function Ue(t){var e=t.childNodes;for(var n in e){var r=e[n];if(-1!==["Wrapper","InLine"].indexOf(r.nodeName)){if(ke("id",t,r),ke("sequence",t,r),"Wrapper"===r.nodeName)return Ge(r);if("InLine"===r.nodeName)return Qe(r)}}}function Qe(t){var e=t.childNodes,n=new ue;for(var r in n.id=t.getAttribute("id")||null,n.sequence=t.getAttribute("sequence")||null,e){var i=e[r];switch(i.nodeName){case"Error":n.errorURLTemplates.push(Se(i));break;case"Impression":n.impressionURLTemplates.push(Se(i));break;case"Creatives":Ee(i,"Creative").forEach((function(t){var e={id:t.getAttribute("id")||null,adId:Ye(t),sequence:t.getAttribute("sequence")||null,apiFramework:t.getAttribute("apiFramework")||null};for(var r in t.childNodes){var i=t.childNodes[r];switch(i.nodeName){case"Linear":var o=Me(i,e);o&&n.creatives.push(o);break;case"NonLinearAds":var s=Ne(i,e);s&&n.creatives.push(s);break;case"CompanionAds":var a=Re(i,e);a&&n.creatives.push(a)}}}));break;case"Extensions":We(n.extensions,Ee(i,"Extension"));break;case"AdSystem":n.system={value:Se(i),version:i.getAttribute("version")||null};break;case"AdTitle":n.title=Se(i);break;case"Description":n.description=Se(i);break;case"Advertiser":n.advertiser=Se(i);break;case"Pricing":n.pricing={value:Se(i),model:i.getAttribute("model")||null,currency:i.getAttribute("currency")||null};break;case"Survey":n.survey=Se(i)}}return n}function Ge(t){var e=Qe(t),n=be(t,"VASTAdTagURI");if(n?e.nextWrapperURL=Se(n):(n=be(t,"VASTAdTagURL"))&&(e.nextWrapperURL=Se(be(n,"URL"))),e.creatives.forEach((function(t){if(-1!==["linear","nonlinear"].indexOf(t.type)){if(t.trackingEvents){e.trackingEvents||(e.trackingEvents={}),e.trackingEvents[t.type]||(e.trackingEvents[t.type]={});var n=function(n){var r=t.trackingEvents[n];e.trackingEvents[t.type][n]||(e.trackingEvents[t.type][n]=[]),r.forEach((function(r){e.trackingEvents[t.type][n].push(r)}))};for(var r in t.trackingEvents)n(r)}t.videoClickTrackingURLTemplates&&(e.videoClickTrackingURLTemplates||(e.videoClickTrackingURLTemplates=[]),t.videoClickTrackingURLTemplates.forEach((function(t){e.videoClickTrackingURLTemplates.push(t)}))),t.videoClickThroughURLTemplate&&(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate),t.videoCustomClickURLTemplates&&(e.videoCustomClickURLTemplates||(e.videoCustomClickURLTemplates=[]),t.videoCustomClickURLTemplates.forEach((function(t){e.videoCustomClickURLTemplates.push(t)})))}})),e.nextWrapperURL)return e}function We(t,e){e.forEach((function(e){var n=new Ae,r=e.attributes,i=e.childNodes;if(e.attributes)for(var o in r){var s=r[o];s.nodeName&&s.nodeValue&&(n.attributes[s.nodeName]=s.nodeValue)}for(var a in i){var l=i[a],c=Se(l);if("#comment"!==l.nodeName&&""!==c){var u=new de;if(u.name=l.nodeName,u.value=c,l.attributes){var A=l.attributes;for(var d in A){var h=A[d];u.attributes[h.nodeName]=h.nodeValue}}n.children.push(u)}}t.push(n)}))}function Ye(t){return t.getAttribute("AdID")||t.getAttribute("adID")||t.getAttribute("adId")||null}function je(){}function He(){He.init.call(this)}function Ke(t){return void 0===t._maxListeners?He.defaultMaxListeners:t._maxListeners}function Ve(t,e,n){if(e)t.call(n);else for(var r=t.length,i=en(t,r),o=0;o0&&s.length>i){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,function(t){"function"==typeof console.warn?console.warn(t):console.log(t)}(a)}}else s=o[e]=n,++t._eventsCount;return t}function Ze(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function tn(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function en(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}je.prototype=Object.create(null),He.EventEmitter=He,He.usingDomains=!1,He.prototype.domain=void 0,He.prototype._events=void 0,He.prototype._maxListeners=void 0,He.defaultMaxListeners=10,He.init=function(){this.domain=null,He.usingDomains&&(!Oe.active||this instanceof Oe.Domain||(this.domain=Oe.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new je,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},He.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},He.prototype.getMaxListeners=function(){return Ke(this)},He.prototype.emit=function(t){var e,n,r,i,o,s,a,l="error"===t;if(s=this._events)l=l&&null==s.error;else if(!l)return!1;if(a=this.domain,l){if(e=arguments[1],!a){if(e instanceof Error)throw e;var c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=s[t]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:Ve(n,u,this);break;case 2:ze(n,u,this,arguments[1]);break;case 3:$e(n,u,this,arguments[1],arguments[2]);break;case 4:Xe(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o0;)if(n[o]===e||n[o].listener&&n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new je,this;delete r[t]}else!function(t,e){for(var n=e,r=n+1,i=t.length;r0?Reflect.ownKeys(this._events):[]};var nn=function(t,e,n){var r="function"==typeof window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLDOM"):void 0;if(!r)return n(new Error("FlashURLHandler: Microsoft.XMLDOM format not supported"));r.async=!1,request.open("GET",t),request.timeout=e.timeout||0,request.withCredentials=e.withCredentials||!1,request.send(),request.onprogress=function(){},request.onload=function(){r.loadXML(request.responseText),n(null,r)}},rn=function(){return window.XDomainRequest&&(t=new XDomainRequest),!!t;var t},on=function(t,e,n){n(new Error("Please bundle the library for node to use the node urlHandler"))};function sn(){try{var t=new window.XMLHttpRequest;return"withCredentials"in t?t:null}catch(t){return console.log("Error in XHRURLHandler support check:",t),null}}var an=function(t,e,n){if("https:"===window.location.protocol&&0===t.indexOf("http://"))return n(new Error("XHRURLHandler: Cannot go from HTTPS to HTTP."));try{var r=sn();r.open("GET",t),r.timeout=e.timeout||0,r.withCredentials=e.withCredentials||!1,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.onreadystatechange=function(){4===r.readyState&&(200===r.status?n(null,r.responseXML):n(new Error("XHRURLHandler: ".concat(r.statusText))))},r.send()}catch(t){n(new Error("XHRURLHandler: Unexpected error"))}},ln=function(){return!!sn()},cn={get:function(t,e,n){return n||("function"==typeof e&&(n=e),e={}),"undefined"==typeof window||null===window?on(t,e,n):ln()?an(t,e,n):rn()?nn(t,e,n):n(new Error("Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler"))}},un=le((function t(){ce(this,t),this.ads=[],this.errorURLTemplates=[]})),An={ERRORCODE:900,extensions:[]},dn=function(t){ne(n,t);var e=ie(n);function n(){var t;return ce(this,n),(t=e.call(this)).remainingAds=[],t.parentURLs=[],t.errorURLTemplates=[],t.rootErrorURLTemplates=[],t.maxWrapperDepth=null,t.URLTemplateFilters=[],t.fetchingOptions={},t}return le(n,[{key:"addURLTemplateFilter",value:function(t){"function"==typeof t&&this.URLTemplateFilters.push(t)}},{key:"removeURLTemplateFilter",value:function(){this.URLTemplateFilters.pop()}},{key:"countURLTemplateFilters",value:function(){return this.URLTemplateFilters.length}},{key:"clearURLTemplateFilters",value:function(){this.URLTemplateFilters=[]}},{key:"trackVastError",value:function(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:{};this.rootURL="",this.remainingAds=[],this.parentURLs=[],this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.maxWrapperDepth=t.wrapperLimit||10,this.fetchingOptions={timeout:t.timeout,withCredentials:t.withCredentials},this.urlHandler=t.urlhandler||cn}},{key:"getRemainingAds",value:function(t){var e=this;if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));var n=t?Ce.flatten(this.remainingAds):this.remainingAds.shift();return this.errorURLTemplates=[],this.parentURLs=[],this.resolveAds(n,{wrapperDepth:0,originalUrl:this.rootURL}).then((function(t){return e.buildVASTResponse(t)}))}},{key:"getAndParseVAST",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),this.rootURL=t,this.fetchVAST(t).then((function(r){return n.originalUrl=t,n.isRootVAST=!0,e.parse(r,n).then((function(t){return e.buildVASTResponse(t)}))}))}},{key:"parseVAST",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),n.isRootVAST=!0,this.parse(t,n).then((function(t){return e.buildVASTResponse(t)}))}},{key:"buildVASTResponse",value:function(t){var e=new un;return e.ads=t,e.errorURLTemplates=this.getErrorURLTemplates(),this.completeWrapperResolving(e),e}},{key:"parse",value:function(t,e){var n=e.resolveAll,r=void 0===n||n,i=e.wrapperSequence,o=void 0===i?null:i,s=e.originalUrl,a=void 0===s?null:s,l=e.wrapperDepth,c=void 0===l?0:l,u=e.isRootVAST,A=void 0!==u&&u;if(!t||!t.documentElement||"VAST"!==t.documentElement.nodeName)return Promise.reject(new Error("Invalid VAST XMLDocument"));var d=[],h=t.documentElement.childNodes;for(var f in h){var p=h[f];if("Error"===p.nodeName){var g=Se(p);A?this.rootErrorURLTemplates.push(g):this.errorURLTemplates.push(g)}if("Ad"===p.nodeName){var m=Ue(p);m?d.push(m):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}var v=d.length,y=d[v-1];return 1===v&&null!=o&&y&&!y.sequence&&(y.sequence=o),!1===r&&(this.remainingAds=xe(d),d=this.remainingAds.shift()),this.resolveAds(d,{wrapperDepth:c,originalUrl:a})}},{key:"resolveAds",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,r=n.wrapperDepth,i=n.originalUrl,o=[];return e.forEach((function(e){var n=t.resolveWrappers(e,r,i);o.push(n)})),Promise.all(o).then((function(e){var n=Ce.flatten(e);if(!n&&t.remainingAds.length>0){var o=t.remainingAds.shift();return t.resolveAds(o,{wrapperDepth:r,originalUrl:i})}return n}))}},{key:"resolveWrappers",value:function(t,e,n){var r=this;return new Promise((function(i,o){if(e++,!t.nextWrapperURL)return delete t.nextWrapperURL,i(t);if(e>=r.maxWrapperDepth||-1!==r.parentURLs.indexOf(t.nextWrapperURL))return t.errorCode=302,delete t.nextWrapperURL,i(t);t.nextWrapperURL=we(t.nextWrapperURL,n);var s=t.sequence;n=t.nextWrapperURL,r.fetchVAST(t.nextWrapperURL,e,n).then((function(o){return r.parse(o,{originalUrl:n,wrapperSequence:s,wrapperDepth:e}).then((function(e){if(delete t.nextWrapperURL,0===e.length)return t.creatives=[],i(t);e.forEach((function(e){e&&Ie(e,t)})),i(e)}))})).catch((function(e){t.errorCode=301,t.errorMessage=e.message,i(t)}))}))}},{key:"completeWrapperResolving",value:function(t){if(0===t.ads.length)this.trackVastError(t.errorURLTemplates,{ERRORCODE:303});else for(var e=t.ads.length-1;e>=0;e--){var n=t.ads[e];(n.errorCode||0===n.creatives.length)&&(this.trackVastError(n.errorURLTemplates.concat(t.errorURLTemplates),{ERRORCODE:n.errorCode||303},{ERRORMESSAGE:n.errorMessage||""},{extensions:n.extensions},{system:n.system}),t.ads.splice(e,1))}}}]),n}(He),hn=null,fn={data:{},length:0,getItem:function(t){return this.data[t]},setItem:function(t,e){this.data[t]=e,this.length=Object.keys(this.data).length},removeItem:function(t){delete data[t],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},pn=function(){function t(){ce(this,t),this.storage=this.initStorage()}return le(t,[{key:"initStorage",value:function(){if(hn)return hn;try{hn="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(t){hn=null}return hn&&!this.isStorageDisabled(hn)||(hn=fn).clear(),hn}},{key:"isStorageDisabled",value:function(t){var e="__VASTStorage__";try{if(t.setItem(e,e),t.getItem(e)!==e)return t.removeItem(e),!0}catch(t){return!0}return t.removeItem(e),!1}},{key:"getItem",value:function(t){return this.storage.getItem(t)}},{key:"setItem",value:function(t,e){return this.storage.setItem(t,e)}},{key:"removeItem",value:function(t){return this.storage.removeItem(t)}},{key:"clear",value:function(){return this.storage.clear()}}]),t}(),gn=function(){function t(e,n,r){ce(this,t),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=n||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new dn,this.storage=r||new pn,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return le(t,[{key:"getParser",value:function(){return this.vastParser}},{key:"lastSuccessfulAd",get:function(){return this.storage.getItem("vast-client-last-successful-ad")},set:function(t){this.storage.setItem("vast-client-last-successful-ad",t)}},{key:"totalCalls",get:function(){return this.storage.getItem("vast-client-total-calls")},set:function(t){this.storage.setItem("vast-client-total-calls",t)}},{key:"totalCallsTimeout",get:function(){return this.storage.getItem("vast-client-total-calls-timeout")},set:function(t){this.storage.setItem("vast-client-total-calls-timeout",t)}},{key:"hasRemainingAds",value:function(){return this.vastParser.remainingAds.length>0}},{key:"getNextAds",value:function(t){return this.vastParser.getRemainingAds(t)}},{key:"get",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Date.now();return(n=Object.assign(this.defaultOptions,n)).hasOwnProperty("resolveAll")||(n.resolveAll=!1),this.totalCallsTimeout=e.totalCalls)return o(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(e.totalCalls,"/").concat(e.cappingFreeLunch)));var s=r-e.lastSuccessfulAd;if(s<0)e.lastSuccessfulAd=0;else if(s3&&void 0!==arguments[3]?arguments[3]:null;for(var a in ce(this,n),(o=e.call(this)).ad=r,o.creative=i,o.variation=s,o.muted=!1,o.impressed=!1,o.skippable=!1,o.trackingEvents={},o._alreadyTriggeredQuartiles={},o.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],o.creative.trackingEvents){var l=o.creative.trackingEvents[a];o.trackingEvents[a]=l.slice(0)}return o.creative instanceof De?o._initLinearTracking():o._initVariationTracking(),t&&o.on("start",(function(){t.lastSuccessfulAd=Date.now()})),o}return le(n,[{key:"_initLinearTracking",value:function(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}},{key:"_initVariationTracking",value:function(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(var t in this.variation.trackingEvents){var e=this.variation.trackingEvents[t];this.trackingEvents[t]?this.trackingEvents[t]=this.trackingEvents[t].concat(e.slice(0)):this.trackingEvents[t]=e.slice(0)}this.variation instanceof _e?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):this.variation instanceof he&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}},{key:"setDuration",value:function(t){this.assetDuration=t,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}}},{key:"setProgress",value:function(t){var e=this,n=this.skipDelay||-1;if(-1===n||this.skippable||(n>t?this.emit("skip-countdown",n-t):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){var r=[];if(t>0){var i=Math.round(t/this.assetDuration*100);for(var o in r.push("start"),r.push("progress-".concat(i,"%")),r.push("progress-".concat(Math.round(t))),this.quartiles)this.isQuartileReached(o,this.quartiles[o],t)&&(r.push(o),this._alreadyTriggeredQuartiles[o]=!0)}r.forEach((function(t){e.track(t,!0)})),t0&&void 0!==arguments[0]?arguments[0]:null;this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates);var e=this.clickThroughURLTemplate||t;if(e){var n=this.linear?{CONTENTPLAYHEAD:this.progressFormatted()}:{},r=Ce.resolveURLTemplates([e],n)[0];this.emit("clickthrough",r)}}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"closeLinear"===t&&!this.trackingEvents[t]&&this.trackingEvents.close&&(t="close");var n=this.trackingEvents[t],r=this.emitAlwaysEvents.indexOf(t)>-1;n?(this.emit(t,""),this.trackURLs(n)):r&&this.emit(t,""),e&&(delete this.trackingEvents[t],r&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(t),1))}},{key:"trackURLs",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(e.ASSETURI=this.creative.mediaFiles[0].fileURL),e.CONTENTPLAYHEAD=this.progressFormatted()),Ce.track(t,e)}},{key:"progressFormatted",value:function(){var t=parseInt(this.progress),e=t/3600;e.length<2&&(e="0".concat(e));var n=t/60%60;n.length<2&&(n="0".concat(n));var r=t%60;return r.length<2&&(r="0".concat(n)),"".concat(e,":").concat(n,":").concat(r,".").concat(parseInt(100*(this.progress-t)))}}]),n}(He),vn=function(t,e,n,r){var i,o={},s={started:!1,active:!1,isVideoEnded:!1,lang:n.getLanguage()},a=null,l="",c=null,u="",A="",d=!1,h=n.getBrowser(),f="Android"===h.os||"iOS"===h.os;(i=document.createElement("div")).setAttribute("class","op-ads"),i.setAttribute("id","op-ads"),n.getContainer().append(i),(c=document.createElement("video")).setAttribute("playsinline","true"),c.setAttribute("title","Advertisement"),c.setAttribute("class","op-ads-vast-video"),(A=document.createElement("div")).setAttribute("class","op-ads-button"),(u=document.createElement("div")).setAttribute("class","op-ads-textview"),A.append(u),i.append(c),i.append(A),l=i;var p=new gn,g=null,m=null,v=function(t){console.log(t),c.style.display="none",e.trigger(lt,{code:t.code,message:t.message}),s.active=!1,s.started=!0,e.play()};return o.isActive=function(){return s.active},o.started=function(){return s.started},o.play=function(){return s.started?c.play():new Promise((function(i,o){!function l(){e.metaLoaded()?(OvenPlayerConsole.log("VAST : main contents meta loaded."),function(){OvenPlayerConsole.log("VAST : checkAutoplaySupport() ");var n=document.createElement("video");n.setAttribute("playsinline","true"),n.src=qt,n.load(),c.load(),f&&e.getName()!==At&&t.load();var r=function(t,e){d=t,n.pause(),n.remove()};return new Promise((function(t,e){if(n.play){var i=n.play();void 0!==i?i.then((function(){OvenPlayerConsole.log("VAST : auto play allowed."),r(!0),t()})).catch((function(e){OvenPlayerConsole.log("VAST : auto play failed",e.message),r(!1),t()})):(OvenPlayerConsole.log("VAST : promise not support"),r(!0),t())}else OvenPlayerConsole.log("VAST : !temporarySupportCheckVideo.play"),r(!0),t()}))}().then((function(){n.isAutoStart()&&!d?(OvenPlayerConsole.log("VAST : autoplayAllowed : false"),s.started=!1,o(new Error("autoplayNotAllowed"))):(p.get(r).then((function(n){if(OvenPlayerConsole.log("VAST : initRequest()"),!(m=n.ads[0]))throw{code:401,message:"File not found. Unable to find Linear/MediaFile from URI."};g=new mn(p,m,m.creatives[0]),OvenPlayerConsole.log("VAST : created ad tracker."),a=function(t,e,n,r,i,o,s){var a={},l={},c=jt(o),u=jt(i),A=jt(t);n.on(Rt,(function(e){e.mute?t.muted=!0:(t.muted=!1,t.volume=e.volume/100)}),l);var d=function(){r.active=!1,u.hide(),!r.started||0!==n.getPosition()&&r.isVideoEnded||(A.hide(),n.play()),n.trigger(at)},h=function(n){c.hasClass("videoAdUiAction")&&(e.skip(),t.pause(),d())};return o.addEventListener("click",h,!1),a.error=function(){OvenPlayerConsole.log("VAST : listener : error.",t.error),console.log("VAST : listener : error.",t.error);var n={},r=t.error&&t.error.code||0;2===r?(n.code=402,n.message="Timeout of MediaFile URI."):3===r?(n.code=405,n.message="Problem displaying MediaFile. Video player found a MediaFile with supported type but couldn’t display it. MediaFile may include: unsupported codecs, different MIME type than MediaFile@type, unsupported delivery method, etc."):4===r?(n.code=403,n.message="Couldn’t find MediaFile that is supported by this video player, based on the attributes of the MediaFile element."):(n.code=400,n.message="General Linear error. Video player is unable to display the Linear Ad."),e.errorWithCode(n.code),s("405")},a.canplay=function(){},a.ended=function(){e.complete(),d()},a.click=function(t){e.click()},a.play=function(){e.setPaused(!1)},a.pause=function(){e.setPaused(!0)},a.timeupdate=function(r){e.setProgress(r.target.currentTime),n.trigger(Lt,{duration:t.duration,position:t.currentTime})},a.volumechange=function(t){OvenPlayerConsole.log("VAST : listener : Ad Video Volumechange."),e.setMuted(t.target.muted)},a.loadedmetadata=function(){OvenPlayerConsole.log("VAST : listener : Ad CONTENT LOADED ."),tt===n.getState()&&n.pause(),e.trackImpression(),n.trigger(it,{remaining:t.duration,isLinear:!0}),t.play()},e.on("skip",(function(){OvenPlayerConsole.log("VAST : listener : skipped")})),e.on("mute",(function(){OvenPlayerConsole.log("VAST : listener : muted")})),e.on("unmute",(function(){OvenPlayerConsole.log("VAST : listener : unmuted")})),e.on("resume",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker resumed."),r.started&&n.setState(ot)})),e.on("pause",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker paused."),n.setState(st)})),e.on("clickthrough",(function(t){OvenPlayerConsole.log("VAST : listener : clickthrough :",t),window.open(t,"_blank")})),e.on("skip-countdown",(function(t){0===t?("ko"===r.lang?c.html("광고 건너뛰기"):c.html("Ad Skip"),c.addClass("videoAdUiAction")):"ko"===r.lang?c.html(parseInt(t)+1+"초 후에 이 광고를 건너뛸 수 있습니다."):c.html("You can skip this ad in "+(parseInt(t)+1))})),e.on("rewind",(function(){OvenPlayerConsole.log("VAST : listener : rewind")})),e.on("start",(function(){OvenPlayerConsole.log("VAST : listener : started"),r.started=!0,r.active=!0,A.show(),u.show(),n.trigger(kt,{isLinear:!0}),n.setState(ot)})),e.on("firstQuartile",(function(){OvenPlayerConsole.log("VAST : listener : firstQuartile")})),e.on("midpoint",(function(){OvenPlayerConsole.log("VAST : listener : midpoint")})),e.on("thirdQuartile",(function(){OvenPlayerConsole.log("VAST : listener : thirdQuartile")})),e.on("creativeView",(function(){OvenPlayerConsole.log("VAST : listener : creativeView")})),Object.keys(a).forEach((function(e){t.removeEventListener(e,a[e]),t.addEventListener(e,a[e])})),l.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),o.removeEventListener("click",h,!1),Object.keys(a).forEach((function(e){t.removeEventListener(e,a[e])}))},l}(c,g,e,s,A,u,v);var r="";m.creatives&&m.creatives.length>0&&m.creatives[0].mediaFiles&&m.creatives[0].mediaFiles.length>0&&m.creatives[0].mediaFiles[0].fileURL&&(r=m.creatives[0].mediaFiles[0].fileURL,OvenPlayerConsole.log("VAST : media url : ",r)),c.src=r,c.volume=t.volume,c.muted=t.muted})).catch((function(t){v(t)})),i())}))):setTimeout(l,100)}()}))},o.pause=function(){c.pause()},o.videoEndedCallback=function(t){t(),s.isVideoEnded=!0},o.destroy=function(){a&&(a.destroy(),a=null),g=null,p=null,l.remove()},o},yn=function(t,e,n){OvenPlayerConsole.log("[Provider] loaded. ");var r={};Yt(r);var i=t.element,o=null,s=null;t.adTagUrl&&(OvenPlayerConsole.log("[Provider] Ad Client - ",e.getAdClient()),(o="vast"===e.getAdClient()?vn(i,r,e,t.adTagUrl):te(i,r,e,t.adTagUrl))||console.log("Can not load due to google ima for Ads.")),s=function(t,e,n,r){var i={};OvenPlayerConsole.log("EventListener loaded.",t,e);var o={},s=-1,a=t;return i.canplay=function(){e.setCanSeek(!0),e.trigger("bufferFull"),OvenPlayerConsole.log("EventListener : on canplay")},i.durationchange=function(){i.progress(),OvenPlayerConsole.log("EventListener : on durationchange"),e.trigger("durationChanged")},i.ended=function(){OvenPlayerConsole.log("EventListener : on ended"),a.pause(),e.getState()!==q&&e.getState()!==J&&e.getState()!==et&&(n?n((function(){e.setState(J)})):e.setState(J))},i.loadeddata=function(){},i.loadedmetadata=function(){var t=e.getSources(),n=e.getCurrentSource(),r=n>-1?t[n].type:"",i={duration:e.isLive()?1/0:a.duration,type:r};e.setMetaLoaded(),OvenPlayerConsole.log("EventListener : on loadedmetadata",i),e.trigger(Bt,i)},i.pause=function(){return e.getState()!==J&&e.getState()!==et&&!a.ended&&!a.error&&a.currentTime!==a.duration&&(OvenPlayerConsole.log("EventListener : on pause"),void e.setState(Z))},i.loadstart=function(){r&&!r.getConfig().showBigPlayButton&&r.getConfig().autoStart&&e.setState(nt)},i.play=function(){s=-1,a.paused||e.getState()===tt||e.setState(nt)},i.playing=function(){OvenPlayerConsole.log("EventListener : on playing"),s<0&&e.setState(tt)},i.progress=function(){var t=a.buffered;if(!t)return!1;var n,r=a.duration,i=a.currentTime,o=(n=(t.length>0?t.end(t.length-1):0)/r,Math.max(Math.min(n,1),0));e.setBuffer(100*o),e.trigger(xt,{bufferPercent:100*o,position:i,duration:r}),OvenPlayerConsole.log("EventListener : on progress",100*o)},i.timeupdate=function(){var t=a.currentTime,n=a.duration;if(!isNaN(n)){if(t>n)return a.pause(),void e.setState(J);var r=e.getSources()[e.getCurrentSource()].sectionStart;r&&ti&&e.getState()===tt)return e.stop(),void e.setState(J);n>9e15&&(n=1/0),e.isSeeking()||a.paused||e.getState()!==rt&&e.getState()!==nt&&e.getState()!==ot||function(t,e){return t.toFixed(2)===e.toFixed(2)}(s,t)||(s=-1,e.setState(tt)),r&&r>0&&(t-=r)<0&&(t=0),i&&(n=i),r&&(n-=r),(e.getState()===tt||e.isSeeking())&&e.trigger(It,{position:t,duration:n})}},i.seeking=function(){e.setSeeking(!0),OvenPlayerConsole.log("EventListener : on seeking",a.currentTime),e.trigger("seek",{position:a.currentTime})},i.seeked=function(){e.isSeeking()&&(OvenPlayerConsole.log("EventListener : on seeked"),e.setSeeking(!1),e.trigger("seeked"))},i.stalled=function(){OvenPlayerConsole.log("EventListener : on stalled")},i.waiting=function(){OvenPlayerConsole.log("EventListener : on waiting",e.getState()),e.isSeeking()?e.setState(nt):e.getState()===tt&&(s=a.currentTime,e.setState(rt))},i.volumechange=function(){OvenPlayerConsole.log("EventListener : on volumechange",Math.round(100*a.volume)),e.trigger(Rt,{volume:Math.round(100*a.volume),mute:a.muted})},i.error=function(){var t={0:300,1:301,2:302,3:303,4:304}[a.error&&a.error.code||0]||0;OvenPlayerConsole.log("EventListener : on error",t),Jt(Qt.codes[t],e)},Object.keys(i).forEach((function(t){a.removeEventListener(t,i[t]),a.addEventListener(t,i[t])})),o.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),Object.keys(i).forEach((function(t){a.removeEventListener(t,i[t])}))},o}(i,r,o?o.videoEndedCallback:null,e),i.playbackRate=i.defaultPlaybackRate=e.getPlaybackRate();var a=function(o){var s=t.sources[t.currentSource];if(t.framerate=s.framerate,r.setVolume(e.getVolume()),t.framerate||e.setTimecodeMode(!0),n)n(s,o);else{OvenPlayerConsole.log("source loaded : ",s,"lastPlayPosition : "+o);var a=i.src;s.file!==a&&(i.src=s.file,(a||""===a)&&i.load()),r.on(Bt,(function(){o>0&&r.seek(o)}))}};return r.getName=function(){return t.name},r.getMse=function(){return t.mse},r.getMediaElement=function(){return t.element},r.canSeek=function(){return t.canSeek},r.setCanSeek=function(e){t.canSeek=e},r.isSeeking=function(){return t.seeking},r.setSeeking=function(e){t.seeking=e},r.setMetaLoaded=function(){t.isLoaded=!0},r.metaLoaded=function(){return t.isLoaded},r.setState=function(e){if(t.state!==e){var n=t.state;if(OvenPlayerConsole.log("Provider : setState()",e),n===ot&&(e===et||e===q))return!1;switch(OvenPlayerConsole.log("Provider : triggerSatatus",e),e){case J:r.trigger("complete");break;case Z:r.trigger(Ct,{prevState:t.state,newstate:Z});break;case st:r.trigger(Ct,{prevState:t.state,newstate:st});break;case tt:r.trigger(bt,{prevState:t.state,newstate:tt});break;case ot:r.trigger(bt,{prevState:t.state,newstate:ot})}t.state=e,r.trigger(yt,{prevstate:n,newstate:t.state})}},r.getState=function(){return t.state},r.setBuffer=function(e){t.buffer=e},r.getBuffer=function(){return t.buffer},r.isLive=function(){return!!t.isLive||i.duration===1/0},r.getDuration=function(){return r.isLive()?1/0:i.duration},r.getDvrWindow=function(){return t.dvrWindow},r.getPosition=function(){return i?i.currentTime:0},r.setVolume=function(t){if(!i)return!1;i.volume=t/100,e.setVolume(t)},r.getVolume=function(){return e.getVolume()},r.setMute=function(t){if(!i)return!1;if(void 0===t){var n=e.isMute();i.muted=!n,e.setMute(!n),r.trigger(Dt,{mute:e.isMute()})}else i.muted=t,e.setMute(t),r.trigger(Dt,{mute:e.isMute()});return i.muted},r.getMute=function(){return e.isMute()},r.preload=function(n,i){return t.sources=n,t.currentSource=Zt(n,e),a(i||0),new Promise((function(t,n){e.isMute()&&r.setMute(!0),e.getVolume()&&r.setVolume(e.getVolume()),t()}))},r.load=function(n){t.sources=n,t.currentSource=Zt(n,e),a(0)},r.play=function(){if(OvenPlayerConsole.log("Provider : play()"),!i)return!1;if(r.getState()!==tt)if(o&&o.isActive()||o&&!o.started())o.play().then((function(t){OvenPlayerConsole.log("Provider : ads play success")})).catch((function(t){OvenPlayerConsole.log("Provider : ads play fail",t)}));else{var t=i.play();void 0!==t?t.then((function(){OvenPlayerConsole.log("Provider : video play success")})).catch((function(t){OvenPlayerConsole.log("Provider : video play error",t.message)})):OvenPlayerConsole.log("Provider : video play success (ie)")}},r.pause=function(){if(OvenPlayerConsole.log("Provider : pause()"),!i)return!1;r.getState()===tt?i.pause():r.getState()===ot&&o.pause()},r.seek=function(t){if(!i)return!1;i.currentTime=t},r.setPlaybackRate=function(t){return!!i&&(r.trigger("playbackRateChanged",{playbackRate:t}),i.playbackRate=i.defaultPlaybackRate=t)},r.getPlaybackRate=function(){return i?i.playbackRate:0},r.getSources=function(){return i?t.sources.map((function(t,e){var n={file:t.file,type:t.type,label:t.label,index:e,sectionStart:t.sectionStart,sectionEnd:t.sectionEnd,gridThumbnail:t.gridThumbnail};return t.lowLatency&&(n.lowLatency=t.lowLatency),n})):[]},r.getCurrentSource=function(){return t.currentSource},r.setCurrentSource=function(n,o){if(n>-1&&t.sources&&t.sources.length>n)return OvenPlayerConsole.log("source changed : "+n),t.currentSource=n,e.setSourceIndex(n),r.setState(q),o&&a(i.currentTime||0),t.currentSource},r.getQualityLevels=function(){return i?t.qualityLevels:[]},r.getCurrentQuality=function(){return i?t.currentQuality:null},r.setCurrentQuality=function(t){},r.getAudioTracks=function(){return i?t.audioTracks:[]},r.getCurrentAudioTrack=function(){return i?t.currentAudioTrack:[]},r.setCurrentAudioTrack=function(t){},r.isAutoQuality=function(){},r.setAutoQuality=function(t){},r.getFramerate=function(){return t.framerate},r.setFramerate=function(e){return t.framerate=e},r.seekFrame=function(e){var n=t.framerate,o=(i.currentTime*n+e)/n;o+=1e-5,r.pause(),r.seek(o)},r.stop=function(){if(!i)return!1;for(OvenPlayerConsole.log("CORE : stop() "),i.removeAttribute("preload"),i.removeAttribute("src");i.firstChild;)i.removeChild(i.firstChild);r.pause(),r.setState(q)},r.destroy=function(){if(!i)return!1;r.stop(),s.destroy(),o&&(o.destroy(),o=null),r.off(),OvenPlayerConsole.log("CORE : destroy() player stop, listener, event destroied")},r.super=function(t){var e=r[t];return function(){return e.apply(r,arguments)}},r},Cn=function(t,e,n){var r=yn({name:ct,element:t,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:q,buffer:0,framerate:0,currentQuality:-1,qualityLevels:[],currentAudioTrack:-1,audioTracks:[],currentSource:-1,sources:[],adTagUrl:n},e,null),i=r.super("destroy");return OvenPlayerConsole.log("HTML5 PROVIDER LOADED."),r.destroy=function(){OvenPlayerConsole.log("HTML5 : PROVIDER DESTROYED."),i()},r},bn=function(t,e,n,r,i,s,a,l){var c={},u={},A=null,d=!1,h=null,f=null,p={},g=!1,m=!1,v=null,y=!1;a.getConfig().webrtcConfig&&!0===a.getConfig().webrtcConfig.recoverPacketLoss&&(m=!0);var C=!0;a.getConfig().webrtcConfig&&!1===a.getConfig().webrtcConfig.generatePublicCandidate&&(C=a.getConfig().webrtcConfig.generatePublicCandidate);var b=W(),E=null;function w(t){var e=null;return f&&t===f.id?e=f.peerConnection:p[t]&&(e=p[t].peerConnection),e}function T(t){t.statisticsTimer&&clearTimeout(t.statisticsTimer),t.status||(t.status={},t.status.lostPacketsArr=[],t.status.slotLength=8,t.status.prevPacketsLost=0,t.status.avg8Losses=0,t.status.avgMoreThanThresholdCount=0,t.status.threshold=40);var e=t.status.lostPacketsArr,n=t.status.slotLength,r=t.status.prevPacketsLost,i=t.status.avg8Losses,s=t.status.threshold;t.statisticsTimer=setTimeout((function(){if(!t.peerConnection)return!1;t.peerConnection.getStats().then((function(l){l&&a.getConfig().autoFallback&&l&&(l.forEach((function(a){if("inbound-rtp"===a.type&&"video"===a.kind&&!a.isRemote){var l=parseInt(a.packetsLost)-parseInt(r);e.push(parseInt(a.packetsLost)-parseInt(r)),e.length>n&&e.shift(),e.length===n&&(i=o().reduce(e,(function(t,e){return t+e}),0)/n,OvenPlayerConsole.log("Last8 LOST PACKET AVG : "+i,"Current Packet LOST: "+l,"Total Packet Lost: "+a.packetsLost,e),i>s?(t.status.avgMoreThanThresholdCount=t.status.avgMoreThanThresholdCount+1,t.status.avgMoreThanThresholdCount>=60&&(OvenPlayerConsole.log("NETWORK UNSTABLED!!! "),B(Qt.codes[510]))):t.status.avgMoreThanThresholdCount=0),t.status.prevPacketsLost=a.packetsLost}})),T(t))}))}),2e3)}function S(i,s,l,u,d){var p={};if(a.getConfig().webrtcConfig&&a.getConfig().webrtcConfig.iceServers)p.iceServers=a.getConfig().webrtcConfig.iceServers,a.getConfig().webrtcConfig.iceTransportPolicy&&(p.iceTransportPolicy=a.getConfig().webrtcConfig.iceTransportPolicy);else if(d){p.iceServers=[];for(var v=0;v-1){b=!0;break}if(!b&&C.urls.length>0){var S=o().clone(C.urls[0]),k=x(S);E&&k&&C.urls.push(S.replace(k,E))}C.username=y.username||y.user_name,C.credential=y.credential,p.iceServers.push(C)}p.iceTransportPolicy="relay"}else p=c;OvenPlayerConsole.log("Main Peer Connection Config : ",p);var I=null;try{I=new RTCPeerConnection(p),t.trigger("peerConnectionPrepared",I)}catch(t){var D=Qt.codes[506];return D.error=t,void B(D)}f={id:i,peerId:s,peerConnection:I},I.setRemoteDescription(new RTCSessionDescription(l)).then((function(){I.createAnswer().then((function(t){var e=function(t){for(var e=t.split("\r\n"),n=-1,r=0;r-1&&e[r].indexOf("opus")>-1){n=e[r].split(" ")[0].split(":")[1];break}return n}(l.sdp);e>-1&&function(t,e){for(var n=t.split("\r\n"),r=!1,i=0;i-1){n[i].indexOf("stereo=1")>-1&&(r=!0);break}return r}(l.sdp,e)&&(t.sdp=function(t,e){for(var n=t.split("\r\n"),r=0;r-1){-1===n[r].indexOf("stereo=1")&&(n[r]=n[r]+";stereo=1");break}return n.join("\r\n")}(t.sdp,e)),OvenPlayerConsole.log("Local SDP",t),P(A,{id:i,peer_id:s,command:"answer",sdp:t}),OvenPlayerConsole.log("create Host Answer : success"),I.setLocalDescription(t).then((function(){})).catch((function(t){var e=Qt.codes[505];e.error=t,B(e)}))})).catch((function(t){var e=Qt.codes[504];e.error=t,B(e)}))})).catch((function(t){var e=Qt.codes[503];e.error=t,B(e)})),u&&R(I,u),I.onicecandidate=function(t){t.candidate&&(OvenPlayerConsole.log("WebRTCLoader send candidate to server : ",t.candidate),P(A,{id:i,peer_id:s,command:"candidate",candidates:[t.candidate]}))},I.onconnectionstatechange=function(t){OvenPlayerConsole.log("[on connection state change]",I.connectionState,t),"connected"===I.connectionState&&r&&r()},I.onicecandidateerror=function(t){},I.onicegatheringstatechange=function(t){},I.oniceconnectionstatechange=function(t){OvenPlayerConsole.log("[on ice connection state change]",I.iceConnectionState,t),"connected"===I.iceConnectionState&&r&&r(),("disconnected"===I.iceConnectionState||"closed"===I.iceConnectionState)&&(g||f&&B(Qt.codes[511]))},I.ontrack=function(t){if(OvenPlayerConsole.log("stream received."),OvenPlayerConsole.log("Recovery On Packet Loss :",m),m&&T(f),h=t.streams[0],n(t.streams[0]),a.getConfig().webrtcConfig&&a.getConfig().webrtcConfig.playoutDelayHint)for(var e=a.getConfig().webrtcConfig.playoutDelayHint,r=f.peerConnection.getReceivers(),i=0;i0){for(var n in p){var r=p[n].peerConnection;r&&(OvenPlayerConsole.log("Closing client peer connection..."),r.close(),r=null)}p={}}A?(OvenPlayerConsole.log("Closing websocket connection..."),OvenPlayerConsole.log("Send Signaling : Stop."),1===A.readyState&&(g=!0,f&&P(A,{command:"stop",id:f.id}),A.close())):g=!1,A=null,e&&(i&&i(e),s(e,t))}function P(t,e){t&&t.send(JSON.stringify(e))}return E=window.onbeforeunload,window.onbeforeunload=function(t){E&&E(t),OvenPlayerConsole.log("This calls auto when browser closed."),B()},t.setCurrentQuality=function(t){if(!v)return-1;var e=v.renditions[t];return e?(P(A,{command:"change_rendition",id:f.id,rendition_name:e.name,auto:!1}),y=!1,l.currentQuality=t,l.currentQuality):l.currentQuality},t.isAutoQuality=function(){return y},t.setAutoQuality=function(t){P(A,{command:"change_rendition",id:f.id,auto:t}),y=t},u.connect=function(){OvenPlayerConsole.log("WebRTCLoader connecting..."),OvenPlayerConsole.log("WebRTCLoader url : "+e),D()},u.destroy=function(){g=!0,B(),window.onbeforeunload=E,E=null},u},En=function(t,e,n){var r={},i=null,o=null,s=null,a=null,l=null,c={name:ut,element:t,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:q,buffer:0,framerate:0,currentQuality:-1,currentSource:-1,qualityLevels:[],sources:[],adTagUrl:n},u=1e4,A=0,d=null,h=!1;function f(){if(Kt(a.file,a.type)){clearTimeout(d),OvenPlayerConsole.log("WEBRTC : onBeforeLoad : ",a),i&&(i.destroy(),i=null);var n=null,o=null;A>0&&(n=function(){clearTimeout(d)},o=function(){clearTimeout(d),performance.now(),h=!0}),i=bn(r,a.file,(function(e){if(t.srcObject&&(t.srcObject=null),l&&(l.close(),l=null),t.srcObject=e,e.getAudioTracks().length>0){var n=window.AudioContext||window.webkitAudioContext;(function(t){var e=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent),n=(/iPhone|iPad|iPod/i.test(navigator.userAgent),!1);e&&"suspended"===t.state&&document.addEventListener("touchend",(function(){n||"running"===t.state||(t.resume(),n=!0)}))})(l=new n),l.createMediaStreamSource(e)}}),o,n,Jt,e,c),performance.now(),i.connect(),A>0&&(r.once(yt,(function(t){h||t.newstate===q&&(clearTimeout(d),p())})),r.once(vt,(function(){h=!1})),d=setTimeout((function(){if(A>0)h||(p(),f());else{p();var t=Qt.codes[512];Jt(t,r)}A--}),u))}}function p(){i&&(i.destroy(),i=null,t.srcObject=null)}return r=yn(c,e,(function(t){var n=e.getConfig();n.webrtcConfig&&("number"==typeof n.webrtcConfig.connectionTimeout&&n.webrtcConfig.connectionTimeout>0&&(u=n.webrtcConfig.connectionTimeout),"number"==typeof n.webrtcConfig.timeoutMaxRetry&&n.webrtcConfig.timeoutMaxRetry>0&&(A=n.webrtcConfig.timeoutMaxRetry)),a=t,f()})),o=r.super("destroy"),s=r.super("play"),OvenPlayerConsole.log("WEBRTC PROVIDER LOADED."),r.removeStream=function(){t.srcObject=null},r.destroy=function(){clearTimeout(d),p(),OvenPlayerConsole.log("WEBRTC : PROVIDER DESTROYED."),o()},r.play=function(){A>0&&!h&&f(),s()},r},wn=function(t,e,n){var r=e?1e3:1024;if(Math.abs(t)=r&&sNumber.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;const n=new Uint8Array(e.length/2);for(let t=0;tNumber.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const n=this[t];return n?parseFloat(n):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){const e=Qn.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const n={};for(Gn.lastIndex=0;null!==(e=Gn.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1)),n[e[1].trim()]=t}return n}}function Yn(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}class jn{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const n=e.attr;for(const e in n)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==n[e]){Un.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=Dn(new Wn({}),n,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=new Date(this.attr["END-DATE"]);Bn(t.getTime())&&(this._endDate=t)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(Bn(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Bn(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Hn{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var Kn="audio",Vn="video",zn="audiovideo";class $n{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Kn]:null,[Vn]:null,[zn]:null},this.baseurl=t}setByteRange(t,e){const n=t.split("@",2),r=[];1===n.length?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(n[1]),r[1]=parseInt(n[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ln.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Xn extends $n{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Hn,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!Bn(this.programDateTime))return null;const t=Bn(this.duration)?this.duration:0;return this.programDateTime+1e3*t}get encrypted(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),e=t.length;if(e>1||1===e&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()}setElementaryStreamInfo(t,e,n,r,i,o=!1){const{elementaryStreams:s}=this,a=s[t];a?(a.startPTS=Math.min(a.startPTS,e),a.endPTS=Math.max(a.endPTS,n),a.startDTS=Math.min(a.startDTS,r),a.endDTS=Math.max(a.endDTS,i)):s[t]={startPTS:e,endPTS:n,startDTS:r,endDTS:i,partial:o}}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t.audio=null,t.video=null,t.audiovideo=null}}class qn extends $n{constructor(t,e,n,r,i){super(n),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Hn,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=r;const o=t.enumeratedString("BYTERANGE");o&&this.setByteRange(o,i),i&&(this.fragOffset=i.fragOffset+i.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}class Jn{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t)return this.advanced=!0,void(this.updated=!0);const e=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&Bn(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Zn(t){return Uint8Array.from(atob(t),(t=>t.charCodeAt(0)))}function tr(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(t=>t.charCodeAt(0)))}var er={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},nr="org.w3.clearkey",rr="com.apple.streamingkeydelivery",ir="com.microsoft.playready",or="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function sr(t){switch(t){case rr:return er.FAIRPLAY;case ir:return er.PLAYREADY;case or:return er.WIDEVINE;case nr:return er.CLEARKEY}}var ar="edef8ba979d64acea3c827dcd51d21ed";function lr(t){switch(t){case er.FAIRPLAY:return rr;case er.PLAYREADY:return ir;case er.WIDEVINE:return or;case er.CLEARKEY:return nr}}function cr(t){const{drmSystems:e,widevineLicenseUrl:n}=t,r=e?[er.FAIRPLAY,er.WIDEVINE,er.PLAYREADY,er.CLEARKEY].filter((t=>!!e[t])):[];return!r[er.WIDEVINE]&&n&&r.push(er.WIDEVINE),r}const ur="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Ar(t,e,n){return Uint8Array.prototype.slice?t.slice(e,n):new Uint8Array(Array.prototype.slice.call(t,e,n))}const dr=(t,e)=>e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,hr=(t,e)=>e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,fr=(t,e)=>{const n=e;let r=0;for(;dr(t,e);)r+=10,r+=pr(t,e+6),hr(t,e+10)&&(r+=10),e+=r;if(r>0)return t.subarray(n,n+r)},pr=(t,e)=>{let n=0;return n=(127&t[e])<<21,n|=(127&t[e+1])<<14,n|=(127&t[e+2])<<7,n|=127&t[e+3],n},gr=(t,e)=>dr(t,e)&&pr(t,e+6)+10<=t.length-e,mr=t=>t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,vr=t=>{const e=String.fromCharCode(t[0],t[1],t[2],t[3]),n=pr(t,4);return{type:e,size:n,data:t.subarray(10,10+n)}},yr=t=>{let e=0;const n=[];for(;dr(t,e);){const r=pr(t,e+6);e+=10;const i=e+r;for(;e+8"PRIV"===t.type?br(t):"W"===t.type[0]?wr(t):Er(t),br=t=>{if(t.size<2)return;const e=Sr(t.data,!0),n=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:n.buffer}},Er=t=>{if(t.size<2)return;if("TXXX"===t.type){let e=1;const n=Sr(t.data.subarray(e),!0);e+=n.length+1;const r=Sr(t.data.subarray(e));return{key:t.type,info:n,data:r}}const e=Sr(t.data.subarray(1));return{key:t.type,data:e}},wr=t=>{if("WXXX"===t.type){if(t.size<2)return;let e=1;const n=Sr(t.data.subarray(e),!0);e+=n.length+1;const r=Sr(t.data.subarray(e));return{key:t.type,info:n,data:r}}const e=Sr(t.data);return{key:t.type,data:e}},Tr=t=>{if(8===t.data.byteLength){const e=new Uint8Array(t.data),n=1&e[3];let r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,n&&(r+=47721858.84),Math.round(r)}},Sr=(t,e=!1)=>{const n=Lr();if(n){const r=n.decode(t);if(e){const t=r.indexOf("\0");return-1!==t?r.substring(0,t):r}return r.replace(/\0/g,"")}const r=t.length;let i,o,s,a="",l=0;for(;l>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:o=t[l++],a+=String.fromCharCode((31&i)<<6|63&o);break;case 14:o=t[l++],s=t[l++],a+=String.fromCharCode((15&i)<<12|(63&o)<<6|(63&s)<<0)}}return a};let kr;function Lr(){return kr||void 0===self.TextDecoder||(kr=new self.TextDecoder("utf-8")),kr}const xr=function(t){let e="";for(let n=0;n>24,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n}function _r(t,e){const n=[];if(!e.length)return n;const r=t.byteLength;for(let i=0;i1?i+o:r;if(Br(t.subarray(i+4,i+8))===e[0])if(1===e.length)n.push(t.subarray(i+8,s));else{const r=_r(t.subarray(i+8,s),e.slice(1));r.length&&Rr.apply(n,r)}i=s}return n}function Nr(t){const e=[],n=t[0];let r=8;const i=Mr(t,r);r+=4,r+=0===n?8:16,r+=2;let o=t.length+0;const s=Pr(t,r);r+=2;for(let n=0;n>>31)return Un.warn("SIDX has hierarchical references (not supported)"),null;const l=Mr(t,n);n+=4,e.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/i,start:o,end:o+a-1}}),o+=a,n+=4,r=n}return{earliestPresentationTime:0,timescale:i,version:n,referencesCount:s,references:e}}function Ur(t){const e=[],n=_r(t,["moov","trak"]);for(let t=0;t{const n=Mr(t,4),r=e[n];r&&(r.default={duration:Mr(t,12),flags:Mr(t,20)})})),e}function Qr(t){const e=_r(t,["schm"])[0];if(e){const n=Br(e.subarray(4,8));if("cbcs"===n||"cenc"===n)return _r(t,["schi","tenc"])[0]}return Un.error("[eme] missing 'schm' box"),null}function Gr(t){const e=Mr(t,0);let n=8;1&e&&(n+=4),4&e&&(n+=4);let r=0;const i=Mr(t,4);for(let o=0;o{const l=a.byteOffset-8;_r(a,["traf"]).map((a=>{const c=_r(a,["tfdt"]).map((t=>{const e=t[0];let n=Mr(t,4);return 1===e&&(n*=Math.pow(2,32),n+=Mr(t,8)),n/i}))[0];return void 0!==c&&(t=c),_r(a,["tfhd"]).map((c=>{const u=Mr(c,4),A=16777215&Mr(c,0);let d=0;const h=0!=(16&A);let f=0;const p=0!=(32&A);let g=8;u===o&&(0!=(1&A)&&(g+=8),0!=(2&A)&&(g+=4),0!=(8&A)&&(d=Mr(c,g),g+=4),h&&(f=Mr(c,g),g+=4),p&&(g+=4),"video"===e.type&&(s=function(t){if(!t)return!1;const e=t.indexOf("."),n=e<0?t:t.substring(0,e);return"hvc1"===n||"hev1"===n||"dvh1"===n||"dvhe"===n}(e.codec)),_r(a,["trun"]).map((o=>{const a=o[0],c=16777215&Mr(o,0),u=0!=(1&c);let A=0;const h=0!=(4&c),p=0!=(256&c);let g=0;const m=0!=(512&c);let v=0;const y=0!=(1024&c),C=0!=(2048&c);let b=0;const E=Mr(o,4);let w=8;u&&(A=Mr(o,w),w+=4),h&&(w+=4);let T=A+l;for(let l=0;l>1&63;return 39===t||40===t}return 6==(31&e)}function Hr(t,e,n,r){const i=Kr(t);let o=0;o+=e;let s=0,a=0,l=!1,c=0;for(;o=i.length)break;c=i[o++],s+=c}while(255===c);a=0;do{if(o>=i.length)break;c=i[o++],a+=c}while(255===c);const t=i.length-o;if(!l&&4===s&&o16){const t=[];for(let e=0;e<16;e++){const n=i[o++].toString(16);t.push(1==n.length?"0"+n:n),3!==e&&5!==e&&7!==e&&9!==e||t.push("-")}const e=a-16,l=new Uint8Array(e);for(let t=0;tt)break}}function Kr(t){const e=t.byteLength,n=[];let r=1;for(;r>8*(15-n)&255;return e}(t);return new zr(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=function(t){const e=t.split(":");let n=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),r=t[t.length-1].split(",");if(2===r.length){const e="base64"===r[0],i=r[1];e?(t.splice(-1,1),n=Zn(i)):n=function(t){const e=tr(t).subarray(0,16),n=new Uint8Array(16);return n.set(e,16-e.length),n}(i)}}return n}(this.uri);if(e)switch(this.keyFormat){case or:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case ir:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(t,e,n){if(16!==t.byteLength)throw new RangeError("Invalid system id");let r,i,o;if(e){r=1,i=new Uint8Array(16*e.length);for(let t=0;t0?(o=new Uint8Array(4),e.length>0&&new DataView(o.buffer).setUint32(0,e.length,!1)):o=new Uint8Array;const s=new Uint8Array(4);return n&&n.byteLength>0&&new DataView(s.buffer).setUint32(0,n.byteLength,!1),function(t,...e){const n=e.length;let r=8,i=n;for(;i--;)r+=e[i].byteLength;const o=new Uint8Array(r);for(o[0]=r>>24&255,o[1]=r>>16&255,o[2]=r>>8&255,o[3]=255&r,o.set(t,4),i=0,r=8;i{const r=e.substring(2,e.length-1),i=null==n?void 0:n[r];return void 0===i?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),e):i}))}return e}function Zr(t,e,n){let r,i,o=t.variableList;if(o||(t.variableList=o={}),"QUERYPARAM"in e){r=e.QUERYPARAM;try{const t=new self.URL(n).searchParams;if(!t.has(r))throw new Error(`"${r}" does not match any query parameter in URI: "${n}"`);i=t.get(r)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`))}}else r=e.NAME,i=e.VALUE;r in o?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):o[r]=i||""}function ti(t,e,n){const r=e.IMPORT;if(n&&r in n){let e=t.variableList;e||(t.variableList=e={}),e[r]=n[r]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function ei(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const ni={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},ri=ei();function ii(t,e){var n;return null!=(n=null==ri?void 0:ri.isTypeSupported(`${e||"video"}/mp4;codecs="${t}"`))&&n}const oi=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,si=/#EXT-X-MEDIA:(.*)/g,ai=/^#EXT(?:INF|-X-TARGETDURATION):/m,li=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ci=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class ui{static findGroup(t,e){for(let n=0;n2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return t}static resolve(t,e){return Ln.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return ai.test(t)}static parseMasterPlaylist(t,e){const n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Xr(t)},r=[];let i;for(oi.lastIndex=0;null!=(i=oi.exec(t));)if(i[1]){var o;const t=new Wn(i[1]);qr(n,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const s=Jr(n,i[2]),a={attrs:t,bitrate:t.decimalInteger("AVERAGE-BANDWIDTH")||t.decimalInteger("BANDWIDTH"),name:t.NAME,url:ui.resolve(s,e)},l=t.decimalResolution("RESOLUTION");l&&(a.width=l.width,a.height=l.height),hi((t.CODECS||"").split(/[ ,]+/).filter((t=>t)),a),a.videoCodec&&-1!==a.videoCodec.indexOf("avc1")&&(a.videoCodec=ui.convertAVC1ToAVCOTI(a.videoCodec)),null!=(o=a.unknownCodecs)&&o.length||r.push(a),n.levels.push(a)}else if(i[3]){const t=i[3],r=i[4];switch(t){case"SESSION-DATA":{const t=new Wn(r);qr(n,t,["DATA-ID","LANGUAGE","VALUE","URI"]);const e=t["DATA-ID"];e&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[e]=t);break}case"SESSION-KEY":{const t=Ai(r,e,n);t.encrypted&&t.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(t)):Un.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${r}"`);break}case"DEFINE":{const t=new Wn(r);qr(n,t,["NAME","VALUE","QUERYPARAM"]),Zr(n,t,e)}break;case"CONTENT-STEERING":{const t=new Wn(r);qr(n,t,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:ui.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":n.startTimeOffset=di(r)}}const s=r.length>0&&r.length({id:t.attrs.AUDIO,audioCodec:t.audioCodec}))),SUBTITLES:o.map((t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec}))),"CLOSED-CAPTIONS":[]};let a=0;for(si.lastIndex=0;null!==(r=si.exec(t));){const t=new Wn(r[1]),o=t.TYPE;if(o){const r=s[o],l=i[o]||[];i[o]=l,qr(n,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const c={attrs:t,bitrate:0,id:a++,groupId:t["GROUP-ID"]||"",instreamId:t["INSTREAM-ID"],name:t.NAME||t.LANGUAGE||"",type:o,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:t.LANGUAGE,url:t.URI?ui.resolve(t.URI,e):""};if(null!=r&&r.length){const t=ui.findGroup(r,c.groupId)||r[0];fi(c,t,"audioCodec"),fi(c,t,"textCodec")}l.push(c)}}return i}static parseLevelPlaylist(t,e,n,r,i,o){const s=new Jn(e),a=s.fragments;let l,c,u,A=null,d=0,h=0,f=0,p=0,g=null,m=new Xn(r,e),v=-1,y=!1;for(li.lastIndex=0,s.m3u8=t,s.hasVariableRefs=Xr(t);null!==(l=li.exec(t));){y&&(y=!1,m=new Xn(r,e),m.start=f,m.sn=d,m.cc=p,m.level=n,A&&(m.initSegment=A,m.rawProgramDateTime=A.rawProgramDateTime,A.rawProgramDateTime=null));const t=l[1];if(t){m.duration=parseFloat(t);const e=(" "+l[2]).slice(1);m.title=e||null,m.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(Bn(m.duration)){m.start=f,u&&mi(m,u,s),m.sn=d,m.level=n,m.cc=p,m.urlId=i,a.push(m);const t=(" "+l[3]).slice(1);m.relurl=Jr(s,t),pi(m,g),g=m,f+=m.duration,d++,h=0,y=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);g?m.setByteRange(t,g):m.setByteRange(t)}else if(l[5])m.rawProgramDateTime=(" "+l[5]).slice(1),m.tagList.push(["PROGRAM-DATE-TIME",m.rawProgramDateTime]),-1===v&&(v=a.length);else{if(l=l[0].match(ci),!l){Un.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c0&&t.bool("CAN-SKIP-DATERANGES"),s.partHoldBack=t.optionalFloat("PART-HOLD-BACK",0),s.holdBack=t.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const t=new Wn(i);s.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=s.partList;t||(t=s.partList=[]);const n=h>0?t[t.length-1]:void 0,r=h++,o=new Wn(i);qr(s,o,["BYTERANGE","URI"]);const a=new qn(o,m,e,r,n);t.push(a),m.duration+=a.duration;break}case"PRELOAD-HINT":{const t=new Wn(i);qr(s,t,["URI"]),s.preloadHint=t;break}case"RENDITION-REPORT":{const t=new Wn(i);qr(s,t,["URI"]),s.renditionReports=s.renditionReports||[],s.renditionReports.push(t);break}default:Un.warn(`line parsed but not handled: ${l}`)}}}g&&!g.relurl?(a.pop(),f-=g.duration,s.partList&&(s.fragmentHint=g)):s.partList&&(pi(m,g),m.cc=p,s.fragmentHint=m,u&&mi(m,u,s));const C=a.length,b=a[0],E=a[C-1];if(f+=s.skippedSegments*s.targetduration,f>0&&C&&E){s.averagetargetduration=f/C;const t=E.sn;s.endSN="initSegment"!==t?t:0,s.live||(E.endList=!0),b&&(s.startCC=b.cc)}else s.endSN=0,s.startCC=0;return s.fragmentHint&&(f+=s.fragmentHint.duration),s.totalduration=f,s.endCC=p,v>0&&function(t,e){let n=t[e];for(let r=e;r--;){const e=t[r];if(!e)return;e.programDateTime=n.programDateTime-1e3*e.duration,n=e}}(a,v),s}}function Ai(t,e,n){var r,i;const o=new Wn(t);qr(n,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const s=null!=(r=o.METHOD)?r:"",a=o.URI,l=o.hexadecimalInteger("IV"),c=o.KEYFORMATVERSIONS,u=null!=(i=o.KEYFORMAT)?i:"identity";a&&o.IV&&!l&&Un.error(`Invalid IV: ${o.IV}`);const A=a?ui.resolve(a,e):"",d=(c||"1").split("/").map(Number).filter(Number.isFinite);return new zr(s,A,u,d,l)}function di(t){const e=new Wn(t).decimalFloatingPoint("TIME-OFFSET");return Bn(e)?e:null}function hi(t,e){["video","audio","text"].forEach((n=>{const r=t.filter((t=>function(t,e){const n=ni[e];return!!n&&!0===n[t.slice(0,4)]}(t,n)));if(r.length){const i=r.filter((t=>0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)));e[`${n}Codec`]=i.length>0?i[0]:r[0],t=t.filter((t=>-1===r.indexOf(t)))}})),e.unknownCodecs=t}function fi(t,e,n){const r=e[n];r&&(t[n]=r)}function pi(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),Bn(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function gi(t,e,n,r){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=n,t.sn="initSegment",r&&(t.levelkeys=r),t.initSegment=null}function mi(t,e,n){t.levelkeys=e;const{encryptedFragments:r}=n;r.length&&r[r.length-1].levelkeys===e||!Object.keys(e).some((t=>e[t].isCommonEncryption))||r.push(t)}var vi="manifest",yi="level",Ci="audioTrack",bi="subtitleTrack",Ei="main",wi="audio",Ti="subtitle";function Si(t){const{type:e}=t;switch(e){case Ci:return wi;case bi:return Ti;default:return Ei}}function ki(t,e){let n=t.url;return void 0!==n&&0!==n.indexOf("data:")||(n=e.url),n}class Li{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.on(Pn.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(Pn.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.off(Pn.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(Pn.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,n=e.pLoader,r=e.loader,i=new(n||r)(e);return this.loaders[t.type]=i,i}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:n}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:vi,url:n,deliveryDirectives:null})}onLevelLoading(t,e){const{id:n,level:r,url:i,deliveryDirectives:o}=e;this.load({id:n,level:r,responseType:"text",type:yi,url:i,deliveryDirectives:o})}onAudioTrackLoading(t,e){const{id:n,groupId:r,url:i,deliveryDirectives:o}=e;this.load({id:n,groupId:r,level:null,responseType:"text",type:Ci,url:i,deliveryDirectives:o})}onSubtitleTrackLoading(t,e){const{id:n,groupId:r,url:i,deliveryDirectives:o}=e;this.load({id:n,groupId:r,level:null,responseType:"text",type:bi,url:i,deliveryDirectives:o})}load(t){var e;const n=this.hls.config;let r,i=this.getInternalLoader(t);if(i){const e=i.context;if(e&&e.url===t.url)return void Un.trace("[playlist-loader]: playlist request ongoing");Un.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),i.abort()}if(r=t.type===vi?n.manifestLoadPolicy.default:Dn({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),i=this.createInternalLoader(t),null!=(e=t.deliveryDirectives)&&e.part){let e;if(t.type===yi&&null!==t.level?e=this.hls.levels[t.level].details:t.type===Ci&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===bi&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,n=e.targetduration;if(t&&n){const e=1e3*Math.max(3*t,.8*n);r=Dn({},r,{maxTimeToFirstByteMs:Math.min(e,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(e,r.maxTimeToFirstByteMs)})}}}const o=r.errorRetry||r.timeoutRetry||{},s={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},a={onSuccess:(t,e,n,r)=>{const i=this.getInternalLoader(n);this.resetInternalLoader(n.type);const o=t.data;0===o.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),ui.isMediaPlaylist(o)?this.handleTrackOrLevelPlaylist(t,e,n,r||null,i):this.handleMasterPlaylist(t,e,n,r)):this.handleManifestParsingError(t,n,new Error("no EXTM3U delimiter"),r||null,e)},onError:(t,e,n,r)=>{this.handleNetworkError(e,n,!1,t,r)},onTimeout:(t,e,n)=>{this.handleNetworkError(e,n,!0,void 0,t)}};i.load(t,s,a)}handleMasterPlaylist(t,e,n,r){const i=this.hls,o=t.data,s=ki(t,n),a=ui.parseMasterPlaylist(o,s);if(a.playlistParsingError)return void this.handleManifestParsingError(t,n,a.playlistParsingError,r,e);const{contentSteering:l,levels:c,sessionData:u,sessionKeys:A,startTimeOffset:d,variableList:h}=a;this.variableList=h;const{AUDIO:f=[],SUBTITLES:p,"CLOSED-CAPTIONS":g}=ui.parseMasterPlaylistMedia(o,s,a);f.length&&(f.some((t=>!t.url))||!c[0].audioCodec||c[0].attrs.AUDIO||(Un.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Wn({}),bitrate:0,url:""}))),i.trigger(Pn.MANIFEST_LOADED,{levels:c,audioTracks:f,subtitles:p,captions:g,contentSteering:l,url:s,stats:e,networkDetails:r,sessionData:u,sessionKeys:A,startTimeOffset:d,variableList:h})}handleTrackOrLevelPlaylist(t,e,n,r,i){const o=this.hls,{id:s,level:a,type:l}=n,c=ki(t,n),u=Bn(s)?s:0,A=Bn(a)?a:u,d=Si(n),h=ui.parseLevelPlaylist(t.data,c,A,d,u,this.variableList);if(l===vi){const t={attrs:new Wn({}),bitrate:0,details:h,name:"",url:c};o.trigger(Pn.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:c,stats:e,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),n.levelDetails=h,this.handlePlaylistLoaded(h,t,e,n,r,i)}handleManifestParsingError(t,e,n,r,i){this.hls.trigger(Pn.ERROR,{type:Mn.NETWORK_ERROR,details:On.MANIFEST_PARSING_ERROR,fatal:e.type===vi,url:t.url,err:n,error:n,reason:n.message,response:t,context:e,networkDetails:r,stats:i})}handleNetworkError(t,e,n=!1,r,i){let o=`A network ${n?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${t.type}`;t.type===yi?o+=`: ${t.level} id: ${t.id}`:t.type!==Ci&&t.type!==bi||(o+=` id: ${t.id} group-id: "${t.groupId}"`);const s=new Error(o);Un.warn(`[playlist-loader]: ${o}`);let a=On.UNKNOWN,l=!1;const c=this.getInternalLoader(t);switch(t.type){case vi:a=n?On.MANIFEST_LOAD_TIMEOUT:On.MANIFEST_LOAD_ERROR,l=!0;break;case yi:a=n?On.LEVEL_LOAD_TIMEOUT:On.LEVEL_LOAD_ERROR,l=!1;break;case Ci:a=n?On.AUDIO_TRACK_LOAD_TIMEOUT:On.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case bi:a=n?On.SUBTITLE_TRACK_LOAD_TIMEOUT:On.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(t.type);const u={type:Mn.NETWORK_ERROR,details:a,fatal:l,url:t.url,loader:c,context:t,error:s,networkDetails:e,stats:i};if(r){const n=(null==e?void 0:e.url)||t.url;u.response=In({url:n,data:void 0},r)}this.hls.trigger(Pn.ERROR,u)}handlePlaylistLoaded(t,e,n,r,i,o){const s=this.hls,{type:a,level:l,id:c,groupId:u,deliveryDirectives:A}=r,d=ki(e,r),h=Si(r),f="number"==typeof r.level&&h===Ei?l:void 0;if(!t.fragments.length){const t=new Error("No Segments found in Playlist");return void s.trigger(Pn.ERROR,{type:Mn.NETWORK_ERROR,details:On.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:t,reason:t.message,response:e,context:r,level:f,parent:h,networkDetails:i,stats:n})}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const p=t.playlistParsingError;if(p)s.trigger(Pn.ERROR,{type:Mn.NETWORK_ERROR,details:On.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:p,reason:p.message,response:e,context:r,level:f,parent:h,networkDetails:i,stats:n});else switch(t.live&&o&&(o.getCacheAge&&(t.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),a){case vi:case yi:s.trigger(Pn.LEVEL_LOADED,{details:t,level:f||0,id:c||0,stats:n,networkDetails:i,deliveryDirectives:A});break;case Ci:s.trigger(Pn.AUDIO_TRACK_LOADED,{details:t,id:c||0,groupId:u||"",stats:n,networkDetails:i,deliveryDirectives:A});break;case bi:s.trigger(Pn.SUBTITLE_TRACK_LOADED,{details:t,id:c||0,groupId:u||"",stats:n,networkDetails:i,deliveryDirectives:A})}}}function xi(t,e){let n;try{n=new Event("addtrack")}catch(t){n=document.createEvent("Event"),n.initEvent("addtrack",!1,!1)}n.track=t,e.dispatchEvent(n)}function Ii(t,e){const n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(n){Un.debug(`[texttrack-utils]: ${n}`);try{const n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}catch(t){Un.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`)}}"disabled"===n&&(t.mode=n)}function Ri(t){const e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(let e=t.cues.length;e--;)t.removeCue(t.cues[e]);"disabled"===e&&(t.mode=e)}function Di(t,e,n,r){const i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues&&t.cues.length>0){const i=function(t,e,n){const r=[],i=function(t,e){if(et[n].endTime)return-1;let r=0,i=n;for(;r<=i;){const o=Math.floor((i+r)/2);if(et[o].startTime&&r-1)for(let o=i,s=t.length;o=e&&i.endTime<=n)r.push(i);else if(i.startTime>n)return r}return r}(t.cues,e,n);for(let e=0;e{const t=Mi();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Fi(t,e){return t.getTime()/1e3-e}class _i{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Ri(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;eOi&&(r=Oi),r-n<=0&&(r=n+.25);for(let t=0;tt.type===Bi&&a:"video"===r?t=>t.type===Pi&&s:t=>t.type===Bi&&a||t.type===Pi&&s,Di(i,e,n,t)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:n,id3Track:r}=this,{dateRanges:i}=e,o=Object.keys(i);if(r){const t=Object.keys(n).filter((t=>!o.includes(t)));for(let e=t.length;e--;){const i=t[e];Object.keys(n[i].cues).forEach((t=>{r.removeCue(n[i].cues[t])})),delete n[i]}}const s=e.fragments[e.fragments.length-1];if(0===o.length||!Bn(null==s?void 0:s.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=s.programDateTime/1e3-s.start,l=Mi();for(let t=0;t{const n=i[e];return n.class===r.class&&n.id!==e&&n.startDate>r.startDate&&t.push(n),t}),[]).sort(((t,e)=>t.startDate.getTime()-e.startDate.getTime()))[0];t&&(f=Fi(t.startDate,a),d=!0)}const g=Object.keys(r.attr);for(let t=0;tthis.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(null===t)return null;const{holdBack:e,partHoldBack:n,targetduration:r}=t,{liveSyncDuration:i,liveSyncDurationCount:o,lowLatencyMode:s}=this.config,a=this.hls.userConfig;let l=s&&n||e;(a.liveSyncDuration||a.liveSyncDurationCount||0===l)&&(l=void 0!==i?i:o*r);const c=r;return l+Math.min(1*this.stallCount,c)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,n=this.levelDetails;if(null===t||null===e||null===n)return null;const r=n.edge,i=t-e-this.edgeStalled,o=r-n.totalduration,s=r-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(o,i),s)}get drift(){const{levelDetails:t}=this;return null===t?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(null===t)return 0;const e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const n=t.buffered.length;return(n?t.buffered.end(n-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Pn.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Pn.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var n;e.details===On.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(n=this.levelDetails)&&n.live&&Un.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const n=this.computeLatency();if(null===n)return;this._latency=n;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:i}=this.config;if(!r||1===i)return;const o=this.targetLatency;if(null===o)return;const s=n-o,a=s.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,i)),n=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,n))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return null===t?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}const Ui=["NONE","TYPE-0","TYPE-1",null];class Qi{constructor(t,e,n){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=n}addDirectives(t){const e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Gi{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((t=>t)).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}get textGroupId(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function Wi(t,e){const n=e.startPTS;if(Bn(n)){let r,i=0;e.sn>t.sn?(i=n-t.start,r=t):(i=t.start-n,r=e),r.duration!==i&&(r.duration=i)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function Yi(t,e,n,r,i,o){r-n<=0&&(Un.warn("Fragment should have a positive duration",e),r=n+e.duration,o=i+e.duration);let s=n,a=r;const l=e.startPTS,c=e.endPTS;if(Bn(l)){const t=Math.abs(l-n);Bn(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,s=Math.max(n,l),n=Math.min(n,l),i=Math.min(i,e.startDTS),a=Math.min(r,c),r=Math.max(r,c),o=Math.max(o,e.endDTS)}const u=n-e.start;0!==e.start&&(e.start=n),e.duration=r-e.start,e.startPTS=n,e.maxStartPTS=s,e.startDTS=i,e.endPTS=r,e.minEndPTS=a,e.endDTS=o;const A=e.sn;if(!t||At.endSN)return 0;let d;const h=A-t.startSN,f=t.fragments;for(f[h]=e,d=h;d>0;d--)Wi(f[d],f[d-1]);for(d=h;d=r.length||Hi(e,r[n].start)}function Hi(t,e){if(e){const n=t.fragments;for(let r=t.skippedSegments;r499)}(r)||!!n)}const Zi=function(t,e){let n=0,r=t.length-1,i=null,o=null;for(;n<=r;){i=(n+r)/2|0,o=t[i];const s=e(o);if(s>0)n=i+1;else{if(!(s<0))return o;r=i-1}}return null};function to(t,e,n=0,r=0){let i=null;if(t?i=e[t.sn-e[0].sn+1]||null:0===n&&0===e[0].start&&(i=e[0]),i&&0===eo(n,r,i))return i;const o=Zi(e,eo.bind(null,n,r));return!o||o===t&&i?i:o}function eo(t=0,e=0,n){if(n.start<=t&&n.start+n.duration>t)return 0;const r=Math.min(e,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-r<=t?1:n.start-r>t&&n.start?-1:0}function no(t,e,n){const r=1e3*Math.min(e,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-r>t}function ro(t,e,n){if(performance.now()-t.lastErrorPerfMs>3e5)return!0;const r=t.details;if(e.details===On.FRAG_GAP&&r&&e.frag){const t=e.frag.start,n=to(null,r.fragments,t);if(n&&!n.gap)return!0}if(n&&t.errors.length3*r.targetduration)return!0}return!1}class io{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Un.log.bind(Un,`${e}:`),this.warn=Un.warn.bind(Un,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const n=null==e?void 0:e.renditionReports;if(n){let r=-1;for(let i=0;i=0&&t>e.partTarget&&(o+=1)}return new Qi(i,o>=0?o:void 0,"")}}}loadPlaylist(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,n){const{details:r,stats:i}=e,o=self.performance.now(),s=i.loading.first?Math.max(0,o-i.loading.first):0;if(r.advancedDateTime=Date.now()-s,r.live||null!=n&&n.live){if(r.reloaded(n),n&&this.log(`live playlist ${t} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),n&&r.fragments.length>0&&function(t,e){let n=null;const r=t.fragments;for(let t=r.length-1;t>=0;t--){const e=r[t].initSegment;if(e){n=e;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let i,o=0;if(function(t,e,n){const r=e.skippedSegments,i=Math.max(t.startSN,e.startSN)-e.startSN,o=(t.fragmentHint?1:0)+(r?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,a=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(let t=i;t<=o;t++){const i=l[s+t];let o=a[t];r&&!o&&t{t.relurl&&(o=t.cc-r.cc),Bn(t.startPTS)&&Bn(t.endPTS)&&(r.start=r.startPTS=t.startPTS,r.startDTS=t.startDTS,r.maxStartPTS=t.maxStartPTS,r.endPTS=t.endPTS,r.endDTS=t.endDTS,r.minEndPTS=t.minEndPTS,r.duration=t.endPTS-t.startPTS,r.duration&&(i=r),e.PTSKnown=e.alignedSliding=!0),r.elementaryStreams=t.elementaryStreams,r.loader=t.loader,r.stats=t.stats,r.urlId=t.urlId,t.initSegment&&(r.initSegment=t.initSegment,n=t.initSegment)})),n&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((t=>{var e;t.initSegment&&t.initSegment.relurl!==(null==(e=n)?void 0:e.relurl)||(t.initSegment=n)})),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((t=>!t)),e.deltaUpdateFailed){Un.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=e.skippedSegments;t--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=function(t,e,n){const r=Dn({},t);return n&&n.forEach((t=>{delete r[t]})),Object.keys(e).forEach((t=>{const n=new jn(e[t].attr,r[t]);n.isValid?r[t]=n:Un.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[t].attr)}"`)})),r}(t.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const s=e.fragments;if(o){Un.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),i?Yi(e,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS):ji(t,e),s.length&&(e.totalduration=e.edge-s[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;const a=e.advancedDateTime;if(e.advanced&&a){const t=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=t),e.driftEndTime=a,e.driftEnd=t}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}(n,r),!this.canLoad||!r.live)return;let s,a,l;if(r.canBlockReload&&r.endSN&&r.advanced){const t=this.hls.config.lowLatencyMode,i=r.lastPartSn,o=r.endSN,c=r.lastPartIndex,u=i===o,A=t?0:c;-1!==c?(a=u?o+1:i,l=u?A:c+1):a=o+1;const d=r.age,h=d+r.ageHeader;let f=Math.min(h-r.partTarget,1.5*r.targetduration);if(f>0){if(n&&f>n.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${f} with playlist age: ${r.age}`),f=0;else{const t=Math.floor(f/r.targetduration);a+=t,void 0!==l&&(l+=Math.round(f%r.targetduration/r.partTarget)),this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${f} skip sn ${t} to part ${l}`)}r.tuneInGoal=f}if(s=this.getDeliveryDirectives(r,e.deliveryDirectives,a,l),t||!u)return void this.loadPlaylist(s)}else(r.canBlockReload||r.canSkipUntil)&&(s=this.getDeliveryDirectives(r,e.deliveryDirectives,a,l));const c=this.hls.mainForwardBufferInfo,u=c?c.end-c.len:0,A=function(t,e=1/0){let n=1e3*t.targetduration;if(t.updated){const r=t.fragments,i=4;if(r.length&&n*i>e){const t=1e3*r[r.length-1].duration;tthis.requestScheduled+A&&(this.requestScheduled=i.loading.start),void 0!==a&&r.canBlockReload?this.requestScheduled=i.loading.first+A-(1e3*r.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+Athis.loadPlaylist(s)),d)}else this.clearTimer()}getDeliveryDirectives(t,e,n,r){let i=function(t,e){const{canSkipUntil:n,canSkipDateRanges:r,endSN:i}=t;return n&&(void 0!==e?e-i:0)=s.maxNumRetry)return!1;if(n&&null!=(l=t.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${o+1}/${s.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const t=Xi(s,o);this.timer=self.setTimeout((()=>this.loadPlaylist()),t),this.warn(`Retrying playlist loading ${o+1}/${s.maxNumRetry} after "${e}" in ${t}ms`)}t.levelRetry=!0,r.resolved=!0}return a}}let oo;class so extends io{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Pn.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Pn.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(Pn.FRAG_LOADED,this.onFragLoaded,this),t.on(Pn.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Pn.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Pn.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(Pn.FRAG_LOADED,this.onFragLoaded,this),t.off(Pn.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach((t=>{t.loadError=0,t.fragmentError=0})),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const n=[],r={};let i;e.levels.forEach((t=>{var e;const o=t.attrs;-1!==(null==(e=t.audioCodec)?void 0:e.indexOf("mp4a.40.34"))&&(oo||(oo=/chrome|firefox/i.test(navigator.userAgent)),oo&&(t.audioCodec=void 0));const{AUDIO:s,CODECS:a,"FRAME-RATE":l,"PATHWAY-ID":c,RESOLUTION:u,SUBTITLES:A}=o,d=`${c||"."}-${t.bitrate}-${u}-${l}-${a}`;i=r[d],i?i.addFallback(t):(i=new Gi(t),r[d]=i,n.push(i)),ao(i,"audio",s),ao(i,"text",A)})),this.filterAndSortMediaOptions(n,e)}filterAndSortMediaOptions(t,e){let n=[],r=[],i=!1,o=!1,s=!1,a=t.filter((({audioCodec:t,videoCodec:e,width:n,height:r,unknownCodecs:a})=>(i||(i=!(!n||!r)),o||(o=!!e),s||(s=!!t),!(null!=a&&a.length)&&(!t||ii(t,"audio"))&&(!e||ii(e,"video")))));if((i||o)&&s&&(a=a.filter((({videoCodec:t,width:e,height:n})=>!!t||!(!e||!n)))),0===a.length)return void Promise.resolve().then((()=>{if(this.hls){const t=new Error("no level with compatible codecs found in manifest");this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:t,reason:t.message})}}));e.audioTracks&&(n=e.audioTracks.filter((t=>!t.audioCodec||ii(t.audioCodec,"audio"))),lo(n)),e.subtitles&&(r=e.subtitles,lo(r));const l=a.slice(0);a.sort(((t,e)=>t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):i&&t.height!==e.height?t.height-e.height:0));let c=l[0];if(this.steering&&(a=this.steering.filterParsedLevels(a),a.length!==l.length))for(let t=0;t!!t.url))};this.hls.trigger(Pn.MANIFEST_PARSED,A),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(0===e.length)return;if(t<0||t>=e.length){const n=new Error("invalid level idx"),r=t<0;if(this.hls.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.LEVEL_SWITCH_ERROR,level:t,fatal:r,error:n,reason:n.message}),r)return;t=Math.min(t,e.length-1)}const n=this.currentLevelIndex,r=this.currentLevel,i=r?r.attrs["PATHWAY-ID"]:void 0,o=e[t],s=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=o,n===t&&o.details&&r&&i===s)return;this.log(`Switching to level ${t}${s?" with Pathway "+s:""} from level ${n}${i?" with Pathway "+i:""}`);const a=Dn({},o,{level:t,maxBitrate:o.maxBitrate,attrs:o.attrs,uri:o.uri,urlId:o.urlId});delete a._attrs,delete a._urlId,this.hls.trigger(Pn.LEVEL_SWITCHING,a);const l=o.details;if(!l||l.live){const t=this.switchParams(o.uri,null==r?void 0:r.details);this.loadPlaylist(t)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(void 0===this._startLevel){const t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){!e.fatal&&e.context&&e.context.type===yi&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(void 0!==e&&e.type===Ei){const t=this._levels[e.level];void 0!==t&&(t.loadError=0)}}onLevelLoaded(t,e){var n;const{level:r,details:i}=e,o=this._levels[r];var s;if(!o)return this.warn(`Invalid level index ${r}`),void(null!=(s=e.deliveryDirectives)&&s.skip&&(i.deltaUpdateFailed=!0));r===this.currentLevelIndex?(0===o.fragmentError&&(o.loadError=0),this.playlistLoaded(r,e,o.details)):null!=(n=e.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const n=this.currentLevel;if(!n)return;const r=this.hls.audioTracks[e.id].groupId;if(n.audioGroupIds&&n.audioGroupId!==r){let t=-1;for(let e=0;en!==e,r=this._levels.filter(((r,i)=>i!==t||(r.url.length>1&&void 0!==e?(r.url=r.url.filter(n),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(n)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(n)),r.urlId=0,!0):(this.steering&&this.steering.removeLevel(r),!1))));this.hls.trigger(Pn.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(t,{levels:e}){e.forEach(((t,e)=>{const{details:n}=t;null!=n&&n.fragments&&n.fragments.forEach((t=>{t.level=e}))})),this._levels=e}}function ao(t,e,n){n&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=n):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=n))}function lo(t){const e={};t.forEach((t=>{const n=t.groupId||"";t.id=e[n]=e[n]||0,e[n]++}))}var co="NOT_LOADED",uo="APPENDING",Ao="PARTIAL",ho="OK";class fo{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(Pn.BUFFER_APPENDED,this.onBufferAppended,this),t.on(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Pn.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.BUFFER_APPENDED,this.onBufferAppended,this),t.off(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Pn.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const n=this.activePartLists[e];if(n)for(let e=n.length;e--;){const r=n[e];if(!r)break;const i=r.end;if(r.start<=t&&null!==i&&t<=i)return r}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:n}=this,r=Object.keys(n);for(let i=r.length;i--;){const o=n[r[i]];if((null==o?void 0:o.body.type)===e&&o.buffered){const e=o.body;if(e.start<=t&&t<=e.end)return e}}return null}detectEvictedFragments(t,e,n,r){this.timeRanges&&(this.timeRanges[t]=e);const i=(null==r?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach((r=>{const o=this.fragments[r];if(!o)return;if(i>=o.body.sn)return;if(!o.buffered&&!o.loaded)return void(o.body.type===n&&this.removeFragment(o.body));const s=o.range[t];s&&s.time.some((t=>{const n=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return n&&this.removeFragment(o.body),n}))}))}detectPartialFragments(t){const e=this.timeRanges,{frag:n,part:r}=t;if(!e||"initSegment"===n.sn)return;const i=go(n),o=this.fragments[i];if(!o||o.buffered&&n.gap)return;const s=!n.relurl;Object.keys(e).forEach((t=>{const i=n.elementaryStreams[t];if(!i)return;const a=e[t],l=s||!0===i.partial;o.range[t]=this.getBufferedTimes(n,r,l,a)})),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,(o.body.endList=n.endList||o.body.endList)&&(this.endListFragments[o.body.type]=o),po(o)||this.removeParts(n.sn-1,n.type)):this.removeFragment(o.body)}removeParts(t,e){const n=this.activePartLists[e];n&&(this.activePartLists[e]=n.filter((e=>e.fragment.sn>=t)))}fragBuffered(t,e){const n=go(t);let r=this.fragments[n];!r&&e&&(r=this.fragments[n]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(t,e,n,r){const i={time:[],partial:n},o=t.start,s=t.end,a=t.minEndPTS||s,l=t.maxStartPTS||o;for(let t=0;t=e&&a<=n){i.time.push({startPTS:Math.max(o,r.start(t)),endPTS:Math.min(s,r.end(t))});break}if(oe)i.partial=!0,i.time.push({startPTS:Math.max(o,r.start(t)),endPTS:Math.min(s,r.end(t))});else if(s<=e)break}return i}getPartialFragment(t){let e,n,r,i=null,o=0;const{bufferPadding:s,fragments:a}=this;return Object.keys(a).forEach((l=>{const c=a[l];c&&po(c)&&(n=c.body.start-s,r=c.body.end+s,t>=n&&t<=r&&(e=Math.min(t-n,r-t),o<=e&&(i=c.body,o=e)))})),i}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||po(e))}getState(t){const e=go(t),n=this.fragments[e];return n?n.buffered?po(n)?Ao:ho:uo:co}isTimeBuffered(t,e,n){let r,i;for(let o=0;o=r&&e<=i)return!0;if(e<=r)return!1}return!1}onFragLoaded(t,e){const{frag:n,part:r}=e;if("initSegment"===n.sn||n.bitrateTest)return;const i=r?null:e,o=go(n);this.fragments[o]={body:n,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:n,part:r,timeRanges:i}=e;if("initSegment"===n.sn)return;const o=n.type;if(r){let t=this.activePartLists[o];t||(this.activePartLists[o]=t=[]),t.push(r)}this.timeRanges=i,Object.keys(i).forEach((t=>{const e=i[t];this.detectEvictedFragments(t,e,o,r)}))}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=go(t);return!!this.fragments[e]}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,n,r,i){r&&!this.hasGaps||Object.keys(this.fragments).forEach((o=>{const s=this.fragments[o];if(!s)return;const a=s.body;a.type!==n||r&&!a.gap||a.startt&&(s.buffered||i)&&this.removeFragment(a)}))}removeFragment(t){const e=go(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const n=this.activePartLists[t.type];if(n){const e=t.sn;this.activePartLists[t.type]=n.filter((t=>t.fragment.sn!==e))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function po(t){var e,n,r;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(n=t.range.audio)?void 0:n.partial)||(null==(r=t.range.audiovideo)?void 0:r.partial))}function go(t){return`${t.type}_${t.level}_${t.urlId}_${t.sn}`}const mo=Math.pow(2,17);class vo{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const n=t.url;if(!n)return Promise.reject(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();const r=this.config,i=r.fLoader,o=r.loader;return new Promise(((s,a)=>{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some((t=>"GAP"===t[0])))return void a(Co(t));t.gap=!1}const l=this.loader=t.loader=i?new i(r):new o(r),c=yo(t),u=qi(r.fragLoadPolicy.default),A={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:mo};t.stats=l.stats,l.load(c,A,{onSuccess:(e,n,r,i)=>{this.resetLoader(t,l);let o=e.data;r.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(o.slice(0,16)),o=o.slice(16)),s({frag:t,part:null,payload:o,networkDetails:i})},onError:(e,r,i,o)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:In({url:n,data:void 0},e),error:new Error(`HTTP Error ${e.code} ${e.text}`),networkDetails:i,stats:o}))},onAbort:(e,n,r)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:r,stats:e}))},onTimeout:(e,n,r)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:r,stats:e}))},onProgress:(n,r,i,o)=>{e&&e({frag:t,part:null,payload:i,networkDetails:o})}})}))}loadPart(t,e,n){this.abort();const r=this.config,i=r.fLoader,o=r.loader;return new Promise(((s,a)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void a(Co(t,e));const l=this.loader=t.loader=i?new i(r):new o(r),c=yo(t,e),u=qi(r.fragLoadPolicy.default),A={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:mo};e.stats=l.stats,l.load(c,A,{onSuccess:(r,i,o,a)=>{this.resetLoader(t,l),this.updateStatsFromPart(t,e);const c={frag:t,part:e,payload:r.data,networkDetails:a};n(c),s(c)},onError:(n,r,i,o)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:In({url:c.url,data:void 0},n),error:new Error(`HTTP Error ${n.code} ${n.text}`),networkDetails:i,stats:o}))},onAbort:(n,r,i)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:i,stats:n}))},onTimeout:(n,r,i)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:i,stats:n}))}})}))}updateStatsFromPart(t,e){const n=t.stats,r=e.stats,i=r.total;if(n.loaded+=r.loaded,i){const r=Math.round(t.duration/e.duration),o=Math.min(Math.round(n.loaded/i),r),s=(r-o)*Math.round(n.loaded/o);n.total=n.loaded+s}else n.total=Math.max(n.loaded,n.total);const o=n.loading,s=r.loading;o.start?o.first+=s.first-s.start:(o.start=s.start,o.first=s.first),o.end=s.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function yo(t,e=null){const n=e||t,r={frag:t,part:e,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},i=n.byteRangeStartOffset,o=n.byteRangeEndOffset;if(Bn(i)&&Bn(o)){var s;let e=i,n=o;if("initSegment"===t.sn&&"AES-128"===(null==(s=t.decryptdata)?void 0:s.method)){const t=o-i;t%16&&(n=o+(16-t%16)),0!==i&&(r.resetIV=!0,e=i-16)}r.rangeStart=e,r.rangeEnd=n}return r}function Co(t,e){const n=new Error(`GAP ${t.gap?"tag":"attribute"} found`),r={type:Mn.MEDIA_ERROR,details:On.FRAG_GAP,fatal:!1,frag:t,error:n,networkDetails:null};return e&&(r.part=e),(e||t).stats.aborted=!0,new bo(r)}class bo extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class Eo{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const n=this.keyUriToKeyInfo[e].loader;if(n){if(t&&t!==n.context.frag.type)return;n.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=On.KEY_LOAD_ERROR,n,r,i){return new bo({type:Mn.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:i,error:n,networkDetails:r})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:n,cc:r}=t;for(let t=0;t{i.setKeyFormat(t)}));break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then((e=>this.loadInternal(t,e))):this.loadInternal(t)}loadInternal(t,e){var n,r;e&&t.setKeyFormat(e);const i=t.decryptdata;if(!i){const n=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,On.KEY_LOAD_ERROR,n))}const o=i.uri;if(!o)return Promise.reject(this.createKeyLoadError(t,On.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));let s=this.keyUriToKeyInfo[o];if(null!=(n=s)&&n.decryptdata.key)return i.key=s.decryptdata.key,Promise.resolve({frag:t,keyInfo:s});var a;if(null!=(r=s)&&r.keyLoadPromise)switch(null==(a=s.mediaKeySessionContext)?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return s.keyLoadPromise.then((e=>(i.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:s})))}switch(s=this.keyUriToKeyInfo[o]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===i.keyFormat?this.loadKeyHTTP(s,t):this.loadKeyEME(s,t);case"AES-128":return this.loadKeyHTTP(s,t);default:return Promise.reject(this.createKeyLoadError(t,On.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(t,e){const n={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(n);if(e)return(t.keyLoadPromise=e.then((e=>(t.mediaKeySessionContext=e,n)))).catch((e=>{throw t.keyLoadPromise=null,e}))}return Promise.resolve(n)}loadKeyHTTP(t,e){const n=this.config,r=new(0,n.loader)(n);return e.keyLoader=t.loader=r,t.keyLoadPromise=new Promise(((i,o)=>{const s={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},a=n.keyLoadPolicy.default,l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,n,r)=>{const{frag:s,keyInfo:a,url:l}=n;if(!s.decryptdata||a!==this.keyUriToKeyInfo[l])return o(this.createKeyLoadError(s,On.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),r));a.decryptdata.key=s.decryptdata.key=new Uint8Array(t.data),s.keyLoader=null,a.loader=null,i({frag:s,keyInfo:a})},onError:(t,n,r,i)=>{this.resetLoader(n),o(this.createKeyLoadError(e,On.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),r,In({url:s.url,data:void 0},t)))},onTimeout:(t,n,r)=>{this.resetLoader(n),o(this.createKeyLoadError(e,On.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),r))},onAbort:(t,n,r)=>{this.resetLoader(n),o(this.createKeyLoadError(e,On.INTERNAL_ABORTED,new Error("key loading aborted"),r))}};r.load(s,l,c)}))}resetLoader(t){const{frag:e,keyInfo:n,url:r}=t,i=n.loader;e.keyLoader===i&&(e.keyLoader=null,n.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}const wo={length:0,start:()=>0,end:()=>0};class To{static isBuffered(t,e){try{if(t){const n=To.getBuffered(t);for(let t=0;t=n.start(t)&&e<=n.end(t))return!0}}catch(t){}return!1}static bufferInfo(t,e,n){try{if(t){const r=To.getBuffered(t),i=[];let o;for(o=0;oo&&(r[i-1].end=t[e].end):r.push(t[e])}else r.push(t[e])}else r=t;let i,o=0,s=e,a=e;for(let t=0;t=l&&e>>8^255&n^99,t[h]=n,e[n]=h;const a=d[h],p=d[a],g=d[p];let m=257*d[n]^16843008*n;r[h]=m<<24|m>>>8,i[h]=m<<16|m>>>16,o[h]=m<<8|m>>>24,s[h]=m,m=16843009*g^65537*p^257*a^16843008*h,l[n]=m<<24|m>>>8,c[n]=m<<16|m>>>16,u[n]=m<<8|m>>>24,A[n]=m,h?(h=a^d[d[d[g^a]]],f^=d[d[f]]):h=f=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let n=!0,r=0;for(;rr?(this.logOnce("WebCrypto AES decrypt"),new Ro(r,new Uint8Array(n)).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized")))).catch((r=>(Un.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(t,e,n))))}onWebCryptoError(t,e,n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,n);const r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const n=t.length-t.length%16;return n!==t.length&&(e=Ar(t,0,n),this.remainderData=Ar(t,n)),e}logOnce(t){this.logEnabled&&(Un.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Mo="STOPPED",Oo="IDLE",Fo="KEY_LOADING",_o="FRAG_LOADING",No="FRAG_LOADING_WAITING_RETRY",Uo="WAITING_TRACK",Qo="PARSING",Go="PARSED",Wo="ENDED",Yo="ERROR",jo="WAITING_INIT_PTS",Ho="WAITING_LEVEL";class Ko extends class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}{constructor(t,e,n,r,i){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Mo,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=i,this.logPrefix=r,this.log=Un.log.bind(Un,`${r}:`),this.warn=Un.warn.bind(Un,`${r}:`),this.hls=t,this.fragmentLoader=new vo(t.config),this.keyLoader=n,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Po(t.config),t.on(Pn.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Mo}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const n=e.partList;if(null!=n&&n.length){const t=n[n.length-1];return To.isBuffered(this.media,t.start+t.duration/2)}const r=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){var t;if(this.levels&&null!==this.levelLastLoaded)return null==(t=this.levels[this.levelLastLoaded])?void 0:t.details}onMediaAttached(t,e){const n=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),n.addEventListener("seeking",this.onvseeking),n.addEventListener("ended",this.onvended);const r=this.config;this.levels&&r.autoStartLoad&&this.state===Mo&&this.startLoad(r.startPosition)}onMediaDetaching(){const t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:n,mediaBuffer:r,state:i}=this,o=n?n.currentTime:0,s=To.bufferInfo(r||n,o,t.maxBufferHole);if(this.log(`media seeking to ${Bn(o)?o.toFixed(3):o}, state: ${i}`),this.state===Wo)this.resetLoadingState();else if(e){const n=t.maxFragLookUpTolerance,r=e.start-n,i=e.start+e.duration+n;if(!s.len||is.end){const t=o>i;(o{if(this.fragContextChanged(t))return this.warn(`Fragment ${t.sn}${e.part?" p: "+e.part.index:""} of level ${t.level} was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)})).then((e=>{if(!e)return;const n=this.state;this.fragContextChanged(t)?(n===_o||!this.fragCurrent&&n===Qo)&&(this.fragmentTracker.removeFragment(t),this.state=Oo):("payload"in e&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(Pn.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))})).catch((e=>{this.state!==Mo&&this.state!==Yo&&(this.warn(e),this.resetFragmentLoading(t))}))}clearTrackerIfNeeded(t){var e;const{fragmentTracker:n}=this;if(n.getState(t)===uo){const e=t.type,r=this.getFwdBufferInfo(this.mediaBuffer,e),i=Math.max(t.duration,r?r.len:this.config.maxBufferLength);this.reduceMaxBufferLength(i)&&n.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?n.removeAllFragments():n.hasParts(t.type)&&(n.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),n.getState(t)===Ao&&n.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,n=null){if(!(t-e))return;const r={startOffset:t,endOffset:e,type:n};this.hls.trigger(Pn.BUFFER_FLUSHING,r)}_loadInitSegment(t,e){this._doFragLoad(t,e).then((e=>{if(!e||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e})).then((e=>{const{hls:n}=this,{payload:r}=e,i=t.decryptdata;if(r&&r.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer).catch((e=>{throw n.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((r=>{const i=self.performance.now();return n.trigger(Pn.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:o,tdecrypt:i}}),e.payload=r,e}))}return e})).then((n=>{const{fragCurrent:r,hls:i,levels:o}=this;if(!o)throw new Error("init load aborted, missing levels");const s=t.stats;this.state=Oo,e.fragmentError=0,t.data=new Uint8Array(n.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),n.frag===r&&i.trigger(Pn.FRAG_BUFFERED,{stats:s,frag:r,part:null,id:t.type}),this.tick()})).catch((e=>{this.state!==Mo&&this.state!==Yo&&(this.warn(e),this.resetFragmentLoading(t))}))}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var n,r,i,o;const s=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Ei?"level":"track"} ${t.level} (frag:[${(null!=(n=t.startPTS)?n:NaN).toFixed(3)}-${(null!=(r=t.endPTS)?r:NaN).toFixed(3)}] > buffer:${s?function(t){let e="";const n=t.length;for(let r=0;r!t)),s=new So(n.level,n.sn,n.stats.chunkCount+1,0,r?r.index:-1,!o);e.flush(s)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,n=null,r){var i;const o=null==e?void 0:e.details;if(!this.levels||!o)throw new Error(`frag load aborted, missing level${o?"":" detail"}s`);let s=null;if(!t.encrypted||null!=(i=t.decryptdata)&&i.key?!t.encrypted&&o.encryptedFragments.length&&this.keyLoader.loadClear(t,o.encryptedFragments):(this.log(`Loading key for ${t.sn} of [${o.startSN}-${o.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${t.level}`),this.state=Fo,this.fragCurrent=t,s=this.keyLoader.load(t).then((t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(Pn.KEY_LOADED,t),this.state===Fo&&(this.state=Oo),t})),this.hls.trigger(Pn.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(s=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),n=Math.max(t.start,n||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const i=o.partList;if(i&&r){n>t.end&&o.fragmentHint&&(t=o.fragmentHint);const a=this.getNextPart(i,t,n);if(a>-1){const l=i[a];let c;return this.log(`Loading part sn: ${t.sn} p: ${l.index} cc: ${t.cc} of playlist [${o.startSN}-${o.endSN}] parts [0-${a}-${i.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(n.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=_o,c=s?s.then((n=>!n||this.fragContextChanged(n.frag)?null:this.doFragPartsLoad(t,l,e,r))).catch((t=>this.handleFragLoadError(t))):this.doFragPartsLoad(t,l,e,r).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(Pn.FRAG_LOADING,{frag:t,part:l,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!t.url||this.loadedEndOfParts(i,n))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${o?"of ["+o.startSN+"-"+o.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(n.toFixed(3))}`),Bn(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=_o;const a=this.config.progressive;let l;return l=a&&s?s.then((e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,r))).catch((t=>this.handleFragLoadError(t))):Promise.all([this.fragmentLoader.load(t,a?r:void 0),s]).then((([t])=>(!a&&t&&r&&r(t),t))).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(Pn.FRAG_LOADING,{frag:t,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(t,e,n,r){return new Promise(((i,o)=>{var s;const a=[],l=null==(s=n.details)?void 0:s.partList,c=e=>{this.fragmentLoader.loadPart(t,e,r).then((r=>{a[e.index]=r;const o=r.part;this.hls.trigger(Pn.FRAG_LOADED,r);const s=Ki(n,t.sn,e.index+1)||Vi(l,t.sn,e.index+1);if(!s)return i({frag:t,part:o,partsLoaded:a});c(s)})).catch(o)};c(e)}))}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===On.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(Pn.ERROR,e)}else this.hls.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Qo)return void(this.fragCurrent||this.state===Mo||this.state===Yo||(this.state=Oo));const{frag:n,part:r,level:i}=e,o=self.performance.now();n.stats.parsing.end=o,r&&(r.stats.parsing.end=o),this.updateLevelTiming(n,r,i,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:n}=this,{level:r,sn:i,part:o}=t;if(null==e||!e[r])return this.warn(`Levels object was unset while buffering fragment ${i} of level ${r}. The current chunk will not be buffered.`),null;const s=e[r],a=o>-1?Ki(s,i,o):null,l=a?a.fragment:function(t,e,n){if(null==t||!t.details)return null;const r=t.details;let i=r.fragments[e-r.startSN];return i||(i=r.fragmentHint,i&&i.sn===e?i:eo&&this.flushMainBuffer(s,t.start)}getFwdBufferInfo(t,e){const n=this.getLoadPosition();return Bn(n)?this.getFwdBufferInfoAtPos(t,n,e):null}getFwdBufferInfoAtPos(t,e,n){const{config:{maxBufferHole:r}}=this,i=To.bufferInfo(t,e,r);if(0===i.len&&void 0!==i.nextStart){const o=this.fragmentTracker.getBufferedFrag(e,n);if(o&&i.nextStart=n&&(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0)}getAppendedFrag(t,e="main"){const n=this.fragmentTracker.getAppendedFrag(t,Ei);return n&&"fragment"in n?n.fragment:n}getNextFragment(t,e){const n=e.fragments,r=n.length;if(!r)return null;const{config:i}=this,o=n[0].start;let s;if(e.live){const o=i.initialLiveManifestSize;if(re}getNextFragmentLoopLoading(t,e,n,r,i){const o=t.gap,s=this.getNextFragment(this.nextLoadPosition,e);if(null===s)return s;if(t=s,o&&t&&!t.gap&&n.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,n.nextStart,r);if(null!==e&&n.len+e.len>=i)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(t,e,n){let r=-1,i=!1,o=!0;for(let s=0,a=t.length;s-1&&nn.start&&n.loaded}getInitialLiveFragment(t,e){const n=this.fragPrevious;let r=null;if(n){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${n.programDateTime}`),r=function(t,e,n){if(null===e||!Array.isArray(t)||!t.length||!Bn(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;n=n||0;for(let r=0;r=t.startSN&&i<=t.endSN){const o=e[i-t.startSN];n.cc===o.cc&&(r=o,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=function(t,e){return Zi(t,(t=>t.cce?-1:0))}(e,n.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const e=this.hls.liveSyncPosition;null!==e&&(r=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return r}getFragmentAtPosition(t,e,n){const{config:r}=this;let{fragPrevious:i}=this,{fragments:o,endSN:s}=n;const{fragmentHint:a}=n,l=r.maxFragLookUpTolerance,c=n.partList,u=!!(r.lowLatencyMode&&null!=c&&c.length&&a);let A;if(u&&a&&!this.bitrateTest&&(o=o.concat(a),s=a.sn),A=te-l?0:l):o[o.length-1],A){const t=A.sn-n.startSN,e=this.fragmentTracker.getState(A);if((e===ho||e===Ao&&A.gap)&&(i=A),i&&A.sn===i.sn&&(!u||c[0].fragment.sn>A.sn)&&i&&A.level===i.level){const e=o[t+1];A=A.sn=o-e.maxFragLookUpTolerance&&i<=s;if(null!==r&&n.duration>r&&(in.startCC||t&&t.cc${t.startSN} prev-sn: ${i?i.sn:"na"} fragments: ${s}`),n}return a}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let n=this.startPosition;if(n ${null==(r=this.fragCurrent)?void 0:r.url}`);const i=e.details===On.FRAG_GAP;i&&this.fragmentTracker.fragBuffered(n,!0);const o=e.errorAction,{action:s,retryCount:a=0,retryConfig:l}=o||{};if(o&&5===s&&l){var c;this.resetStartWhenNotLoaded(null!=(c=this.levelLastLoaded)?c:n.level);const r=Xi(l,a);this.warn(`Fragment ${n.sn} of ${t} ${n.level} errored with ${e.details}, retrying loading ${a+1}/${l.maxNumRetry} in ${r}ms`),o.resolved=!0,this.retryDate=self.performance.now()+r,this.state=No}else l&&o?(this.resetFragmentErrors(t),a.5;r&&this.reduceMaxBufferLength(n.len);const i=!r;return i&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),i}return!1}resetFragmentErrors(t){t===wi&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Mo&&(this.state=Oo)}afterBufferFlushed(t,e,n){if(!t)return;const r=To.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,r,n),this.state===Wo&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Oo}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(e=this.levelLastLoaded)?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,n,r){var i;const o=n.details;if(o){if(Object.keys(t.elementaryStreams).reduce(((e,i)=>{const s=t.elementaryStreams[i];if(s){const a=s.endPTS-s.startPTS;if(a<=0)return this.warn(`Could not parse fragment ${t.sn} ${i} duration reliably (${a})`),e||!1;const l=r?0:Yi(o,t,s.startPTS,s.endPTS,s.startDTS,s.endDTS);return this.hls.trigger(Pn.LEVEL_PTS_UPDATED,{details:o,level:n,drift:l,type:i,frag:t,start:s.startPTS,end:s.endPTS}),!0}return e}),!1))n.fragmentError=0;else if(null===(null==(i=this.transmuxer)?void 0:i.error)){const e=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(0===n.fragmentError&&(n.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(e.message),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:`Found no media in msn ${t.sn} of level "${n.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Go,this.hls.trigger(Pn.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){var e,n,r;"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(n=this.levelLastLoaded)?n:null==(r=this.fragCurrent)?void 0:r.level)?e:0),this.resetLoadingState())}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function Vo(){return self.SourceBuffer||self.WebKitSourceBuffer}function zo(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class $o{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,n,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,n){}demux(t,e){this.cachedData&&(t=Wr(this.cachedData,t),this.cachedData=null);let n,r=fr(t,0),i=r?r.length:0;const o=this._audioTrack,s=this._id3Track,a=r?(t=>{const e=yr(t);for(let t=0;t0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Bi,duration:Number.POSITIVE_INFINITY});iBn(t)?90*t:9e4*e+(n?9e4*n.baseTime/n.timescale:0);function qo(t,e){return 255===t[e]&&240==(246&t[e+1])}function Jo(t,e){return 1&t[e+1]?7:9}function Zo(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function ts(t,e){return e+1=t.length)return!1;const r=Zo(t,e);if(r<=n)return!1;const i=e+r;return i===t.length||ts(t,i)}return!1}function ns(t,e,n,r,i){if(!t.samplerate){const o=function(t,e,n,r){let i,o,s,a;const l=navigator.userAgent.toLowerCase(),c=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=1+((192&e[n+2])>>>6);const A=(60&e[n+2])>>>2;if(!(A>u.length-1))return s=(1&e[n+2])<<2,s|=(192&e[n+3])>>>6,Un.log(`manifest codec:${r}, ADTS type:${i}, samplingIndex:${A}`),/firefox/i.test(l)?A>=6?(i=5,a=new Array(4),o=A-3):(i=2,a=new Array(2),o=A):-1!==l.indexOf("android")?(i=2,a=new Array(2),o=A):(i=5,a=new Array(4),r&&(-1!==r.indexOf("mp4a.40.29")||-1!==r.indexOf("mp4a.40.5"))||!r&&A>=6?o=A-3:((r&&-1!==r.indexOf("mp4a.40.2")&&(A>=6&&1===s||/vivaldi/i.test(l))||!r&&1===s)&&(i=2,a=new Array(2)),o=A)),a[0]=i<<3,a[0]|=(14&A)>>1,a[1]|=(1&A)<<7,a[1]|=s<<3,5===i&&(a[1]|=(14&o)>>1,a[2]=(1&o)<<7,a[2]|=8,a[3]=0),{config:a,samplerate:u[A],channelCount:s,codec:"mp4a.40."+i,manifestCodec:c};t.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${A}`})}(e,n,r,i);if(!o)return;t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,Un.log(`parsed codec:${t.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function rs(t){return 9216e4/t}function is(t,e,n,r,i){const o=r+i*rs(t.samplerate),s=function(t,e){const n=Jo(t,e);if(e+n<=t.length){const r=Zo(t,e)-n;if(r>0)return{headerLength:n,frameLength:r}}}(e,n);let a;if(s){const{frameLength:r,headerLength:i}=s,l=i+r,c=Math.max(0,n+l-e.length);c?(a=new Uint8Array(l-i),a.set(e.subarray(n+i,e.length),0)):a=e.subarray(n+i,n+l);const u={unit:a,pts:o};return c||t.samples.push(u),{sample:u,length:l,missing:c}}const l=e.length-n;return a=new Uint8Array(l),a.set(e.subarray(n,e.length),0),{sample:{unit:a,pts:o},length:l,missing:-1}}const os=/\/emsg[-/]ID3/i;let ss=null;const as=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],ls=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],cs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],us=[0,1,1,4];function As(t,e,n,r,i){if(n+24>e.length)return;const o=ds(e,n);if(o&&n+o.frameLength<=e.length){const s=r+i*(9e4*o.samplesPerFrame/o.sampleRate),a={unit:e.subarray(n,n+o.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=o.channelCount,t.samplerate=o.sampleRate,t.samples.push(a),{sample:a,length:o.frameLength,missing:0}}}function ds(t,e){const n=t[e+1]>>3&3,r=t[e+1]>>1&3,i=t[e+2]>>4&15,o=t[e+2]>>2&3;if(1!==n&&0!==i&&15!==i&&3!==o){const s=t[e+2]>>1&1,a=t[e+3]>>6,l=1e3*as[14*(3===n?3-r:3===r?3:4)+i-1],c=ls[3*(3===n?0:2===n?1:2)+o],u=3===a?1:2,A=cs[n][r],d=us[r],h=8*A*d,f=Math.floor(A*l/c+s)*d;if(null===ss){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ss=t?parseInt(t[1]):0}return!!ss&&ss<=87&&2===r&&l>=224e3&&0===a&&(t[e+3]=128|t[e+3]),{sampleRate:c,channelCount:u,frameLength:f,samplesPerFrame:h}}}function hs(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function fs(t,e){return e+1t?(this.word<<=t,this.bitsAvailable-=t):(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const n=this.word>>>32-e;if(t>32&&Un.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return e=t-e,e>0&&this.bitsAvailable?n<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e,n=8,r=8;for(let i=0;i{const o=new Uint8Array(i);r.set(o,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,n)}))}decryptAacSamples(t,e,n){for(;;e++){if(e>=t.length)return void n();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,n),this.decrypter.isSync())))return}}getAvcEncryptedData(t){const e=16*Math.floor((t.length-48)/160)+16,n=new Int8Array(e);let r=0;for(let e=32;e{i.data=this.getAvcDecryptedUnit(o,s),this.decrypter.isSync()||this.decryptAvcSamples(t,e,n+1,r)}))}decryptAvcSamples(t,e,n,r){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,n=0){if(e>=t.length)return void r();const i=t[e].units;for(;!(n>=i.length);n++){const o=i[n];if(!(o.data.length<=48||1!==o.type&&5!==o.type||(this.decryptAvcSample(t,e,n,r,o),this.decrypter.isSync())))return}}}}const vs=188;class ys{constructor(t,e,n){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=n}static probe(t){const e=ys.syncOffset(t);return e>0&&Un.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),-1!==e}static syncOffset(t){const e=t.length;let n=Math.min(940,t.length-vs)+1,r=0;for(;r1&&(0===o&&s>2||a+vs>n))return o}r++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Dr[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,n,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=ys.createTrack("video"),this._audioTrack=ys.createTrack("audio",r),this._id3Track=ys.createTrack("id3"),this._txtTrack=ys.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=n,this._duration=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:n}=this;t&&(t.pesData=null),e&&(e.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,n=!1,r=!1){let i;n||(this.sampleAes=null);const o=this._avcTrack,s=this._audioTrack,a=this._id3Track,l=this._txtTrack;let c=o.pid,u=o.pesData,A=s.pid,d=a.pid,h=s.pesData,f=a.pesData,p=null,g=this.pmtParsed,m=this._pmtId,v=t.length;if(this.remainderData&&(v=(t=Wr(this.remainderData,t)).length,this.remainderData=null),v>4>1){if(C=e+5+t[e+4],C===e+vs)continue}else C=e+4;switch(v){case c:r&&(u&&(i=Ts(u))&&this.parseAVCPES(o,l,i,!1),u={data:[],size:0}),u&&(u.data.push(t.subarray(C,e+vs)),u.size+=e+vs-C);break;case A:if(r){if(h&&(i=Ts(h)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,i);break;case"mp3":this.parseMPEGPES(s,i)}h={data:[],size:0}}h&&(h.data.push(t.subarray(C,e+vs)),h.size+=e+vs-C);break;case d:r&&(f&&(i=Ts(f))&&this.parseID3PES(a,i),f={data:[],size:0}),f&&(f.data.push(t.subarray(C,e+vs)),f.size+=e+vs-C);break;case 0:r&&(C+=t[C]+1),m=this._pmtId=Es(t,C);break;case m:{r&&(C+=t[C]+1);const i=ws(t,C,this.typeSupported,n);c=i.avc,c>0&&(o.pid=c),A=i.audio,A>0&&(s.pid=A,s.segmentCodec=i.segmentCodec),d=i.id3,d>0&&(a.pid=d),null===p||g||(Un.warn(`MPEG-TS PMT found at ${e} after unknown PID '${p}'. Backtracking to sync byte @${y} to parse all TS packets.`),p=null,e=y-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=v}}else C++;if(C>0){const t=new Error(`Found ${C} TS packet/s that do not start with 0x47`);this.observer.emit(Pn.ERROR,Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message})}o.pesData=u,s.pesData=h,a.pesData=f;const b={audioTrack:s,videoTrack:o,id3Track:a,textTrack:l};return r&&this.extractRemainingSamples(b),b}flush(){const{remainderData:t}=this;let e;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:n,id3Track:r,textTrack:i}=t,o=n.pesData,s=e.pesData,a=r.pesData;let l;if(o&&(l=Ts(o))?(this.parseAVCPES(n,i,l,!0),n.pesData=null):n.pesData=o,s&&(l=Ts(s))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,l);break;case"mp3":this.parseMPEGPES(e,l)}e.pesData=null}else null!=s&&s.size&&Un.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=s;a&&(l=Ts(a))?(this.parseID3PES(r,l),r.pesData=null):r.pesData=a}demuxSampleAes(t,e,n){const r=this.demux(t,n,!0,!this.config.progressive),i=this.sampleAes=new ms(this.observer,this.config,e);return this.decrypt(r,i)}decrypt(t,e){return new Promise((n=>{const{audioTrack:r,videoTrack:i}=t;r.samples&&"aac"===r.segmentCodec?e.decryptAacSamples(r.samples,0,(()=>{i.samples?e.decryptAvcSamples(i.samples,0,0,(()=>{n(t)})):n(t)})):i.samples&&e.decryptAvcSamples(i.samples,0,0,(()=>{n(t)}))}))}destroy(){this._duration=0}parseAVCPES(t,e,n,r){const i=this.parseAVCNALu(t,n.data);let o,s=this.avcSample,a=!1;n.data=null,s&&i.length&&!t.audFound&&(Ss(s,t),s=this.avcSample=Cs(!1,n.pts,n.dts,"")),i.forEach((r=>{var i;switch(r.type){case 1:{let e=!1;o=!0;const i=r.data;if(a&&i.length>4){const t=new gs(i).readSliceType();2!==t&&4!==t&&7!==t&&9!==t||(e=!0)}var l;e&&null!=(l=s)&&l.frame&&!s.key&&(Ss(s,t),s=this.avcSample=null),s||(s=this.avcSample=Cs(!0,n.pts,n.dts,"")),s.frame=!0,s.key=e;break}case 5:o=!0,null!=(i=s)&&i.frame&&!s.key&&(Ss(s,t),s=this.avcSample=null),s||(s=this.avcSample=Cs(!0,n.pts,n.dts,"")),s.key=!0,s.frame=!0;break;case 6:o=!0,Hr(r.data,1,n.pts,e.samples);break;case 7:if(o=!0,a=!0,!t.sps){const e=r.data,n=new gs(e).readSPS();t.width=n.width,t.height=n.height,t.pixelRatio=n.pixelRatio,t.sps=[e],t.duration=this._duration;const i=e.subarray(1,4);let o="avc1.";for(let t=0;t<3;t++){let e=i[t].toString(16);e.length<2&&(e="0"+e),o+=e}t.codec=o}break;case 8:o=!0,t.pps||(t.pps=[r.data]);break;case 9:o=!1,t.audFound=!0,s&&Ss(s,t),s=this.avcSample=Cs(!1,n.pts,n.dts,"");break;case 12:o=!0;break;default:o=!1,s&&(s.debug+="unknown NAL "+r.type+" ")}s&&o&&s.units.push(r)})),r&&s&&(Ss(s,t),this.avcSample=null)}getLastNalUnit(t){var e;let n,r=this.avcSample;if(r&&0!==r.units.length||(r=t[t.length-1]),null!=(e=r)&&e.units){const t=r.units;n=t[t.length-1]}return n}parseAVCNALu(t,e){const n=e.byteLength;let r=t.naluState||0;const i=r,o=[];let s,a,l,c=0,u=-1,A=0;for(-1===r&&(u=0,A=31&e[0],r=0,c=1);c=0){const t={data:e.subarray(u,c-r-1),type:A};o.push(t)}else{const n=this.getLastNalUnit(t.samples);if(n&&(i&&c<=4-i&&n.state&&(n.data=n.data.subarray(0,n.data.byteLength-i)),a=c-r-1,a>0)){const t=new Uint8Array(n.data.byteLength+a);t.set(n.data,0),t.set(e.subarray(0,a),n.data.byteLength),n.data=t,n.state=0}}c=0&&r>=0){const t={data:e.subarray(u,n),type:A,state:r};o.push(t)}if(0===o.length){const n=this.getLastNalUnit(t.samples);if(n){const t=new Uint8Array(n.data.byteLength+e.byteLength);t.set(n.data,0),t.set(e,n.data.byteLength),n.data=t}}return t.naluState=r,o}parseAACPES(t,e){let n=0;const r=this.aacOverFlow;let i,o,s,a=e.data;if(r){this.aacOverFlow=null;const e=r.missing,i=r.sample.unit.byteLength;if(-1===e){const t=new Uint8Array(i+a.byteLength);t.set(r.sample.unit,0),t.set(a,i),a=t}else{const o=i-e;r.sample.unit.set(a.subarray(0,e),o),t.samples.push(r.sample),n=r.missing}}for(i=n,o=a.length;i1;){const t=new Uint8Array(a[0].length+a[1].length);t.set(a[0]),t.set(a[1],a[0].length),a[0]=t,a.splice(1,1)}if(e=a[0],1===(e[0]<<16)+(e[1]<<8)+e[2]){if(n=(e[4]<<8)+e[5],n&&n>t.size-6)return null;const l=e[7];192&l&&(i=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&l?(o=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,i-o>54e5&&(Un.warn(`${Math.round((i-o)/9e4)}s delta between PTS and DTS, align them`),i=o)):o=i),r=e[8];let c=r+9;if(t.size<=c)return null;t.size-=c;const u=new Uint8Array(t.size);for(let t=0,n=a.length;tn){c-=n;continue}e=e.subarray(c),n-=c,c=0}u.set(e,s),s+=n}return n&&(n-=r+3),{data:u,pts:i,dts:o,len:n}}return null}function Ss(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const n=e.samples,r=n.length;if(!r)return void e.dropped++;{const e=n[r-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&Un.log(t.pts+"/"+t.dts+":"+t.debug)}class ks{static getSilentFrame(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const Ls=Math.pow(2,32)-1;class xs{static init(){let t;for(t in xs.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},xs.types)xs.types.hasOwnProperty(t)&&(xs.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);xs.HDLR_TYPES={video:e,audio:n};const r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);xs.STTS=xs.STSC=xs.STCO=i,xs.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),xs.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),xs.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),xs.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);xs.FTYP=xs.box(xs.types.ftyp,o,a,o,s),xs.DINF=xs.box(xs.types.dinf,xs.box(xs.types.dref,r))}static box(t,...e){let n=8,r=e.length;const i=r;for(;r--;)n+=e[r].byteLength;const o=new Uint8Array(n);for(o[0]=n>>24&255,o[1]=n>>16&255,o[2]=n>>8&255,o[3]=255&n,o.set(t,4),r=0,n=8;r>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))}static mdia(t){return xs.box(xs.types.mdia,xs.mdhd(t.timescale,t.duration),xs.hdlr(t.type),xs.minf(t))}static mfhd(t){return xs.box(xs.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?xs.box(xs.types.minf,xs.box(xs.types.smhd,xs.SMHD),xs.DINF,xs.stbl(t)):xs.box(xs.types.minf,xs.box(xs.types.vmhd,xs.VMHD),xs.DINF,xs.stbl(t))}static moof(t,e,n){return xs.box(xs.types.moof,xs.mfhd(t),xs.traf(n,e))}static moov(t){let e=t.length;const n=[];for(;e--;)n[e]=xs.trak(t[e]);return xs.box.apply(null,[xs.types.moov,xs.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(xs.mvex(t)))}static mvex(t){let e=t.length;const n=[];for(;e--;)n[e]=xs.trex(t[e]);return xs.box.apply(null,[xs.types.mvex,...n])}static mvhd(t,e){e*=t;const n=Math.floor(e/(Ls+1)),r=Math.floor(e%(Ls+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return xs.box(xs.types.mvhd,i)}static sdtp(t){const e=t.samples||[],n=new Uint8Array(4+e.length);let r,i;for(r=0;r>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(n));for(e=0;e>>8&255),o.push(255&r),o=o.concat(Array.prototype.slice.call(n));const s=xs.box(xs.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|t.sps.length].concat(i).concat([t.pps.length]).concat(o))),a=t.width,l=t.height,c=t.pixelRatio[0],u=t.pixelRatio[1];return xs.box(xs.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,xs.box(xs.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),xs.box(xs.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return xs.box(xs.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),xs.box(xs.types.esds,xs.esds(t)))}static mp3(t){const e=t.samplerate;return xs.box(xs.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?xs.box(xs.types.stsd,xs.STSD,xs.mp3(t)):xs.box(xs.types.stsd,xs.STSD,xs.mp4a(t)):xs.box(xs.types.stsd,xs.STSD,xs.avc1(t))}static tkhd(t){const e=t.id,n=t.duration*t.timescale,r=t.width,i=t.height,o=Math.floor(n/(Ls+1)),s=Math.floor(n%(Ls+1));return xs.box(xs.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))}static traf(t,e){const n=xs.sdtp(t),r=t.id,i=Math.floor(e/(Ls+1)),o=Math.floor(e%(Ls+1));return xs.box(xs.types.traf,xs.box(xs.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),xs.box(xs.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,o>>24,o>>16&255,o>>8&255,255&o])),xs.trun(t,n.length+16+20+8+16+8+8),n)}static trak(t){return t.duration=t.duration||4294967295,xs.box(xs.types.trak,xs.tkhd(t),xs.mdia(t))}static trex(t){const e=t.id;return xs.box(xs.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const n=t.samples||[],r=n.length,i=12+16*r,o=new Uint8Array(i);let s,a,l,c,u,A;for(e+=8+i,o.set(["video"===t.type?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),s=0;s>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,A>>>24&255,A>>>16&255,A>>>8&255,255&A],12+16*s);return xs.box(xs.types.trun,o)}static initSegment(t){xs.types||xs.init();const e=xs.moov(t),n=new Uint8Array(xs.FTYP.byteLength+e.byteLength);return n.set(xs.FTYP),n.set(e,xs.FTYP.byteLength),n}}function Is(t,e,n=1,r=!1){const i=t*e*n;return r?Math.round(i):i}function Rs(t,e=!1){return Is(t,1e3,1/9e4,e)}xs.types=void 0,xs.HDLR_TYPES=void 0,xs.STTS=void 0,xs.STSC=void 0,xs.STCO=void 0,xs.STSZ=void 0,xs.VMHD=void 0,xs.SMHD=void 0,xs.STSD=void 0,xs.FTYP=void 0,xs.DINF=void 0;let Ds,Bs=null,Ps=null;class Ms{constructor(t,e,n,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=n,this.ISGenerated=!1,null===Bs){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Bs=t?parseInt(t[1]):0}if(null===Ps){const t=navigator.userAgent.match(/Safari\/(\d+)/i);Ps=t?parseInt(t[1]):0}}destroy(){}resetTimeStamp(t){Un.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){Un.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Un.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const n=t.reduce(((t,n)=>{const r=n.pts-t;return r<-4294967296?(e=!0,Os(t,n.pts)):r>0?t:n.pts}),t[0].pts);return e&&Un.debug("PTS rollover detected"),n}remux(t,e,n,r,i,o,s,a){let l,c,u,A,d,h,f=i,p=i;const g=t.pid>-1,m=e.pid>-1,v=e.samples.length,y=t.samples.length>0,C=s&&v>0||v>1;if((!g||y)&&(!m||C)||this.ISGenerated||s){this.ISGenerated||(u=this.generateIS(t,e,i,o));const n=this.isVideoContiguous;let r,s=-1;if(C&&(s=function(t){for(let e=0;e0){Un.warn(`[mp4-remuxer]: Dropped ${s} out of ${v} video samples due to a missing keyframe`);const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(s),e.dropped+=s,p+=(e.samples[0].pts-t)/e.inputTimeScale,r=p}else-1===s&&(Un.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),h=!1);if(this.ISGenerated){if(y&&C){const n=this.getVideoStartPts(e.samples),r=(Os(t.samples[0].pts,n)-n)/e.inputTimeScale;f+=Math.max(0,r),p+=Math.max(0,-r)}if(y){if(t.samplerate||(Un.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(t,e,i,o)),c=this.remuxAudio(t,f,this.isAudioContiguous,o,m||C||a===wi?p:void 0),C){const r=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(Un.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(t,e,i,o)),l=this.remuxVideo(e,p,n,r)}}else C&&(l=this.remuxVideo(e,p,n,0));l&&(l.firstKeyFrame=s,l.independent=-1!==s,l.firstKeyFramePTS=r)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(n.samples.length&&(d=Fs(n,i,this._initPTS,this._initDTS)),r.samples.length&&(A=_s(r,i,this._initPTS))),{audio:c,video:l,initSegment:u,independent:h,text:A,id3:d}}generateIS(t,e,n,r){const i=t.samples,o=e.samples,s=this.typeSupported,a={},l=this._initPTS;let c,u,A,d=!l||r,h="audio/mp4";if(d&&(c=u=1/0),t.config&&i.length&&(t.timescale=t.samplerate,"mp3"===t.segmentCodec&&(s.mpeg?(h="audio/mpeg",t.codec=""):s.mp3&&(t.codec="mp3")),a.audio={id:"audio",container:h,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&s.mpeg?new Uint8Array(0):xs.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(A=t.inputTimeScale,l&&A===l.timescale?d=!1:c=u=i[0].pts-Math.round(A*n))),e.sps&&e.pps&&o.length&&(e.timescale=e.inputTimeScale,a.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:xs.initSegment([e]),metadata:{width:e.width,height:e.height}},d))if(A=e.inputTimeScale,l&&A===l.timescale)d=!1;else{const t=this.getVideoStartPts(o),e=Math.round(A*n);u=Math.min(u,Os(o[0].dts,t)-e),c=Math.min(c,t-e)}if(Object.keys(a).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:c,timescale:A},this._initDTS={baseTime:u,timescale:A}):c=A=void 0,{tracks:a,initPTS:c,timescale:A}}remuxVideo(t,e,n,r){const i=t.inputTimeScale,o=t.samples,s=[],a=o.length,l=this._initPTS;let c,u,A=this.nextAvcDts,d=8,h=this.videoSampleDuration,f=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=!1;n&&null!==A||(A=e*i-(o[0].pts-Os(o[0].dts,o[0].pts)));const m=l.baseTime*i/l.timescale;for(let t=0;t0?t-1:t].dts&&(g=!0)}g&&o.sort((function(t,e){const n=t.dts-e.dts,r=t.pts-e.pts;return n||r})),c=o[0].dts,u=o[o.length-1].dts;const v=u-c,y=v?Math.round(v/(a-1)):h||t.inputTimeScale/30;if(n){const t=c-A,e=t>y,n=t<-1;if((e||n)&&(e?Un.warn(`AVC: ${Rs(t,!0)} ms (${t}dts) hole between fragments detected, filling it`):Un.warn(`AVC: ${Rs(-t,!0)} ms (${t}dts) overlapping between fragments detected`),!n||A>=o[0].pts)){c=A;const e=o[0].pts-t;o[0].dts=c,o[0].pts=e,Un.log(`Video: First PTS/DTS adjusted: ${Rs(e,!0)}/${Rs(c,!0)}, delta: ${Rs(t,!0)} ms`)}}c=Math.max(0,c);let C=0,b=0;for(let t=0;t0?e.dts-o[t-1].dts:y;if(l=t>0?e.pts-o[t-1].pts:y,n.stretchShortVideoTrack&&null!==this.nextAudioPts){const t=Math.floor(n.maxBufferHole*i),o=(r?f+r*i:this.nextAudioPts)-e.pts;o>t?(h=o-s,h<0?h=s:S=!0,Un.log(`[mp4-remuxer]: It is approximately ${o/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=s}else h=s}const u=Math.round(e.pts-e.dts);k=Math.min(k,h),x=Math.max(x,h),L=Math.min(L,l),I=Math.max(I,l),s.push(new Ns(e.key,h,c,u))}if(s.length)if(Bs){if(Bs<70){const t=s[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(Ps&&I-L0&&(r&&Math.abs(g-p)<9e3||Math.abs(Os(h[0].pts-m,g)-p)<20*l),h.forEach((function(t){t.pts=Os(t.pts-m,g)})),!n||p<0){if(h=h.filter((t=>t.pts>=0)),!h.length)return;p=0===i?0:r&&!d?Math.max(0,g):h[0].pts}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let n=0,r=p;n=e*l&&c<1e4&&d){let e=Math.round(a/l);r=s-e*l,r<0&&(e--,r+=l),0===n&&(this.nextAudioPts=p=r),Un.warn(`[mp4-remuxer]: Injecting ${e} audio frame @ ${(r/o).toFixed(3)}s due to ${Math.round(1e3*a/o)} ms gap.`);for(let o=0;o0))return;b+=f;try{v=new Uint8Array(b)}catch(t){return void this.observer.emit(Pn.ERROR,Pn.ERROR,{type:Mn.MUX_ERROR,details:On.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:b,reason:`fail allocating audio mdat ${b}`})}u||(new DataView(v.buffer).setUint32(0,b),v.set(xs.types.mdat,4))}v.set(i,f);const l=i.byteLength;f+=l,A.push(new Ns(!0,a,l,0)),C=o}const w=A.length;if(!w)return;const T=A[A.length-1];this.nextAudioPts=p=C+s*T.duration;const S=u?new Uint8Array(0):xs.moof(t.sequenceNumber++,y/s,Dn({},t,{samples:A}));t.samples=[];const k=y/o,L=p/o,x={data1:S,data2:v,startPTS:k,endPTS:L,startDTS:k,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:w};return this.isAudioContiguous=!0,x}remuxEmptyAudio(t,e,n,r){const i=t.inputTimeScale,o=i/(t.samplerate?t.samplerate:i),s=this.nextAudioPts,a=this._initDTS,l=9e4*a.baseTime/a.timescale,c=(null!==s?s:r.startDTS*i)+l,u=r.endDTS*i+l,A=1024*o,d=Math.ceil((u-c)/A),h=ks.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(Un.warn("[mp4-remuxer]: remux empty Audio"),!h)return void Un.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const f=[];for(let t=0;t4294967296;)t+=n;return t}function Fs(t,e,n,r){const i=t.samples.length;if(!i)return;const o=t.inputTimeScale;for(let s=0;st.pts-e.pts));const o=t.samples;return t.samples=[],{samples:o}}class Ns{constructor(t,e,n,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=n,this.cts=r,this.flags=new Us(t)}}class Us{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}function Qs(t,e){const n=null==t?void 0:t.codec;return n&&n.length>4?n:"hvc1"===n||"hev1"===n?"hvc1.1.6.L120.90":"av01"===n?"av01.0.04M.08":"avc1"===n||e===Vn?"avc1.42e01e":"mp4a.40.5"}try{Ds=self.performance.now.bind(self.performance)}catch(t){Un.debug("Unable to use Performance API on this environment"),Ds="undefined"!=typeof self&&self.Date.now}const Gs=[{demux:class{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,n,r){const i=this.videoTrack=zo("video",1),o=this.audioTrack=zo("audio",1),s=this.txtTrack=zo("text",1);if(this.id3Track=zo("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const a=Ur(t);if(a.video){const{id:t,timescale:e,codec:n}=a.video;i.id=t,i.timescale=s.timescale=e,i.codec=n}if(a.audio){const{id:t,timescale:e,codec:n}=a.audio;o.id=t,o.timescale=e,o.codec=n}s.id=Dr.text,i.sampleDuration=0,i.duration=o.duration=r}resetContiguity(){this.remainderData=null}static probe(t){return _r(t=t.length>16384?t.subarray(0,16384):t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let n=t;const r=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(n=Wr(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},n=_r(t,["moof"]);if(!n)return e;if(n.length<2)return e.remainder=t,e;const r=n[n.length-1];return e.valid=Ar(t,0,r.byteOffset-8),e.remainder=Ar(t,r.byteOffset-8),e}(n);this.remainderData=e.remainder,r.samples=e.valid||new Uint8Array}else r.samples=n;const o=this.extractID3Track(r,e);return i.samples=Yr(e,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,n=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(e,this.timeOffset);return n.samples=Yr(t,e),{videoTrack:e,audioTrack:zo(),id3Track:r,textTrack:zo()}}extractID3Track(t,e){const n=this.id3Track;if(t.samples.length){const r=_r(t.samples,["emsg"]);r&&r.forEach((t=>{const r=function(t){const e=t[0];let n="",r="",i=0,o=0,s=0,a=0,l=0,c=0;if(0===e){for(;"\0"!==Br(t.subarray(c,c+1));)n+=Br(t.subarray(c,c+1)),c+=1;for(n+=Br(t.subarray(c,c+1)),c+=1;"\0"!==Br(t.subarray(c,c+1));)r+=Br(t.subarray(c,c+1)),c+=1;r+=Br(t.subarray(c,c+1)),c+=1,i=Mr(t,12),o=Mr(t,16),a=Mr(t,20),l=Mr(t,24),c=28}else if(1===e){c+=4,i=Mr(t,c),c+=4;const e=Mr(t,c);c+=4;const o=Mr(t,c);for(c+=4,s=2**32*e+o,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,Un.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),a=Mr(t,c),c+=4,l=Mr(t,c),c+=4;"\0"!==Br(t.subarray(c,c+1));)n+=Br(t.subarray(c,c+1)),c+=1;for(n+=Br(t.subarray(c,c+1)),c+=1;"\0"!==Br(t.subarray(c,c+1));)r+=Br(t.subarray(c,c+1)),c+=1;r+=Br(t.subarray(c,c+1)),c+=1}return{schemeIdUri:n,value:r,timeScale:i,presentationTime:s,presentationTimeDelta:o,eventDuration:a,id:l,payload:t.subarray(c,t.byteLength)}}(t);if(os.test(r.schemeIdUri)){const t=Bn(r.presentationTime)?r.presentationTime/r.timeScale:e+r.presentationTimeDelta/r.timeScale;let i=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;i<=.001&&(i=Number.POSITIVE_INFINITY);const o=r.payload;n.samples.push({data:o,len:o.byteLength,dts:t,pts:t,type:Pi,duration:i})}}))}return n}demuxSampleAes(t,e,n){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,n,r){this.audioCodec=e,this.videoCodec=n,this.generateInitSegment(function(t,e){if(!t||!e)return t;const n=e.keyId;return n&&e.isCommonEncryption&&_r(t,["moov","trak"]).forEach((t=>{const e=_r(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let r=_r(e,["enca"]);const i=r.length>0;i||(r=_r(e,["encv"])),r.forEach((t=>{_r(i?t.subarray(28):t.subarray(78),["sinf"]).forEach((t=>{const e=Qr(t);if(e){const t=e.subarray(8,24);t.some((t=>0!==t))||(Un.log(`[eme] Patching keyId in 'enc${i?"a":"v"}>sinf>>tenc' box: ${xr(t)} -> ${xr(n)}`),e.set(n,8))}}))}))})),t}(t,r)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:n}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const r=this.initData=Ur(t);e||(e=Qs(r.audio,Kn)),n||(n=Qs(r.video,Vn));const i={};r.audio&&r.video?i.audiovideo={container:"video/mp4",codec:e+","+n,initSegment:t,id:"main"}:r.audio?i.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:r.video?i.video={container:"video/mp4",codec:n,initSegment:t,id:"main"}:Un.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i}remux(t,e,n,r,i,o){var s,a;let{initPTS:l,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:r,id3:n,initSegment:void 0};Bn(c)||(c=this.lastEndTime=i||0);const A=e.samples;if(null==A||!A.length)return u;const d={initPTS:void 0,timescale:1};let h=this.initData;if(null!=(s=h)&&s.length||(this.generateInitSegment(A),h=this.initData),null==(a=h)||!a.length)return Un.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);const f=function(t,e){let n=0,r=0,i=0;const o=_r(t,["moof","traf"]);for(let t=0;tt+e.info.duration||0),0))}return e}return r||i}(A,h),p=function(t,e){return _r(e,["moof","traf"]).reduce(((e,n)=>{const r=_r(n,["tfdt"])[0],i=r[0],o=_r(n,["tfhd"]).reduce(((e,n)=>{const o=Mr(n,4),s=t[o];if(s){let t=Mr(r,4);if(1===i){if(t===Ir)return Un.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=Ir+1,t+=Mr(r,8)}const n=t/(s.timescale||9e4);if(isFinite(n)&&(null===e||ni}(l,g,i,f)||d.timescale!==l.timescale&&o)&&(d.initPTS=g-i,l&&1===l.timescale&&Un.warn("Adjusting initPTS by "+(d.initPTS-l.baseTime)),this.initPTS=l={baseTime:d.initPTS,timescale:1});const m=t?g-l.baseTime/l.timescale:c,v=m+f;!function(t,e,n){_r(e,["moof","traf"]).forEach((e=>{_r(e,["tfhd"]).forEach((r=>{const i=Mr(r,4),o=t[i];if(!o)return;const s=o.timescale||9e4;_r(e,["tfdt"]).forEach((t=>{const e=t[0];let r=Mr(t,4);if(0===e)r-=n*s,r=Math.max(r,0),Fr(t,4,r);else{r*=Math.pow(2,32),r+=Mr(t,8),r-=n*s,r=Math.max(r,0);const e=Math.floor(r/(Ir+1)),i=Math.floor(r%(Ir+1));Fr(t,4,e),Fr(t,8,i)}}))}))}))}(h,A,l.baseTime/l.timescale),f>0?this.lastEndTime=v:(Un.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const y=!!h.audio,C=!!h.video;let b="";y&&(b+="audio"),C&&(b+="video");const E={data1:A,startPTS:m,startDTS:m,endPTS:v,endDTS:v,type:b,hasAudio:y,hasVideo:C,nb:1,dropped:0};return u.audio="audio"===E.type?E:void 0,u.video="audio"!==E.type?E:void 0,u.initSegment=d,u.id3=Fs(n,i,l,l),r.samples.length&&(u.text=_s(r,i,l)),u}}},{demux:ys,remux:Ms},{demux:class extends $o{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,n,r){super.resetInitSegment(t,e,n,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(fr(t,0)||[]).length;for(let n=t.length;e0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(n=e),n}(o,e);if(y&&"AES-128"===y.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(o,y.key.buffer,y.iv.buffer).then((t=>{const e=this.push(t,null,n);return this.decryptionPromise=null,e})),this.decryptionPromise;{let e=t.softwareDecrypt(o,y.key.buffer,y.iv.buffer);if(n.part>-1&&(e=t.flush()),!e)return i.executeEnd=Ds(),Ys(n);o=new Uint8Array(e)}}const C=this.needsProbing(c,u);if(C){const t=this.configureTransmuxer(o);if(t)return Un.warn(`[transmuxer] ${t.message}`),this.observer.emit(Pn.ERROR,Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),i.executeEnd=Ds(),Ys(n)}(c||u||h||C)&&this.resetInitSegment(v,f,p,m,e),(c||h||C)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const b=this.transmux(o,y,d,A,n),E=this.currentTransmuxState;return E.contiguous=!0,E.discontinuity=!1,E.trackSwitch=!1,i.executeEnd=Ds(),b}flush(t){const e=t.transmuxing;e.executeStart=Ds();const{decrypter:n,currentTransmuxState:r,decryptionPromise:i}=this;if(i)return i.then((()=>this.flush(t)));const o=[],{timeOffset:s}=r;if(n){const e=n.flush();e&&o.push(this.push(e,null,t))}const{demuxer:a,remuxer:l}=this;if(!a||!l)return e.executeEnd=Ds(),[Ys(t)];const c=a.flush(s);return js(c)?c.then((e=>(this.flushRemux(o,e,t),o))):(this.flushRemux(o,c,t),o)}flushRemux(t,e,n){const{audioTrack:r,videoTrack:i,id3Track:o,textTrack:s}=e,{accurateTimeOffset:a,timeOffset:l}=this.currentTransmuxState;Un.log(`[transmuxer.ts]: Flushed fragment ${n.sn}${n.part>-1?" p: "+n.part:""} of level ${n.level}`);const c=this.remuxer.remux(r,i,o,s,l,a,!0,this.id);t.push({remuxResult:c,chunkMeta:n}),n.transmuxing.executeEnd=Ds()}resetInitialTimestamp(t){const{demuxer:e,remuxer:n}=this;e&&n&&(e.resetTimeStamp(t),n.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,n,r,i){const{demuxer:o,remuxer:s}=this;o&&s&&(o.resetInitSegment(t,e,n,r),s.resetInitSegment(t,e,n,i))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,n,r,i){let o;return o=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,n,r,i):this.transmuxUnencrypted(t,n,r,i),o}transmuxUnencrypted(t,e,n,r){const{audioTrack:i,videoTrack:o,id3Track:s,textTrack:a}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(i,o,s,a,e,n,!1,this.id),chunkMeta:r}}transmuxSampleAes(t,e,n,r,i){return this.demuxer.demuxSampleAes(t,e,n).then((t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,n,r,!1,this.id),chunkMeta:i})))}configureTransmuxer(t){const{config:e,observer:n,typeSupported:r,vendor:i}=this;let o;for(let e=0,n=Gs.length;e({remuxResult:{},chunkMeta:t});function js(t){return"then"in t&&t.then instanceof Function}class Hs{constructor(t,e,n,r,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=n,this.duration=r,this.defaultInitPts=i||null}}class Ks{constructor(t,e,n,r,i,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=n,this.trackSwitch=r,this.timeOffset=i,this.initSegmentChange=o}}var Vs={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||t,s),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i!1};class Xs{constructor(t,e,n,r){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const i=t.config;this.hls=t,this.id=e,this.useWorker=!!i.enableWorker,this.onTransmuxComplete=n,this.onFlush=r;const o=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===Pn.ERROR&&(this.error=e.error),this.hls.trigger(t,e)};this.observer=new zs,this.observer.on(Pn.FRAG_DECRYPTED,o),this.observer.on(Pn.ERROR,o);const s={mp4:$s.isTypeSupported("video/mp4"),mpeg:$s.isTypeSupported("audio/mpeg"),mp3:$s.isTypeSupported('audio/mp4; codecs="mp3"')},a=navigator.vendor;if(!this.useWorker||"undefined"==typeof Worker||!i.workerPath&&"function"!=typeof __HLS_WORKER_BUNDLE__)this.transmuxer=new Ws(this.observer,s,i,a,e);else try{i.workerPath?(Un.log(`loading Web Worker ${i.workerPath} for "${e}"`),this.workerContext=function(t){const e=new self.URL(t,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}(i.workerPath)):(Un.log(`injecting Web Worker for "${e}"`),this.workerContext=function(){const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(t);return{worker:new self.Worker(e),objectURL:e}}()),this.onwmsg=t=>this.onWorkerMessage(t);const{worker:t}=this.workerContext;t.addEventListener("message",this.onwmsg),t.onerror=t=>{const n=new Error(`${t.message} (${t.filename}:${t.lineno})`);i.enableWorker=!1,Un.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:n})},t.postMessage({cmd:"init",typeSupported:s,vendor:a,id:e,config:JSON.stringify(i)})}catch(t){Un.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new Ws(this.observer,s,i,a,e)}}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,n,r,i,o,s,a,l,c){var u,A;l.transmuxing.start=self.performance.now();const{transmuxer:d}=this,h=o?o.start:i.start,f=i.decryptdata,p=this.frag,g=!(p&&i.cc===p.cc),m=!(p&&l.level===p.level),v=p?l.sn-p.sn:-1,y=this.part?l.part-this.part.index:-1,C=0===v&&l.id>1&&l.id===(null==p?void 0:p.stats.chunkCount),b=!m&&(1===v||0===v&&(1===y||C&&y<=0)),E=self.performance.now();(m||v||0===i.stats.parsing.start)&&(i.stats.parsing.start=E),!o||!y&&b||(o.stats.parsing.start=E);const w=!(p&&(null==(u=i.initSegment)?void 0:u.url)===(null==(A=p.initSegment)?void 0:A.url)),T=new Ks(g,b,a,m,h,w);if(!b||g||w){Un.log(`[transmuxer-interface, ${i.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${g}\n trackSwitch: ${m}\n contiguous: ${b}\n accurateTimeOffset: ${a}\n timeOffset: ${h}\n initSegmentChange: ${w}`);const t=new Hs(n,r,e,s,c);this.configureTransmuxer(t)}if(this.frag=i,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:f,chunkMeta:l,state:T},t instanceof ArrayBuffer?[t]:[]);else if(d){const e=d.push(t,f,l,T);js(e)?(d.async=!0,e.then((t=>{this.handleTransmuxComplete(t)})).catch((t=>{this.transmuxerError(t,l,"transmuxer-interface push error")}))):(d.async=!1,this.handleTransmuxComplete(e))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let n=e.flush(t);js(n)||e.async?(js(n)||(n=Promise.resolve(n)),n.then((e=>{this.handleFlushResult(e,t)})).catch((e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}))):this.handleFlushResult(n,t)}}transmuxerError(t,e,n){this.hls&&(this.error=t,this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:n}))}handleFlushResult(t,e){t.forEach((t=>{this.handleTransmuxComplete(t)})),this.onFlush(e)}onWorkerMessage(t){const e=t.data,n=this.hls;switch(e.event){case"init":{var r;const t=null==(r=this.workerContext)?void 0:r.objectURL;t&&self.URL.revokeObjectURL(t);break}case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":Un[e.data.logType]&&Un[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,n.trigger(e.event,e.data)}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}class qs{constructor(t,e,n,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=n,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:n,media:r,stalled:i}=this;if(null===r)return;const{currentTime:o,seeking:s}=r,a=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,o!==t){if(this.moved=!0,null!==i){if(this.stallReported){const t=self.performance.now()-i;Un.warn(`playback not stuck anymore @${o}, after ${Math.round(t)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(l||a)return void(this.stalled=null);if(r.paused&&!s||r.ended||0===r.playbackRate||!To.getBuffered(r).length)return;const c=To.bufferInfo(r,o,0),u=c.len>0,A=c.nextStart||0;if(!u&&!A)return;if(s){const t=c.len>2,n=!A||e&&e.start<=o||A-o>2&&!this.fragmentTracker.getPartialFragment(o);if(t||n)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var d;const t=Math.max(A,c.start||0)-o,e=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,n=(null==e||null==(d=e.details)?void 0:d.live)?2*e.details.targetduration:2,r=this.fragmentTracker.getPartialFragment(o);if(t>0&&(t<=n||r))return void this._trySkipBufferHole(r)}const h=self.performance.now();if(null===i)return void(this.stalled=h);const f=h-i;if(!s&&f>=250&&(this._reportStall(c),!this.media))return;const p=To.bufferInfo(r,o,n.maxBufferHole);this._tryFixBufferStall(p,f)}_tryFixBufferStall(t,e){const{config:n,fragmentTracker:r,media:i}=this;if(null===i)return;const o=i.currentTime,s=r.getPartialFragment(o);(!s||!this._trySkipBufferHole(s)&&this.media)&&(t.len>n.maxBufferHole||t.nextStart&&t.nextStart-o1e3*n.highBufferWatchdogPeriod&&(Un.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:n,stallReported:r}=this;if(!r&&n){this.stallReported=!0;const r=new Error(`Playback stalling at @${n.currentTime} due to low buffer (${JSON.stringify(t)})`);Un.warn(r.message),e.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:n,media:r}=this;if(null===r)return 0;const i=r.currentTime,o=To.bufferInfo(r,i,0),s=i0&&o.len<1&&r.readyState<3,c=s-i;if(c>0&&(a||l)){if(c>e.maxBufferHole){const{fragmentTracker:e}=this;let n=!1;if(0===i){const t=e.getAppendedFrag(0,Ei);t&&s1?(t=0,this.bitrateTest=!0):t=n.nextAutoLevel),this.level=n.nextLoadLevel=t,this.loadedmetadata=!1}e>0&&-1===t&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Oo,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Mo}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Ho:{var t;const{levels:e,level:n}=this,r=null==e||null==(t=e[n])?void 0:t.details;if(r&&(!r.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(r))break;this.state=Oo;break}if(this.hls.nextLoadLevel!==this.level){this.state=Oo;break}break}case No:{var e;const t=self.performance.now(),n=this.retryDate;(!n||t>=n||null!=(e=this.media)&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Oo)}}this.state===Oo&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:n,media:r}=this,{config:i,nextLoadLevel:o}=t;if(null===e||!r&&(this.startFragRequested||!i.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(null==n||!n[o])return;const s=n[o],a=this.getMainFwdBufferInfo();if(null===a)return;const l=this.getLevelDetails();if(l&&this._streamEnded(a,l)){const t={};return this.altAudio&&(t.type="video"),this.hls.trigger(Pn.BUFFER_EOS,t),void(this.state=Wo)}t.loadLevel!==o&&-1===t.manualLevel&&this.log(`Adapting to level ${o} from level ${this.level}`),this.level=t.nextLoadLevel=o;const c=s.details;if(!c||this.state===Ho||c.live&&this.levelLastLoaded!==o)return this.level=o,void(this.state=Ho);const u=a.len,A=this.getMaxBufferLength(s.maxBitrate);if(u>=A)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const d=this.backtrackFragment?this.backtrackFragment.start:a.end;let h=this.getNextFragment(d,c);if(this.couldBacktrack&&!this.fragPrevious&&h&&"initSegment"!==h.sn&&this.fragmentTracker.getState(h)!==ho){var f;const t=(null!=(f=this.backtrackFragment)?f:h).sn-c.startSN,e=c.fragments[t-1];e&&h.cc===e.cc&&(h=e,this.fragmentTracker.removeFragment(e))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(h&&this.isLoopLoading(h,d)){if(!h.gap){const t=this.audioOnly&&!this.altAudio?Kn:Vn,e=(t===Vn?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,Ei)}h=this.getNextFragmentLoopLoading(h,c,a,Ei,A)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,s,d))}loadFragment(t,e,n){const r=this.fragmentTracker.getState(t);this.fragCurrent=t,r===co||r===Ao?"initSegment"===t.sn?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,n)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,Ei)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(null!=e&&e.readyState){let n;const r=this.getAppendedFrag(e.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const i=this.getLevelDetails();if(null!=i&&i.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*i.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],r=this.fragLastKbps;n=r&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*r)+1:0}else n=0;const o=this.getBufferedFrag(e.currentTime+n);if(o){const t=this.followingBufferedFrag(o);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,n=t.duration,r=Math.max(o.end,e+Math.min(Math.max(n-this.config.maxFragLookUpTolerance,.5*n),.75*n));this.flushMainBuffer(r,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Fo:case _o:case No:case Qo:case Go:this.state=Oo}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const n=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new qs(this.config,n,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;Bn(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const n=this.getMainFwdBufferInfo();null!==n&&0!==n.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${n?n.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(Pn.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let n,r=!1,i=!1;e.levels.forEach((t=>{n=t.audioCodec,n&&(-1!==n.indexOf("mp4a.40.2")&&(r=!0),-1!==n.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=r&&i&&!function(){var t;const e=Vo();return"function"==typeof(null==e||null==(t=e.prototype)?void 0:t.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:n}=this;if(!n||this.state!==Oo)return;const r=n[e.level];(!r.details||r.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(r.details))&&(this.state=Ho)}onLevelLoaded(t,e){var n;const{levels:r}=this,i=e.level,o=e.details,s=o.totalduration;if(!r)return void this.warn(`Levels were reset while loading level ${i}`);this.log(`Level ${i} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${s}`);const a=r[i],l=this.fragCurrent;!l||this.state!==_o&&this.state!==No||l.level===e.level&&l.urlId===a.urlId||!l.loader||this.abortCurrentFrag();let c=0;if(o.live||null!=(n=a.details)&&n.live){if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;c=this.alignPlaylists(o,a.details)}if(a.details=o,this.levelLastLoaded=i,this.hls.trigger(Pn.LEVEL_UPDATED,{details:o,level:i}),this.state===Ho){if(this.waitForCdnTuneIn(o))return;this.state=Oo}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,c),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:n,part:r,payload:i}=t,{levels:o}=this;if(!o)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const s=o[n.level],a=s.details;if(!a)return this.warn(`Dropping fragment ${n.sn} of level ${n.level} after level details were reset`),void this.fragmentTracker.removeFragment(n);const l=s.videoCodec,c=a.PTSKnown||!a.live,u=null==(e=n.initSegment)?void 0:e.data,A=this._getAudioCodec(s),d=this.transmuxer=this.transmuxer||new Xs(this.hls,Ei,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),h=r?r.index:-1,f=-1!==h,p=new So(n.level,n.sn,n.stats.chunkCount,i.byteLength,h,f),g=this.initPTS[n.cc];d.push(i,u,A,l,n,r,a.totalduration,c,p,g)}onAudioTrackSwitching(t,e){const n=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const t=this.fragCurrent;t&&(this.log("Switching to main audio track, cancel main fragment load"),t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const t=this.hls;n&&(t.trigger(Pn.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),t.trigger(Pn.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const n=e.id,r=!!this.hls.audioTracks[n].url;if(r){const t=this.videoBuffer;t&&this.mediaBuffer!==t&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t)}this.altAudio=r,this.tick()}onBufferCreated(t,e){const n=e.tracks;let r,i,o=!1;for(const t in n){const e=n[t];if("main"===e.id){if(i=t,r=e,"video"===t){const e=n[t];e&&(this.videoBuffer=e.buffer)}}else o=!0}o&&r?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:n,part:r}=e;if(n&&n.type!==Ei)return;if(this.fragContextChanged(n))return this.warn(`Fragment ${n.sn}${r?" p: "+r.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Go&&(this.state=Oo));const i=r?r.stats:n.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),"initSegment"!==n.sn&&(this.fragPrevious=n),this.fragBufferedComplete(n,r)}onError(t,e){var n;if(e.fatal)this.state=Yo;else switch(e.details){case On.FRAG_GAP:case On.FRAG_PARSING_ERROR:case On.FRAG_DECRYPT_ERROR:case On.FRAG_LOAD_ERROR:case On.FRAG_LOAD_TIMEOUT:case On.KEY_LOAD_ERROR:case On.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ei,e);break;case On.LEVEL_LOAD_ERROR:case On.LEVEL_LOAD_TIMEOUT:case On.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Ho||(null==(n=e.context)?void 0:n.type)!==yi||(this.state=Oo);break;case On.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case On.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}checkBuffer(){const{media:t,gapController:e}=this;if(t&&e&&t.readyState){if(this.loadedmetadata||!To.getBuffered(t).length){const t=this.state!==Oo?this.fragCurrent:null;e.poll(this.lastCurrentTime,t)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Oo,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==Kn||this.audioOnly&&!this.altAudio){const t=(e===Vn?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(t,e,Ei)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let n=this.startPosition;if(n>=0&&e0&&(i{const{hls:r}=this;if(!n||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Oo,this.startFragRequested=!1,this.bitrateTest=!1;const i=t.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),r.trigger(Pn.FRAG_LOADED,n),t.bitrateTest=!1}))}_handleTransmuxComplete(t){var e;const n="main",{hls:r}=this,{remuxResult:i,chunkMeta:o}=t,s=this.getCurrentContext(o);if(!s)return void this.resetWhenMissingContext(o);const{frag:a,part:l,level:c}=s,{video:u,text:A,id3:d,initSegment:h}=i,{details:f}=c,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(a))this.fragmentTracker.removeFragment(a);else{if(this.state=Qo,h){if(null!=h&&h.tracks){const t=a.initSegment||a;this._bufferInitSegment(c,h.tracks,t,o),r.trigger(Pn.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:n,tracks:h.tracks})}const t=h.initPTS,e=h.timescale;Bn(t)&&(this.initPTS[a.cc]={baseTime:t,timescale:e},r.trigger(Pn.INIT_PTS_FOUND,{frag:a,id:n,initPTS:t,timescale:e}))}if(u&&f&&"initSegment"!==a.sn){const t=f.fragments[a.sn-1-f.startSN],e=a.sn===f.startSN,n=!t||a.cc>t.cc;if(!1!==i.independent){const{startPTS:t,endPTS:r,startDTS:i,endDTS:s}=u;if(l)l.elementaryStreams[u.type]={startPTS:t,endPTS:r,startDTS:i,endDTS:s};else if(u.firstKeyFrame&&u.independent&&1===o.id&&!n&&(this.couldBacktrack=!0),u.dropped&&u.independent){const i=this.getMainFwdBufferInfo(),o=(i?i.end:this.getLoadPosition())+this.config.maxBufferHole,l=u.firstKeyFramePTS?u.firstKeyFramePTS:t;if(!e&&o{const i=e[t].initSegment;null!=i&&i.byteLength&&this.hls.trigger(Pn.BUFFER_APPENDING,{type:t,data:i,frag:n,part:null,chunkMeta:r,parent:n.type})})),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Ei)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Oo}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const n=t.currentTime;if(To.isBuffered(t,n)?e=this.getAppendedFrag(n):To.isBuffered(t,n+.1)&&(e=this.getAppendedFrag(n+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,n=e.level;t&&e.sn===t.sn&&t.level===n&&e.urlId===t.urlId||(this.fragPlaying=e,this.hls.trigger(Pn.FRAG_CHANGED,{frag:e}),t&&t.level===n||this.hls.trigger(Pn.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,n=this.currentFrag;if(n&&Bn(e)&&Bn(n.programDateTime)){const t=n.programDateTime+1e3*(e-n.start);return new Date(t)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class Zs{constructor(t,e=0,n=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=n}sample(t,e){const n=Math.pow(this.alpha_,t);this.estimate_=e*(1-n)+n*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class ta{constructor(t,e,n,r=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Zs(t),this.fast_=new Zs(e),this.defaultTTFB_=r,this.ttfb_=new Zs(t)}update(t,e){const{slow_:n,fast_:r,ttfb_:i}=this;n.halfLife!==t&&(this.slow_=new Zs(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.fast_=new Zs(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.ttfb_=new Zs(t,i.getEstimate(),i.getTotalWeight()))}sample(t,e){const n=(t=Math.max(t,this.minDelayMs_))/1e3,r=8*e/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(t){const e=t/1e3,n=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(n,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class ea{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let n;return t.length?(n=1===t.length?t[0]:function(t,e){const n=new Uint8Array(e);let r=0;for(let e=0;et[n]!==e[n]))}class ia{constructor(t){this.buffered=void 0;const e=(e,n,r)=>{if((n>>>=0)>r-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${r})`);return t[n][e]};this.buffered={get length(){return t.length},end:n=>e("end",n,t.length),start:n=>e("start",n,t.length)}}}function oa(t){const e=[];for(let n=0;n{e=t})),r={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,t),n}executeNext(t){const{buffers:e,queues:n}=this,r=e[t],i=n[t];if(i.length){const e=i[0];try{e.execute()}catch(n){Un.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),e.onError(n),null!=r&&r.updating||(i.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const aa=ei(),la=/([ha]vc.)(?:\.[^.,]+)+/,ca={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ua=function(t){let e=t;return ca.hasOwnProperty(t)&&(e=ca[t]),String.fromCharCode(e)},Aa=15,da=100,ha={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},fa={17:2,18:4,21:6,22:8,23:10,19:13,20:15},pa={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ga={25:2,26:4,29:6,30:8,31:10,27:13,28:15},ma=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class va{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const n="function"==typeof e?e():e;Un.log(`${this.time} [${t}] ${n}`)}}}const ya=function(t){const e=[];for(let n=0;nda&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=da)}moveCursor(t){const e=this.pos+t;if(t>1)for(let t=this.pos+1;t=144&&this.backSpace();const e=ua(t);this.pos>=da?this.logger.log(0,(()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!")):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))}clearFromPos(t){let e;for(e=t;e"pacData = "+JSON.stringify(t)));let e=t.row-1;if(this.nrRollUpRows&&e"bkgData = "+JSON.stringify(t))),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let n="",r=-1;for(let n=0;n0&&(n=t?"["+e.join(" | ")+"]":e.join("\n")),n}getTextAndFormat(){return this.rows}}class Ta{constructor(t,e,n){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new wa(n),this.nonDisplayedMemory=new wa(n),this.lastOutputScreen=new wa(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(()=>"MODE="+t)),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let e=0;ee+": "+this.writeScreen.getDisplayText(!0))),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0))),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(()=>"DISP: "+this.displayedMemory.getDisplayText()))}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{const n=Math.floor(t/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=r[n]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Sa{constructor(t,e,n){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const r=new va;this.channels=[null,new Ta(t,e,r),new Ta(t+1,n,r)],this.cmdHistory={a:null,b:null},this.logger=r}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let n,r,i,o=!1;this.logger.time=t;for(let t=0;t ("+ya([r,i])+")"),n=this.parseCmd(r,i),n||(n=this.parseMidrow(r,i)),n||(n=this.parsePAC(r,i)),n||(n=this.parseBackgroundAttributes(r,i)),!n&&(o=this.parseChars(r,i),o)){const t=this.currentChannel;t&&t>0?this.channels[t].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||o||this.logger.log(2,"Couldn't parse cleaned data "+ya([r,i])+" orig: "+ya([e[t],e[t+1]]))}}parseCmd(t,e){const{cmdHistory:n}=this;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;if(La(t,e,n))return ka(null,null,n),this.logger.log(3,"Repeated command ("+ya([t,e])+") is dropped"),!0;const r=20===t||21===t||23===t?1:2,i=this.channels[r];return 20===t||21===t||28===t||29===t?32===e?i.ccRCL():33===e?i.ccBS():34===e?i.ccAOF():35===e?i.ccAON():36===e?i.ccDER():37===e?i.ccRU(2):38===e?i.ccRU(3):39===e?i.ccRU(4):40===e?i.ccFON():41===e?i.ccRDC():42===e?i.ccTR():43===e?i.ccRTD():44===e?i.ccEDM():45===e?i.ccCR():46===e?i.ccENM():47===e&&i.ccEOC():i.ccTO(e-32),ka(t,e,n),this.currentChannel=r,!0}parseMidrow(t,e){let n=0;if((17===t||25===t)&&e>=32&&e<=47){if(n=17===t?1:2,n!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[n];return!!r&&(r.ccMIDROW(e),this.logger.log(3,"MIDROW ("+ya([t,e])+")"),!0)}return!1}parsePAC(t,e){let n;const r=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;if(La(t,e,r))return ka(null,null,r),!0;const i=t<=23?1:2;n=e>=64&&e<=95?1===i?ha[t]:pa[t]:1===i?fa[t]:ga[t];const o=this.channels[i];return!!o&&(o.setPAC(this.interpretPAC(n,e)),ka(t,e,r),this.currentChannel=i,!0)}interpretPAC(t,e){let n;const r={color:null,italics:!1,indent:null,underline:!1,row:t};return n=e>95?e-96:e-64,r.underline=1==(1&n),n<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((n-16)/2),r}parseChars(t,e){let n,r=null,i=null;if(t>=25?(n=2,i=t-8):(n=1,i=t),i>=17&&i<=19){let t;t=17===i?e+80:18===i?e+112:e+144,this.logger.log(2,"Special char '"+ua(t)+"' in channel "+n),r=[t]}else t>=32&&t<=127&&(r=0===e?[t]:[t,e]);if(r){const n=ya(r);this.logger.log(3,"Char codes = "+n.join(",")),ka(t,e,this.cmdHistory)}return r}parseBackgroundAttributes(t,e){if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;let n;const r={};16===t||24===t?(n=Math.floor((e-32)/2),r.background=ma[n],e%2==1&&(r.background=r.background+"_semi")):45===e?r.background="transparent":(r.foreground="black",47===e&&(r.underline=!0));const i=t<=23?1:2;return this.channels[i].setBkgData(r),ka(t,e,this.cmdHistory),!0}reset(){for(let t=0;tt)&&(this.startTime=t),this.endTime=e,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Ia=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function n(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;const n=e.toLowerCase();return!!~t.indexOf(n)&&n}function r(t){return n(e,t)}function i(t,...e){let n=1;for(;n100)throw new Error("Position must be between 0 and 100.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"positionAlign",i({},l,{get:function(){return C},set:function(t){const e=r(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");C=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"size",i({},l,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"align",i({},l,{get:function(){return E},set:function(t){const e=r(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),a.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o}();class Ra{decode(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Da(t){function e(t,e,n,r){return 3600*(0|t)+60*(0|e)+(0|n)+parseFloat(r||0)}const n=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?e(n[2],n[3],0,n[4]):e(n[1],n[2],n[3],n[4]):null}class Ba{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,n){return n?this.has(t)?this.values[t]:e[n]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,n){for(let r=0;r=0&&n<=100)return this.set(t,n),!0}return!1}}function Pa(t,e,n,r){const i=r?t.split(r):[t];for(const t in i){if("string"!=typeof i[t])continue;const r=i[t].split(n);2===r.length&&e(r[0],r[1])}}const Ma=new Ia(0,0,""),Oa="middle"===Ma.align?"middle":"center";function Fa(t,e,n){const r=t;function i(){const e=Da(t);if(null===e)throw new Error("Malformed timestamp: "+r);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function o(){t=t.replace(/^\s+/,"")}if(o(),e.startTime=i(),o(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);t=t.slice(3),o(),e.endTime=i(),o(),function(t,e){const r=new Ba;Pa(t,(function(t,e){let i;switch(t){case"region":for(let i=n.length-1;i>=0;i--)if(n[i].id===e){r.set(t,n[i].region);break}break;case"vertical":r.alt(t,e,["rl","lr"]);break;case"line":i=e.split(","),r.integer(t,i[0]),r.percent(t,i[0])&&r.set("snapToLines",!1),r.alt(t,i[0],["auto"]),2===i.length&&r.alt("lineAlign",i[1],["start",Oa,"end"]);break;case"position":i=e.split(","),r.percent(t,i[0]),2===i.length&&r.alt("positionAlign",i[1],["start",Oa,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,e);break;case"align":r.alt(t,e,["start",Oa,"end","left","right"])}}),/:/,/\s/),e.region=r.get("region",null),e.vertical=r.get("vertical","");let i=r.get("line","auto");"auto"===i&&-1===Ma.line&&(i=-1),e.line=i,e.lineAlign=r.get("lineAlign","start"),e.snapToLines=r.get("snapToLines",!0),e.size=r.get("size",100),e.align=r.get("align",Oa);let o=r.get("position","auto");"auto"===o&&50===Ma.position&&(o="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=o}(t,e)}function _a(t){return t.replace(//gi,"\n")}class Na{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Ra,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function n(){let t=e.buffer,n=0;for(t=_a(t);n>>0).toString()};function Wa(t,e,n){return Ga(t.toString())+Ga(e.toString())+Ga(n)}const Ya="stpp.ttml.im1t",ja=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ha=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Ka={left:"start",center:"center",right:"end",start:"start",end:"end"};function Va(t,e,n,r){const i=_r(new Uint8Array(t),["mdat"]);if(0===i.length)return void r(new Error("Could not parse IMSC1 mdat"));const o=i.map((t=>Sr(t))),s=function(t,e,n=1,r=!1){return Is(t,e,1/n,r)}(e.baseTime,1,e.timescale);try{o.forEach((t=>n(function(t,e){const n=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(r).reduce(((t,e)=>(t[e]=n.getAttribute(`ttp:${e}`)||r[e],t)),{}),o="preserve"!==n.getAttribute("xml:space"),s=$a(za(n,"styling","style")),a=$a(za(n,"layout","region")),l=za(n,"body","[begin]");return[].map.call(l,(t=>{const n=Xa(t,o);if(!n||!t.hasAttribute("begin"))return null;const r=Za(t.getAttribute("begin"),i),l=Za(t.getAttribute("dur"),i);let c=Za(t.getAttribute("end"),i);if(null===r)throw Ja(t);if(null===c){if(null===l)throw Ja(t);c=r+l}const u=new Ia(r-e,c-e,n);u.id=Wa(u.startTime,u.endTime,u.text);const A=function(t,e,n){const r="http://www.w3.org/ns/ttml#styling";let i=null;const o=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return o&&n.hasOwnProperty(o)&&(i=n[o]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(((n,o)=>{const s=qa(e,r,o)||qa(t,r,o)||qa(i,r,o);return s&&(n[o]=s),n}),{})}(a[t.getAttribute("region")],s[t.getAttribute("style")],s),{textAlign:d}=A;if(d){const t=Ka[d];t&&(u.lineAlign=t),u.align=d}return Dn(u,A),u})).filter((t=>null!==t))}(t,s))))}catch(t){r(t)}}function za(t,e,n){const r=t.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(n)):[]}function $a(t){return t.reduce(((t,e)=>{const n=e.getAttribute("xml:id");return n&&(t[n]=e),t}),{})}function Xa(t,e){return[].slice.call(t.childNodes).reduce(((t,n,r)=>{var i;return"br"===n.nodeName&&r?t+"\n":null!=(i=n.childNodes)&&i.length?Xa(n,e):e?t+n.textContent.trim().replace(/\s+/g," "):t+n.textContent}),"")}function qa(t,e,n){return t&&t.hasAttributeNS(e,n)?t.getAttributeNS(e,n):null}function Ja(t){return new Error(`Could not parse ttml timestamp ${t}`)}function Za(t,e){if(!t)return null;let n=Da(t);return null===n&&(ja.test(t)?n=function(t,e){const n=ja.exec(t),r=(0|n[4])+(0|n[5])/e.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+r/e.frameRate}(t,e):Ha.test(t)&&(n=function(t,e){const n=Ha.exec(t),r=Number(n[1]);switch(n[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}(t,e))),n}function tl(t,e){return!!t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}class el{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(Pn.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(Pn.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const n=this.hls.levels[e.droppedLevel];this.isLevelAllowed(n)&&this.restrictedLevels.push({bitrate:n.bitrate,height:n.height,width:n.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const n=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,n.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const n=e.filter(((e,n)=>this.isLevelAllowed(e)&&n<=t));return this.clientRect=null,el.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const n=t.getBoundingClientRect();e.width=n.width,e.height=n.height,e.width||e.height||(e.width=n.right-n.left||t.width||0,e.height=n.bottom-n.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}isLevelAllowed(t){return!this.restrictedLevels.some((e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height))}static getMaxLevelByMediaSize(t,e,n){if(null==t||!t.length)return-1;let r=t.length-1;for(let s=0;s=e||a.height>=n)&&(i=a,!(o=t[s+1])||i.width!==o.width||i.height!==o.height)){r=s;break}}var i,o;return r}}const nl="[eme]";class rl{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=rl.CDMCleanupPromise?[rl.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=Un.debug.bind(Un,nl),this.log=Un.log.bind(Un,nl),this.warn=Un.warn.bind(Un,nl),this.error=Un.error.bind(Un,nl),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Pn.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Pn.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Pn.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Pn.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:n}=this.config,r=e[t];if(r)return r.licenseUrl;if(t===er.WIDEVINE&&n)return n;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,n=e[t];if(n)return n.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,n=(t,e,n)=>!!t&&n.indexOf(t)===e,r=e.map((t=>t.audioCodec)).filter(n),i=e.map((t=>t.videoCodec)).filter(n);return r.length+i.length===0&&i.push("avc1.42e01e"),new Promise(((e,n)=>{const o=t=>{const s=t.shift();this.getMediaKeysPromise(s,r,i).then((t=>e({keySystem:s,mediaKeys:t}))).catch((e=>{t.length?o(t):n(e instanceof il?e:new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};o(t)}))}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:n}=this.config;if("function"!=typeof n){let t=`Configured requestMediaKeySystemAccess is not a function ${n}`;return null===ur&&"http:"===self.location.protocol&&(t=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(t))}return n(t,e)}getMediaKeysPromise(t,e,n){const r=function(t,e,n,r){let i;switch(t){case er.FAIRPLAY:i=["cenc","sinf"];break;case er.WIDEVINE:case er.PLAYREADY:i=["cenc"];break;case er.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return function(t,e,n,r){return[{initDataTypes:t,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map((t=>({contentType:`audio/mp4; codecs="${t}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null}))),videoCapabilities:n.map((t=>({contentType:`video/mp4; codecs="${t}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null})))}]}(i,e,n,r)}(t,e,n,this.config.drmSystemOptions),i=this.keySystemAccessPromises[t];let o=null==i?void 0:i.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(r)}`),o=this.requestMediaKeySystemAccess(t,r);const e=this.keySystemAccessPromises[t]={keySystemAccess:o};return o.catch((e=>{this.log(`Failed to obtain access to key-system "${t}": ${e}`)})),o.then((n=>{this.log(`Access for key-system "${n.keySystem}" obtained`);const r=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),e.mediaKeys=n.createMediaKeys().then((e=>(this.log(`Media-keys created for "${t}"`),r.then((n=>n?this.setMediaKeysServerCertificate(e,t,n):e))))),e.mediaKeys.catch((e=>{this.error(`Failed to create media-keys for "${t}"}: ${e}`)})),e.mediaKeys}))}return o.then((()=>i.mediaKeys))}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:n}){this.log(`Creating key-system session "${e}" keyId: ${xr(t.keyId||[])}`);const r=n.createSession(),i={decryptdata:t,keySystem:e,mediaKeys:n,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const n=this.createMediaKeySessionContext(t),r=this.getKeyIdString(e),i="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(n,i,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return xr(t.keyId)}updateKeySession(t,e){var n;const r=t.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${xr((null==(n=t.decryptdata)?void 0:n.keyId)||[])}\n } (data length: ${e?e.byteLength:e})`),r.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise(((e,n)=>{const r=cr(this.config),i=t.map(sr).filter((t=>!!t&&-1!==r.indexOf(t)));return this.getKeySystemSelectionPromise(i).then((({keySystem:t})=>{const r=lr(t);r?e(r):n(new Error(`Unable to find format for key-system "${t}"`))})).catch(n)}))}loadKey(t){const e=t.keyInfo.decryptdata,n=this.getKeyIdString(e),r=`(keyId: ${n} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${r}`);let i=this.keyIdToKeySessionPromise[n];return i||(i=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(e).then((({keySystem:n,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${r}`),this.attemptSetMediaKeys(n,i).then((()=>{this.throwIfDestroyed();const t=this.createMediaKeySessionContext({keySystem:n,mediaKeys:i,decryptdata:e});return this.generateRequestWithPreferredKeySession(t,"cenc",e.pssh,"playlist-key")}))))),i.catch((t=>this.handleError(t)))),i}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof il?this.hls.trigger(Pn.ERROR,t.data):this.hls.trigger(Pn.ERROR,{type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),n=this.keyIdToKeySessionPromise[e];if(!n){const e=sr(t.keyFormat),n=e?[e]:cr(this.config);return this.attemptKeySystemAccess(n)}return n}getKeySystemSelectionPromise(t){if(t.length||(t=cr(this.config)),0===t.length)throw new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:n}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),null===n)return;let r,i;if("sinf"===e&&this.config.drmSystems[er.FAIRPLAY]){const t=Br(new Uint8Array(n));try{const e=Zn(JSON.parse(t).sinf),n=Qr(new Uint8Array(e));if(!n)return;r=n.subarray(8,24),i=er.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const t=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},n=new DataView(t),r=n.getUint32(0);if(t.byteLength!==r&&r>44)return null;if(1886614376!==n.getUint32(4))return null;if(e.version=n.getUint32(8)>>>24,e.version>1)return null;e.systemId=xr(new Uint8Array(t,12,16));const i=n.getUint32(28);if(0===e.version){if(r-32this.generateRequestWithPreferredKeySession(i,e,n,"encrypted-event-key-match")));break}}l||(l=s[o]=this.getKeySystemSelectionPromise([i]).then((({keySystem:t,mediaKeys:i})=>{var s;this.throwIfDestroyed();const a=new zr("ISO-23001-7",o,null!=(s=lr(t))?s:"");return a.pssh=new Uint8Array(n),a.keyId=r,this.attemptSetMediaKeys(t,i).then((()=>{this.throwIfDestroyed();const r=this.createMediaKeySessionContext({decryptdata:a,keySystem:t,mediaKeys:i});return this.generateRequestWithPreferredKeySession(r,e,n,"encrypted-event-no-match")}))}))),l.catch((t=>this.handleError(t)))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const n=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const r=Promise.all(n).then((()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)}));return this.setMediaKeysQueue.push(r),r.then((()=>{this.log(`Media-keys set for "${t}"`),n.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((t=>-1===n.indexOf(t)))}))}generateRequestWithPreferredKeySession(t,e,n,r){var i,o;const s=null==(i=this.config.drmSystems)||null==(o=i[t.keySystem])?void 0:o.generateRequest;if(s)try{const r=s.call(this.hls,e,n,t);if(!r)throw new Error("Invalid response from configured generateRequest filter");e=r.initDataType,n=t.decryptdata.pssh=r.initData?new Uint8Array(r.initData):null}catch(t){var a;if(this.warn(t.message),null!=(a=this.hls)&&a.config.debug)throw t}if(null===n)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(t);const l=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${r}": ${l} (init data type: ${e} length: ${n?n.byteLength:null})`);const c=new zs;t.mediaKeysSession.onmessage=e=>{const n=t.mediaKeysSession;if(!n)return void c.emit("error",new Error("invalid state"));const{messageType:r,message:i}=e;this.log(`"${r}" message event for session "${n.sessionId}" message size: ${i.byteLength}`),"license-request"===r||"license-renewal"===r?this.renewLicense(t,i).catch((t=>{this.handleError(t),c.emit("error",t)})):"license-release"===r?t.keySystem===er.FAIRPLAY&&(this.updateKeySession(t,tr("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${r}"`)},t.mediaKeysSession.onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void c.emit("error",new Error("invalid state"));this.onKeyStatusChange(t);const n=t.keyStatus;c.emit("keyStatus",n),"expired"===n&&(this.warn(`${t.keySystem} expired for key ${l}`),this.renewKeySession(t))};const u=new Promise(((t,e)=>{c.on("error",e),c.on("keyStatus",(n=>{n.startsWith("usable")?t():"output-restricted"===n?e(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===n?e(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${n}"`)):"expired"===n?e(new Error("key expired while generating request")):this.warn(`unhandled key status change "${n}"`)}))}));return t.mediaKeysSession.generateRequest(e,n).then((()=>{var e;this.log(`Request generated for key-session "${null==(e=t.mediaKeysSession)?void 0:e.sessionId}" keyId: ${l}`)})).catch((t=>{throw new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},`Error generating key-session request: ${t}`)})).then((()=>u)).catch((e=>{throw c.removeAllListeners(),this.removeSession(t),e})).then((()=>(c.removeAllListeners(),t)))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach(((e,n)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${xr("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))} session keyId: ${xr(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e}))}fetchServerCertificate(t){const e=this.config,n=new(0,e.loader)(e),r=this.getServerCertificateUrl(t);return r?(this.log(`Fetching serverCertificate for "${t}"`),new Promise(((i,o)=>{const s={responseType:"arraybuffer",url:r},a=e.certLoadPolicy.default,l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,n,r)=>{i(t.data)},onError:(e,n,i,a)=>{o(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:In({url:s.url,data:void 0},e)},`"${t}" certificate request failed (${r}). Status: ${e.code} (${e.text})`))},onTimeout:(e,n,i)=>{o(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:{url:s.url,data:void 0}},`"${t}" certificate request timed out (${r})`))},onAbort:(t,e,n)=>{o(new Error("aborted"))}};n.load(s,l,c)}))):Promise.resolve()}setMediaKeysServerCertificate(t,e,n){return new Promise(((r,i)=>{t.setServerCertificate(n).then((i=>{this.log(`setServerCertificate ${i?"success":"not supported by CDM"} (${null==n?void 0:n.byteLength}) on "${e}"`),r(t)})).catch((t=>{i(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))}))}))}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then((e=>this.updateKeySession(t,new Uint8Array(e)).catch((t=>{throw new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))))}setupLicenseXHR(t,e,n,r){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then((()=>{if(!n.decryptdata)throw new Error("Key removed");return i.call(this.hls,t,e,n,r)})).catch((o=>{if(!n.decryptdata)throw o;return t.open("POST",e,!0),i.call(this.hls,t,e,n,r)})).then((n=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:n||r}))):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:r}))}requestLicense(t,e){const n=this.config.keyLoadPolicy.default;return new Promise(((r,i)=>{const o=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${o}`);const s=new XMLHttpRequest;s.responseType="arraybuffer",s.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return i(new Error("invalid state"));if(4===s.readyState)if(200===s.status){this._requestLicenseFailureCount=0;let e=s.response;this.log(`License received ${e instanceof ArrayBuffer?e.byteLength:e}`);const n=this.config.licenseResponseCallback;if(n)try{e=n.call(this.hls,s,o,t)}catch(t){this.error(t)}r(e)}else{const a=n.errorRetry,l=a?a.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||s.status>=400&&s.status<500)i(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:o,data:void 0,code:s.status,text:s.statusText}},`License Request XHR failed (${o}). Status: ${s.status} (${s.statusText})`));else{const n=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${n} attempts left`),this.requestLicense(t,e).then(r,i)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=s,this.setupLicenseXHR(s,o,t,e).then((({xhr:t,licenseChallenge:e})=>{t.send(e)}))}))}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const n=e.media;this.media=n,n.addEventListener("encrypted",this.onMediaEncrypted),n.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},zr.clearKeyUriToKeyIdMap();const n=e.length;rl.CDMCleanupPromise=Promise.all(e.map((t=>this.removeSession(t))).concat(null==t?void 0:t.setMediaKeys(null).catch((e=>{this.log(`Could not clear media keys: ${e}. media.src: ${null==t?void 0:t.src}`)})))).then((()=>{n&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)})).catch((e=>{this.log(`Could not close sessions and clear media keys: ${e}. media.src: ${null==t?void 0:t.src}`)}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(e&&this.config.emeEnabled&&!this.keyFormatPromise){const t=e.reduce(((t,e)=>(-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t)),[]);this.log(`Selecting key-system from session-keys ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:n}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(t);return r>-1&&this.mediaKeySessions.splice(r,1),e.remove().catch((t=>{this.log(`Could not remove session: ${t}`)})).then((()=>e.close())).catch((t=>{this.log(`Could not close session: ${t}`)}))}}}rl.CDMCleanupPromise=void 0;class il extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}var ol="a",sl="av";class al{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:"m",su:!this.initialized})}catch(t){Un.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{const e=t.frag,n=this.hls.levels[e.level],r=this.getObjectType(e),i={d:1e3*e.duration,ot:r};"v"!==r&&r!==ol&&r!=sl||(i.br=n.bitrate/1e3,i.tb=this.getTopBandwidth(r)/1e3,i.bl=this.getBufferLength(r)),this.apply(t,i)}catch(t){Un.warn("Could not generate segment CMCD data.",t)}},this.hls=t;const e=this.config=t.config,{cmcd:n}=e;null!=n&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||al.uuid(),this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.registerListeners())}registerListeners(){const t=this.hls;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHED,this.onMediaDetached,this),t.on(Pn.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHED,this.onMediaDetached,this),t.off(Pn.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var n,r;this.audioBuffer=null==(n=e.tracks.audio)?void 0:n.buffer,this.videoBuffer=null==(r=e.tracks.video)?void 0:r.buffer}createData(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){Dn(e,this.createData());const n="i"===e.ot||"v"===e.ot||e.ot===sl;if(this.starved&&n&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering),this.useHeaders){const n=al.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),Dn(t.headers,n)}else{const n=al.toQuery(e);if(!n)return;t.url=al.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;return"subtitle"===e?"tt":"initSegment"===t.sn?"i":"audio"===e?ol:"main"===e?this.hls.audioTracks.length?"v":sl:void 0}getTopBandwidth(t){let e,n=0;const r=this.hls;if(t===ol)e=r.audioTracks;else{const t=r.maxAutoLevel,n=t>-1?t+1:r.levels.length;e=r.levels.slice(0,n)}for(const t of e)t.bitrate>n&&(n=t.bitrate);return n>0?n:NaN}getBufferLength(t){const e=this.hls.media,n=t===ol?this.audioBuffer:this.videoBuffer;return n&&e?1e3*To.bufferInfo(n,e.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,n=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new n(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,n,r){e(t),this.loader.load(t,n,r)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,n=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new n(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,n,r){e(t),this.loader.load(t,n,r)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],n=t=>!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t,r=t=>Math.round(t),i=t=>100*r(t/100),o={br:r,d:r,bl:i,dl:i,mtp:i,nor:t=>encodeURIComponent(t),rtp:i,tb:r},s=Object.keys(t||{}).sort();for(const r of s){let i=t[r];if(!n(i))continue;if("v"===r&&1===i)continue;if("pr"==r&&1===i)continue;const s=o[r];s&&(i=s(i));const a=typeof i;let l;l="ot"===r||"sf"===r||"st"===r?`${r}=${i}`:"boolean"===a?r:"number"===a?`${r}=${i}`:`${r}=${JSON.stringify(i)}`,e.push(l)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),n={},r=["Object","Request","Session","Status"],i=[{},{},{},{}],o={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const n of e)i[null!=o[n]?o[n]:1][n]=t[n];for(let t=0;t{const o=t.filter((t=>t.groupId===i)).map((t=>{const o=Dn({},t);return o.details=void 0,o.attrs=new Wn(o.attrs),o.url=o.attrs.URI=cl(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",n),o.groupId=o.attrs["GROUP-ID"]=e[i],o.attrs["PATHWAY-ID"]=r,o}));t.push(...o)}))}function cl(t,e,n,r){const{HOST:i,PARAMS:o,[n]:s}=r;let a;e&&(a=null==s?void 0:s[e],a&&(t=a));const l=new self.URL(t);return i&&!a&&(l.host=i),o&&Object.keys(o).sort().forEach((t=>{t&&l.searchParams.set(t,o[t])})),l.href}const ul=/^age:\s*[\d.]+\s*$/im;class Al{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new Hn,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,n){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=n,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const n=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then((()=>{if(!this.stats.aborted)return i(n,e.url)})).catch((t=>(n.open("GET",e.url,!0),i(n,e.url)))).then((()=>{this.stats.aborted||this.openAndSendXhr(n,e,t)})).catch((t=>{this.callbacks.onError({code:n.status,text:t.message},e,n,r)})):this.openAndSendXhr(n,e,t)}openAndSendXhr(t,e,n){t.readyState||t.open("GET",e.url,!0);const r=this.context.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:o}=n.loadPolicy;if(r)for(const e in r)t.setRequestHeader(e,r[e]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),n.timeout=i&&Bn(i)?i:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:n}=this;if(!t||!e)return;const r=e.readyState,i=this.config;if(!n.aborted&&r>=2&&(0===n.loading.first&&(n.loading.first=Math.max(self.performance.now(),n.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(n.loading.first-n.loading.start)))),4===r)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const r=e.status,o="text"!==e.responseType;if(r>=200&&r<300&&(o&&e.response||null!==e.responseText)){n.loading.end=Math.max(self.performance.now(),n.loading.first);const i=o?e.response:e.responseText,s="arraybuffer"===e.responseType?i.byteLength:i.length;if(n.loaded=n.total=s,n.bwEstimate=8e3*n.total/(n.loading.end-n.loading.first),!this.callbacks)return;const a=this.callbacks.onProgress;if(a&&a(n,t,i,e),!this.callbacks)return;const l={url:e.responseURL,data:i,code:r};this.callbacks.onSuccess(l,n,t,e)}else{const o=i.loadPolicy.errorRetry;Ji(o,n.retry,!1,r)?this.retry(o):(Un.error(`${r} while loading ${t.url}`),this.callbacks.onError({code:r,text:e.statusText},t,e,n))}}}loadtimeout(){var t;const e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(Ji(e,this.stats.retry,!0))this.retry(e);else{Un.warn(`timeout while loading ${this.context.url}`);const t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:n}=this;this.retryDelay=Xi(t,n.retry),n.retry++,Un.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${n.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&ul.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const dl=/(\d+)-(\d+)\/(\d+)/;class hl{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||fl,this.controller=new self.AbortController,this.stats=new Hn}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,n){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const i=function(t,e){const n={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Dn({},t.headers))};return t.rangeEnd&&n.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),n}(t,this.controller.signal),o=n.onProgress,s="arraybuffer"===t.responseType,a=s?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=n,this.request=this.fetchSetup(t,i),self.clearTimeout(this.requestTimeout),e.timeout=l&&Bn(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),n.onTimeout(r,t,this.response)}),e.timeout),self.fetch(this.request).then((i=>{this.response=this.loader=i;const a=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),n.onTimeout(r,t,this.response)}),c-(a-r.loading.start)),!i.ok){const{status:t,statusText:e}=i;throw new pl(e||"fetch, bad network response",t,i)}return r.loading.first=a,r.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=dl.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(Bn(t))return t}const n=t.get("Content-Length");if(n)return parseInt(n)}(i.headers)||r.total,o&&Bn(e.highWaterMark)?this.loadProgressively(i,r,t,e.highWaterMark,o):s?i.arrayBuffer():"json"===t.responseType?i.json():i.text()})).then((i=>{const{response:s}=this;self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const l=i[a];l&&(r.loaded=r.total=l);const c={url:s.url,data:i,code:s.status};o&&!Bn(e.highWaterMark)&&o(r,t,i,s),n.onSuccess(c,r,t,s)})).catch((e=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const i=e&&e.code||0,o=e?e.message:null;n.onError({code:i,text:o},t,e?e.details:null,r)}))}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,n,r=0,i){const o=new ea,s=t.body.getReader(),a=()=>s.read().then((s=>{if(s.done)return o.dataLength&&i(e,n,o.flush(),t),Promise.resolve(new ArrayBuffer(0));const l=s.value,c=l.length;return e.loaded+=c,c=r&&i(e,n,o.flush(),t)):i(e,n,l,t),a()})).catch((()=>Promise.reject()));return a()}}function fl(t,e){return new self.Request(t.url,e)}class pl extends Error{constructor(t,e,n){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=n}}const gl=/\s/,ml={newCue(t,e,n,r){const i=[];let o,s,a,l,c;const u=self.VTTCue||self.TextTrackCue;for(let d=0;d=16?l--:l++;const r=_a(c.trim()),h=Wa(e,n,r);null!=t&&null!=(A=t.cues)&&A.getCueById(h)||(s=new u(e,n,r),s.id=h,s.line=d+1,s.align="left",s.position=10+Math.min(80,10*Math.floor(8*l/32)),i.push(s))}return t&&i.length&&(i.sort(((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line)),i.forEach((e=>Ii(t,e)))),i}},vl=In(In({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Al,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new ta(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(Pn.FRAG_LOADING,this.onFragLoading,this),t.on(Pn.FRAG_LOADED,this.onFragLoaded,this),t.on(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Pn.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.FRAG_LOADING,this.onFragLoading,this),t.off(Pn.FRAG_LOADED,this.onFragLoaded,this),t.off(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Pn.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var n;const r=e.frag;this.ignoreFragment(r)||(this.fragCurrent=r,this.partCurrent=null!=(n=e.part)?n:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,n,r){return t+n/e+(r?this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const n=this.hls.config,{total:r,bwEstimate:i}=e.stats;Bn(r)&&Bn(i)&&(this.lastLevelLoadSec=8*r/i),e.details.live?this.bwEstimator.update(n.abrEwmaSlowLive,n.abrEwmaFastLive):this.bwEstimator.update(n.abrEwmaSlowVoD,n.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:n}=this,{autoLevelEnabled:r,media:i}=n;if(!t||!i)return;const o=performance.now(),s=e?e.stats:t.stats,a=e?e.duration:t.duration,l=o-s.loading.start;if(s.aborted||s.loaded&&s.loaded===s.total||0===t.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!r||i.paused||!i.playbackRate||!i.readyState)return;const c=n.mainForwardBufferInfo;if(null===c)return;const u=this.bwEstimator.getEstimateTTFB(),A=Math.abs(i.playbackRate);if(l<=Math.max(u,a/(2*A)*1e3))return;const d=c.len/A;if(d>=2*a/A)return;const h=s.loading.first?s.loading.first-s.loading.start:-1,f=s.loaded&&h>-1,p=this.bwEstimator.getEstimate(),{levels:g,minAutoLevel:m}=n,v=g[t.level],y=s.total||Math.max(s.loaded,Math.round(a*v.maxBitrate/8));let C=l-h;C<1&&f&&(C=Math.min(l,8*s.loaded/p));const b=f?1e3*s.loaded/C:0,E=b?(y-s.loaded)/b:8*y/p+u/1e3;if(E<=d)return;const w=b?8*b:p;let T,S=Number.POSITIVE_INFINITY;for(T=t.level-1;T>m;T--){const t=g[T].maxBitrate;if(S=this.getTimeToLoadFrag(u/1e3,w,a*t,!g[T].details),S=E||S>10*a||(n.nextLoadLevel=T,f?this.bwEstimator.sample(l-Math.min(u,h),s.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),Un.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;\n Time to underbuffer: ${d.toFixed(3)} s\n Estimated load time for current fragment: ${E.toFixed(3)} s\n Estimated load time for down switch fragment: ${S.toFixed(3)} s\n TTFB estimate: ${h}\n Current BW estimate: ${Bn(p)?(p/1024).toFixed(3):"Unknown"} Kb/s\n New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s\n Aborting and switching to level ${T}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),n.trigger(Pn.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:s}))}onFragLoaded(t,{frag:e,part:n}){const r=n?n.stats:e.stats;if(e.type===Ei&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const t=n?n.duration:e.duration,i=this.hls.levels[e.level],o=(i.loaded?i.loaded.bytes:0)+r.loaded,s=(i.loaded?i.loaded.duration:0)+t;i.loaded={bytes:o,duration:s},i.realBitrate=Math.round(8*o/s)}if(e.bitrateTest){const t={stats:r,frag:e,part:n,id:e.type};this.onFragBuffered(Pn.FRAG_BUFFERED,t),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:n,part:r}=e,i=null!=r&&r.stats.loaded?r.stats:n.stats;if(i.aborted)return;if(this.ignoreFragment(n))return;const o=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),n.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Ei||"initSegment"===t.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;let n=this.getNextABRAutoLevel();if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,n)&&e[t].loadError<=e[n].loadError)return t}return-1!==t&&(n=Math.min(t,n)),n}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:n}=this,{maxAutoLevel:r,config:i,minAutoLevel:o,media:s}=n,a=e?e.duration:t?t.duration:0,l=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,u=n.mainForwardBufferInfo,A=(u?u.len:0)/l;let d=this.findBestLevel(c,o,r,A,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(d>=0)return d;Un.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let h=a?Math.min(a,i.maxStarvationDelay):i.maxStarvationDelay,f=i.abrBandWidthFactor,p=i.abrBandWidthUpFactor;if(!A){const t=this.bitrateTestDelay;t&&(h=(a?Math.min(a,i.maxLoadingDelay):i.maxLoadingDelay)-t,Un.trace(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),f=p=1)}return d=this.findBestLevel(c,o,r,A+h,f,p),Math.max(d,0)}findBestLevel(t,e,n,r,i,o){var s;const{fragCurrent:a,partCurrent:l,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,A=u[c],d=!(null==A||null==(s=A.details)||!s.live),h=null==A?void 0:A.codecSet,f=l?l.duration:a?a.duration:0,p=this.bwEstimator.getEstimateTTFB()/1e3;let g=e,m=-1;for(let s=n;s>=e;s--){const e=u[s];if(!e||h&&e.codecSet!==h){e&&(g=Math.min(s,g),m=Math.max(s,m));continue}-1!==m&&Un.trace(`[abr] Skipped level(s) ${g}-${m} with CODECS:"${u[m].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const n=e.details,a=(l?null==n?void 0:n.partTarget:null==n?void 0:n.averagetargetduration)||f;let v;v=s<=c?i*t:o*t;const y=u[s].maxBitrate,C=this.getTimeToLoadFrag(p,v,y*a,void 0===n);if(Un.trace(`[abr] level:${s} adjustedbw-bitrate:${Math.round(v-y)} avgDuration:${a.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:${C.toFixed(1)}`),v>y&&(0===C||!Bn(C)||d&&!this.bitrateTestDelay||C{const{media:t,mediaSource:e}=this;Un.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(Pn.MEDIA_ATTACHED,{media:t})),e&&e.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{Un.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{Un.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:t,_objectUrl:e}=this;t&&t.src!==e&&Un.error(`Media element src was set while attaching MediaSource (${e} > ${t.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.BUFFER_RESET,this.onBufferReset,this),t.on(Pn.BUFFER_APPENDING,this.onBufferAppending,this),t.on(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Pn.BUFFER_EOS,this.onBufferEos,this),t.on(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(Pn.FRAG_PARSED,this.onFragParsed,this),t.on(Pn.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.BUFFER_RESET,this.onBufferReset,this),t.off(Pn.BUFFER_APPENDING,this.onBufferAppending,this),t.off(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Pn.BUFFER_EOS,this.onBufferEos,this),t.off(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(Pn.FRAG_PARSED,this.onFragParsed,this),t.off(Pn.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new sa(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let n=2;(e.audio&&!e.video||!e.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,Un.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const n=this.media=e.media;if(n&&aa){const t=this.mediaSource=new aa;t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(t),this._objectUrl=n.src,n.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:n}=this;if(e){if(Un.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){Un.warn(`[buffer-controller]: onMediaDetaching: ${t.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),n&&self.URL.revokeObjectURL(n),t.src===n?(t.removeAttribute("src"),t.load()):Un.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(Pn.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(e){Un.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,e)}})),this._initSourceBuffer()}onBufferCodecs(t,e){const n=this.getSourceBufferTypes().length;Object.keys(e).forEach((t=>{if(n){const n=this.tracks[t];if(n&&"function"==typeof n.buffer.changeType){const{id:r,codec:i,levelCodec:o,container:s,metadata:a}=e[t],l=(n.levelCodec||n.codec).replace(la,"$1"),c=(o||i).replace(la,"$1");if(l!==c){const e=`${s};codecs=${o||i}`;this.appendChangeType(t,e),Un.log(`[buffer-controller]: switching codec ${l} to ${c}`),this.tracks[t]={buffer:n.buffer,codec:i,container:s,levelCodec:o,metadata:a,id:r}}}}else this.pendingTracks[t]=e[t]})),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:n}=this,r={execute:()=>{const r=this.sourceBuffer[t];r&&(Un.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),r.changeType(e)),n.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{Un.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,e)}};n.append(r,t)}onBufferAppending(t,e){const{hls:n,operationQueue:r,tracks:i}=this,{data:o,type:s,frag:a,part:l,chunkMeta:c}=e,u=c.buffering[s],A=self.performance.now();u.start=A;const d=a.stats.buffering,h=l?l.stats.buffering:null;0===d.start&&(d.start=A),h&&0===h.start&&(h.start=A);const f=i.audio;let p=!1;"audio"===s&&"audio/mpeg"===(null==f?void 0:f.container)&&(p=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const g=a.start,m={execute:()=>{if(u.executeStart=self.performance.now(),p){const t=this.sourceBuffer[s];if(t){const e=g-t.timestampOffset;Math.abs(e)>=.1&&(Un.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${g} (delta: ${e}) sn: ${a.sn})`),t.timestampOffset=g)}}this.appendExecutor(o,s)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();u.executeEnd=u.end=t,0===d.first&&(d.first=t),h&&0===h.first&&(h.first=t);const{sourceBuffer:e}=this,n={};for(const t in e)n[t]=To.getBuffered(e[t]);this.appendError=0,this.hls.trigger(Pn.BUFFER_APPENDED,{type:s,frag:a,part:l,chunkMeta:c,parent:a.type,timeRanges:n})},onError:t=>{Un.error(`[buffer-controller]: Error encountered while trying to append to the ${s} SourceBuffer`,t);const e={type:Mn.MEDIA_ERROR,parent:a.type,details:On.BUFFER_APPEND_ERROR,frag:a,part:l,chunkMeta:c,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=On.BUFFER_FULL_ERROR:(this.appendError++,e.details=On.BUFFER_APPEND_ERROR,this.appendError>n.config.appendErrorMaxRetry&&(Un.error(`[buffer-controller]: Failed ${n.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),e.fatal=!0)),n.trigger(Pn.ERROR,e)}};r.append(m,s)}onBufferFlushing(t,e){const{operationQueue:n}=this,r=t=>({execute:this.removeExecutor.bind(this,t,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Pn.BUFFER_FLUSHED,{type:t})},onError:e=>{Un.warn(`[buffer-controller]: Failed to remove from ${t} SourceBuffer`,e)}});e.type?n.append(r(e.type),e.type):this.getSourceBufferTypes().forEach((t=>{n.append(r(t),t)}))}onFragParsed(t,e){const{frag:n,part:r}=e,i=[],o=r?r.elementaryStreams:n.elementaryStreams;o.audiovideo?i.push("audiovideo"):(o.audio&&i.push("audio"),o.video&&i.push("video")),0===i.length&&Un.warn(`Fragments must have at least one ElementaryStreamType set. type: ${n.type} level: ${n.level} sn: ${n.sn}`),this.blockBuffers((()=>{const t=self.performance.now();n.stats.buffering.end=t,r&&(r.stats.buffering.end=t);const e=r?r.stats:n.stats;this.hls.trigger(Pn.FRAG_BUFFERED,{frag:n,part:r,stats:e,id:n.type})}),i)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce(((t,n)=>{const r=this.sourceBuffer[n];return!r||e.type&&e.type!==n||(r.ending=!0,r.ended||(r.ended=!0,Un.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),t&&!(r&&!r.ended)}),!0)&&(Un.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((()=>{this.getSourceBufferTypes().forEach((t=>{const e=this.sourceBuffer[t];e&&(e.ending=!1)}));const{mediaSource:t}=this;t&&"open"===t.readyState?(Un.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&Un.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${t.readyState}`)})))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:n,sourceBuffer:r}=this;if(!n||null===e)return;const i=this.getSourceBufferTypes();if(!i.length)return;const o=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(!Bn(o)||o<0)return;const s=n.currentTime,a=e.levelTargetDuration,l=Math.max(o,a),c=Math.floor(s/a)*a-l;i.forEach((n=>{const i=r[n];if(i){const r=To.getBuffered(i);if(r.length>0&&c>r.start(0)){if(t.trigger(Pn.BACK_BUFFER_REACHED,{bufferEnd:c}),e.live)t.trigger(Pn.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(i.ended&&r.end(r.length-1)-s<2*a)return void Un.info(`[buffer-controller]: Cannot flush ${n} back buffer while SourceBuffer is in ended state`);t.trigger(Pn.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:n})}}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:t,hls:e,media:n,mediaSource:r}=this,i=t.fragments[0].start+t.totalduration,o=n.duration,s=Bn(r.duration)?r.duration:0;t.live&&e.config.liveDurationInfinity?(Un.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(i>s&&i>o||!Bn(o))&&(Un.log(`[buffer-controller]: Updating Media Source duration to ${i.toFixed(3)}`),r.duration=i)}updateSeekableRange(t){const e=this.mediaSource,n=t.fragments;if(n.length&&t.live&&null!=e&&e.setLiveSeekableRange){const r=Math.max(0,n[0].start),i=Math.max(r,r+t.totalduration);e.setLiveSeekableRange(r,i)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:n}=this,r=Object.keys(n).length;if(r&&!t||2===r){this.createSourceBuffers(n),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(Pn.BUFFER_CREATED,{tracks:this.tracks}),t.forEach((t=>{e.executeNext(t)}));else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:n}=this;if(!n)throw Error("createSourceBuffers called when mediaSource was null");for(const r in t)if(!e[r]){const i=t[r];if(!i)throw Error(`source buffer exists for track ${r}, however track does not`);const o=i.levelCodec||i.codec,s=`${i.container};codecs=${o}`;Un.log(`[buffer-controller]: creating sourceBuffer(${s})`);try{const t=e[r]=n.addSourceBuffer(s),a=r;this.addBufferListener(a,"updatestart",this._onSBUpdateStart),this.addBufferListener(a,"updateend",this._onSBUpdateEnd),this.addBufferListener(a,"error",this._onSBUpdateError),this.tracks[r]={buffer:t,codec:o,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(t){Un.error(`[buffer-controller]: error while trying to add sourceBuffer: ${t.message}`),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:s})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const n=new Error(`${t} SourceBuffer error`);Un.error(`[buffer-controller]: ${n}`,e),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_APPENDING_ERROR,error:n,fatal:!1});const r=this.operationQueue.current(t);r&&r.onError(e)}removeExecutor(t,e,n){const{media:r,mediaSource:i,operationQueue:o,sourceBuffer:s}=this,a=s[t];if(!r||!i||!a)return Un.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),void o.shiftAndExecuteNext(t);const l=Bn(r.duration)?r.duration:1/0,c=Bn(i.duration)?i.duration:1/0,u=Math.max(0,e),A=Math.min(n,l,c);A>u&&!a.ending?(a.ended=!1,Un.log(`[buffer-controller]: Removing [${u},${A}] from the ${t} SourceBuffer`),a.remove(u,A)):o.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:n,sourceBuffer:r}=this,i=r[e];if(!i)return Un.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),void n.shiftAndExecuteNext(e);i.ended=!1,i.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length)return Un.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);const{operationQueue:n}=this,r=e.map((t=>n.appendBlocker(t)));Promise.all(r).then((()=>{t(),e.forEach((t=>{const e=this.sourceBuffer[t];null!=e&&e.updating||n.shiftAndExecuteNext(t)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,n){const r=this.sourceBuffer[t];if(!r)return;const i=n.bind(this,t);this.listeners[t].push({event:e,listener:i}),r.addEventListener(e,i)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach((t=>{e.removeEventListener(t.event,t.listener)}))}},capLevelController:el,errorController:class{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=Un.log.bind(Un,"[info]:"),this.warn=Un.warn.bind(Un,"[warning]:"),this.error=Un.error.bind(Un,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(Pn.ERROR,this.onError,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(Pn.ERROR,this.onError,this),t.off(Pn.ERROR,this.onErrorOut,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(null==t?void 0:t.type)===Ei?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var n,r;if(e.fatal)return;const i=this.hls,o=e.context;switch(e.details){case On.FRAG_LOAD_ERROR:case On.FRAG_LOAD_TIMEOUT:case On.KEY_LOAD_ERROR:case On.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case On.FRAG_PARSING_ERROR:if(null!=(n=e.frag)&&n.gap)return void(e.errorAction={action:0,flags:0});case On.FRAG_GAP:case On.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=2);case On.LEVEL_EMPTY_ERROR:case On.LEVEL_PARSING_ERROR:{var s,a;const t=e.parent===Ei?e.level:i.loadLevel;e.details===On.LEVEL_EMPTY_ERROR&&null!=(s=e.context)&&null!=(a=s.levelDetails)&&a.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case On.LEVEL_LOAD_ERROR:case On.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==o?void 0:o.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.level)));case On.AUDIO_TRACK_LOAD_ERROR:case On.AUDIO_TRACK_LOAD_TIMEOUT:case On.SUBTITLE_LOAD_ERROR:case On.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){const t=i.levels[i.loadLevel];if(t&&(o.type===Ci&&o.groupId===t.audioGroupId||o.type===bi&&o.groupId===t.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=2,void(e.errorAction.flags=1)}return;case On.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=i.levels[i.loadLevel],n=null==t?void 0:t.attrs["HDCP-LEVEL"];n&&(e.errorAction={action:2,flags:2,hdcpLevel:n})}return;case On.BUFFER_ADD_CODEC_ERROR:case On.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(r=e.level)?r:i.loadLevel));case On.INTERNAL_EXCEPTION:case On.BUFFER_APPENDING_ERROR:case On.BUFFER_APPEND_ERROR:case On.BUFFER_FULL_ERROR:case On.LEVEL_SWITCH_ERROR:case On.BUFFER_STALLED_ERROR:case On.BUFFER_SEEK_OVER_HOLE:case On.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:0,flags:0})}if(e.type===Mn.KEY_SYSTEM_ERROR){const t=this.getVariantLevelIndex(e.frag);return e.levelRetry=!1,void(e.errorAction=this.getLevelSwitchAction(e,t))}}getPlaylistRetryOrSwitchAction(t,e){var n;const r=$i(this.hls.config.playlistLoadPolicy,t),i=this.playlistError++,o=null==(n=t.response)?void 0:n.code;if(Ji(r,i,zi(t),o))return{action:5,flags:0,retryConfig:r,retryCount:i};const s=this.getLevelSwitchAction(t,e);return r&&(s.retryConfig=r,s.retryCount=i),s}getFragRetryOrSwitchAction(t){const e=this.hls,n=this.getVariantLevelIndex(t.frag),r=e.levels[n],{fragLoadPolicy:i,keyLoadPolicy:o}=e.config,s=$i(t.details.startsWith("key")?o:i,t),a=e.levels.reduce(((t,e)=>t+e.fragmentError),0);if(r){var l;t.details!==On.FRAG_GAP&&r.fragmentError++;const e=null==(l=t.response)?void 0:l.code;if(Ji(s,a,zi(t),e))return{action:5,flags:0,retryConfig:s,retryCount:a}}const c=this.getLevelSwitchAction(t,n);return s&&(c.retryConfig=s,c.retryCount=a),c}getLevelSwitchAction(t,e){const n=this.hls;null==e&&(e=n.loadLevel);const r=this.hls.levels[e];if(r&&(r.loadError++,n.autoLevelEnabled)){var i,o;let e=-1;const{levels:s,loadLevel:a,minAutoLevel:l,maxAutoLevel:c}=n,u=null==(i=t.frag)?void 0:i.type,{type:A,groupId:d}=null!=(o=t.context)?o:{};for(let n=s.length;n--;){const i=(n+a)%s.length;if(i!==a&&i>=l&&i<=c&&0===s[i].loadError){const n=s[i];if(t.details===On.FRAG_GAP&&t.frag){const e=s[i].details;if(e){const n=to(t.frag,e.fragments,t.frag.start);if(null!=n&&n.gap)continue}}else{if(A===Ci&&d===n.audioGroupId||A===bi&&d===n.textGroupId)continue;if(u===wi&&r.audioGroupId===n.audioGroupId||u===Ti&&r.textGroupId===n.textGroupId)continue}e=i;break}}if(e>-1&&n.loadLevel!==e)return t.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:e}}return{action:2,flags:1}}onErrorOut(t,e){var n;switch(null==(n=e.errorAction)?void 0:n.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===On.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){const e=this.hls,n=t.errorAction;if(!n)return;const{flags:r,hdcpLevel:i,nextAutoLevel:o}=n;switch(r){case 0:this.switchLevel(t,o);break;case 1:n.resolved||(n.resolved=this.redundantFailover(t));break;case 2:i&&(e.maxHdcpLevel=Ui[Ui.indexOf(i)-1],n.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}n.resolved||this.switchLevel(t,o)}switchLevel(t,e){void 0!==e&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:n}=this,r=t.parent===Ei?t.level:e.loadLevel,i=e.levels[r],o=i.url.length,s=t.frag?t.frag.urlId:i.urlId;i.urlId!==s||t.frag&&!i.details||this.penalizeRendition(i,t);for(let a=1;a{t.urlId=l})),e.nextLoadLevel=r,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:n}=this,r=n[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};r.lastErrorPerfMs=performance.now(),r.errors.push(e),r.details=t.details,n[t.urlId]=r}},fpsController:class{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const n=this.hls.config;if(n.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=t,t&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),n.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,n){const r=performance.now();if(e){if(this.lastTime){const t=r-this.lastTime,i=n-this.lastDroppedFrames,o=e-this.lastDecodedFrames,s=1e3*i/t,a=this.hls;if(a.trigger(Pn.FPS_DROP,{currentDropped:i,currentDecoded:o,totalDroppedFrames:n}),s>0&&i>a.config.fpsDroppedMonitoringThreshold*o){let t=a.currentLevel;Un.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===a.autoLevelCapping||a.autoLevelCapping>=t)&&(t-=1,a.trigger(Pn.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:a.currentLevel}),a.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=n,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ur,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:ml,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Ko{constructor(t,e,n){super(t,e,n,"[subtitle-stream-controller]",Ti),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Pn.ERROR,this.onError,this),t.on(Pn.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Pn.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Pn.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Pn.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Pn.ERROR,this.onError,this),t.off(Pn.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(Pn.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Pn.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Pn.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Oo,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:n,success:r}=e;if(this.fragPrevious=n,this.state=Oo,!r)return;const i=this.tracksBuffered[this.currentTrackId];if(!i)return;let o;const s=n.start;for(let t=0;t=i[t].start&&s<=i[t].end){o=i[t];break}const a=n.start+n.duration;o?o.end=a:(o={start:s,end:a},i.push(o)),this.fragmentTracker.fragBuffered(n)}onBufferFlushing(t,e){const{startOffset:n,endOffset:r}=e;if(0===n&&r!==Number.POSITIVE_INFINITY){const t=r-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach((e=>{for(let n=0;nnew Gi(t))):(this.tracksBuffered=[],this.levels=e.map((t=>{const e=new Gi(t);return this.tracksBuffered[e.id]=[],e})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Ti),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||-1===this.currentTrackId)return void this.clearInterval();const n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.setInterval(500)}onSubtitleTrackLoaded(t,e){var n;const{details:r,id:i}=e,{currentTrackId:o,levels:s}=this;if(!s.length)return;const a=s[o];if(i>=s.length||i!==o||!a)return;this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(r.live||null!=(n=a.details)&&n.live){const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;const e=t.fragments[0];a.details?(l=this.alignPlaylists(r,a.details),0===l&&e&&(l=e.start,Hi(r,l))):r.hasProgramDateTime&&t.hasProgramDateTime?(Io(r,t),l=r.fragments[0].start):e&&(l=e.start,Hi(r,l))}a.details=r,this.levelLastLoaded=i,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(a.details,l),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===Oo&&(to(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:n}=t,r=e.decryptdata,i=this.hls;if(!this.fragContextChanged(e)&&n&&n.byteLength>0&&r&&r.key&&r.iv&&"AES-128"===r.method){const t=performance.now();this.decrypter.decrypt(new Uint8Array(n),r.key.buffer,r.iv.buffer).catch((t=>{throw i.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((n=>{const r=performance.now();i.trigger(Pn.FRAG_DECRYPTED,{frag:e,payload:n,stats:{tstart:t,tdecrypt:r}})})).catch((t=>{this.warn(`${t.name}: ${t.message}`),this.state=Oo}))}}doTick(){if(this.media){if(this.state===Oo){const{currentTrackId:t,levels:e}=this,n=e[t];if(!e.length||!n||!n.details)return;const{config:r}=this,i=this.getLoadPosition(),o=To.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),{end:s,len:a}=o,l=this.getFwdBufferInfo(this.media,Ei),c=n.details;if(a>this.getMaxBufferLength(null==l?void 0:l.len)+c.levelTargetDuration)return;const u=c.fragments,A=u.length,d=c.edge;let h=null;const f=this.fragPrevious;if(sd-t?0:t;h=to(f,u,Math.max(u[0].start,s),e),!h&&f&&f.startthis.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.on(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Pn.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.off(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Pn.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),oa(this.media.textTracks).forEach((t=>{Ri(t)})),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:n,details:r}=e,{trackId:i}=this,o=this.tracksInGroup[i];if(!o)return void this.warn(`Invalid subtitle track id ${n}`);const s=o.details;o.details=e.details,this.log(`subtitle track ${n} loaded [${r.startSN}-${r.endSN}]`),n===this.trackId&&this.playlistLoaded(n,e,s)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null==e||!e.textGroupIds)return;const n=e.textGroupIds[e.urlId],r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==n){const t=this.tracks.filter((t=>!n||t.groupId===n));this.tracksInGroup=t;const e=this.findTrackId(null==r?void 0:r.name)||this.findTrackId();this.groupId=n||null;const i={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${n}" group-id`),this.hls.trigger(Pn.SUBTITLE_TRACKS_UPDATED,i),-1!==e&&this.setSubtitleTrack(e,r)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId,r)}findTrackId(t){const e=this.tracksInGroup;for(let n=0;nt.groupId===this.groupId));if(-1===t)[].slice.call(r).forEach((t=>{t.mode="disabled"}));else{const t=i[n];t&&(t.mode="disabled")}const o=i[t];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var n;const r=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=t);if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(-1===t||null!=(n=r[t])&&n.details)||t<-1||t>=r.length)return;this.clearTimer();const i=r[t];if(this.log(`Switching to subtitle-track ${t}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:"")),this.trackId=t,i){const{id:t,groupId:n="",name:r,type:o,url:s}=i;this.hls.trigger(Pn.SUBTITLE_TRACK_SWITCH,{id:t,groupId:n,name:r,type:o,url:s});const a=this.switchParams(i.url,null==e?void 0:e.details);this.loadPlaylist(a)}else this.hls.trigger(Pn.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=oa(this.media.textTracks);for(let n=0;n=0&&(r[0]=Math.min(r[0],e),r[1]=Math.max(r[1],n),o=!0,u/(n-e)>.5))return}var s,a,l,c;if(o||i.push([e,n]),this.config.renderTextTracksNatively){const i=this.captionsTracks[t];this.Cues.newCue(i,e,n,r)}else{const i=this.Cues.newCue(null,e,n,r);this.hls.trigger(Pn.CUES_PARSED,{type:"captions",cues:i,track:t})}}onInitPtsFound(t,{frag:e,id:n,initPTS:r,timescale:i}){const{unparsedVttFrags:o}=this;"main"===n&&(this.initPTS[e.cc]={baseTime:r,timescale:i}),o.length&&(this.unparsedVttFrags=[],o.forEach((t=>{this.onFragLoaded(Pn.FRAG_LOADED,t)})))}getExistingTrack(t){const{media:e}=this;if(e)for(let n=0;n{Ri(t[e]),delete t[e]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let t=0;tt.textCodec===Ya));if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(na(this.tracks,n))return void(this.tracks=n);if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){const t=this.media?this.media.textTracks:null;this.tracks.forEach(((e,n)=>{let r;if(t&&n({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t})));this.hls.trigger(Pn.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),n=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&n)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((t=>{const e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!e)return;const n=`textTrack${e[1]}`,r=this.captionsProperties[n];r&&(r.label=t.name,t.lang&&(r.languageCode=t.lang),r.media=t)}))}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:n,cea608Parser2:r,lastSn:i,lastPartIndex:o}=this;if(this.enabled&&n&&r&&e.frag.type===Ei){var s,a;const t=e.frag.sn,l=null!=(s=null==e||null==(a=e.part)?void 0:a.index)?s:-1;t===i+1||t===i&&l===o+1||(n.reset(),r.reset()),this.lastSn=t,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:n,payload:r}=e;if(n.type===Ti)if(r.byteLength){const t=n.decryptdata,i="stats"in e;if(null==t||!t.encrypted||i){const t=this.tracks[n.level],i=this.vttCCs;i[n.cc]||(i[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),t&&t.textCodec===Ya?this._parseIMSC1(n,r):this._parseVTTs(e)}}else this.hls.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const n=this.hls;Va(e,this.initPTS[t.cc],(e=>{this._appendCues(e,t.level),n.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(e=>{Un.log(`Failed to parse IMSC1: ${e}`),n.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))}_parseVTTs(t){var e;const{frag:n,payload:r}=t,{initPTS:i,unparsedVttFrags:o}=this,s=i.length-1;if(!i[n.cc]&&-1===s)return void o.push(t);const a=this.hls;!function(t,e,n,r,i,o,s){const a=new Na,l=Sr(new Uint8Array(t)).trim().replace(Ua,"\n").split("\n"),c=[],u=e?function(t,e=1){return Is(t,9e4,1/e)}(e.baseTime,e.timescale):0;let A,d="00:00.000",h=0,f=0,p=!0;a.oncue=function(t){const o=n[r];let s=n.ccOffset;const a=(h-u)/9e4;if(null!=o&&o.new&&(void 0!==f?s=n.ccOffset=o.start:function(t,e,n){let r=t[e],i=t[r.prevCC];if(!i||!i.new&&r.new)return t.ccOffset=t.presentationOffset=r.start,void(r.new=!1);for(;null!=(o=i)&&o.new;){var o;t.ccOffset+=r.start-i.start,r.new=!1,r=i,i=t[r.prevCC]}t.presentationOffset=n}(n,r,a)),a){if(!e)return void(A=new Error("Missing initPTS for VTT MPEGTS"));s=a-n.presentationOffset}const l=t.endTime-t.startTime,d=Os(9e4*(t.startTime+s-f),9e4*i)/9e4;t.startTime=Math.max(d,0),t.endTime=Math.max(d+l,0);const p=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(p)),t.id||(t.id=Wa(t.startTime,t.endTime,p)),t.endTime>0&&c.push(t)},a.onparsingerror=function(t){A=t},a.onflush=function(){A?s(A):o(c)},l.forEach((t=>{if(p){if(Qa(t,"X-TIMESTAMP-MAP=")){p=!1,t.slice(16).split(",").forEach((t=>{Qa(t,"LOCAL:")?d=t.slice(6):Qa(t,"MPEGTS:")&&(h=parseInt(t.slice(7)))}));try{f=function(t){let e=parseInt(t.slice(-3));const n=parseInt(t.slice(-6,-4)),r=parseInt(t.slice(-9,-7)),i=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(Bn(e)&&Bn(n)&&Bn(r)&&Bn(i)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return e+=1e3*n,e+=6e4*r,e+=36e5*i,e}(d)/1e3}catch(t){A=t}return}""===t&&(p=!1)}a.parse(t+"\n")})),a.flush()}(null!=(e=n.initSegment)&&e.data?Wr(n.initSegment.data,new Uint8Array(r)):r,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,(t=>{this._appendCues(t,n.level),a.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})}),(e=>{const i="Missing initPTS for VTT MPEGTS"===e.message;i?o.push(t):this._fallbackToIMSC1(n,r),Un.log(`Failed to parse VTT cue: ${e}`),i&&s>n.cc||a.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:e})}))}_fallbackToIMSC1(t,e){const n=this.tracks[t.level];n.textCodec||Va(e,this.initPTS[t.cc],(()=>{n.textCodec=Ya,this._parseIMSC1(t,e)}),(()=>{n.textCodec="wvtt"}))}_appendCues(t,e){const n=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||"disabled"===n.mode)return;t.forEach((t=>Ii(n,t)))}else{const r=this.tracks[e];if(!r)return;const i=r.default?"default":"subtitles"+e;n.trigger(Pn.CUES_PARSED,{type:"subtitles",cues:t,track:i})}}onFragDecrypted(t,e){const{frag:n}=e;n.type===Ti&&this.onFragLoaded(Pn.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:n,cea608Parser2:r}=this;if(!this.enabled||!n||!r)return;const{frag:i,samples:o}=e;if(i.type!==Ei||"NONE"!==this.closedCaptionsForLevel(i))for(let t=0;tDi(t[r],e,n)))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==r){const{textTracks:t}=this;Object.keys(t).forEach((n=>Di(t[n],e,r)))}}}extractCea608Data(t){const e=[[],[]],n=31&t[0];let r=2;for(let i=0;i0&&-1===t?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Oo):(this.loadedmetadata=!1,this.state=Uo),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Oo:this.doTickIdle();break;case Uo:{var t;const{levels:e,trackId:n}=this,r=null==e||null==(t=e[n])?void 0:t.details;if(r){if(this.waitForCdnTuneIn(r))break;this.state=jo}break}case No:{var e;const t=performance.now(),n=this.retryDate;(!n||t>=n||null!=(e=this.media)&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Oo);break}case jo:{const t=this.waitingData;if(t){const{frag:e,part:n,cache:r,complete:i}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=_o;const t={frag:e,part:n,payload:r.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),i&&super._handleFragmentLoadComplete(t)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${e.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const t=this.getLoadPosition(),n=To.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);eo(n.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log(`Waiting fragment cc (${e.cc}) @ ${e.start} cancelled because another fragment at ${n.end} is needed`),this.clearWaitingFragment())}}else this.state=Oo}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Oo)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:n,trackId:r}=this,i=t.config;if(null==e||!e[r])return;if(!n&&(this.startFragRequested||!i.startFragPrefetch))return;const o=e[r],s=o.details;if(!s||s.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(s))return void(this.state=Uo);const a=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&a&&(this.bufferFlushed=!1,this.afterBufferFlushed(a,Kn,wi));const l=this.getFwdBufferInfo(a,wi);if(null===l)return;const{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(l,s))return t.trigger(Pn.BUFFER_EOS,{type:"audio"}),void(this.state=Wo);const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Ei),d=l.len,h=this.getMaxBufferLength(null==A?void 0:A.len);if(d>=h&&!u)return;const f=s.fragments[0].start;let p=l.end;if(u&&n){const t=this.getLoadPosition();c&&u.attrs!==c.attrs&&(p=t),s.PTSKnown&&tf||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=f+.05)}let g=this.getNextFragment(p,s),m=!1;if(g&&this.isLoopLoading(g,p)&&(m=!!g.gap,g=this.getNextFragmentLoopLoading(g,s,l,Ei,h)),!g)return void(this.bufferFlushed=!0);const v=A&&g.start>A.end+s.targetduration;if(v||(null==A||!A.len)&&l.len){const t=this.getAppendedFrag(g.start,Ei);if(null===t)return;if(m||(m=!!t.gap||!!v&&0===A.len),v&&!m||m&&l.nextStart&&l.nextStartnew Gi(t)))}onAudioTrackSwitching(t,e){const n=!!e.url;this.trackId=e.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),n?this.setInterval(100):this.resetTransmuxer(),n?(this.switchingTrack=e,this.state=Oo):(this.switchingTrack=null,this.bufferedTrack=e,this.state=Mo),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(Pn.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var n;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=e);const{levels:r}=this,{details:i,id:o}=e;if(!r)return void this.warn(`Audio tracks were reset while loading level ${o}`);this.log(`Track ${o} loaded [${i.startSN},${i.endSN}]${i.lastPartSn?`[part-${i.lastPartSn}-${i.lastPartIndex}]`:""},duration:${i.totalduration}`);const s=r[o];let a=0;if(i.live||null!=(n=s.details)&&n.live){this.checkLiveUpdate(i);const t=this.mainDetails;if(i.deltaUpdateFailed||!t)return;!s.details&&i.hasProgramDateTime&&t.hasProgramDateTime?(Io(i,t),a=i.fragments[0].start):a=this.alignPlaylists(i,s.details)}s.details=i,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(s.details,a),this.state!==Uo||this.waitForCdnTuneIn(i)||(this.state=Oo),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:n,part:r,payload:i}=t,{config:o,trackId:s,levels:a}=this;if(!a)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const l=a[s];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(n.start);const u=o.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let A=this.transmuxer;A||(A=this.transmuxer=new Xs(this.hls,wi,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const d=this.initPTS[n.cc],h=null==(e=n.initSegment)?void 0:e.data;if(void 0!==d){const t=!1,e=r?r.index:-1,o=-1!==e,s=new So(n.level,n.sn,n.stats.chunkCount,i.byteLength,e,o);A.push(i,h,u,"",n,r,c.totalduration,t,s,d)}else{this.log(`Unknown video PTS for cc ${n.cc}, waiting for video PTS before demuxing audio frag ${n.sn} of [${c.startSN} ,${c.endSN}],track ${s}`);const{cache:t}=this.waitingData=this.waitingData||{frag:n,part:r,cache:new ea,complete:!1};t.push(new Uint8Array(i)),this.waitingVideoCC=this.videoTrackCC,this.state=jo}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const n=e.tracks.audio;n&&(this.mediaBuffer=n.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:n,part:r}=e;if(n.type===wi)if(this.fragContextChanged(n))this.warn(`Fragment ${n.sn}${r?" p: "+r.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==n.sn){this.fragPrevious=n;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(Pn.AUDIO_TRACK_SWITCHED,In({},t)))}this.fragBufferedComplete(n,r)}else if(!this.loadedmetadata&&n.type===Ei){const t=this.videoBuffer||this.media;t&&To.getBuffered(t).length&&(this.loadedmetadata=!0)}}onError(t,e){var n;if(e.fatal)this.state=Yo;else switch(e.details){case On.FRAG_GAP:case On.FRAG_PARSING_ERROR:case On.FRAG_DECRYPT_ERROR:case On.FRAG_LOAD_ERROR:case On.FRAG_LOAD_TIMEOUT:case On.KEY_LOAD_ERROR:case On.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(wi,e);break;case On.AUDIO_TRACK_LOAD_ERROR:case On.AUDIO_TRACK_LOAD_TIMEOUT:case On.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Uo||(null==(n=e.context)?void 0:n.type)!==Ci||(this.state=Oo);break;case On.BUFFER_FULL_ERROR:if(!e.parent||"audio"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case On.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushed(t,{type:e}){e===Kn&&(this.bufferFlushed=!0,this.state===Wo&&(this.state=Oo))}_handleTransmuxComplete(t){var e;const n="audio",{hls:r}=this,{remuxResult:i,chunkMeta:o}=t,s=this.getCurrentContext(o);if(!s)return void this.resetWhenMissingContext(o);const{frag:a,part:l,level:c}=s,{details:u}=c,{audio:A,text:d,id3:h,initSegment:f}=i;if(!this.fragContextChanged(a)&&u){if(this.state=Qo,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const t=a.initSegment||a;this._bufferInitSegment(f.tracks,t,o),r.trigger(Pn.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:n,tracks:f.tracks})}if(A){const{startPTS:t,endPTS:e,startDTS:n,endDTS:r}=A;l&&(l.elementaryStreams.audio={startPTS:t,endPTS:e,startDTS:n,endDTS:r}),a.setElementaryStreamInfo(Kn,t,e,n,r),this.bufferFragmentData(A,a,l,o)}if(null!=h&&null!=(e=h.samples)&&e.length){const t=Dn({id:n,frag:a,details:u},h);r.trigger(Pn.FRAG_PARSING_METADATA,t)}if(d){const t=Dn({id:n,frag:a,details:u},d);r.trigger(Pn.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(a)}_bufferInitSegment(t,e,n){if(this.state!==Qo)return;t.video&&delete t.video;const r=t.audio;if(!r)return;r.levelCodec=r.codec,r.id="audio",this.log(`Init audio buffer, container:${r.container}, codecs[parsed]=[${r.codec}]`),this.hls.trigger(Pn.BUFFER_CODECS,t);const i=r.initSegment;if(null!=i&&i.byteLength){const t={type:"audio",frag:e,part:null,chunkMeta:n,parent:e.type,data:i};this.hls.trigger(Pn.BUFFER_APPENDING,t)}this.tick()}loadFragment(t,e,n){const r=this.fragmentTracker.getState(t);var i;this.fragCurrent=t,this.switchingTrack||r===co||r===Ao?"initSegment"===t.sn?this._loadInitSegment(t,e):null!=(i=e.details)&&i.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=jo):(this.startFragRequested=!0,super.loadFragment(t,e,n)):this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:n,bufferedTrack:r}=this,i=null==r?void 0:r.attrs,o=t.attrs;n&&i&&(i.CHANNELS!==o.CHANNELS||i.NAME!==o.NAME||i.LANGUAGE!==o.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(Pn.AUDIO_TRACK_SWITCHED,In({},t))}},audioTrackController:class extends io{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.on(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Pn.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(Pn.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.off(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Pn.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(Pn.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:n,groupId:r,details:i}=e,o=this.tracksInGroup[n];if(!o||o.groupId!==r)return void this.warn(`Track with id:${n} and group:${r} not found in active group ${o.groupId}`);const s=o.details;o.details=e.details,this.log(`audio-track ${n} "${o.name}" lang:${o.lang} group:${r} loaded [${i.startSN}-${i.endSN}]`),n===this.trackId&&this.playlistLoaded(n,e,s)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null==e||!e.audioGroupIds)return;const n=e.audioGroupIds[e.urlId];if(this.groupId!==n){this.groupId=n||null;const t=this.tracks.filter((t=>!n||t.groupId===n));this.selectDefaultTrack&&!t.some((t=>t.default))&&(this.selectDefaultTrack=!1),this.tracksInGroup=t;const e={audioTracks:t};this.log(`Updating audio tracks, ${t.length} track(s) found in group:${n}`),this.hls.trigger(Pn.AUDIO_TRACKS_UPDATED,e),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){!e.fatal&&e.context&&e.context.type===Ci&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length)return void this.warn("Invalid id passed to audio-track controller");this.clearTimer();const n=this.currentTrack;e[this.trackId];const r=e[t],{groupId:i,name:o}=r;if(this.log(`Switching to audio-track ${t} "${o}" lang:${r.lang} group:${i}`),this.trackId=t,this.currentTrack=r,this.selectDefaultTrack=!1,this.hls.trigger(Pn.AUDIO_TRACK_SWITCHING,In({},r)),r.details&&!r.details.live)return;const s=this.switchParams(r.url,null==n?void 0:n.details);this.loadPlaylist(s)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==e)this.setAudioTrack(e);else{const e=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(e.message),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}findTrackId(t){const e=this.tracksInGroup;for(let n=0;ne!==t)))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:n}=e;null!==n&&(this.pathwayId=n.pathwayId,this.uri=n.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:n}=e;if(2===(null==n?void 0:n.action)&&1===n.flags){let t=this.pathwayPriority;const e=this.pathwayId;this.penalizedPathways[e]||(this.penalizedPathways[e]=performance.now()),!t&&this.levels&&(t=this.levels.reduce(((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t)),[])),t&&t.length>1&&(this.updatePathwayPriority(t),n.resolved=this.pathwayId!==e)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){const n=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${n}"`),e=this.getLevelsForPathway(n),this.pathwayId=n}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter((e=>t===e.pathwayId))}updatePathwayPriority(t){let e;this.pathwayPriority=t;const n=this.penalizedPathways,r=performance.now();Object.keys(n).forEach((t=>{r-n[t]>3e5&&delete n[t]}));for(let r=0;r0){this.log(`Setting Pathway to "${i}"`),this.pathwayId=i,this.hls.trigger(Pn.LEVELS_UPDATED,{levels:e});const t=this.hls.levels[o];s&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${t.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(t){const e=this.levels;if(!e)return;const n={},r={};t.forEach((t=>{const{ID:i,"BASE-ID":o,"URI-REPLACEMENT":s}=t;if(e.some((t=>t.pathwayId===i)))return;const a=this.getLevelsForPathway(o).map((t=>{const e=Dn({},t);e.details=void 0,e.url=cl(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s);const o=new Wn(t.attrs);o["PATHWAY-ID"]=i;const a=o.AUDIO&&`${o.AUDIO}_clone_${i}`,l=o.SUBTITLES&&`${o.SUBTITLES}_clone_${i}`;a&&(n[o.AUDIO]=a,o.AUDIO=a),l&&(r[o.SUBTITLES]=l,o.SUBTITLES=l),e.attrs=o;const c=new Gi(e);return ao(c,"audio",a),ao(c,"text",l),c}));e.push(...a),ll(this.audioTracks,n,s,i),ll(this.subtitleTracks,r,s,i)}))}loadSteeringManifest(t){const e=this.hls.config,n=e.loader;let r;this.loader&&this.loader.destroy(),this.loader=new n(e);try{r=new self.URL(t)}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${t}`)}if("data:"!==r.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+t)}const i={responseType:"json",url:r.href},o=e.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},a={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(t,e,n,i)=>{this.log(`Loaded steering manifest: "${r}"`);const o=t.data;if(1!==o.VERSION)return void this.log(`Steering VERSION ${o.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=o.TTL;const{"RELOAD-URI":s,"PATHWAY-CLONES":a,"PATHWAY-PRIORITY":l}=o;if(s)try{this.uri=new self.URL(s,r).href}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${s}`)}this.scheduleRefresh(this.uri||n.url),a&&this.clonePathways(a),l&&this.updatePathwayPriority(l)},onError:(t,e,n,r)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${e.url})`),this.stopLoad(),410===t.code)return this.enabled=!1,void this.log(`Steering manifest ${e.url} no longer available`);let i=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,i);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(i=1e3*parseFloat(e))}this.log(`Steering manifest ${e.url} rate limited`)}},onTimeout:(t,e,n)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(i,a,l)}scheduleRefresh(t,e=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((()=>{this.loadSteeringManifest(t)}),e)}}});function yl(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(yl):Object.keys(t).reduce(((e,n)=>(e[n]=yl(t[n]),e)),{}):t}class Cl{static get version(){return"1.4.12"}static isSupported(){return function(){const t=ei();if(!t)return!1;const e=Vo(),n=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!n&&!!r}()}static get Events(){return Pn}static get ErrorTypes(){return Mn}static get ErrorDetails(){return On}static get DefaultConfig(){return Cl.defaultConfig?Cl.defaultConfig:vl}static set DefaultConfig(t){Cl.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new zs,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,function(t,e){if(self.console&&!0===t||"object"==typeof t){!function(t,...e){e.forEach((function(e){Nn[e]=t[e]?t[e].bind(t):function(t){const e=self.console[t];return e?e.bind(self.console,`[${t}] >`):Fn}(e)}))}(t,"debug","log","info","warn","error");try{Nn.log('Debug logs enabled for "Hls instance" in hls.js version 1.4.12')}catch(t){Nn=_n}}else Nn=_n}(t.debug||!1);const e=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const n=yl(t),r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((t=>{const i=`${"level"===t?"playlist":t}LoadPolicy`,o=void 0===e[i],s=[];r.forEach((r=>{const a=`${t}Loading${r}`,l=e[a];if(void 0!==l&&o){s.push(a);const t=n[i].default;switch(e[i]={default:t},r){case"TimeOut":t.maxLoadTimeMs=l,t.maxTimeToFirstByteMs=l;break;case"MaxRetry":t.errorRetry.maxNumRetry=l,t.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":t.errorRetry.retryDelayMs=l,t.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":t.errorRetry.maxRetryDelayMs=l,t.timeoutRetry.maxRetryDelayMs=l}}})),s.length&&Un.warn(`hls.js config: "${s.join('", "')}" setting(s) are deprecated, use "${i}": ${JSON.stringify(e[i])}`)})),In(In({},n),e)}(Cl.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&function(t){const e=t.loader;e!==hl&&e!==Al?(Un.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=hl,t.progressive=!0,t.enableSoftwareAES=!0,Un.log("[config]: Progressive streaming enabled, using FetchLoader"))}(e);const{abrController:n,bufferController:r,capLevelController:i,errorController:o,fpsController:s}=e,a=new o(this),l=this.abrController=new n(this),c=this.bufferController=new r(this),u=this.capLevelController=new i(this),A=new s(this),d=new Li(this),h=new _i(this),f=e.contentSteeringController,p=f?new f(this):null,g=this.levelController=new so(this,p),m=new fo(this),v=new Eo(this.config),y=this.streamController=new Js(this,m,v);u.setStreamController(y),A.setStreamController(y);const C=[d,g,y];p&&C.splice(1,0,p),this.networkControllers=C;const b=[l,c,u,A,h,m];this.audioTrackController=this.createController(e.audioTrackController,C);const E=e.audioStreamController;E&&C.push(new E(this,m,v)),this.subtitleTrackController=this.createController(e.subtitleTrackController,C);const w=e.subtitleStreamController;w&&C.push(new w(this,m,v)),this.createController(e.timelineController,b),v.emeController=this.emeController=this.createController(e.emeController,b),this.cmcdController=this.createController(e.cmcdController,b),this.latencyController=this.createController(Ni,b),this.coreComponents=b,C.push(a);const T=a.onErrorOut;"function"==typeof T&&this.on(Pn.ERROR,T,a)}createController(t,e){if(t){const n=new t(this);return e&&e.push(n),n}return null}on(t,e,n=this){this._emitter.on(t,e,n)}once(t,e,n=this){this._emitter.once(t,e,n)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,n=this,r){this._emitter.off(t,e,n,r)}listeners(t){return this._emitter.listeners(t)}emit(t,e,n){return this._emitter.emit(t,e,n)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){Un.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){Un.log("destroy"),this.trigger(Pn.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((t=>t.destroy())),this.networkControllers.length=0,this.coreComponents.forEach((t=>t.destroy())),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){Un.log("attachMedia"),this._media=t,this.trigger(Pn.MEDIA_ATTACHING,{media:t})}detachMedia(){Un.log("detachMedia"),this.trigger(Pn.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,n=this.url,r=this.url=Ln.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});Un.log(`loadSource:${r}`),e&&n&&(n!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(Pn.MANIFEST_LOADING,{url:t})}startLoad(t=-1){Un.log(`startLoad(${t})`),this.networkControllers.forEach((e=>{e.startLoad(t)}))}stopLoad(){Un.log("stopLoad"),this.networkControllers.forEach((t=>{t.stopLoad()}))}swapAudioCodec(){Un.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Un.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){Un.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){Un.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){Un.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){Un.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){Un.log(`set startLevel:${t}`),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(Un.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Ui.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const n=t.length;for(let r=0;r=e)return r;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:n}=this;let r;if(r=-1===e&&t&&t.length?t.length-1:e,n)for(let e=r;e--;){const r=t[e].attrs["HDCP-LEVEL"];if(r&&r<=n)return e}return r}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Cl.defaultConfig=void 0;var bl,El,wl=function(t,e,n){var r={},i=null,o=null,s=null,a=null,l=!1;try{var c={debug:!1},u=e.getConfig().hlsConfig;if(u)for(var A in u)c[A]=u[A];i=new Cl(c),window.op_hls=i,i.attachMedia(t);var d={name:dt,element:t,mse:i,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:q,buffer:0,dvrWindow:0,framerate:0,currentQuality:-1,qualityLevels:[],currentAudioTrack:-1,audioTracks:[],currentSource:-1,sources:[],adTagUrl:n};r=yn(d,e,(function(t,e){OvenPlayerConsole.log("HLS : onExtendedLoad : ",t,"lastPlayPosition : "+e),r.trigger("hlsPrepared",i),i.loadSource(t.file),i.once(Cl.Events.MANIFEST_LOADED,(function(t,e){for(var n=0;n=0&&r.seek(e)})),i.on(Cl.Events.LEVEL_SWITCHED,(function(t,e){d.currentQuality=e.level,r.trigger(Mt,{isAuto:i.autoLevelEnabled,currentQuality:d.currentQuality,type:"render"})})),i.on(Cl.Events.AUDIO_TRACK_SWITCHED,(function(t,e){d.currentAudioTrack=e.id,r.trigger(Ut,{currentAudioTrack:d.currentAudioTrack})})),i.on(Cl.Events.LEVEL_UPDATED,(function(t,e){e&&e.details&&(d.dvrWindow=e.details.totalduration)})),i.on(Cl.Events.ERROR,(function(e,n){if(n&&n.networkDetails&&202===n.networkDetails.status)return a&&(clearTimeout(a),a=null),r.setState(nt),void(a=setTimeout((function(){i&&(r.stop(),i.stopLoad(),i.loadSource(t.file))}),1e3));if(n.fatal){var o=302;n&&n.networkDetails&&400===n.networkDetails.status?o=306:n&&n.networkDetails&&403===n.networkDetails.status?o=307:n&&n.networkDetails&&406===n.networkDetails.status&&(o=308);var s=Qt.codes[o];s.error=n.details,Jt(s,r)}})),r.on(yt,(function(t){l||t.prevstate!==nt||t.newstate!==q||(a&&(clearTimeout(a),a=null),i&&i.stopLoad())}))})),r.setCurrentQuality=function(t){return i.currentLevel=t,d.currentQuality=t,d.currentQuality},r.isAutoQuality=function(){return i.autoLevelEnabled},r.setAutoQuality=function(t){i.currentLevel=t?-1:i.currentLevel},r.setCurrentAudioTrack=function(t){return i.audioTrack=t,d.currentAudioTrack=t,d.currentAudioTrack},r.getDuration=function(){return t.duration},o=r.super("stop"),r.stop=function(){a&&(clearTimeout(a),a=null),i&&i.stopLoad(),o()},s=r.super("destroy"),r.destroy=function(){a&&(clearTimeout(a),a=null),i&&(i.destroy(),r.trigger("hlsDestroyed")),i=null,OvenPlayerConsole.log("HLS : PROVIDER DESTROYED."),s()},OvenPlayerConsole.log("HLS PROVIDER LOADED.")}catch(t){var h=Qt.codes[106];throw h.error=t,h}return r},Tl=function(t){var e={};Yt(e),OvenPlayerConsole.log("API loaded.");var n=function(t){var e={},n={playlist:[],currentIndex:0},r=Xt();OvenPlayerConsole.log("PlaylistManager loaded.");var i=function(t){if(t&&(t.file||t.host||t.application||t.stream)){var e=Object.assign({},{default:!1},t);e.file=s(""+e.file),e.host&&e.application&&e.stream&&(e.file=e.host+"/"+e.application+"/stream/"+e.stream,delete e.host,delete e.application,delete e.stream);var n=/^[^/]+\/(?:x-)?([^/]+)$/;if(n.test(e.type)&&(e.mimeType=e.type,e.type=e.type.replace(n,"$1")),Ht(e.file)?e.type="rtmp":Kt(e.file)?e.type="webrtc":Vt(e.file,e.type)?e.type="hls":zt(e.file,e.type)?e.type="dash":e.type||(e.type=a(e.file)),e.lowLatency&&(e.lowLatency=e.lowLatency),e.type){switch(e.type){case"m3u8":case"vnd.apple.mpegurl":e.type="hls";break;case"m4a":e.type="aac";break;case"smil":e.type="rtmp"}return Object.keys(e).forEach((function(t){""===e[t]&&delete e[t]})),e}}};return e.initPlaylist=function(t,e){OvenPlayerConsole.log("PlaylistManager setPlaylist() ",t);var s=(o().isArray(t)?t:[t]).map((function(t){o().isArray(t.tracks)||delete t.tracks;var n=Object.assign({},{sources:[],tracks:[],title:""},t);n.sources!==Object(n.sources)||o().isArray(n.sources)||(n.sources=[i(n.sources)]),o().isArray(n.sources)&&0!==n.sources.length||(n.sources=[i(n)]),o().isArray(n.sources)&&0!==n.sources.length||(t.levels?n.sources=t.levels:n.sources=[i(t)]);for(var s=0;s0}))||[];return n.playlist=s,s},e.getPlaylist=function(){return OvenPlayerConsole.log("PlaylistManager getPlaylist() ",n.playlist),n.playlist},e.getCurrentPlayList=function(){return n.playlist[n.currentIndex]?n.playlist[n.currentIndex]:[]},e.getCurrentPlaylistIndex=function(){return n.currentIndex},e.setCurrentPlaylist=function(e){return n.playlist[e]&&(n.currentIndex=e,t.trigger(pt,n.currentIndex)),n.currentIndex},e.getCurrentSources=function(){return n.playlist[n.currentIndex]?(OvenPlayerConsole.log("PlaylistManager getCurrentSources() ",n.playlist[n.currentIndex].sources),n.playlist[n.currentIndex].sources):null},e.getCurrentAdTag=function(){if(n.playlist[n.currentIndex])return n.playlist[n.currentIndex].adTagUrl||""},e}(e),i=function(){var t=Xt(),e={},n={};OvenPlayerConsole.log("ProviderController loaded.");var r=function(t,n){e[t]||(OvenPlayerConsole.log("ProviderController _registerProvider() ",t),e[t]=n)},i={html5:function(){var t=Cn;return r(ct,t),{name:ct,provider:t}},webrtc:function(){var t=En;return r(ut,t),{name:ut,provider:t}},dash:function(){var t=Tn;return r(At,t),{name:At,provider:t}},hls:function(){var t=wl;return r(dt,t),{name:dt,provider:t}}};return n.loadProviders=function(e){var n=t.findProviderNamesByPlaylist(e);return OvenPlayerConsole.log("ProviderController loadProviders() ",n),n?Promise.all(n.filter((function(t){return!!i[t]})).map((function(t){return i[t]()}))):Promise.reject(Qt.codes[101])},n.findByName=function(t){return OvenPlayerConsole.log("ProviderController findByName() ",t),e[t]},n.getProviderBySource=function(e){var r=t.findProviderNameBySource(e);return OvenPlayerConsole.log("ProviderController getProviderBySource() ",r),n.findByName(r)},n.isSameProvider=function(e,n){return OvenPlayerConsole.log("ProviderController isSameProvider() ",t.findProviderNameBySource(e),t.findProviderNameBySource(n)),t.findProviderNameBySource(e)===t.findProviderNameBySource(n)},n}(),l=W(),c=function(t,e){var n={},r=jt(t),i="";return OvenPlayerConsole.log("MediaManager loaded. browser : ",e),n.createMedia=function(t,e){return n.empty(),o=e.isLoop(),s=e.isAutoStart(),(i=document.createElement("video")).setAttribute("preload","auto"),i.setAttribute("disableremoteplayback",""),i.setAttribute("webkit-playsinline","true"),i.setAttribute("playsinline","true"),o&&i.setAttribute("loop",""),s&&i.setAttribute("autoplay",""),r.append(i),i;var o,s},n.createAdContainer=function(){var t=document.createElement("div");return t.setAttribute("class","op-ads"),r.append(t),t},n.empty=function(){OvenPlayerConsole.log("MediaManager removeElement()"),r.removeChild(i),i=null},n.destroy=function(){r.removeChild(),r=null,i.src=null,i.srcObject=null,i=null},n}(t,l),u="",A="",d="",h=function(t){OvenPlayerConsole.log("runNextPlaylist");var r=t,i=!!n.getPlaylist()[r];A.setSourceIndex(0),A.setVolume(u.getVolume()),i?(n.setCurrentPlaylist(r),f()):e.trigger(gt,null)},f=function(t){return i.loadProviders(n.getCurrentPlayList()).then((function(t){if(t.length<1)throw Qt.codes[101];u&&(u.destroy(),u=null),d&&(d.destroy(),d=null),d=function(t,e){var n={},r=[],i=-1,s=X(),a=!0;OvenPlayerConsole.log("Caption Manager >> ",e);var l=function(t,e){return t.data=e||[],t.name=t.label||t.name||t.language,t.id=function(t,e){var n,i=t.kind||"cc";return n=t.default||t.defaulttrack?"default":t.id||i+e,a&&(c(r.length||0),a=!1),n}(t,r.length),r.push(t),t.id},c=function(e){i=e,t.trigger(Ft,i)};if(t.getConfig().playlist&&t.getConfig().playlist.length>0){var u=t.getConfig().playlist[e];if(u&&u.tracks&&u.tracks.length>0)for(var A=function(e){var n=u.tracks[e];Wt(n.kind)&&!o().findWhere(n,{file:n.file})&&s.load(n,n.lang,(function(t){t&&t.length>0&&l(n,t)}),(function(e){var n=Qt.codes[305];n.error=e,t.trigger(vt,n)}))},d=0;d-1&&r[i]){var s=o().filter(r[i].data,(function(t){return n>=t.startTime&&(!t.endTime||n)<=t.endTime}));s&&s.length>0&&t.trigger(Ot,s[0])}})),n.flushCaptionList=function(t){r=[],c(t)},n.getCaptionList=function(){return r||[]},n.getCurrentCaption=function(){return i},n.setCurrentCaption=function(t){if(!(t>-2&&t0&&l(e,t)}),(function(e){var n=errors[305];n.error=e,t.trigger(vt,n)}))},n.removeCaption=function(t){return t>-1&&t=.25&&t<=4})).map((function(t){return Math.round(4*t)/4}))).indexOf(1)<0&&s.push(1),s.sort(),e.playbackRates=s,e.rtmpBufferTime=e.rtmpBufferTime>10?10:e.rtmpBufferTime,e.rtmpBufferTimeMax=e.rtmpBufferTimeMax>50?50:e.rtmpBufferTimeMax,e.playbackRates.indexOf(e.playbackRate)<0&&(e.playbackRate=1);var a=e.playlist;if(a)o().isArray(a.playlist)&&(e.feedData=a,e.playlist=a.playlist);else{var l=o().pick(e,["title","description","type","image","file","sources","tracks","host","application","stream","adTagUrl"]);e.playlist=[l]}return delete e.duration,e}(t);return{getConfig:function(){return n},getAdClient:function(){return n.adClient},setConfig:function(t,e){n[t]=e},getContainer:function(){return n.mediaContainer},getPlaybackRate:function(){return n.playbackRate},setPlaybackRate:function(t){return n.playbackRate=t,t},getQualityLabel:function(){return n.qualityLabel},setQualityLabel:function(t){n.qualityLabel=t},isCurrentProtocolOnly:function(){return n.currentProtocolOnly},getSourceIndex:function(){return n.sourceIndex},setSourceIndex:function(t){n.sourceIndex=t},setTimecodeMode:function(t){n.timecode!==t&&(n.timecode=t,e.trigger(_t,t))},isTimecodeMode:function(){return n.timecode},getRtmpBufferTime:function(){return n.rtmpBufferTime},getRtmpBufferTimeMax:function(){return n.rtmpBufferTimeMax},setMute:function(t){n.mute=t},isMute:function(){return n.mute},getVolume:function(){return n.volume},setVolume:function(t){n.volume=t},isLoop:function(){return n.loop},isAutoStart:function(){return n.autoStart},isControls:function(){return n.controls},getPlaybackRates:function(){return n.playbackRates},getBrowser:function(){return n.browser},getSystemText:function(){return n.systemText},getLanguage:function(){return n.lang},getPlaylist:function(){return n.playlist},setPlaylist:function(t){return o().isArray(t)?n.playlist=t:n.playlist=[t],n.playlist}}}(r,e),OvenPlayerConsole.log("API : init()"),OvenPlayerConsole.log("API : init() config : ",A),Qt.codes=A.getSystemText().api.error,n.initPlaylist(A.getPlaylist(),A),OvenPlayerConsole.log("API : init() sources : ",n.getCurrentSources()),f(),setTimeout((function(){e.trigger(ht)}))},e.getProviderName=function(){return u?u.getName():null},e.getProvider=function(){return u},e.getMseInstance=function(){return u?u.getMse():null},e.getConfig=function(){return OvenPlayerConsole.log("API : getConfig()",A.getConfig()),A.getConfig()},e.getBrowser=function(){return A.getBrowser()},e.setTimecodeMode=function(t){OvenPlayerConsole.log("API : setTimecodeMode()",t),A.setTimecodeMode(t)},e.isTimecodeMode=function(){return OvenPlayerConsole.log("API : isTimecodeMode()"),A.isTimecodeMode()},e.getFramerate=function(){if(OvenPlayerConsole.log("API : getFramerate()"),u)return u.getFramerate()},e.seekFrame=function(t){return u?(OvenPlayerConsole.log("API : seekFrame()",t),u.seekFrame(t)):null},e.getDuration=function(){return u?(OvenPlayerConsole.log("API : getDuration()",u.getDuration()),u.getDuration()):null},e.getDvrWindow=function(){return u?(OvenPlayerConsole.log("API : getDvrWindow()",u.getDvrWindow()),u.getDvrWindow()):null},e.getPosition=function(){return u?(OvenPlayerConsole.log("API : getPosition()",u.getPosition()),u.getPosition()):null},e.getVolume=function(){return u?(OvenPlayerConsole.log("API : getVolume()",u.getVolume()),u.getVolume()):null},e.setVolume=function(t){if(!u)return null;OvenPlayerConsole.log("API : setVolume() "+t),u.setVolume(t)},e.setMute=function(t){return u?(OvenPlayerConsole.log("API : setMute() "+t),u.setMute(t)):null},e.getMute=function(){return u?(OvenPlayerConsole.log("API : getMute() "+u.getMute()),u.getMute()):null},e.load=function(t){return OvenPlayerConsole.log("API : load() ",t),t&&(A.setSourceIndex(0),u&&u.getQualityLevels().length>0&&u.setCurrentQuality(0),"sources"in t?A.setPlaylist(t):A.setPlaylist({sources:t}),n.initPlaylist(A.getPlaylist(),A)),f()},e.play=function(){if(!u)return null;OvenPlayerConsole.log("API : play() "),u.metaLoaded()||A.isAutoStart()?u.play():e.once(Bt,(function(){u.play()}))},e.pause=function(){if(!u)return null;OvenPlayerConsole.log("API : pause() "),u.pause()},e.seek=function(t){if(!u)return null;OvenPlayerConsole.log("API : seek() "+t),u.seek(t)},e.setPlaybackRate=function(t){return u?(OvenPlayerConsole.log("API : setPlaybackRate() ",t),u.setPlaybackRate(A.setPlaybackRate(t))):null},e.getPlaybackRate=function(){return u?(OvenPlayerConsole.log("API : getPlaybackRate() ",u.getPlaybackRate()),u.getPlaybackRate()):null},e.getPlaylist=function(){return OvenPlayerConsole.log("API : getPlaylist() ",n.getPlaylist()),n.getPlaylist()},e.getCurrentPlaylist=function(){return OvenPlayerConsole.log("API : getCurrentPlaylist() ",n.getCurrentPlaylistIndex()),n.getCurrentPlaylistIndex()},e.setCurrentPlaylist=function(t){OvenPlayerConsole.log("API : setCurrentPlaylist() ",t),h(t)},e.getSources=function(){return u?(OvenPlayerConsole.log("API : getSources() ",u.getSources()),u.getSources()):null},e.getCurrentSource=function(){return u?(OvenPlayerConsole.log("API : getCurrentSource() ",u.getCurrentSource()),u.getCurrentSource()):null},e.setCurrentSource=function(t){if(!u)return null;OvenPlayerConsole.log("API : setCurrentSource() ",t);var n=u.getPosition();return A.setSourceIndex(t),f(n).then((function(){e.trigger(Pt,{currentSource:t})})),t},e.getQualityLevels=function(){return u?(OvenPlayerConsole.log("API : getQualityLevels() ",u.getQualityLevels()),u.getQualityLevels()):null},e.getCurrentQuality=function(){return u?(OvenPlayerConsole.log("API : getCurrentQuality() ",u.getCurrentQuality()),u.getCurrentQuality()):null},e.setCurrentQuality=function(t){return u?(OvenPlayerConsole.log("API : setCurrentQuality() ",t),u.setCurrentQuality(t)):null},e.getAudioTracks=function(){return u?(OvenPlayerConsole.log("API : getAudioTracks() ",u.getAudioTracks()),u.getAudioTracks()):null},e.getCurrentAudioTrack=function(){return u?(OvenPlayerConsole.log("API : getCurrentAudioTrack() ",u.getCurrentAudioTrack()),u.getCurrentAudioTrack()):null},e.setCurrentAudioTrack=function(t){return u?(OvenPlayerConsole.log("API : setCurrentAudioTrack() ",t),u.setCurrentAudioTrack(t)):null},e.isAutoQuality=function(){return u?(OvenPlayerConsole.log("API : isAutoQuality()"),u.isAutoQuality()):null},e.setAutoQuality=function(t){return u?(OvenPlayerConsole.log("API : setAutoQuality() ",t),u.setAutoQuality(t)):null},e.getCaptionList=function(){return d?(OvenPlayerConsole.log("API : getCaptionList() ",d.getCaptionList()),d.getCaptionList()):null},e.getCurrentCaption=function(){return d?(OvenPlayerConsole.log("API : getCurrentCaption() ",d.getCurrentCaption()),d.getCurrentCaption()):null},e.setCurrentCaption=function(t){if(!d)return null;OvenPlayerConsole.log("API : setCurrentCaption() ",t),d.setCurrentCaption(t)},e.addCaption=function(t){return d?(OvenPlayerConsole.log("API : addCaption() "),d.addCaption(t)):null},e.removeCaption=function(t){return d?(OvenPlayerConsole.log("API : removeCaption() ",t),d.removeCaption(t)):null},e.getBuffer=function(){if(!u)return null;OvenPlayerConsole.log("API : getBuffer() ",u.getBuffer()),u.getBuffer()},e.getState=function(){return u?(OvenPlayerConsole.log("API : getState() ",u.getState()),u.getState()):null},e.stop=function(){if(!u)return null;OvenPlayerConsole.log("API : stop() "),u.stop()},e.remove=function(){OvenPlayerConsole.log("API : remove() "),d&&(d.destroy(),d=null),u&&(u.destroy(),u=null),c&&(c.destroy(),c=null),e.trigger(ft),e.off(),i=null,n=null,A=null,OvenPlayerConsole.log("API : remove() - currentProvider, providerController, playlistManager, playerConfig, api event destroed. "),Sl.removePlayer(e)},e.getMediaElement=function(){return u.getMediaElement()},e.getVersion=function(){return r},e},Sl=(El=(bl={}).playerList=[],bl.create=function(t,e){window.OvenPlayerConsole&&0!==Object.keys(window.OvenPlayerConsole).length||(window.OvenPlayerConsole={},OvenPlayerConsole.log=function(){});var n=$t(t),r=Tl(n);return r.init(e),El.push(r),r},bl.getPlayerList=function(){return El},bl.getPlayerByContainerId=function(t){for(var e=0;e
'+(e.isRoot?"":'<')+''+e.title+'
';return o().forEach(e.body,(function(t){n+=Ll(t,e.useCheck)})),n+="
"},Ll=function(t,e){return'
'+(e?'':"")+''+t.title+""+(t.hasNext?'>'+t.description+"":"")+"
"},xl=function(t,e){return'
')+'
').concat(t.image?""):''," ").concat(t.duration?''.concat(l(t.duration),""):"","
")+'
'.concat(t.title,"
")+"
"},Il={TextViewTemplate:function(t){return'
'+"

".concat(t,"

")+'
'},ViewTemplate:function(t,e){return'
")+'
'},HelpersTemplate:function(t,e){return'
'},BigButtonTemplate:function(t,e){return'
'+"".concat(e===tt?'':"")+"".concat(e===Z?'':"")+"".concat(e===q?'':"")+"".concat(e===J?'':"")+"
"},ThumbnailTemplate:function(t,e){return'
'+"".concat(e.title?'
'.concat(e.title,"
"):"")+"
"},WaterMarkTemplate:function(t,e){return'
'+"".concat(e.waterMark.image?''):"")+"".concat(e.waterMark.text?''.concat(e.waterMark.text,""):"")+"
"},MessageBoxTemplate:function(t,e){return'
')+'
'+'
'.concat(e.message)+"".concat(e.description?'
'.concat(e.description,"
"):"")+"
"+"".concat(e.iconClass?'
'):"")+"
"},SpinnerTemplate:function(t){return'
'},ContextPanelTemplate:function(t){return'
'+''.concat(t.context," ").concat(r,"")+"
"},CaptionViewerTemplate:function(t){return'
      
'},ControlsTemplate:function(t,e){return'
'+'
'.concat(e?'':"","
")+'
'},VolumeButtonTemplate:function(t){return'
'},ProgressBarTemplate:function(t){return'
00:00
'},PlayButtonTemplate:function(t){return'
'},SettingButtonTemplate:function(t){return''},FrameButtonsTemplate:function(t){return'
'},TimeDisplayTemplate:function(t,e){return'
'+(e.duration===1/0?''+("webrtc"===e.type?e.isP2P?''.concat(t.controls.low_latency_p2p,""):''.concat(t.controls.low_latency_live,""):''.concat(t.controls.live,""))+"":'00:00 / 00:00')+"
"},FullScreenButtonTemplate:function(t){return''},PanelsTemplate:kl,SpeedPanelTemplate:kl,SourcePanelTemplate:kl,QualityPanelTemplate:kl,AudioTrackPanelTemplate:kl,CaptionPanelTemplate:kl,TimeDisplayPanelTemplate:kl,PlaylistPanelTemplate:function(t,e){return'
'+'
'.concat(t.playlist,'
')+'
'}},Rl=function(t,e,n,r,i,s,a,l){var c,u=o().isElement(t)?jt(t):t,A={},d=null,h={};h.data=r;var f=function(t){var e=document.createElement("div");return e.innerHTML=t,c=jt(e.firstChild),e.firstChild};return n&&n.systemText&&(d=n.systemText.ui),l?u.replace(f(Il[e+"Template"](d,r))):u.append(f(Il[e+"Template"](d,r))),s&&s(c,h),Object.keys(i).forEach((function(t){var e=t.split(" "),n=e[0].replace(/ /gi,""),r=e[1].replace(/ /gi,""),o="";if(o="document"===r||"window"===r||"body"===r?jt(r):c.find(r)||(c.hasClass(r.replace(".",""))?c:null),!(n&&r&&o))return!1;var s=Object.keys(A).length++,a=function(e){return i[t](e,c,h)};A[s]={name:n,target:r,callback:a};var l=null;n.indexOf("touch")>-1&&(l={passive:!0});var u=o.get().length;if(u>1)for(var d=o.get(),f=0;f1)for(var i=n.get(),o=0;o-1?i=!1:(i=!0,t.find(".op-caption-text").text(""))}),r),e.on(Ot,(function(e){if(!i&&e&&e.text){var n=e.endTime-e.startTime;o&&clearTimeout(o),t.find(".op-caption-text").html(e.text),n&&(o=setTimeout((function(){t.find(".op-caption-text").text("")}),1e3*n))}}),r)}),(function(n){t.find(".op-caption-text").text(""),e.off(Ft,null,n),e.off(Ot,null,n)}))}(t,e),e.on(ht,(function(){u&&m(),A&&(r&&r.destroy(),r=function(t,e,n){var r=null,i=null;return Rl(t,"WaterMark",e.getConfig(),n,{},(function(t,n){r=t.find(".op-watermark"),i=t.find(".op-watermark-text");var s=e.getConfig().waterMark,a=s.position||"top-right",l=s.y||"5%",c=s.x||"2.8125%";r.css(a.split("-")[0],l),r.css(a.split("-")[1],c);var u=s.width||"auto",A=s.height||"auto";r.css("width",u),r.css("height",A);var d=s.opacity||.7;r.css("opacity",d),s.text&&s.font&&o().each(s.font,(function(t,e){i.css(e,t)}))}),(function(){}))}(t,e,e.getConfig())),i||(g(Z),i=!0)}),h),e.on(St,(function(n){n.message&&(s&&s.destroy(),a&&a.destroy(),c=Dl(t,e,n.message,null,n.timer,n.iconClass,n.onClickCallback,!1),e.once(Dt,(function(t){!t.mute&&c&&c.destroy()}),h))}),h),e.on(yt,(function(t){t&&t.newstate&&(t.newstate===q&&a&&a.destroy(),t.newstate===tt||t.newstate===ot?(d=!1,a&&a.destroy(),s&&s.destroy(),n&&n.destroy(),f||l.show(!1)):t.newstate===J?(l.show(!1),g(t.newstate)):t.newstate===rt||t.newstate===nt||"adLoading"===t.newstate?(d=!1,a&&a.destroy(),s&&s.destroy(),l.show(!0)):f||l.show(!1))}),h),e.on(Pt,(function(){u&&m()})),e.on(Mt,(function(t){if(t.currentQuality<0)return!1;t.isAuto?(f=!1,l.show(!1)):"request"===t.type?(p=t.currentQuality,f=!0,l.show(!0)):"render"===t.type&&p===t.currentQuality&&(f=!1,l.show(!1))}),h),e.on(vt,(function(n){if(510===n.code&&(d=!0),101===n.code&&0===e.getPlaylist().length&&(d=!0),!d){var r="",i="";s&&s.destroy(),n&&n.code&&n.code>=100&&n.code<1e3?(r=n.message,100===n.code&&(i=n.error.toString())):r="Can not play due to unknown reasons.",OvenPlayerConsole.log("error occured : ",n),function(n,r,i,o,l,c){s&&s.destroy(),a&&a.destroy(),a=Dl(t,e,n,r,null,"op-warning",null,!0)}(r,i)}}),h),e.on(mt,(function(t){var n="Because the network connection is unstable, the following media source will be played.";e.getCurrentSource()+1===e.getQualityLevels().length&&(n="Network connection is unstable. Check the network connection."),OvenPlayerConsole.log(n)}),h),e.on(gt,(function(){u&&m()}),h)}),(function(t){e.off(ht,null,t),e.off(yt,null,t),e.off(St,null,t),e.off(vt,null,t),e.off(mt,null,t),e.off(gt,null,t),e.off(pt,null,t)}))},Pl=[],Ml=function(){var t={},e=function(){for(var t=0;t1,!0===e.getConfig().hidePlaylistIcon&&(u=!1);var v={"mouseleave .op-controls":function(t,e,n){t.preventDefault(),r.setMouseDown(!1),e.find(".op-volume-slider-container").removeClass("active")},"click .op-playlist-button":function(t,n,r){t.preventDefault(),function(t,e){var n=jt(e.getContainerElement()),r="",i=e.getPlaylist(),o=i.length,s=6,a=0,l=[];function c(t){var n,a,c=Math.ceil(o/s),u=e.getCurrentPlaylist();l=i.slice(t*s,t*s+s),r.find(".op-playlist-body-row").removeChild(),r.find(".op-arrow-left").removeClass("disable"),r.find(".op-arrow-right").removeClass("disable");for(var A=0;A576?s=6:n.width()<=576&&(s=1);var A={"click .btn-close":function(t,e,n){t.preventDefault(),n.destroy()},"click .op-arrow-left":function(t,e,n){t.preventDefault(),jt(t.target).hasClass("disable")||c(--a)},"click .op-arrow-right":function(t,e,n){t.preventDefault(),jt(t.target).hasClass("disable")||c(++a)}};Rl(t,"PlaylistPanel",e.getConfig(),i,A,(function(t,n){r=t,c(a=u()),e.on(wt,(function(t){"xsmall"===t&&6===s?(s=1,c(a=u())):"small"!==t&&"medium"!==t&&"large"!==t||1!==s||(s=6,c(a=u()))}),n),e.on(pt,(function(t){c(a=u())}),n),t.get().addEventListener("click",(function(t){for(var n=t.target;n;){if(jt(n).hasClass("op-playlist-card"))return void e.setCurrentPlaylist(parseInt(jt(n).attr("data-index")));n=n.parentElement}}),!0)}),(function(t){e.off(wt,null,t),e.off(pt,null,t)}))}(n,e)}};return Rl(t,"Controls",e.getConfig(),u,v,(function(t,u){function h(n,r){s&&s.destroy(),s=function(t,e,n,r){var i=jt(e.getContainerElement());e.getConfig().disableSeekUI&&t.addClass("op-progressbar-container-disabled");var o=0,s=!1,a=Ml(),c="",u=0,A="",d="",h="",f="",p="",g="",m=0,v="",y="",C=e.getBrowser().mobile,b=e.getMediaElement(),E=!1,w=!1;function T(t){var e=A.width(),n=e*t;h.css("width",n+"px"),f.css("left",n+"px");var r=(e-m)*t;p.css("left",r+"px"),o=n}function S(t){var e=A.width()*t;f.css("width",(0===t?t:e-o)+"px")}function k(t){var e=A.width(),n=A.offset().left,r=t.pageX;t.touches&&(r=t.pageX||t.touches[0].clientX);var i=(r-n)/e;return i<0?0:i>1?1:i}function L(){return b.seekable.end(b.seekable.length-1)-b.seekable.start(0)}function x(t,n){if(a.size()>0||-1===t)return v.hide(),void y.hide();if(v.show(),y.show(),E&&!w){var r=e.getDvrWindow()*(1-t);e.isTimecodeMode()?v.text("- "+l(r)):v.text("- "+Math.round(r*e.getFramerate()))}else if(E&&w){var i=L()*(1-t);e.isTimecodeMode()?v.text("- "+l(i)):v.text("- "+Math.round(i*e.getFramerate()))}else{var o=e.getDuration()*t;e.isTimecodeMode()?v.text(l(o)):v.text(Math.round(o*e.getFramerate()))}var s=v.width(),u=A.width(),d=u*t,h=n.pageX-A.offset().left;n.touches&&(h=(n.pageX||n.touches[0].clientX)-A.offset().left);var f=function(t){return h0&&(n+=o),e.seek(n)}r&&r.type===dt&&r.duration===1/0&&(E=!0,e.getProviderName()===ct&&(w=!0));var R={"touchstart .op-progressbar":function(t){if(n)return!1;s=!0;var e=k(t);if(-1===e)return!1;T(e),S(0),I(e)},"touchmove .op-progressbar":function(t){if(s){var e=k(t);if(-1===e)return!1;T(e),S(0),I(e),x(e,t)}},"touchend .op-progressbar":function(t){s&&(s=!1),i.removeClass("op-progressbar-hover"),v.hide(),y.hide()},"mouseenter .op-progressbar":function(t,e,r){t.preventDefault(),C||(n||v.show(),i.addClass("op-progressbar-hover"))},"mouseleave .op-progressbar":function(t,e,n){t.preventDefault(),s=!1,i.removeClass("op-progressbar-hover"),v.hide(),y.hide(),S(0)},"mousedown .op-progressbar":function(t,e,r){if(t.preventDefault(),n||C)return!1;s=!0;var i=k(t);if(-1===i)return!1;T(i),S(0),I(i)},"mousemove .op-progressbar":function(t,e,r){if(t.preventDefault(),!s&&!n&&!C){var i=k(t);S(i),x(i,t)}if(s&&!C){var o=k(t);if(-1===o)return!1;T(o),S(0),I(o),x(o,t)}},"mouseup .op-progressbar":function(t,e,n){t.preventDefault(),s&&!C&&(s=!1,i.removeClass("op-progressbar-hover"))}};return e.getConfig().disableSeekUI&&(R={}),Rl(t,"ProgressBar",e.getConfig(),null,R,(function(t,r){A=t,d=t.find(".op-load-progress"),h=t.find(".op-play-progress"),f=t.find(".op-hover-progress"),p=t.find(".op-progressbar-knob-container"),g=t.find(".op-progressbar-knob"),m=g.width(),v=t.find(".op-progressbar-time"),y=t.find(".op-progressbar-preview"),n?e.on(Lt,(function(t){t&&t.duration&&t.position&&(T(t.position/t.duration),t.duration)}),r):(e.on(It,(function(t){if(t&&t.duration&&t.position){u=t.duration;var n=t.position/t.duration;if(E&&!w&&(n=(e.getDvrWindow()-(t.duration-t.position))/e.getDvrWindow()),E&&w){var r=L();u=r,n=(r-(r-Math.min(r,t.position)))/r}T(n)}}),r),e.on(xt,(function(t){var e,n;t&&t.bufferPercent&&(e=t.bufferPercent/100,n=A.width()*e,d.css("width",n+"px"))}),r))}),(function(t){n?e.off(Lt,null,t):(e.off(It,null,t),e.off(xt,null,t))}))}(t.find(".op-progressbar-container"),e,n,r)}function v(){o&&o.destroy(),o=function(t,e){var n=Ml(),r={"click .op-setting-button":function(t,r,i){t.preventDefault();var o=r.closest(".op-controls-container");if(n.size()>0)n.clear();else{var s=function(t){var e={id:"panel-"+(new Date).getTime(),title:"Settings",body:[],isRoot:!0,panelType:""},n=t.getConfig();n&&n.systemText&&(Object.keys(_l).forEach((function(t){_l[t]=n.systemText.ui.setting[t]})),e.title=n.systemText.ui.setting.title);var r=t.getSources(),i=r&&r.length>0?r[t.getCurrentSource()]:null,o=t.getQualityLevels(),s=o&&o.length>0?o[t.getCurrentQuality()]:null,a=t.getAudioTracks(),l=a&&a.length>0?a[t.getCurrentAudioTrack()]:null,c=t.getCaptionList(),u=t.getCurrentCaption(),A=t.getFramerate();if(i){var d={title:_l.speed,value:t.getPlaybackRate()+_l.speedUnit,description:t.getPlaybackRate()+_l.speedUnit,panelType:"speed",hasNext:!0};e.body.push(d)}if(r&&r.length>1){var h={title:_l.source,value:i?i.label:"Default",description:i?i.label:"Default",panelType:"source",hasNext:!0};e.body.push(h)}if(o&&o.length>0){var f={title:_l.quality,value:s?s.label:"Default",description:s?s.label:"Default",panelType:"quality",hasNext:!0};e.body.push(f)}if(a&&a.length>0){var p={title:_l.audioTrack,value:l?l.label:"Default",description:l?l.label:"Default",panelType:"audioTrack",hasNext:!0};e.body.push(p)}if(c&&c.length>0){var g={title:_l.caption,value:c[u]?c[u].label:"OFF",description:c[u]?c[u].label:"OFF",panelType:"caption",hasNext:!0};e.body.push(g)}if(A>0){var m={title:_l.display,value:t.isTimecodeMode()?"Play time":"Framecode",description:t.isTimecodeMode()?"Play time":"Framecode",panelType:"display",hasNext:!0};e.body.push(m)}return e}(e);n.add(Fl(o,e,s))}}};return Rl(t,"SettingButton",e.getConfig(),null,r,(function(t,e){}),(function(t){}))}(t.find(".setting-holder"),e)}function y(){c||(c=function(t,e){var n=jt(e.getContainerElement()),r="",i="",o=!1,s=(e.getConfig(),e.getBrowser()),a="iOS"===s.os,l=(s.os,""),c=!1,u={onfullscreenchange:"fullscreenchange",onmozfullscreenchange:"mozfullscreenchange",onwebkitfullscreenchange:"webkitfullscreenchange",MSFullscreenChange:"MSFullscreenChange"};function A(){var t=!1,e=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;return e&&n.get()===e&&(t=!0),t}function d(){OvenPlayerConsole.log("FULLSCREEN STATE : ",A()),A()?(n.addClass("op-fullscreen"),o=!0,r.hide(),i.show()):(n.removeClass("op-fullscreen"),o=!1,r.show(),i.hide())}function h(){OvenPlayerConsole.log("afterFullScreenChangedCallback () "),d(),e.trigger(Tt,o)}function f(){o?(n.removeClass("op-fullscreen"),o=!1,r.show(),i.hide()):(n.addClass("op-fullscreen"),o=!0,r.hide(),i.show()),e.trigger(Tt,o)}function p(){var t;!o||a&&!A()?function(){var t,r="",i=n.get(),s=n.find("video")?n.find("video").get():i,l=null;if(a){if(s.length>1)for(var u=0;u1)for(var i=0;i9e15&&(n.duration=1/0);var r=e.getSources()[e.getCurrentSource()].sectionStart,i=e.getSources()[e.getCurrentSource()].sectionEnd;i&&(n.duration=i),r&&(n.duration=n.duration-r),function(n){a&&a.destroy(),a=function(t,e,n){var r="",i="",o="",s=e.getMediaElement(),a=!1,c=!1;function u(t){return l(t)}var A={"click .op-live-text":function(t,n,r){t.preventDefault(),e.seek(Number.MAX_SAFE_INTEGER);var i=e.getConfig();if(i.hlsConfig){var o=i.hlsConfig;"number"==typeof o.liveSyncDuration&&(e.getMseInstance().config.liveSyncDuration=o.liveSyncDuration),"number"==typeof o.liveMaxLatencyDuration&&(e.getMseInstance().config.liveMaxLatencyDuration=o.liveMaxLatencyDuration),"number"==typeof o.maxLiveSyncPlaybackRate&&(e.getMseInstance().config.maxLiveSyncPlaybackRate=o.maxLiveSyncPlaybackRate)}}};return Rl(t,"TimeDisplay",e.getConfig(),n,A,(function(t,l){var A=e.isTimecodeMode();r=t.find(".op-time-current"),i=t.find(".op-time-duration"),o=t.find(".op-live-badge"),t.find(".op-live-text"),n&&n.type===dt&&n.duration===1/0&&(a=!0,e.getProviderName()===ct&&(c=!0)),n.duration!==1/0?(A?i.text(u(n.duration)):i.text(Math.round(n.duration*e.getFramerate())+" ("+e.getFramerate()+"fps)"),e.on(_t,(function(t){(A=t)?i.text(u(n.duration)):i.text(Math.round(n.duration*e.getFramerate())+" ("+e.getFramerate()+"fps)")}),l),e.on(It,(function(t){A?r.text(u(t.position)):r.text(Math.round(t.position*e.getFramerate()))}),l)):a&&!c?e.on(It,(function(t){t.duration-t.position>3?o.addClass("op-live-badge-delayed"):o.removeClass("op-live-badge-delayed")}),l):a&&c&&e.on(It,(function(t){s.seekable.end(s.seekable.length-1)-s.seekable.start(0)-t.position>3?o.addClass("op-live-badge-delayed"):o.removeClass("op-live-badge-delayed")}),l)}),(function(t){e.off(_t,null,t),e.off(It,null,t)}))}(t.find(".op-left-controls"),e,n)}(n),y(),e.getFramerate&&e.getFramerate(),n.duration===1/0?(OvenPlayerConsole.log("[[[[LIVE MODE]]]]"),n.type===dt?h(!1,n):s&&s.destroy()):h(!1),A=!0}function b(){a&&a.destroy(),s&&s.destroy(),v(),y(),g.removeClass("linear-ad")}i=function(t,e){var n="",r="",i="",o="",s="",a="",l="",c={"click .op-play-button":function(t,n,r){t.preventDefault();var i=e.getState(),o=e.getPlaylist(),s=e.getCurrentPlaylist();i===q?e.play():i===tt||i===ot?e.pause():i===nt||i===rt?e.stop():i===Z||i===st?e.play():i===et?e.setCurrentSource(e.getCurrentSource()):i===J&&o.length===s+1&&(e.seek(0),e.play())},"click .op-seek-button-back":function(t,n,r){var i=e.getConfig().seekControlInterval;i||(i=10);var o=e.getPosition()-i;o<0&&(o=0),e.seek(o)},"click .op-seek-button-forward":function(t,n,r){var i=e.getConfig().seekControlInterval;i||(i=10);var o=e.getPosition()+i;o>e.getDuration()&&(o=e.getDuration()),e.seek(o)}};return Rl(t,"PlayButton",e.getConfig(),null,c,(function(t,c){n=t.find(".op-play-button .op-play"),r=t.find(".op-play-button .op-pause"),i=t.find(".op-play-button .op-replay"),o=t.find(".op-seek-button-back"),s=t.find(".op-seek-button-forward"),a=t.find(".op-seek-back-text"),l=t.find(".op-seek-forward-text"),e.on(yt,(function(t){var e;t&&t.newstate&&(e=t.newstate,n.hide(),r.hide(),i.hide(),e===tt||e===ot||e===nt||e===rt?r.show():e===Z||e===st?n.show():e===J?i.show():n.show())}),c),e.getConfig().showSeekControl||(o.hide(),s.hide());var u=e.getConfig().seekControlInterval;u?(a.text(u),l.text(u)):(a.text(10),l.text(10))}),(function(t){e.off(yt,null,t)}))}(t.find(".op-left-controls"),e),r=function(t,e){var n="",r="",i="",o="",s="",a="",l="",c=!1,u=0,A="iOS"===e.getBrowser().os||"Android"===e.getBrowser().os;function d(t){e.getMute()&&(t=0),function(t){s.hide(),a.hide(),l.hide(),t>=70?s.show():t<70&&t>0?a.show():0==t?l.show():s.show()}(t);var n=u*t/100;i.css("left",n+"px"),o.css("width",n+"px")}function h(t){var e=((t.pageX||t.touches[0].clientX)-r.offset().left)/70*100;return e<0&&(e=0),e>100&&(e=100),e}var f={"click .op-volume-button":function(t,n,r){t.preventDefault(),A||(0===e.getVolume()?(e.setMute(!1),e.setVolume(100)):e.setMute())},"mouseenter .op-volume-button":function(t,e,r){t.preventDefault(),A||n.addClass("active")},"mouseleave .op-volume-silder":function(t,e,n){t.preventDefault(),c=!1},"mousedown .op-volume-silder":function(t,n,r){t.preventDefault(),c=!0,e.setMute(!1),e.setVolume(h(t))},"mouseup .op-volume-silder":function(t,e,n){t.preventDefault(),c=!1},"mousemove .op-volume-silder":function(t,n,r){if(t.preventDefault(),!c)return!1;e.setVolume(h(t))},"touchstart .op-volume-button":function(t){A&&(e.getMute()?e.setMute(!1):e.setMute(!0))}},p=Rl(t,"VolumeButton",e.getConfig(),null,f,(function(t,c){n=t.find(".op-volume-slider-container"),e.getBrowser().mobile&&n.hide(),r=t.find(".op-volume-silder"),i=t.find(".op-volume-slider-handle"),o=t.find(".op-volume-slider-value"),s=t.find(".op-volume-max"),a=t.find(".op-volume-small"),l=t.find(".op-volume-mute"),u=64,i.css("left",u+"px"),d(e.getVolume()),e.on(ht,(function(){d(e.getVolume())}),c),e.on(Rt,(function(t){d(t.volume)}),c),e.on(Dt,(function(t){t.mute?d(0):d(e.getVolume())}),c)}),(function(t){e.off(ht,null,t),e.off(Rt,null,t),e.off(Dt,null,t)}));return p.setMouseDown=function(t){c=t},p}(t.find(".op-left-controls"),e);var E=e.getPlaylist(),w=e.getCurrentPlaylist();E&&E[w]&&E[w].adTagUrl||v(),y(),e.on(ht,(function(){t.show()}),u),e.on(Bt,(function(t){n=t.duration,m=t,t.isP2P=d,C(t)}),u),e.on(It,(function(t){(f||e&&e.getProviderName&&"rtmp"===e.getProviderName())&&!n&&m&&m.duration!==t.duration&&(m=t,C(t))}),u),e.on(wt,(function(t){g.find(".op-setting-panel")&&g.find(".op-setting-panel").css("max-height",g.height()-g.find(".op-bottom-panel").height()+"px")}),u),e.on(Nt,(function(t){d=t}),u),e.on(bt,(function(){if(!A){var n="";e.getSources().length>0&&e.getSources()[e.getCurrentSource()]&&e.getSources()[e.getCurrentSource()].type&&(n=e.getSources()[e.getCurrentSource()].type),C({isP2P:d,duration:e.getDuration(),type:n})}t.show()}),u),e.on(vt,(function(e){t.show()}),u),e.on(kt,(function(t){t.isLinear?(g.addClass("linear-ad"),h(!0),a&&a.destroy(),o&&o.destroy(),p&&c&&c.destroy()):g.removeClass("linear-ad")}),u),e.on(at,(function(){b()}),u),e.on(lt,(function(){b()}),u),e.on(Pt,(function(){b()}),u)}),(function(t){e.off(Bt,null,t),e.off(It,null,t),e.off(at,null,t),e.off(kt,null,t),e.off(Nt,null,t),e.off(lt,null,t),e.off(wt,null,t),e.off(Pt,null,t),a&&a.destroy(),i&&i.destroy(),s&&s.destroy(),c&&c.destroy(),r&&r.destroy()}))},Ul=n(5655),Ql=n.n(Ul),Gl=n(3379),Wl=n.n(Gl),Yl=n(7795),jl=n.n(Yl),Hl=n(569),Kl=n.n(Hl),Vl=n(3565),zl=n.n(Vl),$l=n(9216),Xl=n.n($l),ql=n(4589),Jl=n.n(ql),Zl=n(2021),tc={};tc.styleTagTransform=Jl(),tc.setAttributes=zl(),tc.insert=Kl().bind(null,"head"),tc.domAPI=jl(),tc.insertStyleElement=Xl(),Wl()(Zl.Z,tc),Zl.Z&&Zl.Z.locals&&Zl.Z.locals;var ec,nc=function(t){var e,n="",r="",i="",o="",s=null,a="",l=q,c=!1,u=Ml(),A="",d="",h=null,f={};function p(t,n){if(a&&(clearTimeout(a),a=null),t){if(u.size()>0)return!1;e.addClass("op-autohide")}else e.removeClass("op-autohide"),n&&(a=setTimeout((function(){if(u.size()>0)return!1;e.addClass("op-autohide")}),3e3))}function g(){var t=l;t===q||t===Z||t===J?(t===J&&s.seek(0),s.play()):t===tt&&s.pause()}function m(t,e){var n,r=s.getDuration(),i=s.getPosition();n=e?Math.max(i-t,0):Math.min(i+t,r),s.seek(n)}function v(t){var e,n=s.getVolume();e=t?Math.min(n+5,100):Math.max(n-5,0),s.setVolume(e)}function y(){var t=e.width();t<576?(A="xsmall",e.addClass("xsmall"),t<490&&e.addClass("xxsmall")):t<768?(A="small",e.addClass("small")):t<992?(A="medium",e.addClass("medium")):(A="large",e.addClass("large"))}var C={"click .ovenplayer":function(t,e,n){if(s&&s.trigger(Et,t),o)return t.preventDefault(),o.destroy(),o=null,!1;if(!jt(t.target).closest(".op-controls-container")&&!jt(t.target).closest(".op-setting-panel")){if(u.size()>0)return t.preventDefault(),u.clear(),!1;s.getDuration()===1/0||s.getBrowser().mobile||g()}},"dblclick .ovenplayer":function(t,e,n){s&&s.getConfig().expandFullScreenUI&&s.toggleFullScreen&&(jt(t.target).closest(".op-controls-container")||jt(t.target).closest(".op-setting-panel")||s.toggleFullScreen())},"touchstart .ovenplayer":function(t,e,n){l===tt||l===q||l===nt||l===ot&&"xsmall"===A?p(!1,!0):p(!1)},"mouseenter .ovenplayer":function(t,e,n){t.preventDefault(),l===tt||l===q||l===nt||l===ot&&"xsmall"===A?p(!1,!0):p(!1)},"mousemove .ovenplayer":function(t,e,n){t.preventDefault(),l===tt||l===q||l===nt||l===ot&&"xsmall"===A?p(!1,!0):p(!1)},"mouseleave .ovenplayer":function(t,e,n){t.preventDefault(),(l===tt||l===q||l===nt||l===ot&&"xsmall"===A)&&p(!0)},"keydown .ovenplayer":function(t,e,n){var r=s.getFramerate();switch(t.keyCode){case 16:t.preventDefault(),c=!0;break;case 32:t.preventDefault(),g();break;case 37:t.preventDefault(),s.getConfig().disableSeekUI||(c&&r?s.seekFrame(-1):m(5,!0));break;case 39:t.preventDefault(),s.getConfig().disableSeekUI||(c&&r?s.seekFrame(1):m(5,!1));break;case 38:t.preventDefault(),v(!0);break;case 40:t.preventDefault(),v(!1)}},"keyup .ovenplayer":function(t,e,n){16===t.keyCode&&(t.preventDefault(),c=!1)},"contextmenu .ovenplayer":function(t,n,r){if(t.stopPropagation(),!jt(t.currentTarget).find("object"))return t.preventDefault(),i=t.pageX,a=t.pageY,o&&(o.destroy(),o=null),o=function(t,e,n){var r=jt(e.getContainerElement()),i={"click .op-context-item":function(t,e,n){t.preventDefault(),window.open("https://github.com/AirenSoft/OvenPlayer","_blank")}};return Rl(t,"ContextPanel",e.getConfig(),n,i,(function(t,e){var i=t.width(),o=t.height(),s=Math.min(n.pageX-r.offset().left,r.width()-i),a=Math.min(n.pageY-r.offset().top,r.height()-o);t.css("left",s+"px"),t.css("top",a+"px")}),(function(){}))}(e,s,{pageX:i,pageY:a}),!1;var i,a}};return(f=Rl(t,"View",null,t.id,C,(function(t,r){e=t,n=r,y(),d=A,h=new(Ql())(e.get(),(function(){e.removeClass("large"),e.removeClass("medium"),e.removeClass("small"),e.removeClass("xsmall"),e.removeClass("xxsmall"),y(),A!==d&&(d=A,s&&s.trigger(wt,d))}))}),(function(){h&&(h.detach(),h=null),i&&(i.destroy(),i=null),r&&(r.destroy(),r=null)}),!0)).getMediaElementContainer=function(){return e.find(".op-media-element-container").get()},f.setApi=function(t){(s=t).getContainerElement=function(){return e.get()},s.getContainerId=function(){return e.get().id},s.on(ht,(function(n){r||(r=Nl(e.find(".op-ui"),t)),o||e.addClass("op-no-controls")})),s.on(vt,(function(t){if(s){var e=s.getSources()||[];r&&e.length}})),s.on(ft,(function(t){n.destroy()})),s.on(bt,(function(n){!r&&o&&(r=Nl(e.find(".op-ui"),t))})),s.on(yt,(function(t){t&&t.newstate&&(l=t.newstate,t.newstate===tt||t.newstate===ot&&"xsmall"===A?p(!1,!0):p(!1))}));var o=s.getConfig()&&s.getConfig().controls;i=Bl(e.find(".op-ui"),t),r=Nl(e.find(".op-ui"),t);var a=s.getConfig().aspectRatio;if(a&&2===a.split(":").length){var c=1*a.split(":")[0],u=1*a.split(":")[1]/c*100;e.find(".op-ratio").css("padding-bottom",u+"%")}s.showControls=function(t){t?(e.removeClass("op-no-controls"),p(!1,!0)):e.addClass("op-no-controls")}},f},rc=(ec={},Object.assign(ec,Sl),ec.create=function(t,e){var n=$t(t),r=nc(n),i=Sl.create(r.getMediaElementContainer(),e);return r.setApi(i),OvenPlayerConsole.log("[OvenPlayer] v.0.10.31"),i},ec)},1001:function(){!function(t){"use strict";if("window"in t&&"document"in t){document.querySelectorAll||(document.querySelectorAll=function(t){var e,n=document.createElement("style"),r=[];for(document.documentElement.firstChild.appendChild(n),document._qsa=[],n.styleSheet.cssText=t+"{x-qsa:expression(document._qsa && document._qsa.push(this))}",window.scrollBy(0,0),n.parentNode.removeChild(n);document._qsa.length;)(e=document._qsa.shift()).style.removeAttribute("x-qsa"),r.push(e);return document._qsa=null,r}),document.querySelector||(document.querySelector=function(t){var e=document.querySelectorAll(t);return e.length?e[0]:null}),document.getElementsByClassName||(document.getElementsByClassName=function(t){return t=String(t).replace(/^|\s+/g,"."),document.querySelectorAll(t)}),t.Node=t.Node||function(){throw TypeError("Illegal constructor")},[["ELEMENT_NODE",1],["ATTRIBUTE_NODE",2],["TEXT_NODE",3],["CDATA_SECTION_NODE",4],["ENTITY_REFERENCE_NODE",5],["ENTITY_NODE",6],["PROCESSING_INSTRUCTION_NODE",7],["COMMENT_NODE",8],["DOCUMENT_NODE",9],["DOCUMENT_TYPE_NODE",10],["DOCUMENT_FRAGMENT_NODE",11],["NOTATION_NODE",12]].forEach((function(e){e[0]in t.Node||(t.Node[e[0]]=e[1])})),t.DOMException=t.DOMException||function(){throw TypeError("Illegal constructor")},[["INDEX_SIZE_ERR",1],["DOMSTRING_SIZE_ERR",2],["HIERARCHY_REQUEST_ERR",3],["WRONG_DOCUMENT_ERR",4],["INVALID_CHARACTER_ERR",5],["NO_DATA_ALLOWED_ERR",6],["NO_MODIFICATION_ALLOWED_ERR",7],["NOT_FOUND_ERR",8],["NOT_SUPPORTED_ERR",9],["INUSE_ATTRIBUTE_ERR",10],["INVALID_STATE_ERR",11],["SYNTAX_ERR",12],["INVALID_MODIFICATION_ERR",13],["NAMESPACE_ERR",14],["INVALID_ACCESS_ERR",15]].forEach((function(e){e[0]in t.DOMException||(t.DOMException[e[0]]=e[1])})),function(){function e(t,e,n){if("function"==typeof e){"DOMContentLoaded"===t&&(t="load");var r=this,i=function(t){t._timeStamp=Date.now(),t._currentTarget=r,e.call(this,t),t._currentTarget=null};this["_"+t+e]=i,this.attachEvent("on"+t,i)}}function n(t,e,n){if("function"==typeof e){"DOMContentLoaded"===t&&(t="load");var r=this["_"+t+e];r&&(this.detachEvent("on"+t,r),this["_"+t+e]=null)}}"Element"in t&&!Element.prototype.addEventListener&&Object.defineProperty&&(Event.CAPTURING_PHASE=1,Event.AT_TARGET=2,Event.BUBBLING_PHASE=3,Object.defineProperties(Event.prototype,{CAPTURING_PHASE:{get:function(){return 1}},AT_TARGET:{get:function(){return 2}},BUBBLING_PHASE:{get:function(){return 3}},target:{get:function(){return this.srcElement}},currentTarget:{get:function(){return this._currentTarget}},eventPhase:{get:function(){return this.srcElement===this.currentTarget?Event.AT_TARGET:Event.BUBBLING_PHASE}},bubbles:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mousemove":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"resize":case"scroll":case"select":case"change":case"submit":case"reset":return!0}return!1}},cancelable:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"submit":return!0}return!1}},timeStamp:{get:function(){return this._timeStamp}},stopPropagation:{value:function(){this.cancelBubble=!0}},preventDefault:{value:function(){this.returnValue=!1}},defaultPrevented:{get:function(){return!1===this.returnValue}}}),[Window,HTMLDocument,Element].forEach((function(t){t.prototype.addEventListener=e,t.prototype.removeEventListener=n})))}(),function(){function e(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}"CustomEvent"in t&&"function"==typeof t.CustomEvent||(e.prototype=t.Event.prototype,t.CustomEvent=e)}(),window.addEvent=function(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent&&(t["e"+e+n]=n,t[e+n]=function(){var r=window.event;r.currentTarget=t,r.preventDefault=function(){r.returnValue=!1},r.stopPropagation=function(){r.cancelBubble=!0},r.target=r.srcElement,r.timeStamp=Date.now(),t["e"+e+n].call(this,r)},t.attachEvent("on"+e,t[e+n]))},window.removeEvent=function(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent&&(t.detachEvent("on"+e,t[e+n]),t[e+n]=null,t["e"+e+n]=null)},function(){function e(t,e){function n(t){return t.length?t.split(/\s+/g):[]}function r(t,e){var r=n(e),i=r.indexOf(t);return-1!==i&&r.splice(i,1),r.join(" ")}if(Object.defineProperties(this,{length:{get:function(){return n(t[e]).length}},item:{value:function(r){var i=n(t[e]);return 0<=r&&r=0&&e.item(n)!==this;);return n>-1})),window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(t){var e,n=(this.document||this.ownerDocument).querySelectorAll(t),r=this;do{for(e=n.length;--e>=0&&n.item(e)!==r;);}while(e<0&&(r=r.parentElement));return r});var e={prepend:function(){var t=[].slice.call(arguments);t=i(t),this.insertBefore(t,this.firstChild)},append:function(){var t=[].slice.call(arguments);t=i(t),this.appendChild(t)}};r(t.Document||t.HTMLDocument,e),r(t.DocumentFragment,e),r(t.Element,e);var n={before:function(){var t=[].slice.call(arguments),e=this.parentNode;if(e){for(var n=this.previousSibling;-1!==t.indexOf(n);)n=n.previousSibling;var r=i(t);e.insertBefore(r,n?n.nextSibling:e.firstChild)}},after:function(){var t=[].slice.call(arguments),e=this.parentNode;if(e){for(var n=this.nextSibling;-1!==t.indexOf(n);)n=n.nextSibling;var r=i(t);e.insertBefore(r,n)}},replaceWith:function(){var t=[].slice.call(arguments),e=this.parentNode;if(e){for(var n=this.nextSibling;-1!==t.indexOf(n);)n=n.nextSibling;var r=i(t);this.parentNode===e?e.replaceChild(r,this):e.insertBefore(r,n)}},remove:function(){this.parentNode&&this.parentNode.removeChild(this)}};r(t.DocumentType,n),r(t.Element,n),r(t.CharacterData,n)}function r(t,e){t&&Object.keys(e).forEach((function(n){if(!(n in t)&&!(n in t.prototype))try{Object.defineProperty(t.prototype,n,Object.getOwnPropertyDescriptor(e,n))}catch(r){t[n]=e[n]}}))}function i(t){var e=null;return t=t.map((function(t){return t instanceof Node?t:document.createTextNode(t)})),1===t.length?e=t[0]:(e=document.createDocumentFragment(),t.forEach((function(t){e.appendChild(t)}))),e}}(self)},5655:function(t,e){var n,r;r=this,void 0===(n=function(){return r.returnExportsGlobal=function(){"use strict";var t=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,20)};function e(){var t,e;this.q=[],this.add=function(t){this.q.push(t)},this.call=function(){for(t=0,e=this.q.length;t
',n.appendChild(n.resizeSensor),"static"==function(t,e){return t.currentStyle?t.currentStyle[e]:window.getComputedStyle?window.getComputedStyle(t,null).getPropertyValue(e):t.style[e]}(n,"position")&&(n.style.position="relative");var s=n.resizeSensor.childNodes[0],a=s.childNodes[0],l=n.resizeSensor.childNodes[1],c=function(){a.style.width="100000px",a.style.height="100000px",s.scrollLeft=1e5,s.scrollTop=1e5,l.scrollLeft=1e5,l.scrollTop=1e5};c();var u,A,d,h,f=!1;t((function e(){n.resizedAttached&&(f&&(n.resizedAttached.call(),f=!1),t(e))}));var p=function(){(d=n.offsetWidth)==u&&(h=n.offsetHeight)==A||(f=!0,u=d,A=h),c()},g=function(t,e,n){t.attachEvent?t.attachEvent("on"+e,n):t.addEventListener(e,n)};g(s,"scroll",p),g(l,"scroll",p)}var r=function(t,e){var r=Object.prototype.toString.call(t),i=this._isCollectionTyped="[object Array]"===r||"[object NodeList]"===r||"[object HTMLCollection]"===r||"undefined"!=typeof jQuery&&t instanceof window.jQuery||"undefined"!=typeof Elements&&t instanceof window.Elements;if(this._element=t,i)for(var o=0,s=t.length;o=0&&n<=b}}function $(t){return function(e){return null==e?void 0:e[t]}}var X=$("byteLength"),q=z(X),J=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/,Z=A?function(t){return g?g(t)&&!G(t):q(t)&&J.test(c.call(t))}:V(!1),tt=$("length");function et(t,e){e=function(t){for(var e={},n=t.length,r=0;r":">",'"':""","'":"'","`":"`"},Ht=Yt(jt),Kt=Yt(bt(jt)),Vt=it.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},zt=/(.)^/,$t={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Xt=/\\|'|\r|\n|\u2028|\u2029/g;function qt(t){return"\\"+$t[t]}var Jt=/^\s*(\w|\$)+\s*$/,Zt=0;function te(t,e,n,r,i){if(!(r instanceof e))return t.apply(n,i);var o=Lt(t.prototype),s=t.apply(o,i);return w(s)?s:o}var ee=E((function(t,e){var n=ee.placeholder;return function r(){for(var i=0,o=e.length,s=Array(o),a=0;a1)ie(a,e-1,n,r),i=r.length;else for(var l=0,c=a.length;l0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}}var ue=ee(ce,2);function Ae(t,e,n){e=Ut(e,n);for(var r,i=nt(t),o=0,s=i.length;o0?0:i-1;o>=0&&o0?s=o>=0?o:Math.max(o+a,s):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return r[o=n(r,i)]===i?o:-1;if(i!=i)return(o=e(l.call(r,s,a),K))>=0?o+s:-1;for(o=t>0?s:a-1;o>=0&&o0?0:s-1;for(i||(r=e[o?o[a]:a],a+=t);a>=0&&a=3;return e(t,Ft(n,i,4),r,o)}}var we=Ee(1),Te=Ee(-1);function Se(t,e,n){var r=[];return e=Ut(e,n),Ce(t,(function(t,n,i){e(t,n,i)&&r.push(t)})),r}function ke(t,e,n){e=Ut(e,n);for(var r=!re(t)&&nt(t),i=(r||t).length,o=0;o=0}var Ie=E((function(t,e,n){var r,i;return F(e)?i=e:(e=Rt(e),r=e.slice(0,-1),e=e[e.length-1]),be(t,(function(t){var o=i;if(!o){if(r&&r.length&&(t=Dt(t,r)),null==t)return;o=t[e]}return null==o?o:o.apply(t,n)}))}));function Re(t,e){return be(t,Ot(e))}function De(t,e,n){var r,i,o=-1/0,a=-1/0;if(null==e||"number"==typeof e&&"object"!=s(t[0])&&null!=t)for(var l=0,c=(t=re(t)?t:Ct(t)).length;lo&&(o=r);else e=Ut(e,n),Ce(t,(function(t,n,r){((i=e(t,n,r))>a||i===-1/0&&o===-1/0)&&(o=t,a=i)}));return o}function Be(t,e,n){if(null==e||n)return re(t)||(t=Ct(t)),t[Gt(t.length-1)];var r=re(t)?xt(t):Ct(t),i=tt(r);e=Math.max(Math.min(e,i),0);for(var o=i-1,s=0;s1&&(r=Ft(r,e[1])),e=lt(t)):(r=Ue,e=ie(e,!1,!1),t=Object(t));for(var i=0,o=e.length;i1&&(n=e[1])):(e=be(ie(e,!1,!1),String),r=function(t,n){return!xe(e,n)}),Qe(t,r,n)}));function We(t,e,n){return l.call(t,0,Math.max(0,t.length-(null==e||n?1:e)))}function Ye(t,e,n){return null==t||t.length<1?null==e||n?void 0:[]:null==e||n?t[0]:We(t,t.length-e)}function je(t,e,n){return l.call(t,null==e||n?1:e)}var He=E((function(t,e){return e=ie(e,!0,!0),Se(t,(function(t){return!xe(e,t)}))})),Ke=E((function(t,e){return He(t,e)}));function Ve(t,e,n,r){S(e)||(r=n,n=e,e=!1),null!=n&&(n=Ut(n,r));for(var i=[],o=[],s=0,a=tt(t);se?(r&&(clearTimeout(r),r=null),a=c,s=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(l,u)),s};return c.cancel=function(){clearTimeout(r),a=0,r=i=o=null},c},debounce:function(t,e,n){var r,i,o,s,a,l=function l(){var c=Wt()-i;e>c?r=setTimeout(l,e-c):(r=null,n||(s=t.apply(a,o)),r||(o=a=null))},c=E((function(c){return a=this,o=c,i=Wt(),r||(r=setTimeout(l,e),n&&(s=t.apply(a,o))),s}));return c.cancel=function(){clearTimeout(r),r=o=a=null},c},wrap:function(t,e){return ee(e,t)},negate:le,compose:function(){var t=arguments,e=t.length-1;return function(){for(var n=e,r=t[e].apply(this,arguments);n--;)r=t[n].call(this,r);return r}},after:function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},before:ce,once:ue,findKey:Ae,findIndex:he,findLastIndex:fe,sortedIndex:pe,indexOf:me,lastIndexOf:ve,find:ye,detect:ye,findWhere:function(t,e){return ye(t,Mt(e))},each:Ce,forEach:Ce,map:be,collect:be,reduce:we,foldl:we,inject:we,reduceRight:Te,foldr:Te,filter:Se,select:Se,reject:function(t,e,n){return Se(t,le(Ut(e)),n)},every:ke,all:ke,some:Le,any:Le,contains:xe,includes:xe,include:xe,invoke:Ie,pluck:Re,where:function(t,e){return Se(t,Mt(e))},max:De,min:function(t,e,n){var r,i,o=1/0,a=1/0;if(null==e||"number"==typeof e&&"object"!=s(t[0])&&null!=t)for(var l=0,c=(t=re(t)?t:Ct(t)).length;lr||void 0===n)return 1;if(n>8&255]},j=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},H=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},K=function(t){return Q(t,23,4)},V=function(t){return Q(t,52,8)},z=function(t,e){y(t.prototype,e,{get:function(){return k(this)[e]}})},$=function(t,e,n,r){var i=f(n),o=k(t);if(i+e>o.byteLength)throw _(I);var s=k(o.buffer).bytes,a=i+o.byteOffset,l=b(s,a,a+e);return r?l:U(l)},X=function(t,e,n,r,i,o){var s=f(n),a=k(t);if(s+e>a.byteLength)throw _(I);for(var l=k(a.buffer).bytes,c=s+a.byteOffset,u=r(+i),A=0;Att;)(J=Z[tt++])in D||l(D,J,R[J]);B.constructor=D}m&&g(M)!==O&&m(M,O);var et=new P(new D(2)),nt=i(M.setInt8);et.setInt8(0,2147483648),et.setInt8(1,2147483649),!et.getInt8(0)&&et.getInt8(1)||c(M,{setInt8:function(t,e){nt(this,t,e<<24>>24)},setUint8:function(t,e){nt(this,t,e<<24>>24)}},{unsafe:!0})}else B=(D=function(t){A(this,B);var e=f(t);L(this,{bytes:N(F(e),0),byteLength:e}),o||(this.byteLength=e)}).prototype,M=(P=function(t,e,n){A(this,M),A(t,B);var r=k(t).byteLength,i=d(e);if(i<0||i>r)throw _("Wrong offset");if(i+(n=void 0===n?r-i:h(n))>r)throw _("Wrong length");L(this,{buffer:t,byteLength:n,byteOffset:i}),o||(this.buffer=t,this.byteLength=n,this.byteOffset=i)}).prototype,o&&(z(D,"byteLength"),z(P,"buffer"),z(P,"byteLength"),z(P,"byteOffset")),c(M,{getInt8:function(t){return $(this,1,t)[0]<<24>>24},getUint8:function(t){return $(this,1,t)[0]},getInt16:function(t){var e=$(this,2,t,arguments.length>1?arguments[1]:void 0);return(e[1]<<8|e[0])<<16>>16},getUint16:function(t){var e=$(this,2,t,arguments.length>1?arguments[1]:void 0);return e[1]<<8|e[0]},getInt32:function(t){return H($(this,4,t,arguments.length>1?arguments[1]:void 0))},getUint32:function(t){return H($(this,4,t,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(t){return G($(this,4,t,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(t){return G($(this,8,t,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(t,e){X(this,1,t,W,e)},setUint8:function(t,e){X(this,1,t,W,e)},setInt16:function(t,e){X(this,2,t,Y,e,arguments.length>2?arguments[2]:void 0)},setUint16:function(t,e){X(this,2,t,Y,e,arguments.length>2?arguments[2]:void 0)},setInt32:function(t,e){X(this,4,t,j,e,arguments.length>2?arguments[2]:void 0)},setUint32:function(t,e){X(this,4,t,j,e,arguments.length>2?arguments[2]:void 0)},setFloat32:function(t,e){X(this,4,t,K,e,arguments.length>2?arguments[2]:void 0)},setFloat64:function(t,e){X(this,8,t,V,e,arguments.length>2?arguments[2]:void 0)}});E(D,x),E(P,"DataView"),t.exports={ArrayBuffer:D,DataView:P}},1048:function(t,e,n){"use strict";var r=n(7908),i=n(1400),o=n(6244),s=Math.min;t.exports=[].copyWithin||function(t,e){var n=r(this),a=o(n),l=i(t,a),c=i(e,a),u=arguments.length>2?arguments[2]:void 0,A=s((void 0===u?a:i(u,a))-c,a-l),d=1;for(c0;)c in n?n[l]=n[c]:delete n[l],l+=d,c+=d;return n}},1285:function(t,e,n){"use strict";var r=n(7908),i=n(1400),o=n(6244);t.exports=function(t){for(var e=r(this),n=o(e),s=arguments.length,a=i(s>1?arguments[1]:void 0,n),l=s>2?arguments[2]:void 0,c=void 0===l?n:i(l,n);c>a;)e[a++]=t;return e}},8533:function(t,e,n){"use strict";var r=n(2092).forEach,i=n(2133)("forEach");t.exports=i?[].forEach:function(t){return r(this,t,arguments.length>1?arguments[1]:void 0)}},7745:function(t,e,n){var r=n(6244);t.exports=function(t,e){for(var n=0,i=r(e),o=new t(i);i>n;)o[n]=e[n++];return o}},8457:function(t,e,n){"use strict";var r=n(7854),i=n(9974),o=n(6916),s=n(7908),a=n(3411),l=n(7659),c=n(4411),u=n(6244),A=n(6135),d=n(8554),h=n(1246),f=r.Array;t.exports=function(t){var e=s(t),n=c(this),r=arguments.length,p=r>1?arguments[1]:void 0,g=void 0!==p;g&&(p=i(p,r>2?arguments[2]:void 0));var m,v,y,C,b,E,w=h(e),T=0;if(!w||this==f&&l(w))for(m=u(e),v=n?new this(m):f(m);m>T;T++)E=g?p(e[T],T):e[T],A(v,T,E);else for(b=(C=d(e,w)).next,v=n?new this:[];!(y=o(b,C)).done;T++)E=g?a(C,p,[y.value,T],!0):y.value,A(v,T,E);return v.length=T,v}},1318:function(t,e,n){var r=n(5656),i=n(1400),o=n(6244),s=function(t){return function(e,n,s){var a,l=r(e),c=o(l),u=i(s,c);if(t&&n!=n){for(;c>u;)if((a=l[u++])!=a)return!0}else for(;c>u;u++)if((t||u in l)&&l[u]===n)return t||u||0;return!t&&-1}};t.exports={includes:s(!0),indexOf:s(!1)}},2092:function(t,e,n){var r=n(9974),i=n(1702),o=n(8361),s=n(7908),a=n(6244),l=n(5417),c=i([].push),u=function(t){var e=1==t,n=2==t,i=3==t,u=4==t,A=6==t,d=7==t,h=5==t||A;return function(f,p,g,m){for(var v,y,C=s(f),b=o(C),E=r(p,g),w=a(b),T=0,S=m||l,k=e?S(f,w):n||d?S(f,0):void 0;w>T;T++)if((h||T in b)&&(y=E(v=b[T],T,C),t))if(e)k[T]=y;else if(y)switch(t){case 3:return!0;case 5:return v;case 6:return T;case 2:c(k,v)}else switch(t){case 4:return!1;case 7:c(k,v)}return A?-1:i||u?u:k}};t.exports={forEach:u(0),map:u(1),filter:u(2),some:u(3),every:u(4),find:u(5),findIndex:u(6),filterReject:u(7)}},6583:function(t,e,n){"use strict";var r=n(2104),i=n(5656),o=n(9303),s=n(6244),a=n(2133),l=Math.min,c=[].lastIndexOf,u=!!c&&1/[1].lastIndexOf(1,-0)<0,A=a("lastIndexOf"),d=u||!A;t.exports=d?function(t){if(u)return r(c,this,arguments)||0;var e=i(this),n=s(e),a=n-1;for(arguments.length>1&&(a=l(a,o(arguments[1]))),a<0&&(a=n+a);a>=0;a--)if(a in e&&e[a]===t)return a||0;return-1}:c},1194:function(t,e,n){var r=n(7293),i=n(5112),o=n(7392),s=i("species");t.exports=function(t){return o>=51||!r((function(){var e=[];return(e.constructor={})[s]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}},2133:function(t,e,n){"use strict";var r=n(7293);t.exports=function(t,e){var n=[][t];return!!n&&r((function(){n.call(null,e||function(){throw 1},1)}))}},3671:function(t,e,n){var r=n(7854),i=n(9662),o=n(7908),s=n(8361),a=n(6244),l=r.TypeError,c=function(t){return function(e,n,r,c){i(n);var u=o(e),A=s(u),d=a(u),h=t?d-1:0,f=t?-1:1;if(r<2)for(;;){if(h in A){c=A[h],h+=f;break}if(h+=f,t?h<0:d<=h)throw l("Reduce of empty array with no initial value")}for(;t?h>=0:d>h;h+=f)h in A&&(c=n(c,A[h],h,u));return c}};t.exports={left:c(!1),right:c(!0)}},1589:function(t,e,n){var r=n(7854),i=n(1400),o=n(6244),s=n(6135),a=r.Array,l=Math.max;t.exports=function(t,e,n){for(var r=o(t),c=i(e,r),u=i(void 0===n?r:n,r),A=a(l(u-c,0)),d=0;c0;)t[r]=t[--r];r!==o++&&(t[r]=n)}return t},a=function(t,e,n,r){for(var i=e.length,o=n.length,s=0,a=0;s1?arguments[1]:void 0);e=e?e.next:n.first;)for(r(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!v(this,t)}}),o(h,n?{get:function(t){var e=v(this,t);return e&&e.value},set:function(t,e){return m(this,0===t?0:t,e)}}:{add:function(t){return m(this,t=0===t?0:t,t)}}),A&&r(h,"size",{get:function(){return g(this).size}}),u},setStrong:function(t,e,n){var r=e+" Iterator",i=p(e),o=p(r);c(t,e,(function(t,e){f(this,{type:r,target:t,state:i(t),kind:e,last:void 0})}),(function(){for(var t=o(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?"keys"==e?{value:n.key,done:!1}:"values"==e?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(t.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),u(e)}}},9320:function(t,e,n){"use strict";var r=n(1702),i=n(2248),o=n(2423).getWeakData,s=n(9670),a=n(111),l=n(5787),c=n(408),u=n(2092),A=n(2597),d=n(9909),h=d.set,f=d.getterFor,p=u.find,g=u.findIndex,m=r([].splice),v=0,y=function(t){return t.frozen||(t.frozen=new C)},C=function(){this.entries=[]},b=function(t,e){return p(t.entries,(function(t){return t[0]===e}))};C.prototype={get:function(t){var e=b(this,t);if(e)return e[1]},has:function(t){return!!b(this,t)},set:function(t,e){var n=b(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=g(this.entries,(function(e){return e[0]===t}));return~e&&m(this.entries,e,1),!!~e}},t.exports={getConstructor:function(t,e,n,r){var u=t((function(t,i){l(t,d),h(t,{type:e,id:v++,frozen:void 0}),null!=i&&c(i,t[r],{that:t,AS_ENTRIES:n})})),d=u.prototype,p=f(e),g=function(t,e,n){var r=p(t),i=o(s(e),!0);return!0===i?y(r).set(e,n):i[r.id]=n,t};return i(d,{delete:function(t){var e=p(this);if(!a(t))return!1;var n=o(t);return!0===n?y(e).delete(t):n&&A(n,e.id)&&delete n[e.id]},has:function(t){var e=p(this);if(!a(t))return!1;var n=o(t);return!0===n?y(e).has(t):n&&A(n,e.id)}}),i(d,n?{get:function(t){var e=p(this);if(a(t)){var n=o(t);return!0===n?y(e).get(t):n?n[e.id]:void 0}},set:function(t,e){return g(this,t,e)}}:{add:function(t){return g(this,t,!0)}}),u}}},7710:function(t,e,n){"use strict";var r=n(2109),i=n(7854),o=n(1702),s=n(4705),a=n(1320),l=n(2423),c=n(408),u=n(5787),A=n(614),d=n(111),h=n(7293),f=n(7072),p=n(8003),g=n(9587);t.exports=function(t,e,n){var m=-1!==t.indexOf("Map"),v=-1!==t.indexOf("Weak"),y=m?"set":"add",C=i[t],b=C&&C.prototype,E=C,w={},T=function(t){var e=o(b[t]);a(b,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(v&&!d(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return v&&!d(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(v&&!d(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if(s(t,!A(C)||!(v||b.forEach&&!h((function(){(new C).entries().next()})))))E=n.getConstructor(e,t,m,y),l.enable();else if(s(t,!0)){var S=new E,k=S[y](v?{}:-0,1)!=S,L=h((function(){S.has(1)})),x=f((function(t){new C(t)})),I=!v&&h((function(){for(var t=new C,e=5;e--;)t[y](e,e);return!t.has(-0)}));x||((E=e((function(t,e){u(t,b);var n=g(new C,t,E);return null!=e&&c(e,n[y],{that:n,AS_ENTRIES:m}),n}))).prototype=b,b.constructor=E),(L||I)&&(T("delete"),T("has"),m&&T("get")),(I||k)&&T(y),v&&b.clear&&delete b.clear}return w[t]=E,r({global:!0,forced:E!=C},w),p(E,t),v||n.setStrong(E,t,m),E}},9920:function(t,e,n){var r=n(2597),i=n(3887),o=n(1236),s=n(3070);t.exports=function(t,e,n){for(var a=i(e),l=s.f,c=o.f,u=0;u"+l+""}},4994:function(t,e,n){"use strict";var r=n(3383).IteratorPrototype,i=n(30),o=n(9114),s=n(8003),a=n(7497),l=function(){return this};t.exports=function(t,e,n,c){var u=e+" Iterator";return t.prototype=i(r,{next:o(+!c,n)}),s(t,u,!1,!0),a[u]=l,t}},8880:function(t,e,n){var r=n(9781),i=n(3070),o=n(9114);t.exports=r?function(t,e,n){return i.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},9114:function(t){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},6135:function(t,e,n){"use strict";var r=n(4948),i=n(3070),o=n(9114);t.exports=function(t,e,n){var s=r(e);s in t?i.f(t,s,o(0,n)):t[s]=n}},5573:function(t,e,n){"use strict";var r=n(7854),i=n(1702),o=n(7293),s=n(6650).start,a=r.RangeError,l=Math.abs,c=Date.prototype,u=c.toISOString,A=i(c.getTime),d=i(c.getUTCDate),h=i(c.getUTCFullYear),f=i(c.getUTCHours),p=i(c.getUTCMilliseconds),g=i(c.getUTCMinutes),m=i(c.getUTCMonth),v=i(c.getUTCSeconds);t.exports=o((function(){return"0385-07-25T07:06:39.999Z"!=u.call(new Date(-50000000000001))}))||!o((function(){u.call(new Date(NaN))}))?function(){if(!isFinite(A(this)))throw a("Invalid time value");var t=this,e=h(t),n=p(t),r=e<0?"-":e>9999?"+":"";return r+s(l(e),r?6:4,0)+"-"+s(m(t)+1,2,0)+"-"+s(d(t),2,0)+"T"+s(f(t),2,0)+":"+s(g(t),2,0)+":"+s(v(t),2,0)+"."+s(n,3,0)+"Z"}:u},8709:function(t,e,n){"use strict";var r=n(7854),i=n(9670),o=n(2140),s=r.TypeError;t.exports=function(t){if(i(this),"string"===t||"default"===t)t="string";else if("number"!==t)throw s("Incorrect hint");return o(this,t)}},654:function(t,e,n){"use strict";var r=n(2109),i=n(6916),o=n(1913),s=n(6530),a=n(614),l=n(4994),c=n(9518),u=n(7674),A=n(8003),d=n(8880),h=n(1320),f=n(5112),p=n(7497),g=n(3383),m=s.PROPER,v=s.CONFIGURABLE,y=g.IteratorPrototype,C=g.BUGGY_SAFARI_ITERATORS,b=f("iterator"),E="keys",w="values",T="entries",S=function(){return this};t.exports=function(t,e,n,s,f,g,k){l(n,e,s);var L,x,I,R=function(t){if(t===f&&O)return O;if(!C&&t in P)return P[t];switch(t){case E:case w:case T:return function(){return new n(this,t)}}return function(){return new n(this)}},D=e+" Iterator",B=!1,P=t.prototype,M=P[b]||P["@@iterator"]||f&&P[f],O=!C&&M||R(f),F="Array"==e&&P.entries||M;if(F&&(L=c(F.call(new t)))!==Object.prototype&&L.next&&(o||c(L)===y||(u?u(L,y):a(L[b])||h(L,b,S)),A(L,D,!0,!0),o&&(p[D]=S)),m&&f==w&&M&&M.name!==w&&(!o&&v?d(P,"name",w):(B=!0,O=function(){return i(M,this)})),f)if(x={values:R(w),keys:g?O:R(E),entries:R(T)},k)for(I in x)(C||B||!(I in P))&&h(P,I,x[I]);else r({target:e,proto:!0,forced:C||B},x);return o&&!k||P[b]===O||h(P,b,O,{name:f}),p[e]=O,x}},7235:function(t,e,n){var r=n(857),i=n(2597),o=n(6061),s=n(3070).f;t.exports=function(t){var e=r.Symbol||(r.Symbol={});i(e,t)||s(e,t,{value:o.f(t)})}},9781:function(t,e,n){var r=n(7293);t.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},317:function(t,e,n){var r=n(7854),i=n(111),o=r.document,s=i(o)&&i(o.createElement);t.exports=function(t){return s?o.createElement(t):{}}},3678:function(t){t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8324:function(t){t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},8509:function(t,e,n){var r=n(317)("span").classList,i=r&&r.constructor&&r.constructor.prototype;t.exports=i===Object.prototype?void 0:i},8886:function(t,e,n){var r=n(8113).match(/firefox\/(\d+)/i);t.exports=!!r&&+r[1]},7871:function(t){t.exports="object"==typeof window},256:function(t,e,n){var r=n(8113);t.exports=/MSIE|Trident/.test(r)},1528:function(t,e,n){var r=n(8113),i=n(7854);t.exports=/ipad|iphone|ipod/i.test(r)&&void 0!==i.Pebble},8334:function(t,e,n){var r=n(8113);t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(r)},5268:function(t,e,n){var r=n(4326),i=n(7854);t.exports="process"==r(i.process)},1036:function(t,e,n){var r=n(8113);t.exports=/web0s(?!.*chrome)/i.test(r)},8113:function(t,e,n){var r=n(5005);t.exports=r("navigator","userAgent")||""},7392:function(t,e,n){var r,i,o=n(7854),s=n(8113),a=o.process,l=o.Deno,c=a&&a.versions||l&&l.version,u=c&&c.v8;u&&(i=(r=u.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!i&&s&&(!(r=s.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=s.match(/Chrome\/(\d+)/))&&(i=+r[1]),t.exports=i},8008:function(t,e,n){var r=n(8113).match(/AppleWebKit\/(\d+)\./);t.exports=!!r&&+r[1]},748:function(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2914:function(t,e,n){var r=n(7293),i=n(9114);t.exports=!r((function(){var t=Error("a");return!("stack"in t)||(Object.defineProperty(t,"stack",i(1,7)),7!==t.stack)}))},7762:function(t,e,n){"use strict";var r=n(9781),i=n(7293),o=n(9670),s=n(30),a=n(6277),l=Error.prototype.toString,c=i((function(){if(r){var t=s(Object.defineProperty({},"name",{get:function(){return this===t}}));if("true"!==l.call(t))return!0}return"2: 1"!==l.call({message:1,name:2})||"Error"!==l.call({})}));t.exports=c?function(){var t=o(this),e=a(t.name,"Error"),n=a(t.message);return e?n?e+": "+n:e:n}:l},2109:function(t,e,n){var r=n(7854),i=n(1236).f,o=n(8880),s=n(1320),a=n(3505),l=n(9920),c=n(4705);t.exports=function(t,e){var n,u,A,d,h,f=t.target,p=t.global,g=t.stat;if(n=p?r:g?r[f]||a(f,{}):(r[f]||{}).prototype)for(u in e){if(d=e[u],A=t.noTargetGet?(h=i(n,u))&&h.value:n[u],!c(p?u:f+(g?".":"#")+u,t.forced)&&void 0!==A){if(typeof d==typeof A)continue;l(d,A)}(t.sham||A&&A.sham)&&o(d,"sham",!0),s(n,u,d,t)}}},7293:function(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},7007:function(t,e,n){"use strict";n(4916);var r=n(1702),i=n(1320),o=n(2261),s=n(7293),a=n(5112),l=n(8880),c=a("species"),u=RegExp.prototype;t.exports=function(t,e,n,A){var d=a(t),h=!s((function(){var e={};return e[d]=function(){return 7},7!=""[t](e)})),f=h&&!s((function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[c]=function(){return n},n.flags="",n[d]=/./[d]),n.exec=function(){return e=!0,null},n[d](""),!e}));if(!h||!f||n){var p=r(/./[d]),g=e(d,""[t],(function(t,e,n,i,s){var a=r(t),l=e.exec;return l===o||l===u.exec?h&&!s?{done:!0,value:p(e,n,i)}:{done:!0,value:a(n,e,i)}:{done:!1}}));i(String.prototype,t,g[0]),i(u,d,g[1])}A&&l(u[d],"sham",!0)}},6790:function(t,e,n){"use strict";var r=n(7854),i=n(3157),o=n(6244),s=n(9974),a=r.TypeError,l=function(t,e,n,r,c,u,A,d){for(var h,f,p=c,g=0,m=!!A&&s(A,d);g0&&i(h))f=o(h),p=l(t,e,h,f,p,u-1)-1;else{if(p>=9007199254740991)throw a("Exceed the acceptable array length");t[p]=h}p++}g++}return p};t.exports=l},6677:function(t,e,n){var r=n(7293);t.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},2104:function(t,e,n){var r=n(4374),i=Function.prototype,o=i.apply,s=i.call;t.exports="object"==typeof Reflect&&Reflect.apply||(r?s.bind(o):function(){return s.apply(o,arguments)})},9974:function(t,e,n){var r=n(1702),i=n(9662),o=n(4374),s=r(r.bind);t.exports=function(t,e){return i(t),void 0===e?t:o?s(t,e):function(){return t.apply(e,arguments)}}},4374:function(t,e,n){var r=n(7293);t.exports=!r((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},7065:function(t,e,n){"use strict";var r=n(7854),i=n(1702),o=n(9662),s=n(111),a=n(2597),l=n(206),c=n(4374),u=r.Function,A=i([].concat),d=i([].join),h={},f=function(t,e,n){if(!a(h,e)){for(var r=[],i=0;i]*>)/g,u=/\$([$&'`]|\d{1,2})/g;t.exports=function(t,e,n,r,A,d){var h=n+t.length,f=r.length,p=u;return void 0!==A&&(A=i(A),p=c),a(d,p,(function(i,a){var c;switch(s(a,0)){case"$":return"$";case"&":return t;case"`":return l(e,0,n);case"'":return l(e,h);case"<":c=A[l(a,1,-1)];break;default:var u=+a;if(0===u)return i;if(u>f){var d=o(u/10);return 0===d?i:d<=f?void 0===r[d-1]?s(a,1):r[d-1]+s(a,1):i}c=r[u-1]}return void 0===c?"":c}))}},7854:function(t,e,n){var r=function(t){return t&&t.Math==Math&&t};t.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},2597:function(t,e,n){var r=n(1702),i=n(7908),o=r({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return o(i(t),e)}},3501:function(t){t.exports={}},842:function(t,e,n){var r=n(7854);t.exports=function(t,e){var n=r.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))}},490:function(t,e,n){var r=n(5005);t.exports=r("document","documentElement")},4664:function(t,e,n){var r=n(9781),i=n(7293),o=n(317);t.exports=!r&&!i((function(){return 7!=Object.defineProperty(o("div"),"a",{get:function(){return 7}}).a}))},1179:function(t,e,n){var r=n(7854).Array,i=Math.abs,o=Math.pow,s=Math.floor,a=Math.log,l=Math.LN2;t.exports={pack:function(t,e,n){var c,u,A,d=r(n),h=8*n-e-1,f=(1<>1,g=23===e?o(2,-24)-o(2,-77):0,m=t<0||0===t&&1/t<0?1:0,v=0;for((t=i(t))!=t||t===1/0?(u=t!=t?1:0,c=f):(c=s(a(t)/l),t*(A=o(2,-c))<1&&(c--,A*=2),(t+=c+p>=1?g/A:g*o(2,1-p))*A>=2&&(c++,A/=2),c+p>=f?(u=0,c=f):c+p>=1?(u=(t*A-1)*o(2,e),c+=p):(u=t*o(2,p-1)*o(2,e),c=0));e>=8;)d[v++]=255&u,u/=256,e-=8;for(c=c<0;)d[v++]=255&c,c/=256,h-=8;return d[--v]|=128*m,d},unpack:function(t,e){var n,r=t.length,i=8*r-e-1,s=(1<>1,l=i-7,c=r-1,u=t[c--],A=127&u;for(u>>=7;l>0;)A=256*A+t[c--],l-=8;for(n=A&(1<<-l)-1,A>>=-l,l+=e;l>0;)n=256*n+t[c--],l-=8;if(0===A)A=1-a;else{if(A===s)return n?NaN:u?-1/0:1/0;n+=o(2,e),A-=a}return(u?-1:1)*n*o(2,A-e)}}},8361:function(t,e,n){var r=n(7854),i=n(1702),o=n(7293),s=n(4326),a=r.Object,l=i("".split);t.exports=o((function(){return!a("z").propertyIsEnumerable(0)}))?function(t){return"String"==s(t)?l(t,""):a(t)}:a},9587:function(t,e,n){var r=n(614),i=n(111),o=n(7674);t.exports=function(t,e,n){var s,a;return o&&r(s=e.constructor)&&s!==n&&i(a=s.prototype)&&a!==n.prototype&&o(t,a),t}},2788:function(t,e,n){var r=n(1702),i=n(614),o=n(5465),s=r(Function.toString);i(o.inspectSource)||(o.inspectSource=function(t){return s(t)}),t.exports=o.inspectSource},8340:function(t,e,n){var r=n(111),i=n(8880);t.exports=function(t,e){r(e)&&"cause"in e&&i(t,"cause",e.cause)}},2423:function(t,e,n){var r=n(2109),i=n(1702),o=n(3501),s=n(111),a=n(2597),l=n(3070).f,c=n(8006),u=n(1156),A=n(2050),d=n(9711),h=n(6677),f=!1,p=d("meta"),g=0,m=function(t){l(t,p,{value:{objectID:"O"+g++,weakData:{}}})},v=t.exports={enable:function(){v.enable=function(){},f=!0;var t=c.f,e=i([].splice),n={};n[p]=1,t(n).length&&(c.f=function(n){for(var r=t(n),i=0,o=r.length;iv;v++)if((C=I(t[v]))&&u(g,C))return C;return new p(!1)}r=A(t,m)}for(b=r.next;!(E=o(b,r)).done;){try{C=I(E.value)}catch(t){h(r,"throw",t)}if("object"==typeof C&&C&&u(g,C))return C}return new p(!1)}},9212:function(t,e,n){var r=n(6916),i=n(9670),o=n(8173);t.exports=function(t,e,n){var s,a;i(t);try{if(!(s=o(t,"return"))){if("throw"===e)throw n;return n}s=r(s,t)}catch(t){a=!0,s=t}if("throw"===e)throw n;if(a)throw s;return i(s),n}},3383:function(t,e,n){"use strict";var r,i,o,s=n(7293),a=n(614),l=n(30),c=n(9518),u=n(1320),A=n(5112),d=n(1913),h=A("iterator"),f=!1;[].keys&&("next"in(o=[].keys())?(i=c(c(o)))!==Object.prototype&&(r=i):f=!0),null==r||s((function(){var t={};return r[h].call(t)!==t}))?r={}:d&&(r=l(r)),a(r[h])||u(r,h,(function(){return this})),t.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:f}},7497:function(t){t.exports={}},6244:function(t,e,n){var r=n(7466);t.exports=function(t){return r(t.length)}},6736:function(t){var e=Math.expm1,n=Math.exp;t.exports=!e||e(10)>22025.465794806718||e(10)<22025.465794806718||-2e-17!=e(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:n(t)-1}:e},6130:function(t,e,n){var r=n(4310),i=Math.abs,o=Math.pow,s=o(2,-52),a=o(2,-23),l=o(2,127)*(2-a),c=o(2,-126);t.exports=Math.fround||function(t){var e,n,o=i(t),u=r(t);return ol||n!=n?u*(1/0):u*n}},202:function(t){var e=Math.log,n=Math.LOG10E;t.exports=Math.log10||function(t){return e(t)*n}},6513:function(t){var e=Math.log;t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:e(1+t)}},4310:function(t){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},5948:function(t,e,n){var r,i,o,s,a,l,c,u,A=n(7854),d=n(9974),h=n(1236).f,f=n(261).set,p=n(8334),g=n(1528),m=n(1036),v=n(5268),y=A.MutationObserver||A.WebKitMutationObserver,C=A.document,b=A.process,E=A.Promise,w=h(A,"queueMicrotask"),T=w&&w.value;T||(r=function(){var t,e;for(v&&(t=b.domain)&&t.exit();i;){e=i.fn,i=i.next;try{e()}catch(t){throw i?s():o=void 0,t}}o=void 0,t&&t.enter()},p||v||m||!y||!C?!g&&E&&E.resolve?((c=E.resolve(void 0)).constructor=E,u=d(c.then,c),s=function(){u(r)}):v?s=function(){b.nextTick(r)}:(f=d(f,A),s=function(){f(r)}):(a=!0,l=C.createTextNode(""),new y(r).observe(l,{characterData:!0}),s=function(){l.data=a=!a})),t.exports=T||function(t){var e={fn:t,next:void 0};o&&(o.next=e),i||(i=e,s()),o=e}},3366:function(t,e,n){var r=n(7854);t.exports=r.Promise},133:function(t,e,n){var r=n(7392),i=n(7293);t.exports=!!Object.getOwnPropertySymbols&&!i((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},590:function(t,e,n){var r=n(7293),i=n(5112),o=n(1913),s=i("iterator");t.exports=!r((function(){var t=new URL("b?a=1&b=2&c=3","http://a"),e=t.searchParams,n="";return t.pathname="c%20d",e.forEach((function(t,r){e.delete("b"),n+=r+t})),o&&!t.toJSON||!e.sort||"http://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[s]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))},8536:function(t,e,n){var r=n(7854),i=n(614),o=n(2788),s=r.WeakMap;t.exports=i(s)&&/native code/.test(o(s))},8523:function(t,e,n){"use strict";var r=n(9662),i=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=r(e),this.reject=r(n)};t.exports.f=function(t){return new i(t)}},6277:function(t,e,n){var r=n(1340);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:r(t)}},3929:function(t,e,n){var r=n(7854),i=n(7850),o=r.TypeError;t.exports=function(t){if(i(t))throw o("The method doesn't accept regular expressions");return t}},7023:function(t,e,n){var r=n(7854).isFinite;t.exports=Number.isFinite||function(t){return"number"==typeof t&&r(t)}},2814:function(t,e,n){var r=n(7854),i=n(7293),o=n(1702),s=n(1340),a=n(3111).trim,l=n(1361),c=o("".charAt),u=r.parseFloat,A=r.Symbol,d=A&&A.iterator,h=1/u(l+"-0")!=-1/0||d&&!i((function(){u(Object(d))}));t.exports=h?function(t){var e=a(s(t)),n=u(e);return 0===n&&"-"==c(e,0)?-0:n}:u},3009:function(t,e,n){var r=n(7854),i=n(7293),o=n(1702),s=n(1340),a=n(3111).trim,l=n(1361),c=r.parseInt,u=r.Symbol,A=u&&u.iterator,d=/^[+-]?0x/i,h=o(d.exec),f=8!==c(l+"08")||22!==c(l+"0x16")||A&&!i((function(){c(Object(A))}));t.exports=f?function(t,e){var n=a(s(t));return c(n,e>>>0||(h(d,n)?16:10))}:c},1574:function(t,e,n){"use strict";var r=n(9781),i=n(1702),o=n(6916),s=n(7293),a=n(1956),l=n(5181),c=n(5296),u=n(7908),A=n(8361),d=Object.assign,h=Object.defineProperty,f=i([].concat);t.exports=!d||s((function(){if(r&&1!==d({b:1},d(h({},"a",{enumerable:!0,get:function(){h(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),i="abcdefghijklmnopqrst";return t[n]=7,i.split("").forEach((function(t){e[t]=t})),7!=d({},t)[n]||a(d({},e)).join("")!=i}))?function(t,e){for(var n=u(t),i=arguments.length,s=1,d=l.f,h=c.f;i>s;)for(var p,g=A(arguments[s++]),m=d?f(a(g),d(g)):a(g),v=m.length,y=0;v>y;)p=m[y++],r&&!o(h,g,p)||(n[p]=g[p]);return n}:d},30:function(t,e,n){var r,i=n(9670),o=n(6048),s=n(748),a=n(3501),l=n(490),c=n(317),u=n(6200)("IE_PROTO"),A=function(){},d=function(t){return" - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
-
-
- - -
- -
-
-
-
-
- - - {{playerMessage}} - -
-
-
- -
-
-
- -
-
- -
    -
  • -
    Sources
    - OvenPlayer - {{playerVersion}} - -
  • -
    -

    Test streams with OvenPlayer

    - -
      -
    • - Sub-Second Latency: WebRTC (Signalling Protocol Conforms to the OME - Specification) -
    • -
    • - Low-Latency HLS -
    • -
    -

    To play the stream of OvenMediaEngine, please refer to the following - documents.

    - -
    - - -
-
-
- -
-
-
    -
  • -
    Player Options
    -
  • -
  • - -
    -
    - -
    General Options
    -
    -
    - - - - - -
    -
    - - - - - -
    -
    - - - - - -
    -
    -
    -
    - -
    WebRTC Options
    -
    -
    - - - - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - - - - -
    -
    - - -
    -
    -
    -
    - -
    HLS Options
    -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - -
    -
    - FairPlay -
    -
    - - -
    -
    - - -
    -
    - Widevine -
    -
    - - -
    -
    -
    -
    -
  • -
  • -
    Demo Options
    -
  • -
  • -
    -
    -
    Reload the player when error occurred
    -
    -
    - - -
    -
    - - -
    -
    -
    -
    -
  • -
-
-
-
    -
  • -
    Usage
    -
  • -
  • -
    -
    - -
  • -
-
-
-
    -
  • -
    Export permanent link
    -
  • -
  • - -
    -
    - -
    - -
    - -
  • -
-
-
-
-
-
-
-
-
-
-
- AirenSoft -
-

- Media Technology Expert Group -

-

- Our mission is to build a powerful media world by making it easier for everyone to - use all the complex and demanding media technologies of the world. -

-
- -
- -
-
OPEN SOURCE PROJECTS
-

- OvenMediaEngine -

-

- OvenPlayer -

-

- OvenLiveKit-Web -

-

- OvenSpace -

-
- -
- -
-
Contact
-

#1203, Twenty First Valley, 157, Yangpyeong-ro, - Yeongdeungpo-gu, Seoul, 07207 Republic of Korea

-

contact@airensoft.com

-

+82-2-6378-5227

-
-
- -
- -
- -
-
-
-
- © 2022 Copyright: - AirenSoft - Co., Ltd. All rights reserved. -
-
- -
- - - - - - - - - - - -
-
-
-
-
-
-
- - - - - - - - - - - diff --git a/dist/ovenplayer.js b/dist/ovenplayer.js index bfaf0053..4fa01624 100644 --- a/dist/ovenplayer.js +++ b/dist/ovenplayer.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.OvenPlayer=e():t.OvenPlayer=e()}(self,(function(){return function(){var t={2950:function(t,e,n){"use strict";n.d(e,{default:function(){return rc}});var r="0.10.31",i=n(741),o=n.n(i);function s(t){return t?t.replace(/^\s+|\s+$/g,""):""}var a=function(t){if(!t||"rtmp"==t.substr(0,4))return"";var e=function(t){var e="";return/[(,]format=mpd-/i.test(t)?e="mpd":/[(,]format=m3u8-/i.test(t)&&(e="m3u8"),e}(t);return e||((t=t.split("?")[0].split("#")[0]).lastIndexOf(".")>-1?t.substr(t.lastIndexOf(".")+1,t.length).toLowerCase():"")};function l(t){var e=parseInt(t,10);if(!t)return"00:00";var n=Math.floor(e/3600),r=Math.floor((e-3600*n)/60),i=e-3600*n-60*r;return r<10&&(r="0"+r),i<10&&(i="0"+i),n>0?n+":"+r+":"+i:r+":"+i}function c(t,e){if(!t)return 0;if(o().isNumber(t)&&!o().isNaN(t))return t;var n=(t=t.replace(",",".")).split(":"),r=n.length,i=0;if("s"===t.slice(-1))i=parseFloat(t);else if("m"===t.slice(-1))i=60*parseFloat(t);else if("h"===t.slice(-1))i=3600*parseFloat(t);else if(r>1){var s=r-1;4===r&&(e&&(i=parseFloat(n[s])/e),s-=1),i+=parseFloat(n[s]),i+=60*parseFloat(n[s-1]),r>=3&&(i+=3600*parseFloat(n[s-2]))}else i=parseFloat(t);return o().isNaN(i)?0:i}function u(t){var e={},n=t.split("\r\n");1===n.length&&(n=t.split("\n"));var r=1;if(n[0].indexOf(" --\x3e ")>0&&(r=0),n.length>r+1&&n[r+1]){var i=n[r],o=i.indexOf(" --\x3e ");o>0&&(e.start=c(i.substr(0,o)),e.end=c(i.substr(o+5)),e.text=n.slice(r+1).join("\r\n"))}return e}var A=window.VTTCue,d={"":!0,lr:!0,rl:!0},h={start:!0,middle:!0,end:!0,left:!0,right:!0};function f(t){return"string"==typeof t&&!!h[t.toLowerCase()]&&t.toLowerCase()}function p(t){for(var e=1;e100)throw new Error("Position must be between 0 and 100.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(r,"positionAlign",p({},o,{get:function(){return C},set:function(t){var e=f(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");C=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"size",p({},o,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(r,"align",p({},o,{get:function(){return E},set:function(t){var e=f(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),r.displayState=void 0,i)return r}).prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)});var g=A,m={"":!0,up:!0};function v(t){return"number"==typeof t&&t>=0&&t<=100}var y=function(){var t=100,e=3,n=0,r=100,i=0,o=100,s="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return t},set:function(e){if(!v(e))throw new Error("Width must be between 0 and 100.");t=e}},lines:{enumerable:!0,get:function(){return e},set:function(t){if("number"!=typeof t)throw new TypeError("Lines must be set to a number.");e=t}},regionAnchorY:{enumerable:!0,get:function(){return r},set:function(t){if(!v(t))throw new Error("RegionAnchorX must be between 0 and 100.");r=t}},regionAnchorX:{enumerable:!0,get:function(){return n},set:function(t){if(!v(t))throw new Error("RegionAnchorY must be between 0 and 100.");n=t}},viewportAnchorY:{enumerable:!0,get:function(){return o},set:function(t){if(!v(t))throw new Error("ViewportAnchorY must be between 0 and 100.");o=t}},viewportAnchorX:{enumerable:!0,get:function(){return i},set:function(t){if(!v(t))throw new Error("ViewportAnchorX must be between 0 and 100.");i=t}},scroll:{enumerable:!0,get:function(){return s},set:function(t){var e=function(t){return"string"==typeof t&&!!m[t.toLowerCase()]&&t.toLowerCase()}(t);if(!1===e)throw new SyntaxError("An invalid or illegal string was specified.");s=e}}})},C=function(){};function b(t,e){return void 0===e&&(e=1),"rgba("+[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16),e].join(",")+")"}var E=1;function w(t,e,n){switch(n){case"webvtt.font.color":case"webvtt.font.opacity":var r=Services.prefs.getCharPref("webvtt.font.color"),i=Services.prefs.getIntPref("webvtt.font.opacity")/100;T.fontSet=b(r,i);break;case"webvtt.font.scale":E=Services.prefs.getIntPref("webvtt.font.scale")/100;break;case"webvtt.bg.color":case"webvtt.bg.opacity":var o=Services.prefs.getCharPref("webvtt.bg.color"),s=Services.prefs.getIntPref("webvtt.bg.opacity")/100;T.backgroundSet=b(o,s);break;case"webvtt.edge.color":case"webvtt.edge.type":var a=Services.prefs.getIntPref("webvtt.edge.type"),l=Services.prefs.getCharPref("webvtt.edge.color");T.edgeSet=["","0px 0px ","4px 4px 4px ","-2px -2px ","2px 2px "][a]+b(l)}}if("undefined"!=typeof Services){var T={};["webvtt.font.color","webvtt.font.opacity","webvtt.font.scale","webvtt.bg.color","webvtt.bg.opacity","webvtt.edge.color","webvtt.edge.type"].forEach((function(t){w(0,0,t),Services.prefs.addObserver(t,w,!1)}))}var S=Object.create||function(){function t(){}return function(e){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return t.prototype=e,new t}}();function k(t,e){this.name="ParsingError",this.code=t.code,this.message=e||t.message}function L(t){function e(t,e,n,r){return 3600*(0|t)+60*(0|e)+(0|n)+(0|r)/1e3}var n=t.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return n?n[3]?e(n[1],n[2],n[3].replace(":",""),n[4]):n[1]>59?e(n[1],n[2],0,n[4]):e(0,n[1],n[2],n[4]):null}function x(){this.values=S(null)}function I(t,e,n,r){var i=r?t.split(r):[t];for(var o in i)if("string"==typeof i[o]){var s=i[o].split(n);2===s.length&&e(s[0],s[1])}}function R(t,e,n){var r=t;function i(){var e=L(t);if(null===e)throw new k(k.Errors.BadTimeStamp,"Malformed timestamp: "+r);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function o(){t=t.replace(/^\s+/,"")}if(o(),e.startTime=i(),o(),"--\x3e"!==t.substr(0,3))throw new k(k.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);t=t.substr(3),o(),e.endTime=i(),o(),function(t,e){var r=new x;I(t,(function(t,e){switch(t){case"region":for(var i=n.length-1;i>=0;i--)if(n[i].id===e){r.set(t,n[i].region);break}break;case"vertical":r.alt(t,e,["rl","lr"]);break;case"line":var o=e.split(","),s=o[0];r.integer(t,s),r.percent(t,s)&&r.set("snapToLines",!1),r.alt(t,s,["auto"]),2===o.length&&r.alt("lineAlign",o[1],["start","middle","end"]);break;case"position":o=e.split(","),r.percent(t,o[0]),2===o.length&&r.alt("positionAlign",o[1],["start","middle","end"]);break;case"size":r.percent(t,e);break;case"align":r.alt(t,e,["start","middle","end","left","right"])}}),/:/,/\s/)}(t)}k.prototype=S(Error.prototype),k.prototype.constructor=k,k.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},x.prototype={set:function(t,e){this.get(t)||""===e||(this.values[t]=e)},get:function(t,e,n){return n?this.has(t)?this.values[t]:e[n]:this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,n){for(var r=0;r=0&&e<=100)&&(this.set(t,e),!0)}};var D={"&":"&","<":"<",">":">","‎":"‎","‏":"‏"," ":" "},B={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},P={v:"title",lang:"lang"},M={rt:"ruby"};function O(t,e){function n(){if(!e)return null;var t,n=e.match(/^([^<]*)(<[^>]+>?)?/);return t=n[1]?n[1]:n[2],e=e.substr(t.length),t}function r(t){return D[t]}function i(t){for(;h=t.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)t=t.replace(h[0],r);return t}function o(t,e){return!M[e.localName]||M[e.localName]===t.localName}function s(e,n){var r=B[e];if(!r)return null;var i=t.document.createElement(r);i.localName=r;var o=P[e];return o&&n&&(i[o]=n.trim()),i}for(var a,l=t.document.createElement("div"),c=l,u=[];null!==(a=n());)if("<"!==a[0])c.appendChild(t.document.createTextNode(i(a)));else{if("/"===a[1]){u.length&&u[u.length-1]===a.substr(2).replace(">","")&&(u.pop(),c=c.parentNode);continue}var A,d=L(a.substr(1,a.length-2));if(d){A=t.document.createProcessingInstruction("timestamp",d),c.appendChild(A);continue}var h=a.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!h)continue;if(!(A=s(h[1],h[3])))continue;if(!o(c,A))continue;h[2]&&(A.className=h[2].substr(1).replace("."," ")),u.push(h[1]),c.appendChild(A),c=A}return l}var F=[1470,1472,1475,1478,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1520,1521,1522,1523,1524,1544,1547,1549,1563,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1645,1646,1647,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1765,1766,1774,1775,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1807,1808,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1969,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2e3,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2036,2037,2042,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2074,2084,2088,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2142,2208,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,8207,64285,64287,64288,64289,64290,64291,64292,64293,64294,64295,64296,64298,64299,64300,64301,64302,64303,64304,64305,64306,64307,64308,64309,64310,64312,64313,64314,64315,64316,64318,64320,64321,64323,64324,64326,64327,64328,64329,64330,64331,64332,64333,64334,64335,64336,64337,64338,64339,64340,64341,64342,64343,64344,64345,64346,64347,64348,64349,64350,64351,64352,64353,64354,64355,64356,64357,64358,64359,64360,64361,64362,64363,64364,64365,64366,64367,64368,64369,64370,64371,64372,64373,64374,64375,64376,64377,64378,64379,64380,64381,64382,64383,64384,64385,64386,64387,64388,64389,64390,64391,64392,64393,64394,64395,64396,64397,64398,64399,64400,64401,64402,64403,64404,64405,64406,64407,64408,64409,64410,64411,64412,64413,64414,64415,64416,64417,64418,64419,64420,64421,64422,64423,64424,64425,64426,64427,64428,64429,64430,64431,64432,64433,64434,64435,64436,64437,64438,64439,64440,64441,64442,64443,64444,64445,64446,64447,64448,64449,64467,64468,64469,64470,64471,64472,64473,64474,64475,64476,64477,64478,64479,64480,64481,64482,64483,64484,64485,64486,64487,64488,64489,64490,64491,64492,64493,64494,64495,64496,64497,64498,64499,64500,64501,64502,64503,64504,64505,64506,64507,64508,64509,64510,64511,64512,64513,64514,64515,64516,64517,64518,64519,64520,64521,64522,64523,64524,64525,64526,64527,64528,64529,64530,64531,64532,64533,64534,64535,64536,64537,64538,64539,64540,64541,64542,64543,64544,64545,64546,64547,64548,64549,64550,64551,64552,64553,64554,64555,64556,64557,64558,64559,64560,64561,64562,64563,64564,64565,64566,64567,64568,64569,64570,64571,64572,64573,64574,64575,64576,64577,64578,64579,64580,64581,64582,64583,64584,64585,64586,64587,64588,64589,64590,64591,64592,64593,64594,64595,64596,64597,64598,64599,64600,64601,64602,64603,64604,64605,64606,64607,64608,64609,64610,64611,64612,64613,64614,64615,64616,64617,64618,64619,64620,64621,64622,64623,64624,64625,64626,64627,64628,64629,64630,64631,64632,64633,64634,64635,64636,64637,64638,64639,64640,64641,64642,64643,64644,64645,64646,64647,64648,64649,64650,64651,64652,64653,64654,64655,64656,64657,64658,64659,64660,64661,64662,64663,64664,64665,64666,64667,64668,64669,64670,64671,64672,64673,64674,64675,64676,64677,64678,64679,64680,64681,64682,64683,64684,64685,64686,64687,64688,64689,64690,64691,64692,64693,64694,64695,64696,64697,64698,64699,64700,64701,64702,64703,64704,64705,64706,64707,64708,64709,64710,64711,64712,64713,64714,64715,64716,64717,64718,64719,64720,64721,64722,64723,64724,64725,64726,64727,64728,64729,64730,64731,64732,64733,64734,64735,64736,64737,64738,64739,64740,64741,64742,64743,64744,64745,64746,64747,64748,64749,64750,64751,64752,64753,64754,64755,64756,64757,64758,64759,64760,64761,64762,64763,64764,64765,64766,64767,64768,64769,64770,64771,64772,64773,64774,64775,64776,64777,64778,64779,64780,64781,64782,64783,64784,64785,64786,64787,64788,64789,64790,64791,64792,64793,64794,64795,64796,64797,64798,64799,64800,64801,64802,64803,64804,64805,64806,64807,64808,64809,64810,64811,64812,64813,64814,64815,64816,64817,64818,64819,64820,64821,64822,64823,64824,64825,64826,64827,64828,64829,64848,64849,64850,64851,64852,64853,64854,64855,64856,64857,64858,64859,64860,64861,64862,64863,64864,64865,64866,64867,64868,64869,64870,64871,64872,64873,64874,64875,64876,64877,64878,64879,64880,64881,64882,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64894,64895,64896,64897,64898,64899,64900,64901,64902,64903,64904,64905,64906,64907,64908,64909,64910,64911,64914,64915,64916,64917,64918,64919,64920,64921,64922,64923,64924,64925,64926,64927,64928,64929,64930,64931,64932,64933,64934,64935,64936,64937,64938,64939,64940,64941,64942,64943,64944,64945,64946,64947,64948,64949,64950,64951,64952,64953,64954,64955,64956,64957,64958,64959,64960,64961,64962,64963,64964,64965,64966,64967,65008,65009,65010,65011,65012,65013,65014,65015,65016,65017,65018,65019,65020,65136,65137,65138,65139,65140,65142,65143,65144,65145,65146,65147,65148,65149,65150,65151,65152,65153,65154,65155,65156,65157,65158,65159,65160,65161,65162,65163,65164,65165,65166,65167,65168,65169,65170,65171,65172,65173,65174,65175,65176,65177,65178,65179,65180,65181,65182,65183,65184,65185,65186,65187,65188,65189,65190,65191,65192,65193,65194,65195,65196,65197,65198,65199,65200,65201,65202,65203,65204,65205,65206,65207,65208,65209,65210,65211,65212,65213,65214,65215,65216,65217,65218,65219,65220,65221,65222,65223,65224,65225,65226,65227,65228,65229,65230,65231,65232,65233,65234,65235,65236,65237,65238,65239,65240,65241,65242,65243,65244,65245,65246,65247,65248,65249,65250,65251,65252,65253,65254,65255,65256,65257,65258,65259,65260,65261,65262,65263,65264,65265,65266,65267,65268,65269,65270,65271,65272,65273,65274,65275,65276,67584,67585,67586,67587,67588,67589,67592,67594,67595,67596,67597,67598,67599,67600,67601,67602,67603,67604,67605,67606,67607,67608,67609,67610,67611,67612,67613,67614,67615,67616,67617,67618,67619,67620,67621,67622,67623,67624,67625,67626,67627,67628,67629,67630,67631,67632,67633,67634,67635,67636,67637,67639,67640,67644,67647,67648,67649,67650,67651,67652,67653,67654,67655,67656,67657,67658,67659,67660,67661,67662,67663,67664,67665,67666,67667,67668,67669,67671,67672,67673,67674,67675,67676,67677,67678,67679,67840,67841,67842,67843,67844,67845,67846,67847,67848,67849,67850,67851,67852,67853,67854,67855,67856,67857,67858,67859,67860,67861,67862,67863,67864,67865,67866,67867,67872,67873,67874,67875,67876,67877,67878,67879,67880,67881,67882,67883,67884,67885,67886,67887,67888,67889,67890,67891,67892,67893,67894,67895,67896,67897,67903,67968,67969,67970,67971,67972,67973,67974,67975,67976,67977,67978,67979,67980,67981,67982,67983,67984,67985,67986,67987,67988,67989,67990,67991,67992,67993,67994,67995,67996,67997,67998,67999,68e3,68001,68002,68003,68004,68005,68006,68007,68008,68009,68010,68011,68012,68013,68014,68015,68016,68017,68018,68019,68020,68021,68022,68023,68030,68031,68096,68112,68113,68114,68115,68117,68118,68119,68121,68122,68123,68124,68125,68126,68127,68128,68129,68130,68131,68132,68133,68134,68135,68136,68137,68138,68139,68140,68141,68142,68143,68144,68145,68146,68147,68160,68161,68162,68163,68164,68165,68166,68167,68176,68177,68178,68179,68180,68181,68182,68183,68184,68192,68193,68194,68195,68196,68197,68198,68199,68200,68201,68202,68203,68204,68205,68206,68207,68208,68209,68210,68211,68212,68213,68214,68215,68216,68217,68218,68219,68220,68221,68222,68223,68352,68353,68354,68355,68356,68357,68358,68359,68360,68361,68362,68363,68364,68365,68366,68367,68368,68369,68370,68371,68372,68373,68374,68375,68376,68377,68378,68379,68380,68381,68382,68383,68384,68385,68386,68387,68388,68389,68390,68391,68392,68393,68394,68395,68396,68397,68398,68399,68400,68401,68402,68403,68404,68405,68416,68417,68418,68419,68420,68421,68422,68423,68424,68425,68426,68427,68428,68429,68430,68431,68432,68433,68434,68435,68436,68437,68440,68441,68442,68443,68444,68445,68446,68447,68448,68449,68450,68451,68452,68453,68454,68455,68456,68457,68458,68459,68460,68461,68462,68463,68464,68465,68466,68472,68473,68474,68475,68476,68477,68478,68479,68608,68609,68610,68611,68612,68613,68614,68615,68616,68617,68618,68619,68620,68621,68622,68623,68624,68625,68626,68627,68628,68629,68630,68631,68632,68633,68634,68635,68636,68637,68638,68639,68640,68641,68642,68643,68644,68645,68646,68647,68648,68649,68650,68651,68652,68653,68654,68655,68656,68657,68658,68659,68660,68661,68662,68663,68664,68665,68666,68667,68668,68669,68670,68671,68672,68673,68674,68675,68676,68677,68678,68679,68680,126464,126465,126466,126467,126469,126470,126471,126472,126473,126474,126475,126476,126477,126478,126479,126480,126481,126482,126483,126484,126485,126486,126487,126488,126489,126490,126491,126492,126493,126494,126495,126497,126498,126500,126503,126505,126506,126507,126508,126509,126510,126511,126512,126513,126514,126516,126517,126518,126519,126521,126523,126530,126535,126537,126539,126541,126542,126543,126545,126546,126548,126551,126553,126555,126557,126559,126561,126562,126564,126567,126568,126569,126570,126572,126573,126574,126575,126576,126577,126578,126580,126581,126582,126583,126585,126586,126587,126588,126590,126592,126593,126594,126595,126596,126597,126598,126599,126600,126601,126603,126604,126605,126606,126607,126608,126609,126610,126611,126612,126613,126614,126615,126616,126617,126618,126619,126625,126626,126627,126629,126630,126631,126632,126633,126635,126636,126637,126638,126639,126640,126641,126642,126643,126644,126645,126646,126647,126648,126649,126650,126651,1114109];function _(){}function N(t,e,n){var r="undefined"!=typeof navigator&&/MSIE\s8\.0/.test(navigator.userAgent),i="rgba(255, 255, 255, 1)",o="rgba(0, 0, 0, 0.8)",s="";void 0!==T&&(i=T.fontSet,o=T.backgroundSet,s=T.edgeSet),r&&(i="rgb(255, 255, 255)",o="rgb(0, 0, 0)"),_.call(this),this.cue=e,this.cueDiv=O(t,e.text);var a={color:i,backgroundColor:o,textShadow:s,position:"relative",left:0,right:0,top:0,bottom:0,display:"inline"};r||(a.writingMode=""===e.vertical?"horizontal-tb":"lr"===e.vertical?"vertical-lr":"vertical-rl",a.unicodeBidi="plaintext"),this.applyStyles(a,this.cueDiv),this.div=t.document.createElement("div"),a={textAlign:"middle"===e.align?"center":e.align,font:n.font,whiteSpace:"pre-line",position:"absolute"},r||(a.direction=function(t){var e,n=[],r="";if(!t||!t.childNodes)return"ltr";function i(t,e){for(var n=e.childNodes.length-1;n>=0;n--)t.push(e.childNodes[n])}function o(t){if(!t||!t.length)return null;var e=t.pop(),n=e.textContent||e.innerText;if(n){var r=n.match(/^.*(\n|\r)/);return r?(t.length=0,r[0]):n}return"ruby"===e.tagName?o(t):e.childNodes?(i(t,e),o(t)):void 0}for(i(n,t);r=o(n);)for(var s=0;s=0&&t.line<=100))return t.line;if(!t.track||!t.track.textTrackList||!t.track.textTrackList.mediaElement)return-1;for(var e=t.track,n=e.textTrackList,r=0,i=0;iA&&(u=u<0?-1:1,u*=Math.ceil(A/c)*c),s<0&&(u+=""===o.vertical?n.height:n.width,a=a.reverse()),i.move(d,u)}else{var h=i.lineHeight/n.height*100;switch(o.lineAlign){case"middle":s-=h/2;break;case"end":s-=h}switch(o.vertical){case"":e.applyStyles({top:e.formatStyle(s,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(s,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(s,"%")})}a=["+y","-x","+x","-y"],i=new U(e)}var f=function(t,e){for(var i,o=new U(t),s=1,a=0;al&&(i=new U(t),s=l),t=new U(o)}return i||o}(i,a);e.move(f.toCSSCompatValues(n))}_.prototype.applyStyles=function(t,e){for(var n in e=e||this.div,t)t.hasOwnProperty(n)&&(e.style[n]=t[n])},_.prototype.formatStyle=function(t,e){return 0===t?0:t+e},N.prototype=S(_.prototype),N.prototype.constructor=N,U.prototype.move=function(t,e){switch(e=void 0!==e?e:this.lineHeight,t){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e}},U.prototype.overlaps=function(t){return this.leftt.left&&this.topt.top},U.prototype.overlapsAny=function(t){for(var e=0;e=t.top&&this.bottom<=t.bottom&&this.left>=t.left&&this.right<=t.right},U.prototype.overlapsOppositeAxis=function(t,e){switch(e){case"+x":return this.leftt.right;case"+y":return this.topt.bottom}},U.prototype.intersectPercentage=function(t){return Math.max(0,Math.min(this.right,t.right)-Math.max(this.left,t.left))*Math.max(0,Math.min(this.bottom,t.bottom)-Math.max(this.top,t.top))/(this.height*this.width)},U.prototype.toCSSCompatValues=function(t){return{top:this.top-t.top,bottom:t.bottom-this.bottom,left:this.left-t.left,right:t.right-this.right,height:this.height,width:this.width}},U.getSimpleBoxPosition=function(t){var e=t.div?t.div.offsetHeight:t.tagName?t.offsetHeight:0,n=t.div?t.div.offsetWidth:t.tagName?t.offsetWidth:0,r=t.div?t.div.offsetTop:t.tagName?t.offsetTop:0;return{left:(t=t.div?t.div.getBoundingClientRect():t.tagName?t.getBoundingClientRect():t).left,right:t.right,top:t.top||r,height:t.height||e,bottom:t.bottom||r+(t.height||e),width:t.width||n}},C.StringDecoder=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}},C.convertCueToDOMTree=function(t,e){return t&&e?O(t,e):null},C.processCues=function(t,e,n){if(!t||!e||!n)return null;for(;n.firstChild;)n.removeChild(n.firstChild);var r=t.document.createElement("div");if(r.style.position="absolute",r.style.left="0",r.style.right="0",r.style.top="0",r.style.bottom="0",r.style.margin="1.5%",n.appendChild(r),function(t){for(var e=0;e]*<[a-z]*/g,K=/]+?start[^=]*=[^0-9]*([0-9]*)["^0-9"]*/i,V=/]*>/gi,z=function(t,e){return e=(((e||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join(""),t.replace(/|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(function(t,n){return e.indexOf("<"+n.toLowerCase()+">")>-1?t:""}))},$=function(t){return t.sort((function(t,e){var n;return 0==(n=t.start-e.start)?t.end-e.end:n}))},X=function(){var t={},e=function(t){return t.map((function(t){return new g(t.start,t.end,t.text)}))};return t.load=function(t,n,r,i){fetch(t.file).then((function(t){t.ok?t.text().then((function(t){var i=[],o=[];if(t.indexOf("WEBVTT")>=0){OvenPlayerConsole.log("WEBVTT LOADED");var a=new G.Parser(window,G.StringDecoder());o=[],a.oncue=function(t){o.push(t)},a.onflush=function(){r(o)},a.parse(t)}else if(t.indexOf("SAMI")>=0){OvenPlayerConsole.log("SAMI LOADED");var l=function(t,e){var n,r,i,o,s,a,l,c,u,A;if(l=function(){var e,n,r,s,l,c,u,d,h,f,p,g,m,v,y,C;for(n=function(t){var n;return(n=new Error(t)).line=u,n.context=e,i.push(n)},u=1,h=[],m={},g=t;f=g.search(),!(d<=0||f<0);)d=g.slice(f+1).search(Y)+1,e=d>0?g.slice(f,f+d):g.slice(f),u+=(null!=(v=g.slice(0,f).match(j))?v.length:void 0)||0,H.test(e)&&n("ERROR_BROKEN_TAGS"),g=g.slice(f+d),(null===(p=+(null!=(y=e.match(K))?parseFloat(y[1]/1e3):void 0))||p<0)&&n("ERROR_INVALID_TIME"),(l=o(e))||n("ERROR_INVALID_LANGUAGE"),u+=(null!=(C=e.match(j))?C.length:void 0)||0,e=(e=e.replace(j,"")).replace(V,"\n"),s={start:p,text:"",contents:r=z(e).trim()},l&&(s.text=r),m[l]||(m[l]=[]),s.start&&m[l].push(s);A=A||function(){var t,e,n=window.navigator,r=["language","browserLanguage","systemLanguage","userLanguage"];if(Array.isArray(n.languages))for(t=0;t0&&(c=b.indexOf(A)>-1?m[A]:m[b.filter((function(t){return"undefined"!==t}))[0]],c=$(c),c=a(c),h=h.concat(c)),$(h)},o=function(t){var e,r;if(t)for(e in n)if((r=n[e]).reClassName.test(t))return r.lang},a=function(t){var e,n,i;for(e=t.length;e--;)n=t[e],null!=(i=t[e-1])&&(i.end=n.start),n.contents&&" "!==n.contents?(delete t[e].contents,n.end||(n.end=n.start+r)):t.splice(e,1);return t},i=[],n={KRCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KRCC)['\"S]?","i")},KOCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KOCC)['\"S]?","i")},KR:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KR)['\"S]?","i")},ENCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(ENCC)['\"S]?","i")},EGCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EGCC)['\"S]?","i")},EN:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EN)['\"S]?","i")},JPCC:{lang:"ja",reClassName:new RegExp("class[^=]*?=[\"'S]*(JPCC)['\"S]?","i")}},null!=e?e.definedLangs:void 0)for(s in u=e.definedLangs)c=u[s],n[s]=c;return r=(null!=e?e.duration:void 0)||10,A=e.fixedLang,t=t.trim(),{result:l(),errors:i}}(t,{fixedLang:n});o=e(l.result),r(o)}else OvenPlayerConsole.log("SRT LOADED"),i=function(t){var e=[],n=(t=s(t)).split("\r\n\r\n");1===n.length&&(n=t.split("\n\n"));for(var r=0;rGet Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Can not load due to dash.js. Please use the latest dash.js.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Error initializing DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Error initializing HLS.",reason:"Error initializing HLS."},300:{code:300,message:"Can not play due to unknown reasons.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Fetching process aborted by user.",reason:"Fetching process aborted by user."},302:{code:302,message:"Some of the media could not be downloaded due to a network error.",reason:"Error occurred when downloading."},303:{code:303,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"Error occurred when decoding."},304:{code:304,message:"Media playback has been canceled. It looks like your media is corrupted or your browser does not support the features your media uses.",reason:"Media playback not supported."},305:{code:305,message:"Can not load captions due to unknown reasons.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server refused the request."},308:{code:308,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server do not accept the request."},501:{code:501,message:"Connection with low-latency(OME) server failed.",reason:"WebSocket connection failed."},502:{code:502,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC internal error."},510:{code:510,message:"Network connection is unstable. Check the network connection.",reason:"Network is slow."},511:{code:511,message:"Connection with low-latency(OME) terminated unexpectedly.",reason:"Unexpected end of connection."},512:{code:512,message:"Connection with low-latency(OME) server failed.",reason:"Connection timeout."}}}},{lang:"ko",ui:{context:"오븐플레이어에 관하여",controls:{live:"라이브",low_latency_live:"초저지연 라이브",low_latency_p2p:"초저지연 P2P"},playlist:"플레이리스트",setting:{title:"설정",speed:"재생 속도",speedUnit:"x",source:"소스",quality:"품질",audioTrack:"오디오",caption:"자막",display:"표시"}},api:{message:{muted_play:"눌러서 소리 켜기"},error:{100:{code:100,message:"알 수 없는 이유로 로드 할 수 없습니다.",reason:"알 수 없는 이유로 로드 할 수 없습니다."},101:{code:101,message:"지원되는 미디어를 찾지 못해 로드 할 수 없습니다.",reason:"Can not load due to playable media not found."},102:{code:102,message:"플레시 로드가 중단 되었습니다.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"DashJS로 인해 로드 할 수 없습니다. 최신 dash.js를 사용해 주세요.",reason:"dash.js version is old."},104:{code:104,message:"Google IMA 라이브러리가 없어 로드 할 수 없습니다.",reason:"Please check the google ima library."},105:{code:105,message:"DASH 초기화 중 오류가 발생했습니다.",reason:"Error initializing DASH."},106:{code:106,message:"HLS 초기화 중 오류가 발생했습니다.",reason:"Error initializing HLS."},300:{code:300,message:"알 수 없는 이유로 재생할 수 없습니다.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"사용자에 의한 프로세스 중단.",reason:"Fetching process aborted by user."},302:{code:302,message:"네트워크 오류로 인해 일부 미디어를 다운로드 할 수 없습니다.",reason:"Error occurred when downloading."},303:{code:303,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"Error occurred when decoding."},304:{code:304,message:"미디어 재생이 취소되었습니다. 미디어가 손상되었거나 브라우저가 미디어에서 사용하는 기능을 지원하지 않는 것 같습니다.",reason:"Media playback not supported."},305:{code:305,message:"알 수 없는 이유로 자막을 로드 할 수 없습니다.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server cannot or will not process the request."},307:{code:307,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server refused the request."},308:{code:308,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server do not accept the request."},501:{code:501,message:"웹소켓 연결 실패",reason:"WebSocket connection failed."},502:{code:502,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC internal error."},510:{code:510,message:"네트워크 연결이 불안정합니다. 네트워크 연결을 확인하십시오.",reason:"Network is slow."},511:{code:511,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Unexpected end of connection."},512:{code:512,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Connection timeout."}}}},{lang:"pl",ui:{context:"O OvenPlayer",controls:{live:"Transmisja na żywo",low_latency_live:"Transmisja z niskim opóźnieniem",low_latency_p2p:"Transmisja z niskim opóźnieniem P2P"},playlist:"Playlista",setting:{title:"Ustawienia",speed:"Prędkość",speedUnit:"x",source:"Źrodło",quality:"Jakość",audioTrack:"Audio",caption:"Podtytuł",display:"Wyświetlacz"}},api:{message:{muted_play:"Naciśnij tutaj, aby aktywować dźwięk"},error:{100:{code:100,message:"Nie można załadować z nieznanego powodu.",reason:"Can not load due to unknown reasons."},101:{code:101,message:"Nie można załadować, ponieważ nie znaleziono multimediów, który można odtworzyć.",reason:"Can not load due to playable media not found."},102:{code:102,message:"Flash fetching process aborted.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Nie można załadować, ponieważ wersja dash.js jest za stara.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Nie można załadować, nie znaleziono DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Nie można załadować, nie znaleziono hlsjs.",reason:"Error initializing HLS"},300:{code:300,message:"Nie można odtworzyć z nieznanego powodu.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Proces pobierania przerwany przez użytkownika.",reason:"Fetching process aborted by user."},302:{code:302,message:"Nie udało się pobrać niektórych multimediów z powodu błędu sieci.",reason:"Error occurred when downloading."},303:{code:303,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"Error occurred when decoding."},304:{code:304,message:"Odtwarzanie zostało anulowane. Wygląda na to, że plik jest uszkodzony lub Twoja przeglądarka nie obsługuje tego pliku.",reason:"Media playback not supported."},305:{code:305,message:"Nie można wczytać napisów z nieznanego powodu.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server refused the request."},308:{code:308,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server do not accept the request."},501:{code:501,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebSocket connection failed."},502:{code:502,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC internal error."},510:{code:510,message:"Połączenie sieciowe jest niestabilne. Sprawdź swoją sieć.",reason:"Network is slow."},511:{code:511,message:"Połączenie z serwerem niskiego opóźnienia (OME) nieoczekiwanie zakończone.",reason:"Unexpected end of connection."},512:{code:512,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"Connection timeout."}}}}],Wt=function(t){return"subtitles"===t||"captions"===t},Yt=function(t){var e=t,n=[],r=function(t,e,n){var r=0,i=t.length;for(r=0;r1?n:n[0]};return(r=o().isElement(e)||o().every(e,(function(t){return o().isElement(t)}))?e:"document"===e?document:"window"===e?window:i(document,e))?(n.show=function(){r.style.display="block"},n.hide=function(){r.style.display="none"},n.addClass=function(t){r.classList?r.classList.add(t):-1===r.className.split(" ").indexOf(t)&&(r.className+=" "+t)},n.after=function(t){r.insertAdjacentHTML("afterend",t)},n.append=function(t){r.appendChild(t)},n.before=function(t){r.insertAdjacentHTML("beforebegin",t)},n.children=function(){return r.children||[]},n.contains=function(t){return r!==t&&r.contains(t)},n.empty=function(){r.innerHTML=""},n.find=function(e){return t(i(r,e))},n.css=function(t,e){if(!e)return r.style[t];r.length>0?r.forEach((function(n){n.style[t]=e})):r.style[t]=e},n.removeClass=function(t){r.classList?r.classList.remove(t):r.className=r.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")},n.removeAttribute=function(t){r.removeAttribute(t)},n.text=function(t){if(void 0===t)return r.textContent;r.textContent=t},n.html=function(t){r.innerHTML=t},n.hasClass=function(t){return r.classList?r.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(r.name)},n.is=function(t){return r===t},n.offset=function(){var t=r.getBoundingClientRect();return{top:t.top+document.body.scrollTop,left:t.left+document.body.scrollLeft}},n.width=function(){return r.clientWidth},n.height=function(){return r.clientHeight},n.attr=function(t){return r.getAttribute(t)},n.replace=function(t){r.replaceWith(t)},n.remove=function(){r.length>1?r.parentElement.removeChild(r):r.remove()},n.removeChild=function(t){if(t)r.removeChild(t);else for(;r.hasChildNodes();)r.removeChild(r.firstChild)},n.get=function(){return r},n.closest=function(e){r.closest=function(t){var e=r;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null};var n=r.closest(e);return n?t(n):null},n):null}),Ht=function(t,e){if(t)return 0==t.indexOf("rtmp:")||"rtmp"==e},Kt=function(t,e){return!!t&&(0===t.indexOf("ws:")||0===t.indexOf("wss:")||"webrtc"===e)},Vt=function(t,e){if(t)return"hls"===e||"m3u8"===e||"application/vnd.apple.mpegurl"===e||"m3u8"==a(t)},zt=function(t,e){if(t)return"mpd"===e||"dash"===e||"application/dash+xml"===e||"mpd"==a(t)},$t=function(t){if(!t)return null;var e=null;if("string"==typeof t)e=document.getElementById(t);else{if(!t.nodeType)return null;e=t}return e},Xt=function(){var t={};OvenPlayerConsole.log("SupportChecker loaded.");var e=W(),n=[{name:"html5",checkSupport:function(t){var n=document.createElement("video");if(!n.canPlayType)return!1;var r=t.file,i=t.type;if(!i)return!1;var o=t.mimeType||{aac:"audio/mp4",mp4:"video/mp4",f4v:"video/mp4",m4v:"video/mp4",mov:"video/mp4",mp3:"audio/mpeg",mpeg:"audio/mpeg",ogv:"video/ogg",ogg:"video/ogg",oga:"video/ogg",vorbis:"video/ogg",webm:"video/webm",f4a:"video/aac",m3u8:"application/vnd.apple.mpegurl",m3u:"application/vnd.apple.mpegurl",hls:"application/vnd.apple.mpegurl"}[i];return!(Vt(r,i)&&("Microsoft Edge"===e.browser||"Android"===e.os)||Ht(r,i)||Kt(r,i)||!o||!n.canPlayType(o))}},{name:"webrtc",checkSupport:function(t){if(!document.createElement("video").canPlayType)return!1;if(Ht(e,n))return!1;var e=t.file,n=t.type;return!!Kt(e,n)}},{name:"dash",checkSupport:function(t){var e=t.file,n=t.type;return!Ht(e,n)&&!("function"!=typeof(window.MediaSource||window.WebKitMediaSource)||!zt(e,n))}},{name:"hls",checkSupport:function(t){document.createElement("video");var e,n,r,i,o=t.file,s=t.type;return!Ht(o,s)&&(e=function(){if("undefined"!=typeof window)return window.MediaSource||window.WebKitMediaSource}(),n=window.SourceBuffer||window.WebKitSourceBuffer,r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!n||n.prototype&&"function"==typeof n.prototype.appendBuffer&&"function"==typeof n.prototype.remove,!!r&&!!i)}},{name:"rtmp",checkSupport:function(t){var n=t.file,r=t.type;return!(!Ht(n,r)||!function(){var t=!1;if("ActiveXObject"in window)try{t=!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(e){t=!1}else t=!!navigator.mimeTypes["application/x-shockwave-flash"];return t}()||"Microsoft Edge"===e.browser||"Android"===e.os||"iOS"===e.os||"Safari"===e.browser)}}];return t.findProviderNameBySource=function(t){OvenPlayerConsole.log("SupportChecker : findProviderNameBySource()",t);for(var e=t===Object(t)?t:{},r=0;r0&&void 0!==arguments[0]?arguments[0]:{};ce(this,t),this.id=e.id||null,this.adId=e.adId||null,this.sequence=e.sequence||null,this.apiFramework=e.apiFramework||null,this.trackingEvents={}})),pe=function(t){ne(n,t);var e=ie(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ce(this,n),(t=e.call(this,r)).type="companion",t.variations=[],t}return le(n)}(fe);function ge(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[];for(var r in e.ASSETURI&&(e.ASSETURI=me(e.ASSETURI)),e.CONTENTPLAYHEAD&&(e.CONTENTPLAYHEAD=me(e.CONTENTPLAYHEAD)),e.ERRORCODE&&!/^[0-9]{3}$/.test(e.ERRORCODE)&&(e.ERRORCODE=900),e.CACHEBUSTING=ve(Math.round(1e8*Math.random()).toString()),e.TIMESTAMP=me((new Date).toISOString()),e.RANDOM=e.random=e.CACHEBUSTING,t){var i=t[r];if("string"==typeof i){for(var o in e){var s=e[o],a="[".concat(o,"]"),l="%%".concat(o,"%%");i=(i=i.replace(a,s)).replace(l,s)}n.push(i)}}return n}function me(t){return encodeURIComponent(t).replace(/[!'()*]/g,(function(t){return"%".concat(t.charCodeAt(0).toString(16))}))}function ve(t){return t.length<8?ye(0,8-t.length,!1).map((function(t){return"0"})).join("")+t:t}function ye(t,e,n){for(var r=[],i=to;i?s++:s--)r.push(s);return r}var Ce={track:function(t,e){ge(t,e).forEach((function(t){"undefined"!=typeof window&&null!==window&&((new Image).src=t)}))},resolveURLTemplates:ge,encodeURIComponentRFC3986:me,leftpad:ve,range:ye,isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},flatten:function t(e){return e.reduce((function(e,n){return e.concat(Array.isArray(n)?t(n):n)}),[])}},be=function(t,e){var n=t.childNodes;for(var r in n){var i=n[r];if(i.nodeName===e)return i}},Ee=function(t,e){var n=[],r=t.childNodes;for(var i in r){var o=r[i];o.nodeName===e&&n.push(o)}return n},we=function(t,e){if(!e)return t;if(0===t.indexOf("//")){var n=location.protocol;return"".concat(n).concat(t)}return-1===t.indexOf("://")?"".concat(e.slice(0,e.lastIndexOf("/")),"/").concat(t):t},Te=function(t){return-1!==["true","TRUE","1"].indexOf(t)},Se=function(t){return t&&(t.textContent||t.text||"").trim()},ke=function(t,e,n){var r=e.getAttribute(t);r&&n.setAttribute(t,r)},Le=function(t){if(null==t)return-1;if(Ce.isNumeric(t))return parseInt(t);var e=t.split(":");if(3!==e.length)return-1;var n=e[2].split("."),r=parseInt(n[0]);2===n.length&&(r+=parseFloat("0.".concat(n[1])));var i=parseInt(60*e[1]),o=parseInt(60*e[0]*60);return isNaN(o)||isNaN(i)||isNaN(r)||i>3600||r>60?-1:o+i+r},xe=function(t){var e=[],n=null;return t.forEach((function(r,i){if(r.sequence&&(r.sequence=parseInt(r.sequence,10)),r.sequence>1){var o=t[i-1];if(o&&o.sequence===r.sequence-1)return void(n&&n.push(r));delete r.sequence}n=[r],e.push(n)})),e},Ie=function(t,e){t.errorURLTemplates=e.errorURLTemplates.concat(t.errorURLTemplates),t.impressionURLTemplates=e.impressionURLTemplates.concat(t.impressionURLTemplates),t.extensions=e.extensions.concat(t.extensions),t.creatives.forEach((function(t){if(e.trackingEvents&&e.trackingEvents[t.type])for(var n in e.trackingEvents[t.type]){var r=e.trackingEvents[t.type][n];t.trackingEvents[n]||(t.trackingEvents[n]=[]),t.trackingEvents[n]=t.trackingEvents[n].concat(r)}})),e.videoClickTrackingURLTemplates&&e.videoClickTrackingURLTemplates.length&&t.creatives.forEach((function(t){"linear"===t.type&&(t.videoClickTrackingURLTemplates=t.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates))})),e.videoCustomClickURLTemplates&&e.videoCustomClickURLTemplates.length&&t.creatives.forEach((function(t){"linear"===t.type&&(t.videoCustomClickURLTemplates=t.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates))})),e.videoClickThroughURLTemplate&&t.creatives.forEach((function(t){"linear"===t.type&&null==t.videoClickThroughURLTemplate&&(t.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate)}))};function Re(t,e){var n=new pe(e);return Ee(t,"Companion").forEach((function(t){var e=new he;e.id=t.getAttribute("id")||null,e.width=t.getAttribute("width"),e.height=t.getAttribute("height"),e.companionClickTrackingURLTemplates=[],Ee(t,"HTMLResource").forEach((function(t){e.type=t.getAttribute("creativeType")||"text/html",e.htmlResource=Se(t)})),Ee(t,"IFrameResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.iframeResource=Se(t)})),Ee(t,"StaticResource").forEach((function(n){e.type=n.getAttribute("creativeType")||0,Ee(t,"AltText").forEach((function(t){e.altText=Se(t)})),e.staticResource=Se(n)})),Ee(t,"TrackingEvents").forEach((function(t){Ee(t,"Tracking").forEach((function(t){var n=t.getAttribute("event"),r=Se(t);n&&r&&(null==e.trackingEvents[n]&&(e.trackingEvents[n]=[]),e.trackingEvents[n].push(r))}))})),Ee(t,"CompanionClickTracking").forEach((function(t){e.companionClickTrackingURLTemplates.push(Se(t))})),e.companionClickThroughURLTemplate=Se(be(t,"CompanionClickThrough")),e.companionClickTrackingURLTemplate=Se(be(t,"CompanionClickTracking")),n.variations.push(e)})),n}var De=function(t){ne(n,t);var e=ie(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ce(this,n),(t=e.call(this,r)).type="linear",t.duration=0,t.skipDelay=null,t.mediaFiles=[],t.videoClickThroughURLTemplate=null,t.videoClickTrackingURLTemplates=[],t.videoCustomClickURLTemplates=[],t.adParameters=null,t.icons=[],t}return le(n)}(fe),Be=le((function t(){ce(this,t),this.program=null,this.height=0,this.width=0,this.xPosition=0,this.yPosition=0,this.apiFramework=null,this.offset=null,this.duration=0,this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.iconClickThroughURLTemplate=null,this.iconClickTrackingURLTemplates=[],this.iconViewTrackingURLTemplate=null})),Pe=le((function t(){ce(this,t),this.id=null,this.fileURL=null,this.deliveryType="progressive",this.mimeType=null,this.codec=null,this.bitrate=0,this.minBitrate=0,this.maxBitrate=0,this.width=0,this.height=0,this.apiFramework=null,this.scalable=null,this.maintainAspectRatio=null}));function Me(t,e){var n,r=new De(e);r.duration=Le(Se(be(t,"Duration")));var i=t.getAttribute("skipoffset");if(null==i)r.skipDelay=null;else if("%"===i.charAt(i.length-1)&&-1!==r.duration){var o=parseInt(i,10);r.skipDelay=r.duration*(o/100)}else r.skipDelay=Le(i);var s=be(t,"VideoClicks");s&&(r.videoClickThroughURLTemplate=Se(be(s,"ClickThrough")),Ee(s,"ClickTracking").forEach((function(t){r.videoClickTrackingURLTemplates.push(Se(t))})),Ee(s,"CustomClick").forEach((function(t){r.videoCustomClickURLTemplates.push(Se(t))})));var a=be(t,"AdParameters");a&&(r.adParameters=Se(a)),Ee(t,"TrackingEvents").forEach((function(t){Ee(t,"Tracking").forEach((function(t){var e=t.getAttribute("event"),i=Se(t);if(e&&i){if("progress"===e){if(!(n=t.getAttribute("offset")))return;e="%"===n.charAt(n.length-1)?"progress-".concat(n):"progress-".concat(Math.round(Le(n)))}null==r.trackingEvents[e]&&(r.trackingEvents[e]=[]),r.trackingEvents[e].push(i)}}))})),Ee(t,"MediaFiles").forEach((function(t){Ee(t,"MediaFile").forEach((function(t){var e=new Pe;e.id=t.getAttribute("id"),e.fileURL=Se(t),e.deliveryType=t.getAttribute("delivery"),e.codec=t.getAttribute("codec"),e.mimeType=t.getAttribute("type"),e.apiFramework=t.getAttribute("apiFramework"),e.bitrate=parseInt(t.getAttribute("bitrate")||0),e.minBitrate=parseInt(t.getAttribute("minBitrate")||0),e.maxBitrate=parseInt(t.getAttribute("maxBitrate")||0),e.width=parseInt(t.getAttribute("width")||0),e.height=parseInt(t.getAttribute("height")||0);var n=t.getAttribute("scalable");n&&"string"==typeof n&&("true"===(n=n.toLowerCase())?e.scalable=!0:"false"===n&&(e.scalable=!1));var i=t.getAttribute("maintainAspectRatio");i&&"string"==typeof i&&("true"===(i=i.toLowerCase())?e.maintainAspectRatio=!0:"false"===i&&(e.maintainAspectRatio=!1)),r.mediaFiles.push(e)}))}));var l=be(t,"Icons");return l&&Ee(l,"Icon").forEach((function(t){var e=new Be;e.program=t.getAttribute("program"),e.height=parseInt(t.getAttribute("height")||0),e.width=parseInt(t.getAttribute("width")||0),e.xPosition=function(t){return-1!==["left","right"].indexOf(t)?t:parseInt(t||0)}(t.getAttribute("xPosition")),e.yPosition=function(t){return-1!==["top","bottom"].indexOf(t)?t:parseInt(t||0)}(t.getAttribute("yPosition")),e.apiFramework=t.getAttribute("apiFramework"),e.offset=Le(t.getAttribute("offset")),e.duration=Le(t.getAttribute("duration")),Ee(t,"HTMLResource").forEach((function(t){e.type=t.getAttribute("creativeType")||"text/html",e.htmlResource=Se(t)})),Ee(t,"IFrameResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.iframeResource=Se(t)})),Ee(t,"StaticResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.staticResource=Se(t)}));var n=be(t,"IconClicks");n&&(e.iconClickThroughURLTemplate=Se(be(n,"IconClickThrough")),Ee(n,"IconClickTracking").forEach((function(t){e.iconClickTrackingURLTemplates.push(Se(t))}))),e.iconViewTrackingURLTemplate=Se(be(t,"IconViewTracking")),r.icons.push(e)})),r}var Oe,Fe=function(t){ne(n,t);var e=ie(n);function n(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ce(this,n),(t=e.call(this,r)).type="nonlinear",t.variations=[],t}return le(n)}(fe),_e=le((function t(){ce(this,t),this.id=null,this.width=0,this.height=0,this.expandedWidth=0,this.expandedHeight=0,this.scalable=!0,this.maintainAspectRatio=!0,this.minSuggestedDuration=0,this.apiFramework="static",this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.nonlinearClickThroughURLTemplate=null,this.nonlinearClickTrackingURLTemplates=[],this.adParameters=null}));function Ne(t,e){var n=new Fe(e);return Ee(t,"TrackingEvents").forEach((function(t){var e,r;Ee(t,"Tracking").forEach((function(t){e=t.getAttribute("event"),r=Se(t),e&&r&&(null==n.trackingEvents[e]&&(n.trackingEvents[e]=[]),n.trackingEvents[e].push(r))}))})),Ee(t,"NonLinear").forEach((function(t){var e=new _e;e.id=t.getAttribute("id")||null,e.width=t.getAttribute("width"),e.height=t.getAttribute("height"),e.expandedWidth=t.getAttribute("expandedWidth"),e.expandedHeight=t.getAttribute("expandedHeight"),e.scalable=Te(t.getAttribute("scalable")),e.maintainAspectRatio=Te(t.getAttribute("maintainAspectRatio")),e.minSuggestedDuration=Le(t.getAttribute("minSuggestedDuration")),e.apiFramework=t.getAttribute("apiFramework"),Ee(t,"HTMLResource").forEach((function(t){e.type=t.getAttribute("creativeType")||"text/html",e.htmlResource=Se(t)})),Ee(t,"IFrameResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.iframeResource=Se(t)})),Ee(t,"StaticResource").forEach((function(t){e.type=t.getAttribute("creativeType")||0,e.staticResource=Se(t)}));var r=be(t,"AdParameters");r&&(e.adParameters=Se(r)),e.nonlinearClickThroughURLTemplate=Se(be(t,"NonLinearClickThrough")),Ee(t,"NonLinearClickTracking").forEach((function(t){e.nonlinearClickTrackingURLTemplates.push(Se(t))})),n.variations.push(e)})),n}function Ue(t){var e=t.childNodes;for(var n in e){var r=e[n];if(-1!==["Wrapper","InLine"].indexOf(r.nodeName)){if(ke("id",t,r),ke("sequence",t,r),"Wrapper"===r.nodeName)return Ge(r);if("InLine"===r.nodeName)return Qe(r)}}}function Qe(t){var e=t.childNodes,n=new ue;for(var r in n.id=t.getAttribute("id")||null,n.sequence=t.getAttribute("sequence")||null,e){var i=e[r];switch(i.nodeName){case"Error":n.errorURLTemplates.push(Se(i));break;case"Impression":n.impressionURLTemplates.push(Se(i));break;case"Creatives":Ee(i,"Creative").forEach((function(t){var e={id:t.getAttribute("id")||null,adId:Ye(t),sequence:t.getAttribute("sequence")||null,apiFramework:t.getAttribute("apiFramework")||null};for(var r in t.childNodes){var i=t.childNodes[r];switch(i.nodeName){case"Linear":var o=Me(i,e);o&&n.creatives.push(o);break;case"NonLinearAds":var s=Ne(i,e);s&&n.creatives.push(s);break;case"CompanionAds":var a=Re(i,e);a&&n.creatives.push(a)}}}));break;case"Extensions":We(n.extensions,Ee(i,"Extension"));break;case"AdSystem":n.system={value:Se(i),version:i.getAttribute("version")||null};break;case"AdTitle":n.title=Se(i);break;case"Description":n.description=Se(i);break;case"Advertiser":n.advertiser=Se(i);break;case"Pricing":n.pricing={value:Se(i),model:i.getAttribute("model")||null,currency:i.getAttribute("currency")||null};break;case"Survey":n.survey=Se(i)}}return n}function Ge(t){var e=Qe(t),n=be(t,"VASTAdTagURI");if(n?e.nextWrapperURL=Se(n):(n=be(t,"VASTAdTagURL"))&&(e.nextWrapperURL=Se(be(n,"URL"))),e.creatives.forEach((function(t){if(-1!==["linear","nonlinear"].indexOf(t.type)){if(t.trackingEvents){e.trackingEvents||(e.trackingEvents={}),e.trackingEvents[t.type]||(e.trackingEvents[t.type]={});var n=function(n){var r=t.trackingEvents[n];e.trackingEvents[t.type][n]||(e.trackingEvents[t.type][n]=[]),r.forEach((function(r){e.trackingEvents[t.type][n].push(r)}))};for(var r in t.trackingEvents)n(r)}t.videoClickTrackingURLTemplates&&(e.videoClickTrackingURLTemplates||(e.videoClickTrackingURLTemplates=[]),t.videoClickTrackingURLTemplates.forEach((function(t){e.videoClickTrackingURLTemplates.push(t)}))),t.videoClickThroughURLTemplate&&(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate),t.videoCustomClickURLTemplates&&(e.videoCustomClickURLTemplates||(e.videoCustomClickURLTemplates=[]),t.videoCustomClickURLTemplates.forEach((function(t){e.videoCustomClickURLTemplates.push(t)})))}})),e.nextWrapperURL)return e}function We(t,e){e.forEach((function(e){var n=new Ae,r=e.attributes,i=e.childNodes;if(e.attributes)for(var o in r){var s=r[o];s.nodeName&&s.nodeValue&&(n.attributes[s.nodeName]=s.nodeValue)}for(var a in i){var l=i[a],c=Se(l);if("#comment"!==l.nodeName&&""!==c){var u=new de;if(u.name=l.nodeName,u.value=c,l.attributes){var A=l.attributes;for(var d in A){var h=A[d];u.attributes[h.nodeName]=h.nodeValue}}n.children.push(u)}}t.push(n)}))}function Ye(t){return t.getAttribute("AdID")||t.getAttribute("adID")||t.getAttribute("adId")||null}function je(){}function He(){He.init.call(this)}function Ke(t){return void 0===t._maxListeners?He.defaultMaxListeners:t._maxListeners}function Ve(t,e,n){if(e)t.call(n);else for(var r=t.length,i=en(t,r),o=0;o0&&s.length>i){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,function(t){"function"==typeof console.warn?console.warn(t):console.log(t)}(a)}}else s=o[e]=n,++t._eventsCount;return t}function Ze(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function tn(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function en(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}je.prototype=Object.create(null),He.EventEmitter=He,He.usingDomains=!1,He.prototype.domain=void 0,He.prototype._events=void 0,He.prototype._maxListeners=void 0,He.defaultMaxListeners=10,He.init=function(){this.domain=null,He.usingDomains&&(!Oe.active||this instanceof Oe.Domain||(this.domain=Oe.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new je,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},He.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},He.prototype.getMaxListeners=function(){return Ke(this)},He.prototype.emit=function(t){var e,n,r,i,o,s,a,l="error"===t;if(s=this._events)l=l&&null==s.error;else if(!l)return!1;if(a=this.domain,l){if(e=arguments[1],!a){if(e instanceof Error)throw e;var c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=s[t]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:Ve(n,u,this);break;case 2:ze(n,u,this,arguments[1]);break;case 3:$e(n,u,this,arguments[1],arguments[2]);break;case 4:Xe(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o0;)if(n[o]===e||n[o].listener&&n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new je,this;delete r[t]}else!function(t,e){for(var n=e,r=n+1,i=t.length;r0?Reflect.ownKeys(this._events):[]};var nn=function(t,e,n){var r="function"==typeof window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLDOM"):void 0;if(!r)return n(new Error("FlashURLHandler: Microsoft.XMLDOM format not supported"));r.async=!1,request.open("GET",t),request.timeout=e.timeout||0,request.withCredentials=e.withCredentials||!1,request.send(),request.onprogress=function(){},request.onload=function(){r.loadXML(request.responseText),n(null,r)}},rn=function(){return window.XDomainRequest&&(t=new XDomainRequest),!!t;var t},on=function(t,e,n){n(new Error("Please bundle the library for node to use the node urlHandler"))};function sn(){try{var t=new window.XMLHttpRequest;return"withCredentials"in t?t:null}catch(t){return console.log("Error in XHRURLHandler support check:",t),null}}var an=function(t,e,n){if("https:"===window.location.protocol&&0===t.indexOf("http://"))return n(new Error("XHRURLHandler: Cannot go from HTTPS to HTTP."));try{var r=sn();r.open("GET",t),r.timeout=e.timeout||0,r.withCredentials=e.withCredentials||!1,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.onreadystatechange=function(){4===r.readyState&&(200===r.status?n(null,r.responseXML):n(new Error("XHRURLHandler: ".concat(r.statusText))))},r.send()}catch(t){n(new Error("XHRURLHandler: Unexpected error"))}},ln=function(){return!!sn()},cn={get:function(t,e,n){return n||("function"==typeof e&&(n=e),e={}),"undefined"==typeof window||null===window?on(t,e,n):ln()?an(t,e,n):rn()?nn(t,e,n):n(new Error("Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler"))}},un=le((function t(){ce(this,t),this.ads=[],this.errorURLTemplates=[]})),An={ERRORCODE:900,extensions:[]},dn=function(t){ne(n,t);var e=ie(n);function n(){var t;return ce(this,n),(t=e.call(this)).remainingAds=[],t.parentURLs=[],t.errorURLTemplates=[],t.rootErrorURLTemplates=[],t.maxWrapperDepth=null,t.URLTemplateFilters=[],t.fetchingOptions={},t}return le(n,[{key:"addURLTemplateFilter",value:function(t){"function"==typeof t&&this.URLTemplateFilters.push(t)}},{key:"removeURLTemplateFilter",value:function(){this.URLTemplateFilters.pop()}},{key:"countURLTemplateFilters",value:function(){return this.URLTemplateFilters.length}},{key:"clearURLTemplateFilters",value:function(){this.URLTemplateFilters=[]}},{key:"trackVastError",value:function(t,e){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:{};this.rootURL="",this.remainingAds=[],this.parentURLs=[],this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.maxWrapperDepth=t.wrapperLimit||10,this.fetchingOptions={timeout:t.timeout,withCredentials:t.withCredentials},this.urlHandler=t.urlhandler||cn}},{key:"getRemainingAds",value:function(t){var e=this;if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));var n=t?Ce.flatten(this.remainingAds):this.remainingAds.shift();return this.errorURLTemplates=[],this.parentURLs=[],this.resolveAds(n,{wrapperDepth:0,originalUrl:this.rootURL}).then((function(t){return e.buildVASTResponse(t)}))}},{key:"getAndParseVAST",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),this.rootURL=t,this.fetchVAST(t).then((function(r){return n.originalUrl=t,n.isRootVAST=!0,e.parse(r,n).then((function(t){return e.buildVASTResponse(t)}))}))}},{key:"parseVAST",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),n.isRootVAST=!0,this.parse(t,n).then((function(t){return e.buildVASTResponse(t)}))}},{key:"buildVASTResponse",value:function(t){var e=new un;return e.ads=t,e.errorURLTemplates=this.getErrorURLTemplates(),this.completeWrapperResolving(e),e}},{key:"parse",value:function(t,e){var n=e.resolveAll,r=void 0===n||n,i=e.wrapperSequence,o=void 0===i?null:i,s=e.originalUrl,a=void 0===s?null:s,l=e.wrapperDepth,c=void 0===l?0:l,u=e.isRootVAST,A=void 0!==u&&u;if(!t||!t.documentElement||"VAST"!==t.documentElement.nodeName)return Promise.reject(new Error("Invalid VAST XMLDocument"));var d=[],h=t.documentElement.childNodes;for(var f in h){var p=h[f];if("Error"===p.nodeName){var g=Se(p);A?this.rootErrorURLTemplates.push(g):this.errorURLTemplates.push(g)}if("Ad"===p.nodeName){var m=Ue(p);m?d.push(m):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}var v=d.length,y=d[v-1];return 1===v&&null!=o&&y&&!y.sequence&&(y.sequence=o),!1===r&&(this.remainingAds=xe(d),d=this.remainingAds.shift()),this.resolveAds(d,{wrapperDepth:c,originalUrl:a})}},{key:"resolveAds",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,r=n.wrapperDepth,i=n.originalUrl,o=[];return e.forEach((function(e){var n=t.resolveWrappers(e,r,i);o.push(n)})),Promise.all(o).then((function(e){var n=Ce.flatten(e);if(!n&&t.remainingAds.length>0){var o=t.remainingAds.shift();return t.resolveAds(o,{wrapperDepth:r,originalUrl:i})}return n}))}},{key:"resolveWrappers",value:function(t,e,n){var r=this;return new Promise((function(i,o){if(e++,!t.nextWrapperURL)return delete t.nextWrapperURL,i(t);if(e>=r.maxWrapperDepth||-1!==r.parentURLs.indexOf(t.nextWrapperURL))return t.errorCode=302,delete t.nextWrapperURL,i(t);t.nextWrapperURL=we(t.nextWrapperURL,n);var s=t.sequence;n=t.nextWrapperURL,r.fetchVAST(t.nextWrapperURL,e,n).then((function(o){return r.parse(o,{originalUrl:n,wrapperSequence:s,wrapperDepth:e}).then((function(e){if(delete t.nextWrapperURL,0===e.length)return t.creatives=[],i(t);e.forEach((function(e){e&&Ie(e,t)})),i(e)}))})).catch((function(e){t.errorCode=301,t.errorMessage=e.message,i(t)}))}))}},{key:"completeWrapperResolving",value:function(t){if(0===t.ads.length)this.trackVastError(t.errorURLTemplates,{ERRORCODE:303});else for(var e=t.ads.length-1;e>=0;e--){var n=t.ads[e];(n.errorCode||0===n.creatives.length)&&(this.trackVastError(n.errorURLTemplates.concat(t.errorURLTemplates),{ERRORCODE:n.errorCode||303},{ERRORMESSAGE:n.errorMessage||""},{extensions:n.extensions},{system:n.system}),t.ads.splice(e,1))}}}]),n}(He),hn=null,fn={data:{},length:0,getItem:function(t){return this.data[t]},setItem:function(t,e){this.data[t]=e,this.length=Object.keys(this.data).length},removeItem:function(t){delete data[t],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},pn=function(){function t(){ce(this,t),this.storage=this.initStorage()}return le(t,[{key:"initStorage",value:function(){if(hn)return hn;try{hn="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(t){hn=null}return hn&&!this.isStorageDisabled(hn)||(hn=fn).clear(),hn}},{key:"isStorageDisabled",value:function(t){var e="__VASTStorage__";try{if(t.setItem(e,e),t.getItem(e)!==e)return t.removeItem(e),!0}catch(t){return!0}return t.removeItem(e),!1}},{key:"getItem",value:function(t){return this.storage.getItem(t)}},{key:"setItem",value:function(t,e){return this.storage.setItem(t,e)}},{key:"removeItem",value:function(t){return this.storage.removeItem(t)}},{key:"clear",value:function(){return this.storage.clear()}}]),t}(),gn=function(){function t(e,n,r){ce(this,t),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=n||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new dn,this.storage=r||new pn,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return le(t,[{key:"getParser",value:function(){return this.vastParser}},{key:"lastSuccessfulAd",get:function(){return this.storage.getItem("vast-client-last-successful-ad")},set:function(t){this.storage.setItem("vast-client-last-successful-ad",t)}},{key:"totalCalls",get:function(){return this.storage.getItem("vast-client-total-calls")},set:function(t){this.storage.setItem("vast-client-total-calls",t)}},{key:"totalCallsTimeout",get:function(){return this.storage.getItem("vast-client-total-calls-timeout")},set:function(t){this.storage.setItem("vast-client-total-calls-timeout",t)}},{key:"hasRemainingAds",value:function(){return this.vastParser.remainingAds.length>0}},{key:"getNextAds",value:function(t){return this.vastParser.getRemainingAds(t)}},{key:"get",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Date.now();return(n=Object.assign(this.defaultOptions,n)).hasOwnProperty("resolveAll")||(n.resolveAll=!1),this.totalCallsTimeout=e.totalCalls)return o(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(e.totalCalls,"/").concat(e.cappingFreeLunch)));var s=r-e.lastSuccessfulAd;if(s<0)e.lastSuccessfulAd=0;else if(s3&&void 0!==arguments[3]?arguments[3]:null;for(var a in ce(this,n),(o=e.call(this)).ad=r,o.creative=i,o.variation=s,o.muted=!1,o.impressed=!1,o.skippable=!1,o.trackingEvents={},o._alreadyTriggeredQuartiles={},o.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],o.creative.trackingEvents){var l=o.creative.trackingEvents[a];o.trackingEvents[a]=l.slice(0)}return o.creative instanceof De?o._initLinearTracking():o._initVariationTracking(),t&&o.on("start",(function(){t.lastSuccessfulAd=Date.now()})),o}return le(n,[{key:"_initLinearTracking",value:function(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}},{key:"_initVariationTracking",value:function(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(var t in this.variation.trackingEvents){var e=this.variation.trackingEvents[t];this.trackingEvents[t]?this.trackingEvents[t]=this.trackingEvents[t].concat(e.slice(0)):this.trackingEvents[t]=e.slice(0)}this.variation instanceof _e?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):this.variation instanceof he&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}},{key:"setDuration",value:function(t){this.assetDuration=t,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}}},{key:"setProgress",value:function(t){var e=this,n=this.skipDelay||-1;if(-1===n||this.skippable||(n>t?this.emit("skip-countdown",n-t):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){var r=[];if(t>0){var i=Math.round(t/this.assetDuration*100);for(var o in r.push("start"),r.push("progress-".concat(i,"%")),r.push("progress-".concat(Math.round(t))),this.quartiles)this.isQuartileReached(o,this.quartiles[o],t)&&(r.push(o),this._alreadyTriggeredQuartiles[o]=!0)}r.forEach((function(t){e.track(t,!0)})),t0&&void 0!==arguments[0]?arguments[0]:null;this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates);var e=this.clickThroughURLTemplate||t;if(e){var n=this.linear?{CONTENTPLAYHEAD:this.progressFormatted()}:{},r=Ce.resolveURLTemplates([e],n)[0];this.emit("clickthrough",r)}}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"closeLinear"===t&&!this.trackingEvents[t]&&this.trackingEvents.close&&(t="close");var n=this.trackingEvents[t],r=this.emitAlwaysEvents.indexOf(t)>-1;n?(this.emit(t,""),this.trackURLs(n)):r&&this.emit(t,""),e&&(delete this.trackingEvents[t],r&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(t),1))}},{key:"trackURLs",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(e.ASSETURI=this.creative.mediaFiles[0].fileURL),e.CONTENTPLAYHEAD=this.progressFormatted()),Ce.track(t,e)}},{key:"progressFormatted",value:function(){var t=parseInt(this.progress),e=t/3600;e.length<2&&(e="0".concat(e));var n=t/60%60;n.length<2&&(n="0".concat(n));var r=t%60;return r.length<2&&(r="0".concat(n)),"".concat(e,":").concat(n,":").concat(r,".").concat(parseInt(100*(this.progress-t)))}}]),n}(He),vn=function(t,e,n,r){var i,o={},s={started:!1,active:!1,isVideoEnded:!1,lang:n.getLanguage()},a=null,l="",c=null,u="",A="",d=!1,h=n.getBrowser(),f="Android"===h.os||"iOS"===h.os;(i=document.createElement("div")).setAttribute("class","op-ads"),i.setAttribute("id","op-ads"),n.getContainer().append(i),(c=document.createElement("video")).setAttribute("playsinline","true"),c.setAttribute("title","Advertisement"),c.setAttribute("class","op-ads-vast-video"),(A=document.createElement("div")).setAttribute("class","op-ads-button"),(u=document.createElement("div")).setAttribute("class","op-ads-textview"),A.append(u),i.append(c),i.append(A),l=i;var p=new gn,g=null,m=null,v=function(t){console.log(t),c.style.display="none",e.trigger(lt,{code:t.code,message:t.message}),s.active=!1,s.started=!0,e.play()};return o.isActive=function(){return s.active},o.started=function(){return s.started},o.play=function(){return s.started?c.play():new Promise((function(i,o){!function l(){e.metaLoaded()?(OvenPlayerConsole.log("VAST : main contents meta loaded."),function(){OvenPlayerConsole.log("VAST : checkAutoplaySupport() ");var n=document.createElement("video");n.setAttribute("playsinline","true"),n.src=qt,n.load(),c.load(),f&&e.getName()!==At&&t.load();var r=function(t,e){d=t,n.pause(),n.remove()};return new Promise((function(t,e){if(n.play){var i=n.play();void 0!==i?i.then((function(){OvenPlayerConsole.log("VAST : auto play allowed."),r(!0),t()})).catch((function(e){OvenPlayerConsole.log("VAST : auto play failed",e.message),r(!1),t()})):(OvenPlayerConsole.log("VAST : promise not support"),r(!0),t())}else OvenPlayerConsole.log("VAST : !temporarySupportCheckVideo.play"),r(!0),t()}))}().then((function(){n.isAutoStart()&&!d?(OvenPlayerConsole.log("VAST : autoplayAllowed : false"),s.started=!1,o(new Error("autoplayNotAllowed"))):(p.get(r).then((function(n){if(OvenPlayerConsole.log("VAST : initRequest()"),!(m=n.ads[0]))throw{code:401,message:"File not found. Unable to find Linear/MediaFile from URI."};g=new mn(p,m,m.creatives[0]),OvenPlayerConsole.log("VAST : created ad tracker."),a=function(t,e,n,r,i,o,s){var a={},l={},c=jt(o),u=jt(i),A=jt(t);n.on(Rt,(function(e){e.mute?t.muted=!0:(t.muted=!1,t.volume=e.volume/100)}),l);var d=function(){r.active=!1,u.hide(),!r.started||0!==n.getPosition()&&r.isVideoEnded||(A.hide(),n.play()),n.trigger(at)},h=function(n){c.hasClass("videoAdUiAction")&&(e.skip(),t.pause(),d())};return o.addEventListener("click",h,!1),a.error=function(){OvenPlayerConsole.log("VAST : listener : error.",t.error),console.log("VAST : listener : error.",t.error);var n={},r=t.error&&t.error.code||0;2===r?(n.code=402,n.message="Timeout of MediaFile URI."):3===r?(n.code=405,n.message="Problem displaying MediaFile. Video player found a MediaFile with supported type but couldn’t display it. MediaFile may include: unsupported codecs, different MIME type than MediaFile@type, unsupported delivery method, etc."):4===r?(n.code=403,n.message="Couldn’t find MediaFile that is supported by this video player, based on the attributes of the MediaFile element."):(n.code=400,n.message="General Linear error. Video player is unable to display the Linear Ad."),e.errorWithCode(n.code),s("405")},a.canplay=function(){},a.ended=function(){e.complete(),d()},a.click=function(t){e.click()},a.play=function(){e.setPaused(!1)},a.pause=function(){e.setPaused(!0)},a.timeupdate=function(r){e.setProgress(r.target.currentTime),n.trigger(Lt,{duration:t.duration,position:t.currentTime})},a.volumechange=function(t){OvenPlayerConsole.log("VAST : listener : Ad Video Volumechange."),e.setMuted(t.target.muted)},a.loadedmetadata=function(){OvenPlayerConsole.log("VAST : listener : Ad CONTENT LOADED ."),tt===n.getState()&&n.pause(),e.trackImpression(),n.trigger(it,{remaining:t.duration,isLinear:!0}),t.play()},e.on("skip",(function(){OvenPlayerConsole.log("VAST : listener : skipped")})),e.on("mute",(function(){OvenPlayerConsole.log("VAST : listener : muted")})),e.on("unmute",(function(){OvenPlayerConsole.log("VAST : listener : unmuted")})),e.on("resume",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker resumed."),r.started&&n.setState(ot)})),e.on("pause",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker paused."),n.setState(st)})),e.on("clickthrough",(function(t){OvenPlayerConsole.log("VAST : listener : clickthrough :",t),window.open(t,"_blank")})),e.on("skip-countdown",(function(t){0===t?("ko"===r.lang?c.html("광고 건너뛰기"):c.html("Ad Skip"),c.addClass("videoAdUiAction")):"ko"===r.lang?c.html(parseInt(t)+1+"초 후에 이 광고를 건너뛸 수 있습니다."):c.html("You can skip this ad in "+(parseInt(t)+1))})),e.on("rewind",(function(){OvenPlayerConsole.log("VAST : listener : rewind")})),e.on("start",(function(){OvenPlayerConsole.log("VAST : listener : started"),r.started=!0,r.active=!0,A.show(),u.show(),n.trigger(kt,{isLinear:!0}),n.setState(ot)})),e.on("firstQuartile",(function(){OvenPlayerConsole.log("VAST : listener : firstQuartile")})),e.on("midpoint",(function(){OvenPlayerConsole.log("VAST : listener : midpoint")})),e.on("thirdQuartile",(function(){OvenPlayerConsole.log("VAST : listener : thirdQuartile")})),e.on("creativeView",(function(){OvenPlayerConsole.log("VAST : listener : creativeView")})),Object.keys(a).forEach((function(e){t.removeEventListener(e,a[e]),t.addEventListener(e,a[e])})),l.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),o.removeEventListener("click",h,!1),Object.keys(a).forEach((function(e){t.removeEventListener(e,a[e])}))},l}(c,g,e,s,A,u,v);var r="";m.creatives&&m.creatives.length>0&&m.creatives[0].mediaFiles&&m.creatives[0].mediaFiles.length>0&&m.creatives[0].mediaFiles[0].fileURL&&(r=m.creatives[0].mediaFiles[0].fileURL,OvenPlayerConsole.log("VAST : media url : ",r)),c.src=r,c.volume=t.volume,c.muted=t.muted})).catch((function(t){v(t)})),i())}))):setTimeout(l,100)}()}))},o.pause=function(){c.pause()},o.videoEndedCallback=function(t){t(),s.isVideoEnded=!0},o.destroy=function(){a&&(a.destroy(),a=null),g=null,p=null,l.remove()},o},yn=function(t,e,n){OvenPlayerConsole.log("[Provider] loaded. ");var r={};Yt(r);var i=t.element,o=null,s=null;t.adTagUrl&&(OvenPlayerConsole.log("[Provider] Ad Client - ",e.getAdClient()),(o="vast"===e.getAdClient()?vn(i,r,e,t.adTagUrl):te(i,r,e,t.adTagUrl))||console.log("Can not load due to google ima for Ads.")),s=function(t,e,n,r){var i={};OvenPlayerConsole.log("EventListener loaded.",t,e);var o={},s=-1,a=t;return i.canplay=function(){e.setCanSeek(!0),e.trigger("bufferFull"),OvenPlayerConsole.log("EventListener : on canplay")},i.durationchange=function(){i.progress(),OvenPlayerConsole.log("EventListener : on durationchange"),e.trigger("durationChanged")},i.ended=function(){OvenPlayerConsole.log("EventListener : on ended"),a.pause(),e.getState()!==q&&e.getState()!==J&&e.getState()!==et&&(n?n((function(){e.setState(J)})):e.setState(J))},i.loadeddata=function(){},i.loadedmetadata=function(){var t=e.getSources(),n=e.getCurrentSource(),r=n>-1?t[n].type:"",i={duration:e.isLive()?1/0:a.duration,type:r};e.setMetaLoaded(),OvenPlayerConsole.log("EventListener : on loadedmetadata",i),e.trigger(Bt,i)},i.pause=function(){return e.getState()!==J&&e.getState()!==et&&!a.ended&&!a.error&&a.currentTime!==a.duration&&(OvenPlayerConsole.log("EventListener : on pause"),void e.setState(Z))},i.loadstart=function(){r&&!r.getConfig().showBigPlayButton&&r.getConfig().autoStart&&e.setState(nt)},i.play=function(){s=-1,a.paused||e.getState()===tt||e.setState(nt)},i.playing=function(){OvenPlayerConsole.log("EventListener : on playing"),s<0&&e.setState(tt)},i.progress=function(){var t=a.buffered;if(!t)return!1;var n,r=a.duration,i=a.currentTime,o=(n=(t.length>0?t.end(t.length-1):0)/r,Math.max(Math.min(n,1),0));e.setBuffer(100*o),e.trigger(xt,{bufferPercent:100*o,position:i,duration:r}),OvenPlayerConsole.log("EventListener : on progress",100*o)},i.timeupdate=function(){var t=a.currentTime,n=a.duration;if(!isNaN(n)){if(t>n)return a.pause(),void e.setState(J);var r=e.getSources()[e.getCurrentSource()].sectionStart;r&&ti&&e.getState()===tt)return e.stop(),void e.setState(J);n>9e15&&(n=1/0),e.isSeeking()||a.paused||e.getState()!==rt&&e.getState()!==nt&&e.getState()!==ot||function(t,e){return t.toFixed(2)===e.toFixed(2)}(s,t)||(s=-1,e.setState(tt)),r&&r>0&&(t-=r)<0&&(t=0),i&&(n=i),r&&(n-=r),(e.getState()===tt||e.isSeeking())&&e.trigger(It,{position:t,duration:n})}},i.seeking=function(){e.setSeeking(!0),OvenPlayerConsole.log("EventListener : on seeking",a.currentTime),e.trigger("seek",{position:a.currentTime})},i.seeked=function(){e.isSeeking()&&(OvenPlayerConsole.log("EventListener : on seeked"),e.setSeeking(!1),e.trigger("seeked"))},i.stalled=function(){OvenPlayerConsole.log("EventListener : on stalled")},i.waiting=function(){OvenPlayerConsole.log("EventListener : on waiting",e.getState()),e.isSeeking()?e.setState(nt):e.getState()===tt&&(s=a.currentTime,e.setState(rt))},i.volumechange=function(){OvenPlayerConsole.log("EventListener : on volumechange",Math.round(100*a.volume)),e.trigger(Rt,{volume:Math.round(100*a.volume),mute:a.muted})},i.error=function(){var t={0:300,1:301,2:302,3:303,4:304}[a.error&&a.error.code||0]||0;OvenPlayerConsole.log("EventListener : on error",t),Jt(Qt.codes[t],e)},Object.keys(i).forEach((function(t){a.removeEventListener(t,i[t]),a.addEventListener(t,i[t])})),o.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),Object.keys(i).forEach((function(t){a.removeEventListener(t,i[t])}))},o}(i,r,o?o.videoEndedCallback:null,e),i.playbackRate=i.defaultPlaybackRate=e.getPlaybackRate();var a=function(o){var s=t.sources[t.currentSource];if(t.framerate=s.framerate,r.setVolume(e.getVolume()),t.framerate||e.setTimecodeMode(!0),n)n(s,o);else{OvenPlayerConsole.log("source loaded : ",s,"lastPlayPosition : "+o);var a=i.src;s.file!==a&&(i.src=s.file,(a||""===a)&&i.load()),r.on(Bt,(function(){o>0&&r.seek(o)}))}};return r.getName=function(){return t.name},r.getMse=function(){return t.mse},r.getMediaElement=function(){return t.element},r.canSeek=function(){return t.canSeek},r.setCanSeek=function(e){t.canSeek=e},r.isSeeking=function(){return t.seeking},r.setSeeking=function(e){t.seeking=e},r.setMetaLoaded=function(){t.isLoaded=!0},r.metaLoaded=function(){return t.isLoaded},r.setState=function(e){if(t.state!==e){var n=t.state;if(OvenPlayerConsole.log("Provider : setState()",e),n===ot&&(e===et||e===q))return!1;switch(OvenPlayerConsole.log("Provider : triggerSatatus",e),e){case J:r.trigger("complete");break;case Z:r.trigger(Ct,{prevState:t.state,newstate:Z});break;case st:r.trigger(Ct,{prevState:t.state,newstate:st});break;case tt:r.trigger(bt,{prevState:t.state,newstate:tt});break;case ot:r.trigger(bt,{prevState:t.state,newstate:ot})}t.state=e,r.trigger(yt,{prevstate:n,newstate:t.state})}},r.getState=function(){return t.state},r.setBuffer=function(e){t.buffer=e},r.getBuffer=function(){return t.buffer},r.isLive=function(){return!!t.isLive||i.duration===1/0},r.getDuration=function(){return r.isLive()?1/0:i.duration},r.getDvrWindow=function(){return t.dvrWindow},r.getPosition=function(){return i?i.currentTime:0},r.setVolume=function(t){if(!i)return!1;i.volume=t/100,e.setVolume(t)},r.getVolume=function(){return e.getVolume()},r.setMute=function(t){if(!i)return!1;if(void 0===t){var n=e.isMute();i.muted=!n,e.setMute(!n),r.trigger(Dt,{mute:e.isMute()})}else i.muted=t,e.setMute(t),r.trigger(Dt,{mute:e.isMute()});return i.muted},r.getMute=function(){return e.isMute()},r.preload=function(n,i){return t.sources=n,t.currentSource=Zt(n,e),a(i||0),new Promise((function(t,n){e.isMute()&&r.setMute(!0),e.getVolume()&&r.setVolume(e.getVolume()),t()}))},r.load=function(n){t.sources=n,t.currentSource=Zt(n,e),a(0)},r.play=function(){if(OvenPlayerConsole.log("Provider : play()"),!i)return!1;if(r.getState()!==tt)if(o&&o.isActive()||o&&!o.started())o.play().then((function(t){OvenPlayerConsole.log("Provider : ads play success")})).catch((function(t){OvenPlayerConsole.log("Provider : ads play fail",t)}));else{var t=i.play();void 0!==t?t.then((function(){OvenPlayerConsole.log("Provider : video play success")})).catch((function(t){OvenPlayerConsole.log("Provider : video play error",t.message)})):OvenPlayerConsole.log("Provider : video play success (ie)")}},r.pause=function(){if(OvenPlayerConsole.log("Provider : pause()"),!i)return!1;r.getState()===tt?i.pause():r.getState()===ot&&o.pause()},r.seek=function(t){if(!i)return!1;i.currentTime=t},r.setPlaybackRate=function(t){return!!i&&(r.trigger("playbackRateChanged",{playbackRate:t}),i.playbackRate=i.defaultPlaybackRate=t)},r.getPlaybackRate=function(){return i?i.playbackRate:0},r.getSources=function(){return i?t.sources.map((function(t,e){var n={file:t.file,type:t.type,label:t.label,index:e,sectionStart:t.sectionStart,sectionEnd:t.sectionEnd,gridThumbnail:t.gridThumbnail};return t.lowLatency&&(n.lowLatency=t.lowLatency),n})):[]},r.getCurrentSource=function(){return t.currentSource},r.setCurrentSource=function(n,o){if(n>-1&&t.sources&&t.sources.length>n)return OvenPlayerConsole.log("source changed : "+n),t.currentSource=n,e.setSourceIndex(n),r.setState(q),o&&a(i.currentTime||0),t.currentSource},r.getQualityLevels=function(){return i?t.qualityLevels:[]},r.getCurrentQuality=function(){return i?t.currentQuality:null},r.setCurrentQuality=function(t){},r.getAudioTracks=function(){return i?t.audioTracks:[]},r.getCurrentAudioTrack=function(){return i?t.currentAudioTrack:[]},r.setCurrentAudioTrack=function(t){},r.isAutoQuality=function(){},r.setAutoQuality=function(t){},r.getFramerate=function(){return t.framerate},r.setFramerate=function(e){return t.framerate=e},r.seekFrame=function(e){var n=t.framerate,o=(i.currentTime*n+e)/n;o+=1e-5,r.pause(),r.seek(o)},r.stop=function(){if(!i)return!1;for(OvenPlayerConsole.log("CORE : stop() "),i.removeAttribute("preload"),i.removeAttribute("src");i.firstChild;)i.removeChild(i.firstChild);r.pause(),r.setState(q)},r.destroy=function(){if(!i)return!1;r.stop(),s.destroy(),o&&(o.destroy(),o=null),r.off(),OvenPlayerConsole.log("CORE : destroy() player stop, listener, event destroied")},r.super=function(t){var e=r[t];return function(){return e.apply(r,arguments)}},r},Cn=function(t,e,n){var r=yn({name:ct,element:t,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:q,buffer:0,framerate:0,currentQuality:-1,qualityLevels:[],currentAudioTrack:-1,audioTracks:[],currentSource:-1,sources:[],adTagUrl:n},e,null),i=r.super("destroy");return OvenPlayerConsole.log("HTML5 PROVIDER LOADED."),r.destroy=function(){OvenPlayerConsole.log("HTML5 : PROVIDER DESTROYED."),i()},r},bn=function(t,e,n,r,i,s,a,l){var c={},u={},A=null,d=!1,h=null,f=null,p={},g=!1,m=!1,v=null,y=!1;a.getConfig().webrtcConfig&&!0===a.getConfig().webrtcConfig.recoverPacketLoss&&(m=!0);var C=!0;a.getConfig().webrtcConfig&&!1===a.getConfig().webrtcConfig.generatePublicCandidate&&(C=a.getConfig().webrtcConfig.generatePublicCandidate);var b=W(),E=null;function w(t){var e=null;return f&&t===f.id?e=f.peerConnection:p[t]&&(e=p[t].peerConnection),e}function T(t){t.statisticsTimer&&clearTimeout(t.statisticsTimer),t.status||(t.status={},t.status.lostPacketsArr=[],t.status.slotLength=8,t.status.prevPacketsLost=0,t.status.avg8Losses=0,t.status.avgMoreThanThresholdCount=0,t.status.threshold=40);var e=t.status.lostPacketsArr,n=t.status.slotLength,r=t.status.prevPacketsLost,i=t.status.avg8Losses,s=t.status.threshold;t.statisticsTimer=setTimeout((function(){if(!t.peerConnection)return!1;t.peerConnection.getStats().then((function(l){l&&a.getConfig().autoFallback&&l&&(l.forEach((function(a){if("inbound-rtp"===a.type&&"video"===a.kind&&!a.isRemote){var l=parseInt(a.packetsLost)-parseInt(r);e.push(parseInt(a.packetsLost)-parseInt(r)),e.length>n&&e.shift(),e.length===n&&(i=o().reduce(e,(function(t,e){return t+e}),0)/n,OvenPlayerConsole.log("Last8 LOST PACKET AVG : "+i,"Current Packet LOST: "+l,"Total Packet Lost: "+a.packetsLost,e),i>s?(t.status.avgMoreThanThresholdCount=t.status.avgMoreThanThresholdCount+1,t.status.avgMoreThanThresholdCount>=60&&(OvenPlayerConsole.log("NETWORK UNSTABLED!!! "),B(Qt.codes[510]))):t.status.avgMoreThanThresholdCount=0),t.status.prevPacketsLost=a.packetsLost}})),T(t))}))}),2e3)}function S(i,s,l,u,d){var p={};if(a.getConfig().webrtcConfig&&a.getConfig().webrtcConfig.iceServers)p.iceServers=a.getConfig().webrtcConfig.iceServers,a.getConfig().webrtcConfig.iceTransportPolicy&&(p.iceTransportPolicy=a.getConfig().webrtcConfig.iceTransportPolicy);else if(d){p.iceServers=[];for(var v=0;v-1){b=!0;break}if(!b&&C.urls.length>0){var S=o().clone(C.urls[0]),k=x(S);E&&k&&C.urls.push(S.replace(k,E))}C.username=y.username||y.user_name,C.credential=y.credential,p.iceServers.push(C)}p.iceTransportPolicy="relay"}else p=c;OvenPlayerConsole.log("Main Peer Connection Config : ",p);var I=null;try{I=new RTCPeerConnection(p),t.trigger("peerConnectionPrepared",I)}catch(t){var D=Qt.codes[506];return D.error=t,void B(D)}f={id:i,peerId:s,peerConnection:I},I.setRemoteDescription(new RTCSessionDescription(l)).then((function(){I.createAnswer().then((function(t){var e=function(t){for(var e=t.split("\r\n"),n=-1,r=0;r-1&&e[r].indexOf("opus")>-1){n=e[r].split(" ")[0].split(":")[1];break}return n}(l.sdp);e>-1&&function(t,e){for(var n=t.split("\r\n"),r=!1,i=0;i-1){n[i].indexOf("stereo=1")>-1&&(r=!0);break}return r}(l.sdp,e)&&(t.sdp=function(t,e){for(var n=t.split("\r\n"),r=0;r-1){-1===n[r].indexOf("stereo=1")&&(n[r]=n[r]+";stereo=1");break}return n.join("\r\n")}(t.sdp,e)),OvenPlayerConsole.log("Local SDP",t),P(A,{id:i,peer_id:s,command:"answer",sdp:t}),OvenPlayerConsole.log("create Host Answer : success"),I.setLocalDescription(t).then((function(){})).catch((function(t){var e=Qt.codes[505];e.error=t,B(e)}))})).catch((function(t){var e=Qt.codes[504];e.error=t,B(e)}))})).catch((function(t){var e=Qt.codes[503];e.error=t,B(e)})),u&&R(I,u),I.onicecandidate=function(t){t.candidate&&(OvenPlayerConsole.log("WebRTCLoader send candidate to server : ",t.candidate),P(A,{id:i,peer_id:s,command:"candidate",candidates:[t.candidate]}))},I.onconnectionstatechange=function(t){OvenPlayerConsole.log("[on connection state change]",I.connectionState,t),"connected"===I.connectionState&&r&&r()},I.onicecandidateerror=function(t){},I.onicegatheringstatechange=function(t){},I.oniceconnectionstatechange=function(t){OvenPlayerConsole.log("[on ice connection state change]",I.iceConnectionState,t),"connected"===I.iceConnectionState&&r&&r(),("disconnected"===I.iceConnectionState||"closed"===I.iceConnectionState)&&(g||f&&B(Qt.codes[511]))},I.ontrack=function(t){if(OvenPlayerConsole.log("stream received."),OvenPlayerConsole.log("Recovery On Packet Loss :",m),m&&T(f),h=t.streams[0],n(t.streams[0]),a.getConfig().webrtcConfig&&a.getConfig().webrtcConfig.playoutDelayHint)for(var e=a.getConfig().webrtcConfig.playoutDelayHint,r=f.peerConnection.getReceivers(),i=0;i0){for(var n in p){var r=p[n].peerConnection;r&&(OvenPlayerConsole.log("Closing client peer connection..."),r.close(),r=null)}p={}}A?(OvenPlayerConsole.log("Closing websocket connection..."),OvenPlayerConsole.log("Send Signaling : Stop."),1===A.readyState&&(g=!0,f&&P(A,{command:"stop",id:f.id}),A.close())):g=!1,A=null,e&&(i&&i(e),s(e,t))}function P(t,e){t&&t.send(JSON.stringify(e))}return E=window.onbeforeunload,window.onbeforeunload=function(t){E&&E(t),OvenPlayerConsole.log("This calls auto when browser closed."),B()},t.setCurrentQuality=function(t){if(!v)return-1;var e=v.renditions[t];return e?(P(A,{command:"change_rendition",id:f.id,rendition_name:e.name,auto:!1}),y=!1,l.currentQuality=t,l.currentQuality):l.currentQuality},t.isAutoQuality=function(){return y},t.setAutoQuality=function(t){P(A,{command:"change_rendition",id:f.id,auto:t}),y=t},u.connect=function(){OvenPlayerConsole.log("WebRTCLoader connecting..."),OvenPlayerConsole.log("WebRTCLoader url : "+e),D()},u.destroy=function(){g=!0,B(),window.onbeforeunload=E,E=null},u},En=function(t,e,n){var r={},i=null,o=null,s=null,a=null,l=null,c={name:ut,element:t,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:q,buffer:0,framerate:0,currentQuality:-1,currentSource:-1,qualityLevels:[],sources:[],adTagUrl:n},u=1e4,A=0,d=null,h=!1;function f(){if(Kt(a.file,a.type)){clearTimeout(d),OvenPlayerConsole.log("WEBRTC : onBeforeLoad : ",a),i&&(i.destroy(),i=null);var n=null,o=null;A>0&&(n=function(){clearTimeout(d)},o=function(){clearTimeout(d),performance.now(),h=!0}),i=bn(r,a.file,(function(e){if(t.srcObject&&(t.srcObject=null),l&&(l.close(),l=null),t.srcObject=e,e.getAudioTracks().length>0){var n=window.AudioContext||window.webkitAudioContext;(function(t){var e=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent),n=(/iPhone|iPad|iPod/i.test(navigator.userAgent),!1);e&&"suspended"===t.state&&document.addEventListener("touchend",(function(){n||"running"===t.state||(t.resume(),n=!0)}))})(l=new n),l.createMediaStreamSource(e)}}),o,n,Jt,e,c),performance.now(),i.connect(),A>0&&(r.once(yt,(function(t){h||t.newstate===q&&(clearTimeout(d),p())})),r.once(vt,(function(){h=!1})),d=setTimeout((function(){if(A>0)h||(p(),f());else{p();var t=Qt.codes[512];Jt(t,r)}A--}),u))}}function p(){i&&(i.destroy(),i=null,t.srcObject=null)}return r=yn(c,e,(function(t){var n=e.getConfig();n.webrtcConfig&&("number"==typeof n.webrtcConfig.connectionTimeout&&n.webrtcConfig.connectionTimeout>0&&(u=n.webrtcConfig.connectionTimeout),"number"==typeof n.webrtcConfig.timeoutMaxRetry&&n.webrtcConfig.timeoutMaxRetry>0&&(A=n.webrtcConfig.timeoutMaxRetry)),a=t,f()})),o=r.super("destroy"),s=r.super("play"),OvenPlayerConsole.log("WEBRTC PROVIDER LOADED."),r.removeStream=function(){t.srcObject=null},r.destroy=function(){clearTimeout(d),p(),OvenPlayerConsole.log("WEBRTC : PROVIDER DESTROYED."),o()},r.play=function(){A>0&&!h&&f(),s()},r},wn=function(t,e,n){var r=e?1e3:1024;if(Math.abs(t)=r&&sNumber.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;const n=new Uint8Array(e.length/2);for(let t=0;tNumber.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const n=this[t];return n?parseFloat(n):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){const e=Qn.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const n={};for(Gn.lastIndex=0;null!==(e=Gn.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1)),n[e[1].trim()]=t}return n}}function Yn(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}class jn{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const n=e.attr;for(const e in n)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==n[e]){Un.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=Dn(new Wn({}),n,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=new Date(this.attr["END-DATE"]);Bn(t.getTime())&&(this._endDate=t)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(Bn(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Bn(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Hn{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var Kn="audio",Vn="video",zn="audiovideo";class $n{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Kn]:null,[Vn]:null,[zn]:null},this.baseurl=t}setByteRange(t,e){const n=t.split("@",2),r=[];1===n.length?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(n[1]),r[1]=parseInt(n[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ln.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Xn extends $n{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Hn,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!Bn(this.programDateTime))return null;const t=Bn(this.duration)?this.duration:0;return this.programDateTime+1e3*t}get encrypted(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),e=t.length;if(e>1||1===e&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()}setElementaryStreamInfo(t,e,n,r,i,o=!1){const{elementaryStreams:s}=this,a=s[t];a?(a.startPTS=Math.min(a.startPTS,e),a.endPTS=Math.max(a.endPTS,n),a.startDTS=Math.min(a.startDTS,r),a.endDTS=Math.max(a.endDTS,i)):s[t]={startPTS:e,endPTS:n,startDTS:r,endDTS:i,partial:o}}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t.audio=null,t.video=null,t.audiovideo=null}}class qn extends $n{constructor(t,e,n,r,i){super(n),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Hn,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=r;const o=t.enumeratedString("BYTERANGE");o&&this.setByteRange(o,i),i&&(this.fragOffset=i.fragOffset+i.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}class Jn{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t)return this.advanced=!0,void(this.updated=!0);const e=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&Bn(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Zn(t){return Uint8Array.from(atob(t),(t=>t.charCodeAt(0)))}function tr(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(t=>t.charCodeAt(0)))}var er={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},nr="org.w3.clearkey",rr="com.apple.streamingkeydelivery",ir="com.microsoft.playready",or="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function sr(t){switch(t){case rr:return er.FAIRPLAY;case ir:return er.PLAYREADY;case or:return er.WIDEVINE;case nr:return er.CLEARKEY}}var ar="edef8ba979d64acea3c827dcd51d21ed";function lr(t){switch(t){case er.FAIRPLAY:return rr;case er.PLAYREADY:return ir;case er.WIDEVINE:return or;case er.CLEARKEY:return nr}}function cr(t){const{drmSystems:e,widevineLicenseUrl:n}=t,r=e?[er.FAIRPLAY,er.WIDEVINE,er.PLAYREADY,er.CLEARKEY].filter((t=>!!e[t])):[];return!r[er.WIDEVINE]&&n&&r.push(er.WIDEVINE),r}const ur="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Ar(t,e,n){return Uint8Array.prototype.slice?t.slice(e,n):new Uint8Array(Array.prototype.slice.call(t,e,n))}const dr=(t,e)=>e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,hr=(t,e)=>e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,fr=(t,e)=>{const n=e;let r=0;for(;dr(t,e);)r+=10,r+=pr(t,e+6),hr(t,e+10)&&(r+=10),e+=r;if(r>0)return t.subarray(n,n+r)},pr=(t,e)=>{let n=0;return n=(127&t[e])<<21,n|=(127&t[e+1])<<14,n|=(127&t[e+2])<<7,n|=127&t[e+3],n},gr=(t,e)=>dr(t,e)&&pr(t,e+6)+10<=t.length-e,mr=t=>t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,vr=t=>{const e=String.fromCharCode(t[0],t[1],t[2],t[3]),n=pr(t,4);return{type:e,size:n,data:t.subarray(10,10+n)}},yr=t=>{let e=0;const n=[];for(;dr(t,e);){const r=pr(t,e+6);e+=10;const i=e+r;for(;e+8"PRIV"===t.type?br(t):"W"===t.type[0]?wr(t):Er(t),br=t=>{if(t.size<2)return;const e=Sr(t.data,!0),n=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:n.buffer}},Er=t=>{if(t.size<2)return;if("TXXX"===t.type){let e=1;const n=Sr(t.data.subarray(e),!0);e+=n.length+1;const r=Sr(t.data.subarray(e));return{key:t.type,info:n,data:r}}const e=Sr(t.data.subarray(1));return{key:t.type,data:e}},wr=t=>{if("WXXX"===t.type){if(t.size<2)return;let e=1;const n=Sr(t.data.subarray(e),!0);e+=n.length+1;const r=Sr(t.data.subarray(e));return{key:t.type,info:n,data:r}}const e=Sr(t.data);return{key:t.type,data:e}},Tr=t=>{if(8===t.data.byteLength){const e=new Uint8Array(t.data),n=1&e[3];let r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,n&&(r+=47721858.84),Math.round(r)}},Sr=(t,e=!1)=>{const n=Lr();if(n){const r=n.decode(t);if(e){const t=r.indexOf("\0");return-1!==t?r.substring(0,t):r}return r.replace(/\0/g,"")}const r=t.length;let i,o,s,a="",l=0;for(;l>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:o=t[l++],a+=String.fromCharCode((31&i)<<6|63&o);break;case 14:o=t[l++],s=t[l++],a+=String.fromCharCode((15&i)<<12|(63&o)<<6|(63&s)<<0)}}return a};let kr;function Lr(){return kr||void 0===self.TextDecoder||(kr=new self.TextDecoder("utf-8")),kr}const xr=function(t){let e="";for(let n=0;n>24,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n}function _r(t,e){const n=[];if(!e.length)return n;const r=t.byteLength;for(let i=0;i1?i+o:r;if(Br(t.subarray(i+4,i+8))===e[0])if(1===e.length)n.push(t.subarray(i+8,s));else{const r=_r(t.subarray(i+8,s),e.slice(1));r.length&&Rr.apply(n,r)}i=s}return n}function Nr(t){const e=[],n=t[0];let r=8;const i=Mr(t,r);r+=4,r+=0===n?8:16,r+=2;let o=t.length+0;const s=Pr(t,r);r+=2;for(let n=0;n>>31)return Un.warn("SIDX has hierarchical references (not supported)"),null;const l=Mr(t,n);n+=4,e.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/i,start:o,end:o+a-1}}),o+=a,n+=4,r=n}return{earliestPresentationTime:0,timescale:i,version:n,referencesCount:s,references:e}}function Ur(t){const e=[],n=_r(t,["moov","trak"]);for(let t=0;t{const n=Mr(t,4),r=e[n];r&&(r.default={duration:Mr(t,12),flags:Mr(t,20)})})),e}function Qr(t){const e=_r(t,["schm"])[0];if(e){const n=Br(e.subarray(4,8));if("cbcs"===n||"cenc"===n)return _r(t,["schi","tenc"])[0]}return Un.error("[eme] missing 'schm' box"),null}function Gr(t){const e=Mr(t,0);let n=8;1&e&&(n+=4),4&e&&(n+=4);let r=0;const i=Mr(t,4);for(let o=0;o{const l=a.byteOffset-8;_r(a,["traf"]).map((a=>{const c=_r(a,["tfdt"]).map((t=>{const e=t[0];let n=Mr(t,4);return 1===e&&(n*=Math.pow(2,32),n+=Mr(t,8)),n/i}))[0];return void 0!==c&&(t=c),_r(a,["tfhd"]).map((c=>{const u=Mr(c,4),A=16777215&Mr(c,0);let d=0;const h=0!=(16&A);let f=0;const p=0!=(32&A);let g=8;u===o&&(0!=(1&A)&&(g+=8),0!=(2&A)&&(g+=4),0!=(8&A)&&(d=Mr(c,g),g+=4),h&&(f=Mr(c,g),g+=4),p&&(g+=4),"video"===e.type&&(s=function(t){if(!t)return!1;const e=t.indexOf("."),n=e<0?t:t.substring(0,e);return"hvc1"===n||"hev1"===n||"dvh1"===n||"dvhe"===n}(e.codec)),_r(a,["trun"]).map((o=>{const a=o[0],c=16777215&Mr(o,0),u=0!=(1&c);let A=0;const h=0!=(4&c),p=0!=(256&c);let g=0;const m=0!=(512&c);let v=0;const y=0!=(1024&c),C=0!=(2048&c);let b=0;const E=Mr(o,4);let w=8;u&&(A=Mr(o,w),w+=4),h&&(w+=4);let T=A+l;for(let l=0;l>1&63;return 39===t||40===t}return 6==(31&e)}function Hr(t,e,n,r){const i=Kr(t);let o=0;o+=e;let s=0,a=0,l=!1,c=0;for(;o=i.length)break;c=i[o++],s+=c}while(255===c);a=0;do{if(o>=i.length)break;c=i[o++],a+=c}while(255===c);const t=i.length-o;if(!l&&4===s&&o16){const t=[];for(let e=0;e<16;e++){const n=i[o++].toString(16);t.push(1==n.length?"0"+n:n),3!==e&&5!==e&&7!==e&&9!==e||t.push("-")}const e=a-16,l=new Uint8Array(e);for(let t=0;tt)break}}function Kr(t){const e=t.byteLength,n=[];let r=1;for(;r>8*(15-n)&255;return e}(t);return new zr(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=function(t){const e=t.split(":");let n=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),r=t[t.length-1].split(",");if(2===r.length){const e="base64"===r[0],i=r[1];e?(t.splice(-1,1),n=Zn(i)):n=function(t){const e=tr(t).subarray(0,16),n=new Uint8Array(16);return n.set(e,16-e.length),n}(i)}}return n}(this.uri);if(e)switch(this.keyFormat){case or:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case ir:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(t,e,n){if(16!==t.byteLength)throw new RangeError("Invalid system id");let r,i,o;if(e){r=1,i=new Uint8Array(16*e.length);for(let t=0;t0?(o=new Uint8Array(4),e.length>0&&new DataView(o.buffer).setUint32(0,e.length,!1)):o=new Uint8Array;const s=new Uint8Array(4);return n&&n.byteLength>0&&new DataView(s.buffer).setUint32(0,n.byteLength,!1),function(t,...e){const n=e.length;let r=8,i=n;for(;i--;)r+=e[i].byteLength;const o=new Uint8Array(r);for(o[0]=r>>24&255,o[1]=r>>16&255,o[2]=r>>8&255,o[3]=255&r,o.set(t,4),i=0,r=8;i{const r=e.substring(2,e.length-1),i=null==n?void 0:n[r];return void 0===i?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),e):i}))}return e}function Zr(t,e,n){let r,i,o=t.variableList;if(o||(t.variableList=o={}),"QUERYPARAM"in e){r=e.QUERYPARAM;try{const t=new self.URL(n).searchParams;if(!t.has(r))throw new Error(`"${r}" does not match any query parameter in URI: "${n}"`);i=t.get(r)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`))}}else r=e.NAME,i=e.VALUE;r in o?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):o[r]=i||""}function ti(t,e,n){const r=e.IMPORT;if(n&&r in n){let e=t.variableList;e||(t.variableList=e={}),e[r]=n[r]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function ei(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const ni={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},ri=ei();function ii(t,e){var n;return null!=(n=null==ri?void 0:ri.isTypeSupported(`${e||"video"}/mp4;codecs="${t}"`))&&n}const oi=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,si=/#EXT-X-MEDIA:(.*)/g,ai=/^#EXT(?:INF|-X-TARGETDURATION):/m,li=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ci=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class ui{static findGroup(t,e){for(let n=0;n2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return t}static resolve(t,e){return Ln.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return ai.test(t)}static parseMasterPlaylist(t,e){const n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Xr(t)},r=[];let i;for(oi.lastIndex=0;null!=(i=oi.exec(t));)if(i[1]){var o;const t=new Wn(i[1]);qr(n,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const s=Jr(n,i[2]),a={attrs:t,bitrate:t.decimalInteger("AVERAGE-BANDWIDTH")||t.decimalInteger("BANDWIDTH"),name:t.NAME,url:ui.resolve(s,e)},l=t.decimalResolution("RESOLUTION");l&&(a.width=l.width,a.height=l.height),hi((t.CODECS||"").split(/[ ,]+/).filter((t=>t)),a),a.videoCodec&&-1!==a.videoCodec.indexOf("avc1")&&(a.videoCodec=ui.convertAVC1ToAVCOTI(a.videoCodec)),null!=(o=a.unknownCodecs)&&o.length||r.push(a),n.levels.push(a)}else if(i[3]){const t=i[3],r=i[4];switch(t){case"SESSION-DATA":{const t=new Wn(r);qr(n,t,["DATA-ID","LANGUAGE","VALUE","URI"]);const e=t["DATA-ID"];e&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[e]=t);break}case"SESSION-KEY":{const t=Ai(r,e,n);t.encrypted&&t.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(t)):Un.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${r}"`);break}case"DEFINE":{const t=new Wn(r);qr(n,t,["NAME","VALUE","QUERYPARAM"]),Zr(n,t,e)}break;case"CONTENT-STEERING":{const t=new Wn(r);qr(n,t,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:ui.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":n.startTimeOffset=di(r)}}const s=r.length>0&&r.length({id:t.attrs.AUDIO,audioCodec:t.audioCodec}))),SUBTITLES:o.map((t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec}))),"CLOSED-CAPTIONS":[]};let a=0;for(si.lastIndex=0;null!==(r=si.exec(t));){const t=new Wn(r[1]),o=t.TYPE;if(o){const r=s[o],l=i[o]||[];i[o]=l,qr(n,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const c={attrs:t,bitrate:0,id:a++,groupId:t["GROUP-ID"]||"",instreamId:t["INSTREAM-ID"],name:t.NAME||t.LANGUAGE||"",type:o,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:t.LANGUAGE,url:t.URI?ui.resolve(t.URI,e):""};if(null!=r&&r.length){const t=ui.findGroup(r,c.groupId)||r[0];fi(c,t,"audioCodec"),fi(c,t,"textCodec")}l.push(c)}}return i}static parseLevelPlaylist(t,e,n,r,i,o){const s=new Jn(e),a=s.fragments;let l,c,u,A=null,d=0,h=0,f=0,p=0,g=null,m=new Xn(r,e),v=-1,y=!1;for(li.lastIndex=0,s.m3u8=t,s.hasVariableRefs=Xr(t);null!==(l=li.exec(t));){y&&(y=!1,m=new Xn(r,e),m.start=f,m.sn=d,m.cc=p,m.level=n,A&&(m.initSegment=A,m.rawProgramDateTime=A.rawProgramDateTime,A.rawProgramDateTime=null));const t=l[1];if(t){m.duration=parseFloat(t);const e=(" "+l[2]).slice(1);m.title=e||null,m.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(Bn(m.duration)){m.start=f,u&&mi(m,u,s),m.sn=d,m.level=n,m.cc=p,m.urlId=i,a.push(m);const t=(" "+l[3]).slice(1);m.relurl=Jr(s,t),pi(m,g),g=m,f+=m.duration,d++,h=0,y=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);g?m.setByteRange(t,g):m.setByteRange(t)}else if(l[5])m.rawProgramDateTime=(" "+l[5]).slice(1),m.tagList.push(["PROGRAM-DATE-TIME",m.rawProgramDateTime]),-1===v&&(v=a.length);else{if(l=l[0].match(ci),!l){Un.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c0&&t.bool("CAN-SKIP-DATERANGES"),s.partHoldBack=t.optionalFloat("PART-HOLD-BACK",0),s.holdBack=t.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const t=new Wn(i);s.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=s.partList;t||(t=s.partList=[]);const n=h>0?t[t.length-1]:void 0,r=h++,o=new Wn(i);qr(s,o,["BYTERANGE","URI"]);const a=new qn(o,m,e,r,n);t.push(a),m.duration+=a.duration;break}case"PRELOAD-HINT":{const t=new Wn(i);qr(s,t,["URI"]),s.preloadHint=t;break}case"RENDITION-REPORT":{const t=new Wn(i);qr(s,t,["URI"]),s.renditionReports=s.renditionReports||[],s.renditionReports.push(t);break}default:Un.warn(`line parsed but not handled: ${l}`)}}}g&&!g.relurl?(a.pop(),f-=g.duration,s.partList&&(s.fragmentHint=g)):s.partList&&(pi(m,g),m.cc=p,s.fragmentHint=m,u&&mi(m,u,s));const C=a.length,b=a[0],E=a[C-1];if(f+=s.skippedSegments*s.targetduration,f>0&&C&&E){s.averagetargetduration=f/C;const t=E.sn;s.endSN="initSegment"!==t?t:0,s.live||(E.endList=!0),b&&(s.startCC=b.cc)}else s.endSN=0,s.startCC=0;return s.fragmentHint&&(f+=s.fragmentHint.duration),s.totalduration=f,s.endCC=p,v>0&&function(t,e){let n=t[e];for(let r=e;r--;){const e=t[r];if(!e)return;e.programDateTime=n.programDateTime-1e3*e.duration,n=e}}(a,v),s}}function Ai(t,e,n){var r,i;const o=new Wn(t);qr(n,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const s=null!=(r=o.METHOD)?r:"",a=o.URI,l=o.hexadecimalInteger("IV"),c=o.KEYFORMATVERSIONS,u=null!=(i=o.KEYFORMAT)?i:"identity";a&&o.IV&&!l&&Un.error(`Invalid IV: ${o.IV}`);const A=a?ui.resolve(a,e):"",d=(c||"1").split("/").map(Number).filter(Number.isFinite);return new zr(s,A,u,d,l)}function di(t){const e=new Wn(t).decimalFloatingPoint("TIME-OFFSET");return Bn(e)?e:null}function hi(t,e){["video","audio","text"].forEach((n=>{const r=t.filter((t=>function(t,e){const n=ni[e];return!!n&&!0===n[t.slice(0,4)]}(t,n)));if(r.length){const i=r.filter((t=>0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)));e[`${n}Codec`]=i.length>0?i[0]:r[0],t=t.filter((t=>-1===r.indexOf(t)))}})),e.unknownCodecs=t}function fi(t,e,n){const r=e[n];r&&(t[n]=r)}function pi(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),Bn(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function gi(t,e,n,r){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=n,t.sn="initSegment",r&&(t.levelkeys=r),t.initSegment=null}function mi(t,e,n){t.levelkeys=e;const{encryptedFragments:r}=n;r.length&&r[r.length-1].levelkeys===e||!Object.keys(e).some((t=>e[t].isCommonEncryption))||r.push(t)}var vi="manifest",yi="level",Ci="audioTrack",bi="subtitleTrack",Ei="main",wi="audio",Ti="subtitle";function Si(t){const{type:e}=t;switch(e){case Ci:return wi;case bi:return Ti;default:return Ei}}function ki(t,e){let n=t.url;return void 0!==n&&0!==n.indexOf("data:")||(n=e.url),n}class Li{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.on(Pn.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(Pn.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.off(Pn.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(Pn.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,n=e.pLoader,r=e.loader,i=new(n||r)(e);return this.loaders[t.type]=i,i}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:n}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:vi,url:n,deliveryDirectives:null})}onLevelLoading(t,e){const{id:n,level:r,url:i,deliveryDirectives:o}=e;this.load({id:n,level:r,responseType:"text",type:yi,url:i,deliveryDirectives:o})}onAudioTrackLoading(t,e){const{id:n,groupId:r,url:i,deliveryDirectives:o}=e;this.load({id:n,groupId:r,level:null,responseType:"text",type:Ci,url:i,deliveryDirectives:o})}onSubtitleTrackLoading(t,e){const{id:n,groupId:r,url:i,deliveryDirectives:o}=e;this.load({id:n,groupId:r,level:null,responseType:"text",type:bi,url:i,deliveryDirectives:o})}load(t){var e;const n=this.hls.config;let r,i=this.getInternalLoader(t);if(i){const e=i.context;if(e&&e.url===t.url)return void Un.trace("[playlist-loader]: playlist request ongoing");Un.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),i.abort()}if(r=t.type===vi?n.manifestLoadPolicy.default:Dn({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),i=this.createInternalLoader(t),null!=(e=t.deliveryDirectives)&&e.part){let e;if(t.type===yi&&null!==t.level?e=this.hls.levels[t.level].details:t.type===Ci&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===bi&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,n=e.targetduration;if(t&&n){const e=1e3*Math.max(3*t,.8*n);r=Dn({},r,{maxTimeToFirstByteMs:Math.min(e,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(e,r.maxTimeToFirstByteMs)})}}}const o=r.errorRetry||r.timeoutRetry||{},s={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},a={onSuccess:(t,e,n,r)=>{const i=this.getInternalLoader(n);this.resetInternalLoader(n.type);const o=t.data;0===o.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),ui.isMediaPlaylist(o)?this.handleTrackOrLevelPlaylist(t,e,n,r||null,i):this.handleMasterPlaylist(t,e,n,r)):this.handleManifestParsingError(t,n,new Error("no EXTM3U delimiter"),r||null,e)},onError:(t,e,n,r)=>{this.handleNetworkError(e,n,!1,t,r)},onTimeout:(t,e,n)=>{this.handleNetworkError(e,n,!0,void 0,t)}};i.load(t,s,a)}handleMasterPlaylist(t,e,n,r){const i=this.hls,o=t.data,s=ki(t,n),a=ui.parseMasterPlaylist(o,s);if(a.playlistParsingError)return void this.handleManifestParsingError(t,n,a.playlistParsingError,r,e);const{contentSteering:l,levels:c,sessionData:u,sessionKeys:A,startTimeOffset:d,variableList:h}=a;this.variableList=h;const{AUDIO:f=[],SUBTITLES:p,"CLOSED-CAPTIONS":g}=ui.parseMasterPlaylistMedia(o,s,a);f.length&&(f.some((t=>!t.url))||!c[0].audioCodec||c[0].attrs.AUDIO||(Un.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Wn({}),bitrate:0,url:""}))),i.trigger(Pn.MANIFEST_LOADED,{levels:c,audioTracks:f,subtitles:p,captions:g,contentSteering:l,url:s,stats:e,networkDetails:r,sessionData:u,sessionKeys:A,startTimeOffset:d,variableList:h})}handleTrackOrLevelPlaylist(t,e,n,r,i){const o=this.hls,{id:s,level:a,type:l}=n,c=ki(t,n),u=Bn(s)?s:0,A=Bn(a)?a:u,d=Si(n),h=ui.parseLevelPlaylist(t.data,c,A,d,u,this.variableList);if(l===vi){const t={attrs:new Wn({}),bitrate:0,details:h,name:"",url:c};o.trigger(Pn.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:c,stats:e,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),n.levelDetails=h,this.handlePlaylistLoaded(h,t,e,n,r,i)}handleManifestParsingError(t,e,n,r,i){this.hls.trigger(Pn.ERROR,{type:Mn.NETWORK_ERROR,details:On.MANIFEST_PARSING_ERROR,fatal:e.type===vi,url:t.url,err:n,error:n,reason:n.message,response:t,context:e,networkDetails:r,stats:i})}handleNetworkError(t,e,n=!1,r,i){let o=`A network ${n?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${t.type}`;t.type===yi?o+=`: ${t.level} id: ${t.id}`:t.type!==Ci&&t.type!==bi||(o+=` id: ${t.id} group-id: "${t.groupId}"`);const s=new Error(o);Un.warn(`[playlist-loader]: ${o}`);let a=On.UNKNOWN,l=!1;const c=this.getInternalLoader(t);switch(t.type){case vi:a=n?On.MANIFEST_LOAD_TIMEOUT:On.MANIFEST_LOAD_ERROR,l=!0;break;case yi:a=n?On.LEVEL_LOAD_TIMEOUT:On.LEVEL_LOAD_ERROR,l=!1;break;case Ci:a=n?On.AUDIO_TRACK_LOAD_TIMEOUT:On.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case bi:a=n?On.SUBTITLE_TRACK_LOAD_TIMEOUT:On.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(t.type);const u={type:Mn.NETWORK_ERROR,details:a,fatal:l,url:t.url,loader:c,context:t,error:s,networkDetails:e,stats:i};if(r){const n=(null==e?void 0:e.url)||t.url;u.response=In({url:n,data:void 0},r)}this.hls.trigger(Pn.ERROR,u)}handlePlaylistLoaded(t,e,n,r,i,o){const s=this.hls,{type:a,level:l,id:c,groupId:u,deliveryDirectives:A}=r,d=ki(e,r),h=Si(r),f="number"==typeof r.level&&h===Ei?l:void 0;if(!t.fragments.length){const t=new Error("No Segments found in Playlist");return void s.trigger(Pn.ERROR,{type:Mn.NETWORK_ERROR,details:On.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:t,reason:t.message,response:e,context:r,level:f,parent:h,networkDetails:i,stats:n})}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const p=t.playlistParsingError;if(p)s.trigger(Pn.ERROR,{type:Mn.NETWORK_ERROR,details:On.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:p,reason:p.message,response:e,context:r,level:f,parent:h,networkDetails:i,stats:n});else switch(t.live&&o&&(o.getCacheAge&&(t.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),a){case vi:case yi:s.trigger(Pn.LEVEL_LOADED,{details:t,level:f||0,id:c||0,stats:n,networkDetails:i,deliveryDirectives:A});break;case Ci:s.trigger(Pn.AUDIO_TRACK_LOADED,{details:t,id:c||0,groupId:u||"",stats:n,networkDetails:i,deliveryDirectives:A});break;case bi:s.trigger(Pn.SUBTITLE_TRACK_LOADED,{details:t,id:c||0,groupId:u||"",stats:n,networkDetails:i,deliveryDirectives:A})}}}function xi(t,e){let n;try{n=new Event("addtrack")}catch(t){n=document.createEvent("Event"),n.initEvent("addtrack",!1,!1)}n.track=t,e.dispatchEvent(n)}function Ii(t,e){const n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(n){Un.debug(`[texttrack-utils]: ${n}`);try{const n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}catch(t){Un.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`)}}"disabled"===n&&(t.mode=n)}function Ri(t){const e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(let e=t.cues.length;e--;)t.removeCue(t.cues[e]);"disabled"===e&&(t.mode=e)}function Di(t,e,n,r){const i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues&&t.cues.length>0){const i=function(t,e,n){const r=[],i=function(t,e){if(et[n].endTime)return-1;let r=0,i=n;for(;r<=i;){const o=Math.floor((i+r)/2);if(et[o].startTime&&r-1)for(let o=i,s=t.length;o=e&&i.endTime<=n)r.push(i);else if(i.startTime>n)return r}return r}(t.cues,e,n);for(let e=0;e{const t=Mi();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Fi(t,e){return t.getTime()/1e3-e}class _i{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Ri(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;eOi&&(r=Oi),r-n<=0&&(r=n+.25);for(let t=0;tt.type===Bi&&a:"video"===r?t=>t.type===Pi&&s:t=>t.type===Bi&&a||t.type===Pi&&s,Di(i,e,n,t)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:n,id3Track:r}=this,{dateRanges:i}=e,o=Object.keys(i);if(r){const t=Object.keys(n).filter((t=>!o.includes(t)));for(let e=t.length;e--;){const i=t[e];Object.keys(n[i].cues).forEach((t=>{r.removeCue(n[i].cues[t])})),delete n[i]}}const s=e.fragments[e.fragments.length-1];if(0===o.length||!Bn(null==s?void 0:s.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=s.programDateTime/1e3-s.start,l=Mi();for(let t=0;t{const n=i[e];return n.class===r.class&&n.id!==e&&n.startDate>r.startDate&&t.push(n),t}),[]).sort(((t,e)=>t.startDate.getTime()-e.startDate.getTime()))[0];t&&(f=Fi(t.startDate,a),d=!0)}const g=Object.keys(r.attr);for(let t=0;tthis.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(null===t)return null;const{holdBack:e,partHoldBack:n,targetduration:r}=t,{liveSyncDuration:i,liveSyncDurationCount:o,lowLatencyMode:s}=this.config,a=this.hls.userConfig;let l=s&&n||e;(a.liveSyncDuration||a.liveSyncDurationCount||0===l)&&(l=void 0!==i?i:o*r);const c=r;return l+Math.min(1*this.stallCount,c)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,n=this.levelDetails;if(null===t||null===e||null===n)return null;const r=n.edge,i=t-e-this.edgeStalled,o=r-n.totalduration,s=r-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(o,i),s)}get drift(){const{levelDetails:t}=this;return null===t?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(null===t)return 0;const e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const n=t.buffered.length;return(n?t.buffered.end(n-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Pn.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Pn.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var n;e.details===On.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(n=this.levelDetails)&&n.live&&Un.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const n=this.computeLatency();if(null===n)return;this._latency=n;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:i}=this.config;if(!r||1===i)return;const o=this.targetLatency;if(null===o)return;const s=n-o,a=s.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,i)),n=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,n))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return null===t?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}const Ui=["NONE","TYPE-0","TYPE-1",null];class Qi{constructor(t,e,n){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=n}addDirectives(t){const e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Gi{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((t=>t)).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}get textGroupId(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function Wi(t,e){const n=e.startPTS;if(Bn(n)){let r,i=0;e.sn>t.sn?(i=n-t.start,r=t):(i=t.start-n,r=e),r.duration!==i&&(r.duration=i)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function Yi(t,e,n,r,i,o){r-n<=0&&(Un.warn("Fragment should have a positive duration",e),r=n+e.duration,o=i+e.duration);let s=n,a=r;const l=e.startPTS,c=e.endPTS;if(Bn(l)){const t=Math.abs(l-n);Bn(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,s=Math.max(n,l),n=Math.min(n,l),i=Math.min(i,e.startDTS),a=Math.min(r,c),r=Math.max(r,c),o=Math.max(o,e.endDTS)}const u=n-e.start;0!==e.start&&(e.start=n),e.duration=r-e.start,e.startPTS=n,e.maxStartPTS=s,e.startDTS=i,e.endPTS=r,e.minEndPTS=a,e.endDTS=o;const A=e.sn;if(!t||At.endSN)return 0;let d;const h=A-t.startSN,f=t.fragments;for(f[h]=e,d=h;d>0;d--)Wi(f[d],f[d-1]);for(d=h;d=r.length||Hi(e,r[n].start)}function Hi(t,e){if(e){const n=t.fragments;for(let r=t.skippedSegments;r499)}(r)||!!n)}const Zi=function(t,e){let n=0,r=t.length-1,i=null,o=null;for(;n<=r;){i=(n+r)/2|0,o=t[i];const s=e(o);if(s>0)n=i+1;else{if(!(s<0))return o;r=i-1}}return null};function to(t,e,n=0,r=0){let i=null;if(t?i=e[t.sn-e[0].sn+1]||null:0===n&&0===e[0].start&&(i=e[0]),i&&0===eo(n,r,i))return i;const o=Zi(e,eo.bind(null,n,r));return!o||o===t&&i?i:o}function eo(t=0,e=0,n){if(n.start<=t&&n.start+n.duration>t)return 0;const r=Math.min(e,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-r<=t?1:n.start-r>t&&n.start?-1:0}function no(t,e,n){const r=1e3*Math.min(e,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-r>t}function ro(t,e,n){if(performance.now()-t.lastErrorPerfMs>3e5)return!0;const r=t.details;if(e.details===On.FRAG_GAP&&r&&e.frag){const t=e.frag.start,n=to(null,r.fragments,t);if(n&&!n.gap)return!0}if(n&&t.errors.length3*r.targetduration)return!0}return!1}class io{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Un.log.bind(Un,`${e}:`),this.warn=Un.warn.bind(Un,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const n=null==e?void 0:e.renditionReports;if(n){let r=-1;for(let i=0;i=0&&t>e.partTarget&&(o+=1)}return new Qi(i,o>=0?o:void 0,"")}}}loadPlaylist(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,n){const{details:r,stats:i}=e,o=self.performance.now(),s=i.loading.first?Math.max(0,o-i.loading.first):0;if(r.advancedDateTime=Date.now()-s,r.live||null!=n&&n.live){if(r.reloaded(n),n&&this.log(`live playlist ${t} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),n&&r.fragments.length>0&&function(t,e){let n=null;const r=t.fragments;for(let t=r.length-1;t>=0;t--){const e=r[t].initSegment;if(e){n=e;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let i,o=0;if(function(t,e,n){const r=e.skippedSegments,i=Math.max(t.startSN,e.startSN)-e.startSN,o=(t.fragmentHint?1:0)+(r?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,a=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(let t=i;t<=o;t++){const i=l[s+t];let o=a[t];r&&!o&&t{t.relurl&&(o=t.cc-r.cc),Bn(t.startPTS)&&Bn(t.endPTS)&&(r.start=r.startPTS=t.startPTS,r.startDTS=t.startDTS,r.maxStartPTS=t.maxStartPTS,r.endPTS=t.endPTS,r.endDTS=t.endDTS,r.minEndPTS=t.minEndPTS,r.duration=t.endPTS-t.startPTS,r.duration&&(i=r),e.PTSKnown=e.alignedSliding=!0),r.elementaryStreams=t.elementaryStreams,r.loader=t.loader,r.stats=t.stats,r.urlId=t.urlId,t.initSegment&&(r.initSegment=t.initSegment,n=t.initSegment)})),n&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((t=>{var e;t.initSegment&&t.initSegment.relurl!==(null==(e=n)?void 0:e.relurl)||(t.initSegment=n)})),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((t=>!t)),e.deltaUpdateFailed){Un.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=e.skippedSegments;t--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=function(t,e,n){const r=Dn({},t);return n&&n.forEach((t=>{delete r[t]})),Object.keys(e).forEach((t=>{const n=new jn(e[t].attr,r[t]);n.isValid?r[t]=n:Un.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[t].attr)}"`)})),r}(t.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const s=e.fragments;if(o){Un.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),i?Yi(e,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS):ji(t,e),s.length&&(e.totalduration=e.edge-s[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;const a=e.advancedDateTime;if(e.advanced&&a){const t=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=t),e.driftEndTime=a,e.driftEnd=t}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}(n,r),!this.canLoad||!r.live)return;let s,a,l;if(r.canBlockReload&&r.endSN&&r.advanced){const t=this.hls.config.lowLatencyMode,i=r.lastPartSn,o=r.endSN,c=r.lastPartIndex,u=i===o,A=t?0:c;-1!==c?(a=u?o+1:i,l=u?A:c+1):a=o+1;const d=r.age,h=d+r.ageHeader;let f=Math.min(h-r.partTarget,1.5*r.targetduration);if(f>0){if(n&&f>n.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${f} with playlist age: ${r.age}`),f=0;else{const t=Math.floor(f/r.targetduration);a+=t,void 0!==l&&(l+=Math.round(f%r.targetduration/r.partTarget)),this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${f} skip sn ${t} to part ${l}`)}r.tuneInGoal=f}if(s=this.getDeliveryDirectives(r,e.deliveryDirectives,a,l),t||!u)return void this.loadPlaylist(s)}else(r.canBlockReload||r.canSkipUntil)&&(s=this.getDeliveryDirectives(r,e.deliveryDirectives,a,l));const c=this.hls.mainForwardBufferInfo,u=c?c.end-c.len:0,A=function(t,e=1/0){let n=1e3*t.targetduration;if(t.updated){const r=t.fragments,i=4;if(r.length&&n*i>e){const t=1e3*r[r.length-1].duration;tthis.requestScheduled+A&&(this.requestScheduled=i.loading.start),void 0!==a&&r.canBlockReload?this.requestScheduled=i.loading.first+A-(1e3*r.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+Athis.loadPlaylist(s)),d)}else this.clearTimer()}getDeliveryDirectives(t,e,n,r){let i=function(t,e){const{canSkipUntil:n,canSkipDateRanges:r,endSN:i}=t;return n&&(void 0!==e?e-i:0)=s.maxNumRetry)return!1;if(n&&null!=(l=t.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${o+1}/${s.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const t=Xi(s,o);this.timer=self.setTimeout((()=>this.loadPlaylist()),t),this.warn(`Retrying playlist loading ${o+1}/${s.maxNumRetry} after "${e}" in ${t}ms`)}t.levelRetry=!0,r.resolved=!0}return a}}let oo;class so extends io{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Pn.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Pn.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(Pn.FRAG_LOADED,this.onFragLoaded,this),t.on(Pn.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Pn.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Pn.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(Pn.FRAG_LOADED,this.onFragLoaded,this),t.off(Pn.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach((t=>{t.loadError=0,t.fragmentError=0})),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const n=[],r={};let i;e.levels.forEach((t=>{var e;const o=t.attrs;-1!==(null==(e=t.audioCodec)?void 0:e.indexOf("mp4a.40.34"))&&(oo||(oo=/chrome|firefox/i.test(navigator.userAgent)),oo&&(t.audioCodec=void 0));const{AUDIO:s,CODECS:a,"FRAME-RATE":l,"PATHWAY-ID":c,RESOLUTION:u,SUBTITLES:A}=o,d=`${c||"."}-${t.bitrate}-${u}-${l}-${a}`;i=r[d],i?i.addFallback(t):(i=new Gi(t),r[d]=i,n.push(i)),ao(i,"audio",s),ao(i,"text",A)})),this.filterAndSortMediaOptions(n,e)}filterAndSortMediaOptions(t,e){let n=[],r=[],i=!1,o=!1,s=!1,a=t.filter((({audioCodec:t,videoCodec:e,width:n,height:r,unknownCodecs:a})=>(i||(i=!(!n||!r)),o||(o=!!e),s||(s=!!t),!(null!=a&&a.length)&&(!t||ii(t,"audio"))&&(!e||ii(e,"video")))));if((i||o)&&s&&(a=a.filter((({videoCodec:t,width:e,height:n})=>!!t||!(!e||!n)))),0===a.length)return void Promise.resolve().then((()=>{if(this.hls){const t=new Error("no level with compatible codecs found in manifest");this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:t,reason:t.message})}}));e.audioTracks&&(n=e.audioTracks.filter((t=>!t.audioCodec||ii(t.audioCodec,"audio"))),lo(n)),e.subtitles&&(r=e.subtitles,lo(r));const l=a.slice(0);a.sort(((t,e)=>t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):i&&t.height!==e.height?t.height-e.height:0));let c=l[0];if(this.steering&&(a=this.steering.filterParsedLevels(a),a.length!==l.length))for(let t=0;t!!t.url))};this.hls.trigger(Pn.MANIFEST_PARSED,A),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(0===e.length)return;if(t<0||t>=e.length){const n=new Error("invalid level idx"),r=t<0;if(this.hls.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.LEVEL_SWITCH_ERROR,level:t,fatal:r,error:n,reason:n.message}),r)return;t=Math.min(t,e.length-1)}const n=this.currentLevelIndex,r=this.currentLevel,i=r?r.attrs["PATHWAY-ID"]:void 0,o=e[t],s=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=o,n===t&&o.details&&r&&i===s)return;this.log(`Switching to level ${t}${s?" with Pathway "+s:""} from level ${n}${i?" with Pathway "+i:""}`);const a=Dn({},o,{level:t,maxBitrate:o.maxBitrate,attrs:o.attrs,uri:o.uri,urlId:o.urlId});delete a._attrs,delete a._urlId,this.hls.trigger(Pn.LEVEL_SWITCHING,a);const l=o.details;if(!l||l.live){const t=this.switchParams(o.uri,null==r?void 0:r.details);this.loadPlaylist(t)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(void 0===this._startLevel){const t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){!e.fatal&&e.context&&e.context.type===yi&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(void 0!==e&&e.type===Ei){const t=this._levels[e.level];void 0!==t&&(t.loadError=0)}}onLevelLoaded(t,e){var n;const{level:r,details:i}=e,o=this._levels[r];var s;if(!o)return this.warn(`Invalid level index ${r}`),void(null!=(s=e.deliveryDirectives)&&s.skip&&(i.deltaUpdateFailed=!0));r===this.currentLevelIndex?(0===o.fragmentError&&(o.loadError=0),this.playlistLoaded(r,e,o.details)):null!=(n=e.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const n=this.currentLevel;if(!n)return;const r=this.hls.audioTracks[e.id].groupId;if(n.audioGroupIds&&n.audioGroupId!==r){let t=-1;for(let e=0;en!==e,r=this._levels.filter(((r,i)=>i!==t||(r.url.length>1&&void 0!==e?(r.url=r.url.filter(n),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(n)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(n)),r.urlId=0,!0):(this.steering&&this.steering.removeLevel(r),!1))));this.hls.trigger(Pn.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(t,{levels:e}){e.forEach(((t,e)=>{const{details:n}=t;null!=n&&n.fragments&&n.fragments.forEach((t=>{t.level=e}))})),this._levels=e}}function ao(t,e,n){n&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=n):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=n))}function lo(t){const e={};t.forEach((t=>{const n=t.groupId||"";t.id=e[n]=e[n]||0,e[n]++}))}var co="NOT_LOADED",uo="APPENDING",Ao="PARTIAL",ho="OK";class fo{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(Pn.BUFFER_APPENDED,this.onBufferAppended,this),t.on(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Pn.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.BUFFER_APPENDED,this.onBufferAppended,this),t.off(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Pn.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const n=this.activePartLists[e];if(n)for(let e=n.length;e--;){const r=n[e];if(!r)break;const i=r.end;if(r.start<=t&&null!==i&&t<=i)return r}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:n}=this,r=Object.keys(n);for(let i=r.length;i--;){const o=n[r[i]];if((null==o?void 0:o.body.type)===e&&o.buffered){const e=o.body;if(e.start<=t&&t<=e.end)return e}}return null}detectEvictedFragments(t,e,n,r){this.timeRanges&&(this.timeRanges[t]=e);const i=(null==r?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach((r=>{const o=this.fragments[r];if(!o)return;if(i>=o.body.sn)return;if(!o.buffered&&!o.loaded)return void(o.body.type===n&&this.removeFragment(o.body));const s=o.range[t];s&&s.time.some((t=>{const n=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return n&&this.removeFragment(o.body),n}))}))}detectPartialFragments(t){const e=this.timeRanges,{frag:n,part:r}=t;if(!e||"initSegment"===n.sn)return;const i=go(n),o=this.fragments[i];if(!o||o.buffered&&n.gap)return;const s=!n.relurl;Object.keys(e).forEach((t=>{const i=n.elementaryStreams[t];if(!i)return;const a=e[t],l=s||!0===i.partial;o.range[t]=this.getBufferedTimes(n,r,l,a)})),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,(o.body.endList=n.endList||o.body.endList)&&(this.endListFragments[o.body.type]=o),po(o)||this.removeParts(n.sn-1,n.type)):this.removeFragment(o.body)}removeParts(t,e){const n=this.activePartLists[e];n&&(this.activePartLists[e]=n.filter((e=>e.fragment.sn>=t)))}fragBuffered(t,e){const n=go(t);let r=this.fragments[n];!r&&e&&(r=this.fragments[n]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(t,e,n,r){const i={time:[],partial:n},o=t.start,s=t.end,a=t.minEndPTS||s,l=t.maxStartPTS||o;for(let t=0;t=e&&a<=n){i.time.push({startPTS:Math.max(o,r.start(t)),endPTS:Math.min(s,r.end(t))});break}if(oe)i.partial=!0,i.time.push({startPTS:Math.max(o,r.start(t)),endPTS:Math.min(s,r.end(t))});else if(s<=e)break}return i}getPartialFragment(t){let e,n,r,i=null,o=0;const{bufferPadding:s,fragments:a}=this;return Object.keys(a).forEach((l=>{const c=a[l];c&&po(c)&&(n=c.body.start-s,r=c.body.end+s,t>=n&&t<=r&&(e=Math.min(t-n,r-t),o<=e&&(i=c.body,o=e)))})),i}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||po(e))}getState(t){const e=go(t),n=this.fragments[e];return n?n.buffered?po(n)?Ao:ho:uo:co}isTimeBuffered(t,e,n){let r,i;for(let o=0;o=r&&e<=i)return!0;if(e<=r)return!1}return!1}onFragLoaded(t,e){const{frag:n,part:r}=e;if("initSegment"===n.sn||n.bitrateTest)return;const i=r?null:e,o=go(n);this.fragments[o]={body:n,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:n,part:r,timeRanges:i}=e;if("initSegment"===n.sn)return;const o=n.type;if(r){let t=this.activePartLists[o];t||(this.activePartLists[o]=t=[]),t.push(r)}this.timeRanges=i,Object.keys(i).forEach((t=>{const e=i[t];this.detectEvictedFragments(t,e,o,r)}))}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=go(t);return!!this.fragments[e]}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,n,r,i){r&&!this.hasGaps||Object.keys(this.fragments).forEach((o=>{const s=this.fragments[o];if(!s)return;const a=s.body;a.type!==n||r&&!a.gap||a.startt&&(s.buffered||i)&&this.removeFragment(a)}))}removeFragment(t){const e=go(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const n=this.activePartLists[t.type];if(n){const e=t.sn;this.activePartLists[t.type]=n.filter((t=>t.fragment.sn!==e))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function po(t){var e,n,r;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(n=t.range.audio)?void 0:n.partial)||(null==(r=t.range.audiovideo)?void 0:r.partial))}function go(t){return`${t.type}_${t.level}_${t.urlId}_${t.sn}`}const mo=Math.pow(2,17);class vo{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const n=t.url;if(!n)return Promise.reject(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();const r=this.config,i=r.fLoader,o=r.loader;return new Promise(((s,a)=>{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some((t=>"GAP"===t[0])))return void a(Co(t));t.gap=!1}const l=this.loader=t.loader=i?new i(r):new o(r),c=yo(t),u=qi(r.fragLoadPolicy.default),A={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:mo};t.stats=l.stats,l.load(c,A,{onSuccess:(e,n,r,i)=>{this.resetLoader(t,l);let o=e.data;r.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(o.slice(0,16)),o=o.slice(16)),s({frag:t,part:null,payload:o,networkDetails:i})},onError:(e,r,i,o)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:In({url:n,data:void 0},e),error:new Error(`HTTP Error ${e.code} ${e.text}`),networkDetails:i,stats:o}))},onAbort:(e,n,r)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:r,stats:e}))},onTimeout:(e,n,r)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:r,stats:e}))},onProgress:(n,r,i,o)=>{e&&e({frag:t,part:null,payload:i,networkDetails:o})}})}))}loadPart(t,e,n){this.abort();const r=this.config,i=r.fLoader,o=r.loader;return new Promise(((s,a)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void a(Co(t,e));const l=this.loader=t.loader=i?new i(r):new o(r),c=yo(t,e),u=qi(r.fragLoadPolicy.default),A={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:mo};e.stats=l.stats,l.load(c,A,{onSuccess:(r,i,o,a)=>{this.resetLoader(t,l),this.updateStatsFromPart(t,e);const c={frag:t,part:e,payload:r.data,networkDetails:a};n(c),s(c)},onError:(n,r,i,o)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:In({url:c.url,data:void 0},n),error:new Error(`HTTP Error ${n.code} ${n.text}`),networkDetails:i,stats:o}))},onAbort:(n,r,i)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:i,stats:n}))},onTimeout:(n,r,i)=>{this.resetLoader(t,l),a(new bo({type:Mn.NETWORK_ERROR,details:On.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:i,stats:n}))}})}))}updateStatsFromPart(t,e){const n=t.stats,r=e.stats,i=r.total;if(n.loaded+=r.loaded,i){const r=Math.round(t.duration/e.duration),o=Math.min(Math.round(n.loaded/i),r),s=(r-o)*Math.round(n.loaded/o);n.total=n.loaded+s}else n.total=Math.max(n.loaded,n.total);const o=n.loading,s=r.loading;o.start?o.first+=s.first-s.start:(o.start=s.start,o.first=s.first),o.end=s.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function yo(t,e=null){const n=e||t,r={frag:t,part:e,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},i=n.byteRangeStartOffset,o=n.byteRangeEndOffset;if(Bn(i)&&Bn(o)){var s;let e=i,n=o;if("initSegment"===t.sn&&"AES-128"===(null==(s=t.decryptdata)?void 0:s.method)){const t=o-i;t%16&&(n=o+(16-t%16)),0!==i&&(r.resetIV=!0,e=i-16)}r.rangeStart=e,r.rangeEnd=n}return r}function Co(t,e){const n=new Error(`GAP ${t.gap?"tag":"attribute"} found`),r={type:Mn.MEDIA_ERROR,details:On.FRAG_GAP,fatal:!1,frag:t,error:n,networkDetails:null};return e&&(r.part=e),(e||t).stats.aborted=!0,new bo(r)}class bo extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class Eo{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const n=this.keyUriToKeyInfo[e].loader;if(n){if(t&&t!==n.context.frag.type)return;n.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=On.KEY_LOAD_ERROR,n,r,i){return new bo({type:Mn.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:i,error:n,networkDetails:r})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:n,cc:r}=t;for(let t=0;t{i.setKeyFormat(t)}));break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then((e=>this.loadInternal(t,e))):this.loadInternal(t)}loadInternal(t,e){var n,r;e&&t.setKeyFormat(e);const i=t.decryptdata;if(!i){const n=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,On.KEY_LOAD_ERROR,n))}const o=i.uri;if(!o)return Promise.reject(this.createKeyLoadError(t,On.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));let s=this.keyUriToKeyInfo[o];if(null!=(n=s)&&n.decryptdata.key)return i.key=s.decryptdata.key,Promise.resolve({frag:t,keyInfo:s});var a;if(null!=(r=s)&&r.keyLoadPromise)switch(null==(a=s.mediaKeySessionContext)?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return s.keyLoadPromise.then((e=>(i.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:s})))}switch(s=this.keyUriToKeyInfo[o]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===i.keyFormat?this.loadKeyHTTP(s,t):this.loadKeyEME(s,t);case"AES-128":return this.loadKeyHTTP(s,t);default:return Promise.reject(this.createKeyLoadError(t,On.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(t,e){const n={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(n);if(e)return(t.keyLoadPromise=e.then((e=>(t.mediaKeySessionContext=e,n)))).catch((e=>{throw t.keyLoadPromise=null,e}))}return Promise.resolve(n)}loadKeyHTTP(t,e){const n=this.config,r=new(0,n.loader)(n);return e.keyLoader=t.loader=r,t.keyLoadPromise=new Promise(((i,o)=>{const s={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},a=n.keyLoadPolicy.default,l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,n,r)=>{const{frag:s,keyInfo:a,url:l}=n;if(!s.decryptdata||a!==this.keyUriToKeyInfo[l])return o(this.createKeyLoadError(s,On.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),r));a.decryptdata.key=s.decryptdata.key=new Uint8Array(t.data),s.keyLoader=null,a.loader=null,i({frag:s,keyInfo:a})},onError:(t,n,r,i)=>{this.resetLoader(n),o(this.createKeyLoadError(e,On.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),r,In({url:s.url,data:void 0},t)))},onTimeout:(t,n,r)=>{this.resetLoader(n),o(this.createKeyLoadError(e,On.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),r))},onAbort:(t,n,r)=>{this.resetLoader(n),o(this.createKeyLoadError(e,On.INTERNAL_ABORTED,new Error("key loading aborted"),r))}};r.load(s,l,c)}))}resetLoader(t){const{frag:e,keyInfo:n,url:r}=t,i=n.loader;e.keyLoader===i&&(e.keyLoader=null,n.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}const wo={length:0,start:()=>0,end:()=>0};class To{static isBuffered(t,e){try{if(t){const n=To.getBuffered(t);for(let t=0;t=n.start(t)&&e<=n.end(t))return!0}}catch(t){}return!1}static bufferInfo(t,e,n){try{if(t){const r=To.getBuffered(t),i=[];let o;for(o=0;oo&&(r[i-1].end=t[e].end):r.push(t[e])}else r.push(t[e])}else r=t;let i,o=0,s=e,a=e;for(let t=0;t=l&&e>>8^255&n^99,t[h]=n,e[n]=h;const a=d[h],p=d[a],g=d[p];let m=257*d[n]^16843008*n;r[h]=m<<24|m>>>8,i[h]=m<<16|m>>>16,o[h]=m<<8|m>>>24,s[h]=m,m=16843009*g^65537*p^257*a^16843008*h,l[n]=m<<24|m>>>8,c[n]=m<<16|m>>>16,u[n]=m<<8|m>>>24,A[n]=m,h?(h=a^d[d[d[g^a]]],f^=d[d[f]]):h=f=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let n=!0,r=0;for(;rr?(this.logOnce("WebCrypto AES decrypt"),new Ro(r,new Uint8Array(n)).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized")))).catch((r=>(Un.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(t,e,n))))}onWebCryptoError(t,e,n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,n);const r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const n=t.length-t.length%16;return n!==t.length&&(e=Ar(t,0,n),this.remainderData=Ar(t,n)),e}logOnce(t){this.logEnabled&&(Un.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Mo="STOPPED",Oo="IDLE",Fo="KEY_LOADING",_o="FRAG_LOADING",No="FRAG_LOADING_WAITING_RETRY",Uo="WAITING_TRACK",Qo="PARSING",Go="PARSED",Wo="ENDED",Yo="ERROR",jo="WAITING_INIT_PTS",Ho="WAITING_LEVEL";class Ko extends class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}{constructor(t,e,n,r,i){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Mo,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=i,this.logPrefix=r,this.log=Un.log.bind(Un,`${r}:`),this.warn=Un.warn.bind(Un,`${r}:`),this.hls=t,this.fragmentLoader=new vo(t.config),this.keyLoader=n,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Po(t.config),t.on(Pn.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Mo}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const n=e.partList;if(null!=n&&n.length){const t=n[n.length-1];return To.isBuffered(this.media,t.start+t.duration/2)}const r=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){var t;if(this.levels&&null!==this.levelLastLoaded)return null==(t=this.levels[this.levelLastLoaded])?void 0:t.details}onMediaAttached(t,e){const n=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),n.addEventListener("seeking",this.onvseeking),n.addEventListener("ended",this.onvended);const r=this.config;this.levels&&r.autoStartLoad&&this.state===Mo&&this.startLoad(r.startPosition)}onMediaDetaching(){const t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:n,mediaBuffer:r,state:i}=this,o=n?n.currentTime:0,s=To.bufferInfo(r||n,o,t.maxBufferHole);if(this.log(`media seeking to ${Bn(o)?o.toFixed(3):o}, state: ${i}`),this.state===Wo)this.resetLoadingState();else if(e){const n=t.maxFragLookUpTolerance,r=e.start-n,i=e.start+e.duration+n;if(!s.len||is.end){const t=o>i;(o{if(this.fragContextChanged(t))return this.warn(`Fragment ${t.sn}${e.part?" p: "+e.part.index:""} of level ${t.level} was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)})).then((e=>{if(!e)return;const n=this.state;this.fragContextChanged(t)?(n===_o||!this.fragCurrent&&n===Qo)&&(this.fragmentTracker.removeFragment(t),this.state=Oo):("payload"in e&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(Pn.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))})).catch((e=>{this.state!==Mo&&this.state!==Yo&&(this.warn(e),this.resetFragmentLoading(t))}))}clearTrackerIfNeeded(t){var e;const{fragmentTracker:n}=this;if(n.getState(t)===uo){const e=t.type,r=this.getFwdBufferInfo(this.mediaBuffer,e),i=Math.max(t.duration,r?r.len:this.config.maxBufferLength);this.reduceMaxBufferLength(i)&&n.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?n.removeAllFragments():n.hasParts(t.type)&&(n.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),n.getState(t)===Ao&&n.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,n=null){if(!(t-e))return;const r={startOffset:t,endOffset:e,type:n};this.hls.trigger(Pn.BUFFER_FLUSHING,r)}_loadInitSegment(t,e){this._doFragLoad(t,e).then((e=>{if(!e||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e})).then((e=>{const{hls:n}=this,{payload:r}=e,i=t.decryptdata;if(r&&r.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer).catch((e=>{throw n.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((r=>{const i=self.performance.now();return n.trigger(Pn.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:o,tdecrypt:i}}),e.payload=r,e}))}return e})).then((n=>{const{fragCurrent:r,hls:i,levels:o}=this;if(!o)throw new Error("init load aborted, missing levels");const s=t.stats;this.state=Oo,e.fragmentError=0,t.data=new Uint8Array(n.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),n.frag===r&&i.trigger(Pn.FRAG_BUFFERED,{stats:s,frag:r,part:null,id:t.type}),this.tick()})).catch((e=>{this.state!==Mo&&this.state!==Yo&&(this.warn(e),this.resetFragmentLoading(t))}))}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var n,r,i,o;const s=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Ei?"level":"track"} ${t.level} (frag:[${(null!=(n=t.startPTS)?n:NaN).toFixed(3)}-${(null!=(r=t.endPTS)?r:NaN).toFixed(3)}] > buffer:${s?function(t){let e="";const n=t.length;for(let r=0;r!t)),s=new So(n.level,n.sn,n.stats.chunkCount+1,0,r?r.index:-1,!o);e.flush(s)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,n=null,r){var i;const o=null==e?void 0:e.details;if(!this.levels||!o)throw new Error(`frag load aborted, missing level${o?"":" detail"}s`);let s=null;if(!t.encrypted||null!=(i=t.decryptdata)&&i.key?!t.encrypted&&o.encryptedFragments.length&&this.keyLoader.loadClear(t,o.encryptedFragments):(this.log(`Loading key for ${t.sn} of [${o.startSN}-${o.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${t.level}`),this.state=Fo,this.fragCurrent=t,s=this.keyLoader.load(t).then((t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(Pn.KEY_LOADED,t),this.state===Fo&&(this.state=Oo),t})),this.hls.trigger(Pn.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(s=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),n=Math.max(t.start,n||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const i=o.partList;if(i&&r){n>t.end&&o.fragmentHint&&(t=o.fragmentHint);const a=this.getNextPart(i,t,n);if(a>-1){const l=i[a];let c;return this.log(`Loading part sn: ${t.sn} p: ${l.index} cc: ${t.cc} of playlist [${o.startSN}-${o.endSN}] parts [0-${a}-${i.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(n.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=_o,c=s?s.then((n=>!n||this.fragContextChanged(n.frag)?null:this.doFragPartsLoad(t,l,e,r))).catch((t=>this.handleFragLoadError(t))):this.doFragPartsLoad(t,l,e,r).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(Pn.FRAG_LOADING,{frag:t,part:l,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!t.url||this.loadedEndOfParts(i,n))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${o?"of ["+o.startSN+"-"+o.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(n.toFixed(3))}`),Bn(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=_o;const a=this.config.progressive;let l;return l=a&&s?s.then((e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,r))).catch((t=>this.handleFragLoadError(t))):Promise.all([this.fragmentLoader.load(t,a?r:void 0),s]).then((([t])=>(!a&&t&&r&&r(t),t))).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(Pn.FRAG_LOADING,{frag:t,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(t,e,n,r){return new Promise(((i,o)=>{var s;const a=[],l=null==(s=n.details)?void 0:s.partList,c=e=>{this.fragmentLoader.loadPart(t,e,r).then((r=>{a[e.index]=r;const o=r.part;this.hls.trigger(Pn.FRAG_LOADED,r);const s=Ki(n,t.sn,e.index+1)||Vi(l,t.sn,e.index+1);if(!s)return i({frag:t,part:o,partsLoaded:a});c(s)})).catch(o)};c(e)}))}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===On.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(Pn.ERROR,e)}else this.hls.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Qo)return void(this.fragCurrent||this.state===Mo||this.state===Yo||(this.state=Oo));const{frag:n,part:r,level:i}=e,o=self.performance.now();n.stats.parsing.end=o,r&&(r.stats.parsing.end=o),this.updateLevelTiming(n,r,i,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:n}=this,{level:r,sn:i,part:o}=t;if(null==e||!e[r])return this.warn(`Levels object was unset while buffering fragment ${i} of level ${r}. The current chunk will not be buffered.`),null;const s=e[r],a=o>-1?Ki(s,i,o):null,l=a?a.fragment:function(t,e,n){if(null==t||!t.details)return null;const r=t.details;let i=r.fragments[e-r.startSN];return i||(i=r.fragmentHint,i&&i.sn===e?i:eo&&this.flushMainBuffer(s,t.start)}getFwdBufferInfo(t,e){const n=this.getLoadPosition();return Bn(n)?this.getFwdBufferInfoAtPos(t,n,e):null}getFwdBufferInfoAtPos(t,e,n){const{config:{maxBufferHole:r}}=this,i=To.bufferInfo(t,e,r);if(0===i.len&&void 0!==i.nextStart){const o=this.fragmentTracker.getBufferedFrag(e,n);if(o&&i.nextStart=n&&(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0)}getAppendedFrag(t,e="main"){const n=this.fragmentTracker.getAppendedFrag(t,Ei);return n&&"fragment"in n?n.fragment:n}getNextFragment(t,e){const n=e.fragments,r=n.length;if(!r)return null;const{config:i}=this,o=n[0].start;let s;if(e.live){const o=i.initialLiveManifestSize;if(re}getNextFragmentLoopLoading(t,e,n,r,i){const o=t.gap,s=this.getNextFragment(this.nextLoadPosition,e);if(null===s)return s;if(t=s,o&&t&&!t.gap&&n.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,n.nextStart,r);if(null!==e&&n.len+e.len>=i)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(t,e,n){let r=-1,i=!1,o=!0;for(let s=0,a=t.length;s-1&&nn.start&&n.loaded}getInitialLiveFragment(t,e){const n=this.fragPrevious;let r=null;if(n){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${n.programDateTime}`),r=function(t,e,n){if(null===e||!Array.isArray(t)||!t.length||!Bn(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;n=n||0;for(let r=0;r=t.startSN&&i<=t.endSN){const o=e[i-t.startSN];n.cc===o.cc&&(r=o,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=function(t,e){return Zi(t,(t=>t.cce?-1:0))}(e,n.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const e=this.hls.liveSyncPosition;null!==e&&(r=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return r}getFragmentAtPosition(t,e,n){const{config:r}=this;let{fragPrevious:i}=this,{fragments:o,endSN:s}=n;const{fragmentHint:a}=n,l=r.maxFragLookUpTolerance,c=n.partList,u=!!(r.lowLatencyMode&&null!=c&&c.length&&a);let A;if(u&&a&&!this.bitrateTest&&(o=o.concat(a),s=a.sn),A=te-l?0:l):o[o.length-1],A){const t=A.sn-n.startSN,e=this.fragmentTracker.getState(A);if((e===ho||e===Ao&&A.gap)&&(i=A),i&&A.sn===i.sn&&(!u||c[0].fragment.sn>A.sn)&&i&&A.level===i.level){const e=o[t+1];A=A.sn=o-e.maxFragLookUpTolerance&&i<=s;if(null!==r&&n.duration>r&&(in.startCC||t&&t.cc${t.startSN} prev-sn: ${i?i.sn:"na"} fragments: ${s}`),n}return a}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let n=this.startPosition;if(n ${null==(r=this.fragCurrent)?void 0:r.url}`);const i=e.details===On.FRAG_GAP;i&&this.fragmentTracker.fragBuffered(n,!0);const o=e.errorAction,{action:s,retryCount:a=0,retryConfig:l}=o||{};if(o&&5===s&&l){var c;this.resetStartWhenNotLoaded(null!=(c=this.levelLastLoaded)?c:n.level);const r=Xi(l,a);this.warn(`Fragment ${n.sn} of ${t} ${n.level} errored with ${e.details}, retrying loading ${a+1}/${l.maxNumRetry} in ${r}ms`),o.resolved=!0,this.retryDate=self.performance.now()+r,this.state=No}else l&&o?(this.resetFragmentErrors(t),a.5;r&&this.reduceMaxBufferLength(n.len);const i=!r;return i&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),i}return!1}resetFragmentErrors(t){t===wi&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Mo&&(this.state=Oo)}afterBufferFlushed(t,e,n){if(!t)return;const r=To.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,r,n),this.state===Wo&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Oo}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(e=this.levelLastLoaded)?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,n,r){var i;const o=n.details;if(o){if(Object.keys(t.elementaryStreams).reduce(((e,i)=>{const s=t.elementaryStreams[i];if(s){const a=s.endPTS-s.startPTS;if(a<=0)return this.warn(`Could not parse fragment ${t.sn} ${i} duration reliably (${a})`),e||!1;const l=r?0:Yi(o,t,s.startPTS,s.endPTS,s.startDTS,s.endDTS);return this.hls.trigger(Pn.LEVEL_PTS_UPDATED,{details:o,level:n,drift:l,type:i,frag:t,start:s.startPTS,end:s.endPTS}),!0}return e}),!1))n.fragmentError=0;else if(null===(null==(i=this.transmuxer)?void 0:i.error)){const e=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(0===n.fragmentError&&(n.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(e.message),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:`Found no media in msn ${t.sn} of level "${n.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Go,this.hls.trigger(Pn.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){var e,n,r;"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(n=this.levelLastLoaded)?n:null==(r=this.fragCurrent)?void 0:r.level)?e:0),this.resetLoadingState())}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function Vo(){return self.SourceBuffer||self.WebKitSourceBuffer}function zo(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class $o{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,n,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,n){}demux(t,e){this.cachedData&&(t=Wr(this.cachedData,t),this.cachedData=null);let n,r=fr(t,0),i=r?r.length:0;const o=this._audioTrack,s=this._id3Track,a=r?(t=>{const e=yr(t);for(let t=0;t0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Bi,duration:Number.POSITIVE_INFINITY});iBn(t)?90*t:9e4*e+(n?9e4*n.baseTime/n.timescale:0);function qo(t,e){return 255===t[e]&&240==(246&t[e+1])}function Jo(t,e){return 1&t[e+1]?7:9}function Zo(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function ts(t,e){return e+1=t.length)return!1;const r=Zo(t,e);if(r<=n)return!1;const i=e+r;return i===t.length||ts(t,i)}return!1}function ns(t,e,n,r,i){if(!t.samplerate){const o=function(t,e,n,r){let i,o,s,a;const l=navigator.userAgent.toLowerCase(),c=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=1+((192&e[n+2])>>>6);const A=(60&e[n+2])>>>2;if(!(A>u.length-1))return s=(1&e[n+2])<<2,s|=(192&e[n+3])>>>6,Un.log(`manifest codec:${r}, ADTS type:${i}, samplingIndex:${A}`),/firefox/i.test(l)?A>=6?(i=5,a=new Array(4),o=A-3):(i=2,a=new Array(2),o=A):-1!==l.indexOf("android")?(i=2,a=new Array(2),o=A):(i=5,a=new Array(4),r&&(-1!==r.indexOf("mp4a.40.29")||-1!==r.indexOf("mp4a.40.5"))||!r&&A>=6?o=A-3:((r&&-1!==r.indexOf("mp4a.40.2")&&(A>=6&&1===s||/vivaldi/i.test(l))||!r&&1===s)&&(i=2,a=new Array(2)),o=A)),a[0]=i<<3,a[0]|=(14&A)>>1,a[1]|=(1&A)<<7,a[1]|=s<<3,5===i&&(a[1]|=(14&o)>>1,a[2]=(1&o)<<7,a[2]|=8,a[3]=0),{config:a,samplerate:u[A],channelCount:s,codec:"mp4a.40."+i,manifestCodec:c};t.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${A}`})}(e,n,r,i);if(!o)return;t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,Un.log(`parsed codec:${t.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function rs(t){return 9216e4/t}function is(t,e,n,r,i){const o=r+i*rs(t.samplerate),s=function(t,e){const n=Jo(t,e);if(e+n<=t.length){const r=Zo(t,e)-n;if(r>0)return{headerLength:n,frameLength:r}}}(e,n);let a;if(s){const{frameLength:r,headerLength:i}=s,l=i+r,c=Math.max(0,n+l-e.length);c?(a=new Uint8Array(l-i),a.set(e.subarray(n+i,e.length),0)):a=e.subarray(n+i,n+l);const u={unit:a,pts:o};return c||t.samples.push(u),{sample:u,length:l,missing:c}}const l=e.length-n;return a=new Uint8Array(l),a.set(e.subarray(n,e.length),0),{sample:{unit:a,pts:o},length:l,missing:-1}}const os=/\/emsg[-/]ID3/i;let ss=null;const as=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],ls=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],cs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],us=[0,1,1,4];function As(t,e,n,r,i){if(n+24>e.length)return;const o=ds(e,n);if(o&&n+o.frameLength<=e.length){const s=r+i*(9e4*o.samplesPerFrame/o.sampleRate),a={unit:e.subarray(n,n+o.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=o.channelCount,t.samplerate=o.sampleRate,t.samples.push(a),{sample:a,length:o.frameLength,missing:0}}}function ds(t,e){const n=t[e+1]>>3&3,r=t[e+1]>>1&3,i=t[e+2]>>4&15,o=t[e+2]>>2&3;if(1!==n&&0!==i&&15!==i&&3!==o){const s=t[e+2]>>1&1,a=t[e+3]>>6,l=1e3*as[14*(3===n?3-r:3===r?3:4)+i-1],c=ls[3*(3===n?0:2===n?1:2)+o],u=3===a?1:2,A=cs[n][r],d=us[r],h=8*A*d,f=Math.floor(A*l/c+s)*d;if(null===ss){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ss=t?parseInt(t[1]):0}return!!ss&&ss<=87&&2===r&&l>=224e3&&0===a&&(t[e+3]=128|t[e+3]),{sampleRate:c,channelCount:u,frameLength:f,samplesPerFrame:h}}}function hs(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function fs(t,e){return e+1t?(this.word<<=t,this.bitsAvailable-=t):(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const n=this.word>>>32-e;if(t>32&&Un.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return e=t-e,e>0&&this.bitsAvailable?n<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e,n=8,r=8;for(let i=0;i{const o=new Uint8Array(i);r.set(o,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,n)}))}decryptAacSamples(t,e,n){for(;;e++){if(e>=t.length)return void n();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,n),this.decrypter.isSync())))return}}getAvcEncryptedData(t){const e=16*Math.floor((t.length-48)/160)+16,n=new Int8Array(e);let r=0;for(let e=32;e{i.data=this.getAvcDecryptedUnit(o,s),this.decrypter.isSync()||this.decryptAvcSamples(t,e,n+1,r)}))}decryptAvcSamples(t,e,n,r){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,n=0){if(e>=t.length)return void r();const i=t[e].units;for(;!(n>=i.length);n++){const o=i[n];if(!(o.data.length<=48||1!==o.type&&5!==o.type||(this.decryptAvcSample(t,e,n,r,o),this.decrypter.isSync())))return}}}}const vs=188;class ys{constructor(t,e,n){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=n}static probe(t){const e=ys.syncOffset(t);return e>0&&Un.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),-1!==e}static syncOffset(t){const e=t.length;let n=Math.min(940,t.length-vs)+1,r=0;for(;r1&&(0===o&&s>2||a+vs>n))return o}r++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Dr[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,n,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=ys.createTrack("video"),this._audioTrack=ys.createTrack("audio",r),this._id3Track=ys.createTrack("id3"),this._txtTrack=ys.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=n,this._duration=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:n}=this;t&&(t.pesData=null),e&&(e.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,n=!1,r=!1){let i;n||(this.sampleAes=null);const o=this._avcTrack,s=this._audioTrack,a=this._id3Track,l=this._txtTrack;let c=o.pid,u=o.pesData,A=s.pid,d=a.pid,h=s.pesData,f=a.pesData,p=null,g=this.pmtParsed,m=this._pmtId,v=t.length;if(this.remainderData&&(v=(t=Wr(this.remainderData,t)).length,this.remainderData=null),v>4>1){if(C=e+5+t[e+4],C===e+vs)continue}else C=e+4;switch(v){case c:r&&(u&&(i=Ts(u))&&this.parseAVCPES(o,l,i,!1),u={data:[],size:0}),u&&(u.data.push(t.subarray(C,e+vs)),u.size+=e+vs-C);break;case A:if(r){if(h&&(i=Ts(h)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,i);break;case"mp3":this.parseMPEGPES(s,i)}h={data:[],size:0}}h&&(h.data.push(t.subarray(C,e+vs)),h.size+=e+vs-C);break;case d:r&&(f&&(i=Ts(f))&&this.parseID3PES(a,i),f={data:[],size:0}),f&&(f.data.push(t.subarray(C,e+vs)),f.size+=e+vs-C);break;case 0:r&&(C+=t[C]+1),m=this._pmtId=Es(t,C);break;case m:{r&&(C+=t[C]+1);const i=ws(t,C,this.typeSupported,n);c=i.avc,c>0&&(o.pid=c),A=i.audio,A>0&&(s.pid=A,s.segmentCodec=i.segmentCodec),d=i.id3,d>0&&(a.pid=d),null===p||g||(Un.warn(`MPEG-TS PMT found at ${e} after unknown PID '${p}'. Backtracking to sync byte @${y} to parse all TS packets.`),p=null,e=y-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=v}}else C++;if(C>0){const t=new Error(`Found ${C} TS packet/s that do not start with 0x47`);this.observer.emit(Pn.ERROR,Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message})}o.pesData=u,s.pesData=h,a.pesData=f;const b={audioTrack:s,videoTrack:o,id3Track:a,textTrack:l};return r&&this.extractRemainingSamples(b),b}flush(){const{remainderData:t}=this;let e;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:n,id3Track:r,textTrack:i}=t,o=n.pesData,s=e.pesData,a=r.pesData;let l;if(o&&(l=Ts(o))?(this.parseAVCPES(n,i,l,!0),n.pesData=null):n.pesData=o,s&&(l=Ts(s))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,l);break;case"mp3":this.parseMPEGPES(e,l)}e.pesData=null}else null!=s&&s.size&&Un.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=s;a&&(l=Ts(a))?(this.parseID3PES(r,l),r.pesData=null):r.pesData=a}demuxSampleAes(t,e,n){const r=this.demux(t,n,!0,!this.config.progressive),i=this.sampleAes=new ms(this.observer,this.config,e);return this.decrypt(r,i)}decrypt(t,e){return new Promise((n=>{const{audioTrack:r,videoTrack:i}=t;r.samples&&"aac"===r.segmentCodec?e.decryptAacSamples(r.samples,0,(()=>{i.samples?e.decryptAvcSamples(i.samples,0,0,(()=>{n(t)})):n(t)})):i.samples&&e.decryptAvcSamples(i.samples,0,0,(()=>{n(t)}))}))}destroy(){this._duration=0}parseAVCPES(t,e,n,r){const i=this.parseAVCNALu(t,n.data);let o,s=this.avcSample,a=!1;n.data=null,s&&i.length&&!t.audFound&&(Ss(s,t),s=this.avcSample=Cs(!1,n.pts,n.dts,"")),i.forEach((r=>{var i;switch(r.type){case 1:{let e=!1;o=!0;const i=r.data;if(a&&i.length>4){const t=new gs(i).readSliceType();2!==t&&4!==t&&7!==t&&9!==t||(e=!0)}var l;e&&null!=(l=s)&&l.frame&&!s.key&&(Ss(s,t),s=this.avcSample=null),s||(s=this.avcSample=Cs(!0,n.pts,n.dts,"")),s.frame=!0,s.key=e;break}case 5:o=!0,null!=(i=s)&&i.frame&&!s.key&&(Ss(s,t),s=this.avcSample=null),s||(s=this.avcSample=Cs(!0,n.pts,n.dts,"")),s.key=!0,s.frame=!0;break;case 6:o=!0,Hr(r.data,1,n.pts,e.samples);break;case 7:if(o=!0,a=!0,!t.sps){const e=r.data,n=new gs(e).readSPS();t.width=n.width,t.height=n.height,t.pixelRatio=n.pixelRatio,t.sps=[e],t.duration=this._duration;const i=e.subarray(1,4);let o="avc1.";for(let t=0;t<3;t++){let e=i[t].toString(16);e.length<2&&(e="0"+e),o+=e}t.codec=o}break;case 8:o=!0,t.pps||(t.pps=[r.data]);break;case 9:o=!1,t.audFound=!0,s&&Ss(s,t),s=this.avcSample=Cs(!1,n.pts,n.dts,"");break;case 12:o=!0;break;default:o=!1,s&&(s.debug+="unknown NAL "+r.type+" ")}s&&o&&s.units.push(r)})),r&&s&&(Ss(s,t),this.avcSample=null)}getLastNalUnit(t){var e;let n,r=this.avcSample;if(r&&0!==r.units.length||(r=t[t.length-1]),null!=(e=r)&&e.units){const t=r.units;n=t[t.length-1]}return n}parseAVCNALu(t,e){const n=e.byteLength;let r=t.naluState||0;const i=r,o=[];let s,a,l,c=0,u=-1,A=0;for(-1===r&&(u=0,A=31&e[0],r=0,c=1);c=0){const t={data:e.subarray(u,c-r-1),type:A};o.push(t)}else{const n=this.getLastNalUnit(t.samples);if(n&&(i&&c<=4-i&&n.state&&(n.data=n.data.subarray(0,n.data.byteLength-i)),a=c-r-1,a>0)){const t=new Uint8Array(n.data.byteLength+a);t.set(n.data,0),t.set(e.subarray(0,a),n.data.byteLength),n.data=t,n.state=0}}c=0&&r>=0){const t={data:e.subarray(u,n),type:A,state:r};o.push(t)}if(0===o.length){const n=this.getLastNalUnit(t.samples);if(n){const t=new Uint8Array(n.data.byteLength+e.byteLength);t.set(n.data,0),t.set(e,n.data.byteLength),n.data=t}}return t.naluState=r,o}parseAACPES(t,e){let n=0;const r=this.aacOverFlow;let i,o,s,a=e.data;if(r){this.aacOverFlow=null;const e=r.missing,i=r.sample.unit.byteLength;if(-1===e){const t=new Uint8Array(i+a.byteLength);t.set(r.sample.unit,0),t.set(a,i),a=t}else{const o=i-e;r.sample.unit.set(a.subarray(0,e),o),t.samples.push(r.sample),n=r.missing}}for(i=n,o=a.length;i1;){const t=new Uint8Array(a[0].length+a[1].length);t.set(a[0]),t.set(a[1],a[0].length),a[0]=t,a.splice(1,1)}if(e=a[0],1===(e[0]<<16)+(e[1]<<8)+e[2]){if(n=(e[4]<<8)+e[5],n&&n>t.size-6)return null;const l=e[7];192&l&&(i=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&l?(o=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,i-o>54e5&&(Un.warn(`${Math.round((i-o)/9e4)}s delta between PTS and DTS, align them`),i=o)):o=i),r=e[8];let c=r+9;if(t.size<=c)return null;t.size-=c;const u=new Uint8Array(t.size);for(let t=0,n=a.length;tn){c-=n;continue}e=e.subarray(c),n-=c,c=0}u.set(e,s),s+=n}return n&&(n-=r+3),{data:u,pts:i,dts:o,len:n}}return null}function Ss(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const n=e.samples,r=n.length;if(!r)return void e.dropped++;{const e=n[r-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&Un.log(t.pts+"/"+t.dts+":"+t.debug)}class ks{static getSilentFrame(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const Ls=Math.pow(2,32)-1;class xs{static init(){let t;for(t in xs.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},xs.types)xs.types.hasOwnProperty(t)&&(xs.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);xs.HDLR_TYPES={video:e,audio:n};const r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);xs.STTS=xs.STSC=xs.STCO=i,xs.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),xs.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),xs.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),xs.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);xs.FTYP=xs.box(xs.types.ftyp,o,a,o,s),xs.DINF=xs.box(xs.types.dinf,xs.box(xs.types.dref,r))}static box(t,...e){let n=8,r=e.length;const i=r;for(;r--;)n+=e[r].byteLength;const o=new Uint8Array(n);for(o[0]=n>>24&255,o[1]=n>>16&255,o[2]=n>>8&255,o[3]=255&n,o.set(t,4),r=0,n=8;r>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))}static mdia(t){return xs.box(xs.types.mdia,xs.mdhd(t.timescale,t.duration),xs.hdlr(t.type),xs.minf(t))}static mfhd(t){return xs.box(xs.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?xs.box(xs.types.minf,xs.box(xs.types.smhd,xs.SMHD),xs.DINF,xs.stbl(t)):xs.box(xs.types.minf,xs.box(xs.types.vmhd,xs.VMHD),xs.DINF,xs.stbl(t))}static moof(t,e,n){return xs.box(xs.types.moof,xs.mfhd(t),xs.traf(n,e))}static moov(t){let e=t.length;const n=[];for(;e--;)n[e]=xs.trak(t[e]);return xs.box.apply(null,[xs.types.moov,xs.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(xs.mvex(t)))}static mvex(t){let e=t.length;const n=[];for(;e--;)n[e]=xs.trex(t[e]);return xs.box.apply(null,[xs.types.mvex,...n])}static mvhd(t,e){e*=t;const n=Math.floor(e/(Ls+1)),r=Math.floor(e%(Ls+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return xs.box(xs.types.mvhd,i)}static sdtp(t){const e=t.samples||[],n=new Uint8Array(4+e.length);let r,i;for(r=0;r>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(n));for(e=0;e>>8&255),o.push(255&r),o=o.concat(Array.prototype.slice.call(n));const s=xs.box(xs.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|t.sps.length].concat(i).concat([t.pps.length]).concat(o))),a=t.width,l=t.height,c=t.pixelRatio[0],u=t.pixelRatio[1];return xs.box(xs.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,xs.box(xs.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),xs.box(xs.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return xs.box(xs.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),xs.box(xs.types.esds,xs.esds(t)))}static mp3(t){const e=t.samplerate;return xs.box(xs.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?xs.box(xs.types.stsd,xs.STSD,xs.mp3(t)):xs.box(xs.types.stsd,xs.STSD,xs.mp4a(t)):xs.box(xs.types.stsd,xs.STSD,xs.avc1(t))}static tkhd(t){const e=t.id,n=t.duration*t.timescale,r=t.width,i=t.height,o=Math.floor(n/(Ls+1)),s=Math.floor(n%(Ls+1));return xs.box(xs.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))}static traf(t,e){const n=xs.sdtp(t),r=t.id,i=Math.floor(e/(Ls+1)),o=Math.floor(e%(Ls+1));return xs.box(xs.types.traf,xs.box(xs.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),xs.box(xs.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,o>>24,o>>16&255,o>>8&255,255&o])),xs.trun(t,n.length+16+20+8+16+8+8),n)}static trak(t){return t.duration=t.duration||4294967295,xs.box(xs.types.trak,xs.tkhd(t),xs.mdia(t))}static trex(t){const e=t.id;return xs.box(xs.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const n=t.samples||[],r=n.length,i=12+16*r,o=new Uint8Array(i);let s,a,l,c,u,A;for(e+=8+i,o.set(["video"===t.type?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),s=0;s>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,A>>>24&255,A>>>16&255,A>>>8&255,255&A],12+16*s);return xs.box(xs.types.trun,o)}static initSegment(t){xs.types||xs.init();const e=xs.moov(t),n=new Uint8Array(xs.FTYP.byteLength+e.byteLength);return n.set(xs.FTYP),n.set(e,xs.FTYP.byteLength),n}}function Is(t,e,n=1,r=!1){const i=t*e*n;return r?Math.round(i):i}function Rs(t,e=!1){return Is(t,1e3,1/9e4,e)}xs.types=void 0,xs.HDLR_TYPES=void 0,xs.STTS=void 0,xs.STSC=void 0,xs.STCO=void 0,xs.STSZ=void 0,xs.VMHD=void 0,xs.SMHD=void 0,xs.STSD=void 0,xs.FTYP=void 0,xs.DINF=void 0;let Ds,Bs=null,Ps=null;class Ms{constructor(t,e,n,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=n,this.ISGenerated=!1,null===Bs){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Bs=t?parseInt(t[1]):0}if(null===Ps){const t=navigator.userAgent.match(/Safari\/(\d+)/i);Ps=t?parseInt(t[1]):0}}destroy(){}resetTimeStamp(t){Un.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){Un.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Un.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const n=t.reduce(((t,n)=>{const r=n.pts-t;return r<-4294967296?(e=!0,Os(t,n.pts)):r>0?t:n.pts}),t[0].pts);return e&&Un.debug("PTS rollover detected"),n}remux(t,e,n,r,i,o,s,a){let l,c,u,A,d,h,f=i,p=i;const g=t.pid>-1,m=e.pid>-1,v=e.samples.length,y=t.samples.length>0,C=s&&v>0||v>1;if((!g||y)&&(!m||C)||this.ISGenerated||s){this.ISGenerated||(u=this.generateIS(t,e,i,o));const n=this.isVideoContiguous;let r,s=-1;if(C&&(s=function(t){for(let e=0;e0){Un.warn(`[mp4-remuxer]: Dropped ${s} out of ${v} video samples due to a missing keyframe`);const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(s),e.dropped+=s,p+=(e.samples[0].pts-t)/e.inputTimeScale,r=p}else-1===s&&(Un.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),h=!1);if(this.ISGenerated){if(y&&C){const n=this.getVideoStartPts(e.samples),r=(Os(t.samples[0].pts,n)-n)/e.inputTimeScale;f+=Math.max(0,r),p+=Math.max(0,-r)}if(y){if(t.samplerate||(Un.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(t,e,i,o)),c=this.remuxAudio(t,f,this.isAudioContiguous,o,m||C||a===wi?p:void 0),C){const r=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(Un.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(t,e,i,o)),l=this.remuxVideo(e,p,n,r)}}else C&&(l=this.remuxVideo(e,p,n,0));l&&(l.firstKeyFrame=s,l.independent=-1!==s,l.firstKeyFramePTS=r)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(n.samples.length&&(d=Fs(n,i,this._initPTS,this._initDTS)),r.samples.length&&(A=_s(r,i,this._initPTS))),{audio:c,video:l,initSegment:u,independent:h,text:A,id3:d}}generateIS(t,e,n,r){const i=t.samples,o=e.samples,s=this.typeSupported,a={},l=this._initPTS;let c,u,A,d=!l||r,h="audio/mp4";if(d&&(c=u=1/0),t.config&&i.length&&(t.timescale=t.samplerate,"mp3"===t.segmentCodec&&(s.mpeg?(h="audio/mpeg",t.codec=""):s.mp3&&(t.codec="mp3")),a.audio={id:"audio",container:h,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&s.mpeg?new Uint8Array(0):xs.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(A=t.inputTimeScale,l&&A===l.timescale?d=!1:c=u=i[0].pts-Math.round(A*n))),e.sps&&e.pps&&o.length&&(e.timescale=e.inputTimeScale,a.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:xs.initSegment([e]),metadata:{width:e.width,height:e.height}},d))if(A=e.inputTimeScale,l&&A===l.timescale)d=!1;else{const t=this.getVideoStartPts(o),e=Math.round(A*n);u=Math.min(u,Os(o[0].dts,t)-e),c=Math.min(c,t-e)}if(Object.keys(a).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:c,timescale:A},this._initDTS={baseTime:u,timescale:A}):c=A=void 0,{tracks:a,initPTS:c,timescale:A}}remuxVideo(t,e,n,r){const i=t.inputTimeScale,o=t.samples,s=[],a=o.length,l=this._initPTS;let c,u,A=this.nextAvcDts,d=8,h=this.videoSampleDuration,f=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=!1;n&&null!==A||(A=e*i-(o[0].pts-Os(o[0].dts,o[0].pts)));const m=l.baseTime*i/l.timescale;for(let t=0;t0?t-1:t].dts&&(g=!0)}g&&o.sort((function(t,e){const n=t.dts-e.dts,r=t.pts-e.pts;return n||r})),c=o[0].dts,u=o[o.length-1].dts;const v=u-c,y=v?Math.round(v/(a-1)):h||t.inputTimeScale/30;if(n){const t=c-A,e=t>y,n=t<-1;if((e||n)&&(e?Un.warn(`AVC: ${Rs(t,!0)} ms (${t}dts) hole between fragments detected, filling it`):Un.warn(`AVC: ${Rs(-t,!0)} ms (${t}dts) overlapping between fragments detected`),!n||A>=o[0].pts)){c=A;const e=o[0].pts-t;o[0].dts=c,o[0].pts=e,Un.log(`Video: First PTS/DTS adjusted: ${Rs(e,!0)}/${Rs(c,!0)}, delta: ${Rs(t,!0)} ms`)}}c=Math.max(0,c);let C=0,b=0;for(let t=0;t0?e.dts-o[t-1].dts:y;if(l=t>0?e.pts-o[t-1].pts:y,n.stretchShortVideoTrack&&null!==this.nextAudioPts){const t=Math.floor(n.maxBufferHole*i),o=(r?f+r*i:this.nextAudioPts)-e.pts;o>t?(h=o-s,h<0?h=s:S=!0,Un.log(`[mp4-remuxer]: It is approximately ${o/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=s}else h=s}const u=Math.round(e.pts-e.dts);k=Math.min(k,h),x=Math.max(x,h),L=Math.min(L,l),I=Math.max(I,l),s.push(new Ns(e.key,h,c,u))}if(s.length)if(Bs){if(Bs<70){const t=s[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(Ps&&I-L0&&(r&&Math.abs(g-p)<9e3||Math.abs(Os(h[0].pts-m,g)-p)<20*l),h.forEach((function(t){t.pts=Os(t.pts-m,g)})),!n||p<0){if(h=h.filter((t=>t.pts>=0)),!h.length)return;p=0===i?0:r&&!d?Math.max(0,g):h[0].pts}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let n=0,r=p;n=e*l&&c<1e4&&d){let e=Math.round(a/l);r=s-e*l,r<0&&(e--,r+=l),0===n&&(this.nextAudioPts=p=r),Un.warn(`[mp4-remuxer]: Injecting ${e} audio frame @ ${(r/o).toFixed(3)}s due to ${Math.round(1e3*a/o)} ms gap.`);for(let o=0;o0))return;b+=f;try{v=new Uint8Array(b)}catch(t){return void this.observer.emit(Pn.ERROR,Pn.ERROR,{type:Mn.MUX_ERROR,details:On.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:b,reason:`fail allocating audio mdat ${b}`})}u||(new DataView(v.buffer).setUint32(0,b),v.set(xs.types.mdat,4))}v.set(i,f);const l=i.byteLength;f+=l,A.push(new Ns(!0,a,l,0)),C=o}const w=A.length;if(!w)return;const T=A[A.length-1];this.nextAudioPts=p=C+s*T.duration;const S=u?new Uint8Array(0):xs.moof(t.sequenceNumber++,y/s,Dn({},t,{samples:A}));t.samples=[];const k=y/o,L=p/o,x={data1:S,data2:v,startPTS:k,endPTS:L,startDTS:k,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:w};return this.isAudioContiguous=!0,x}remuxEmptyAudio(t,e,n,r){const i=t.inputTimeScale,o=i/(t.samplerate?t.samplerate:i),s=this.nextAudioPts,a=this._initDTS,l=9e4*a.baseTime/a.timescale,c=(null!==s?s:r.startDTS*i)+l,u=r.endDTS*i+l,A=1024*o,d=Math.ceil((u-c)/A),h=ks.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(Un.warn("[mp4-remuxer]: remux empty Audio"),!h)return void Un.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const f=[];for(let t=0;t4294967296;)t+=n;return t}function Fs(t,e,n,r){const i=t.samples.length;if(!i)return;const o=t.inputTimeScale;for(let s=0;st.pts-e.pts));const o=t.samples;return t.samples=[],{samples:o}}class Ns{constructor(t,e,n,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=n,this.cts=r,this.flags=new Us(t)}}class Us{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}function Qs(t,e){const n=null==t?void 0:t.codec;return n&&n.length>4?n:"hvc1"===n||"hev1"===n?"hvc1.1.6.L120.90":"av01"===n?"av01.0.04M.08":"avc1"===n||e===Vn?"avc1.42e01e":"mp4a.40.5"}try{Ds=self.performance.now.bind(self.performance)}catch(t){Un.debug("Unable to use Performance API on this environment"),Ds="undefined"!=typeof self&&self.Date.now}const Gs=[{demux:class{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,n,r){const i=this.videoTrack=zo("video",1),o=this.audioTrack=zo("audio",1),s=this.txtTrack=zo("text",1);if(this.id3Track=zo("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const a=Ur(t);if(a.video){const{id:t,timescale:e,codec:n}=a.video;i.id=t,i.timescale=s.timescale=e,i.codec=n}if(a.audio){const{id:t,timescale:e,codec:n}=a.audio;o.id=t,o.timescale=e,o.codec=n}s.id=Dr.text,i.sampleDuration=0,i.duration=o.duration=r}resetContiguity(){this.remainderData=null}static probe(t){return _r(t=t.length>16384?t.subarray(0,16384):t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let n=t;const r=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(n=Wr(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},n=_r(t,["moof"]);if(!n)return e;if(n.length<2)return e.remainder=t,e;const r=n[n.length-1];return e.valid=Ar(t,0,r.byteOffset-8),e.remainder=Ar(t,r.byteOffset-8),e}(n);this.remainderData=e.remainder,r.samples=e.valid||new Uint8Array}else r.samples=n;const o=this.extractID3Track(r,e);return i.samples=Yr(e,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,n=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(e,this.timeOffset);return n.samples=Yr(t,e),{videoTrack:e,audioTrack:zo(),id3Track:r,textTrack:zo()}}extractID3Track(t,e){const n=this.id3Track;if(t.samples.length){const r=_r(t.samples,["emsg"]);r&&r.forEach((t=>{const r=function(t){const e=t[0];let n="",r="",i=0,o=0,s=0,a=0,l=0,c=0;if(0===e){for(;"\0"!==Br(t.subarray(c,c+1));)n+=Br(t.subarray(c,c+1)),c+=1;for(n+=Br(t.subarray(c,c+1)),c+=1;"\0"!==Br(t.subarray(c,c+1));)r+=Br(t.subarray(c,c+1)),c+=1;r+=Br(t.subarray(c,c+1)),c+=1,i=Mr(t,12),o=Mr(t,16),a=Mr(t,20),l=Mr(t,24),c=28}else if(1===e){c+=4,i=Mr(t,c),c+=4;const e=Mr(t,c);c+=4;const o=Mr(t,c);for(c+=4,s=2**32*e+o,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,Un.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),a=Mr(t,c),c+=4,l=Mr(t,c),c+=4;"\0"!==Br(t.subarray(c,c+1));)n+=Br(t.subarray(c,c+1)),c+=1;for(n+=Br(t.subarray(c,c+1)),c+=1;"\0"!==Br(t.subarray(c,c+1));)r+=Br(t.subarray(c,c+1)),c+=1;r+=Br(t.subarray(c,c+1)),c+=1}return{schemeIdUri:n,value:r,timeScale:i,presentationTime:s,presentationTimeDelta:o,eventDuration:a,id:l,payload:t.subarray(c,t.byteLength)}}(t);if(os.test(r.schemeIdUri)){const t=Bn(r.presentationTime)?r.presentationTime/r.timeScale:e+r.presentationTimeDelta/r.timeScale;let i=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;i<=.001&&(i=Number.POSITIVE_INFINITY);const o=r.payload;n.samples.push({data:o,len:o.byteLength,dts:t,pts:t,type:Pi,duration:i})}}))}return n}demuxSampleAes(t,e,n){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,n,r){this.audioCodec=e,this.videoCodec=n,this.generateInitSegment(function(t,e){if(!t||!e)return t;const n=e.keyId;return n&&e.isCommonEncryption&&_r(t,["moov","trak"]).forEach((t=>{const e=_r(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let r=_r(e,["enca"]);const i=r.length>0;i||(r=_r(e,["encv"])),r.forEach((t=>{_r(i?t.subarray(28):t.subarray(78),["sinf"]).forEach((t=>{const e=Qr(t);if(e){const t=e.subarray(8,24);t.some((t=>0!==t))||(Un.log(`[eme] Patching keyId in 'enc${i?"a":"v"}>sinf>>tenc' box: ${xr(t)} -> ${xr(n)}`),e.set(n,8))}}))}))})),t}(t,r)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:n}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const r=this.initData=Ur(t);e||(e=Qs(r.audio,Kn)),n||(n=Qs(r.video,Vn));const i={};r.audio&&r.video?i.audiovideo={container:"video/mp4",codec:e+","+n,initSegment:t,id:"main"}:r.audio?i.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:r.video?i.video={container:"video/mp4",codec:n,initSegment:t,id:"main"}:Un.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i}remux(t,e,n,r,i,o){var s,a;let{initPTS:l,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:r,id3:n,initSegment:void 0};Bn(c)||(c=this.lastEndTime=i||0);const A=e.samples;if(null==A||!A.length)return u;const d={initPTS:void 0,timescale:1};let h=this.initData;if(null!=(s=h)&&s.length||(this.generateInitSegment(A),h=this.initData),null==(a=h)||!a.length)return Un.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);const f=function(t,e){let n=0,r=0,i=0;const o=_r(t,["moof","traf"]);for(let t=0;tt+e.info.duration||0),0))}return e}return r||i}(A,h),p=function(t,e){return _r(e,["moof","traf"]).reduce(((e,n)=>{const r=_r(n,["tfdt"])[0],i=r[0],o=_r(n,["tfhd"]).reduce(((e,n)=>{const o=Mr(n,4),s=t[o];if(s){let t=Mr(r,4);if(1===i){if(t===Ir)return Un.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=Ir+1,t+=Mr(r,8)}const n=t/(s.timescale||9e4);if(isFinite(n)&&(null===e||ni}(l,g,i,f)||d.timescale!==l.timescale&&o)&&(d.initPTS=g-i,l&&1===l.timescale&&Un.warn("Adjusting initPTS by "+(d.initPTS-l.baseTime)),this.initPTS=l={baseTime:d.initPTS,timescale:1});const m=t?g-l.baseTime/l.timescale:c,v=m+f;!function(t,e,n){_r(e,["moof","traf"]).forEach((e=>{_r(e,["tfhd"]).forEach((r=>{const i=Mr(r,4),o=t[i];if(!o)return;const s=o.timescale||9e4;_r(e,["tfdt"]).forEach((t=>{const e=t[0];let r=Mr(t,4);if(0===e)r-=n*s,r=Math.max(r,0),Fr(t,4,r);else{r*=Math.pow(2,32),r+=Mr(t,8),r-=n*s,r=Math.max(r,0);const e=Math.floor(r/(Ir+1)),i=Math.floor(r%(Ir+1));Fr(t,4,e),Fr(t,8,i)}}))}))}))}(h,A,l.baseTime/l.timescale),f>0?this.lastEndTime=v:(Un.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const y=!!h.audio,C=!!h.video;let b="";y&&(b+="audio"),C&&(b+="video");const E={data1:A,startPTS:m,startDTS:m,endPTS:v,endDTS:v,type:b,hasAudio:y,hasVideo:C,nb:1,dropped:0};return u.audio="audio"===E.type?E:void 0,u.video="audio"!==E.type?E:void 0,u.initSegment=d,u.id3=Fs(n,i,l,l),r.samples.length&&(u.text=_s(r,i,l)),u}}},{demux:ys,remux:Ms},{demux:class extends $o{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,n,r){super.resetInitSegment(t,e,n,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:r,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(fr(t,0)||[]).length;for(let n=t.length;e0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(n=e),n}(o,e);if(y&&"AES-128"===y.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(o,y.key.buffer,y.iv.buffer).then((t=>{const e=this.push(t,null,n);return this.decryptionPromise=null,e})),this.decryptionPromise;{let e=t.softwareDecrypt(o,y.key.buffer,y.iv.buffer);if(n.part>-1&&(e=t.flush()),!e)return i.executeEnd=Ds(),Ys(n);o=new Uint8Array(e)}}const C=this.needsProbing(c,u);if(C){const t=this.configureTransmuxer(o);if(t)return Un.warn(`[transmuxer] ${t.message}`),this.observer.emit(Pn.ERROR,Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),i.executeEnd=Ds(),Ys(n)}(c||u||h||C)&&this.resetInitSegment(v,f,p,m,e),(c||h||C)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const b=this.transmux(o,y,d,A,n),E=this.currentTransmuxState;return E.contiguous=!0,E.discontinuity=!1,E.trackSwitch=!1,i.executeEnd=Ds(),b}flush(t){const e=t.transmuxing;e.executeStart=Ds();const{decrypter:n,currentTransmuxState:r,decryptionPromise:i}=this;if(i)return i.then((()=>this.flush(t)));const o=[],{timeOffset:s}=r;if(n){const e=n.flush();e&&o.push(this.push(e,null,t))}const{demuxer:a,remuxer:l}=this;if(!a||!l)return e.executeEnd=Ds(),[Ys(t)];const c=a.flush(s);return js(c)?c.then((e=>(this.flushRemux(o,e,t),o))):(this.flushRemux(o,c,t),o)}flushRemux(t,e,n){const{audioTrack:r,videoTrack:i,id3Track:o,textTrack:s}=e,{accurateTimeOffset:a,timeOffset:l}=this.currentTransmuxState;Un.log(`[transmuxer.ts]: Flushed fragment ${n.sn}${n.part>-1?" p: "+n.part:""} of level ${n.level}`);const c=this.remuxer.remux(r,i,o,s,l,a,!0,this.id);t.push({remuxResult:c,chunkMeta:n}),n.transmuxing.executeEnd=Ds()}resetInitialTimestamp(t){const{demuxer:e,remuxer:n}=this;e&&n&&(e.resetTimeStamp(t),n.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,n,r,i){const{demuxer:o,remuxer:s}=this;o&&s&&(o.resetInitSegment(t,e,n,r),s.resetInitSegment(t,e,n,i))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,n,r,i){let o;return o=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,n,r,i):this.transmuxUnencrypted(t,n,r,i),o}transmuxUnencrypted(t,e,n,r){const{audioTrack:i,videoTrack:o,id3Track:s,textTrack:a}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(i,o,s,a,e,n,!1,this.id),chunkMeta:r}}transmuxSampleAes(t,e,n,r,i){return this.demuxer.demuxSampleAes(t,e,n).then((t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,n,r,!1,this.id),chunkMeta:i})))}configureTransmuxer(t){const{config:e,observer:n,typeSupported:r,vendor:i}=this;let o;for(let e=0,n=Gs.length;e({remuxResult:{},chunkMeta:t});function js(t){return"then"in t&&t.then instanceof Function}class Hs{constructor(t,e,n,r,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=n,this.duration=r,this.defaultInitPts=i||null}}class Ks{constructor(t,e,n,r,i,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=n,this.trackSwitch=r,this.timeOffset=i,this.initSegmentChange=o}}var Vs={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||t,s),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i!1};class Xs{constructor(t,e,n,r){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const i=t.config;this.hls=t,this.id=e,this.useWorker=!!i.enableWorker,this.onTransmuxComplete=n,this.onFlush=r;const o=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===Pn.ERROR&&(this.error=e.error),this.hls.trigger(t,e)};this.observer=new zs,this.observer.on(Pn.FRAG_DECRYPTED,o),this.observer.on(Pn.ERROR,o);const s={mp4:$s.isTypeSupported("video/mp4"),mpeg:$s.isTypeSupported("audio/mpeg"),mp3:$s.isTypeSupported('audio/mp4; codecs="mp3"')},a=navigator.vendor;if(!this.useWorker||"undefined"==typeof Worker||!i.workerPath&&"function"!=typeof __HLS_WORKER_BUNDLE__)this.transmuxer=new Ws(this.observer,s,i,a,e);else try{i.workerPath?(Un.log(`loading Web Worker ${i.workerPath} for "${e}"`),this.workerContext=function(t){const e=new self.URL(t,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}(i.workerPath)):(Un.log(`injecting Web Worker for "${e}"`),this.workerContext=function(){const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(t);return{worker:new self.Worker(e),objectURL:e}}()),this.onwmsg=t=>this.onWorkerMessage(t);const{worker:t}=this.workerContext;t.addEventListener("message",this.onwmsg),t.onerror=t=>{const n=new Error(`${t.message} (${t.filename}:${t.lineno})`);i.enableWorker=!1,Un.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:n})},t.postMessage({cmd:"init",typeSupported:s,vendor:a,id:e,config:JSON.stringify(i)})}catch(t){Un.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new Ws(this.observer,s,i,a,e)}}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,n,r,i,o,s,a,l,c){var u,A;l.transmuxing.start=self.performance.now();const{transmuxer:d}=this,h=o?o.start:i.start,f=i.decryptdata,p=this.frag,g=!(p&&i.cc===p.cc),m=!(p&&l.level===p.level),v=p?l.sn-p.sn:-1,y=this.part?l.part-this.part.index:-1,C=0===v&&l.id>1&&l.id===(null==p?void 0:p.stats.chunkCount),b=!m&&(1===v||0===v&&(1===y||C&&y<=0)),E=self.performance.now();(m||v||0===i.stats.parsing.start)&&(i.stats.parsing.start=E),!o||!y&&b||(o.stats.parsing.start=E);const w=!(p&&(null==(u=i.initSegment)?void 0:u.url)===(null==(A=p.initSegment)?void 0:A.url)),T=new Ks(g,b,a,m,h,w);if(!b||g||w){Un.log(`[transmuxer-interface, ${i.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${g}\n trackSwitch: ${m}\n contiguous: ${b}\n accurateTimeOffset: ${a}\n timeOffset: ${h}\n initSegmentChange: ${w}`);const t=new Hs(n,r,e,s,c);this.configureTransmuxer(t)}if(this.frag=i,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:f,chunkMeta:l,state:T},t instanceof ArrayBuffer?[t]:[]);else if(d){const e=d.push(t,f,l,T);js(e)?(d.async=!0,e.then((t=>{this.handleTransmuxComplete(t)})).catch((t=>{this.transmuxerError(t,l,"transmuxer-interface push error")}))):(d.async=!1,this.handleTransmuxComplete(e))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let n=e.flush(t);js(n)||e.async?(js(n)||(n=Promise.resolve(n)),n.then((e=>{this.handleFlushResult(e,t)})).catch((e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}))):this.handleFlushResult(n,t)}}transmuxerError(t,e,n){this.hls&&(this.error=t,this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:n}))}handleFlushResult(t,e){t.forEach((t=>{this.handleTransmuxComplete(t)})),this.onFlush(e)}onWorkerMessage(t){const e=t.data,n=this.hls;switch(e.event){case"init":{var r;const t=null==(r=this.workerContext)?void 0:r.objectURL;t&&self.URL.revokeObjectURL(t);break}case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":Un[e.data.logType]&&Un[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,n.trigger(e.event,e.data)}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}class qs{constructor(t,e,n,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=n,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:n,media:r,stalled:i}=this;if(null===r)return;const{currentTime:o,seeking:s}=r,a=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,o!==t){if(this.moved=!0,null!==i){if(this.stallReported){const t=self.performance.now()-i;Un.warn(`playback not stuck anymore @${o}, after ${Math.round(t)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(l||a)return void(this.stalled=null);if(r.paused&&!s||r.ended||0===r.playbackRate||!To.getBuffered(r).length)return;const c=To.bufferInfo(r,o,0),u=c.len>0,A=c.nextStart||0;if(!u&&!A)return;if(s){const t=c.len>2,n=!A||e&&e.start<=o||A-o>2&&!this.fragmentTracker.getPartialFragment(o);if(t||n)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var d;const t=Math.max(A,c.start||0)-o,e=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,n=(null==e||null==(d=e.details)?void 0:d.live)?2*e.details.targetduration:2,r=this.fragmentTracker.getPartialFragment(o);if(t>0&&(t<=n||r))return void this._trySkipBufferHole(r)}const h=self.performance.now();if(null===i)return void(this.stalled=h);const f=h-i;if(!s&&f>=250&&(this._reportStall(c),!this.media))return;const p=To.bufferInfo(r,o,n.maxBufferHole);this._tryFixBufferStall(p,f)}_tryFixBufferStall(t,e){const{config:n,fragmentTracker:r,media:i}=this;if(null===i)return;const o=i.currentTime,s=r.getPartialFragment(o);(!s||!this._trySkipBufferHole(s)&&this.media)&&(t.len>n.maxBufferHole||t.nextStart&&t.nextStart-o1e3*n.highBufferWatchdogPeriod&&(Un.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:n,stallReported:r}=this;if(!r&&n){this.stallReported=!0;const r=new Error(`Playback stalling at @${n.currentTime} due to low buffer (${JSON.stringify(t)})`);Un.warn(r.message),e.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:n,media:r}=this;if(null===r)return 0;const i=r.currentTime,o=To.bufferInfo(r,i,0),s=i0&&o.len<1&&r.readyState<3,c=s-i;if(c>0&&(a||l)){if(c>e.maxBufferHole){const{fragmentTracker:e}=this;let n=!1;if(0===i){const t=e.getAppendedFrag(0,Ei);t&&s1?(t=0,this.bitrateTest=!0):t=n.nextAutoLevel),this.level=n.nextLoadLevel=t,this.loadedmetadata=!1}e>0&&-1===t&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Oo,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Mo}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Ho:{var t;const{levels:e,level:n}=this,r=null==e||null==(t=e[n])?void 0:t.details;if(r&&(!r.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(r))break;this.state=Oo;break}if(this.hls.nextLoadLevel!==this.level){this.state=Oo;break}break}case No:{var e;const t=self.performance.now(),n=this.retryDate;(!n||t>=n||null!=(e=this.media)&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Oo)}}this.state===Oo&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:n,media:r}=this,{config:i,nextLoadLevel:o}=t;if(null===e||!r&&(this.startFragRequested||!i.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(null==n||!n[o])return;const s=n[o],a=this.getMainFwdBufferInfo();if(null===a)return;const l=this.getLevelDetails();if(l&&this._streamEnded(a,l)){const t={};return this.altAudio&&(t.type="video"),this.hls.trigger(Pn.BUFFER_EOS,t),void(this.state=Wo)}t.loadLevel!==o&&-1===t.manualLevel&&this.log(`Adapting to level ${o} from level ${this.level}`),this.level=t.nextLoadLevel=o;const c=s.details;if(!c||this.state===Ho||c.live&&this.levelLastLoaded!==o)return this.level=o,void(this.state=Ho);const u=a.len,A=this.getMaxBufferLength(s.maxBitrate);if(u>=A)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const d=this.backtrackFragment?this.backtrackFragment.start:a.end;let h=this.getNextFragment(d,c);if(this.couldBacktrack&&!this.fragPrevious&&h&&"initSegment"!==h.sn&&this.fragmentTracker.getState(h)!==ho){var f;const t=(null!=(f=this.backtrackFragment)?f:h).sn-c.startSN,e=c.fragments[t-1];e&&h.cc===e.cc&&(h=e,this.fragmentTracker.removeFragment(e))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(h&&this.isLoopLoading(h,d)){if(!h.gap){const t=this.audioOnly&&!this.altAudio?Kn:Vn,e=(t===Vn?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,Ei)}h=this.getNextFragmentLoopLoading(h,c,a,Ei,A)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,s,d))}loadFragment(t,e,n){const r=this.fragmentTracker.getState(t);this.fragCurrent=t,r===co||r===Ao?"initSegment"===t.sn?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,n)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,Ei)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(null!=e&&e.readyState){let n;const r=this.getAppendedFrag(e.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const i=this.getLevelDetails();if(null!=i&&i.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*i.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],r=this.fragLastKbps;n=r&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*r)+1:0}else n=0;const o=this.getBufferedFrag(e.currentTime+n);if(o){const t=this.followingBufferedFrag(o);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,n=t.duration,r=Math.max(o.end,e+Math.min(Math.max(n-this.config.maxFragLookUpTolerance,.5*n),.75*n));this.flushMainBuffer(r,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Fo:case _o:case No:case Qo:case Go:this.state=Oo}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const n=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new qs(this.config,n,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;Bn(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const n=this.getMainFwdBufferInfo();null!==n&&0!==n.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${n?n.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(Pn.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let n,r=!1,i=!1;e.levels.forEach((t=>{n=t.audioCodec,n&&(-1!==n.indexOf("mp4a.40.2")&&(r=!0),-1!==n.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=r&&i&&!function(){var t;const e=Vo();return"function"==typeof(null==e||null==(t=e.prototype)?void 0:t.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:n}=this;if(!n||this.state!==Oo)return;const r=n[e.level];(!r.details||r.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(r.details))&&(this.state=Ho)}onLevelLoaded(t,e){var n;const{levels:r}=this,i=e.level,o=e.details,s=o.totalduration;if(!r)return void this.warn(`Levels were reset while loading level ${i}`);this.log(`Level ${i} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${s}`);const a=r[i],l=this.fragCurrent;!l||this.state!==_o&&this.state!==No||l.level===e.level&&l.urlId===a.urlId||!l.loader||this.abortCurrentFrag();let c=0;if(o.live||null!=(n=a.details)&&n.live){if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;c=this.alignPlaylists(o,a.details)}if(a.details=o,this.levelLastLoaded=i,this.hls.trigger(Pn.LEVEL_UPDATED,{details:o,level:i}),this.state===Ho){if(this.waitForCdnTuneIn(o))return;this.state=Oo}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,c),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:n,part:r,payload:i}=t,{levels:o}=this;if(!o)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const s=o[n.level],a=s.details;if(!a)return this.warn(`Dropping fragment ${n.sn} of level ${n.level} after level details were reset`),void this.fragmentTracker.removeFragment(n);const l=s.videoCodec,c=a.PTSKnown||!a.live,u=null==(e=n.initSegment)?void 0:e.data,A=this._getAudioCodec(s),d=this.transmuxer=this.transmuxer||new Xs(this.hls,Ei,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),h=r?r.index:-1,f=-1!==h,p=new So(n.level,n.sn,n.stats.chunkCount,i.byteLength,h,f),g=this.initPTS[n.cc];d.push(i,u,A,l,n,r,a.totalduration,c,p,g)}onAudioTrackSwitching(t,e){const n=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const t=this.fragCurrent;t&&(this.log("Switching to main audio track, cancel main fragment load"),t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const t=this.hls;n&&(t.trigger(Pn.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),t.trigger(Pn.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const n=e.id,r=!!this.hls.audioTracks[n].url;if(r){const t=this.videoBuffer;t&&this.mediaBuffer!==t&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t)}this.altAudio=r,this.tick()}onBufferCreated(t,e){const n=e.tracks;let r,i,o=!1;for(const t in n){const e=n[t];if("main"===e.id){if(i=t,r=e,"video"===t){const e=n[t];e&&(this.videoBuffer=e.buffer)}}else o=!0}o&&r?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:n,part:r}=e;if(n&&n.type!==Ei)return;if(this.fragContextChanged(n))return this.warn(`Fragment ${n.sn}${r?" p: "+r.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Go&&(this.state=Oo));const i=r?r.stats:n.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),"initSegment"!==n.sn&&(this.fragPrevious=n),this.fragBufferedComplete(n,r)}onError(t,e){var n;if(e.fatal)this.state=Yo;else switch(e.details){case On.FRAG_GAP:case On.FRAG_PARSING_ERROR:case On.FRAG_DECRYPT_ERROR:case On.FRAG_LOAD_ERROR:case On.FRAG_LOAD_TIMEOUT:case On.KEY_LOAD_ERROR:case On.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ei,e);break;case On.LEVEL_LOAD_ERROR:case On.LEVEL_LOAD_TIMEOUT:case On.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Ho||(null==(n=e.context)?void 0:n.type)!==yi||(this.state=Oo);break;case On.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case On.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}checkBuffer(){const{media:t,gapController:e}=this;if(t&&e&&t.readyState){if(this.loadedmetadata||!To.getBuffered(t).length){const t=this.state!==Oo?this.fragCurrent:null;e.poll(this.lastCurrentTime,t)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Oo,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==Kn||this.audioOnly&&!this.altAudio){const t=(e===Vn?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(t,e,Ei)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let n=this.startPosition;if(n>=0&&e0&&(i{const{hls:r}=this;if(!n||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Oo,this.startFragRequested=!1,this.bitrateTest=!1;const i=t.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),r.trigger(Pn.FRAG_LOADED,n),t.bitrateTest=!1}))}_handleTransmuxComplete(t){var e;const n="main",{hls:r}=this,{remuxResult:i,chunkMeta:o}=t,s=this.getCurrentContext(o);if(!s)return void this.resetWhenMissingContext(o);const{frag:a,part:l,level:c}=s,{video:u,text:A,id3:d,initSegment:h}=i,{details:f}=c,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(a))this.fragmentTracker.removeFragment(a);else{if(this.state=Qo,h){if(null!=h&&h.tracks){const t=a.initSegment||a;this._bufferInitSegment(c,h.tracks,t,o),r.trigger(Pn.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:n,tracks:h.tracks})}const t=h.initPTS,e=h.timescale;Bn(t)&&(this.initPTS[a.cc]={baseTime:t,timescale:e},r.trigger(Pn.INIT_PTS_FOUND,{frag:a,id:n,initPTS:t,timescale:e}))}if(u&&f&&"initSegment"!==a.sn){const t=f.fragments[a.sn-1-f.startSN],e=a.sn===f.startSN,n=!t||a.cc>t.cc;if(!1!==i.independent){const{startPTS:t,endPTS:r,startDTS:i,endDTS:s}=u;if(l)l.elementaryStreams[u.type]={startPTS:t,endPTS:r,startDTS:i,endDTS:s};else if(u.firstKeyFrame&&u.independent&&1===o.id&&!n&&(this.couldBacktrack=!0),u.dropped&&u.independent){const i=this.getMainFwdBufferInfo(),o=(i?i.end:this.getLoadPosition())+this.config.maxBufferHole,l=u.firstKeyFramePTS?u.firstKeyFramePTS:t;if(!e&&o{const i=e[t].initSegment;null!=i&&i.byteLength&&this.hls.trigger(Pn.BUFFER_APPENDING,{type:t,data:i,frag:n,part:null,chunkMeta:r,parent:n.type})})),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Ei)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Oo}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const n=t.currentTime;if(To.isBuffered(t,n)?e=this.getAppendedFrag(n):To.isBuffered(t,n+.1)&&(e=this.getAppendedFrag(n+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,n=e.level;t&&e.sn===t.sn&&t.level===n&&e.urlId===t.urlId||(this.fragPlaying=e,this.hls.trigger(Pn.FRAG_CHANGED,{frag:e}),t&&t.level===n||this.hls.trigger(Pn.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,n=this.currentFrag;if(n&&Bn(e)&&Bn(n.programDateTime)){const t=n.programDateTime+1e3*(e-n.start);return new Date(t)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class Zs{constructor(t,e=0,n=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=n}sample(t,e){const n=Math.pow(this.alpha_,t);this.estimate_=e*(1-n)+n*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class ta{constructor(t,e,n,r=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Zs(t),this.fast_=new Zs(e),this.defaultTTFB_=r,this.ttfb_=new Zs(t)}update(t,e){const{slow_:n,fast_:r,ttfb_:i}=this;n.halfLife!==t&&(this.slow_=new Zs(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.fast_=new Zs(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.ttfb_=new Zs(t,i.getEstimate(),i.getTotalWeight()))}sample(t,e){const n=(t=Math.max(t,this.minDelayMs_))/1e3,r=8*e/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(t){const e=t/1e3,n=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(n,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class ea{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let n;return t.length?(n=1===t.length?t[0]:function(t,e){const n=new Uint8Array(e);let r=0;for(let e=0;et[n]!==e[n]))}class ia{constructor(t){this.buffered=void 0;const e=(e,n,r)=>{if((n>>>=0)>r-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${r})`);return t[n][e]};this.buffered={get length(){return t.length},end:n=>e("end",n,t.length),start:n=>e("start",n,t.length)}}}function oa(t){const e=[];for(let n=0;n{e=t})),r={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,t),n}executeNext(t){const{buffers:e,queues:n}=this,r=e[t],i=n[t];if(i.length){const e=i[0];try{e.execute()}catch(n){Un.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),e.onError(n),null!=r&&r.updating||(i.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const aa=ei(),la=/([ha]vc.)(?:\.[^.,]+)+/,ca={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ua=function(t){let e=t;return ca.hasOwnProperty(t)&&(e=ca[t]),String.fromCharCode(e)},Aa=15,da=100,ha={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},fa={17:2,18:4,21:6,22:8,23:10,19:13,20:15},pa={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ga={25:2,26:4,29:6,30:8,31:10,27:13,28:15},ma=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class va{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const n="function"==typeof e?e():e;Un.log(`${this.time} [${t}] ${n}`)}}}const ya=function(t){const e=[];for(let n=0;nda&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=da)}moveCursor(t){const e=this.pos+t;if(t>1)for(let t=this.pos+1;t=144&&this.backSpace();const e=ua(t);this.pos>=da?this.logger.log(0,(()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!")):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))}clearFromPos(t){let e;for(e=t;e"pacData = "+JSON.stringify(t)));let e=t.row-1;if(this.nrRollUpRows&&e"bkgData = "+JSON.stringify(t))),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let n="",r=-1;for(let n=0;n0&&(n=t?"["+e.join(" | ")+"]":e.join("\n")),n}getTextAndFormat(){return this.rows}}class Ta{constructor(t,e,n){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new wa(n),this.nonDisplayedMemory=new wa(n),this.lastOutputScreen=new wa(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(()=>"MODE="+t)),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let e=0;ee+": "+this.writeScreen.getDisplayText(!0))),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0))),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(()=>"DISP: "+this.displayedMemory.getDisplayText()))}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{const n=Math.floor(t/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=r[n]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Sa{constructor(t,e,n){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const r=new va;this.channels=[null,new Ta(t,e,r),new Ta(t+1,n,r)],this.cmdHistory={a:null,b:null},this.logger=r}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let n,r,i,o=!1;this.logger.time=t;for(let t=0;t ("+ya([r,i])+")"),n=this.parseCmd(r,i),n||(n=this.parseMidrow(r,i)),n||(n=this.parsePAC(r,i)),n||(n=this.parseBackgroundAttributes(r,i)),!n&&(o=this.parseChars(r,i),o)){const t=this.currentChannel;t&&t>0?this.channels[t].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||o||this.logger.log(2,"Couldn't parse cleaned data "+ya([r,i])+" orig: "+ya([e[t],e[t+1]]))}}parseCmd(t,e){const{cmdHistory:n}=this;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;if(La(t,e,n))return ka(null,null,n),this.logger.log(3,"Repeated command ("+ya([t,e])+") is dropped"),!0;const r=20===t||21===t||23===t?1:2,i=this.channels[r];return 20===t||21===t||28===t||29===t?32===e?i.ccRCL():33===e?i.ccBS():34===e?i.ccAOF():35===e?i.ccAON():36===e?i.ccDER():37===e?i.ccRU(2):38===e?i.ccRU(3):39===e?i.ccRU(4):40===e?i.ccFON():41===e?i.ccRDC():42===e?i.ccTR():43===e?i.ccRTD():44===e?i.ccEDM():45===e?i.ccCR():46===e?i.ccENM():47===e&&i.ccEOC():i.ccTO(e-32),ka(t,e,n),this.currentChannel=r,!0}parseMidrow(t,e){let n=0;if((17===t||25===t)&&e>=32&&e<=47){if(n=17===t?1:2,n!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[n];return!!r&&(r.ccMIDROW(e),this.logger.log(3,"MIDROW ("+ya([t,e])+")"),!0)}return!1}parsePAC(t,e){let n;const r=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;if(La(t,e,r))return ka(null,null,r),!0;const i=t<=23?1:2;n=e>=64&&e<=95?1===i?ha[t]:pa[t]:1===i?fa[t]:ga[t];const o=this.channels[i];return!!o&&(o.setPAC(this.interpretPAC(n,e)),ka(t,e,r),this.currentChannel=i,!0)}interpretPAC(t,e){let n;const r={color:null,italics:!1,indent:null,underline:!1,row:t};return n=e>95?e-96:e-64,r.underline=1==(1&n),n<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((n-16)/2),r}parseChars(t,e){let n,r=null,i=null;if(t>=25?(n=2,i=t-8):(n=1,i=t),i>=17&&i<=19){let t;t=17===i?e+80:18===i?e+112:e+144,this.logger.log(2,"Special char '"+ua(t)+"' in channel "+n),r=[t]}else t>=32&&t<=127&&(r=0===e?[t]:[t,e]);if(r){const n=ya(r);this.logger.log(3,"Char codes = "+n.join(",")),ka(t,e,this.cmdHistory)}return r}parseBackgroundAttributes(t,e){if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;let n;const r={};16===t||24===t?(n=Math.floor((e-32)/2),r.background=ma[n],e%2==1&&(r.background=r.background+"_semi")):45===e?r.background="transparent":(r.foreground="black",47===e&&(r.underline=!0));const i=t<=23?1:2;return this.channels[i].setBkgData(r),ka(t,e,this.cmdHistory),!0}reset(){for(let t=0;tt)&&(this.startTime=t),this.endTime=e,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Ia=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function n(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;const n=e.toLowerCase();return!!~t.indexOf(n)&&n}function r(t){return n(e,t)}function i(t,...e){let n=1;for(;n100)throw new Error("Position must be between 0 and 100.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"positionAlign",i({},l,{get:function(){return C},set:function(t){const e=r(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");C=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"size",i({},l,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"align",i({},l,{get:function(){return E},set:function(t){const e=r(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),a.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o}();class Ra{decode(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Da(t){function e(t,e,n,r){return 3600*(0|t)+60*(0|e)+(0|n)+parseFloat(r||0)}const n=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?e(n[2],n[3],0,n[4]):e(n[1],n[2],n[3],n[4]):null}class Ba{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,n){return n?this.has(t)?this.values[t]:e[n]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,n){for(let r=0;r=0&&n<=100)return this.set(t,n),!0}return!1}}function Pa(t,e,n,r){const i=r?t.split(r):[t];for(const t in i){if("string"!=typeof i[t])continue;const r=i[t].split(n);2===r.length&&e(r[0],r[1])}}const Ma=new Ia(0,0,""),Oa="middle"===Ma.align?"middle":"center";function Fa(t,e,n){const r=t;function i(){const e=Da(t);if(null===e)throw new Error("Malformed timestamp: "+r);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function o(){t=t.replace(/^\s+/,"")}if(o(),e.startTime=i(),o(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);t=t.slice(3),o(),e.endTime=i(),o(),function(t,e){const r=new Ba;Pa(t,(function(t,e){let i;switch(t){case"region":for(let i=n.length-1;i>=0;i--)if(n[i].id===e){r.set(t,n[i].region);break}break;case"vertical":r.alt(t,e,["rl","lr"]);break;case"line":i=e.split(","),r.integer(t,i[0]),r.percent(t,i[0])&&r.set("snapToLines",!1),r.alt(t,i[0],["auto"]),2===i.length&&r.alt("lineAlign",i[1],["start",Oa,"end"]);break;case"position":i=e.split(","),r.percent(t,i[0]),2===i.length&&r.alt("positionAlign",i[1],["start",Oa,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,e);break;case"align":r.alt(t,e,["start",Oa,"end","left","right"])}}),/:/,/\s/),e.region=r.get("region",null),e.vertical=r.get("vertical","");let i=r.get("line","auto");"auto"===i&&-1===Ma.line&&(i=-1),e.line=i,e.lineAlign=r.get("lineAlign","start"),e.snapToLines=r.get("snapToLines",!0),e.size=r.get("size",100),e.align=r.get("align",Oa);let o=r.get("position","auto");"auto"===o&&50===Ma.position&&(o="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=o}(t,e)}function _a(t){return t.replace(//gi,"\n")}class Na{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Ra,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function n(){let t=e.buffer,n=0;for(t=_a(t);n>>0).toString()};function Wa(t,e,n){return Ga(t.toString())+Ga(e.toString())+Ga(n)}const Ya="stpp.ttml.im1t",ja=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ha=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Ka={left:"start",center:"center",right:"end",start:"start",end:"end"};function Va(t,e,n,r){const i=_r(new Uint8Array(t),["mdat"]);if(0===i.length)return void r(new Error("Could not parse IMSC1 mdat"));const o=i.map((t=>Sr(t))),s=function(t,e,n=1,r=!1){return Is(t,e,1/n,r)}(e.baseTime,1,e.timescale);try{o.forEach((t=>n(function(t,e){const n=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(r).reduce(((t,e)=>(t[e]=n.getAttribute(`ttp:${e}`)||r[e],t)),{}),o="preserve"!==n.getAttribute("xml:space"),s=$a(za(n,"styling","style")),a=$a(za(n,"layout","region")),l=za(n,"body","[begin]");return[].map.call(l,(t=>{const n=Xa(t,o);if(!n||!t.hasAttribute("begin"))return null;const r=Za(t.getAttribute("begin"),i),l=Za(t.getAttribute("dur"),i);let c=Za(t.getAttribute("end"),i);if(null===r)throw Ja(t);if(null===c){if(null===l)throw Ja(t);c=r+l}const u=new Ia(r-e,c-e,n);u.id=Wa(u.startTime,u.endTime,u.text);const A=function(t,e,n){const r="http://www.w3.org/ns/ttml#styling";let i=null;const o=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return o&&n.hasOwnProperty(o)&&(i=n[o]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(((n,o)=>{const s=qa(e,r,o)||qa(t,r,o)||qa(i,r,o);return s&&(n[o]=s),n}),{})}(a[t.getAttribute("region")],s[t.getAttribute("style")],s),{textAlign:d}=A;if(d){const t=Ka[d];t&&(u.lineAlign=t),u.align=d}return Dn(u,A),u})).filter((t=>null!==t))}(t,s))))}catch(t){r(t)}}function za(t,e,n){const r=t.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(n)):[]}function $a(t){return t.reduce(((t,e)=>{const n=e.getAttribute("xml:id");return n&&(t[n]=e),t}),{})}function Xa(t,e){return[].slice.call(t.childNodes).reduce(((t,n,r)=>{var i;return"br"===n.nodeName&&r?t+"\n":null!=(i=n.childNodes)&&i.length?Xa(n,e):e?t+n.textContent.trim().replace(/\s+/g," "):t+n.textContent}),"")}function qa(t,e,n){return t&&t.hasAttributeNS(e,n)?t.getAttributeNS(e,n):null}function Ja(t){return new Error(`Could not parse ttml timestamp ${t}`)}function Za(t,e){if(!t)return null;let n=Da(t);return null===n&&(ja.test(t)?n=function(t,e){const n=ja.exec(t),r=(0|n[4])+(0|n[5])/e.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+r/e.frameRate}(t,e):Ha.test(t)&&(n=function(t,e){const n=Ha.exec(t),r=Number(n[1]);switch(n[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}(t,e))),n}function tl(t,e){return!!t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}class el{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(Pn.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(Pn.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const n=this.hls.levels[e.droppedLevel];this.isLevelAllowed(n)&&this.restrictedLevels.push({bitrate:n.bitrate,height:n.height,width:n.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const n=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,n.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const n=e.filter(((e,n)=>this.isLevelAllowed(e)&&n<=t));return this.clientRect=null,el.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const n=t.getBoundingClientRect();e.width=n.width,e.height=n.height,e.width||e.height||(e.width=n.right-n.left||t.width||0,e.height=n.bottom-n.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}isLevelAllowed(t){return!this.restrictedLevels.some((e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height))}static getMaxLevelByMediaSize(t,e,n){if(null==t||!t.length)return-1;let r=t.length-1;for(let s=0;s=e||a.height>=n)&&(i=a,!(o=t[s+1])||i.width!==o.width||i.height!==o.height)){r=s;break}}var i,o;return r}}const nl="[eme]";class rl{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=rl.CDMCleanupPromise?[rl.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=Un.debug.bind(Un,nl),this.log=Un.log.bind(Un,nl),this.warn=Un.warn.bind(Un,nl),this.error=Un.error.bind(Un,nl),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Pn.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Pn.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Pn.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Pn.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:n}=this.config,r=e[t];if(r)return r.licenseUrl;if(t===er.WIDEVINE&&n)return n;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,n=e[t];if(n)return n.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,n=(t,e,n)=>!!t&&n.indexOf(t)===e,r=e.map((t=>t.audioCodec)).filter(n),i=e.map((t=>t.videoCodec)).filter(n);return r.length+i.length===0&&i.push("avc1.42e01e"),new Promise(((e,n)=>{const o=t=>{const s=t.shift();this.getMediaKeysPromise(s,r,i).then((t=>e({keySystem:s,mediaKeys:t}))).catch((e=>{t.length?o(t):n(e instanceof il?e:new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};o(t)}))}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:n}=this.config;if("function"!=typeof n){let t=`Configured requestMediaKeySystemAccess is not a function ${n}`;return null===ur&&"http:"===self.location.protocol&&(t=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(t))}return n(t,e)}getMediaKeysPromise(t,e,n){const r=function(t,e,n,r){let i;switch(t){case er.FAIRPLAY:i=["cenc","sinf"];break;case er.WIDEVINE:case er.PLAYREADY:i=["cenc"];break;case er.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return function(t,e,n,r){return[{initDataTypes:t,persistentState:r.persistentState||"not-allowed",distinctiveIdentifier:r.distinctiveIdentifier||"not-allowed",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map((t=>({contentType:`audio/mp4; codecs="${t}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null}))),videoCapabilities:n.map((t=>({contentType:`video/mp4; codecs="${t}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null})))}]}(i,e,n,r)}(t,e,n,this.config.drmSystemOptions),i=this.keySystemAccessPromises[t];let o=null==i?void 0:i.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(r)}`),o=this.requestMediaKeySystemAccess(t,r);const e=this.keySystemAccessPromises[t]={keySystemAccess:o};return o.catch((e=>{this.log(`Failed to obtain access to key-system "${t}": ${e}`)})),o.then((n=>{this.log(`Access for key-system "${n.keySystem}" obtained`);const r=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),e.mediaKeys=n.createMediaKeys().then((e=>(this.log(`Media-keys created for "${t}"`),r.then((n=>n?this.setMediaKeysServerCertificate(e,t,n):e))))),e.mediaKeys.catch((e=>{this.error(`Failed to create media-keys for "${t}"}: ${e}`)})),e.mediaKeys}))}return o.then((()=>i.mediaKeys))}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:n}){this.log(`Creating key-system session "${e}" keyId: ${xr(t.keyId||[])}`);const r=n.createSession(),i={decryptdata:t,keySystem:e,mediaKeys:n,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const n=this.createMediaKeySessionContext(t),r=this.getKeyIdString(e),i="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(n,i,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return xr(t.keyId)}updateKeySession(t,e){var n;const r=t.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${xr((null==(n=t.decryptdata)?void 0:n.keyId)||[])}\n } (data length: ${e?e.byteLength:e})`),r.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise(((e,n)=>{const r=cr(this.config),i=t.map(sr).filter((t=>!!t&&-1!==r.indexOf(t)));return this.getKeySystemSelectionPromise(i).then((({keySystem:t})=>{const r=lr(t);r?e(r):n(new Error(`Unable to find format for key-system "${t}"`))})).catch(n)}))}loadKey(t){const e=t.keyInfo.decryptdata,n=this.getKeyIdString(e),r=`(keyId: ${n} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${r}`);let i=this.keyIdToKeySessionPromise[n];return i||(i=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(e).then((({keySystem:n,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${r}`),this.attemptSetMediaKeys(n,i).then((()=>{this.throwIfDestroyed();const t=this.createMediaKeySessionContext({keySystem:n,mediaKeys:i,decryptdata:e});return this.generateRequestWithPreferredKeySession(t,"cenc",e.pssh,"playlist-key")}))))),i.catch((t=>this.handleError(t)))),i}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof il?this.hls.trigger(Pn.ERROR,t.data):this.hls.trigger(Pn.ERROR,{type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),n=this.keyIdToKeySessionPromise[e];if(!n){const e=sr(t.keyFormat),n=e?[e]:cr(this.config);return this.attemptKeySystemAccess(n)}return n}getKeySystemSelectionPromise(t){if(t.length||(t=cr(this.config)),0===t.length)throw new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:n}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),null===n)return;let r,i;if("sinf"===e&&this.config.drmSystems[er.FAIRPLAY]){const t=Br(new Uint8Array(n));try{const e=Zn(JSON.parse(t).sinf),n=Qr(new Uint8Array(e));if(!n)return;r=n.subarray(8,24),i=er.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const t=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},n=new DataView(t),r=n.getUint32(0);if(t.byteLength!==r&&r>44)return null;if(1886614376!==n.getUint32(4))return null;if(e.version=n.getUint32(8)>>>24,e.version>1)return null;e.systemId=xr(new Uint8Array(t,12,16));const i=n.getUint32(28);if(0===e.version){if(r-32this.generateRequestWithPreferredKeySession(i,e,n,"encrypted-event-key-match")));break}}l||(l=s[o]=this.getKeySystemSelectionPromise([i]).then((({keySystem:t,mediaKeys:i})=>{var s;this.throwIfDestroyed();const a=new zr("ISO-23001-7",o,null!=(s=lr(t))?s:"");return a.pssh=new Uint8Array(n),a.keyId=r,this.attemptSetMediaKeys(t,i).then((()=>{this.throwIfDestroyed();const r=this.createMediaKeySessionContext({decryptdata:a,keySystem:t,mediaKeys:i});return this.generateRequestWithPreferredKeySession(r,e,n,"encrypted-event-no-match")}))}))),l.catch((t=>this.handleError(t)))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const n=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const r=Promise.all(n).then((()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)}));return this.setMediaKeysQueue.push(r),r.then((()=>{this.log(`Media-keys set for "${t}"`),n.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((t=>-1===n.indexOf(t)))}))}generateRequestWithPreferredKeySession(t,e,n,r){var i,o;const s=null==(i=this.config.drmSystems)||null==(o=i[t.keySystem])?void 0:o.generateRequest;if(s)try{const r=s.call(this.hls,e,n,t);if(!r)throw new Error("Invalid response from configured generateRequest filter");e=r.initDataType,n=t.decryptdata.pssh=r.initData?new Uint8Array(r.initData):null}catch(t){var a;if(this.warn(t.message),null!=(a=this.hls)&&a.config.debug)throw t}if(null===n)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(t);const l=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${r}": ${l} (init data type: ${e} length: ${n?n.byteLength:null})`);const c=new zs;t.mediaKeysSession.onmessage=e=>{const n=t.mediaKeysSession;if(!n)return void c.emit("error",new Error("invalid state"));const{messageType:r,message:i}=e;this.log(`"${r}" message event for session "${n.sessionId}" message size: ${i.byteLength}`),"license-request"===r||"license-renewal"===r?this.renewLicense(t,i).catch((t=>{this.handleError(t),c.emit("error",t)})):"license-release"===r?t.keySystem===er.FAIRPLAY&&(this.updateKeySession(t,tr("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${r}"`)},t.mediaKeysSession.onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void c.emit("error",new Error("invalid state"));this.onKeyStatusChange(t);const n=t.keyStatus;c.emit("keyStatus",n),"expired"===n&&(this.warn(`${t.keySystem} expired for key ${l}`),this.renewKeySession(t))};const u=new Promise(((t,e)=>{c.on("error",e),c.on("keyStatus",(n=>{n.startsWith("usable")?t():"output-restricted"===n?e(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===n?e(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${n}"`)):"expired"===n?e(new Error("key expired while generating request")):this.warn(`unhandled key status change "${n}"`)}))}));return t.mediaKeysSession.generateRequest(e,n).then((()=>{var e;this.log(`Request generated for key-session "${null==(e=t.mediaKeysSession)?void 0:e.sessionId}" keyId: ${l}`)})).catch((t=>{throw new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},`Error generating key-session request: ${t}`)})).then((()=>u)).catch((e=>{throw c.removeAllListeners(),this.removeSession(t),e})).then((()=>(c.removeAllListeners(),t)))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach(((e,n)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${xr("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))} session keyId: ${xr(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e}))}fetchServerCertificate(t){const e=this.config,n=new(0,e.loader)(e),r=this.getServerCertificateUrl(t);return r?(this.log(`Fetching serverCertificate for "${t}"`),new Promise(((i,o)=>{const s={responseType:"arraybuffer",url:r},a=e.certLoadPolicy.default,l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,n,r)=>{i(t.data)},onError:(e,n,i,a)=>{o(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:In({url:s.url,data:void 0},e)},`"${t}" certificate request failed (${r}). Status: ${e.code} (${e.text})`))},onTimeout:(e,n,i)=>{o(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:{url:s.url,data:void 0}},`"${t}" certificate request timed out (${r})`))},onAbort:(t,e,n)=>{o(new Error("aborted"))}};n.load(s,l,c)}))):Promise.resolve()}setMediaKeysServerCertificate(t,e,n){return new Promise(((r,i)=>{t.setServerCertificate(n).then((i=>{this.log(`setServerCertificate ${i?"success":"not supported by CDM"} (${null==n?void 0:n.byteLength}) on "${e}"`),r(t)})).catch((t=>{i(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))}))}))}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then((e=>this.updateKeySession(t,new Uint8Array(e)).catch((t=>{throw new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))))}setupLicenseXHR(t,e,n,r){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then((()=>{if(!n.decryptdata)throw new Error("Key removed");return i.call(this.hls,t,e,n,r)})).catch((o=>{if(!n.decryptdata)throw o;return t.open("POST",e,!0),i.call(this.hls,t,e,n,r)})).then((n=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:n||r}))):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:r}))}requestLicense(t,e){const n=this.config.keyLoadPolicy.default;return new Promise(((r,i)=>{const o=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${o}`);const s=new XMLHttpRequest;s.responseType="arraybuffer",s.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return i(new Error("invalid state"));if(4===s.readyState)if(200===s.status){this._requestLicenseFailureCount=0;let e=s.response;this.log(`License received ${e instanceof ArrayBuffer?e.byteLength:e}`);const n=this.config.licenseResponseCallback;if(n)try{e=n.call(this.hls,s,o,t)}catch(t){this.error(t)}r(e)}else{const a=n.errorRetry,l=a?a.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||s.status>=400&&s.status<500)i(new il({type:Mn.KEY_SYSTEM_ERROR,details:On.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:o,data:void 0,code:s.status,text:s.statusText}},`License Request XHR failed (${o}). Status: ${s.status} (${s.statusText})`));else{const n=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${n} attempts left`),this.requestLicense(t,e).then(r,i)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=s,this.setupLicenseXHR(s,o,t,e).then((({xhr:t,licenseChallenge:e})=>{t.send(e)}))}))}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const n=e.media;this.media=n,n.addEventListener("encrypted",this.onMediaEncrypted),n.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},zr.clearKeyUriToKeyIdMap();const n=e.length;rl.CDMCleanupPromise=Promise.all(e.map((t=>this.removeSession(t))).concat(null==t?void 0:t.setMediaKeys(null).catch((e=>{this.log(`Could not clear media keys: ${e}. media.src: ${null==t?void 0:t.src}`)})))).then((()=>{n&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)})).catch((e=>{this.log(`Could not close sessions and clear media keys: ${e}. media.src: ${null==t?void 0:t.src}`)}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(e&&this.config.emeEnabled&&!this.keyFormatPromise){const t=e.reduce(((t,e)=>(-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t)),[]);this.log(`Selecting key-system from session-keys ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:n}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(t);return r>-1&&this.mediaKeySessions.splice(r,1),e.remove().catch((t=>{this.log(`Could not remove session: ${t}`)})).then((()=>e.close())).catch((t=>{this.log(`Could not close session: ${t}`)}))}}}rl.CDMCleanupPromise=void 0;class il extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}var ol="a",sl="av";class al{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:"m",su:!this.initialized})}catch(t){Un.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{const e=t.frag,n=this.hls.levels[e.level],r=this.getObjectType(e),i={d:1e3*e.duration,ot:r};"v"!==r&&r!==ol&&r!=sl||(i.br=n.bitrate/1e3,i.tb=this.getTopBandwidth(r)/1e3,i.bl=this.getBufferLength(r)),this.apply(t,i)}catch(t){Un.warn("Could not generate segment CMCD data.",t)}},this.hls=t;const e=this.config=t.config,{cmcd:n}=e;null!=n&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||al.uuid(),this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.registerListeners())}registerListeners(){const t=this.hls;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHED,this.onMediaDetached,this),t.on(Pn.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHED,this.onMediaDetached,this),t.off(Pn.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var n,r;this.audioBuffer=null==(n=e.tracks.audio)?void 0:n.buffer,this.videoBuffer=null==(r=e.tracks.video)?void 0:r.buffer}createData(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){Dn(e,this.createData());const n="i"===e.ot||"v"===e.ot||e.ot===sl;if(this.starved&&n&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering),this.useHeaders){const n=al.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),Dn(t.headers,n)}else{const n=al.toQuery(e);if(!n)return;t.url=al.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;return"subtitle"===e?"tt":"initSegment"===t.sn?"i":"audio"===e?ol:"main"===e?this.hls.audioTracks.length?"v":sl:void 0}getTopBandwidth(t){let e,n=0;const r=this.hls;if(t===ol)e=r.audioTracks;else{const t=r.maxAutoLevel,n=t>-1?t+1:r.levels.length;e=r.levels.slice(0,n)}for(const t of e)t.bitrate>n&&(n=t.bitrate);return n>0?n:NaN}getBufferLength(t){const e=this.hls.media,n=t===ol?this.audioBuffer:this.videoBuffer;return n&&e?1e3*To.bufferInfo(n,e.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,n=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new n(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,n,r){e(t),this.loader.load(t,n,r)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,n=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new n(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,n,r){e(t),this.loader.load(t,n,r)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],n=t=>!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t,r=t=>Math.round(t),i=t=>100*r(t/100),o={br:r,d:r,bl:i,dl:i,mtp:i,nor:t=>encodeURIComponent(t),rtp:i,tb:r},s=Object.keys(t||{}).sort();for(const r of s){let i=t[r];if(!n(i))continue;if("v"===r&&1===i)continue;if("pr"==r&&1===i)continue;const s=o[r];s&&(i=s(i));const a=typeof i;let l;l="ot"===r||"sf"===r||"st"===r?`${r}=${i}`:"boolean"===a?r:"number"===a?`${r}=${i}`:`${r}=${JSON.stringify(i)}`,e.push(l)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),n={},r=["Object","Request","Session","Status"],i=[{},{},{},{}],o={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const n of e)i[null!=o[n]?o[n]:1][n]=t[n];for(let t=0;t{const o=t.filter((t=>t.groupId===i)).map((t=>{const o=Dn({},t);return o.details=void 0,o.attrs=new Wn(o.attrs),o.url=o.attrs.URI=cl(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",n),o.groupId=o.attrs["GROUP-ID"]=e[i],o.attrs["PATHWAY-ID"]=r,o}));t.push(...o)}))}function cl(t,e,n,r){const{HOST:i,PARAMS:o,[n]:s}=r;let a;e&&(a=null==s?void 0:s[e],a&&(t=a));const l=new self.URL(t);return i&&!a&&(l.host=i),o&&Object.keys(o).sort().forEach((t=>{t&&l.searchParams.set(t,o[t])})),l.href}const ul=/^age:\s*[\d.]+\s*$/im;class Al{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new Hn,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,n){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=n,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const n=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then((()=>{if(!this.stats.aborted)return i(n,e.url)})).catch((t=>(n.open("GET",e.url,!0),i(n,e.url)))).then((()=>{this.stats.aborted||this.openAndSendXhr(n,e,t)})).catch((t=>{this.callbacks.onError({code:n.status,text:t.message},e,n,r)})):this.openAndSendXhr(n,e,t)}openAndSendXhr(t,e,n){t.readyState||t.open("GET",e.url,!0);const r=this.context.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:o}=n.loadPolicy;if(r)for(const e in r)t.setRequestHeader(e,r[e]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),n.timeout=i&&Bn(i)?i:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:n}=this;if(!t||!e)return;const r=e.readyState,i=this.config;if(!n.aborted&&r>=2&&(0===n.loading.first&&(n.loading.first=Math.max(self.performance.now(),n.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(n.loading.first-n.loading.start)))),4===r)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const r=e.status,o="text"!==e.responseType;if(r>=200&&r<300&&(o&&e.response||null!==e.responseText)){n.loading.end=Math.max(self.performance.now(),n.loading.first);const i=o?e.response:e.responseText,s="arraybuffer"===e.responseType?i.byteLength:i.length;if(n.loaded=n.total=s,n.bwEstimate=8e3*n.total/(n.loading.end-n.loading.first),!this.callbacks)return;const a=this.callbacks.onProgress;if(a&&a(n,t,i,e),!this.callbacks)return;const l={url:e.responseURL,data:i,code:r};this.callbacks.onSuccess(l,n,t,e)}else{const o=i.loadPolicy.errorRetry;Ji(o,n.retry,!1,r)?this.retry(o):(Un.error(`${r} while loading ${t.url}`),this.callbacks.onError({code:r,text:e.statusText},t,e,n))}}}loadtimeout(){var t;const e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(Ji(e,this.stats.retry,!0))this.retry(e);else{Un.warn(`timeout while loading ${this.context.url}`);const t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:n}=this;this.retryDelay=Xi(t,n.retry),n.retry++,Un.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${n.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&ul.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const dl=/(\d+)-(\d+)\/(\d+)/;class hl{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||fl,this.controller=new self.AbortController,this.stats=new Hn}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,n){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const i=function(t,e){const n={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Dn({},t.headers))};return t.rangeEnd&&n.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),n}(t,this.controller.signal),o=n.onProgress,s="arraybuffer"===t.responseType,a=s?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=n,this.request=this.fetchSetup(t,i),self.clearTimeout(this.requestTimeout),e.timeout=l&&Bn(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),n.onTimeout(r,t,this.response)}),e.timeout),self.fetch(this.request).then((i=>{this.response=this.loader=i;const a=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),n.onTimeout(r,t,this.response)}),c-(a-r.loading.start)),!i.ok){const{status:t,statusText:e}=i;throw new pl(e||"fetch, bad network response",t,i)}return r.loading.first=a,r.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=dl.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(Bn(t))return t}const n=t.get("Content-Length");if(n)return parseInt(n)}(i.headers)||r.total,o&&Bn(e.highWaterMark)?this.loadProgressively(i,r,t,e.highWaterMark,o):s?i.arrayBuffer():"json"===t.responseType?i.json():i.text()})).then((i=>{const{response:s}=this;self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const l=i[a];l&&(r.loaded=r.total=l);const c={url:s.url,data:i,code:s.status};o&&!Bn(e.highWaterMark)&&o(r,t,i,s),n.onSuccess(c,r,t,s)})).catch((e=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const i=e&&e.code||0,o=e?e.message:null;n.onError({code:i,text:o},t,e?e.details:null,r)}))}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,n,r=0,i){const o=new ea,s=t.body.getReader(),a=()=>s.read().then((s=>{if(s.done)return o.dataLength&&i(e,n,o.flush(),t),Promise.resolve(new ArrayBuffer(0));const l=s.value,c=l.length;return e.loaded+=c,c=r&&i(e,n,o.flush(),t)):i(e,n,l,t),a()})).catch((()=>Promise.reject()));return a()}}function fl(t,e){return new self.Request(t.url,e)}class pl extends Error{constructor(t,e,n){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=n}}const gl=/\s/,ml={newCue(t,e,n,r){const i=[];let o,s,a,l,c;const u=self.VTTCue||self.TextTrackCue;for(let d=0;d=16?l--:l++;const r=_a(c.trim()),h=Wa(e,n,r);null!=t&&null!=(A=t.cues)&&A.getCueById(h)||(s=new u(e,n,r),s.id=h,s.line=d+1,s.align="left",s.position=10+Math.min(80,10*Math.floor(8*l/32)),i.push(s))}return t&&i.length&&(i.sort(((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line)),i.forEach((e=>Ii(t,e)))),i}},vl=In(In({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Al,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new ta(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(Pn.FRAG_LOADING,this.onFragLoading,this),t.on(Pn.FRAG_LOADED,this.onFragLoaded,this),t.on(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Pn.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.FRAG_LOADING,this.onFragLoading,this),t.off(Pn.FRAG_LOADED,this.onFragLoaded,this),t.off(Pn.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Pn.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var n;const r=e.frag;this.ignoreFragment(r)||(this.fragCurrent=r,this.partCurrent=null!=(n=e.part)?n:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,n,r){return t+n/e+(r?this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const n=this.hls.config,{total:r,bwEstimate:i}=e.stats;Bn(r)&&Bn(i)&&(this.lastLevelLoadSec=8*r/i),e.details.live?this.bwEstimator.update(n.abrEwmaSlowLive,n.abrEwmaFastLive):this.bwEstimator.update(n.abrEwmaSlowVoD,n.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:n}=this,{autoLevelEnabled:r,media:i}=n;if(!t||!i)return;const o=performance.now(),s=e?e.stats:t.stats,a=e?e.duration:t.duration,l=o-s.loading.start;if(s.aborted||s.loaded&&s.loaded===s.total||0===t.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!r||i.paused||!i.playbackRate||!i.readyState)return;const c=n.mainForwardBufferInfo;if(null===c)return;const u=this.bwEstimator.getEstimateTTFB(),A=Math.abs(i.playbackRate);if(l<=Math.max(u,a/(2*A)*1e3))return;const d=c.len/A;if(d>=2*a/A)return;const h=s.loading.first?s.loading.first-s.loading.start:-1,f=s.loaded&&h>-1,p=this.bwEstimator.getEstimate(),{levels:g,minAutoLevel:m}=n,v=g[t.level],y=s.total||Math.max(s.loaded,Math.round(a*v.maxBitrate/8));let C=l-h;C<1&&f&&(C=Math.min(l,8*s.loaded/p));const b=f?1e3*s.loaded/C:0,E=b?(y-s.loaded)/b:8*y/p+u/1e3;if(E<=d)return;const w=b?8*b:p;let T,S=Number.POSITIVE_INFINITY;for(T=t.level-1;T>m;T--){const t=g[T].maxBitrate;if(S=this.getTimeToLoadFrag(u/1e3,w,a*t,!g[T].details),S=E||S>10*a||(n.nextLoadLevel=T,f?this.bwEstimator.sample(l-Math.min(u,h),s.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),Un.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;\n Time to underbuffer: ${d.toFixed(3)} s\n Estimated load time for current fragment: ${E.toFixed(3)} s\n Estimated load time for down switch fragment: ${S.toFixed(3)} s\n TTFB estimate: ${h}\n Current BW estimate: ${Bn(p)?(p/1024).toFixed(3):"Unknown"} Kb/s\n New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s\n Aborting and switching to level ${T}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),n.trigger(Pn.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:s}))}onFragLoaded(t,{frag:e,part:n}){const r=n?n.stats:e.stats;if(e.type===Ei&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const t=n?n.duration:e.duration,i=this.hls.levels[e.level],o=(i.loaded?i.loaded.bytes:0)+r.loaded,s=(i.loaded?i.loaded.duration:0)+t;i.loaded={bytes:o,duration:s},i.realBitrate=Math.round(8*o/s)}if(e.bitrateTest){const t={stats:r,frag:e,part:n,id:e.type};this.onFragBuffered(Pn.FRAG_BUFFERED,t),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:n,part:r}=e,i=null!=r&&r.stats.loaded?r.stats:n.stats;if(i.aborted)return;if(this.ignoreFragment(n))return;const o=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),n.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Ei||"initSegment"===t.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;let n=this.getNextABRAutoLevel();if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,n)&&e[t].loadError<=e[n].loadError)return t}return-1!==t&&(n=Math.min(t,n)),n}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:n}=this,{maxAutoLevel:r,config:i,minAutoLevel:o,media:s}=n,a=e?e.duration:t?t.duration:0,l=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,u=n.mainForwardBufferInfo,A=(u?u.len:0)/l;let d=this.findBestLevel(c,o,r,A,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(d>=0)return d;Un.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let h=a?Math.min(a,i.maxStarvationDelay):i.maxStarvationDelay,f=i.abrBandWidthFactor,p=i.abrBandWidthUpFactor;if(!A){const t=this.bitrateTestDelay;t&&(h=(a?Math.min(a,i.maxLoadingDelay):i.maxLoadingDelay)-t,Un.trace(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),f=p=1)}return d=this.findBestLevel(c,o,r,A+h,f,p),Math.max(d,0)}findBestLevel(t,e,n,r,i,o){var s;const{fragCurrent:a,partCurrent:l,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,A=u[c],d=!(null==A||null==(s=A.details)||!s.live),h=null==A?void 0:A.codecSet,f=l?l.duration:a?a.duration:0,p=this.bwEstimator.getEstimateTTFB()/1e3;let g=e,m=-1;for(let s=n;s>=e;s--){const e=u[s];if(!e||h&&e.codecSet!==h){e&&(g=Math.min(s,g),m=Math.max(s,m));continue}-1!==m&&Un.trace(`[abr] Skipped level(s) ${g}-${m} with CODECS:"${u[m].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const n=e.details,a=(l?null==n?void 0:n.partTarget:null==n?void 0:n.averagetargetduration)||f;let v;v=s<=c?i*t:o*t;const y=u[s].maxBitrate,C=this.getTimeToLoadFrag(p,v,y*a,void 0===n);if(Un.trace(`[abr] level:${s} adjustedbw-bitrate:${Math.round(v-y)} avgDuration:${a.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:${C.toFixed(1)}`),v>y&&(0===C||!Bn(C)||d&&!this.bitrateTestDelay||C{const{media:t,mediaSource:e}=this;Un.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(Pn.MEDIA_ATTACHED,{media:t})),e&&e.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{Un.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{Un.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:t,_objectUrl:e}=this;t&&t.src!==e&&Un.error(`Media element src was set while attaching MediaSource (${e} > ${t.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.BUFFER_RESET,this.onBufferReset,this),t.on(Pn.BUFFER_APPENDING,this.onBufferAppending,this),t.on(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Pn.BUFFER_EOS,this.onBufferEos,this),t.on(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(Pn.FRAG_PARSED,this.onFragParsed,this),t.on(Pn.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.BUFFER_RESET,this.onBufferReset,this),t.off(Pn.BUFFER_APPENDING,this.onBufferAppending,this),t.off(Pn.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Pn.BUFFER_EOS,this.onBufferEos,this),t.off(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(Pn.FRAG_PARSED,this.onFragParsed,this),t.off(Pn.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new sa(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let n=2;(e.audio&&!e.video||!e.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,Un.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const n=this.media=e.media;if(n&&aa){const t=this.mediaSource=new aa;t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(t),this._objectUrl=n.src,n.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:n}=this;if(e){if(Un.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){Un.warn(`[buffer-controller]: onMediaDetaching: ${t.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),n&&self.URL.revokeObjectURL(n),t.src===n?(t.removeAttribute("src"),t.load()):Un.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(Pn.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(e){Un.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,e)}})),this._initSourceBuffer()}onBufferCodecs(t,e){const n=this.getSourceBufferTypes().length;Object.keys(e).forEach((t=>{if(n){const n=this.tracks[t];if(n&&"function"==typeof n.buffer.changeType){const{id:r,codec:i,levelCodec:o,container:s,metadata:a}=e[t],l=(n.levelCodec||n.codec).replace(la,"$1"),c=(o||i).replace(la,"$1");if(l!==c){const e=`${s};codecs=${o||i}`;this.appendChangeType(t,e),Un.log(`[buffer-controller]: switching codec ${l} to ${c}`),this.tracks[t]={buffer:n.buffer,codec:i,container:s,levelCodec:o,metadata:a,id:r}}}}else this.pendingTracks[t]=e[t]})),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:n}=this,r={execute:()=>{const r=this.sourceBuffer[t];r&&(Un.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),r.changeType(e)),n.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{Un.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,e)}};n.append(r,t)}onBufferAppending(t,e){const{hls:n,operationQueue:r,tracks:i}=this,{data:o,type:s,frag:a,part:l,chunkMeta:c}=e,u=c.buffering[s],A=self.performance.now();u.start=A;const d=a.stats.buffering,h=l?l.stats.buffering:null;0===d.start&&(d.start=A),h&&0===h.start&&(h.start=A);const f=i.audio;let p=!1;"audio"===s&&"audio/mpeg"===(null==f?void 0:f.container)&&(p=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const g=a.start,m={execute:()=>{if(u.executeStart=self.performance.now(),p){const t=this.sourceBuffer[s];if(t){const e=g-t.timestampOffset;Math.abs(e)>=.1&&(Un.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${g} (delta: ${e}) sn: ${a.sn})`),t.timestampOffset=g)}}this.appendExecutor(o,s)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();u.executeEnd=u.end=t,0===d.first&&(d.first=t),h&&0===h.first&&(h.first=t);const{sourceBuffer:e}=this,n={};for(const t in e)n[t]=To.getBuffered(e[t]);this.appendError=0,this.hls.trigger(Pn.BUFFER_APPENDED,{type:s,frag:a,part:l,chunkMeta:c,parent:a.type,timeRanges:n})},onError:t=>{Un.error(`[buffer-controller]: Error encountered while trying to append to the ${s} SourceBuffer`,t);const e={type:Mn.MEDIA_ERROR,parent:a.type,details:On.BUFFER_APPEND_ERROR,frag:a,part:l,chunkMeta:c,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=On.BUFFER_FULL_ERROR:(this.appendError++,e.details=On.BUFFER_APPEND_ERROR,this.appendError>n.config.appendErrorMaxRetry&&(Un.error(`[buffer-controller]: Failed ${n.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),e.fatal=!0)),n.trigger(Pn.ERROR,e)}};r.append(m,s)}onBufferFlushing(t,e){const{operationQueue:n}=this,r=t=>({execute:this.removeExecutor.bind(this,t,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Pn.BUFFER_FLUSHED,{type:t})},onError:e=>{Un.warn(`[buffer-controller]: Failed to remove from ${t} SourceBuffer`,e)}});e.type?n.append(r(e.type),e.type):this.getSourceBufferTypes().forEach((t=>{n.append(r(t),t)}))}onFragParsed(t,e){const{frag:n,part:r}=e,i=[],o=r?r.elementaryStreams:n.elementaryStreams;o.audiovideo?i.push("audiovideo"):(o.audio&&i.push("audio"),o.video&&i.push("video")),0===i.length&&Un.warn(`Fragments must have at least one ElementaryStreamType set. type: ${n.type} level: ${n.level} sn: ${n.sn}`),this.blockBuffers((()=>{const t=self.performance.now();n.stats.buffering.end=t,r&&(r.stats.buffering.end=t);const e=r?r.stats:n.stats;this.hls.trigger(Pn.FRAG_BUFFERED,{frag:n,part:r,stats:e,id:n.type})}),i)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce(((t,n)=>{const r=this.sourceBuffer[n];return!r||e.type&&e.type!==n||(r.ending=!0,r.ended||(r.ended=!0,Un.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),t&&!(r&&!r.ended)}),!0)&&(Un.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((()=>{this.getSourceBufferTypes().forEach((t=>{const e=this.sourceBuffer[t];e&&(e.ending=!1)}));const{mediaSource:t}=this;t&&"open"===t.readyState?(Un.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&Un.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${t.readyState}`)})))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:n,sourceBuffer:r}=this;if(!n||null===e)return;const i=this.getSourceBufferTypes();if(!i.length)return;const o=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(!Bn(o)||o<0)return;const s=n.currentTime,a=e.levelTargetDuration,l=Math.max(o,a),c=Math.floor(s/a)*a-l;i.forEach((n=>{const i=r[n];if(i){const r=To.getBuffered(i);if(r.length>0&&c>r.start(0)){if(t.trigger(Pn.BACK_BUFFER_REACHED,{bufferEnd:c}),e.live)t.trigger(Pn.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(i.ended&&r.end(r.length-1)-s<2*a)return void Un.info(`[buffer-controller]: Cannot flush ${n} back buffer while SourceBuffer is in ended state`);t.trigger(Pn.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:n})}}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:t,hls:e,media:n,mediaSource:r}=this,i=t.fragments[0].start+t.totalduration,o=n.duration,s=Bn(r.duration)?r.duration:0;t.live&&e.config.liveDurationInfinity?(Un.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(i>s&&i>o||!Bn(o))&&(Un.log(`[buffer-controller]: Updating Media Source duration to ${i.toFixed(3)}`),r.duration=i)}updateSeekableRange(t){const e=this.mediaSource,n=t.fragments;if(n.length&&t.live&&null!=e&&e.setLiveSeekableRange){const r=Math.max(0,n[0].start),i=Math.max(r,r+t.totalduration);e.setLiveSeekableRange(r,i)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:n}=this,r=Object.keys(n).length;if(r&&!t||2===r){this.createSourceBuffers(n),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(Pn.BUFFER_CREATED,{tracks:this.tracks}),t.forEach((t=>{e.executeNext(t)}));else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:n}=this;if(!n)throw Error("createSourceBuffers called when mediaSource was null");for(const r in t)if(!e[r]){const i=t[r];if(!i)throw Error(`source buffer exists for track ${r}, however track does not`);const o=i.levelCodec||i.codec,s=`${i.container};codecs=${o}`;Un.log(`[buffer-controller]: creating sourceBuffer(${s})`);try{const t=e[r]=n.addSourceBuffer(s),a=r;this.addBufferListener(a,"updatestart",this._onSBUpdateStart),this.addBufferListener(a,"updateend",this._onSBUpdateEnd),this.addBufferListener(a,"error",this._onSBUpdateError),this.tracks[r]={buffer:t,codec:o,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(t){Un.error(`[buffer-controller]: error while trying to add sourceBuffer: ${t.message}`),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:s})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const n=new Error(`${t} SourceBuffer error`);Un.error(`[buffer-controller]: ${n}`,e),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.BUFFER_APPENDING_ERROR,error:n,fatal:!1});const r=this.operationQueue.current(t);r&&r.onError(e)}removeExecutor(t,e,n){const{media:r,mediaSource:i,operationQueue:o,sourceBuffer:s}=this,a=s[t];if(!r||!i||!a)return Un.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),void o.shiftAndExecuteNext(t);const l=Bn(r.duration)?r.duration:1/0,c=Bn(i.duration)?i.duration:1/0,u=Math.max(0,e),A=Math.min(n,l,c);A>u&&!a.ending?(a.ended=!1,Un.log(`[buffer-controller]: Removing [${u},${A}] from the ${t} SourceBuffer`),a.remove(u,A)):o.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:n,sourceBuffer:r}=this,i=r[e];if(!i)return Un.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),void n.shiftAndExecuteNext(e);i.ended=!1,i.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length)return Un.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);const{operationQueue:n}=this,r=e.map((t=>n.appendBlocker(t)));Promise.all(r).then((()=>{t(),e.forEach((t=>{const e=this.sourceBuffer[t];null!=e&&e.updating||n.shiftAndExecuteNext(t)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,n){const r=this.sourceBuffer[t];if(!r)return;const i=n.bind(this,t);this.listeners[t].push({event:e,listener:i}),r.addEventListener(e,i)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach((t=>{e.removeEventListener(t.event,t.listener)}))}},capLevelController:el,errorController:class{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=Un.log.bind(Un,"[info]:"),this.warn=Un.warn.bind(Un,"[warning]:"),this.error=Un.error.bind(Un,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(Pn.ERROR,this.onError,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(Pn.ERROR,this.onError,this),t.off(Pn.ERROR,this.onErrorOut,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(null==t?void 0:t.type)===Ei?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var n,r;if(e.fatal)return;const i=this.hls,o=e.context;switch(e.details){case On.FRAG_LOAD_ERROR:case On.FRAG_LOAD_TIMEOUT:case On.KEY_LOAD_ERROR:case On.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case On.FRAG_PARSING_ERROR:if(null!=(n=e.frag)&&n.gap)return void(e.errorAction={action:0,flags:0});case On.FRAG_GAP:case On.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=2);case On.LEVEL_EMPTY_ERROR:case On.LEVEL_PARSING_ERROR:{var s,a;const t=e.parent===Ei?e.level:i.loadLevel;e.details===On.LEVEL_EMPTY_ERROR&&null!=(s=e.context)&&null!=(a=s.levelDetails)&&a.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case On.LEVEL_LOAD_ERROR:case On.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==o?void 0:o.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.level)));case On.AUDIO_TRACK_LOAD_ERROR:case On.AUDIO_TRACK_LOAD_TIMEOUT:case On.SUBTITLE_LOAD_ERROR:case On.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){const t=i.levels[i.loadLevel];if(t&&(o.type===Ci&&o.groupId===t.audioGroupId||o.type===bi&&o.groupId===t.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=2,void(e.errorAction.flags=1)}return;case On.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=i.levels[i.loadLevel],n=null==t?void 0:t.attrs["HDCP-LEVEL"];n&&(e.errorAction={action:2,flags:2,hdcpLevel:n})}return;case On.BUFFER_ADD_CODEC_ERROR:case On.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(r=e.level)?r:i.loadLevel));case On.INTERNAL_EXCEPTION:case On.BUFFER_APPENDING_ERROR:case On.BUFFER_APPEND_ERROR:case On.BUFFER_FULL_ERROR:case On.LEVEL_SWITCH_ERROR:case On.BUFFER_STALLED_ERROR:case On.BUFFER_SEEK_OVER_HOLE:case On.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:0,flags:0})}if(e.type===Mn.KEY_SYSTEM_ERROR){const t=this.getVariantLevelIndex(e.frag);return e.levelRetry=!1,void(e.errorAction=this.getLevelSwitchAction(e,t))}}getPlaylistRetryOrSwitchAction(t,e){var n;const r=$i(this.hls.config.playlistLoadPolicy,t),i=this.playlistError++,o=null==(n=t.response)?void 0:n.code;if(Ji(r,i,zi(t),o))return{action:5,flags:0,retryConfig:r,retryCount:i};const s=this.getLevelSwitchAction(t,e);return r&&(s.retryConfig=r,s.retryCount=i),s}getFragRetryOrSwitchAction(t){const e=this.hls,n=this.getVariantLevelIndex(t.frag),r=e.levels[n],{fragLoadPolicy:i,keyLoadPolicy:o}=e.config,s=$i(t.details.startsWith("key")?o:i,t),a=e.levels.reduce(((t,e)=>t+e.fragmentError),0);if(r){var l;t.details!==On.FRAG_GAP&&r.fragmentError++;const e=null==(l=t.response)?void 0:l.code;if(Ji(s,a,zi(t),e))return{action:5,flags:0,retryConfig:s,retryCount:a}}const c=this.getLevelSwitchAction(t,n);return s&&(c.retryConfig=s,c.retryCount=a),c}getLevelSwitchAction(t,e){const n=this.hls;null==e&&(e=n.loadLevel);const r=this.hls.levels[e];if(r&&(r.loadError++,n.autoLevelEnabled)){var i,o;let e=-1;const{levels:s,loadLevel:a,minAutoLevel:l,maxAutoLevel:c}=n,u=null==(i=t.frag)?void 0:i.type,{type:A,groupId:d}=null!=(o=t.context)?o:{};for(let n=s.length;n--;){const i=(n+a)%s.length;if(i!==a&&i>=l&&i<=c&&0===s[i].loadError){const n=s[i];if(t.details===On.FRAG_GAP&&t.frag){const e=s[i].details;if(e){const n=to(t.frag,e.fragments,t.frag.start);if(null!=n&&n.gap)continue}}else{if(A===Ci&&d===n.audioGroupId||A===bi&&d===n.textGroupId)continue;if(u===wi&&r.audioGroupId===n.audioGroupId||u===Ti&&r.textGroupId===n.textGroupId)continue}e=i;break}}if(e>-1&&n.loadLevel!==e)return t.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:e}}return{action:2,flags:1}}onErrorOut(t,e){var n;switch(null==(n=e.errorAction)?void 0:n.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===On.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){const e=this.hls,n=t.errorAction;if(!n)return;const{flags:r,hdcpLevel:i,nextAutoLevel:o}=n;switch(r){case 0:this.switchLevel(t,o);break;case 1:n.resolved||(n.resolved=this.redundantFailover(t));break;case 2:i&&(e.maxHdcpLevel=Ui[Ui.indexOf(i)-1],n.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}n.resolved||this.switchLevel(t,o)}switchLevel(t,e){void 0!==e&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:n}=this,r=t.parent===Ei?t.level:e.loadLevel,i=e.levels[r],o=i.url.length,s=t.frag?t.frag.urlId:i.urlId;i.urlId!==s||t.frag&&!i.details||this.penalizeRendition(i,t);for(let a=1;a{t.urlId=l})),e.nextLoadLevel=r,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:n}=this,r=n[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};r.lastErrorPerfMs=performance.now(),r.errors.push(e),r.details=t.details,n[t.urlId]=r}},fpsController:class{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Pn.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const n=this.hls.config;if(n.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=t,t&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),n.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,n){const r=performance.now();if(e){if(this.lastTime){const t=r-this.lastTime,i=n-this.lastDroppedFrames,o=e-this.lastDecodedFrames,s=1e3*i/t,a=this.hls;if(a.trigger(Pn.FPS_DROP,{currentDropped:i,currentDecoded:o,totalDroppedFrames:n}),s>0&&i>a.config.fpsDroppedMonitoringThreshold*o){let t=a.currentLevel;Un.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===a.autoLevelCapping||a.autoLevelCapping>=t)&&(t-=1,a.trigger(Pn.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:a.currentLevel}),a.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=n,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ur,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:ml,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Ko{constructor(t,e,n){super(t,e,n,"[subtitle-stream-controller]",Ti),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Pn.ERROR,this.onError,this),t.on(Pn.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Pn.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Pn.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Pn.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Pn.ERROR,this.onError,this),t.off(Pn.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(Pn.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Pn.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(Pn.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Pn.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Oo,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:n,success:r}=e;if(this.fragPrevious=n,this.state=Oo,!r)return;const i=this.tracksBuffered[this.currentTrackId];if(!i)return;let o;const s=n.start;for(let t=0;t=i[t].start&&s<=i[t].end){o=i[t];break}const a=n.start+n.duration;o?o.end=a:(o={start:s,end:a},i.push(o)),this.fragmentTracker.fragBuffered(n)}onBufferFlushing(t,e){const{startOffset:n,endOffset:r}=e;if(0===n&&r!==Number.POSITIVE_INFINITY){const t=r-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach((e=>{for(let n=0;nnew Gi(t))):(this.tracksBuffered=[],this.levels=e.map((t=>{const e=new Gi(t);return this.tracksBuffered[e.id]=[],e})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Ti),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||-1===this.currentTrackId)return void this.clearInterval();const n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.setInterval(500)}onSubtitleTrackLoaded(t,e){var n;const{details:r,id:i}=e,{currentTrackId:o,levels:s}=this;if(!s.length)return;const a=s[o];if(i>=s.length||i!==o||!a)return;this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(r.live||null!=(n=a.details)&&n.live){const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;const e=t.fragments[0];a.details?(l=this.alignPlaylists(r,a.details),0===l&&e&&(l=e.start,Hi(r,l))):r.hasProgramDateTime&&t.hasProgramDateTime?(Io(r,t),l=r.fragments[0].start):e&&(l=e.start,Hi(r,l))}a.details=r,this.levelLastLoaded=i,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(a.details,l),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===Oo&&(to(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:n}=t,r=e.decryptdata,i=this.hls;if(!this.fragContextChanged(e)&&n&&n.byteLength>0&&r&&r.key&&r.iv&&"AES-128"===r.method){const t=performance.now();this.decrypter.decrypt(new Uint8Array(n),r.key.buffer,r.iv.buffer).catch((t=>{throw i.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((n=>{const r=performance.now();i.trigger(Pn.FRAG_DECRYPTED,{frag:e,payload:n,stats:{tstart:t,tdecrypt:r}})})).catch((t=>{this.warn(`${t.name}: ${t.message}`),this.state=Oo}))}}doTick(){if(this.media){if(this.state===Oo){const{currentTrackId:t,levels:e}=this,n=e[t];if(!e.length||!n||!n.details)return;const{config:r}=this,i=this.getLoadPosition(),o=To.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),{end:s,len:a}=o,l=this.getFwdBufferInfo(this.media,Ei),c=n.details;if(a>this.getMaxBufferLength(null==l?void 0:l.len)+c.levelTargetDuration)return;const u=c.fragments,A=u.length,d=c.edge;let h=null;const f=this.fragPrevious;if(sd-t?0:t;h=to(f,u,Math.max(u[0].start,s),e),!h&&f&&f.startthis.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.on(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Pn.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Pn.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.off(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Pn.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Pn.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),oa(this.media.textTracks).forEach((t=>{Ri(t)})),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:n,details:r}=e,{trackId:i}=this,o=this.tracksInGroup[i];if(!o)return void this.warn(`Invalid subtitle track id ${n}`);const s=o.details;o.details=e.details,this.log(`subtitle track ${n} loaded [${r.startSN}-${r.endSN}]`),n===this.trackId&&this.playlistLoaded(n,e,s)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null==e||!e.textGroupIds)return;const n=e.textGroupIds[e.urlId],r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==n){const t=this.tracks.filter((t=>!n||t.groupId===n));this.tracksInGroup=t;const e=this.findTrackId(null==r?void 0:r.name)||this.findTrackId();this.groupId=n||null;const i={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${n}" group-id`),this.hls.trigger(Pn.SUBTITLE_TRACKS_UPDATED,i),-1!==e&&this.setSubtitleTrack(e,r)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId,r)}findTrackId(t){const e=this.tracksInGroup;for(let n=0;nt.groupId===this.groupId));if(-1===t)[].slice.call(r).forEach((t=>{t.mode="disabled"}));else{const t=i[n];t&&(t.mode="disabled")}const o=i[t];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var n;const r=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=t);if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(-1===t||null!=(n=r[t])&&n.details)||t<-1||t>=r.length)return;this.clearTimer();const i=r[t];if(this.log(`Switching to subtitle-track ${t}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:"")),this.trackId=t,i){const{id:t,groupId:n="",name:r,type:o,url:s}=i;this.hls.trigger(Pn.SUBTITLE_TRACK_SWITCH,{id:t,groupId:n,name:r,type:o,url:s});const a=this.switchParams(i.url,null==e?void 0:e.details);this.loadPlaylist(a)}else this.hls.trigger(Pn.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=oa(this.media.textTracks);for(let n=0;n=0&&(r[0]=Math.min(r[0],e),r[1]=Math.max(r[1],n),o=!0,u/(n-e)>.5))return}var s,a,l,c;if(o||i.push([e,n]),this.config.renderTextTracksNatively){const i=this.captionsTracks[t];this.Cues.newCue(i,e,n,r)}else{const i=this.Cues.newCue(null,e,n,r);this.hls.trigger(Pn.CUES_PARSED,{type:"captions",cues:i,track:t})}}onInitPtsFound(t,{frag:e,id:n,initPTS:r,timescale:i}){const{unparsedVttFrags:o}=this;"main"===n&&(this.initPTS[e.cc]={baseTime:r,timescale:i}),o.length&&(this.unparsedVttFrags=[],o.forEach((t=>{this.onFragLoaded(Pn.FRAG_LOADED,t)})))}getExistingTrack(t){const{media:e}=this;if(e)for(let n=0;n{Ri(t[e]),delete t[e]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let t=0;tt.textCodec===Ya));if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(na(this.tracks,n))return void(this.tracks=n);if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){const t=this.media?this.media.textTracks:null;this.tracks.forEach(((e,n)=>{let r;if(t&&n({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t})));this.hls.trigger(Pn.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),n=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&n)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((t=>{const e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!e)return;const n=`textTrack${e[1]}`,r=this.captionsProperties[n];r&&(r.label=t.name,t.lang&&(r.languageCode=t.lang),r.media=t)}))}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:n,cea608Parser2:r,lastSn:i,lastPartIndex:o}=this;if(this.enabled&&n&&r&&e.frag.type===Ei){var s,a;const t=e.frag.sn,l=null!=(s=null==e||null==(a=e.part)?void 0:a.index)?s:-1;t===i+1||t===i&&l===o+1||(n.reset(),r.reset()),this.lastSn=t,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:n,payload:r}=e;if(n.type===Ti)if(r.byteLength){const t=n.decryptdata,i="stats"in e;if(null==t||!t.encrypted||i){const t=this.tracks[n.level],i=this.vttCCs;i[n.cc]||(i[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),t&&t.textCodec===Ya?this._parseIMSC1(n,r):this._parseVTTs(e)}}else this.hls.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const n=this.hls;Va(e,this.initPTS[t.cc],(e=>{this._appendCues(e,t.level),n.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(e=>{Un.log(`Failed to parse IMSC1: ${e}`),n.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))}_parseVTTs(t){var e;const{frag:n,payload:r}=t,{initPTS:i,unparsedVttFrags:o}=this,s=i.length-1;if(!i[n.cc]&&-1===s)return void o.push(t);const a=this.hls;!function(t,e,n,r,i,o,s){const a=new Na,l=Sr(new Uint8Array(t)).trim().replace(Ua,"\n").split("\n"),c=[],u=e?function(t,e=1){return Is(t,9e4,1/e)}(e.baseTime,e.timescale):0;let A,d="00:00.000",h=0,f=0,p=!0;a.oncue=function(t){const o=n[r];let s=n.ccOffset;const a=(h-u)/9e4;if(null!=o&&o.new&&(void 0!==f?s=n.ccOffset=o.start:function(t,e,n){let r=t[e],i=t[r.prevCC];if(!i||!i.new&&r.new)return t.ccOffset=t.presentationOffset=r.start,void(r.new=!1);for(;null!=(o=i)&&o.new;){var o;t.ccOffset+=r.start-i.start,r.new=!1,r=i,i=t[r.prevCC]}t.presentationOffset=n}(n,r,a)),a){if(!e)return void(A=new Error("Missing initPTS for VTT MPEGTS"));s=a-n.presentationOffset}const l=t.endTime-t.startTime,d=Os(9e4*(t.startTime+s-f),9e4*i)/9e4;t.startTime=Math.max(d,0),t.endTime=Math.max(d+l,0);const p=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(p)),t.id||(t.id=Wa(t.startTime,t.endTime,p)),t.endTime>0&&c.push(t)},a.onparsingerror=function(t){A=t},a.onflush=function(){A?s(A):o(c)},l.forEach((t=>{if(p){if(Qa(t,"X-TIMESTAMP-MAP=")){p=!1,t.slice(16).split(",").forEach((t=>{Qa(t,"LOCAL:")?d=t.slice(6):Qa(t,"MPEGTS:")&&(h=parseInt(t.slice(7)))}));try{f=function(t){let e=parseInt(t.slice(-3));const n=parseInt(t.slice(-6,-4)),r=parseInt(t.slice(-9,-7)),i=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(Bn(e)&&Bn(n)&&Bn(r)&&Bn(i)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return e+=1e3*n,e+=6e4*r,e+=36e5*i,e}(d)/1e3}catch(t){A=t}return}""===t&&(p=!1)}a.parse(t+"\n")})),a.flush()}(null!=(e=n.initSegment)&&e.data?Wr(n.initSegment.data,new Uint8Array(r)):r,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,(t=>{this._appendCues(t,n.level),a.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})}),(e=>{const i="Missing initPTS for VTT MPEGTS"===e.message;i?o.push(t):this._fallbackToIMSC1(n,r),Un.log(`Failed to parse VTT cue: ${e}`),i&&s>n.cc||a.trigger(Pn.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:e})}))}_fallbackToIMSC1(t,e){const n=this.tracks[t.level];n.textCodec||Va(e,this.initPTS[t.cc],(()=>{n.textCodec=Ya,this._parseIMSC1(t,e)}),(()=>{n.textCodec="wvtt"}))}_appendCues(t,e){const n=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||"disabled"===n.mode)return;t.forEach((t=>Ii(n,t)))}else{const r=this.tracks[e];if(!r)return;const i=r.default?"default":"subtitles"+e;n.trigger(Pn.CUES_PARSED,{type:"subtitles",cues:t,track:i})}}onFragDecrypted(t,e){const{frag:n}=e;n.type===Ti&&this.onFragLoaded(Pn.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:n,cea608Parser2:r}=this;if(!this.enabled||!n||!r)return;const{frag:i,samples:o}=e;if(i.type!==Ei||"NONE"!==this.closedCaptionsForLevel(i))for(let t=0;tDi(t[r],e,n)))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==r){const{textTracks:t}=this;Object.keys(t).forEach((n=>Di(t[n],e,r)))}}}extractCea608Data(t){const e=[[],[]],n=31&t[0];let r=2;for(let i=0;i0&&-1===t?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Oo):(this.loadedmetadata=!1,this.state=Uo),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Oo:this.doTickIdle();break;case Uo:{var t;const{levels:e,trackId:n}=this,r=null==e||null==(t=e[n])?void 0:t.details;if(r){if(this.waitForCdnTuneIn(r))break;this.state=jo}break}case No:{var e;const t=performance.now(),n=this.retryDate;(!n||t>=n||null!=(e=this.media)&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Oo);break}case jo:{const t=this.waitingData;if(t){const{frag:e,part:n,cache:r,complete:i}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=_o;const t={frag:e,part:n,payload:r.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),i&&super._handleFragmentLoadComplete(t)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${e.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const t=this.getLoadPosition(),n=To.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);eo(n.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log(`Waiting fragment cc (${e.cc}) @ ${e.start} cancelled because another fragment at ${n.end} is needed`),this.clearWaitingFragment())}}else this.state=Oo}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Oo)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:n,trackId:r}=this,i=t.config;if(null==e||!e[r])return;if(!n&&(this.startFragRequested||!i.startFragPrefetch))return;const o=e[r],s=o.details;if(!s||s.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(s))return void(this.state=Uo);const a=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&a&&(this.bufferFlushed=!1,this.afterBufferFlushed(a,Kn,wi));const l=this.getFwdBufferInfo(a,wi);if(null===l)return;const{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(l,s))return t.trigger(Pn.BUFFER_EOS,{type:"audio"}),void(this.state=Wo);const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Ei),d=l.len,h=this.getMaxBufferLength(null==A?void 0:A.len);if(d>=h&&!u)return;const f=s.fragments[0].start;let p=l.end;if(u&&n){const t=this.getLoadPosition();c&&u.attrs!==c.attrs&&(p=t),s.PTSKnown&&tf||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=f+.05)}let g=this.getNextFragment(p,s),m=!1;if(g&&this.isLoopLoading(g,p)&&(m=!!g.gap,g=this.getNextFragmentLoopLoading(g,s,l,Ei,h)),!g)return void(this.bufferFlushed=!0);const v=A&&g.start>A.end+s.targetduration;if(v||(null==A||!A.len)&&l.len){const t=this.getAppendedFrag(g.start,Ei);if(null===t)return;if(m||(m=!!t.gap||!!v&&0===A.len),v&&!m||m&&l.nextStart&&l.nextStartnew Gi(t)))}onAudioTrackSwitching(t,e){const n=!!e.url;this.trackId=e.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),n?this.setInterval(100):this.resetTransmuxer(),n?(this.switchingTrack=e,this.state=Oo):(this.switchingTrack=null,this.bufferedTrack=e,this.state=Mo),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(Pn.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var n;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=e);const{levels:r}=this,{details:i,id:o}=e;if(!r)return void this.warn(`Audio tracks were reset while loading level ${o}`);this.log(`Track ${o} loaded [${i.startSN},${i.endSN}]${i.lastPartSn?`[part-${i.lastPartSn}-${i.lastPartIndex}]`:""},duration:${i.totalduration}`);const s=r[o];let a=0;if(i.live||null!=(n=s.details)&&n.live){this.checkLiveUpdate(i);const t=this.mainDetails;if(i.deltaUpdateFailed||!t)return;!s.details&&i.hasProgramDateTime&&t.hasProgramDateTime?(Io(i,t),a=i.fragments[0].start):a=this.alignPlaylists(i,s.details)}s.details=i,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(s.details,a),this.state!==Uo||this.waitForCdnTuneIn(i)||(this.state=Oo),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:n,part:r,payload:i}=t,{config:o,trackId:s,levels:a}=this;if(!a)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const l=a[s];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(n.start);const u=o.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let A=this.transmuxer;A||(A=this.transmuxer=new Xs(this.hls,wi,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const d=this.initPTS[n.cc],h=null==(e=n.initSegment)?void 0:e.data;if(void 0!==d){const t=!1,e=r?r.index:-1,o=-1!==e,s=new So(n.level,n.sn,n.stats.chunkCount,i.byteLength,e,o);A.push(i,h,u,"",n,r,c.totalduration,t,s,d)}else{this.log(`Unknown video PTS for cc ${n.cc}, waiting for video PTS before demuxing audio frag ${n.sn} of [${c.startSN} ,${c.endSN}],track ${s}`);const{cache:t}=this.waitingData=this.waitingData||{frag:n,part:r,cache:new ea,complete:!1};t.push(new Uint8Array(i)),this.waitingVideoCC=this.videoTrackCC,this.state=jo}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const n=e.tracks.audio;n&&(this.mediaBuffer=n.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:n,part:r}=e;if(n.type===wi)if(this.fragContextChanged(n))this.warn(`Fragment ${n.sn}${r?" p: "+r.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==n.sn){this.fragPrevious=n;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(Pn.AUDIO_TRACK_SWITCHED,In({},t)))}this.fragBufferedComplete(n,r)}else if(!this.loadedmetadata&&n.type===Ei){const t=this.videoBuffer||this.media;t&&To.getBuffered(t).length&&(this.loadedmetadata=!0)}}onError(t,e){var n;if(e.fatal)this.state=Yo;else switch(e.details){case On.FRAG_GAP:case On.FRAG_PARSING_ERROR:case On.FRAG_DECRYPT_ERROR:case On.FRAG_LOAD_ERROR:case On.FRAG_LOAD_TIMEOUT:case On.KEY_LOAD_ERROR:case On.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(wi,e);break;case On.AUDIO_TRACK_LOAD_ERROR:case On.AUDIO_TRACK_LOAD_TIMEOUT:case On.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Uo||(null==(n=e.context)?void 0:n.type)!==Ci||(this.state=Oo);break;case On.BUFFER_FULL_ERROR:if(!e.parent||"audio"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case On.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushed(t,{type:e}){e===Kn&&(this.bufferFlushed=!0,this.state===Wo&&(this.state=Oo))}_handleTransmuxComplete(t){var e;const n="audio",{hls:r}=this,{remuxResult:i,chunkMeta:o}=t,s=this.getCurrentContext(o);if(!s)return void this.resetWhenMissingContext(o);const{frag:a,part:l,level:c}=s,{details:u}=c,{audio:A,text:d,id3:h,initSegment:f}=i;if(!this.fragContextChanged(a)&&u){if(this.state=Qo,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const t=a.initSegment||a;this._bufferInitSegment(f.tracks,t,o),r.trigger(Pn.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:n,tracks:f.tracks})}if(A){const{startPTS:t,endPTS:e,startDTS:n,endDTS:r}=A;l&&(l.elementaryStreams.audio={startPTS:t,endPTS:e,startDTS:n,endDTS:r}),a.setElementaryStreamInfo(Kn,t,e,n,r),this.bufferFragmentData(A,a,l,o)}if(null!=h&&null!=(e=h.samples)&&e.length){const t=Dn({id:n,frag:a,details:u},h);r.trigger(Pn.FRAG_PARSING_METADATA,t)}if(d){const t=Dn({id:n,frag:a,details:u},d);r.trigger(Pn.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(a)}_bufferInitSegment(t,e,n){if(this.state!==Qo)return;t.video&&delete t.video;const r=t.audio;if(!r)return;r.levelCodec=r.codec,r.id="audio",this.log(`Init audio buffer, container:${r.container}, codecs[parsed]=[${r.codec}]`),this.hls.trigger(Pn.BUFFER_CODECS,t);const i=r.initSegment;if(null!=i&&i.byteLength){const t={type:"audio",frag:e,part:null,chunkMeta:n,parent:e.type,data:i};this.hls.trigger(Pn.BUFFER_APPENDING,t)}this.tick()}loadFragment(t,e,n){const r=this.fragmentTracker.getState(t);var i;this.fragCurrent=t,this.switchingTrack||r===co||r===Ao?"initSegment"===t.sn?this._loadInitSegment(t,e):null!=(i=e.details)&&i.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=jo):(this.startFragRequested=!0,super.loadFragment(t,e,n)):this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:n,bufferedTrack:r}=this,i=null==r?void 0:r.attrs,o=t.attrs;n&&i&&(i.CHANNELS!==o.CHANNELS||i.NAME!==o.NAME||i.LANGUAGE!==o.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(Pn.AUDIO_TRACK_SWITCHED,In({},t))}},audioTrackController:class extends io{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.on(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Pn.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(Pn.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Pn.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Pn.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Pn.LEVEL_LOADING,this.onLevelLoading,this),t.off(Pn.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Pn.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(Pn.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:n,groupId:r,details:i}=e,o=this.tracksInGroup[n];if(!o||o.groupId!==r)return void this.warn(`Track with id:${n} and group:${r} not found in active group ${o.groupId}`);const s=o.details;o.details=e.details,this.log(`audio-track ${n} "${o.name}" lang:${o.lang} group:${r} loaded [${i.startSN}-${i.endSN}]`),n===this.trackId&&this.playlistLoaded(n,e,s)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null==e||!e.audioGroupIds)return;const n=e.audioGroupIds[e.urlId];if(this.groupId!==n){this.groupId=n||null;const t=this.tracks.filter((t=>!n||t.groupId===n));this.selectDefaultTrack&&!t.some((t=>t.default))&&(this.selectDefaultTrack=!1),this.tracksInGroup=t;const e={audioTracks:t};this.log(`Updating audio tracks, ${t.length} track(s) found in group:${n}`),this.hls.trigger(Pn.AUDIO_TRACKS_UPDATED,e),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){!e.fatal&&e.context&&e.context.type===Ci&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length)return void this.warn("Invalid id passed to audio-track controller");this.clearTimer();const n=this.currentTrack;e[this.trackId];const r=e[t],{groupId:i,name:o}=r;if(this.log(`Switching to audio-track ${t} "${o}" lang:${r.lang} group:${i}`),this.trackId=t,this.currentTrack=r,this.selectDefaultTrack=!1,this.hls.trigger(Pn.AUDIO_TRACK_SWITCHING,In({},r)),r.details&&!r.details.live)return;const s=this.switchParams(r.url,null==n?void 0:n.details);this.loadPlaylist(s)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==e)this.setAudioTrack(e);else{const e=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(e.message),this.hls.trigger(Pn.ERROR,{type:Mn.MEDIA_ERROR,details:On.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}findTrackId(t){const e=this.tracksInGroup;for(let n=0;ne!==t)))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:n}=e;null!==n&&(this.pathwayId=n.pathwayId,this.uri=n.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:n}=e;if(2===(null==n?void 0:n.action)&&1===n.flags){let t=this.pathwayPriority;const e=this.pathwayId;this.penalizedPathways[e]||(this.penalizedPathways[e]=performance.now()),!t&&this.levels&&(t=this.levels.reduce(((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t)),[])),t&&t.length>1&&(this.updatePathwayPriority(t),n.resolved=this.pathwayId!==e)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){const n=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${n}"`),e=this.getLevelsForPathway(n),this.pathwayId=n}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter((e=>t===e.pathwayId))}updatePathwayPriority(t){let e;this.pathwayPriority=t;const n=this.penalizedPathways,r=performance.now();Object.keys(n).forEach((t=>{r-n[t]>3e5&&delete n[t]}));for(let r=0;r0){this.log(`Setting Pathway to "${i}"`),this.pathwayId=i,this.hls.trigger(Pn.LEVELS_UPDATED,{levels:e});const t=this.hls.levels[o];s&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${t.bitrate}`),this.hls.nextLoadLevel=o);break}}}clonePathways(t){const e=this.levels;if(!e)return;const n={},r={};t.forEach((t=>{const{ID:i,"BASE-ID":o,"URI-REPLACEMENT":s}=t;if(e.some((t=>t.pathwayId===i)))return;const a=this.getLevelsForPathway(o).map((t=>{const e=Dn({},t);e.details=void 0,e.url=cl(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s);const o=new Wn(t.attrs);o["PATHWAY-ID"]=i;const a=o.AUDIO&&`${o.AUDIO}_clone_${i}`,l=o.SUBTITLES&&`${o.SUBTITLES}_clone_${i}`;a&&(n[o.AUDIO]=a,o.AUDIO=a),l&&(r[o.SUBTITLES]=l,o.SUBTITLES=l),e.attrs=o;const c=new Gi(e);return ao(c,"audio",a),ao(c,"text",l),c}));e.push(...a),ll(this.audioTracks,n,s,i),ll(this.subtitleTracks,r,s,i)}))}loadSteeringManifest(t){const e=this.hls.config,n=e.loader;let r;this.loader&&this.loader.destroy(),this.loader=new n(e);try{r=new self.URL(t)}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${t}`)}if("data:"!==r.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+t)}const i={responseType:"json",url:r.href},o=e.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},a={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(t,e,n,i)=>{this.log(`Loaded steering manifest: "${r}"`);const o=t.data;if(1!==o.VERSION)return void this.log(`Steering VERSION ${o.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=o.TTL;const{"RELOAD-URI":s,"PATHWAY-CLONES":a,"PATHWAY-PRIORITY":l}=o;if(s)try{this.uri=new self.URL(s,r).href}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${s}`)}this.scheduleRefresh(this.uri||n.url),a&&this.clonePathways(a),l&&this.updatePathwayPriority(l)},onError:(t,e,n,r)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${e.url})`),this.stopLoad(),410===t.code)return this.enabled=!1,void this.log(`Steering manifest ${e.url} no longer available`);let i=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,i);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(i=1e3*parseFloat(e))}this.log(`Steering manifest ${e.url} rate limited`)}},onTimeout:(t,e,n)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(i,a,l)}scheduleRefresh(t,e=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((()=>{this.loadSteeringManifest(t)}),e)}}});function yl(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(yl):Object.keys(t).reduce(((e,n)=>(e[n]=yl(t[n]),e)),{}):t}class Cl{static get version(){return"1.4.12"}static isSupported(){return function(){const t=ei();if(!t)return!1;const e=Vo(),n=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),r=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!n&&!!r}()}static get Events(){return Pn}static get ErrorTypes(){return Mn}static get ErrorDetails(){return On}static get DefaultConfig(){return Cl.defaultConfig?Cl.defaultConfig:vl}static set DefaultConfig(t){Cl.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new zs,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,function(t,e){if(self.console&&!0===t||"object"==typeof t){!function(t,...e){e.forEach((function(e){Nn[e]=t[e]?t[e].bind(t):function(t){const e=self.console[t];return e?e.bind(self.console,`[${t}] >`):Fn}(e)}))}(t,"debug","log","info","warn","error");try{Nn.log('Debug logs enabled for "Hls instance" in hls.js version 1.4.12')}catch(t){Nn=_n}}else Nn=_n}(t.debug||!1);const e=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const n=yl(t),r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((t=>{const i=`${"level"===t?"playlist":t}LoadPolicy`,o=void 0===e[i],s=[];r.forEach((r=>{const a=`${t}Loading${r}`,l=e[a];if(void 0!==l&&o){s.push(a);const t=n[i].default;switch(e[i]={default:t},r){case"TimeOut":t.maxLoadTimeMs=l,t.maxTimeToFirstByteMs=l;break;case"MaxRetry":t.errorRetry.maxNumRetry=l,t.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":t.errorRetry.retryDelayMs=l,t.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":t.errorRetry.maxRetryDelayMs=l,t.timeoutRetry.maxRetryDelayMs=l}}})),s.length&&Un.warn(`hls.js config: "${s.join('", "')}" setting(s) are deprecated, use "${i}": ${JSON.stringify(e[i])}`)})),In(In({},n),e)}(Cl.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&function(t){const e=t.loader;e!==hl&&e!==Al?(Un.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=hl,t.progressive=!0,t.enableSoftwareAES=!0,Un.log("[config]: Progressive streaming enabled, using FetchLoader"))}(e);const{abrController:n,bufferController:r,capLevelController:i,errorController:o,fpsController:s}=e,a=new o(this),l=this.abrController=new n(this),c=this.bufferController=new r(this),u=this.capLevelController=new i(this),A=new s(this),d=new Li(this),h=new _i(this),f=e.contentSteeringController,p=f?new f(this):null,g=this.levelController=new so(this,p),m=new fo(this),v=new Eo(this.config),y=this.streamController=new Js(this,m,v);u.setStreamController(y),A.setStreamController(y);const C=[d,g,y];p&&C.splice(1,0,p),this.networkControllers=C;const b=[l,c,u,A,h,m];this.audioTrackController=this.createController(e.audioTrackController,C);const E=e.audioStreamController;E&&C.push(new E(this,m,v)),this.subtitleTrackController=this.createController(e.subtitleTrackController,C);const w=e.subtitleStreamController;w&&C.push(new w(this,m,v)),this.createController(e.timelineController,b),v.emeController=this.emeController=this.createController(e.emeController,b),this.cmcdController=this.createController(e.cmcdController,b),this.latencyController=this.createController(Ni,b),this.coreComponents=b,C.push(a);const T=a.onErrorOut;"function"==typeof T&&this.on(Pn.ERROR,T,a)}createController(t,e){if(t){const n=new t(this);return e&&e.push(n),n}return null}on(t,e,n=this){this._emitter.on(t,e,n)}once(t,e,n=this){this._emitter.once(t,e,n)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,n=this,r){this._emitter.off(t,e,n,r)}listeners(t){return this._emitter.listeners(t)}emit(t,e,n){return this._emitter.emit(t,e,n)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){Un.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(Pn.ERROR,{type:Mn.OTHER_ERROR,details:On.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){Un.log("destroy"),this.trigger(Pn.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((t=>t.destroy())),this.networkControllers.length=0,this.coreComponents.forEach((t=>t.destroy())),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){Un.log("attachMedia"),this._media=t,this.trigger(Pn.MEDIA_ATTACHING,{media:t})}detachMedia(){Un.log("detachMedia"),this.trigger(Pn.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,n=this.url,r=this.url=Ln.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});Un.log(`loadSource:${r}`),e&&n&&(n!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(Pn.MANIFEST_LOADING,{url:t})}startLoad(t=-1){Un.log(`startLoad(${t})`),this.networkControllers.forEach((e=>{e.startLoad(t)}))}stopLoad(){Un.log("stopLoad"),this.networkControllers.forEach((t=>{t.stopLoad()}))}swapAudioCodec(){Un.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Un.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){Un.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){Un.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){Un.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){Un.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){Un.log(`set startLevel:${t}`),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(Un.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Ui.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const n=t.length;for(let r=0;r=e)return r;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:n}=this;let r;if(r=-1===e&&t&&t.length?t.length-1:e,n)for(let e=r;e--;){const r=t[e].attrs["HDCP-LEVEL"];if(r&&r<=n)return e}return r}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Cl.defaultConfig=void 0;var bl,El,wl=function(t,e,n){var r={},i=null,o=null,s=null,a=null,l=!1;try{var c={debug:!1},u=e.getConfig().hlsConfig;if(u)for(var A in u)c[A]=u[A];i=new Cl(c),window.op_hls=i,i.attachMedia(t);var d={name:dt,element:t,mse:i,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:q,buffer:0,dvrWindow:0,framerate:0,currentQuality:-1,qualityLevels:[],currentAudioTrack:-1,audioTracks:[],currentSource:-1,sources:[],adTagUrl:n};r=yn(d,e,(function(t,e){OvenPlayerConsole.log("HLS : onExtendedLoad : ",t,"lastPlayPosition : "+e),r.trigger("hlsPrepared",i),i.loadSource(t.file),i.once(Cl.Events.MANIFEST_LOADED,(function(t,e){for(var n=0;n=0&&r.seek(e)})),i.on(Cl.Events.LEVEL_SWITCHED,(function(t,e){d.currentQuality=e.level,r.trigger(Mt,{isAuto:i.autoLevelEnabled,currentQuality:d.currentQuality,type:"render"})})),i.on(Cl.Events.AUDIO_TRACK_SWITCHED,(function(t,e){d.currentAudioTrack=e.id,r.trigger(Ut,{currentAudioTrack:d.currentAudioTrack})})),i.on(Cl.Events.LEVEL_UPDATED,(function(t,e){e&&e.details&&(d.dvrWindow=e.details.totalduration)})),i.on(Cl.Events.ERROR,(function(e,n){if(n&&n.networkDetails&&202===n.networkDetails.status)return a&&(clearTimeout(a),a=null),r.setState(nt),void(a=setTimeout((function(){i&&(r.stop(),i.stopLoad(),i.loadSource(t.file))}),1e3));if(n.fatal){var o=302;n&&n.networkDetails&&400===n.networkDetails.status?o=306:n&&n.networkDetails&&403===n.networkDetails.status?o=307:n&&n.networkDetails&&406===n.networkDetails.status&&(o=308);var s=Qt.codes[o];s.error=n.details,Jt(s,r)}})),r.on(yt,(function(t){l||t.prevstate!==nt||t.newstate!==q||(a&&(clearTimeout(a),a=null),i&&i.stopLoad())}))})),r.setCurrentQuality=function(t){return i.currentLevel=t,d.currentQuality=t,d.currentQuality},r.isAutoQuality=function(){return i.autoLevelEnabled},r.setAutoQuality=function(t){i.currentLevel=t?-1:i.currentLevel},r.setCurrentAudioTrack=function(t){return i.audioTrack=t,d.currentAudioTrack=t,d.currentAudioTrack},r.getDuration=function(){return t.duration},o=r.super("stop"),r.stop=function(){a&&(clearTimeout(a),a=null),i&&i.stopLoad(),o()},s=r.super("destroy"),r.destroy=function(){a&&(clearTimeout(a),a=null),i&&(i.destroy(),r.trigger("hlsDestroyed")),i=null,OvenPlayerConsole.log("HLS : PROVIDER DESTROYED."),s()},OvenPlayerConsole.log("HLS PROVIDER LOADED.")}catch(t){var h=Qt.codes[106];throw h.error=t,h}return r},Tl=function(t){var e={};Yt(e),OvenPlayerConsole.log("API loaded.");var n=function(t){var e={},n={playlist:[],currentIndex:0},r=Xt();OvenPlayerConsole.log("PlaylistManager loaded.");var i=function(t){if(t&&(t.file||t.host||t.application||t.stream)){var e=Object.assign({},{default:!1},t);e.file=s(""+e.file),e.host&&e.application&&e.stream&&(e.file=e.host+"/"+e.application+"/stream/"+e.stream,delete e.host,delete e.application,delete e.stream);var n=/^[^/]+\/(?:x-)?([^/]+)$/;if(n.test(e.type)&&(e.mimeType=e.type,e.type=e.type.replace(n,"$1")),Ht(e.file)?e.type="rtmp":Kt(e.file)?e.type="webrtc":Vt(e.file,e.type)?e.type="hls":zt(e.file,e.type)?e.type="dash":e.type||(e.type=a(e.file)),e.lowLatency&&(e.lowLatency=e.lowLatency),e.type){switch(e.type){case"m3u8":case"vnd.apple.mpegurl":e.type="hls";break;case"m4a":e.type="aac";break;case"smil":e.type="rtmp"}return Object.keys(e).forEach((function(t){""===e[t]&&delete e[t]})),e}}};return e.initPlaylist=function(t,e){OvenPlayerConsole.log("PlaylistManager setPlaylist() ",t);var s=(o().isArray(t)?t:[t]).map((function(t){o().isArray(t.tracks)||delete t.tracks;var n=Object.assign({},{sources:[],tracks:[],title:""},t);n.sources!==Object(n.sources)||o().isArray(n.sources)||(n.sources=[i(n.sources)]),o().isArray(n.sources)&&0!==n.sources.length||(n.sources=[i(n)]),o().isArray(n.sources)&&0!==n.sources.length||(t.levels?n.sources=t.levels:n.sources=[i(t)]);for(var s=0;s0}))||[];return n.playlist=s,s},e.getPlaylist=function(){return OvenPlayerConsole.log("PlaylistManager getPlaylist() ",n.playlist),n.playlist},e.getCurrentPlayList=function(){return n.playlist[n.currentIndex]?n.playlist[n.currentIndex]:[]},e.getCurrentPlaylistIndex=function(){return n.currentIndex},e.setCurrentPlaylist=function(e){return n.playlist[e]&&(OvenPlayerConsole(e),n.currentIndex=e,t.trigger(pt,n.currentIndex)),n.currentIndex},e.getCurrentSources=function(){return n.playlist[n.currentIndex]?(OvenPlayerConsole.log("PlaylistManager getCurrentSources() ",n.playlist[n.currentIndex].sources),n.playlist[n.currentIndex].sources):null},e.getCurrentAdTag=function(){if(n.playlist[n.currentIndex])return n.playlist[n.currentIndex].adTagUrl||""},e}(e),i=function(){var t=Xt(),e={},n={};OvenPlayerConsole.log("ProviderController loaded.");var r=function(t,n){e[t]||(OvenPlayerConsole.log("ProviderController _registerProvider() ",t),e[t]=n)},i={html5:function(){var t=Cn;return r(ct,t),{name:ct,provider:t}},webrtc:function(){var t=En;return r(ut,t),{name:ut,provider:t}},dash:function(){var t=Tn;return r(At,t),{name:At,provider:t}},hls:function(){var t=wl;return r(dt,t),{name:dt,provider:t}}};return n.loadProviders=function(e){var n=t.findProviderNamesByPlaylist(e);return OvenPlayerConsole.log("ProviderController loadProviders() ",n),n?Promise.all(n.filter((function(t){return!!i[t]})).map((function(t){return i[t]()}))):Promise.reject(Qt.codes[101])},n.findByName=function(t){return OvenPlayerConsole.log("ProviderController findByName() ",t),e[t]},n.getProviderBySource=function(e){var r=t.findProviderNameBySource(e);return OvenPlayerConsole.log("ProviderController getProviderBySource() ",r),n.findByName(r)},n.isSameProvider=function(e,n){return OvenPlayerConsole.log("ProviderController isSameProvider() ",t.findProviderNameBySource(e),t.findProviderNameBySource(n)),t.findProviderNameBySource(e)===t.findProviderNameBySource(n)},n}(),l=W(),c=function(t,e){var n={},r=jt(t),i="";return OvenPlayerConsole.log("MediaManager loaded. browser : ",e),n.createMedia=function(t,e){return n.empty(),o=e.isLoop(),s=e.isAutoStart(),(i=document.createElement("video")).setAttribute("preload","auto"),i.setAttribute("disableremoteplayback",""),i.setAttribute("webkit-playsinline","true"),i.setAttribute("playsinline","true"),o&&i.setAttribute("loop",""),s&&i.setAttribute("autoplay",""),r.append(i),i;var o,s},n.createAdContainer=function(){var t=document.createElement("div");return t.setAttribute("class","op-ads"),r.append(t),t},n.empty=function(){OvenPlayerConsole.log("MediaManager removeElement()"),r.removeChild(i),i=null},n.destroy=function(){r.removeChild(),r=null,i.srcObject=null,i=null},n}(t,l),u="",A="",d="",h=function(t){OvenPlayerConsole.log("runNextPlaylist");var r=t,i=!!n.getPlaylist()[r];A.setSourceIndex(0),A.setVolume(u.getVolume()),i?(n.setCurrentPlaylist(r),f()):e.trigger(gt,null)},f=function(t){return i.loadProviders(n.getCurrentPlayList()).then((function(t){if(t.length<1)throw Qt.codes[101];u&&(u.destroy(),u=null),d&&(d.destroy(),d=null),d=function(t,e){var n={},r=[],i=-1,s=X(),a=!0;OvenPlayerConsole.log("Caption Manager >> ",e);var l=function(t,e){return t.data=e||[],t.name=t.label||t.name||t.language,t.id=function(t,e){var n,i=t.kind||"cc";return n=t.default||t.defaulttrack?"default":t.id||i+e,a&&(c(r.length||0),a=!1),n}(t,r.length),r.push(t),t.id},c=function(e){i=e,t.trigger(Ft,i)};if(t.getConfig().playlist&&t.getConfig().playlist.length>0){var u=t.getConfig().playlist[e];if(u&&u.tracks&&u.tracks.length>0)for(var A=function(e){var n=u.tracks[e];Wt(n.kind)&&!o().findWhere(n,{file:n.file})&&s.load(n,n.lang,(function(t){t&&t.length>0&&l(n,t)}),(function(e){var n=Qt.codes[305];n.error=e,t.trigger(vt,n)}))},d=0;d-1&&r[i]){var s=o().filter(r[i].data,(function(t){return n>=t.startTime&&(!t.endTime||n)<=t.endTime}));s&&s.length>0&&t.trigger(Ot,s[0])}})),n.flushCaptionList=function(t){r=[],c(t)},n.getCaptionList=function(){return r||[]},n.getCurrentCaption=function(){return i},n.setCurrentCaption=function(t){if(!(t>-2&&t0&&l(e,t)}),(function(e){var n=errors[305];n.error=e,t.trigger(vt,n)}))},n.removeCaption=function(t){return t>-1&&t=.25&&t<=4})).map((function(t){return Math.round(4*t)/4}))).indexOf(1)<0&&s.push(1),s.sort(),e.playbackRates=s,e.rtmpBufferTime=e.rtmpBufferTime>10?10:e.rtmpBufferTime,e.rtmpBufferTimeMax=e.rtmpBufferTimeMax>50?50:e.rtmpBufferTimeMax,e.playbackRates.indexOf(e.playbackRate)<0&&(e.playbackRate=1);var a=e.playlist;if(a)o().isArray(a.playlist)&&(e.feedData=a,e.playlist=a.playlist);else{var l=o().pick(e,["title","description","type","image","file","sources","tracks","host","application","stream","adTagUrl"]);e.playlist=[l]}return delete e.duration,e}(t);return{getConfig:function(){return n},getAdClient:function(){return n.adClient},setConfig:function(t,e){n[t]=e},getContainer:function(){return n.mediaContainer},getPlaybackRate:function(){return n.playbackRate},setPlaybackRate:function(t){return n.playbackRate=t,t},getQualityLabel:function(){return n.qualityLabel},setQualityLabel:function(t){n.qualityLabel=t},isCurrentProtocolOnly:function(){return n.currentProtocolOnly},getSourceIndex:function(){return n.sourceIndex},setSourceIndex:function(t){n.sourceIndex=t},setTimecodeMode:function(t){n.timecode!==t&&(n.timecode=t,e.trigger(_t,t))},isTimecodeMode:function(){return n.timecode},getRtmpBufferTime:function(){return n.rtmpBufferTime},getRtmpBufferTimeMax:function(){return n.rtmpBufferTimeMax},setMute:function(t){n.mute=t},isMute:function(){return n.mute},getVolume:function(){return n.volume},setVolume:function(t){n.volume=t},isLoop:function(){return n.loop},isAutoStart:function(){return n.autoStart},isControls:function(){return n.controls},getPlaybackRates:function(){return n.playbackRates},getBrowser:function(){return n.browser},getSystemText:function(){return n.systemText},getLanguage:function(){return n.lang},getPlaylist:function(){return n.playlist},setPlaylist:function(t){return o().isArray(t)?n.playlist=t:n.playlist=[t],n.playlist}}}(r,e),OvenPlayerConsole.log("API : init()"),OvenPlayerConsole.log("API : init() config : ",A),Qt.codes=A.getSystemText().api.error,n.initPlaylist(A.getPlaylist(),A),OvenPlayerConsole.log("API : init() sources : ",n.getCurrentSources()),f(),setTimeout((function(){e.trigger(ht)}))},e.getProviderName=function(){return u?u.getName():null},e.getProvider=function(){return u},e.getMseInstance=function(){return u?u.getMse():null},e.getConfig=function(){return OvenPlayerConsole.log("API : getConfig()",A.getConfig()),A.getConfig()},e.getBrowser=function(){return A.getBrowser()},e.setTimecodeMode=function(t){OvenPlayerConsole.log("API : setTimecodeMode()",t),A.setTimecodeMode(t)},e.isTimecodeMode=function(){return OvenPlayerConsole.log("API : isTimecodeMode()"),A.isTimecodeMode()},e.getFramerate=function(){if(OvenPlayerConsole.log("API : getFramerate()"),u)return u.getFramerate()},e.seekFrame=function(t){return u?(OvenPlayerConsole.log("API : seekFrame()",t),u.seekFrame(t)):null},e.getDuration=function(){return u?(OvenPlayerConsole.log("API : getDuration()",u.getDuration()),u.getDuration()):null},e.getDvrWindow=function(){return u?(OvenPlayerConsole.log("API : getDvrWindow()",u.getDvrWindow()),u.getDvrWindow()):null},e.getPosition=function(){return u?(OvenPlayerConsole.log("API : getPosition()",u.getPosition()),u.getPosition()):null},e.getVolume=function(){return u?(OvenPlayerConsole.log("API : getVolume()",u.getVolume()),u.getVolume()):null},e.setVolume=function(t){if(!u)return null;OvenPlayerConsole.log("API : setVolume() "+t),u.setVolume(t)},e.setMute=function(t){return u?(OvenPlayerConsole.log("API : setMute() "+t),u.setMute(t)):null},e.getMute=function(){return u?(OvenPlayerConsole.log("API : getMute() "+u.getMute()),u.getMute()):null},e.load=function(t){return OvenPlayerConsole.log("API : load() ",t),t&&(A.setSourceIndex(0),u&&u.getQualityLevels().length>0&&u.setCurrentQuality(0),"sources"in t?A.setPlaylist(t):A.setPlaylist({sources:t}),n.initPlaylist(A.getPlaylist(),A)),f()},e.play=function(){if(!u)return null;OvenPlayerConsole.log("API : play() "),u.metaLoaded()||A.isAutoStart()?u.play():e.once(Bt,(function(){u.play()}))},e.pause=function(){if(!u)return null;OvenPlayerConsole.log("API : pause() "),u.pause()},e.seek=function(t){if(!u)return null;OvenPlayerConsole.log("API : seek() "+t),u.seek(t)},e.setPlaybackRate=function(t){return u?(OvenPlayerConsole.log("API : setPlaybackRate() ",t),u.setPlaybackRate(A.setPlaybackRate(t))):null},e.getPlaybackRate=function(){return u?(OvenPlayerConsole.log("API : getPlaybackRate() ",u.getPlaybackRate()),u.getPlaybackRate()):null},e.getPlaylist=function(){return OvenPlayerConsole.log("API : getPlaylist() ",n.getPlaylist()),n.getPlaylist()},e.getCurrentPlaylist=function(){return OvenPlayerConsole.log("API : getCurrentPlaylist() ",n.getCurrentPlaylistIndex()),n.getCurrentPlaylistIndex()},e.setCurrentPlaylist=function(t){OvenPlayerConsole.log("API : setCurrentPlaylist() ",t),h(t)},e.getSources=function(){return u?(OvenPlayerConsole.log("API : getSources() ",u.getSources()),u.getSources()):null},e.getCurrentSource=function(){return u?(OvenPlayerConsole.log("API : getCurrentSource() ",u.getCurrentSource()),u.getCurrentSource()):null},e.setCurrentSource=function(t){if(!u)return null;OvenPlayerConsole.log("API : setCurrentSource() ",t);var n=u.getPosition();return A.setSourceIndex(t),f(n).then((function(){e.trigger(Pt,{currentSource:t})})),t},e.getQualityLevels=function(){return u?(OvenPlayerConsole.log("API : getQualityLevels() ",u.getQualityLevels()),u.getQualityLevels()):null},e.getCurrentQuality=function(){return u?(OvenPlayerConsole.log("API : getCurrentQuality() ",u.getCurrentQuality()),u.getCurrentQuality()):null},e.setCurrentQuality=function(t){return u?(OvenPlayerConsole.log("API : setCurrentQuality() ",t),u.setCurrentQuality(t)):null},e.getAudioTracks=function(){return u?(OvenPlayerConsole.log("API : getAudioTracks() ",u.getAudioTracks()),u.getAudioTracks()):null},e.getCurrentAudioTrack=function(){return u?(OvenPlayerConsole.log("API : getCurrentAudioTrack() ",u.getCurrentAudioTrack()),u.getCurrentAudioTrack()):null},e.setCurrentAudioTrack=function(t){return u?(OvenPlayerConsole.log("API : setCurrentAudioTrack() ",t),u.setCurrentAudioTrack(t)):null},e.isAutoQuality=function(){return u?(OvenPlayerConsole.log("API : isAutoQuality()"),u.isAutoQuality()):null},e.setAutoQuality=function(t){return u?(OvenPlayerConsole.log("API : setAutoQuality() ",t),u.setAutoQuality(t)):null},e.getCaptionList=function(){return d?(OvenPlayerConsole.log("API : getCaptionList() ",d.getCaptionList()),d.getCaptionList()):null},e.getCurrentCaption=function(){return d?(OvenPlayerConsole.log("API : getCurrentCaption() ",d.getCurrentCaption()),d.getCurrentCaption()):null},e.setCurrentCaption=function(t){if(!d)return null;OvenPlayerConsole.log("API : setCurrentCaption() ",t),d.setCurrentCaption(t)},e.addCaption=function(t){return d?(OvenPlayerConsole.log("API : addCaption() "),d.addCaption(t)):null},e.removeCaption=function(t){return d?(OvenPlayerConsole.log("API : removeCaption() ",t),d.removeCaption(t)):null},e.getBuffer=function(){if(!u)return null;OvenPlayerConsole.log("API : getBuffer() ",u.getBuffer()),u.getBuffer()},e.getState=function(){return u?(OvenPlayerConsole.log("API : getState() ",u.getState()),u.getState()):null},e.stop=function(){if(!u)return null;OvenPlayerConsole.log("API : stop() "),u.stop()},e.remove=function(){OvenPlayerConsole.log("API : remove() "),d&&(d.destroy(),d=null),u&&(u.destroy(),u=null),c&&(c.destroy(),c=null),e.trigger(ft),e.off(),i=null,n=null,A=null,OvenPlayerConsole.log("API : remove() - currentProvider, providerController, playlistManager, playerConfig, api event destroed. "),Sl.removePlayer(e)},e.getMediaElement=function(){return u.getMediaElement()},e.getVersion=function(){return r},e},Sl=(El=(bl={}).playerList=[],bl.create=function(t,e){window.OvenPlayerConsole&&0!==Object.keys(window.OvenPlayerConsole).length||(window.OvenPlayerConsole={},OvenPlayerConsole.log=function(){});var n=$t(t),r=Tl(n);return r.init(e),El.push(r),r},bl.getPlayerList=function(){return El},bl.getPlayerByContainerId=function(t){for(var e=0;e
'+(e.isRoot?"":'<')+''+e.title+'
';return o().forEach(e.body,(function(t){n+=Ll(t,e.useCheck)})),n+="
"},Ll=function(t,e){return'
'+(e?'':"")+''+t.title+""+(t.hasNext?'>'+t.description+"":"")+"
"},xl=function(t,e){return'
')+'
').concat(t.image?""):''," ").concat(t.duration?''.concat(l(t.duration),""):"","
")+'
'.concat(t.title,"
")+"
"},Il={TextViewTemplate:function(t){return'
'+"

".concat(t,"

")+'
'},ViewTemplate:function(t,e){return'
")+'
'},HelpersTemplate:function(t,e){return'
'},BigButtonTemplate:function(t,e){return'
'+"".concat(e===tt?'':"")+"".concat(e===Z?'':"")+"".concat(e===q?'':"")+"".concat(e===J?'':"")+"
"},ThumbnailTemplate:function(t,e){return'
'+"".concat(e.title?'
'.concat(e.title,"
"):"")+"
"},WaterMarkTemplate:function(t,e){return'
'+"".concat(e.waterMark.image?''):"")+"".concat(e.waterMark.text?''.concat(e.waterMark.text,""):"")+"
"},MessageBoxTemplate:function(t,e){return'
')+'
'+'
'.concat(e.message)+"".concat(e.description?'
'.concat(e.description,"
"):"")+"
"+"".concat(e.iconClass?'
'):"")+"
"},SpinnerTemplate:function(t){return'
'},ContextPanelTemplate:function(t){return'
'+''.concat(t.context," ").concat(r,"")+"
"},CaptionViewerTemplate:function(t){return'
      
'},ControlsTemplate:function(t,e){return'
'+'
'.concat(e?'':"","
")+'
'},VolumeButtonTemplate:function(t){return'
'},ProgressBarTemplate:function(t){return'
00:00
'},PlayButtonTemplate:function(t){return'
'},SettingButtonTemplate:function(t){return''},FrameButtonsTemplate:function(t){return'
'},TimeDisplayTemplate:function(t,e){return'
'+(e.duration===1/0?''+("webrtc"===e.type?e.isP2P?''.concat(t.controls.low_latency_p2p,""):''.concat(t.controls.low_latency_live,""):''.concat(t.controls.live,""))+"":'00:00 / 00:00')+"
"},FullScreenButtonTemplate:function(t){return''},PanelsTemplate:kl,SpeedPanelTemplate:kl,SourcePanelTemplate:kl,QualityPanelTemplate:kl,AudioTrackPanelTemplate:kl,CaptionPanelTemplate:kl,TimeDisplayPanelTemplate:kl,PlaylistPanelTemplate:function(t,e){return'
'+'
'.concat(t.playlist,'
')+'
'}},Rl=function(t,e,n,r,i,s,a,l){var c,u=o().isElement(t)?jt(t):t,A={},d=null,h={};h.data=r;var f=function(t){var e=document.createElement("div");return e.innerHTML=t,c=jt(e.firstChild),e.firstChild};return n&&n.systemText&&(d=n.systemText.ui),l?u.replace(f(Il[e+"Template"](d,r))):u.append(f(Il[e+"Template"](d,r))),s&&s(c,h),Object.keys(i).forEach((function(t){var e=t.split(" "),n=e[0].replace(/ /gi,""),r=e[1].replace(/ /gi,""),o="";if(o="document"===r||"window"===r||"body"===r?jt(r):c.find(r)||(c.hasClass(r.replace(".",""))?c:null),!(n&&r&&o))return!1;var s=Object.keys(A).length++,a=function(e){return i[t](e,c,h)};A[s]={name:n,target:r,callback:a};var l=null;n.indexOf("touch")>-1&&(l={passive:!0});var u=o.get().length;if(u>1)for(var d=o.get(),f=0;f1)for(var i=n.get(),o=0;o-1?i=!1:(i=!0,t.find(".op-caption-text").text(""))}),r),e.on(Ot,(function(e){if(!i&&e&&e.text){var n=e.endTime-e.startTime;o&&clearTimeout(o),t.find(".op-caption-text").html(e.text),n&&(o=setTimeout((function(){t.find(".op-caption-text").text("")}),1e3*n))}}),r)}),(function(n){t.find(".op-caption-text").text(""),e.off(Ft,null,n),e.off(Ot,null,n)}))}(t,e),e.on(ht,(function(){u&&m(),A&&(r&&r.destroy(),r=function(t,e,n){var r=null,i=null;return Rl(t,"WaterMark",e.getConfig(),n,{},(function(t,n){r=t.find(".op-watermark"),i=t.find(".op-watermark-text");var s=e.getConfig().waterMark,a=s.position||"top-right",l=s.y||"5%",c=s.x||"2.8125%";r.css(a.split("-")[0],l),r.css(a.split("-")[1],c);var u=s.width||"auto",A=s.height||"auto";r.css("width",u),r.css("height",A);var d=s.opacity||.7;r.css("opacity",d),s.text&&s.font&&o().each(s.font,(function(t,e){i.css(e,t)}))}),(function(){}))}(t,e,e.getConfig())),i||(g(Z),i=!0)}),h),e.on(St,(function(n){n.message&&(s&&s.destroy(),a&&a.destroy(),c=Dl(t,e,n.message,null,n.timer,n.iconClass,n.onClickCallback,!1),e.once(Dt,(function(t){!t.mute&&c&&c.destroy()}),h))}),h),e.on(yt,(function(t){t&&t.newstate&&(t.newstate===q&&a&&a.destroy(),t.newstate===tt||t.newstate===ot?(d=!1,a&&a.destroy(),s&&s.destroy(),n&&n.destroy(),f||l.show(!1)):t.newstate===J?(l.show(!1),g(t.newstate)):t.newstate===rt||t.newstate===nt||"adLoading"===t.newstate?(d=!1,a&&a.destroy(),s&&s.destroy(),l.show(!0)):f||l.show(!1))}),h),e.on(Pt,(function(){u&&m()})),e.on(Mt,(function(t){if(t.currentQuality<0)return!1;t.isAuto?(f=!1,l.show(!1)):"request"===t.type?(p=t.currentQuality,f=!0,l.show(!0)):"render"===t.type&&p===t.currentQuality&&(f=!1,l.show(!1))}),h),e.on(vt,(function(n){if(510===n.code&&(d=!0),101===n.code&&0===e.getPlaylist().length&&(d=!0),!d){var r="",i="";s&&s.destroy(),n&&n.code&&n.code>=100&&n.code<1e3?(r=n.message,100===n.code&&(i=n.error.toString())):r="Can not play due to unknown reasons.",OvenPlayerConsole.log("error occured : ",n),function(n,r,i,o,l,c){s&&s.destroy(),a&&a.destroy(),a=Dl(t,e,n,r,null,"op-warning",null,!0)}(r,i)}}),h),e.on(mt,(function(t){var n="Because the network connection is unstable, the following media source will be played.";e.getCurrentSource()+1===e.getQualityLevels().length&&(n="Network connection is unstable. Check the network connection."),OvenPlayerConsole.log(n)}),h),e.on(gt,(function(){u&&m()}),h)}),(function(t){e.off(ht,null,t),e.off(yt,null,t),e.off(St,null,t),e.off(vt,null,t),e.off(mt,null,t),e.off(gt,null,t),e.off(pt,null,t)}))},Pl=[],Ml=function(){var t={},e=function(){for(var t=0;t1,!0===e.getConfig().hidePlaylistIcon&&(u=!1);var v={"mouseleave .op-controls":function(t,e,n){t.preventDefault(),r.setMouseDown(!1),e.find(".op-volume-slider-container").removeClass("active")},"click .op-playlist-button":function(t,n,r){t.preventDefault(),function(t,e){var n=jt(e.getContainerElement()),r="",i=e.getPlaylist(),o=i.length,s=6,a=0,l=[];function c(t){var n,a,c=Math.ceil(o/s),u=e.getCurrentPlaylist();l=i.slice(t*s,t*s+s),r.find(".op-playlist-body-row").removeChild(),r.find(".op-arrow-left").removeClass("disable"),r.find(".op-arrow-right").removeClass("disable");for(var A=0;A576?s=6:n.width()<=576&&(s=1);var A={"click .btn-close":function(t,e,n){t.preventDefault(),n.destroy()},"click .op-arrow-left":function(t,e,n){t.preventDefault(),jt(t.target).hasClass("disable")||c(--a)},"click .op-arrow-right":function(t,e,n){t.preventDefault(),jt(t.target).hasClass("disable")||c(++a)}};Rl(t,"PlaylistPanel",e.getConfig(),i,A,(function(t,n){r=t,c(a=u()),e.on(wt,(function(t){"xsmall"===t&&6===s?(s=1,c(a=u())):"small"!==t&&"medium"!==t&&"large"!==t||1!==s||(s=6,c(a=u()))}),n),e.on(pt,(function(t){c(a=u())}),n),t.get().addEventListener("click",(function(t){for(var n=t.target;n;){if(jt(n).hasClass("op-playlist-card"))return void e.setCurrentPlaylist(parseInt(jt(n).attr("data-index")));n=n.parentElement}}),!0)}),(function(t){e.off(wt,null,t),e.off(pt,null,t)}))}(n,e)}};return Rl(t,"Controls",e.getConfig(),u,v,(function(t,u){function h(n,r){s&&s.destroy(),s=function(t,e,n,r){var i=jt(e.getContainerElement());e.getConfig().disableSeekUI&&t.addClass("op-progressbar-container-disabled");var o=0,s=!1,a=Ml(),c="",u=0,A="",d="",h="",f="",p="",g="",m=0,v="",y="",C=e.getBrowser().mobile,b=e.getMediaElement(),E=!1,w=!1;function T(t){var e=A.width(),n=e*t;h.css("width",n+"px"),f.css("left",n+"px");var r=(e-m)*t;p.css("left",r+"px"),o=n}function S(t){var e=A.width()*t;f.css("width",(0===t?t:e-o)+"px")}function k(t){var e=A.width(),n=A.offset().left,r=t.pageX;t.touches&&(r=t.pageX||t.touches[0].clientX);var i=(r-n)/e;return i<0?0:i>1?1:i}function L(){return b.seekable.end(b.seekable.length-1)-b.seekable.start(0)}function x(t,n){if(a.size()>0||-1===t)return v.hide(),void y.hide();if(v.show(),y.show(),E&&!w){var r=e.getDvrWindow()*(1-t);e.isTimecodeMode()?v.text("- "+l(r)):v.text("- "+Math.round(r*e.getFramerate()))}else if(E&&w){var i=L()*(1-t);e.isTimecodeMode()?v.text("- "+l(i)):v.text("- "+Math.round(i*e.getFramerate()))}else{var o=e.getDuration()*t;e.isTimecodeMode()?v.text(l(o)):v.text(Math.round(o*e.getFramerate()))}var s=v.width(),u=A.width(),d=u*t,h=n.pageX-A.offset().left;n.touches&&(h=(n.pageX||n.touches[0].clientX)-A.offset().left);var f=function(t){return h0&&(n+=o),e.seek(n)}r&&r.type===dt&&r.duration===1/0&&(E=!0,e.getProviderName()===ct&&(w=!0));var R={"touchstart .op-progressbar":function(t){if(n)return!1;s=!0;var e=k(t);if(-1===e)return!1;T(e),S(0),I(e)},"touchmove .op-progressbar":function(t){if(s){var e=k(t);if(-1===e)return!1;T(e),S(0),I(e),x(e,t)}},"touchend .op-progressbar":function(t){s&&(s=!1),i.removeClass("op-progressbar-hover"),v.hide(),y.hide()},"mouseenter .op-progressbar":function(t,e,r){t.preventDefault(),C||(n||v.show(),i.addClass("op-progressbar-hover"))},"mouseleave .op-progressbar":function(t,e,n){t.preventDefault(),s=!1,i.removeClass("op-progressbar-hover"),v.hide(),y.hide(),S(0)},"mousedown .op-progressbar":function(t,e,r){if(t.preventDefault(),n||C)return!1;s=!0;var i=k(t);if(-1===i)return!1;T(i),S(0),I(i)},"mousemove .op-progressbar":function(t,e,r){if(t.preventDefault(),!s&&!n&&!C){var i=k(t);S(i),x(i,t)}if(s&&!C){var o=k(t);if(-1===o)return!1;T(o),S(0),I(o),x(o,t)}},"mouseup .op-progressbar":function(t,e,n){t.preventDefault(),s&&!C&&(s=!1,i.removeClass("op-progressbar-hover"))}};return e.getConfig().disableSeekUI&&(R={}),Rl(t,"ProgressBar",e.getConfig(),null,R,(function(t,r){A=t,d=t.find(".op-load-progress"),h=t.find(".op-play-progress"),f=t.find(".op-hover-progress"),p=t.find(".op-progressbar-knob-container"),g=t.find(".op-progressbar-knob"),m=g.width(),v=t.find(".op-progressbar-time"),y=t.find(".op-progressbar-preview"),n?e.on(Lt,(function(t){t&&t.duration&&t.position&&(T(t.position/t.duration),t.duration)}),r):(e.on(It,(function(t){if(t&&t.duration&&t.position){u=t.duration;var n=t.position/t.duration;if(E&&!w&&(n=(e.getDvrWindow()-(t.duration-t.position))/e.getDvrWindow()),E&&w){var r=L();u=r,n=(r-(r-Math.min(r,t.position)))/r}T(n)}}),r),e.on(xt,(function(t){var e,n;t&&t.bufferPercent&&(e=t.bufferPercent/100,n=A.width()*e,d.css("width",n+"px"))}),r))}),(function(t){n?e.off(Lt,null,t):(e.off(It,null,t),e.off(xt,null,t))}))}(t.find(".op-progressbar-container"),e,n,r)}function v(){o&&o.destroy(),o=function(t,e){var n=Ml(),r={"click .op-setting-button":function(t,r,i){t.preventDefault();var o=r.closest(".op-controls-container");if(n.size()>0)n.clear();else{var s=function(t){var e={id:"panel-"+(new Date).getTime(),title:"Settings",body:[],isRoot:!0,panelType:""},n=t.getConfig();n&&n.systemText&&(Object.keys(_l).forEach((function(t){_l[t]=n.systemText.ui.setting[t]})),e.title=n.systemText.ui.setting.title);var r=t.getSources(),i=r&&r.length>0?r[t.getCurrentSource()]:null,o=t.getQualityLevels(),s=o&&o.length>0?o[t.getCurrentQuality()]:null,a=t.getAudioTracks(),l=a&&a.length>0?a[t.getCurrentAudioTrack()]:null,c=t.getCaptionList(),u=t.getCurrentCaption(),A=t.getFramerate();if(i){var d={title:_l.speed,value:t.getPlaybackRate()+_l.speedUnit,description:t.getPlaybackRate()+_l.speedUnit,panelType:"speed",hasNext:!0};e.body.push(d)}if(r&&r.length>1){var h={title:_l.source,value:i?i.label:"Default",description:i?i.label:"Default",panelType:"source",hasNext:!0};e.body.push(h)}if(o&&o.length>0){var f={title:_l.quality,value:s?s.label:"Default",description:s?s.label:"Default",panelType:"quality",hasNext:!0};e.body.push(f)}if(a&&a.length>0){var p={title:_l.audioTrack,value:l?l.label:"Default",description:l?l.label:"Default",panelType:"audioTrack",hasNext:!0};e.body.push(p)}if(c&&c.length>0){var g={title:_l.caption,value:c[u]?c[u].label:"OFF",description:c[u]?c[u].label:"OFF",panelType:"caption",hasNext:!0};e.body.push(g)}if(A>0){var m={title:_l.display,value:t.isTimecodeMode()?"Play time":"Framecode",description:t.isTimecodeMode()?"Play time":"Framecode",panelType:"display",hasNext:!0};e.body.push(m)}return e}(e);n.add(Fl(o,e,s))}}};return Rl(t,"SettingButton",e.getConfig(),null,r,(function(t,e){}),(function(t){}))}(t.find(".setting-holder"),e)}function y(){c||(c=function(t,e){var n=jt(e.getContainerElement()),r="",i="",o=!1,s=(e.getConfig(),e.getBrowser()),a="iOS"===s.os,l=(s.os,""),c=!1,u={onfullscreenchange:"fullscreenchange",onmozfullscreenchange:"mozfullscreenchange",onwebkitfullscreenchange:"webkitfullscreenchange",MSFullscreenChange:"MSFullscreenChange"};function A(){var t=!1,e=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;return e&&n.get()===e&&(t=!0),t}function d(){OvenPlayerConsole.log("FULLSCREEN STATE : ",A()),A()?(n.addClass("op-fullscreen"),o=!0,r.hide(),i.show()):(n.removeClass("op-fullscreen"),o=!1,r.show(),i.hide())}function h(){OvenPlayerConsole.log("afterFullScreenChangedCallback () "),d(),e.trigger(Tt,o)}function f(){o?(n.removeClass("op-fullscreen"),o=!1,r.show(),i.hide()):(n.addClass("op-fullscreen"),o=!0,r.hide(),i.show()),e.trigger(Tt,o)}function p(){var t;!o||a&&!A()?function(){var t,r="",i=n.get(),s=n.find("video")?n.find("video").get():i,l=null;if(a){if(s.length>1)for(var u=0;u1)for(var i=0;i9e15&&(n.duration=1/0);var r=e.getSources()[e.getCurrentSource()].sectionStart,i=e.getSources()[e.getCurrentSource()].sectionEnd;i&&(n.duration=i),r&&(n.duration=n.duration-r),function(n){a&&a.destroy(),a=function(t,e,n){var r="",i="",o="",s=e.getMediaElement(),a=!1,c=!1;function u(t){return l(t)}var A={"click .op-live-text":function(t,n,r){t.preventDefault(),e.seek(Number.MAX_SAFE_INTEGER);var i=e.getConfig();if(i.hlsConfig){var o=i.hlsConfig;"number"==typeof o.liveSyncDuration&&(e.getMseInstance().config.liveSyncDuration=o.liveSyncDuration),"number"==typeof o.liveMaxLatencyDuration&&(e.getMseInstance().config.liveMaxLatencyDuration=o.liveMaxLatencyDuration),"number"==typeof o.maxLiveSyncPlaybackRate&&(e.getMseInstance().config.maxLiveSyncPlaybackRate=o.maxLiveSyncPlaybackRate)}}};return Rl(t,"TimeDisplay",e.getConfig(),n,A,(function(t,l){var A=e.isTimecodeMode();r=t.find(".op-time-current"),i=t.find(".op-time-duration"),o=t.find(".op-live-badge"),t.find(".op-live-text"),n&&n.type===dt&&n.duration===1/0&&(a=!0,e.getProviderName()===ct&&(c=!0)),n.duration!==1/0?(A?i.text(u(n.duration)):i.text(Math.round(n.duration*e.getFramerate())+" ("+e.getFramerate()+"fps)"),e.on(_t,(function(t){(A=t)?i.text(u(n.duration)):i.text(Math.round(n.duration*e.getFramerate())+" ("+e.getFramerate()+"fps)")}),l),e.on(It,(function(t){A?r.text(u(t.position)):r.text(Math.round(t.position*e.getFramerate()))}),l)):a&&!c?e.on(It,(function(t){t.duration-t.position>3?o.addClass("op-live-badge-delayed"):o.removeClass("op-live-badge-delayed")}),l):a&&c&&e.on(It,(function(t){s.seekable.end(s.seekable.length-1)-s.seekable.start(0)-t.position>3?o.addClass("op-live-badge-delayed"):o.removeClass("op-live-badge-delayed")}),l)}),(function(t){e.off(_t,null,t),e.off(It,null,t)}))}(t.find(".op-left-controls"),e,n)}(n),y(),e.getFramerate&&e.getFramerate(),n.duration===1/0?(OvenPlayerConsole.log("[[[[LIVE MODE]]]]"),n.type===dt?h(!1,n):s&&s.destroy()):h(!1),A=!0}function b(){a&&a.destroy(),s&&s.destroy(),v(),y(),g.removeClass("linear-ad")}i=function(t,e){var n="",r="",i="",o="",s="",a="",l="",c={"click .op-play-button":function(t,n,r){t.preventDefault();var i=e.getState(),o=e.getPlaylist(),s=e.getCurrentPlaylist();i===q?e.play():i===tt||i===ot?e.pause():i===nt||i===rt?e.stop():i===Z||i===st?e.play():i===et?e.setCurrentSource(e.getCurrentSource()):i===J&&o.length===s+1&&(e.seek(0),e.play())},"click .op-seek-button-back":function(t,n,r){var i=e.getConfig().seekControlInterval;i||(i=10);var o=e.getPosition()-i;o<0&&(o=0),e.seek(o)},"click .op-seek-button-forward":function(t,n,r){var i=e.getConfig().seekControlInterval;i||(i=10);var o=e.getPosition()+i;o>e.getDuration()&&(o=e.getDuration()),e.seek(o)}};return Rl(t,"PlayButton",e.getConfig(),null,c,(function(t,c){n=t.find(".op-play-button .op-play"),r=t.find(".op-play-button .op-pause"),i=t.find(".op-play-button .op-replay"),o=t.find(".op-seek-button-back"),s=t.find(".op-seek-button-forward"),a=t.find(".op-seek-back-text"),l=t.find(".op-seek-forward-text"),e.on(yt,(function(t){var e;t&&t.newstate&&(e=t.newstate,n.hide(),r.hide(),i.hide(),e===tt||e===ot||e===nt||e===rt?r.show():e===Z||e===st?n.show():e===J?i.show():n.show())}),c),e.getConfig().showSeekControl||(o.hide(),s.hide());var u=e.getConfig().seekControlInterval;u?(a.text(u),l.text(u)):(a.text(10),l.text(10))}),(function(t){e.off(yt,null,t)}))}(t.find(".op-left-controls"),e),r=function(t,e){var n="",r="",i="",o="",s="",a="",l="",c=!1,u=0,A="iOS"===e.getBrowser().os||"Android"===e.getBrowser().os;function d(t){e.getMute()&&(t=0),function(t){s.hide(),a.hide(),l.hide(),t>=70?s.show():t<70&&t>0?a.show():0==t?l.show():s.show()}(t);var n=u*t/100;i.css("left",n+"px"),o.css("width",n+"px")}function h(t){var e=((t.pageX||t.touches[0].clientX)-r.offset().left)/70*100;return e<0&&(e=0),e>100&&(e=100),e}var f={"click .op-volume-button":function(t,n,r){t.preventDefault(),A||(0===e.getVolume()?(e.setMute(!1),e.setVolume(100)):e.setMute())},"mouseenter .op-volume-button":function(t,e,r){t.preventDefault(),A||n.addClass("active")},"mouseleave .op-volume-silder":function(t,e,n){t.preventDefault(),c=!1},"mousedown .op-volume-silder":function(t,n,r){t.preventDefault(),c=!0,e.setMute(!1),e.setVolume(h(t))},"mouseup .op-volume-silder":function(t,e,n){t.preventDefault(),c=!1},"mousemove .op-volume-silder":function(t,n,r){if(t.preventDefault(),!c)return!1;e.setVolume(h(t))},"touchstart .op-volume-button":function(t){A&&(e.getMute()?e.setMute(!1):e.setMute(!0))}},p=Rl(t,"VolumeButton",e.getConfig(),null,f,(function(t,c){n=t.find(".op-volume-slider-container"),e.getBrowser().mobile&&n.hide(),r=t.find(".op-volume-silder"),i=t.find(".op-volume-slider-handle"),o=t.find(".op-volume-slider-value"),s=t.find(".op-volume-max"),a=t.find(".op-volume-small"),l=t.find(".op-volume-mute"),u=64,i.css("left",u+"px"),d(e.getVolume()),e.on(ht,(function(){d(e.getVolume())}),c),e.on(Rt,(function(t){d(t.volume)}),c),e.on(Dt,(function(t){t.mute?d(0):d(e.getVolume())}),c)}),(function(t){e.off(ht,null,t),e.off(Rt,null,t),e.off(Dt,null,t)}));return p.setMouseDown=function(t){c=t},p}(t.find(".op-left-controls"),e);var E=e.getPlaylist(),w=e.getCurrentPlaylist();E&&E[w]&&E[w].adTagUrl||v(),y(),e.on(ht,(function(){t.show()}),u),e.on(Bt,(function(t){n=t.duration,m=t,t.isP2P=d,C(t)}),u),e.on(It,(function(t){(f||e&&e.getProviderName&&"rtmp"===e.getProviderName())&&!n&&m&&m.duration!==t.duration&&(m=t,C(t))}),u),e.on(wt,(function(t){g.find(".op-setting-panel")&&g.find(".op-setting-panel").css("max-height",g.height()-g.find(".op-bottom-panel").height()+"px")}),u),e.on(Nt,(function(t){d=t}),u),e.on(bt,(function(){if(!A){var n="";e.getSources().length>0&&e.getSources()[e.getCurrentSource()]&&e.getSources()[e.getCurrentSource()].type&&(n=e.getSources()[e.getCurrentSource()].type),C({isP2P:d,duration:e.getDuration(),type:n})}t.show()}),u),e.on(vt,(function(e){t.show()}),u),e.on(kt,(function(t){t.isLinear?(g.addClass("linear-ad"),h(!0),a&&a.destroy(),o&&o.destroy(),p&&c&&c.destroy()):g.removeClass("linear-ad")}),u),e.on(at,(function(){b()}),u),e.on(lt,(function(){b()}),u),e.on(Pt,(function(){b()}),u)}),(function(t){e.off(Bt,null,t),e.off(It,null,t),e.off(at,null,t),e.off(kt,null,t),e.off(Nt,null,t),e.off(lt,null,t),e.off(wt,null,t),e.off(Pt,null,t),a&&a.destroy(),i&&i.destroy(),s&&s.destroy(),c&&c.destroy(),r&&r.destroy()}))},Ul=n(5655),Ql=n.n(Ul),Gl=n(3379),Wl=n.n(Gl),Yl=n(7795),jl=n.n(Yl),Hl=n(569),Kl=n.n(Hl),Vl=n(3565),zl=n.n(Vl),$l=n(9216),Xl=n.n($l),ql=n(4589),Jl=n.n(ql),Zl=n(2021),tc={};tc.styleTagTransform=Jl(),tc.setAttributes=zl(),tc.insert=Kl().bind(null,"head"),tc.domAPI=jl(),tc.insertStyleElement=Xl(),Wl()(Zl.Z,tc),Zl.Z&&Zl.Z.locals&&Zl.Z.locals;var ec,nc=function(t){var e,n="",r="",i="",o="",s=null,a="",l=q,c=!1,u=Ml(),A="",d="",h=null,f={};function p(t,n){if(a&&(clearTimeout(a),a=null),t){if(u.size()>0)return!1;e.addClass("op-autohide")}else e.removeClass("op-autohide"),n&&(a=setTimeout((function(){if(u.size()>0)return!1;e.addClass("op-autohide")}),3e3))}function g(){var t=l;t===q||t===Z||t===J?(t===J&&s.seek(0),s.play()):t===tt&&s.pause()}function m(t,e){var n,r=s.getDuration(),i=s.getPosition();n=e?Math.max(i-t,0):Math.min(i+t,r),s.seek(n)}function v(t){var e,n=s.getVolume();e=t?Math.min(n+5,100):Math.max(n-5,0),s.setVolume(e)}function y(){var t=e.width();t<576?(A="xsmall",e.addClass("xsmall"),t<490&&e.addClass("xxsmall")):t<768?(A="small",e.addClass("small")):t<992?(A="medium",e.addClass("medium")):(A="large",e.addClass("large"))}var C={"click .ovenplayer":function(t,e,n){if(s&&s.trigger(Et,t),o)return t.preventDefault(),o.destroy(),o=null,!1;if(!jt(t.target).closest(".op-controls-container")&&!jt(t.target).closest(".op-setting-panel")){if(u.size()>0)return t.preventDefault(),u.clear(),!1;s.getDuration()===1/0||s.getBrowser().mobile||g()}},"dblclick .ovenplayer":function(t,e,n){s&&s.getConfig().expandFullScreenUI&&s.toggleFullScreen&&(jt(t.target).closest(".op-controls-container")||jt(t.target).closest(".op-setting-panel")||s.toggleFullScreen())},"touchstart .ovenplayer":function(t,e,n){l===tt||l===q||l===nt||l===ot&&"xsmall"===A?p(!1,!0):p(!1)},"mouseenter .ovenplayer":function(t,e,n){t.preventDefault(),l===tt||l===q||l===nt||l===ot&&"xsmall"===A?p(!1,!0):p(!1)},"mousemove .ovenplayer":function(t,e,n){t.preventDefault(),l===tt||l===q||l===nt||l===ot&&"xsmall"===A?p(!1,!0):p(!1)},"mouseleave .ovenplayer":function(t,e,n){t.preventDefault(),(l===tt||l===q||l===nt||l===ot&&"xsmall"===A)&&p(!0)},"keydown .ovenplayer":function(t,e,n){var r=s.getFramerate();switch(t.keyCode){case 16:t.preventDefault(),c=!0;break;case 32:t.preventDefault(),g();break;case 37:t.preventDefault(),s.getConfig().disableSeekUI||(c&&r?s.seekFrame(-1):m(5,!0));break;case 39:t.preventDefault(),s.getConfig().disableSeekUI||(c&&r?s.seekFrame(1):m(5,!1));break;case 38:t.preventDefault(),v(!0);break;case 40:t.preventDefault(),v(!1)}},"keyup .ovenplayer":function(t,e,n){16===t.keyCode&&(t.preventDefault(),c=!1)},"contextmenu .ovenplayer":function(t,n,r){if(t.stopPropagation(),!jt(t.currentTarget).find("object"))return t.preventDefault(),i=t.pageX,a=t.pageY,o&&(o.destroy(),o=null),o=function(t,e,n){var r=jt(e.getContainerElement()),i={"click .op-context-item":function(t,e,n){t.preventDefault(),window.open("https://github.com/AirenSoft/OvenPlayer","_blank")}};return Rl(t,"ContextPanel",e.getConfig(),n,i,(function(t,e){var i=t.width(),o=t.height(),s=Math.min(n.pageX-r.offset().left,r.width()-i),a=Math.min(n.pageY-r.offset().top,r.height()-o);t.css("left",s+"px"),t.css("top",a+"px")}),(function(){}))}(e,s,{pageX:i,pageY:a}),!1;var i,a}};return(f=Rl(t,"View",null,t.id,C,(function(t,r){e=t,n=r,y(),d=A,h=new(Ql())(e.get(),(function(){e.removeClass("large"),e.removeClass("medium"),e.removeClass("small"),e.removeClass("xsmall"),e.removeClass("xxsmall"),y(),A!==d&&(d=A,s&&s.trigger(wt,d))}))}),(function(){h&&(h.detach(),h=null),i&&(i.destroy(),i=null),r&&(r.destroy(),r=null)}),!0)).getMediaElementContainer=function(){return e.find(".op-media-element-container").get()},f.setApi=function(t){(s=t).getContainerElement=function(){return e.get()},s.getContainerId=function(){return e.get().id},s.on(ht,(function(n){r||(r=Nl(e.find(".op-ui"),t)),o||e.addClass("op-no-controls")})),s.on(vt,(function(t){if(s){var e=s.getSources()||[];r&&e.length}})),s.on(ft,(function(t){n.destroy()})),s.on(bt,(function(n){!r&&o&&(r=Nl(e.find(".op-ui"),t))})),s.on(yt,(function(t){t&&t.newstate&&(l=t.newstate,t.newstate===tt||t.newstate===ot&&"xsmall"===A?p(!1,!0):p(!1))}));var o=s.getConfig()&&s.getConfig().controls;i=Bl(e.find(".op-ui"),t),r=Nl(e.find(".op-ui"),t);var a=s.getConfig().aspectRatio;if(a&&2===a.split(":").length){var c=1*a.split(":")[0],u=1*a.split(":")[1]/c*100;e.find(".op-ratio").css("padding-bottom",u+"%")}s.showControls=function(t){t?(e.removeClass("op-no-controls"),p(!1,!0)):e.addClass("op-no-controls")}},f},rc=(ec={},Object.assign(ec,Sl),ec.create=function(t,e){var n=$t(t),r=nc(n),i=Sl.create(r.getMediaElementContainer(),e);return r.setApi(i),OvenPlayerConsole.log("[OvenPlayer] v.0.10.31"),i},ec)},1001:function(){!function(t){"use strict";if("window"in t&&"document"in t){document.querySelectorAll||(document.querySelectorAll=function(t){var e,n=document.createElement("style"),r=[];for(document.documentElement.firstChild.appendChild(n),document._qsa=[],n.styleSheet.cssText=t+"{x-qsa:expression(document._qsa && document._qsa.push(this))}",window.scrollBy(0,0),n.parentNode.removeChild(n);document._qsa.length;)(e=document._qsa.shift()).style.removeAttribute("x-qsa"),r.push(e);return document._qsa=null,r}),document.querySelector||(document.querySelector=function(t){var e=document.querySelectorAll(t);return e.length?e[0]:null}),document.getElementsByClassName||(document.getElementsByClassName=function(t){return t=String(t).replace(/^|\s+/g,"."),document.querySelectorAll(t)}),t.Node=t.Node||function(){throw TypeError("Illegal constructor")},[["ELEMENT_NODE",1],["ATTRIBUTE_NODE",2],["TEXT_NODE",3],["CDATA_SECTION_NODE",4],["ENTITY_REFERENCE_NODE",5],["ENTITY_NODE",6],["PROCESSING_INSTRUCTION_NODE",7],["COMMENT_NODE",8],["DOCUMENT_NODE",9],["DOCUMENT_TYPE_NODE",10],["DOCUMENT_FRAGMENT_NODE",11],["NOTATION_NODE",12]].forEach((function(e){e[0]in t.Node||(t.Node[e[0]]=e[1])})),t.DOMException=t.DOMException||function(){throw TypeError("Illegal constructor")},[["INDEX_SIZE_ERR",1],["DOMSTRING_SIZE_ERR",2],["HIERARCHY_REQUEST_ERR",3],["WRONG_DOCUMENT_ERR",4],["INVALID_CHARACTER_ERR",5],["NO_DATA_ALLOWED_ERR",6],["NO_MODIFICATION_ALLOWED_ERR",7],["NOT_FOUND_ERR",8],["NOT_SUPPORTED_ERR",9],["INUSE_ATTRIBUTE_ERR",10],["INVALID_STATE_ERR",11],["SYNTAX_ERR",12],["INVALID_MODIFICATION_ERR",13],["NAMESPACE_ERR",14],["INVALID_ACCESS_ERR",15]].forEach((function(e){e[0]in t.DOMException||(t.DOMException[e[0]]=e[1])})),function(){function e(t,e,n){if("function"==typeof e){"DOMContentLoaded"===t&&(t="load");var r=this,i=function(t){t._timeStamp=Date.now(),t._currentTarget=r,e.call(this,t),t._currentTarget=null};this["_"+t+e]=i,this.attachEvent("on"+t,i)}}function n(t,e,n){if("function"==typeof e){"DOMContentLoaded"===t&&(t="load");var r=this["_"+t+e];r&&(this.detachEvent("on"+t,r),this["_"+t+e]=null)}}"Element"in t&&!Element.prototype.addEventListener&&Object.defineProperty&&(Event.CAPTURING_PHASE=1,Event.AT_TARGET=2,Event.BUBBLING_PHASE=3,Object.defineProperties(Event.prototype,{CAPTURING_PHASE:{get:function(){return 1}},AT_TARGET:{get:function(){return 2}},BUBBLING_PHASE:{get:function(){return 3}},target:{get:function(){return this.srcElement}},currentTarget:{get:function(){return this._currentTarget}},eventPhase:{get:function(){return this.srcElement===this.currentTarget?Event.AT_TARGET:Event.BUBBLING_PHASE}},bubbles:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mousemove":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"resize":case"scroll":case"select":case"change":case"submit":case"reset":return!0}return!1}},cancelable:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"submit":return!0}return!1}},timeStamp:{get:function(){return this._timeStamp}},stopPropagation:{value:function(){this.cancelBubble=!0}},preventDefault:{value:function(){this.returnValue=!1}},defaultPrevented:{get:function(){return!1===this.returnValue}}}),[Window,HTMLDocument,Element].forEach((function(t){t.prototype.addEventListener=e,t.prototype.removeEventListener=n})))}(),function(){function e(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}"CustomEvent"in t&&"function"==typeof t.CustomEvent||(e.prototype=t.Event.prototype,t.CustomEvent=e)}(),window.addEvent=function(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent&&(t["e"+e+n]=n,t[e+n]=function(){var r=window.event;r.currentTarget=t,r.preventDefault=function(){r.returnValue=!1},r.stopPropagation=function(){r.cancelBubble=!0},r.target=r.srcElement,r.timeStamp=Date.now(),t["e"+e+n].call(this,r)},t.attachEvent("on"+e,t[e+n]))},window.removeEvent=function(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent&&(t.detachEvent("on"+e,t[e+n]),t[e+n]=null,t["e"+e+n]=null)},function(){function e(t,e){function n(t){return t.length?t.split(/\s+/g):[]}function r(t,e){var r=n(e),i=r.indexOf(t);return-1!==i&&r.splice(i,1),r.join(" ")}if(Object.defineProperties(this,{length:{get:function(){return n(t[e]).length}},item:{value:function(r){var i=n(t[e]);return 0<=r&&r=0&&e.item(n)!==this;);return n>-1})),window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(t){var e,n=(this.document||this.ownerDocument).querySelectorAll(t),r=this;do{for(e=n.length;--e>=0&&n.item(e)!==r;);}while(e<0&&(r=r.parentElement));return r});var e={prepend:function(){var t=[].slice.call(arguments);t=i(t),this.insertBefore(t,this.firstChild)},append:function(){var t=[].slice.call(arguments);t=i(t),this.appendChild(t)}};r(t.Document||t.HTMLDocument,e),r(t.DocumentFragment,e),r(t.Element,e);var n={before:function(){var t=[].slice.call(arguments),e=this.parentNode;if(e){for(var n=this.previousSibling;-1!==t.indexOf(n);)n=n.previousSibling;var r=i(t);e.insertBefore(r,n?n.nextSibling:e.firstChild)}},after:function(){var t=[].slice.call(arguments),e=this.parentNode;if(e){for(var n=this.nextSibling;-1!==t.indexOf(n);)n=n.nextSibling;var r=i(t);e.insertBefore(r,n)}},replaceWith:function(){var t=[].slice.call(arguments),e=this.parentNode;if(e){for(var n=this.nextSibling;-1!==t.indexOf(n);)n=n.nextSibling;var r=i(t);this.parentNode===e?e.replaceChild(r,this):e.insertBefore(r,n)}},remove:function(){this.parentNode&&this.parentNode.removeChild(this)}};r(t.DocumentType,n),r(t.Element,n),r(t.CharacterData,n)}function r(t,e){t&&Object.keys(e).forEach((function(n){if(!(n in t)&&!(n in t.prototype))try{Object.defineProperty(t.prototype,n,Object.getOwnPropertyDescriptor(e,n))}catch(r){t[n]=e[n]}}))}function i(t){var e=null;return t=t.map((function(t){return t instanceof Node?t:document.createTextNode(t)})),1===t.length?e=t[0]:(e=document.createDocumentFragment(),t.forEach((function(t){e.appendChild(t)}))),e}}(self)},5655:function(t,e){var n,r;r=this,void 0===(n=function(){return r.returnExportsGlobal=function(){"use strict";var t=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,20)};function e(){var t,e;this.q=[],this.add=function(t){this.q.push(t)},this.call=function(){for(t=0,e=this.q.length;t
',n.appendChild(n.resizeSensor),"static"==function(t,e){return t.currentStyle?t.currentStyle[e]:window.getComputedStyle?window.getComputedStyle(t,null).getPropertyValue(e):t.style[e]}(n,"position")&&(n.style.position="relative");var s=n.resizeSensor.childNodes[0],a=s.childNodes[0],l=n.resizeSensor.childNodes[1],c=function(){a.style.width="100000px",a.style.height="100000px",s.scrollLeft=1e5,s.scrollTop=1e5,l.scrollLeft=1e5,l.scrollTop=1e5};c();var u,A,d,h,f=!1;t((function e(){n.resizedAttached&&(f&&(n.resizedAttached.call(),f=!1),t(e))}));var p=function(){(d=n.offsetWidth)==u&&(h=n.offsetHeight)==A||(f=!0,u=d,A=h),c()},g=function(t,e,n){t.attachEvent?t.attachEvent("on"+e,n):t.addEventListener(e,n)};g(s,"scroll",p),g(l,"scroll",p)}var r=function(t,e){var r=Object.prototype.toString.call(t),i=this._isCollectionTyped="[object Array]"===r||"[object NodeList]"===r||"[object HTMLCollection]"===r||"undefined"!=typeof jQuery&&t instanceof window.jQuery||"undefined"!=typeof Elements&&t instanceof window.Elements;if(this._element=t,i)for(var o=0,s=t.length;o=0&&n<=b}}function $(t){return function(e){return null==e?void 0:e[t]}}var X=$("byteLength"),q=z(X),J=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/,Z=A?function(t){return g?g(t)&&!G(t):q(t)&&J.test(c.call(t))}:V(!1),tt=$("length");function et(t,e){e=function(t){for(var e={},n=t.length,r=0;r":">",'"':""","'":"'","`":"`"},Ht=Yt(jt),Kt=Yt(bt(jt)),Vt=it.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},zt=/(.)^/,$t={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Xt=/\\|'|\r|\n|\u2028|\u2029/g;function qt(t){return"\\"+$t[t]}var Jt=/^\s*(\w|\$)+\s*$/,Zt=0;function te(t,e,n,r,i){if(!(r instanceof e))return t.apply(n,i);var o=Lt(t.prototype),s=t.apply(o,i);return w(s)?s:o}var ee=E((function(t,e){var n=ee.placeholder;return function r(){for(var i=0,o=e.length,s=Array(o),a=0;a1)ie(a,e-1,n,r),i=r.length;else for(var l=0,c=a.length;l0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}}var ue=ee(ce,2);function Ae(t,e,n){e=Ut(e,n);for(var r,i=nt(t),o=0,s=i.length;o0?0:i-1;o>=0&&o0?s=o>=0?o:Math.max(o+a,s):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return r[o=n(r,i)]===i?o:-1;if(i!=i)return(o=e(l.call(r,s,a),K))>=0?o+s:-1;for(o=t>0?s:a-1;o>=0&&o0?0:s-1;for(i||(r=e[o?o[a]:a],a+=t);a>=0&&a=3;return e(t,Ft(n,i,4),r,o)}}var we=Ee(1),Te=Ee(-1);function Se(t,e,n){var r=[];return e=Ut(e,n),Ce(t,(function(t,n,i){e(t,n,i)&&r.push(t)})),r}function ke(t,e,n){e=Ut(e,n);for(var r=!re(t)&&nt(t),i=(r||t).length,o=0;o=0}var Ie=E((function(t,e,n){var r,i;return F(e)?i=e:(e=Rt(e),r=e.slice(0,-1),e=e[e.length-1]),be(t,(function(t){var o=i;if(!o){if(r&&r.length&&(t=Dt(t,r)),null==t)return;o=t[e]}return null==o?o:o.apply(t,n)}))}));function Re(t,e){return be(t,Ot(e))}function De(t,e,n){var r,i,o=-1/0,a=-1/0;if(null==e||"number"==typeof e&&"object"!=s(t[0])&&null!=t)for(var l=0,c=(t=re(t)?t:Ct(t)).length;lo&&(o=r);else e=Ut(e,n),Ce(t,(function(t,n,r){((i=e(t,n,r))>a||i===-1/0&&o===-1/0)&&(o=t,a=i)}));return o}function Be(t,e,n){if(null==e||n)return re(t)||(t=Ct(t)),t[Gt(t.length-1)];var r=re(t)?xt(t):Ct(t),i=tt(r);e=Math.max(Math.min(e,i),0);for(var o=i-1,s=0;s1&&(r=Ft(r,e[1])),e=lt(t)):(r=Ue,e=ie(e,!1,!1),t=Object(t));for(var i=0,o=e.length;i1&&(n=e[1])):(e=be(ie(e,!1,!1),String),r=function(t,n){return!xe(e,n)}),Qe(t,r,n)}));function We(t,e,n){return l.call(t,0,Math.max(0,t.length-(null==e||n?1:e)))}function Ye(t,e,n){return null==t||t.length<1?null==e||n?void 0:[]:null==e||n?t[0]:We(t,t.length-e)}function je(t,e,n){return l.call(t,null==e||n?1:e)}var He=E((function(t,e){return e=ie(e,!0,!0),Se(t,(function(t){return!xe(e,t)}))})),Ke=E((function(t,e){return He(t,e)}));function Ve(t,e,n,r){S(e)||(r=n,n=e,e=!1),null!=n&&(n=Ut(n,r));for(var i=[],o=[],s=0,a=tt(t);se?(r&&(clearTimeout(r),r=null),a=c,s=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(l,u)),s};return c.cancel=function(){clearTimeout(r),a=0,r=i=o=null},c},debounce:function(t,e,n){var r,i,o,s,a,l=function l(){var c=Wt()-i;e>c?r=setTimeout(l,e-c):(r=null,n||(s=t.apply(a,o)),r||(o=a=null))},c=E((function(c){return a=this,o=c,i=Wt(),r||(r=setTimeout(l,e),n&&(s=t.apply(a,o))),s}));return c.cancel=function(){clearTimeout(r),r=o=a=null},c},wrap:function(t,e){return ee(e,t)},negate:le,compose:function(){var t=arguments,e=t.length-1;return function(){for(var n=e,r=t[e].apply(this,arguments);n--;)r=t[n].call(this,r);return r}},after:function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},before:ce,once:ue,findKey:Ae,findIndex:he,findLastIndex:fe,sortedIndex:pe,indexOf:me,lastIndexOf:ve,find:ye,detect:ye,findWhere:function(t,e){return ye(t,Mt(e))},each:Ce,forEach:Ce,map:be,collect:be,reduce:we,foldl:we,inject:we,reduceRight:Te,foldr:Te,filter:Se,select:Se,reject:function(t,e,n){return Se(t,le(Ut(e)),n)},every:ke,all:ke,some:Le,any:Le,contains:xe,includes:xe,include:xe,invoke:Ie,pluck:Re,where:function(t,e){return Se(t,Mt(e))},max:De,min:function(t,e,n){var r,i,o=1/0,a=1/0;if(null==e||"number"==typeof e&&"object"!=s(t[0])&&null!=t)for(var l=0,c=(t=re(t)?t:Ct(t)).length;lr||void 0===n)return 1;if(n>8&255]},j=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},H=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},K=function(t){return Q(t,23,4)},V=function(t){return Q(t,52,8)},z=function(t,e){y(t.prototype,e,{get:function(){return k(this)[e]}})},$=function(t,e,n,r){var i=f(n),o=k(t);if(i+e>o.byteLength)throw _(I);var s=k(o.buffer).bytes,a=i+o.byteOffset,l=b(s,a,a+e);return r?l:U(l)},X=function(t,e,n,r,i,o){var s=f(n),a=k(t);if(s+e>a.byteLength)throw _(I);for(var l=k(a.buffer).bytes,c=s+a.byteOffset,u=r(+i),A=0;Att;)(J=Z[tt++])in D||l(D,J,R[J]);B.constructor=D}m&&g(M)!==O&&m(M,O);var et=new P(new D(2)),nt=i(M.setInt8);et.setInt8(0,2147483648),et.setInt8(1,2147483649),!et.getInt8(0)&&et.getInt8(1)||c(M,{setInt8:function(t,e){nt(this,t,e<<24>>24)},setUint8:function(t,e){nt(this,t,e<<24>>24)}},{unsafe:!0})}else B=(D=function(t){A(this,B);var e=f(t);L(this,{bytes:N(F(e),0),byteLength:e}),o||(this.byteLength=e)}).prototype,M=(P=function(t,e,n){A(this,M),A(t,B);var r=k(t).byteLength,i=d(e);if(i<0||i>r)throw _("Wrong offset");if(i+(n=void 0===n?r-i:h(n))>r)throw _("Wrong length");L(this,{buffer:t,byteLength:n,byteOffset:i}),o||(this.buffer=t,this.byteLength=n,this.byteOffset=i)}).prototype,o&&(z(D,"byteLength"),z(P,"buffer"),z(P,"byteLength"),z(P,"byteOffset")),c(M,{getInt8:function(t){return $(this,1,t)[0]<<24>>24},getUint8:function(t){return $(this,1,t)[0]},getInt16:function(t){var e=$(this,2,t,arguments.length>1?arguments[1]:void 0);return(e[1]<<8|e[0])<<16>>16},getUint16:function(t){var e=$(this,2,t,arguments.length>1?arguments[1]:void 0);return e[1]<<8|e[0]},getInt32:function(t){return H($(this,4,t,arguments.length>1?arguments[1]:void 0))},getUint32:function(t){return H($(this,4,t,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(t){return G($(this,4,t,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(t){return G($(this,8,t,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(t,e){X(this,1,t,W,e)},setUint8:function(t,e){X(this,1,t,W,e)},setInt16:function(t,e){X(this,2,t,Y,e,arguments.length>2?arguments[2]:void 0)},setUint16:function(t,e){X(this,2,t,Y,e,arguments.length>2?arguments[2]:void 0)},setInt32:function(t,e){X(this,4,t,j,e,arguments.length>2?arguments[2]:void 0)},setUint32:function(t,e){X(this,4,t,j,e,arguments.length>2?arguments[2]:void 0)},setFloat32:function(t,e){X(this,4,t,K,e,arguments.length>2?arguments[2]:void 0)},setFloat64:function(t,e){X(this,8,t,V,e,arguments.length>2?arguments[2]:void 0)}});E(D,x),E(P,"DataView"),t.exports={ArrayBuffer:D,DataView:P}},1048:function(t,e,n){"use strict";var r=n(7908),i=n(1400),o=n(6244),s=Math.min;t.exports=[].copyWithin||function(t,e){var n=r(this),a=o(n),l=i(t,a),c=i(e,a),u=arguments.length>2?arguments[2]:void 0,A=s((void 0===u?a:i(u,a))-c,a-l),d=1;for(c0;)c in n?n[l]=n[c]:delete n[l],l+=d,c+=d;return n}},1285:function(t,e,n){"use strict";var r=n(7908),i=n(1400),o=n(6244);t.exports=function(t){for(var e=r(this),n=o(e),s=arguments.length,a=i(s>1?arguments[1]:void 0,n),l=s>2?arguments[2]:void 0,c=void 0===l?n:i(l,n);c>a;)e[a++]=t;return e}},8533:function(t,e,n){"use strict";var r=n(2092).forEach,i=n(2133)("forEach");t.exports=i?[].forEach:function(t){return r(this,t,arguments.length>1?arguments[1]:void 0)}},7745:function(t,e,n){var r=n(6244);t.exports=function(t,e){for(var n=0,i=r(e),o=new t(i);i>n;)o[n]=e[n++];return o}},8457:function(t,e,n){"use strict";var r=n(7854),i=n(9974),o=n(6916),s=n(7908),a=n(3411),l=n(7659),c=n(4411),u=n(6244),A=n(6135),d=n(8554),h=n(1246),f=r.Array;t.exports=function(t){var e=s(t),n=c(this),r=arguments.length,p=r>1?arguments[1]:void 0,g=void 0!==p;g&&(p=i(p,r>2?arguments[2]:void 0));var m,v,y,C,b,E,w=h(e),T=0;if(!w||this==f&&l(w))for(m=u(e),v=n?new this(m):f(m);m>T;T++)E=g?p(e[T],T):e[T],A(v,T,E);else for(b=(C=d(e,w)).next,v=n?new this:[];!(y=o(b,C)).done;T++)E=g?a(C,p,[y.value,T],!0):y.value,A(v,T,E);return v.length=T,v}},1318:function(t,e,n){var r=n(5656),i=n(1400),o=n(6244),s=function(t){return function(e,n,s){var a,l=r(e),c=o(l),u=i(s,c);if(t&&n!=n){for(;c>u;)if((a=l[u++])!=a)return!0}else for(;c>u;u++)if((t||u in l)&&l[u]===n)return t||u||0;return!t&&-1}};t.exports={includes:s(!0),indexOf:s(!1)}},2092:function(t,e,n){var r=n(9974),i=n(1702),o=n(8361),s=n(7908),a=n(6244),l=n(5417),c=i([].push),u=function(t){var e=1==t,n=2==t,i=3==t,u=4==t,A=6==t,d=7==t,h=5==t||A;return function(f,p,g,m){for(var v,y,C=s(f),b=o(C),E=r(p,g),w=a(b),T=0,S=m||l,k=e?S(f,w):n||d?S(f,0):void 0;w>T;T++)if((h||T in b)&&(y=E(v=b[T],T,C),t))if(e)k[T]=y;else if(y)switch(t){case 3:return!0;case 5:return v;case 6:return T;case 2:c(k,v)}else switch(t){case 4:return!1;case 7:c(k,v)}return A?-1:i||u?u:k}};t.exports={forEach:u(0),map:u(1),filter:u(2),some:u(3),every:u(4),find:u(5),findIndex:u(6),filterReject:u(7)}},6583:function(t,e,n){"use strict";var r=n(2104),i=n(5656),o=n(9303),s=n(6244),a=n(2133),l=Math.min,c=[].lastIndexOf,u=!!c&&1/[1].lastIndexOf(1,-0)<0,A=a("lastIndexOf"),d=u||!A;t.exports=d?function(t){if(u)return r(c,this,arguments)||0;var e=i(this),n=s(e),a=n-1;for(arguments.length>1&&(a=l(a,o(arguments[1]))),a<0&&(a=n+a);a>=0;a--)if(a in e&&e[a]===t)return a||0;return-1}:c},1194:function(t,e,n){var r=n(7293),i=n(5112),o=n(7392),s=i("species");t.exports=function(t){return o>=51||!r((function(){var e=[];return(e.constructor={})[s]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}},2133:function(t,e,n){"use strict";var r=n(7293);t.exports=function(t,e){var n=[][t];return!!n&&r((function(){n.call(null,e||function(){throw 1},1)}))}},3671:function(t,e,n){var r=n(7854),i=n(9662),o=n(7908),s=n(8361),a=n(6244),l=r.TypeError,c=function(t){return function(e,n,r,c){i(n);var u=o(e),A=s(u),d=a(u),h=t?d-1:0,f=t?-1:1;if(r<2)for(;;){if(h in A){c=A[h],h+=f;break}if(h+=f,t?h<0:d<=h)throw l("Reduce of empty array with no initial value")}for(;t?h>=0:d>h;h+=f)h in A&&(c=n(c,A[h],h,u));return c}};t.exports={left:c(!1),right:c(!0)}},1589:function(t,e,n){var r=n(7854),i=n(1400),o=n(6244),s=n(6135),a=r.Array,l=Math.max;t.exports=function(t,e,n){for(var r=o(t),c=i(e,r),u=i(void 0===n?r:n,r),A=a(l(u-c,0)),d=0;c0;)t[r]=t[--r];r!==o++&&(t[r]=n)}return t},a=function(t,e,n,r){for(var i=e.length,o=n.length,s=0,a=0;s1?arguments[1]:void 0);e=e?e.next:n.first;)for(r(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!v(this,t)}}),o(h,n?{get:function(t){var e=v(this,t);return e&&e.value},set:function(t,e){return m(this,0===t?0:t,e)}}:{add:function(t){return m(this,t=0===t?0:t,t)}}),A&&r(h,"size",{get:function(){return g(this).size}}),u},setStrong:function(t,e,n){var r=e+" Iterator",i=p(e),o=p(r);c(t,e,(function(t,e){f(this,{type:r,target:t,state:i(t),kind:e,last:void 0})}),(function(){for(var t=o(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?"keys"==e?{value:n.key,done:!1}:"values"==e?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(t.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),u(e)}}},9320:function(t,e,n){"use strict";var r=n(1702),i=n(2248),o=n(2423).getWeakData,s=n(9670),a=n(111),l=n(5787),c=n(408),u=n(2092),A=n(2597),d=n(9909),h=d.set,f=d.getterFor,p=u.find,g=u.findIndex,m=r([].splice),v=0,y=function(t){return t.frozen||(t.frozen=new C)},C=function(){this.entries=[]},b=function(t,e){return p(t.entries,(function(t){return t[0]===e}))};C.prototype={get:function(t){var e=b(this,t);if(e)return e[1]},has:function(t){return!!b(this,t)},set:function(t,e){var n=b(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=g(this.entries,(function(e){return e[0]===t}));return~e&&m(this.entries,e,1),!!~e}},t.exports={getConstructor:function(t,e,n,r){var u=t((function(t,i){l(t,d),h(t,{type:e,id:v++,frozen:void 0}),null!=i&&c(i,t[r],{that:t,AS_ENTRIES:n})})),d=u.prototype,p=f(e),g=function(t,e,n){var r=p(t),i=o(s(e),!0);return!0===i?y(r).set(e,n):i[r.id]=n,t};return i(d,{delete:function(t){var e=p(this);if(!a(t))return!1;var n=o(t);return!0===n?y(e).delete(t):n&&A(n,e.id)&&delete n[e.id]},has:function(t){var e=p(this);if(!a(t))return!1;var n=o(t);return!0===n?y(e).has(t):n&&A(n,e.id)}}),i(d,n?{get:function(t){var e=p(this);if(a(t)){var n=o(t);return!0===n?y(e).get(t):n?n[e.id]:void 0}},set:function(t,e){return g(this,t,e)}}:{add:function(t){return g(this,t,!0)}}),u}}},7710:function(t,e,n){"use strict";var r=n(2109),i=n(7854),o=n(1702),s=n(4705),a=n(1320),l=n(2423),c=n(408),u=n(5787),A=n(614),d=n(111),h=n(7293),f=n(7072),p=n(8003),g=n(9587);t.exports=function(t,e,n){var m=-1!==t.indexOf("Map"),v=-1!==t.indexOf("Weak"),y=m?"set":"add",C=i[t],b=C&&C.prototype,E=C,w={},T=function(t){var e=o(b[t]);a(b,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(v&&!d(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return v&&!d(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(v&&!d(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if(s(t,!A(C)||!(v||b.forEach&&!h((function(){(new C).entries().next()})))))E=n.getConstructor(e,t,m,y),l.enable();else if(s(t,!0)){var S=new E,k=S[y](v?{}:-0,1)!=S,L=h((function(){S.has(1)})),x=f((function(t){new C(t)})),I=!v&&h((function(){for(var t=new C,e=5;e--;)t[y](e,e);return!t.has(-0)}));x||((E=e((function(t,e){u(t,b);var n=g(new C,t,E);return null!=e&&c(e,n[y],{that:n,AS_ENTRIES:m}),n}))).prototype=b,b.constructor=E),(L||I)&&(T("delete"),T("has"),m&&T("get")),(I||k)&&T(y),v&&b.clear&&delete b.clear}return w[t]=E,r({global:!0,forced:E!=C},w),p(E,t),v||n.setStrong(E,t,m),E}},9920:function(t,e,n){var r=n(2597),i=n(3887),o=n(1236),s=n(3070);t.exports=function(t,e,n){for(var a=i(e),l=s.f,c=o.f,u=0;u"+l+""}},4994:function(t,e,n){"use strict";var r=n(3383).IteratorPrototype,i=n(30),o=n(9114),s=n(8003),a=n(7497),l=function(){return this};t.exports=function(t,e,n,c){var u=e+" Iterator";return t.prototype=i(r,{next:o(+!c,n)}),s(t,u,!1,!0),a[u]=l,t}},8880:function(t,e,n){var r=n(9781),i=n(3070),o=n(9114);t.exports=r?function(t,e,n){return i.f(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},9114:function(t){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},6135:function(t,e,n){"use strict";var r=n(4948),i=n(3070),o=n(9114);t.exports=function(t,e,n){var s=r(e);s in t?i.f(t,s,o(0,n)):t[s]=n}},5573:function(t,e,n){"use strict";var r=n(7854),i=n(1702),o=n(7293),s=n(6650).start,a=r.RangeError,l=Math.abs,c=Date.prototype,u=c.toISOString,A=i(c.getTime),d=i(c.getUTCDate),h=i(c.getUTCFullYear),f=i(c.getUTCHours),p=i(c.getUTCMilliseconds),g=i(c.getUTCMinutes),m=i(c.getUTCMonth),v=i(c.getUTCSeconds);t.exports=o((function(){return"0385-07-25T07:06:39.999Z"!=u.call(new Date(-50000000000001))}))||!o((function(){u.call(new Date(NaN))}))?function(){if(!isFinite(A(this)))throw a("Invalid time value");var t=this,e=h(t),n=p(t),r=e<0?"-":e>9999?"+":"";return r+s(l(e),r?6:4,0)+"-"+s(m(t)+1,2,0)+"-"+s(d(t),2,0)+"T"+s(f(t),2,0)+":"+s(g(t),2,0)+":"+s(v(t),2,0)+"."+s(n,3,0)+"Z"}:u},8709:function(t,e,n){"use strict";var r=n(7854),i=n(9670),o=n(2140),s=r.TypeError;t.exports=function(t){if(i(this),"string"===t||"default"===t)t="string";else if("number"!==t)throw s("Incorrect hint");return o(this,t)}},654:function(t,e,n){"use strict";var r=n(2109),i=n(6916),o=n(1913),s=n(6530),a=n(614),l=n(4994),c=n(9518),u=n(7674),A=n(8003),d=n(8880),h=n(1320),f=n(5112),p=n(7497),g=n(3383),m=s.PROPER,v=s.CONFIGURABLE,y=g.IteratorPrototype,C=g.BUGGY_SAFARI_ITERATORS,b=f("iterator"),E="keys",w="values",T="entries",S=function(){return this};t.exports=function(t,e,n,s,f,g,k){l(n,e,s);var L,x,I,R=function(t){if(t===f&&O)return O;if(!C&&t in P)return P[t];switch(t){case E:case w:case T:return function(){return new n(this,t)}}return function(){return new n(this)}},D=e+" Iterator",B=!1,P=t.prototype,M=P[b]||P["@@iterator"]||f&&P[f],O=!C&&M||R(f),F="Array"==e&&P.entries||M;if(F&&(L=c(F.call(new t)))!==Object.prototype&&L.next&&(o||c(L)===y||(u?u(L,y):a(L[b])||h(L,b,S)),A(L,D,!0,!0),o&&(p[D]=S)),m&&f==w&&M&&M.name!==w&&(!o&&v?d(P,"name",w):(B=!0,O=function(){return i(M,this)})),f)if(x={values:R(w),keys:g?O:R(E),entries:R(T)},k)for(I in x)(C||B||!(I in P))&&h(P,I,x[I]);else r({target:e,proto:!0,forced:C||B},x);return o&&!k||P[b]===O||h(P,b,O,{name:f}),p[e]=O,x}},7235:function(t,e,n){var r=n(857),i=n(2597),o=n(6061),s=n(3070).f;t.exports=function(t){var e=r.Symbol||(r.Symbol={});i(e,t)||s(e,t,{value:o.f(t)})}},9781:function(t,e,n){var r=n(7293);t.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},317:function(t,e,n){var r=n(7854),i=n(111),o=r.document,s=i(o)&&i(o.createElement);t.exports=function(t){return s?o.createElement(t):{}}},3678:function(t){t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8324:function(t){t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},8509:function(t,e,n){var r=n(317)("span").classList,i=r&&r.constructor&&r.constructor.prototype;t.exports=i===Object.prototype?void 0:i},8886:function(t,e,n){var r=n(8113).match(/firefox\/(\d+)/i);t.exports=!!r&&+r[1]},7871:function(t){t.exports="object"==typeof window},256:function(t,e,n){var r=n(8113);t.exports=/MSIE|Trident/.test(r)},1528:function(t,e,n){var r=n(8113),i=n(7854);t.exports=/ipad|iphone|ipod/i.test(r)&&void 0!==i.Pebble},8334:function(t,e,n){var r=n(8113);t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(r)},5268:function(t,e,n){var r=n(4326),i=n(7854);t.exports="process"==r(i.process)},1036:function(t,e,n){var r=n(8113);t.exports=/web0s(?!.*chrome)/i.test(r)},8113:function(t,e,n){var r=n(5005);t.exports=r("navigator","userAgent")||""},7392:function(t,e,n){var r,i,o=n(7854),s=n(8113),a=o.process,l=o.Deno,c=a&&a.versions||l&&l.version,u=c&&c.v8;u&&(i=(r=u.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!i&&s&&(!(r=s.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=s.match(/Chrome\/(\d+)/))&&(i=+r[1]),t.exports=i},8008:function(t,e,n){var r=n(8113).match(/AppleWebKit\/(\d+)\./);t.exports=!!r&&+r[1]},748:function(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2914:function(t,e,n){var r=n(7293),i=n(9114);t.exports=!r((function(){var t=Error("a");return!("stack"in t)||(Object.defineProperty(t,"stack",i(1,7)),7!==t.stack)}))},7762:function(t,e,n){"use strict";var r=n(9781),i=n(7293),o=n(9670),s=n(30),a=n(6277),l=Error.prototype.toString,c=i((function(){if(r){var t=s(Object.defineProperty({},"name",{get:function(){return this===t}}));if("true"!==l.call(t))return!0}return"2: 1"!==l.call({message:1,name:2})||"Error"!==l.call({})}));t.exports=c?function(){var t=o(this),e=a(t.name,"Error"),n=a(t.message);return e?n?e+": "+n:e:n}:l},2109:function(t,e,n){var r=n(7854),i=n(1236).f,o=n(8880),s=n(1320),a=n(3505),l=n(9920),c=n(4705);t.exports=function(t,e){var n,u,A,d,h,f=t.target,p=t.global,g=t.stat;if(n=p?r:g?r[f]||a(f,{}):(r[f]||{}).prototype)for(u in e){if(d=e[u],A=t.noTargetGet?(h=i(n,u))&&h.value:n[u],!c(p?u:f+(g?".":"#")+u,t.forced)&&void 0!==A){if(typeof d==typeof A)continue;l(d,A)}(t.sham||A&&A.sham)&&o(d,"sham",!0),s(n,u,d,t)}}},7293:function(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},7007:function(t,e,n){"use strict";n(4916);var r=n(1702),i=n(1320),o=n(2261),s=n(7293),a=n(5112),l=n(8880),c=a("species"),u=RegExp.prototype;t.exports=function(t,e,n,A){var d=a(t),h=!s((function(){var e={};return e[d]=function(){return 7},7!=""[t](e)})),f=h&&!s((function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[c]=function(){return n},n.flags="",n[d]=/./[d]),n.exec=function(){return e=!0,null},n[d](""),!e}));if(!h||!f||n){var p=r(/./[d]),g=e(d,""[t],(function(t,e,n,i,s){var a=r(t),l=e.exec;return l===o||l===u.exec?h&&!s?{done:!0,value:p(e,n,i)}:{done:!0,value:a(n,e,i)}:{done:!1}}));i(String.prototype,t,g[0]),i(u,d,g[1])}A&&l(u[d],"sham",!0)}},6790:function(t,e,n){"use strict";var r=n(7854),i=n(3157),o=n(6244),s=n(9974),a=r.TypeError,l=function(t,e,n,r,c,u,A,d){for(var h,f,p=c,g=0,m=!!A&&s(A,d);g0&&i(h))f=o(h),p=l(t,e,h,f,p,u-1)-1;else{if(p>=9007199254740991)throw a("Exceed the acceptable array length");t[p]=h}p++}g++}return p};t.exports=l},6677:function(t,e,n){var r=n(7293);t.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},2104:function(t,e,n){var r=n(4374),i=Function.prototype,o=i.apply,s=i.call;t.exports="object"==typeof Reflect&&Reflect.apply||(r?s.bind(o):function(){return s.apply(o,arguments)})},9974:function(t,e,n){var r=n(1702),i=n(9662),o=n(4374),s=r(r.bind);t.exports=function(t,e){return i(t),void 0===e?t:o?s(t,e):function(){return t.apply(e,arguments)}}},4374:function(t,e,n){var r=n(7293);t.exports=!r((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},7065:function(t,e,n){"use strict";var r=n(7854),i=n(1702),o=n(9662),s=n(111),a=n(2597),l=n(206),c=n(4374),u=r.Function,A=i([].concat),d=i([].join),h={},f=function(t,e,n){if(!a(h,e)){for(var r=[],i=0;i]*>)/g,u=/\$([$&'`]|\d{1,2})/g;t.exports=function(t,e,n,r,A,d){var h=n+t.length,f=r.length,p=u;return void 0!==A&&(A=i(A),p=c),a(d,p,(function(i,a){var c;switch(s(a,0)){case"$":return"$";case"&":return t;case"`":return l(e,0,n);case"'":return l(e,h);case"<":c=A[l(a,1,-1)];break;default:var u=+a;if(0===u)return i;if(u>f){var d=o(u/10);return 0===d?i:d<=f?void 0===r[d-1]?s(a,1):r[d-1]+s(a,1):i}c=r[u-1]}return void 0===c?"":c}))}},7854:function(t,e,n){var r=function(t){return t&&t.Math==Math&&t};t.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},2597:function(t,e,n){var r=n(1702),i=n(7908),o=r({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return o(i(t),e)}},3501:function(t){t.exports={}},842:function(t,e,n){var r=n(7854);t.exports=function(t,e){var n=r.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))}},490:function(t,e,n){var r=n(5005);t.exports=r("document","documentElement")},4664:function(t,e,n){var r=n(9781),i=n(7293),o=n(317);t.exports=!r&&!i((function(){return 7!=Object.defineProperty(o("div"),"a",{get:function(){return 7}}).a}))},1179:function(t,e,n){var r=n(7854).Array,i=Math.abs,o=Math.pow,s=Math.floor,a=Math.log,l=Math.LN2;t.exports={pack:function(t,e,n){var c,u,A,d=r(n),h=8*n-e-1,f=(1<>1,g=23===e?o(2,-24)-o(2,-77):0,m=t<0||0===t&&1/t<0?1:0,v=0;for((t=i(t))!=t||t===1/0?(u=t!=t?1:0,c=f):(c=s(a(t)/l),t*(A=o(2,-c))<1&&(c--,A*=2),(t+=c+p>=1?g/A:g*o(2,1-p))*A>=2&&(c++,A/=2),c+p>=f?(u=0,c=f):c+p>=1?(u=(t*A-1)*o(2,e),c+=p):(u=t*o(2,p-1)*o(2,e),c=0));e>=8;)d[v++]=255&u,u/=256,e-=8;for(c=c<0;)d[v++]=255&c,c/=256,h-=8;return d[--v]|=128*m,d},unpack:function(t,e){var n,r=t.length,i=8*r-e-1,s=(1<>1,l=i-7,c=r-1,u=t[c--],A=127&u;for(u>>=7;l>0;)A=256*A+t[c--],l-=8;for(n=A&(1<<-l)-1,A>>=-l,l+=e;l>0;)n=256*n+t[c--],l-=8;if(0===A)A=1-a;else{if(A===s)return n?NaN:u?-1/0:1/0;n+=o(2,e),A-=a}return(u?-1:1)*n*o(2,A-e)}}},8361:function(t,e,n){var r=n(7854),i=n(1702),o=n(7293),s=n(4326),a=r.Object,l=i("".split);t.exports=o((function(){return!a("z").propertyIsEnumerable(0)}))?function(t){return"String"==s(t)?l(t,""):a(t)}:a},9587:function(t,e,n){var r=n(614),i=n(111),o=n(7674);t.exports=function(t,e,n){var s,a;return o&&r(s=e.constructor)&&s!==n&&i(a=s.prototype)&&a!==n.prototype&&o(t,a),t}},2788:function(t,e,n){var r=n(1702),i=n(614),o=n(5465),s=r(Function.toString);i(o.inspectSource)||(o.inspectSource=function(t){return s(t)}),t.exports=o.inspectSource},8340:function(t,e,n){var r=n(111),i=n(8880);t.exports=function(t,e){r(e)&&"cause"in e&&i(t,"cause",e.cause)}},2423:function(t,e,n){var r=n(2109),i=n(1702),o=n(3501),s=n(111),a=n(2597),l=n(3070).f,c=n(8006),u=n(1156),A=n(2050),d=n(9711),h=n(6677),f=!1,p=d("meta"),g=0,m=function(t){l(t,p,{value:{objectID:"O"+g++,weakData:{}}})},v=t.exports={enable:function(){v.enable=function(){},f=!0;var t=c.f,e=i([].splice),n={};n[p]=1,t(n).length&&(c.f=function(n){for(var r=t(n),i=0,o=r.length;iv;v++)if((C=I(t[v]))&&u(g,C))return C;return new p(!1)}r=A(t,m)}for(b=r.next;!(E=o(b,r)).done;){try{C=I(E.value)}catch(t){h(r,"throw",t)}if("object"==typeof C&&C&&u(g,C))return C}return new p(!1)}},9212:function(t,e,n){var r=n(6916),i=n(9670),o=n(8173);t.exports=function(t,e,n){var s,a;i(t);try{if(!(s=o(t,"return"))){if("throw"===e)throw n;return n}s=r(s,t)}catch(t){a=!0,s=t}if("throw"===e)throw n;if(a)throw s;return i(s),n}},3383:function(t,e,n){"use strict";var r,i,o,s=n(7293),a=n(614),l=n(30),c=n(9518),u=n(1320),A=n(5112),d=n(1913),h=A("iterator"),f=!1;[].keys&&("next"in(o=[].keys())?(i=c(c(o)))!==Object.prototype&&(r=i):f=!0),null==r||s((function(){var t={};return r[h].call(t)!==t}))?r={}:d&&(r=l(r)),a(r[h])||u(r,h,(function(){return this})),t.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:f}},7497:function(t){t.exports={}},6244:function(t,e,n){var r=n(7466);t.exports=function(t){return r(t.length)}},6736:function(t){var e=Math.expm1,n=Math.exp;t.exports=!e||e(10)>22025.465794806718||e(10)<22025.465794806718||-2e-17!=e(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:n(t)-1}:e},6130:function(t,e,n){var r=n(4310),i=Math.abs,o=Math.pow,s=o(2,-52),a=o(2,-23),l=o(2,127)*(2-a),c=o(2,-126);t.exports=Math.fround||function(t){var e,n,o=i(t),u=r(t);return ol||n!=n?u*(1/0):u*n}},202:function(t){var e=Math.log,n=Math.LOG10E;t.exports=Math.log10||function(t){return e(t)*n}},6513:function(t){var e=Math.log;t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:e(1+t)}},4310:function(t){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},5948:function(t,e,n){var r,i,o,s,a,l,c,u,A=n(7854),d=n(9974),h=n(1236).f,f=n(261).set,p=n(8334),g=n(1528),m=n(1036),v=n(5268),y=A.MutationObserver||A.WebKitMutationObserver,C=A.document,b=A.process,E=A.Promise,w=h(A,"queueMicrotask"),T=w&&w.value;T||(r=function(){var t,e;for(v&&(t=b.domain)&&t.exit();i;){e=i.fn,i=i.next;try{e()}catch(t){throw i?s():o=void 0,t}}o=void 0,t&&t.enter()},p||v||m||!y||!C?!g&&E&&E.resolve?((c=E.resolve(void 0)).constructor=E,u=d(c.then,c),s=function(){u(r)}):v?s=function(){b.nextTick(r)}:(f=d(f,A),s=function(){f(r)}):(a=!0,l=C.createTextNode(""),new y(r).observe(l,{characterData:!0}),s=function(){l.data=a=!a})),t.exports=T||function(t){var e={fn:t,next:void 0};o&&(o.next=e),i||(i=e,s()),o=e}},3366:function(t,e,n){var r=n(7854);t.exports=r.Promise},133:function(t,e,n){var r=n(7392),i=n(7293);t.exports=!!Object.getOwnPropertySymbols&&!i((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},590:function(t,e,n){var r=n(7293),i=n(5112),o=n(1913),s=i("iterator");t.exports=!r((function(){var t=new URL("b?a=1&b=2&c=3","http://a"),e=t.searchParams,n="";return t.pathname="c%20d",e.forEach((function(t,r){e.delete("b"),n+=r+t})),o&&!t.toJSON||!e.sort||"http://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[s]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))},8536:function(t,e,n){var r=n(7854),i=n(614),o=n(2788),s=r.WeakMap;t.exports=i(s)&&/native code/.test(o(s))},8523:function(t,e,n){"use strict";var r=n(9662),i=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=r(e),this.reject=r(n)};t.exports.f=function(t){return new i(t)}},6277:function(t,e,n){var r=n(1340);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:r(t)}},3929:function(t,e,n){var r=n(7854),i=n(7850),o=r.TypeError;t.exports=function(t){if(i(t))throw o("The method doesn't accept regular expressions");return t}},7023:function(t,e,n){var r=n(7854).isFinite;t.exports=Number.isFinite||function(t){return"number"==typeof t&&r(t)}},2814:function(t,e,n){var r=n(7854),i=n(7293),o=n(1702),s=n(1340),a=n(3111).trim,l=n(1361),c=o("".charAt),u=r.parseFloat,A=r.Symbol,d=A&&A.iterator,h=1/u(l+"-0")!=-1/0||d&&!i((function(){u(Object(d))}));t.exports=h?function(t){var e=a(s(t)),n=u(e);return 0===n&&"-"==c(e,0)?-0:n}:u},3009:function(t,e,n){var r=n(7854),i=n(7293),o=n(1702),s=n(1340),a=n(3111).trim,l=n(1361),c=r.parseInt,u=r.Symbol,A=u&&u.iterator,d=/^[+-]?0x/i,h=o(d.exec),f=8!==c(l+"08")||22!==c(l+"0x16")||A&&!i((function(){c(Object(A))}));t.exports=f?function(t,e){var n=a(s(t));return c(n,e>>>0||(h(d,n)?16:10))}:c},1574:function(t,e,n){"use strict";var r=n(9781),i=n(1702),o=n(6916),s=n(7293),a=n(1956),l=n(5181),c=n(5296),u=n(7908),A=n(8361),d=Object.assign,h=Object.defineProperty,f=i([].concat);t.exports=!d||s((function(){if(r&&1!==d({b:1},d(h({},"a",{enumerable:!0,get:function(){h(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),i="abcdefghijklmnopqrst";return t[n]=7,i.split("").forEach((function(t){e[t]=t})),7!=d({},t)[n]||a(d({},e)).join("")!=i}))?function(t,e){for(var n=u(t),i=arguments.length,s=1,d=l.f,h=c.f;i>s;)for(var p,g=A(arguments[s++]),m=d?f(a(g),d(g)):a(g),v=m.length,y=0;v>y;)p=m[y++],r&&!o(h,g,p)||(n[p]=g[p]);return n}:d},30:function(t,e,n){var r,i=n(9670),o=n(6048),s=n(748),a=n(3501),l=n(490),c=n(317),u=n(6200)("IE_PROTO"),A=function(){},d=function(t){return" @@ -319,7 +319,9 @@ You need to place the `dash.js` first, and then `ovenplayer.js` as shown below: ### Initialize for HLS -OvenPlayer will use third party to initialize HLS [hls.js](https://github.com/video-dev/hls.js). +If you want to play HLS, you need the [hls.js](https://github.com/video-dev/hls.js). + +You need to place the `hls.js` first, and then `ovenplayer.js` as shown below: ```markup @@ -336,6 +338,9 @@ OvenPlayer will use third party to initialize HLS [hls.js](https://github.com/vi
+ + + diff --git a/package-lock.json b/package-lock.json index 25d1dae9..23c47965 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,15 @@ { "name": "ovenplayer", - "version": "0.10.31", + "version": "0.10.27", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ovenplayer", - "version": "0.10.31", + "version": "0.10.26", "license": "MIT", "dependencies": { "core-js": "^3.16.3", - "hls.js": "^1.4.12", "whatwg-fetch": "^3.6.2" }, "devDependencies": { @@ -2145,35 +2144,26 @@ } }, "node_modules/browserslist": { - "version": "4.22.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", - "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", + "version": "4.19.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz", + "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==", "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], "dependencies": { - "caniuse-lite": "^1.0.30001541", - "electron-to-chromium": "^1.4.535", - "node-releases": "^2.0.13", - "update-browserslist-db": "^1.0.13" + "caniuse-lite": "^1.0.30001286", + "electron-to-chromium": "^1.4.17", + "escalade": "^3.1.1", + "node-releases": "^2.0.1", + "picocolors": "^1.0.0" }, "bin": { "browserslist": "cli.js" }, "engines": { "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" } }, "node_modules/buffer-from": { @@ -2205,24 +2195,14 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001546", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001546.tgz", - "integrity": "sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==", + "version": "1.0.30001312", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz", + "integrity": "sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ==", "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ] + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + } }, "node_modules/chalk": { "version": "2.4.2", @@ -2394,18 +2374,28 @@ } }, "node_modules/core-js-compat": { - "version": "3.33.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.33.0.tgz", - "integrity": "sha512-0w4LcLXsVEuNkIqwjjf9rjCoPhK8uqA4tMRh4Ge26vfLtUutshn+aRJU21I9LCJlh2QQHfisNToLjw1XEJLTWw==", + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.0.tgz", + "integrity": "sha512-OSXseNPSK2OPJa6GdtkMz/XxeXx8/CJvfhQWTqd6neuUraujcL4jVsjkLQz1OWnax8xVQJnRPe0V2jqNWORA+A==", "dev": true, "dependencies": { - "browserslist": "^4.22.1" + "browserslist": "^4.19.1", + "semver": "7.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" } }, + "node_modules/core-js-compat/node_modules/semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -2447,9 +2437,9 @@ } }, "node_modules/css-loader/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -2549,9 +2539,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.543", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.543.tgz", - "integrity": "sha512-t2ZP4AcGE0iKCCQCBx/K2426crYdxD3YU6l0uK2EO3FZH0pbC4pFz/sZm2ruZsND6hQBTcDWWlo/MLpiOdif5g==", + "version": "1.4.68", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.68.tgz", + "integrity": "sha512-cId+QwWrV8R1UawO6b9BR1hnkJ4EJPCPAr4h315vliHUtVUJDk39Sg1PMNnaWKfj5x+93ssjeJ9LKL6r8LaMiA==", "dev": true }, "node_modules/emojis-list": { @@ -3056,11 +3046,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/hls.js": { - "version": "1.4.12", - "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.4.12.tgz", - "integrity": "sha512-1RBpx2VihibzE3WE9kGoVCtrhhDWTzydzElk/kyRbEOLnb1WIE+3ZabM/L8BqKFTCL3pUy4QzhXgD1Q6Igr1JA==" - }, "node_modules/hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -3389,10 +3374,13 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, "bin": { "json5": "lib/cli.js" }, @@ -3479,9 +3467,9 @@ } }, "node_modules/less/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true, "optional": true, "bin": { @@ -3522,9 +3510,9 @@ } }, "node_modules/loader-utils/node_modules/json5": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", - "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "dev": true, "dependencies": { "minimist": "^1.2.0" @@ -3693,16 +3681,10 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", + "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -3754,9 +3736,9 @@ "dev": true }, "node_modules/node-releases": { - "version": "2.0.13", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", - "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", + "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", "dev": true }, "node_modules/npm-run-path": { @@ -3955,31 +3937,21 @@ } }, "node_modules/postcss": { - "version": "8.4.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", - "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "version": "8.4.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.6.tgz", + "integrity": "sha512-OovjwIzs9Te46vlEx7+uXB0PLijpwjXGKXjVGGPIGubGpq7uh5Xgf6D6FiJ/SzJMBosHDp6a2hiXOS97iBXcaA==", "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], "dependencies": { - "nanoid": "^3.3.6", + "nanoid": "^3.2.0", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, "engines": { "node": "^10 || ^12 || >=14" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" } }, "node_modules/postcss-modules-extract-imports": { @@ -4302,9 +4274,9 @@ } }, "node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -4713,36 +4685,6 @@ "node": ">= 0.8" } }, - "node_modules/update-browserslist-db": { - "version": "1.0.13", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", - "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -6578,15 +6520,16 @@ } }, "browserslist": { - "version": "4.22.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", - "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", + "version": "4.19.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz", + "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001541", - "electron-to-chromium": "^1.4.535", - "node-releases": "^2.0.13", - "update-browserslist-db": "^1.0.13" + "caniuse-lite": "^1.0.30001286", + "electron-to-chromium": "^1.4.17", + "escalade": "^3.1.1", + "node-releases": "^2.0.1", + "picocolors": "^1.0.0" } }, "buffer-from": { @@ -6612,9 +6555,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001546", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001546.tgz", - "integrity": "sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==", + "version": "1.0.30001312", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz", + "integrity": "sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ==", "dev": true }, "chalk": { @@ -6749,12 +6692,21 @@ "integrity": "sha512-YUdI3fFu4TF/2WykQ2xzSiTQdldLB4KVuL9WeAy5XONZYt5Cun/fpQvctoKbCgvPhmzADeesTk/j2Rdx77AcKQ==" }, "core-js-compat": { - "version": "3.33.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.33.0.tgz", - "integrity": "sha512-0w4LcLXsVEuNkIqwjjf9rjCoPhK8uqA4tMRh4Ge26vfLtUutshn+aRJU21I9LCJlh2QQHfisNToLjw1XEJLTWw==", + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.0.tgz", + "integrity": "sha512-OSXseNPSK2OPJa6GdtkMz/XxeXx8/CJvfhQWTqd6neuUraujcL4jVsjkLQz1OWnax8xVQJnRPe0V2jqNWORA+A==", "dev": true, "requires": { - "browserslist": "^4.22.1" + "browserslist": "^4.19.1", + "semver": "7.0.0" + }, + "dependencies": { + "semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "dev": true + } } }, "cross-spawn": { @@ -6785,9 +6737,9 @@ }, "dependencies": { "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -6853,9 +6805,9 @@ } }, "electron-to-chromium": { - "version": "1.4.543", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.543.tgz", - "integrity": "sha512-t2ZP4AcGE0iKCCQCBx/K2426crYdxD3YU6l0uK2EO3FZH0pbC4pFz/sZm2ruZsND6hQBTcDWWlo/MLpiOdif5g==", + "version": "1.4.68", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.68.tgz", + "integrity": "sha512-cId+QwWrV8R1UawO6b9BR1hnkJ4EJPCPAr4h315vliHUtVUJDk39Sg1PMNnaWKfj5x+93ssjeJ9LKL6r8LaMiA==", "dev": true }, "emojis-list": { @@ -7246,11 +7198,6 @@ "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", "dev": true }, - "hls.js": { - "version": "1.4.12", - "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.4.12.tgz", - "integrity": "sha512-1RBpx2VihibzE3WE9kGoVCtrhhDWTzydzElk/kyRbEOLnb1WIE+3ZabM/L8BqKFTCL3pUy4QzhXgD1Q6Igr1JA==" - }, "hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -7485,10 +7432,13 @@ "dev": true }, "json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } }, "kind-of": { "version": "6.0.3", @@ -7532,9 +7482,9 @@ } }, "semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true, "optional": true }, @@ -7574,9 +7524,9 @@ }, "dependencies": { "json5": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", - "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "dev": true, "requires": { "minimist": "^1.2.0" @@ -7705,9 +7655,9 @@ "dev": true }, "nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", + "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", "dev": true }, "needle": { @@ -7747,9 +7697,9 @@ "dev": true }, "node-releases": { - "version": "2.0.13", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", - "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", + "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", "dev": true }, "npm-run-path": { @@ -7891,12 +7841,12 @@ } }, "postcss": { - "version": "8.4.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", - "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "version": "8.4.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.6.tgz", + "integrity": "sha512-OovjwIzs9Te46vlEx7+uXB0PLijpwjXGKXjVGGPIGubGpq7uh5Xgf6D6FiJ/SzJMBosHDp6a2hiXOS97iBXcaA==", "dev": true, "requires": { - "nanoid": "^3.3.6", + "nanoid": "^3.2.0", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } @@ -8145,9 +8095,9 @@ } }, "semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, "send": { @@ -8446,16 +8396,6 @@ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "dev": true }, - "update-browserslist-db": { - "version": "1.0.13", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", - "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", - "dev": true, - "requires": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" - } - }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index ebac4966..84ee0dd0 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ }, "dependencies": { "core-js": "^3.16.3", - "hls.js": "^1.4.12", "whatwg-fetch": "^3.6.2" } -} +} \ No newline at end of file diff --git a/src/js/api/provider/html5/providers/Hls.js b/src/js/api/provider/html5/providers/Hls.js index 00e98d69..0bc97609 100644 --- a/src/js/api/provider/html5/providers/Hls.js +++ b/src/js/api/provider/html5/providers/Hls.js @@ -1,8 +1,6 @@ /** * Created by hoho on 2018. 6. 7.. */ -import Hls from "hls.js"; - import Provider from "api/provider/html5/Provider"; import { errorTrigger } from "api/provider/utils"; import { @@ -22,9 +20,8 @@ import sizeHumanizer from "utils/sizeHumanizer"; /** * @brief hlsjs provider extended core. - * @param element player element. + * @param container player element. * @param playerConfig config. - * @param adTagUrl url for ad * */ @@ -307,4 +304,4 @@ const HlsProvider = function (element, playerConfig, adTagUrl) { }; -export default HlsProvider; +export default HlsProvider; \ No newline at end of file From 34b6d0980104ced475b452acdefd0f31767a4c22 Mon Sep 17 00:00:00 2001 From: Arkadii Shvartsman Date: Sat, 14 Oct 2023 18:27:04 +0200 Subject: [PATCH 6/8] fetch null fixer --- dist/ovenplayer.js | 2 +- dist/ovenplayer.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/ovenplayer.js b/dist/ovenplayer.js index 4fa01624..09889f76 100644 --- a/dist/ovenplayer.js +++ b/dist/ovenplayer.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.OvenPlayer=t():e.OvenPlayer=t()}(self,(function(){return function(){var e={8445:function(e,t,n){"use strict";n.d(t,{default:function(){return Ar}});var r="0.10.31",o=n(741),i=n.n(o);function a(e){return e?e.replace(/^\s+|\s+$/g,""):""}var A=function(e){if(!e||"rtmp"==e.substr(0,4))return"";var t=function(e){var t="";return/[(,]format=mpd-/i.test(e)?t="mpd":/[(,]format=m3u8-/i.test(e)&&(t="m3u8"),t}(e);return t||((e=e.split("?")[0].split("#")[0]).lastIndexOf(".")>-1?e.substr(e.lastIndexOf(".")+1,e.length).toLowerCase():"")};function s(e){var t=parseInt(e,10);if(!e)return"00:00";var n=Math.floor(t/3600),r=Math.floor((t-3600*n)/60),o=t-3600*n-60*r;return r<10&&(r="0"+r),o<10&&(o="0"+o),n>0?n+":"+r+":"+o:r+":"+o}function c(e,t){if(!e)return 0;if(i().isNumber(e)&&!i().isNaN(e))return e;var n=(e=e.replace(",",".")).split(":"),r=n.length,o=0;if("s"===e.slice(-1))o=parseFloat(e);else if("m"===e.slice(-1))o=60*parseFloat(e);else if("h"===e.slice(-1))o=3600*parseFloat(e);else if(r>1){var a=r-1;4===r&&(t&&(o=parseFloat(n[a])/t),a-=1),o+=parseFloat(n[a]),o+=60*parseFloat(n[a-1]),r>=3&&(o+=3600*parseFloat(n[a-2]))}else o=parseFloat(e);return i().isNaN(o)?0:o}function u(e){var t={},n=e.split("\r\n");1===n.length&&(n=e.split("\n"));var r=1;if(n[0].indexOf(" --\x3e ")>0&&(r=0),n.length>r+1&&n[r+1]){var o=n[r],i=o.indexOf(" --\x3e ");i>0&&(t.start=c(o.substr(0,i)),t.end=c(o.substr(i+5)),t.text=n.slice(r+1).join("\r\n"))}return t}var l=window.VTTCue,f={"":!0,lr:!0,rl:!0},p={start:!0,middle:!0,end:!0,left:!0,right:!0};function d(e){return"string"==typeof e&&!!p[e.toLowerCase()]&&e.toLowerCase()}function g(e){for(var t=1;t100)throw new Error("Position must be between 0 and 100.");C=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"positionAlign",g({},i,{get:function(){return y},set:function(e){var t=d(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(r,"size",g({},i,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"align",g({},i,{get:function(){return w},set:function(e){var t=d(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),r.displayState=void 0,o)return r}).prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)});var h=l,v={"":!0,up:!0};function m(e){return"number"==typeof e&&e>=0&&e<=100}var C=function(){var e=100,t=3,n=0,r=100,o=0,i=100,a="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return e},set:function(t){if(!m(t))throw new Error("Width must be between 0 and 100.");e=t}},lines:{enumerable:!0,get:function(){return t},set:function(e){if("number"!=typeof e)throw new TypeError("Lines must be set to a number.");t=e}},regionAnchorY:{enumerable:!0,get:function(){return r},set:function(e){if(!m(e))throw new Error("RegionAnchorX must be between 0 and 100.");r=e}},regionAnchorX:{enumerable:!0,get:function(){return n},set:function(e){if(!m(e))throw new Error("RegionAnchorY must be between 0 and 100.");n=e}},viewportAnchorY:{enumerable:!0,get:function(){return i},set:function(e){if(!m(e))throw new Error("ViewportAnchorY must be between 0 and 100.");i=e}},viewportAnchorX:{enumerable:!0,get:function(){return o},set:function(e){if(!m(e))throw new Error("ViewportAnchorX must be between 0 and 100.");o=e}},scroll:{enumerable:!0,get:function(){return a},set:function(e){var t=function(e){return"string"==typeof e&&!!v[e.toLowerCase()]&&e.toLowerCase()}(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");a=t}}})},y=function(){};function b(e,t){return void 0===t&&(t=1),"rgba("+[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16),t].join(",")+")"}var w=1;function E(e,t,n){switch(n){case"webvtt.font.color":case"webvtt.font.opacity":var r=Services.prefs.getCharPref("webvtt.font.color"),o=Services.prefs.getIntPref("webvtt.font.opacity")/100;B.fontSet=b(r,o);break;case"webvtt.font.scale":w=Services.prefs.getIntPref("webvtt.font.scale")/100;break;case"webvtt.bg.color":case"webvtt.bg.opacity":var i=Services.prefs.getCharPref("webvtt.bg.color"),a=Services.prefs.getIntPref("webvtt.bg.opacity")/100;B.backgroundSet=b(i,a);break;case"webvtt.edge.color":case"webvtt.edge.type":var A=Services.prefs.getIntPref("webvtt.edge.type"),s=Services.prefs.getCharPref("webvtt.edge.color");B.edgeSet=["","0px 0px ","4px 4px 4px ","-2px -2px ","2px 2px "][A]+b(s)}}if("undefined"!=typeof Services){var B={};["webvtt.font.color","webvtt.font.opacity","webvtt.font.scale","webvtt.bg.color","webvtt.bg.opacity","webvtt.edge.color","webvtt.edge.type"].forEach((function(e){E(0,0,e),Services.prefs.addObserver(e,E,!1)}))}var x=Object.create||function(){function e(){}return function(t){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return e.prototype=t,new e}}();function k(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}function I(e){function t(e,t,n,r){return 3600*(0|e)+60*(0|t)+(0|n)+(0|r)/1e3}var n=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return n?n[3]?t(n[1],n[2],n[3].replace(":",""),n[4]):n[1]>59?t(n[1],n[2],0,n[4]):t(0,n[1],n[2],n[4]):null}function S(){this.values=x(null)}function T(e,t,n,r){var o=r?e.split(r):[e];for(var i in o)if("string"==typeof o[i]){var a=o[i].split(n);2===a.length&&t(a[0],a[1])}}function L(e,t,n){var r=e;function o(){var t=I(e);if(null===t)throw new k(k.Errors.BadTimeStamp,"Malformed timestamp: "+r);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function i(){e=e.replace(/^\s+/,"")}if(i(),t.startTime=o(),i(),"--\x3e"!==e.substr(0,3))throw new k(k.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);e=e.substr(3),i(),t.endTime=o(),i(),function(e,t){var r=new S;T(e,(function(e,t){switch(e){case"region":for(var o=n.length-1;o>=0;o--)if(n[o].id===t){r.set(e,n[o].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":var i=t.split(","),a=i[0];r.integer(e,a),r.percent(e,a)&&r.set("snapToLines",!1),r.alt(e,a,["auto"]),2===i.length&&r.alt("lineAlign",i[1],["start","middle","end"]);break;case"position":i=t.split(","),r.percent(e,i[0]),2===i.length&&r.alt("positionAlign",i[1],["start","middle","end"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start","middle","end","left","right"])}}),/:/,/\s/)}(e)}k.prototype=x(Error.prototype),k.prototype.constructor=k,k.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},S.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,n){for(var r=0;r=0&&t<=100)&&(this.set(e,t),!0)}};var R={"&":"&","<":"<",">":">","‎":"‎","‏":"‏"," ":" "},M={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},O={v:"title",lang:"lang"},Q={rt:"ruby"};function D(e,t){function n(){if(!t)return null;var e,n=t.match(/^([^<]*)(<[^>]+>?)?/);return e=n[1]?n[1]:n[2],t=t.substr(e.length),e}function r(e){return R[e]}function o(e){for(;p=e.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)e=e.replace(p[0],r);return e}function i(e,t){return!Q[t.localName]||Q[t.localName]===e.localName}function a(t,n){var r=M[t];if(!r)return null;var o=e.document.createElement(r);o.localName=r;var i=O[t];return i&&n&&(o[i]=n.trim()),o}for(var A,s=e.document.createElement("div"),c=s,u=[];null!==(A=n());)if("<"!==A[0])c.appendChild(e.document.createTextNode(o(A)));else{if("/"===A[1]){u.length&&u[u.length-1]===A.substr(2).replace(">","")&&(u.pop(),c=c.parentNode);continue}var l,f=I(A.substr(1,A.length-2));if(f){l=e.document.createProcessingInstruction("timestamp",f),c.appendChild(l);continue}var p=A.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!p)continue;if(!(l=a(p[1],p[3])))continue;if(!i(c,l))continue;p[2]&&(l.className=p[2].substr(1).replace("."," ")),u.push(p[1]),c.appendChild(l),c=l}return s}var P=[1470,1472,1475,1478,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1520,1521,1522,1523,1524,1544,1547,1549,1563,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1645,1646,1647,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1765,1766,1774,1775,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1807,1808,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1969,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2e3,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2036,2037,2042,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2074,2084,2088,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2142,2208,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,8207,64285,64287,64288,64289,64290,64291,64292,64293,64294,64295,64296,64298,64299,64300,64301,64302,64303,64304,64305,64306,64307,64308,64309,64310,64312,64313,64314,64315,64316,64318,64320,64321,64323,64324,64326,64327,64328,64329,64330,64331,64332,64333,64334,64335,64336,64337,64338,64339,64340,64341,64342,64343,64344,64345,64346,64347,64348,64349,64350,64351,64352,64353,64354,64355,64356,64357,64358,64359,64360,64361,64362,64363,64364,64365,64366,64367,64368,64369,64370,64371,64372,64373,64374,64375,64376,64377,64378,64379,64380,64381,64382,64383,64384,64385,64386,64387,64388,64389,64390,64391,64392,64393,64394,64395,64396,64397,64398,64399,64400,64401,64402,64403,64404,64405,64406,64407,64408,64409,64410,64411,64412,64413,64414,64415,64416,64417,64418,64419,64420,64421,64422,64423,64424,64425,64426,64427,64428,64429,64430,64431,64432,64433,64434,64435,64436,64437,64438,64439,64440,64441,64442,64443,64444,64445,64446,64447,64448,64449,64467,64468,64469,64470,64471,64472,64473,64474,64475,64476,64477,64478,64479,64480,64481,64482,64483,64484,64485,64486,64487,64488,64489,64490,64491,64492,64493,64494,64495,64496,64497,64498,64499,64500,64501,64502,64503,64504,64505,64506,64507,64508,64509,64510,64511,64512,64513,64514,64515,64516,64517,64518,64519,64520,64521,64522,64523,64524,64525,64526,64527,64528,64529,64530,64531,64532,64533,64534,64535,64536,64537,64538,64539,64540,64541,64542,64543,64544,64545,64546,64547,64548,64549,64550,64551,64552,64553,64554,64555,64556,64557,64558,64559,64560,64561,64562,64563,64564,64565,64566,64567,64568,64569,64570,64571,64572,64573,64574,64575,64576,64577,64578,64579,64580,64581,64582,64583,64584,64585,64586,64587,64588,64589,64590,64591,64592,64593,64594,64595,64596,64597,64598,64599,64600,64601,64602,64603,64604,64605,64606,64607,64608,64609,64610,64611,64612,64613,64614,64615,64616,64617,64618,64619,64620,64621,64622,64623,64624,64625,64626,64627,64628,64629,64630,64631,64632,64633,64634,64635,64636,64637,64638,64639,64640,64641,64642,64643,64644,64645,64646,64647,64648,64649,64650,64651,64652,64653,64654,64655,64656,64657,64658,64659,64660,64661,64662,64663,64664,64665,64666,64667,64668,64669,64670,64671,64672,64673,64674,64675,64676,64677,64678,64679,64680,64681,64682,64683,64684,64685,64686,64687,64688,64689,64690,64691,64692,64693,64694,64695,64696,64697,64698,64699,64700,64701,64702,64703,64704,64705,64706,64707,64708,64709,64710,64711,64712,64713,64714,64715,64716,64717,64718,64719,64720,64721,64722,64723,64724,64725,64726,64727,64728,64729,64730,64731,64732,64733,64734,64735,64736,64737,64738,64739,64740,64741,64742,64743,64744,64745,64746,64747,64748,64749,64750,64751,64752,64753,64754,64755,64756,64757,64758,64759,64760,64761,64762,64763,64764,64765,64766,64767,64768,64769,64770,64771,64772,64773,64774,64775,64776,64777,64778,64779,64780,64781,64782,64783,64784,64785,64786,64787,64788,64789,64790,64791,64792,64793,64794,64795,64796,64797,64798,64799,64800,64801,64802,64803,64804,64805,64806,64807,64808,64809,64810,64811,64812,64813,64814,64815,64816,64817,64818,64819,64820,64821,64822,64823,64824,64825,64826,64827,64828,64829,64848,64849,64850,64851,64852,64853,64854,64855,64856,64857,64858,64859,64860,64861,64862,64863,64864,64865,64866,64867,64868,64869,64870,64871,64872,64873,64874,64875,64876,64877,64878,64879,64880,64881,64882,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64894,64895,64896,64897,64898,64899,64900,64901,64902,64903,64904,64905,64906,64907,64908,64909,64910,64911,64914,64915,64916,64917,64918,64919,64920,64921,64922,64923,64924,64925,64926,64927,64928,64929,64930,64931,64932,64933,64934,64935,64936,64937,64938,64939,64940,64941,64942,64943,64944,64945,64946,64947,64948,64949,64950,64951,64952,64953,64954,64955,64956,64957,64958,64959,64960,64961,64962,64963,64964,64965,64966,64967,65008,65009,65010,65011,65012,65013,65014,65015,65016,65017,65018,65019,65020,65136,65137,65138,65139,65140,65142,65143,65144,65145,65146,65147,65148,65149,65150,65151,65152,65153,65154,65155,65156,65157,65158,65159,65160,65161,65162,65163,65164,65165,65166,65167,65168,65169,65170,65171,65172,65173,65174,65175,65176,65177,65178,65179,65180,65181,65182,65183,65184,65185,65186,65187,65188,65189,65190,65191,65192,65193,65194,65195,65196,65197,65198,65199,65200,65201,65202,65203,65204,65205,65206,65207,65208,65209,65210,65211,65212,65213,65214,65215,65216,65217,65218,65219,65220,65221,65222,65223,65224,65225,65226,65227,65228,65229,65230,65231,65232,65233,65234,65235,65236,65237,65238,65239,65240,65241,65242,65243,65244,65245,65246,65247,65248,65249,65250,65251,65252,65253,65254,65255,65256,65257,65258,65259,65260,65261,65262,65263,65264,65265,65266,65267,65268,65269,65270,65271,65272,65273,65274,65275,65276,67584,67585,67586,67587,67588,67589,67592,67594,67595,67596,67597,67598,67599,67600,67601,67602,67603,67604,67605,67606,67607,67608,67609,67610,67611,67612,67613,67614,67615,67616,67617,67618,67619,67620,67621,67622,67623,67624,67625,67626,67627,67628,67629,67630,67631,67632,67633,67634,67635,67636,67637,67639,67640,67644,67647,67648,67649,67650,67651,67652,67653,67654,67655,67656,67657,67658,67659,67660,67661,67662,67663,67664,67665,67666,67667,67668,67669,67671,67672,67673,67674,67675,67676,67677,67678,67679,67840,67841,67842,67843,67844,67845,67846,67847,67848,67849,67850,67851,67852,67853,67854,67855,67856,67857,67858,67859,67860,67861,67862,67863,67864,67865,67866,67867,67872,67873,67874,67875,67876,67877,67878,67879,67880,67881,67882,67883,67884,67885,67886,67887,67888,67889,67890,67891,67892,67893,67894,67895,67896,67897,67903,67968,67969,67970,67971,67972,67973,67974,67975,67976,67977,67978,67979,67980,67981,67982,67983,67984,67985,67986,67987,67988,67989,67990,67991,67992,67993,67994,67995,67996,67997,67998,67999,68e3,68001,68002,68003,68004,68005,68006,68007,68008,68009,68010,68011,68012,68013,68014,68015,68016,68017,68018,68019,68020,68021,68022,68023,68030,68031,68096,68112,68113,68114,68115,68117,68118,68119,68121,68122,68123,68124,68125,68126,68127,68128,68129,68130,68131,68132,68133,68134,68135,68136,68137,68138,68139,68140,68141,68142,68143,68144,68145,68146,68147,68160,68161,68162,68163,68164,68165,68166,68167,68176,68177,68178,68179,68180,68181,68182,68183,68184,68192,68193,68194,68195,68196,68197,68198,68199,68200,68201,68202,68203,68204,68205,68206,68207,68208,68209,68210,68211,68212,68213,68214,68215,68216,68217,68218,68219,68220,68221,68222,68223,68352,68353,68354,68355,68356,68357,68358,68359,68360,68361,68362,68363,68364,68365,68366,68367,68368,68369,68370,68371,68372,68373,68374,68375,68376,68377,68378,68379,68380,68381,68382,68383,68384,68385,68386,68387,68388,68389,68390,68391,68392,68393,68394,68395,68396,68397,68398,68399,68400,68401,68402,68403,68404,68405,68416,68417,68418,68419,68420,68421,68422,68423,68424,68425,68426,68427,68428,68429,68430,68431,68432,68433,68434,68435,68436,68437,68440,68441,68442,68443,68444,68445,68446,68447,68448,68449,68450,68451,68452,68453,68454,68455,68456,68457,68458,68459,68460,68461,68462,68463,68464,68465,68466,68472,68473,68474,68475,68476,68477,68478,68479,68608,68609,68610,68611,68612,68613,68614,68615,68616,68617,68618,68619,68620,68621,68622,68623,68624,68625,68626,68627,68628,68629,68630,68631,68632,68633,68634,68635,68636,68637,68638,68639,68640,68641,68642,68643,68644,68645,68646,68647,68648,68649,68650,68651,68652,68653,68654,68655,68656,68657,68658,68659,68660,68661,68662,68663,68664,68665,68666,68667,68668,68669,68670,68671,68672,68673,68674,68675,68676,68677,68678,68679,68680,126464,126465,126466,126467,126469,126470,126471,126472,126473,126474,126475,126476,126477,126478,126479,126480,126481,126482,126483,126484,126485,126486,126487,126488,126489,126490,126491,126492,126493,126494,126495,126497,126498,126500,126503,126505,126506,126507,126508,126509,126510,126511,126512,126513,126514,126516,126517,126518,126519,126521,126523,126530,126535,126537,126539,126541,126542,126543,126545,126546,126548,126551,126553,126555,126557,126559,126561,126562,126564,126567,126568,126569,126570,126572,126573,126574,126575,126576,126577,126578,126580,126581,126582,126583,126585,126586,126587,126588,126590,126592,126593,126594,126595,126596,126597,126598,126599,126600,126601,126603,126604,126605,126606,126607,126608,126609,126610,126611,126612,126613,126614,126615,126616,126617,126618,126619,126625,126626,126627,126629,126630,126631,126632,126633,126635,126636,126637,126638,126639,126640,126641,126642,126643,126644,126645,126646,126647,126648,126649,126650,126651,1114109];function F(){}function U(e,t,n){var r="undefined"!=typeof navigator&&/MSIE\s8\.0/.test(navigator.userAgent),o="rgba(255, 255, 255, 1)",i="rgba(0, 0, 0, 0.8)",a="";void 0!==B&&(o=B.fontSet,i=B.backgroundSet,a=B.edgeSet),r&&(o="rgb(255, 255, 255)",i="rgb(0, 0, 0)"),F.call(this),this.cue=t,this.cueDiv=D(e,t.text);var A={color:o,backgroundColor:i,textShadow:a,position:"relative",left:0,right:0,top:0,bottom:0,display:"inline"};r||(A.writingMode=""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",A.unicodeBidi="plaintext"),this.applyStyles(A,this.cueDiv),this.div=e.document.createElement("div"),A={textAlign:"middle"===t.align?"center":t.align,font:n.font,whiteSpace:"pre-line",position:"absolute"},r||(A.direction=function(e){var t,n=[],r="";if(!e||!e.childNodes)return"ltr";function o(e,t){for(var n=t.childNodes.length-1;n>=0;n--)e.push(t.childNodes[n])}function i(e){if(!e||!e.length)return null;var t=e.pop(),n=t.textContent||t.innerText;if(n){var r=n.match(/^.*(\n|\r)/);return r?(e.length=0,r[0]):n}return"ruby"===t.tagName?i(e):t.childNodes?(o(e,t),i(e)):void 0}for(o(n,e);r=i(n);)for(var a=0;a=0&&e.line<=100))return e.line;if(!e.track||!e.track.textTrackList||!e.track.textTrackList.mediaElement)return-1;for(var t=e.track,n=t.textTrackList,r=0,o=0;ol&&(u=u<0?-1:1,u*=Math.ceil(l/c)*c),a<0&&(u+=""===i.vertical?n.height:n.width,A=A.reverse()),o.move(f,u)}else{var p=o.lineHeight/n.height*100;switch(i.lineAlign){case"middle":a-=p/2;break;case"end":a-=p}switch(i.vertical){case"":t.applyStyles({top:t.formatStyle(a,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(a,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(a,"%")})}A=["+y","-x","+x","-y"],o=new N(t)}var d=function(e,t){for(var o,i=new N(e),a=1,A=0;As&&(o=new N(e),a=s),e=new N(i)}return o||i}(o,A);t.move(d.toCSSCompatValues(n))}F.prototype.applyStyles=function(e,t){for(var n in t=t||this.div,e)e.hasOwnProperty(n)&&(t.style[n]=e[n])},F.prototype.formatStyle=function(e,t){return 0===e?0:e+t},U.prototype=x(F.prototype),U.prototype.constructor=U,N.prototype.move=function(e,t){switch(t=void 0!==t?t:this.lineHeight,e){case"+x":this.left+=t,this.right+=t;break;case"-x":this.left-=t,this.right-=t;break;case"+y":this.top+=t,this.bottom+=t;break;case"-y":this.top-=t,this.bottom-=t}},N.prototype.overlaps=function(e){return this.lefte.left&&this.tope.top},N.prototype.overlapsAny=function(e){for(var t=0;t=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right},N.prototype.overlapsOppositeAxis=function(e,t){switch(t){case"+x":return this.lefte.right;case"+y":return this.tope.bottom}},N.prototype.intersectPercentage=function(e){return Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left))*Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top))/(this.height*this.width)},N.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}},N.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,n=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,r=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;return{left:(e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e).left,right:e.right,top:e.top||r,height:e.height||t,bottom:e.bottom||r+(e.height||t),width:e.width||n}},y.StringDecoder=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}},y.convertCueToDOMTree=function(e,t){return e&&t?D(e,t):null},y.processCues=function(e,t,n){if(!e||!t||!n)return null;for(;n.firstChild;)n.removeChild(n.firstChild);var r=e.document.createElement("div");if(r.style.position="absolute",r.style.left="0",r.style.right="0",r.style.top="0",r.style.bottom="0",r.style.margin="1.5%",n.appendChild(r),function(e){for(var t=0;t]*<[a-z]*/g,V=/]+?start[^=]*=[^0-9]*([0-9]*)["^0-9"]*/i,H=/]*>/gi,J=function(e,t){return t=(((t||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join(""),e.replace(/|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(function(e,n){return t.indexOf("<"+n.toLowerCase()+">")>-1?e:""}))},Z=function(e){return e.sort((function(e,t){var n;return 0==(n=e.start-t.start)?e.end-t.end:n}))},K=function(){var e={},t=function(e){return e.map((function(e){return new h(e.start,e.end,e.text)}))};return e.load=function(e,n,r,o){fetch(e.file).then((function(e){e.ok?e.text().then((function(e){var o=[],i=[];if(e.indexOf("WEBVTT")>=0){OvenPlayerConsole.log("WEBVTT LOADED");var A=new j.Parser(window,j.StringDecoder());i=[],A.oncue=function(e){i.push(e)},A.onflush=function(){r(i)},A.parse(e)}else if(e.indexOf("SAMI")>=0){OvenPlayerConsole.log("SAMI LOADED");var s=function(e,t){var n,r,o,i,a,A,s,c,u,l;if(s=function(){var t,n,r,a,s,c,u,f,p,d,g,h,v,m,C,y;for(n=function(e){var n;return(n=new Error(e)).line=u,n.context=t,o.push(n)},u=1,p=[],v={},h=e;d=h.search(),!(f<=0||d<0);)f=h.slice(d+1).search(G)+1,t=f>0?h.slice(d,d+f):h.slice(d),u+=(null!=(m=h.slice(0,d).match(z))?m.length:void 0)||0,_.test(t)&&n("ERROR_BROKEN_TAGS"),h=h.slice(d+f),(null===(g=+(null!=(C=t.match(V))?parseFloat(C[1]/1e3):void 0))||g<0)&&n("ERROR_INVALID_TIME"),(s=i(t))||n("ERROR_INVALID_LANGUAGE"),u+=(null!=(y=t.match(z))?y.length:void 0)||0,t=(t=t.replace(z,"")).replace(H,"\n"),a={start:g,text:"",contents:r=J(t).trim()},s&&(a.text=r),v[s]||(v[s]=[]),a.start&&v[s].push(a);l=l||function(){var e,t,n=window.navigator,r=["language","browserLanguage","systemLanguage","userLanguage"];if(Array.isArray(n.languages))for(e=0;e0&&(c=b.indexOf(l)>-1?v[l]:v[b.filter((function(e){return"undefined"!==e}))[0]],c=Z(c),c=A(c),p=p.concat(c)),Z(p)},i=function(e){var t,r;if(e)for(t in n)if((r=n[t]).reClassName.test(e))return r.lang},A=function(e){var t,n,o;for(t=e.length;t--;)n=e[t],null!=(o=e[t-1])&&(o.end=n.start),n.contents&&" "!==n.contents?(delete e[t].contents,n.end||(n.end=n.start+r)):e.splice(t,1);return e},o=[],n={KRCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KRCC)['\"S]?","i")},KOCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KOCC)['\"S]?","i")},KR:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KR)['\"S]?","i")},ENCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(ENCC)['\"S]?","i")},EGCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EGCC)['\"S]?","i")},EN:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EN)['\"S]?","i")},JPCC:{lang:"ja",reClassName:new RegExp("class[^=]*?=[\"'S]*(JPCC)['\"S]?","i")}},null!=t?t.definedLangs:void 0)for(a in u=t.definedLangs)c=u[a],n[a]=c;return r=(null!=t?t.duration:void 0)||10,l=t.fixedLang,e=e.trim(),{result:s(),errors:o}}(e,{fixedLang:n});i=t(s.result),r(i)}else OvenPlayerConsole.log("SRT LOADED"),o=function(e){var t=[],n=(e=a(e)).split("\r\n\r\n");1===n.length&&(n=e.split("\n\n"));for(var r=0;rGet Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Can not load due to dash.js. Please use the latest dash.js.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Error initializing DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Error initializing HLS.",reason:"Error initializing HLS."},300:{code:300,message:"Can not play due to unknown reasons.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Fetching process aborted by user.",reason:"Fetching process aborted by user."},302:{code:302,message:"Some of the media could not be downloaded due to a network error.",reason:"Error occurred when downloading."},303:{code:303,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"Error occurred when decoding."},304:{code:304,message:"Media playback has been canceled. It looks like your media is corrupted or your browser does not support the features your media uses.",reason:"Media playback not supported."},305:{code:305,message:"Can not load captions due to unknown reasons.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server refused the request."},308:{code:308,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server do not accept the request."},501:{code:501,message:"Connection with low-latency(OME) server failed.",reason:"WebSocket connection failed."},502:{code:502,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC internal error."},510:{code:510,message:"Network connection is unstable. Check the network connection.",reason:"Network is slow."},511:{code:511,message:"Connection with low-latency(OME) terminated unexpectedly.",reason:"Unexpected end of connection."},512:{code:512,message:"Connection with low-latency(OME) server failed.",reason:"Connection timeout."}}}},{lang:"ko",ui:{context:"오븐플레이어에 관하여",controls:{live:"라이브",low_latency_live:"초저지연 라이브",low_latency_p2p:"초저지연 P2P"},playlist:"플레이리스트",setting:{title:"설정",speed:"재생 속도",speedUnit:"x",source:"소스",quality:"품질",audioTrack:"오디오",caption:"자막",display:"표시"}},api:{message:{muted_play:"눌러서 소리 켜기"},error:{100:{code:100,message:"알 수 없는 이유로 로드 할 수 없습니다.",reason:"알 수 없는 이유로 로드 할 수 없습니다."},101:{code:101,message:"지원되는 미디어를 찾지 못해 로드 할 수 없습니다.",reason:"Can not load due to playable media not found."},102:{code:102,message:"플레시 로드가 중단 되었습니다.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"DashJS로 인해 로드 할 수 없습니다. 최신 dash.js를 사용해 주세요.",reason:"dash.js version is old."},104:{code:104,message:"Google IMA 라이브러리가 없어 로드 할 수 없습니다.",reason:"Please check the google ima library."},105:{code:105,message:"DASH 초기화 중 오류가 발생했습니다.",reason:"Error initializing DASH."},106:{code:106,message:"HLS 초기화 중 오류가 발생했습니다.",reason:"Error initializing HLS."},300:{code:300,message:"알 수 없는 이유로 재생할 수 없습니다.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"사용자에 의한 프로세스 중단.",reason:"Fetching process aborted by user."},302:{code:302,message:"네트워크 오류로 인해 일부 미디어를 다운로드 할 수 없습니다.",reason:"Error occurred when downloading."},303:{code:303,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"Error occurred when decoding."},304:{code:304,message:"미디어 재생이 취소되었습니다. 미디어가 손상되었거나 브라우저가 미디어에서 사용하는 기능을 지원하지 않는 것 같습니다.",reason:"Media playback not supported."},305:{code:305,message:"알 수 없는 이유로 자막을 로드 할 수 없습니다.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server cannot or will not process the request."},307:{code:307,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server refused the request."},308:{code:308,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server do not accept the request."},501:{code:501,message:"웹소켓 연결 실패",reason:"WebSocket connection failed."},502:{code:502,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC internal error."},510:{code:510,message:"네트워크 연결이 불안정합니다. 네트워크 연결을 확인하십시오.",reason:"Network is slow."},511:{code:511,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Unexpected end of connection."},512:{code:512,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Connection timeout."}}}},{lang:"pl",ui:{context:"O OvenPlayer",controls:{live:"Transmisja na żywo",low_latency_live:"Transmisja z niskim opóźnieniem",low_latency_p2p:"Transmisja z niskim opóźnieniem P2P"},playlist:"Playlista",setting:{title:"Ustawienia",speed:"Prędkość",speedUnit:"x",source:"Źrodło",quality:"Jakość",audioTrack:"Audio",caption:"Podtytuł",display:"Wyświetlacz"}},api:{message:{muted_play:"Naciśnij tutaj, aby aktywować dźwięk"},error:{100:{code:100,message:"Nie można załadować z nieznanego powodu.",reason:"Can not load due to unknown reasons."},101:{code:101,message:"Nie można załadować, ponieważ nie znaleziono multimediów, który można odtworzyć.",reason:"Can not load due to playable media not found."},102:{code:102,message:"Flash fetching process aborted.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Nie można załadować, ponieważ wersja dash.js jest za stara.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Nie można załadować, nie znaleziono DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Nie można załadować, nie znaleziono hlsjs.",reason:"Error initializing HLS"},300:{code:300,message:"Nie można odtworzyć z nieznanego powodu.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Proces pobierania przerwany przez użytkownika.",reason:"Fetching process aborted by user."},302:{code:302,message:"Nie udało się pobrać niektórych multimediów z powodu błędu sieci.",reason:"Error occurred when downloading."},303:{code:303,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"Error occurred when decoding."},304:{code:304,message:"Odtwarzanie zostało anulowane. Wygląda na to, że plik jest uszkodzony lub Twoja przeglądarka nie obsługuje tego pliku.",reason:"Media playback not supported."},305:{code:305,message:"Nie można wczytać napisów z nieznanego powodu.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server refused the request."},308:{code:308,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server do not accept the request."},501:{code:501,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebSocket connection failed."},502:{code:502,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC internal error."},510:{code:510,message:"Połączenie sieciowe jest niestabilne. Sprawdź swoją sieć.",reason:"Network is slow."},511:{code:511,message:"Połączenie z serwerem niskiego opóźnienia (OME) nieoczekiwanie zakończone.",reason:"Unexpected end of connection."},512:{code:512,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"Connection timeout."}}}}],Ye=function(e){return"subtitles"===e||"captions"===e},Ge=function(e){var t=e,n=[],r=function(e,t,n){var r=0,o=e.length;for(r=0;r1?n:n[0]};return(r=i().isElement(t)||i().every(t,(function(e){return i().isElement(e)}))?t:"document"===t?document:"window"===t?window:o(document,t))?(n.show=function(){r.style.display="block"},n.hide=function(){r.style.display="none"},n.addClass=function(e){r.classList?r.classList.add(e):-1===r.className.split(" ").indexOf(e)&&(r.className+=" "+e)},n.after=function(e){r.insertAdjacentHTML("afterend",e)},n.append=function(e){r.appendChild(e)},n.before=function(e){r.insertAdjacentHTML("beforebegin",e)},n.children=function(){return r.children||[]},n.contains=function(e){return r!==e&&r.contains(e)},n.empty=function(){r.innerHTML=""},n.find=function(t){return e(o(r,t))},n.css=function(e,t){if(!t)return r.style[e];r.length>0?r.forEach((function(n){n.style[e]=t})):r.style[e]=t},n.removeClass=function(e){r.classList?r.classList.remove(e):r.className=r.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")},n.removeAttribute=function(e){r.removeAttribute(e)},n.text=function(e){if(void 0===e)return r.textContent;r.textContent=e},n.html=function(e){r.innerHTML=e},n.hasClass=function(e){return r.classList?r.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(r.name)},n.is=function(e){return r===e},n.offset=function(){var e=r.getBoundingClientRect();return{top:e.top+document.body.scrollTop,left:e.left+document.body.scrollLeft}},n.width=function(){return r.clientWidth},n.height=function(){return r.clientHeight},n.attr=function(e){return r.getAttribute(e)},n.replace=function(e){r.replaceWith(e)},n.remove=function(){r.length>1?r.parentElement.removeChild(r):r.remove()},n.removeChild=function(e){if(e)r.removeChild(e);else for(;r.hasChildNodes();)r.removeChild(r.firstChild)},n.get=function(){return r},n.closest=function(t){r.closest=function(e){var t=r;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null};var n=r.closest(t);return n?e(n):null},n):null}),_e=function(e,t){if(e)return 0==e.indexOf("rtmp:")||"rtmp"==t},Ve=function(e,t){return!!e&&(0===e.indexOf("ws:")||0===e.indexOf("wss:")||"webrtc"===t)},He=function(e,t){if(e)return"hls"===t||"m3u8"===t||"application/vnd.apple.mpegurl"===t||"m3u8"==A(e)},Je=function(e,t){if(e)return"mpd"===t||"dash"===t||"application/dash+xml"===t||"mpd"==A(e)},Ze=function(e){if(!e)return null;var t=null;if("string"==typeof e)t=document.getElementById(e);else{if(!e.nodeType)return null;t=e}return t},Ke=function(){var e={};OvenPlayerConsole.log("SupportChecker loaded.");var t=Y(),n=[{name:"html5",checkSupport:function(e){var n=document.createElement("video");if(!n.canPlayType)return!1;var r=e.file,o=e.type;if(!o)return!1;var i=e.mimeType||{aac:"audio/mp4",mp4:"video/mp4",f4v:"video/mp4",m4v:"video/mp4",mov:"video/mp4",mp3:"audio/mpeg",mpeg:"audio/mpeg",ogv:"video/ogg",ogg:"video/ogg",oga:"video/ogg",vorbis:"video/ogg",webm:"video/webm",f4a:"video/aac",m3u8:"application/vnd.apple.mpegurl",m3u:"application/vnd.apple.mpegurl",hls:"application/vnd.apple.mpegurl"}[o];return!(He(r,o)&&("Microsoft Edge"===t.browser||"Android"===t.os)||_e(r,o)||Ve(r,o)||!i||!n.canPlayType(i))}},{name:"webrtc",checkSupport:function(e){if(!document.createElement("video").canPlayType)return!1;if(_e(t,n))return!1;var t=e.file,n=e.type;return!!Ve(t,n)}},{name:"dash",checkSupport:function(e){var t=e.file,n=e.type;return!_e(t,n)&&!("function"!=typeof(window.MediaSource||window.WebKitMediaSource)||!Je(t,n))}},{name:"hls",checkSupport:function(e){document.createElement("video");var t,n,r,o,i=e.file,a=e.type;return!_e(i,a)&&(t=function(){if("undefined"!=typeof window)return window.MediaSource||window.WebKitMediaSource}(),n=window.SourceBuffer||window.WebKitSourceBuffer,r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),o=!n||n.prototype&&"function"==typeof n.prototype.appendBuffer&&"function"==typeof n.prototype.remove,!!r&&!!o)}},{name:"rtmp",checkSupport:function(e){var n=e.file,r=e.type;return!(!_e(n,r)||!function(){var e=!1;if("ActiveXObject"in window)try{e=!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(t){e=!1}else e=!!navigator.mimeTypes["application/x-shockwave-flash"];return e}()||"Microsoft Edge"===t.browser||"Android"===t.os||"iOS"===t.os||"Safari"===t.browser)}}];return e.findProviderNameBySource=function(e){OvenPlayerConsole.log("SupportChecker : findProviderNameBySource()",e);for(var t=e===Object(e)?e:{},r=0;r0&&void 0!==arguments[0]?arguments[0]:{};ct(this,e),this.id=t.id||null,this.adId=t.adId||null,this.sequence=t.sequence||null,this.apiFramework=t.apiFramework||null,this.trackingEvents={}})),gt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="companion",e.variations=[],e}return st(n)}(dt);function ht(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[];for(var r in t.ASSETURI&&(t.ASSETURI=vt(t.ASSETURI)),t.CONTENTPLAYHEAD&&(t.CONTENTPLAYHEAD=vt(t.CONTENTPLAYHEAD)),t.ERRORCODE&&!/^[0-9]{3}$/.test(t.ERRORCODE)&&(t.ERRORCODE=900),t.CACHEBUSTING=mt(Math.round(1e8*Math.random()).toString()),t.TIMESTAMP=vt((new Date).toISOString()),t.RANDOM=t.random=t.CACHEBUSTING,e){var o=e[r];if("string"==typeof o){for(var i in t){var a=t[i],A="[".concat(i,"]"),s="%%".concat(i,"%%");o=(o=o.replace(A,a)).replace(s,a)}n.push(o)}}return n}function vt(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16))}))}function mt(e){return e.length<8?Ct(0,8-e.length,!1).map((function(e){return"0"})).join("")+e:e}function Ct(e,t,n){for(var r=[],o=ei;o?a++:a--)r.push(a);return r}var yt={track:function(e,t){ht(e,t).forEach((function(e){"undefined"!=typeof window&&null!==window&&((new Image).src=e)}))},resolveURLTemplates:ht,encodeURIComponentRFC3986:vt,leftpad:mt,range:Ct,isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},flatten:function e(t){return t.reduce((function(t,n){return t.concat(Array.isArray(n)?e(n):n)}),[])}},bt=function(e,t){var n=e.childNodes;for(var r in n){var o=n[r];if(o.nodeName===t)return o}},wt=function(e,t){var n=[],r=e.childNodes;for(var o in r){var i=r[o];i.nodeName===t&&n.push(i)}return n},Et=function(e,t){if(!t)return e;if(0===e.indexOf("//")){var n=location.protocol;return"".concat(n).concat(e)}return-1===e.indexOf("://")?"".concat(t.slice(0,t.lastIndexOf("/")),"/").concat(e):e},Bt=function(e){return-1!==["true","TRUE","1"].indexOf(e)},xt=function(e){return e&&(e.textContent||e.text||"").trim()},kt=function(e,t,n){var r=t.getAttribute(e);r&&n.setAttribute(e,r)},It=function(e){if(null==e)return-1;if(yt.isNumeric(e))return parseInt(e);var t=e.split(":");if(3!==t.length)return-1;var n=t[2].split("."),r=parseInt(n[0]);2===n.length&&(r+=parseFloat("0.".concat(n[1])));var o=parseInt(60*t[1]),i=parseInt(60*t[0]*60);return isNaN(i)||isNaN(o)||isNaN(r)||o>3600||r>60?-1:i+o+r},St=function(e){var t=[],n=null;return e.forEach((function(r,o){if(r.sequence&&(r.sequence=parseInt(r.sequence,10)),r.sequence>1){var i=e[o-1];if(i&&i.sequence===r.sequence-1)return void(n&&n.push(r));delete r.sequence}n=[r],t.push(n)})),t},Tt=function(e,t){e.errorURLTemplates=t.errorURLTemplates.concat(e.errorURLTemplates),e.impressionURLTemplates=t.impressionURLTemplates.concat(e.impressionURLTemplates),e.extensions=t.extensions.concat(e.extensions),e.creatives.forEach((function(e){if(t.trackingEvents&&t.trackingEvents[e.type])for(var n in t.trackingEvents[e.type]){var r=t.trackingEvents[e.type][n];e.trackingEvents[n]||(e.trackingEvents[n]=[]),e.trackingEvents[n]=e.trackingEvents[n].concat(r)}})),t.videoClickTrackingURLTemplates&&t.videoClickTrackingURLTemplates.length&&e.creatives.forEach((function(e){"linear"===e.type&&(e.videoClickTrackingURLTemplates=e.videoClickTrackingURLTemplates.concat(t.videoClickTrackingURLTemplates))})),t.videoCustomClickURLTemplates&&t.videoCustomClickURLTemplates.length&&e.creatives.forEach((function(e){"linear"===e.type&&(e.videoCustomClickURLTemplates=e.videoCustomClickURLTemplates.concat(t.videoCustomClickURLTemplates))})),t.videoClickThroughURLTemplate&&e.creatives.forEach((function(e){"linear"===e.type&&null==e.videoClickThroughURLTemplate&&(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate)}))};function Lt(e,t){var n=new gt(t);return wt(e,"Companion").forEach((function(e){var t=new pt;t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.companionClickTrackingURLTemplates=[],wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(n){t.type=n.getAttribute("creativeType")||0,wt(e,"AltText").forEach((function(e){t.altText=xt(e)})),t.staticResource=xt(n)})),wt(e,"TrackingEvents").forEach((function(e){wt(e,"Tracking").forEach((function(e){var n=e.getAttribute("event"),r=xt(e);n&&r&&(null==t.trackingEvents[n]&&(t.trackingEvents[n]=[]),t.trackingEvents[n].push(r))}))})),wt(e,"CompanionClickTracking").forEach((function(e){t.companionClickTrackingURLTemplates.push(xt(e))})),t.companionClickThroughURLTemplate=xt(bt(e,"CompanionClickThrough")),t.companionClickTrackingURLTemplate=xt(bt(e,"CompanionClickTracking")),n.variations.push(t)})),n}var Rt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="linear",e.duration=0,e.skipDelay=null,e.mediaFiles=[],e.videoClickThroughURLTemplate=null,e.videoClickTrackingURLTemplates=[],e.videoCustomClickURLTemplates=[],e.adParameters=null,e.icons=[],e}return st(n)}(dt),Mt=st((function e(){ct(this,e),this.program=null,this.height=0,this.width=0,this.xPosition=0,this.yPosition=0,this.apiFramework=null,this.offset=null,this.duration=0,this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.iconClickThroughURLTemplate=null,this.iconClickTrackingURLTemplates=[],this.iconViewTrackingURLTemplate=null})),Ot=st((function e(){ct(this,e),this.id=null,this.fileURL=null,this.deliveryType="progressive",this.mimeType=null,this.codec=null,this.bitrate=0,this.minBitrate=0,this.maxBitrate=0,this.width=0,this.height=0,this.apiFramework=null,this.scalable=null,this.maintainAspectRatio=null}));function Qt(e,t){var n,r=new Rt(t);r.duration=It(xt(bt(e,"Duration")));var o=e.getAttribute("skipoffset");if(null==o)r.skipDelay=null;else if("%"===o.charAt(o.length-1)&&-1!==r.duration){var i=parseInt(o,10);r.skipDelay=r.duration*(i/100)}else r.skipDelay=It(o);var a=bt(e,"VideoClicks");a&&(r.videoClickThroughURLTemplate=xt(bt(a,"ClickThrough")),wt(a,"ClickTracking").forEach((function(e){r.videoClickTrackingURLTemplates.push(xt(e))})),wt(a,"CustomClick").forEach((function(e){r.videoCustomClickURLTemplates.push(xt(e))})));var A=bt(e,"AdParameters");A&&(r.adParameters=xt(A)),wt(e,"TrackingEvents").forEach((function(e){wt(e,"Tracking").forEach((function(e){var t=e.getAttribute("event"),o=xt(e);if(t&&o){if("progress"===t){if(!(n=e.getAttribute("offset")))return;t="%"===n.charAt(n.length-1)?"progress-".concat(n):"progress-".concat(Math.round(It(n)))}null==r.trackingEvents[t]&&(r.trackingEvents[t]=[]),r.trackingEvents[t].push(o)}}))})),wt(e,"MediaFiles").forEach((function(e){wt(e,"MediaFile").forEach((function(e){var t=new Ot;t.id=e.getAttribute("id"),t.fileURL=xt(e),t.deliveryType=e.getAttribute("delivery"),t.codec=e.getAttribute("codec"),t.mimeType=e.getAttribute("type"),t.apiFramework=e.getAttribute("apiFramework"),t.bitrate=parseInt(e.getAttribute("bitrate")||0),t.minBitrate=parseInt(e.getAttribute("minBitrate")||0),t.maxBitrate=parseInt(e.getAttribute("maxBitrate")||0),t.width=parseInt(e.getAttribute("width")||0),t.height=parseInt(e.getAttribute("height")||0);var n=e.getAttribute("scalable");n&&"string"==typeof n&&("true"===(n=n.toLowerCase())?t.scalable=!0:"false"===n&&(t.scalable=!1));var o=e.getAttribute("maintainAspectRatio");o&&"string"==typeof o&&("true"===(o=o.toLowerCase())?t.maintainAspectRatio=!0:"false"===o&&(t.maintainAspectRatio=!1)),r.mediaFiles.push(t)}))}));var s=bt(e,"Icons");return s&&wt(s,"Icon").forEach((function(e){var t=new Mt;t.program=e.getAttribute("program"),t.height=parseInt(e.getAttribute("height")||0),t.width=parseInt(e.getAttribute("width")||0),t.xPosition=function(e){return-1!==["left","right"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("xPosition")),t.yPosition=function(e){return-1!==["top","bottom"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("yPosition")),t.apiFramework=e.getAttribute("apiFramework"),t.offset=It(e.getAttribute("offset")),t.duration=It(e.getAttribute("duration")),wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=xt(e)}));var n=bt(e,"IconClicks");n&&(t.iconClickThroughURLTemplate=xt(bt(n,"IconClickThrough")),wt(n,"IconClickTracking").forEach((function(e){t.iconClickTrackingURLTemplates.push(xt(e))}))),t.iconViewTrackingURLTemplate=xt(bt(e,"IconViewTracking")),r.icons.push(t)})),r}var Dt,Pt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="nonlinear",e.variations=[],e}return st(n)}(dt),Ft=st((function e(){ct(this,e),this.id=null,this.width=0,this.height=0,this.expandedWidth=0,this.expandedHeight=0,this.scalable=!0,this.maintainAspectRatio=!0,this.minSuggestedDuration=0,this.apiFramework="static",this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.nonlinearClickThroughURLTemplate=null,this.nonlinearClickTrackingURLTemplates=[],this.adParameters=null}));function Ut(e,t){var n=new Pt(t);return wt(e,"TrackingEvents").forEach((function(e){var t,r;wt(e,"Tracking").forEach((function(e){t=e.getAttribute("event"),r=xt(e),t&&r&&(null==n.trackingEvents[t]&&(n.trackingEvents[t]=[]),n.trackingEvents[t].push(r))}))})),wt(e,"NonLinear").forEach((function(e){var t=new Ft;t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.expandedWidth=e.getAttribute("expandedWidth"),t.expandedHeight=e.getAttribute("expandedHeight"),t.scalable=Bt(e.getAttribute("scalable")),t.maintainAspectRatio=Bt(e.getAttribute("maintainAspectRatio")),t.minSuggestedDuration=It(e.getAttribute("minSuggestedDuration")),t.apiFramework=e.getAttribute("apiFramework"),wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=xt(e)}));var r=bt(e,"AdParameters");r&&(t.adParameters=xt(r)),t.nonlinearClickThroughURLTemplate=xt(bt(e,"NonLinearClickThrough")),wt(e,"NonLinearClickTracking").forEach((function(e){t.nonlinearClickTrackingURLTemplates.push(xt(e))})),n.variations.push(t)})),n}function Nt(e){var t=e.childNodes;for(var n in t){var r=t[n];if(-1!==["Wrapper","InLine"].indexOf(r.nodeName)){if(kt("id",e,r),kt("sequence",e,r),"Wrapper"===r.nodeName)return jt(r);if("InLine"===r.nodeName)return Wt(r)}}}function Wt(e){var t=e.childNodes,n=new ut;for(var r in n.id=e.getAttribute("id")||null,n.sequence=e.getAttribute("sequence")||null,t){var o=t[r];switch(o.nodeName){case"Error":n.errorURLTemplates.push(xt(o));break;case"Impression":n.impressionURLTemplates.push(xt(o));break;case"Creatives":wt(o,"Creative").forEach((function(e){var t={id:e.getAttribute("id")||null,adId:Gt(e),sequence:e.getAttribute("sequence")||null,apiFramework:e.getAttribute("apiFramework")||null};for(var r in e.childNodes){var o=e.childNodes[r];switch(o.nodeName){case"Linear":var i=Qt(o,t);i&&n.creatives.push(i);break;case"NonLinearAds":var a=Ut(o,t);a&&n.creatives.push(a);break;case"CompanionAds":var A=Lt(o,t);A&&n.creatives.push(A)}}}));break;case"Extensions":Yt(n.extensions,wt(o,"Extension"));break;case"AdSystem":n.system={value:xt(o),version:o.getAttribute("version")||null};break;case"AdTitle":n.title=xt(o);break;case"Description":n.description=xt(o);break;case"Advertiser":n.advertiser=xt(o);break;case"Pricing":n.pricing={value:xt(o),model:o.getAttribute("model")||null,currency:o.getAttribute("currency")||null};break;case"Survey":n.survey=xt(o)}}return n}function jt(e){var t=Wt(e),n=bt(e,"VASTAdTagURI");if(n?t.nextWrapperURL=xt(n):(n=bt(e,"VASTAdTagURL"))&&(t.nextWrapperURL=xt(bt(n,"URL"))),t.creatives.forEach((function(e){if(-1!==["linear","nonlinear"].indexOf(e.type)){if(e.trackingEvents){t.trackingEvents||(t.trackingEvents={}),t.trackingEvents[e.type]||(t.trackingEvents[e.type]={});var n=function(n){var r=e.trackingEvents[n];t.trackingEvents[e.type][n]||(t.trackingEvents[e.type][n]=[]),r.forEach((function(r){t.trackingEvents[e.type][n].push(r)}))};for(var r in e.trackingEvents)n(r)}e.videoClickTrackingURLTemplates&&(t.videoClickTrackingURLTemplates||(t.videoClickTrackingURLTemplates=[]),e.videoClickTrackingURLTemplates.forEach((function(e){t.videoClickTrackingURLTemplates.push(e)}))),e.videoClickThroughURLTemplate&&(t.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate),e.videoCustomClickURLTemplates&&(t.videoCustomClickURLTemplates||(t.videoCustomClickURLTemplates=[]),e.videoCustomClickURLTemplates.forEach((function(e){t.videoCustomClickURLTemplates.push(e)})))}})),t.nextWrapperURL)return t}function Yt(e,t){t.forEach((function(t){var n=new lt,r=t.attributes,o=t.childNodes;if(t.attributes)for(var i in r){var a=r[i];a.nodeName&&a.nodeValue&&(n.attributes[a.nodeName]=a.nodeValue)}for(var A in o){var s=o[A],c=xt(s);if("#comment"!==s.nodeName&&""!==c){var u=new ft;if(u.name=s.nodeName,u.value=c,s.attributes){var l=s.attributes;for(var f in l){var p=l[f];u.attributes[p.nodeName]=p.nodeValue}}n.children.push(u)}}e.push(n)}))}function Gt(e){return e.getAttribute("AdID")||e.getAttribute("adID")||e.getAttribute("adId")||null}function zt(){}function _t(){_t.init.call(this)}function Vt(e){return void 0===e._maxListeners?_t.defaultMaxListeners:e._maxListeners}function Ht(e,t,n){if(t)e.call(n);else for(var r=e.length,o=tn(e,r),i=0;i0&&a.length>o){a.warned=!0;var A=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");A.name="MaxListenersExceededWarning",A.emitter=e,A.type=t,A.count=a.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(A)}}else a=i[t]=n,++e._eventsCount;return e}function $t(e,t,n){var r=!1;function o(){e.removeListener(t,o),r||(r=!0,n.apply(e,arguments))}return o.listener=n,o}function en(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function tn(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}zt.prototype=Object.create(null),_t.EventEmitter=_t,_t.usingDomains=!1,_t.prototype.domain=void 0,_t.prototype._events=void 0,_t.prototype._maxListeners=void 0,_t.defaultMaxListeners=10,_t.init=function(){this.domain=null,_t.usingDomains&&(!Dt.active||this instanceof Dt.Domain||(this.domain=Dt.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new zt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_t.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_t.prototype.getMaxListeners=function(){return Vt(this)},_t.prototype.emit=function(e){var t,n,r,o,i,a,A,s="error"===e;if(a=this._events)s=s&&null==a.error;else if(!s)return!1;if(A=this.domain,s){if(t=arguments[1],!A){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=A,t.domainThrown=!1,A.emit("error",t),!1}if(!(n=a[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:Ht(n,u,this);break;case 2:Jt(n,u,this,arguments[1]);break;case 3:Zt(n,u,this,arguments[1],arguments[2]);break;case 4:Kt(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i0;)if(n[i]===t||n[i].listener&&n[i].listener===t){a=n[i].listener,o=i;break}if(o<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new zt,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,o=e.length;r0?Reflect.ownKeys(this._events):[]};var nn=function(e,t,n){var r="function"==typeof window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLDOM"):void 0;if(!r)return n(new Error("FlashURLHandler: Microsoft.XMLDOM format not supported"));r.async=!1,request.open("GET",e),request.timeout=t.timeout||0,request.withCredentials=t.withCredentials||!1,request.send(),request.onprogress=function(){},request.onload=function(){r.loadXML(request.responseText),n(null,r)}},rn=function(){return window.XDomainRequest&&(e=new XDomainRequest),!!e;var e},on=function(e,t,n){n(new Error("Please bundle the library for node to use the node urlHandler"))};function an(){try{var e=new window.XMLHttpRequest;return"withCredentials"in e?e:null}catch(e){return console.log("Error in XHRURLHandler support check:",e),null}}var An,sn,cn=function(e,t,n){if("https:"===window.location.protocol&&0===e.indexOf("http://"))return n(new Error("XHRURLHandler: Cannot go from HTTPS to HTTP."));try{var r=an();r.open("GET",e),r.timeout=t.timeout||0,r.withCredentials=t.withCredentials||!1,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.onreadystatechange=function(){4===r.readyState&&(200===r.status?n(null,r.responseXML):n(new Error("XHRURLHandler: ".concat(r.statusText))))},r.send()}catch(e){n(new Error("XHRURLHandler: Unexpected error"))}},un=function(){return!!an()},ln={get:function(e,t,n){return n||("function"==typeof t&&(n=t),t={}),"undefined"==typeof window||null===window?on(e,t,n):un()?cn(e,t,n):rn()?nn(e,t,n):n(new Error("Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler"))}},fn=st((function e(){ct(this,e),this.ads=[],this.errorURLTemplates=[]})),pn={ERRORCODE:900,extensions:[]},dn=function(e){nt(n,e);var t=ot(n);function n(){var e;return ct(this,n),(e=t.call(this)).remainingAds=[],e.parentURLs=[],e.errorURLTemplates=[],e.rootErrorURLTemplates=[],e.maxWrapperDepth=null,e.URLTemplateFilters=[],e.fetchingOptions={},e}return st(n,[{key:"addURLTemplateFilter",value:function(e){"function"==typeof e&&this.URLTemplateFilters.push(e)}},{key:"removeURLTemplateFilter",value:function(){this.URLTemplateFilters.pop()}},{key:"countURLTemplateFilters",value:function(){return this.URLTemplateFilters.length}},{key:"clearURLTemplateFilters",value:function(){this.URLTemplateFilters=[]}},{key:"trackVastError",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o0&&void 0!==arguments[0]?arguments[0]:{};this.rootURL="",this.remainingAds=[],this.parentURLs=[],this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.maxWrapperDepth=e.wrapperLimit||10,this.fetchingOptions={timeout:e.timeout,withCredentials:e.withCredentials},this.urlHandler=e.urlhandler||ln}},{key:"getRemainingAds",value:function(e){var t=this;if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));var n=e?yt.flatten(this.remainingAds):this.remainingAds.shift();return this.errorURLTemplates=[],this.parentURLs=[],this.resolveAds(n,{wrapperDepth:0,originalUrl:this.rootURL}).then((function(e){return t.buildVASTResponse(e)}))}},{key:"getAndParseVAST",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),this.rootURL=e,this.fetchVAST(e).then((function(r){return n.originalUrl=e,n.isRootVAST=!0,t.parse(r,n).then((function(e){return t.buildVASTResponse(e)}))}))}},{key:"parseVAST",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),n.isRootVAST=!0,this.parse(e,n).then((function(e){return t.buildVASTResponse(e)}))}},{key:"buildVASTResponse",value:function(e){var t=new fn;return t.ads=e,t.errorURLTemplates=this.getErrorURLTemplates(),this.completeWrapperResolving(t),t}},{key:"parse",value:function(e,t){var n=t.resolveAll,r=void 0===n||n,o=t.wrapperSequence,i=void 0===o?null:o,a=t.originalUrl,A=void 0===a?null:a,s=t.wrapperDepth,c=void 0===s?0:s,u=t.isRootVAST,l=void 0!==u&&u;if(!e||!e.documentElement||"VAST"!==e.documentElement.nodeName)return Promise.reject(new Error("Invalid VAST XMLDocument"));var f=[],p=e.documentElement.childNodes;for(var d in p){var g=p[d];if("Error"===g.nodeName){var h=xt(g);l?this.rootErrorURLTemplates.push(h):this.errorURLTemplates.push(h)}if("Ad"===g.nodeName){var v=Nt(g);v?f.push(v):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}var m=f.length,C=f[m-1];return 1===m&&null!=i&&C&&!C.sequence&&(C.sequence=i),!1===r&&(this.remainingAds=St(f),f=this.remainingAds.shift()),this.resolveAds(f,{wrapperDepth:c,originalUrl:A})}},{key:"resolveAds",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,r=n.wrapperDepth,o=n.originalUrl,i=[];return t.forEach((function(t){var n=e.resolveWrappers(t,r,o);i.push(n)})),Promise.all(i).then((function(t){var n=yt.flatten(t);if(!n&&e.remainingAds.length>0){var i=e.remainingAds.shift();return e.resolveAds(i,{wrapperDepth:r,originalUrl:o})}return n}))}},{key:"resolveWrappers",value:function(e,t,n){var r=this;return new Promise((function(o,i){if(t++,!e.nextWrapperURL)return delete e.nextWrapperURL,o(e);if(t>=r.maxWrapperDepth||-1!==r.parentURLs.indexOf(e.nextWrapperURL))return e.errorCode=302,delete e.nextWrapperURL,o(e);e.nextWrapperURL=Et(e.nextWrapperURL,n);var a=e.sequence;n=e.nextWrapperURL,r.fetchVAST(e.nextWrapperURL,t,n).then((function(i){return r.parse(i,{originalUrl:n,wrapperSequence:a,wrapperDepth:t}).then((function(t){if(delete e.nextWrapperURL,0===t.length)return e.creatives=[],o(e);t.forEach((function(t){t&&Tt(t,e)})),o(t)}))})).catch((function(t){e.errorCode=301,e.errorMessage=t.message,o(e)}))}))}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;t>=0;t--){var n=e.ads[t];(n.errorCode||0===n.creatives.length)&&(this.trackVastError(n.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:n.errorCode||303},{ERRORMESSAGE:n.errorMessage||""},{extensions:n.extensions},{system:n.system}),e.ads.splice(t,1))}}}]),n}(_t),gn=null,hn={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},vn=function(){function e(){ct(this,e),this.storage=this.initStorage()}return st(e,[{key:"initStorage",value:function(){if(gn)return gn;try{gn="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){gn=null}return gn&&!this.isStorageDisabled(gn)||(gn=hn).clear(),gn}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),mn=function(){function e(t,n,r){ct(this,e),this.cappingFreeLunch=t||0,this.cappingMinimumTimeInterval=n||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new dn,this.storage=r||new vn,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return st(e,[{key:"getParser",value:function(){return this.vastParser}},{key:"lastSuccessfulAd",get:function(){return this.storage.getItem("vast-client-last-successful-ad")},set:function(e){this.storage.setItem("vast-client-last-successful-ad",e)}},{key:"totalCalls",get:function(){return this.storage.getItem("vast-client-total-calls")},set:function(e){this.storage.setItem("vast-client-total-calls",e)}},{key:"totalCallsTimeout",get:function(){return this.storage.getItem("vast-client-total-calls-timeout")},set:function(e){this.storage.setItem("vast-client-total-calls-timeout",e)}},{key:"hasRemainingAds",value:function(){return this.vastParser.remainingAds.length>0}},{key:"getNextAds",value:function(e){return this.vastParser.getRemainingAds(e)}},{key:"get",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Date.now();return(n=Object.assign(this.defaultOptions,n)).hasOwnProperty("resolveAll")||(n.resolveAll=!1),this.totalCallsTimeout=t.totalCalls)return i(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(t.totalCalls,"/").concat(t.cappingFreeLunch)));var a=r-t.lastSuccessfulAd;if(a<0)t.lastSuccessfulAd=0;else if(a3&&void 0!==arguments[3]?arguments[3]:null;for(var A in ct(this,n),(i=t.call(this)).ad=r,i.creative=o,i.variation=a,i.muted=!1,i.impressed=!1,i.skippable=!1,i.trackingEvents={},i._alreadyTriggeredQuartiles={},i.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],i.creative.trackingEvents){var s=i.creative.trackingEvents[A];i.trackingEvents[A]=s.slice(0)}return i.creative instanceof Rt?i._initLinearTracking():i._initVariationTracking(),e&&i.on("start",(function(){e.lastSuccessfulAd=Date.now()})),i}return st(n,[{key:"_initLinearTracking",value:function(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}},{key:"_initVariationTracking",value:function(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(var e in this.variation.trackingEvents){var t=this.variation.trackingEvents[e];this.trackingEvents[e]?this.trackingEvents[e]=this.trackingEvents[e].concat(t.slice(0)):this.trackingEvents[e]=t.slice(0)}this.variation instanceof Ft?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):this.variation instanceof pt&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}},{key:"setDuration",value:function(e){this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}}},{key:"setProgress",value:function(e){var t=this,n=this.skipDelay||-1;if(-1===n||this.skippable||(n>e?this.emit("skip-countdown",n-e):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){var r=[];if(e>0){var o=Math.round(e/this.assetDuration*100);for(var i in r.push("start"),r.push("progress-".concat(o,"%")),r.push("progress-".concat(Math.round(e))),this.quartiles)this.isQuartileReached(i,this.quartiles[i],e)&&(r.push(i),this._alreadyTriggeredQuartiles[i]=!0)}r.forEach((function(e){t.track(e,!0)})),e0&&void 0!==arguments[0]?arguments[0]:null;this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates);var t=this.clickThroughURLTemplate||e;if(t){var n=this.linear?{CONTENTPLAYHEAD:this.progressFormatted()}:{},r=yt.resolveURLTemplates([t],n)[0];this.emit("clickthrough",r)}}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"closeLinear"===e&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close");var n=this.trackingEvents[e],r=this.emitAlwaysEvents.indexOf(e)>-1;n?(this.emit(e,""),this.trackURLs(n)):r&&this.emit(e,""),t&&(delete this.trackingEvents[e],r&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}},{key:"trackURLs",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(t.ASSETURI=this.creative.mediaFiles[0].fileURL),t.CONTENTPLAYHEAD=this.progressFormatted()),yt.track(e,t)}},{key:"progressFormatted",value:function(){var e=parseInt(this.progress),t=e/3600;t.length<2&&(t="0".concat(t));var n=e/60%60;n.length<2&&(n="0".concat(n));var r=e%60;return r.length<2&&(r="0".concat(n)),"".concat(t,":").concat(n,":").concat(r,".").concat(parseInt(100*(this.progress-e)))}}]),n}(_t),yn=function(e,t,n,r){var o,i={},a={started:!1,active:!1,isVideoEnded:!1,lang:n.getLanguage()},A=null,s="",c=null,u="",l="",f=!1,p=n.getBrowser(),d="Android"===p.os||"iOS"===p.os;(o=document.createElement("div")).setAttribute("class","op-ads"),o.setAttribute("id","op-ads"),n.getContainer().append(o),(c=document.createElement("video")).setAttribute("playsinline","true"),c.setAttribute("title","Advertisement"),c.setAttribute("class","op-ads-vast-video"),(l=document.createElement("div")).setAttribute("class","op-ads-button"),(u=document.createElement("div")).setAttribute("class","op-ads-textview"),l.append(u),o.append(c),o.append(l),s=o;var g=new mn,h=null,v=null,m=function(e){console.log(e),c.style.display="none",t.trigger(se,{code:e.code,message:e.message}),a.active=!1,a.started=!0,t.play()};return i.isActive=function(){return a.active},i.started=function(){return a.started},i.play=function(){return a.started?c.play():new Promise((function(o,i){!function s(){t.metaLoaded()?(OvenPlayerConsole.log("VAST : main contents meta loaded."),function(){OvenPlayerConsole.log("VAST : checkAutoplaySupport() ");var n=document.createElement("video");n.setAttribute("playsinline","true"),n.src=Xe,n.load(),c.load(),d&&t.getName()!==le&&e.load();var r=function(e,t){f=e,n.pause(),n.remove()};return new Promise((function(e,t){if(n.play){var o=n.play();void 0!==o?o.then((function(){OvenPlayerConsole.log("VAST : auto play allowed."),r(!0),e()})).catch((function(t){OvenPlayerConsole.log("VAST : auto play failed",t.message),r(!1),e()})):(OvenPlayerConsole.log("VAST : promise not support"),r(!0),e())}else OvenPlayerConsole.log("VAST : !temporarySupportCheckVideo.play"),r(!0),e()}))}().then((function(){n.isAutoStart()&&!f?(OvenPlayerConsole.log("VAST : autoplayAllowed : false"),a.started=!1,i(new Error("autoplayNotAllowed"))):(g.get(r).then((function(n){if(OvenPlayerConsole.log("VAST : initRequest()"),!(v=n.ads[0]))throw{code:401,message:"File not found. Unable to find Linear/MediaFile from URI."};h=new Cn(g,v,v.creatives[0]),OvenPlayerConsole.log("VAST : created ad tracker."),A=function(e,t,n,r,o,i,a){var A={},s={},c=ze(i),u=ze(o),l=ze(e);n.on(Le,(function(t){t.mute?e.muted=!0:(e.muted=!1,e.volume=t.volume/100)}),s);var f=function(){r.active=!1,u.hide(),!r.started||0!==n.getPosition()&&r.isVideoEnded||(l.hide(),n.play()),n.trigger(Ae)},p=function(n){c.hasClass("videoAdUiAction")&&(t.skip(),e.pause(),f())};return i.addEventListener("click",p,!1),A.error=function(){OvenPlayerConsole.log("VAST : listener : error.",e.error),console.log("VAST : listener : error.",e.error);var n={},r=e.error&&e.error.code||0;2===r?(n.code=402,n.message="Timeout of MediaFile URI."):3===r?(n.code=405,n.message="Problem displaying MediaFile. Video player found a MediaFile with supported type but couldn’t display it. MediaFile may include: unsupported codecs, different MIME type than MediaFile@type, unsupported delivery method, etc."):4===r?(n.code=403,n.message="Couldn’t find MediaFile that is supported by this video player, based on the attributes of the MediaFile element."):(n.code=400,n.message="General Linear error. Video player is unable to display the Linear Ad."),t.errorWithCode(n.code),a("405")},A.canplay=function(){},A.ended=function(){t.complete(),f()},A.click=function(e){t.click()},A.play=function(){t.setPaused(!1)},A.pause=function(){t.setPaused(!0)},A.timeupdate=function(r){t.setProgress(r.target.currentTime),n.trigger(Ie,{duration:e.duration,position:e.currentTime})},A.volumechange=function(e){OvenPlayerConsole.log("VAST : listener : Ad Video Volumechange."),t.setMuted(e.target.muted)},A.loadedmetadata=function(){OvenPlayerConsole.log("VAST : listener : Ad CONTENT LOADED ."),ee===n.getState()&&n.pause(),t.trackImpression(),n.trigger(oe,{remaining:e.duration,isLinear:!0}),e.play()},t.on("skip",(function(){OvenPlayerConsole.log("VAST : listener : skipped")})),t.on("mute",(function(){OvenPlayerConsole.log("VAST : listener : muted")})),t.on("unmute",(function(){OvenPlayerConsole.log("VAST : listener : unmuted")})),t.on("resume",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker resumed."),r.started&&n.setState(ie)})),t.on("pause",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker paused."),n.setState(ae)})),t.on("clickthrough",(function(e){OvenPlayerConsole.log("VAST : listener : clickthrough :",e),window.open(e,"_blank")})),t.on("skip-countdown",(function(e){0===e?("ko"===r.lang?c.html("광고 건너뛰기"):c.html("Ad Skip"),c.addClass("videoAdUiAction")):"ko"===r.lang?c.html(parseInt(e)+1+"초 후에 이 광고를 건너뛸 수 있습니다."):c.html("You can skip this ad in "+(parseInt(e)+1))})),t.on("rewind",(function(){OvenPlayerConsole.log("VAST : listener : rewind")})),t.on("start",(function(){OvenPlayerConsole.log("VAST : listener : started"),r.started=!0,r.active=!0,l.show(),u.show(),n.trigger(ke,{isLinear:!0}),n.setState(ie)})),t.on("firstQuartile",(function(){OvenPlayerConsole.log("VAST : listener : firstQuartile")})),t.on("midpoint",(function(){OvenPlayerConsole.log("VAST : listener : midpoint")})),t.on("thirdQuartile",(function(){OvenPlayerConsole.log("VAST : listener : thirdQuartile")})),t.on("creativeView",(function(){OvenPlayerConsole.log("VAST : listener : creativeView")})),Object.keys(A).forEach((function(t){e.removeEventListener(t,A[t]),e.addEventListener(t,A[t])})),s.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),i.removeEventListener("click",p,!1),Object.keys(A).forEach((function(t){e.removeEventListener(t,A[t])}))},s}(c,h,t,a,l,u,m);var r="";v.creatives&&v.creatives.length>0&&v.creatives[0].mediaFiles&&v.creatives[0].mediaFiles.length>0&&v.creatives[0].mediaFiles[0].fileURL&&(r=v.creatives[0].mediaFiles[0].fileURL,OvenPlayerConsole.log("VAST : media url : ",r)),c.src=r,c.volume=e.volume,c.muted=e.muted})).catch((function(e){m(e)})),o())}))):setTimeout(s,100)}()}))},i.pause=function(){c.pause()},i.videoEndedCallback=function(e){e(),a.isVideoEnded=!0},i.destroy=function(){A&&(A.destroy(),A=null),h=null,g=null,s.remove()},i},bn=function(e,t,n){OvenPlayerConsole.log("[Provider] loaded. ");var r={};Ge(r);var o=e.element,i=null,a=null;e.adTagUrl&&(OvenPlayerConsole.log("[Provider] Ad Client - ",t.getAdClient()),(i="vast"===t.getAdClient()?yn(o,r,t,e.adTagUrl):et(o,r,t,e.adTagUrl))||console.log("Can not load due to google ima for Ads.")),a=function(e,t,n,r){var o={};OvenPlayerConsole.log("EventListener loaded.",e,t);var i={},a=-1,A=e;return o.canplay=function(){t.setCanSeek(!0),t.trigger("bufferFull"),OvenPlayerConsole.log("EventListener : on canplay")},o.durationchange=function(){o.progress(),OvenPlayerConsole.log("EventListener : on durationchange"),t.trigger("durationChanged")},o.ended=function(){OvenPlayerConsole.log("EventListener : on ended"),A.pause(),t.getState()!==X&&t.getState()!==q&&t.getState()!==te&&(n?n((function(){t.setState(q)})):t.setState(q))},o.loadeddata=function(){},o.loadedmetadata=function(){var e=t.getSources(),n=t.getCurrentSource(),r=n>-1?e[n].type:"",o={duration:t.isLive()?1/0:A.duration,type:r};t.setMetaLoaded(),OvenPlayerConsole.log("EventListener : on loadedmetadata",o),t.trigger(Me,o)},o.pause=function(){return t.getState()!==q&&t.getState()!==te&&!A.ended&&!A.error&&A.currentTime!==A.duration&&(OvenPlayerConsole.log("EventListener : on pause"),void t.setState($))},o.loadstart=function(){r&&!r.getConfig().showBigPlayButton&&r.getConfig().autoStart&&t.setState(ne)},o.play=function(){a=-1,A.paused||t.getState()===ee||t.setState(ne)},o.playing=function(){OvenPlayerConsole.log("EventListener : on playing"),a<0&&t.setState(ee)},o.progress=function(){var e=A.buffered;if(!e)return!1;var n,r=A.duration,o=A.currentTime,i=(n=(e.length>0?e.end(e.length-1):0)/r,Math.max(Math.min(n,1),0));t.setBuffer(100*i),t.trigger(Se,{bufferPercent:100*i,position:o,duration:r}),OvenPlayerConsole.log("EventListener : on progress",100*i)},o.timeupdate=function(){var e=A.currentTime,n=A.duration;if(!isNaN(n)){if(e>n)return A.pause(),void t.setState(q);var r=t.getSources()[t.getCurrentSource()].sectionStart;r&&eo&&t.getState()===ee)return t.stop(),void t.setState(q);n>9e15&&(n=1/0),t.isSeeking()||A.paused||t.getState()!==re&&t.getState()!==ne&&t.getState()!==ie||function(e,t){return e.toFixed(2)===t.toFixed(2)}(a,e)||(a=-1,t.setState(ee)),r&&r>0&&(e-=r)<0&&(e=0),o&&(n=o),r&&(n-=r),(t.getState()===ee||t.isSeeking())&&t.trigger(Te,{position:e,duration:n})}},o.seeking=function(){t.setSeeking(!0),OvenPlayerConsole.log("EventListener : on seeking",A.currentTime),t.trigger("seek",{position:A.currentTime})},o.seeked=function(){t.isSeeking()&&(OvenPlayerConsole.log("EventListener : on seeked"),t.setSeeking(!1),t.trigger("seeked"))},o.stalled=function(){OvenPlayerConsole.log("EventListener : on stalled")},o.waiting=function(){OvenPlayerConsole.log("EventListener : on waiting",t.getState()),t.isSeeking()?t.setState(ne):t.getState()===ee&&(a=A.currentTime,t.setState(re))},o.volumechange=function(){OvenPlayerConsole.log("EventListener : on volumechange",Math.round(100*A.volume)),t.trigger(Le,{volume:Math.round(100*A.volume),mute:A.muted})},o.error=function(){var e={0:300,1:301,2:302,3:303,4:304}[A.error&&A.error.code||0]||0;OvenPlayerConsole.log("EventListener : on error",e),qe(We.codes[e],t)},Object.keys(o).forEach((function(e){A.removeEventListener(e,o[e]),A.addEventListener(e,o[e])})),i.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),Object.keys(o).forEach((function(e){A.removeEventListener(e,o[e])}))},i}(o,r,i?i.videoEndedCallback:null,t),o.playbackRate=o.defaultPlaybackRate=t.getPlaybackRate();var A=function(i){var a=e.sources[e.currentSource];if(e.framerate=a.framerate,r.setVolume(t.getVolume()),e.framerate||t.setTimecodeMode(!0),n)n(a,i);else{OvenPlayerConsole.log("source loaded : ",a,"lastPlayPosition : "+i);var A=o.src;a.file!==A&&(o.src=a.file,(A||""===A)&&o.load()),r.on(Me,(function(){i>0&&r.seek(i)}))}};return r.getName=function(){return e.name},r.getMse=function(){return e.mse},r.getMediaElement=function(){return e.element},r.canSeek=function(){return e.canSeek},r.setCanSeek=function(t){e.canSeek=t},r.isSeeking=function(){return e.seeking},r.setSeeking=function(t){e.seeking=t},r.setMetaLoaded=function(){e.isLoaded=!0},r.metaLoaded=function(){return e.isLoaded},r.setState=function(t){if(e.state!==t){var n=e.state;if(OvenPlayerConsole.log("Provider : setState()",t),n===ie&&(t===te||t===X))return!1;switch(OvenPlayerConsole.log("Provider : triggerSatatus",t),t){case q:r.trigger("complete");break;case $:r.trigger(ye,{prevState:e.state,newstate:$});break;case ae:r.trigger(ye,{prevState:e.state,newstate:ae});break;case ee:r.trigger(be,{prevState:e.state,newstate:ee});break;case ie:r.trigger(be,{prevState:e.state,newstate:ie})}e.state=t,r.trigger(Ce,{prevstate:n,newstate:e.state})}},r.getState=function(){return e.state},r.setBuffer=function(t){e.buffer=t},r.getBuffer=function(){return e.buffer},r.isLive=function(){return!!e.isLive||o.duration===1/0},r.getDuration=function(){return r.isLive()?1/0:o.duration},r.getDvrWindow=function(){return e.dvrWindow},r.getPosition=function(){return o?o.currentTime:0},r.setVolume=function(e){if(!o)return!1;o.volume=e/100,t.setVolume(e)},r.getVolume=function(){return t.getVolume()},r.setMute=function(e){if(!o)return!1;if(void 0===e){var n=t.isMute();o.muted=!n,t.setMute(!n),r.trigger(Re,{mute:t.isMute()})}else o.muted=e,t.setMute(e),r.trigger(Re,{mute:t.isMute()});return o.muted},r.getMute=function(){return t.isMute()},r.preload=function(n,o){return e.sources=n,e.currentSource=$e(n,t),A(o||0),new Promise((function(e,n){t.isMute()&&r.setMute(!0),t.getVolume()&&r.setVolume(t.getVolume()),e()}))},r.load=function(n){e.sources=n,e.currentSource=$e(n,t),A(0)},r.play=function(){if(OvenPlayerConsole.log("Provider : play()"),!o)return!1;if(r.getState()!==ee)if(i&&i.isActive()||i&&!i.started())i.play().then((function(e){OvenPlayerConsole.log("Provider : ads play success")})).catch((function(e){OvenPlayerConsole.log("Provider : ads play fail",e)}));else{var e=o.play();void 0!==e?e.then((function(){OvenPlayerConsole.log("Provider : video play success")})).catch((function(e){OvenPlayerConsole.log("Provider : video play error",e.message)})):OvenPlayerConsole.log("Provider : video play success (ie)")}},r.pause=function(){if(OvenPlayerConsole.log("Provider : pause()"),!o)return!1;r.getState()===ee?o.pause():r.getState()===ie&&i.pause()},r.seek=function(e){if(!o)return!1;o.currentTime=e},r.setPlaybackRate=function(e){return!!o&&(r.trigger("playbackRateChanged",{playbackRate:e}),o.playbackRate=o.defaultPlaybackRate=e)},r.getPlaybackRate=function(){return o?o.playbackRate:0},r.getSources=function(){return o?e.sources.map((function(e,t){var n={file:e.file,type:e.type,label:e.label,index:t,sectionStart:e.sectionStart,sectionEnd:e.sectionEnd,gridThumbnail:e.gridThumbnail};return e.lowLatency&&(n.lowLatency=e.lowLatency),n})):[]},r.getCurrentSource=function(){return e.currentSource},r.setCurrentSource=function(n,i){if(n>-1&&e.sources&&e.sources.length>n)return OvenPlayerConsole.log("source changed : "+n),e.currentSource=n,t.setSourceIndex(n),r.setState(X),i&&A(o.currentTime||0),e.currentSource},r.getQualityLevels=function(){return o?e.qualityLevels:[]},r.getCurrentQuality=function(){return o?e.currentQuality:null},r.setCurrentQuality=function(e){},r.getAudioTracks=function(){return o?e.audioTracks:[]},r.getCurrentAudioTrack=function(){return o?e.currentAudioTrack:[]},r.setCurrentAudioTrack=function(e){},r.isAutoQuality=function(){},r.setAutoQuality=function(e){},r.getFramerate=function(){return e.framerate},r.setFramerate=function(t){return e.framerate=t},r.seekFrame=function(t){var n=e.framerate,i=(o.currentTime*n+t)/n;i+=1e-5,r.pause(),r.seek(i)},r.stop=function(){if(!o)return!1;for(OvenPlayerConsole.log("CORE : stop() "),o.removeAttribute("preload"),o.removeAttribute("src");o.firstChild;)o.removeChild(o.firstChild);r.pause(),r.setState(X)},r.destroy=function(){if(!o)return!1;r.stop(),a.destroy(),i&&(i.destroy(),i=null),r.off(),OvenPlayerConsole.log("CORE : destroy() player stop, listener, event destroied")},r.super=function(e){var t=r[e];return function(){return t.apply(r,arguments)}},r},wn=function(e,t,n){var r=bn({name:ce,element:e,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:X,buffer:0,framerate:0,currentQuality:-1,qualityLevels:[],currentAudioTrack:-1,audioTracks:[],currentSource:-1,sources:[],adTagUrl:n},t,null),o=r.super("destroy");return OvenPlayerConsole.log("HTML5 PROVIDER LOADED."),r.destroy=function(){OvenPlayerConsole.log("HTML5 : PROVIDER DESTROYED."),o()},r},En=function(e,t,n,r,o,a,A,s){var c={},u={},l=null,f=!1,p=null,d=null,g={},h=!1,v=!1,m=null,C=!1;A.getConfig().webrtcConfig&&!0===A.getConfig().webrtcConfig.recoverPacketLoss&&(v=!0);var y=!0;A.getConfig().webrtcConfig&&!1===A.getConfig().webrtcConfig.generatePublicCandidate&&(y=A.getConfig().webrtcConfig.generatePublicCandidate);var b=Y(),w=null;function E(e){var t=null;return d&&e===d.id?t=d.peerConnection:g[e]&&(t=g[e].peerConnection),t}function B(e){e.statisticsTimer&&clearTimeout(e.statisticsTimer),e.status||(e.status={},e.status.lostPacketsArr=[],e.status.slotLength=8,e.status.prevPacketsLost=0,e.status.avg8Losses=0,e.status.avgMoreThanThresholdCount=0,e.status.threshold=40);var t=e.status.lostPacketsArr,n=e.status.slotLength,r=e.status.prevPacketsLost,o=e.status.avg8Losses,a=e.status.threshold;e.statisticsTimer=setTimeout((function(){if(!e.peerConnection)return!1;e.peerConnection.getStats().then((function(s){s&&A.getConfig().autoFallback&&s&&(s.forEach((function(A){if("inbound-rtp"===A.type&&"video"===A.kind&&!A.isRemote){var s=parseInt(A.packetsLost)-parseInt(r);t.push(parseInt(A.packetsLost)-parseInt(r)),t.length>n&&t.shift(),t.length===n&&(o=i().reduce(t,(function(e,t){return e+t}),0)/n,OvenPlayerConsole.log("Last8 LOST PACKET AVG : "+o,"Current Packet LOST: "+s,"Total Packet Lost: "+A.packetsLost,t),o>a?(e.status.avgMoreThanThresholdCount=e.status.avgMoreThanThresholdCount+1,e.status.avgMoreThanThresholdCount>=60&&(OvenPlayerConsole.log("NETWORK UNSTABLED!!! "),M(We.codes[510]))):e.status.avgMoreThanThresholdCount=0),e.status.prevPacketsLost=A.packetsLost}})),B(e))}))}),2e3)}function x(o,a,s,u,f){var g={};if(A.getConfig().webrtcConfig&&A.getConfig().webrtcConfig.iceServers)g.iceServers=A.getConfig().webrtcConfig.iceServers,A.getConfig().webrtcConfig.iceTransportPolicy&&(g.iceTransportPolicy=A.getConfig().webrtcConfig.iceTransportPolicy);else if(f){g.iceServers=[];for(var m=0;m-1){b=!0;break}if(!b&&y.urls.length>0){var x=i().clone(y.urls[0]),k=S(x);w&&k&&y.urls.push(x.replace(k,w))}y.username=C.username||C.user_name,y.credential=C.credential,g.iceServers.push(y)}g.iceTransportPolicy="relay"}else g=c;OvenPlayerConsole.log("Main Peer Connection Config : ",g);var T=null;try{T=new RTCPeerConnection(g),e.trigger("peerConnectionPrepared",T)}catch(e){var R=We.codes[506];return R.error=e,void M(R)}d={id:o,peerId:a,peerConnection:T},T.setRemoteDescription(new RTCSessionDescription(s)).then((function(){T.createAnswer().then((function(e){var t=function(e){for(var t=e.split("\r\n"),n=-1,r=0;r-1&&t[r].indexOf("opus")>-1){n=t[r].split(" ")[0].split(":")[1];break}return n}(s.sdp);t>-1&&function(e,t){for(var n=e.split("\r\n"),r=!1,o=0;o-1){n[o].indexOf("stereo=1")>-1&&(r=!0);break}return r}(s.sdp,t)&&(e.sdp=function(e,t){for(var n=e.split("\r\n"),r=0;r-1){-1===n[r].indexOf("stereo=1")&&(n[r]=n[r]+";stereo=1");break}return n.join("\r\n")}(e.sdp,t)),OvenPlayerConsole.log("Local SDP",e),O(l,{id:o,peer_id:a,command:"answer",sdp:e}),OvenPlayerConsole.log("create Host Answer : success"),T.setLocalDescription(e).then((function(){})).catch((function(e){var t=We.codes[505];t.error=e,M(t)}))})).catch((function(e){var t=We.codes[504];t.error=e,M(t)}))})).catch((function(e){var t=We.codes[503];t.error=e,M(t)})),u&&L(T,u),T.onicecandidate=function(e){e.candidate&&(OvenPlayerConsole.log("WebRTCLoader send candidate to server : ",e.candidate),O(l,{id:o,peer_id:a,command:"candidate",candidates:[e.candidate]}))},T.onconnectionstatechange=function(e){OvenPlayerConsole.log("[on connection state change]",T.connectionState,e),"connected"===T.connectionState&&r&&r()},T.onicecandidateerror=function(e){},T.onicegatheringstatechange=function(e){},T.oniceconnectionstatechange=function(e){OvenPlayerConsole.log("[on ice connection state change]",T.iceConnectionState,e),"connected"===T.iceConnectionState&&r&&r(),("disconnected"===T.iceConnectionState||"closed"===T.iceConnectionState)&&(h||d&&M(We.codes[511]))},T.ontrack=function(e){if(OvenPlayerConsole.log("stream received."),OvenPlayerConsole.log("Recovery On Packet Loss :",v),v&&B(d),p=e.streams[0],n(e.streams[0]),A.getConfig().webrtcConfig&&A.getConfig().webrtcConfig.playoutDelayHint)for(var t=A.getConfig().webrtcConfig.playoutDelayHint,r=d.peerConnection.getReceivers(),o=0;o0){for(var n in g){var r=g[n].peerConnection;r&&(OvenPlayerConsole.log("Closing client peer connection..."),r.close(),r=null)}g={}}l?(OvenPlayerConsole.log("Closing websocket connection..."),OvenPlayerConsole.log("Send Signaling : Stop."),1===l.readyState&&(h=!0,d&&O(l,{command:"stop",id:d.id}),l.close())):h=!1,l=null,t&&(o&&o(t),a(t,e))}function O(e,t){e&&e.send(JSON.stringify(t))}return w=window.onbeforeunload,window.onbeforeunload=function(e){w&&w(e),OvenPlayerConsole.log("This calls auto when browser closed."),M()},e.setCurrentQuality=function(e){if(!m)return-1;var t=m.renditions[e];return t?(O(l,{command:"change_rendition",id:d.id,rendition_name:t.name,auto:!1}),C=!1,s.currentQuality=e,s.currentQuality):s.currentQuality},e.isAutoQuality=function(){return C},e.setAutoQuality=function(e){O(l,{command:"change_rendition",id:d.id,auto:e}),C=e},u.connect=function(){OvenPlayerConsole.log("WebRTCLoader connecting..."),OvenPlayerConsole.log("WebRTCLoader url : "+t),R()},u.destroy=function(){h=!0,M(),window.onbeforeunload=w,w=null},u},Bn=function(e,t,n){var r={},o=null,i=null,a=null,A=null,s=null,c={name:ue,element:e,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:X,buffer:0,framerate:0,currentQuality:-1,currentSource:-1,qualityLevels:[],sources:[],adTagUrl:n},u=1e4,l=0,f=null,p=!1;function d(){if(Ve(A.file,A.type)){clearTimeout(f),OvenPlayerConsole.log("WEBRTC : onBeforeLoad : ",A),o&&(o.destroy(),o=null);var n=null,i=null;l>0&&(n=function(){clearTimeout(f)},i=function(){clearTimeout(f),performance.now(),p=!0}),o=En(r,A.file,(function(t){if(e.srcObject&&(e.srcObject=null),s&&(s.close(),s=null),e.srcObject=t,t.getAudioTracks().length>0){var n=window.AudioContext||window.webkitAudioContext;(function(e){var t=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent),n=(/iPhone|iPad|iPod/i.test(navigator.userAgent),!1);t&&"suspended"===e.state&&document.addEventListener("touchend",(function(){n||"running"===e.state||(e.resume(),n=!0)}))})(s=new n),s.createMediaStreamSource(t)}}),i,n,qe,t,c),performance.now(),o.connect(),l>0&&(r.once(Ce,(function(e){p||e.newstate===X&&(clearTimeout(f),g())})),r.once(me,(function(){p=!1})),f=setTimeout((function(){if(l>0)p||(g(),d());else{g();var e=We.codes[512];qe(e,r)}l--}),u))}}function g(){o&&(o.destroy(),o=null,e.srcObject=null)}return r=bn(c,t,(function(e){var n=t.getConfig();n.webrtcConfig&&("number"==typeof n.webrtcConfig.connectionTimeout&&n.webrtcConfig.connectionTimeout>0&&(u=n.webrtcConfig.connectionTimeout),"number"==typeof n.webrtcConfig.timeoutMaxRetry&&n.webrtcConfig.timeoutMaxRetry>0&&(l=n.webrtcConfig.timeoutMaxRetry)),A=e,d()})),i=r.super("destroy"),a=r.super("play"),OvenPlayerConsole.log("WEBRTC PROVIDER LOADED."),r.removeStream=function(){e.srcObject=null},r.destroy=function(){clearTimeout(f),g(),OvenPlayerConsole.log("WEBRTC : PROVIDER DESTROYED."),i()},r.play=function(){l>0&&!p&&d(),a()},r},xn=function(e,t,n){var r=t?1e3:1024;if(Math.abs(e)=r&&a=0&&r.seek(t)})),o.on(Hls.Events.LEVEL_SWITCHED,(function(e,t){f.currentQuality=t.level,r.trigger(Qe,{isAuto:o.autoLevelEnabled,currentQuality:f.currentQuality,type:"render"})})),o.on(Hls.Events.AUDIO_TRACK_SWITCHED,(function(e,t){f.currentAudioTrack=t.id,r.trigger(Ne,{currentAudioTrack:f.currentAudioTrack})})),o.on(Hls.Events.LEVEL_UPDATED,(function(e,t){t&&t.details&&(f.dvrWindow=t.details.totalduration)})),o.on(Hls.Events.ERROR,(function(t,n){if(n&&n.networkDetails&&202===n.networkDetails.status)return A&&(clearTimeout(A),A=null),r.setState(ne),void(A=setTimeout((function(){o&&(r.stop(),o.stopLoad(),o.loadSource(e.file))}),1e3));if(n.fatal){var i=302;n&&n.networkDetails&&400===n.networkDetails.status?i=306:n&&n.networkDetails&&403===n.networkDetails.status?i=307:n&&n.networkDetails&&406===n.networkDetails.status&&(i=308);var a=We.codes[i];a.error=n.details,qe(a,r)}})),r.on(Ce,(function(e){s||e.prevstate!==ne||e.newstate!==X||(A&&(clearTimeout(A),A=null),o&&o.stopLoad())}))})),r.setCurrentQuality=function(e){return o.currentLevel=e,f.currentQuality=e,f.currentQuality},r.isAutoQuality=function(){return o.autoLevelEnabled},r.setAutoQuality=function(e){o.currentLevel=e?-1:o.currentLevel},r.setCurrentAudioTrack=function(e){return o.audioTrack=e,f.currentAudioTrack=e,f.currentAudioTrack},r.getDuration=function(){return e.duration},i=r.super("stop"),r.stop=function(){A&&(clearTimeout(A),A=null),o&&o.stopLoad(),i()},a=r.super("destroy"),r.destroy=function(){A&&(clearTimeout(A),A=null),o&&(o.destroy(),r.trigger("hlsDestroyed")),o=null,OvenPlayerConsole.log("HLS : PROVIDER DESTROYED."),a()},OvenPlayerConsole.log("HLS PROVIDER LOADED.")}catch(e){var p=We.codes[106];throw p.error=e,p}return r},Sn=function(e){var t={};Ge(t),OvenPlayerConsole.log("API loaded.");var n=function(e){var t={},n={playlist:[],currentIndex:0},r=Ke();OvenPlayerConsole.log("PlaylistManager loaded.");var o=function(e){if(e&&(e.file||e.host||e.application||e.stream)){var t=Object.assign({},{default:!1},e);t.file=a(""+t.file),t.host&&t.application&&t.stream&&(t.file=t.host+"/"+t.application+"/stream/"+t.stream,delete t.host,delete t.application,delete t.stream);var n=/^[^/]+\/(?:x-)?([^/]+)$/;if(n.test(t.type)&&(t.mimeType=t.type,t.type=t.type.replace(n,"$1")),_e(t.file)?t.type="rtmp":Ve(t.file)?t.type="webrtc":He(t.file,t.type)?t.type="hls":Je(t.file,t.type)?t.type="dash":t.type||(t.type=A(t.file)),t.lowLatency&&(t.lowLatency=t.lowLatency),t.type){switch(t.type){case"m3u8":case"vnd.apple.mpegurl":t.type="hls";break;case"m4a":t.type="aac";break;case"smil":t.type="rtmp"}return Object.keys(t).forEach((function(e){""===t[e]&&delete t[e]})),t}}};return t.initPlaylist=function(e,t){OvenPlayerConsole.log("PlaylistManager setPlaylist() ",e);var a=(i().isArray(e)?e:[e]).map((function(e){i().isArray(e.tracks)||delete e.tracks;var n=Object.assign({},{sources:[],tracks:[],title:""},e);n.sources!==Object(n.sources)||i().isArray(n.sources)||(n.sources=[o(n.sources)]),i().isArray(n.sources)&&0!==n.sources.length||(n.sources=[o(n)]),i().isArray(n.sources)&&0!==n.sources.length||(e.levels?n.sources=e.levels:n.sources=[o(e)]);for(var a=0;a0}))||[];return n.playlist=a,a},t.getPlaylist=function(){return OvenPlayerConsole.log("PlaylistManager getPlaylist() ",n.playlist),n.playlist},t.getCurrentPlayList=function(){return n.playlist[n.currentIndex]?n.playlist[n.currentIndex]:[]},t.getCurrentPlaylistIndex=function(){return n.currentIndex},t.setCurrentPlaylist=function(t){return n.playlist[t]&&(n.currentIndex=t,e.trigger(ge,n.currentIndex)),n.currentIndex},t.getCurrentSources=function(){return n.playlist[n.currentIndex]?(OvenPlayerConsole.log("PlaylistManager getCurrentSources() ",n.playlist[n.currentIndex].sources),n.playlist[n.currentIndex].sources):null},t.getCurrentAdTag=function(){if(n.playlist[n.currentIndex])return n.playlist[n.currentIndex].adTagUrl||""},t}(t),o=function(){var e=Ke(),t={},n={};OvenPlayerConsole.log("ProviderController loaded.");var r=function(e,n){t[e]||(OvenPlayerConsole.log("ProviderController _registerProvider() ",e),t[e]=n)},o={html5:function(){var e=wn;return r(ce,e),{name:ce,provider:e}},webrtc:function(){var e=Bn;return r(ue,e),{name:ue,provider:e}},dash:function(){var e=kn;return r(le,e),{name:le,provider:e}},hls:function(){var e=In;return r(fe,e),{name:fe,provider:e}}};return n.loadProviders=function(t){var n=e.findProviderNamesByPlaylist(t);return OvenPlayerConsole.log("ProviderController loadProviders() ",n),n?Promise.all(n.filter((function(e){return!!o[e]})).map((function(e){return o[e]()}))):Promise.reject(We.codes[101])},n.findByName=function(e){return OvenPlayerConsole.log("ProviderController findByName() ",e),t[e]},n.getProviderBySource=function(t){var r=e.findProviderNameBySource(t);return OvenPlayerConsole.log("ProviderController getProviderBySource() ",r),n.findByName(r)},n.isSameProvider=function(t,n){return OvenPlayerConsole.log("ProviderController isSameProvider() ",e.findProviderNameBySource(t),e.findProviderNameBySource(n)),e.findProviderNameBySource(t)===e.findProviderNameBySource(n)},n}(),s=Y(),c=function(e,t){var n={},r=ze(e),o="";return OvenPlayerConsole.log("MediaManager loaded. browser : ",t),n.createMedia=function(e,t){return n.empty(),i=t.isLoop(),a=t.isAutoStart(),(o=document.createElement("video")).setAttribute("preload","auto"),o.setAttribute("disableremoteplayback",""),o.setAttribute("webkit-playsinline","true"),o.setAttribute("playsinline","true"),i&&o.setAttribute("loop",""),a&&o.setAttribute("autoplay",""),r.append(o),o;var i,a},n.createAdContainer=function(){var e=document.createElement("div");return e.setAttribute("class","op-ads"),r.append(e),e},n.empty=function(){OvenPlayerConsole.log("MediaManager removeElement()"),r.removeChild(o),o=null},n.destroy=function(){r.removeChild(),r=null,o.src=null,o.srcObject=null,o=null},n}(e,s),u="",l="",f="",p=function(e){OvenPlayerConsole.log("runNextPlaylist");var r=e,o=!!n.getPlaylist()[r];l.setSourceIndex(0),l.setVolume(u.getVolume()),o?(n.setCurrentPlaylist(r),d()):t.trigger(he,null)},d=function(e){return o.loadProviders(n.getCurrentPlayList()).then((function(e){if(e.length<1)throw We.codes[101];u&&(u.destroy(),u=null),f&&(f.destroy(),f=null),f=function(e,t){var n={},r=[],o=-1,a=K(),A=!0;OvenPlayerConsole.log("Caption Manager >> ",t);var s=function(e,t){return e.data=t||[],e.name=e.label||e.name||e.language,e.id=function(e,t){var n,o=e.kind||"cc";return n=e.default||e.defaulttrack?"default":e.id||o+t,A&&(c(r.length||0),A=!1),n}(e,r.length),r.push(e),e.id},c=function(t){o=t,e.trigger(Pe,o)};if(e.getConfig().playlist&&e.getConfig().playlist.length>0){var u=e.getConfig().playlist[t];if(u&&u.tracks&&u.tracks.length>0)for(var l=function(t){var n=u.tracks[t];Ye(n.kind)&&!i().findWhere(n,{file:n.file})&&a.load(n,n.lang,(function(e){e&&e.length>0&&s(n,e)}),(function(t){var n=We.codes[305];n.error=t,e.trigger(me,n)}))},f=0;f-1&&r[o]){var a=i().filter(r[o].data,(function(e){return n>=e.startTime&&(!e.endTime||n)<=e.endTime}));a&&a.length>0&&e.trigger(De,a[0])}})),n.flushCaptionList=function(e){r=[],c(e)},n.getCaptionList=function(){return r||[]},n.getCurrentCaption=function(){return o},n.setCurrentCaption=function(e){if(!(e>-2&&e0&&s(t,e)}),(function(t){var n=errors[305];n.error=t,e.trigger(me,n)}))},n.removeCaption=function(e){return e>-1&&e=.25&&e<=4})).map((function(e){return Math.round(4*e)/4}))).indexOf(1)<0&&a.push(1),a.sort(),t.playbackRates=a,t.rtmpBufferTime=t.rtmpBufferTime>10?10:t.rtmpBufferTime,t.rtmpBufferTimeMax=t.rtmpBufferTimeMax>50?50:t.rtmpBufferTimeMax,t.playbackRates.indexOf(t.playbackRate)<0&&(t.playbackRate=1);var A=t.playlist;if(A)i().isArray(A.playlist)&&(t.feedData=A,t.playlist=A.playlist);else{var s=i().pick(t,["title","description","type","image","file","sources","tracks","host","application","stream","adTagUrl"]);t.playlist=[s]}return delete t.duration,t}(e);return{getConfig:function(){return n},getAdClient:function(){return n.adClient},setConfig:function(e,t){n[e]=t},getContainer:function(){return n.mediaContainer},getPlaybackRate:function(){return n.playbackRate},setPlaybackRate:function(e){return n.playbackRate=e,e},getQualityLabel:function(){return n.qualityLabel},setQualityLabel:function(e){n.qualityLabel=e},isCurrentProtocolOnly:function(){return n.currentProtocolOnly},getSourceIndex:function(){return n.sourceIndex},setSourceIndex:function(e){n.sourceIndex=e},setTimecodeMode:function(e){n.timecode!==e&&(n.timecode=e,t.trigger(Fe,e))},isTimecodeMode:function(){return n.timecode},getRtmpBufferTime:function(){return n.rtmpBufferTime},getRtmpBufferTimeMax:function(){return n.rtmpBufferTimeMax},setMute:function(e){n.mute=e},isMute:function(){return n.mute},getVolume:function(){return n.volume},setVolume:function(e){n.volume=e},isLoop:function(){return n.loop},isAutoStart:function(){return n.autoStart},isControls:function(){return n.controls},getPlaybackRates:function(){return n.playbackRates},getBrowser:function(){return n.browser},getSystemText:function(){return n.systemText},getLanguage:function(){return n.lang},getPlaylist:function(){return n.playlist},setPlaylist:function(e){return i().isArray(e)?n.playlist=e:n.playlist=[e],n.playlist}}}(r,t),OvenPlayerConsole.log("API : init()"),OvenPlayerConsole.log("API : init() config : ",l),We.codes=l.getSystemText().api.error,n.initPlaylist(l.getPlaylist(),l),OvenPlayerConsole.log("API : init() sources : ",n.getCurrentSources()),d(),setTimeout((function(){t.trigger(pe)}))},t.getProviderName=function(){return u?u.getName():null},t.getProvider=function(){return u},t.getMseInstance=function(){return u?u.getMse():null},t.getConfig=function(){return OvenPlayerConsole.log("API : getConfig()",l.getConfig()),l.getConfig()},t.getBrowser=function(){return l.getBrowser()},t.setTimecodeMode=function(e){OvenPlayerConsole.log("API : setTimecodeMode()",e),l.setTimecodeMode(e)},t.isTimecodeMode=function(){return OvenPlayerConsole.log("API : isTimecodeMode()"),l.isTimecodeMode()},t.getFramerate=function(){if(OvenPlayerConsole.log("API : getFramerate()"),u)return u.getFramerate()},t.seekFrame=function(e){return u?(OvenPlayerConsole.log("API : seekFrame()",e),u.seekFrame(e)):null},t.getDuration=function(){return u?(OvenPlayerConsole.log("API : getDuration()",u.getDuration()),u.getDuration()):null},t.getDvrWindow=function(){return u?(OvenPlayerConsole.log("API : getDvrWindow()",u.getDvrWindow()),u.getDvrWindow()):null},t.getPosition=function(){return u?(OvenPlayerConsole.log("API : getPosition()",u.getPosition()),u.getPosition()):null},t.getVolume=function(){return u?(OvenPlayerConsole.log("API : getVolume()",u.getVolume()),u.getVolume()):null},t.setVolume=function(e){if(!u)return null;OvenPlayerConsole.log("API : setVolume() "+e),u.setVolume(e)},t.setMute=function(e){return u?(OvenPlayerConsole.log("API : setMute() "+e),u.setMute(e)):null},t.getMute=function(){return u?(OvenPlayerConsole.log("API : getMute() "+u.getMute()),u.getMute()):null},t.load=function(e){return OvenPlayerConsole.log("API : load() ",e),e&&(l.setSourceIndex(0),u&&u.getQualityLevels().length>0&&u.setCurrentQuality(0),"sources"in e?l.setPlaylist(e):l.setPlaylist({sources:e}),n.initPlaylist(l.getPlaylist(),l)),d()},t.play=function(){if(!u)return null;OvenPlayerConsole.log("API : play() "),u.metaLoaded()||l.isAutoStart()?u.play():t.once(Me,(function(){u.play()}))},t.pause=function(){if(!u)return null;OvenPlayerConsole.log("API : pause() "),u.pause()},t.seek=function(e){if(!u)return null;OvenPlayerConsole.log("API : seek() "+e),u.seek(e)},t.setPlaybackRate=function(e){return u?(OvenPlayerConsole.log("API : setPlaybackRate() ",e),u.setPlaybackRate(l.setPlaybackRate(e))):null},t.getPlaybackRate=function(){return u?(OvenPlayerConsole.log("API : getPlaybackRate() ",u.getPlaybackRate()),u.getPlaybackRate()):null},t.getPlaylist=function(){return OvenPlayerConsole.log("API : getPlaylist() ",n.getPlaylist()),n.getPlaylist()},t.getCurrentPlaylist=function(){return OvenPlayerConsole.log("API : getCurrentPlaylist() ",n.getCurrentPlaylistIndex()),n.getCurrentPlaylistIndex()},t.setCurrentPlaylist=function(e){OvenPlayerConsole.log("API : setCurrentPlaylist() ",e),p(e)},t.getSources=function(){return u?(OvenPlayerConsole.log("API : getSources() ",u.getSources()),u.getSources()):null},t.getCurrentSource=function(){return u?(OvenPlayerConsole.log("API : getCurrentSource() ",u.getCurrentSource()),u.getCurrentSource()):null},t.setCurrentSource=function(e){if(!u)return null;OvenPlayerConsole.log("API : setCurrentSource() ",e);var n=u.getPosition();return l.setSourceIndex(e),d(n).then((function(){t.trigger(Oe,{currentSource:e})})),e},t.getQualityLevels=function(){return u?(OvenPlayerConsole.log("API : getQualityLevels() ",u.getQualityLevels()),u.getQualityLevels()):null},t.getCurrentQuality=function(){return u?(OvenPlayerConsole.log("API : getCurrentQuality() ",u.getCurrentQuality()),u.getCurrentQuality()):null},t.setCurrentQuality=function(e){return u?(OvenPlayerConsole.log("API : setCurrentQuality() ",e),u.setCurrentQuality(e)):null},t.getAudioTracks=function(){return u?(OvenPlayerConsole.log("API : getAudioTracks() ",u.getAudioTracks()),u.getAudioTracks()):null},t.getCurrentAudioTrack=function(){return u?(OvenPlayerConsole.log("API : getCurrentAudioTrack() ",u.getCurrentAudioTrack()),u.getCurrentAudioTrack()):null},t.setCurrentAudioTrack=function(e){return u?(OvenPlayerConsole.log("API : setCurrentAudioTrack() ",e),u.setCurrentAudioTrack(e)):null},t.isAutoQuality=function(){return u?(OvenPlayerConsole.log("API : isAutoQuality()"),u.isAutoQuality()):null},t.setAutoQuality=function(e){return u?(OvenPlayerConsole.log("API : setAutoQuality() ",e),u.setAutoQuality(e)):null},t.getCaptionList=function(){return f?(OvenPlayerConsole.log("API : getCaptionList() ",f.getCaptionList()),f.getCaptionList()):null},t.getCurrentCaption=function(){return f?(OvenPlayerConsole.log("API : getCurrentCaption() ",f.getCurrentCaption()),f.getCurrentCaption()):null},t.setCurrentCaption=function(e){if(!f)return null;OvenPlayerConsole.log("API : setCurrentCaption() ",e),f.setCurrentCaption(e)},t.addCaption=function(e){return f?(OvenPlayerConsole.log("API : addCaption() "),f.addCaption(e)):null},t.removeCaption=function(e){return f?(OvenPlayerConsole.log("API : removeCaption() ",e),f.removeCaption(e)):null},t.getBuffer=function(){if(!u)return null;OvenPlayerConsole.log("API : getBuffer() ",u.getBuffer()),u.getBuffer()},t.getState=function(){return u?(OvenPlayerConsole.log("API : getState() ",u.getState()),u.getState()):null},t.stop=function(){if(!u)return null;OvenPlayerConsole.log("API : stop() "),u.stop()},t.remove=function(){OvenPlayerConsole.log("API : remove() "),f&&(f.destroy(),f=null),u&&(u.destroy(),u=null),c&&(c.destroy(),c=null),t.trigger(de),t.off(),o=null,n=null,l=null,OvenPlayerConsole.log("API : remove() - currentProvider, providerController, playlistManager, playerConfig, api event destroed. "),Tn.removePlayer(t)},t.getMediaElement=function(){return u.getMediaElement()},t.getVersion=function(){return r},t},Tn=(sn=(An={}).playerList=[],An.create=function(e,t){window.OvenPlayerConsole&&0!==Object.keys(window.OvenPlayerConsole).length||(window.OvenPlayerConsole={},OvenPlayerConsole.log=function(){});var n=Ze(e),r=Sn(n);return r.init(t),sn.push(r),r},An.getPlayerList=function(){return sn},An.getPlayerByContainerId=function(e){for(var t=0;t
'+(t.isRoot?"":'<')+''+t.title+'
';return i().forEach(t.body,(function(e){n+=Rn(e,t.useCheck)})),n+="
"},Rn=function(e,t){return'
'+(t?'':"")+''+e.title+""+(e.hasNext?'>'+e.description+"":"")+"
"},Mn=function(e,t){return'
')+'
').concat(e.image?""):''," ").concat(e.duration?''.concat(s(e.duration),""):"","
")+'
'.concat(e.title,"
")+"
"},On={TextViewTemplate:function(e){return'
'+"

".concat(e,"

")+'
'},ViewTemplate:function(e,t){return'
")+'
'},HelpersTemplate:function(e,t){return'
'},BigButtonTemplate:function(e,t){return'
'+"".concat(t===ee?'':"")+"".concat(t===$?'':"")+"".concat(t===X?'':"")+"".concat(t===q?'':"")+"
"},ThumbnailTemplate:function(e,t){return'
'+"".concat(t.title?'
'.concat(t.title,"
"):"")+"
"},WaterMarkTemplate:function(e,t){return'
'+"".concat(t.waterMark.image?''):"")+"".concat(t.waterMark.text?''.concat(t.waterMark.text,""):"")+"
"},MessageBoxTemplate:function(e,t){return'
')+'
'+'
'.concat(t.message)+"".concat(t.description?'
'.concat(t.description,"
"):"")+"
"+"".concat(t.iconClass?'
'):"")+"
"},SpinnerTemplate:function(e){return'
'},ContextPanelTemplate:function(e){return'
'+''.concat(e.context," ").concat(r,"")+"
"},CaptionViewerTemplate:function(e){return'
      
'},ControlsTemplate:function(e,t){return'
'+'
'.concat(t?'':"","
")+'
'},VolumeButtonTemplate:function(e){return'
'},ProgressBarTemplate:function(e){return'
00:00
'},PlayButtonTemplate:function(e){return'
'},SettingButtonTemplate:function(e){return''},FrameButtonsTemplate:function(e){return'
'},TimeDisplayTemplate:function(e,t){return'
'+(t.duration===1/0?''+("webrtc"===t.type?t.isP2P?''.concat(e.controls.low_latency_p2p,""):''.concat(e.controls.low_latency_live,""):''.concat(e.controls.live,""))+"":'00:00 / 00:00')+"
"},FullScreenButtonTemplate:function(e){return''},PanelsTemplate:Ln,SpeedPanelTemplate:Ln,SourcePanelTemplate:Ln,QualityPanelTemplate:Ln,AudioTrackPanelTemplate:Ln,CaptionPanelTemplate:Ln,TimeDisplayPanelTemplate:Ln,PlaylistPanelTemplate:function(e,t){return'
'+'
'.concat(e.playlist,'
')+'
'}},Qn=function(e,t,n,r,o,a,A,s){var c,u=i().isElement(e)?ze(e):e,l={},f=null,p={};p.data=r;var d=function(e){var t=document.createElement("div");return t.innerHTML=e,c=ze(t.firstChild),t.firstChild};return n&&n.systemText&&(f=n.systemText.ui),s?u.replace(d(On[t+"Template"](f,r))):u.append(d(On[t+"Template"](f,r))),a&&a(c,p),Object.keys(o).forEach((function(e){var t=e.split(" "),n=t[0].replace(/ /gi,""),r=t[1].replace(/ /gi,""),i="";if(i="document"===r||"window"===r||"body"===r?ze(r):c.find(r)||(c.hasClass(r.replace(".",""))?c:null),!(n&&r&&i))return!1;var a=Object.keys(l).length++,A=function(t){return o[e](t,c,p)};l[a]={name:n,target:r,callback:A};var s=null;n.indexOf("touch")>-1&&(s={passive:!0});var u=i.get().length;if(u>1)for(var f=i.get(),d=0;d1)for(var o=n.get(),i=0;i-1?o=!1:(o=!0,e.find(".op-caption-text").text(""))}),r),t.on(De,(function(t){if(!o&&t&&t.text){var n=t.endTime-t.startTime;i&&clearTimeout(i),e.find(".op-caption-text").html(t.text),n&&(i=setTimeout((function(){e.find(".op-caption-text").text("")}),1e3*n))}}),r)}),(function(n){e.find(".op-caption-text").text(""),t.off(Pe,null,n),t.off(De,null,n)}))}(e,t),t.on(pe,(function(){u&&v(),l&&(r&&r.destroy(),r=function(e,t,n){var r=null,o=null;return Qn(e,"WaterMark",t.getConfig(),n,{},(function(e,n){r=e.find(".op-watermark"),o=e.find(".op-watermark-text");var a=t.getConfig().waterMark,A=a.position||"top-right",s=a.y||"5%",c=a.x||"2.8125%";r.css(A.split("-")[0],s),r.css(A.split("-")[1],c);var u=a.width||"auto",l=a.height||"auto";r.css("width",u),r.css("height",l);var f=a.opacity||.7;r.css("opacity",f),a.text&&a.font&&i().each(a.font,(function(e,t){o.css(t,e)}))}),(function(){}))}(e,t,t.getConfig())),o||(h($),o=!0)}),p),t.on(xe,(function(n){n.message&&(a&&a.destroy(),A&&A.destroy(),c=Dn(e,t,n.message,null,n.timer,n.iconClass,n.onClickCallback,!1),t.once(Re,(function(e){!e.mute&&c&&c.destroy()}),p))}),p),t.on(Ce,(function(e){e&&e.newstate&&(e.newstate===X&&A&&A.destroy(),e.newstate===ee||e.newstate===ie?(f=!1,A&&A.destroy(),a&&a.destroy(),n&&n.destroy(),d||s.show(!1)):e.newstate===q?(s.show(!1),h(e.newstate)):e.newstate===re||e.newstate===ne||"adLoading"===e.newstate?(f=!1,A&&A.destroy(),a&&a.destroy(),s.show(!0)):d||s.show(!1))}),p),t.on(Oe,(function(){u&&v()})),t.on(Qe,(function(e){if(e.currentQuality<0)return!1;e.isAuto?(d=!1,s.show(!1)):"request"===e.type?(g=e.currentQuality,d=!0,s.show(!0)):"render"===e.type&&g===e.currentQuality&&(d=!1,s.show(!1))}),p),t.on(me,(function(n){if(510===n.code&&(f=!0),101===n.code&&0===t.getPlaylist().length&&(f=!0),!f){var r="",o="";a&&a.destroy(),n&&n.code&&n.code>=100&&n.code<1e3?(r=n.message,100===n.code&&(o=n.error.toString())):r="Can not play due to unknown reasons.",OvenPlayerConsole.log("error occured : ",n),function(n,r,o,i,s,c){a&&a.destroy(),A&&A.destroy(),A=Dn(e,t,n,r,null,"op-warning",null,!0)}(r,o)}}),p),t.on(ve,(function(e){var n="Because the network connection is unstable, the following media source will be played.";t.getCurrentSource()+1===t.getQualityLevels().length&&(n="Network connection is unstable. Check the network connection."),OvenPlayerConsole.log(n)}),p),t.on(he,(function(){u&&v()}),p)}),(function(e){t.off(pe,null,e),t.off(Ce,null,e),t.off(xe,null,e),t.off(me,null,e),t.off(ve,null,e),t.off(he,null,e),t.off(ge,null,e)}))},Fn=[],Un=function(){var e={},t=function(){for(var e=0;e1,!0===t.getConfig().hidePlaylistIcon&&(u=!1);var m={"mouseleave .op-controls":function(e,t,n){e.preventDefault(),r.setMouseDown(!1),t.find(".op-volume-slider-container").removeClass("active")},"click .op-playlist-button":function(e,n,r){e.preventDefault(),function(e,t){var n=ze(t.getContainerElement()),r="",o=t.getPlaylist(),i=o.length,a=6,A=0,s=[];function c(e){var n,A,c=Math.ceil(i/a),u=t.getCurrentPlaylist();s=o.slice(e*a,e*a+a),r.find(".op-playlist-body-row").removeChild(),r.find(".op-arrow-left").removeClass("disable"),r.find(".op-arrow-right").removeClass("disable");for(var l=0;l576?a=6:n.width()<=576&&(a=1);var l={"click .btn-close":function(e,t,n){e.preventDefault(),n.destroy()},"click .op-arrow-left":function(e,t,n){e.preventDefault(),ze(e.target).hasClass("disable")||c(--A)},"click .op-arrow-right":function(e,t,n){e.preventDefault(),ze(e.target).hasClass("disable")||c(++A)}};Qn(e,"PlaylistPanel",t.getConfig(),o,l,(function(e,n){r=e,c(A=u()),t.on(Ee,(function(e){"xsmall"===e&&6===a?(a=1,c(A=u())):"small"!==e&&"medium"!==e&&"large"!==e||1!==a||(a=6,c(A=u()))}),n),t.on(ge,(function(e){c(A=u())}),n),e.get().addEventListener("click",(function(e){for(var n=e.target;n;){if(ze(n).hasClass("op-playlist-card"))return void t.setCurrentPlaylist(parseInt(ze(n).attr("data-index")));n=n.parentElement}}),!0)}),(function(e){t.off(Ee,null,e),t.off(ge,null,e)}))}(n,t)}};return Qn(e,"Controls",t.getConfig(),u,m,(function(e,u){function p(n,r){a&&a.destroy(),a=function(e,t,n,r){var o=ze(t.getContainerElement());t.getConfig().disableSeekUI&&e.addClass("op-progressbar-container-disabled");var i=0,a=!1,A=Un(),c="",u=0,l="",f="",p="",d="",g="",h="",v=0,m="",C="",y=t.getBrowser().mobile,b=t.getMediaElement(),w=!1,E=!1;function B(e){var t=l.width(),n=t*e;p.css("width",n+"px"),d.css("left",n+"px");var r=(t-v)*e;g.css("left",r+"px"),i=n}function x(e){var t=l.width()*e;d.css("width",(0===e?e:t-i)+"px")}function k(e){var t=l.width(),n=l.offset().left,r=e.pageX;e.touches&&(r=e.pageX||e.touches[0].clientX);var o=(r-n)/t;return o<0?0:o>1?1:o}function I(){return b.seekable.end(b.seekable.length-1)-b.seekable.start(0)}function S(e,n){if(A.size()>0||-1===e)return m.hide(),void C.hide();if(m.show(),C.show(),w&&!E){var r=t.getDvrWindow()*(1-e);t.isTimecodeMode()?m.text("- "+s(r)):m.text("- "+Math.round(r*t.getFramerate()))}else if(w&&E){var o=I()*(1-e);t.isTimecodeMode()?m.text("- "+s(o)):m.text("- "+Math.round(o*t.getFramerate()))}else{var i=t.getDuration()*e;t.isTimecodeMode()?m.text(s(i)):m.text(Math.round(i*t.getFramerate()))}var a=m.width(),u=l.width(),f=u*e,p=n.pageX-l.offset().left;n.touches&&(p=(n.pageX||n.touches[0].clientX)-l.offset().left);var d=function(e){return p0&&(n+=i),t.seek(n)}r&&r.type===fe&&r.duration===1/0&&(w=!0,t.getProviderName()===ce&&(E=!0));var L={"touchstart .op-progressbar":function(e){if(n)return!1;a=!0;var t=k(e);if(-1===t)return!1;B(t),x(0),T(t)},"touchmove .op-progressbar":function(e){if(a){var t=k(e);if(-1===t)return!1;B(t),x(0),T(t),S(t,e)}},"touchend .op-progressbar":function(e){a&&(a=!1),o.removeClass("op-progressbar-hover"),m.hide(),C.hide()},"mouseenter .op-progressbar":function(e,t,r){e.preventDefault(),y||(n||m.show(),o.addClass("op-progressbar-hover"))},"mouseleave .op-progressbar":function(e,t,n){e.preventDefault(),a=!1,o.removeClass("op-progressbar-hover"),m.hide(),C.hide(),x(0)},"mousedown .op-progressbar":function(e,t,r){if(e.preventDefault(),n||y)return!1;a=!0;var o=k(e);if(-1===o)return!1;B(o),x(0),T(o)},"mousemove .op-progressbar":function(e,t,r){if(e.preventDefault(),!a&&!n&&!y){var o=k(e);x(o),S(o,e)}if(a&&!y){var i=k(e);if(-1===i)return!1;B(i),x(0),T(i),S(i,e)}},"mouseup .op-progressbar":function(e,t,n){e.preventDefault(),a&&!y&&(a=!1,o.removeClass("op-progressbar-hover"))}};return t.getConfig().disableSeekUI&&(L={}),Qn(e,"ProgressBar",t.getConfig(),null,L,(function(e,r){l=e,f=e.find(".op-load-progress"),p=e.find(".op-play-progress"),d=e.find(".op-hover-progress"),g=e.find(".op-progressbar-knob-container"),h=e.find(".op-progressbar-knob"),v=h.width(),m=e.find(".op-progressbar-time"),C=e.find(".op-progressbar-preview"),n?t.on(Ie,(function(e){e&&e.duration&&e.position&&(B(e.position/e.duration),e.duration)}),r):(t.on(Te,(function(e){if(e&&e.duration&&e.position){u=e.duration;var n=e.position/e.duration;if(w&&!E&&(n=(t.getDvrWindow()-(e.duration-e.position))/t.getDvrWindow()),w&&E){var r=I();u=r,n=(r-(r-Math.min(r,e.position)))/r}B(n)}}),r),t.on(Se,(function(e){var t,n;e&&e.bufferPercent&&(t=e.bufferPercent/100,n=l.width()*t,f.css("width",n+"px"))}),r))}),(function(e){n?t.off(Ie,null,e):(t.off(Te,null,e),t.off(Se,null,e))}))}(e.find(".op-progressbar-container"),t,n,r)}function m(){i&&i.destroy(),i=function(e,t){var n=Un(),r={"click .op-setting-button":function(e,r,o){e.preventDefault();var i=r.closest(".op-controls-container");if(n.size()>0)n.clear();else{var a=function(e){var t={id:"panel-"+(new Date).getTime(),title:"Settings",body:[],isRoot:!0,panelType:""},n=e.getConfig();n&&n.systemText&&(Object.keys(jn).forEach((function(e){jn[e]=n.systemText.ui.setting[e]})),t.title=n.systemText.ui.setting.title);var r=e.getSources(),o=r&&r.length>0?r[e.getCurrentSource()]:null,i=e.getQualityLevels(),a=i&&i.length>0?i[e.getCurrentQuality()]:null,A=e.getAudioTracks(),s=A&&A.length>0?A[e.getCurrentAudioTrack()]:null,c=e.getCaptionList(),u=e.getCurrentCaption(),l=e.getFramerate();if(o){var f={title:jn.speed,value:e.getPlaybackRate()+jn.speedUnit,description:e.getPlaybackRate()+jn.speedUnit,panelType:"speed",hasNext:!0};t.body.push(f)}if(r&&r.length>1){var p={title:jn.source,value:o?o.label:"Default",description:o?o.label:"Default",panelType:"source",hasNext:!0};t.body.push(p)}if(i&&i.length>0){var d={title:jn.quality,value:a?a.label:"Default",description:a?a.label:"Default",panelType:"quality",hasNext:!0};t.body.push(d)}if(A&&A.length>0){var g={title:jn.audioTrack,value:s?s.label:"Default",description:s?s.label:"Default",panelType:"audioTrack",hasNext:!0};t.body.push(g)}if(c&&c.length>0){var h={title:jn.caption,value:c[u]?c[u].label:"OFF",description:c[u]?c[u].label:"OFF",panelType:"caption",hasNext:!0};t.body.push(h)}if(l>0){var v={title:jn.display,value:e.isTimecodeMode()?"Play time":"Framecode",description:e.isTimecodeMode()?"Play time":"Framecode",panelType:"display",hasNext:!0};t.body.push(v)}return t}(t);n.add(Wn(i,t,a))}}};return Qn(e,"SettingButton",t.getConfig(),null,r,(function(e,t){}),(function(e){}))}(e.find(".setting-holder"),t)}function C(){c||(c=function(e,t){var n=ze(t.getContainerElement()),r="",o="",i=!1,a=(t.getConfig(),t.getBrowser()),A="iOS"===a.os,s=(a.os,""),c=!1,u={onfullscreenchange:"fullscreenchange",onmozfullscreenchange:"mozfullscreenchange",onwebkitfullscreenchange:"webkitfullscreenchange",MSFullscreenChange:"MSFullscreenChange"};function l(){var e=!1,t=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;return t&&n.get()===t&&(e=!0),e}function f(){OvenPlayerConsole.log("FULLSCREEN STATE : ",l()),l()?(n.addClass("op-fullscreen"),i=!0,r.hide(),o.show()):(n.removeClass("op-fullscreen"),i=!1,r.show(),o.hide())}function p(){OvenPlayerConsole.log("afterFullScreenChangedCallback () "),f(),t.trigger(Be,i)}function d(){i?(n.removeClass("op-fullscreen"),i=!1,r.show(),o.hide()):(n.addClass("op-fullscreen"),i=!0,r.hide(),o.show()),t.trigger(Be,i)}function g(){var e;!i||A&&!l()?function(){var e,r="",o=n.get(),a=n.find("video")?n.find("video").get():o,s=null;if(A){if(a.length>1)for(var u=0;u1)for(var o=0;o9e15&&(n.duration=1/0);var r=t.getSources()[t.getCurrentSource()].sectionStart,o=t.getSources()[t.getCurrentSource()].sectionEnd;o&&(n.duration=o),r&&(n.duration=n.duration-r),function(n){A&&A.destroy(),A=function(e,t,n){var r="",o="",i="",a=t.getMediaElement(),A=!1,c=!1;function u(e){return s(e)}var l={"click .op-live-text":function(e,n,r){e.preventDefault(),t.seek(Number.MAX_SAFE_INTEGER);var o=t.getConfig();if(o.hlsConfig){var i=o.hlsConfig;"number"==typeof i.liveSyncDuration&&(t.getMseInstance().config.liveSyncDuration=i.liveSyncDuration),"number"==typeof i.liveMaxLatencyDuration&&(t.getMseInstance().config.liveMaxLatencyDuration=i.liveMaxLatencyDuration),"number"==typeof i.maxLiveSyncPlaybackRate&&(t.getMseInstance().config.maxLiveSyncPlaybackRate=i.maxLiveSyncPlaybackRate)}}};return Qn(e,"TimeDisplay",t.getConfig(),n,l,(function(e,s){var l=t.isTimecodeMode();r=e.find(".op-time-current"),o=e.find(".op-time-duration"),i=e.find(".op-live-badge"),e.find(".op-live-text"),n&&n.type===fe&&n.duration===1/0&&(A=!0,t.getProviderName()===ce&&(c=!0)),n.duration!==1/0?(l?o.text(u(n.duration)):o.text(Math.round(n.duration*t.getFramerate())+" ("+t.getFramerate()+"fps)"),t.on(Fe,(function(e){(l=e)?o.text(u(n.duration)):o.text(Math.round(n.duration*t.getFramerate())+" ("+t.getFramerate()+"fps)")}),s),t.on(Te,(function(e){l?r.text(u(e.position)):r.text(Math.round(e.position*t.getFramerate()))}),s)):A&&!c?t.on(Te,(function(e){e.duration-e.position>3?i.addClass("op-live-badge-delayed"):i.removeClass("op-live-badge-delayed")}),s):A&&c&&t.on(Te,(function(e){a.seekable.end(a.seekable.length-1)-a.seekable.start(0)-e.position>3?i.addClass("op-live-badge-delayed"):i.removeClass("op-live-badge-delayed")}),s)}),(function(e){t.off(Fe,null,e),t.off(Te,null,e)}))}(e.find(".op-left-controls"),t,n)}(n),C(),t.getFramerate&&t.getFramerate(),n.duration===1/0?(OvenPlayerConsole.log("[[[[LIVE MODE]]]]"),n.type===fe?p(!1,n):a&&a.destroy()):p(!1),l=!0}function b(){A&&A.destroy(),a&&a.destroy(),m(),C(),h.removeClass("linear-ad")}o=function(e,t){var n="",r="",o="",i="",a="",A="",s="",c={"click .op-play-button":function(e,n,r){e.preventDefault();var o=t.getState(),i=t.getPlaylist(),a=t.getCurrentPlaylist();o===X?t.play():o===ee||o===ie?t.pause():o===ne||o===re?t.stop():o===$||o===ae?t.play():o===te?t.setCurrentSource(t.getCurrentSource()):o===q&&i.length===a+1&&(t.seek(0),t.play())},"click .op-seek-button-back":function(e,n,r){var o=t.getConfig().seekControlInterval;o||(o=10);var i=t.getPosition()-o;i<0&&(i=0),t.seek(i)},"click .op-seek-button-forward":function(e,n,r){var o=t.getConfig().seekControlInterval;o||(o=10);var i=t.getPosition()+o;i>t.getDuration()&&(i=t.getDuration()),t.seek(i)}};return Qn(e,"PlayButton",t.getConfig(),null,c,(function(e,c){n=e.find(".op-play-button .op-play"),r=e.find(".op-play-button .op-pause"),o=e.find(".op-play-button .op-replay"),i=e.find(".op-seek-button-back"),a=e.find(".op-seek-button-forward"),A=e.find(".op-seek-back-text"),s=e.find(".op-seek-forward-text"),t.on(Ce,(function(e){var t;e&&e.newstate&&(t=e.newstate,n.hide(),r.hide(),o.hide(),t===ee||t===ie||t===ne||t===re?r.show():t===$||t===ae?n.show():t===q?o.show():n.show())}),c),t.getConfig().showSeekControl||(i.hide(),a.hide());var u=t.getConfig().seekControlInterval;u?(A.text(u),s.text(u)):(A.text(10),s.text(10))}),(function(e){t.off(Ce,null,e)}))}(e.find(".op-left-controls"),t),r=function(e,t){var n="",r="",o="",i="",a="",A="",s="",c=!1,u=0,l="iOS"===t.getBrowser().os||"Android"===t.getBrowser().os;function f(e){t.getMute()&&(e=0),function(e){a.hide(),A.hide(),s.hide(),e>=70?a.show():e<70&&e>0?A.show():0==e?s.show():a.show()}(e);var n=u*e/100;o.css("left",n+"px"),i.css("width",n+"px")}function p(e){var t=((e.pageX||e.touches[0].clientX)-r.offset().left)/70*100;return t<0&&(t=0),t>100&&(t=100),t}var d={"click .op-volume-button":function(e,n,r){e.preventDefault(),l||(0===t.getVolume()?(t.setMute(!1),t.setVolume(100)):t.setMute())},"mouseenter .op-volume-button":function(e,t,r){e.preventDefault(),l||n.addClass("active")},"mouseleave .op-volume-silder":function(e,t,n){e.preventDefault(),c=!1},"mousedown .op-volume-silder":function(e,n,r){e.preventDefault(),c=!0,t.setMute(!1),t.setVolume(p(e))},"mouseup .op-volume-silder":function(e,t,n){e.preventDefault(),c=!1},"mousemove .op-volume-silder":function(e,n,r){if(e.preventDefault(),!c)return!1;t.setVolume(p(e))},"touchstart .op-volume-button":function(e){l&&(t.getMute()?t.setMute(!1):t.setMute(!0))}},g=Qn(e,"VolumeButton",t.getConfig(),null,d,(function(e,c){n=e.find(".op-volume-slider-container"),t.getBrowser().mobile&&n.hide(),r=e.find(".op-volume-silder"),o=e.find(".op-volume-slider-handle"),i=e.find(".op-volume-slider-value"),a=e.find(".op-volume-max"),A=e.find(".op-volume-small"),s=e.find(".op-volume-mute"),u=64,o.css("left",u+"px"),f(t.getVolume()),t.on(pe,(function(){f(t.getVolume())}),c),t.on(Le,(function(e){f(e.volume)}),c),t.on(Re,(function(e){e.mute?f(0):f(t.getVolume())}),c)}),(function(e){t.off(pe,null,e),t.off(Le,null,e),t.off(Re,null,e)}));return g.setMouseDown=function(e){c=e},g}(e.find(".op-left-controls"),t);var w=t.getPlaylist(),E=t.getCurrentPlaylist();w&&w[E]&&w[E].adTagUrl||m(),C(),t.on(pe,(function(){e.show()}),u),t.on(Me,(function(e){n=e.duration,v=e,e.isP2P=f,y(e)}),u),t.on(Te,(function(e){(d||t&&t.getProviderName&&"rtmp"===t.getProviderName())&&!n&&v&&v.duration!==e.duration&&(v=e,y(e))}),u),t.on(Ee,(function(e){h.find(".op-setting-panel")&&h.find(".op-setting-panel").css("max-height",h.height()-h.find(".op-bottom-panel").height()+"px")}),u),t.on(Ue,(function(e){f=e}),u),t.on(be,(function(){if(!l){var n="";t.getSources().length>0&&t.getSources()[t.getCurrentSource()]&&t.getSources()[t.getCurrentSource()].type&&(n=t.getSources()[t.getCurrentSource()].type),y({isP2P:f,duration:t.getDuration(),type:n})}e.show()}),u),t.on(me,(function(t){e.show()}),u),t.on(ke,(function(e){e.isLinear?(h.addClass("linear-ad"),p(!0),A&&A.destroy(),i&&i.destroy(),g&&c&&c.destroy()):h.removeClass("linear-ad")}),u),t.on(Ae,(function(){b()}),u),t.on(se,(function(){b()}),u),t.on(Oe,(function(){b()}),u)}),(function(e){t.off(Me,null,e),t.off(Te,null,e),t.off(Ae,null,e),t.off(ke,null,e),t.off(Ue,null,e),t.off(se,null,e),t.off(Ee,null,e),t.off(Oe,null,e),A&&A.destroy(),o&&o.destroy(),a&&a.destroy(),c&&c.destroy(),r&&r.destroy()}))},Gn=n(5655),zn=n.n(Gn),_n=n(3379),Vn=n.n(_n),Hn=n(7795),Jn=n.n(Hn),Zn=n(569),Kn=n.n(Zn),Xn=n(3565),qn=n.n(Xn),$n=n(9216),er=n.n($n),tr=n(4589),nr=n.n(tr),rr=n(2021),or={};or.styleTagTransform=nr(),or.setAttributes=qn(),or.insert=Kn().bind(null,"head"),or.domAPI=Jn(),or.insertStyleElement=er(),Vn()(rr.Z,or),rr.Z&&rr.Z.locals&&rr.Z.locals;var ir,ar=function(e){var t,n="",r="",o="",i="",a=null,A="",s=X,c=!1,u=Un(),l="",f="",p=null,d={};function g(e,n){if(A&&(clearTimeout(A),A=null),e){if(u.size()>0)return!1;t.addClass("op-autohide")}else t.removeClass("op-autohide"),n&&(A=setTimeout((function(){if(u.size()>0)return!1;t.addClass("op-autohide")}),3e3))}function h(){var e=s;e===X||e===$||e===q?(e===q&&a.seek(0),a.play()):e===ee&&a.pause()}function v(e,t){var n,r=a.getDuration(),o=a.getPosition();n=t?Math.max(o-e,0):Math.min(o+e,r),a.seek(n)}function m(e){var t,n=a.getVolume();t=e?Math.min(n+5,100):Math.max(n-5,0),a.setVolume(t)}function C(){var e=t.width();e<576?(l="xsmall",t.addClass("xsmall"),e<490&&t.addClass("xxsmall")):e<768?(l="small",t.addClass("small")):e<992?(l="medium",t.addClass("medium")):(l="large",t.addClass("large"))}var y={"click .ovenplayer":function(e,t,n){if(a&&a.trigger(we,e),i)return e.preventDefault(),i.destroy(),i=null,!1;if(!ze(e.target).closest(".op-controls-container")&&!ze(e.target).closest(".op-setting-panel")){if(u.size()>0)return e.preventDefault(),u.clear(),!1;a.getDuration()===1/0||a.getBrowser().mobile||h()}},"dblclick .ovenplayer":function(e,t,n){a&&a.getConfig().expandFullScreenUI&&a.toggleFullScreen&&(ze(e.target).closest(".op-controls-container")||ze(e.target).closest(".op-setting-panel")||a.toggleFullScreen())},"touchstart .ovenplayer":function(e,t,n){s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mouseenter .ovenplayer":function(e,t,n){e.preventDefault(),s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mousemove .ovenplayer":function(e,t,n){e.preventDefault(),s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mouseleave .ovenplayer":function(e,t,n){e.preventDefault(),(s===ee||s===X||s===ne||s===ie&&"xsmall"===l)&&g(!0)},"keydown .ovenplayer":function(e,t,n){var r=a.getFramerate();switch(e.keyCode){case 16:e.preventDefault(),c=!0;break;case 32:e.preventDefault(),h();break;case 37:e.preventDefault(),a.getConfig().disableSeekUI||(c&&r?a.seekFrame(-1):v(5,!0));break;case 39:e.preventDefault(),a.getConfig().disableSeekUI||(c&&r?a.seekFrame(1):v(5,!1));break;case 38:e.preventDefault(),m(!0);break;case 40:e.preventDefault(),m(!1)}},"keyup .ovenplayer":function(e,t,n){16===e.keyCode&&(e.preventDefault(),c=!1)},"contextmenu .ovenplayer":function(e,n,r){if(e.stopPropagation(),!ze(e.currentTarget).find("object"))return e.preventDefault(),o=e.pageX,A=e.pageY,i&&(i.destroy(),i=null),i=function(e,t,n){var r=ze(t.getContainerElement()),o={"click .op-context-item":function(e,t,n){e.preventDefault(),window.open("https://github.com/AirenSoft/OvenPlayer","_blank")}};return Qn(e,"ContextPanel",t.getConfig(),n,o,(function(e,t){var o=e.width(),i=e.height(),a=Math.min(n.pageX-r.offset().left,r.width()-o),A=Math.min(n.pageY-r.offset().top,r.height()-i);e.css("left",a+"px"),e.css("top",A+"px")}),(function(){}))}(t,a,{pageX:o,pageY:A}),!1;var o,A}};return(d=Qn(e,"View",null,e.id,y,(function(e,r){t=e,n=r,C(),f=l,p=new(zn())(t.get(),(function(){t.removeClass("large"),t.removeClass("medium"),t.removeClass("small"),t.removeClass("xsmall"),t.removeClass("xxsmall"),C(),l!==f&&(f=l,a&&a.trigger(Ee,f))}))}),(function(){p&&(p.detach(),p=null),o&&(o.destroy(),o=null),r&&(r.destroy(),r=null)}),!0)).getMediaElementContainer=function(){return t.find(".op-media-element-container").get()},d.setApi=function(e){(a=e).getContainerElement=function(){return t.get()},a.getContainerId=function(){return t.get().id},a.on(pe,(function(n){r||(r=Yn(t.find(".op-ui"),e)),i||t.addClass("op-no-controls")})),a.on(me,(function(e){if(a){var t=a.getSources()||[];r&&t.length}})),a.on(de,(function(e){n.destroy()})),a.on(be,(function(n){!r&&i&&(r=Yn(t.find(".op-ui"),e))})),a.on(Ce,(function(e){e&&e.newstate&&(s=e.newstate,e.newstate===ee||e.newstate===ie&&"xsmall"===l?g(!1,!0):g(!1))}));var i=a.getConfig()&&a.getConfig().controls;o=Pn(t.find(".op-ui"),e),r=Yn(t.find(".op-ui"),e);var A=a.getConfig().aspectRatio;if(A&&2===A.split(":").length){var c=1*A.split(":")[0],u=1*A.split(":")[1]/c*100;t.find(".op-ratio").css("padding-bottom",u+"%")}a.showControls=function(e){e?(t.removeClass("op-no-controls"),g(!1,!0)):t.addClass("op-no-controls")}},d},Ar=(ir={},Object.assign(ir,Tn),ir.create=function(e,t){var n=Ze(e),r=ar(n),o=Tn.create(r.getMediaElementContainer(),t);return r.setApi(o),OvenPlayerConsole.log("[OvenPlayer] v.0.10.31"),o},ir)},1001:function(){!function(e){"use strict";if("window"in e&&"document"in e){document.querySelectorAll||(document.querySelectorAll=function(e){var t,n=document.createElement("style"),r=[];for(document.documentElement.firstChild.appendChild(n),document._qsa=[],n.styleSheet.cssText=e+"{x-qsa:expression(document._qsa && document._qsa.push(this))}",window.scrollBy(0,0),n.parentNode.removeChild(n);document._qsa.length;)(t=document._qsa.shift()).style.removeAttribute("x-qsa"),r.push(t);return document._qsa=null,r}),document.querySelector||(document.querySelector=function(e){var t=document.querySelectorAll(e);return t.length?t[0]:null}),document.getElementsByClassName||(document.getElementsByClassName=function(e){return e=String(e).replace(/^|\s+/g,"."),document.querySelectorAll(e)}),e.Node=e.Node||function(){throw TypeError("Illegal constructor")},[["ELEMENT_NODE",1],["ATTRIBUTE_NODE",2],["TEXT_NODE",3],["CDATA_SECTION_NODE",4],["ENTITY_REFERENCE_NODE",5],["ENTITY_NODE",6],["PROCESSING_INSTRUCTION_NODE",7],["COMMENT_NODE",8],["DOCUMENT_NODE",9],["DOCUMENT_TYPE_NODE",10],["DOCUMENT_FRAGMENT_NODE",11],["NOTATION_NODE",12]].forEach((function(t){t[0]in e.Node||(e.Node[t[0]]=t[1])})),e.DOMException=e.DOMException||function(){throw TypeError("Illegal constructor")},[["INDEX_SIZE_ERR",1],["DOMSTRING_SIZE_ERR",2],["HIERARCHY_REQUEST_ERR",3],["WRONG_DOCUMENT_ERR",4],["INVALID_CHARACTER_ERR",5],["NO_DATA_ALLOWED_ERR",6],["NO_MODIFICATION_ALLOWED_ERR",7],["NOT_FOUND_ERR",8],["NOT_SUPPORTED_ERR",9],["INUSE_ATTRIBUTE_ERR",10],["INVALID_STATE_ERR",11],["SYNTAX_ERR",12],["INVALID_MODIFICATION_ERR",13],["NAMESPACE_ERR",14],["INVALID_ACCESS_ERR",15]].forEach((function(t){t[0]in e.DOMException||(e.DOMException[t[0]]=t[1])})),function(){function t(e,t,n){if("function"==typeof t){"DOMContentLoaded"===e&&(e="load");var r=this,o=function(e){e._timeStamp=Date.now(),e._currentTarget=r,t.call(this,e),e._currentTarget=null};this["_"+e+t]=o,this.attachEvent("on"+e,o)}}function n(e,t,n){if("function"==typeof t){"DOMContentLoaded"===e&&(e="load");var r=this["_"+e+t];r&&(this.detachEvent("on"+e,r),this["_"+e+t]=null)}}"Element"in e&&!Element.prototype.addEventListener&&Object.defineProperty&&(Event.CAPTURING_PHASE=1,Event.AT_TARGET=2,Event.BUBBLING_PHASE=3,Object.defineProperties(Event.prototype,{CAPTURING_PHASE:{get:function(){return 1}},AT_TARGET:{get:function(){return 2}},BUBBLING_PHASE:{get:function(){return 3}},target:{get:function(){return this.srcElement}},currentTarget:{get:function(){return this._currentTarget}},eventPhase:{get:function(){return this.srcElement===this.currentTarget?Event.AT_TARGET:Event.BUBBLING_PHASE}},bubbles:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mousemove":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"resize":case"scroll":case"select":case"change":case"submit":case"reset":return!0}return!1}},cancelable:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"submit":return!0}return!1}},timeStamp:{get:function(){return this._timeStamp}},stopPropagation:{value:function(){this.cancelBubble=!0}},preventDefault:{value:function(){this.returnValue=!1}},defaultPrevented:{get:function(){return!1===this.returnValue}}}),[Window,HTMLDocument,Element].forEach((function(e){e.prototype.addEventListener=t,e.prototype.removeEventListener=n})))}(),function(){function t(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}"CustomEvent"in e&&"function"==typeof e.CustomEvent||(t.prototype=e.Event.prototype,e.CustomEvent=t)}(),window.addEvent=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&(e["e"+t+n]=n,e[t+n]=function(){var r=window.event;r.currentTarget=e,r.preventDefault=function(){r.returnValue=!1},r.stopPropagation=function(){r.cancelBubble=!0},r.target=r.srcElement,r.timeStamp=Date.now(),e["e"+t+n].call(this,r)},e.attachEvent("on"+t,e[t+n]))},window.removeEvent=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&(e.detachEvent("on"+t,e[t+n]),e[t+n]=null,e["e"+t+n]=null)},function(){function t(e,t){function n(e){return e.length?e.split(/\s+/g):[]}function r(e,t){var r=n(t),o=r.indexOf(e);return-1!==o&&r.splice(o,1),r.join(" ")}if(Object.defineProperties(this,{length:{get:function(){return n(e[t]).length}},item:{value:function(r){var o=n(e[t]);return 0<=r&&r=0&&t.item(n)!==this;);return n>-1})),window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,n=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do{for(t=n.length;--t>=0&&n.item(t)!==r;);}while(t<0&&(r=r.parentElement));return r});var t={prepend:function(){var e=[].slice.call(arguments);e=o(e),this.insertBefore(e,this.firstChild)},append:function(){var e=[].slice.call(arguments);e=o(e),this.appendChild(e)}};r(e.Document||e.HTMLDocument,t),r(e.DocumentFragment,t),r(e.Element,t);var n={before:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.previousSibling;-1!==e.indexOf(n);)n=n.previousSibling;var r=o(e);t.insertBefore(r,n?n.nextSibling:t.firstChild)}},after:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.nextSibling;-1!==e.indexOf(n);)n=n.nextSibling;var r=o(e);t.insertBefore(r,n)}},replaceWith:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.nextSibling;-1!==e.indexOf(n);)n=n.nextSibling;var r=o(e);this.parentNode===t?t.replaceChild(r,this):t.insertBefore(r,n)}},remove:function(){this.parentNode&&this.parentNode.removeChild(this)}};r(e.DocumentType,n),r(e.Element,n),r(e.CharacterData,n)}function r(e,t){e&&Object.keys(t).forEach((function(n){if(!(n in e)&&!(n in e.prototype))try{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t,n))}catch(r){e[n]=t[n]}}))}function o(e){var t=null;return e=e.map((function(e){return e instanceof Node?e:document.createTextNode(e)})),1===e.length?t=e[0]:(t=document.createDocumentFragment(),e.forEach((function(e){t.appendChild(e)}))),t}}(self)},5655:function(e,t){var n,r;r=this,void 0===(n=function(){return r.returnExportsGlobal=function(){"use strict";var e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){return window.setTimeout(e,20)};function t(){var e,t;this.q=[],this.add=function(e){this.q.push(e)},this.call=function(){for(e=0,t=this.q.length;e
',n.appendChild(n.resizeSensor),"static"==function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null).getPropertyValue(t):e.style[t]}(n,"position")&&(n.style.position="relative");var a=n.resizeSensor.childNodes[0],A=a.childNodes[0],s=n.resizeSensor.childNodes[1],c=function(){A.style.width="100000px",A.style.height="100000px",a.scrollLeft=1e5,a.scrollTop=1e5,s.scrollLeft=1e5,s.scrollTop=1e5};c();var u,l,f,p,d=!1;e((function t(){n.resizedAttached&&(d&&(n.resizedAttached.call(),d=!1),e(t))}));var g=function(){(f=n.offsetWidth)==u&&(p=n.offsetHeight)==l||(d=!0,u=f,l=p),c()},h=function(e,t,n){e.attachEvent?e.attachEvent("on"+t,n):e.addEventListener(t,n)};h(a,"scroll",g),h(s,"scroll",g)}var r=function(e,t){var r=Object.prototype.toString.call(e),o=this._isCollectionTyped="[object Array]"===r||"[object NodeList]"===r||"[object HTMLCollection]"===r||"undefined"!=typeof jQuery&&e instanceof window.jQuery||"undefined"!=typeof Elements&&e instanceof window.Elements;if(this._element=e,o)for(var i=0,a=e.length;i=0&&n<=b}}function Z(e){return function(t){return null==t?void 0:t[e]}}var K=Z("byteLength"),X=J(K),q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/,$=l?function(e){return h?h(e)&&!j(e):X(e)&&q.test(c.call(e))}:H(!1),ee=Z("length");function te(e,t){t=function(e){for(var t={},n=e.length,r=0;r":">",'"':""","'":"'","`":"`"},_e=Ge(ze),Ve=Ge(be(ze)),He=oe.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Je=/(.)^/,Ze={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Ke=/\\|'|\r|\n|\u2028|\u2029/g;function Xe(e){return"\\"+Ze[e]}var qe=/^\s*(\w|\$)+\s*$/,$e=0;function et(e,t,n,r,o){if(!(r instanceof t))return e.apply(n,o);var i=Ie(e.prototype),a=e.apply(i,o);return E(a)?a:i}var tt=w((function(e,t){var n=tt.placeholder;return function r(){for(var o=0,i=t.length,a=Array(i),A=0;A1)ot(A,t-1,n,r),o=r.length;else for(var s=0,c=A.length;s0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}var ut=tt(ct,2);function lt(e,t,n){t=Ne(t,n);for(var r,o=ne(e),i=0,a=o.length;i0?0:o-1;i>=0&&i0?a=i>=0?i:Math.max(i+A,a):A=i>=0?Math.min(i+1,A):i+A+1;else if(n&&i&&A)return r[i=n(r,o)]===o?i:-1;if(o!=o)return(i=t(s.call(r,a,A),V))>=0?i+a:-1;for(i=e>0?a:A-1;i>=0&&i0?0:a-1;for(o||(r=t[i?i[A]:A],A+=e);A>=0&&A=3;return t(e,Pe(n,o,4),r,i)}}var Et=wt(1),Bt=wt(-1);function xt(e,t,n){var r=[];return t=Ne(t,n),yt(e,(function(e,n,o){t(e,n,o)&&r.push(e)})),r}function kt(e,t,n){t=Ne(t,n);for(var r=!rt(e)&&ne(e),o=(r||e).length,i=0;i=0}var Tt=w((function(e,t,n){var r,o;return P(t)?o=t:(t=Le(t),r=t.slice(0,-1),t=t[t.length-1]),bt(e,(function(e){var i=o;if(!i){if(r&&r.length&&(e=Re(e,r)),null==e)return;i=e[t]}return null==i?i:i.apply(e,n)}))}));function Lt(e,t){return bt(e,De(t))}function Rt(e,t,n){var r,o,i=-1/0,A=-1/0;if(null==t||"number"==typeof t&&"object"!=a(e[0])&&null!=e)for(var s=0,c=(e=rt(e)?e:ye(e)).length;si&&(i=r);else t=Ne(t,n),yt(e,(function(e,n,r){((o=t(e,n,r))>A||o===-1/0&&i===-1/0)&&(i=e,A=o)}));return i}function Mt(e,t,n){if(null==t||n)return rt(e)||(e=ye(e)),e[je(e.length-1)];var r=rt(e)?Se(e):ye(e),o=ee(r);t=Math.max(Math.min(t,o),0);for(var i=o-1,a=0;a1&&(r=Pe(r,t[1])),t=se(e)):(r=Nt,t=ot(t,!1,!1),e=Object(e));for(var o=0,i=t.length;o1&&(n=t[1])):(t=bt(ot(t,!1,!1),String),r=function(e,n){return!St(t,n)}),Wt(e,r,n)}));function Yt(e,t,n){return s.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))}function Gt(e,t,n){return null==e||e.length<1?null==t||n?void 0:[]:null==t||n?e[0]:Yt(e,e.length-t)}function zt(e,t,n){return s.call(e,null==t||n?1:t)}var _t=w((function(e,t){return t=ot(t,!0,!0),xt(e,(function(e){return!St(t,e)}))})),Vt=w((function(e,t){return _t(e,t)}));function Ht(e,t,n,r){x(t)||(r=n,n=t,t=!1),null!=n&&(n=Ne(n,r));for(var o=[],i=[],a=0,A=ee(e);at?(r&&(clearTimeout(r),r=null),A=c,a=e.apply(o,i),r||(o=i=null)):r||!1===n.trailing||(r=setTimeout(s,u)),a};return c.cancel=function(){clearTimeout(r),A=0,r=o=i=null},c},debounce:function(e,t,n){var r,o,i,a,A,s=function s(){var c=Ye()-o;t>c?r=setTimeout(s,t-c):(r=null,n||(a=e.apply(A,i)),r||(i=A=null))},c=w((function(c){return A=this,i=c,o=Ye(),r||(r=setTimeout(s,t),n&&(a=e.apply(A,i))),a}));return c.cancel=function(){clearTimeout(r),r=i=A=null},c},wrap:function(e,t){return tt(t,e)},negate:st,compose:function(){var e=arguments,t=e.length-1;return function(){for(var n=t,r=e[t].apply(this,arguments);n--;)r=e[n].call(this,r);return r}},after:function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},before:ct,once:ut,findKey:lt,findIndex:pt,findLastIndex:dt,sortedIndex:gt,indexOf:vt,lastIndexOf:mt,find:Ct,detect:Ct,findWhere:function(e,t){return Ct(e,Qe(t))},each:yt,forEach:yt,map:bt,collect:bt,reduce:Et,foldl:Et,inject:Et,reduceRight:Bt,foldr:Bt,filter:xt,select:xt,reject:function(e,t,n){return xt(e,st(Ne(t)),n)},every:kt,all:kt,some:It,any:It,contains:St,includes:St,include:St,invoke:Tt,pluck:Lt,where:function(e,t){return xt(e,Qe(t))},max:Rt,min:function(e,t,n){var r,o,i=1/0,A=1/0;if(null==t||"number"==typeof t&&"object"!=a(e[0])&&null!=e)for(var s=0,c=(e=rt(e)?e:ye(e)).length;sr||void 0===n)return 1;if(n>8&255]},z=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},_=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},V=function(e){return W(e,23,4)},H=function(e){return W(e,52,8)},J=function(e,t){C(e.prototype,t,{get:function(){return k(this)[t]}})},Z=function(e,t,n,r){var o=d(n),i=k(e);if(o+t>i.byteLength)throw F(T);var a=k(i.buffer).bytes,A=o+i.byteOffset,s=b(a,A,A+t);return r?s:N(s)},K=function(e,t,n,r,o,i){var a=d(n),A=k(e);if(a+t>A.byteLength)throw F(T);for(var s=k(A.buffer).bytes,c=a+A.byteOffset,u=r(+o),l=0;lee;)(q=$[ee++])in R||s(R,q,L[q]);M.constructor=R}v&&h(Q)!==D&&v(Q,D);var te=new O(new R(2)),ne=o(Q.setInt8);te.setInt8(0,2147483648),te.setInt8(1,2147483649),!te.getInt8(0)&&te.getInt8(1)||c(Q,{setInt8:function(e,t){ne(this,e,t<<24>>24)},setUint8:function(e,t){ne(this,e,t<<24>>24)}},{unsafe:!0})}else M=(R=function(e){l(this,M);var t=d(e);I(this,{bytes:U(P(t),0),byteLength:t}),i||(this.byteLength=t)}).prototype,Q=(O=function(e,t,n){l(this,Q),l(e,M);var r=k(e).byteLength,o=f(t);if(o<0||o>r)throw F("Wrong offset");if(o+(n=void 0===n?r-o:p(n))>r)throw F("Wrong length");I(this,{buffer:e,byteLength:n,byteOffset:o}),i||(this.buffer=e,this.byteLength=n,this.byteOffset=o)}).prototype,i&&(J(R,"byteLength"),J(O,"buffer"),J(O,"byteLength"),J(O,"byteOffset")),c(Q,{getInt8:function(e){return Z(this,1,e)[0]<<24>>24},getUint8:function(e){return Z(this,1,e)[0]},getInt16:function(e){var t=Z(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Z(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return _(Z(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return _(Z(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return j(Z(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return j(Z(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){K(this,1,e,Y,t)},setUint8:function(e,t){K(this,1,e,Y,t)},setInt16:function(e,t){K(this,2,e,G,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){K(this,2,e,G,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){K(this,4,e,z,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){K(this,4,e,z,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){K(this,4,e,V,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){K(this,8,e,H,t,arguments.length>2?arguments[2]:void 0)}});w(R,S),w(O,"DataView"),e.exports={ArrayBuffer:R,DataView:O}},1048:function(e,t,n){"use strict";var r=n(7908),o=n(1400),i=n(6244),a=Math.min;e.exports=[].copyWithin||function(e,t){var n=r(this),A=i(n),s=o(e,A),c=o(t,A),u=arguments.length>2?arguments[2]:void 0,l=a((void 0===u?A:o(u,A))-c,A-s),f=1;for(c0;)c in n?n[s]=n[c]:delete n[s],s+=f,c+=f;return n}},1285:function(e,t,n){"use strict";var r=n(7908),o=n(1400),i=n(6244);e.exports=function(e){for(var t=r(this),n=i(t),a=arguments.length,A=o(a>1?arguments[1]:void 0,n),s=a>2?arguments[2]:void 0,c=void 0===s?n:o(s,n);c>A;)t[A++]=e;return t}},8533:function(e,t,n){"use strict";var r=n(2092).forEach,o=n(2133)("forEach");e.exports=o?[].forEach:function(e){return r(this,e,arguments.length>1?arguments[1]:void 0)}},7745:function(e,t,n){var r=n(6244);e.exports=function(e,t){for(var n=0,o=r(t),i=new e(o);o>n;)i[n]=t[n++];return i}},8457:function(e,t,n){"use strict";var r=n(7854),o=n(9974),i=n(6916),a=n(7908),A=n(3411),s=n(7659),c=n(4411),u=n(6244),l=n(6135),f=n(8554),p=n(1246),d=r.Array;e.exports=function(e){var t=a(e),n=c(this),r=arguments.length,g=r>1?arguments[1]:void 0,h=void 0!==g;h&&(g=o(g,r>2?arguments[2]:void 0));var v,m,C,y,b,w,E=p(t),B=0;if(!E||this==d&&s(E))for(v=u(t),m=n?new this(v):d(v);v>B;B++)w=h?g(t[B],B):t[B],l(m,B,w);else for(b=(y=f(t,E)).next,m=n?new this:[];!(C=i(b,y)).done;B++)w=h?A(y,g,[C.value,B],!0):C.value,l(m,B,w);return m.length=B,m}},1318:function(e,t,n){var r=n(5656),o=n(1400),i=n(6244),a=function(e){return function(t,n,a){var A,s=r(t),c=i(s),u=o(a,c);if(e&&n!=n){for(;c>u;)if((A=s[u++])!=A)return!0}else for(;c>u;u++)if((e||u in s)&&s[u]===n)return e||u||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},2092:function(e,t,n){var r=n(9974),o=n(1702),i=n(8361),a=n(7908),A=n(6244),s=n(5417),c=o([].push),u=function(e){var t=1==e,n=2==e,o=3==e,u=4==e,l=6==e,f=7==e,p=5==e||l;return function(d,g,h,v){for(var m,C,y=a(d),b=i(y),w=r(g,h),E=A(b),B=0,x=v||s,k=t?x(d,E):n||f?x(d,0):void 0;E>B;B++)if((p||B in b)&&(C=w(m=b[B],B,y),e))if(t)k[B]=C;else if(C)switch(e){case 3:return!0;case 5:return m;case 6:return B;case 2:c(k,m)}else switch(e){case 4:return!1;case 7:c(k,m)}return l?-1:o||u?u:k}};e.exports={forEach:u(0),map:u(1),filter:u(2),some:u(3),every:u(4),find:u(5),findIndex:u(6),filterReject:u(7)}},6583:function(e,t,n){"use strict";var r=n(2104),o=n(5656),i=n(9303),a=n(6244),A=n(2133),s=Math.min,c=[].lastIndexOf,u=!!c&&1/[1].lastIndexOf(1,-0)<0,l=A("lastIndexOf"),f=u||!l;e.exports=f?function(e){if(u)return r(c,this,arguments)||0;var t=o(this),n=a(t),A=n-1;for(arguments.length>1&&(A=s(A,i(arguments[1]))),A<0&&(A=n+A);A>=0;A--)if(A in t&&t[A]===e)return A||0;return-1}:c},1194:function(e,t,n){var r=n(7293),o=n(5112),i=n(7392),a=o("species");e.exports=function(e){return i>=51||!r((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}},2133:function(e,t,n){"use strict";var r=n(7293);e.exports=function(e,t){var n=[][e];return!!n&&r((function(){n.call(null,t||function(){throw 1},1)}))}},3671:function(e,t,n){var r=n(7854),o=n(9662),i=n(7908),a=n(8361),A=n(6244),s=r.TypeError,c=function(e){return function(t,n,r,c){o(n);var u=i(t),l=a(u),f=A(u),p=e?f-1:0,d=e?-1:1;if(r<2)for(;;){if(p in l){c=l[p],p+=d;break}if(p+=d,e?p<0:f<=p)throw s("Reduce of empty array with no initial value")}for(;e?p>=0:f>p;p+=d)p in l&&(c=n(c,l[p],p,u));return c}};e.exports={left:c(!1),right:c(!0)}},1589:function(e,t,n){var r=n(7854),o=n(1400),i=n(6244),a=n(6135),A=r.Array,s=Math.max;e.exports=function(e,t,n){for(var r=i(e),c=o(t,r),u=o(void 0===n?r:n,r),l=A(s(u-c,0)),f=0;c0;)e[r]=e[--r];r!==i++&&(e[r]=n)}return e},A=function(e,t,n,r){for(var o=t.length,i=n.length,a=0,A=0;a1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!m(this,e)}}),i(p,n?{get:function(e){var t=m(this,e);return t&&t.value},set:function(e,t){return v(this,0===e?0:e,t)}}:{add:function(e){return v(this,e=0===e?0:e,e)}}),l&&r(p,"size",{get:function(){return h(this).size}}),u},setStrong:function(e,t,n){var r=t+" Iterator",o=g(t),i=g(r);c(e,t,(function(e,t){d(this,{type:r,target:e,state:o(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),u(t)}}},9320:function(e,t,n){"use strict";var r=n(1702),o=n(2248),i=n(2423).getWeakData,a=n(9670),A=n(111),s=n(5787),c=n(408),u=n(2092),l=n(2597),f=n(9909),p=f.set,d=f.getterFor,g=u.find,h=u.findIndex,v=r([].splice),m=0,C=function(e){return e.frozen||(e.frozen=new y)},y=function(){this.entries=[]},b=function(e,t){return g(e.entries,(function(e){return e[0]===t}))};y.prototype={get:function(e){var t=b(this,e);if(t)return t[1]},has:function(e){return!!b(this,e)},set:function(e,t){var n=b(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=h(this.entries,(function(t){return t[0]===e}));return~t&&v(this.entries,t,1),!!~t}},e.exports={getConstructor:function(e,t,n,r){var u=e((function(e,o){s(e,f),p(e,{type:t,id:m++,frozen:void 0}),null!=o&&c(o,e[r],{that:e,AS_ENTRIES:n})})),f=u.prototype,g=d(t),h=function(e,t,n){var r=g(e),o=i(a(t),!0);return!0===o?C(r).set(t,n):o[r.id]=n,e};return o(f,{delete:function(e){var t=g(this);if(!A(e))return!1;var n=i(e);return!0===n?C(t).delete(e):n&&l(n,t.id)&&delete n[t.id]},has:function(e){var t=g(this);if(!A(e))return!1;var n=i(e);return!0===n?C(t).has(e):n&&l(n,t.id)}}),o(f,n?{get:function(e){var t=g(this);if(A(e)){var n=i(e);return!0===n?C(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return h(this,e,t)}}:{add:function(e){return h(this,e,!0)}}),u}}},7710:function(e,t,n){"use strict";var r=n(2109),o=n(7854),i=n(1702),a=n(4705),A=n(1320),s=n(2423),c=n(408),u=n(5787),l=n(614),f=n(111),p=n(7293),d=n(7072),g=n(8003),h=n(9587);e.exports=function(e,t,n){var v=-1!==e.indexOf("Map"),m=-1!==e.indexOf("Weak"),C=v?"set":"add",y=o[e],b=y&&y.prototype,w=y,E={},B=function(e){var t=i(b[e]);A(b,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(m&&!f(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return m&&!f(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(m&&!f(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(a(e,!l(y)||!(m||b.forEach&&!p((function(){(new y).entries().next()})))))w=n.getConstructor(t,e,v,C),s.enable();else if(a(e,!0)){var x=new w,k=x[C](m?{}:-0,1)!=x,I=p((function(){x.has(1)})),S=d((function(e){new y(e)})),T=!m&&p((function(){for(var e=new y,t=5;t--;)e[C](t,t);return!e.has(-0)}));S||((w=t((function(e,t){u(e,b);var n=h(new y,e,w);return null!=t&&c(t,n[C],{that:n,AS_ENTRIES:v}),n}))).prototype=b,b.constructor=w),(I||T)&&(B("delete"),B("has"),v&&B("get")),(T||k)&&B(C),m&&b.clear&&delete b.clear}return E[e]=w,r({global:!0,forced:w!=y},E),g(w,e),m||n.setStrong(w,e,v),w}},9920:function(e,t,n){var r=n(2597),o=n(3887),i=n(1236),a=n(3070);e.exports=function(e,t,n){for(var A=o(t),s=a.f,c=i.f,u=0;u"+s+""}},4994:function(e,t,n){"use strict";var r=n(3383).IteratorPrototype,o=n(30),i=n(9114),a=n(8003),A=n(7497),s=function(){return this};e.exports=function(e,t,n,c){var u=t+" Iterator";return e.prototype=o(r,{next:i(+!c,n)}),a(e,u,!1,!0),A[u]=s,e}},8880:function(e,t,n){var r=n(9781),o=n(3070),i=n(9114);e.exports=r?function(e,t,n){return o.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},9114:function(e){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},6135:function(e,t,n){"use strict";var r=n(4948),o=n(3070),i=n(9114);e.exports=function(e,t,n){var a=r(t);a in e?o.f(e,a,i(0,n)):e[a]=n}},5573:function(e,t,n){"use strict";var r=n(7854),o=n(1702),i=n(7293),a=n(6650).start,A=r.RangeError,s=Math.abs,c=Date.prototype,u=c.toISOString,l=o(c.getTime),f=o(c.getUTCDate),p=o(c.getUTCFullYear),d=o(c.getUTCHours),g=o(c.getUTCMilliseconds),h=o(c.getUTCMinutes),v=o(c.getUTCMonth),m=o(c.getUTCSeconds);e.exports=i((function(){return"0385-07-25T07:06:39.999Z"!=u.call(new Date(-50000000000001))}))||!i((function(){u.call(new Date(NaN))}))?function(){if(!isFinite(l(this)))throw A("Invalid time value");var e=this,t=p(e),n=g(e),r=t<0?"-":t>9999?"+":"";return r+a(s(t),r?6:4,0)+"-"+a(v(e)+1,2,0)+"-"+a(f(e),2,0)+"T"+a(d(e),2,0)+":"+a(h(e),2,0)+":"+a(m(e),2,0)+"."+a(n,3,0)+"Z"}:u},8709:function(e,t,n){"use strict";var r=n(7854),o=n(9670),i=n(2140),a=r.TypeError;e.exports=function(e){if(o(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw a("Incorrect hint");return i(this,e)}},654:function(e,t,n){"use strict";var r=n(2109),o=n(6916),i=n(1913),a=n(6530),A=n(614),s=n(4994),c=n(9518),u=n(7674),l=n(8003),f=n(8880),p=n(1320),d=n(5112),g=n(7497),h=n(3383),v=a.PROPER,m=a.CONFIGURABLE,C=h.IteratorPrototype,y=h.BUGGY_SAFARI_ITERATORS,b=d("iterator"),w="keys",E="values",B="entries",x=function(){return this};e.exports=function(e,t,n,a,d,h,k){s(n,t,a);var I,S,T,L=function(e){if(e===d&&D)return D;if(!y&&e in O)return O[e];switch(e){case w:case E:case B:return function(){return new n(this,e)}}return function(){return new n(this)}},R=t+" Iterator",M=!1,O=e.prototype,Q=O[b]||O["@@iterator"]||d&&O[d],D=!y&&Q||L(d),P="Array"==t&&O.entries||Q;if(P&&(I=c(P.call(new e)))!==Object.prototype&&I.next&&(i||c(I)===C||(u?u(I,C):A(I[b])||p(I,b,x)),l(I,R,!0,!0),i&&(g[R]=x)),v&&d==E&&Q&&Q.name!==E&&(!i&&m?f(O,"name",E):(M=!0,D=function(){return o(Q,this)})),d)if(S={values:L(E),keys:h?D:L(w),entries:L(B)},k)for(T in S)(y||M||!(T in O))&&p(O,T,S[T]);else r({target:t,proto:!0,forced:y||M},S);return i&&!k||O[b]===D||p(O,b,D,{name:d}),g[t]=D,S}},7235:function(e,t,n){var r=n(857),o=n(2597),i=n(6061),a=n(3070).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});o(t,e)||a(t,e,{value:i.f(e)})}},9781:function(e,t,n){var r=n(7293);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},317:function(e,t,n){var r=n(7854),o=n(111),i=r.document,a=o(i)&&o(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},3678:function(e){e.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8324:function(e){e.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},8509:function(e,t,n){var r=n(317)("span").classList,o=r&&r.constructor&&r.constructor.prototype;e.exports=o===Object.prototype?void 0:o},8886:function(e,t,n){var r=n(8113).match(/firefox\/(\d+)/i);e.exports=!!r&&+r[1]},7871:function(e){e.exports="object"==typeof window},256:function(e,t,n){var r=n(8113);e.exports=/MSIE|Trident/.test(r)},1528:function(e,t,n){var r=n(8113),o=n(7854);e.exports=/ipad|iphone|ipod/i.test(r)&&void 0!==o.Pebble},8334:function(e,t,n){var r=n(8113);e.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(r)},5268:function(e,t,n){var r=n(4326),o=n(7854);e.exports="process"==r(o.process)},1036:function(e,t,n){var r=n(8113);e.exports=/web0s(?!.*chrome)/i.test(r)},8113:function(e,t,n){var r=n(5005);e.exports=r("navigator","userAgent")||""},7392:function(e,t,n){var r,o,i=n(7854),a=n(8113),A=i.process,s=i.Deno,c=A&&A.versions||s&&s.version,u=c&&c.v8;u&&(o=(r=u.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!o&&a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(o=+r[1]),e.exports=o},8008:function(e,t,n){var r=n(8113).match(/AppleWebKit\/(\d+)\./);e.exports=!!r&&+r[1]},748:function(e){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2914:function(e,t,n){var r=n(7293),o=n(9114);e.exports=!r((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",o(1,7)),7!==e.stack)}))},7762:function(e,t,n){"use strict";var r=n(9781),o=n(7293),i=n(9670),a=n(30),A=n(6277),s=Error.prototype.toString,c=o((function(){if(r){var e=a(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==s.call(e))return!0}return"2: 1"!==s.call({message:1,name:2})||"Error"!==s.call({})}));e.exports=c?function(){var e=i(this),t=A(e.name,"Error"),n=A(e.message);return t?n?t+": "+n:t:n}:s},2109:function(e,t,n){var r=n(7854),o=n(1236).f,i=n(8880),a=n(1320),A=n(3505),s=n(9920),c=n(4705);e.exports=function(e,t){var n,u,l,f,p,d=e.target,g=e.global,h=e.stat;if(n=g?r:h?r[d]||A(d,{}):(r[d]||{}).prototype)for(u in t){if(f=t[u],l=e.noTargetGet?(p=o(n,u))&&p.value:n[u],!c(g?u:d+(h?".":"#")+u,e.forced)&&void 0!==l){if(typeof f==typeof l)continue;s(f,l)}(e.sham||l&&l.sham)&&i(f,"sham",!0),a(n,u,f,e)}}},7293:function(e){e.exports=function(e){try{return!!e()}catch(e){return!0}}},7007:function(e,t,n){"use strict";n(4916);var r=n(1702),o=n(1320),i=n(2261),a=n(7293),A=n(5112),s=n(8880),c=A("species"),u=RegExp.prototype;e.exports=function(e,t,n,l){var f=A(e),p=!a((function(){var t={};return t[f]=function(){return 7},7!=""[e](t)})),d=p&&!a((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[c]=function(){return n},n.flags="",n[f]=/./[f]),n.exec=function(){return t=!0,null},n[f](""),!t}));if(!p||!d||n){var g=r(/./[f]),h=t(f,""[e],(function(e,t,n,o,a){var A=r(e),s=t.exec;return s===i||s===u.exec?p&&!a?{done:!0,value:g(t,n,o)}:{done:!0,value:A(n,t,o)}:{done:!1}}));o(String.prototype,e,h[0]),o(u,f,h[1])}l&&s(u[f],"sham",!0)}},6790:function(e,t,n){"use strict";var r=n(7854),o=n(3157),i=n(6244),a=n(9974),A=r.TypeError,s=function(e,t,n,r,c,u,l,f){for(var p,d,g=c,h=0,v=!!l&&a(l,f);h0&&o(p))d=i(p),g=s(e,t,p,d,g,u-1)-1;else{if(g>=9007199254740991)throw A("Exceed the acceptable array length");e[g]=p}g++}h++}return g};e.exports=s},6677:function(e,t,n){var r=n(7293);e.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},2104:function(e,t,n){var r=n(4374),o=Function.prototype,i=o.apply,a=o.call;e.exports="object"==typeof Reflect&&Reflect.apply||(r?a.bind(i):function(){return a.apply(i,arguments)})},9974:function(e,t,n){var r=n(1702),o=n(9662),i=n(4374),a=r(r.bind);e.exports=function(e,t){return o(e),void 0===t?e:i?a(e,t):function(){return e.apply(t,arguments)}}},4374:function(e,t,n){var r=n(7293);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},7065:function(e,t,n){"use strict";var r=n(7854),o=n(1702),i=n(9662),a=n(111),A=n(2597),s=n(206),c=n(4374),u=r.Function,l=o([].concat),f=o([].join),p={},d=function(e,t,n){if(!A(p,t)){for(var r=[],o=0;o]*>)/g,u=/\$([$&'`]|\d{1,2})/g;e.exports=function(e,t,n,r,l,f){var p=n+e.length,d=r.length,g=u;return void 0!==l&&(l=o(l),g=c),A(f,g,(function(o,A){var c;switch(a(A,0)){case"$":return"$";case"&":return e;case"`":return s(t,0,n);case"'":return s(t,p);case"<":c=l[s(A,1,-1)];break;default:var u=+A;if(0===u)return o;if(u>d){var f=i(u/10);return 0===f?o:f<=d?void 0===r[f-1]?a(A,1):r[f-1]+a(A,1):o}c=r[u-1]}return void 0===c?"":c}))}},7854:function(e,t,n){var r=function(e){return e&&e.Math==Math&&e};e.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},2597:function(e,t,n){var r=n(1702),o=n(7908),i=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return i(o(e),t)}},3501:function(e){e.exports={}},842:function(e,t,n){var r=n(7854);e.exports=function(e,t){var n=r.console;n&&n.error&&(1==arguments.length?n.error(e):n.error(e,t))}},490:function(e,t,n){var r=n(5005);e.exports=r("document","documentElement")},4664:function(e,t,n){var r=n(9781),o=n(7293),i=n(317);e.exports=!r&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},1179:function(e,t,n){var r=n(7854).Array,o=Math.abs,i=Math.pow,a=Math.floor,A=Math.log,s=Math.LN2;e.exports={pack:function(e,t,n){var c,u,l,f=r(n),p=8*n-t-1,d=(1<>1,h=23===t?i(2,-24)-i(2,-77):0,v=e<0||0===e&&1/e<0?1:0,m=0;for((e=o(e))!=e||e===1/0?(u=e!=e?1:0,c=d):(c=a(A(e)/s),e*(l=i(2,-c))<1&&(c--,l*=2),(e+=c+g>=1?h/l:h*i(2,1-g))*l>=2&&(c++,l/=2),c+g>=d?(u=0,c=d):c+g>=1?(u=(e*l-1)*i(2,t),c+=g):(u=e*i(2,g-1)*i(2,t),c=0));t>=8;)f[m++]=255&u,u/=256,t-=8;for(c=c<0;)f[m++]=255&c,c/=256,p-=8;return f[--m]|=128*v,f},unpack:function(e,t){var n,r=e.length,o=8*r-t-1,a=(1<>1,s=o-7,c=r-1,u=e[c--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(0===l)l=1-A;else{if(l===a)return n?NaN:u?-1/0:1/0;n+=i(2,t),l-=A}return(u?-1:1)*n*i(2,l-t)}}},8361:function(e,t,n){var r=n(7854),o=n(1702),i=n(7293),a=n(4326),A=r.Object,s=o("".split);e.exports=i((function(){return!A("z").propertyIsEnumerable(0)}))?function(e){return"String"==a(e)?s(e,""):A(e)}:A},9587:function(e,t,n){var r=n(614),o=n(111),i=n(7674);e.exports=function(e,t,n){var a,A;return i&&r(a=t.constructor)&&a!==n&&o(A=a.prototype)&&A!==n.prototype&&i(e,A),e}},2788:function(e,t,n){var r=n(1702),o=n(614),i=n(5465),a=r(Function.toString);o(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),e.exports=i.inspectSource},8340:function(e,t,n){var r=n(111),o=n(8880);e.exports=function(e,t){r(t)&&"cause"in t&&o(e,"cause",t.cause)}},2423:function(e,t,n){var r=n(2109),o=n(1702),i=n(3501),a=n(111),A=n(2597),s=n(3070).f,c=n(8006),u=n(1156),l=n(2050),f=n(9711),p=n(6677),d=!1,g=f("meta"),h=0,v=function(e){s(e,g,{value:{objectID:"O"+h++,weakData:{}}})},m=e.exports={enable:function(){m.enable=function(){},d=!0;var e=c.f,t=o([].splice),n={};n[g]=1,e(n).length&&(c.f=function(n){for(var r=e(n),o=0,i=r.length;om;m++)if((y=T(e[m]))&&u(h,y))return y;return new g(!1)}r=l(e,v)}for(b=r.next;!(w=i(b,r)).done;){try{y=T(w.value)}catch(e){p(r,"throw",e)}if("object"==typeof y&&y&&u(h,y))return y}return new g(!1)}},9212:function(e,t,n){var r=n(6916),o=n(9670),i=n(8173);e.exports=function(e,t,n){var a,A;o(e);try{if(!(a=i(e,"return"))){if("throw"===t)throw n;return n}a=r(a,e)}catch(e){A=!0,a=e}if("throw"===t)throw n;if(A)throw a;return o(a),n}},3383:function(e,t,n){"use strict";var r,o,i,a=n(7293),A=n(614),s=n(30),c=n(9518),u=n(1320),l=n(5112),f=n(1913),p=l("iterator"),d=!1;[].keys&&("next"in(i=[].keys())?(o=c(c(i)))!==Object.prototype&&(r=o):d=!0),null==r||a((function(){var e={};return r[p].call(e)!==e}))?r={}:f&&(r=s(r)),A(r[p])||u(r,p,(function(){return this})),e.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:d}},7497:function(e){e.exports={}},6244:function(e,t,n){var r=n(7466);e.exports=function(e){return r(e.length)}},6736:function(e){var t=Math.expm1,n=Math.exp;e.exports=!t||t(10)>22025.465794806718||t(10)<22025.465794806718||-2e-17!=t(-2e-17)?function(e){return 0==(e=+e)?e:e>-1e-6&&e<1e-6?e+e*e/2:n(e)-1}:t},6130:function(e,t,n){var r=n(4310),o=Math.abs,i=Math.pow,a=i(2,-52),A=i(2,-23),s=i(2,127)*(2-A),c=i(2,-126);e.exports=Math.fround||function(e){var t,n,i=o(e),u=r(e);return is||n!=n?u*(1/0):u*n}},202:function(e){var t=Math.log,n=Math.LOG10E;e.exports=Math.log10||function(e){return t(e)*n}},6513:function(e){var t=Math.log;e.exports=Math.log1p||function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:t(1+e)}},4310:function(e){e.exports=Math.sign||function(e){return 0==(e=+e)||e!=e?e:e<0?-1:1}},5948:function(e,t,n){var r,o,i,a,A,s,c,u,l=n(7854),f=n(9974),p=n(1236).f,d=n(261).set,g=n(8334),h=n(1528),v=n(1036),m=n(5268),C=l.MutationObserver||l.WebKitMutationObserver,y=l.document,b=l.process,w=l.Promise,E=p(l,"queueMicrotask"),B=E&&E.value;B||(r=function(){var e,t;for(m&&(e=b.domain)&&e.exit();o;){t=o.fn,o=o.next;try{t()}catch(e){throw o?a():i=void 0,e}}i=void 0,e&&e.enter()},g||m||v||!C||!y?!h&&w&&w.resolve?((c=w.resolve(void 0)).constructor=w,u=f(c.then,c),a=function(){u(r)}):m?a=function(){b.nextTick(r)}:(d=f(d,l),a=function(){d(r)}):(A=!0,s=y.createTextNode(""),new C(r).observe(s,{characterData:!0}),a=function(){s.data=A=!A})),e.exports=B||function(e){var t={fn:e,next:void 0};i&&(i.next=t),o||(o=t,a()),i=t}},3366:function(e,t,n){var r=n(7854);e.exports=r.Promise},133:function(e,t,n){var r=n(7392),o=n(7293);e.exports=!!Object.getOwnPropertySymbols&&!o((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},590:function(e,t,n){var r=n(7293),o=n(5112),i=n(1913),a=o("iterator");e.exports=!r((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),i&&!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[a]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))},8536:function(e,t,n){var r=n(7854),o=n(614),i=n(2788),a=r.WeakMap;e.exports=o(a)&&/native code/.test(i(a))},8523:function(e,t,n){"use strict";var r=n(9662),o=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=r(t),this.reject=r(n)};e.exports.f=function(e){return new o(e)}},6277:function(e,t,n){var r=n(1340);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:r(e)}},3929:function(e,t,n){var r=n(7854),o=n(7850),i=r.TypeError;e.exports=function(e){if(o(e))throw i("The method doesn't accept regular expressions");return e}},7023:function(e,t,n){var r=n(7854).isFinite;e.exports=Number.isFinite||function(e){return"number"==typeof e&&r(e)}},2814:function(e,t,n){var r=n(7854),o=n(7293),i=n(1702),a=n(1340),A=n(3111).trim,s=n(1361),c=i("".charAt),u=r.parseFloat,l=r.Symbol,f=l&&l.iterator,p=1/u(s+"-0")!=-1/0||f&&!o((function(){u(Object(f))}));e.exports=p?function(e){var t=A(a(e)),n=u(t);return 0===n&&"-"==c(t,0)?-0:n}:u},3009:function(e,t,n){var r=n(7854),o=n(7293),i=n(1702),a=n(1340),A=n(3111).trim,s=n(1361),c=r.parseInt,u=r.Symbol,l=u&&u.iterator,f=/^[+-]?0x/i,p=i(f.exec),d=8!==c(s+"08")||22!==c(s+"0x16")||l&&!o((function(){c(Object(l))}));e.exports=d?function(e,t){var n=A(a(e));return c(n,t>>>0||(p(f,n)?16:10))}:c},1574:function(e,t,n){"use strict";var r=n(9781),o=n(1702),i=n(6916),a=n(7293),A=n(1956),s=n(5181),c=n(5296),u=n(7908),l=n(8361),f=Object.assign,p=Object.defineProperty,d=o([].concat);e.exports=!f||a((function(){if(r&&1!==f({b:1},f(p({},"a",{enumerable:!0,get:function(){p(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),o="abcdefghijklmnopqrst";return e[n]=7,o.split("").forEach((function(e){t[e]=e})),7!=f({},e)[n]||A(f({},t)).join("")!=o}))?function(e,t){for(var n=u(e),o=arguments.length,a=1,f=s.f,p=c.f;o>a;)for(var g,h=l(arguments[a++]),v=f?d(A(h),f(h)):A(h),m=v.length,C=0;m>C;)g=v[C++],r&&!i(p,h,g)||(n[g]=h[g]);return n}:f},30:function(e,t,n){var r,o=n(9670),i=n(6048),a=n(748),A=n(3501),s=n(490),c=n(317),u=n(6200)("IE_PROTO"),l=function(){},f=function(e){return"