@mux/playback-core 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +4 -4
- package/dist/playback-core.js +15 -15
- package/dist/playback-core.js.map +4 -4
- package/dist/playback-core.mjs +15 -15
- package/dist/playback-core.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/autoplay.d.ts +4 -12
- package/dist/types/index.d.ts +14 -61
- package/dist/types/preload.d.ts +1 -0
- package/dist/types/types.d.ts +69 -0
- package/dist/types/util.d.ts +4 -2
- package/dist/types-ts3.4/autoplay.d.ts +4 -12
- package/dist/types-ts3.4/index.d.ts +14 -64
- package/dist/types-ts3.4/preload.d.ts +1 -0
- package/dist/types-ts3.4/types.d.ts +69 -0
- package/dist/types-ts3.4/util.d.ts +7 -2
- package/package.json +13 -4
package/dist/playback-core.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
"use strict";(()=>{var wt=Object.create;var pt=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var kt=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty;var yt=(K,P)=>()=>(P||K((P={exports:{}}).exports,P),P.exports);var Kt=(K,P,h,R)=>{if(P&&typeof P=="object"||typeof P=="function")for(let p of Bt(P))!Nt.call(K,p)&&p!==h&&pt(K,p,{get:()=>P[p],enumerable:!(R=Ut(P,p))||R.enumerable});return K};var tt=(K,P,h)=>(h=K!=null?wt(kt(K)):{},Kt(P||!K||!K.__esModule?pt(h,"default",{value:K,enumerable:!0}):h,K));var Et=yt((rt,at)=>{(function(){var K=!1;(function(P,h){typeof rt=="object"&&typeof at=="object"?at.exports=h():typeof K=="function"&&K.amd?K("mux",[],h):typeof rt=="object"?rt.mux=h():P.mux=h()})(typeof self!="undefined"?self:this,function(){return function(P){function h(p){if(R[p])return R[p].exports;var S=R[p]={i:p,l:!1,exports:{}};return P[p].call(S.exports,S,S.exports,h),S.l=!0,S.exports}var R={};return h.m=P,h.c=R,h.d=function(p,S,I){h.o(p,S)||Object.defineProperty(p,S,{configurable:!1,enumerable:!0,get:I})},h.n=function(p){var S=p&&p.__esModule?function(){return p.default}:function(){return p};return h.d(S,"a",S),S},h.o=function(p,S){return Object.prototype.hasOwnProperty.call(p,S)},h.p="",h(h.s=18)}([function(P,h,R){(function(p){var S;S=typeof window!="undefined"?window:p!==void 0?p:typeof self!="undefined"?self:{},P.exports=S}).call(h,R(20))},function(P,h){function R(C,U,B){switch(B.length){case 0:return C.call(U);case 1:return C.call(U,B[0]);case 2:return C.call(U,B[0],B[1]);case 3:return C.call(U,B[0],B[1],B[2])}return C.apply(U,B)}function p(C,U){for(var B=-1,N=Array(C);++B<C;)N[B]=U(B);return N}function S(C,U){var B=F(C)||g(C)?p(C.length,String):[],N=B.length,k=!!N;for(var j in C)!U&&!o.call(C,j)||k&&(j=="length"||y(j,N))||B.push(j);return B}function I(C,U,B){var N=C[U];o.call(C,U)&&T(N,B)&&(B!==void 0||U in C)||(C[U]=B)}function x(C){if(!_(C))return O(C);var U=[];for(var B in Object(C))o.call(C,B)&&B!="constructor"&&U.push(B);return U}function L(C,U){return U=b(U===void 0?C.length-1:U,0),function(){for(var B=arguments,N=-1,k=b(B.length-U,0),j=Array(k);++N<k;)j[N]=B[U+N];N=-1;for(var H=Array(U+1);++N<U;)H[N]=B[N];return H[U]=j,R(C,this,H)}}function A(C,U,B,N){B||(B={});for(var k=-1,j=U.length;++k<j;){var H=U[k],V=N?N(B[H],C[H],H,B,C):void 0;I(B,H,V===void 0?C[H]:V)}return B}function y(C,U){return!!(U=U==null?t:U)&&(typeof C=="number"||c.test(C))&&C>-1&&C%1==0&&C<U}function D(C,U,B){if(!u(B))return!1;var N=typeof U;return!!(N=="number"?E(B)&&y(U,B.length):N=="string"&&U in B)&&T(B[U],C)}function _(C){var U=C&&C.constructor;return C===(typeof U=="function"&&U.prototype||f)}function T(C,U){return C===U||C!==C&&U!==U}function g(C){return a(C)&&o.call(C,"callee")&&(!m.call(C,"callee")||v.call(C)==l)}function E(C){return C!=null&&s(C.length)&&!e(C)}function a(C){return n(C)&&E(C)}function e(C){var U=u(C)?v.call(C):"";return U==d||U==r}function s(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=t}function u(C){var U=typeof C;return!!C&&(U=="object"||U=="function")}function n(C){return!!C&&typeof C=="object"}function i(C){return E(C)?S(C):x(C)}var t=9007199254740991,l="[object Arguments]",d="[object Function]",r="[object GeneratorFunction]",c=/^(?:0|[1-9]\d*)$/,f=Object.prototype,o=f.hasOwnProperty,v=f.toString,m=f.propertyIsEnumerable,O=function(C,U){return function(B){return C(U(B))}}(Object.keys,Object),b=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return L(function(U,B){var N=-1,k=B.length,j=k>1?B[k-1]:void 0,H=k>2?B[2]:void 0;for(j=C.length>3&&typeof j=="function"?(k--,j):void 0,H&&D(B[0],B[1],H)&&(j=k<3?void 0:j,k=1),U=Object(U);++N<k;){var V=B[N];V&&C(U,V,N,j)}return U})}(function(C,U){if(M||_(U)||E(U))return void A(U,i(U),C);for(var B in U)o.call(U,B)&&I(C,B,U[B])});P.exports=w},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I={};I.now=function(){var x=S.default.performance,L=x&&x.timing;return L&&typeof L.navigationStart=="number"&&typeof x.now=="function"?L.navigationStart+x.now():Date.now()},h.default=I},function(P,h,R){"use strict";function p(S,I,x){x=x===void 0?1:x,S[I]=S[I]||0,S[I]+=x}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(21),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=S.default.methodFactory;S.default.methodFactory=function(x,L,A){var y=I(x,L,A);return function(){for(var D=["[mux]"],_=0;_<arguments.length;_++)D.push(arguments[_]);y.apply(void 0,D)}},S.default.setLevel(S.default.getLevel()),h.default=S.default},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(x){return I(x)[0]},S=function(x){return I(x)[1]},I=function(x){if(typeof x!="string"||x==="")return["localhost"];var L=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,A=x.match(L)||[],y=A[4],D=void 0;return y&&(D=(y.match(/[^\.]+\.[^\.]+$/)||[])[0]),[y,D]};h.extractHostnameAndDomain=I,h.extractHostname=p,h.extractDomain=S},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(I){var x=16*Math.random()|0;return(I==="x"?x:3&x|8).toString(16)})},S=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};h.generateUUID=p,h.generateShortID=S},function(P,h,R){"use strict";function p(I){I=I||"";var x={};return I.trim().split(/[\r\n]+/).forEach(function(L){if(L){var A=L.split(": "),y=A.shift();y&&(S.indexOf(y.toLowerCase())>=0||y.toLowerCase().indexOf("x-litix-")===0)&&(x[y]=A.join(": "))}}),x}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=["x-cdn","content-type"]},function(P,h,R){"use strict";var p=SyntaxError,S=Function,I=TypeError,x=function(o){try{return S('"use strict"; return ('+o+").constructor;")()}catch{}},L=Object.getOwnPropertyDescriptor;if(L)try{L({},"")}catch{L=null}var A=function(){throw new I},y=L?function(){try{return arguments.callee,A}catch{try{return L(arguments,"callee").get}catch{return A}}}():A,D=R(43)(),_=Object.getPrototypeOf||function(o){return o.__proto__},T={},g=typeof Uint8Array=="undefined"?void 0:_(Uint8Array),E={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":D?_([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":S,"%GeneratorFunction%":T,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":D?_(_([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&D?_(new Map()[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?void 0:Promise,"%Proxy%":typeof Proxy=="undefined"?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?void 0:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?void 0:Set,"%SetIteratorPrototype%":typeof Set!="undefined"&&D?_(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":D?_(""[Symbol.iterator]()):void 0,"%Symbol%":D?Symbol:void 0,"%SyntaxError%":p,"%ThrowTypeError%":y,"%TypedArray%":g,"%TypeError%":I,"%Uint8Array%":typeof Uint8Array=="undefined"?void 0:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?void 0:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?void 0:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?void 0:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?void 0:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?void 0:WeakSet},a=function o(v){var m;if(v==="%AsyncFunction%")m=x("async function () {}");else if(v==="%GeneratorFunction%")m=x("function* () {}");else if(v==="%AsyncGeneratorFunction%")m=x("async function* () {}");else if(v==="%AsyncGenerator%"){var O=o("%AsyncGeneratorFunction%");O&&(m=O.prototype)}else if(v==="%AsyncIteratorPrototype%"){var b=o("%AsyncGenerator%");b&&(m=_(b.prototype))}return E[v]=m,m},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},s=R(9),u=R(46),n=s.call(Function.call,Array.prototype.concat),i=s.call(Function.apply,Array.prototype.splice),t=s.call(Function.call,String.prototype.replace),l=s.call(Function.call,String.prototype.slice),d=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,r=/\\(\\)?/g,c=function(o){var v=l(o,0,1),m=l(o,-1);if(v==="%"&&m!=="%")throw new p("invalid intrinsic syntax, expected closing `%`");if(m==="%"&&v!=="%")throw new p("invalid intrinsic syntax, expected opening `%`");var O=[];return t(o,d,function(b,M,F,w){O[O.length]=F?t(w,r,"$1"):M||b}),O},f=function(o,v){var m,O=o;if(u(e,O)&&(m=e[O],O="%"+m[0]+"%"),u(E,O)){var b=E[O];if(b===T&&(b=a(O)),b===void 0&&!v)throw new I("intrinsic "+o+" exists, but is not available. Please file an issue!");return{alias:m,name:O,value:b}}throw new p("intrinsic "+o+" does not exist!")};P.exports=function(o,v){if(typeof o!="string"||o.length===0)throw new I("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof v!="boolean")throw new I('"allowMissing" argument must be a boolean');var m=c(o),O=m.length>0?m[0]:"",b=f("%"+O+"%",v),M=b.name,F=b.value,w=!1,C=b.alias;C&&(O=C[0],i(m,n([0,1],C)));for(var U=1,B=!0;U<m.length;U+=1){var N=m[U],k=l(N,0,1),j=l(N,-1);if((k==='"'||k==="'"||k==="`"||j==='"'||j==="'"||j==="`")&&k!==j)throw new p("property names with quotes must have matching quotes");if(N!=="constructor"&&B||(w=!0),O+="."+N,M="%"+O+"%",u(E,M))F=E[M];else if(F!=null){if(!(N in F)){if(!v)throw new I("base intrinsic for "+o+" exists, but the property is not available.");return}if(L&&U+1>=m.length){var H=L(F,N);B=!!H,F=B&&"get"in H&&!("originalValue"in H.get)?H.get:F[N]}else B=u(F,N),F=F[N];B&&!w&&(E[M]=F)}}return F}},function(P,h,R){"use strict";var p=R(45);P.exports=Function.prototype.bind||p},function(P,h,R){"use strict";var p=String.prototype.replace,S=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};P.exports={default:I.RFC3986,formatters:{RFC1738:function(x){return p.call(x,S,"+")},RFC3986:function(x){return String(x)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0}),h.findMediaElement=h.getMuxPlayerId=void 0;var p=R(6),S=function(x){return x&&x.nodeName!==void 0?(x.muxId||(x.muxId=x.id||(0,p.generateShortID)()),x.muxId):x},I=function(x){var L=void 0;return x&&x.nodeName!==void 0?(L=x,x=S(L)):L=document.querySelector(x),[L,x,L&&L.nodeName?L.nodeName.toLowerCase():""]};h.getMuxPlayerId=S,h.findMediaElement=I},function(P,h,R){"use strict";function p(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(0),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I={};I.exists=function(){var x=S.default.performance;return(x&&x.timing)!==void 0},I.domContentLoadedEventEnd=function(){var x=S.default.performance,L=x&&x.timing;return L&&L.domContentLoadedEventEnd},I.navigationStart=function(){var x=S.default.performance,L=x&&x.timing;return L&&L.navigationStart},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(S){var I={};for(var x in S){var L=S[x];L["DATA-ID"].search("io.litix.data.")!==-1&&(I[L["DATA-ID"].replace("io.litix.data.","")]=L.VALUE)}return I};h.default=p},function(P,h,R){"use strict";var p=R(41),S=R(51),I=R(10);P.exports={formats:I,parse:S,stringify:p}},function(P,h,R){"use strict";var p=R(10),S=Object.prototype.hasOwnProperty,I=Array.isArray,x=function(){for(var u=[],n=0;n<256;++n)u.push("%"+((n<16?"0":"")+n.toString(16)).toUpperCase());return u}(),L=function(u){for(;u.length>1;){var n=u.pop(),i=n.obj[n.prop];if(I(i)){for(var t=[],l=0;l<i.length;++l)i[l]!==void 0&&t.push(i[l]);n.obj[n.prop]=t}}},A=function(u,n){for(var i=n&&n.plainObjects?Object.create(null):{},t=0;t<u.length;++t)u[t]!==void 0&&(i[t]=u[t]);return i},y=function u(n,i,t){if(!i)return n;if(typeof i!="object"){if(I(n))n.push(i);else{if(!n||typeof n!="object")return[n,i];(t&&(t.plainObjects||t.allowPrototypes)||!S.call(Object.prototype,i))&&(n[i]=!0)}return n}if(!n||typeof n!="object")return[n].concat(i);var l=n;return I(n)&&!I(i)&&(l=A(n,t)),I(n)&&I(i)?(i.forEach(function(d,r){if(S.call(n,r)){var c=n[r];c&&typeof c=="object"&&d&&typeof d=="object"?n[r]=u(c,d,t):n.push(d)}else n[r]=d}),n):Object.keys(i).reduce(function(d,r){var c=i[r];return S.call(d,r)?d[r]=u(d[r],c,t):d[r]=c,d},l)},D=function(u,n){return Object.keys(n).reduce(function(i,t){return i[t]=n[t],i},u)},_=function(u,n,i){var t=u.replace(/\+/g," ");if(i==="iso-8859-1")return t.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(t)}catch{return t}},T=function(u,n,i,t,l){if(u.length===0)return u;var d=u;if(typeof u=="symbol"?d=Symbol.prototype.toString.call(u):typeof u!="string"&&(d=String(u)),i==="iso-8859-1")return escape(d).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});for(var r="",c=0;c<d.length;++c){var f=d.charCodeAt(c);f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||l===p.RFC1738&&(f===40||f===41)?r+=d.charAt(c):f<128?r+=x[f]:f<2048?r+=x[192|f>>6]+x[128|63&f]:f<55296||f>=57344?r+=x[224|f>>12]+x[128|f>>6&63]+x[128|63&f]:(c+=1,f=65536+((1023&f)<<10|1023&d.charCodeAt(c)),r+=x[240|f>>18]+x[128|f>>12&63]+x[128|f>>6&63]+x[128|63&f])}return r},g=function(u){for(var n=[{obj:{o:u},prop:"o"}],i=[],t=0;t<n.length;++t)for(var l=n[t],d=l.obj[l.prop],r=Object.keys(d),c=0;c<r.length;++c){var f=r[c],o=d[f];typeof o=="object"&&o!==null&&i.indexOf(o)===-1&&(n.push({obj:d,prop:f}),i.push(o))}return L(n),u},E=function(u){return Object.prototype.toString.call(u)==="[object RegExp]"},a=function(u){return!(!u||typeof u!="object")&&!!(u.constructor&&u.constructor.isBuffer&&u.constructor.isBuffer(u))},e=function(u,n){return[].concat(u,n)},s=function(u,n){if(I(u)){for(var i=[],t=0;t<u.length;t+=1)i.push(n(u[t]));return i}return n(u)};P.exports={arrayToObject:A,assign:D,combine:e,compact:g,decode:_,encode:T,isBuffer:a,isRegExp:E,maybeMap:s,merge:y}},function(P,h,R){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}function S(E){var a={};for(var e in E)E.hasOwnProperty(e)&&(a[E[e]]=e);return a}function I(E){var a={},e={};return Object.keys(E).forEach(function(s){var u=!1;if(E.hasOwnProperty(s)&&E[s]!==void 0){var n=s.split("_"),i=n[0],t=_[i];t||(L.default.info("Data key word `"+n[0]+"` not expected in "+s),t=i+"_"),n.splice(1).forEach(function(l){l==="url"&&(u=!0),g[l]?t+=g[l]:Number(l)&&Math.floor(Number(l))===Number(l)?t+=l:(L.default.info("Data key word `"+l+"` not expected in "+s),t+="_"+l+"_")}),u?e[t]=E[s]:a[t]=E[s]}}),(0,y.default)(a,e)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=I;var x=R(4),L=p(x),A=R(1),y=p(A),D={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},_=S(D),T={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},g=S(T)},function(P,h,R){"use strict";P.exports=R(19).default},function(P,h,R){"use strict";function p(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(h,"__esModule",{value:!0});var S=function(){function r(c,f){var o=[],v=!0,m=!1,O=void 0;try{for(var b,M=c[Symbol.iterator]();!(v=(b=M.next()).done)&&(o.push(b.value),!f||o.length!==f);v=!0);}catch(F){m=!0,O=F}finally{try{!v&&M.return&&M.return()}finally{if(m)throw O}}return o}return function(c,f){if(Array.isArray(c))return c;if(Symbol.iterator in Object(c))return r(c,f);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(0),x=p(I),L=R(11),A=R(4),y=p(A),D=R(12),_=p(D),T=R(2),g=p(T),E=R(22),a=p(E),e=R(58),s=p(e),u=R(59),n=p(u),i=R(64),t=p(i),l={},d=function r(c){var f=arguments;typeof c=="string"?r.hasOwnProperty(c)?x.default.setTimeout(function(){f=Array.prototype.splice.call(f,1),r[c].apply(null,f)},0):y.default.warn("`"+c+"` is an unknown task"):typeof c=="function"?x.default.setTimeout(function(){c(r)},0):y.default.warn("`"+c+"` is invalid.")};d.loaded=g.default.now(),d.NAME="mux-embed",d.VERSION="4.8.0",d.API_VERSION="2.1",d.PLAYER_TRACKED=!1,d.monitor=function(r,c){return(0,s.default)(d,r,c)},d.destroyMonitor=function(r){var c=(0,L.findMediaElement)(r),f=S(c,1),o=f[0];o&&o.mux&&typeof o.mux.destroy=="function"?o.mux.destroy():y.default.error("A video element monitor for `"+r+"` has not been initialized via `mux.monitor`.")},d.addHLSJS=function(r,c){var f=(0,L.getMuxPlayerId)(r);l[f]?l[f].addHLSJS(c):y.default.error("A monitor for `"+f+"` has not been initialized.")},d.addDashJS=function(r,c){var f=(0,L.getMuxPlayerId)(r);l[f]?l[f].addDashJS(c):y.default.error("A monitor for `"+f+"` has not been initialized.")},d.removeHLSJS=function(r){var c=(0,L.getMuxPlayerId)(r);l[c]?l[c].removeHLSJS():y.default.error("A monitor for `"+c+"` has not been initialized.")},d.removeDashJS=function(r){var c=(0,L.getMuxPlayerId)(r);l[c]?l[c].removeDashJS():y.default.error("A monitor for `"+c+"` has not been initialized.")},d.init=function(r,c){(0,_.default)()&&c&&c.respectDoNotTrack&&y.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=(0,L.getMuxPlayerId)(r);l[f]=new a.default(d,f,c)},d.emit=function(r,c,f){var o=(0,L.getMuxPlayerId)(r);l[o]?(l[o].emit(c,f),c==="destroy"&&delete l[o]):y.default.error("A monitor for `"+o+"` has not been initialized.")},x.default!==void 0&&typeof x.default.addEventListener=="function"&&x.default.addEventListener("pagehide",function(r){r.persisted||(d.WINDOW_UNLOADING=!0)},!1),d.checkDoNotTrack=_.default,d.log=y.default,d.utils=n.default,d.events=t.default,h.default=d},function(P,h){var R;R=function(){return this}();try{R=R||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(R=window)}P.exports=R},function(P,h,R){var p,S;(function(I,x){"use strict";p=x,(S=typeof p=="function"?p.call(h,R,h,P):p)!==void 0&&(P.exports=S)})(0,function(){"use strict";function I(n,i){var t=n[i];if(typeof t.bind=="function")return t.bind(n);try{return Function.prototype.bind.call(t,n)}catch{return function(){return Function.prototype.apply.apply(t,[n,arguments])}}}function x(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function L(n){return n==="debug"&&(n="log"),typeof console!==g&&(n==="trace"&&E?x:console[n]!==void 0?I(console,n):console.log!==void 0?I(console,"log"):T)}function A(n,i){for(var t=0;t<a.length;t++){var l=a[t];this[l]=t<n?T:this.methodFactory(l,n,i)}this.log=this.debug}function y(n,i,t){return function(){typeof console!==g&&(A.call(this,i,t),this[n].apply(this,arguments))}}function D(n,i,t){return L(n)||y.apply(this,arguments)}function _(n,i,t){function l(m){var O=(a[m]||"silent").toUpperCase();if(typeof window!==g&&o){try{return void(window.localStorage[o]=O)}catch{}try{window.document.cookie=encodeURIComponent(o)+"="+O+";"}catch{}}}function d(){var m;if(typeof window!==g&&o){try{m=window.localStorage[o]}catch{}if(typeof m===g)try{var O=window.document.cookie,b=O.indexOf(encodeURIComponent(o)+"=");b!==-1&&(m=/^([^;]+)/.exec(O.slice(b))[1])}catch{}return f.levels[m]===void 0&&(m=void 0),m}}function r(){if(typeof window!==g&&o){try{return void window.localStorage.removeItem(o)}catch{}try{window.document.cookie=encodeURIComponent(o)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var c,f=this;i=i==null?"WARN":i;var o="loglevel";typeof n=="string"?o+=":"+n:typeof n=="symbol"&&(o=void 0),f.name=n,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=t||D,f.getLevel=function(){return c},f.setLevel=function(m,O){if(typeof m=="string"&&f.levels[m.toUpperCase()]!==void 0&&(m=f.levels[m.toUpperCase()]),!(typeof m=="number"&&m>=0&&m<=f.levels.SILENT))throw"log.setLevel() called with invalid level: "+m;if(c=m,O!==!1&&l(m),A.call(f,m,n),typeof console===g&&m<f.levels.SILENT)return"No console available for logging"},f.setDefaultLevel=function(m){i=m,d()||f.setLevel(m,!1)},f.resetLevel=function(){f.setLevel(i,!1),r()},f.enableAll=function(m){f.setLevel(f.levels.TRACE,m)},f.disableAll=function(m){f.setLevel(f.levels.SILENT,m)};var v=d();v==null&&(v=i),f.setLevel(v,!1)}var T=function(){},g="undefined",E=typeof window!==g&&typeof window.navigator!==g&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],e=new _,s={};e.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var i=s[n];return i||(i=s[n]=new _(n,e.getLevel(),e.methodFactory)),i};var u=typeof window!==g?window.log:void 0;return e.noConflict=function(){return typeof window!==g&&window.log===e&&(window.log=u),e},e.getLoggers=function(){return s},e.default=e,e})},function(P,h,R){"use strict";function p(ee){return ee&&ee.__esModule?ee:{default:ee}}Object.defineProperty(h,"__esModule",{value:!0});var S=function(){function ee($,Z){var ue=[],he=!0,se=!1,me=void 0;try{for(var pe,Ee=$[Symbol.iterator]();!(he=(pe=Ee.next()).done)&&(ue.push(pe.value),!Z||ue.length!==Z);he=!0);}catch(ae){se=!0,me=ae}finally{try{!he&&Ee.return&&Ee.return()}finally{if(se)throw me}}return ue}return function($,Z){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return ee($,Z);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(4),x=p(I),L=R(1),A=p(L),y=R(6),D=R(5),_=R(0),T=p(_),g=R(13),E=p(g),a=R(3),e=p(a),s=R(23),u=R(24),n=R(25),i=p(n),t=R(26),l=p(t),d=R(27),r=p(d),c=R(28),f=p(c),o=R(29),v=p(o),m=R(30),O=p(m),b=R(31),M=p(b),F=R(32),w=p(F),C=R(33),U=p(C),B=R(34),N=p(B),k=R(35),j=p(k),H=R(36),V=p(H),Y=R(37),Q=p(Y),J=R(38),z=p(J),q=R(39),re=p(q),X=R(57),le=p(X),ne=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],te=function(ee,$,Z){var ue=this;this.DOM_CONTENT_LOADED_EVENT_END=E.default.domContentLoadedEventEnd(),this.NAVIGATION_START=E.default.navigationStart();var he={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(ae){return ae}};this.mux=ee,this.id=$,Z=(0,A.default)(he,Z),Z.data=Z.data||{},Z.data.property_key&&(Z.data.env_key=Z.data.property_key,delete Z.data.property_key),x.default.setLevel(Z.debug?"debug":"warn"),this.getPlayheadTime=Z.getPlayheadTime,this.getStateData=Z.getStateData||function(){},this.getAdData=Z.getAdData||function(){},this.minimumRebufferDuration=Z.minimumRebufferDuration,this.sustainedRebufferThreshold=Z.sustainedRebufferThreshold,this.playbackHeartbeatTime=Z.playbackHeartbeatTime,this.disableRebufferTracking=Z.disableRebufferTracking,this.disableRebufferTracking&&this.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),this.errorTranslator=Z.errorTranslator,this.playbackEventDispatcher=new re.default(ee,Z.data.env_key,Z),this.data={player_instance_id:(0,y.generateUUID)(),mux_sample_rate:Z.sampleRate,beacon_domain:Z.beaconCollectionDomain?Z.beaconCollectionDomain:Z.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(ae,fe){fe=(0,A.default)({viewer_time:this.mux.utils.now()},fe),this.oldEmit(ae,fe)};var se=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(ae,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,A.default)(this.data,fe),this._initializeViewData(),this.one("play",se),this.one("adbreakstart",se)});var me=function(ae){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ae)}.bind(this);if(this.on("videochange",function(ae,fe){me(fe)}),this.on("programchange",function(ae,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me((0,A.default)(fe,{view_program_changed:!0})),se(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(ae,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),this.on("destroy",this.destroy),T.default!==void 0&&typeof T.default.addEventListener=="function"&&typeof T.default.removeEventListener=="function"){var pe=function(ae){ae.persisted||ue.destroy()};T.default.addEventListener("pagehide",pe,!1),this.on("destroy",function(){T.default.removeEventListener("pagehide",pe)})}this.on("playerready",function(ae,fe){(0,A.default)(this.data,fe)}),ne.forEach(function(ae){ue.on(ae,function(fe,ge){ae.indexOf("ad")!==0&&this._updateStateData(),(0,A.default)(this.data,ge),this._sanitizeData()}),ue.on("after"+ae,function(){(ae!=="error"||this.viewErrored)&&this.send(ae)})}),this.on("viewend",function(ae,fe){(0,A.default)(ue.data,fe)});var Ee=function(ae){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};this.one("playerready",Ee),r.default.apply(this),z.default.apply(this),j.default.apply(this),O.default.apply(this),l.default.apply(this),N.default.apply(this),f.default.apply(this),v.default.apply(this),V.default.apply(this),M.default.apply(this),w.default.apply(this),U.default.apply(this),Q.default.apply(this),le.default.apply(this),Z.hlsjs&&this.addHLSJS(Z),Z.dashjs&&this.addDashJS(Z),this.emit("viewinit",Z.data)};(0,A.default)(te.prototype,i.default.prototype),(0,A.default)(te.prototype,O.default.prototype),(0,A.default)(te.prototype,j.default.prototype),(0,A.default)(te.prototype,l.default.prototype),(0,A.default)(te.prototype,f.default.prototype),(0,A.default)(te.prototype,v.default.prototype),(0,A.default)(te.prototype,V.default.prototype),(0,A.default)(te.prototype,w.default.prototype),(0,A.default)(te.prototype,U.default.prototype),te.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),T.default.clearTimeout(this._heartBeatTimeout))},te.prototype.send=function(ee){var $=(0,A.default)({},this.data),Z=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||Z.forEach(function(pe){$[pe]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var ue=(0,D.extractHostnameAndDomain)($.video_source_url),he=S(ue,2),se=he[0],me=he[1];$.video_source_domain=me,$.video_source_hostname=se}delete $.ad_request_id,this.playbackEventDispatcher.send(ee,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},te.prototype._updateStateData=function(){(0,A.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},te.prototype._sanitizeData=function(){var ee=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Z=parseInt(ee.data[$],10);ee.data[$]=isNaN(Z)?void 0:Z}),["player_source_url","video_source_url"].forEach(function($){if(ee.data[$]){var Z=ee.data[$].toLowerCase();Z.indexOf("data:")!==0&&Z.indexOf("blob:")!==0||(ee.data[$]="MSE style URL")}})},te.prototype._resetVideoData=function(ee,$){var Z=this;Object.keys(this.data).forEach(function(ue){ue.indexOf("video_")===0&&delete Z.data[ue]})},te.prototype._resetViewData=function(){var ee=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete ee.data[$]}),this.data.view_sequence_number=1},te.prototype._resetErrorData=function(ee,$){delete this.data.player_error_code,delete this.data.player_error_message},te.prototype._initializeViewData=function(){var ee=this,$=this.data.view_id=(0,y.generateUUID)(),Z=function(){$===ee.data.view_id&&(0,e.default)(ee.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Z):Z()},te.prototype._restartHeartBeat=function(){var ee=this;T.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=T.default.setTimeout(function(){ee.data.player_is_paused||ee.emit("hb")},1e4))},te.prototype.addHLSJS=function(ee){return ee.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=ee.hlsjs,void(0,s.monitorHlsJs)(this.mux,this.id,ee.hlsjs,{},ee.Hls||T.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},te.prototype.removeHLSJS=function(){this.hlsjs&&((0,s.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},te.prototype.addDashJS=function(ee){return ee.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=ee.dashjs,void(0,u.monitorDashJS)(this.mux,this.id,ee.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},te.prototype.removeDashJS=function(){this.dashjs&&((0,u.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},h.default=te},function(P,h,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(h,"__esModule",{value:!0}),h.stopMonitoringHlsJs=h.monitorHlsJs=void 0;var S=R(7),I=p(S),x=R(13),L=p(x),A=R(5),y=R(14),D=p(y),_=function(a){if(!a)return{};var e=L.default.navigationStart(),s=a.loading,u=s?s.start:a.trequest,n=s?s.first:a.tfirst,i=s?s.end:a.tload;return{bytesLoaded:a.total,requestStart:Math.round(e+u),responseStart:Math.round(e+n),responseEnd:Math.round(e+i)}},T=function(a){if(a&&typeof a.getAllResponseHeaders=="function")return(0,I.default)(a.getAllResponseHeaders())},g=function(a,e,s){var u=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),n=a.log,i=a.utils.secondsToMs,t=function(b){var M=parseInt(u.version),F=void 0;return M===1&&b.programDateTime!==null&&(F=b.programDateTime),M===0&&b.pdt!==null&&(F=b.pdt),F};if(!L.default.exists())return void n.warn("performance timing not supported. Not tracking HLS.js.");var l=function(b,M){return a.emit(e,b,M)},d=function(b,M){var F=M.levels,w=M.audioTracks,C=M.url,U=M.stats,B=M.networkDetails,N=M.sessionData,k={},j={},H={};H=(0,D.default)(N),F.forEach(function(q,re){k[re]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),w.forEach(function(q,re){j[re]={name:q.name,language:q.lang,bitrate:q.bitrate}});var V=_(U),Y=V.bytesLoaded,Q=V.requestStart,J=V.responseStart,z=V.responseEnd;H.request_event_type=b,H.request_bytes_loaded=Y,H.request_start=Q,H.request_response_start=J,H.request_response_end=z,H.request_type="manifest",H.request_hostname=(0,A.extractHostname)(C),H.request_response_headers=T(B),H.request_rendition_lists={media:k,audio:j,video:{}},l("requestcompleted",H)};s.on(u.Events.MANIFEST_LOADED,d);var r=function(b,M){var F=M.details,w=M.level,C=M.networkDetails,U=M.stats,B=_(U),N=B.bytesLoaded,k=B.requestStart,j=B.responseStart,H=B.responseEnd,V=F.fragments[F.fragments.length-1],Y=t(V)+i(V.duration);l("requestcompleted",{request_event_type:b,request_bytes_loaded:N,request_start:k,request_response_start:j,request_response_end:H,request_current_level:w,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:T(C),video_holdback:F.holdBack&&i(F.holdBack),video_part_holdback:F.partHoldBack&&i(F.partHoldBack),video_part_target_duration:F.partTarget&&i(F.partTarget),video_target_duration:F.targetduration&&i(F.targetduration),video_source_is_live:F.live,player_manifest_newest_program_time:isNaN(Y)?void 0:Y})};s.on(u.Events.LEVEL_LOADED,r);var c=function(b,M){var F=M.details,w=M.networkDetails,C=M.stats,U=_(C),B=U.bytesLoaded,N=U.requestStart,k=U.responseStart,j=U.responseEnd;l("requestcompleted",{request_event_type:b,request_bytes_loaded:B,request_start:N,request_response_start:k,request_response_end:j,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:T(w)})};s.on(u.Events.AUDIO_TRACK_LOADED,c);var f=function(b,M){var F=M.stats,w=M.networkDetails,C=M.frag,U=_(F),B=U.bytesLoaded,N=U.requestStart,k=U.responseStart,j=U.responseEnd,H={request_event_type:b,request_bytes_loaded:B,request_start:N,request_response_start:k,request_response_end:j,request_hostname:w?(0,A.extractHostname)(w.responseURL):void 0,request_response_headers:T(w),request_media_duration:C.duration};C.type==="main"?(H.request_type="media",H.request_current_level=C.level,H.request_video_width=(s.levels[C.level]||{}).width,H.request_video_height=(s.levels[C.level]||{}).height):H.request_type=C.type,l("requestcompleted",H)};s.on(u.Events.FRAG_LOADED,f);var o=function(b,M){var F=M.frag,w=F.start,C=t(F),U={currentFragmentPDT:C,currentFragmentStart:i(w)};l("fragmentchange",U)};s.on(u.Events.FRAG_CHANGED,o);var v=function(b,M){var F=M.type,w=M.details,C=M.response,U=M.fatal,B=M.context,N=M.frag;if(w===u.ErrorDetails.MANIFEST_LOAD_ERROR||w===u.ErrorDetails.MANIFEST_LOAD_TIMEOUT||w===u.ErrorDetails.FRAG_LOAD_ERROR||w===u.ErrorDetails.FRAG_LOAD_TIMEOUT||w===u.ErrorDetails.LEVEL_LOAD_ERROR||w===u.ErrorDetails.LEVEL_LOAD_TIMEOUT){var k=N&&N.url||B&&B.url||"";l("requestfailed",{request_error:w,request_url:k,request_hostname:(0,A.extractHostname)(k),request_type:w===u.ErrorDetails.FRAG_LOAD_ERROR||w===u.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}U&&l("error",{player_error_code:F,player_error_message:w})};s.on(u.Events.ERROR,v);var m=function(b,M){var F=M.frag,w=F&&F._url||"";l("requestcanceled",{request_cancel:b,request_url:w,request_type:"media",request_hostname:(0,A.extractHostname)(w)})};s.on(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var O=function(b,M){var F=M.level,w=s.levels[F];if(w&&w.attrs&&w.attrs.BANDWIDTH){var C=w.attrs.BANDWIDTH;C?l("renditionchange",{video_source_bitrate:C,video_source_width:w.width,video_source_height:w.height}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};s.on(u.Events.LEVEL_SWITCHED,O),s._stopMuxMonitor=function(){s.off(u.Events.MANIFEST_LOADED,d),s.off(u.Events.LEVEL_LOADED,r),s.off(u.Events.AUDIO_TRACK_LOADED,c),s.off(u.Events.FRAG_LOADED,f),s.off(u.Events.FRAG_CHANGED,o),s.off(u.Events.ERROR,v),s.off(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),s.off(u.Events.LEVEL_SWITCHED,O),s.off(u.Events.DESTROYING,s._stopMuxMonitor),delete s._stopMuxMonitor},s.on(u.Events.DESTROYING,s._stopMuxMonitor)},E=function(a){a&&typeof a._stopMuxMonitor=="function"&&a._stopMuxMonitor()};h.monitorHlsJs=g,h.stopMonitoringHlsJs=E},function(P,h,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(h,"__esModule",{value:!0}),h.stopMonitoringDashJS=h.monitorDashJS=void 0;var S=R(0),I=p(S),x=R(7),L=p(x),A=R(5),y=function(g,E){if(!g||typeof g.getRequests!="function")return{};var a=g.getRequests({state:"executed"});if(a.length===0)return{};var e=a[a.length-1],s=(0,A.extractHostname)(e.url),u=e.bytesLoaded,n=new Date(e.requestStartDate).getTime(),i=new Date(e.firstByteDate).getTime(),t=new Date(e.requestEndDate).getTime(),l=isNaN(e.duration)?0:e.duration,d=typeof E.getMetricsFor=="function"?E.getMetricsFor(e.mediaType).HttpList:E.getDashMetrics().getHttpRequests(e.mediaType),r=void 0;return d.length>0&&(r=(0,L.default)(d[d.length-1]._responseHeaders||"")),{requestStart:n,requestResponseStart:i,requestResponseEnd:t,requestBytesLoaded:u,requestResponseHeaders:r,requestMediaDuration:l,requestHostname:s}},D=function(g,E){var a=E.getQualityFor(g),e=E.getCurrentTrackFor(g),s=e.bitrateList;return s?{currentLevel:a,renditionWidth:s[a].width||null,renditionHeight:s[a].height||null,renditionBitrate:s[a].bandwidth}:{}},_=function(g,E,a){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],g.log);if(!a||!a.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var s=function(f,o){return g.emit(E,f,o)},u=function(f){var o=f.type,v=f.data,m=v||{},O=m.url;s("requestcompleted",{request_event_type:o,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,A.extractHostname)(O)})};a.on("manifestLoaded",u);var n={},i=function(f){var o=f.type,v=f.fragmentModel,m=f.chunk,O=m||{},b=O.mediaInfo,M=b||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(Y,Q){C[Q]={},C[Q].width=Y.width,C[Q].height=Y.height,C[Q].bitrate=Y.bandwidth,C[Q].attrs={}}),F==="video"?n.video=C:F==="audio"?n.audio=C:n.media=C;var U=y(v,a),B=U.requestStart,N=U.requestResponseStart,k=U.requestResponseEnd,j=U.requestResponseHeaders,H=U.requestMediaDuration,V=U.requestHostname;s("requestcompleted",{request_event_type:o,request_start:B,request_response_start:N,request_response_end:k,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:j,request_hostname:V,request_media_duration:H,request_rendition_lists:n})};a.on("initFragmentLoaded",i);var t=function(f){var o=f.type,v=f.fragmentModel,m=f.chunk,O=m||{},b=O.mediaInfo,M=O.start,F=b||{},w=F.type,C=y(v,a),U=C.requestStart,B=C.requestResponseStart,N=C.requestResponseEnd,k=C.requestBytesLoaded,j=C.requestResponseHeaders,H=C.requestMediaDuration,V=C.requestHostname,Y=D(w,a),Q=Y.currentLevel,J=Y.renditionWidth,z=Y.renditionHeight,q=Y.renditionBitrate;s("requestcompleted",{request_event_type:o,request_start:U,request_response_start:B,request_response_end:N,request_bytes_loaded:k,request_type:w,request_response_headers:j,request_hostname:V,request_media_start_time:M,request_media_duration:H,request_current_level:Q,request_labeled_bitrate:q,request_video_width:J,request_video_height:z})};a.on("mediaFragmentLoaded",t);var l={video:void 0,audio:void 0,totalBitrate:void 0},d=function(){if(l.video&&typeof l.video.bitrate=="number"){if(!l.video.width||!l.video.height)return void e.warn("have bitrate info for video but missing width/height");var f=l.video.bitrate;return l.audio&&typeof l.audio.bitrate=="number"&&(f+=l.audio.bitrate),f!==l.totalBitrate?(l.totalBitrate=f,{video_source_bitrate:f,video_source_height:l.video.height,video_source_width:l.video.width}):void 0}},r=function(f,o,v){if(typeof f.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",f);var m=f.mediaType;if(m==="audio"||m==="video"){var O=a.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===f.newQuality});if(!O||typeof O.bitrate!="number")return void e.warn("missing bitrate info for "+m);l[m]=O;var b=d();b&&s("renditionchange",b)}};a.on("qualityChangeRendered",r);var c=function(f){var o=f.error,v=f.event;v=v||{};var m=v.request||{},O=I.default.event&&I.default.event.currentTarget||{};s("requestfailed",{request_error:o+"_"+v.id+"_"+m.type,request_url:v.url,request_hostname:(0,A.extractHostname)(v.url),request_type:m.mediaType,request_error_code:O.status,request_error_type:O.statusText})};a.on("error",c),a._stopMuxMonitor=function(){a.off("manifestLoaded",u),a.off("initFragmentLoaded",i),a.off("mediaFragmentLoaded",t),a.off("qualityChangeRendered",r),a.off("error",c),delete a._stopMuxMonitor}},T=function(g){g&&typeof g._stopMuxMonitor=="function"&&g._stopMuxMonitor()};h.monitorDashJS=_,h.stopMonitoringDashJS=T},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){},S=0;p.prototype.on=function(I,x,L){return x._eventEmitterGuid=x._eventEmitterGuid||++S,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],L&&(x=x.bind(L)),this._listeners[I].push(x),x},p.prototype.off=function(I,x){var L=this._listeners&&this._listeners[I];L&&L.forEach(function(A,y){A._eventEmitterGuid===x._eventEmitterGuid&&L.splice(y,1)})},p.prototype.one=function(I,x,L){var A=this;x._eventEmitterGuid=x._eventEmitterGuid||++S;var y=function D(){A.off(I,D),x.apply(L||this,arguments)};y._eventEmitterGuid=x._eventEmitterGuid,this.on(I,y)},p.prototype.emit=function(I,x){var L=this;if(this._listeners){x=x||{};var A=this._listeners["before*"]||[],y=this._listeners[I]||[],D=this._listeners["after"+I]||[],_=function(T,g){T=T.slice(),T.forEach(function(E){E.call(L,{type:I},g)})};_(A,x),_(y,x),_(D,x)}},h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,this.on("playing",function(){this._playheadShouldBeProgressing=!0}),this.on("play",this._startPlaybackHeartbeatInterval),this.on("playing",this._startPlaybackHeartbeatInterval),this.on("adbreakstart",this._startPlaybackHeartbeatInterval),this.on("adplay",this._startPlaybackHeartbeatInterval),this.on("adplaying",this._startPlaybackHeartbeatInterval),this.on("seeking",this._startPlaybackHeartbeatInterval),this.on("devicewake",this._startPlaybackHeartbeatInterval),this.on("viewstart",this._startPlaybackHeartbeatInterval),this.on("rebufferstart",this._startPlaybackHeartbeatInterval),this.on("pause",this._stopPlaybackHeartbeatInterval),this.on("ended",this._stopPlaybackHeartbeatInterval),this.on("viewend",this._stopPlaybackHeartbeatInterval),this.on("error",this._stopPlaybackHeartbeatInterval),this.on("aderror",this._stopPlaybackHeartbeatInterval),this.on("adpause",this._stopPlaybackHeartbeatInterval),this.on("adended",this._stopPlaybackHeartbeatInterval),this.on("adbreakend",this._stopPlaybackHeartbeatInterval),this.on("seeked",function(){this.data.player_is_paused?this._stopPlaybackHeartbeatInterval():this._startPlaybackHeartbeatInterval()}),this.on("timeupdate",function(){this._playbackHeartbeatInterval!==null&&this.emit("playbackheartbeat")}),this.on("devicesleep",function(x,L){this._playbackHeartbeatInterval!==null&&(S.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:L.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var x=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=S.default.setInterval(function(){x.emit("playbackheartbeat")},this.playbackHeartbeatTime))},I.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(S.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},h.default=I},function(P,h,R){"use strict";function p(){var S=this;this.on("viewinit",function(){S.viewErrored=!1}),this.on("error",function(){try{var I=S.errorTranslator({player_error_code:S.data.player_error_code,player_error_message:S.data.player_error_message});I?(S.data.player_error_code=I.player_error_code,S.data.player_error_message=I.player_error_message,S.viewErrored=!0):(delete S.data.player_error_code,delete S.data.player_error_message)}catch(x){S.mux.log.warn("Exception in error translator callback.",x),S.viewErrored=!0}})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(3),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(x,L){var A=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=A),(0,S.default)(this.data,"view_watch_time",A-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=A},I.prototype._clearWatchTimeState=function(x,L){this._updateWatchTime(x,L),this._watchTimeTrackerLastCheckedTime=null},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(3),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this._playbackTimeTrackerLastPlayheadPosition=-1,this.on("playbackheartbeat",this._updatePlaybackTime),this.on("playbackheartbeatend",this._clearPlaybackTimeState),this.on("seeking",this._clearPlaybackTimeState)};I.prototype._updatePlaybackTime=function(){var x=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&x>this._playbackTimeTrackerLastPlayheadPosition){var L=x-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&(0,S.default)(this.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=x},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){this.on("playbackheartbeat",this._updatePlayheadTime),this.on("playbackheartbeatend",this._updatePlayheadTime),this.on("timeupdate",this._updatePlayheadTime),this.on("destroy",function(){this.off("timeupdate",this._updatePlayheadTime)})};p.prototype._updateMaxPlayheadPosition=function(){this.data.view_max_playhead_position=this.data.view_max_playhead_position===void 0?this.data.player_playhead_time:Math.max(this.data.view_max_playhead_position,this.data.player_playhead_time)},p.prototype._updatePlayheadTime=function(S,I){var x=this,L=function(){x.currentFragmentPDT&&x.currentFragmentStart&&(x.data.player_program_time=x.currentFragmentPDT+x.data.player_playhead_time-x.currentFragmentStart)};if(I&&I.player_playhead_time)this.data.player_playhead_time=I.player_playhead_time,L(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var A=this.getPlayheadTime();A!==void 0&&(this.data.player_playhead_time=A,L(),this._updateMaxPlayheadPosition())}},h.default=p},function(P,h,R){"use strict";function p(){var x=this;if(!this.disableRebufferTracking){var L=void 0,A=function(){if(L){var y=x.data.viewer_time-L;(0,I.default)(x.data,"view_rebuffer_duration",y),L=x.data.viewer_time}x.data.view_watch_time>=0&&x.data.view_rebuffer_count>0&&(x.data.view_rebuffer_frequency=x.data.view_rebuffer_count/x.data.view_watch_time,x.data.view_rebuffer_percentage=x.data.view_rebuffer_duration/x.data.view_watch_time)};this.on("playbackheartbeat",function(){return A()}),this.on("rebufferstart",function(){L||((0,I.default)(x.data,"view_rebuffer_count",1),L=x.data.viewer_time,x.one("rebufferend",function(){A(),L=void 0}))})}}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(3),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(2),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this.disableRebufferTracking||this.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,this.on("playbackheartbeat",this._checkIfRebuffering),this.on("playbackheartbeatend",this._cleanupRebufferTracker),this.on("seeking",function(){this._cleanupRebufferTracker(null,{viewer_time:S.default.now()})}))};I.prototype._checkIfRebuffering=function(x,L){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(x,L):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(L.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(x,L,!0):(L.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=L.viewer_time))},I.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},I.prototype._prepareRebufferTrackerState=function(x){this._lastCheckedTime=x,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=x},I.prototype._cleanupRebufferTracker=function(x,L){var A=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:L.viewer_time});else{if(this._lastCheckedTime===null)return;var y=this.data.player_playhead_time-this._lastPlayheadTime,D=L.viewer_time-this._lastPlayheadTimeUpdatedTime;y>0&&D-y>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+D-y}))}A?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()},h.default=I},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(2),S=function(x){return x&&x.__esModule?x:{default:x}}(p),I=function(){this.on("viewinit",function(){var x=this.data,L=x.view_id;if(!x.view_program_changed){var A=function(y,D){var _=D.viewer_time;y.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(_||S.default.now(),L):y.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(_||S.default.now(),L)};this.one("playing",A),this.one("adplaying",A),this.one("viewend",function(){this.off("playing",A),this.off("adplaying",A)})}})};I.prototype.calculateTimeToFirstFrame=function(x,L){L===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:x}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},h.default=I},function(P,h,R){"use strict";function p(){var x=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var L=["pause","rebufferstart","seeking","error","adbreakstart","hb"],A=["playing","hb"];L.forEach(function(y){x.on(y,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var D=this.data.player_playhead_time-this._lastPlayheadPosition;if(D<0)return void(this._lastPlayheadPosition=-1);var _=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),T=Math.max(0,_-1),g=Math.max(0,1-_);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,T),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,g),(0,I.default)(this.data,"view_total_content_playback_time",D),(0,I.default)(this.data,"view_total_upscaling",T*D),(0,I.default)(this.data,"view_total_downscaling",g*D)}this._lastPlayheadPosition=-1})}),A.forEach(function(y){x.on(y,function(){this._lastPlayheadPosition=this.data.player_playhead_time,this._lastPlayerWidth=this.data.player_width,this._lastPlayerHeight=this.data.player_height,this._lastSourceWidth=this.data.video_source_width,this._lastSourceHeight=this.data.video_source_height})})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(3),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";function p(_){return _&&_.__esModule?_:{default:_}}function S(){this.isSeeking=!1,this.on("seeking",function(_,T){(0,D.default)(this.data,T),this._lastSeekingTime=x.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var _=this._lastSeekingTime||x.default.now(),T=x.default.now()-_;(0,A.default)(this.data,"view_seek_count",1),(0,A.default)(this.data,"view_seek_duration",T);var g=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(g,T)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=S;var I=R(2),x=p(I),L=R(3),A=p(L),y=R(1),D=p(y)},function(P,h,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(h,"__esModule",{value:!0});var S=function(){function g(E,a){var e=[],s=!0,u=!1,n=void 0;try{for(var i,t=E[Symbol.iterator]();!(s=(i=t.next()).done)&&(e.push(i.value),!a||e.length!==a);s=!0);}catch(l){u=!0,n=l}finally{try{!s&&t.return&&t.return()}finally{if(u)throw n}}return e}return function(E,a){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return g(E,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(3),x=p(I),L=R(5),A=R(1),y=p(A),D=function(g,E){g.push(E),g.sort(function(a,e){return a.viewer_time-e.viewer_time})},_=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],T=function(){var g=this;this.on("viewinit",function(){this.isAdBreak=!1,this._currentAdRequestNumber=0,this._currentAdResponseNumber=0,this._adRequests=[],this._adResponses=[],this._adHasPlayed=!1,this._wouldBeNewAdPlay=!0,this._prerollPlayTime=void 0}),_.forEach(function(a){return g.on(a,g._updateAdData)});var E=function(){g.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",E),this.on("playing",E),this.on("viewend",E),this.on("adrequest",function(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),D(this._adRequests,e),(0,x.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,x.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),D(this._adResponses,e);var s=this.findAdRequest(e.ad_request_id);s&&(0,x.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-s.viewer_time))}),this.on("adplay",function(a,e){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,x.default)(this.data,"view_ad_played_count")),this.inPrerollPosition()&&!this.data.view_preroll_played&&(this.data.view_preroll_played=!0,this._adRequests.length>0&&(this.data.view_preroll_request_time=Math.max(0,e.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,e.viewer_time-this.data.view_start)),this._prerollPlayTime=e.viewer_time)}),this.on("adplaying",function(a,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};T.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},T.prototype.findAdRequest=function(g){for(var E=0;E<this._adRequests.length;E++)if(this._adRequests[E].ad_request_id===g)return this._adRequests[E]},T.prototype._updateAdData=function(g,E){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&E.ad_tag_url){var a=(0,L.extractHostnameAndDomain)(E.ad_tag_url),e=S(a,2),s=e[0],u=e[1];this.data.view_preroll_ad_tag_domain=u,this.data.view_preroll_ad_tag_hostname=s}if(!this.data.view_preroll_ad_asset_hostname&&E.ad_asset_url){var n=(0,L.extractHostnameAndDomain)(E.ad_asset_url),i=S(n,2),t=i[0],l=i[1];this.data.view_preroll_ad_asset_domain=l,this.data.view_preroll_ad_asset_hostname=t}}},h.default=T},function(P,h,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}function S(){var y=this,D=void 0,_=void 0,T=function(){y.disableRebufferTracking||((0,A.default)(y.data,"view_waiting_rebuffer_count",1),D=x.default.now(),_=window.setInterval(function(){if(D){var s=x.default.now();(0,A.default)(y.data,"view_waiting_rebuffer_duration",s-D),D=s}},250))},g=function(){y.disableRebufferTracking||D&&((0,A.default)(y.data,"view_waiting_rebuffer_duration",x.default.now()-D),D=!1,window.clearInterval(_))},E=!1,a=function(){E=!0},e=function(){E=!1,g()};this.on("waiting",function(){E&&T()}),this.on("playing",function(){g(),a()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=S;var I=R(2),x=p(I),L=R(3),A=p(L)},function(P,h,R){"use strict";function p(_){return _&&_.__esModule?_:{default:_}}function S(){var _=this;this.one("playbackheartbeat",y),this.on("playbackheartbeatend",function(){_.off("before*",D),_.one("playbackheartbeat",y)})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=S;var I=R(1),x=p(I),L=R(2),A=p(L),y=function(){this.lastWallClockTime=A.default.now(),this.on("before*",D)},D=function(_){var T=A.default.now(),g=this.lastWallClockTime;this.lastWallClockTime=T,T-g>3e4&&(this.emit("devicesleep",{viewer_time:g}),(0,x.default)(this.data,{viewer_time:g}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:T}),(0,x.default)(this.data,{viewer_time:T}),this.send("devicewake"))}},function(P,h,R){"use strict";function p(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(h,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},I=R(0),x=p(I),L=R(40),A=R(4),y=p(A),D=R(53),_=p(D),T=R(12),g=p(T),E=R(54),a=p(E),e=R(17),s=p(e),u=R(55),n=p(u),i=R(1),t=p(i),l=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],d=["viewstart","error","ended","viewend"],r=function(o,v){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=o,this.envKey=v,this.eventQueue=new n.default((0,_.default)(v,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var O=m.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:O.name,viewer_application_version:O.version,viewer_application_engine:O.layout,viewer_device_name:O.product,viewer_device_category:"",viewer_device_manufacturer:O.manufacturer,viewer_os_family:O.os&&O.os.family,viewer_os_architecture:O.os&&O.os.architecture,viewer_os_version:O.os&&O.os.version};var b=(0,a.default)();b&&(this.pageLevelData=(0,t.default)(this.pageLevelData,{viewer_connection_type:b})),x.default!==void 0&&x.default.location&&x.default.location.href&&(this.pageLevelData.page_url=x.default.location.href),this.viewerData=this.disableCookies?{}:(0,L.getAndUpdateViewerData)()};r.prototype.send=function(o,v){if(o){if(this.respectDoNotTrack&&(0,g.default)())return y.default.info("Not sending `"+o+"` because Do Not Track is enabled");if(!v||(v===void 0?"undefined":S(v))!=="object")return y.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,L.getAndUpdateSessionData)(),O={};(0,t.default)(O,this.pageLevelData),(0,t.default)(O,v),(0,t.default)(O,m),(0,t.default)(O,this.viewerData),O.event=o,O.env_key=this.envKey,O.user_id&&(O.viewer_user_id=O.user_id,delete O.user_id);var b=O.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(o,O),F=(0,s.default)(M);if(this.lastEventTime=this.mux.utils.now(),b)return y.default.info("Not sending event due to sample rate restriction",o,O,F);if(this.envKey||y.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",o,O,F),!this.rateLimited){if(y.default.info("Sending event",o,O,F),this.rateLimited=!this.eventQueue.queueEvent(o,F),this.mux.WINDOW_UNLOADING&&o==="viewend")this.eventQueue.destroy(!0);else if((d.indexOf(o)>=0||this.mux.WINDOW_VISIBLE===!1&&o==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return O.event="eventrateexceeded",F=(0,s.default)(O),this.eventQueue.queueEvent(O.event,F),y.default.error("Beaconing disabled due to rate limit.")}}},r.prototype.destroy=function(){this.eventQueue.destroy(!1)};var c=function(o,v,m,O){return!(!o||v.indexOf("request_")!==0)&&(v==="request_response_headers"||(m===void 0?"undefined":S(m))!=="object"||(O===void 0?"undefined":S(O))!=="object"||Object.keys(m||{}).length!==Object.keys(O||{}).length)},f=function(o,v){return o==="renditionchange"&&v.indexOf("video_source_")===0};r.prototype._deduplicateBeaconData=function(o,v){var m=this,O={},b=v.view_id;if(!b||o==="viewstart"||o==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)O=(0,t.default)({},v),b&&(this.previousBeaconData=O),b&&o==="viewend"&&(this.previousBeaconData=null);else{var M=o.indexOf("request")===0;Object.keys(v).forEach(function(F){var w=v[F];(w!==m.previousBeaconData[F]||l.indexOf(F)>-1||c(M,F,w,m.previousBeaconData[F])||f(o,F))&&(O[F]=w,m.previousBeaconData[F]=w)})}return O},h.default=r},function(P,h,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(h,"__esModule",{value:!0}),h.getAndUpdateSessionData=h.getAndUpdateViewerData=void 0;var S=R(15),I=p(S),x=R(52),L=p(x),A=R(6),y=R(2),D=p(y),_=function(){var a=void 0;try{a=I.default.parse(L.default.get("muxData")||"")}catch{a={}}return a},T=function(a){try{L.default.set("muxData",I.default.stringify(a),{expires:7300})}catch{}},g=function(){var a=_();return a.mux_viewer_id=a.mux_viewer_id||(0,A.generateUUID)(),a.msn=a.msn||Math.random(),T(a),{mux_viewer_id:a.mux_viewer_id,mux_sample_number:a.msn}},E=function(){var a=_(),e=D.default.now();return a.session_start&&(a.sst=a.session_start,delete a.session_start),a.session_id&&(a.sid=a.session_id,delete a.session_id),a.session_expires&&(a.sex=a.session_expires,delete a.session_expires),(!a.sex||a.sex<e)&&(a.sid=(0,A.generateUUID)(),a.sst=e),a.sex=e+15e5,T(a),{session_id:a.sid,session_start:a.sst,session_expires:a.sex}};h.getAndUpdateViewerData=g,h.getAndUpdateSessionData=E},function(P,h,R){"use strict";var p=R(42),S=R(16),I=R(10),x=Object.prototype.hasOwnProperty,L={brackets:function(n){return n+"[]"},comma:"comma",indices:function(n,i){return n+"["+i+"]"},repeat:function(n){return n}},A=Array.isArray,y=String.prototype.split,D=Array.prototype.push,_=function(n,i){D.apply(n,A(i)?i:[i])},T=Date.prototype.toISOString,g=I.default,E={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:S.encode,encodeValuesOnly:!1,format:g,formatter:I.formatters[g],indices:!1,serializeDate:function(n){return T.call(n)},skipNulls:!1,strictNullHandling:!1},a=function(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||typeof n=="symbol"||typeof n=="bigint"},e={},s=function n(i,t,l,d,r,c,f,o,v,m,O,b,M,F,w){for(var C=i,U=w,B=0,N=!1;(U=U.get(e))!==void 0&&!N;){var k=U.get(i);if(B+=1,k!==void 0){if(k===B)throw new RangeError("Cyclic object value");N=!0}U.get(e)===void 0&&(B=0)}if(typeof f=="function"?C=f(t,C):C instanceof Date?C=m(C):l==="comma"&&A(C)&&(C=S.maybeMap(C,function(te){return te instanceof Date?m(te):te})),C===null){if(d)return c&&!M?c(t,E.encoder,F,"key",O):t;C=""}if(a(C)||S.isBuffer(C)){if(c){var j=M?t:c(t,E.encoder,F,"key",O);if(l==="comma"&&M){for(var H=y.call(String(C),","),V="",Y=0;Y<H.length;++Y)V+=(Y===0?"":",")+b(c(H[Y],E.encoder,F,"value",O));return[b(j)+"="+V]}return[b(j)+"="+b(c(C,E.encoder,F,"value",O))]}return[b(t)+"="+b(String(C))]}var Q=[];if(C===void 0)return Q;var J;if(l==="comma"&&A(C))J=[{value:C.length>0?C.join(",")||null:void 0}];else if(A(f))J=f;else{var z=Object.keys(C);J=o?z.sort(o):z}for(var q=0;q<J.length;++q){var re=J[q],X=typeof re=="object"&&re.value!==void 0?re.value:C[re];if(!r||X!==null){var le=A(C)?typeof l=="function"?l(t,re):t:t+(v?"."+re:"["+re+"]");w.set(i,B);var ne=p();ne.set(e,w),_(Q,n(X,le,l,d,r,c,f,o,v,m,O,b,M,F,ne))}}return Q},u=function(n){if(!n)return E;if(n.encoder!==null&&n.encoder!==void 0&&typeof n.encoder!="function")throw new TypeError("Encoder has to be a function.");var i=n.charset||E.charset;if(n.charset!==void 0&&n.charset!=="utf-8"&&n.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=I.default;if(n.format!==void 0){if(!x.call(I.formatters,n.format))throw new TypeError("Unknown format option provided.");t=n.format}var l=I.formatters[t],d=E.filter;return(typeof n.filter=="function"||A(n.filter))&&(d=n.filter),{addQueryPrefix:typeof n.addQueryPrefix=="boolean"?n.addQueryPrefix:E.addQueryPrefix,allowDots:n.allowDots===void 0?E.allowDots:!!n.allowDots,charset:i,charsetSentinel:typeof n.charsetSentinel=="boolean"?n.charsetSentinel:E.charsetSentinel,delimiter:n.delimiter===void 0?E.delimiter:n.delimiter,encode:typeof n.encode=="boolean"?n.encode:E.encode,encoder:typeof n.encoder=="function"?n.encoder:E.encoder,encodeValuesOnly:typeof n.encodeValuesOnly=="boolean"?n.encodeValuesOnly:E.encodeValuesOnly,filter:d,format:t,formatter:l,serializeDate:typeof n.serializeDate=="function"?n.serializeDate:E.serializeDate,skipNulls:typeof n.skipNulls=="boolean"?n.skipNulls:E.skipNulls,sort:typeof n.sort=="function"?n.sort:null,strictNullHandling:typeof n.strictNullHandling=="boolean"?n.strictNullHandling:E.strictNullHandling}};P.exports=function(n,i){var t,l,d=n,r=u(i);typeof r.filter=="function"?(l=r.filter,d=l("",d)):A(r.filter)&&(l=r.filter,t=l);var c=[];if(typeof d!="object"||d===null)return"";var f;f=i&&i.arrayFormat in L?i.arrayFormat:i&&"indices"in i?i.indices?"indices":"repeat":"indices";var o=L[f];t||(t=Object.keys(d)),r.sort&&t.sort(r.sort);for(var v=p(),m=0;m<t.length;++m){var O=t[m];r.skipNulls&&d[O]===null||_(c,s(d[O],O,o,r.strictNullHandling,r.skipNulls,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,v))}var b=c.join(r.delimiter),M=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?M+="utf8=%26%2310003%3B&":M+="utf8=%E2%9C%93&"),b.length>0?M+b:""}},function(P,h,R){"use strict";var p=R(8),S=R(47),I=R(49),x=p("%TypeError%"),L=p("%WeakMap%",!0),A=p("%Map%",!0),y=S("WeakMap.prototype.get",!0),D=S("WeakMap.prototype.set",!0),_=S("WeakMap.prototype.has",!0),T=S("Map.prototype.get",!0),g=S("Map.prototype.set",!0),E=S("Map.prototype.has",!0),a=function(n,i){for(var t,l=n;(t=l.next)!==null;l=t)if(t.key===i)return l.next=t.next,t.next=n.next,n.next=t,t},e=function(n,i){var t=a(n,i);return t&&t.value},s=function(n,i,t){var l=a(n,i);l?l.value=t:n.next={key:i,next:n.next,value:t}},u=function(n,i){return!!a(n,i)};P.exports=function(){var n,i,t,l={assert:function(d){if(!l.has(d))throw new x("Side channel does not contain "+I(d))},get:function(d){if(L&&d&&(typeof d=="object"||typeof d=="function")){if(n)return y(n,d)}else if(A){if(i)return T(i,d)}else if(t)return e(t,d)},has:function(d){if(L&&d&&(typeof d=="object"||typeof d=="function")){if(n)return _(n,d)}else if(A){if(i)return E(i,d)}else if(t)return u(t,d);return!1},set:function(d,r){L&&d&&(typeof d=="object"||typeof d=="function")?(n||(n=new L),D(n,d,r)):A?(i||(i=new A),g(i,d,r)):(t||(t={key:{},next:null}),s(t,d,r))}};return l}},function(P,h,R){"use strict";var p=typeof Symbol!="undefined"&&Symbol,S=R(44);P.exports=function(){return typeof p=="function"&&typeof Symbol=="function"&&typeof p("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&S()}},function(P,h,R){"use strict";P.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var p={},S=Symbol("test"),I=Object(S);if(typeof S=="string"||Object.prototype.toString.call(S)!=="[object Symbol]"||Object.prototype.toString.call(I)!=="[object Symbol]")return!1;p[S]=42;for(S in p)return!1;if(typeof Object.keys=="function"&&Object.keys(p).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(p).length!==0)return!1;var x=Object.getOwnPropertySymbols(p);if(x.length!==1||x[0]!==S||!Object.prototype.propertyIsEnumerable.call(p,S))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var L=Object.getOwnPropertyDescriptor(p,S);if(L.value!==42||L.enumerable!==!0)return!1}return!0}},function(P,h,R){"use strict";var p=Array.prototype.slice,S=Object.prototype.toString;P.exports=function(I){var x=this;if(typeof x!="function"||S.call(x)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+x);for(var L,A=p.call(arguments,1),y=function(){if(this instanceof L){var E=x.apply(this,A.concat(p.call(arguments)));return Object(E)===E?E:this}return x.apply(I,A.concat(p.call(arguments)))},D=Math.max(0,x.length-A.length),_=[],T=0;T<D;T++)_.push("$"+T);if(L=Function("binder","return function ("+_.join(",")+"){ return binder.apply(this,arguments); }")(y),x.prototype){var g=function(){};g.prototype=x.prototype,L.prototype=new g,g.prototype=null}return L}},function(P,h,R){"use strict";var p=R(9);P.exports=p.call(Function.call,Object.prototype.hasOwnProperty)},function(P,h,R){"use strict";var p=R(8),S=R(48),I=S(p("String.prototype.indexOf"));P.exports=function(x,L){var A=p(x,!!L);return typeof A=="function"&&I(x,".prototype.")>-1?S(A):A}},function(P,h,R){"use strict";var p=R(9),S=R(8),I=S("%Function.prototype.apply%"),x=S("%Function.prototype.call%"),L=S("%Reflect.apply%",!0)||p.call(x,I),A=S("%Object.getOwnPropertyDescriptor%",!0),y=S("%Object.defineProperty%",!0),D=S("%Math.max%");if(y)try{y({},"a",{value:1})}catch{y=null}P.exports=function(T){var g=L(p,x,arguments);return A&&y&&A(g,"length").configurable&&y(g,"length",{value:1+D(0,T.length-(arguments.length-1))}),g};var _=function(){return L(p,I,arguments)};y?y(P.exports,"apply",{value:_}):P.exports.apply=_},function(P,h,R){function p(W,G){if(W===1/0||W===-1/0||W!==W||W&&W>-1e3&&W<1e3||ue.call(/e/,G))return G;var oe=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof W=="number"){var de=W<0?-pe(-W):pe(W);if(de!==W){var ce=String(de),Se=te.call(G,ce.length+1);return ee.call(ce,oe,"$&_")+"."+ee.call(ee.call(Se,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ee.call(G,oe,"$&_")}function S(W,G,oe){var de=(oe.quoteStyle||G)==="double"?'"':"'";return de+W+de}function I(W){return ee.call(String(W),/"/g,""")}function x(W){return!(e(W)!=="[object Array]"||ve&&typeof W=="object"&&ve in W)}function L(W){return!(e(W)!=="[object Date]"||ve&&typeof W=="object"&&ve in W)}function A(W){return!(e(W)!=="[object RegExp]"||ve&&typeof W=="object"&&ve in W)}function y(W){return!(e(W)!=="[object Error]"||ve&&typeof W=="object"&&ve in W)}function D(W){return!(e(W)!=="[object String]"||ve&&typeof W=="object"&&ve in W)}function _(W){return!(e(W)!=="[object Number]"||ve&&typeof W=="object"&&ve in W)}function T(W){return!(e(W)!=="[object Boolean]"||ve&&typeof W=="object"&&ve in W)}function g(W){if(ge)return W&&typeof W=="object"&&W instanceof Symbol;if(typeof W=="symbol")return!0;if(!W||typeof W!="object"||!fe)return!1;try{return fe.call(W),!0}catch{}return!1}function E(W){if(!W||typeof W!="object"||!Ee)return!1;try{return Ee.call(W),!0}catch{}return!1}function a(W,G){return ye.call(W,G)}function e(W){return X.call(W)}function s(W){if(W.name)return W.name;var G=ne.call(le.call(W),/^function\s*([\w$]+)/);return G?G[1]:null}function u(W,G){if(W.indexOf)return W.indexOf(G);for(var oe=0,de=W.length;oe<de;oe++)if(W[oe]===G)return oe;return-1}function n(W){if(!U||!W||typeof W!="object")return!1;try{U.call(W);try{j.call(W)}catch{return!0}return W instanceof Map}catch{}return!1}function i(W){if(!Y||!W||typeof W!="object")return!1;try{Y.call(W,Y);try{J.call(W,J)}catch{return!0}return W instanceof WeakMap}catch{}return!1}function t(W){if(!q||!W||typeof W!="object")return!1;try{return q.call(W),!0}catch{}return!1}function l(W){if(!j||!W||typeof W!="object")return!1;try{j.call(W);try{U.call(W)}catch{return!0}return W instanceof Set}catch{}return!1}function d(W){if(!J||!W||typeof W!="object")return!1;try{J.call(W,J);try{Y.call(W,Y)}catch{return!0}return W instanceof WeakSet}catch{}return!1}function r(W){return!(!W||typeof W!="object")&&(typeof HTMLElement!="undefined"&&W instanceof HTMLElement||typeof W.nodeName=="string"&&typeof W.getAttribute=="function")}function c(W,G){if(W.length>G.maxStringLength){var oe=W.length-G.maxStringLength,de="... "+oe+" more character"+(oe>1?"s":"");return c(te.call(W,0,G.maxStringLength),G)+de}return S(ee.call(ee.call(W,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,f),"single",G)}function f(W){var G=W.charCodeAt(0),oe={8:"b",9:"t",10:"n",12:"f",13:"r"}[G];return oe?"\\"+oe:"\\x"+(G<16?"0":"")+$.call(G.toString(16))}function o(W){return"Object("+W+")"}function v(W){return W+" { ? }"}function m(W,G,oe,de){return W+" ("+G+") {"+(de?M(oe,de):se.call(oe,", "))+"}"}function O(W){for(var G=0;G<W.length;G++)if(u(W[G],`
|
|
1
|
+
"use strict";(()=>{var Nt=Object.create;var yt=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var Et=(K,R)=>()=>(R||K((R={exports:{}}).exports,R),R.exports);var Ht=(K,R,h,P)=>{if(R&&typeof R=="object"||typeof R=="function")for(let p of jt(R))!Gt.call(K,p)&&p!==h&&yt(K,p,{get:()=>R[p],enumerable:!(P=Kt(R,p))||P.enumerable});return K};var rt=(K,R,h)=>(h=K!=null?Nt(Wt(K)):{},Ht(R||!K||!K.__esModule?yt(h,"default",{value:K,enumerable:!0}):h,K));var Tt=Et((it,lt)=>{(function(){var K=!1;(function(R,h){typeof it=="object"&&typeof lt=="object"?lt.exports=h():typeof K=="function"&&K.amd?K("mux",[],h):typeof it=="object"?it.mux=h():R.mux=h()})(typeof self!="undefined"?self:this,function(){return function(R){function h(p){if(P[p])return P[p].exports;var x=P[p]={i:p,l:!1,exports:{}};return R[p].call(x.exports,x,x.exports,h),x.l=!0,x.exports}var P={};return h.m=R,h.c=P,h.d=function(p,x,I){h.o(p,x)||Object.defineProperty(p,x,{configurable:!1,enumerable:!0,get:I})},h.n=function(p){var x=p&&p.__esModule?function(){return p.default}:function(){return p};return h.d(x,"a",x),x},h.o=function(p,x){return Object.prototype.hasOwnProperty.call(p,x)},h.p="",h(h.s=18)}([function(R,h,P){(function(p){var x;x=typeof window!="undefined"?window:p!==void 0?p:typeof self!="undefined"?self:{},R.exports=x}).call(h,P(20))},function(R,h){function P(C,U,B){switch(B.length){case 0:return C.call(U);case 1:return C.call(U,B[0]);case 2:return C.call(U,B[0],B[1]);case 3:return C.call(U,B[0],B[1],B[2])}return C.apply(U,B)}function p(C,U){for(var B=-1,N=Array(C);++B<C;)N[B]=U(B);return N}function x(C,U){var B=F(C)||g(C)?p(C.length,String):[],N=B.length,k=!!N;for(var j in C)!U&&!o.call(C,j)||k&&(j=="length"||y(j,N))||B.push(j);return B}function I(C,U,B){var N=C[U];o.call(C,U)&&S(N,B)&&(B!==void 0||U in C)||(C[U]=B)}function T(C){if(!L(C))return O(C);var U=[];for(var B in Object(C))o.call(C,B)&&B!="constructor"&&U.push(B);return U}function _(C,U){return U=b(U===void 0?C.length-1:U,0),function(){for(var B=arguments,N=-1,k=b(B.length-U,0),j=Array(k);++N<k;)j[N]=B[U+N];N=-1;for(var H=Array(U+1);++N<U;)H[N]=B[N];return H[U]=j,P(C,this,H)}}function A(C,U,B,N){B||(B={});for(var k=-1,j=U.length;++k<j;){var H=U[k],V=N?N(B[H],C[H],H,B,C):void 0;I(B,H,V===void 0?C[H]:V)}return B}function y(C,U){return!!(U=U==null?t:U)&&(typeof C=="number"||c.test(C))&&C>-1&&C%1==0&&C<U}function D(C,U,B){if(!u(B))return!1;var N=typeof U;return!!(N=="number"?E(B)&&y(U,B.length):N=="string"&&U in B)&&S(B[U],C)}function L(C){var U=C&&C.constructor;return C===(typeof U=="function"&&U.prototype||f)}function S(C,U){return C===U||C!==C&&U!==U}function g(C){return a(C)&&o.call(C,"callee")&&(!m.call(C,"callee")||v.call(C)==l)}function E(C){return C!=null&&s(C.length)&&!e(C)}function a(C){return n(C)&&E(C)}function e(C){var U=u(C)?v.call(C):"";return U==d||U==r}function s(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=t}function u(C){var U=typeof C;return!!C&&(U=="object"||U=="function")}function n(C){return!!C&&typeof C=="object"}function i(C){return E(C)?x(C):T(C)}var t=9007199254740991,l="[object Arguments]",d="[object Function]",r="[object GeneratorFunction]",c=/^(?:0|[1-9]\d*)$/,f=Object.prototype,o=f.hasOwnProperty,v=f.toString,m=f.propertyIsEnumerable,O=function(C,U){return function(B){return C(U(B))}}(Object.keys,Object),b=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return _(function(U,B){var N=-1,k=B.length,j=k>1?B[k-1]:void 0,H=k>2?B[2]:void 0;for(j=C.length>3&&typeof j=="function"?(k--,j):void 0,H&&D(B[0],B[1],H)&&(j=k<3?void 0:j,k=1),U=Object(U);++N<k;){var V=B[N];V&&C(U,V,N,j)}return U})}(function(C,U){if(M||L(U)||E(U))return void A(U,i(U),C);for(var B in U)o.call(U,B)&&I(C,B,U[B])});R.exports=w},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(0),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I={};I.now=function(){var T=x.default.performance,_=T&&T.timing;return _&&typeof _.navigationStart=="number"&&typeof T.now=="function"?_.navigationStart+T.now():Date.now()},h.default=I},function(R,h,P){"use strict";function p(x,I,T){T=T===void 0?1:T,x[I]=x[I]||0,x[I]+=T}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(21),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=x.default.methodFactory;x.default.methodFactory=function(T,_,A){var y=I(T,_,A);return function(){for(var D=["[mux]"],L=0;L<arguments.length;L++)D.push(arguments[L]);y.apply(void 0,D)}},x.default.setLevel(x.default.getLevel()),h.default=x.default},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(T){return I(T)[0]},x=function(T){return I(T)[1]},I=function(T){if(typeof T!="string"||T==="")return["localhost"];var _=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,A=T.match(_)||[],y=A[4],D=void 0;return y&&(D=(y.match(/[^\.]+\.[^\.]+$/)||[])[0]),[y,D]};h.extractHostnameAndDomain=I,h.extractHostname=p,h.extractDomain=x},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(I){var T=16*Math.random()|0;return(I==="x"?T:3&T|8).toString(16)})},x=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};h.generateUUID=p,h.generateShortID=x},function(R,h,P){"use strict";function p(I){I=I||"";var T={};return I.trim().split(/[\r\n]+/).forEach(function(_){if(_){var A=_.split(": "),y=A.shift();y&&(x.indexOf(y.toLowerCase())>=0||y.toLowerCase().indexOf("x-litix-")===0)&&(T[y]=A.join(": "))}}),T}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var x=["x-cdn","content-type"]},function(R,h,P){"use strict";var p=SyntaxError,x=Function,I=TypeError,T=function(o){try{return x('"use strict"; return ('+o+").constructor;")()}catch{}},_=Object.getOwnPropertyDescriptor;if(_)try{_({},"")}catch{_=null}var A=function(){throw new I},y=_?function(){try{return arguments.callee,A}catch{try{return _(arguments,"callee").get}catch{return A}}}():A,D=P(43)(),L=Object.getPrototypeOf||function(o){return o.__proto__},S={},g=typeof Uint8Array=="undefined"?void 0:L(Uint8Array),E={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":D?L([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":x,"%GeneratorFunction%":S,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":D?L(L([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&D?L(new Map()[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?void 0:Promise,"%Proxy%":typeof Proxy=="undefined"?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?void 0:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?void 0:Set,"%SetIteratorPrototype%":typeof Set!="undefined"&&D?L(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":D?L(""[Symbol.iterator]()):void 0,"%Symbol%":D?Symbol:void 0,"%SyntaxError%":p,"%ThrowTypeError%":y,"%TypedArray%":g,"%TypeError%":I,"%Uint8Array%":typeof Uint8Array=="undefined"?void 0:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?void 0:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?void 0:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?void 0:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?void 0:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?void 0:WeakSet},a=function o(v){var m;if(v==="%AsyncFunction%")m=T("async function () {}");else if(v==="%GeneratorFunction%")m=T("function* () {}");else if(v==="%AsyncGeneratorFunction%")m=T("async function* () {}");else if(v==="%AsyncGenerator%"){var O=o("%AsyncGeneratorFunction%");O&&(m=O.prototype)}else if(v==="%AsyncIteratorPrototype%"){var b=o("%AsyncGenerator%");b&&(m=L(b.prototype))}return E[v]=m,m},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},s=P(9),u=P(46),n=s.call(Function.call,Array.prototype.concat),i=s.call(Function.apply,Array.prototype.splice),t=s.call(Function.call,String.prototype.replace),l=s.call(Function.call,String.prototype.slice),d=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,r=/\\(\\)?/g,c=function(o){var v=l(o,0,1),m=l(o,-1);if(v==="%"&&m!=="%")throw new p("invalid intrinsic syntax, expected closing `%`");if(m==="%"&&v!=="%")throw new p("invalid intrinsic syntax, expected opening `%`");var O=[];return t(o,d,function(b,M,F,w){O[O.length]=F?t(w,r,"$1"):M||b}),O},f=function(o,v){var m,O=o;if(u(e,O)&&(m=e[O],O="%"+m[0]+"%"),u(E,O)){var b=E[O];if(b===S&&(b=a(O)),b===void 0&&!v)throw new I("intrinsic "+o+" exists, but is not available. Please file an issue!");return{alias:m,name:O,value:b}}throw new p("intrinsic "+o+" does not exist!")};R.exports=function(o,v){if(typeof o!="string"||o.length===0)throw new I("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof v!="boolean")throw new I('"allowMissing" argument must be a boolean');var m=c(o),O=m.length>0?m[0]:"",b=f("%"+O+"%",v),M=b.name,F=b.value,w=!1,C=b.alias;C&&(O=C[0],i(m,n([0,1],C)));for(var U=1,B=!0;U<m.length;U+=1){var N=m[U],k=l(N,0,1),j=l(N,-1);if((k==='"'||k==="'"||k==="`"||j==='"'||j==="'"||j==="`")&&k!==j)throw new p("property names with quotes must have matching quotes");if(N!=="constructor"&&B||(w=!0),O+="."+N,M="%"+O+"%",u(E,M))F=E[M];else if(F!=null){if(!(N in F)){if(!v)throw new I("base intrinsic for "+o+" exists, but the property is not available.");return}if(_&&U+1>=m.length){var H=_(F,N);B=!!H,F=B&&"get"in H&&!("originalValue"in H.get)?H.get:F[N]}else B=u(F,N),F=F[N];B&&!w&&(E[M]=F)}}return F}},function(R,h,P){"use strict";var p=P(45);R.exports=Function.prototype.bind||p},function(R,h,P){"use strict";var p=String.prototype.replace,x=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};R.exports={default:I.RFC3986,formatters:{RFC1738:function(T){return p.call(T,x,"+")},RFC3986:function(T){return String(T)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0}),h.findMediaElement=h.getMuxPlayerId=void 0;var p=P(6),x=function(T){return T&&T.nodeName!==void 0?(T.muxId||(T.muxId=T.id||(0,p.generateShortID)()),T.muxId):T},I=function(T){var _=void 0;return T&&T.nodeName!==void 0?(_=T,T=x(_)):_=document.querySelector(T),[_,T,_&&_.nodeName?_.nodeName.toLowerCase():""]};h.getMuxPlayerId=x,h.findMediaElement=I},function(R,h,P){"use strict";function p(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var x=P(0),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(0),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I={};I.exists=function(){var T=x.default.performance;return(T&&T.timing)!==void 0},I.domContentLoadedEventEnd=function(){var T=x.default.performance,_=T&&T.timing;return _&&_.domContentLoadedEventEnd},I.navigationStart=function(){var T=x.default.performance,_=T&&T.timing;return _&&_.navigationStart},h.default=I},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(x){var I={};for(var T in x){var _=x[T];_["DATA-ID"].search("io.litix.data.")!==-1&&(I[_["DATA-ID"].replace("io.litix.data.","")]=_.VALUE)}return I};h.default=p},function(R,h,P){"use strict";var p=P(41),x=P(51),I=P(10);R.exports={formats:I,parse:x,stringify:p}},function(R,h,P){"use strict";var p=P(10),x=Object.prototype.hasOwnProperty,I=Array.isArray,T=function(){for(var u=[],n=0;n<256;++n)u.push("%"+((n<16?"0":"")+n.toString(16)).toUpperCase());return u}(),_=function(u){for(;u.length>1;){var n=u.pop(),i=n.obj[n.prop];if(I(i)){for(var t=[],l=0;l<i.length;++l)i[l]!==void 0&&t.push(i[l]);n.obj[n.prop]=t}}},A=function(u,n){for(var i=n&&n.plainObjects?Object.create(null):{},t=0;t<u.length;++t)u[t]!==void 0&&(i[t]=u[t]);return i},y=function u(n,i,t){if(!i)return n;if(typeof i!="object"){if(I(n))n.push(i);else{if(!n||typeof n!="object")return[n,i];(t&&(t.plainObjects||t.allowPrototypes)||!x.call(Object.prototype,i))&&(n[i]=!0)}return n}if(!n||typeof n!="object")return[n].concat(i);var l=n;return I(n)&&!I(i)&&(l=A(n,t)),I(n)&&I(i)?(i.forEach(function(d,r){if(x.call(n,r)){var c=n[r];c&&typeof c=="object"&&d&&typeof d=="object"?n[r]=u(c,d,t):n.push(d)}else n[r]=d}),n):Object.keys(i).reduce(function(d,r){var c=i[r];return x.call(d,r)?d[r]=u(d[r],c,t):d[r]=c,d},l)},D=function(u,n){return Object.keys(n).reduce(function(i,t){return i[t]=n[t],i},u)},L=function(u,n,i){var t=u.replace(/\+/g," ");if(i==="iso-8859-1")return t.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(t)}catch{return t}},S=function(u,n,i,t,l){if(u.length===0)return u;var d=u;if(typeof u=="symbol"?d=Symbol.prototype.toString.call(u):typeof u!="string"&&(d=String(u)),i==="iso-8859-1")return escape(d).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});for(var r="",c=0;c<d.length;++c){var f=d.charCodeAt(c);f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||l===p.RFC1738&&(f===40||f===41)?r+=d.charAt(c):f<128?r+=T[f]:f<2048?r+=T[192|f>>6]+T[128|63&f]:f<55296||f>=57344?r+=T[224|f>>12]+T[128|f>>6&63]+T[128|63&f]:(c+=1,f=65536+((1023&f)<<10|1023&d.charCodeAt(c)),r+=T[240|f>>18]+T[128|f>>12&63]+T[128|f>>6&63]+T[128|63&f])}return r},g=function(u){for(var n=[{obj:{o:u},prop:"o"}],i=[],t=0;t<n.length;++t)for(var l=n[t],d=l.obj[l.prop],r=Object.keys(d),c=0;c<r.length;++c){var f=r[c],o=d[f];typeof o=="object"&&o!==null&&i.indexOf(o)===-1&&(n.push({obj:d,prop:f}),i.push(o))}return _(n),u},E=function(u){return Object.prototype.toString.call(u)==="[object RegExp]"},a=function(u){return!(!u||typeof u!="object")&&!!(u.constructor&&u.constructor.isBuffer&&u.constructor.isBuffer(u))},e=function(u,n){return[].concat(u,n)},s=function(u,n){if(I(u)){for(var i=[],t=0;t<u.length;t+=1)i.push(n(u[t]));return i}return n(u)};R.exports={arrayToObject:A,assign:D,combine:e,compact:g,decode:L,encode:S,isBuffer:a,isRegExp:E,maybeMap:s,merge:y}},function(R,h,P){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}function x(E){var a={};for(var e in E)E.hasOwnProperty(e)&&(a[E[e]]=e);return a}function I(E){var a={},e={};return Object.keys(E).forEach(function(s){var u=!1;if(E.hasOwnProperty(s)&&E[s]!==void 0){var n=s.split("_"),i=n[0],t=L[i];t||(_.default.info("Data key word `"+n[0]+"` not expected in "+s),t=i+"_"),n.splice(1).forEach(function(l){l==="url"&&(u=!0),g[l]?t+=g[l]:Number(l)&&Math.floor(Number(l))===Number(l)?t+=l:(_.default.info("Data key word `"+l+"` not expected in "+s),t+="_"+l+"_")}),u?e[t]=E[s]:a[t]=E[s]}}),(0,y.default)(a,e)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=I;var T=P(4),_=p(T),A=P(1),y=p(A),D={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},L=x(D),S={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},g=x(S)},function(R,h,P){"use strict";R.exports=P(19).default},function(R,h,P){"use strict";function p(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(h,"__esModule",{value:!0});var x=function(){function r(c,f){var o=[],v=!0,m=!1,O=void 0;try{for(var b,M=c[Symbol.iterator]();!(v=(b=M.next()).done)&&(o.push(b.value),!f||o.length!==f);v=!0);}catch(F){m=!0,O=F}finally{try{!v&&M.return&&M.return()}finally{if(m)throw O}}return o}return function(c,f){if(Array.isArray(c))return c;if(Symbol.iterator in Object(c))return r(c,f);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=P(0),T=p(I),_=P(11),A=P(4),y=p(A),D=P(12),L=p(D),S=P(2),g=p(S),E=P(22),a=p(E),e=P(58),s=p(e),u=P(59),n=p(u),i=P(64),t=p(i),l={},d=function r(c){var f=arguments;typeof c=="string"?r.hasOwnProperty(c)?T.default.setTimeout(function(){f=Array.prototype.splice.call(f,1),r[c].apply(null,f)},0):y.default.warn("`"+c+"` is an unknown task"):typeof c=="function"?T.default.setTimeout(function(){c(r)},0):y.default.warn("`"+c+"` is invalid.")};d.loaded=g.default.now(),d.NAME="mux-embed",d.VERSION="4.8.0",d.API_VERSION="2.1",d.PLAYER_TRACKED=!1,d.monitor=function(r,c){return(0,s.default)(d,r,c)},d.destroyMonitor=function(r){var c=(0,_.findMediaElement)(r),f=x(c,1),o=f[0];o&&o.mux&&typeof o.mux.destroy=="function"?o.mux.destroy():y.default.error("A video element monitor for `"+r+"` has not been initialized via `mux.monitor`.")},d.addHLSJS=function(r,c){var f=(0,_.getMuxPlayerId)(r);l[f]?l[f].addHLSJS(c):y.default.error("A monitor for `"+f+"` has not been initialized.")},d.addDashJS=function(r,c){var f=(0,_.getMuxPlayerId)(r);l[f]?l[f].addDashJS(c):y.default.error("A monitor for `"+f+"` has not been initialized.")},d.removeHLSJS=function(r){var c=(0,_.getMuxPlayerId)(r);l[c]?l[c].removeHLSJS():y.default.error("A monitor for `"+c+"` has not been initialized.")},d.removeDashJS=function(r){var c=(0,_.getMuxPlayerId)(r);l[c]?l[c].removeDashJS():y.default.error("A monitor for `"+c+"` has not been initialized.")},d.init=function(r,c){(0,L.default)()&&c&&c.respectDoNotTrack&&y.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=(0,_.getMuxPlayerId)(r);l[f]=new a.default(d,f,c)},d.emit=function(r,c,f){var o=(0,_.getMuxPlayerId)(r);l[o]?(l[o].emit(c,f),c==="destroy"&&delete l[o]):y.default.error("A monitor for `"+o+"` has not been initialized.")},T.default!==void 0&&typeof T.default.addEventListener=="function"&&T.default.addEventListener("pagehide",function(r){r.persisted||(d.WINDOW_UNLOADING=!0)},!1),d.checkDoNotTrack=L.default,d.log=y.default,d.utils=n.default,d.events=t.default,h.default=d},function(R,h){var P;P=function(){return this}();try{P=P||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(P=window)}R.exports=P},function(R,h,P){var p,x;(function(I,T){"use strict";p=T,(x=typeof p=="function"?p.call(h,P,h,R):p)!==void 0&&(R.exports=x)})(0,function(){"use strict";function I(n,i){var t=n[i];if(typeof t.bind=="function")return t.bind(n);try{return Function.prototype.bind.call(t,n)}catch{return function(){return Function.prototype.apply.apply(t,[n,arguments])}}}function T(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function _(n){return n==="debug"&&(n="log"),typeof console!==g&&(n==="trace"&&E?T:console[n]!==void 0?I(console,n):console.log!==void 0?I(console,"log"):S)}function A(n,i){for(var t=0;t<a.length;t++){var l=a[t];this[l]=t<n?S:this.methodFactory(l,n,i)}this.log=this.debug}function y(n,i,t){return function(){typeof console!==g&&(A.call(this,i,t),this[n].apply(this,arguments))}}function D(n,i,t){return _(n)||y.apply(this,arguments)}function L(n,i,t){function l(m){var O=(a[m]||"silent").toUpperCase();if(typeof window!==g&&o){try{return void(window.localStorage[o]=O)}catch{}try{window.document.cookie=encodeURIComponent(o)+"="+O+";"}catch{}}}function d(){var m;if(typeof window!==g&&o){try{m=window.localStorage[o]}catch{}if(typeof m===g)try{var O=window.document.cookie,b=O.indexOf(encodeURIComponent(o)+"=");b!==-1&&(m=/^([^;]+)/.exec(O.slice(b))[1])}catch{}return f.levels[m]===void 0&&(m=void 0),m}}function r(){if(typeof window!==g&&o){try{return void window.localStorage.removeItem(o)}catch{}try{window.document.cookie=encodeURIComponent(o)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var c,f=this;i=i==null?"WARN":i;var o="loglevel";typeof n=="string"?o+=":"+n:typeof n=="symbol"&&(o=void 0),f.name=n,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=t||D,f.getLevel=function(){return c},f.setLevel=function(m,O){if(typeof m=="string"&&f.levels[m.toUpperCase()]!==void 0&&(m=f.levels[m.toUpperCase()]),!(typeof m=="number"&&m>=0&&m<=f.levels.SILENT))throw"log.setLevel() called with invalid level: "+m;if(c=m,O!==!1&&l(m),A.call(f,m,n),typeof console===g&&m<f.levels.SILENT)return"No console available for logging"},f.setDefaultLevel=function(m){i=m,d()||f.setLevel(m,!1)},f.resetLevel=function(){f.setLevel(i,!1),r()},f.enableAll=function(m){f.setLevel(f.levels.TRACE,m)},f.disableAll=function(m){f.setLevel(f.levels.SILENT,m)};var v=d();v==null&&(v=i),f.setLevel(v,!1)}var S=function(){},g="undefined",E=typeof window!==g&&typeof window.navigator!==g&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"],e=new L,s={};e.getLogger=function(n){if(typeof n!="symbol"&&typeof n!="string"||n==="")throw new TypeError("You must supply a name when creating a logger.");var i=s[n];return i||(i=s[n]=new L(n,e.getLevel(),e.methodFactory)),i};var u=typeof window!==g?window.log:void 0;return e.noConflict=function(){return typeof window!==g&&window.log===e&&(window.log=u),e},e.getLoggers=function(){return s},e.default=e,e})},function(R,h,P){"use strict";function p(ee){return ee&&ee.__esModule?ee:{default:ee}}Object.defineProperty(h,"__esModule",{value:!0});var x=function(){function ee($,Z){var ue=[],he=!0,se=!1,me=void 0;try{for(var pe,Ee=$[Symbol.iterator]();!(he=(pe=Ee.next()).done)&&(ue.push(pe.value),!Z||ue.length!==Z);he=!0);}catch(ae){se=!0,me=ae}finally{try{!he&&Ee.return&&Ee.return()}finally{if(se)throw me}}return ue}return function($,Z){if(Array.isArray($))return $;if(Symbol.iterator in Object($))return ee($,Z);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=P(4),T=p(I),_=P(1),A=p(_),y=P(6),D=P(5),L=P(0),S=p(L),g=P(13),E=p(g),a=P(3),e=p(a),s=P(23),u=P(24),n=P(25),i=p(n),t=P(26),l=p(t),d=P(27),r=p(d),c=P(28),f=p(c),o=P(29),v=p(o),m=P(30),O=p(m),b=P(31),M=p(b),F=P(32),w=p(F),C=P(33),U=p(C),B=P(34),N=p(B),k=P(35),j=p(k),H=P(36),V=p(H),Y=P(37),Q=p(Y),J=P(38),z=p(J),q=P(39),re=p(q),X=P(57),le=p(X),ne=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],te=function(ee,$,Z){var ue=this;this.DOM_CONTENT_LOADED_EVENT_END=E.default.domContentLoadedEventEnd(),this.NAVIGATION_START=E.default.navigationStart();var he={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(ae){return ae}};this.mux=ee,this.id=$,Z=(0,A.default)(he,Z),Z.data=Z.data||{},Z.data.property_key&&(Z.data.env_key=Z.data.property_key,delete Z.data.property_key),T.default.setLevel(Z.debug?"debug":"warn"),this.getPlayheadTime=Z.getPlayheadTime,this.getStateData=Z.getStateData||function(){},this.getAdData=Z.getAdData||function(){},this.minimumRebufferDuration=Z.minimumRebufferDuration,this.sustainedRebufferThreshold=Z.sustainedRebufferThreshold,this.playbackHeartbeatTime=Z.playbackHeartbeatTime,this.disableRebufferTracking=Z.disableRebufferTracking,this.disableRebufferTracking&&this.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),this.errorTranslator=Z.errorTranslator,this.playbackEventDispatcher=new re.default(ee,Z.data.env_key,Z),this.data={player_instance_id:(0,y.generateUUID)(),mux_sample_rate:Z.sampleRate,beacon_domain:Z.beaconCollectionDomain?Z.beaconCollectionDomain:Z.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(ae,fe){fe=(0,A.default)({viewer_time:this.mux.utils.now()},fe),this.oldEmit(ae,fe)};var se=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(ae,fe){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,A.default)(this.data,fe),this._initializeViewData(),this.one("play",se),this.one("adbreakstart",se)});var me=function(ae){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ae)}.bind(this);if(this.on("videochange",function(ae,fe){me(fe)}),this.on("programchange",function(ae,fe){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me((0,A.default)(fe,{view_program_changed:!0})),se(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(ae,fe){this.currentFragmentPDT=fe.currentFragmentPDT,this.currentFragmentStart=fe.currentFragmentStart}),this.on("destroy",this.destroy),S.default!==void 0&&typeof S.default.addEventListener=="function"&&typeof S.default.removeEventListener=="function"){var pe=function(ae){ae.persisted||ue.destroy()};S.default.addEventListener("pagehide",pe,!1),this.on("destroy",function(){S.default.removeEventListener("pagehide",pe)})}this.on("playerready",function(ae,fe){(0,A.default)(this.data,fe)}),ne.forEach(function(ae){ue.on(ae,function(fe,ge){ae.indexOf("ad")!==0&&this._updateStateData(),(0,A.default)(this.data,ge),this._sanitizeData()}),ue.on("after"+ae,function(){(ae!=="error"||this.viewErrored)&&this.send(ae)})}),this.on("viewend",function(ae,fe){(0,A.default)(ue.data,fe)});var Ee=function(ae){var fe=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=fe-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};this.one("playerready",Ee),r.default.apply(this),z.default.apply(this),j.default.apply(this),O.default.apply(this),l.default.apply(this),N.default.apply(this),f.default.apply(this),v.default.apply(this),V.default.apply(this),M.default.apply(this),w.default.apply(this),U.default.apply(this),Q.default.apply(this),le.default.apply(this),Z.hlsjs&&this.addHLSJS(Z),Z.dashjs&&this.addDashJS(Z),this.emit("viewinit",Z.data)};(0,A.default)(te.prototype,i.default.prototype),(0,A.default)(te.prototype,O.default.prototype),(0,A.default)(te.prototype,j.default.prototype),(0,A.default)(te.prototype,l.default.prototype),(0,A.default)(te.prototype,f.default.prototype),(0,A.default)(te.prototype,v.default.prototype),(0,A.default)(te.prototype,V.default.prototype),(0,A.default)(te.prototype,w.default.prototype),(0,A.default)(te.prototype,U.default.prototype),te.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),S.default.clearTimeout(this._heartBeatTimeout))},te.prototype.send=function(ee){var $=(0,A.default)({},this.data),Z=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if($.video_source_is_live===void 0&&($.player_source_duration===1/0||$.video_source_duration===1/0?$.video_source_is_live=!0:($.player_source_duration>0||$.video_source_duration>0)&&($.video_source_is_live=!1)),$.video_source_is_live||Z.forEach(function(pe){$[pe]=void 0}),$.video_source_url=$.video_source_url||$.player_source_url,$.video_source_url){var ue=(0,D.extractHostnameAndDomain)($.video_source_url),he=x(ue,2),se=he[0],me=he[1];$.video_source_domain=me,$.video_source_hostname=se}delete $.ad_request_id,this.playbackEventDispatcher.send(ee,$),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},te.prototype._updateStateData=function(){(0,A.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},te.prototype._sanitizeData=function(){var ee=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function($){var Z=parseInt(ee.data[$],10);ee.data[$]=isNaN(Z)?void 0:Z}),["player_source_url","video_source_url"].forEach(function($){if(ee.data[$]){var Z=ee.data[$].toLowerCase();Z.indexOf("data:")!==0&&Z.indexOf("blob:")!==0||(ee.data[$]="MSE style URL")}})},te.prototype._resetVideoData=function(ee,$){var Z=this;Object.keys(this.data).forEach(function(ue){ue.indexOf("video_")===0&&delete Z.data[ue]})},te.prototype._resetViewData=function(){var ee=this;Object.keys(this.data).forEach(function($){$.indexOf("view_")===0&&delete ee.data[$]}),this.data.view_sequence_number=1},te.prototype._resetErrorData=function(ee,$){delete this.data.player_error_code,delete this.data.player_error_message},te.prototype._initializeViewData=function(){var ee=this,$=this.data.view_id=(0,y.generateUUID)(),Z=function(){$===ee.data.view_id&&(0,e.default)(ee.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",Z):Z()},te.prototype._restartHeartBeat=function(){var ee=this;S.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=S.default.setTimeout(function(){ee.data.player_is_paused||ee.emit("hb")},1e4))},te.prototype.addHLSJS=function(ee){return ee.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=ee.hlsjs,void(0,s.monitorHlsJs)(this.mux,this.id,ee.hlsjs,{},ee.Hls||S.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},te.prototype.removeHLSJS=function(){this.hlsjs&&((0,s.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},te.prototype.addDashJS=function(ee){return ee.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=ee.dashjs,void(0,u.monitorDashJS)(this.mux,this.id,ee.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},te.prototype.removeDashJS=function(){this.dashjs&&((0,u.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},h.default=te},function(R,h,P){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(h,"__esModule",{value:!0}),h.stopMonitoringHlsJs=h.monitorHlsJs=void 0;var x=P(7),I=p(x),T=P(13),_=p(T),A=P(5),y=P(14),D=p(y),L=function(a){if(!a)return{};var e=_.default.navigationStart(),s=a.loading,u=s?s.start:a.trequest,n=s?s.first:a.tfirst,i=s?s.end:a.tload;return{bytesLoaded:a.total,requestStart:Math.round(e+u),responseStart:Math.round(e+n),responseEnd:Math.round(e+i)}},S=function(a){if(a&&typeof a.getAllResponseHeaders=="function")return(0,I.default)(a.getAllResponseHeaders())},g=function(a,e,s){var u=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),n=a.log,i=a.utils.secondsToMs,t=function(b){var M=parseInt(u.version),F=void 0;return M===1&&b.programDateTime!==null&&(F=b.programDateTime),M===0&&b.pdt!==null&&(F=b.pdt),F};if(!_.default.exists())return void n.warn("performance timing not supported. Not tracking HLS.js.");var l=function(b,M){return a.emit(e,b,M)},d=function(b,M){var F=M.levels,w=M.audioTracks,C=M.url,U=M.stats,B=M.networkDetails,N=M.sessionData,k={},j={},H={};H=(0,D.default)(N),F.forEach(function(q,re){k[re]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),w.forEach(function(q,re){j[re]={name:q.name,language:q.lang,bitrate:q.bitrate}});var V=L(U),Y=V.bytesLoaded,Q=V.requestStart,J=V.responseStart,z=V.responseEnd;H.request_event_type=b,H.request_bytes_loaded=Y,H.request_start=Q,H.request_response_start=J,H.request_response_end=z,H.request_type="manifest",H.request_hostname=(0,A.extractHostname)(C),H.request_response_headers=S(B),H.request_rendition_lists={media:k,audio:j,video:{}},l("requestcompleted",H)};s.on(u.Events.MANIFEST_LOADED,d);var r=function(b,M){var F=M.details,w=M.level,C=M.networkDetails,U=M.stats,B=L(U),N=B.bytesLoaded,k=B.requestStart,j=B.responseStart,H=B.responseEnd,V=F.fragments[F.fragments.length-1],Y=t(V)+i(V.duration);l("requestcompleted",{request_event_type:b,request_bytes_loaded:N,request_start:k,request_response_start:j,request_response_end:H,request_current_level:w,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:S(C),video_holdback:F.holdBack&&i(F.holdBack),video_part_holdback:F.partHoldBack&&i(F.partHoldBack),video_part_target_duration:F.partTarget&&i(F.partTarget),video_target_duration:F.targetduration&&i(F.targetduration),video_source_is_live:F.live,player_manifest_newest_program_time:isNaN(Y)?void 0:Y})};s.on(u.Events.LEVEL_LOADED,r);var c=function(b,M){var F=M.details,w=M.networkDetails,C=M.stats,U=L(C),B=U.bytesLoaded,N=U.requestStart,k=U.responseStart,j=U.responseEnd;l("requestcompleted",{request_event_type:b,request_bytes_loaded:B,request_start:N,request_response_start:k,request_response_end:j,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:S(w)})};s.on(u.Events.AUDIO_TRACK_LOADED,c);var f=function(b,M){var F=M.stats,w=M.networkDetails,C=M.frag,U=L(F),B=U.bytesLoaded,N=U.requestStart,k=U.responseStart,j=U.responseEnd,H={request_event_type:b,request_bytes_loaded:B,request_start:N,request_response_start:k,request_response_end:j,request_hostname:w?(0,A.extractHostname)(w.responseURL):void 0,request_response_headers:S(w),request_media_duration:C.duration};C.type==="main"?(H.request_type="media",H.request_current_level=C.level,H.request_video_width=(s.levels[C.level]||{}).width,H.request_video_height=(s.levels[C.level]||{}).height):H.request_type=C.type,l("requestcompleted",H)};s.on(u.Events.FRAG_LOADED,f);var o=function(b,M){var F=M.frag,w=F.start,C=t(F),U={currentFragmentPDT:C,currentFragmentStart:i(w)};l("fragmentchange",U)};s.on(u.Events.FRAG_CHANGED,o);var v=function(b,M){var F=M.type,w=M.details,C=M.response,U=M.fatal,B=M.context,N=M.frag;if(w===u.ErrorDetails.MANIFEST_LOAD_ERROR||w===u.ErrorDetails.MANIFEST_LOAD_TIMEOUT||w===u.ErrorDetails.FRAG_LOAD_ERROR||w===u.ErrorDetails.FRAG_LOAD_TIMEOUT||w===u.ErrorDetails.LEVEL_LOAD_ERROR||w===u.ErrorDetails.LEVEL_LOAD_TIMEOUT){var k=N&&N.url||B&&B.url||"";l("requestfailed",{request_error:w,request_url:k,request_hostname:(0,A.extractHostname)(k),request_type:w===u.ErrorDetails.FRAG_LOAD_ERROR||w===u.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}U&&l("error",{player_error_code:F,player_error_message:w})};s.on(u.Events.ERROR,v);var m=function(b,M){var F=M.frag,w=F&&F._url||"";l("requestcanceled",{request_cancel:b,request_url:w,request_type:"media",request_hostname:(0,A.extractHostname)(w)})};s.on(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var O=function(b,M){var F=M.level,w=s.levels[F];if(w&&w.attrs&&w.attrs.BANDWIDTH){var C=w.attrs.BANDWIDTH;C?l("renditionchange",{video_source_bitrate:C,video_source_width:w.width,video_source_height:w.height}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};s.on(u.Events.LEVEL_SWITCHED,O),s._stopMuxMonitor=function(){s.off(u.Events.MANIFEST_LOADED,d),s.off(u.Events.LEVEL_LOADED,r),s.off(u.Events.AUDIO_TRACK_LOADED,c),s.off(u.Events.FRAG_LOADED,f),s.off(u.Events.FRAG_CHANGED,o),s.off(u.Events.ERROR,v),s.off(u.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),s.off(u.Events.LEVEL_SWITCHED,O),s.off(u.Events.DESTROYING,s._stopMuxMonitor),delete s._stopMuxMonitor},s.on(u.Events.DESTROYING,s._stopMuxMonitor)},E=function(a){a&&typeof a._stopMuxMonitor=="function"&&a._stopMuxMonitor()};h.monitorHlsJs=g,h.stopMonitoringHlsJs=E},function(R,h,P){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(h,"__esModule",{value:!0}),h.stopMonitoringDashJS=h.monitorDashJS=void 0;var x=P(0),I=p(x),T=P(7),_=p(T),A=P(5),y=function(g,E){if(!g||typeof g.getRequests!="function")return{};var a=g.getRequests({state:"executed"});if(a.length===0)return{};var e=a[a.length-1],s=(0,A.extractHostname)(e.url),u=e.bytesLoaded,n=new Date(e.requestStartDate).getTime(),i=new Date(e.firstByteDate).getTime(),t=new Date(e.requestEndDate).getTime(),l=isNaN(e.duration)?0:e.duration,d=typeof E.getMetricsFor=="function"?E.getMetricsFor(e.mediaType).HttpList:E.getDashMetrics().getHttpRequests(e.mediaType),r=void 0;return d.length>0&&(r=(0,_.default)(d[d.length-1]._responseHeaders||"")),{requestStart:n,requestResponseStart:i,requestResponseEnd:t,requestBytesLoaded:u,requestResponseHeaders:r,requestMediaDuration:l,requestHostname:s}},D=function(g,E){var a=E.getQualityFor(g),e=E.getCurrentTrackFor(g),s=e.bitrateList;return s?{currentLevel:a,renditionWidth:s[a].width||null,renditionHeight:s[a].height||null,renditionBitrate:s[a].bandwidth}:{}},L=function(g,E,a){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],g.log);if(!a||!a.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var s=function(f,o){return g.emit(E,f,o)},u=function(f){var o=f.type,v=f.data,m=v||{},O=m.url;s("requestcompleted",{request_event_type:o,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,A.extractHostname)(O)})};a.on("manifestLoaded",u);var n={},i=function(f){var o=f.type,v=f.fragmentModel,m=f.chunk,O=m||{},b=O.mediaInfo,M=b||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(Y,Q){C[Q]={},C[Q].width=Y.width,C[Q].height=Y.height,C[Q].bitrate=Y.bandwidth,C[Q].attrs={}}),F==="video"?n.video=C:F==="audio"?n.audio=C:n.media=C;var U=y(v,a),B=U.requestStart,N=U.requestResponseStart,k=U.requestResponseEnd,j=U.requestResponseHeaders,H=U.requestMediaDuration,V=U.requestHostname;s("requestcompleted",{request_event_type:o,request_start:B,request_response_start:N,request_response_end:k,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:j,request_hostname:V,request_media_duration:H,request_rendition_lists:n})};a.on("initFragmentLoaded",i);var t=function(f){var o=f.type,v=f.fragmentModel,m=f.chunk,O=m||{},b=O.mediaInfo,M=O.start,F=b||{},w=F.type,C=y(v,a),U=C.requestStart,B=C.requestResponseStart,N=C.requestResponseEnd,k=C.requestBytesLoaded,j=C.requestResponseHeaders,H=C.requestMediaDuration,V=C.requestHostname,Y=D(w,a),Q=Y.currentLevel,J=Y.renditionWidth,z=Y.renditionHeight,q=Y.renditionBitrate;s("requestcompleted",{request_event_type:o,request_start:U,request_response_start:B,request_response_end:N,request_bytes_loaded:k,request_type:w,request_response_headers:j,request_hostname:V,request_media_start_time:M,request_media_duration:H,request_current_level:Q,request_labeled_bitrate:q,request_video_width:J,request_video_height:z})};a.on("mediaFragmentLoaded",t);var l={video:void 0,audio:void 0,totalBitrate:void 0},d=function(){if(l.video&&typeof l.video.bitrate=="number"){if(!l.video.width||!l.video.height)return void e.warn("have bitrate info for video but missing width/height");var f=l.video.bitrate;return l.audio&&typeof l.audio.bitrate=="number"&&(f+=l.audio.bitrate),f!==l.totalBitrate?(l.totalBitrate=f,{video_source_bitrate:f,video_source_height:l.video.height,video_source_width:l.video.width}):void 0}},r=function(f,o,v){if(typeof f.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",f);var m=f.mediaType;if(m==="audio"||m==="video"){var O=a.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===f.newQuality});if(!O||typeof O.bitrate!="number")return void e.warn("missing bitrate info for "+m);l[m]=O;var b=d();b&&s("renditionchange",b)}};a.on("qualityChangeRendered",r);var c=function(f){var o=f.error,v=f.event;v=v||{};var m=v.request||{},O=I.default.event&&I.default.event.currentTarget||{};s("requestfailed",{request_error:o+"_"+v.id+"_"+m.type,request_url:v.url,request_hostname:(0,A.extractHostname)(v.url),request_type:m.mediaType,request_error_code:O.status,request_error_type:O.statusText})};a.on("error",c),a._stopMuxMonitor=function(){a.off("manifestLoaded",u),a.off("initFragmentLoaded",i),a.off("mediaFragmentLoaded",t),a.off("qualityChangeRendered",r),a.off("error",c),delete a._stopMuxMonitor}},S=function(g){g&&typeof g._stopMuxMonitor=="function"&&g._stopMuxMonitor()};h.monitorDashJS=L,h.stopMonitoringDashJS=S},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){},x=0;p.prototype.on=function(I,T,_){return T._eventEmitterGuid=T._eventEmitterGuid||++x,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],_&&(T=T.bind(_)),this._listeners[I].push(T),T},p.prototype.off=function(I,T){var _=this._listeners&&this._listeners[I];_&&_.forEach(function(A,y){A._eventEmitterGuid===T._eventEmitterGuid&&_.splice(y,1)})},p.prototype.one=function(I,T,_){var A=this;T._eventEmitterGuid=T._eventEmitterGuid||++x;var y=function D(){A.off(I,D),T.apply(_||this,arguments)};y._eventEmitterGuid=T._eventEmitterGuid,this.on(I,y)},p.prototype.emit=function(I,T){var _=this;if(this._listeners){T=T||{};var A=this._listeners["before*"]||[],y=this._listeners[I]||[],D=this._listeners["after"+I]||[],L=function(S,g){S=S.slice(),S.forEach(function(E){E.call(_,{type:I},g)})};L(A,T),L(y,T),L(D,T)}},h.default=p},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(0),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=function(){this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,this.on("playing",function(){this._playheadShouldBeProgressing=!0}),this.on("play",this._startPlaybackHeartbeatInterval),this.on("playing",this._startPlaybackHeartbeatInterval),this.on("adbreakstart",this._startPlaybackHeartbeatInterval),this.on("adplay",this._startPlaybackHeartbeatInterval),this.on("adplaying",this._startPlaybackHeartbeatInterval),this.on("seeking",this._startPlaybackHeartbeatInterval),this.on("devicewake",this._startPlaybackHeartbeatInterval),this.on("viewstart",this._startPlaybackHeartbeatInterval),this.on("rebufferstart",this._startPlaybackHeartbeatInterval),this.on("pause",this._stopPlaybackHeartbeatInterval),this.on("ended",this._stopPlaybackHeartbeatInterval),this.on("viewend",this._stopPlaybackHeartbeatInterval),this.on("error",this._stopPlaybackHeartbeatInterval),this.on("aderror",this._stopPlaybackHeartbeatInterval),this.on("adpause",this._stopPlaybackHeartbeatInterval),this.on("adended",this._stopPlaybackHeartbeatInterval),this.on("adbreakend",this._stopPlaybackHeartbeatInterval),this.on("seeked",function(){this.data.player_is_paused?this._stopPlaybackHeartbeatInterval():this._startPlaybackHeartbeatInterval()}),this.on("timeupdate",function(){this._playbackHeartbeatInterval!==null&&this.emit("playbackheartbeat")}),this.on("devicesleep",function(T,_){this._playbackHeartbeatInterval!==null&&(x.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:_.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var T=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=x.default.setInterval(function(){T.emit("playbackheartbeat")},this.playbackHeartbeatTime))},I.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(x.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},h.default=I},function(R,h,P){"use strict";function p(){var x=this;this.on("viewinit",function(){x.viewErrored=!1}),this.on("error",function(){try{var I=x.errorTranslator({player_error_code:x.data.player_error_code,player_error_message:x.data.player_error_message});I?(x.data.player_error_code=I.player_error_code,x.data.player_error_message=I.player_error_message,x.viewErrored=!0):(delete x.data.player_error_code,delete x.data.player_error_message)}catch(T){x.mux.log.warn("Exception in error translator callback.",T),x.viewErrored=!0}})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(3),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(T,_){var A=_.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=A),(0,x.default)(this.data,"view_watch_time",A-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=A},I.prototype._clearWatchTimeState=function(T,_){this._updateWatchTime(T,_),this._watchTimeTrackerLastCheckedTime=null},h.default=I},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(3),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=function(){this._playbackTimeTrackerLastPlayheadPosition=-1,this.on("playbackheartbeat",this._updatePlaybackTime),this.on("playbackheartbeatend",this._clearPlaybackTimeState),this.on("seeking",this._clearPlaybackTimeState)};I.prototype._updatePlaybackTime=function(){var T=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&T>this._playbackTimeTrackerLastPlayheadPosition){var _=T-this._playbackTimeTrackerLastPlayheadPosition;_<=1e3&&(0,x.default)(this.data,"view_content_playback_time",_)}this._playbackTimeTrackerLastPlayheadPosition=T},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},h.default=I},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=function(){this.on("playbackheartbeat",this._updatePlayheadTime),this.on("playbackheartbeatend",this._updatePlayheadTime),this.on("timeupdate",this._updatePlayheadTime),this.on("destroy",function(){this.off("timeupdate",this._updatePlayheadTime)})};p.prototype._updateMaxPlayheadPosition=function(){this.data.view_max_playhead_position=this.data.view_max_playhead_position===void 0?this.data.player_playhead_time:Math.max(this.data.view_max_playhead_position,this.data.player_playhead_time)},p.prototype._updatePlayheadTime=function(x,I){var T=this,_=function(){T.currentFragmentPDT&&T.currentFragmentStart&&(T.data.player_program_time=T.currentFragmentPDT+T.data.player_playhead_time-T.currentFragmentStart)};if(I&&I.player_playhead_time)this.data.player_playhead_time=I.player_playhead_time,_(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var A=this.getPlayheadTime();A!==void 0&&(this.data.player_playhead_time=A,_(),this._updateMaxPlayheadPosition())}},h.default=p},function(R,h,P){"use strict";function p(){var T=this;if(!this.disableRebufferTracking){var _=void 0,A=function(){if(_){var y=T.data.viewer_time-_;(0,I.default)(T.data,"view_rebuffer_duration",y),_=T.data.viewer_time}T.data.view_watch_time>=0&&T.data.view_rebuffer_count>0&&(T.data.view_rebuffer_frequency=T.data.view_rebuffer_count/T.data.view_watch_time,T.data.view_rebuffer_percentage=T.data.view_rebuffer_duration/T.data.view_watch_time)};this.on("playbackheartbeat",function(){return A()}),this.on("rebufferstart",function(){_||((0,I.default)(T.data,"view_rebuffer_count",1),_=T.data.viewer_time,T.one("rebufferend",function(){A(),_=void 0}))})}}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var x=P(3),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(2),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=function(){this.disableRebufferTracking||this.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,this.on("playbackheartbeat",this._checkIfRebuffering),this.on("playbackheartbeatend",this._cleanupRebufferTracker),this.on("seeking",function(){this._cleanupRebufferTracker(null,{viewer_time:x.default.now()})}))};I.prototype._checkIfRebuffering=function(T,_){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(T,_):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(_.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(T,_,!0):(_.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=_.viewer_time))},I.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},I.prototype._prepareRebufferTrackerState=function(T){this._lastCheckedTime=T,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=T},I.prototype._cleanupRebufferTracker=function(T,_){var A=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:_.viewer_time});else{if(this._lastCheckedTime===null)return;var y=this.data.player_playhead_time-this._lastPlayheadTime,D=_.viewer_time-this._lastPlayheadTimeUpdatedTime;y>0&&D-y>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+D-y}))}A?this._prepareRebufferTrackerState(_.viewer_time):this._clearRebufferTrackerState()},h.default=I},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(2),x=function(T){return T&&T.__esModule?T:{default:T}}(p),I=function(){this.on("viewinit",function(){var T=this.data,_=T.view_id;if(!T.view_program_changed){var A=function(y,D){var L=D.viewer_time;y.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(L||x.default.now(),_):y.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(L||x.default.now(),_)};this.one("playing",A),this.one("adplaying",A),this.one("viewend",function(){this.off("playing",A),this.off("adplaying",A)})}})};I.prototype.calculateTimeToFirstFrame=function(T,_){_===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:T}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},h.default=I},function(R,h,P){"use strict";function p(){var T=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var _=["pause","rebufferstart","seeking","error","adbreakstart","hb"],A=["playing","hb"];_.forEach(function(y){T.on(y,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var D=this.data.player_playhead_time-this._lastPlayheadPosition;if(D<0)return void(this._lastPlayheadPosition=-1);var L=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),S=Math.max(0,L-1),g=Math.max(0,1-L);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,S),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,g),(0,I.default)(this.data,"view_total_content_playback_time",D),(0,I.default)(this.data,"view_total_upscaling",S*D),(0,I.default)(this.data,"view_total_downscaling",g*D)}this._lastPlayheadPosition=-1})}),A.forEach(function(y){T.on(y,function(){this._lastPlayheadPosition=this.data.player_playhead_time,this._lastPlayerWidth=this.data.player_width,this._lastPlayerHeight=this.data.player_height,this._lastSourceWidth=this.data.video_source_width,this._lastSourceHeight=this.data.video_source_height})})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var x=P(3),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(R,h,P){"use strict";function p(L){return L&&L.__esModule?L:{default:L}}function x(){this.isSeeking=!1,this.on("seeking",function(L,S){(0,D.default)(this.data,S),this._lastSeekingTime=T.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var L=this._lastSeekingTime||T.default.now(),S=T.default.now()-L;(0,A.default)(this.data,"view_seek_count",1),(0,A.default)(this.data,"view_seek_duration",S);var g=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(g,S)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=x;var I=P(2),T=p(I),_=P(3),A=p(_),y=P(1),D=p(y)},function(R,h,P){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(h,"__esModule",{value:!0});var x=function(){function g(E,a){var e=[],s=!0,u=!1,n=void 0;try{for(var i,t=E[Symbol.iterator]();!(s=(i=t.next()).done)&&(e.push(i.value),!a||e.length!==a);s=!0);}catch(l){u=!0,n=l}finally{try{!s&&t.return&&t.return()}finally{if(u)throw n}}return e}return function(E,a){if(Array.isArray(E))return E;if(Symbol.iterator in Object(E))return g(E,a);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=P(3),T=p(I),_=P(5),A=P(1),y=p(A),D=function(g,E){g.push(E),g.sort(function(a,e){return a.viewer_time-e.viewer_time})},L=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],S=function(){var g=this;this.on("viewinit",function(){this.isAdBreak=!1,this._currentAdRequestNumber=0,this._currentAdResponseNumber=0,this._adRequests=[],this._adResponses=[],this._adHasPlayed=!1,this._wouldBeNewAdPlay=!0,this._prerollPlayTime=void 0}),L.forEach(function(a){return g.on(a,g._updateAdData)});var E=function(){g.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",E),this.on("playing",E),this.on("viewend",E),this.on("adrequest",function(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),D(this._adRequests,e),(0,T.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,T.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(a,e){e=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),D(this._adResponses,e);var s=this.findAdRequest(e.ad_request_id);s&&(0,T.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-s.viewer_time))}),this.on("adplay",function(a,e){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,T.default)(this.data,"view_ad_played_count")),this.inPrerollPosition()&&!this.data.view_preroll_played&&(this.data.view_preroll_played=!0,this._adRequests.length>0&&(this.data.view_preroll_request_time=Math.max(0,e.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,e.viewer_time-this.data.view_start)),this._prerollPlayTime=e.viewer_time)}),this.on("adplaying",function(a,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};S.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},S.prototype.findAdRequest=function(g){for(var E=0;E<this._adRequests.length;E++)if(this._adRequests[E].ad_request_id===g)return this._adRequests[E]},S.prototype._updateAdData=function(g,E){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&E.ad_tag_url){var a=(0,_.extractHostnameAndDomain)(E.ad_tag_url),e=x(a,2),s=e[0],u=e[1];this.data.view_preroll_ad_tag_domain=u,this.data.view_preroll_ad_tag_hostname=s}if(!this.data.view_preroll_ad_asset_hostname&&E.ad_asset_url){var n=(0,_.extractHostnameAndDomain)(E.ad_asset_url),i=x(n,2),t=i[0],l=i[1];this.data.view_preroll_ad_asset_domain=l,this.data.view_preroll_ad_asset_hostname=t}}},h.default=S},function(R,h,P){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}function x(){var y=this,D=void 0,L=void 0,S=function(){y.disableRebufferTracking||((0,A.default)(y.data,"view_waiting_rebuffer_count",1),D=T.default.now(),L=window.setInterval(function(){if(D){var s=T.default.now();(0,A.default)(y.data,"view_waiting_rebuffer_duration",s-D),D=s}},250))},g=function(){y.disableRebufferTracking||D&&((0,A.default)(y.data,"view_waiting_rebuffer_duration",T.default.now()-D),D=!1,window.clearInterval(L))},E=!1,a=function(){E=!0},e=function(){E=!1,g()};this.on("waiting",function(){E&&S()}),this.on("playing",function(){g(),a()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=x;var I=P(2),T=p(I),_=P(3),A=p(_)},function(R,h,P){"use strict";function p(L){return L&&L.__esModule?L:{default:L}}function x(){var L=this;this.one("playbackheartbeat",y),this.on("playbackheartbeatend",function(){L.off("before*",D),L.one("playbackheartbeat",y)})}Object.defineProperty(h,"__esModule",{value:!0}),h.default=x;var I=P(1),T=p(I),_=P(2),A=p(_),y=function(){this.lastWallClockTime=A.default.now(),this.on("before*",D)},D=function(L){var S=A.default.now(),g=this.lastWallClockTime;this.lastWallClockTime=S,S-g>3e4&&(this.emit("devicesleep",{viewer_time:g}),(0,T.default)(this.data,{viewer_time:g}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:S}),(0,T.default)(this.data,{viewer_time:S}),this.send("devicewake"))}},function(R,h,P){"use strict";function p(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(h,"__esModule",{value:!0});var x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},I=P(0),T=p(I),_=P(40),A=P(4),y=p(A),D=P(53),L=p(D),S=P(12),g=p(S),E=P(54),a=p(E),e=P(17),s=p(e),u=P(55),n=p(u),i=P(1),t=p(i),l=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],d=["viewstart","error","ended","viewend"],r=function(o,v){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=o,this.envKey=v,this.eventQueue=new n.default((0,L.default)(v,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var O=m.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:O.name,viewer_application_version:O.version,viewer_application_engine:O.layout,viewer_device_name:O.product,viewer_device_category:"",viewer_device_manufacturer:O.manufacturer,viewer_os_family:O.os&&O.os.family,viewer_os_architecture:O.os&&O.os.architecture,viewer_os_version:O.os&&O.os.version};var b=(0,a.default)();b&&(this.pageLevelData=(0,t.default)(this.pageLevelData,{viewer_connection_type:b})),T.default!==void 0&&T.default.location&&T.default.location.href&&(this.pageLevelData.page_url=T.default.location.href),this.viewerData=this.disableCookies?{}:(0,_.getAndUpdateViewerData)()};r.prototype.send=function(o,v){if(o){if(this.respectDoNotTrack&&(0,g.default)())return y.default.info("Not sending `"+o+"` because Do Not Track is enabled");if(!v||(v===void 0?"undefined":x(v))!=="object")return y.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,_.getAndUpdateSessionData)(),O={};(0,t.default)(O,this.pageLevelData),(0,t.default)(O,v),(0,t.default)(O,m),(0,t.default)(O,this.viewerData),O.event=o,O.env_key=this.envKey,O.user_id&&(O.viewer_user_id=O.user_id,delete O.user_id);var b=O.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(o,O),F=(0,s.default)(M);if(this.lastEventTime=this.mux.utils.now(),b)return y.default.info("Not sending event due to sample rate restriction",o,O,F);if(this.envKey||y.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",o,O,F),!this.rateLimited){if(y.default.info("Sending event",o,O,F),this.rateLimited=!this.eventQueue.queueEvent(o,F),this.mux.WINDOW_UNLOADING&&o==="viewend")this.eventQueue.destroy(!0);else if((d.indexOf(o)>=0||this.mux.WINDOW_VISIBLE===!1&&o==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return O.event="eventrateexceeded",F=(0,s.default)(O),this.eventQueue.queueEvent(O.event,F),y.default.error("Beaconing disabled due to rate limit.")}}},r.prototype.destroy=function(){this.eventQueue.destroy(!1)};var c=function(o,v,m,O){return!(!o||v.indexOf("request_")!==0)&&(v==="request_response_headers"||(m===void 0?"undefined":x(m))!=="object"||(O===void 0?"undefined":x(O))!=="object"||Object.keys(m||{}).length!==Object.keys(O||{}).length)},f=function(o,v){return o==="renditionchange"&&v.indexOf("video_source_")===0};r.prototype._deduplicateBeaconData=function(o,v){var m=this,O={},b=v.view_id;if(!b||o==="viewstart"||o==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)O=(0,t.default)({},v),b&&(this.previousBeaconData=O),b&&o==="viewend"&&(this.previousBeaconData=null);else{var M=o.indexOf("request")===0;Object.keys(v).forEach(function(F){var w=v[F];(w!==m.previousBeaconData[F]||l.indexOf(F)>-1||c(M,F,w,m.previousBeaconData[F])||f(o,F))&&(O[F]=w,m.previousBeaconData[F]=w)})}return O},h.default=r},function(R,h,P){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(h,"__esModule",{value:!0}),h.getAndUpdateSessionData=h.getAndUpdateViewerData=void 0;var x=P(15),I=p(x),T=P(52),_=p(T),A=P(6),y=P(2),D=p(y),L=function(){var a=void 0;try{a=I.default.parse(_.default.get("muxData")||"")}catch{a={}}return a},S=function(a){try{_.default.set("muxData",I.default.stringify(a),{expires:7300})}catch{}},g=function(){var a=L();return a.mux_viewer_id=a.mux_viewer_id||(0,A.generateUUID)(),a.msn=a.msn||Math.random(),S(a),{mux_viewer_id:a.mux_viewer_id,mux_sample_number:a.msn}},E=function(){var a=L(),e=D.default.now();return a.session_start&&(a.sst=a.session_start,delete a.session_start),a.session_id&&(a.sid=a.session_id,delete a.session_id),a.session_expires&&(a.sex=a.session_expires,delete a.session_expires),(!a.sex||a.sex<e)&&(a.sid=(0,A.generateUUID)(),a.sst=e),a.sex=e+15e5,S(a),{session_id:a.sid,session_start:a.sst,session_expires:a.sex}};h.getAndUpdateViewerData=g,h.getAndUpdateSessionData=E},function(R,h,P){"use strict";var p=P(42),x=P(16),I=P(10),T=Object.prototype.hasOwnProperty,_={brackets:function(n){return n+"[]"},comma:"comma",indices:function(n,i){return n+"["+i+"]"},repeat:function(n){return n}},A=Array.isArray,y=String.prototype.split,D=Array.prototype.push,L=function(n,i){D.apply(n,A(i)?i:[i])},S=Date.prototype.toISOString,g=I.default,E={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:x.encode,encodeValuesOnly:!1,format:g,formatter:I.formatters[g],indices:!1,serializeDate:function(n){return S.call(n)},skipNulls:!1,strictNullHandling:!1},a=function(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||typeof n=="symbol"||typeof n=="bigint"},e={},s=function n(i,t,l,d,r,c,f,o,v,m,O,b,M,F,w){for(var C=i,U=w,B=0,N=!1;(U=U.get(e))!==void 0&&!N;){var k=U.get(i);if(B+=1,k!==void 0){if(k===B)throw new RangeError("Cyclic object value");N=!0}U.get(e)===void 0&&(B=0)}if(typeof f=="function"?C=f(t,C):C instanceof Date?C=m(C):l==="comma"&&A(C)&&(C=x.maybeMap(C,function(te){return te instanceof Date?m(te):te})),C===null){if(d)return c&&!M?c(t,E.encoder,F,"key",O):t;C=""}if(a(C)||x.isBuffer(C)){if(c){var j=M?t:c(t,E.encoder,F,"key",O);if(l==="comma"&&M){for(var H=y.call(String(C),","),V="",Y=0;Y<H.length;++Y)V+=(Y===0?"":",")+b(c(H[Y],E.encoder,F,"value",O));return[b(j)+"="+V]}return[b(j)+"="+b(c(C,E.encoder,F,"value",O))]}return[b(t)+"="+b(String(C))]}var Q=[];if(C===void 0)return Q;var J;if(l==="comma"&&A(C))J=[{value:C.length>0?C.join(",")||null:void 0}];else if(A(f))J=f;else{var z=Object.keys(C);J=o?z.sort(o):z}for(var q=0;q<J.length;++q){var re=J[q],X=typeof re=="object"&&re.value!==void 0?re.value:C[re];if(!r||X!==null){var le=A(C)?typeof l=="function"?l(t,re):t:t+(v?"."+re:"["+re+"]");w.set(i,B);var ne=p();ne.set(e,w),L(Q,n(X,le,l,d,r,c,f,o,v,m,O,b,M,F,ne))}}return Q},u=function(n){if(!n)return E;if(n.encoder!==null&&n.encoder!==void 0&&typeof n.encoder!="function")throw new TypeError("Encoder has to be a function.");var i=n.charset||E.charset;if(n.charset!==void 0&&n.charset!=="utf-8"&&n.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=I.default;if(n.format!==void 0){if(!T.call(I.formatters,n.format))throw new TypeError("Unknown format option provided.");t=n.format}var l=I.formatters[t],d=E.filter;return(typeof n.filter=="function"||A(n.filter))&&(d=n.filter),{addQueryPrefix:typeof n.addQueryPrefix=="boolean"?n.addQueryPrefix:E.addQueryPrefix,allowDots:n.allowDots===void 0?E.allowDots:!!n.allowDots,charset:i,charsetSentinel:typeof n.charsetSentinel=="boolean"?n.charsetSentinel:E.charsetSentinel,delimiter:n.delimiter===void 0?E.delimiter:n.delimiter,encode:typeof n.encode=="boolean"?n.encode:E.encode,encoder:typeof n.encoder=="function"?n.encoder:E.encoder,encodeValuesOnly:typeof n.encodeValuesOnly=="boolean"?n.encodeValuesOnly:E.encodeValuesOnly,filter:d,format:t,formatter:l,serializeDate:typeof n.serializeDate=="function"?n.serializeDate:E.serializeDate,skipNulls:typeof n.skipNulls=="boolean"?n.skipNulls:E.skipNulls,sort:typeof n.sort=="function"?n.sort:null,strictNullHandling:typeof n.strictNullHandling=="boolean"?n.strictNullHandling:E.strictNullHandling}};R.exports=function(n,i){var t,l,d=n,r=u(i);typeof r.filter=="function"?(l=r.filter,d=l("",d)):A(r.filter)&&(l=r.filter,t=l);var c=[];if(typeof d!="object"||d===null)return"";var f;f=i&&i.arrayFormat in _?i.arrayFormat:i&&"indices"in i?i.indices?"indices":"repeat":"indices";var o=_[f];t||(t=Object.keys(d)),r.sort&&t.sort(r.sort);for(var v=p(),m=0;m<t.length;++m){var O=t[m];r.skipNulls&&d[O]===null||L(c,s(d[O],O,o,r.strictNullHandling,r.skipNulls,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,v))}var b=c.join(r.delimiter),M=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?M+="utf8=%26%2310003%3B&":M+="utf8=%E2%9C%93&"),b.length>0?M+b:""}},function(R,h,P){"use strict";var p=P(8),x=P(47),I=P(49),T=p("%TypeError%"),_=p("%WeakMap%",!0),A=p("%Map%",!0),y=x("WeakMap.prototype.get",!0),D=x("WeakMap.prototype.set",!0),L=x("WeakMap.prototype.has",!0),S=x("Map.prototype.get",!0),g=x("Map.prototype.set",!0),E=x("Map.prototype.has",!0),a=function(n,i){for(var t,l=n;(t=l.next)!==null;l=t)if(t.key===i)return l.next=t.next,t.next=n.next,n.next=t,t},e=function(n,i){var t=a(n,i);return t&&t.value},s=function(n,i,t){var l=a(n,i);l?l.value=t:n.next={key:i,next:n.next,value:t}},u=function(n,i){return!!a(n,i)};R.exports=function(){var n,i,t,l={assert:function(d){if(!l.has(d))throw new T("Side channel does not contain "+I(d))},get:function(d){if(_&&d&&(typeof d=="object"||typeof d=="function")){if(n)return y(n,d)}else if(A){if(i)return S(i,d)}else if(t)return e(t,d)},has:function(d){if(_&&d&&(typeof d=="object"||typeof d=="function")){if(n)return L(n,d)}else if(A){if(i)return E(i,d)}else if(t)return u(t,d);return!1},set:function(d,r){_&&d&&(typeof d=="object"||typeof d=="function")?(n||(n=new _),D(n,d,r)):A?(i||(i=new A),g(i,d,r)):(t||(t={key:{},next:null}),s(t,d,r))}};return l}},function(R,h,P){"use strict";var p=typeof Symbol!="undefined"&&Symbol,x=P(44);R.exports=function(){return typeof p=="function"&&typeof Symbol=="function"&&typeof p("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&x()}},function(R,h,P){"use strict";R.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var p={},x=Symbol("test"),I=Object(x);if(typeof x=="string"||Object.prototype.toString.call(x)!=="[object Symbol]"||Object.prototype.toString.call(I)!=="[object Symbol]")return!1;p[x]=42;for(x in p)return!1;if(typeof Object.keys=="function"&&Object.keys(p).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(p).length!==0)return!1;var T=Object.getOwnPropertySymbols(p);if(T.length!==1||T[0]!==x||!Object.prototype.propertyIsEnumerable.call(p,x))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var _=Object.getOwnPropertyDescriptor(p,x);if(_.value!==42||_.enumerable!==!0)return!1}return!0}},function(R,h,P){"use strict";var p=Array.prototype.slice,x=Object.prototype.toString;R.exports=function(I){var T=this;if(typeof T!="function"||x.call(T)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+T);for(var _,A=p.call(arguments,1),y=function(){if(this instanceof _){var E=T.apply(this,A.concat(p.call(arguments)));return Object(E)===E?E:this}return T.apply(I,A.concat(p.call(arguments)))},D=Math.max(0,T.length-A.length),L=[],S=0;S<D;S++)L.push("$"+S);if(_=Function("binder","return function ("+L.join(",")+"){ return binder.apply(this,arguments); }")(y),T.prototype){var g=function(){};g.prototype=T.prototype,_.prototype=new g,g.prototype=null}return _}},function(R,h,P){"use strict";var p=P(9);R.exports=p.call(Function.call,Object.prototype.hasOwnProperty)},function(R,h,P){"use strict";var p=P(8),x=P(48),I=x(p("String.prototype.indexOf"));R.exports=function(T,_){var A=p(T,!!_);return typeof A=="function"&&I(T,".prototype.")>-1?x(A):A}},function(R,h,P){"use strict";var p=P(9),x=P(8),I=x("%Function.prototype.apply%"),T=x("%Function.prototype.call%"),_=x("%Reflect.apply%",!0)||p.call(T,I),A=x("%Object.getOwnPropertyDescriptor%",!0),y=x("%Object.defineProperty%",!0),D=x("%Math.max%");if(y)try{y({},"a",{value:1})}catch{y=null}R.exports=function(S){var g=_(p,T,arguments);return A&&y&&A(g,"length").configurable&&y(g,"length",{value:1+D(0,S.length-(arguments.length-1))}),g};var L=function(){return _(p,I,arguments)};y?y(R.exports,"apply",{value:L}):R.exports.apply=L},function(R,h,P){function p(W,G){if(W===1/0||W===-1/0||W!==W||W&&W>-1e3&&W<1e3||ue.call(/e/,G))return G;var oe=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof W=="number"){var de=W<0?-pe(-W):pe(W);if(de!==W){var ce=String(de),Se=te.call(G,ce.length+1);return ee.call(ce,oe,"$&_")+"."+ee.call(ee.call(Se,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ee.call(G,oe,"$&_")}function x(W,G,oe){var de=(oe.quoteStyle||G)==="double"?'"':"'";return de+W+de}function I(W){return ee.call(String(W),/"/g,""")}function T(W){return!(e(W)!=="[object Array]"||ve&&typeof W=="object"&&ve in W)}function _(W){return!(e(W)!=="[object Date]"||ve&&typeof W=="object"&&ve in W)}function A(W){return!(e(W)!=="[object RegExp]"||ve&&typeof W=="object"&&ve in W)}function y(W){return!(e(W)!=="[object Error]"||ve&&typeof W=="object"&&ve in W)}function D(W){return!(e(W)!=="[object String]"||ve&&typeof W=="object"&&ve in W)}function L(W){return!(e(W)!=="[object Number]"||ve&&typeof W=="object"&&ve in W)}function S(W){return!(e(W)!=="[object Boolean]"||ve&&typeof W=="object"&&ve in W)}function g(W){if(ge)return W&&typeof W=="object"&&W instanceof Symbol;if(typeof W=="symbol")return!0;if(!W||typeof W!="object"||!fe)return!1;try{return fe.call(W),!0}catch{}return!1}function E(W){if(!W||typeof W!="object"||!Ee)return!1;try{return Ee.call(W),!0}catch{}return!1}function a(W,G){return ye.call(W,G)}function e(W){return X.call(W)}function s(W){if(W.name)return W.name;var G=ne.call(le.call(W),/^function\s*([\w$]+)/);return G?G[1]:null}function u(W,G){if(W.indexOf)return W.indexOf(G);for(var oe=0,de=W.length;oe<de;oe++)if(W[oe]===G)return oe;return-1}function n(W){if(!U||!W||typeof W!="object")return!1;try{U.call(W);try{j.call(W)}catch{return!0}return W instanceof Map}catch{}return!1}function i(W){if(!Y||!W||typeof W!="object")return!1;try{Y.call(W,Y);try{J.call(W,J)}catch{return!0}return W instanceof WeakMap}catch{}return!1}function t(W){if(!q||!W||typeof W!="object")return!1;try{return q.call(W),!0}catch{}return!1}function l(W){if(!j||!W||typeof W!="object")return!1;try{j.call(W);try{U.call(W)}catch{return!0}return W instanceof Set}catch{}return!1}function d(W){if(!J||!W||typeof W!="object")return!1;try{J.call(W,J);try{Y.call(W,Y)}catch{return!0}return W instanceof WeakSet}catch{}return!1}function r(W){return!(!W||typeof W!="object")&&(typeof HTMLElement!="undefined"&&W instanceof HTMLElement||typeof W.nodeName=="string"&&typeof W.getAttribute=="function")}function c(W,G){if(W.length>G.maxStringLength){var oe=W.length-G.maxStringLength,de="... "+oe+" more character"+(oe>1?"s":"");return c(te.call(W,0,G.maxStringLength),G)+de}return x(ee.call(ee.call(W,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,f),"single",G)}function f(W){var G=W.charCodeAt(0),oe={8:"b",9:"t",10:"n",12:"f",13:"r"}[G];return oe?"\\"+oe:"\\x"+(G<16?"0":"")+$.call(G.toString(16))}function o(W){return"Object("+W+")"}function v(W){return W+" { ? }"}function m(W,G,oe,de){return W+" ("+G+") {"+(de?M(oe,de):se.call(oe,", "))+"}"}function O(W){for(var G=0;G<W.length;G++)if(u(W[G],`
|
|
2
2
|
`)>=0)return!1;return!0}function b(W,G){var oe;if(W.indent===" ")oe=" ";else{if(!(typeof W.indent=="number"&&W.indent>0))return null;oe=se.call(Array(W.indent+1)," ")}return{base:oe,prev:se.call(Array(G+1),oe)}}function M(W,G){if(W.length===0)return"";var oe=`
|
|
3
3
|
`+G.prev+G.base;return oe+se.call(W,","+oe)+`
|
|
4
|
-
`+G.prev}function F(W,G){var oe=x(W),de=[];if(oe){de.length=W.length;for(var ce=0;ce<W.length;ce++)de[ce]=a(W,ce)?G(W[ce],W):""}var Se,ie=typeof ae=="function"?ae(W):[];if(ge){Se={};for(var Ae=0;Ae<ie.length;Ae++)Se["$"+ie[Ae]]=ie[Ae]}for(var De in W)a(W,De)&&(oe&&String(Number(De))===De&&De<W.length||ge&&Se["$"+De]instanceof Symbol||(ue.call(/[^\w$]/,De)?de.push(G(De,W)+": "+G(W[De],W)):de.push(De+": "+G(W[De],W))));if(typeof ae=="function")for(var Le=0;Le<ie.length;Le++)Te.call(W,ie[Le])&&de.push("["+G(ie[Le])+"]: "+G(W[ie[Le]],W));return de}var w=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&w?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,U=w&&C&&typeof C.get=="function"?C.get:null,B=w&&Map.prototype.forEach,N=typeof Set=="function"&&Set.prototype,k=Object.getOwnPropertyDescriptor&&N?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,j=N&&k&&typeof k.get=="function"?k.get:null,H=N&&Set.prototype.forEach,V=typeof WeakMap=="function"&&WeakMap.prototype,Y=V?WeakMap.prototype.has:null,Q=typeof WeakSet=="function"&&WeakSet.prototype,J=Q?WeakSet.prototype.has:null,z=typeof WeakRef=="function"&&WeakRef.prototype,q=z?WeakRef.prototype.deref:null,re=Boolean.prototype.valueOf,X=Object.prototype.toString,le=Function.prototype.toString,ne=String.prototype.match,te=String.prototype.slice,ee=String.prototype.replace,$=String.prototype.toUpperCase,Z=String.prototype.toLowerCase,ue=RegExp.prototype.test,he=Array.prototype.concat,se=Array.prototype.join,me=Array.prototype.slice,pe=Math.floor,Ee=typeof BigInt=="function"?BigInt.prototype.valueOf:null,ae=Object.getOwnPropertySymbols,fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ge=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ve=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ge?"object":"symbol")?Symbol.toStringTag:null,Te=Object.prototype.propertyIsEnumerable,_e=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(W){return W.__proto__}:null),Oe=R(50).custom,xe=Oe&&g(Oe)?Oe:null;P.exports=function W(G,oe,de,ce){function Se(Ke,et,Ft){if(et&&(ce=me.call(ce),ce.push(et)),Ft){var mt={depth:ie.depth};return a(ie,"quoteStyle")&&(mt.quoteStyle=ie.quoteStyle),W(Ke,mt,de+1,ce)}return W(Ke,ie,de+1,ce)}var ie=oe||{};if(a(ie,"quoteStyle")&&ie.quoteStyle!=="single"&&ie.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(a(ie,"maxStringLength")&&(typeof ie.maxStringLength=="number"?ie.maxStringLength<0&&ie.maxStringLength!==1/0:ie.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ae=!a(ie,"customInspect")||ie.customInspect;if(typeof Ae!="boolean"&&Ae!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(a(ie,"indent")&&ie.indent!==null&&ie.indent!==" "&&!(parseInt(ie.indent,10)===ie.indent&&ie.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(a(ie,"numericSeparator")&&typeof ie.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var De=ie.numericSeparator;if(G===void 0)return"undefined";if(G===null)return"null";if(typeof G=="boolean")return G?"true":"false";if(typeof G=="string")return c(G,ie);if(typeof G=="number"){if(G===0)return 1/0/G>0?"0":"-0";var Le=String(G);return De?p(G,Le):Le}if(typeof G=="bigint"){var Ce=String(G)+"n";return De?p(G,Ce):Ce}var Pe=ie.depth===void 0?5:ie.depth;if(de===void 0&&(de=0),de>=Pe&&Pe>0&&typeof G=="object")return x(G)?"[Array]":"[Object]";var Ie=b(ie,de);if(ce===void 0)ce=[];else if(u(ce,G)>=0)return"[Circular]";if(typeof G=="function"){var Ve=s(G),Be=F(G,Se);return"[Function"+(Ve?": "+Ve:" (anonymous)")+"]"+(Be.length>0?" { "+se.call(Be,", ")+" }":"")}if(g(G)){var Re=ge?ee.call(String(G),/^(Symbol\(.*\))_[^)]*$/,"$1"):fe.call(G);return typeof G!="object"||ge?Re:o(Re)}if(r(G)){for(var Fe="<"+Z.call(String(G.nodeName)),ke=G.attributes||[],Ne=0;Ne<ke.length;Ne++)Fe+=" "+ke[Ne].name+"="+S(I(ke[Ne].value),"double",ie);return Fe+=">",G.childNodes&&G.childNodes.length&&(Fe+="..."),Fe+="</"+Z.call(String(G.nodeName))+">"}if(x(G)){if(G.length===0)return"[]";var Ye=F(G,Se);return Ie&&!O(Ye)?"["+M(Ye,Ie)+"]":"[ "+se.call(Ye,", ")+" ]"}if(y(G)){var ze=F(G,Se);return"cause"in G&&!Te.call(G,"cause")?"{ ["+String(G)+"] "+se.call(he.call("[cause]: "+Se(G.cause),ze),", ")+" }":ze.length===0?"["+String(G)+"]":"{ ["+String(G)+"] "+se.call(ze,", ")+" }"}if(typeof G=="object"&&Ae){if(xe&&typeof G[xe]=="function")return G[xe]();if(Ae!=="symbol"&&typeof G.inspect=="function")return G.inspect()}if(n(G)){var $e=[];return B.call(G,function(Ke,et){$e.push(Se(et,G,!0)+" => "+Se(Ke,G))}),m("Map",U.call(G),$e,Ie)}if(l(G)){var Ze=[];return H.call(G,function(Ke){Ze.push(Se(Ke,G))}),m("Set",j.call(G),Ze,Ie)}if(i(G))return v("WeakMap");if(d(G))return v("WeakSet");if(t(G))return v("WeakRef");if(_(G))return o(Se(Number(G)));if(E(G))return o(Se(Ee.call(G)));if(T(G))return o(re.call(G));if(D(G))return o(Se(String(G)));if(!L(G)&&!A(G)){var we=F(G,Se),Xe=_e?_e(G)===Object.prototype:G instanceof Object||G.constructor===Object,Qe=G instanceof Object?"":"null prototype",qe=!Xe&&ve&&Object(G)===G&&ve in G?te.call(e(G),8,-1):Qe?"Object":"",Ct=Xe||typeof G.constructor!="function"?"":G.constructor.name?G.constructor.name+" ":"",nt=Ct+(qe||Qe?"["+se.call(he.call([],qe||[],Qe||[]),": ")+"] ":"");return we.length===0?nt+"{}":Ie?nt+"{"+M(we,Ie)+"}":nt+"{ "+se.call(we,", ")+" }"}return String(G)};var ye=Object.prototype.hasOwnProperty||function(W){return W in this}},function(P,h){},function(P,h,R){"use strict";var p=R(16),S=Object.prototype.hasOwnProperty,I=Array.isArray,x={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:p.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},L=function(g){return g.replace(/&#(\d+);/g,function(E,a){return String.fromCharCode(parseInt(a,10))})},A=function(g,E){return g&&typeof g=="string"&&E.comma&&g.indexOf(",")>-1?g.split(","):g},y=function(g,E){var a,e={},s=E.ignoreQueryPrefix?g.replace(/^\?/,""):g,u=E.parameterLimit===1/0?void 0:E.parameterLimit,n=s.split(E.delimiter,u),i=-1,t=E.charset;if(E.charsetSentinel)for(a=0;a<n.length;++a)n[a].indexOf("utf8=")===0&&(n[a]==="utf8=%E2%9C%93"?t="utf-8":n[a]==="utf8=%26%2310003%3B"&&(t="iso-8859-1"),i=a,a=n.length);for(a=0;a<n.length;++a)if(a!==i){var l,d,r=n[a],c=r.indexOf("]="),f=c===-1?r.indexOf("="):c+1;f===-1?(l=E.decoder(r,x.decoder,t,"key"),d=E.strictNullHandling?null:""):(l=E.decoder(r.slice(0,f),x.decoder,t,"key"),d=p.maybeMap(A(r.slice(f+1),E),function(o){return E.decoder(o,x.decoder,t,"value")})),d&&E.interpretNumericEntities&&t==="iso-8859-1"&&(d=L(d)),r.indexOf("[]=")>-1&&(d=I(d)?[d]:d),S.call(e,l)?e[l]=p.combine(e[l],d):e[l]=d}return e},D=function(g,E,a,e){for(var s=e?E:A(E,a),u=g.length-1;u>=0;--u){var n,i=g[u];if(i==="[]"&&a.parseArrays)n=[].concat(s);else{n=a.plainObjects?Object.create(null):{};var t=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,l=parseInt(t,10);a.parseArrays||t!==""?!isNaN(l)&&i!==t&&String(l)===t&&l>=0&&a.parseArrays&&l<=a.arrayLimit?(n=[],n[l]=s):t!=="__proto__"&&(n[t]=s):n={0:s}}s=n}return s},_=function(g,E,a,e){if(g){var s=a.allowDots?g.replace(/\.([^.[]+)/g,"[$1]"):g,u=/(\[[^[\]]*])/,n=/(\[[^[\]]*])/g,i=a.depth>0&&u.exec(s),t=i?s.slice(0,i.index):s,l=[];if(t){if(!a.plainObjects&&S.call(Object.prototype,t)&&!a.allowPrototypes)return;l.push(t)}for(var d=0;a.depth>0&&(i=n.exec(s))!==null&&d<a.depth;){if(d+=1,!a.plainObjects&&S.call(Object.prototype,i[1].slice(1,-1))&&!a.allowPrototypes)return;l.push(i[1])}return i&&l.push("["+s.slice(i.index)+"]"),D(l,E,a,e)}},T=function(g){if(!g)return x;if(g.decoder!==null&&g.decoder!==void 0&&typeof g.decoder!="function")throw new TypeError("Decoder has to be a function.");if(g.charset!==void 0&&g.charset!=="utf-8"&&g.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var E=g.charset===void 0?x.charset:g.charset;return{allowDots:g.allowDots===void 0?x.allowDots:!!g.allowDots,allowPrototypes:typeof g.allowPrototypes=="boolean"?g.allowPrototypes:x.allowPrototypes,allowSparse:typeof g.allowSparse=="boolean"?g.allowSparse:x.allowSparse,arrayLimit:typeof g.arrayLimit=="number"?g.arrayLimit:x.arrayLimit,charset:E,charsetSentinel:typeof g.charsetSentinel=="boolean"?g.charsetSentinel:x.charsetSentinel,comma:typeof g.comma=="boolean"?g.comma:x.comma,decoder:typeof g.decoder=="function"?g.decoder:x.decoder,delimiter:typeof g.delimiter=="string"||p.isRegExp(g.delimiter)?g.delimiter:x.delimiter,depth:typeof g.depth=="number"||g.depth===!1?+g.depth:x.depth,ignoreQueryPrefix:g.ignoreQueryPrefix===!0,interpretNumericEntities:typeof g.interpretNumericEntities=="boolean"?g.interpretNumericEntities:x.interpretNumericEntities,parameterLimit:typeof g.parameterLimit=="number"?g.parameterLimit:x.parameterLimit,parseArrays:g.parseArrays!==!1,plainObjects:typeof g.plainObjects=="boolean"?g.plainObjects:x.plainObjects,strictNullHandling:typeof g.strictNullHandling=="boolean"?g.strictNullHandling:x.strictNullHandling}};P.exports=function(g,E){var a=T(E);if(g===""||g===null||g===void 0)return a.plainObjects?Object.create(null):{};for(var e=typeof g=="string"?y(g,a):g,s=a.plainObjects?Object.create(null):{},u=Object.keys(e),n=0;n<u.length;++n){var i=u[n],t=_(i,e[i],a,typeof g=="string");s=p.merge(s,t,a)}return a.allowSparse===!0?s:p.compact(s)}},function(P,h,R){"use strict";var p,S,I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(x){return typeof x}:function(x){return x&&typeof Symbol=="function"&&x.constructor===Symbol&&x!==Symbol.prototype?"symbol":typeof x};(function(x){var L=!1;if(p=x,(S=typeof p=="function"?p.call(h,R,h,P):p)!==void 0&&(P.exports=S),L=!0,I(h)==="object"&&(P.exports=x(),L=!0),!L){var A=window.Cookies,y=window.Cookies=x();y.noConflict=function(){return window.Cookies=A,y}}})(function(){function x(A){function y(D,_,T){var g;if(typeof document!="undefined"){if(arguments.length>1){if(T=L({path:"/"},y.defaults,T),typeof T.expires=="number"){var E=new Date;E.setMilliseconds(E.getMilliseconds()+864e5*T.expires),T.expires=E}try{g=JSON.stringify(_),/^[\{\[]/.test(g)&&(_=g)}catch{}return _=A.write?A.write(_,D):encodeURIComponent(String(_)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),D=encodeURIComponent(String(D)),D=D.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),D=D.replace(/[\(\)]/g,escape),document.cookie=[D,"=",_,T.expires?"; expires="+T.expires.toUTCString():"",T.path?"; path="+T.path:"",T.domain?"; domain="+T.domain:"",T.secure?"; secure":""].join("")}D||(g={});for(var a=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,s=0;s<a.length;s++){var u=a[s].split("="),n=u.slice(1).join("=");n.charAt(0)==='"'&&(n=n.slice(1,-1));try{var i=u[0].replace(e,decodeURIComponent);if(n=A.read?A.read(n,i):A(n,i)||n.replace(e,decodeURIComponent),this.json)try{n=JSON.parse(n)}catch{}if(D===i){g=n;break}D||(g[i]=n)}catch{}}return g}}return y.set=y,y.get=function(D){return y.call(y,D)},y.getJSON=function(){return y.apply({json:!0},[].slice.call(arguments))},y.defaults={},y.remove=function(D,_){y(D,"",L(_,{expires:-1}))},y.withConverter=x,y}var L=function(){for(var A=0,y={};A<arguments.length;A++){var D=arguments[A];for(var _ in D)y[_]=D[_]}return y};return x(function(){})})},function(P,h,R){"use strict";function p(S,I){var x=I.beaconCollectionDomain,L=I.beaconDomain;if(x)return"https://"+x;S=S||"inferred";var A=L||"litix.io";return S.match(/^[a-z0-9]+$/)?"https://"+S+"."+A:"https://img.litix.io/a.gif"}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=R(0),S=function(L){return L&&L.__esModule?L:{default:L}}(p),I=function(){var L=void 0;switch(x()){case"cellular":L="cellular";break;case"ethernet":L="wired";break;case"wifi":L="wifi";break;case void 0:break;default:L="other"}return L},x=function(){var L=S.default.navigator,A=L&&(L.connection||L.mozConnection||L.webkitConnection);return A&&A.type};h.default=I},function(P,h,R){"use strict";function p(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(0),I=p(S),x=R(4),L=p(x),A=R(56),y=p(A),D=R(1),_=p(D),T=R(17),g=p(T),E=R(2),a=p(E),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,s={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},u=function(n,i){this._beaconUrl=n||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,_.default)({},s,i)};u.prototype.queueEvent=function(n,i){var t=(0,_.default)({},i);return e?(this._eventQueue.length<=this._options.maxQueueLength||n==="eventrateexceeded")&&(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(y.default.send(this._beaconUrl,t),!0)},u.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},u.prototype.destroy=function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,n?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},u.prototype._clearBeaconQueue=function(){var n=I.default.navigator,i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,t=this._eventQueue.slice(i);i>0&&(0,_.default)(t[t.length-1],(0,g.default)({mux_view_message:"event queue truncated"}));var l=this._createPayload(t);if(n.sendBeacon)n.sendBeacon(this._beaconUrl,l);else if(I.default.XMLHttpRequest){var d=new I.default.XMLHttpRequest;d.open("POST",this._beaconUrl),d.setRequestHeader("Content-Type","application/json"),d.send(l)}else y.default.send(this._beaconUrl,t[t.length-1])},u.prototype._sendBeaconQueue=function(){var n=this;if(I.default.XMLHttpRequest&&!this._postInFlight){var i=new I.default.XMLHttpRequest,t=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,i.onreadystatechange=function(){i.readyState===4&&(i.status!==200?(n._eventQueue=t.concat(n._eventQueue),n._failureCount+=1,L.default.info("Error sending beacon: "+i.status),L.default.info(i.responseText)):n._failureCount=0,n._roundTripTime=a.default.now()-d,n._postInFlight=!1)},i.open("POST",this._beaconUrl),i.setRequestHeader("Content-Type","application/json");var l=this._createPayload(t),d=a.default.now();i.send(l)}},u.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var n=Math.pow(2,this._failureCount-1);return(1+(n*=Math.random()))*this._options.baseTimeBetweenBeacons},u.prototype._startBeaconSending=function(){var n=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){n._eventQueue.length&&n._sendBeaconQueue(),n._startBeaconSending()},this._getNextBeaconTime()))},u.prototype._createPayload=function(n){var i={transmission_timestamp:Math.round(a.default.now())};return this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:i,events:n})},h.default=u},function(P,h,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(15),I=p(S),x=R(0),L=p(x),A={};A.send=function(y,D){function _(){T.src=E+(g?"&rc="+g:"")}var T=new Image,g=0,E=y+"?"+I.default.stringify(D);return T.addEventListener("error",function(){g>3||L.default.setTimeout(function(){g++,_()},5e3*g)}),_(),T},h.default=A},function(P,h,R){"use strict";function p(){function S(E,a){var e=a.request_start,s=a.request_response_start,u=a.request_response_end,n=a.request_bytes_loaded;D++;var i=void 0,t=void 0;if(s?(i=s-e,t=u-s):t=u-e,t>0&&n>0){var l=n/t*8e3;_++,A+=n,y+=t,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,l),this.data.view_average_request_throughput=A/y*8e3,this.data.view_request_count=D,i>0&&(L+=i,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,i),this.data.view_average_request_latency=L/_)}}function I(E,a){D++,T++,this.data.view_request_count=D,this.data.view_request_failed_count=T}function x(E,a){D++,g++,this.data.view_request_count=D,this.data.view_request_canceled_count=g}var L=0,A=0,y=0,D=0,_=0,T=0,g=0;this.on("requestcompleted",S),this.on("requestfailed",I),this.on("requestcanceled",x)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";function p(_,T,g){var E=(0,A.findMediaElement)(T),a=I(E,3),e=a[0],s=a[1],u=a[2],n=_.log,i=_.utils.getComputedStyle,t=_.utils.secondsToMs,l={automaticErrorTracking:!0};if(!e)return n.error("No element was found with the `"+s+"` query selector.");if(u!=="video"&&u!=="audio")return n.error("The element of `"+s+"` was not a media element.");g=(0,L.default)(l,g),g.data=(0,L.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},g.data),g.getPlayheadTime=function(){return t(e.currentTime)},g.getStateData=function(){var r=this.hlsjs&&this.hlsjs.url,c=this.dashjs&&S(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:e.paused,player_playhead_time:t(e.currentTime),player_width:parseInt(i(e,"width")),player_height:parseInt(i(e,"height")),player_autoplay_on:e.autoplay,player_preload_on:e.preload,video_poster_url:e.poster,video_source_url:r||c||e.currentSrc,video_source_duration:t(e.duration),video_source_height:e.videoHeight,video_source_width:e.videoWidth}},e.mux=e.mux||{},e.mux.deleted=!1,e.mux.emit=function(r,c){_.emit(s,r,c)};var d=function(){n.error("The monitor for this video element has already been destroyed.")};e.mux.destroy=function(){Object.keys(e.mux.listeners).forEach(function(r){e.removeEventListener(r,e.mux.listeners[r],!1)}),delete e.mux.listeners,e.mux.destroy=d,e.mux.swapElement=d,e.mux.emit=d,e.mux.addHLSJS=d,e.mux.addDashJS=d,e.mux.removeHLSJS=d,e.mux.removeDashJS=d,e.mux.deleted=!0,_.emit(s,"destroy")},e.mux.swapElement=function(r){var c=(0,A.findMediaElement)(r),f=I(c,3),o=f[0],v=f[1],m=f[2];return o?m!=="video"&&m!=="audio"?_.log.error("The element of `"+v+"` was not a media element."):(o.muxId=e.muxId,delete e.muxId,o.mux=o.mux||{},o.mux.listeners=(0,L.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(o.mux.listeners).forEach(function(O){e.removeEventListener(O,o.mux.listeners[O],!1),o.addEventListener(O,o.mux.listeners[O],!1)}),o.mux.swapElement=e.mux.swapElement,o.mux.destroy=e.mux.destroy,delete e.mux,void(e=o)):_.log.error("No element was found with the `"+v+"` query selector.")},e.mux.addHLSJS=function(r){_.addHLSJS(s,r)},e.mux.addDashJS=function(r){_.addDashJS(s,r)},e.mux.removeHLSJS=function(){_.removeHLSJS(s)},e.mux.removeDashJS=function(){_.removeDashJS(s)},_.init(s,g),_.emit(s,"playerready"),e.paused||(_.emit(s,"play"),e.readyState>2&&_.emit(s,"playing")),e.mux.listeners={},y.forEach(function(r){(r!=="error"||g.automaticErrorTracking)&&(e.mux.listeners[r]=function(){var c={};if(r==="error"){if(!e.error||e.error.code===1)return;c.player_error_code=e.error.code,c.player_error_message=D[e.error.code]||e.error.message}_.emit(s,r,c)},e.addEventListener(r,e.mux.listeners[r],!1))})}Object.defineProperty(h,"__esModule",{value:!0});var S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},I=function(){function _(T,g){var E=[],a=!0,e=!1,s=void 0;try{for(var u,n=T[Symbol.iterator]();!(a=(u=n.next()).done)&&(E.push(u.value),!g||E.length!==g);a=!0);}catch(i){e=!0,s=i}finally{try{!a&&n.return&&n.return()}finally{if(e)throw s}}return E}return function(T,g){if(Array.isArray(T))return T;if(Symbol.iterator in Object(T))return _(T,g);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();h.default=p;var x=R(1),L=function(_){return _&&_.__esModule?_:{default:_}}(x),A=R(11),y=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],D={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(P,h,R){"use strict";function p(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(60),I=p(S),x=R(3),L=p(x),A=R(61),y=p(A),D=R(62),_=p(D),T=R(1),g=p(T),E=R(7),a=p(E),e=R(5),s=R(2),u=p(s),n=R(63),i=p(n),t={};t.safeCall=I.default,t.safeIncrement=L.default,t.getComputedStyle=y.default,t.secondsToMs=_.default,t.assign=g.default,t.headersStringToObject=a.default,t.extractHostnameAndDomain=e.extractHostnameAndDomain,t.extractHostname=e.extractHostname,t.now=u.default.now,t.manifestParser=i.default,h.default=t},function(P,h,R){"use strict";function p(x,L,A,y){var D=y;if(x&&typeof x[L]=="function")try{D=x[L].apply(x,A)}catch(_){I.default.info("safeCall error",_)}return D}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(4),I=function(x){return x&&x.__esModule?x:{default:x}}(S)},function(P,h,R){"use strict";function p(L,A){if(L&&A&&I.default&&typeof I.default.getComputedStyle=="function"){var y=void 0;return x&&x.has(L)&&(y=x.get(L)),y||(y=I.default.getComputedStyle(L,null),x&&x.set(L,y)),y.getPropertyValue(A)}}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var S=R(0),I=function(L){return L&&L.__esModule?L:{default:L}}(S),x=void 0;I.default&&I.default.WeakMap&&(x=new WeakMap)},function(P,h,R){"use strict";function p(S){return Math.floor(1e3*S)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(P,h,R){"use strict";function p(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(h,"__esModule",{value:!0});var S=R(1),I=p(S),x=R(14),L=p(x),A={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},y=function(u){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(u),this.manifest};y.prototype.process=function(u){var n=void 0;for(this.buffer+=u,n=this.buffer.indexOf(`
|
|
4
|
+
`+G.prev}function F(W,G){var oe=T(W),de=[];if(oe){de.length=W.length;for(var ce=0;ce<W.length;ce++)de[ce]=a(W,ce)?G(W[ce],W):""}var Se,ie=typeof ae=="function"?ae(W):[];if(ge){Se={};for(var Ae=0;Ae<ie.length;Ae++)Se["$"+ie[Ae]]=ie[Ae]}for(var De in W)a(W,De)&&(oe&&String(Number(De))===De&&De<W.length||ge&&Se["$"+De]instanceof Symbol||(ue.call(/[^\w$]/,De)?de.push(G(De,W)+": "+G(W[De],W)):de.push(De+": "+G(W[De],W))));if(typeof ae=="function")for(var _e=0;_e<ie.length;_e++)Te.call(W,ie[_e])&&de.push("["+G(ie[_e])+"]: "+G(W[ie[_e]],W));return de}var w=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&w?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,U=w&&C&&typeof C.get=="function"?C.get:null,B=w&&Map.prototype.forEach,N=typeof Set=="function"&&Set.prototype,k=Object.getOwnPropertyDescriptor&&N?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,j=N&&k&&typeof k.get=="function"?k.get:null,H=N&&Set.prototype.forEach,V=typeof WeakMap=="function"&&WeakMap.prototype,Y=V?WeakMap.prototype.has:null,Q=typeof WeakSet=="function"&&WeakSet.prototype,J=Q?WeakSet.prototype.has:null,z=typeof WeakRef=="function"&&WeakRef.prototype,q=z?WeakRef.prototype.deref:null,re=Boolean.prototype.valueOf,X=Object.prototype.toString,le=Function.prototype.toString,ne=String.prototype.match,te=String.prototype.slice,ee=String.prototype.replace,$=String.prototype.toUpperCase,Z=String.prototype.toLowerCase,ue=RegExp.prototype.test,he=Array.prototype.concat,se=Array.prototype.join,me=Array.prototype.slice,pe=Math.floor,Ee=typeof BigInt=="function"?BigInt.prototype.valueOf:null,ae=Object.getOwnPropertySymbols,fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ge=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ve=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ge?"object":"symbol")?Symbol.toStringTag:null,Te=Object.prototype.propertyIsEnumerable,Le=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(W){return W.__proto__}:null),Oe=P(50).custom,xe=Oe&&g(Oe)?Oe:null;R.exports=function W(G,oe,de,ce){function Se(je,tt,kt){if(tt&&(ce=me.call(ce),ce.push(tt)),kt){var pt={depth:ie.depth};return a(ie,"quoteStyle")&&(pt.quoteStyle=ie.quoteStyle),W(je,pt,de+1,ce)}return W(je,ie,de+1,ce)}var ie=oe||{};if(a(ie,"quoteStyle")&&ie.quoteStyle!=="single"&&ie.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(a(ie,"maxStringLength")&&(typeof ie.maxStringLength=="number"?ie.maxStringLength<0&&ie.maxStringLength!==1/0:ie.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ae=!a(ie,"customInspect")||ie.customInspect;if(typeof Ae!="boolean"&&Ae!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(a(ie,"indent")&&ie.indent!==null&&ie.indent!==" "&&!(parseInt(ie.indent,10)===ie.indent&&ie.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(a(ie,"numericSeparator")&&typeof ie.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var De=ie.numericSeparator;if(G===void 0)return"undefined";if(G===null)return"null";if(typeof G=="boolean")return G?"true":"false";if(typeof G=="string")return c(G,ie);if(typeof G=="number"){if(G===0)return 1/0/G>0?"0":"-0";var _e=String(G);return De?p(G,_e):_e}if(typeof G=="bigint"){var Ce=String(G)+"n";return De?p(G,Ce):Ce}var Re=ie.depth===void 0?5:ie.depth;if(de===void 0&&(de=0),de>=Re&&Re>0&&typeof G=="object")return T(G)?"[Array]":"[Object]";var Ie=b(ie,de);if(ce===void 0)ce=[];else if(u(ce,G)>=0)return"[Circular]";if(typeof G=="function"){var Ve=s(G),ke=F(G,Se);return"[Function"+(Ve?": "+Ve:" (anonymous)")+"]"+(ke.length>0?" { "+se.call(ke,", ")+" }":"")}if(g(G)){var Pe=ge?ee.call(String(G),/^(Symbol\(.*\))_[^)]*$/,"$1"):fe.call(G);return typeof G!="object"||ge?Pe:o(Pe)}if(r(G)){for(var Fe="<"+Z.call(String(G.nodeName)),Ne=G.attributes||[],Ke=0;Ke<Ne.length;Ke++)Fe+=" "+Ne[Ke].name+"="+x(I(Ne[Ke].value),"double",ie);return Fe+=">",G.childNodes&&G.childNodes.length&&(Fe+="..."),Fe+="</"+Z.call(String(G.nodeName))+">"}if(T(G)){if(G.length===0)return"[]";var Ye=F(G,Se);return Ie&&!O(Ye)?"["+M(Ye,Ie)+"]":"[ "+se.call(Ye,", ")+" ]"}if(y(G)){var ze=F(G,Se);return"cause"in G&&!Te.call(G,"cause")?"{ ["+String(G)+"] "+se.call(he.call("[cause]: "+Se(G.cause),ze),", ")+" }":ze.length===0?"["+String(G)+"]":"{ ["+String(G)+"] "+se.call(ze,", ")+" }"}if(typeof G=="object"&&Ae){if(xe&&typeof G[xe]=="function")return G[xe]();if(Ae!=="symbol"&&typeof G.inspect=="function")return G.inspect()}if(n(G)){var Ze=[];return B.call(G,function(je,tt){Ze.push(Se(tt,G,!0)+" => "+Se(je,G))}),m("Map",U.call(G),Ze,Ie)}if(l(G)){var qe=[];return H.call(G,function(je){qe.push(Se(je,G))}),m("Set",j.call(G),qe,Ie)}if(i(G))return v("WeakMap");if(d(G))return v("WeakSet");if(t(G))return v("WeakRef");if(L(G))return o(Se(Number(G)));if(E(G))return o(Se(Ee.call(G)));if(S(G))return o(re.call(G));if(D(G))return o(Se(String(G)));if(!_(G)&&!A(G)){var we=F(G,Se),Xe=Le?Le(G)===Object.prototype:G instanceof Object||G.constructor===Object,Qe=G instanceof Object?"":"null prototype",et=!Xe&&ve&&Object(G)===G&&ve in G?te.call(e(G),8,-1):Qe?"Object":"",Bt=Xe||typeof G.constructor!="function"?"":G.constructor.name?G.constructor.name+" ":"",ot=Bt+(et||Qe?"["+se.call(he.call([],et||[],Qe||[]),": ")+"] ":"");return we.length===0?ot+"{}":Ie?ot+"{"+M(we,Ie)+"}":ot+"{ "+se.call(we,", ")+" }"}return String(G)};var ye=Object.prototype.hasOwnProperty||function(W){return W in this}},function(R,h){},function(R,h,P){"use strict";var p=P(16),x=Object.prototype.hasOwnProperty,I=Array.isArray,T={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:p.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},_=function(g){return g.replace(/&#(\d+);/g,function(E,a){return String.fromCharCode(parseInt(a,10))})},A=function(g,E){return g&&typeof g=="string"&&E.comma&&g.indexOf(",")>-1?g.split(","):g},y=function(g,E){var a,e={},s=E.ignoreQueryPrefix?g.replace(/^\?/,""):g,u=E.parameterLimit===1/0?void 0:E.parameterLimit,n=s.split(E.delimiter,u),i=-1,t=E.charset;if(E.charsetSentinel)for(a=0;a<n.length;++a)n[a].indexOf("utf8=")===0&&(n[a]==="utf8=%E2%9C%93"?t="utf-8":n[a]==="utf8=%26%2310003%3B"&&(t="iso-8859-1"),i=a,a=n.length);for(a=0;a<n.length;++a)if(a!==i){var l,d,r=n[a],c=r.indexOf("]="),f=c===-1?r.indexOf("="):c+1;f===-1?(l=E.decoder(r,T.decoder,t,"key"),d=E.strictNullHandling?null:""):(l=E.decoder(r.slice(0,f),T.decoder,t,"key"),d=p.maybeMap(A(r.slice(f+1),E),function(o){return E.decoder(o,T.decoder,t,"value")})),d&&E.interpretNumericEntities&&t==="iso-8859-1"&&(d=_(d)),r.indexOf("[]=")>-1&&(d=I(d)?[d]:d),x.call(e,l)?e[l]=p.combine(e[l],d):e[l]=d}return e},D=function(g,E,a,e){for(var s=e?E:A(E,a),u=g.length-1;u>=0;--u){var n,i=g[u];if(i==="[]"&&a.parseArrays)n=[].concat(s);else{n=a.plainObjects?Object.create(null):{};var t=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,l=parseInt(t,10);a.parseArrays||t!==""?!isNaN(l)&&i!==t&&String(l)===t&&l>=0&&a.parseArrays&&l<=a.arrayLimit?(n=[],n[l]=s):t!=="__proto__"&&(n[t]=s):n={0:s}}s=n}return s},L=function(g,E,a,e){if(g){var s=a.allowDots?g.replace(/\.([^.[]+)/g,"[$1]"):g,u=/(\[[^[\]]*])/,n=/(\[[^[\]]*])/g,i=a.depth>0&&u.exec(s),t=i?s.slice(0,i.index):s,l=[];if(t){if(!a.plainObjects&&x.call(Object.prototype,t)&&!a.allowPrototypes)return;l.push(t)}for(var d=0;a.depth>0&&(i=n.exec(s))!==null&&d<a.depth;){if(d+=1,!a.plainObjects&&x.call(Object.prototype,i[1].slice(1,-1))&&!a.allowPrototypes)return;l.push(i[1])}return i&&l.push("["+s.slice(i.index)+"]"),D(l,E,a,e)}},S=function(g){if(!g)return T;if(g.decoder!==null&&g.decoder!==void 0&&typeof g.decoder!="function")throw new TypeError("Decoder has to be a function.");if(g.charset!==void 0&&g.charset!=="utf-8"&&g.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var E=g.charset===void 0?T.charset:g.charset;return{allowDots:g.allowDots===void 0?T.allowDots:!!g.allowDots,allowPrototypes:typeof g.allowPrototypes=="boolean"?g.allowPrototypes:T.allowPrototypes,allowSparse:typeof g.allowSparse=="boolean"?g.allowSparse:T.allowSparse,arrayLimit:typeof g.arrayLimit=="number"?g.arrayLimit:T.arrayLimit,charset:E,charsetSentinel:typeof g.charsetSentinel=="boolean"?g.charsetSentinel:T.charsetSentinel,comma:typeof g.comma=="boolean"?g.comma:T.comma,decoder:typeof g.decoder=="function"?g.decoder:T.decoder,delimiter:typeof g.delimiter=="string"||p.isRegExp(g.delimiter)?g.delimiter:T.delimiter,depth:typeof g.depth=="number"||g.depth===!1?+g.depth:T.depth,ignoreQueryPrefix:g.ignoreQueryPrefix===!0,interpretNumericEntities:typeof g.interpretNumericEntities=="boolean"?g.interpretNumericEntities:T.interpretNumericEntities,parameterLimit:typeof g.parameterLimit=="number"?g.parameterLimit:T.parameterLimit,parseArrays:g.parseArrays!==!1,plainObjects:typeof g.plainObjects=="boolean"?g.plainObjects:T.plainObjects,strictNullHandling:typeof g.strictNullHandling=="boolean"?g.strictNullHandling:T.strictNullHandling}};R.exports=function(g,E){var a=S(E);if(g===""||g===null||g===void 0)return a.plainObjects?Object.create(null):{};for(var e=typeof g=="string"?y(g,a):g,s=a.plainObjects?Object.create(null):{},u=Object.keys(e),n=0;n<u.length;++n){var i=u[n],t=L(i,e[i],a,typeof g=="string");s=p.merge(s,t,a)}return a.allowSparse===!0?s:p.compact(s)}},function(R,h,P){"use strict";var p,x,I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(T){return typeof T}:function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T};(function(T){var _=!1;if(p=T,(x=typeof p=="function"?p.call(h,P,h,R):p)!==void 0&&(R.exports=x),_=!0,I(h)==="object"&&(R.exports=T(),_=!0),!_){var A=window.Cookies,y=window.Cookies=T();y.noConflict=function(){return window.Cookies=A,y}}})(function(){function T(A){function y(D,L,S){var g;if(typeof document!="undefined"){if(arguments.length>1){if(S=_({path:"/"},y.defaults,S),typeof S.expires=="number"){var E=new Date;E.setMilliseconds(E.getMilliseconds()+864e5*S.expires),S.expires=E}try{g=JSON.stringify(L),/^[\{\[]/.test(g)&&(L=g)}catch{}return L=A.write?A.write(L,D):encodeURIComponent(String(L)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),D=encodeURIComponent(String(D)),D=D.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),D=D.replace(/[\(\)]/g,escape),document.cookie=[D,"=",L,S.expires?"; expires="+S.expires.toUTCString():"",S.path?"; path="+S.path:"",S.domain?"; domain="+S.domain:"",S.secure?"; secure":""].join("")}D||(g={});for(var a=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,s=0;s<a.length;s++){var u=a[s].split("="),n=u.slice(1).join("=");n.charAt(0)==='"'&&(n=n.slice(1,-1));try{var i=u[0].replace(e,decodeURIComponent);if(n=A.read?A.read(n,i):A(n,i)||n.replace(e,decodeURIComponent),this.json)try{n=JSON.parse(n)}catch{}if(D===i){g=n;break}D||(g[i]=n)}catch{}}return g}}return y.set=y,y.get=function(D){return y.call(y,D)},y.getJSON=function(){return y.apply({json:!0},[].slice.call(arguments))},y.defaults={},y.remove=function(D,L){y(D,"",_(L,{expires:-1}))},y.withConverter=T,y}var _=function(){for(var A=0,y={};A<arguments.length;A++){var D=arguments[A];for(var L in D)y[L]=D[L]}return y};return T(function(){})})},function(R,h,P){"use strict";function p(x,I){var T=I.beaconCollectionDomain,_=I.beaconDomain;if(T)return"https://"+T;x=x||"inferred";var A=_||"litix.io";return x.match(/^[a-z0-9]+$/)?"https://"+x+"."+A:"https://img.litix.io/a.gif"}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p=P(0),x=function(_){return _&&_.__esModule?_:{default:_}}(p),I=function(){var _=void 0;switch(T()){case"cellular":_="cellular";break;case"ethernet":_="wired";break;case"wifi":_="wifi";break;case void 0:break;default:_="other"}return _},T=function(){var _=x.default.navigator,A=_&&(_.connection||_.mozConnection||_.webkitConnection);return A&&A.type};h.default=I},function(R,h,P){"use strict";function p(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(h,"__esModule",{value:!0});var x=P(0),I=p(x),T=P(4),_=p(T),A=P(56),y=p(A),D=P(1),L=p(D),S=P(17),g=p(S),E=P(2),a=p(E),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,s={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},u=function(n,i){this._beaconUrl=n||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,L.default)({},s,i)};u.prototype.queueEvent=function(n,i){var t=(0,L.default)({},i);return e?(this._eventQueue.length<=this._options.maxQueueLength||n==="eventrateexceeded")&&(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(y.default.send(this._beaconUrl,t),!0)},u.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},u.prototype.destroy=function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,n?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},u.prototype._clearBeaconQueue=function(){var n=I.default.navigator,i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,t=this._eventQueue.slice(i);i>0&&(0,L.default)(t[t.length-1],(0,g.default)({mux_view_message:"event queue truncated"}));var l=this._createPayload(t);if(n.sendBeacon)n.sendBeacon(this._beaconUrl,l);else if(I.default.XMLHttpRequest){var d=new I.default.XMLHttpRequest;d.open("POST",this._beaconUrl),d.setRequestHeader("Content-Type","application/json"),d.send(l)}else y.default.send(this._beaconUrl,t[t.length-1])},u.prototype._sendBeaconQueue=function(){var n=this;if(I.default.XMLHttpRequest&&!this._postInFlight){var i=new I.default.XMLHttpRequest,t=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,i.onreadystatechange=function(){i.readyState===4&&(i.status!==200?(n._eventQueue=t.concat(n._eventQueue),n._failureCount+=1,_.default.info("Error sending beacon: "+i.status),_.default.info(i.responseText)):n._failureCount=0,n._roundTripTime=a.default.now()-d,n._postInFlight=!1)},i.open("POST",this._beaconUrl),i.setRequestHeader("Content-Type","application/json");var l=this._createPayload(t),d=a.default.now();i.send(l)}},u.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var n=Math.pow(2,this._failureCount-1);return(1+(n*=Math.random()))*this._options.baseTimeBetweenBeacons},u.prototype._startBeaconSending=function(){var n=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){n._eventQueue.length&&n._sendBeaconQueue(),n._startBeaconSending()},this._getNextBeaconTime()))},u.prototype._createPayload=function(n){var i={transmission_timestamp:Math.round(a.default.now())};return this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:i,events:n})},h.default=u},function(R,h,P){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}Object.defineProperty(h,"__esModule",{value:!0});var x=P(15),I=p(x),T=P(0),_=p(T),A={};A.send=function(y,D){function L(){S.src=E+(g?"&rc="+g:"")}var S=new Image,g=0,E=y+"?"+I.default.stringify(D);return S.addEventListener("error",function(){g>3||_.default.setTimeout(function(){g++,L()},5e3*g)}),L(),S},h.default=A},function(R,h,P){"use strict";function p(){function x(E,a){var e=a.request_start,s=a.request_response_start,u=a.request_response_end,n=a.request_bytes_loaded;D++;var i=void 0,t=void 0;if(s?(i=s-e,t=u-s):t=u-e,t>0&&n>0){var l=n/t*8e3;L++,A+=n,y+=t,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,l),this.data.view_average_request_throughput=A/y*8e3,this.data.view_request_count=D,i>0&&(_+=i,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,i),this.data.view_average_request_latency=_/L)}}function I(E,a){D++,S++,this.data.view_request_count=D,this.data.view_request_failed_count=S}function T(E,a){D++,g++,this.data.view_request_count=D,this.data.view_request_canceled_count=g}var _=0,A=0,y=0,D=0,L=0,S=0,g=0;this.on("requestcompleted",x),this.on("requestfailed",I),this.on("requestcanceled",T)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(R,h,P){"use strict";function p(L,S,g){var E=(0,A.findMediaElement)(S),a=I(E,3),e=a[0],s=a[1],u=a[2],n=L.log,i=L.utils.getComputedStyle,t=L.utils.secondsToMs,l={automaticErrorTracking:!0};if(!e)return n.error("No element was found with the `"+s+"` query selector.");if(u!=="video"&&u!=="audio")return n.error("The element of `"+s+"` was not a media element.");g=(0,_.default)(l,g),g.data=(0,_.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},g.data),g.getPlayheadTime=function(){return t(e.currentTime)},g.getStateData=function(){var r=this.hlsjs&&this.hlsjs.url,c=this.dashjs&&x(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:e.paused,player_playhead_time:t(e.currentTime),player_width:parseInt(i(e,"width")),player_height:parseInt(i(e,"height")),player_autoplay_on:e.autoplay,player_preload_on:e.preload,video_poster_url:e.poster,video_source_url:r||c||e.currentSrc,video_source_duration:t(e.duration),video_source_height:e.videoHeight,video_source_width:e.videoWidth}},e.mux=e.mux||{},e.mux.deleted=!1,e.mux.emit=function(r,c){L.emit(s,r,c)};var d=function(){n.error("The monitor for this video element has already been destroyed.")};e.mux.destroy=function(){Object.keys(e.mux.listeners).forEach(function(r){e.removeEventListener(r,e.mux.listeners[r],!1)}),delete e.mux.listeners,e.mux.destroy=d,e.mux.swapElement=d,e.mux.emit=d,e.mux.addHLSJS=d,e.mux.addDashJS=d,e.mux.removeHLSJS=d,e.mux.removeDashJS=d,e.mux.deleted=!0,L.emit(s,"destroy")},e.mux.swapElement=function(r){var c=(0,A.findMediaElement)(r),f=I(c,3),o=f[0],v=f[1],m=f[2];return o?m!=="video"&&m!=="audio"?L.log.error("The element of `"+v+"` was not a media element."):(o.muxId=e.muxId,delete e.muxId,o.mux=o.mux||{},o.mux.listeners=(0,_.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(o.mux.listeners).forEach(function(O){e.removeEventListener(O,o.mux.listeners[O],!1),o.addEventListener(O,o.mux.listeners[O],!1)}),o.mux.swapElement=e.mux.swapElement,o.mux.destroy=e.mux.destroy,delete e.mux,void(e=o)):L.log.error("No element was found with the `"+v+"` query selector.")},e.mux.addHLSJS=function(r){L.addHLSJS(s,r)},e.mux.addDashJS=function(r){L.addDashJS(s,r)},e.mux.removeHLSJS=function(){L.removeHLSJS(s)},e.mux.removeDashJS=function(){L.removeDashJS(s)},L.init(s,g),L.emit(s,"playerready"),e.paused||(L.emit(s,"play"),e.readyState>2&&L.emit(s,"playing")),e.mux.listeners={},y.forEach(function(r){(r!=="error"||g.automaticErrorTracking)&&(e.mux.listeners[r]=function(){var c={};if(r==="error"){if(!e.error||e.error.code===1)return;c.player_error_code=e.error.code,c.player_error_message=D[e.error.code]||e.error.message}L.emit(s,r,c)},e.addEventListener(r,e.mux.listeners[r],!1))})}Object.defineProperty(h,"__esModule",{value:!0});var x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},I=function(){function L(S,g){var E=[],a=!0,e=!1,s=void 0;try{for(var u,n=S[Symbol.iterator]();!(a=(u=n.next()).done)&&(E.push(u.value),!g||E.length!==g);a=!0);}catch(i){e=!0,s=i}finally{try{!a&&n.return&&n.return()}finally{if(e)throw s}}return E}return function(S,g){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return L(S,g);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();h.default=p;var T=P(1),_=function(L){return L&&L.__esModule?L:{default:L}}(T),A=P(11),y=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],D={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(R,h,P){"use strict";function p(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(h,"__esModule",{value:!0});var x=P(60),I=p(x),T=P(3),_=p(T),A=P(61),y=p(A),D=P(62),L=p(D),S=P(1),g=p(S),E=P(7),a=p(E),e=P(5),s=P(2),u=p(s),n=P(63),i=p(n),t={};t.safeCall=I.default,t.safeIncrement=_.default,t.getComputedStyle=y.default,t.secondsToMs=L.default,t.assign=g.default,t.headersStringToObject=a.default,t.extractHostnameAndDomain=e.extractHostnameAndDomain,t.extractHostname=e.extractHostname,t.now=u.default.now,t.manifestParser=i.default,h.default=t},function(R,h,P){"use strict";function p(T,_,A,y){var D=y;if(T&&typeof T[_]=="function")try{D=T[_].apply(T,A)}catch(L){I.default.info("safeCall error",L)}return D}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var x=P(4),I=function(T){return T&&T.__esModule?T:{default:T}}(x)},function(R,h,P){"use strict";function p(_,A){if(_&&A&&I.default&&typeof I.default.getComputedStyle=="function"){var y=void 0;return T&&T.has(_)&&(y=T.get(_)),y||(y=I.default.getComputedStyle(_,null),T&&T.set(_,y)),y.getPropertyValue(A)}}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p;var x=P(0),I=function(_){return _&&_.__esModule?_:{default:_}}(x),T=void 0;I.default&&I.default.WeakMap&&(T=new WeakMap)},function(R,h,P){"use strict";function p(x){return Math.floor(1e3*x)}Object.defineProperty(h,"__esModule",{value:!0}),h.default=p},function(R,h,P){"use strict";function p(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(h,"__esModule",{value:!0});var x=P(1),I=p(x),T=P(14),_=p(T),A={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},y=function(u){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(u),this.manifest};y.prototype.process=function(u){var n=void 0;for(this.buffer+=u,n=this.buffer.indexOf(`
|
|
5
5
|
`);n>-1;n=this.buffer.indexOf(`
|
|
6
|
-
`))this.processLine(this.buffer.substring(0,n)),this.buffer=this.buffer.substring(n+1)},y.prototype.processLine=function(u){var n=u.indexOf(":"),i=e(u,n),t=i[0],l=i.length===2?T(i[1]):void 0;if(t[0]!=="#")this.currentUri.uri=t,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(t){case A.TARGET_DURATION:if(!isFinite(l)||l<0)return;this.manifest.targetDuration=l,this.setHoldBack();break;case A.PART_INF:D(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case A.SERVER_CONTROL:D(this.manifest,i),this.setHoldBack();break;case A.INF:l===0?this.currentUri.duration=.01:l>0&&(this.currentUri.duration=l);break;case A.PROGRAM_DATE_TIME:var d=l,r=new Date(d);this.manifest.dateTimeString||(this.manifest.dateTimeString=d,this.manifest.dateTimeObject=r),this.currentUri.dateTimeString=d,this.currentUri.dateTimeObject=r;break;case A.VERSION:D(this.manifest,i);break;case A.SESSION_DATA:var c=s(i[1]),f=(0,L.default)(c);(0,I.default)(this.manifest.sessionData,f)}},y.prototype.setHoldBack=function(){var u=this.manifest,n=u.serverControl,i=u.targetDuration,t=u.partTargetDuration;if(n){var l="holdBack",d="partHoldBack",r=i&&3*i,c=t&&2*t;i&&!n.hasOwnProperty(l)&&(n[l]=r),r&&n[l]<r&&(n[l]=r),t&&!n.hasOwnProperty(d)&&(n[d]=3*t),t&&n[d]<c&&(n[d]=c)}};var D=function(u,n){var i=_(n[0].replace("#EXT-X-","")),t=void 0;a(n[1])?(t={},t=(0,I.default)(E(n[1]),t)):t=T(n[1]),u[i]=t},_=function(u){return u.toLowerCase().replace(/-(\w)/g,function(n){return n[1].toUpperCase()})},T=function(u){if(u.toLowerCase()==="yes"||u.toLowerCase()==="no")return u.toLowerCase()==="yes";var n=u.indexOf(":")!==-1?u:parseFloat(u);return isNaN(n)?u:n},g=function(u){var n={},i=u.split("=");return i.length>1&&(n[_(i[0])]=T(i[1])),n},E=function(u){for(var n=u.split(","),i={},t=0;n.length>t;t++){var l=n[t],d=g(l);i=(0,I.default)(d,i)}return i},a=function(u){return u.indexOf("=")>-1},e=function(u,n){return n===-1?[u]:[u.substring(0,n),u.substring(n+1)]},s=function(u){var n={};if(u){var i=u.search(",");return[u.slice(0,i),u.slice(i+1)].forEach(function(t,l){for(var d=t.replace(/['"]+/g,"").split("="),r=0;r<d.length;r++)d[r]==="DATA-ID"&&(n["DATA-ID"]=d[1-r]),d[r]==="VALUE"&&(n.VALUE=d[1-r])}),{data:n}}};h.default=y},function(P,h,R){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};h.default=p}])})})()});var it=yt((Je,st)=>{typeof window!="undefined"&&function(P,h){typeof Je=="object"&&typeof st=="object"?st.exports=h():typeof define=="function"&&define.amd?define([],h):typeof Je=="object"?Je.Hls=h():P.Hls=h()}(Je,function(){return function(K){var P={};function h(R){if(P[R])return P[R].exports;var p=P[R]={i:R,l:!1,exports:{}};return K[R].call(p.exports,p,p.exports,h),p.l=!0,p.exports}return h.m=K,h.c=P,h.d=function(R,p,S){h.o(R,p)||Object.defineProperty(R,p,{enumerable:!0,get:S})},h.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},h.t=function(R,p){if(p&1&&(R=h(R)),p&8||p&4&&typeof R=="object"&&R&&R.__esModule)return R;var S=Object.create(null);if(h.r(S),Object.defineProperty(S,"default",{enumerable:!0,value:R}),p&2&&typeof R!="string")for(var I in R)h.d(S,I,function(x){return R[x]}.bind(null,I));return S},h.n=function(R){var p=R&&R.__esModule?function(){return R.default}:function(){return R};return h.d(p,"a",p),p},h.o=function(R,p){return Object.prototype.hasOwnProperty.call(R,p)},h.p="/dist/",h(h.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(K,P,h){"use strict";var R=Object.prototype.hasOwnProperty,p="~";function S(){}Object.create&&(S.prototype=Object.create(null),new S().__proto__||(p=!1));function I(y,D,_){this.fn=y,this.context=D,this.once=_||!1}function x(y,D,_,T,g){if(typeof _!="function")throw new TypeError("The listener must be a function");var E=new I(_,T||y,g),a=p?p+D:D;return y._events[a]?y._events[a].fn?y._events[a]=[y._events[a],E]:y._events[a].push(E):(y._events[a]=E,y._eventsCount++),y}function L(y,D){--y._eventsCount===0?y._events=new S:delete y._events[D]}function A(){this._events=new S,this._eventsCount=0}A.prototype.eventNames=function(){var D=[],_,T;if(this._eventsCount===0)return D;for(T in _=this._events)R.call(_,T)&&D.push(p?T.slice(1):T);return Object.getOwnPropertySymbols?D.concat(Object.getOwnPropertySymbols(_)):D},A.prototype.listeners=function(D){var _=p?p+D:D,T=this._events[_];if(!T)return[];if(T.fn)return[T.fn];for(var g=0,E=T.length,a=new Array(E);g<E;g++)a[g]=T[g].fn;return a},A.prototype.listenerCount=function(D){var _=p?p+D:D,T=this._events[_];return T?T.fn?1:T.length:0},A.prototype.emit=function(D,_,T,g,E,a){var e=p?p+D:D;if(!this._events[e])return!1;var s=this._events[e],u=arguments.length,n,i;if(s.fn){switch(s.once&&this.removeListener(D,s.fn,void 0,!0),u){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,_),!0;case 3:return s.fn.call(s.context,_,T),!0;case 4:return s.fn.call(s.context,_,T,g),!0;case 5:return s.fn.call(s.context,_,T,g,E),!0;case 6:return s.fn.call(s.context,_,T,g,E,a),!0}for(i=1,n=new Array(u-1);i<u;i++)n[i-1]=arguments[i];s.fn.apply(s.context,n)}else{var t=s.length,l;for(i=0;i<t;i++)switch(s[i].once&&this.removeListener(D,s[i].fn,void 0,!0),u){case 1:s[i].fn.call(s[i].context);break;case 2:s[i].fn.call(s[i].context,_);break;case 3:s[i].fn.call(s[i].context,_,T);break;case 4:s[i].fn.call(s[i].context,_,T,g);break;default:if(!n)for(l=1,n=new Array(u-1);l<u;l++)n[l-1]=arguments[l];s[i].fn.apply(s[i].context,n)}}return!0},A.prototype.on=function(D,_,T){return x(this,D,_,T,!1)},A.prototype.once=function(D,_,T){return x(this,D,_,T,!0)},A.prototype.removeListener=function(D,_,T,g){var E=p?p+D:D;if(!this._events[E])return this;if(!_)return L(this,E),this;var a=this._events[E];if(a.fn)a.fn===_&&(!g||a.once)&&(!T||a.context===T)&&L(this,E);else{for(var e=0,s=[],u=a.length;e<u;e++)(a[e].fn!==_||g&&!a[e].once||T&&a[e].context!==T)&&s.push(a[e]);s.length?this._events[E]=s.length===1?s[0]:s:L(this,E)}return this},A.prototype.removeAllListeners=function(D){var _;return D?(_=p?p+D:D,this._events[_]&&L(this,_)):(this._events=new S,this._eventsCount=0),this},A.prototype.off=A.prototype.removeListener,A.prototype.addListener=A.prototype.on,A.prefixed=p,A.EventEmitter=A,K.exports=A},"./node_modules/url-toolkit/src/url-toolkit.js":function(K,P,h){(function(R){var p=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,S=/^(?=([^\/?#]*))\1([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,x=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,L={buildAbsoluteURL:function(A,y,D){if(D=D||{},A=A.trim(),y=y.trim(),!y){if(!D.alwaysNormalize)return A;var _=L.parseURL(A);if(!_)throw new Error("Error trying to parse base URL.");return _.path=L.normalizePath(_.path),L.buildURLFromParts(_)}var T=L.parseURL(y);if(!T)throw new Error("Error trying to parse relative URL.");if(T.scheme)return D.alwaysNormalize?(T.path=L.normalizePath(T.path),L.buildURLFromParts(T)):y;var g=L.parseURL(A);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var E=S.exec(g.path);g.netLoc=E[1],g.path=E[2]}g.netLoc&&!g.path&&(g.path="/");var a={scheme:g.scheme,netLoc:T.netLoc,path:null,params:T.params,query:T.query,fragment:T.fragment};if(!T.netLoc&&(a.netLoc=g.netLoc,T.path[0]!=="/"))if(!T.path)a.path=g.path,T.params||(a.params=g.params,T.query||(a.query=g.query));else{var e=g.path,s=e.substring(0,e.lastIndexOf("/")+1)+T.path;a.path=L.normalizePath(s)}return a.path===null&&(a.path=D.alwaysNormalize?L.normalizePath(T.path):T.path),L.buildURLFromParts(a)},parseURL:function(A){var y=p.exec(A);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(A){for(A=A.split("").reverse().join("").replace(I,"");A.length!==(A=A.replace(x,"")).length;);return A.split("").reverse().join("")},buildURLFromParts:function(A){return A.scheme+A.netLoc+A.path+A.params+A.query+A.fragment}};K.exports=L})(this)},"./node_modules/webworkify-webpack/index.js":function(K,P,h){function R(D){var _={};function T(E){if(_[E])return _[E].exports;var a=_[E]={i:E,l:!1,exports:{}};return D[E].call(a.exports,a,a.exports,T),a.l=!0,a.exports}T.m=D,T.c=_,T.i=function(E){return E},T.d=function(E,a,e){T.o(E,a)||Object.defineProperty(E,a,{configurable:!1,enumerable:!0,get:e})},T.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},T.n=function(E){var a=E&&E.__esModule?function(){return E.default}:function(){return E};return T.d(a,"a",a),a},T.o=function(E,a){return Object.prototype.hasOwnProperty.call(E,a)},T.p="/",T.oe=function(E){throw console.error(E),E};var g=T(T.s=ENTRY_MODULE);return g.default||g}var p="[\\.|\\-|\\+|\\w|/|@]+",S="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+p+").*?\\)";function I(D){return(D+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function x(D){return!isNaN(1*D)}function L(D,_,T){var g={};g[T]=[];var E=_.toString(),a=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!a)return g;for(var e=a[1],s=new RegExp("(\\\\n|\\W)"+I(e)+S,"g"),u;u=s.exec(E);)u[3]!=="dll-reference"&&g[T].push(u[3]);for(s=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+p+'))"\\)\\)'+S,"g");u=s.exec(E);)D[u[2]]||(g[T].push(u[1]),D[u[2]]=h(u[1]).m),g[u[2]]=g[u[2]]||[],g[u[2]].push(u[4]);for(var n=Object.keys(g),i=0;i<n.length;i++)for(var t=0;t<g[n[i]].length;t++)x(g[n[i]][t])&&(g[n[i]][t]=1*g[n[i]][t]);return g}function A(D){var _=Object.keys(D);return _.reduce(function(T,g){return T||D[g].length>0},!1)}function y(D,_){for(var T={main:[_]},g={main:[]},E={main:{}};A(T);)for(var a=Object.keys(T),e=0;e<a.length;e++){var s=a[e],u=T[s],n=u.pop();if(E[s]=E[s]||{},!(E[s][n]||!D[s][n])){E[s][n]=!0,g[s]=g[s]||[],g[s].push(n);for(var i=L(D,D[s][n],s),t=Object.keys(i),l=0;l<t.length;l++)T[t[l]]=T[t[l]]||[],T[t[l]]=T[t[l]].concat(i[t[l]])}}return g}K.exports=function(D,_){_=_||{};var T={main:h.m},g=_.all?{main:Object.keys(T.main)}:y(T,D),E="";Object.keys(g).filter(function(n){return n!=="main"}).forEach(function(n){for(var i=0;g[n][i];)i++;g[n].push(i),T[n][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",E=E+"var "+n+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[n].map(function(t){return""+JSON.stringify(t)+": "+T[n][t].toString()}).join(",")+`});
|
|
7
|
-
`}),E=E+"new (("+
|
|
8
|
-
Current BW estimate: `+(Object(
|
|
6
|
+
`))this.processLine(this.buffer.substring(0,n)),this.buffer=this.buffer.substring(n+1)},y.prototype.processLine=function(u){var n=u.indexOf(":"),i=e(u,n),t=i[0],l=i.length===2?S(i[1]):void 0;if(t[0]!=="#")this.currentUri.uri=t,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(t){case A.TARGET_DURATION:if(!isFinite(l)||l<0)return;this.manifest.targetDuration=l,this.setHoldBack();break;case A.PART_INF:D(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case A.SERVER_CONTROL:D(this.manifest,i),this.setHoldBack();break;case A.INF:l===0?this.currentUri.duration=.01:l>0&&(this.currentUri.duration=l);break;case A.PROGRAM_DATE_TIME:var d=l,r=new Date(d);this.manifest.dateTimeString||(this.manifest.dateTimeString=d,this.manifest.dateTimeObject=r),this.currentUri.dateTimeString=d,this.currentUri.dateTimeObject=r;break;case A.VERSION:D(this.manifest,i);break;case A.SESSION_DATA:var c=s(i[1]),f=(0,_.default)(c);(0,I.default)(this.manifest.sessionData,f)}},y.prototype.setHoldBack=function(){var u=this.manifest,n=u.serverControl,i=u.targetDuration,t=u.partTargetDuration;if(n){var l="holdBack",d="partHoldBack",r=i&&3*i,c=t&&2*t;i&&!n.hasOwnProperty(l)&&(n[l]=r),r&&n[l]<r&&(n[l]=r),t&&!n.hasOwnProperty(d)&&(n[d]=3*t),t&&n[d]<c&&(n[d]=c)}};var D=function(u,n){var i=L(n[0].replace("#EXT-X-","")),t=void 0;a(n[1])?(t={},t=(0,I.default)(E(n[1]),t)):t=S(n[1]),u[i]=t},L=function(u){return u.toLowerCase().replace(/-(\w)/g,function(n){return n[1].toUpperCase()})},S=function(u){if(u.toLowerCase()==="yes"||u.toLowerCase()==="no")return u.toLowerCase()==="yes";var n=u.indexOf(":")!==-1?u:parseFloat(u);return isNaN(n)?u:n},g=function(u){var n={},i=u.split("=");return i.length>1&&(n[L(i[0])]=S(i[1])),n},E=function(u){for(var n=u.split(","),i={},t=0;n.length>t;t++){var l=n[t],d=g(l);i=(0,I.default)(d,i)}return i},a=function(u){return u.indexOf("=")>-1},e=function(u,n){return n===-1?[u]:[u.substring(0,n),u.substring(n+1)]},s=function(u){var n={};if(u){var i=u.search(",");return[u.slice(0,i),u.slice(i+1)].forEach(function(t,l){for(var d=t.replace(/['"]+/g,"").split("="),r=0;r<d.length;r++)d[r]==="DATA-ID"&&(n["DATA-ID"]=d[1-r]),d[r]==="VALUE"&&(n.VALUE=d[1-r])}),{data:n}}};h.default=y},function(R,h,P){"use strict";Object.defineProperty(h,"__esModule",{value:!0});var p={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};h.default=p}])})})()});var nt=Et((Je,ut)=>{typeof window!="undefined"&&function(R,h){typeof Je=="object"&&typeof ut=="object"?ut.exports=h():typeof define=="function"&&define.amd?define([],h):typeof Je=="object"?Je.Hls=h():R.Hls=h()}(Je,function(){return function(K){var R={};function h(P){if(R[P])return R[P].exports;var p=R[P]={i:P,l:!1,exports:{}};return K[P].call(p.exports,p,p.exports,h),p.l=!0,p.exports}return h.m=K,h.c=R,h.d=function(P,p,x){h.o(P,p)||Object.defineProperty(P,p,{enumerable:!0,get:x})},h.r=function(P){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(P,"__esModule",{value:!0})},h.t=function(P,p){if(p&1&&(P=h(P)),p&8||p&4&&typeof P=="object"&&P&&P.__esModule)return P;var x=Object.create(null);if(h.r(x),Object.defineProperty(x,"default",{enumerable:!0,value:P}),p&2&&typeof P!="string")for(var I in P)h.d(x,I,function(T){return P[T]}.bind(null,I));return x},h.n=function(P){var p=P&&P.__esModule?function(){return P.default}:function(){return P};return h.d(p,"a",p),p},h.o=function(P,p){return Object.prototype.hasOwnProperty.call(P,p)},h.p="/dist/",h(h.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(K,R,h){"use strict";var P=Object.prototype.hasOwnProperty,p="~";function x(){}Object.create&&(x.prototype=Object.create(null),new x().__proto__||(p=!1));function I(y,D,L){this.fn=y,this.context=D,this.once=L||!1}function T(y,D,L,S,g){if(typeof L!="function")throw new TypeError("The listener must be a function");var E=new I(L,S||y,g),a=p?p+D:D;return y._events[a]?y._events[a].fn?y._events[a]=[y._events[a],E]:y._events[a].push(E):(y._events[a]=E,y._eventsCount++),y}function _(y,D){--y._eventsCount===0?y._events=new x:delete y._events[D]}function A(){this._events=new x,this._eventsCount=0}A.prototype.eventNames=function(){var D=[],L,S;if(this._eventsCount===0)return D;for(S in L=this._events)P.call(L,S)&&D.push(p?S.slice(1):S);return Object.getOwnPropertySymbols?D.concat(Object.getOwnPropertySymbols(L)):D},A.prototype.listeners=function(D){var L=p?p+D:D,S=this._events[L];if(!S)return[];if(S.fn)return[S.fn];for(var g=0,E=S.length,a=new Array(E);g<E;g++)a[g]=S[g].fn;return a},A.prototype.listenerCount=function(D){var L=p?p+D:D,S=this._events[L];return S?S.fn?1:S.length:0},A.prototype.emit=function(D,L,S,g,E,a){var e=p?p+D:D;if(!this._events[e])return!1;var s=this._events[e],u=arguments.length,n,i;if(s.fn){switch(s.once&&this.removeListener(D,s.fn,void 0,!0),u){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,L),!0;case 3:return s.fn.call(s.context,L,S),!0;case 4:return s.fn.call(s.context,L,S,g),!0;case 5:return s.fn.call(s.context,L,S,g,E),!0;case 6:return s.fn.call(s.context,L,S,g,E,a),!0}for(i=1,n=new Array(u-1);i<u;i++)n[i-1]=arguments[i];s.fn.apply(s.context,n)}else{var t=s.length,l;for(i=0;i<t;i++)switch(s[i].once&&this.removeListener(D,s[i].fn,void 0,!0),u){case 1:s[i].fn.call(s[i].context);break;case 2:s[i].fn.call(s[i].context,L);break;case 3:s[i].fn.call(s[i].context,L,S);break;case 4:s[i].fn.call(s[i].context,L,S,g);break;default:if(!n)for(l=1,n=new Array(u-1);l<u;l++)n[l-1]=arguments[l];s[i].fn.apply(s[i].context,n)}}return!0},A.prototype.on=function(D,L,S){return T(this,D,L,S,!1)},A.prototype.once=function(D,L,S){return T(this,D,L,S,!0)},A.prototype.removeListener=function(D,L,S,g){var E=p?p+D:D;if(!this._events[E])return this;if(!L)return _(this,E),this;var a=this._events[E];if(a.fn)a.fn===L&&(!g||a.once)&&(!S||a.context===S)&&_(this,E);else{for(var e=0,s=[],u=a.length;e<u;e++)(a[e].fn!==L||g&&!a[e].once||S&&a[e].context!==S)&&s.push(a[e]);s.length?this._events[E]=s.length===1?s[0]:s:_(this,E)}return this},A.prototype.removeAllListeners=function(D){var L;return D?(L=p?p+D:D,this._events[L]&&_(this,L)):(this._events=new x,this._eventsCount=0),this},A.prototype.off=A.prototype.removeListener,A.prototype.addListener=A.prototype.on,A.prefixed=p,A.EventEmitter=A,K.exports=A},"./node_modules/url-toolkit/src/url-toolkit.js":function(K,R,h){(function(P){var p=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,x=/^(?=([^\/?#]*))\1([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,T=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,_={buildAbsoluteURL:function(A,y,D){if(D=D||{},A=A.trim(),y=y.trim(),!y){if(!D.alwaysNormalize)return A;var L=_.parseURL(A);if(!L)throw new Error("Error trying to parse base URL.");return L.path=_.normalizePath(L.path),_.buildURLFromParts(L)}var S=_.parseURL(y);if(!S)throw new Error("Error trying to parse relative URL.");if(S.scheme)return D.alwaysNormalize?(S.path=_.normalizePath(S.path),_.buildURLFromParts(S)):y;var g=_.parseURL(A);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var E=x.exec(g.path);g.netLoc=E[1],g.path=E[2]}g.netLoc&&!g.path&&(g.path="/");var a={scheme:g.scheme,netLoc:S.netLoc,path:null,params:S.params,query:S.query,fragment:S.fragment};if(!S.netLoc&&(a.netLoc=g.netLoc,S.path[0]!=="/"))if(!S.path)a.path=g.path,S.params||(a.params=g.params,S.query||(a.query=g.query));else{var e=g.path,s=e.substring(0,e.lastIndexOf("/")+1)+S.path;a.path=_.normalizePath(s)}return a.path===null&&(a.path=D.alwaysNormalize?_.normalizePath(S.path):S.path),_.buildURLFromParts(a)},parseURL:function(A){var y=p.exec(A);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(A){for(A=A.split("").reverse().join("").replace(I,"");A.length!==(A=A.replace(T,"")).length;);return A.split("").reverse().join("")},buildURLFromParts:function(A){return A.scheme+A.netLoc+A.path+A.params+A.query+A.fragment}};K.exports=_})(this)},"./node_modules/webworkify-webpack/index.js":function(K,R,h){function P(D){var L={};function S(E){if(L[E])return L[E].exports;var a=L[E]={i:E,l:!1,exports:{}};return D[E].call(a.exports,a,a.exports,S),a.l=!0,a.exports}S.m=D,S.c=L,S.i=function(E){return E},S.d=function(E,a,e){S.o(E,a)||Object.defineProperty(E,a,{configurable:!1,enumerable:!0,get:e})},S.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},S.n=function(E){var a=E&&E.__esModule?function(){return E.default}:function(){return E};return S.d(a,"a",a),a},S.o=function(E,a){return Object.prototype.hasOwnProperty.call(E,a)},S.p="/",S.oe=function(E){throw console.error(E),E};var g=S(S.s=ENTRY_MODULE);return g.default||g}var p="[\\.|\\-|\\+|\\w|/|@]+",x="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+p+").*?\\)";function I(D){return(D+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function T(D){return!isNaN(1*D)}function _(D,L,S){var g={};g[S]=[];var E=L.toString(),a=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!a)return g;for(var e=a[1],s=new RegExp("(\\\\n|\\W)"+I(e)+x,"g"),u;u=s.exec(E);)u[3]!=="dll-reference"&&g[S].push(u[3]);for(s=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+p+'))"\\)\\)'+x,"g");u=s.exec(E);)D[u[2]]||(g[S].push(u[1]),D[u[2]]=h(u[1]).m),g[u[2]]=g[u[2]]||[],g[u[2]].push(u[4]);for(var n=Object.keys(g),i=0;i<n.length;i++)for(var t=0;t<g[n[i]].length;t++)T(g[n[i]][t])&&(g[n[i]][t]=1*g[n[i]][t]);return g}function A(D){var L=Object.keys(D);return L.reduce(function(S,g){return S||D[g].length>0},!1)}function y(D,L){for(var S={main:[L]},g={main:[]},E={main:{}};A(S);)for(var a=Object.keys(S),e=0;e<a.length;e++){var s=a[e],u=S[s],n=u.pop();if(E[s]=E[s]||{},!(E[s][n]||!D[s][n])){E[s][n]=!0,g[s]=g[s]||[],g[s].push(n);for(var i=_(D,D[s][n],s),t=Object.keys(i),l=0;l<t.length;l++)S[t[l]]=S[t[l]]||[],S[t[l]]=S[t[l]].concat(i[t[l]])}}return g}K.exports=function(D,L){L=L||{};var S={main:h.m},g=L.all?{main:Object.keys(S.main)}:y(S,D),E="";Object.keys(g).filter(function(n){return n!=="main"}).forEach(function(n){for(var i=0;g[n][i];)i++;g[n].push(i),S[n][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",E=E+"var "+n+" = ("+P.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[n].map(function(t){return""+JSON.stringify(t)+": "+S[n][t].toString()}).join(",")+`});
|
|
7
|
+
`}),E=E+"new (("+P.toString().replace("ENTRY_MODULE",JSON.stringify(D))+")({"+g.main.map(function(n){return""+JSON.stringify(n)+": "+S.main[n].toString()}).join(",")+"}))(self);";var a=new window.Blob([E],{type:"text/javascript"});if(L.bare)return a;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,s=e.createObjectURL(a),u=new window.Worker(s);return u.objectURL=s,u}},"./src/config.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"hlsDefaultConfig",function(){return l}),h.d(R,"mergeConfig",function(){return r}),h.d(R,"enableStreamingMode",function(){return c});var P=h("./src/controller/abr-controller.ts"),p=h("./src/controller/audio-stream-controller.ts"),x=h("./src/controller/audio-track-controller.ts"),I=h("./src/controller/subtitle-stream-controller.ts"),T=h("./src/controller/subtitle-track-controller.ts"),_=h("./src/controller/buffer-controller.ts"),A=h("./src/controller/timeline-controller.ts"),y=h("./src/controller/cap-level-controller.ts"),D=h("./src/controller/fps-controller.ts"),L=h("./src/controller/eme-controller.ts"),S=h("./src/controller/cmcd-controller.ts"),g=h("./src/utils/xhr-loader.ts"),E=h("./src/utils/fetch-loader.ts"),a=h("./src/utils/cues.ts"),e=h("./src/utils/mediakeys-helper.ts"),s=h("./src/utils/logger.ts");function u(){return u=Object.assign?Object.assign.bind():function(f){for(var o=1;o<arguments.length;o++){var v=arguments[o];for(var m in v)Object.prototype.hasOwnProperty.call(v,m)&&(f[m]=v[m])}return f},u.apply(this,arguments)}function n(f,o){var v=Object.keys(f);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(f);o&&(m=m.filter(function(O){return Object.getOwnPropertyDescriptor(f,O).enumerable})),v.push.apply(v,m)}return v}function i(f){for(var o=1;o<arguments.length;o++){var v=arguments[o]!=null?arguments[o]:{};o%2?n(Object(v),!0).forEach(function(m){t(f,m,v[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(v)):n(Object(v)).forEach(function(m){Object.defineProperty(f,m,Object.getOwnPropertyDescriptor(v,m))})}return f}function t(f,o,v){return o in f?Object.defineProperty(f,o,{value:v,enumerable:!0,configurable:!0,writable:!0}):f[o]=v,f}var l=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:P.default,bufferController:_.default,capLevelController:y.default,fpsController:D.default,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,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},d()),{},{subtitleStreamController:I.SubtitleStreamController,subtitleTrackController:T.default,timelineController:A.TimelineController,audioStreamController:p.default,audioTrackController:x.default,emeController:L.default,cmcdController:S.default});function d(){return{cueHandler:a.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r(f,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return u({},f,o)}function c(f){var o=f.loader;if(o!==E.default&&o!==g.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),f.progressive=!1;else{var v=Object(E.fetchSupported)();v&&(f.loader=E.default,f.progressive=!0,f.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/polyfills/number.ts"),p=h("./src/utils/ewma-bandwidth-estimator.ts"),x=h("./src/events.ts"),I=h("./src/utils/buffer-helper.ts"),T=h("./src/errors.ts"),_=h("./src/types/loader.ts"),A=h("./src/utils/logger.ts");function y(S,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(S,a.key,a)}}function D(S,g,E){return g&&y(S.prototype,g),E&&y(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}var L=function(){function S(E){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=E;var a=E.config;this.bwEstimator=new p.default(a.abrEwmaSlowVoD,a.abrEwmaFastVoD,a.abrEwmaDefaultEstimate),this.registerListeners()}var g=S.prototype;return g.registerListeners=function(){var a=this.hls;a.on(x.Events.FRAG_LOADING,this.onFragLoading,this),a.on(x.Events.FRAG_LOADED,this.onFragLoaded,this),a.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),a.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.on(x.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var a=this.hls;a.off(x.Events.FRAG_LOADING,this.onFragLoading,this),a.off(x.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(x.Events.FRAG_BUFFERED,this.onFragBuffered,this),a.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),a.off(x.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},g.onFragLoading=function(a,e){var s=e.frag;if(s.type===_.PlaylistLevelType.MAIN&&!this.timer){var u;this.fragCurrent=s,this.partCurrent=(u=e.part)!=null?u:null,this.timer=self.setInterval(this.onCheck,100)}},g.onLevelLoaded=function(a,e){var s=this.hls.config;e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},g._abandonRulesCheck=function(){var a=this.fragCurrent,e=this.partCurrent,s=this.hls,u=s.autoLevelEnabled,n=s.config,i=s.media;if(!(!a||!i)){var t=e?e.stats:a.stats,l=e?e.duration:a.duration;if(t.aborted){A.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!u||i.paused||!i.playbackRate||!i.readyState)){var d=performance.now()-t.loading.start,r=Math.abs(i.playbackRate);if(!(d<=500*l/r)){var c=s.levels,f=s.minAutoLevel,o=c[a.level],v=t.total||Math.max(t.loaded,Math.round(l*o.maxBitrate/8)),m=Math.max(1,t.bwEstimate?t.bwEstimate/8:t.loaded*1e3/d),O=(v-t.loaded)/m,b=i.currentTime,M=(I.BufferHelper.bufferInfo(i,b,n.maxBufferHole).end-b)/r;if(!(M>=2*l/r||O<=M)){var F=Number.POSITIVE_INFINITY,w;for(w=a.level-1;w>f;w--){var C=c[w].maxBitrate;if(F=l*C/(8*.8*m),F<M)break}if(!(F>=O)){var U=this.bwEstimator.getEstimate();A.logger.warn("Fragment "+a.sn+(e?" part "+e.index:"")+" of level "+a.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+w+`
|
|
8
|
+
Current BW estimate: `+(Object(P.isFiniteNumber)(U)?(U/1024).toFixed(3):"Unknown")+` Kb/s
|
|
9
9
|
Estimated load time for current fragment: `+O.toFixed(3)+` s
|
|
10
10
|
Estimated load time for the next fragment: `+F.toFixed(3)+` s
|
|
11
|
-
Time to underbuffer: `+M.toFixed(3)+" s"),s.nextLoadLevel=w,this.bwEstimator.sample(d,t.loaded),this.clearTimer(),a.loader&&(this.fragCurrent=this.partCurrent=null,a.loader.abort()),s.trigger(S.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:e,stats:t})}}}}}},g.onFragLoaded=function(a,e){var s=e.frag,u=e.part;if(s.type===L.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(s.sn)){var n=u?u.stats:s.stats,i=u?u.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var t=this.hls.levels[s.level],l=(t.loaded?t.loaded.bytes:0)+n.loaded,d=(t.loaded?t.loaded.duration:0)+i;t.loaded={bytes:l,duration:d},t.realBitrate=Math.round(8*l/d)}if(s.bitrateTest){var r={stats:n,frag:s,part:u,id:s.type};this.onFragBuffered(S.Events.FRAG_BUFFERED,r)}}},g.onFragBuffered=function(a,e){var s=e.frag,u=e.part,n=u?u.stats:s.stats;if(!n.aborted&&!(s.type!==L.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=n.parsing.end-n.loading.start;this.bwEstimator.sample(i,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(a,e){switch(e.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var a=this.fragCurrent,e=this.partCurrent,s=this.hls,u=s.maxAutoLevel,n=s.config,i=s.minAutoLevel,t=s.media,l=e?e.duration:a?a.duration:0,d=t?t.currentTime:0,r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,f=(I.BufferHelper.bufferInfo(t,d,n.maxBufferHole).end-d)/r,o=this.findBestLevel(c,i,u,f,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(o>=0)return o;A.logger.trace((f?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,m=n.abrBandWidthFactor,O=n.abrBandWidthUpFactor;if(!f){var b=this.bitrateTestDelay;if(b){var M=l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay;v=M-b,A.logger.trace("bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),m=O=1}}return o=this.findBestLevel(c,i,u,f+v,m,O),Math.max(o,0)},g.findBestLevel=function(a,e,s,u,n,i){for(var t,l=this.fragCurrent,d=this.partCurrent,r=this.lastLoadedFragLevel,c=this.hls.levels,f=c[r],o=!!(f!=null&&(t=f.details)!==null&&t!==void 0&&t.live),v=f==null?void 0:f.codecSet,m=d?d.duration:l?l.duration:0,O=s;O>=e;O--){var b=c[O];if(!(!b||v&&b.codecSet!==v)){var M=b.details,F=(d?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||m,w=void 0;O<=r?w=n*a:w=i*a;var C=c[O].maxBitrate,U=C*F/w;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+O+"/"+Math.round(w)+"/"+C+"/"+F+"/"+u+"/"+U),w>C&&(!U||o&&!this.bitrateTestDelay||U<u))return O}}return-1},D(T,[{key:"nextAutoLevel",get:function(){var a=this._nextAutoLevel,e=this.bwEstimator;if(a!==-1&&!e.canEstimate())return a;var s=this.getNextABRAutoLevel();return a!==-1&&this.hls.levels[s].loadError?a:(a!==-1&&(s=Math.min(a,s)),s)},set:function(a){this._nextAutoLevel=a}}]),T}();P.default=_},"./src/controller/audio-stream-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/controller/base-stream-controller.ts"),S=h("./src/events.ts"),I=h("./src/utils/buffer-helper.ts"),x=h("./src/controller/fragment-tracker.ts"),L=h("./src/types/level.ts"),A=h("./src/types/loader.ts"),y=h("./src/loader/fragment.ts"),D=h("./src/demux/chunk-cache.ts"),_=h("./src/demux/transmuxer-interface.ts"),T=h("./src/types/transmuxer.ts"),g=h("./src/controller/fragment-finders.ts"),E=h("./src/utils/discontinuities.ts"),a=h("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(t){for(var l=1;l<arguments.length;l++){var d=arguments[l];for(var r in d)Object.prototype.hasOwnProperty.call(d,r)&&(t[r]=d[r])}return t},e.apply(this,arguments)}function s(t,l){t.prototype=Object.create(l.prototype),t.prototype.constructor=t,u(t,l)}function u(t,l){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,c){return r.__proto__=c,r},u(t,l)}var n=100,i=function(t){s(l,t);function l(r,c){var f;return f=t.call(this,r,c,"[audio-stream-controller]")||this,f.videoBuffer=null,f.videoTrackCC=-1,f.waitingVideoCC=-1,f.audioSwitch=!1,f.trackId=-1,f.waitingData=null,f.mainDetails=null,f.bufferFlushed=!1,f.cachedTrackLoadedData=null,f._registerListeners(),f}var d=l.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var c=this.hls;c.on(S.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(S.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(S.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(S.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.on(S.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(S.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.on(S.Events.ERROR,this.onError,this),c.on(S.Events.BUFFER_RESET,this.onBufferReset,this),c.on(S.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(S.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(S.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(S.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var c=this.hls;c.off(S.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(S.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(S.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(S.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(S.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.off(S.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(S.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.off(S.Events.ERROR,this.onError,this),c.off(S.Events.BUFFER_RESET,this.onBufferReset,this),c.off(S.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(S.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(S.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.off(S.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(c,f){var o=f.frag,v=f.id,m=f.initPTS;if(v==="main"){var O=o.cc;this.initPTS[o.cc]=m,this.log("InitPTS for cc: "+O+" found from main: "+m),this.videoTrackCC=O,this.state===p.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(c){if(!this.levels){this.startPosition=c,this.state=p.State.STOPPED;return}var f=this.lastCurrentTime;this.stopLoad(),this.setInterval(n),this.fragLoadError=0,f>0&&c===-1?(this.log("Override startPosition with lastCurrentTime @"+f.toFixed(3)),c=f,this.state=p.State.IDLE):(this.loadedmetadata=!1,this.state=p.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},d.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_TRACK:{var c,f=this.levels,o=this.trackId,v=f==null||(c=f[o])===null||c===void 0?void 0:c.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=p.State.WAITING_INIT_PTS}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var m,O=performance.now(),b=this.retryDate;(!b||O>=b||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=p.State.IDLE);break}case p.State.WAITING_INIT_PTS:{var M=this.waitingData;if(M){var F=M.frag,w=M.part,C=M.cache,U=M.complete;if(this.initPTS[F.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.FRAG_LOADING;var B=C.flush(),N={frag:F,part:w,payload:B,networkDetails:null};this._handleFragmentLoadProgress(N),U&&t.prototype._handleFragmentLoadComplete.call(this,N)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+F.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var k=this.getLoadPosition(),j=I.BufferHelper.bufferInfo(this.mediaBuffer,k,this.config.maxBufferHole),H=Object(g.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,F);H<0&&(this.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=p.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var c=this.waitingData;c&&(this.fragmentTracker.removeFragment(c.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.IDLE)},d.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},d.onTickEnd=function(){var c=this.media;if(!(!c||!c.readyState)){var f=this.mediaBuffer?this.mediaBuffer:c,o=f.buffered;!this.loadedmetadata&&o.length&&(this.loadedmetadata=!0),this.lastCurrentTime=c.currentTime}},d.doTickIdle=function(){var c,f,o=this.hls,v=this.levels,m=this.media,O=this.trackId,b=o.config;if(!(!v||!v[O])&&!(!m&&(this.startFragRequested||!b.startFragPrefetch))){var M=v[O],F=M.details;if(!F||F.live&&this.levelLastLoaded!==O||this.waitForCdnTuneIn(F)){this.state=p.State.WAITING_TRACK;return}var w=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&w&&(this.bufferFlushed=!1,this.afterBufferFlushed(w,y.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(w,A.PlaylistLevelType.AUDIO);if(C!==null){var U=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.PlaylistLevelType.MAIN),B=C.len,N=this.getMaxBufferLength(U==null?void 0:U.len),k=this.audioSwitch;if(!(B>=N&&!k)){if(!k&&this._streamEnded(C,F)){o.trigger(S.Events.BUFFER_EOS,{type:"audio"}),this.state=p.State.ENDED;return}var j=F.fragments,H=j[0].start,V=C.end;if(k&&m){var Y=this.getLoadPosition();V=Y,F.PTSKnown&&Y<H&&(C.end>H||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),m.currentTime=H+.05)}if(!(U&&V>U.end+F.targetduration)&&!((!U||!U.len)&&C.len)){var Q=this.getNextFragment(V,F);if(!Q){this.bufferFlushed=!0;return}((c=Q.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((f=Q.decryptdata)!==null&&f!==void 0&&f.key)?this.loadKey(Q,F):this.loadFragment(Q,F,V)}}}}},d.getMaxBufferLength=function(c){var f=t.prototype.getMaxBufferLength.call(this);return c?Math.max(f,c):f},d.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(c,f){var o=f.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(v){return new L.Level(v)})},d.onAudioTrackSwitching=function(c,f){var o=!!f.url;this.trackId=f.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),o?this.setInterval(n):this.resetTransmuxer(),o?(this.audioSwitch=!0,this.state=p.State.IDLE):this.state=p.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(c,f){this.mainDetails=f.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(S.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},d.onAudioTrackLoaded=function(c,f){var o;if(this.mainDetails==null){this.cachedTrackLoadedData=f;return}var v=this.levels,m=f.details,O=f.id;if(!v){this.warn("Audio tracks were reset while loading level "+O);return}this.log("Track "+O+" loaded ["+m.startSN+","+m.endSN+"],duration:"+m.totalduration);var b=v[O],M=0;if(m.live||(o=b.details)!==null&&o!==void 0&&o.live){var F=this.mainDetails;if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed||!F)return;!b.details&&m.hasProgramDateTime&&F.hasProgramDateTime?(Object(E.alignMediaPlaylistByPDT)(m,F),M=m.fragments[0].start):M=this.alignPlaylists(m,b.details)}b.details=m,this.levelLastLoaded=O,!this.startFragRequested&&(this.mainDetails||!m.live)&&this.setStartPosition(b.details,M),this.state===p.State.WAITING_TRACK&&!this.waitForCdnTuneIn(m)&&(this.state=p.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(c){var f,o=c.frag,v=c.part,m=c.payload,O=this.config,b=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var F=M[b];console.assert(F,"Audio track is defined on fragment load progress");var w=F.details;console.assert(w,"Audio track details are defined on fragment load progress");var C=O.defaultAudioCodec||F.audioCodec||"mp4a.40.2",U=this.transmuxer;U||(U=this.transmuxer=new _.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var B=this.initPTS[o.cc],N=(f=o.initSegment)===null||f===void 0?void 0:f.data;if(B!==void 0){var k=!1,j=v?v.index:-1,H=j!==-1,V=new T.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,m.byteLength,j,H);U.push(m,N,C,"",o,v,w.totalduration,k,V,B)}else{this.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+b);var Y=this.waitingData=this.waitingData||{frag:o,part:v,cache:new D.default,complete:!1},Q=Y.cache;Q.push(new Uint8Array(m)),this.waitingVideoCC=this.videoTrackCC,this.state=p.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(c){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,c)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(c,f){var o=f.tracks.audio;o&&(this.mediaBuffer=o.buffer||null),f.tracks.video&&(this.videoBuffer=f.tracks.video.buffer||null)},d.onFragBuffered=function(c,f){var o=f.frag,v=f.part;if(o.type===A.PlaylistLevelType.AUDIO){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(v?" p: "+v.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}o.sn!=="initSegment"&&(this.fragPrevious=o,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(S.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(o,v)}},d.onError=function(c,f){switch(f.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,f);break;case a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==p.State.ERROR&&this.state!==p.State.STOPPED&&(this.state=f.fatal?p.State.ERROR:p.State.IDLE,this.warn(f.details+" while loading frag, switching to "+this.state+" state"));break;case a.ErrorDetails.BUFFER_FULL_ERROR:if(f.parent==="audio"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var o=!0,v=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);v&&v.len>.5&&(o=!this.reduceMaxBufferLength(v.len)),o&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},d.onBufferFlushed=function(c,f){var o=f.type;o===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(c){var f,o="audio",v=this.hls,m=c.remuxResult,O=c.chunkMeta,b=this.getCurrentContext(O);if(!b){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(O.level);return}var M=b.frag,F=b.part,w=b.level.details,C=m.audio,U=m.text,B=m.id3,N=m.initSegment;if(!(this.fragContextChanged(M)||!w)){if(this.state=p.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),N!=null&&N.tracks&&(this._bufferInitSegment(N.tracks,M,O),v.trigger(S.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:o,tracks:N.tracks})),C){var k=C.startPTS,j=C.endPTS,H=C.startDTS,V=C.endDTS;F&&(F.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:k,endPTS:j,startDTS:H,endDTS:V}),M.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,k,j,H,V),this.bufferFragmentData(C,M,F,O)}if(B!=null&&(f=B.samples)!==null&&f!==void 0&&f.length){var Y=e({id:o,frag:M,details:w},B);v.trigger(S.Events.FRAG_PARSING_METADATA,Y)}if(U){var Q=e({id:o,frag:M,details:w},U);v.trigger(S.Events.FRAG_PARSING_USERDATA,Q)}}},d._bufferInitSegment=function(c,f,o){if(this.state===p.State.PARSING){c.video&&delete c.video;var v=c.audio;if(!!v){v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(S.Events.BUFFER_CODECS,c);var m=v.initSegment;if(m!=null&&m.byteLength){var O={type:"audio",frag:f,part:null,chunkMeta:o,parent:f.type,data:m};this.hls.trigger(S.Events.BUFFER_APPENDING,O)}this.tick()}}},d.loadFragment=function(c,f,o){var v=this.fragmentTracker.getState(c);this.fragCurrent=c,(this.audioSwitch||v===x.FragmentState.NOT_LOADED||v===x.FragmentState.PARTIAL)&&(c.sn==="initSegment"?this._loadInitSegment(c):f.live&&!Object(R.isFiniteNumber)(this.initPTS[c.cc])?(this.log("Waiting for video PTS in continuity counter "+c.cc+" of live stream before loading audio fragment "+c.sn+" of level "+this.trackId),this.state=p.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,c,f,o)))},d.completeAudioSwitch=function(){var c=this.hls,f=this.media,o=this.trackId;f&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,c.trigger(S.Events.AUDIO_TRACK_SWITCHED,{id:o})},l}(p.default);P.default=i},"./src/controller/audio-track-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/controller/base-playlist-controller.ts"),I=h("./src/types/loader.ts");function x(_,T){for(var g=0;g<T.length;g++){var E=T[g];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(_,E.key,E)}}function L(_,T,g){return T&&x(_.prototype,T),g&&x(_,g),Object.defineProperty(_,"prototype",{writable:!1}),_}function A(_,T){_.prototype=Object.create(T.prototype),_.prototype.constructor=_,y(_,T)}function y(_,T){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,a){return E.__proto__=a,E},y(_,T)}var D=function(_){A(T,_);function T(E){var a;return a=_.call(this,E,"[audio-track-controller]")||this,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.trackName="",a.selectDefaultTrack=!0,a.registerListeners(),a}var g=T.prototype;return g.registerListeners=function(){var a=this.hls;a.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(R.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var a=this.hls;a.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(R.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,_.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(a,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(a,e){var s=e.id,u=e.details,n=this.tracksInGroup[s];if(!n){this.warn("Invalid audio track id "+s);return}var i=n.details;n.details=e.details,this.log("audioTrack "+s+" loaded ["+u.startSN+"-"+u.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},g.onLevelLoading=function(a,e){this.switchLevel(e.level)},g.onLevelSwitching=function(a,e){this.switchLevel(e.level)},g.switchLevel=function(a){var e=this.hls.levels[a];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var u=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!u.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var n={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}}},g.onError=function(a,e){_.prototype.onError.call(this,a,e),!(e.fatal||!e.context)&&e.context.type===I.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},g.setAudioTrack=function(a){var e=this.tracksInGroup;if(a<0||a>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+a);var u=e[a],n=u.id,i=u.groupId,t=i===void 0?"":i,l=u.name,d=u.type,r=u.url;if(this.trackId=a,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:t,name:l,type:d,url:r}),!(u.details&&!u.details.live)){var c=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(c)}},g.selectInitialTrack=function(){var a=this.tracksInGroup;console.assert(a.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(a){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var u=e[s];if((!this.selectDefaultTrack||u.default)&&(!a||a===u.name))return u.id}return-1},g.loadPlaylist=function(a){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,u=e.groupId,n=e.url;if(a)try{n=a.addDirectives(n)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:u,deliveryDirectives:a||null})}},L(T,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1,this.setAudioTrack(a)}}]),T}(S.default);P.default=D},"./src/controller/base-playlist-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return L});var R=h("./src/polyfills/number.ts"),p=h("./src/types/level.ts"),S=h("./src/controller/level-helper.ts"),I=h("./src/utils/logger.ts"),x=h("./src/errors.ts"),L=function(){function A(D,_){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=I.logger.log.bind(I.logger,_+":"),this.warn=I.logger.warn.bind(I.logger,_+":"),this.hls=D}var y=A.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(_,T){T.fatal&&T.type===x.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(_,T){var g=T==null?void 0:T.renditionReports;if(g)for(var E=0;E<g.length;E++){var a=g[E],e=""+a.URI;if(e===_.slice(-e.length)){var s=parseInt(a["LAST-MSN"]),u=parseInt(a["LAST-PART"]);if(T&&this.hls.config.lowLatencyMode){var n=Math.min(T.age-T.partTarget,T.targetduration);u!==void 0&&n>T.partTarget&&(u+=1)}if(Object(R.isFiniteNumber)(s))return new p.HlsUrlParameters(s,Object(R.isFiniteNumber)(u)?u:void 0,p.HlsSkip.No)}}},y.loadPlaylist=function(_){},y.shouldLoadTrack=function(_){return this.canLoad&&_&&!!_.url&&(!_.details||_.details.live)},y.playlistLoaded=function(_,T,g){var E=this,a=T.details,e=T.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(a.advancedDateTime=Date.now()-s,a.live||g!=null&&g.live){if(a.reloaded(g),g&&this.log("live playlist "+_+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),g&&a.fragments.length>0&&Object(S.mergeDetails)(g,a),!this.canLoad||!a.live)return;var u,n=void 0,i=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var t=this.hls.config.lowLatencyMode,l=a.lastPartSn,d=a.endSN,r=a.lastPartIndex,c=r!==-1,f=l===d,o=t?0:r;c?(n=f?d+1:l,i=f?o:r+1):n=d+1;var v=a.age,m=v+a.ageHeader,O=Math.min(m-a.partTarget,a.targetduration*1.5);if(O>0){if(g&&O>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+O+" with playlist age: "+a.age),O=0;else{var b=Math.floor(O/a.targetduration);if(n+=b,i!==void 0){var M=Math.round(O%a.targetduration/a.partTarget);i+=M}this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+O+" skip sn "+b+" to part "+i)}a.tuneInGoal=O}if(u=this.getDeliveryDirectives(a,T.deliveryDirectives,n,i),t||!f){this.loadPlaylist(u);return}}else u=this.getDeliveryDirectives(a,T.deliveryDirectives,n,i);var F=Object(S.computeReloadInterval)(a,e);n!==void 0&&a.canBlockReload&&(F-=a.partTarget||1),this.log("reload live playlist "+_+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(u)},F)}else this.clearTimer()},y.getDeliveryDirectives=function(_,T,g,E){var a=Object(p.getSkipValue)(_,g);return T!=null&&T.skip&&_.deltaUpdateFailed&&(g=T.msn,E=T.part,a=p.HlsSkip.No),new p.HlsUrlParameters(g,E,a)},y.retryLoadingOrFail=function(_){var T=this,g=this.hls.config,E=this.retryCount<g.levelLoadingMaxRetry;if(E){var a;if(this.retryCount++,_.details.indexOf("LoadTimeOut")>-1&&(a=_.context)!==null&&a!==void 0&&a.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+_.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+_.details+'"')}}else this.warn('cannot recover from error "'+_.details+'"'),this.clearTimer(),_.fatal=!0;return E},A}()},"./src/controller/base-stream-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"State",function(){return d}),h.d(P,"default",function(){return r});var R=h("./src/polyfills/number.ts"),p=h("./src/task-loop.ts"),S=h("./src/controller/fragment-tracker.ts"),I=h("./src/utils/buffer-helper.ts"),x=h("./src/utils/logger.ts"),L=h("./src/events.ts"),A=h("./src/errors.ts"),y=h("./src/types/transmuxer.ts"),D=h("./src/utils/mp4-tools.ts"),_=h("./src/utils/discontinuities.ts"),T=h("./src/controller/fragment-finders.ts"),g=h("./src/controller/level-helper.ts"),E=h("./src/loader/fragment-loader.ts"),a=h("./src/crypt/decrypter.ts"),e=h("./src/utils/time-ranges.ts"),s=h("./src/types/loader.ts");function u(c,f){for(var o=0;o<f.length;o++){var v=f[o];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(c,v.key,v)}}function n(c,f,o){return f&&u(c.prototype,f),o&&u(c,o),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function t(c,f){c.prototype=Object.create(f.prototype),c.prototype.constructor=c,l(c,f)}function l(c,f){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,m){return v.__proto__=m,v},l(c,f)}var d={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},r=function(c){t(f,c);function f(v,m,O){var b;return b=c.call(this)||this,b.hls=void 0,b.fragPrevious=null,b.fragCurrent=null,b.fragmentTracker=void 0,b.transmuxer=null,b._state=d.STOPPED,b.media=null,b.mediaBuffer=null,b.config=void 0,b.bitrateTest=!1,b.lastCurrentTime=0,b.nextLoadPosition=0,b.startPosition=0,b.loadedmetadata=!1,b.fragLoadError=0,b.retryDate=0,b.levels=null,b.fragmentLoader=void 0,b.levelLastLoaded=null,b.startFragRequested=!1,b.decrypter=void 0,b.initPTS=[],b.onvseeking=null,b.onvended=null,b.logPrefix="",b.log=void 0,b.warn=void 0,b.logPrefix=O,b.log=x.logger.log.bind(x.logger,O+":"),b.warn=x.logger.warn.bind(x.logger,O+":"),b.hls=v,b.fragmentLoader=new E.default(v.config),b.fragmentTracker=m,b.config=v.config,b.decrypter=new a.default(v,v.config),v.on(L.Events.KEY_LOADED,b.onKeyLoaded,i(b)),v.on(L.Events.LEVEL_SWITCHING,b.onLevelSwitching,i(b)),b}var o=f.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(m){},o.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},o._streamEnded=function(m,O){var b=this.fragCurrent,M=this.fragmentTracker;if(!O.live&&b&&this.media&&b.sn>=O.endSN&&!m.nextStart){var F=O.partList;if(F!=null&&F.length){var w=F[F.length-1],C=I.BufferHelper.isBuffered(this.media,w.start+w.duration/2);return C}var U=M.getState(b);return U===S.FragmentState.PARTIAL||U===S.FragmentState.OK}return!1},o.onMediaAttached=function(m,O){var b=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),b.addEventListener("seeking",this.onvseeking),b.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===d.STOPPED&&this.startLoad(M.startPosition)},o.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&this.onvseeking&&this.onvended&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var m=this.config,O=this.fragCurrent,b=this.media,M=this.mediaBuffer,F=this.state,w=b?b.currentTime:0,C=I.BufferHelper.bufferInfo(M||b,w,m.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(w)?w.toFixed(3):w)+", state: "+F),F===d.ENDED)this.resetLoadingState();else if(O&&!C.len){var U=m.maxFragLookUpTolerance,B=O.start-U,N=O.start+O.duration+U,k=w>N;(w<B||k)&&(k&&O.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),O.loader.abort()),this.resetLoadingState())}b&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(m,O){if(!(this.state!==d.KEY_LOADING||O.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var b=this.levels[O.frag.level].details;b&&this.loadFragment(O.frag,b,O.frag.start)}},o.onLevelSwitching=function(m,O){this.fragLoadError=0},o.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=d.STOPPED,this.hls.off(L.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(L.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,c.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(m,O){this.log("Loading key for "+m.sn+" of ["+O.startSN+"-"+O.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=d.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(L.Events.KEY_LOADING,{frag:m})},o.loadFragment=function(m,O,b){this._loadFragForPlayback(m,O,b)},o._loadFragForPlayback=function(m,O,b){var M=this,F=function(C){if(M.fragContextChanged(m)){M.warn("Fragment "+m.sn+(C.part?" p: "+C.part.index:"")+" of level "+m.level+" was dropped during download."),M.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(m,O,b,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===d.FRAG_LOADING||!M.fragCurrent&&C===d.PARSING)&&(M.fragmentTracker.removeFragment(m),M.state=d.IDLE);return}"payload"in w&&(M.log("Loaded fragment "+m.sn+" of level "+m.level),M.hls.trigger(L.Events.FRAG_LOADED,w)),M._handleFragmentLoadComplete(w)}}).catch(function(w){M.state===d.STOPPED||M.state===d.ERROR||(M.warn(w),M.resetFragmentLoading(m))})},o.flushMainBuffer=function(m,O,b){if(b===void 0&&(b=null),!!(m-O)){var M={startOffset:m,endOffset:O,type:b};this.fragLoadError=0,this.hls.trigger(L.Events.BUFFER_FLUSHING,M)}},o._loadInitSegment=function(m){var O=this;this._doFragLoad(m).then(function(b){if(!b||O.fragContextChanged(m)||!O.levels)throw new Error("init load aborted");return b}).then(function(b){var M=O.hls,F=b.payload,w=m.decryptdata;if(F&&F.byteLength>0&&w&&w.key&&w.iv&&w.method==="AES-128"){var C=self.performance.now();return O.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(U){var B=self.performance.now();return M.trigger(L.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:C,tdecrypt:B}}),b.payload=U,b})}return b}).then(function(b){var M=O.fragCurrent,F=O.hls,w=O.levels;if(!w)throw new Error("init load aborted, missing levels");var C=w[m.level].details;console.assert(C,"Level details are defined when init segment is loaded");var U=m.stats;O.state=d.IDLE,O.fragLoadError=0,m.data=new Uint8Array(b.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),b.frag===M&&F.trigger(L.Events.FRAG_BUFFERED,{stats:U,frag:M,part:null,id:m.type}),O.tick()}).catch(function(b){O.state===d.STOPPED||O.state===d.ERROR||(O.warn(b),O.resetFragmentLoading(m))})},o.fragContextChanged=function(m){var O=this.fragCurrent;return!m||!O||m.level!==O.level||m.sn!==O.sn||m.urlId!==O.urlId},o.fragBufferedComplete=function(m,O){var b=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(O?" part: "+O.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+(b?e.default.toString(I.BufferHelper.getBuffered(b)):"(detached)")),this.state=d.IDLE,b&&(!this.loadedmetadata&&b.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},o.seekToStartPos=function(){},o._handleFragmentLoadComplete=function(m){var O=this.transmuxer;if(!!O){var b=m.frag,M=m.part,F=m.partsLoaded,w=!F||F.length===0||F.some(function(U){return!U}),C=new y.ChunkMetadata(b.level,b.sn,b.stats.chunkCount+1,0,M?M.index:-1,!w);O.flush(C)}},o._handleFragmentLoadProgress=function(m){},o._doFragLoad=function(m,O,b,M){var F=this;if(b===void 0&&(b=null),!this.levels)throw new Error("frag load aborted, missing levels");if(b=Math.max(m.start,b||0),this.config.lowLatencyMode&&O){var w=O.partList;if(w&&M){b>m.end&&O.fragmentHint&&(m=O.fragmentHint);var C=this.getNextPart(w,m,b);if(C>-1){var U=w[C];return this.log("Loading part sn: "+m.sn+" p: "+U.index+" cc: "+m.cc+" of playlist ["+O.startSN+"-"+O.endSN+"] parts [0-"+C+"-"+(w.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=d.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,part:w[C],targetBufferTime:b}),this.doFragPartsLoad(m,w,C,M).catch(function(B){return F.handleFragLoadError(B)})}else if(!m.url||this.loadedEndOfParts(w,b))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(O?"of ["+O.startSN+"-"+O.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),Object(R.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=d.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:m,targetBufferTime:b}),this.fragmentLoader.load(m,M).catch(function(B){return F.handleFragLoadError(B)})},o.doFragPartsLoad=function(m,O,b,M){var F=this;return new Promise(function(w,C){var U=[],B=function N(k){var j=O[k];F.fragmentLoader.loadPart(m,j,M).then(function(H){U[j.index]=H;var V=H.part;F.hls.trigger(L.Events.FRAG_LOADED,H);var Y=O[k+1];if(Y&&Y.fragment===m)N(k+1);else return w({frag:m,part:V,partsLoaded:U})}).catch(C)};B(b)})},o.handleFragLoadError=function(m){var O=m.data;return O&&O.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(O.frag,O.part):this.hls.trigger(L.Events.ERROR,O),null},o._handleTransmuxerFlush=function(m){var O=this.getCurrentContext(m);if(!O||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var b=O.frag,M=O.part,F=O.level,w=self.performance.now();b.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(b,M,F,m.partial)},o.getCurrentContext=function(m){var O=this.levels,b=m.level,M=m.sn,F=m.part;if(!O||!O[b])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+b+". The current chunk will not be buffered."),null;var w=O[b],C=F>-1?Object(g.getPartWith)(w,M,F):null,U=C?C.fragment:Object(g.getFragmentWithSN)(w,M,this.fragCurrent);return U?{frag:U,part:C,level:w}:null},o.bufferFragmentData=function(m,O,b,M){if(!(!m||this.state!==d.PARSING)){var F=m.data1,w=m.data2,C=F;if(F&&w&&(C=Object(D.appendUint8Array)(F,w)),!(!C||!C.length)){var U={type:m.type,frag:O,part:b,chunkMeta:M,parent:O.type,data:C};this.hls.trigger(L.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!b&&this.flushBufferGap(O)}}},o.flushBufferGap=function(m){var O=this.media;if(!!O){if(!I.BufferHelper.isBuffered(O,O.currentTime)){this.flushMainBuffer(0,m.start);return}var b=O.currentTime,M=I.BufferHelper.bufferInfo(O,b,0),F=m.duration,w=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(m.start-w,M.end-w),b+w);m.start-C>w&&this.flushMainBuffer(C,m.start)}},o.getFwdBufferInfo=function(m,O){var b=this.config,M=this.getLoadPosition();if(!Object(R.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(m,M,b.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var w=this.fragmentTracker.getBufferedFrag(M,O);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,b.maxBufferHole))}return F},o.getMaxBufferLength=function(m){var O=this.config,b;return m?b=Math.max(8*O.maxBufferSize/m,O.maxBufferLength):b=O.maxBufferLength,Math.min(b,O.maxMaxBufferLength)},o.reduceMaxBufferLength=function(m){var O=this.config,b=m||O.maxBufferLength;return O.maxMaxBufferLength>=b?(O.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+O.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(m,O){var b=O.fragments,M=b.length;if(!M)return null;var F=this.config,w=b[0].start,C;if(O.live){var U=F.initialLiveManifestSize;if(M<U)return this.warn("Not enough fragments to start playback (have: "+M+", need: "+U+")"),null;!O.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(C=this.getInitialLiveFragment(O,b),this.startPosition=C?this.hls.liveSyncPosition||C.start:m)}else m<=w&&(C=b[0]);if(!C){var B=F.lowLatencyMode?O.partEnd:O.fragmentEnd;C=this.getFragmentAtPosition(m,B,O)}return this.mapToInitFragWhenRequired(C)},o.mapToInitFragWhenRequired=function(m){return m!=null&&m.initSegment&&!(m!=null&&m.initSegment.data)&&!this.bitrateTest?m.initSegment:m},o.getNextPart=function(m,O,b){for(var M=-1,F=!1,w=!0,C=0,U=m.length;C<U;C++){var B=m[C];if(w=w&&!B.independent,M>-1&&b<B.start)break;var N=B.loaded;!N&&(F||B.independent||w)&&B.fragment===O&&(M=C),F=N}return M},o.loadedEndOfParts=function(m,O){var b=m[m.length-1];return b&&O>b.start&&b.loaded},o.getInitialLiveFragment=function(m,O){var b=this.fragPrevious,M=null;if(b){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+b.programDateTime),M=Object(T.findFragmentByPDT)(O,b.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=b.sn+1;if(F>=m.startSN&&F<=m.endSN){var w=O[F-m.startSN];b.cc===w.cc&&(M=w,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(T.findFragWithCC)(O,b.cc),M&&this.log("Live playlist, switching playlist, load frag with same CC: "+M.sn))}}else{var C=this.hls.liveSyncPosition;C!==null&&(M=this.getFragmentAtPosition(C,this.bitrateTest?m.fragmentEnd:m.edge,m))}return M},o.getFragmentAtPosition=function(m,O,b){var M=this.config,F=this.fragPrevious,w=b.fragments,C=b.endSN,U=b.fragmentHint,B=M.maxFragLookUpTolerance,N=!!(M.lowLatencyMode&&b.partList&&U);N&&U&&!this.bitrateTest&&(w=w.concat(U),C=U.sn);var k;if(m<O){var j=m>O-B?0:B;k=Object(T.findFragmentByPTS)(F,w,m,j)}else k=w[w.length-1];if(k){var H=k.sn-b.startSN;if(F&&k.sn===F.sn&&!N){var V=F&&k.level===F.level;if(V){var Y=w[H+1];k.sn<C&&this.fragmentTracker.getState(Y)!==S.FragmentState.OK?(this.log("SN "+k.sn+" just loaded, load next one: "+Y.sn),k=Y):k=null}}}return k},o.synchronizeToLiveEdge=function(m){var O=this.config,b=this.media;if(!!b){var M=this.hls.liveSyncPosition,F=b.currentTime,w=m.fragments[0].start,C=m.edge,U=F>=w-O.maxFragLookUpTolerance&&F<=C;if(M!==null&&b.duration>M&&(F<M||!U)){var B=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*m.targetduration;(!U&&b.readyState<4||F<C-B)&&(this.loadedmetadata||(this.nextLoadPosition=M),b.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+C+", reset currentTime to : "+M.toFixed(3)),b.currentTime=M))}}},o.alignPlaylists=function(m,O){var b=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,w=M!==null?b[M]:null,C=m.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var U=m.fragments[0].start,B=!O,N=m.alignedSliding&&Object(R.isFiniteNumber)(U);if(B||!N&&!U){Object(_.alignStream)(F,w,m);var k=m.fragments[0].start;return this.log("Live playlist sliding: "+k.toFixed(2)+" start-sn: "+(O?O.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),k}return U},o.waitForCdnTuneIn=function(m){var O=3;return m.live&&m.canBlockReload&&m.partTarget&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*O)},o.setStartPosition=function(m,O){var b=this.startPosition;if(b<O&&(b=-1),b===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(R.isFiniteNumber)(M)?(b=O+M,M<0&&(b+=m.totalduration),b=Math.min(Math.max(O,b),O+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+b),this.startPosition=b):m.live?b=this.hls.liveSyncPosition||O:this.startPosition=b=0,this.lastCurrentTime=b}this.nextLoadPosition=b},o.getLoadPosition=function(){var m=this.media,O=0;return this.loadedmetadata&&m?O=m.currentTime:this.nextLoadPosition&&(O=this.nextLoadPosition),O},o.handleFragLoadAborted=function(m,O){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(O?" part"+O.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},o.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m)&&this.state!==d.FRAG_LOADING_WAITING_RETRY)&&(this.state=d.IDLE)},o.onFragmentOrKeyLoadError=function(m,O){if(!O.fatal){var b=O.frag;if(!(!b||b.type!==m)){var M=this.fragCurrent;console.assert(M&&b.sn===M.sn&&b.level===M.level&&b.urlId===M.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var w=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+b.sn+" of "+m+" "+b.level+" failed to load, retrying in "+w+"ms"),this.retryDate=self.performance.now()+w,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else O.levelRetry?(m===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(x.logger.error(O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},o.afterBufferFlushed=function(m,O,b){if(!!m){var M=I.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(O,M,b),this.state===d.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},o.resetStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var O=this.levels?this.levels[m].details:null;O!=null&&O.live?(this.startPosition=-1,this.setStartPosition(O,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},o.updateLevelTiming=function(m,O,b,M){var F=this,w=b.details;console.assert(!!w,"level.details must be defined");var C=Object.keys(m.elementaryStreams).reduce(function(U,B){var N=m.elementaryStreams[B];if(N){var k=N.endPTS-N.startPTS;if(k<=0)return F.warn("Could not parse fragment "+m.sn+" "+B+" duration reliably ("+k+")"),U||!1;var j=M?0:Object(g.updateFragPTSDTS)(w,m,N.startPTS,N.endPTS,N.startDTS,N.endDTS);return F.hls.trigger(L.Events.LEVEL_PTS_UPDATED,{details:w,level:b,drift:j,type:B,frag:m,start:N.startPTS,end:N.endPTS}),!0}return U},!1);C||(this.warn("Found no media in fragment "+m.sn+" of level "+b.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=d.PARSED,this.hls.trigger(L.Events.FRAG_PARSED,{frag:m,part:O})},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},n(f,[{key:"state",get:function(){return this._state},set:function(m){var O=this._state;O!==m&&(this._state=m,this.log(O+"->"+m))}}]),f}(p.default)},"./src/controller/buffer-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T});var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/utils/logger.ts"),I=h("./src/errors.ts"),x=h("./src/utils/buffer-helper.ts"),L=h("./src/utils/mediasource-helper.ts"),A=h("./src/loader/fragment.ts"),y=h("./src/controller/buffer-operation-queue.ts"),D=Object(L.getMediaSource)(),_=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function g(a){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=e.hls,u=e.media,n=e.mediaSource;S.logger.log("[buffer-controller]: Media source opened"),u&&(e.updateMediaElementDuration(),s.trigger(p.Events.MEDIA_ATTACHED,{media:u})),n&&n.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){S.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){S.logger.log("[buffer-controller]: Media source ended")},this.hls=a,this._initSourceBuffer(),this.registerListeners()}var E=g.prototype;return E.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},E.destroy=function(){this.unregisterListeners(),this.details=null},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},E.onManifestParsed=function(e,s){var u=2;(s.audio&&!s.video||!s.altAudio)&&(u=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=u,this.details=null,S.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},E.onMediaAttaching=function(e,s){var u=this.media=s.media;if(u&&D){var n=this.mediaSource=new D;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),u.src=self.URL.createObjectURL(n),this._objectUrl=u.src}},E.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,u=this._objectUrl;if(s){if(S.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(n){S.logger.warn("[buffer-controller]: onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(u&&self.URL.revokeObjectURL(u),e.src===u?(e.removeAttribute("src"),e.load()):S.logger.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(p.Events.MEDIA_DETACHED,void 0)},E.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var u=e.sourceBuffer[s];try{u&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(u),e.sourceBuffer[s]=void 0)}catch(n){S.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",n)}}),this._initSourceBuffer()},E.onBufferCodecs=function(e,s){var u=this,n=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(n){var t=u.tracks[i];if(t&&typeof t.buffer.changeType=="function"){var l=s[i],d=l.id,r=l.codec,c=l.levelCodec,f=l.container,o=l.metadata,v=(t.levelCodec||t.codec).replace(_,"$1"),m=(c||r).replace(_,"$1");if(v!==m){var O=f+";codecs="+(c||r);u.appendChangeType(i,O),S.logger.log("[buffer-controller]: switching codec "+v+" to "+m),u.tracks[i]={buffer:t.buffer,codec:r,container:f,levelCodec:c,metadata:o,id:d}}}}else u.pendingTracks[i]=s[i]}),!n&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},E.appendChangeType=function(e,s){var u=this,n=this.operationQueue,i={execute:function(){var l=u.sourceBuffer[e];l&&(S.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),l.changeType(s)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(l){S.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",l)}};n.append(i,e)},E.onBufferAppending=function(e,s){var u=this,n=this.hls,i=this.operationQueue,t=this.tracks,l=s.data,d=s.type,r=s.frag,c=s.part,f=s.chunkMeta,o=f.buffering[d],v=self.performance.now();o.start=v;var m=r.stats.buffering,O=c?c.stats.buffering:null;m.start===0&&(m.start=v),O&&O.start===0&&(O.start=v);var b=t.audio,M=d==="audio"&&f.id===1&&(b==null?void 0:b.container)==="audio/mpeg",F={execute:function(){if(o.executeStart=self.performance.now(),M){var C=u.sourceBuffer[d];if(C){var U=r.start-C.timestampOffset;Math.abs(U)>=.1&&(S.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+r.start+" (delta: "+U+") sn: "+r.sn+")"),C.timestampOffset=r.start)}}u.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var C=self.performance.now();o.executeEnd=o.end=C,m.first===0&&(m.first=C),O&&O.first===0&&(O.first=C);var U=u.sourceBuffer,B={};for(var N in U)B[N]=x.BufferHelper.getBuffered(U[N]);u.appendError=0,u.hls.trigger(p.Events.BUFFER_APPENDED,{type:d,frag:r,part:c,chunkMeta:f,parent:r.type,timeRanges:B})},onError:function(C){S.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",C);var U={type:I.ErrorTypes.MEDIA_ERROR,parent:r.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=I.ErrorDetails.BUFFER_FULL_ERROR:(u.appendError++,U.details=I.ErrorDetails.BUFFER_APPEND_ERROR,u.appendError>n.config.appendErrorMaxRetry&&(S.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0,n.stopLoad())),n.trigger(p.Events.ERROR,U)}};i.append(F,d)},E.onBufferFlushing=function(e,s){var u=this,n=this.operationQueue,i=function(l){return{execute:u.removeExecutor.bind(u,l,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){u.hls.trigger(p.Events.BUFFER_FLUSHED,{type:l})},onError:function(r){S.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",r)}}};s.type?n.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(t){n.append(i(t),t)})},E.onFragParsed=function(e,s){var u=this,n=s.frag,i=s.part,t=[],l=i?i.elementaryStreams:n.elementaryStreams;l[A.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(l[A.ElementaryStreamTypes.AUDIO]&&t.push("audio"),l[A.ElementaryStreamTypes.VIDEO]&&t.push("video"));var d=function(){var c=self.performance.now();n.stats.buffering.end=c,i&&(i.stats.buffering.end=c);var f=i?i.stats:n.stats;u.hls.trigger(p.Events.FRAG_BUFFERED,{frag:n,part:i,stats:f,id:n.type})};t.length===0&&S.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(d,t)},E.onFragChanged=function(e,s){this.flushBackBuffer()},E.onBufferEos=function(e,s){var u=this,n=this.getSourceBufferTypes().reduce(function(i,t){var l=u.sourceBuffer[t];return(!s.type||s.type===t)&&l&&!l.ended&&(l.ended=!0,S.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),i&&!!(!l||l.ended)},!0);n&&this.blockBuffers(function(){var i=u.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},E.onLevelUpdated=function(e,s){var u=s.details;!u.fragments.length||(this.details=u,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},E.flushBackBuffer=function(){var e=this.hls,s=this.details,u=this.media,n=this.sourceBuffer;if(!(!u||s===null)){var i=this.getSourceBufferTypes();if(!!i.length){var t=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(R.isFiniteNumber)(t)||t<0)){var l=u.currentTime,d=s.levelTargetDuration,r=Math.max(t,d),c=Math.floor(l/d)*d-r;i.forEach(function(f){var o=n[f];if(o){var v=x.BufferHelper.getBuffered(o);v.length>0&&c>v.start(0)&&(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),s.live&&e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:f}))}})}}}},E.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,u=this.media,n=this.mediaSource,i=e.fragments[0].start+e.totalduration,t=u.duration,l=Object(R.isFiniteNumber)(n.duration)?n.duration:0;e.live&&s.config.liveDurationInfinity?(S.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(i>l&&i>t||!Object(R.isFiniteNumber)(t))&&(S.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),n.duration=i)}},E.updateSeekableRange=function(e){var s=this.mediaSource,u=e.fragments,n=u.length;if(n&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,u[0].start),t=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,t)}},E.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,u=this.pendingTracks,n=Object.keys(u).length;if(n&&!e||n===2){this.createSourceBuffers(u),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(t){s.executeNext(t)})}},E.createSourceBuffers=function(e){var s=this.sourceBuffer,u=this.mediaSource;if(!u)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var i in e)if(!s[i]){var t=e[i];if(!t)throw Error("source buffer exists for track "+i+", however track does not");var l=t.levelCodec||t.codec,d=t.container+";codecs="+l;S.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var r=s[i]=u.addSourceBuffer(d),c=i;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[i]={buffer:r,codec:l,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id},n++}catch(f){S.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+f.message),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}n&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},E._onSBUpdateStart=function(e){var s=this.operationQueue,u=s.current(e);u.onStart()},E._onSBUpdateEnd=function(e){var s=this.operationQueue,u=s.current(e);u.onComplete(),s.shiftAndExecuteNext(e)},E._onSBUpdateError=function(e,s){S.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var u=this.operationQueue.current(e);u&&u.onError(s)},E.removeExecutor=function(e,s,u){var n=this.media,i=this.mediaSource,t=this.operationQueue,l=this.sourceBuffer,d=l[e];if(!n||!i||!d){S.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(e);return}var r=Object(R.isFiniteNumber)(n.duration)?n.duration:1/0,c=Object(R.isFiniteNumber)(i.duration)?i.duration:1/0,f=Math.max(0,s),o=Math.min(u,r,c);o>f?(S.logger.log("[buffer-controller]: Removing ["+f+","+o+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(f,o)):t.shiftAndExecuteNext(e)},E.appendExecutor=function(e,s){var u=this.operationQueue,n=this.sourceBuffer,i=n[s];if(!i){S.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),u.shiftAndExecuteNext(s);return}i.ended=!1,console.assert(!i.updating,s+" sourceBuffer must not be updating"),i.appendBuffer(e)},E.blockBuffers=function(e,s){var u=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){S.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var n=this.operationQueue,i=s.map(function(t){return n.appendBlocker(t)});Promise.all(i).then(function(){e(),s.forEach(function(t){var l=u.sourceBuffer[t];(!l||!l.updating)&&n.shiftAndExecuteNext(t)})})},E.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},E.addBufferListener=function(e,s,u){var n=this.sourceBuffer[e];if(!!n){var i=u.bind(this,e);this.listeners[e].push({event:s,listener:i}),n.addEventListener(s,i)}},E.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(u){s.removeEventListener(u.event,u.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return p});var R=h("./src/utils/logger.ts"),p=function(){function S(x){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=x}var I=S.prototype;return I.append=function(L,A){var y=this.queues[A];y.push(L),y.length===1&&this.buffers[A]&&this.executeNext(A)},I.insertAbort=function(L,A){var y=this.queues[A];y.unshift(L),this.executeNext(A)},I.appendBlocker=function(L){var A,y=new Promise(function(_){A=_}),D={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(D,L),y},I.executeNext=function(L){var A=this.buffers,y=this.queues,D=A[L],_=y[L];if(_.length){var T=_[0];try{T.execute()}catch(g){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),T.onError(g),(!D||!D.updating)&&(_.shift(),this.executeNext(L))}}},I.shiftAndExecuteNext=function(L){this.queues[L].shift(),this.executeNext(L)},I.current=function(L){return this.queues[L][0]},S}()},"./src/controller/cap-level-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts");function p(x,L){for(var A=0;A<L.length;A++){var y=L[A];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(x,y.key,y)}}function S(x,L,A){return L&&p(x.prototype,L),A&&p(x,A),Object.defineProperty(x,"prototype",{writable:!1}),x}var I=function(){function x(A){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=A,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var L=x.prototype;return L.setStreamController=function(y){this.streamController=y},L.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},L.registerListeners=function(){var y=this.hls;y.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var y=this.hls;y.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(y,D){x.isLevelAllowed(D.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(D.droppedLevel)},L.onMediaAttaching=function(y,D){this.media=D.media instanceof HTMLVideoElement?D.media:null},L.onManifestParsed=function(y,D){var _=this.hls;this.restrictedLevels=[],this.firstLevel=D.firstLevel,_.config.capLevelToPlayerSize&&D.video&&this.startCapping()},L.onBufferCodecs=function(y,D){var _=this.hls;_.config.capLevelToPlayerSize&&D.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var D=this.hls;D.autoLevelCapping=this.getMaxLevel(y.length-1),D.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=D.autoLevelCapping}}},L.getMaxLevel=function(y){var D=this,_=this.hls.levels;if(!_.length)return-1;var T=_.filter(function(g,E){return x.isLevelAllowed(E,D.restrictedLevels)&&E<=y});return this.clientRect=null,x.getMaxLevelByMediaSize(T,this.mediaWidth,this.mediaHeight)},L.startCapping=function(){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())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,D={width:0,height:0};if(y){var _=y.getBoundingClientRect();D.width=_.width,D.height=_.height,!D.width&&!D.height&&(D.width=_.right-_.left||y.width||0,D.height=_.bottom-_.top||y.height||0)}return this.clientRect=D,D},x.isLevelAllowed=function(y,D){return D===void 0&&(D=[]),D.indexOf(y)===-1},x.getMaxLevelByMediaSize=function(y,D,_){if(!y||!y.length)return-1;for(var T=function(s,u){return u?s.width!==u.width||s.height!==u.height:!0},g=y.length-1,E=0;E<y.length;E+=1){var a=y[E];if((a.width>=D||a.height>=_)&&T(a,y[E+1])){g=E;break}}return g},S(x,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),x}();P.default=I},"./src/controller/cmcd-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T});var R=h("./src/events.ts"),p=h("./src/types/cmcd.ts"),S=h("./src/utils/buffer-helper.ts"),I=h("./src/utils/logger.ts");function x(g,E){for(var a=0;a<E.length;a++){var e=E[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function L(g,E,a){return E&&x(g.prototype,E),a&&x(g,a),Object.defineProperty(g,"prototype",{writable:!1}),g}function A(g,E){var a=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(a)return(a=a.call(g)).next.bind(a);if(Array.isArray(g)||(a=y(g))||E&&g&&typeof g.length=="number"){a&&(g=a);var e=0;return function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
12
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(g,E){if(!!g){if(typeof g=="string")return D(g,E);var a=Object.prototype.toString.call(g).slice(8,-1);if(a==="Object"&&g.constructor&&(a=g.constructor.name),a==="Map"||a==="Set")return Array.from(g);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return D(g,E)}}function D(g,E){(E==null||E>g.length)&&(E=g.length);for(var a=0,e=new Array(E);a<E;a++)e[a]=g[a];return e}function _(){return _=Object.assign?Object.assign.bind():function(g){for(var E=1;E<arguments.length;E++){var a=arguments[E];for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&(g[e]=a[e])}return g},_.apply(this,arguments)}var T=function(){function g(a){var e=this;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=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(n){try{e.apply(n,{ot:p.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){I.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(n){try{var i=n.frag,t=e.hls.levels[i.level],l=e.getObjectType(i),d={d:i.duration*1e3,ot:l};(l===p.CMCDObjectType.VIDEO||l===p.CMCDObjectType.AUDIO||l==p.CMCDObjectType.MUXED)&&(d.br=t.bitrate/1e3,d.tb=e.getTopBandwidth(l)/1e3,d.bl=e.getBufferLength(l)),e.apply(n,d)}catch(r){I.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=a;var s=this.config=a.config,u=s.cmcd;u!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=u.sessionId||g.uuid(),this.cid=u.contentId,this.useHeaders=u.useHeaders===!0,this.registerListeners())}var E=g.prototype;return E.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this)},E.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},E.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},E.onMediaAttached=function(e,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},E.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},E.onBufferCreated=function(e,s){var u,n;this.audioBuffer=(u=s.tracks.audio)===null||u===void 0?void 0:u.buffer,this.videoBuffer=(n=s.tracks.video)===null||n===void 0?void 0:n.buffer},E.createData=function(){var e;return{v:p.CMCDVersion,sf:p.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},E.apply=function(e,s){s===void 0&&(s={}),_(s,this.createData());var u=s.ot===p.CMCDObjectType.INIT||s.ot===p.CMCDObjectType.VIDEO||s.ot===p.CMCDObjectType.MUXED;if(this.starved&&u&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var n=g.toHeaders(s);if(!Object.keys(n).length)return;e.headers||(e.headers={}),_(e.headers,n)}else{var i=g.toQuery(s);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},E.getObjectType=function(e){var s=e.type;if(s==="subtitle")return p.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return p.CMCDObjectType.INIT;if(s==="audio")return p.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?p.CMCDObjectType.VIDEO:p.CMCDObjectType.MUXED},E.getTopBandwidth=function(e){var s=0,u,n=this.hls;if(e===p.CMCDObjectType.AUDIO)u=n.audioTracks;else{var i=n.maxAutoLevel,t=i>-1?i+1:n.levels.length;u=n.levels.slice(0,t)}for(var l=A(u),d;!(d=l()).done;){var r=d.value;r.bitrate>s&&(s=r.bitrate)}return s>0?s:NaN},E.getBufferLength=function(e){var s=this.hls.media,u=e===p.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!u||!s)return NaN;var n=S.BufferHelper.bufferInfo(u,s.currentTime,this.config.maxBufferHole);return n.len*1e3},E.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,u=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new u(t)}var i=n.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,d,r){s(l),this.loader.load(l,d,r)},L(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},E.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,u=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new u(t)}var i=n.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,d,r){s(l),this.loader.load(l,d,r)},L(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},g.serialize=function(e){for(var s=[],u=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},n=function(M){return Math.round(M)},i=function(M){return n(M/100)*100},t=function(M){return encodeURIComponent(M)},l={br:n,d:n,bl:i,dl:i,mtp:i,nor:t,rtp:i,tb:n},d=Object.keys(e||{}).sort(),r=A(d),c;!(c=r()).done;){var f=c.value,o=e[f];if(!!u(o)&&!(f==="v"&&o===1)&&!(f=="pr"&&o===1)){var v=l[f];v&&(o=v(o));var m=typeof o,O=void 0;f==="ot"||f==="sf"||f==="st"?O=f+"="+o:m==="boolean"?O=f:m==="number"?O=f+"="+o:O=f+"="+JSON.stringify(o),s.push(O)}}return s.join(",")},g.toHeaders=function(e){for(var s=Object.keys(e),u={},n=["Object","Request","Session","Status"],i=[{},{},{},{}],t={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},l=0,d=s;l<d.length;l++){var r=d[l],c=t[r]!=null?t[r]:1;i[c][r]=e[r]}for(var f=0;f<i.length;f++){var o=g.serialize(i[f]);o&&(u["CMCD-"+n[f]]=o)}return u},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,s){if(!s)return e;var u=e.includes("?")?"&":"?";return""+e+u+s},g}()},"./src/controller/eme-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/utils/logger.ts"),I=h("./src/utils/mediakeys-helper.ts");function x(T,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(T,a.key,a)}}function L(T,g,E){return g&&x(T.prototype,g),E&&x(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}var A=3,y=function(g,E,a){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:a.audioRobustness||""})}),E.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:a.videoRobustness||""})}),[e]},D=function(g,E,a,e){switch(g){case I.KeySystems.WIDEVINE:return y(E,a,e);default:throw new Error("Unknown key-system: "+g)}},_=function(){function T(E){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=E,this._config=E.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var g=T.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(a){switch(a){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+a+'"')},g._attemptKeySystemAccess=function(a,e,s){var u=this,n=D(a,e,s,this._drmSystemOptions);S.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(a,n);this.mediaKeysPromise=i.then(function(t){return u._onMediaKeySystemAccessObtained(a,t)}),i.catch(function(t){S.logger.error('Failed to obtain key-system "'+a+'" access:',t)})},g._onMediaKeySystemAccessObtained=function(a,e){var s=this;S.logger.log('Access for key-system "'+a+'" obtained');var u={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:a};this._mediaKeysList.push(u);var n=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return u.mediaKeys=i,S.logger.log('Media-keys created for key-system "'+a+'"'),s._onMediaKeysCreated(),i});return n.catch(function(i){S.logger.error("Failed to create media-keys:",i)}),n},g._onMediaKeysCreated=function(){var a=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),a._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(a){var e=this;S.logger.log("New key-system session "+a.sessionId),a.addEventListener("message",function(s){e._onKeySessionMessage(a,s.message)},!1)},g._onKeySessionMessage=function(a,e){S.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){S.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),a.update(s).catch(function(u){S.logger.warn("Updating key-session failed: "+u)})})},g.onMediaEncrypted=function(a){var e=this;if(S.logger.log('Media is encrypted using "'+a.initDataType+'" init data type'),!this.mediaKeysPromise){S.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(n){!e._media||(e._attemptSetMediaKeys(n),e._generateRequestWithPreferredKeySession(a.initDataType,a.initData))};this.mediaKeysPromise.then(s).catch(s)},g._attemptSetMediaKeys=function(a){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){S.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}S.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(a,e){var s=this,u=this._mediaKeysList[0];if(!u){S.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(u.mediaKeysSessionInitialized){S.logger.warn("Key-Session already initialized but requested again");return}var n=u.mediaKeysSession;if(!n){S.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){S.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}S.logger.log('Generating key-session request for "'+a+'" init data type'),u.mediaKeysSessionInitialized=!0,n.generateRequest(a,e).then(function(){S.logger.debug("Key-session generation succeeded")}).catch(function(i){S.logger.error("Error generating key-session request:",i),s.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(a,e,s){var u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,u,a,e,s);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,u,a),n=void 0}catch(i){S.logger.error(i)}try{u.readyState||u.open("POST",a,!0),n&&n.call(this.hls,u,a)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return u},g._onLicenseRequestReadyStageChange=function(a,e,s,u){switch(a.readyState){case 4:if(a.status===200){this._requestLicenseFailureCount=0,S.logger.log("License request succeeded");var n=a.response,i=this._licenseResponseCallback;if(i)try{n=i.call(this.hls,a,e)}catch(l){S.logger.error(l)}u(n)}else{if(S.logger.error("License Request XHR failed ("+e+"). Status: "+a.status+" ("+a.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>A){this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var t=A-this._requestLicenseFailureCount+1;S.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(s,u)}break}},g._generateLicenseRequestChallenge=function(a,e){switch(a.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+a.mediaKeySystemDomain)},g._requestLicense=function(a,e){S.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){S.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var u=this.getLicenseServerUrl(s.mediaKeySystemDomain),n=this._createLicenseXhr(u,a,e);S.logger.log("Sending license request to URL: "+u);var i=this._generateLicenseRequestChallenge(s,a);n.send(i)}catch(t){S.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(a,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},g.onMediaDetached=function(){var a=this._media,e=this._mediaKeysList;!a||(a.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return a.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(a,e){if(!!this._emeEnabled){var s=e.levels.map(function(n){return n.audioCodec}).filter(function(n){return!!n}),u=e.levels.map(function(n){return n.videoCodec}).filter(function(n){return!!n});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,s,u)}},L(T,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),T}();P.default=_},"./src/controller/fps-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/utils/logger.ts"),S=function(){function I(L){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=L,this.registerListeners()}var x=I.prototype;return x.setStreamController=function(A){this.streamController=A},x.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},x.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},x.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},x.onMediaAttaching=function(A,y){var D=this.hls.config;if(D.capLevelOnFPSDrop){var _=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=_,_&&typeof _.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),D.fpsDroppedMonitoringPeriod)}},x.checkFPS=function(A,y,D){var _=performance.now();if(y){if(this.lastTime){var T=_-this.lastTime,g=D-this.lastDroppedFrames,E=y-this.lastDecodedFrames,a=1e3*g/T,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:g,currentDecoded:E,totalDroppedFrames:D}),a>0&&g>e.config.fpsDroppedMonitoringThreshold*E){var s=e.currentLevel;p.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=_,this.lastDroppedFrames=D,this.lastDecodedFrames=y}},x.checkFPSInterval=function(){var A=this.media;if(A)if(this.isVideoPlaybackQualityAvailable){var y=A.getVideoPlaybackQuality();this.checkFPS(A,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(A,A.webkitDecodedFrameCount,A.webkitDroppedFrameCount)},I}();P.default=S},"./src/controller/fragment-finders.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"findFragmentByPDT",function(){return S}),h.d(P,"findFragmentByPTS",function(){return I}),h.d(P,"fragmentWithinToleranceTest",function(){return x}),h.d(P,"pdtWithinToleranceTest",function(){return L}),h.d(P,"findFragWithCC",function(){return A});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/binary-search.ts");function S(y,D,_){if(D===null||!Array.isArray(y)||!y.length||!Object(R.isFiniteNumber)(D))return null;var T=y[0].programDateTime;if(D<(T||0))return null;var g=y[y.length-1].endProgramDateTime;if(D>=(g||0))return null;_=_||0;for(var E=0;E<y.length;++E){var a=y[E];if(L(D,_,a))return a}return null}function I(y,D,_,T){_===void 0&&(_=0),T===void 0&&(T=0);var g=null;if(y?g=D[y.sn-D[0].sn+1]||null:_===0&&D[0].start===0&&(g=D[0]),g&&x(_,T,g)===0)return g;var E=p.default.search(D,x.bind(null,_,T));return E||g}function x(y,D,_){y===void 0&&(y=0),D===void 0&&(D=0);var T=Math.min(D,_.duration+(_.deltaPTS?_.deltaPTS:0));return _.start+_.duration-T<=y?1:_.start-T>y&&_.start?-1:0}function L(y,D,_){var T=Math.min(D,_.duration+(_.deltaPTS?_.deltaPTS:0))*1e3,g=_.endProgramDateTime||0;return g-T>y}function A(y,D){return p.default.search(y,function(_){return _.cc<D?1:_.cc>D?-1:0})}},"./src/controller/fragment-tracker.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"FragmentState",function(){return S}),h.d(P,"FragmentTracker",function(){return I});var R=h("./src/events.ts"),p=h("./src/types/loader.ts"),S;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(S||(S={}));var I=function(){function A(D){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=D,this._registerListeners()}var y=A.prototype;return y._registerListeners=function(){var _=this.hls;_.on(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),_.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),_.on(R.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var _=this.hls;_.off(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),_.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),_.off(R.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(_,T){if(T===p.PlaylistLevelType.MAIN){var g=this.activeFragment,E=this.activeParts;if(!g)return null;if(E)for(var a=E.length;a--;){var e=E[a],s=e?e.end:g.appendedPTS;if(e.start<=_&&s!==void 0&&_<=s)return a>9&&(this.activeParts=E.slice(a-9)),e}else if(g.start<=_&&g.appendedPTS!==void 0&&_<=g.appendedPTS)return g}return this.getBufferedFrag(_,T)},y.getBufferedFrag=function(_,T){for(var g=this.fragments,E=Object.keys(g),a=E.length;a--;){var e=g[E[a]];if((e==null?void 0:e.body.type)===T&&e.buffered){var s=e.body;if(s.start<=_&&_<=s.end)return s}}return null},y.detectEvictedFragments=function(_,T,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e){if(!e.buffered){e.body.type===g&&E.removeFragment(e.body);return}var s=e.range[_];!s||s.time.some(function(u){var n=!E.isTimeBuffered(u.startPTS,u.endPTS,T);return n&&E.removeFragment(e.body),n})}})},y.detectPartialFragments=function(_){var T=this,g=this.timeRanges,E=_.frag,a=_.part;if(!(!g||E.sn==="initSegment")){var e=L(E),s=this.fragments[e];!s||(Object.keys(g).forEach(function(u){var n=E.elementaryStreams[u];if(!!n){var i=g[u],t=a!==null||n.partial===!0;s.range[u]=T.getBufferedTimes(E,a,t,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(_){var T=L(_),g=this.fragments[T];g&&(g.loaded=null,g.buffered=!0)},y.getBufferedTimes=function(_,T,g,E){for(var a={time:[],partial:g},e=T?T.start:_.start,s=T?T.end:_.end,u=_.minEndPTS||s,n=_.maxStartPTS||e,i=0;i<E.length;i++){var t=E.start(i)-this.bufferPadding,l=E.end(i)+this.bufferPadding;if(n>=t&&u<=l){a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(s,E.end(i))});break}else if(e<l&&s>t)a.partial=!0,a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(s,E.end(i))});else if(s<=t)break}return a},y.getPartialFragment=function(_){var T=null,g,E,a,e=0,s=this.bufferPadding,u=this.fragments;return Object.keys(u).forEach(function(n){var i=u[n];!i||x(i)&&(E=i.body.start-s,a=i.body.end+s,_>=E&&_<=a&&(g=Math.min(_-E,a-_),e<=g&&(T=i.body,e=g)))}),T},y.getState=function(_){var T=L(_),g=this.fragments[T];return g?g.buffered?x(g)?S.PARTIAL:S.OK:S.APPENDING:S.NOT_LOADED},y.isTimeBuffered=function(_,T,g){for(var E,a,e=0;e<g.length;e++){if(E=g.start(e)-this.bufferPadding,a=g.end(e)+this.bufferPadding,_>=E&&T<=a)return!0;if(T<=E)return!1}return!1},y.onFragLoaded=function(_,T){var g=T.frag,E=T.part;if(!(g.sn==="initSegment"||g.bitrateTest||E)){var a=L(g);this.fragments[a]={body:g,loaded:T,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(_,T){var g=this,E=T.frag,a=T.part,e=T.timeRanges;if(E.type===p.PlaylistLevelType.MAIN)if(this.activeFragment=E,a){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(a)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(u){var n=e[u];if(g.detectEvictedFragments(u,n),!a)for(var i=0;i<n.length;i++)E.appendedPTS=Math.max(n.end(i),E.appendedPTS||0)})},y.onFragBuffered=function(_,T){this.detectPartialFragments(T)},y.hasFragment=function(_){var T=L(_);return!!this.fragments[T]},y.removeFragmentsInRange=function(_,T,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e&&e.buffered){var s=e.body;s.type===g&&s.start<T&&s.end>_&&E.removeFragment(s)}})},y.removeFragment=function(_){var T=L(_);_.stats.loaded=0,_.clearElementaryStreamInfo(),delete this.fragments[T]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},A}();function x(A){var y,D;return A.buffered&&(((y=A.range.video)===null||y===void 0?void 0:y.partial)||((D=A.range.audio)===null||D===void 0?void 0:D.partial))}function L(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"STALL_MINIMUM_DURATION_MS",function(){return x}),h.d(P,"MAX_START_GAP_JUMP",function(){return L}),h.d(P,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return A}),h.d(P,"SKIP_BUFFER_RANGE_START",function(){return y}),h.d(P,"default",function(){return D});var R=h("./src/utils/buffer-helper.ts"),p=h("./src/errors.ts"),S=h("./src/events.ts"),I=h("./src/utils/logger.ts"),x=250,L=2,A=.1,y=.05,D=function(){function _(g,E,a,e){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=g,this.media=E,this.fragmentTracker=a,this.hls=e}var T=_.prototype;return T.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},T.poll=function(E,a){var e=this.config,s=this.media,u=this.stalled;if(s!==null){var n=s.currentTime,i=s.seeking,t=this.seeking&&!i,l=!this.seeking&&i;if(this.seeking=i,n!==E){if(this.moved=!0,u!==null){if(this.stallReported){var d=self.performance.now()-u;I.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(d)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||t)&&(this.stalled=null),!(s.paused&&!i||s.ended||s.playbackRate===0||!R.BufferHelper.getBuffered(s).length)){var r=R.BufferHelper.bufferInfo(s,n,0),c=r.len>0,f=r.nextStart||0;if(!(!c&&!f)){if(i){var o=r.len>L,v=!f||a&&a.start<=n||f-n>L&&!this.fragmentTracker.getPartialFragment(n);if(o||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,O=Math.max(f,r.start||0)-n,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=b==null||(m=b.details)===null||m===void 0?void 0:m.live,F=M?b.details.targetduration*2:L;if(O>0&&O<=F){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(u===null){this.stalled=w;return}var C=w-u;if(!(!i&&C>=x&&(this._reportStall(r),!this.media))){var U=R.BufferHelper.bufferInfo(s,n,e.maxBufferHole);this._tryFixBufferStall(U,C)}}}}},T._tryFixBufferStall=function(E,a){var e=this.config,s=this.fragmentTracker,u=this.media;if(u!==null){var n=u.currentTime,i=s.getPartialFragment(n);if(i){var t=this._trySkipBufferHole(i);if(t||!this.media)return}E.len>e.maxBufferHole&&a>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},T._reportStall=function(E){var a=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,I.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(E)+")"),a.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E.len}))},T._trySkipBufferHole=function(E){var a=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var u=s.currentTime,n=0,i=R.BufferHelper.getBuffered(s),t=0;t<i.length;t++){var l=i.start(t);if(u+a.maxBufferHole>=n&&u<l){var d=Math.max(l+y,s.currentTime+A);return I.logger.warn("skipping hole, adjusting currentTime from "+u+" to "+d),this.moved=!0,this.stalled=null,s.currentTime=d,E&&e.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+u+" to "+d,frag:E}),d}n=i.end(t)}return 0},T._tryNudgeBuffer=function(){var E=this.config,a=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var u=e.currentTime;if(this.nudgeRetry++,s<E.nudgeMaxRetry){var n=u+(s+1)*E.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+u+" to "+n),e.currentTime=n,a.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else I.logger.error("Playhead still not moving while enough data buffered @"+u+" after "+E.nudgeMaxRetry+" nudges"),a.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},_}()},"./src/controller/id3-track-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/utils/texttrack-utils.ts"),I=h("./src/demux/id3.ts"),x=h("./src/loader/date-range.ts"),L=h("./src/types/demuxer.ts"),A=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function D(g,E){return g.getTime()/1e3-E}function _(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var T=function(){function g(a){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=a,this._registerListeners()}var E=g.prototype;return E.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},E._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E.onMediaAttached=function(e,s){this.media=s.media},E.onMediaDetaching=function(){!this.id3Track||(Object(S.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},E.onManifestLoading=function(){this.dateRangeCuesAppended={}},E.createTrack=function(e){var s=this.getID3Track(e.textTracks);return s.mode="hidden",s},E.getID3Track=function(e){if(!!this.media){for(var s=0;s<e.length;s++){var u=e[s];if(u.kind==="metadata"&&u.label==="id3")return Object(S.sendAddTrackEvent)(u,this.media),u}return this.media.addTextTrack("metadata","id3")}},E.onFragParsingMetadata=function(e,s){if(!!this.media){var u=this.hls.config,n=u.enableEmsgMetadataCues,i=u.enableID3MetadataCues;if(!(!n&&!i)){var t=s.frag,l=s.samples,d=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var r=d.edge||t.end,c=y(),f=!1,o={},v=0;v<l.length;v++){var m=l[v].type;if(!(m===L.MetadataSchema.emsg&&!n||!i)){var O=I.getID3Frames(l[v].data);if(O){var b=l[v].pts,M=r,F=M-b;F<=0&&(M=b+A);for(var w=0;w<O.length;w++){var C=O[w];if(!I.isTimeStampFrame(C)){var U=new c(b,M,"");U.value=C,m&&(U.type=m),this.id3Track.addCue(U),o[C.key]=null,f=!0}}}}}f&&this.updateId3CueEnds(o)}}},E.updateId3CueEnds=function(e){var s,u=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(u)for(var n=u.length;n--;){var i,t=u[n],l=(i=t.value)===null||i===void 0?void 0:i.key;if(l&&l in e){var d=e[l];d&&t.endTime!==d&&(t.endTime=d),e[l]=t.startTime}}},E.onBufferFlushing=function(e,s){var u=s.startOffset,n=s.endOffset,i=s.type,t=this.id3Track,l=this.hls;if(!!l){var d=l.config,r=d.enableEmsgMetadataCues,c=d.enableID3MetadataCues;if(t&&(r||c)){var f;i==="audio"?f=function(v){return v.type===L.MetadataSchema.audioId3&&c}:i==="video"?f=function(v){return v.type===L.MetadataSchema.emsg&&r}:f=function(v){return v.type===L.MetadataSchema.audioId3&&c||v.type===L.MetadataSchema.emsg&&r},Object(S.removeCuesInRange)(t,u,n,f)}}},E.onLevelUpdated=function(e,s){var u=this,n=s.details;if(!(!this.media||!n.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,t=this.id3Track,l=n.dateRanges,d=Object.keys(l);if(t)for(var r=Object.keys(i).filter(function(F){return!d.includes(F)}),c=function(w){var C=r[w];Object.keys(i[C].cues).forEach(function(U){t.removeCue(i[C].cues[U])}),delete i[C]},f=r.length;f--;)c(f);var o=n.fragments[n.fragments.length-1];if(!(d.length===0||!Object(R.isFiniteNumber)(o==null?void 0:o.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var v=o.programDateTime/1e3-o.start,m=n.edge||o.end,O=y(),b=function(w){var C=d[w],U=l[C],B=i[C],N=(B==null?void 0:B.cues)||{},k=(B==null?void 0:B.durationKnown)||!1,j=D(U.startDate,v),H=m,V=U.endDate;if(V)H=D(V,v),k=!0;else if(U.endOnNext&&!k){var Y=d.reduce(function(X,le){var ne=l[le];return ne.class===U.class&&ne.id!==le&&ne.startDate>U.startDate&&X.push(ne),X},[]).sort(function(X,le){return X.startDate.getTime()-le.startDate.getTime()})[0];Y&&(H=D(Y.startDate,v),k=!0)}for(var Q=Object.keys(U.attr),J=0;J<Q.length;J++){var z=Q[J];if(!(z===x.DateRangeAttribute.ID||z===x.DateRangeAttribute.CLASS||z===x.DateRangeAttribute.START_DATE||z===x.DateRangeAttribute.DURATION||z===x.DateRangeAttribute.END_DATE||z===x.DateRangeAttribute.END_ON_NEXT)){var q=N[z];if(q)k&&!B.durationKnown&&(q.endTime=H);else{var re=U.attr[z];q=new O(j,H,""),(z===x.DateRangeAttribute.SCTE35_OUT||z===x.DateRangeAttribute.SCTE35_IN)&&(re=_(re)),q.value={key:z,data:re},q.type=L.MetadataSchema.dateRange,u.id3Track.addCue(q),N[z]=q}}}i[C]={cues:N,dateRange:U,durationKnown:k}},M=0;M<d.length;M++)b(M)}}},g}();P.default=T},"./src/controller/latency-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return L});var R=h("./src/errors.ts"),p=h("./src/events.ts"),S=h("./src/utils/logger.ts");function I(A,y){for(var D=0;D<y.length;D++){var _=y[D];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(A,_.key,_)}}function x(A,y,D){return y&&I(A.prototype,y),D&&I(A,D),Object.defineProperty(A,"prototype",{writable:!1}),A}var L=function(){function A(D){var _=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return _.timeupdate()},this.hls=D,this.config=D.config,this.registerListeners()}var y=A.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},y.onMediaAttached=function(_,T){this.media=T.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(_,T){var g=T.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(_,T){T.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,S.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var _=this.media,T=this.levelDetails;if(!(!_||!T)){this.currentTime=_.currentTime;var g=this.computeLatency();if(g!==null){this._latency=g;var E=this.config,a=E.lowLatencyMode,e=E.maxLiveSyncPlaybackRate;if(!(!a||e===1)){var s=this.targetLatency;if(s!==null){var u=g-s,n=Math.min(this.maxLatency,s+T.targetduration),i=u<n;if(T.live&&i&&u>.05&&this.forwardBufferLength>1){var t=Math.min(2,Math.max(1,e)),l=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20;_.playbackRate=Math.min(t,Math.max(1,l))}else _.playbackRate!==1&&_.playbackRate!==0&&(_.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var _=this.levelDetails;return _===null?null:_.edge+_.age},y.computeLatency=function(){var _=this.estimateLiveEdge();return _===null?null:_-this.currentTime},x(A,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var _=this.config,T=this.levelDetails;return _.liveMaxLatencyDuration!==void 0?_.liveMaxLatencyDuration:T?_.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var _=this.levelDetails;if(_===null)return null;var T=_.holdBack,g=_.partHoldBack,E=_.targetduration,a=this.config,e=a.liveSyncDuration,s=a.liveSyncDurationCount,u=a.lowLatencyMode,n=this.hls.userConfig,i=u&&g||T;(n.liveSyncDuration||n.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:s*E);var t=E,l=1;return i+Math.min(this.stallCount*l,t)}},{key:"liveSyncPosition",get:function(){var _=this.estimateLiveEdge(),T=this.targetLatency,g=this.levelDetails;if(_===null||T===null||g===null)return null;var E=g.edge,a=_-T-this.edgeStalled,e=E-g.totalduration,s=E-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,a),s)}},{key:"drift",get:function(){var _=this.levelDetails;return _===null?1:_.drift}},{key:"edgeStalled",get:function(){var _=this.levelDetails;if(_===null)return 0;var T=(this.config.lowLatencyMode&&_.partTarget||_.targetduration)*3;return Math.max(_.age-T,0)}},{key:"forwardBufferLength",get:function(){var _=this.media,T=this.levelDetails;if(!_||!T)return 0;var g=_.buffered.length;return(g?_.buffered.end(g-1):T.edge)-this.currentTime}}]),A}()},"./src/controller/level-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return a});var R=h("./src/types/level.ts"),p=h("./src/events.ts"),S=h("./src/errors.ts"),I=h("./src/utils/codecs.ts"),x=h("./src/controller/level-helper.ts"),L=h("./src/controller/base-playlist-controller.ts"),A=h("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var u=arguments[s];for(var n in u)Object.prototype.hasOwnProperty.call(u,n)&&(e[n]=u[n])}return e},y.apply(this,arguments)}function D(e,s){for(var u=0;u<s.length;u++){var n=s[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _(e,s,u){return s&&D(e.prototype,s),u&&D(e,u),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,g(e,s)}function g(e,s){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},g(e,s)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),a=function(e){T(s,e);function s(n){var i;return i=e.call(this,n,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var u=s.prototype;return u._registerListeners=function(){var i=this.hls;i.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(p.Events.ERROR,this.onError,this)},u._unregisterListeners=function(){var i=this.hls;i.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(p.Events.ERROR,this.onError,this)},u.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},u.startLoad=function(){var i=this._levels;i.forEach(function(t){t.loadError=0}),e.prototype.startLoad.call(this)},u.onManifestLoaded=function(i,t){var l=[],d=[],r=[],c,f={},o,v=!1,m=!1,O=!1;if(t.levels.forEach(function(w){var C=w.attrs;v=v||!!(w.width&&w.height),m=m||!!w.videoCodec,O=O||!!w.audioCodec,E&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var U=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;o=f[U],o?o.url.push(w.url):(o=new R.Level(w),f[U]=o,l.push(o)),C&&(C.AUDIO&&Object(x.addGroupId)(o,"audio",C.AUDIO),C.SUBTITLES&&Object(x.addGroupId)(o,"text",C.SUBTITLES))}),(v||m)&&O&&(l=l.filter(function(w){var C=w.videoCodec,U=w.width,B=w.height;return!!C||!!(U&&B)})),l=l.filter(function(w){var C=w.audioCodec,U=w.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!U||Object(I.isCodecSupportedInMp4)(U,"video"))}),t.audioTracks&&(d=t.audioTracks.filter(function(w){return!w.audioCodec||Object(I.isCodecSupportedInMp4)(w.audioCodec,"audio")}),Object(x.assignTrackIdsByGroup)(d)),t.subtitles&&(r=t.subtitles,Object(x.assignTrackIdsByGroup)(r)),l.length>0){c=l[0].bitrate,l.sort(function(w,C){return w.bitrate-C.bitrate}),this._levels=l;for(var b=0;b<l.length;b++)if(l[b].bitrate===c){this._firstLevel=b,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+c);break}var M=O&&!m,F={levels:l,audioTracks:d,subtitleTracks:r,firstLevel:this._firstLevel,stats:t.stats,audio:O,video:m,altAudio:!M&&d.some(function(w){return!!w.url})};this.hls.trigger(p.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(p.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},u.onError=function(i,t){var l;if(e.prototype.onError.call(this,i,t),!t.fatal){var d=t.context,r=this._levels[this.currentLevelIndex];if(d&&(d.type===A.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&d.groupId===r.audioGroupIds[r.urlId]||d.type===A.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&d.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,f=!0,o;switch(t.details){case S.ErrorDetails.FRAG_LOAD_ERROR:case S.ErrorDetails.FRAG_LOAD_TIMEOUT:case S.ErrorDetails.KEY_LOAD_ERROR:case S.ErrorDetails.KEY_LOAD_TIMEOUT:if(t.frag){var v=t.frag.type===A.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,m=this._levels[v];m?(m.fragmentError++,m.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=v)):o=v}break;case S.ErrorDetails.LEVEL_LOAD_ERROR:case S.ErrorDetails.LEVEL_LOAD_TIMEOUT:d&&(d.deliveryDirectives&&(f=!1),o=d.level),c=!0;break;case S.ErrorDetails.REMUX_ALLOC_ERROR:o=(l=t.level)!=null?l:this.currentLevelIndex,c=!0;break}o!==void 0&&this.recoverLevel(t,o,c,f)}},u.recoverLevel=function(i,t,l,d){var r=i.details,c=this._levels[t];if(c.loadError++,l){var f=this.retryLoadingOrFail(i);if(f)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var o=c.url.length;if(o>1&&c.loadError<o)i.levelRetry=!0,this.redundantFailover(t);else if(this.manualLevelIndex===-1){for(var v=-1,m=this._levels,O=m.length;O--;){var b=(O+this.currentLevelIndex)%m.length;if(b!==this.currentLevelIndex&&m[b].loadError===0){v=b;break}}v>-1&&this.currentLevelIndex!==v&&(this.warn(r+": switch to "+v),i.levelRetry=!0,this.hls.nextAutoLevel=v)}}},u.redundantFailover=function(i){var t=this._levels[i],l=t.url.length;if(l>1){var d=(t.urlId+1)%l;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(r){r.urlId=d}),this.level=i}},u.onFragLoaded=function(i,t){var l=t.frag;if(l!==void 0&&l.type===A.PlaylistLevelType.MAIN){var d=this._levels[l.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},u.onLevelLoaded=function(i,t){var l,d=t.level,r=t.details,c=this._levels[d];if(!c){var f;this.warn("Invalid level index "+d),(f=t.deliveryDirectives)!==null&&f!==void 0&&f.skip&&(r.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(d,t,c.details)):(l=t.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(r.deltaUpdateFailed=!0)},u.onAudioTrackSwitched=function(i,t){var l=this.hls.levels[this.currentLevelIndex];if(!!l&&l.audioGroupIds){for(var d=-1,r=this.hls.audioTracks[t.id].groupId,c=0;c<l.audioGroupIds.length;c++)if(l.audioGroupIds[c]===r){d=c;break}d!==l.urlId&&(l.urlId=d,this.startLoad())}},u.loadPlaylist=function(i){var t=this.currentLevelIndex,l=this._levels[t];if(this.canLoad&&l&&l.url.length>0){var d=l.urlId,r=l.url[d];if(i)try{r=i.addDirectives(r)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+t+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+d+" "+r),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:r,level:t,id:d,deliveryDirectives:i||null})}},u.removeLevel=function(i,t){var l=function(c,f){return f!==t},d=this._levels.filter(function(r,c){return c!==i?!0:r.url.length>1&&t!==void 0?(r.url=r.url.filter(l),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(l)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(l)),r.urlId=0,!0):!1}).map(function(r,c){var f=r.details;return f!=null&&f.fragments&&f.fragments.forEach(function(o){o.level=c}),r});this._levels=d,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:d})},_(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var t,l=this._levels;if(l.length!==0&&!(this.currentLevelIndex===i&&(t=l[i])!==null&&t!==void 0&&t.details)){if(i<0||i>=l.length){var d=i<0;if(this.hls.trigger(p.Events.ERROR,{type:S.ErrorTypes.OTHER_ERROR,details:S.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:d,reason:"invalid level idx"}),d)return;i=Math.min(i,l.length-1)}this.clearTimer();var r=this.currentLevelIndex,c=l[r],f=l[i];this.log("switching to level "+i+" from "+r),this.currentLevelIndex=i;var o=y({},f,{level:i,maxBitrate:f.maxBitrate,uri:f.uri,urlId:f.urlId});delete o._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,o);var v=f.details;if(!v||v.live){var m=this.switchParams(f.uri,c==null?void 0:c.details);this.loadPlaylist(m)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),s}(L.default)},"./src/controller/level-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"addGroupId",function(){return x}),h.d(P,"assignTrackIdsByGroup",function(){return L}),h.d(P,"updatePTS",function(){return A}),h.d(P,"updateFragPTSDTS",function(){return D}),h.d(P,"mergeDetails",function(){return _}),h.d(P,"mapPartIntersection",function(){return g}),h.d(P,"mapFragmentIntersection",function(){return E}),h.d(P,"adjustSliding",function(){return a}),h.d(P,"addSliding",function(){return e}),h.d(P,"computeReloadInterval",function(){return s}),h.d(P,"getFragmentWithSN",function(){return u}),h.d(P,"getPartWith",function(){return n});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/logger.ts"),S=h("./src/loader/date-range.ts");function I(){return I=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(i[d]=l[d])}return i},I.apply(this,arguments)}function x(i,t,l){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(l);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(l);break}}function L(i){var t={};i.forEach(function(l){var d=l.groupId||"";l.id=t[d]=t[d]||0,t[d]++})}function A(i,t,l){var d=i[t],r=i[l];y(d,r)}function y(i,t){var l=t.startPTS;if(Object(R.isFiniteNumber)(l)){var d=0,r;t.sn>i.sn?(d=l-i.start,r=i):(d=i.start-l,r=t),r.duration!==d&&(r.duration=d)}else if(t.sn>i.sn){var c=i.cc===t.cc;c&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration}else t.start=Math.max(i.start-t.duration,0)}function D(i,t,l,d,r,c){var f=d-l;f<=0&&(p.logger.warn("Fragment should have a positive duration",t),d=l+t.duration,c=r+t.duration);var o=l,v=d,m=t.startPTS,O=t.endPTS;if(Object(R.isFiniteNumber)(m)){var b=Math.abs(m-l);Object(R.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(b,t.deltaPTS):t.deltaPTS=b,o=Math.max(l,m),l=Math.min(l,m),r=Math.min(r,t.startDTS),v=Math.min(d,O),d=Math.max(d,O),c=Math.max(c,t.endDTS)}t.duration=d-l;var M=l-t.start;t.appendedPTS=d,t.start=t.startPTS=l,t.maxStartPTS=o,t.startDTS=r,t.endPTS=d,t.minEndPTS=v,t.endDTS=c;var F=t.sn;if(!i||F<i.startSN||F>i.endSN)return 0;var w,C=F-i.startSN,U=i.fragments;for(U[C]=t,w=C;w>0;w--)y(U[w],U[w-1]);for(w=C;w<U.length-1;w++)y(U[w],U[w+1]);return i.fragmentHint&&y(U[U.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,M}function _(i,t){for(var l=null,d=i.fragments,r=d.length-1;r>=0;r--){var c=d[r].initSegment;if(c){l=c;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var f=0,o;if(E(i,t,function(w,C){w.relurl&&(f=w.cc-C.cc),Object(R.isFiniteNumber)(w.startPTS)&&Object(R.isFiniteNumber)(w.endPTS)&&(C.start=C.startPTS=w.startPTS,C.startDTS=w.startDTS,C.appendedPTS=w.appendedPTS,C.maxStartPTS=w.maxStartPTS,C.endPTS=w.endPTS,C.endDTS=w.endDTS,C.minEndPTS=w.minEndPTS,C.duration=w.endPTS-w.startPTS,C.duration&&(o=C),t.PTSKnown=t.alignedSliding=!0),C.elementaryStreams=w.elementaryStreams,C.loader=w.loader,C.stats=w.stats,C.urlId=w.urlId,w.initSegment&&(C.initSegment=w.initSegment,l=w.initSegment)}),l){var v=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;v.forEach(function(w){var C;(!w.initSegment||w.initSegment.relurl===((C=l)===null||C===void 0?void 0:C.relurl))&&(w.initSegment=l)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(function(w){return!w}),t.deltaUpdateFailed){p.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var m=t.skippedSegments;m--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=T(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var O=t.fragments;if(f){p.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<O.length;b++)O[b].cc+=f}t.skippedSegments&&(t.startCC=t.fragments[0].cc),g(i.partList,t.partList,function(w,C){C.elementaryStreams=w.elementaryStreams,C.stats=w.stats}),o?D(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):a(i,t),O.length&&(t.totalduration=t.edge-O[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var M=t.advancedDateTime;if(t.advanced&&M){var F=t.edge;t.driftStart||(t.driftStartTime=M,t.driftStart=F),t.driftEndTime=M,t.driftEnd=F}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function T(i,t,l){var d=I({},i);return l&&l.forEach(function(r){delete d[r]}),Object.keys(t).forEach(function(r){var c=new S.DateRange(t[r].attr,d[r]);c.isValid?d[r]=c:p.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[r].attr)+'"')}),d}function g(i,t,l){if(i&&t)for(var d=0,r=0,c=i.length;r<=c;r++){var f=i[r],o=t[r+d];f&&o&&f.index===o.index&&f.fragment.sn===o.fragment.sn?l(f,o):d--}}function E(i,t,l){for(var d=t.skippedSegments,r=Math.max(i.startSN,t.startSN)-t.startSN,c=(i.fragmentHint?1:0)+(d?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,f=t.startSN-i.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,v=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,m=r;m<=c;m++){var O=v[f+m],b=o[m];d&&!b&&m<d&&(b=t.fragments[m]=O),O&&b&&l(O,b)}}function a(i,t){var l=t.startSN+t.skippedSegments-i.startSN,d=i.fragments;l<0||l>=d.length||e(t,d[l].start)}function e(i,t){if(t){for(var l=i.fragments,d=i.skippedSegments;d<l.length;d++)l[d].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function s(i,t){var l=1e3*i.levelTargetDuration,d=l/2,r=i.age,c=r>0&&r<l*3,f=t.loading.end-t.loading.start,o,v=i.availabilityDelay;if(i.updated===!1)if(c){var m=333*i.misses;o=Math.max(Math.min(d,f*2),m),i.availabilityDelay=(i.availabilityDelay||0)+o}else o=d;else c?(v=Math.min(v||l/2,r),i.availabilityDelay=v,o=v+l-r):o=l-f;return Math.round(o)}function u(i,t,l){if(!i||!i.details)return null;var d=i.details,r=d.fragments[t-d.startSN];return r||(r=d.fragmentHint,r&&r.sn===t)?r:t<d.startSN&&l&&l.sn===t?l:null}function n(i,t,l){if(!i||!i.details)return null;var d=i.details.partList;if(d)for(var r=d.length;r--;){var c=d[r];if(c.index===l&&c.fragment.sn===t)return c}return null}},"./src/controller/stream-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return n});var R=h("./src/polyfills/number.ts"),p=h("./src/controller/base-stream-controller.ts"),S=h("./src/is-supported.ts"),I=h("./src/events.ts"),x=h("./src/utils/buffer-helper.ts"),L=h("./src/controller/fragment-tracker.ts"),A=h("./src/types/loader.ts"),y=h("./src/loader/fragment.ts"),D=h("./src/demux/transmuxer-interface.ts"),_=h("./src/types/transmuxer.ts"),T=h("./src/controller/gap-controller.ts"),g=h("./src/errors.ts");function E(i,t){for(var l=0;l<t.length;l++){var d=t[l];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(i,d.key,d)}}function a(i,t,l){return t&&E(i.prototype,t),l&&E(i,l),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,s(i,t)}function s(i,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,r){return d.__proto__=r,d},s(i,t)}var u=100,n=function(i){e(t,i);function t(d,r){var c;return c=i.call(this,d,r,"[stream-controller]")||this,c.audioCodecSwap=!1,c.gapController=null,c.level=-1,c._forceStartLoad=!1,c.altAudio=!1,c.audioOnly=!1,c.fragPlaying=null,c.onvplaying=null,c.onvseeked=null,c.fragLastKbps=0,c.couldBacktrack=!1,c.backtrackFragment=null,c.audioCodecSwitch=!1,c.videoBuffer=null,c._registerListeners(),c}var l=t.prototype;return l._registerListeners=function(){var r=this.hls;r.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(I.Events.ERROR,this.onError,this),r.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l._unregisterListeners=function(){var r=this.hls;r.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(I.Events.ERROR,this.onError,this),r.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},l.startLoad=function(r){if(this.levels){var c=this.lastCurrentTime,f=this.hls;if(this.stopLoad(),this.setInterval(u),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var o=f.startLevel;o===-1&&(f.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=f.nextAutoLevel),this.level=f.nextLoadLevel=o,this.loadedmetadata=!1}c>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+c.toFixed(3)),r=c),this.state=p.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=p.State.STOPPED},l.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},l.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_LEVEL:{var r,c=this.levels,f=this.level,o=c==null||(r=c[f])===null||r===void 0?void 0:r.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=p.State.IDLE;break}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var v,m=self.performance.now(),O=this.retryDate;(!O||m>=O||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=p.State.IDLE)}break;default:break}this.onTickEnd()},l.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},l.doTickIdle=function(){var r,c,f=this.hls,o=this.levelLastLoaded,v=this.levels,m=this.media,O=f.config,b=f.nextLoadLevel;if(!(o===null||!m&&(this.startFragRequested||!O.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!v||!v[b])){var M=v[b];this.level=f.nextLoadLevel=b;var F=M.details;if(!F||this.state===p.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==b){this.state=p.State.WAITING_LEVEL;return}var w=this.getMainFwdBufferInfo();if(w!==null){var C=w.len,U=this.getMaxBufferLength(M.maxBitrate);if(!(C>=U)){if(this._streamEnded(w,F)){var B={};this.altAudio&&(B.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,B),this.state=p.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>w.end&&(this.backtrackFragment=null);var N=this.backtrackFragment?this.backtrackFragment.start:w.end,k=this.getNextFragment(N,F);if(this.couldBacktrack&&!this.fragPrevious&&k&&k.sn!=="initSegment"&&this.fragmentTracker.getState(k)!==L.FragmentState.OK){var j,H=((j=this.backtrackFragment)!=null?j:k).sn,V=H-F.startSN,Y=F.fragments[V-1];Y&&k.cc===Y.cc&&(k=Y,this.fragmentTracker.removeFragment(Y))}else this.backtrackFragment&&w.len&&(this.backtrackFragment=null);if(k&&this.fragmentTracker.getState(k)===L.FragmentState.OK&&this.nextLoadPosition>N){var Q=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;m&&this.afterBufferFlushed(m,Q,A.PlaylistLevelType.MAIN),k=this.getNextFragment(this.nextLoadPosition,F)}!k||(k.initSegment&&!k.initSegment.data&&!this.bitrateTest&&(k=k.initSegment),((r=k.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((c=k.decryptdata)!==null&&c!==void 0&&c.key)?this.loadKey(k,F):this.loadFragment(k,F,N))}}}},l.loadFragment=function(r,c,f){var o,v=this.fragmentTracker.getState(r);this.fragCurrent=r,v===L.FragmentState.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,r,c,f)):v===L.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((o=this.media)===null||o===void 0?void 0:o.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},l.getAppendedFrag=function(r){var c=this.fragmentTracker.getAppendedFrag(r,A.PlaylistLevelType.MAIN);return c&&"fragment"in c?c.fragment:c},l.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,A.PlaylistLevelType.MAIN)},l.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},l.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},l.nextLevelSwitch=function(){var r=this.levels,c=this.media;if(c!=null&&c.readyState){var f,o=this.getAppendedFrag(c.currentTime);if(o&&o.start>1&&this.flushMainBuffer(0,o.start-1),!c.paused&&r){var v=this.hls.nextLoadLevel,m=r[v],O=this.fragLastKbps;O&&this.fragCurrent?f=this.fragCurrent.duration*m.maxBitrate/(1e3*O)+1:f=0}else f=0;var b=this.getBufferedFrag(c.currentTime+f);if(b){var M=this.followingBufferedFrag(b);if(M){this.abortCurrentFrag();var F=M.maxStartPTS?M.maxStartPTS:M.start,w=M.duration,C=Math.max(b.end,F+Math.min(Math.max(w-this.config.maxFragLookUpTolerance,w*.5),w*.75));this.flushMainBuffer(C,Number.POSITIVE_INFINITY)}}}},l.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r!=null&&r.loader&&r.loader.abort(),this.state){case p.State.KEY_LOADING:case p.State.FRAG_LOADING:case p.State.FRAG_LOADING_WAITING_RETRY:case p.State.PARSING:case p.State.PARSED:this.state=p.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},l.flushMainBuffer=function(r,c){i.prototype.flushMainBuffer.call(this,r,c,this.altAudio?"video":null)},l.onMediaAttached=function(r,c){i.prototype.onMediaAttached.call(this,r,c);var f=c.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),f.addEventListener("playing",this.onvplaying),f.addEventListener("seeked",this.onvseeked),this.gapController=new T.default(this.config,f,this.fragmentTracker,this.hls)},l.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},l.onMediaPlaying=function(){this.tick()},l.onMediaSeeked=function(){var r=this.media,c=r?r.currentTime:null;Object(R.isFiniteNumber)(c)&&this.log("Media seeked to "+c.toFixed(3)),this.tick()},l.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(I.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},l.onManifestParsed=function(r,c){var f=!1,o=!1,v;c.levels.forEach(function(m){v=m.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(f=!0),v.indexOf("mp4a.40.5")!==-1&&(o=!0))}),this.audioCodecSwitch=f&&o&&!Object(S.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=c.levels,this.startFragRequested=!1},l.onLevelLoading=function(r,c){var f=this.levels;if(!(!f||this.state!==p.State.IDLE)){var o=f[c.level];(!o.details||o.details.live&&this.levelLastLoaded!==c.level||this.waitForCdnTuneIn(o.details))&&(this.state=p.State.WAITING_LEVEL)}},l.onLevelLoaded=function(r,c){var f,o=this.levels,v=c.level,m=c.details,O=m.totalduration;if(!o){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+m.startSN+","+m.endSN+"], cc ["+m.startCC+", "+m.endCC+"] duration:"+O);var b=this.fragCurrent;b&&(this.state===p.State.FRAG_LOADING||this.state===p.State.FRAG_LOADING_WAITING_RETRY)&&b.level!==c.level&&b.loader&&(this.state=p.State.IDLE,this.backtrackFragment=null,b.loader.abort());var M=o[v],F=0;if(m.live||(f=M.details)!==null&&f!==void 0&&f.live){if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed)return;F=this.alignPlaylists(m,M.details)}if(M.details=m,this.levelLastLoaded=v,this.hls.trigger(I.Events.LEVEL_UPDATED,{details:m,level:v}),this.state===p.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(m))return;this.state=p.State.IDLE}this.startFragRequested?m.live&&this.synchronizeToLiveEdge(m):this.setStartPosition(m,F),this.tick()},l._handleFragmentLoadProgress=function(r){var c,f=r.frag,o=r.part,v=r.payload,m=this.levels;if(!m){this.warn("Levels were reset while fragment load was in progress. Fragment "+f.sn+" of level "+f.level+" will not be buffered");return}var O=m[f.level],b=O.details;if(!b){this.warn("Dropping fragment "+f.sn+" of level "+f.level+" after level details were reset");return}var M=O.videoCodec,F=b.PTSKnown||!b.live,w=(c=f.initSegment)===null||c===void 0?void 0:c.data,C=this._getAudioCodec(O),U=this.transmuxer=this.transmuxer||new D.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),B=o?o.index:-1,N=B!==-1,k=new _.ChunkMetadata(f.level,f.sn,f.stats.chunkCount,v.byteLength,B,N),j=this.initPTS[f.cc];U.push(v,w,C,M,f,o,b.totalduration,F,k,j)},l.onAudioTrackSwitching=function(r,c){var f=this.altAudio,o=!!c.url,v=c.id;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var m=this.fragCurrent;m!=null&&m.loader&&(this.log("Switching to main audio track, cancel main fragment load"),m.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var O=this.hls;f&&O.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),O.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:v})}},l.onAudioTrackSwitched=function(r,c){var f=c.id,o=!!this.hls.audioTracks[f].url;if(o){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=o,this.tick()},l.onBufferCreated=function(r,c){var f=c.tracks,o,v,m=!1;for(var O in f){var b=f[O];if(b.id==="main"){if(v=O,o=b,O==="video"){var M=f[O];M&&(this.videoBuffer=M.buffer)}}else m=!0}m&&o?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},l.onFragBuffered=function(r,c){var f=c.frag,o=c.part;if(!(f&&f.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(f)){this.warn("Fragment "+f.sn+(o?" p: "+o.index:"")+" of level "+f.level+" finished buffering, but was aborted. state: "+this.state),this.state===p.State.PARSED&&(this.state=p.State.IDLE);return}var v=o?o.stats:f.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),f.sn!=="initSegment"&&(this.fragPrevious=f),this.fragBufferedComplete(f,o)}},l.onError=function(r,c){switch(c.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,c);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==p.State.ERROR&&(c.fatal?(this.warn(""+c.details),this.state=p.State.ERROR):!c.levelRetry&&this.state===p.State.WAITING_LEVEL&&(this.state=p.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(c.parent==="main"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var f=!0,o=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);o&&o.len>.5&&(f=!this.reduceMaxBufferLength(o.len)),f&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},l.checkBuffer=function(){var r=this.media,c=this.gapController;if(!(!r||!c||!r.readyState)){if(this.loadedmetadata||!x.BufferHelper.getBuffered(r).length){var f=this.state!==p.State.IDLE?this.fragCurrent:null;c.poll(this.lastCurrentTime,f)}this.lastCurrentTime=r.currentTime}},l.onFragLoadEmergencyAborted=function(){this.state=p.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},l.onBufferFlushed=function(r,c){var f=c.type;if(f!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var o=(f===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,f,A.PlaylistLevelType.MAIN)}},l.onLevelsUpdated=function(r,c){this.levels=c.levels},l.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},l.seekToStartPos=function(){var r=this.media;if(!!r){var c=r.currentTime,f=this.startPosition;if(f>=0&&c<f){if(r.seeking){this.log("could not seek to "+f+", already seeking at "+c);return}var o=x.BufferHelper.getBuffered(r),v=o.length?o.start(0):0,m=v-f;m>0&&(m<this.config.maxBufferHole||m<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+m+" to match buffer start"),f+=m,this.startPosition=f),this.log("seek to target start position "+f+" from current time "+c),r.currentTime=f}}},l._getAudioCodec=function(r){var c=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&c&&(this.log("Swapping audio codec"),c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5"),c},l._loadBitrateTestFrag=function(r){var c=this;r.bitrateTest=!0,this._doFragLoad(r).then(function(f){var o=c.hls;if(!(!f||o.nextLoadLevel||c.fragContextChanged(r))){c.fragLoadError=0,c.state=p.State.IDLE,c.startFragRequested=!1,c.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),o.trigger(I.Events.FRAG_LOADED,f),r.bitrateTest=!1}})},l._handleTransmuxComplete=function(r){var c,f="main",o=this.hls,v=r.remuxResult,m=r.chunkMeta,O=this.getCurrentContext(m);if(!O){this.warn("The loading context changed while buffering fragment "+m.sn+" of level "+m.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(m.level);return}var b=O.frag,M=O.part,F=O.level,w=v.video,C=v.text,U=v.id3,B=v.initSegment,N=F.details,k=this.altAudio?void 0:v.audio;if(!this.fragContextChanged(b)){if(this.state=p.State.PARSING,B){B.tracks&&(this._bufferInitSegment(F,B.tracks,b,m),o.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:f,tracks:B.tracks}));var j=B.initPTS,H=B.timescale;Object(R.isFiniteNumber)(j)&&(this.initPTS[b.cc]=j,o.trigger(I.Events.INIT_PTS_FOUND,{frag:b,id:f,initPTS:j,timescale:H}))}if(w&&v.independent!==!1){if(N){var V=w.startPTS,Y=w.endPTS,Q=w.startDTS,J=w.endDTS;if(M)M.elementaryStreams[w.type]={startPTS:V,endPTS:Y,startDTS:Q,endDTS:J};else if(w.firstKeyFrame&&w.independent&&(this.couldBacktrack=!0),w.dropped&&w.independent){var z=this.getMainFwdBufferInfo(),q=(z?z.end:this.getLoadPosition())+this.config.maxBufferHole,re=w.firstKeyFramePTS?w.firstKeyFramePTS:V;if(q<re-this.config.maxBufferHole){this.backtrack(b);return}b.setElementaryStreamInfo(w.type,b.start,Y,b.start,J,!0)}b.setElementaryStreamInfo(w.type,V,Y,Q,J),this.backtrackFragment&&(this.backtrackFragment=b),this.bufferFragmentData(w,b,M,m)}}else if(v.independent===!1){this.backtrack(b);return}if(k){var X=k.startPTS,le=k.endPTS,ne=k.startDTS,te=k.endDTS;M&&(M.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:le,startDTS:ne,endDTS:te}),b.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,X,le,ne,te),this.bufferFragmentData(k,b,M,m)}if(N&&U!==null&&U!==void 0&&(c=U.samples)!==null&&c!==void 0&&c.length){var ee={id:f,frag:b,details:N,samples:U.samples};o.trigger(I.Events.FRAG_PARSING_METADATA,ee)}if(N&&C){var $={id:f,frag:b,details:N,samples:C.samples};o.trigger(I.Events.FRAG_PARSING_USERDATA,$)}}},l._bufferInitSegment=function(r,c,f,o){var v=this;if(this.state===p.State.PARSING){this.audioOnly=!!c.audio&&!c.video,this.altAudio&&!this.audioOnly&&delete c.audio;var m=c.audio,O=c.video,b=c.audiovideo;if(m){var M=r.audioCodec,F=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(M&&(M.indexOf("mp4a.40.5")!==-1?M="mp4a.40.2":M="mp4a.40.5"),m.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(M="mp4a.40.5")),F.indexOf("android")!==-1&&m.container!=="audio/mpeg"&&(M="mp4a.40.2",this.log("Android: force audio codec to "+M)),r.audioCodec&&r.audioCodec!==M&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+M+'"'),m.levelCodec=M,m.id="main",this.log("Init audio buffer, container:"+m.container+", codecs[selected/level/parsed]=["+(M||"")+"/"+(r.audioCodec||"")+"/"+m.codec+"]")}O&&(O.levelCodec=r.videoCodec,O.id="main",this.log("Init video buffer, container:"+O.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+O.codec+"]")),b&&this.log("Init audiovideo buffer, container:"+b.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+b.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,c),Object.keys(c).forEach(function(w){var C=c[w],U=C.initSegment;U!=null&&U.byteLength&&v.hls.trigger(I.Events.BUFFER_APPENDING,{type:w,data:U,frag:f,part:null,chunkMeta:o,parent:f.type})}),this.tick()}},l.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.PlaylistLevelType.MAIN)},l.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=p.State.IDLE},l.checkFragmentChanged=function(){var r=this.media,c=null;if(r&&r.readyState>1&&r.seeking===!1){var f=r.currentTime;if(x.BufferHelper.isBuffered(r,f)?c=this.getAppendedFrag(f):x.BufferHelper.isBuffered(r,f+.1)&&(c=this.getAppendedFrag(f+.1)),c){this.backtrackFragment=null;var o=this.fragPlaying,v=c.level;(!o||c.sn!==o.sn||o.level!==v||c.urlId!==o.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:c}),(!o||o.level!==v)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=c)}}},a(t,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var c=r.currentTime,f=this.currentFrag;if(f&&Object(R.isFiniteNumber)(c)&&Object(R.isFiniteNumber)(f.programDateTime)){var o=f.programDateTime+(c-f.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(p.default)},"./src/controller/subtitle-stream-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"SubtitleStreamController",function(){return e});var R=h("./src/events.ts"),p=h("./src/utils/buffer-helper.ts"),S=h("./src/controller/fragment-finders.ts"),I=h("./src/utils/discontinuities.ts"),x=h("./src/controller/level-helper.ts"),L=h("./src/controller/fragment-tracker.ts"),A=h("./src/controller/base-stream-controller.ts"),y=h("./src/types/loader.ts"),D=h("./src/types/level.ts");function _(u,n){for(var i=0;i<n.length;i++){var t=n[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(u,t.key,t)}}function T(u,n,i){return n&&_(u.prototype,n),i&&_(u,i),Object.defineProperty(u,"prototype",{writable:!1}),u}function g(u,n){u.prototype=Object.create(n.prototype),u.prototype.constructor=u,E(u,n)}function E(u,n){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,l){return t.__proto__=l,t},E(u,n)}var a=500,e=function(u){g(n,u);function n(t,l){var d;return d=u.call(this,t,l,"[subtitle-stream-controller]")||this,d.levels=[],d.currentTrackId=-1,d.tracksBuffered=[],d.mainDetails=null,d._registerListeners(),d}var i=n.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var l=this.hls;l.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(R.Events.ERROR,this.onError,this),l.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var l=this.hls;l.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(R.Events.ERROR,this.onError,this),l.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(a),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(l,d){this.mainDetails=d.details},i.onSubtitleFragProcessed=function(l,d){var r=d.frag,c=d.success;if(this.fragPrevious=r,this.state=A.State.IDLE,!!c){var f=this.tracksBuffered[this.currentTrackId];if(!!f){for(var o,v=r.start,m=0;m<f.length;m++)if(v>=f[m].start&&v<=f[m].end){o=f[m];break}var O=r.start+r.duration;o?o.end=O:(o={start:v,end:O},f.push(o)),this.fragmentTracker.fragBuffered(r)}}},i.onBufferFlushing=function(l,d){var r=d.startOffset,c=d.endOffset;if(r===0&&c!==Number.POSITIVE_INFINITY){var f=this.currentTrackId,o=this.levels;if(!o.length||!o[f]||!o[f].details)return;var v=o[f].details,m=v.targetduration,O=c-m;if(O<=0)return;d.endOffsetSubtitles=Math.max(0,O),this.tracksBuffered.forEach(function(b){for(var M=0;M<b.length;){if(b[M].end<=O){b.shift();continue}else if(b[M].start<O)b[M].start=O;else break;M++}}),this.fragmentTracker.removeFragmentsInRange(r,O,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(l,d){var r,c=d.frag;!c||c.type!==y.PlaylistLevelType.SUBTITLE||((r=this.fragCurrent)!==null&&r!==void 0&&r.loader&&this.fragCurrent.loader.abort(),this.state=A.State.IDLE)},i.onSubtitleTracksUpdated=function(l,d){var r=this,c=d.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(f){return new D.Level(f)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(f){r.tracksBuffered[f.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(l,d){if(this.currentTrackId=d.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(a)},i.onSubtitleTrackLoaded=function(l,d){var r,c=d.details,f=d.id,o=this.currentTrackId,v=this.levels;if(!!v.length){var m=v[o];if(!(f>=v.length||f!==o||!m)){if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(r=m.details)!==null&&r!==void 0&&r.live){var O=this.mainDetails;if(c.deltaUpdateFailed||!O)return;var b=O.fragments[0];if(!m.details)c.hasProgramDateTime&&O.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(c,O):b&&Object(x.addSliding)(c,b.start);else{var M=this.alignPlaylists(c,m.details);M===0&&b&&Object(x.addSliding)(c,b.start)}}if(m.details=c,this.levelLastLoaded=f,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var F=Object(S.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}}}},i._handleFragmentLoadComplete=function(l){var d=l.frag,r=l.payload,c=d.decryptdata,f=this.hls;if(!this.fragContextChanged(d)&&r&&r.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),c.key.buffer,c.iv.buffer).then(function(v){var m=performance.now();f.trigger(R.Events.FRAG_DECRYPTED,{frag:d,payload:v,stats:{tstart:o,tdecrypt:m}})})}},i.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var l=this.currentTrackId,d=this.levels;if(!d.length||!d[l]||!d[l].details)return;var r=d[l].details,c=r.targetduration,f=this.config,o=this.media,v=p.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o.currentTime-c,f.maxBufferHole),m=v.end,O=v.len,b=this.getMaxBufferLength()+c;if(O>b)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var M=r.fragments,F=M.length,w=r.edge,C,U=this.fragPrevious;if(m<w){var B=f.maxFragLookUpTolerance;C=Object(S.findFragmentByPTS)(U,M,Math.max(M[0].start,m),B),!C&&U&&U.start<M[0].start&&(C=M[0])}else C=M[F-1];if(C=this.mapToInitFragWhenRequired(C),!C||this.fragmentTracker.getState(C)!==L.FragmentState.NOT_LOADED)return;C.encrypted?this.loadKey(C,r):this.loadFragment(C,r,m)}},i.loadFragment=function(l,d,r){this.fragCurrent=l,l.sn==="initSegment"?this._loadInitSegment(l):u.prototype.loadFragment.call(this,l,d,r)},T(n,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(A.default),s=function(n){this.buffered=void 0;var i=function(l,d,r){if(d=d>>>0,d>r-1)throw new DOMException("Failed to execute '"+l+"' on 'TimeRanges': The index provided ("+d+") is greater than the maximum bound ("+r+")");return n[d][l]};this.buffered={get length(){return n.length},end:function(l){return i("end",l,n.length)},start:function(l){return i("start",l,n.length)}}}},"./src/controller/subtitle-track-controller.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/events.ts"),p=h("./src/utils/texttrack-utils.ts"),S=h("./src/controller/base-playlist-controller.ts"),I=h("./src/types/loader.ts");function x(T,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(T,a.key,a)}}function L(T,g,E){return g&&x(T.prototype,g),E&&x(T,E),Object.defineProperty(T,"prototype",{writable:!1}),T}function A(T,g){T.prototype=Object.create(g.prototype),T.prototype.constructor=T,y(T,g)}function y(T,g){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,e){return a.__proto__=e,a},y(T,g)}var D=function(T){A(g,T);function g(a){var e;return e=T.call(this,a,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var E=g.prototype;return E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,T.prototype.destroy.call(this)},E.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.Events.ERROR,this.onError,this)},E.onMediaAttached=function(e,s){this.media=s.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))},E.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},E.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=_(this.media.textTracks);e.forEach(function(s){Object(p.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null}},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},E.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},E.onSubtitleTrackLoaded=function(e,s){var u=s.id,n=s.details,i=this.trackId,t=this.tracksInGroup[i];if(!t){this.warn("Invalid subtitle track id "+u);return}var l=t.details;t.details=s.details,this.log("subtitle track "+u+" loaded ["+n.startSN+"-"+n.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,s,l))},E.onLevelLoading=function(e,s){this.switchLevel(s.level)},E.onLevelSwitching=function(e,s){this.switchLevel(s.level)},E.switchLevel=function(e){var s=this.hls.levels[e];if(!!(s!=null&&s.textGroupIds)){var u=s.textGroupIds[s.urlId];if(this.groupId!==u){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(d){return!u||d.groupId===u});this.tracksInGroup=i;var t=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=u;var l={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,l),t!==-1&&this.setSubtitleTrack(t,n)}}},E.findTrackId=function(e){for(var s=this.tracksInGroup,u=0;u<s.length;u++){var n=s[u];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},E.onError=function(e,s){T.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===I.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},E.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var u=s.id,n=s.groupId,i=s.url;if(e)try{i=e.addDirectives(i)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+u),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:i,id:u,groupId:n,deliveryDirectives:e||null})}},E.toggleTrackModes=function(e){var s=this,u=this.media,n=this.trackId;if(!!u){var i=_(u.textTracks),t=i.filter(function(r){return r.groupId===s.groupId});if(e===-1)[].slice.call(i).forEach(function(r){r.mode="disabled"});else{var l=t[n];l&&(l.mode="disabled")}var d=t[e];d&&(d.mode=this.subtitleDisplay?"showing":"hidden")}},E.setSubtitleTrack=function(e,s){var u,n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(u=n[e])!==null&&u!==void 0&&u.details)||e<-1||e>=n.length)){this.clearTimer();var i=n[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var t=i.id,l=i.groupId,d=l===void 0?"":l,r=i.name,c=i.type,f=i.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t,groupId:d,name:r,type:c,url:f});var o=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(o)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},E.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,s=_(this.media.textTracks),u=0;u<s.length;u++)if(s[u].mode==="hidden")e=u;else if(s[u].mode==="showing"){e=u;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},L(g,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),g}(S.default);function _(T){for(var g=[],E=0;E<T.length;E++){var a=T[E];a.kind==="subtitles"&&a.label&&g.push(T[E])}return g}P.default=D},"./src/controller/timeline-controller.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"TimelineController",function(){return T});var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/utils/cea-608-parser.ts"),I=h("./src/utils/output-filter.ts"),x=h("./src/utils/webvtt-parser.ts"),L=h("./src/utils/texttrack-utils.ts"),A=h("./src/utils/imsc1-ttml-parser.ts"),y=h("./src/utils/mp4-tools.ts"),D=h("./src/types/loader.ts"),_=h("./src/utils/logger.ts"),T=function(){function e(u){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=a(),this.captionsProperties=void 0,this.hls=u,this.config=u.config,this.Cues=u.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var n=new I.default(this,"textTrack1"),i=new I.default(this,"textTrack2"),t=new I.default(this,"textTrack3"),l=new I.default(this,"textTrack4");this.cea608Parser1=new S.default(1,n,i),this.cea608Parser2=new S.default(3,t,l)}u.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.on(p.Events.FRAG_LOADING,this.onFragLoading,this),u.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),u.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),u.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),u.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var n=this.hls;n.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(p.Events.FRAG_LOADING,this.onFragLoading,this),n.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),n.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(n,i,t,l,d){for(var r=!1,c=d.length;c--;){var f=d[c],o=E(f[0],f[1],i,t);if(o>=0&&(f[0]=Math.min(f[0],i),f[1]=Math.max(f[1],t),r=!0,o/(t-i)>.5))return}if(r||d.push([i,t]),this.config.renderTextTracksNatively){var v=this.captionsTracks[n];this.Cues.newCue(v,i,t,l)}else{var m=this.Cues.newCue(null,i,t,l);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:m,track:n})}},s.onInitPtsFound=function(n,i){var t=this,l=i.frag,d=i.id,r=i.initPTS,c=i.timescale,f=this.unparsedVttFrags;d==="main"&&(this.initPTS[l.cc]=r,this.timescale[l.cc]=c),f.length&&(this.unparsedVttFrags=[],f.forEach(function(o){t.onFragLoaded(p.Events.FRAG_LOADED,o)}))},s.getExistingTrack=function(n){var i=this.media;if(i)for(var t=0;t<i.textTracks.length;t++){var l=i.textTracks[t];if(l[n])return l}return null},s.createCaptionsTrack=function(n){this.config.renderTextTracksNatively?this.createNativeTrack(n):this.createNonNativeTrack(n)},s.createNativeTrack=function(n){if(!this.captionsTracks[n]){var i=this.captionsProperties,t=this.captionsTracks,l=this.media,d=i[n],r=d.label,c=d.languageCode,f=this.getExistingTrack(n);if(f)t[n]=f,Object(L.clearCurrentCues)(t[n]),Object(L.sendAddTrackEvent)(t[n],l);else{var o=this.createTextTrack("captions",r,c);o&&(o[n]=!0,t[n]=o)}}},s.createNonNativeTrack=function(n){if(!this.nonNativeCaptionsTracks[n]){var i=this.captionsProperties[n];if(!!i){var t=i.label,l={_id:n,label:t,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[n]=l,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})}}},s.createTextTrack=function(n,i,t){var l=this.media;if(!!l)return l.addTextTrack(n,i,t)},s.onMediaAttaching=function(n,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var n=this.captionsTracks;Object.keys(n).forEach(function(i){Object(L.clearCurrentCues)(n[i]),delete n[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=a(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var n=this.media;if(!!n){var i=n.textTracks;if(i)for(var t=0;t<i.length;t++)Object(L.clearCurrentCues)(i[t])}},s.onSubtitleTracksUpdated=function(n,i){var t=this;this.textTracks=[];var l=i.subtitleTracks||[],d=l.some(function(o){return o.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||d&&this.config.enableIMSC1){var r=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var c=this.media?this.media.textTracks:[];this.tracks.forEach(function(o,v){var m;if(v<c.length){for(var O=null,b=0;b<c.length;b++)if(g(c[b],o)){O=c[b];break}O&&(m=O)}if(m)Object(L.clearCurrentCues)(m);else{var M=t._captionsOrSubtitlesFromCharacteristics(o);m=t.createTextTrack(M,o.name,o.lang),m&&(m.mode="disabled")}m&&(m.groupId=o.groupId,t.textTracks.push(m))})}else if(!r&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(o){return{label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},s._captionsOrSubtitlesFromCharacteristics=function(n){var i;if((i=n.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(n.attrs.CHARACTERISTICS),l=/describes-music-and-sound/gi.test(n.attrs.CHARACTERISTICS);if(t&&l)return"captions"}return"subtitles"},s.onManifestLoaded=function(n,i){var t=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(l){var d=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!!d){var r="textTrack"+d[1],c=t.captionsProperties[r];!c||(c.label=l.name,l.lang&&(c.languageCode=l.lang),c.media=l)}})},s.onFragLoading=function(n,i){var t=this.cea608Parser1,l=this.cea608Parser2,d=this.lastSn,r=this.lastPartIndex;if(!(!this.enabled||!(t&&l))&&i.frag.type===D.PlaylistLevelType.MAIN){var c,f,o=i.frag.sn,v=(c=i==null||(f=i.part)===null||f===void 0?void 0:f.index)!=null?c:-1;o===d+1||o===d&&v===r+1||(t.reset(),l.reset()),this.lastSn=o,this.lastPartIndex=v}},s.onFragLoaded=function(n,i){var t=i.frag,l=i.payload,d=this.initPTS,r=this.unparsedVttFrags;if(t.type===D.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(R.isFiniteNumber)(d[t.cc])){r.push(i),d.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")});return}var c=t.decryptdata,f="stats"in i;if(c==null||c.key==null||c.method!=="AES-128"||f){var o=this.tracks[t.level],v=this.vttCCs;v[t.cc]||(v[t.cc]={start:t.start,prevCC:this.prevCC,new:!0},this.prevCC=t.cc),o&&o.textCodec===A.IMSC1_CODEC?this._parseIMSC1(t,l):this._parseVTTs(t,l,v)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(n,i){var t=this,l=this.hls;Object(A.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(d){t._appendCues(d,n.level),l.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(d){_.logger.log("Failed to parse IMSC1: "+d),l.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:d})})},s._parseVTTs=function(n,i,t){var l,d=this,r=this.hls,c=(l=n.initSegment)!==null&&l!==void 0&&l.data?Object(y.appendUint8Array)(n.initSegment.data,new Uint8Array(i)):i;Object(x.parseWebVTT)(c,this.initPTS[n.cc],this.timescale[n.cc],t,n.cc,n.start,function(f){d._appendCues(f,n.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(f){d._fallbackToIMSC1(n,i),_.logger.log("Failed to parse VTT cue: "+f),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:f})})},s._fallbackToIMSC1=function(n,i){var t=this,l=this.tracks[n.level];l.textCodec||Object(A.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(){l.textCodec=A.IMSC1_CODEC,t._parseIMSC1(n,i)},function(){l.textCodec="wvtt"})},s._appendCues=function(n,i){var t=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[i];if(!l||l.mode==="disabled")return;n.forEach(function(c){return Object(L.addCueToTrack)(l,c)})}else{var d=this.tracks[i];if(!d)return;var r=d.default?"default":"subtitles"+i;t.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:n,track:r})}},s.onFragDecrypted=function(n,i){var t=i.frag;if(t.type===D.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(p.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(n,i){var t=this.cea608Parser1,l=this.cea608Parser2;if(!(!this.enabled||!(t&&l)))for(var d=0;d<i.samples.length;d++){var r=i.samples[d].bytes;if(r){var c=this.extractCea608Data(r);t.addData(i.samples[d].pts,c[0]),l.addData(i.samples[d].pts,c[1])}}},s.onBufferFlushing=function(n,i){var t=i.startOffset,l=i.endOffset,d=i.endOffsetSubtitles,r=i.type,c=this.media;if(!(!c||c.currentTime<l)){if(!r||r==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(v){return Object(L.removeCuesInRange)(f[v],t,l)})}if(this.config.renderTextTracksNatively&&t===0&&d!==void 0){var o=this.textTracks;Object.keys(o).forEach(function(v){return Object(L.removeCuesInRange)(o[v],t,d)})}}},s.extractCea608Data=function(n){for(var i=[[],[]],t=n[0]&31,l=2,d=0;d<t;d++){var r=n[l++],c=127&n[l++],f=127&n[l++];if(!(c===0&&f===0)){var o=(4&r)!==0;if(o){var v=3&r;(v===0||v===1)&&(i[v].push(c),i[v].push(f))}}}return i},e}();function g(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function E(e,s,u,n){return Math.min(s,n)-Math.max(e,u)}function a(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(I,x){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=x}var S=p.prototype;return S.decrypt=function(x,L){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},L,x)},p}()},"./src/crypt/aes-decryptor.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"removePadding",function(){return p}),h.d(P,"default",function(){return S});var R=h("./src/utils/typed-array.ts");function p(I){var x=I.byteLength,L=x&&new DataView(I.buffer).getUint8(x-1);return L?Object(R.sliceUint8)(I,0,x-L):I}var S=function(){function I(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var x=I.prototype;return x.uint8ArrayToUint32Array_=function(A){for(var y=new DataView(A),D=new Uint32Array(4),_=0;_<4;_++)D[_]=y.getUint32(_*4);return D},x.initTable=function(){var A=this.sBox,y=this.invSBox,D=this.subMix,_=D[0],T=D[1],g=D[2],E=D[3],a=this.invSubMix,e=a[0],s=a[1],u=a[2],n=a[3],i=new Uint32Array(256),t=0,l=0,d=0;for(d=0;d<256;d++)d<128?i[d]=d<<1:i[d]=d<<1^283;for(d=0;d<256;d++){var r=l^l<<1^l<<2^l<<3^l<<4;r=r>>>8^r&255^99,A[t]=r,y[r]=t;var c=i[t],f=i[c],o=i[f],v=i[r]*257^r*16843008;_[t]=v<<24|v>>>8,T[t]=v<<16|v>>>16,g[t]=v<<8|v>>>24,E[t]=v,v=o*16843009^f*65537^c*257^t*16843008,e[r]=v<<24|v>>>8,s[r]=v<<16|v>>>16,u[r]=v<<8|v>>>24,n[r]=v,t?(t=c^i[i[i[o^c]]],l^=i[i[l]]):t=l=1}},x.expandKey=function(A){for(var y=this.uint8ArrayToUint32Array_(A),D=!0,_=0;_<y.length&&D;)D=y[_]===this.key[_],_++;if(!D){this.key=y;var T=this.keySize=y.length;if(T!==4&&T!==6&&T!==8)throw new Error("Invalid aes key size="+T);var g=this.ksRows=(T+6+1)*4,E,a,e=this.keySchedule=new Uint32Array(g),s=this.invKeySchedule=new Uint32Array(g),u=this.sBox,n=this.rcon,i=this.invSubMix,t=i[0],l=i[1],d=i[2],r=i[3],c,f;for(E=0;E<g;E++){if(E<T){c=e[E]=y[E];continue}f=c,E%T===0?(f=f<<8|f>>>24,f=u[f>>>24]<<24|u[f>>>16&255]<<16|u[f>>>8&255]<<8|u[f&255],f^=n[E/T|0]<<24):T>6&&E%T===4&&(f=u[f>>>24]<<24|u[f>>>16&255]<<16|u[f>>>8&255]<<8|u[f&255]),e[E]=c=(e[E-T]^f)>>>0}for(a=0;a<g;a++)E=g-a,a&3?f=e[E]:f=e[E-4],a<4||E<=4?s[a]=f:s[a]=t[u[f>>>24]]^l[u[f>>>16&255]]^d[u[f>>>8&255]]^r[u[f&255]],s[a]=s[a]>>>0}},x.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},x.decrypt=function(A,y,D){for(var _=this.keySize+6,T=this.invKeySchedule,g=this.invSBox,E=this.invSubMix,a=E[0],e=E[1],s=E[2],u=E[3],n=this.uint8ArrayToUint32Array_(D),i=n[0],t=n[1],l=n[2],d=n[3],r=new Int32Array(A),c=new Int32Array(r.length),f,o,v,m,O,b,M,F,w,C,U,B,N,k,j=this.networkToHostOrderSwap;y<r.length;){for(w=j(r[y]),C=j(r[y+1]),U=j(r[y+2]),B=j(r[y+3]),O=w^T[0],b=B^T[1],M=U^T[2],F=C^T[3],N=4,k=1;k<_;k++)f=a[O>>>24]^e[b>>16&255]^s[M>>8&255]^u[F&255]^T[N],o=a[b>>>24]^e[M>>16&255]^s[F>>8&255]^u[O&255]^T[N+1],v=a[M>>>24]^e[F>>16&255]^s[O>>8&255]^u[b&255]^T[N+2],m=a[F>>>24]^e[O>>16&255]^s[b>>8&255]^u[M&255]^T[N+3],O=f,b=o,M=v,F=m,N=N+4;f=g[O>>>24]<<24^g[b>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^T[N],o=g[b>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[O&255]^T[N+1],v=g[M>>>24]<<24^g[F>>16&255]<<16^g[O>>8&255]<<8^g[b&255]^T[N+2],m=g[F>>>24]<<24^g[O>>16&255]<<16^g[b>>8&255]<<8^g[M&255]^T[N+3],c[y]=j(f^i),c[y+1]=j(m^t),c[y+2]=j(v^l),c[y+3]=j(o^d),i=w,t=C,l=U,d=B,y=y+4}return c.buffer},I}()},"./src/crypt/decrypter.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return y});var R=h("./src/crypt/aes-crypto.ts"),p=h("./src/crypt/fast-aes-key.ts"),S=h("./src/crypt/aes-decryptor.ts"),I=h("./src/utils/logger.ts"),x=h("./src/utils/mp4-tools.ts"),L=h("./src/utils/typed-array.ts"),A=16,y=function(){function D(T,g,E){var a=E===void 0?{}:E,e=a.removePKCS7Padding,s=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=T,this.config=g,this.removePKCS7Padding=s,s)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var _=D.prototype;return _.destroy=function(){this.observer=null},_.isSync=function(){return this.config.enableSoftwareAES},_.flush=function(){var g=this.currentResult;if(!g){this.reset();return}var E=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(S.removePadding)(E):E},_.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},_.decrypt=function(g,E,a,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),E,a);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),E,a).then(e)},_.softwareDecrypt=function(g,E,a){var e=this.currentIV,s=this.currentResult,u=this.remainderData;this.logOnce("JS AES decrypt"),u&&(g=Object(x.appendUint8Array)(u,g),this.remainderData=null);var n=this.getValidChunk(g);if(!n.length)return null;e&&(a=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new S.default),i.expandKey(E);var t=s;return this.currentResult=i.decrypt(n.buffer,0,a),this.currentIV=Object(L.sliceUint8)(n,-16).buffer,t||null},_.webCryptoDecrypt=function(g,E,a){var e=this,s=this.subtle;return(this.key!==E||!this.fastAesKey)&&(this.key=E,this.fastAesKey=new p.default(s,E)),this.fastAesKey.expandKey().then(function(u){if(!s)return Promise.reject(new Error("web crypto not initialized"));var n=new R.default(s,a);return n.decrypt(g.buffer,u)}).catch(function(u){return e.onWebCryptoError(u,g,E,a)})},_.onWebCryptoError=function(g,E,a,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,a,e)},_.getValidChunk=function(g){var E=g,a=g.length-g.length%A;return a!==g.length&&(E=Object(L.sliceUint8)(g,0,a),this.remainderData=Object(L.sliceUint8)(g,a)),E},_.logOnce=function(g){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},D}()},"./src/crypt/fast-aes-key.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(I,x){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=x}var S=p.prototype;return S.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},p}()},"./src/demux/aacdemuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/demux/base-audio-demuxer.ts"),p=h("./src/demux/adts.ts"),S=h("./src/utils/logger.ts"),I=h("./src/demux/id3.ts");function x(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,L(y,D)}function L(y,D){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,g){return T.__proto__=g,T},L(y,D)}var A=function(y){x(D,y);function D(T,g){var E;return E=y.call(this)||this,E.observer=void 0,E.config=void 0,E.observer=T,E.config=g,E}var _=D.prototype;return _.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=I.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(p.probe(g,a))return S.logger.log("ADTS sync word found !"),!0;return!1},_.canParse=function(g,E){return p.canParse(g,E)},_.appendFrame=function(g,E,a){p.initTrackConfig(g,this.observer,E,a,g.manifestCodec);var e=p.appendFrame(g,E,a,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},D}(R.default);P.default=A},"./src/demux/adts.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"getAudioConfig",function(){return I}),h.d(P,"isHeaderPattern",function(){return x}),h.d(P,"getHeaderLength",function(){return L}),h.d(P,"getFullFrameLength",function(){return A}),h.d(P,"canGetFrameLength",function(){return y}),h.d(P,"isHeader",function(){return D}),h.d(P,"canParse",function(){return _}),h.d(P,"probe",function(){return T}),h.d(P,"initTrackConfig",function(){return g}),h.d(P,"getFrameDuration",function(){return E}),h.d(P,"parseFrameHeader",function(){return a}),h.d(P,"appendFrame",function(){return e});var R=h("./src/utils/logger.ts"),p=h("./src/errors.ts"),S=h("./src/events.ts");function I(s,u,n,i){var t,l,d,r,c=navigator.userAgent.toLowerCase(),f=i,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((u[n+2]&192)>>>6)+1;var v=(u[n+2]&60)>>>2;if(v>o.length-1){s.trigger(S.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v});return}return d=(u[n+2]&1)<<2,d|=(u[n+3]&192)>>>6,R.logger.log("manifest codec:"+i+", ADTS type:"+t+", samplingIndex:"+v),/firefox/i.test(c)?v>=6?(t=5,r=new Array(4),l=v-3):(t=2,r=new Array(2),l=v):c.indexOf("android")!==-1?(t=2,r=new Array(2),l=v):(t=5,r=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?l=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&d===1||/vivaldi/i.test(c))||!i&&d===1)&&(t=2,r=new Array(2)),l=v)),r[0]=t<<3,r[0]|=(v&14)>>1,r[1]|=(v&1)<<7,r[1]|=d<<3,t===5&&(r[1]|=(l&14)>>1,r[2]=(l&1)<<7,r[2]|=2<<2,r[3]=0),{config:r,samplerate:o[v],channelCount:d,codec:"mp4a.40."+t,manifestCodec:f}}function x(s,u){return s[u]===255&&(s[u+1]&246)===240}function L(s,u){return s[u+1]&1?7:9}function A(s,u){return(s[u+3]&3)<<11|s[u+4]<<3|(s[u+5]&224)>>>5}function y(s,u){return u+5<s.length}function D(s,u){return u+1<s.length&&x(s,u)}function _(s,u){return y(s,u)&&x(s,u)&&A(s,u)<=s.length-u}function T(s,u){if(D(s,u)){var n=L(s,u);if(u+n>=s.length)return!1;var i=A(s,u);if(i<=n)return!1;var t=u+i;return t===s.length||D(s,t)}return!1}function g(s,u,n,i,t){if(!s.samplerate){var l=I(u,n,i,t);if(!l)return;s.config=l.config,s.samplerate=l.samplerate,s.channelCount=l.channelCount,s.codec=l.codec,s.manifestCodec=l.manifestCodec,R.logger.log("parsed codec:"+s.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function E(s){return 1024*9e4/s}function a(s,u){var n=L(s,u);if(u+n<=s.length){var i=A(s,u)-n;if(i>0)return{headerLength:n,frameLength:i}}}function e(s,u,n,i,t){var l=E(s.samplerate),d=i+t*l,r=a(u,n),c;if(r){var f=r.frameLength,o=r.headerLength,v=o+f,m=Math.max(0,n+v-u.length);m?(c=new Uint8Array(v-o),c.set(u.subarray(n+o,u.length),0)):c=u.subarray(n+o,n+v);var O={unit:c,pts:d};return m||s.samples.push(O),{sample:O,length:v,missing:m}}var b=u.length-n;c=new Uint8Array(b),c.set(u.subarray(n,u.length),0);var M={unit:c,pts:d};return{sample:M,length:b,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"initPTSFn",function(){return y});var R=h("./src/polyfills/number.ts"),p=h("./src/demux/id3.ts"),S=h("./src/types/demuxer.ts"),I=h("./src/demux/dummy-demuxed-track.ts"),x=h("./src/utils/mp4-tools.ts"),L=h("./src/utils/typed-array.ts"),A=function(){function D(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var _=D.prototype;return _.resetInitSegment=function(g,E,a,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},_.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},_.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},_.canParse=function(g,E){return!1},_.appendFrame=function(g,E,a){},_.demux=function(g,E){this.cachedData&&(g=Object(x.appendUint8Array)(this.cachedData,g),this.cachedData=null);var a=p.getID3Data(g,0),e=a?a.length:0,s,u,n=this._audioTrack,i=this._id3Track,t=a?p.getTimeStamp(a):void 0,l=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(R.isFiniteNumber)(t))&&(this.basePTS=y(t,E,this.initPTS)),a&&a.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:a,type:S.MetadataSchema.audioId3}),u=this.basePTS;e<l;){if(this.canParse(g,e)){var d=this.appendFrame(n,g,e);d?(this.frameIndex++,u=d.sample.pts,e+=d.length,s=e):e=l}else p.canParse(g,e)?(a=p.getID3Data(g,e),i.samples.push({pts:u,dts:u,data:a,type:S.MetadataSchema.audioId3}),e+=a.length,s=e):e++;if(e===l&&s!==l){var r=Object(L.sliceUint8)(g,s);this.cachedData?this.cachedData=Object(x.appendUint8Array)(this.cachedData,r):this.cachedData=r}}return{audioTrack:n,videoTrack:Object(I.dummyTrack)(),id3Track:i,textTrack:Object(I.dummyTrack)()}},_.demuxSampleAes=function(g,E,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},_.flush=function(g){var E=this.cachedData;return E&&(this.cachedData=null,this.demux(E,0)),{audioTrack:this._audioTrack,videoTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},_.destroy=function(){},D}(),y=function(_,T,g){return Object(R.isFiniteNumber)(_)?_*90:T*9e4+(g||0)};P.default=A},"./src/demux/chunk-cache.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function S(){this.chunks=[],this.dataLength=0}var I=S.prototype;return I.push=function(L){this.chunks.push(L),this.dataLength+=L.length},I.flush=function(){var L=this.chunks,A=this.dataLength,y;if(L.length)L.length===1?y=L[0]:y=p(L,A);else return new Uint8Array(0);return this.reset(),y},I.reset=function(){this.chunks.length=0,this.dataLength=0},S}();function p(S,I){for(var x=new Uint8Array(I),L=0,A=0;A<S.length;A++){var y=S[A];x.set(y,L),L+=y.length}return x}},"./src/demux/dummy-demuxed-track.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"dummyTrack",function(){return R});function R(p,S){return p===void 0&&(p=""),S===void 0&&(S=9e4),{type:p,id:-1,pid:-1,inputTimeScale:S,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/logger.ts"),p=function(){function S(x){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=x,this.bytesAvailable=x.byteLength,this.word=0,this.bitsAvailable=0}var I=S.prototype;return I.loadWord=function(){var L=this.data,A=this.bytesAvailable,y=L.byteLength-A,D=new Uint8Array(4),_=Math.min(4,A);if(_===0)throw new Error("no bytes available");D.set(L.subarray(y,y+_)),this.word=new DataView(D.buffer).getUint32(0),this.bitsAvailable=_*8,this.bytesAvailable-=_},I.skipBits=function(L){var A;this.bitsAvailable>L?(this.word<<=L,this.bitsAvailable-=L):(L-=this.bitsAvailable,A=L>>3,L-=A>>3,this.bytesAvailable-=A,this.loadWord(),this.word<<=L,this.bitsAvailable-=L)},I.readBits=function(L){var A=Math.min(this.bitsAvailable,L),y=this.word>>>32-A;return L>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=A,this.bitsAvailable>0?this.word<<=A:this.bytesAvailable>0&&this.loadWord(),A=L-A,A>0&&this.bitsAvailable?y<<A|this.readBits(A):y},I.skipLZ=function(){var L;for(L=0;L<this.bitsAvailable;++L)if((this.word&2147483648>>>L)!==0)return this.word<<=L,this.bitsAvailable-=L,L;return this.loadWord(),L+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var L=this.skipLZ();return this.readBits(L+1)-1},I.readEG=function(){var L=this.readUEG();return 1&L?1+L>>>1:-1*(L>>>1)},I.readBoolean=function(){return this.readBits(1)===1},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(L){for(var A=8,y=8,D,_=0;_<L;_++)y!==0&&(D=this.readEG(),y=(A+D+256)%256),A=y===0?A:y},I.readSPS=function(){var L=0,A=0,y=0,D=0,_,T,g,E=this.readUByte.bind(this),a=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),u=this.skipBits.bind(this),n=this.skipEG.bind(this),i=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);E();var l=E();if(a(5),u(3),E(),i(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var d=e();if(d===3&&u(1),i(),i(),u(1),s())for(T=d!==3?8:12,g=0;g<T;g++)s()&&(g<6?t(16):t(64))}i();var r=e();if(r===0)e();else if(r===1)for(u(1),n(),n(),_=e(),g=0;g<_;g++)n();i(),u(1);var c=e(),f=e(),o=a(1);o===0&&u(1),u(1),s()&&(L=e(),A=e(),y=e(),D=e());var v=[1,1];if(s()&&s()){var m=E();switch(m){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:{v=[E()<<8|E(),E()<<8|E()];break}}}return{width:Math.ceil((c+1)*16-L*2-A*2),height:(2-o)*(f+1)*16-(o?2:4)*(y+D),pixelRatio:v}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},S}();P.default=p},"./src/demux/id3.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isHeader",function(){return R}),h.d(P,"isFooter",function(){return p}),h.d(P,"getID3Data",function(){return S}),h.d(P,"canParse",function(){return x}),h.d(P,"getTimeStamp",function(){return L}),h.d(P,"isTimeStampFrame",function(){return A}),h.d(P,"getID3Frames",function(){return D}),h.d(P,"decodeFrame",function(){return _}),h.d(P,"utf8ArrayToStr",function(){return e}),h.d(P,"testables",function(){return s});var R=function(t,l){return l+10<=t.length&&t[l]===73&&t[l+1]===68&&t[l+2]===51&&t[l+3]<255&&t[l+4]<255&&t[l+6]<128&&t[l+7]<128&&t[l+8]<128&&t[l+9]<128},p=function(t,l){return l+10<=t.length&&t[l]===51&&t[l+1]===68&&t[l+2]===73&&t[l+3]<255&&t[l+4]<255&&t[l+6]<128&&t[l+7]<128&&t[l+8]<128&&t[l+9]<128},S=function(t,l){for(var d=l,r=0;R(t,l);){r+=10;var c=I(t,l+6);r+=c,p(t,l+10)&&(r+=10),l+=r}if(r>0)return t.subarray(d,d+r)},I=function(t,l){var d=0;return d=(t[l]&127)<<21,d|=(t[l+1]&127)<<14,d|=(t[l+2]&127)<<7,d|=t[l+3]&127,d},x=function(t,l){return R(t,l)&&I(t,l+6)+10<=t.length-l},L=function(t){for(var l=D(t),d=0;d<l.length;d++){var r=l[d];if(A(r))return a(r)}},A=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},y=function(t){var l=String.fromCharCode(t[0],t[1],t[2],t[3]),d=I(t,4),r=10;return{type:l,size:d,data:t.subarray(r,r+d)}},D=function(t){for(var l=0,d=[];R(t,l);){var r=I(t,l+6);l+=10;for(var c=l+r;l+8<c;){var f=y(t.subarray(l)),o=_(f);o&&d.push(o),l+=f.size+10}p(t,l)&&(l+=10)}return d},_=function(t){return t.type==="PRIV"?T(t):t.type[0]==="W"?E(t):g(t)},T=function(t){if(!(t.size<2)){var l=e(t.data,!0),d=new Uint8Array(t.data.subarray(l.length+1));return{key:t.type,info:l,data:d.buffer}}},g=function(t){if(!(t.size<2)){if(t.type==="TXXX"){var l=1,d=e(t.data.subarray(l),!0);l+=d.length+1;var r=e(t.data.subarray(l));return{key:t.type,info:d,data:r}}var c=e(t.data.subarray(1));return{key:t.type,data:c}}},E=function(t){if(t.type==="WXXX"){if(t.size<2)return;var l=1,d=e(t.data.subarray(l),!0);l+=d.length+1;var r=e(t.data.subarray(l));return{key:t.type,info:d,data:r}}var c=e(t.data);return{key:t.type,data:c}},a=function(t){if(t.data.byteLength===8){var l=new Uint8Array(t.data),d=l[3]&1,r=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return r/=45,d&&(r+=4772185884e-2),Math.round(r)}},e=function(t,l){l===void 0&&(l=!1);var d=n();if(d){var r=d.decode(t);if(l){var c=r.indexOf("\0");return c!==-1?r.substring(0,c):r}return r.replace(/\0/g,"")}for(var f=t.length,o,v,m,O="",b=0;b<f;){if(o=t[b++],o===0&&l)return O;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:O+=String.fromCharCode(o);break;case 12:case 13:v=t[b++],O+=String.fromCharCode((o&31)<<6|v&63);break;case 14:v=t[b++],m=t[b++],O+=String.fromCharCode((o&15)<<12|(v&63)<<6|(m&63)<<0);break;default:}}return O},s={decodeTextFrame:g},u;function n(){return!u&&typeof self.TextDecoder!="undefined"&&(u=new self.TextDecoder("utf-8")),u}},"./src/demux/mp3demuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/demux/base-audio-demuxer.ts"),p=h("./src/demux/id3.ts"),S=h("./src/utils/logger.ts"),I=h("./src/demux/mpegaudio.ts");function x(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,L(y,D)}function L(y,D){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,g){return T.__proto__=g,T},L(y,D)}var A=function(y){x(D,y);function D(){return y.apply(this,arguments)||this}var _=D.prototype;return _.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=p.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(I.probe(g,a))return S.logger.log("MPEG Audio sync word found !"),!0;return!1},_.canParse=function(g,E){return I.canParse(g,E)},_.appendFrame=function(g,E,a){if(this.basePTS!==null)return I.appendFrame(g,E,a,this.basePTS,this.frameIndex)},D}(R.default);P.default=A},"./src/demux/mp4demuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/types/demuxer.ts"),S=h("./src/utils/mp4-tools.ts"),I=h("./src/demux/dummy-demuxed-track.ts"),x=/\/emsg[-/]ID3/i,L=function(){function A(D,_){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=_}var y=A.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(_,T,g,E){var a=Object(S.parseInitSegment)(_),e=this.videoTrack=Object(I.dummyTrack)("video",1),s=this.audioTrack=Object(I.dummyTrack)("audio",1),u=this.txtTrack=Object(I.dummyTrack)("text",1);if(this.id3Track=Object(I.dummyTrack)("id3",1),this.timeOffset=0,a.video){var n=a.video,i=n.id,t=n.timescale,l=n.codec;e.id=i,e.timescale=u.timescale=t,e.codec=l}if(a.audio){var d=a.audio,r=d.id,c=d.timescale,f=d.codec;s.id=r,s.timescale=c,s.codec=f}u.id=S.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=E},y.resetContiguity=function(){},A.probe=function(_){return _=_.length>16384?_.subarray(0,16384):_,Object(S.findBox)(_,["moof"]).length>0},y.demux=function(_,T){this.timeOffset=T;var g=_,E=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(S.appendUint8Array)(this.remainderData,_));var e=Object(S.segmentValidRange)(g);this.remainderData=e.remainder,E.samples=e.valid||new Uint8Array}else E.samples=g;var s=this.extractID3Track(E,T);return a.samples=Object(S.parseSamples)(T,E),{videoTrack:E,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var _=this.timeOffset,T=this.videoTrack,g=this.txtTrack;T.samples=this.remainderData||new Uint8Array,this.remainderData=null;var E=this.extractID3Track(T,this.timeOffset);return g.samples=Object(S.parseSamples)(_,T),{videoTrack:T,audioTrack:Object(I.dummyTrack)(),id3Track:E,textTrack:Object(I.dummyTrack)()}},y.extractID3Track=function(_,T){var g=this.id3Track;if(_.samples.length){var E=Object(S.findBox)(_.samples,["emsg"]);E&&E.forEach(function(a){var e=Object(S.parseEmsg)(a);if(x.test(e.schemeIdUri)){var s=Object(R.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:T+e.presentationTimeDelta/e.timeScale,u=e.payload;g.samples.push({data:u,len:u.byteLength,dts:s,pts:s,type:p.MetadataSchema.emsg})}})}return g},y.demuxSampleAes=function(_,T,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},A}();P.default=L},"./src/demux/mpegaudio.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"appendFrame",function(){return L}),h.d(P,"parseHeader",function(){return A}),h.d(P,"isHeaderPattern",function(){return y}),h.d(P,"isHeader",function(){return D}),h.d(P,"canParse",function(){return _}),h.d(P,"probe",function(){return T});var R=null,p=[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],S=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],I=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],x=[0,1,1,4];function L(g,E,a,e,s){if(!(a+24>E.length)){var u=A(E,a);if(u&&a+u.frameLength<=E.length){var n=u.samplesPerFrame*9e4/u.sampleRate,i=e+s*n,t={unit:E.subarray(a,a+u.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=u.channelCount,g.samplerate=u.sampleRate,g.samples.push(t),{sample:t,length:u.frameLength,missing:0}}}}function A(g,E){var a=g[E+1]>>3&3,e=g[E+1]>>1&3,s=g[E+2]>>4&15,u=g[E+2]>>2&3;if(a!==1&&s!==0&&s!==15&&u!==3){var n=g[E+2]>>1&1,i=g[E+3]>>6,t=a===3?3-e:e===3?3:4,l=p[t*14+s-1]*1e3,d=a===3?0:a===2?1:2,r=S[d*3+u],c=i===3?1:2,f=I[a][e],o=x[e],v=f*8*o,m=Math.floor(f*l/r+n)*o;if(R===null){var O=navigator.userAgent||"",b=O.match(/Chrome\/(\d+)/i);R=b?parseInt(b[1]):0}var M=!!R&&R<=87;return M&&e===2&&l>=224e3&&i===0&&(g[E+3]=g[E+3]|128),{sampleRate:r,channelCount:c,frameLength:m,samplesPerFrame:v}}}function y(g,E){return g[E]===255&&(g[E+1]&224)===224&&(g[E+1]&6)!==0}function D(g,E){return E+1<g.length&&y(g,E)}function _(g,E){var a=4;return y(g,E)&&a<=g.length-E}function T(g,E){if(E+1<g.length&&y(g,E)){var a=4,e=A(g,E),s=a;e!=null&&e.frameLength&&(s=e.frameLength);var u=E+s;return u===g.length||D(g,u)}return!1}},"./src/demux/sample-aes.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/crypt/decrypter.ts"),p=h("./src/demux/tsdemuxer.ts"),S=function(){function I(L,A,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new R.default(L,A,{removePKCS7Padding:!1})}var x=I.prototype;return x.decryptBuffer=function(A,y){this.decrypter.decrypt(A,this.keyData.key.buffer,this.keyData.iv.buffer,y)},x.decryptAacSample=function(A,y,D,_){var T=A[y].unit;if(!(T.length<=16)){var g=T.subarray(16,T.length-T.length%16),E=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),a=this;this.decryptBuffer(E,function(e){var s=new Uint8Array(e);T.set(s,16),_||a.decryptAacSamples(A,y+1,D)})}},x.decryptAacSamples=function(A,y,D){for(;;y++){if(y>=A.length){D();return}if(!(A[y].unit.length<32)){var _=this.decrypter.isSync();if(this.decryptAacSample(A,y,D,_),!_)return}}},x.getAvcEncryptedData=function(A){for(var y=Math.floor((A.length-48)/160)*16+16,D=new Int8Array(y),_=0,T=32;T<A.length-16;T+=160,_+=16)D.set(A.subarray(T,T+16),_);return D},x.getAvcDecryptedUnit=function(A,y){for(var D=new Uint8Array(y),_=0,T=32;T<A.length-16;T+=160,_+=16)A.set(D.subarray(_,_+16),T);return A},x.decryptAvcSample=function(A,y,D,_,T,g){var E=Object(p.discardEPB)(T.data),a=this.getAvcEncryptedData(E),e=this;this.decryptBuffer(a.buffer,function(s){T.data=e.getAvcDecryptedUnit(E,s),g||e.decryptAvcSamples(A,y,D+1,_)})},x.decryptAvcSamples=function(A,y,D,_){if(A instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,D=0){if(y>=A.length){_();return}for(var T=A[y].units;!(D>=T.length);D++){var g=T[D];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var E=this.decrypter.isSync();if(this.decryptAvcSample(A,y,D,_,g,E),!E)return}}}},I}();P.default=S},"./src/demux/transmuxer-interface.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T});var R=h("./node_modules/webworkify-webpack/index.js"),p=h.n(R),S=h("./src/events.ts"),I=h("./src/demux/transmuxer.ts"),x=h("./src/utils/logger.ts"),L=h("./src/errors.ts"),A=h("./src/utils/mediasource-helper.ts"),y=h("./node_modules/eventemitter3/index.js"),D=h.n(y),_=Object(A.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function g(a,e,s,u){var n=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=a,this.id=e,this.onTransmuxComplete=s,this.onFlush=u;var i=a.config,t=function(f,o){o=o||{},o.frag=n.frag,o.id=n.id,a.trigger(f,o)};this.observer=new y.EventEmitter,this.observer.on(S.Events.FRAG_DECRYPTED,t),this.observer.on(S.Events.ERROR,t);var l={mp4:_.isTypeSupported("video/mp4"),mpeg:_.isTypeSupported("audio/mpeg"),mp3:_.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){x.logger.log("demuxing in webworker");var r;try{r=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),r.addEventListener("message",this.onwmsg),r.onerror=function(c){a.trigger(S.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},r.postMessage({cmd:"init",typeSupported:l,vendor:d,id:e,config:JSON.stringify(i)})}catch(c){x.logger.warn("Error in worker:",c),x.logger.error("Error while initializing DemuxerWorker, fallback to inline"),r&&self.URL.revokeObjectURL(r.objectURL),this.transmuxer=new I.default(this.observer,l,i,d,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,l,i,d,e)}var E=g.prototype;return E.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var u=this.observer;u&&u.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},E.push=function(e,s,u,n,i,t,l,d,r,c){var f,o,v=this;r.transmuxing.start=self.performance.now();var m=this.transmuxer,O=this.worker,b=t?t.start:i.start,M=i.decryptdata,F=this.frag,w=!(F&&i.cc===F.cc),C=!(F&&r.level===F.level),U=F?r.sn-F.sn:-1,B=this.part?r.part-this.part.index:-1,N=U===0&&r.id>1&&r.id===(F==null?void 0:F.stats.chunkCount),k=!C&&(U===1||U===0&&(B===1||N&&B<=0)),j=self.performance.now();(C||U||i.stats.parsing.start===0)&&(i.stats.parsing.start=j),t&&(B||!k)&&(t.stats.parsing.start=j);var H=!(F&&((f=i.initSegment)===null||f===void 0?void 0:f.url)===((o=F.initSegment)===null||o===void 0?void 0:o.url)),V=new I.TransmuxState(w,k,d,C,b,H);if(!k||w||H){x.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+r.sn+" p: "+r.part+" level: "+r.level+" id: "+r.id+`
|
|
11
|
+
Time to underbuffer: `+M.toFixed(3)+" s"),s.nextLoadLevel=w,this.bwEstimator.sample(d,t.loaded),this.clearTimer(),a.loader&&(this.fragCurrent=this.partCurrent=null,a.loader.abort()),s.trigger(x.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:e,stats:t})}}}}}},g.onFragLoaded=function(a,e){var s=e.frag,u=e.part;if(s.type===_.PlaylistLevelType.MAIN&&Object(P.isFiniteNumber)(s.sn)){var n=u?u.stats:s.stats,i=u?u.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var t=this.hls.levels[s.level],l=(t.loaded?t.loaded.bytes:0)+n.loaded,d=(t.loaded?t.loaded.duration:0)+i;t.loaded={bytes:l,duration:d},t.realBitrate=Math.round(8*l/d)}if(s.bitrateTest){var r={stats:n,frag:s,part:u,id:s.type};this.onFragBuffered(x.Events.FRAG_BUFFERED,r)}}},g.onFragBuffered=function(a,e){var s=e.frag,u=e.part,n=u?u.stats:s.stats;if(!n.aborted&&!(s.type!==_.PlaylistLevelType.MAIN||s.sn==="initSegment")){var i=n.parsing.end-n.loading.start;this.bwEstimator.sample(i,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(a,e){switch(e.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var a=this.fragCurrent,e=this.partCurrent,s=this.hls,u=s.maxAutoLevel,n=s.config,i=s.minAutoLevel,t=s.media,l=e?e.duration:a?a.duration:0,d=t?t.currentTime:0,r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,f=(I.BufferHelper.bufferInfo(t,d,n.maxBufferHole).end-d)/r,o=this.findBestLevel(c,i,u,f,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(o>=0)return o;A.logger.trace((f?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,m=n.abrBandWidthFactor,O=n.abrBandWidthUpFactor;if(!f){var b=this.bitrateTestDelay;if(b){var M=l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay;v=M-b,A.logger.trace("bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),m=O=1}}return o=this.findBestLevel(c,i,u,f+v,m,O),Math.max(o,0)},g.findBestLevel=function(a,e,s,u,n,i){for(var t,l=this.fragCurrent,d=this.partCurrent,r=this.lastLoadedFragLevel,c=this.hls.levels,f=c[r],o=!!(f!=null&&(t=f.details)!==null&&t!==void 0&&t.live),v=f==null?void 0:f.codecSet,m=d?d.duration:l?l.duration:0,O=s;O>=e;O--){var b=c[O];if(!(!b||v&&b.codecSet!==v)){var M=b.details,F=(d?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||m,w=void 0;O<=r?w=n*a:w=i*a;var C=c[O].maxBitrate,U=C*F/w;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+O+"/"+Math.round(w)+"/"+C+"/"+F+"/"+u+"/"+U),w>C&&(!U||o&&!this.bitrateTestDelay||U<u))return O}}return-1},D(S,[{key:"nextAutoLevel",get:function(){var a=this._nextAutoLevel,e=this.bwEstimator;if(a!==-1&&!e.canEstimate())return a;var s=this.getNextABRAutoLevel();return a!==-1&&this.hls.levels[s].loadError?a:(a!==-1&&(s=Math.min(a,s)),s)},set:function(a){this._nextAutoLevel=a}}]),S}();R.default=L},"./src/controller/audio-stream-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/polyfills/number.ts"),p=h("./src/controller/base-stream-controller.ts"),x=h("./src/events.ts"),I=h("./src/utils/buffer-helper.ts"),T=h("./src/controller/fragment-tracker.ts"),_=h("./src/types/level.ts"),A=h("./src/types/loader.ts"),y=h("./src/loader/fragment.ts"),D=h("./src/demux/chunk-cache.ts"),L=h("./src/demux/transmuxer-interface.ts"),S=h("./src/types/transmuxer.ts"),g=h("./src/controller/fragment-finders.ts"),E=h("./src/utils/discontinuities.ts"),a=h("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(t){for(var l=1;l<arguments.length;l++){var d=arguments[l];for(var r in d)Object.prototype.hasOwnProperty.call(d,r)&&(t[r]=d[r])}return t},e.apply(this,arguments)}function s(t,l){t.prototype=Object.create(l.prototype),t.prototype.constructor=t,u(t,l)}function u(t,l){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,c){return r.__proto__=c,r},u(t,l)}var n=100,i=function(t){s(l,t);function l(r,c){var f;return f=t.call(this,r,c,"[audio-stream-controller]")||this,f.videoBuffer=null,f.videoTrackCC=-1,f.waitingVideoCC=-1,f.audioSwitch=!1,f.trackId=-1,f.waitingData=null,f.mainDetails=null,f.bufferFlushed=!1,f.cachedTrackLoadedData=null,f._registerListeners(),f}var d=l.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var c=this.hls;c.on(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.on(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.on(x.Events.ERROR,this.onError,this),c.on(x.Events.BUFFER_RESET,this.onBufferReset,this),c.on(x.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.on(x.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var c=this.hls;c.off(x.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(x.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(x.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(x.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(x.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),c.off(x.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(x.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),c.off(x.Events.ERROR,this.onError,this),c.off(x.Events.BUFFER_RESET,this.onBufferReset,this),c.off(x.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(x.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(x.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),c.off(x.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(c,f){var o=f.frag,v=f.id,m=f.initPTS;if(v==="main"){var O=o.cc;this.initPTS[o.cc]=m,this.log("InitPTS for cc: "+O+" found from main: "+m),this.videoTrackCC=O,this.state===p.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(c){if(!this.levels){this.startPosition=c,this.state=p.State.STOPPED;return}var f=this.lastCurrentTime;this.stopLoad(),this.setInterval(n),this.fragLoadError=0,f>0&&c===-1?(this.log("Override startPosition with lastCurrentTime @"+f.toFixed(3)),c=f,this.state=p.State.IDLE):(this.loadedmetadata=!1,this.state=p.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},d.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_TRACK:{var c,f=this.levels,o=this.trackId,v=f==null||(c=f[o])===null||c===void 0?void 0:c.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=p.State.WAITING_INIT_PTS}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var m,O=performance.now(),b=this.retryDate;(!b||O>=b||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=p.State.IDLE);break}case p.State.WAITING_INIT_PTS:{var M=this.waitingData;if(M){var F=M.frag,w=M.part,C=M.cache,U=M.complete;if(this.initPTS[F.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.FRAG_LOADING;var B=C.flush(),N={frag:F,part:w,payload:B,networkDetails:null};this._handleFragmentLoadProgress(N),U&&t.prototype._handleFragmentLoadComplete.call(this,N)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+F.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var k=this.getLoadPosition(),j=I.BufferHelper.bufferInfo(this.mediaBuffer,k,this.config.maxBufferHole),H=Object(g.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,F);H<0&&(this.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=p.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var c=this.waitingData;c&&(this.fragmentTracker.removeFragment(c.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.IDLE)},d.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},d.onTickEnd=function(){var c=this.media;if(!(!c||!c.readyState)){var f=this.mediaBuffer?this.mediaBuffer:c,o=f.buffered;!this.loadedmetadata&&o.length&&(this.loadedmetadata=!0),this.lastCurrentTime=c.currentTime}},d.doTickIdle=function(){var c,f,o=this.hls,v=this.levels,m=this.media,O=this.trackId,b=o.config;if(!(!v||!v[O])&&!(!m&&(this.startFragRequested||!b.startFragPrefetch))){var M=v[O],F=M.details;if(!F||F.live&&this.levelLastLoaded!==O||this.waitForCdnTuneIn(F)){this.state=p.State.WAITING_TRACK;return}var w=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&w&&(this.bufferFlushed=!1,this.afterBufferFlushed(w,y.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(w,A.PlaylistLevelType.AUDIO);if(C!==null){var U=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.PlaylistLevelType.MAIN),B=C.len,N=this.getMaxBufferLength(U==null?void 0:U.len),k=this.audioSwitch;if(!(B>=N&&!k)){if(!k&&this._streamEnded(C,F)){o.trigger(x.Events.BUFFER_EOS,{type:"audio"}),this.state=p.State.ENDED;return}var j=F.fragments,H=j[0].start,V=C.end;if(k&&m){var Y=this.getLoadPosition();V=Y,F.PTSKnown&&Y<H&&(C.end>H||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),m.currentTime=H+.05)}if(!(U&&V>U.end+F.targetduration)&&!((!U||!U.len)&&C.len)){var Q=this.getNextFragment(V,F);if(!Q){this.bufferFlushed=!0;return}((c=Q.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((f=Q.decryptdata)!==null&&f!==void 0&&f.key)?this.loadKey(Q,F):this.loadFragment(Q,F,V)}}}}},d.getMaxBufferLength=function(c){var f=t.prototype.getMaxBufferLength.call(this);return c?Math.max(f,c):f},d.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(c,f){var o=f.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(v){return new _.Level(v)})},d.onAudioTrackSwitching=function(c,f){var o=!!f.url;this.trackId=f.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),o?this.setInterval(n):this.resetTransmuxer(),o?(this.audioSwitch=!0,this.state=p.State.IDLE):this.state=p.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(c,f){this.mainDetails=f.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(x.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},d.onAudioTrackLoaded=function(c,f){var o;if(this.mainDetails==null){this.cachedTrackLoadedData=f;return}var v=this.levels,m=f.details,O=f.id;if(!v){this.warn("Audio tracks were reset while loading level "+O);return}this.log("Track "+O+" loaded ["+m.startSN+","+m.endSN+"],duration:"+m.totalduration);var b=v[O],M=0;if(m.live||(o=b.details)!==null&&o!==void 0&&o.live){var F=this.mainDetails;if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed||!F)return;!b.details&&m.hasProgramDateTime&&F.hasProgramDateTime?(Object(E.alignMediaPlaylistByPDT)(m,F),M=m.fragments[0].start):M=this.alignPlaylists(m,b.details)}b.details=m,this.levelLastLoaded=O,!this.startFragRequested&&(this.mainDetails||!m.live)&&this.setStartPosition(b.details,M),this.state===p.State.WAITING_TRACK&&!this.waitForCdnTuneIn(m)&&(this.state=p.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(c){var f,o=c.frag,v=c.part,m=c.payload,O=this.config,b=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var F=M[b];console.assert(F,"Audio track is defined on fragment load progress");var w=F.details;console.assert(w,"Audio track details are defined on fragment load progress");var C=O.defaultAudioCodec||F.audioCodec||"mp4a.40.2",U=this.transmuxer;U||(U=this.transmuxer=new L.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var B=this.initPTS[o.cc],N=(f=o.initSegment)===null||f===void 0?void 0:f.data;if(B!==void 0){var k=!1,j=v?v.index:-1,H=j!==-1,V=new S.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,m.byteLength,j,H);U.push(m,N,C,"",o,v,w.totalduration,k,V,B)}else{this.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+b);var Y=this.waitingData=this.waitingData||{frag:o,part:v,cache:new D.default,complete:!1},Q=Y.cache;Q.push(new Uint8Array(m)),this.waitingVideoCC=this.videoTrackCC,this.state=p.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(c){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,c)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(c,f){var o=f.tracks.audio;o&&(this.mediaBuffer=o.buffer||null),f.tracks.video&&(this.videoBuffer=f.tracks.video.buffer||null)},d.onFragBuffered=function(c,f){var o=f.frag,v=f.part;if(o.type===A.PlaylistLevelType.AUDIO){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(v?" p: "+v.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}o.sn!=="initSegment"&&(this.fragPrevious=o,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(x.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(o,v)}},d.onError=function(c,f){switch(f.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,f);break;case a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==p.State.ERROR&&this.state!==p.State.STOPPED&&(this.state=f.fatal?p.State.ERROR:p.State.IDLE,this.warn(f.details+" while loading frag, switching to "+this.state+" state"));break;case a.ErrorDetails.BUFFER_FULL_ERROR:if(f.parent==="audio"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var o=!0,v=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);v&&v.len>.5&&(o=!this.reduceMaxBufferLength(v.len)),o&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},d.onBufferFlushed=function(c,f){var o=f.type;o===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(c){var f,o="audio",v=this.hls,m=c.remuxResult,O=c.chunkMeta,b=this.getCurrentContext(O);if(!b){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(O.level);return}var M=b.frag,F=b.part,w=b.level.details,C=m.audio,U=m.text,B=m.id3,N=m.initSegment;if(!(this.fragContextChanged(M)||!w)){if(this.state=p.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),N!=null&&N.tracks&&(this._bufferInitSegment(N.tracks,M,O),v.trigger(x.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:o,tracks:N.tracks})),C){var k=C.startPTS,j=C.endPTS,H=C.startDTS,V=C.endDTS;F&&(F.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:k,endPTS:j,startDTS:H,endDTS:V}),M.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,k,j,H,V),this.bufferFragmentData(C,M,F,O)}if(B!=null&&(f=B.samples)!==null&&f!==void 0&&f.length){var Y=e({id:o,frag:M,details:w},B);v.trigger(x.Events.FRAG_PARSING_METADATA,Y)}if(U){var Q=e({id:o,frag:M,details:w},U);v.trigger(x.Events.FRAG_PARSING_USERDATA,Q)}}},d._bufferInitSegment=function(c,f,o){if(this.state===p.State.PARSING){c.video&&delete c.video;var v=c.audio;if(!!v){v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(x.Events.BUFFER_CODECS,c);var m=v.initSegment;if(m!=null&&m.byteLength){var O={type:"audio",frag:f,part:null,chunkMeta:o,parent:f.type,data:m};this.hls.trigger(x.Events.BUFFER_APPENDING,O)}this.tick()}}},d.loadFragment=function(c,f,o){var v=this.fragmentTracker.getState(c);this.fragCurrent=c,(this.audioSwitch||v===T.FragmentState.NOT_LOADED||v===T.FragmentState.PARTIAL)&&(c.sn==="initSegment"?this._loadInitSegment(c):f.live&&!Object(P.isFiniteNumber)(this.initPTS[c.cc])?(this.log("Waiting for video PTS in continuity counter "+c.cc+" of live stream before loading audio fragment "+c.sn+" of level "+this.trackId),this.state=p.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,c,f,o)))},d.completeAudioSwitch=function(){var c=this.hls,f=this.media,o=this.trackId;f&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,c.trigger(x.Events.AUDIO_TRACK_SWITCHED,{id:o})},l}(p.default);R.default=i},"./src/controller/audio-track-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/events.ts"),p=h("./src/errors.ts"),x=h("./src/controller/base-playlist-controller.ts"),I=h("./src/types/loader.ts");function T(L,S){for(var g=0;g<S.length;g++){var E=S[g];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(L,E.key,E)}}function _(L,S,g){return S&&T(L.prototype,S),g&&T(L,g),Object.defineProperty(L,"prototype",{writable:!1}),L}function A(L,S){L.prototype=Object.create(S.prototype),L.prototype.constructor=L,y(L,S)}function y(L,S){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,a){return E.__proto__=a,E},y(L,S)}var D=function(L){A(S,L);function S(E){var a;return a=L.call(this,E,"[audio-track-controller]")||this,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.trackName="",a.selectDefaultTrack=!0,a.registerListeners(),a}var g=S.prototype;return g.registerListeners=function(){var a=this.hls;a.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.on(P.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var a=this.hls;a.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(P.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),a.off(P.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,L.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(a,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(a,e){var s=e.id,u=e.details,n=this.tracksInGroup[s];if(!n){this.warn("Invalid audio track id "+s);return}var i=n.details;n.details=e.details,this.log("audioTrack "+s+" loaded ["+u.startSN+"-"+u.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,e,i))},g.onLevelLoading=function(a,e){this.switchLevel(e.level)},g.onLevelSwitching=function(a,e){this.switchLevel(e.level)},g.switchLevel=function(a){var e=this.hls.levels[a];if(!!(e!=null&&e.audioGroupIds)){var s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s;var u=this.tracks.filter(function(i){return!s||i.groupId===s});this.selectDefaultTrack&&!u.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var n={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(P.Events.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}}},g.onError=function(a,e){L.prototype.onError.call(this,a,e),!(e.fatal||!e.context)&&e.context.type===I.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},g.setAudioTrack=function(a){var e=this.tracksInGroup;if(a<0||a>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+a);var u=e[a],n=u.id,i=u.groupId,t=i===void 0?"":i,l=u.name,d=u.type,r=u.url;if(this.trackId=a,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(P.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:t,name:l,type:d,url:r}),!(u.details&&!u.details.live)){var c=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(c)}},g.selectInitialTrack=function(){var a=this.tracksInGroup;console.assert(a.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(a){for(var e=this.tracksInGroup,s=0;s<e.length;s++){var u=e[s];if((!this.selectDefaultTrack||u.default)&&(!a||a===u.name))return u.id}return-1},g.loadPlaylist=function(a){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var s=e.id,u=e.groupId,n=e.url;if(a)try{n=a.addDirectives(n)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(P.Events.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:u,deliveryDirectives:a||null})}},_(S,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1,this.setAudioTrack(a)}}]),S}(x.default);R.default=D},"./src/controller/base-playlist-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return _});var P=h("./src/polyfills/number.ts"),p=h("./src/types/level.ts"),x=h("./src/controller/level-helper.ts"),I=h("./src/utils/logger.ts"),T=h("./src/errors.ts"),_=function(){function A(D,L){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=I.logger.log.bind(I.logger,L+":"),this.warn=I.logger.warn.bind(I.logger,L+":"),this.hls=D}var y=A.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(L,S){S.fatal&&S.type===T.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},y.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},y.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},y.stopLoad=function(){this.canLoad=!1,this.clearTimer()},y.switchParams=function(L,S){var g=S==null?void 0:S.renditionReports;if(g)for(var E=0;E<g.length;E++){var a=g[E],e=""+a.URI;if(e===L.slice(-e.length)){var s=parseInt(a["LAST-MSN"]),u=parseInt(a["LAST-PART"]);if(S&&this.hls.config.lowLatencyMode){var n=Math.min(S.age-S.partTarget,S.targetduration);u!==void 0&&n>S.partTarget&&(u+=1)}if(Object(P.isFiniteNumber)(s))return new p.HlsUrlParameters(s,Object(P.isFiniteNumber)(u)?u:void 0,p.HlsSkip.No)}}},y.loadPlaylist=function(L){},y.shouldLoadTrack=function(L){return this.canLoad&&L&&!!L.url&&(!L.details||L.details.live)},y.playlistLoaded=function(L,S,g){var E=this,a=S.details,e=S.stats,s=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(a.advancedDateTime=Date.now()-s,a.live||g!=null&&g.live){if(a.reloaded(g),g&&this.log("live playlist "+L+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),g&&a.fragments.length>0&&Object(x.mergeDetails)(g,a),!this.canLoad||!a.live)return;var u,n=void 0,i=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var t=this.hls.config.lowLatencyMode,l=a.lastPartSn,d=a.endSN,r=a.lastPartIndex,c=r!==-1,f=l===d,o=t?0:r;c?(n=f?d+1:l,i=f?o:r+1):n=d+1;var v=a.age,m=v+a.ageHeader,O=Math.min(m-a.partTarget,a.targetduration*1.5);if(O>0){if(g&&O>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+O+" with playlist age: "+a.age),O=0;else{var b=Math.floor(O/a.targetduration);if(n+=b,i!==void 0){var M=Math.round(O%a.targetduration/a.partTarget);i+=M}this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+O+" skip sn "+b+" to part "+i)}a.tuneInGoal=O}if(u=this.getDeliveryDirectives(a,S.deliveryDirectives,n,i),t||!f){this.loadPlaylist(u);return}}else u=this.getDeliveryDirectives(a,S.deliveryDirectives,n,i);var F=Object(x.computeReloadInterval)(a,e);n!==void 0&&a.canBlockReload&&(F-=a.partTarget||1),this.log("reload live playlist "+L+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(u)},F)}else this.clearTimer()},y.getDeliveryDirectives=function(L,S,g,E){var a=Object(p.getSkipValue)(L,g);return S!=null&&S.skip&&L.deltaUpdateFailed&&(g=S.msn,E=S.part,a=p.HlsSkip.No),new p.HlsUrlParameters(g,E,a)},y.retryLoadingOrFail=function(L){var S=this,g=this.hls.config,E=this.retryCount<g.levelLoadingMaxRetry;if(E){var a;if(this.retryCount++,L.details.indexOf("LoadTimeOut")>-1&&(a=L.context)!==null&&a!==void 0&&a.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+L.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return S.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+L.details+'"')}}else this.warn('cannot recover from error "'+L.details+'"'),this.clearTimer(),L.fatal=!0;return E},A}()},"./src/controller/base-stream-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"State",function(){return d}),h.d(R,"default",function(){return r});var P=h("./src/polyfills/number.ts"),p=h("./src/task-loop.ts"),x=h("./src/controller/fragment-tracker.ts"),I=h("./src/utils/buffer-helper.ts"),T=h("./src/utils/logger.ts"),_=h("./src/events.ts"),A=h("./src/errors.ts"),y=h("./src/types/transmuxer.ts"),D=h("./src/utils/mp4-tools.ts"),L=h("./src/utils/discontinuities.ts"),S=h("./src/controller/fragment-finders.ts"),g=h("./src/controller/level-helper.ts"),E=h("./src/loader/fragment-loader.ts"),a=h("./src/crypt/decrypter.ts"),e=h("./src/utils/time-ranges.ts"),s=h("./src/types/loader.ts");function u(c,f){for(var o=0;o<f.length;o++){var v=f[o];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(c,v.key,v)}}function n(c,f,o){return f&&u(c.prototype,f),o&&u(c,o),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function t(c,f){c.prototype=Object.create(f.prototype),c.prototype.constructor=c,l(c,f)}function l(c,f){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,m){return v.__proto__=m,v},l(c,f)}var d={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},r=function(c){t(f,c);function f(v,m,O){var b;return b=c.call(this)||this,b.hls=void 0,b.fragPrevious=null,b.fragCurrent=null,b.fragmentTracker=void 0,b.transmuxer=null,b._state=d.STOPPED,b.media=null,b.mediaBuffer=null,b.config=void 0,b.bitrateTest=!1,b.lastCurrentTime=0,b.nextLoadPosition=0,b.startPosition=0,b.loadedmetadata=!1,b.fragLoadError=0,b.retryDate=0,b.levels=null,b.fragmentLoader=void 0,b.levelLastLoaded=null,b.startFragRequested=!1,b.decrypter=void 0,b.initPTS=[],b.onvseeking=null,b.onvended=null,b.logPrefix="",b.log=void 0,b.warn=void 0,b.logPrefix=O,b.log=T.logger.log.bind(T.logger,O+":"),b.warn=T.logger.warn.bind(T.logger,O+":"),b.hls=v,b.fragmentLoader=new E.default(v.config),b.fragmentTracker=m,b.config=v.config,b.decrypter=new a.default(v,v.config),v.on(_.Events.KEY_LOADED,b.onKeyLoaded,i(b)),v.on(_.Events.LEVEL_SWITCHING,b.onLevelSwitching,i(b)),b}var o=f.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(m){},o.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=d.STOPPED},o._streamEnded=function(m,O){var b=this.fragCurrent,M=this.fragmentTracker;if(!O.live&&b&&this.media&&b.sn>=O.endSN&&!m.nextStart){var F=O.partList;if(F!=null&&F.length){var w=F[F.length-1],C=I.BufferHelper.isBuffered(this.media,w.start+w.duration/2);return C}var U=M.getState(b);return U===x.FragmentState.PARTIAL||U===x.FragmentState.OK}return!1},o.onMediaAttached=function(m,O){var b=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),b.addEventListener("seeking",this.onvseeking),b.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===d.STOPPED&&this.startLoad(M.startPosition)},o.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&this.onvseeking&&this.onvended&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var m=this.config,O=this.fragCurrent,b=this.media,M=this.mediaBuffer,F=this.state,w=b?b.currentTime:0,C=I.BufferHelper.bufferInfo(M||b,w,m.maxBufferHole);if(this.log("media seeking to "+(Object(P.isFiniteNumber)(w)?w.toFixed(3):w)+", state: "+F),F===d.ENDED)this.resetLoadingState();else if(O&&!C.len){var U=m.maxFragLookUpTolerance,B=O.start-U,N=O.start+O.duration+U,k=w>N;(w<B||k)&&(k&&O.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),O.loader.abort()),this.resetLoadingState())}b&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(m,O){if(!(this.state!==d.KEY_LOADING||O.frag!==this.fragCurrent||!this.levels)){this.state=d.IDLE;var b=this.levels[O.frag.level].details;b&&this.loadFragment(O.frag,b,O.frag.start)}},o.onLevelSwitching=function(m,O){this.fragLoadError=0},o.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=d.STOPPED,this.hls.off(_.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(_.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,c.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(m,O){this.log("Loading key for "+m.sn+" of ["+O.startSN+"-"+O.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=d.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(_.Events.KEY_LOADING,{frag:m})},o.loadFragment=function(m,O,b){this._loadFragForPlayback(m,O,b)},o._loadFragForPlayback=function(m,O,b){var M=this,F=function(C){if(M.fragContextChanged(m)){M.warn("Fragment "+m.sn+(C.part?" p: "+C.part.index:"")+" of level "+m.level+" was dropped during download."),M.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(m,O,b,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===d.FRAG_LOADING||!M.fragCurrent&&C===d.PARSING)&&(M.fragmentTracker.removeFragment(m),M.state=d.IDLE);return}"payload"in w&&(M.log("Loaded fragment "+m.sn+" of level "+m.level),M.hls.trigger(_.Events.FRAG_LOADED,w)),M._handleFragmentLoadComplete(w)}}).catch(function(w){M.state===d.STOPPED||M.state===d.ERROR||(M.warn(w),M.resetFragmentLoading(m))})},o.flushMainBuffer=function(m,O,b){if(b===void 0&&(b=null),!!(m-O)){var M={startOffset:m,endOffset:O,type:b};this.fragLoadError=0,this.hls.trigger(_.Events.BUFFER_FLUSHING,M)}},o._loadInitSegment=function(m){var O=this;this._doFragLoad(m).then(function(b){if(!b||O.fragContextChanged(m)||!O.levels)throw new Error("init load aborted");return b}).then(function(b){var M=O.hls,F=b.payload,w=m.decryptdata;if(F&&F.byteLength>0&&w&&w.key&&w.iv&&w.method==="AES-128"){var C=self.performance.now();return O.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(U){var B=self.performance.now();return M.trigger(_.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:C,tdecrypt:B}}),b.payload=U,b})}return b}).then(function(b){var M=O.fragCurrent,F=O.hls,w=O.levels;if(!w)throw new Error("init load aborted, missing levels");var C=w[m.level].details;console.assert(C,"Level details are defined when init segment is loaded");var U=m.stats;O.state=d.IDLE,O.fragLoadError=0,m.data=new Uint8Array(b.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),b.frag===M&&F.trigger(_.Events.FRAG_BUFFERED,{stats:U,frag:M,part:null,id:m.type}),O.tick()}).catch(function(b){O.state===d.STOPPED||O.state===d.ERROR||(O.warn(b),O.resetFragmentLoading(m))})},o.fragContextChanged=function(m){var O=this.fragCurrent;return!m||!O||m.level!==O.level||m.sn!==O.sn||m.urlId!==O.urlId},o.fragBufferedComplete=function(m,O){var b=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(O?" part: "+O.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+(b?e.default.toString(I.BufferHelper.getBuffered(b)):"(detached)")),this.state=d.IDLE,b&&(!this.loadedmetadata&&b.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},o.seekToStartPos=function(){},o._handleFragmentLoadComplete=function(m){var O=this.transmuxer;if(!!O){var b=m.frag,M=m.part,F=m.partsLoaded,w=!F||F.length===0||F.some(function(U){return!U}),C=new y.ChunkMetadata(b.level,b.sn,b.stats.chunkCount+1,0,M?M.index:-1,!w);O.flush(C)}},o._handleFragmentLoadProgress=function(m){},o._doFragLoad=function(m,O,b,M){var F=this;if(b===void 0&&(b=null),!this.levels)throw new Error("frag load aborted, missing levels");if(b=Math.max(m.start,b||0),this.config.lowLatencyMode&&O){var w=O.partList;if(w&&M){b>m.end&&O.fragmentHint&&(m=O.fragmentHint);var C=this.getNextPart(w,m,b);if(C>-1){var U=w[C];return this.log("Loading part sn: "+m.sn+" p: "+U.index+" cc: "+m.cc+" of playlist ["+O.startSN+"-"+O.endSN+"] parts [0-"+C+"-"+(w.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=d.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:m,part:w[C],targetBufferTime:b}),this.doFragPartsLoad(m,w,C,M).catch(function(B){return F.handleFragLoadError(B)})}else if(!m.url||this.loadedEndOfParts(w,b))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(O?"of ["+O.startSN+"-"+O.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),Object(P.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=d.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:m,targetBufferTime:b}),this.fragmentLoader.load(m,M).catch(function(B){return F.handleFragLoadError(B)})},o.doFragPartsLoad=function(m,O,b,M){var F=this;return new Promise(function(w,C){var U=[],B=function N(k){var j=O[k];F.fragmentLoader.loadPart(m,j,M).then(function(H){U[j.index]=H;var V=H.part;F.hls.trigger(_.Events.FRAG_LOADED,H);var Y=O[k+1];if(Y&&Y.fragment===m)N(k+1);else return w({frag:m,part:V,partsLoaded:U})}).catch(C)};B(b)})},o.handleFragLoadError=function(m){var O=m.data;return O&&O.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(O.frag,O.part):this.hls.trigger(_.Events.ERROR,O),null},o._handleTransmuxerFlush=function(m){var O=this.getCurrentContext(m);if(!O||this.state!==d.PARSING){this.fragCurrent||(this.state=d.IDLE);return}var b=O.frag,M=O.part,F=O.level,w=self.performance.now();b.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(b,M,F,m.partial)},o.getCurrentContext=function(m){var O=this.levels,b=m.level,M=m.sn,F=m.part;if(!O||!O[b])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+b+". The current chunk will not be buffered."),null;var w=O[b],C=F>-1?Object(g.getPartWith)(w,M,F):null,U=C?C.fragment:Object(g.getFragmentWithSN)(w,M,this.fragCurrent);return U?{frag:U,part:C,level:w}:null},o.bufferFragmentData=function(m,O,b,M){if(!(!m||this.state!==d.PARSING)){var F=m.data1,w=m.data2,C=F;if(F&&w&&(C=Object(D.appendUint8Array)(F,w)),!(!C||!C.length)){var U={type:m.type,frag:O,part:b,chunkMeta:M,parent:O.type,data:C};this.hls.trigger(_.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!b&&this.flushBufferGap(O)}}},o.flushBufferGap=function(m){var O=this.media;if(!!O){if(!I.BufferHelper.isBuffered(O,O.currentTime)){this.flushMainBuffer(0,m.start);return}var b=O.currentTime,M=I.BufferHelper.bufferInfo(O,b,0),F=m.duration,w=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(m.start-w,M.end-w),b+w);m.start-C>w&&this.flushMainBuffer(C,m.start)}},o.getFwdBufferInfo=function(m,O){var b=this.config,M=this.getLoadPosition();if(!Object(P.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(m,M,b.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var w=this.fragmentTracker.getBufferedFrag(M,O);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,b.maxBufferHole))}return F},o.getMaxBufferLength=function(m){var O=this.config,b;return m?b=Math.max(8*O.maxBufferSize/m,O.maxBufferLength):b=O.maxBufferLength,Math.min(b,O.maxMaxBufferLength)},o.reduceMaxBufferLength=function(m){var O=this.config,b=m||O.maxBufferLength;return O.maxMaxBufferLength>=b?(O.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+O.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(m,O){var b=O.fragments,M=b.length;if(!M)return null;var F=this.config,w=b[0].start,C;if(O.live){var U=F.initialLiveManifestSize;if(M<U)return this.warn("Not enough fragments to start playback (have: "+M+", need: "+U+")"),null;!O.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(C=this.getInitialLiveFragment(O,b),this.startPosition=C?this.hls.liveSyncPosition||C.start:m)}else m<=w&&(C=b[0]);if(!C){var B=F.lowLatencyMode?O.partEnd:O.fragmentEnd;C=this.getFragmentAtPosition(m,B,O)}return this.mapToInitFragWhenRequired(C)},o.mapToInitFragWhenRequired=function(m){return m!=null&&m.initSegment&&!(m!=null&&m.initSegment.data)&&!this.bitrateTest?m.initSegment:m},o.getNextPart=function(m,O,b){for(var M=-1,F=!1,w=!0,C=0,U=m.length;C<U;C++){var B=m[C];if(w=w&&!B.independent,M>-1&&b<B.start)break;var N=B.loaded;!N&&(F||B.independent||w)&&B.fragment===O&&(M=C),F=N}return M},o.loadedEndOfParts=function(m,O){var b=m[m.length-1];return b&&O>b.start&&b.loaded},o.getInitialLiveFragment=function(m,O){var b=this.fragPrevious,M=null;if(b){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+b.programDateTime),M=Object(S.findFragmentByPDT)(O,b.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=b.sn+1;if(F>=m.startSN&&F<=m.endSN){var w=O[F-m.startSN];b.cc===w.cc&&(M=w,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(S.findFragWithCC)(O,b.cc),M&&this.log("Live playlist, switching playlist, load frag with same CC: "+M.sn))}}else{var C=this.hls.liveSyncPosition;C!==null&&(M=this.getFragmentAtPosition(C,this.bitrateTest?m.fragmentEnd:m.edge,m))}return M},o.getFragmentAtPosition=function(m,O,b){var M=this.config,F=this.fragPrevious,w=b.fragments,C=b.endSN,U=b.fragmentHint,B=M.maxFragLookUpTolerance,N=!!(M.lowLatencyMode&&b.partList&&U);N&&U&&!this.bitrateTest&&(w=w.concat(U),C=U.sn);var k;if(m<O){var j=m>O-B?0:B;k=Object(S.findFragmentByPTS)(F,w,m,j)}else k=w[w.length-1];if(k){var H=k.sn-b.startSN;if(F&&k.sn===F.sn&&!N){var V=F&&k.level===F.level;if(V){var Y=w[H+1];k.sn<C&&this.fragmentTracker.getState(Y)!==x.FragmentState.OK?(this.log("SN "+k.sn+" just loaded, load next one: "+Y.sn),k=Y):k=null}}}return k},o.synchronizeToLiveEdge=function(m){var O=this.config,b=this.media;if(!!b){var M=this.hls.liveSyncPosition,F=b.currentTime,w=m.fragments[0].start,C=m.edge,U=F>=w-O.maxFragLookUpTolerance&&F<=C;if(M!==null&&b.duration>M&&(F<M||!U)){var B=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*m.targetduration;(!U&&b.readyState<4||F<C-B)&&(this.loadedmetadata||(this.nextLoadPosition=M),b.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+C+", reset currentTime to : "+M.toFixed(3)),b.currentTime=M))}}},o.alignPlaylists=function(m,O){var b=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,w=M!==null?b[M]:null,C=m.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var U=m.fragments[0].start,B=!O,N=m.alignedSliding&&Object(P.isFiniteNumber)(U);if(B||!N&&!U){Object(L.alignStream)(F,w,m);var k=m.fragments[0].start;return this.log("Live playlist sliding: "+k.toFixed(2)+" start-sn: "+(O?O.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),k}return U},o.waitForCdnTuneIn=function(m){var O=3;return m.live&&m.canBlockReload&&m.partTarget&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*O)},o.setStartPosition=function(m,O){var b=this.startPosition;if(b<O&&(b=-1),b===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(P.isFiniteNumber)(M)?(b=O+M,M<0&&(b+=m.totalduration),b=Math.min(Math.max(O,b),O+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+b),this.startPosition=b):m.live?b=this.hls.liveSyncPosition||O:this.startPosition=b=0,this.lastCurrentTime=b}this.nextLoadPosition=b},o.getLoadPosition=function(){var m=this.media,O=0;return this.loadedmetadata&&m?O=m.currentTime:this.nextLoadPosition&&(O=this.nextLoadPosition),O},o.handleFragLoadAborted=function(m,O){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(O?" part"+O.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},o.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m)&&this.state!==d.FRAG_LOADING_WAITING_RETRY)&&(this.state=d.IDLE)},o.onFragmentOrKeyLoadError=function(m,O){if(!O.fatal){var b=O.frag;if(!(!b||b.type!==m)){var M=this.fragCurrent;console.assert(M&&b.sn===M.sn&&b.level===M.level&&b.urlId===M.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var w=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+b.sn+" of "+m+" "+b.level+" failed to load, retrying in "+w+"ms"),this.retryDate=self.performance.now()+w,this.fragLoadError++,this.state=d.FRAG_LOADING_WAITING_RETRY}else O.levelRetry?(m===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=d.IDLE):(T.logger.error(O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.hls.stopLoad(),this.state=d.ERROR)}}},o.afterBufferFlushed=function(m,O,b){if(!!m){var M=I.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(O,M,b),this.state===d.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=d.IDLE},o.resetStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var O=this.levels?this.levels[m].details:null;O!=null&&O.live?(this.startPosition=-1,this.setStartPosition(O,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},o.updateLevelTiming=function(m,O,b,M){var F=this,w=b.details;console.assert(!!w,"level.details must be defined");var C=Object.keys(m.elementaryStreams).reduce(function(U,B){var N=m.elementaryStreams[B];if(N){var k=N.endPTS-N.startPTS;if(k<=0)return F.warn("Could not parse fragment "+m.sn+" "+B+" duration reliably ("+k+")"),U||!1;var j=M?0:Object(g.updateFragPTSDTS)(w,m,N.startPTS,N.endPTS,N.startDTS,N.endDTS);return F.hls.trigger(_.Events.LEVEL_PTS_UPDATED,{details:w,level:b,drift:j,type:B,frag:m,start:N.startPTS,end:N.endPTS}),!0}return U},!1);C||(this.warn("Found no media in fragment "+m.sn+" of level "+b.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=d.PARSED,this.hls.trigger(_.Events.FRAG_PARSED,{frag:m,part:O})},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},n(f,[{key:"state",get:function(){return this._state},set:function(m){var O=this._state;O!==m&&(this._state=m,this.log(O+"->"+m))}}]),f}(p.default)},"./src/controller/buffer-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return S});var P=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),x=h("./src/utils/logger.ts"),I=h("./src/errors.ts"),T=h("./src/utils/buffer-helper.ts"),_=h("./src/utils/mediasource-helper.ts"),A=h("./src/loader/fragment.ts"),y=h("./src/controller/buffer-operation-queue.ts"),D=Object(_.getMediaSource)(),L=/([ha]vc.)(?:\.[^.,]+)+/,S=function(){function g(a){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=e.hls,u=e.media,n=e.mediaSource;x.logger.log("[buffer-controller]: Media source opened"),u&&(e.updateMediaElementDuration(),s.trigger(p.Events.MEDIA_ATTACHED,{media:u})),n&&n.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){x.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){x.logger.log("[buffer-controller]: Media source ended")},this.hls=a,this._initSourceBuffer(),this.registerListeners()}var E=g.prototype;return E.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},E.destroy=function(){this.unregisterListeners(),this.details=null},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},E._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},E.onManifestParsed=function(e,s){var u=2;(s.audio&&!s.video||!s.altAudio)&&(u=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=u,this.details=null,x.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},E.onMediaAttaching=function(e,s){var u=this.media=s.media;if(u&&D){var n=this.mediaSource=new D;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),u.src=self.URL.createObjectURL(n),this._objectUrl=u.src}},E.onMediaDetaching=function(){var e=this.media,s=this.mediaSource,u=this._objectUrl;if(s){if(x.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(n){x.logger.warn("[buffer-controller]: onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(u&&self.URL.revokeObjectURL(u),e.src===u?(e.removeAttribute("src"),e.load()):x.logger.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(p.Events.MEDIA_DETACHED,void 0)},E.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(s){var u=e.sourceBuffer[s];try{u&&(e.removeBufferListeners(s),e.mediaSource&&e.mediaSource.removeSourceBuffer(u),e.sourceBuffer[s]=void 0)}catch(n){x.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",n)}}),this._initSourceBuffer()},E.onBufferCodecs=function(e,s){var u=this,n=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(i){if(n){var t=u.tracks[i];if(t&&typeof t.buffer.changeType=="function"){var l=s[i],d=l.id,r=l.codec,c=l.levelCodec,f=l.container,o=l.metadata,v=(t.levelCodec||t.codec).replace(L,"$1"),m=(c||r).replace(L,"$1");if(v!==m){var O=f+";codecs="+(c||r);u.appendChangeType(i,O),x.logger.log("[buffer-controller]: switching codec "+v+" to "+m),u.tracks[i]={buffer:t.buffer,codec:r,container:f,levelCodec:c,metadata:o,id:d}}}}else u.pendingTracks[i]=s[i]}),!n&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},E.appendChangeType=function(e,s){var u=this,n=this.operationQueue,i={execute:function(){var l=u.sourceBuffer[e];l&&(x.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+s),l.changeType(s)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(l){x.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",l)}};n.append(i,e)},E.onBufferAppending=function(e,s){var u=this,n=this.hls,i=this.operationQueue,t=this.tracks,l=s.data,d=s.type,r=s.frag,c=s.part,f=s.chunkMeta,o=f.buffering[d],v=self.performance.now();o.start=v;var m=r.stats.buffering,O=c?c.stats.buffering:null;m.start===0&&(m.start=v),O&&O.start===0&&(O.start=v);var b=t.audio,M=d==="audio"&&f.id===1&&(b==null?void 0:b.container)==="audio/mpeg",F={execute:function(){if(o.executeStart=self.performance.now(),M){var C=u.sourceBuffer[d];if(C){var U=r.start-C.timestampOffset;Math.abs(U)>=.1&&(x.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+r.start+" (delta: "+U+") sn: "+r.sn+")"),C.timestampOffset=r.start)}}u.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var C=self.performance.now();o.executeEnd=o.end=C,m.first===0&&(m.first=C),O&&O.first===0&&(O.first=C);var U=u.sourceBuffer,B={};for(var N in U)B[N]=T.BufferHelper.getBuffered(U[N]);u.appendError=0,u.hls.trigger(p.Events.BUFFER_APPENDED,{type:d,frag:r,part:c,chunkMeta:f,parent:r.type,timeRanges:B})},onError:function(C){x.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",C);var U={type:I.ErrorTypes.MEDIA_ERROR,parent:r.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=I.ErrorDetails.BUFFER_FULL_ERROR:(u.appendError++,U.details=I.ErrorDetails.BUFFER_APPEND_ERROR,u.appendError>n.config.appendErrorMaxRetry&&(x.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0,n.stopLoad())),n.trigger(p.Events.ERROR,U)}};i.append(F,d)},E.onBufferFlushing=function(e,s){var u=this,n=this.operationQueue,i=function(l){return{execute:u.removeExecutor.bind(u,l,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){u.hls.trigger(p.Events.BUFFER_FLUSHED,{type:l})},onError:function(r){x.logger.warn("[buffer-controller]: Failed to remove from "+l+" SourceBuffer",r)}}};s.type?n.append(i(s.type),s.type):this.getSourceBufferTypes().forEach(function(t){n.append(i(t),t)})},E.onFragParsed=function(e,s){var u=this,n=s.frag,i=s.part,t=[],l=i?i.elementaryStreams:n.elementaryStreams;l[A.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(l[A.ElementaryStreamTypes.AUDIO]&&t.push("audio"),l[A.ElementaryStreamTypes.VIDEO]&&t.push("video"));var d=function(){var c=self.performance.now();n.stats.buffering.end=c,i&&(i.stats.buffering.end=c);var f=i?i.stats:n.stats;u.hls.trigger(p.Events.FRAG_BUFFERED,{frag:n,part:i,stats:f,id:n.type})};t.length===0&&x.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(d,t)},E.onFragChanged=function(e,s){this.flushBackBuffer()},E.onBufferEos=function(e,s){var u=this,n=this.getSourceBufferTypes().reduce(function(i,t){var l=u.sourceBuffer[t];return(!s.type||s.type===t)&&l&&!l.ended&&(l.ended=!0,x.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),i&&!!(!l||l.ended)},!0);n&&this.blockBuffers(function(){var i=u.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},E.onLevelUpdated=function(e,s){var u=s.details;!u.fragments.length||(this.details=u,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},E.flushBackBuffer=function(){var e=this.hls,s=this.details,u=this.media,n=this.sourceBuffer;if(!(!u||s===null)){var i=this.getSourceBufferTypes();if(!!i.length){var t=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(P.isFiniteNumber)(t)||t<0)){var l=u.currentTime,d=s.levelTargetDuration,r=Math.max(t,d),c=Math.floor(l/d)*d-r;i.forEach(function(f){var o=n[f];if(o){var v=T.BufferHelper.getBuffered(o);v.length>0&&c>v.start(0)&&(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),s.live&&e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:f}))}})}}}},E.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,s=this.hls,u=this.media,n=this.mediaSource,i=e.fragments[0].start+e.totalduration,t=u.duration,l=Object(P.isFiniteNumber)(n.duration)?n.duration:0;e.live&&s.config.liveDurationInfinity?(x.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(i>l&&i>t||!Object(P.isFiniteNumber)(t))&&(x.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),n.duration=i)}},E.updateSeekableRange=function(e){var s=this.mediaSource,u=e.fragments,n=u.length;if(n&&e.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var i=Math.max(0,u[0].start),t=Math.max(i,i+e.totalduration);s.setLiveSeekableRange(i,t)}},E.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,s=this.operationQueue,u=this.pendingTracks,n=Object.keys(u).length;if(n&&!e||n===2){this.createSourceBuffers(u),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(t){s.executeNext(t)})}},E.createSourceBuffers=function(e){var s=this.sourceBuffer,u=this.mediaSource;if(!u)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var i in e)if(!s[i]){var t=e[i];if(!t)throw Error("source buffer exists for track "+i+", however track does not");var l=t.levelCodec||t.codec,d=t.container+";codecs="+l;x.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var r=s[i]=u.addSourceBuffer(d),c=i;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[i]={buffer:r,codec:l,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id},n++}catch(f){x.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+f.message),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}n&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},E._onSBUpdateStart=function(e){var s=this.operationQueue,u=s.current(e);u.onStart()},E._onSBUpdateEnd=function(e){var s=this.operationQueue,u=s.current(e);u.onComplete(),s.shiftAndExecuteNext(e)},E._onSBUpdateError=function(e,s){x.logger.error("[buffer-controller]: "+e+" SourceBuffer error",s),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var u=this.operationQueue.current(e);u&&u.onError(s)},E.removeExecutor=function(e,s,u){var n=this.media,i=this.mediaSource,t=this.operationQueue,l=this.sourceBuffer,d=l[e];if(!n||!i||!d){x.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(e);return}var r=Object(P.isFiniteNumber)(n.duration)?n.duration:1/0,c=Object(P.isFiniteNumber)(i.duration)?i.duration:1/0,f=Math.max(0,s),o=Math.min(u,r,c);o>f?(x.logger.log("[buffer-controller]: Removing ["+f+","+o+"] from the "+e+" SourceBuffer"),console.assert(!d.updating,e+" sourceBuffer must not be updating"),d.remove(f,o)):t.shiftAndExecuteNext(e)},E.appendExecutor=function(e,s){var u=this.operationQueue,n=this.sourceBuffer,i=n[s];if(!i){x.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),u.shiftAndExecuteNext(s);return}i.ended=!1,console.assert(!i.updating,s+" sourceBuffer must not be updating"),i.appendBuffer(e)},E.blockBuffers=function(e,s){var u=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){x.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var n=this.operationQueue,i=s.map(function(t){return n.appendBlocker(t)});Promise.all(i).then(function(){e(),s.forEach(function(t){var l=u.sourceBuffer[t];(!l||!l.updating)&&n.shiftAndExecuteNext(t)})})},E.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},E.addBufferListener=function(e,s,u){var n=this.sourceBuffer[e];if(!!n){var i=u.bind(this,e);this.listeners[e].push({event:s,listener:i}),n.addEventListener(s,i)}},E.removeBufferListeners=function(e){var s=this.sourceBuffer[e];!s||this.listeners[e].forEach(function(u){s.removeEventListener(u.event,u.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return p});var P=h("./src/utils/logger.ts"),p=function(){function x(T){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=T}var I=x.prototype;return I.append=function(_,A){var y=this.queues[A];y.push(_),y.length===1&&this.buffers[A]&&this.executeNext(A)},I.insertAbort=function(_,A){var y=this.queues[A];y.unshift(_),this.executeNext(A)},I.appendBlocker=function(_){var A,y=new Promise(function(L){A=L}),D={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(D,_),y},I.executeNext=function(_){var A=this.buffers,y=this.queues,D=A[_],L=y[_];if(L.length){var S=L[0];try{S.execute()}catch(g){P.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),S.onError(g),(!D||!D.updating)&&(L.shift(),this.executeNext(_))}}},I.shiftAndExecuteNext=function(_){this.queues[_].shift(),this.executeNext(_)},I.current=function(_){return this.queues[_][0]},x}()},"./src/controller/cap-level-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/events.ts");function p(T,_){for(var A=0;A<_.length;A++){var y=_[A];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(T,y.key,y)}}function x(T,_,A){return _&&p(T.prototype,_),A&&p(T,A),Object.defineProperty(T,"prototype",{writable:!1}),T}var I=function(){function T(A){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=A,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var _=T.prototype;return _.setStreamController=function(y){this.streamController=y},_.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},_.registerListeners=function(){var y=this.hls;y.on(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},_.unregisterListener=function(){var y=this.hls;y.off(P.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},_.onFpsDropLevelCapping=function(y,D){T.isLevelAllowed(D.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(D.droppedLevel)},_.onMediaAttaching=function(y,D){this.media=D.media instanceof HTMLVideoElement?D.media:null},_.onManifestParsed=function(y,D){var L=this.hls;this.restrictedLevels=[],this.firstLevel=D.firstLevel,L.config.capLevelToPlayerSize&&D.video&&this.startCapping()},_.onBufferCodecs=function(y,D){var L=this.hls;L.config.capLevelToPlayerSize&&D.video&&this.startCapping()},_.onMediaDetaching=function(){this.stopCapping()},_.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var y=this.hls.levels;if(y.length){var D=this.hls;D.autoLevelCapping=this.getMaxLevel(y.length-1),D.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=D.autoLevelCapping}}},_.getMaxLevel=function(y){var D=this,L=this.hls.levels;if(!L.length)return-1;var S=L.filter(function(g,E){return T.isLevelAllowed(E,D.restrictedLevels)&&E<=y});return this.clientRect=null,T.getMaxLevelByMediaSize(S,this.mediaWidth,this.mediaHeight)},_.startCapping=function(){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=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},_.getDimensions=function(){if(this.clientRect)return this.clientRect;var y=this.media,D={width:0,height:0};if(y){var L=y.getBoundingClientRect();D.width=L.width,D.height=L.height,!D.width&&!D.height&&(D.width=L.right-L.left||y.width||0,D.height=L.bottom-L.top||y.height||0)}return this.clientRect=D,D},T.isLevelAllowed=function(y,D){return D===void 0&&(D=[]),D.indexOf(y)===-1},T.getMaxLevelByMediaSize=function(y,D,L){if(!y||!y.length)return-1;for(var S=function(s,u){return u?s.width!==u.width||s.height!==u.height:!0},g=y.length-1,E=0;E<y.length;E+=1){var a=y[E];if((a.width>=D||a.height>=L)&&S(a,y[E+1])){g=E;break}}return g},x(T,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var y=1;if(!this.hls.config.ignoreDevicePixelRatio)try{y=self.devicePixelRatio}catch{}return y}}]),T}();R.default=I},"./src/controller/cmcd-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return S});var P=h("./src/events.ts"),p=h("./src/types/cmcd.ts"),x=h("./src/utils/buffer-helper.ts"),I=h("./src/utils/logger.ts");function T(g,E){for(var a=0;a<E.length;a++){var e=E[a];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function _(g,E,a){return E&&T(g.prototype,E),a&&T(g,a),Object.defineProperty(g,"prototype",{writable:!1}),g}function A(g,E){var a=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(a)return(a=a.call(g)).next.bind(a);if(Array.isArray(g)||(a=y(g))||E&&g&&typeof g.length=="number"){a&&(g=a);var e=0;return function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y(g,E){if(!!g){if(typeof g=="string")return D(g,E);var a=Object.prototype.toString.call(g).slice(8,-1);if(a==="Object"&&g.constructor&&(a=g.constructor.name),a==="Map"||a==="Set")return Array.from(g);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return D(g,E)}}function D(g,E){(E==null||E>g.length)&&(E=g.length);for(var a=0,e=new Array(E);a<E;a++)e[a]=g[a];return e}function L(){return L=Object.assign?Object.assign.bind():function(g){for(var E=1;E<arguments.length;E++){var a=arguments[E];for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&(g[e]=a[e])}return g},L.apply(this,arguments)}var S=function(){function g(a){var e=this;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=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(n){try{e.apply(n,{ot:p.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){I.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(n){try{var i=n.frag,t=e.hls.levels[i.level],l=e.getObjectType(i),d={d:i.duration*1e3,ot:l};(l===p.CMCDObjectType.VIDEO||l===p.CMCDObjectType.AUDIO||l==p.CMCDObjectType.MUXED)&&(d.br=t.bitrate/1e3,d.tb=e.getTopBandwidth(l)/1e3,d.bl=e.getBufferLength(l)),e.apply(n,d)}catch(r){I.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=a;var s=this.config=a.config,u=s.cmcd;u!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=u.sessionId||g.uuid(),this.cid=u.contentId,this.useHeaders=u.useHeaders===!0,this.registerListeners())}var E=g.prototype;return E.registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this)},E.unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},E.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},E.onMediaAttached=function(e,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},E.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},E.onBufferCreated=function(e,s){var u,n;this.audioBuffer=(u=s.tracks.audio)===null||u===void 0?void 0:u.buffer,this.videoBuffer=(n=s.tracks.video)===null||n===void 0?void 0:n.buffer},E.createData=function(){var e;return{v:p.CMCDVersion,sf:p.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},E.apply=function(e,s){s===void 0&&(s={}),L(s,this.createData());var u=s.ot===p.CMCDObjectType.INIT||s.ot===p.CMCDObjectType.VIDEO||s.ot===p.CMCDObjectType.MUXED;if(this.starved&&u&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var n=g.toHeaders(s);if(!Object.keys(n).length)return;e.headers||(e.headers={}),L(e.headers,n)}else{var i=g.toQuery(s);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},E.getObjectType=function(e){var s=e.type;if(s==="subtitle")return p.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return p.CMCDObjectType.INIT;if(s==="audio")return p.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?p.CMCDObjectType.VIDEO:p.CMCDObjectType.MUXED},E.getTopBandwidth=function(e){var s=0,u,n=this.hls;if(e===p.CMCDObjectType.AUDIO)u=n.audioTracks;else{var i=n.maxAutoLevel,t=i>-1?i+1:n.levels.length;u=n.levels.slice(0,t)}for(var l=A(u),d;!(d=l()).done;){var r=d.value;r.bitrate>s&&(s=r.bitrate)}return s>0?s:NaN},E.getBufferLength=function(e){var s=this.hls.media,u=e===p.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!u||!s)return NaN;var n=x.BufferHelper.bufferInfo(u,s.currentTime,this.config.maxBufferHole);return n.len*1e3},E.createPlaylistLoader=function(){var e=this.config.pLoader,s=this.applyPlaylistData,u=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new u(t)}var i=n.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,d,r){s(l),this.loader.load(l,d,r)},_(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},E.createFragmentLoader=function(){var e=this.config.fLoader,s=this.applyFragmentData,u=e||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new u(t)}var i=n.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(l,d,r){s(l),this.loader.load(l,d,r)},_(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)},g.serialize=function(e){for(var s=[],u=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},n=function(M){return Math.round(M)},i=function(M){return n(M/100)*100},t=function(M){return encodeURIComponent(M)},l={br:n,d:n,bl:i,dl:i,mtp:i,nor:t,rtp:i,tb:n},d=Object.keys(e||{}).sort(),r=A(d),c;!(c=r()).done;){var f=c.value,o=e[f];if(!!u(o)&&!(f==="v"&&o===1)&&!(f=="pr"&&o===1)){var v=l[f];v&&(o=v(o));var m=typeof o,O=void 0;f==="ot"||f==="sf"||f==="st"?O=f+"="+o:m==="boolean"?O=f:m==="number"?O=f+"="+o:O=f+"="+JSON.stringify(o),s.push(O)}}return s.join(",")},g.toHeaders=function(e){for(var s=Object.keys(e),u={},n=["Object","Request","Session","Status"],i=[{},{},{},{}],t={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},l=0,d=s;l<d.length;l++){var r=d[l],c=t[r]!=null?t[r]:1;i[c][r]=e[r]}for(var f=0;f<i.length;f++){var o=g.serialize(i[f]);o&&(u["CMCD-"+n[f]]=o)}return u},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,s){if(!s)return e;var u=e.includes("?")?"&":"?";return""+e+u+s},g}()},"./src/controller/eme-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/events.ts"),p=h("./src/errors.ts"),x=h("./src/utils/logger.ts"),I=h("./src/utils/mediakeys-helper.ts");function T(S,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(S,a.key,a)}}function _(S,g,E){return g&&T(S.prototype,g),E&&T(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}var A=3,y=function(g,E,a){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(s){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:a.audioRobustness||""})}),E.forEach(function(s){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:a.videoRobustness||""})}),[e]},D=function(g,E,a,e){switch(g){case I.KeySystems.WIDEVINE:return y(E,a,e);default:throw new Error("Unknown key-system: "+g)}},L=function(){function S(E){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=E,this._config=E.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var g=S.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(P.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(a){switch(a){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+a+'"')},g._attemptKeySystemAccess=function(a,e,s){var u=this,n=D(a,e,s,this._drmSystemOptions);x.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(a,n);this.mediaKeysPromise=i.then(function(t){return u._onMediaKeySystemAccessObtained(a,t)}),i.catch(function(t){x.logger.error('Failed to obtain key-system "'+a+'" access:',t)})},g._onMediaKeySystemAccessObtained=function(a,e){var s=this;x.logger.log('Access for key-system "'+a+'" obtained');var u={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:a};this._mediaKeysList.push(u);var n=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return u.mediaKeys=i,x.logger.log('Media-keys created for key-system "'+a+'"'),s._onMediaKeysCreated(),i});return n.catch(function(i){x.logger.error("Failed to create media-keys:",i)}),n},g._onMediaKeysCreated=function(){var a=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),a._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(a){var e=this;x.logger.log("New key-system session "+a.sessionId),a.addEventListener("message",function(s){e._onKeySessionMessage(a,s.message)},!1)},g._onKeySessionMessage=function(a,e){x.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(s){x.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),a.update(s).catch(function(u){x.logger.warn("Updating key-session failed: "+u)})})},g.onMediaEncrypted=function(a){var e=this;if(x.logger.log('Media is encrypted using "'+a.initDataType+'" init data type'),!this.mediaKeysPromise){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(n){!e._media||(e._attemptSetMediaKeys(n),e._generateRequestWithPreferredKeySession(a.initDataType,a.initData))};this.mediaKeysPromise.then(s).catch(s)},g._attemptSetMediaKeys=function(a){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){x.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}x.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(a,e){var s=this,u=this._mediaKeysList[0];if(!u){x.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(u.mediaKeysSessionInitialized){x.logger.warn("Key-Session already initialized but requested again");return}var n=u.mediaKeysSession;if(!n){x.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){x.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}x.logger.log('Generating key-session request for "'+a+'" init data type'),u.mediaKeysSessionInitialized=!0,n.generateRequest(a,e).then(function(){x.logger.debug("Key-session generation succeeded")}).catch(function(i){x.logger.error("Error generating key-session request:",i),s.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(a,e,s){var u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,u,a,e,s);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,u,a),n=void 0}catch(i){x.logger.error(i)}try{u.readyState||u.open("POST",a,!0),n&&n.call(this.hls,u,a)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return u},g._onLicenseRequestReadyStageChange=function(a,e,s,u){switch(a.readyState){case 4:if(a.status===200){this._requestLicenseFailureCount=0,x.logger.log("License request succeeded");var n=a.response,i=this._licenseResponseCallback;if(i)try{n=i.call(this.hls,a,e)}catch(l){x.logger.error(l)}u(n)}else{if(x.logger.error("License Request XHR failed ("+e+"). Status: "+a.status+" ("+a.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>A){this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var t=A-this._requestLicenseFailureCount+1;x.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(s,u)}break}},g._generateLicenseRequestChallenge=function(a,e){switch(a.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+a.mediaKeySystemDomain)},g._requestLicense=function(a,e){x.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){x.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var u=this.getLicenseServerUrl(s.mediaKeySystemDomain),n=this._createLicenseXhr(u,a,e);x.logger.log("Sending license request to URL: "+u);var i=this._generateLicenseRequestChallenge(s,a);n.send(i)}catch(t){x.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(a,e){if(!!this._emeEnabled){var s=e.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},g.onMediaDetached=function(){var a=this._media,e=this._mediaKeysList;!a||(a.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return a.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(a,e){if(!!this._emeEnabled){var s=e.levels.map(function(n){return n.audioCodec}).filter(function(n){return!!n}),u=e.levels.map(function(n){return n.videoCodec}).filter(function(n){return!!n});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,s,u)}},_(S,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),S}();R.default=L},"./src/controller/fps-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/events.ts"),p=h("./src/utils/logger.ts"),x=function(){function I(_){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=_,this.registerListeners()}var T=I.prototype;return T.setStreamController=function(A){this.streamController=A},T.registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},T.unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching)},T.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},T.onMediaAttaching=function(A,y){var D=this.hls.config;if(D.capLevelOnFPSDrop){var L=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=L,L&&typeof L.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),D.fpsDroppedMonitoringPeriod)}},T.checkFPS=function(A,y,D){var L=performance.now();if(y){if(this.lastTime){var S=L-this.lastTime,g=D-this.lastDroppedFrames,E=y-this.lastDecodedFrames,a=1e3*g/S,e=this.hls;if(e.trigger(P.Events.FPS_DROP,{currentDropped:g,currentDecoded:E,totalDroppedFrames:D}),a>0&&g>e.config.fpsDroppedMonitoringThreshold*E){var s=e.currentLevel;p.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=s)&&(s=s-1,e.trigger(P.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:e.currentLevel}),e.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=L,this.lastDroppedFrames=D,this.lastDecodedFrames=y}},T.checkFPSInterval=function(){var A=this.media;if(A)if(this.isVideoPlaybackQualityAvailable){var y=A.getVideoPlaybackQuality();this.checkFPS(A,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(A,A.webkitDecodedFrameCount,A.webkitDroppedFrameCount)},I}();R.default=x},"./src/controller/fragment-finders.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"findFragmentByPDT",function(){return x}),h.d(R,"findFragmentByPTS",function(){return I}),h.d(R,"fragmentWithinToleranceTest",function(){return T}),h.d(R,"pdtWithinToleranceTest",function(){return _}),h.d(R,"findFragWithCC",function(){return A});var P=h("./src/polyfills/number.ts"),p=h("./src/utils/binary-search.ts");function x(y,D,L){if(D===null||!Array.isArray(y)||!y.length||!Object(P.isFiniteNumber)(D))return null;var S=y[0].programDateTime;if(D<(S||0))return null;var g=y[y.length-1].endProgramDateTime;if(D>=(g||0))return null;L=L||0;for(var E=0;E<y.length;++E){var a=y[E];if(_(D,L,a))return a}return null}function I(y,D,L,S){L===void 0&&(L=0),S===void 0&&(S=0);var g=null;if(y?g=D[y.sn-D[0].sn+1]||null:L===0&&D[0].start===0&&(g=D[0]),g&&T(L,S,g)===0)return g;var E=p.default.search(D,T.bind(null,L,S));return E||g}function T(y,D,L){y===void 0&&(y=0),D===void 0&&(D=0);var S=Math.min(D,L.duration+(L.deltaPTS?L.deltaPTS:0));return L.start+L.duration-S<=y?1:L.start-S>y&&L.start?-1:0}function _(y,D,L){var S=Math.min(D,L.duration+(L.deltaPTS?L.deltaPTS:0))*1e3,g=L.endProgramDateTime||0;return g-S>y}function A(y,D){return p.default.search(y,function(L){return L.cc<D?1:L.cc>D?-1:0})}},"./src/controller/fragment-tracker.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"FragmentState",function(){return x}),h.d(R,"FragmentTracker",function(){return I});var P=h("./src/events.ts"),p=h("./src/types/loader.ts"),x;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(x||(x={}));var I=function(){function A(D){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=D,this._registerListeners()}var y=A.prototype;return y._registerListeners=function(){var L=this.hls;L.on(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),L.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),L.on(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var L=this.hls;L.off(P.Events.BUFFER_APPENDED,this.onBufferAppended,this),L.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this),L.off(P.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(L,S){if(S===p.PlaylistLevelType.MAIN){var g=this.activeFragment,E=this.activeParts;if(!g)return null;if(E)for(var a=E.length;a--;){var e=E[a],s=e?e.end:g.appendedPTS;if(e.start<=L&&s!==void 0&&L<=s)return a>9&&(this.activeParts=E.slice(a-9)),e}else if(g.start<=L&&g.appendedPTS!==void 0&&L<=g.appendedPTS)return g}return this.getBufferedFrag(L,S)},y.getBufferedFrag=function(L,S){for(var g=this.fragments,E=Object.keys(g),a=E.length;a--;){var e=g[E[a]];if((e==null?void 0:e.body.type)===S&&e.buffered){var s=e.body;if(s.start<=L&&L<=s.end)return s}}return null},y.detectEvictedFragments=function(L,S,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e){if(!e.buffered){e.body.type===g&&E.removeFragment(e.body);return}var s=e.range[L];!s||s.time.some(function(u){var n=!E.isTimeBuffered(u.startPTS,u.endPTS,S);return n&&E.removeFragment(e.body),n})}})},y.detectPartialFragments=function(L){var S=this,g=this.timeRanges,E=L.frag,a=L.part;if(!(!g||E.sn==="initSegment")){var e=_(E),s=this.fragments[e];!s||(Object.keys(g).forEach(function(u){var n=E.elementaryStreams[u];if(!!n){var i=g[u],t=a!==null||n.partial===!0;s.range[u]=S.getBufferedTimes(E,a,t,i)}}),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},y.fragBuffered=function(L){var S=_(L),g=this.fragments[S];g&&(g.loaded=null,g.buffered=!0)},y.getBufferedTimes=function(L,S,g,E){for(var a={time:[],partial:g},e=S?S.start:L.start,s=S?S.end:L.end,u=L.minEndPTS||s,n=L.maxStartPTS||e,i=0;i<E.length;i++){var t=E.start(i)-this.bufferPadding,l=E.end(i)+this.bufferPadding;if(n>=t&&u<=l){a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(s,E.end(i))});break}else if(e<l&&s>t)a.partial=!0,a.time.push({startPTS:Math.max(e,E.start(i)),endPTS:Math.min(s,E.end(i))});else if(s<=t)break}return a},y.getPartialFragment=function(L){var S=null,g,E,a,e=0,s=this.bufferPadding,u=this.fragments;return Object.keys(u).forEach(function(n){var i=u[n];!i||T(i)&&(E=i.body.start-s,a=i.body.end+s,L>=E&&L<=a&&(g=Math.min(L-E,a-L),e<=g&&(S=i.body,e=g)))}),S},y.getState=function(L){var S=_(L),g=this.fragments[S];return g?g.buffered?T(g)?x.PARTIAL:x.OK:x.APPENDING:x.NOT_LOADED},y.isTimeBuffered=function(L,S,g){for(var E,a,e=0;e<g.length;e++){if(E=g.start(e)-this.bufferPadding,a=g.end(e)+this.bufferPadding,L>=E&&S<=a)return!0;if(S<=E)return!1}return!1},y.onFragLoaded=function(L,S){var g=S.frag,E=S.part;if(!(g.sn==="initSegment"||g.bitrateTest||E)){var a=_(g);this.fragments[a]={body:g,loaded:S,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(L,S){var g=this,E=S.frag,a=S.part,e=S.timeRanges;if(E.type===p.PlaylistLevelType.MAIN)if(this.activeFragment=E,a){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(a)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(u){var n=e[u];if(g.detectEvictedFragments(u,n),!a)for(var i=0;i<n.length;i++)E.appendedPTS=Math.max(n.end(i),E.appendedPTS||0)})},y.onFragBuffered=function(L,S){this.detectPartialFragments(S)},y.hasFragment=function(L){var S=_(L);return!!this.fragments[S]},y.removeFragmentsInRange=function(L,S,g){var E=this;Object.keys(this.fragments).forEach(function(a){var e=E.fragments[a];if(!!e&&e.buffered){var s=e.body;s.type===g&&s.start<S&&s.end>L&&E.removeFragment(s)}})},y.removeFragment=function(L){var S=_(L);L.stats.loaded=0,L.clearElementaryStreamInfo(),delete this.fragments[S]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},A}();function T(A){var y,D;return A.buffered&&(((y=A.range.video)===null||y===void 0?void 0:y.partial)||((D=A.range.audio)===null||D===void 0?void 0:D.partial))}function _(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"STALL_MINIMUM_DURATION_MS",function(){return T}),h.d(R,"MAX_START_GAP_JUMP",function(){return _}),h.d(R,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return A}),h.d(R,"SKIP_BUFFER_RANGE_START",function(){return y}),h.d(R,"default",function(){return D});var P=h("./src/utils/buffer-helper.ts"),p=h("./src/errors.ts"),x=h("./src/events.ts"),I=h("./src/utils/logger.ts"),T=250,_=2,A=.1,y=.05,D=function(){function L(g,E,a,e){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=g,this.media=E,this.fragmentTracker=a,this.hls=e}var S=L.prototype;return S.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},S.poll=function(E,a){var e=this.config,s=this.media,u=this.stalled;if(s!==null){var n=s.currentTime,i=s.seeking,t=this.seeking&&!i,l=!this.seeking&&i;if(this.seeking=i,n!==E){if(this.moved=!0,u!==null){if(this.stallReported){var d=self.performance.now()-u;I.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(d)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||t)&&(this.stalled=null),!(s.paused&&!i||s.ended||s.playbackRate===0||!P.BufferHelper.getBuffered(s).length)){var r=P.BufferHelper.bufferInfo(s,n,0),c=r.len>0,f=r.nextStart||0;if(!(!c&&!f)){if(i){var o=r.len>_,v=!f||a&&a.start<=n||f-n>_&&!this.fragmentTracker.getPartialFragment(n);if(o||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,O=Math.max(f,r.start||0)-n,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=b==null||(m=b.details)===null||m===void 0?void 0:m.live,F=M?b.details.targetduration*2:_;if(O>0&&O<=F){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(u===null){this.stalled=w;return}var C=w-u;if(!(!i&&C>=T&&(this._reportStall(r),!this.media))){var U=P.BufferHelper.bufferInfo(s,n,e.maxBufferHole);this._tryFixBufferStall(U,C)}}}}},S._tryFixBufferStall=function(E,a){var e=this.config,s=this.fragmentTracker,u=this.media;if(u!==null){var n=u.currentTime,i=s.getPartialFragment(n);if(i){var t=this._trySkipBufferHole(i);if(t||!this.media)return}E.len>e.maxBufferHole&&a>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},S._reportStall=function(E){var a=this.hls,e=this.media,s=this.stallReported;!s&&e&&(this.stallReported=!0,I.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(E)+")"),a.trigger(x.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E.len}))},S._trySkipBufferHole=function(E){var a=this.config,e=this.hls,s=this.media;if(s===null)return 0;for(var u=s.currentTime,n=0,i=P.BufferHelper.getBuffered(s),t=0;t<i.length;t++){var l=i.start(t);if(u+a.maxBufferHole>=n&&u<l){var d=Math.max(l+y,s.currentTime+A);return I.logger.warn("skipping hole, adjusting currentTime from "+u+" to "+d),this.moved=!0,this.stalled=null,s.currentTime=d,E&&e.trigger(x.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+u+" to "+d,frag:E}),d}n=i.end(t)}return 0},S._tryNudgeBuffer=function(){var E=this.config,a=this.hls,e=this.media,s=this.nudgeRetry;if(e!==null){var u=e.currentTime;if(this.nudgeRetry++,s<E.nudgeMaxRetry){var n=u+(s+1)*E.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+u+" to "+n),e.currentTime=n,a.trigger(x.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else I.logger.error("Playhead still not moving while enough data buffered @"+u+" after "+E.nudgeMaxRetry+" nudges"),a.trigger(x.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},L}()},"./src/controller/id3-track-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),x=h("./src/utils/texttrack-utils.ts"),I=h("./src/demux/id3.ts"),T=h("./src/loader/date-range.ts"),_=h("./src/types/demuxer.ts"),A=.25;function y(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function D(g,E){return g.getTime()/1e3-E}function L(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var S=function(){function g(a){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=a,this._registerListeners()}var E=g.prototype;return E.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},E._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},E.onMediaAttached=function(e,s){this.media=s.media},E.onMediaDetaching=function(){!this.id3Track||(Object(x.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},E.onManifestLoading=function(){this.dateRangeCuesAppended={}},E.createTrack=function(e){var s=this.getID3Track(e.textTracks);return s.mode="hidden",s},E.getID3Track=function(e){if(!!this.media){for(var s=0;s<e.length;s++){var u=e[s];if(u.kind==="metadata"&&u.label==="id3")return Object(x.sendAddTrackEvent)(u,this.media),u}return this.media.addTextTrack("metadata","id3")}},E.onFragParsingMetadata=function(e,s){if(!!this.media){var u=this.hls.config,n=u.enableEmsgMetadataCues,i=u.enableID3MetadataCues;if(!(!n&&!i)){var t=s.frag,l=s.samples,d=s.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var r=d.edge||t.end,c=y(),f=!1,o={},v=0;v<l.length;v++){var m=l[v].type;if(!(m===_.MetadataSchema.emsg&&!n||!i)){var O=I.getID3Frames(l[v].data);if(O){var b=l[v].pts,M=r,F=M-b;F<=0&&(M=b+A);for(var w=0;w<O.length;w++){var C=O[w];if(!I.isTimeStampFrame(C)){var U=new c(b,M,"");U.value=C,m&&(U.type=m),this.id3Track.addCue(U),o[C.key]=null,f=!0}}}}}f&&this.updateId3CueEnds(o)}}},E.updateId3CueEnds=function(e){var s,u=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(u)for(var n=u.length;n--;){var i,t=u[n],l=(i=t.value)===null||i===void 0?void 0:i.key;if(l&&l in e){var d=e[l];d&&t.endTime!==d&&(t.endTime=d),e[l]=t.startTime}}},E.onBufferFlushing=function(e,s){var u=s.startOffset,n=s.endOffset,i=s.type,t=this.id3Track,l=this.hls;if(!!l){var d=l.config,r=d.enableEmsgMetadataCues,c=d.enableID3MetadataCues;if(t&&(r||c)){var f;i==="audio"?f=function(v){return v.type===_.MetadataSchema.audioId3&&c}:i==="video"?f=function(v){return v.type===_.MetadataSchema.emsg&&r}:f=function(v){return v.type===_.MetadataSchema.audioId3&&c||v.type===_.MetadataSchema.emsg&&r},Object(x.removeCuesInRange)(t,u,n,f)}}},E.onLevelUpdated=function(e,s){var u=this,n=s.details;if(!(!this.media||!n.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,t=this.id3Track,l=n.dateRanges,d=Object.keys(l);if(t)for(var r=Object.keys(i).filter(function(F){return!d.includes(F)}),c=function(w){var C=r[w];Object.keys(i[C].cues).forEach(function(U){t.removeCue(i[C].cues[U])}),delete i[C]},f=r.length;f--;)c(f);var o=n.fragments[n.fragments.length-1];if(!(d.length===0||!Object(P.isFiniteNumber)(o==null?void 0:o.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var v=o.programDateTime/1e3-o.start,m=n.edge||o.end,O=y(),b=function(w){var C=d[w],U=l[C],B=i[C],N=(B==null?void 0:B.cues)||{},k=(B==null?void 0:B.durationKnown)||!1,j=D(U.startDate,v),H=m,V=U.endDate;if(V)H=D(V,v),k=!0;else if(U.endOnNext&&!k){var Y=d.reduce(function(X,le){var ne=l[le];return ne.class===U.class&&ne.id!==le&&ne.startDate>U.startDate&&X.push(ne),X},[]).sort(function(X,le){return X.startDate.getTime()-le.startDate.getTime()})[0];Y&&(H=D(Y.startDate,v),k=!0)}for(var Q=Object.keys(U.attr),J=0;J<Q.length;J++){var z=Q[J];if(!(z===T.DateRangeAttribute.ID||z===T.DateRangeAttribute.CLASS||z===T.DateRangeAttribute.START_DATE||z===T.DateRangeAttribute.DURATION||z===T.DateRangeAttribute.END_DATE||z===T.DateRangeAttribute.END_ON_NEXT)){var q=N[z];if(q)k&&!B.durationKnown&&(q.endTime=H);else{var re=U.attr[z];q=new O(j,H,""),(z===T.DateRangeAttribute.SCTE35_OUT||z===T.DateRangeAttribute.SCTE35_IN)&&(re=L(re)),q.value={key:z,data:re},q.type=_.MetadataSchema.dateRange,u.id3Track.addCue(q),N[z]=q}}}i[C]={cues:N,dateRange:U,durationKnown:k}},M=0;M<d.length;M++)b(M)}}},g}();R.default=S},"./src/controller/latency-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return _});var P=h("./src/errors.ts"),p=h("./src/events.ts"),x=h("./src/utils/logger.ts");function I(A,y){for(var D=0;D<y.length;D++){var L=y[D];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(A,L.key,L)}}function T(A,y,D){return y&&I(A.prototype,y),D&&I(A,D),Object.defineProperty(A,"prototype",{writable:!1}),A}var _=function(){function A(D){var L=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return L.timeupdate()},this.hls=D,this.config=D.config,this.registerListeners()}var y=A.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},y.onMediaAttached=function(L,S){this.media=S.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},y.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},y.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},y.onLevelUpdated=function(L,S){var g=S.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(L,S){S.details===P.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,x.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var L=this.media,S=this.levelDetails;if(!(!L||!S)){this.currentTime=L.currentTime;var g=this.computeLatency();if(g!==null){this._latency=g;var E=this.config,a=E.lowLatencyMode,e=E.maxLiveSyncPlaybackRate;if(!(!a||e===1)){var s=this.targetLatency;if(s!==null){var u=g-s,n=Math.min(this.maxLatency,s+S.targetduration),i=u<n;if(S.live&&i&&u>.05&&this.forwardBufferLength>1){var t=Math.min(2,Math.max(1,e)),l=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20;L.playbackRate=Math.min(t,Math.max(1,l))}else L.playbackRate!==1&&L.playbackRate!==0&&(L.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var L=this.levelDetails;return L===null?null:L.edge+L.age},y.computeLatency=function(){var L=this.estimateLiveEdge();return L===null?null:L-this.currentTime},T(A,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var L=this.config,S=this.levelDetails;return L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:S?L.liveMaxLatencyDurationCount*S.targetduration:0}},{key:"targetLatency",get:function(){var L=this.levelDetails;if(L===null)return null;var S=L.holdBack,g=L.partHoldBack,E=L.targetduration,a=this.config,e=a.liveSyncDuration,s=a.liveSyncDurationCount,u=a.lowLatencyMode,n=this.hls.userConfig,i=u&&g||S;(n.liveSyncDuration||n.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:s*E);var t=E,l=1;return i+Math.min(this.stallCount*l,t)}},{key:"liveSyncPosition",get:function(){var L=this.estimateLiveEdge(),S=this.targetLatency,g=this.levelDetails;if(L===null||S===null||g===null)return null;var E=g.edge,a=L-S-this.edgeStalled,e=E-g.totalduration,s=E-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,a),s)}},{key:"drift",get:function(){var L=this.levelDetails;return L===null?1:L.drift}},{key:"edgeStalled",get:function(){var L=this.levelDetails;if(L===null)return 0;var S=(this.config.lowLatencyMode&&L.partTarget||L.targetduration)*3;return Math.max(L.age-S,0)}},{key:"forwardBufferLength",get:function(){var L=this.media,S=this.levelDetails;if(!L||!S)return 0;var g=L.buffered.length;return(g?L.buffered.end(g-1):S.edge)-this.currentTime}}]),A}()},"./src/controller/level-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return a});var P=h("./src/types/level.ts"),p=h("./src/events.ts"),x=h("./src/errors.ts"),I=h("./src/utils/codecs.ts"),T=h("./src/controller/level-helper.ts"),_=h("./src/controller/base-playlist-controller.ts"),A=h("./src/types/loader.ts");function y(){return y=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var u=arguments[s];for(var n in u)Object.prototype.hasOwnProperty.call(u,n)&&(e[n]=u[n])}return e},y.apply(this,arguments)}function D(e,s){for(var u=0;u<s.length;u++){var n=s[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function L(e,s,u){return s&&D(e.prototype,s),u&&D(e,u),Object.defineProperty(e,"prototype",{writable:!1}),e}function S(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,g(e,s)}function g(e,s){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},g(e,s)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),a=function(e){S(s,e);function s(n){var i;return i=e.call(this,n,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var u=s.prototype;return u._registerListeners=function(){var i=this.hls;i.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(p.Events.ERROR,this.onError,this)},u._unregisterListeners=function(){var i=this.hls;i.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(p.Events.ERROR,this.onError,this)},u.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},u.startLoad=function(){var i=this._levels;i.forEach(function(t){t.loadError=0}),e.prototype.startLoad.call(this)},u.onManifestLoaded=function(i,t){var l=[],d=[],r=[],c,f={},o,v=!1,m=!1,O=!1;if(t.levels.forEach(function(w){var C=w.attrs;v=v||!!(w.width&&w.height),m=m||!!w.videoCodec,O=O||!!w.audioCodec,E&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var U=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;o=f[U],o?o.url.push(w.url):(o=new P.Level(w),f[U]=o,l.push(o)),C&&(C.AUDIO&&Object(T.addGroupId)(o,"audio",C.AUDIO),C.SUBTITLES&&Object(T.addGroupId)(o,"text",C.SUBTITLES))}),(v||m)&&O&&(l=l.filter(function(w){var C=w.videoCodec,U=w.width,B=w.height;return!!C||!!(U&&B)})),l=l.filter(function(w){var C=w.audioCodec,U=w.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!U||Object(I.isCodecSupportedInMp4)(U,"video"))}),t.audioTracks&&(d=t.audioTracks.filter(function(w){return!w.audioCodec||Object(I.isCodecSupportedInMp4)(w.audioCodec,"audio")}),Object(T.assignTrackIdsByGroup)(d)),t.subtitles&&(r=t.subtitles,Object(T.assignTrackIdsByGroup)(r)),l.length>0){c=l[0].bitrate,l.sort(function(w,C){return w.bitrate-C.bitrate}),this._levels=l;for(var b=0;b<l.length;b++)if(l[b].bitrate===c){this._firstLevel=b,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+c);break}var M=O&&!m,F={levels:l,audioTracks:d,subtitleTracks:r,firstLevel:this._firstLevel,stats:t.stats,audio:O,video:m,altAudio:!M&&d.some(function(w){return!!w.url})};this.hls.trigger(p.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(p.Events.ERROR,{type:x.ErrorTypes.MEDIA_ERROR,details:x.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},u.onError=function(i,t){var l;if(e.prototype.onError.call(this,i,t),!t.fatal){var d=t.context,r=this._levels[this.currentLevelIndex];if(d&&(d.type===A.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&d.groupId===r.audioGroupIds[r.urlId]||d.type===A.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&d.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,f=!0,o;switch(t.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:if(t.frag){var v=t.frag.type===A.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,m=this._levels[v];m?(m.fragmentError++,m.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=v)):o=v}break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:d&&(d.deliveryDirectives&&(f=!1),o=d.level),c=!0;break;case x.ErrorDetails.REMUX_ALLOC_ERROR:o=(l=t.level)!=null?l:this.currentLevelIndex,c=!0;break}o!==void 0&&this.recoverLevel(t,o,c,f)}},u.recoverLevel=function(i,t,l,d){var r=i.details,c=this._levels[t];if(c.loadError++,l){var f=this.retryLoadingOrFail(i);if(f)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(d){var o=c.url.length;if(o>1&&c.loadError<o)i.levelRetry=!0,this.redundantFailover(t);else if(this.manualLevelIndex===-1){for(var v=-1,m=this._levels,O=m.length;O--;){var b=(O+this.currentLevelIndex)%m.length;if(b!==this.currentLevelIndex&&m[b].loadError===0){v=b;break}}v>-1&&this.currentLevelIndex!==v&&(this.warn(r+": switch to "+v),i.levelRetry=!0,this.hls.nextAutoLevel=v)}}},u.redundantFailover=function(i){var t=this._levels[i],l=t.url.length;if(l>1){var d=(t.urlId+1)%l;this.warn("Switching to redundant URL-id "+d),this._levels.forEach(function(r){r.urlId=d}),this.level=i}},u.onFragLoaded=function(i,t){var l=t.frag;if(l!==void 0&&l.type===A.PlaylistLevelType.MAIN){var d=this._levels[l.level];d!==void 0&&(d.fragmentError=0,d.loadError=0)}},u.onLevelLoaded=function(i,t){var l,d=t.level,r=t.details,c=this._levels[d];if(!c){var f;this.warn("Invalid level index "+d),(f=t.deliveryDirectives)!==null&&f!==void 0&&f.skip&&(r.deltaUpdateFailed=!0);return}d===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(d,t,c.details)):(l=t.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(r.deltaUpdateFailed=!0)},u.onAudioTrackSwitched=function(i,t){var l=this.hls.levels[this.currentLevelIndex];if(!!l&&l.audioGroupIds){for(var d=-1,r=this.hls.audioTracks[t.id].groupId,c=0;c<l.audioGroupIds.length;c++)if(l.audioGroupIds[c]===r){d=c;break}d!==l.urlId&&(l.urlId=d,this.startLoad())}},u.loadPlaylist=function(i){var t=this.currentLevelIndex,l=this._levels[t];if(this.canLoad&&l&&l.url.length>0){var d=l.urlId,r=l.url[d];if(i)try{r=i.addDirectives(r)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+t+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+d+" "+r),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:r,level:t,id:d,deliveryDirectives:i||null})}},u.removeLevel=function(i,t){var l=function(c,f){return f!==t},d=this._levels.filter(function(r,c){return c!==i?!0:r.url.length>1&&t!==void 0?(r.url=r.url.filter(l),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(l)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(l)),r.urlId=0,!0):!1}).map(function(r,c){var f=r.details;return f!=null&&f.fragments&&f.fragments.forEach(function(o){o.level=c}),r});this._levels=d,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:d})},L(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var t,l=this._levels;if(l.length!==0&&!(this.currentLevelIndex===i&&(t=l[i])!==null&&t!==void 0&&t.details)){if(i<0||i>=l.length){var d=i<0;if(this.hls.trigger(p.Events.ERROR,{type:x.ErrorTypes.OTHER_ERROR,details:x.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:d,reason:"invalid level idx"}),d)return;i=Math.min(i,l.length-1)}this.clearTimer();var r=this.currentLevelIndex,c=l[r],f=l[i];this.log("switching to level "+i+" from "+r),this.currentLevelIndex=i;var o=y({},f,{level:i,maxBitrate:f.maxBitrate,uri:f.uri,urlId:f.urlId});delete o._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,o);var v=f.details;if(!v||v.live){var m=this.switchParams(f.uri,c==null?void 0:c.details);this.loadPlaylist(m)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),s}(_.default)},"./src/controller/level-helper.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"addGroupId",function(){return T}),h.d(R,"assignTrackIdsByGroup",function(){return _}),h.d(R,"updatePTS",function(){return A}),h.d(R,"updateFragPTSDTS",function(){return D}),h.d(R,"mergeDetails",function(){return L}),h.d(R,"mapPartIntersection",function(){return g}),h.d(R,"mapFragmentIntersection",function(){return E}),h.d(R,"adjustSliding",function(){return a}),h.d(R,"addSliding",function(){return e}),h.d(R,"computeReloadInterval",function(){return s}),h.d(R,"getFragmentWithSN",function(){return u}),h.d(R,"getPartWith",function(){return n});var P=h("./src/polyfills/number.ts"),p=h("./src/utils/logger.ts"),x=h("./src/loader/date-range.ts");function I(){return I=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(i[d]=l[d])}return i},I.apply(this,arguments)}function T(i,t,l){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(l);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(l);break}}function _(i){var t={};i.forEach(function(l){var d=l.groupId||"";l.id=t[d]=t[d]||0,t[d]++})}function A(i,t,l){var d=i[t],r=i[l];y(d,r)}function y(i,t){var l=t.startPTS;if(Object(P.isFiniteNumber)(l)){var d=0,r;t.sn>i.sn?(d=l-i.start,r=i):(d=i.start-l,r=t),r.duration!==d&&(r.duration=d)}else if(t.sn>i.sn){var c=i.cc===t.cc;c&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration}else t.start=Math.max(i.start-t.duration,0)}function D(i,t,l,d,r,c){var f=d-l;f<=0&&(p.logger.warn("Fragment should have a positive duration",t),d=l+t.duration,c=r+t.duration);var o=l,v=d,m=t.startPTS,O=t.endPTS;if(Object(P.isFiniteNumber)(m)){var b=Math.abs(m-l);Object(P.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(b,t.deltaPTS):t.deltaPTS=b,o=Math.max(l,m),l=Math.min(l,m),r=Math.min(r,t.startDTS),v=Math.min(d,O),d=Math.max(d,O),c=Math.max(c,t.endDTS)}t.duration=d-l;var M=l-t.start;t.appendedPTS=d,t.start=t.startPTS=l,t.maxStartPTS=o,t.startDTS=r,t.endPTS=d,t.minEndPTS=v,t.endDTS=c;var F=t.sn;if(!i||F<i.startSN||F>i.endSN)return 0;var w,C=F-i.startSN,U=i.fragments;for(U[C]=t,w=C;w>0;w--)y(U[w],U[w-1]);for(w=C;w<U.length-1;w++)y(U[w],U[w+1]);return i.fragmentHint&&y(U[U.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,M}function L(i,t){for(var l=null,d=i.fragments,r=d.length-1;r>=0;r--){var c=d[r].initSegment;if(c){l=c;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var f=0,o;if(E(i,t,function(w,C){w.relurl&&(f=w.cc-C.cc),Object(P.isFiniteNumber)(w.startPTS)&&Object(P.isFiniteNumber)(w.endPTS)&&(C.start=C.startPTS=w.startPTS,C.startDTS=w.startDTS,C.appendedPTS=w.appendedPTS,C.maxStartPTS=w.maxStartPTS,C.endPTS=w.endPTS,C.endDTS=w.endDTS,C.minEndPTS=w.minEndPTS,C.duration=w.endPTS-w.startPTS,C.duration&&(o=C),t.PTSKnown=t.alignedSliding=!0),C.elementaryStreams=w.elementaryStreams,C.loader=w.loader,C.stats=w.stats,C.urlId=w.urlId,w.initSegment&&(C.initSegment=w.initSegment,l=w.initSegment)}),l){var v=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;v.forEach(function(w){var C;(!w.initSegment||w.initSegment.relurl===((C=l)===null||C===void 0?void 0:C.relurl))&&(w.initSegment=l)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(function(w){return!w}),t.deltaUpdateFailed){p.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var m=t.skippedSegments;m--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=S(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var O=t.fragments;if(f){p.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<O.length;b++)O[b].cc+=f}t.skippedSegments&&(t.startCC=t.fragments[0].cc),g(i.partList,t.partList,function(w,C){C.elementaryStreams=w.elementaryStreams,C.stats=w.stats}),o?D(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):a(i,t),O.length&&(t.totalduration=t.edge-O[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var M=t.advancedDateTime;if(t.advanced&&M){var F=t.edge;t.driftStart||(t.driftStartTime=M,t.driftStart=F),t.driftEndTime=M,t.driftEnd=F}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function S(i,t,l){var d=I({},i);return l&&l.forEach(function(r){delete d[r]}),Object.keys(t).forEach(function(r){var c=new x.DateRange(t[r].attr,d[r]);c.isValid?d[r]=c:p.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[r].attr)+'"')}),d}function g(i,t,l){if(i&&t)for(var d=0,r=0,c=i.length;r<=c;r++){var f=i[r],o=t[r+d];f&&o&&f.index===o.index&&f.fragment.sn===o.fragment.sn?l(f,o):d--}}function E(i,t,l){for(var d=t.skippedSegments,r=Math.max(i.startSN,t.startSN)-t.startSN,c=(i.fragmentHint?1:0)+(d?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,f=t.startSN-i.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,v=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,m=r;m<=c;m++){var O=v[f+m],b=o[m];d&&!b&&m<d&&(b=t.fragments[m]=O),O&&b&&l(O,b)}}function a(i,t){var l=t.startSN+t.skippedSegments-i.startSN,d=i.fragments;l<0||l>=d.length||e(t,d[l].start)}function e(i,t){if(t){for(var l=i.fragments,d=i.skippedSegments;d<l.length;d++)l[d].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function s(i,t){var l=1e3*i.levelTargetDuration,d=l/2,r=i.age,c=r>0&&r<l*3,f=t.loading.end-t.loading.start,o,v=i.availabilityDelay;if(i.updated===!1)if(c){var m=333*i.misses;o=Math.max(Math.min(d,f*2),m),i.availabilityDelay=(i.availabilityDelay||0)+o}else o=d;else c?(v=Math.min(v||l/2,r),i.availabilityDelay=v,o=v+l-r):o=l-f;return Math.round(o)}function u(i,t,l){if(!i||!i.details)return null;var d=i.details,r=d.fragments[t-d.startSN];return r||(r=d.fragmentHint,r&&r.sn===t)?r:t<d.startSN&&l&&l.sn===t?l:null}function n(i,t,l){if(!i||!i.details)return null;var d=i.details.partList;if(d)for(var r=d.length;r--;){var c=d[r];if(c.index===l&&c.fragment.sn===t)return c}return null}},"./src/controller/stream-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return n});var P=h("./src/polyfills/number.ts"),p=h("./src/controller/base-stream-controller.ts"),x=h("./src/is-supported.ts"),I=h("./src/events.ts"),T=h("./src/utils/buffer-helper.ts"),_=h("./src/controller/fragment-tracker.ts"),A=h("./src/types/loader.ts"),y=h("./src/loader/fragment.ts"),D=h("./src/demux/transmuxer-interface.ts"),L=h("./src/types/transmuxer.ts"),S=h("./src/controller/gap-controller.ts"),g=h("./src/errors.ts");function E(i,t){for(var l=0;l<t.length;l++){var d=t[l];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(i,d.key,d)}}function a(i,t,l){return t&&E(i.prototype,t),l&&E(i,l),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,s(i,t)}function s(i,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,r){return d.__proto__=r,d},s(i,t)}var u=100,n=function(i){e(t,i);function t(d,r){var c;return c=i.call(this,d,r,"[stream-controller]")||this,c.audioCodecSwap=!1,c.gapController=null,c.level=-1,c._forceStartLoad=!1,c.altAudio=!1,c.audioOnly=!1,c.fragPlaying=null,c.onvplaying=null,c.onvseeked=null,c.fragLastKbps=0,c.couldBacktrack=!1,c.backtrackFragment=null,c.audioCodecSwitch=!1,c.videoBuffer=null,c._registerListeners(),c}var l=t.prototype;return l._registerListeners=function(){var r=this.hls;r.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(I.Events.ERROR,this.onError,this),r.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l._unregisterListeners=function(){var r=this.hls;r.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(I.Events.ERROR,this.onError,this),r.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},l.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},l.startLoad=function(r){if(this.levels){var c=this.lastCurrentTime,f=this.hls;if(this.stopLoad(),this.setInterval(u),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var o=f.startLevel;o===-1&&(f.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=f.nextAutoLevel),this.level=f.nextLoadLevel=o,this.loadedmetadata=!1}c>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+c.toFixed(3)),r=c),this.state=p.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=p.State.STOPPED},l.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},l.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_LEVEL:{var r,c=this.levels,f=this.level,o=c==null||(r=c[f])===null||r===void 0?void 0:r.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=p.State.IDLE;break}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var v,m=self.performance.now(),O=this.retryDate;(!O||m>=O||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=p.State.IDLE)}break;default:break}this.onTickEnd()},l.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},l.doTickIdle=function(){var r,c,f=this.hls,o=this.levelLastLoaded,v=this.levels,m=this.media,O=f.config,b=f.nextLoadLevel;if(!(o===null||!m&&(this.startFragRequested||!O.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!v||!v[b])){var M=v[b];this.level=f.nextLoadLevel=b;var F=M.details;if(!F||this.state===p.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==b){this.state=p.State.WAITING_LEVEL;return}var w=this.getMainFwdBufferInfo();if(w!==null){var C=w.len,U=this.getMaxBufferLength(M.maxBitrate);if(!(C>=U)){if(this._streamEnded(w,F)){var B={};this.altAudio&&(B.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,B),this.state=p.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>w.end&&(this.backtrackFragment=null);var N=this.backtrackFragment?this.backtrackFragment.start:w.end,k=this.getNextFragment(N,F);if(this.couldBacktrack&&!this.fragPrevious&&k&&k.sn!=="initSegment"&&this.fragmentTracker.getState(k)!==_.FragmentState.OK){var j,H=((j=this.backtrackFragment)!=null?j:k).sn,V=H-F.startSN,Y=F.fragments[V-1];Y&&k.cc===Y.cc&&(k=Y,this.fragmentTracker.removeFragment(Y))}else this.backtrackFragment&&w.len&&(this.backtrackFragment=null);if(k&&this.fragmentTracker.getState(k)===_.FragmentState.OK&&this.nextLoadPosition>N){var Q=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;m&&this.afterBufferFlushed(m,Q,A.PlaylistLevelType.MAIN),k=this.getNextFragment(this.nextLoadPosition,F)}!k||(k.initSegment&&!k.initSegment.data&&!this.bitrateTest&&(k=k.initSegment),((r=k.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((c=k.decryptdata)!==null&&c!==void 0&&c.key)?this.loadKey(k,F):this.loadFragment(k,F,N))}}}},l.loadFragment=function(r,c,f){var o,v=this.fragmentTracker.getState(r);this.fragCurrent=r,v===_.FragmentState.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,r,c,f)):v===_.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((o=this.media)===null||o===void 0?void 0:o.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},l.getAppendedFrag=function(r){var c=this.fragmentTracker.getAppendedFrag(r,A.PlaylistLevelType.MAIN);return c&&"fragment"in c?c.fragment:c},l.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,A.PlaylistLevelType.MAIN)},l.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},l.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},l.nextLevelSwitch=function(){var r=this.levels,c=this.media;if(c!=null&&c.readyState){var f,o=this.getAppendedFrag(c.currentTime);if(o&&o.start>1&&this.flushMainBuffer(0,o.start-1),!c.paused&&r){var v=this.hls.nextLoadLevel,m=r[v],O=this.fragLastKbps;O&&this.fragCurrent?f=this.fragCurrent.duration*m.maxBitrate/(1e3*O)+1:f=0}else f=0;var b=this.getBufferedFrag(c.currentTime+f);if(b){var M=this.followingBufferedFrag(b);if(M){this.abortCurrentFrag();var F=M.maxStartPTS?M.maxStartPTS:M.start,w=M.duration,C=Math.max(b.end,F+Math.min(Math.max(w-this.config.maxFragLookUpTolerance,w*.5),w*.75));this.flushMainBuffer(C,Number.POSITIVE_INFINITY)}}}},l.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r!=null&&r.loader&&r.loader.abort(),this.state){case p.State.KEY_LOADING:case p.State.FRAG_LOADING:case p.State.FRAG_LOADING_WAITING_RETRY:case p.State.PARSING:case p.State.PARSED:this.state=p.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},l.flushMainBuffer=function(r,c){i.prototype.flushMainBuffer.call(this,r,c,this.altAudio?"video":null)},l.onMediaAttached=function(r,c){i.prototype.onMediaAttached.call(this,r,c);var f=c.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),f.addEventListener("playing",this.onvplaying),f.addEventListener("seeked",this.onvseeked),this.gapController=new S.default(this.config,f,this.fragmentTracker,this.hls)},l.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},l.onMediaPlaying=function(){this.tick()},l.onMediaSeeked=function(){var r=this.media,c=r?r.currentTime:null;Object(P.isFiniteNumber)(c)&&this.log("Media seeked to "+c.toFixed(3)),this.tick()},l.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(I.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},l.onManifestParsed=function(r,c){var f=!1,o=!1,v;c.levels.forEach(function(m){v=m.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(f=!0),v.indexOf("mp4a.40.5")!==-1&&(o=!0))}),this.audioCodecSwitch=f&&o&&!Object(x.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=c.levels,this.startFragRequested=!1},l.onLevelLoading=function(r,c){var f=this.levels;if(!(!f||this.state!==p.State.IDLE)){var o=f[c.level];(!o.details||o.details.live&&this.levelLastLoaded!==c.level||this.waitForCdnTuneIn(o.details))&&(this.state=p.State.WAITING_LEVEL)}},l.onLevelLoaded=function(r,c){var f,o=this.levels,v=c.level,m=c.details,O=m.totalduration;if(!o){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+m.startSN+","+m.endSN+"], cc ["+m.startCC+", "+m.endCC+"] duration:"+O);var b=this.fragCurrent;b&&(this.state===p.State.FRAG_LOADING||this.state===p.State.FRAG_LOADING_WAITING_RETRY)&&b.level!==c.level&&b.loader&&(this.state=p.State.IDLE,this.backtrackFragment=null,b.loader.abort());var M=o[v],F=0;if(m.live||(f=M.details)!==null&&f!==void 0&&f.live){if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed)return;F=this.alignPlaylists(m,M.details)}if(M.details=m,this.levelLastLoaded=v,this.hls.trigger(I.Events.LEVEL_UPDATED,{details:m,level:v}),this.state===p.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(m))return;this.state=p.State.IDLE}this.startFragRequested?m.live&&this.synchronizeToLiveEdge(m):this.setStartPosition(m,F),this.tick()},l._handleFragmentLoadProgress=function(r){var c,f=r.frag,o=r.part,v=r.payload,m=this.levels;if(!m){this.warn("Levels were reset while fragment load was in progress. Fragment "+f.sn+" of level "+f.level+" will not be buffered");return}var O=m[f.level],b=O.details;if(!b){this.warn("Dropping fragment "+f.sn+" of level "+f.level+" after level details were reset");return}var M=O.videoCodec,F=b.PTSKnown||!b.live,w=(c=f.initSegment)===null||c===void 0?void 0:c.data,C=this._getAudioCodec(O),U=this.transmuxer=this.transmuxer||new D.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),B=o?o.index:-1,N=B!==-1,k=new L.ChunkMetadata(f.level,f.sn,f.stats.chunkCount,v.byteLength,B,N),j=this.initPTS[f.cc];U.push(v,w,C,M,f,o,b.totalduration,F,k,j)},l.onAudioTrackSwitching=function(r,c){var f=this.altAudio,o=!!c.url,v=c.id;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var m=this.fragCurrent;m!=null&&m.loader&&(this.log("Switching to main audio track, cancel main fragment load"),m.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var O=this.hls;f&&O.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),O.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:v})}},l.onAudioTrackSwitched=function(r,c){var f=c.id,o=!!this.hls.audioTracks[f].url;if(o){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=o,this.tick()},l.onBufferCreated=function(r,c){var f=c.tracks,o,v,m=!1;for(var O in f){var b=f[O];if(b.id==="main"){if(v=O,o=b,O==="video"){var M=f[O];M&&(this.videoBuffer=M.buffer)}}else m=!0}m&&o?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},l.onFragBuffered=function(r,c){var f=c.frag,o=c.part;if(!(f&&f.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(f)){this.warn("Fragment "+f.sn+(o?" p: "+o.index:"")+" of level "+f.level+" finished buffering, but was aborted. state: "+this.state),this.state===p.State.PARSED&&(this.state=p.State.IDLE);return}var v=o?o.stats:f.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),f.sn!=="initSegment"&&(this.fragPrevious=f),this.fragBufferedComplete(f,o)}},l.onError=function(r,c){switch(c.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,c);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==p.State.ERROR&&(c.fatal?(this.warn(""+c.details),this.state=p.State.ERROR):!c.levelRetry&&this.state===p.State.WAITING_LEVEL&&(this.state=p.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(c.parent==="main"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var f=!0,o=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);o&&o.len>.5&&(f=!this.reduceMaxBufferLength(o.len)),f&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},l.checkBuffer=function(){var r=this.media,c=this.gapController;if(!(!r||!c||!r.readyState)){if(this.loadedmetadata||!T.BufferHelper.getBuffered(r).length){var f=this.state!==p.State.IDLE?this.fragCurrent:null;c.poll(this.lastCurrentTime,f)}this.lastCurrentTime=r.currentTime}},l.onFragLoadEmergencyAborted=function(){this.state=p.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},l.onBufferFlushed=function(r,c){var f=c.type;if(f!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var o=(f===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,f,A.PlaylistLevelType.MAIN)}},l.onLevelsUpdated=function(r,c){this.levels=c.levels},l.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},l.seekToStartPos=function(){var r=this.media;if(!!r){var c=r.currentTime,f=this.startPosition;if(f>=0&&c<f){if(r.seeking){this.log("could not seek to "+f+", already seeking at "+c);return}var o=T.BufferHelper.getBuffered(r),v=o.length?o.start(0):0,m=v-f;m>0&&(m<this.config.maxBufferHole||m<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+m+" to match buffer start"),f+=m,this.startPosition=f),this.log("seek to target start position "+f+" from current time "+c),r.currentTime=f}}},l._getAudioCodec=function(r){var c=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&c&&(this.log("Swapping audio codec"),c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5"),c},l._loadBitrateTestFrag=function(r){var c=this;r.bitrateTest=!0,this._doFragLoad(r).then(function(f){var o=c.hls;if(!(!f||o.nextLoadLevel||c.fragContextChanged(r))){c.fragLoadError=0,c.state=p.State.IDLE,c.startFragRequested=!1,c.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),o.trigger(I.Events.FRAG_LOADED,f),r.bitrateTest=!1}})},l._handleTransmuxComplete=function(r){var c,f="main",o=this.hls,v=r.remuxResult,m=r.chunkMeta,O=this.getCurrentContext(m);if(!O){this.warn("The loading context changed while buffering fragment "+m.sn+" of level "+m.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(m.level);return}var b=O.frag,M=O.part,F=O.level,w=v.video,C=v.text,U=v.id3,B=v.initSegment,N=F.details,k=this.altAudio?void 0:v.audio;if(!this.fragContextChanged(b)){if(this.state=p.State.PARSING,B){B.tracks&&(this._bufferInitSegment(F,B.tracks,b,m),o.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:f,tracks:B.tracks}));var j=B.initPTS,H=B.timescale;Object(P.isFiniteNumber)(j)&&(this.initPTS[b.cc]=j,o.trigger(I.Events.INIT_PTS_FOUND,{frag:b,id:f,initPTS:j,timescale:H}))}if(w&&v.independent!==!1){if(N){var V=w.startPTS,Y=w.endPTS,Q=w.startDTS,J=w.endDTS;if(M)M.elementaryStreams[w.type]={startPTS:V,endPTS:Y,startDTS:Q,endDTS:J};else if(w.firstKeyFrame&&w.independent&&(this.couldBacktrack=!0),w.dropped&&w.independent){var z=this.getMainFwdBufferInfo(),q=(z?z.end:this.getLoadPosition())+this.config.maxBufferHole,re=w.firstKeyFramePTS?w.firstKeyFramePTS:V;if(q<re-this.config.maxBufferHole){this.backtrack(b);return}b.setElementaryStreamInfo(w.type,b.start,Y,b.start,J,!0)}b.setElementaryStreamInfo(w.type,V,Y,Q,J),this.backtrackFragment&&(this.backtrackFragment=b),this.bufferFragmentData(w,b,M,m)}}else if(v.independent===!1){this.backtrack(b);return}if(k){var X=k.startPTS,le=k.endPTS,ne=k.startDTS,te=k.endDTS;M&&(M.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:le,startDTS:ne,endDTS:te}),b.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,X,le,ne,te),this.bufferFragmentData(k,b,M,m)}if(N&&U!==null&&U!==void 0&&(c=U.samples)!==null&&c!==void 0&&c.length){var ee={id:f,frag:b,details:N,samples:U.samples};o.trigger(I.Events.FRAG_PARSING_METADATA,ee)}if(N&&C){var $={id:f,frag:b,details:N,samples:C.samples};o.trigger(I.Events.FRAG_PARSING_USERDATA,$)}}},l._bufferInitSegment=function(r,c,f,o){var v=this;if(this.state===p.State.PARSING){this.audioOnly=!!c.audio&&!c.video,this.altAudio&&!this.audioOnly&&delete c.audio;var m=c.audio,O=c.video,b=c.audiovideo;if(m){var M=r.audioCodec,F=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(M&&(M.indexOf("mp4a.40.5")!==-1?M="mp4a.40.2":M="mp4a.40.5"),m.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(M="mp4a.40.5")),F.indexOf("android")!==-1&&m.container!=="audio/mpeg"&&(M="mp4a.40.2",this.log("Android: force audio codec to "+M)),r.audioCodec&&r.audioCodec!==M&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+M+'"'),m.levelCodec=M,m.id="main",this.log("Init audio buffer, container:"+m.container+", codecs[selected/level/parsed]=["+(M||"")+"/"+(r.audioCodec||"")+"/"+m.codec+"]")}O&&(O.levelCodec=r.videoCodec,O.id="main",this.log("Init video buffer, container:"+O.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+O.codec+"]")),b&&this.log("Init audiovideo buffer, container:"+b.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+b.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,c),Object.keys(c).forEach(function(w){var C=c[w],U=C.initSegment;U!=null&&U.byteLength&&v.hls.trigger(I.Events.BUFFER_APPENDING,{type:w,data:U,frag:f,part:null,chunkMeta:o,parent:f.type})}),this.tick()}},l.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.PlaylistLevelType.MAIN)},l.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=p.State.IDLE},l.checkFragmentChanged=function(){var r=this.media,c=null;if(r&&r.readyState>1&&r.seeking===!1){var f=r.currentTime;if(T.BufferHelper.isBuffered(r,f)?c=this.getAppendedFrag(f):T.BufferHelper.isBuffered(r,f+.1)&&(c=this.getAppendedFrag(f+.1)),c){this.backtrackFragment=null;var o=this.fragPlaying,v=c.level;(!o||c.sn!==o.sn||o.level!==v||c.urlId!==o.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:c}),(!o||o.level!==v)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=c)}}},a(t,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var c=r.currentTime,f=this.currentFrag;if(f&&Object(P.isFiniteNumber)(c)&&Object(P.isFiniteNumber)(f.programDateTime)){var o=f.programDateTime+(c-f.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(p.default)},"./src/controller/subtitle-stream-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"SubtitleStreamController",function(){return e});var P=h("./src/events.ts"),p=h("./src/utils/buffer-helper.ts"),x=h("./src/controller/fragment-finders.ts"),I=h("./src/utils/discontinuities.ts"),T=h("./src/controller/level-helper.ts"),_=h("./src/controller/fragment-tracker.ts"),A=h("./src/controller/base-stream-controller.ts"),y=h("./src/types/loader.ts"),D=h("./src/types/level.ts");function L(u,n){for(var i=0;i<n.length;i++){var t=n[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(u,t.key,t)}}function S(u,n,i){return n&&L(u.prototype,n),i&&L(u,i),Object.defineProperty(u,"prototype",{writable:!1}),u}function g(u,n){u.prototype=Object.create(n.prototype),u.prototype.constructor=u,E(u,n)}function E(u,n){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,l){return t.__proto__=l,t},E(u,n)}var a=500,e=function(u){g(n,u);function n(t,l){var d;return d=u.call(this,t,l,"[subtitle-stream-controller]")||this,d.levels=[],d.currentTrackId=-1,d.tracksBuffered=[],d.mainDetails=null,d._registerListeners(),d}var i=n.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var l=this.hls;l.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(P.Events.ERROR,this.onError,this),l.on(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var l=this.hls;l.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(P.Events.ERROR,this.onError,this),l.off(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(P.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(P.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(a),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(l,d){this.mainDetails=d.details},i.onSubtitleFragProcessed=function(l,d){var r=d.frag,c=d.success;if(this.fragPrevious=r,this.state=A.State.IDLE,!!c){var f=this.tracksBuffered[this.currentTrackId];if(!!f){for(var o,v=r.start,m=0;m<f.length;m++)if(v>=f[m].start&&v<=f[m].end){o=f[m];break}var O=r.start+r.duration;o?o.end=O:(o={start:v,end:O},f.push(o)),this.fragmentTracker.fragBuffered(r)}}},i.onBufferFlushing=function(l,d){var r=d.startOffset,c=d.endOffset;if(r===0&&c!==Number.POSITIVE_INFINITY){var f=this.currentTrackId,o=this.levels;if(!o.length||!o[f]||!o[f].details)return;var v=o[f].details,m=v.targetduration,O=c-m;if(O<=0)return;d.endOffsetSubtitles=Math.max(0,O),this.tracksBuffered.forEach(function(b){for(var M=0;M<b.length;){if(b[M].end<=O){b.shift();continue}else if(b[M].start<O)b[M].start=O;else break;M++}}),this.fragmentTracker.removeFragmentsInRange(r,O,y.PlaylistLevelType.SUBTITLE)}},i.onError=function(l,d){var r,c=d.frag;!c||c.type!==y.PlaylistLevelType.SUBTITLE||((r=this.fragCurrent)!==null&&r!==void 0&&r.loader&&this.fragCurrent.loader.abort(),this.state=A.State.IDLE)},i.onSubtitleTracksUpdated=function(l,d){var r=this,c=d.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(f){return new D.Level(f)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(f){r.tracksBuffered[f.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(l,d){if(this.currentTrackId=d.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(a)},i.onSubtitleTrackLoaded=function(l,d){var r,c=d.details,f=d.id,o=this.currentTrackId,v=this.levels;if(!!v.length){var m=v[o];if(!(f>=v.length||f!==o||!m)){if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(r=m.details)!==null&&r!==void 0&&r.live){var O=this.mainDetails;if(c.deltaUpdateFailed||!O)return;var b=O.fragments[0];if(!m.details)c.hasProgramDateTime&&O.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(c,O):b&&Object(T.addSliding)(c,b.start);else{var M=this.alignPlaylists(c,m.details);M===0&&b&&Object(T.addSliding)(c,b.start)}}if(m.details=c,this.levelLastLoaded=f,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var F=Object(x.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}}}},i._handleFragmentLoadComplete=function(l){var d=l.frag,r=l.payload,c=d.decryptdata,f=this.hls;if(!this.fragContextChanged(d)&&r&&r.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),c.key.buffer,c.iv.buffer).then(function(v){var m=performance.now();f.trigger(P.Events.FRAG_DECRYPTED,{frag:d,payload:v,stats:{tstart:o,tdecrypt:m}})})}},i.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var l=this.currentTrackId,d=this.levels;if(!d.length||!d[l]||!d[l].details)return;var r=d[l].details,c=r.targetduration,f=this.config,o=this.media,v=p.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o.currentTime-c,f.maxBufferHole),m=v.end,O=v.len,b=this.getMaxBufferLength()+c;if(O>b)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var M=r.fragments,F=M.length,w=r.edge,C,U=this.fragPrevious;if(m<w){var B=f.maxFragLookUpTolerance;C=Object(x.findFragmentByPTS)(U,M,Math.max(M[0].start,m),B),!C&&U&&U.start<M[0].start&&(C=M[0])}else C=M[F-1];if(C=this.mapToInitFragWhenRequired(C),!C||this.fragmentTracker.getState(C)!==_.FragmentState.NOT_LOADED)return;C.encrypted?this.loadKey(C,r):this.loadFragment(C,r,m)}},i.loadFragment=function(l,d,r){this.fragCurrent=l,l.sn==="initSegment"?this._loadInitSegment(l):u.prototype.loadFragment.call(this,l,d,r)},S(n,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(A.default),s=function(n){this.buffered=void 0;var i=function(l,d,r){if(d=d>>>0,d>r-1)throw new DOMException("Failed to execute '"+l+"' on 'TimeRanges': The index provided ("+d+") is greater than the maximum bound ("+r+")");return n[d][l]};this.buffered={get length(){return n.length},end:function(l){return i("end",l,n.length)},start:function(l){return i("start",l,n.length)}}}},"./src/controller/subtitle-track-controller.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/events.ts"),p=h("./src/utils/texttrack-utils.ts"),x=h("./src/controller/base-playlist-controller.ts"),I=h("./src/types/loader.ts");function T(S,g){for(var E=0;E<g.length;E++){var a=g[E];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(S,a.key,a)}}function _(S,g,E){return g&&T(S.prototype,g),E&&T(S,E),Object.defineProperty(S,"prototype",{writable:!1}),S}function A(S,g){S.prototype=Object.create(g.prototype),S.prototype.constructor=S,y(S,g)}function y(S,g){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,e){return a.__proto__=e,a},y(S,g)}var D=function(S){A(g,S);function g(a){var e;return e=S.call(this,a,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var E=g.prototype;return E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,S.prototype.destroy.call(this)},E.registerListeners=function(){var e=this.hls;e.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(P.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var e=this.hls;e.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(P.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(P.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(P.Events.ERROR,this.onError,this)},E.onMediaAttached=function(e,s){this.media=s.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))},E.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},E.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=L(this.media.textTracks);e.forEach(function(s){Object(p.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null}},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},E.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},E.onSubtitleTrackLoaded=function(e,s){var u=s.id,n=s.details,i=this.trackId,t=this.tracksInGroup[i];if(!t){this.warn("Invalid subtitle track id "+u);return}var l=t.details;t.details=s.details,this.log("subtitle track "+u+" loaded ["+n.startSN+"-"+n.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,s,l))},E.onLevelLoading=function(e,s){this.switchLevel(s.level)},E.onLevelSwitching=function(e,s){this.switchLevel(s.level)},E.switchLevel=function(e){var s=this.hls.levels[e];if(!!(s!=null&&s.textGroupIds)){var u=s.textGroupIds[s.urlId];if(this.groupId!==u){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(d){return!u||d.groupId===u});this.tracksInGroup=i;var t=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=u;var l={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(P.Events.SUBTITLE_TRACKS_UPDATED,l),t!==-1&&this.setSubtitleTrack(t,n)}}},E.findTrackId=function(e){for(var s=this.tracksInGroup,u=0;u<s.length;u++){var n=s[u];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},E.onError=function(e,s){S.prototype.onError.call(this,e,s),!(s.fatal||!s.context)&&s.context.type===I.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},E.loadPlaylist=function(e){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var u=s.id,n=s.groupId,i=s.url;if(e)try{i=e.addDirectives(i)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+u),this.hls.trigger(P.Events.SUBTITLE_TRACK_LOADING,{url:i,id:u,groupId:n,deliveryDirectives:e||null})}},E.toggleTrackModes=function(e){var s=this,u=this.media,n=this.trackId;if(!!u){var i=L(u.textTracks),t=i.filter(function(r){return r.groupId===s.groupId});if(e===-1)[].slice.call(i).forEach(function(r){r.mode="disabled"});else{var l=t[n];l&&(l.mode="disabled")}var d=t[e];d&&(d.mode=this.subtitleDisplay?"showing":"hidden")}},E.setSubtitleTrack=function(e,s){var u,n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(u=n[e])!==null&&u!==void 0&&u.details)||e<-1||e>=n.length)){this.clearTimer();var i=n[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var t=i.id,l=i.groupId,d=l===void 0?"":l,r=i.name,c=i.type,f=i.url;this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:t,groupId:d,name:r,type:c,url:f});var o=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(o)}else this.hls.trigger(P.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},E.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,s=L(this.media.textTracks),u=0;u<s.length;u++)if(s[u].mode==="hidden")e=u;else if(s[u].mode==="showing"){e=u;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},_(g,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}}]),g}(x.default);function L(S){for(var g=[],E=0;E<S.length;E++){var a=S[E];a.kind==="subtitles"&&a.label&&g.push(S[E])}return g}R.default=D},"./src/controller/timeline-controller.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"TimelineController",function(){return S});var P=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),x=h("./src/utils/cea-608-parser.ts"),I=h("./src/utils/output-filter.ts"),T=h("./src/utils/webvtt-parser.ts"),_=h("./src/utils/texttrack-utils.ts"),A=h("./src/utils/imsc1-ttml-parser.ts"),y=h("./src/utils/mp4-tools.ts"),D=h("./src/types/loader.ts"),L=h("./src/utils/logger.ts"),S=function(){function e(u){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=a(),this.captionsProperties=void 0,this.hls=u,this.config=u.config,this.Cues=u.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var n=new I.default(this,"textTrack1"),i=new I.default(this,"textTrack2"),t=new I.default(this,"textTrack3"),l=new I.default(this,"textTrack4");this.cea608Parser1=new x.default(1,n,i),this.cea608Parser2=new x.default(3,t,l)}u.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.on(p.Events.FRAG_LOADING,this.onFragLoading,this),u.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),u.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),u.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),u.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=e.prototype;return s.destroy=function(){var n=this.hls;n.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(p.Events.FRAG_LOADING,this.onFragLoading,this),n.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),n.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(n,i,t,l,d){for(var r=!1,c=d.length;c--;){var f=d[c],o=E(f[0],f[1],i,t);if(o>=0&&(f[0]=Math.min(f[0],i),f[1]=Math.max(f[1],t),r=!0,o/(t-i)>.5))return}if(r||d.push([i,t]),this.config.renderTextTracksNatively){var v=this.captionsTracks[n];this.Cues.newCue(v,i,t,l)}else{var m=this.Cues.newCue(null,i,t,l);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:m,track:n})}},s.onInitPtsFound=function(n,i){var t=this,l=i.frag,d=i.id,r=i.initPTS,c=i.timescale,f=this.unparsedVttFrags;d==="main"&&(this.initPTS[l.cc]=r,this.timescale[l.cc]=c),f.length&&(this.unparsedVttFrags=[],f.forEach(function(o){t.onFragLoaded(p.Events.FRAG_LOADED,o)}))},s.getExistingTrack=function(n){var i=this.media;if(i)for(var t=0;t<i.textTracks.length;t++){var l=i.textTracks[t];if(l[n])return l}return null},s.createCaptionsTrack=function(n){this.config.renderTextTracksNatively?this.createNativeTrack(n):this.createNonNativeTrack(n)},s.createNativeTrack=function(n){if(!this.captionsTracks[n]){var i=this.captionsProperties,t=this.captionsTracks,l=this.media,d=i[n],r=d.label,c=d.languageCode,f=this.getExistingTrack(n);if(f)t[n]=f,Object(_.clearCurrentCues)(t[n]),Object(_.sendAddTrackEvent)(t[n],l);else{var o=this.createTextTrack("captions",r,c);o&&(o[n]=!0,t[n]=o)}}},s.createNonNativeTrack=function(n){if(!this.nonNativeCaptionsTracks[n]){var i=this.captionsProperties[n];if(!!i){var t=i.label,l={_id:n,label:t,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[n]=l,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})}}},s.createTextTrack=function(n,i,t){var l=this.media;if(!!l)return l.addTextTrack(n,i,t)},s.onMediaAttaching=function(n,i){this.media=i.media,this._cleanTracks()},s.onMediaDetaching=function(){var n=this.captionsTracks;Object.keys(n).forEach(function(i){Object(_.clearCurrentCues)(n[i]),delete n[i]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=a(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var n=this.media;if(!!n){var i=n.textTracks;if(i)for(var t=0;t<i.length;t++)Object(_.clearCurrentCues)(i[t])}},s.onSubtitleTracksUpdated=function(n,i){var t=this;this.textTracks=[];var l=i.subtitleTracks||[],d=l.some(function(o){return o.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||d&&this.config.enableIMSC1){var r=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var c=this.media?this.media.textTracks:[];this.tracks.forEach(function(o,v){var m;if(v<c.length){for(var O=null,b=0;b<c.length;b++)if(g(c[b],o)){O=c[b];break}O&&(m=O)}if(m)Object(_.clearCurrentCues)(m);else{var M=t._captionsOrSubtitlesFromCharacteristics(o);m=t.createTextTrack(M,o.name,o.lang),m&&(m.mode="disabled")}m&&(m.groupId=o.groupId,t.textTracks.push(m))})}else if(!r&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(o){return{label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},s._captionsOrSubtitlesFromCharacteristics=function(n){var i;if((i=n.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(n.attrs.CHARACTERISTICS),l=/describes-music-and-sound/gi.test(n.attrs.CHARACTERISTICS);if(t&&l)return"captions"}return"subtitles"},s.onManifestLoaded=function(n,i){var t=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(l){var d=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!!d){var r="textTrack"+d[1],c=t.captionsProperties[r];!c||(c.label=l.name,l.lang&&(c.languageCode=l.lang),c.media=l)}})},s.onFragLoading=function(n,i){var t=this.cea608Parser1,l=this.cea608Parser2,d=this.lastSn,r=this.lastPartIndex;if(!(!this.enabled||!(t&&l))&&i.frag.type===D.PlaylistLevelType.MAIN){var c,f,o=i.frag.sn,v=(c=i==null||(f=i.part)===null||f===void 0?void 0:f.index)!=null?c:-1;o===d+1||o===d&&v===r+1||(t.reset(),l.reset()),this.lastSn=o,this.lastPartIndex=v}},s.onFragLoaded=function(n,i){var t=i.frag,l=i.payload,d=this.initPTS,r=this.unparsedVttFrags;if(t.type===D.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(P.isFiniteNumber)(d[t.cc])){r.push(i),d.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")});return}var c=t.decryptdata,f="stats"in i;if(c==null||c.key==null||c.method!=="AES-128"||f){var o=this.tracks[t.level],v=this.vttCCs;v[t.cc]||(v[t.cc]={start:t.start,prevCC:this.prevCC,new:!0},this.prevCC=t.cc),o&&o.textCodec===A.IMSC1_CODEC?this._parseIMSC1(t,l):this._parseVTTs(t,l,v)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(n,i){var t=this,l=this.hls;Object(A.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(d){t._appendCues(d,n.level),l.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(d){L.logger.log("Failed to parse IMSC1: "+d),l.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:d})})},s._parseVTTs=function(n,i,t){var l,d=this,r=this.hls,c=(l=n.initSegment)!==null&&l!==void 0&&l.data?Object(y.appendUint8Array)(n.initSegment.data,new Uint8Array(i)):i;Object(T.parseWebVTT)(c,this.initPTS[n.cc],this.timescale[n.cc],t,n.cc,n.start,function(f){d._appendCues(f,n.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(f){d._fallbackToIMSC1(n,i),L.logger.log("Failed to parse VTT cue: "+f),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:f})})},s._fallbackToIMSC1=function(n,i){var t=this,l=this.tracks[n.level];l.textCodec||Object(A.parseIMSC1)(i,this.initPTS[n.cc],this.timescale[n.cc],function(){l.textCodec=A.IMSC1_CODEC,t._parseIMSC1(n,i)},function(){l.textCodec="wvtt"})},s._appendCues=function(n,i){var t=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[i];if(!l||l.mode==="disabled")return;n.forEach(function(c){return Object(_.addCueToTrack)(l,c)})}else{var d=this.tracks[i];if(!d)return;var r=d.default?"default":"subtitles"+i;t.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:n,track:r})}},s.onFragDecrypted=function(n,i){var t=i.frag;if(t.type===D.PlaylistLevelType.SUBTITLE){if(!Object(P.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(p.Events.FRAG_LOADED,i)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(n,i){var t=this.cea608Parser1,l=this.cea608Parser2;if(!(!this.enabled||!(t&&l)))for(var d=0;d<i.samples.length;d++){var r=i.samples[d].bytes;if(r){var c=this.extractCea608Data(r);t.addData(i.samples[d].pts,c[0]),l.addData(i.samples[d].pts,c[1])}}},s.onBufferFlushing=function(n,i){var t=i.startOffset,l=i.endOffset,d=i.endOffsetSubtitles,r=i.type,c=this.media;if(!(!c||c.currentTime<l)){if(!r||r==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(v){return Object(_.removeCuesInRange)(f[v],t,l)})}if(this.config.renderTextTracksNatively&&t===0&&d!==void 0){var o=this.textTracks;Object.keys(o).forEach(function(v){return Object(_.removeCuesInRange)(o[v],t,d)})}}},s.extractCea608Data=function(n){for(var i=[[],[]],t=n[0]&31,l=2,d=0;d<t;d++){var r=n[l++],c=127&n[l++],f=127&n[l++];if(!(c===0&&f===0)){var o=(4&r)!==0;if(o){var v=3&r;(v===0||v===1)&&(i[v].push(c),i[v].push(f))}}}return i},e}();function g(e,s){return e&&e.label===s.name&&!(e.textTrack1||e.textTrack2)}function E(e,s,u,n){return Math.min(s,n)-Math.max(e,u)}function a(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return P});var P=function(){function p(I,T){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=T}var x=p.prototype;return x.decrypt=function(T,_){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},_,T)},p}()},"./src/crypt/aes-decryptor.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"removePadding",function(){return p}),h.d(R,"default",function(){return x});var P=h("./src/utils/typed-array.ts");function p(I){var T=I.byteLength,_=T&&new DataView(I.buffer).getUint8(T-1);return _?Object(P.sliceUint8)(I,0,T-_):I}var x=function(){function I(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var T=I.prototype;return T.uint8ArrayToUint32Array_=function(A){for(var y=new DataView(A),D=new Uint32Array(4),L=0;L<4;L++)D[L]=y.getUint32(L*4);return D},T.initTable=function(){var A=this.sBox,y=this.invSBox,D=this.subMix,L=D[0],S=D[1],g=D[2],E=D[3],a=this.invSubMix,e=a[0],s=a[1],u=a[2],n=a[3],i=new Uint32Array(256),t=0,l=0,d=0;for(d=0;d<256;d++)d<128?i[d]=d<<1:i[d]=d<<1^283;for(d=0;d<256;d++){var r=l^l<<1^l<<2^l<<3^l<<4;r=r>>>8^r&255^99,A[t]=r,y[r]=t;var c=i[t],f=i[c],o=i[f],v=i[r]*257^r*16843008;L[t]=v<<24|v>>>8,S[t]=v<<16|v>>>16,g[t]=v<<8|v>>>24,E[t]=v,v=o*16843009^f*65537^c*257^t*16843008,e[r]=v<<24|v>>>8,s[r]=v<<16|v>>>16,u[r]=v<<8|v>>>24,n[r]=v,t?(t=c^i[i[i[o^c]]],l^=i[i[l]]):t=l=1}},T.expandKey=function(A){for(var y=this.uint8ArrayToUint32Array_(A),D=!0,L=0;L<y.length&&D;)D=y[L]===this.key[L],L++;if(!D){this.key=y;var S=this.keySize=y.length;if(S!==4&&S!==6&&S!==8)throw new Error("Invalid aes key size="+S);var g=this.ksRows=(S+6+1)*4,E,a,e=this.keySchedule=new Uint32Array(g),s=this.invKeySchedule=new Uint32Array(g),u=this.sBox,n=this.rcon,i=this.invSubMix,t=i[0],l=i[1],d=i[2],r=i[3],c,f;for(E=0;E<g;E++){if(E<S){c=e[E]=y[E];continue}f=c,E%S===0?(f=f<<8|f>>>24,f=u[f>>>24]<<24|u[f>>>16&255]<<16|u[f>>>8&255]<<8|u[f&255],f^=n[E/S|0]<<24):S>6&&E%S===4&&(f=u[f>>>24]<<24|u[f>>>16&255]<<16|u[f>>>8&255]<<8|u[f&255]),e[E]=c=(e[E-S]^f)>>>0}for(a=0;a<g;a++)E=g-a,a&3?f=e[E]:f=e[E-4],a<4||E<=4?s[a]=f:s[a]=t[u[f>>>24]]^l[u[f>>>16&255]]^d[u[f>>>8&255]]^r[u[f&255]],s[a]=s[a]>>>0}},T.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},T.decrypt=function(A,y,D){for(var L=this.keySize+6,S=this.invKeySchedule,g=this.invSBox,E=this.invSubMix,a=E[0],e=E[1],s=E[2],u=E[3],n=this.uint8ArrayToUint32Array_(D),i=n[0],t=n[1],l=n[2],d=n[3],r=new Int32Array(A),c=new Int32Array(r.length),f,o,v,m,O,b,M,F,w,C,U,B,N,k,j=this.networkToHostOrderSwap;y<r.length;){for(w=j(r[y]),C=j(r[y+1]),U=j(r[y+2]),B=j(r[y+3]),O=w^S[0],b=B^S[1],M=U^S[2],F=C^S[3],N=4,k=1;k<L;k++)f=a[O>>>24]^e[b>>16&255]^s[M>>8&255]^u[F&255]^S[N],o=a[b>>>24]^e[M>>16&255]^s[F>>8&255]^u[O&255]^S[N+1],v=a[M>>>24]^e[F>>16&255]^s[O>>8&255]^u[b&255]^S[N+2],m=a[F>>>24]^e[O>>16&255]^s[b>>8&255]^u[M&255]^S[N+3],O=f,b=o,M=v,F=m,N=N+4;f=g[O>>>24]<<24^g[b>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^S[N],o=g[b>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[O&255]^S[N+1],v=g[M>>>24]<<24^g[F>>16&255]<<16^g[O>>8&255]<<8^g[b&255]^S[N+2],m=g[F>>>24]<<24^g[O>>16&255]<<16^g[b>>8&255]<<8^g[M&255]^S[N+3],c[y]=j(f^i),c[y+1]=j(m^t),c[y+2]=j(v^l),c[y+3]=j(o^d),i=w,t=C,l=U,d=B,y=y+4}return c.buffer},I}()},"./src/crypt/decrypter.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return y});var P=h("./src/crypt/aes-crypto.ts"),p=h("./src/crypt/fast-aes-key.ts"),x=h("./src/crypt/aes-decryptor.ts"),I=h("./src/utils/logger.ts"),T=h("./src/utils/mp4-tools.ts"),_=h("./src/utils/typed-array.ts"),A=16,y=function(){function D(S,g,E){var a=E===void 0?{}:E,e=a.removePKCS7Padding,s=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=S,this.config=g,this.removePKCS7Padding=s,s)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var L=D.prototype;return L.destroy=function(){this.observer=null},L.isSync=function(){return this.config.enableSoftwareAES},L.flush=function(){var g=this.currentResult;if(!g){this.reset();return}var E=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(x.removePadding)(E):E},L.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},L.decrypt=function(g,E,a,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),E,a);var s=this.flush();s&&e(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),E,a).then(e)},L.softwareDecrypt=function(g,E,a){var e=this.currentIV,s=this.currentResult,u=this.remainderData;this.logOnce("JS AES decrypt"),u&&(g=Object(T.appendUint8Array)(u,g),this.remainderData=null);var n=this.getValidChunk(g);if(!n.length)return null;e&&(a=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new x.default),i.expandKey(E);var t=s;return this.currentResult=i.decrypt(n.buffer,0,a),this.currentIV=Object(_.sliceUint8)(n,-16).buffer,t||null},L.webCryptoDecrypt=function(g,E,a){var e=this,s=this.subtle;return(this.key!==E||!this.fastAesKey)&&(this.key=E,this.fastAesKey=new p.default(s,E)),this.fastAesKey.expandKey().then(function(u){if(!s)return Promise.reject(new Error("web crypto not initialized"));var n=new P.default(s,a);return n.decrypt(g.buffer,u)}).catch(function(u){return e.onWebCryptoError(u,g,E,a)})},L.onWebCryptoError=function(g,E,a,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,a,e)},L.getValidChunk=function(g){var E=g,a=g.length-g.length%A;return a!==g.length&&(E=Object(_.sliceUint8)(g,0,a),this.remainderData=Object(_.sliceUint8)(g,a)),E},L.logOnce=function(g){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},D}()},"./src/crypt/fast-aes-key.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return P});var P=function(){function p(I,T){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=T}var x=p.prototype;return x.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},p}()},"./src/demux/aacdemuxer.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/demux/base-audio-demuxer.ts"),p=h("./src/demux/adts.ts"),x=h("./src/utils/logger.ts"),I=h("./src/demux/id3.ts");function T(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,_(y,D)}function _(y,D){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(S,g){return S.__proto__=g,S},_(y,D)}var A=function(y){T(D,y);function D(S,g){var E;return E=y.call(this)||this,E.observer=void 0,E.config=void 0,E.observer=S,E.config=g,E}var L=D.prototype;return L.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=I.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(p.probe(g,a))return x.logger.log("ADTS sync word found !"),!0;return!1},L.canParse=function(g,E){return p.canParse(g,E)},L.appendFrame=function(g,E,a){p.initTrackConfig(g,this.observer,E,a,g.manifestCodec);var e=p.appendFrame(g,E,a,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},D}(P.default);R.default=A},"./src/demux/adts.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"getAudioConfig",function(){return I}),h.d(R,"isHeaderPattern",function(){return T}),h.d(R,"getHeaderLength",function(){return _}),h.d(R,"getFullFrameLength",function(){return A}),h.d(R,"canGetFrameLength",function(){return y}),h.d(R,"isHeader",function(){return D}),h.d(R,"canParse",function(){return L}),h.d(R,"probe",function(){return S}),h.d(R,"initTrackConfig",function(){return g}),h.d(R,"getFrameDuration",function(){return E}),h.d(R,"parseFrameHeader",function(){return a}),h.d(R,"appendFrame",function(){return e});var P=h("./src/utils/logger.ts"),p=h("./src/errors.ts"),x=h("./src/events.ts");function I(s,u,n,i){var t,l,d,r,c=navigator.userAgent.toLowerCase(),f=i,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((u[n+2]&192)>>>6)+1;var v=(u[n+2]&60)>>>2;if(v>o.length-1){s.trigger(x.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v});return}return d=(u[n+2]&1)<<2,d|=(u[n+3]&192)>>>6,P.logger.log("manifest codec:"+i+", ADTS type:"+t+", samplingIndex:"+v),/firefox/i.test(c)?v>=6?(t=5,r=new Array(4),l=v-3):(t=2,r=new Array(2),l=v):c.indexOf("android")!==-1?(t=2,r=new Array(2),l=v):(t=5,r=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?l=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&d===1||/vivaldi/i.test(c))||!i&&d===1)&&(t=2,r=new Array(2)),l=v)),r[0]=t<<3,r[0]|=(v&14)>>1,r[1]|=(v&1)<<7,r[1]|=d<<3,t===5&&(r[1]|=(l&14)>>1,r[2]=(l&1)<<7,r[2]|=2<<2,r[3]=0),{config:r,samplerate:o[v],channelCount:d,codec:"mp4a.40."+t,manifestCodec:f}}function T(s,u){return s[u]===255&&(s[u+1]&246)===240}function _(s,u){return s[u+1]&1?7:9}function A(s,u){return(s[u+3]&3)<<11|s[u+4]<<3|(s[u+5]&224)>>>5}function y(s,u){return u+5<s.length}function D(s,u){return u+1<s.length&&T(s,u)}function L(s,u){return y(s,u)&&T(s,u)&&A(s,u)<=s.length-u}function S(s,u){if(D(s,u)){var n=_(s,u);if(u+n>=s.length)return!1;var i=A(s,u);if(i<=n)return!1;var t=u+i;return t===s.length||D(s,t)}return!1}function g(s,u,n,i,t){if(!s.samplerate){var l=I(u,n,i,t);if(!l)return;s.config=l.config,s.samplerate=l.samplerate,s.channelCount=l.channelCount,s.codec=l.codec,s.manifestCodec=l.manifestCodec,P.logger.log("parsed codec:"+s.codec+", rate:"+l.samplerate+", channels:"+l.channelCount)}}function E(s){return 1024*9e4/s}function a(s,u){var n=_(s,u);if(u+n<=s.length){var i=A(s,u)-n;if(i>0)return{headerLength:n,frameLength:i}}}function e(s,u,n,i,t){var l=E(s.samplerate),d=i+t*l,r=a(u,n),c;if(r){var f=r.frameLength,o=r.headerLength,v=o+f,m=Math.max(0,n+v-u.length);m?(c=new Uint8Array(v-o),c.set(u.subarray(n+o,u.length),0)):c=u.subarray(n+o,n+v);var O={unit:c,pts:d};return m||s.samples.push(O),{sample:O,length:v,missing:m}}var b=u.length-n;c=new Uint8Array(b),c.set(u.subarray(n,u.length),0);var M={unit:c,pts:d};return{sample:M,length:b,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"initPTSFn",function(){return y});var P=h("./src/polyfills/number.ts"),p=h("./src/demux/id3.ts"),x=h("./src/types/demuxer.ts"),I=h("./src/demux/dummy-demuxed-track.ts"),T=h("./src/utils/mp4-tools.ts"),_=h("./src/utils/typed-array.ts"),A=function(){function D(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var L=D.prototype;return L.resetInitSegment=function(g,E,a,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},L.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},L.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},L.canParse=function(g,E){return!1},L.appendFrame=function(g,E,a){},L.demux=function(g,E){this.cachedData&&(g=Object(T.appendUint8Array)(this.cachedData,g),this.cachedData=null);var a=p.getID3Data(g,0),e=a?a.length:0,s,u,n=this._audioTrack,i=this._id3Track,t=a?p.getTimeStamp(a):void 0,l=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(P.isFiniteNumber)(t))&&(this.basePTS=y(t,E,this.initPTS)),a&&a.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:a,type:x.MetadataSchema.audioId3}),u=this.basePTS;e<l;){if(this.canParse(g,e)){var d=this.appendFrame(n,g,e);d?(this.frameIndex++,u=d.sample.pts,e+=d.length,s=e):e=l}else p.canParse(g,e)?(a=p.getID3Data(g,e),i.samples.push({pts:u,dts:u,data:a,type:x.MetadataSchema.audioId3}),e+=a.length,s=e):e++;if(e===l&&s!==l){var r=Object(_.sliceUint8)(g,s);this.cachedData?this.cachedData=Object(T.appendUint8Array)(this.cachedData,r):this.cachedData=r}}return{audioTrack:n,videoTrack:Object(I.dummyTrack)(),id3Track:i,textTrack:Object(I.dummyTrack)()}},L.demuxSampleAes=function(g,E,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},L.flush=function(g){var E=this.cachedData;return E&&(this.cachedData=null,this.demux(E,0)),{audioTrack:this._audioTrack,videoTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},L.destroy=function(){},D}(),y=function(L,S,g){return Object(P.isFiniteNumber)(L)?L*90:S*9e4+(g||0)};R.default=A},"./src/demux/chunk-cache.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return P});var P=function(){function x(){this.chunks=[],this.dataLength=0}var I=x.prototype;return I.push=function(_){this.chunks.push(_),this.dataLength+=_.length},I.flush=function(){var _=this.chunks,A=this.dataLength,y;if(_.length)_.length===1?y=_[0]:y=p(_,A);else return new Uint8Array(0);return this.reset(),y},I.reset=function(){this.chunks.length=0,this.dataLength=0},x}();function p(x,I){for(var T=new Uint8Array(I),_=0,A=0;A<x.length;A++){var y=x[A];T.set(y,_),_+=y.length}return T}},"./src/demux/dummy-demuxed-track.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"dummyTrack",function(){return P});function P(p,x){return p===void 0&&(p=""),x===void 0&&(x=9e4),{type:p,id:-1,pid:-1,inputTimeScale:x,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/utils/logger.ts"),p=function(){function x(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var I=x.prototype;return I.loadWord=function(){var _=this.data,A=this.bytesAvailable,y=_.byteLength-A,D=new Uint8Array(4),L=Math.min(4,A);if(L===0)throw new Error("no bytes available");D.set(_.subarray(y,y+L)),this.word=new DataView(D.buffer).getUint32(0),this.bitsAvailable=L*8,this.bytesAvailable-=L},I.skipBits=function(_){var A;this.bitsAvailable>_?(this.word<<=_,this.bitsAvailable-=_):(_-=this.bitsAvailable,A=_>>3,_-=A>>3,this.bytesAvailable-=A,this.loadWord(),this.word<<=_,this.bitsAvailable-=_)},I.readBits=function(_){var A=Math.min(this.bitsAvailable,_),y=this.word>>>32-A;return _>32&&P.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=A,this.bitsAvailable>0?this.word<<=A:this.bytesAvailable>0&&this.loadWord(),A=_-A,A>0&&this.bitsAvailable?y<<A|this.readBits(A):y},I.skipLZ=function(){var _;for(_=0;_<this.bitsAvailable;++_)if((this.word&2147483648>>>_)!==0)return this.word<<=_,this.bitsAvailable-=_,_;return this.loadWord(),_+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var _=this.skipLZ();return this.readBits(_+1)-1},I.readEG=function(){var _=this.readUEG();return 1&_?1+_>>>1:-1*(_>>>1)},I.readBoolean=function(){return this.readBits(1)===1},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(_){for(var A=8,y=8,D,L=0;L<_;L++)y!==0&&(D=this.readEG(),y=(A+D+256)%256),A=y===0?A:y},I.readSPS=function(){var _=0,A=0,y=0,D=0,L,S,g,E=this.readUByte.bind(this),a=this.readBits.bind(this),e=this.readUEG.bind(this),s=this.readBoolean.bind(this),u=this.skipBits.bind(this),n=this.skipEG.bind(this),i=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);E();var l=E();if(a(5),u(3),E(),i(),l===100||l===110||l===122||l===244||l===44||l===83||l===86||l===118||l===128){var d=e();if(d===3&&u(1),i(),i(),u(1),s())for(S=d!==3?8:12,g=0;g<S;g++)s()&&(g<6?t(16):t(64))}i();var r=e();if(r===0)e();else if(r===1)for(u(1),n(),n(),L=e(),g=0;g<L;g++)n();i(),u(1);var c=e(),f=e(),o=a(1);o===0&&u(1),u(1),s()&&(_=e(),A=e(),y=e(),D=e());var v=[1,1];if(s()&&s()){var m=E();switch(m){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:{v=[E()<<8|E(),E()<<8|E()];break}}}return{width:Math.ceil((c+1)*16-_*2-A*2),height:(2-o)*(f+1)*16-(o?2:4)*(y+D),pixelRatio:v}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},x}();R.default=p},"./src/demux/id3.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"isHeader",function(){return P}),h.d(R,"isFooter",function(){return p}),h.d(R,"getID3Data",function(){return x}),h.d(R,"canParse",function(){return T}),h.d(R,"getTimeStamp",function(){return _}),h.d(R,"isTimeStampFrame",function(){return A}),h.d(R,"getID3Frames",function(){return D}),h.d(R,"decodeFrame",function(){return L}),h.d(R,"utf8ArrayToStr",function(){return e}),h.d(R,"testables",function(){return s});var P=function(t,l){return l+10<=t.length&&t[l]===73&&t[l+1]===68&&t[l+2]===51&&t[l+3]<255&&t[l+4]<255&&t[l+6]<128&&t[l+7]<128&&t[l+8]<128&&t[l+9]<128},p=function(t,l){return l+10<=t.length&&t[l]===51&&t[l+1]===68&&t[l+2]===73&&t[l+3]<255&&t[l+4]<255&&t[l+6]<128&&t[l+7]<128&&t[l+8]<128&&t[l+9]<128},x=function(t,l){for(var d=l,r=0;P(t,l);){r+=10;var c=I(t,l+6);r+=c,p(t,l+10)&&(r+=10),l+=r}if(r>0)return t.subarray(d,d+r)},I=function(t,l){var d=0;return d=(t[l]&127)<<21,d|=(t[l+1]&127)<<14,d|=(t[l+2]&127)<<7,d|=t[l+3]&127,d},T=function(t,l){return P(t,l)&&I(t,l+6)+10<=t.length-l},_=function(t){for(var l=D(t),d=0;d<l.length;d++){var r=l[d];if(A(r))return a(r)}},A=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},y=function(t){var l=String.fromCharCode(t[0],t[1],t[2],t[3]),d=I(t,4),r=10;return{type:l,size:d,data:t.subarray(r,r+d)}},D=function(t){for(var l=0,d=[];P(t,l);){var r=I(t,l+6);l+=10;for(var c=l+r;l+8<c;){var f=y(t.subarray(l)),o=L(f);o&&d.push(o),l+=f.size+10}p(t,l)&&(l+=10)}return d},L=function(t){return t.type==="PRIV"?S(t):t.type[0]==="W"?E(t):g(t)},S=function(t){if(!(t.size<2)){var l=e(t.data,!0),d=new Uint8Array(t.data.subarray(l.length+1));return{key:t.type,info:l,data:d.buffer}}},g=function(t){if(!(t.size<2)){if(t.type==="TXXX"){var l=1,d=e(t.data.subarray(l),!0);l+=d.length+1;var r=e(t.data.subarray(l));return{key:t.type,info:d,data:r}}var c=e(t.data.subarray(1));return{key:t.type,data:c}}},E=function(t){if(t.type==="WXXX"){if(t.size<2)return;var l=1,d=e(t.data.subarray(l),!0);l+=d.length+1;var r=e(t.data.subarray(l));return{key:t.type,info:d,data:r}}var c=e(t.data);return{key:t.type,data:c}},a=function(t){if(t.data.byteLength===8){var l=new Uint8Array(t.data),d=l[3]&1,r=(l[4]<<23)+(l[5]<<15)+(l[6]<<7)+l[7];return r/=45,d&&(r+=4772185884e-2),Math.round(r)}},e=function(t,l){l===void 0&&(l=!1);var d=n();if(d){var r=d.decode(t);if(l){var c=r.indexOf("\0");return c!==-1?r.substring(0,c):r}return r.replace(/\0/g,"")}for(var f=t.length,o,v,m,O="",b=0;b<f;){if(o=t[b++],o===0&&l)return O;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:O+=String.fromCharCode(o);break;case 12:case 13:v=t[b++],O+=String.fromCharCode((o&31)<<6|v&63);break;case 14:v=t[b++],m=t[b++],O+=String.fromCharCode((o&15)<<12|(v&63)<<6|(m&63)<<0);break;default:}}return O},s={decodeTextFrame:g},u;function n(){return!u&&typeof self.TextDecoder!="undefined"&&(u=new self.TextDecoder("utf-8")),u}},"./src/demux/mp3demuxer.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/demux/base-audio-demuxer.ts"),p=h("./src/demux/id3.ts"),x=h("./src/utils/logger.ts"),I=h("./src/demux/mpegaudio.ts");function T(y,D){y.prototype=Object.create(D.prototype),y.prototype.constructor=y,_(y,D)}function _(y,D){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(S,g){return S.__proto__=g,S},_(y,D)}var A=function(y){T(D,y);function D(){return y.apply(this,arguments)||this}var L=D.prototype;return L.resetInitSegment=function(g,E,a,e){y.prototype.resetInitSegment.call(this,g,E,a,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:E,duration:e,inputTimeScale:9e4,dropped:0}},D.probe=function(g){if(!g)return!1;for(var E=p.getID3Data(g,0)||[],a=E.length,e=g.length;a<e;a++)if(I.probe(g,a))return x.logger.log("MPEG Audio sync word found !"),!0;return!1},L.canParse=function(g,E){return I.canParse(g,E)},L.appendFrame=function(g,E,a){if(this.basePTS!==null)return I.appendFrame(g,E,a,this.basePTS,this.frameIndex)},D}(P.default);R.default=A},"./src/demux/mp4demuxer.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/polyfills/number.ts"),p=h("./src/types/demuxer.ts"),x=h("./src/utils/mp4-tools.ts"),I=h("./src/demux/dummy-demuxed-track.ts"),T=/\/emsg[-/]ID3/i,_=function(){function A(D,L){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=L}var y=A.prototype;return y.resetTimeStamp=function(){},y.resetInitSegment=function(L,S,g,E){var a=Object(x.parseInitSegment)(L),e=this.videoTrack=Object(I.dummyTrack)("video",1),s=this.audioTrack=Object(I.dummyTrack)("audio",1),u=this.txtTrack=Object(I.dummyTrack)("text",1);if(this.id3Track=Object(I.dummyTrack)("id3",1),this.timeOffset=0,a.video){var n=a.video,i=n.id,t=n.timescale,l=n.codec;e.id=i,e.timescale=u.timescale=t,e.codec=l}if(a.audio){var d=a.audio,r=d.id,c=d.timescale,f=d.codec;s.id=r,s.timescale=c,s.codec=f}u.id=x.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=s.duration=E},y.resetContiguity=function(){},A.probe=function(L){return L=L.length>16384?L.subarray(0,16384):L,Object(x.findBox)(L,["moof"]).length>0},y.demux=function(L,S){this.timeOffset=S;var g=L,E=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(x.appendUint8Array)(this.remainderData,L));var e=Object(x.segmentValidRange)(g);this.remainderData=e.remainder,E.samples=e.valid||new Uint8Array}else E.samples=g;var s=this.extractID3Track(E,S);return a.samples=Object(x.parseSamples)(S,E),{videoTrack:E,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},y.flush=function(){var L=this.timeOffset,S=this.videoTrack,g=this.txtTrack;S.samples=this.remainderData||new Uint8Array,this.remainderData=null;var E=this.extractID3Track(S,this.timeOffset);return g.samples=Object(x.parseSamples)(L,S),{videoTrack:S,audioTrack:Object(I.dummyTrack)(),id3Track:E,textTrack:Object(I.dummyTrack)()}},y.extractID3Track=function(L,S){var g=this.id3Track;if(L.samples.length){var E=Object(x.findBox)(L.samples,["emsg"]);E&&E.forEach(function(a){var e=Object(x.parseEmsg)(a);if(T.test(e.schemeIdUri)){var s=Object(P.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:S+e.presentationTimeDelta/e.timeScale,u=e.payload;g.samples.push({data:u,len:u.byteLength,dts:s,pts:s,type:p.MetadataSchema.emsg})}})}return g},y.demuxSampleAes=function(L,S,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},y.destroy=function(){},A}();R.default=_},"./src/demux/mpegaudio.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"appendFrame",function(){return _}),h.d(R,"parseHeader",function(){return A}),h.d(R,"isHeaderPattern",function(){return y}),h.d(R,"isHeader",function(){return D}),h.d(R,"canParse",function(){return L}),h.d(R,"probe",function(){return S});var P=null,p=[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],x=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],I=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],T=[0,1,1,4];function _(g,E,a,e,s){if(!(a+24>E.length)){var u=A(E,a);if(u&&a+u.frameLength<=E.length){var n=u.samplesPerFrame*9e4/u.sampleRate,i=e+s*n,t={unit:E.subarray(a,a+u.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=u.channelCount,g.samplerate=u.sampleRate,g.samples.push(t),{sample:t,length:u.frameLength,missing:0}}}}function A(g,E){var a=g[E+1]>>3&3,e=g[E+1]>>1&3,s=g[E+2]>>4&15,u=g[E+2]>>2&3;if(a!==1&&s!==0&&s!==15&&u!==3){var n=g[E+2]>>1&1,i=g[E+3]>>6,t=a===3?3-e:e===3?3:4,l=p[t*14+s-1]*1e3,d=a===3?0:a===2?1:2,r=x[d*3+u],c=i===3?1:2,f=I[a][e],o=T[e],v=f*8*o,m=Math.floor(f*l/r+n)*o;if(P===null){var O=navigator.userAgent||"",b=O.match(/Chrome\/(\d+)/i);P=b?parseInt(b[1]):0}var M=!!P&&P<=87;return M&&e===2&&l>=224e3&&i===0&&(g[E+3]=g[E+3]|128),{sampleRate:r,channelCount:c,frameLength:m,samplesPerFrame:v}}}function y(g,E){return g[E]===255&&(g[E+1]&224)===224&&(g[E+1]&6)!==0}function D(g,E){return E+1<g.length&&y(g,E)}function L(g,E){var a=4;return y(g,E)&&a<=g.length-E}function S(g,E){if(E+1<g.length&&y(g,E)){var a=4,e=A(g,E),s=a;e!=null&&e.frameLength&&(s=e.frameLength);var u=E+s;return u===g.length||D(g,u)}return!1}},"./src/demux/sample-aes.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/crypt/decrypter.ts"),p=h("./src/demux/tsdemuxer.ts"),x=function(){function I(_,A,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new P.default(_,A,{removePKCS7Padding:!1})}var T=I.prototype;return T.decryptBuffer=function(A,y){this.decrypter.decrypt(A,this.keyData.key.buffer,this.keyData.iv.buffer,y)},T.decryptAacSample=function(A,y,D,L){var S=A[y].unit;if(!(S.length<=16)){var g=S.subarray(16,S.length-S.length%16),E=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),a=this;this.decryptBuffer(E,function(e){var s=new Uint8Array(e);S.set(s,16),L||a.decryptAacSamples(A,y+1,D)})}},T.decryptAacSamples=function(A,y,D){for(;;y++){if(y>=A.length){D();return}if(!(A[y].unit.length<32)){var L=this.decrypter.isSync();if(this.decryptAacSample(A,y,D,L),!L)return}}},T.getAvcEncryptedData=function(A){for(var y=Math.floor((A.length-48)/160)*16+16,D=new Int8Array(y),L=0,S=32;S<A.length-16;S+=160,L+=16)D.set(A.subarray(S,S+16),L);return D},T.getAvcDecryptedUnit=function(A,y){for(var D=new Uint8Array(y),L=0,S=32;S<A.length-16;S+=160,L+=16)A.set(D.subarray(L,L+16),S);return A},T.decryptAvcSample=function(A,y,D,L,S,g){var E=Object(p.discardEPB)(S.data),a=this.getAvcEncryptedData(E),e=this;this.decryptBuffer(a.buffer,function(s){S.data=e.getAvcDecryptedUnit(E,s),g||e.decryptAvcSamples(A,y,D+1,L)})},T.decryptAvcSamples=function(A,y,D,L){if(A instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,D=0){if(y>=A.length){L();return}for(var S=A[y].units;!(D>=S.length);D++){var g=S[D];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var E=this.decrypter.isSync();if(this.decryptAvcSample(A,y,D,L,g,E),!E)return}}}},I}();R.default=x},"./src/demux/transmuxer-interface.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return S});var P=h("./node_modules/webworkify-webpack/index.js"),p=h.n(P),x=h("./src/events.ts"),I=h("./src/demux/transmuxer.ts"),T=h("./src/utils/logger.ts"),_=h("./src/errors.ts"),A=h("./src/utils/mediasource-helper.ts"),y=h("./node_modules/eventemitter3/index.js"),D=h.n(y),L=Object(A.getMediaSource)()||{isTypeSupported:function(){return!1}},S=function(){function g(a,e,s,u){var n=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=a,this.id=e,this.onTransmuxComplete=s,this.onFlush=u;var i=a.config,t=function(f,o){o=o||{},o.frag=n.frag,o.id=n.id,a.trigger(f,o)};this.observer=new y.EventEmitter,this.observer.on(x.Events.FRAG_DECRYPTED,t),this.observer.on(x.Events.ERROR,t);var l={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){T.logger.log("demuxing in webworker");var r;try{r=this.worker=P("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),r.addEventListener("message",this.onwmsg),r.onerror=function(c){a.trigger(x.Events.ERROR,{type:_.ErrorTypes.OTHER_ERROR,details:_.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},r.postMessage({cmd:"init",typeSupported:l,vendor:d,id:e,config:JSON.stringify(i)})}catch(c){T.logger.warn("Error in worker:",c),T.logger.error("Error while initializing DemuxerWorker, fallback to inline"),r&&self.URL.revokeObjectURL(r.objectURL),this.transmuxer=new I.default(this.observer,l,i,d,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,l,i,d,e)}var E=g.prototype;return E.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var u=this.observer;u&&u.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},E.push=function(e,s,u,n,i,t,l,d,r,c){var f,o,v=this;r.transmuxing.start=self.performance.now();var m=this.transmuxer,O=this.worker,b=t?t.start:i.start,M=i.decryptdata,F=this.frag,w=!(F&&i.cc===F.cc),C=!(F&&r.level===F.level),U=F?r.sn-F.sn:-1,B=this.part?r.part-this.part.index:-1,N=U===0&&r.id>1&&r.id===(F==null?void 0:F.stats.chunkCount),k=!C&&(U===1||U===0&&(B===1||N&&B<=0)),j=self.performance.now();(C||U||i.stats.parsing.start===0)&&(i.stats.parsing.start=j),t&&(B||!k)&&(t.stats.parsing.start=j);var H=!(F&&((f=i.initSegment)===null||f===void 0?void 0:f.url)===((o=F.initSegment)===null||o===void 0?void 0:o.url)),V=new I.TransmuxState(w,k,d,C,b,H);if(!k||w||H){T.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+r.sn+" p: "+r.part+" level: "+r.level+" id: "+r.id+`
|
|
13
13
|
discontinuity: `+w+`
|
|
14
14
|
trackSwitch: `+C+`
|
|
15
15
|
contiguous: `+k+`
|
|
16
16
|
accurateTimeOffset: `+d+`
|
|
17
17
|
timeOffset: `+b+`
|
|
18
|
-
initSegmentChange: `+H);var Y=new I.TransmuxConfig(u,n,s,l,c);this.configureTransmuxer(Y)}if(this.frag=i,this.part=t,O)O.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:r,state:V},e instanceof ArrayBuffer?[e]:[]);else if(m){var Q=m.push(e,M,r,V);Object(I.isPromise)(Q)?Q.then(function(J){v.handleTransmuxComplete(J)}):this.handleTransmuxComplete(Q)}},E.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var u=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(u){var i=u.flush(e);Object(I.isPromise)(i)?i.then(function(t){s.handleFlushResult(t,e)}):this.handleFlushResult(i,e)}},E.handleFlushResult=function(e,s){var u=this;e.forEach(function(n){u.handleTransmuxComplete(n)}),this.onFlush(s)},E.onWorkerMessage=function(e){var s=e.data,u=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":x.logger[s.data.logType]&&x.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,u.trigger(s.event,s.data);break}}},E.configureTransmuxer=function(e){var s=this.worker,u=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):u&&u.configure(e)},E.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return L});var R=h("./src/demux/transmuxer.ts"),p=h("./src/events.ts"),S=h("./src/utils/logger.ts"),I=h("./node_modules/eventemitter3/index.js"),x=h.n(I);function L(T){var g=new I.EventEmitter,E=function(s,u){T.postMessage({event:s,data:u})};g.on(p.Events.FRAG_DECRYPTED,E),g.on(p.Events.ERROR,E);var a=function(){var s=function(i){var t=function(d){E("workerLog",{logType:i,message:d})};S.logger[i]=t};for(var u in S.logger)s(u)};T.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var u=JSON.parse(s.config);T.transmuxer=new R.default(g,s.typeSupported,u,s.vendor,s.id),Object(S.enableLogs)(u.debug),a(),E("init",null);break}case"configure":{T.transmuxer.configure(s.config);break}case"demux":{var n=T.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(R.isPromise)(n)?n.then(function(l){A(T,l)}):A(T,n);break}case"flush":{var i=s.chunkMeta,t=T.transmuxer.flush(i);Object(R.isPromise)(t)?t.then(function(l){D(T,l,i)}):D(T,t,i);break}default:break}})}function A(T,g){if(_(g.remuxResult))return!1;var E=[],a=g.remuxResult,e=a.audio,s=a.video;return e&&y(E,e),s&&y(E,s),T.postMessage({event:"transmuxComplete",data:g},E),!0}function y(T,g){g.data1&&T.push(g.data1.buffer),g.data2&&T.push(g.data2.buffer)}function D(T,g,E){var a=g.reduce(function(e,s){return A(T,s)||e},!1);a||T.postMessage({event:"transmuxComplete",data:g[0]}),T.postMessage({event:"flush",data:E})}function _(T){return!T.audio&&!T.video&&!T.text&&!T.id3&&!T.initSegment}},"./src/demux/transmuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return E}),h.d(P,"isPromise",function(){return s}),h.d(P,"TransmuxConfig",function(){return u}),h.d(P,"TransmuxState",function(){return n});var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/crypt/decrypter.ts"),I=h("./src/demux/aacdemuxer.ts"),x=h("./src/demux/mp4demuxer.ts"),L=h("./src/demux/tsdemuxer.ts"),A=h("./src/demux/mp3demuxer.ts"),y=h("./src/remux/mp4-remuxer.ts"),D=h("./src/remux/passthrough-remuxer.ts"),_=h("./src/utils/logger.ts"),T;try{T=self.performance.now.bind(self.performance)}catch{_.logger.debug("Unable to use Performance API on this environment"),T=self.Date.now}var g=[{demux:L.default,remux:y.default},{demux:x.default,remux:D.default},{demux:I.default,remux:y.default},{demux:A.default,remux:y.default}],E=function(){function i(l,d,r,c,f){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=l,this.typeSupported=d,this.config=r,this.vendor=c,this.id=f}var t=i.prototype;return t.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},t.push=function(d,r,c,f){var o=this,v=c.transmuxing;v.executeStart=T();var m=new Uint8Array(d),O=this.config,b=this.currentTransmuxState,M=this.transmuxConfig;f&&(this.currentTransmuxState=f);var F=f||b,w=F.contiguous,C=F.discontinuity,U=F.trackSwitch,B=F.accurateTimeOffset,N=F.timeOffset,k=F.initSegmentChange,j=M.audioCodec,H=M.videoCodec,V=M.defaultInitPts,Y=M.duration,Q=M.initSegmentData;(C||U||k)&&this.resetInitSegment(Q,j,H,Y),(C||k)&&this.resetInitialTimestamp(V),w||this.resetContiguity();var J=a(m,r);if(J&&J.method==="AES-128"){var z=this.getDecrypter();if(O.enableSoftwareAES){var q=z.softwareDecrypt(m,J.key.buffer,J.iv.buffer);if(!q)return v.executeEnd=T(),e(c);m=new Uint8Array(q)}else return this.decryptionPromise=z.webCryptoDecrypt(m,J.key.buffer,J.iv.buffer).then(function(le){var ne=o.push(le,null,c);return o.decryptionPromise=null,ne}),this.decryptionPromise}this.needsProbing(m,C,U)&&this.configureTransmuxer(m,M);var re=this.transmux(m,J,N,B,c),X=this.currentTransmuxState;return X.contiguous=!0,X.discontinuity=!1,X.trackSwitch=!1,v.executeEnd=T(),re},t.flush=function(d){var r=this,c=d.transmuxing;c.executeStart=T();var f=this.decrypter,o=this.currentTransmuxState,v=this.decryptionPromise;if(v)return v.then(function(){return r.flush(d)});var m=[],O=o.timeOffset;if(f){var b=f.flush();b&&m.push(this.push(b,null,d))}var M=this.demuxer,F=this.remuxer;if(!M||!F)return this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),c.executeEnd=T(),[e(d)];var w=M.flush(O);return s(w)?w.then(function(C){return r.flushRemux(m,C,d),m}):(this.flushRemux(m,w,d),m)},t.flushRemux=function(d,r,c){var f=r.audioTrack,o=r.videoTrack,v=r.id3Track,m=r.textTrack,O=this.currentTransmuxState,b=O.accurateTimeOffset,M=O.timeOffset;_.logger.log("[transmuxer.ts]: Flushed fragment "+c.sn+(c.part>-1?" p: "+c.part:"")+" of level "+c.level);var F=this.remuxer.remux(f,o,v,m,M,b,!0,this.id);d.push({remuxResult:F,chunkMeta:c}),c.transmuxing.executeEnd=T()},t.resetInitialTimestamp=function(d){var r=this.demuxer,c=this.remuxer;!r||!c||(r.resetTimeStamp(d),c.resetTimeStamp(d))},t.resetContiguity=function(){var d=this.demuxer,r=this.remuxer;!d||!r||(d.resetContiguity(),r.resetNextTimestamp())},t.resetInitSegment=function(d,r,c,f){var o=this.demuxer,v=this.remuxer;!o||!v||(o.resetInitSegment(d,r,c,f),v.resetInitSegment(d,r,c))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(d,r,c,f,o){var v;return r&&r.method==="SAMPLE-AES"?v=this.transmuxSampleAes(d,r,c,f,o):v=this.transmuxUnencrypted(d,c,f,o),v},t.transmuxUnencrypted=function(d,r,c,f){var o=this.demuxer.demux(d,r,!1,!this.config.progressive),v=o.audioTrack,m=o.videoTrack,O=o.id3Track,b=o.textTrack,M=this.remuxer.remux(v,m,O,b,r,c,!1,this.id);return{remuxResult:M,chunkMeta:f}},t.transmuxSampleAes=function(d,r,c,f,o){var v=this;return this.demuxer.demuxSampleAes(d,r,c).then(function(m){var O=v.remuxer.remux(m.audioTrack,m.videoTrack,m.id3Track,m.textTrack,c,f,!1,v.id);return{remuxResult:O,chunkMeta:o}})},t.configureTransmuxer=function(d,r){for(var c=this.config,f=this.observer,o=this.typeSupported,v=this.vendor,m=r.audioCodec,O=r.defaultInitPts,b=r.duration,M=r.initSegmentData,F=r.videoCodec,w,C=0,U=g.length;C<U;C++)if(g[C].demux.probe(d)){w=g[C];break}w||(_.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:x.default,remux:D.default});var B=this.demuxer,N=this.remuxer,k=w.remux,j=w.demux;(!N||!(N instanceof k))&&(this.remuxer=new k(f,c,o,v)),(!B||!(B instanceof j))&&(this.demuxer=new j(f,c,o),this.probe=j.probe),this.resetInitSegment(M,m,F,b),this.resetInitialTimestamp(O)},t.needsProbing=function(d,r,c){return!this.demuxer||!this.remuxer||r||c},t.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new S.default(this.observer,this.config)),d},i}();function a(i,t){var l=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(l=t),l}var e=function(t){return{remuxResult:{},chunkMeta:t}};function s(i){return"then"in i&&i.then instanceof Function}var u=function(t,l,d,r,c){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=l,this.initSegmentData=d,this.duration=r,this.defaultInitPts=c},n=function(t,l,d,r,c,f){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=l,this.accurateTimeOffset=d,this.trackSwitch=r,this.timeOffset=c,this.initSegmentChange=f}},"./src/demux/tsdemuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"discardEPB",function(){return u});var R=h("./src/demux/adts.ts"),p=h("./src/demux/mpegaudio.ts"),S=h("./src/demux/exp-golomb.ts"),I=h("./src/demux/sample-aes.ts"),x=h("./src/events.ts"),L=h("./src/utils/mp4-tools.ts"),A=h("./src/utils/logger.ts"),y=h("./src/errors.ts"),D=h("./src/types/demuxer.ts");function _(){return _=Object.assign?Object.assign.bind():function(n){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(n[l]=t[l])}return n},_.apply(this,arguments)}var T=function(){function n(t,l,d){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=l,this.typeSupported=d}n.probe=function(l){return l[0]===71&&l[188]===71},n.createTrack=function(l,d){return{container:l==="video"||l==="audio"?"video/mp2t":void 0,type:l,id:L.RemuxerTrackIdConfig[l],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:l==="audio"?d:void 0}};var i=n.prototype;return i.resetInitSegment=function(l,d,r,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video"),this._audioTrack=n.createTrack("audio",c),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=d,this.videoCodec=r,this._duration=c},i.resetTimeStamp=function(){},i.resetContiguity=function(){var l=this._audioTrack,d=this._avcTrack,r=this._id3Track;l&&(l.pesData=null),d&&(d.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null},i.demux=function(l,d,r,c){r===void 0&&(r=!1),c===void 0&&(c=!1),r||(this.sampleAes=null);var f,o=this._avcTrack,v=this._audioTrack,m=this._id3Track,O=this._txtTrack,b=o.pid,M=o.pesData,F=v.pid,w=m.pid,C=v.pesData,U=m.pesData,B=null,N=this.pmtParsed,k=this._pmtId,j=l.length;if(this.remainderData&&(l=Object(L.appendUint8Array)(this.remainderData,l),j=l.length,this.remainderData=null),j<188&&!c)return this.remainderData=l,{audioTrack:v,videoTrack:o,id3Track:m,textTrack:O};j-=j%188,j<l.byteLength&&!c&&(this.remainderData=new Uint8Array(l.buffer,j,l.buffer.byteLength-j));for(var H=0,V=0;V<j;V+=188)if(l[V]===71){var Y=!!(l[V+1]&64),Q=((l[V+1]&31)<<8)+l[V+2],J=(l[V+3]&48)>>4,z=void 0;if(J>1){if(z=V+5+l[V+4],z===V+188)continue}else z=V+4;switch(Q){case b:Y&&(M&&(f=e(M))&&this.parseAVCPES(o,O,f,!1),M={data:[],size:0}),M&&(M.data.push(l.subarray(z,V+188)),M.size+=V+188-z);break;case F:if(Y){if(C&&(f=e(C)))switch(v.segmentCodec){case"aac":this.parseAACPES(v,f);break;case"mp3":this.parseMPEGPES(v,f);break}C={data:[],size:0}}C&&(C.data.push(l.subarray(z,V+188)),C.size+=V+188-z);break;case w:Y&&(U&&(f=e(U))&&this.parseID3PES(m,f),U={data:[],size:0}),U&&(U.data.push(l.subarray(z,V+188)),U.size+=V+188-z);break;case 0:Y&&(z+=l[z]+1),k=this._pmtId=E(l,z);break;case k:{Y&&(z+=l[z]+1);var q=a(l,z,this.typeSupported,r);b=q.avc,b>0&&(o.pid=b),F=q.audio,F>0&&(v.pid=F,v.segmentCodec=q.segmentCodec),w=q.id3,w>0&&(m.pid=w),B!==null&&!N&&(A.logger.log("unknown PID '"+B+"' in TS found"),B=null),N=this.pmtParsed=!0;break}case 17:case 8191:break;default:B=Q;break}}else H++;H>0&&this.observer.emit(x.Events.ERROR,x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+H+" TS packet/s that do not start with 0x47"}),o.pesData=M,v.pesData=C,m.pesData=U;var re={audioTrack:v,videoTrack:o,id3Track:m,textTrack:O};return c&&this.extractRemainingSamples(re),re},i.flush=function(){var l=this.remainderData;this.remainderData=null;var d;return l?d=this.demux(l,-1,!1,!0):d={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},i.extractRemainingSamples=function(l){var d=l.audioTrack,r=l.videoTrack,c=l.id3Track,f=l.textTrack,o=r.pesData,v=d.pesData,m=c.pesData,O;if(o&&(O=e(o))?(this.parseAVCPES(r,f,O,!0),r.pesData=null):r.pesData=o,v&&(O=e(v))){switch(d.segmentCodec){case"aac":this.parseAACPES(d,O);break;case"mp3":this.parseMPEGPES(d,O);break}d.pesData=null}else v!=null&&v.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=v;m&&(O=e(m))?(this.parseID3PES(c,O),c.pesData=null):c.pesData=m},i.demuxSampleAes=function(l,d,r){var c=this.demux(l,r,!0,!this.config.progressive),f=this.sampleAes=new I.default(this.observer,this.config,d);return this.decrypt(c,f)},i.decrypt=function(l,d){return new Promise(function(r){var c=l.audioTrack,f=l.videoTrack;c.samples&&c.segmentCodec==="aac"?d.decryptAacSamples(c.samples,0,function(){f.samples?d.decryptAvcSamples(f.samples,0,0,function(){r(l)}):r(l)}):f.samples&&d.decryptAvcSamples(f.samples,0,0,function(){r(l)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(l,d,r,c){var f=this,o=this.parseAVCNALu(l,r.data),v=!1,m=this.avcSample,O,b=!1;r.data=null,m&&o.length&&!l.audFound&&(s(m,l),m=this.avcSample=g(!1,r.pts,r.dts,"")),o.forEach(function(M){switch(M.type){case 1:{O=!0,m||(m=f.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="NDR "),m.frame=!0;var F=M.data;if(b&&F.length>4){var w=new S.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(m.key=!0)}break}case 5:O=!0,m||(m=f.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{O=!0,v&&m&&(m.debug+="SEI "),Object(L.parseSEIMessageFromNALu)(u(M.data),r.pts,d.samples);break}case 7:if(O=!0,b=!0,v&&m&&(m.debug+="SPS "),!l.sps){var C=new S.default(M.data),U=C.readSPS();l.width=U.width,l.height=U.height,l.pixelRatio=U.pixelRatio,l.sps=[M.data],l.duration=f._duration;for(var B=M.data.subarray(1,4),N="avc1.",k=0;k<3;k++){var j=B[k].toString(16);j.length<2&&(j="0"+j),N+=j}l.codec=N}break;case 8:O=!0,v&&m&&(m.debug+="PPS "),l.pps||(l.pps=[M.data]);break;case 9:O=!1,l.audFound=!0,m&&s(m,l),m=f.avcSample=g(!1,r.pts,r.dts,v?"AUD ":"");break;case 12:O=!0;break;default:O=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&O){var H=m.units;H.push(M)}}),c&&m&&(s(m,l),this.avcSample=null)},i.getLastNalUnit=function(l){var d,r=this.avcSample,c;if((!r||r.units.length===0)&&(r=l[l.length-1]),(d=r)!==null&&d!==void 0&&d.units){var f=r.units;c=f[f.length-1]}return c},i.parseAVCNALu=function(l,d){var r=d.byteLength,c=l.naluState||0,f=c,o=[],v=0,m,O,b,M=-1,F=0;for(c===-1&&(M=0,F=d[0]&31,c=0,v=1);v<r;){if(m=d[v++],!c){c=m?0:1;continue}if(c===1){c=m?0:2;continue}if(!m)c=3;else if(m===1){if(M>=0){var w={data:d.subarray(M,v-c-1),type:F};o.push(w)}else{var C=this.getLastNalUnit(l.samples);if(C&&(f&&v<=4-f&&C.state&&(C.data=C.data.subarray(0,C.data.byteLength-f)),O=v-c-1,O>0)){var U=new Uint8Array(C.data.byteLength+O);U.set(C.data,0),U.set(d.subarray(0,O),C.data.byteLength),C.data=U,C.state=0}}v<r?(b=d[v]&31,M=v,F=b,c=0):c=-1}else c=0}if(M>=0&&c>=0){var B={data:d.subarray(M,r),type:F,state:c};o.push(B)}if(o.length===0){var N=this.getLastNalUnit(l.samples);if(N){var k=new Uint8Array(N.data.byteLength+d.byteLength);k.set(N.data,0),k.set(d,N.data.byteLength),N.data=k}}return l.naluState=c,o},i.parseAACPES=function(l,d){var r=0,c=this.aacOverFlow,f=d.data;if(c){this.aacOverFlow=null;var o=c.missing,v=c.sample.unit.byteLength;if(o===-1){var m=new Uint8Array(v+f.byteLength);m.set(c.sample.unit,0),m.set(f,v),f=m}else{var O=v-o;c.sample.unit.set(f.subarray(0,o),O),l.samples.push(c.sample),r=c.missing}}var b,M;for(b=r,M=f.length;b<M-1&&!R.isHeader(f,b);b++);if(b!==r){var F,w;if(b<M-1?(F="AAC PES did not start with ADTS header,offset:"+b,w=!1):(F="no ADTS header found in AAC PES",w=!0),A.logger.warn("parsing error:"+F),this.observer.emit(x.Events.ERROR,x.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:w,reason:F}),w)return}R.initTrackConfig(l,this.observer,f,b,this.audioCodec);var C;if(d.pts!==void 0)C=d.pts;else if(c){var U=R.getFrameDuration(l.samplerate);C=c.sample.pts+U}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var B=0,N;b<M;)if(N=R.appendFrame(l,f,b,C,B),b+=N.length,N.missing){this.aacOverFlow=N;break}else for(B++;b<M-1&&!R.isHeader(f,b);b++);},i.parseMPEGPES=function(l,d){var r=d.data,c=r.length,f=0,o=0,v=d.pts;if(v===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<c;)if(p.isHeader(r,o)){var m=p.appendFrame(l,r,o,v,f);if(m)o+=m.length,f++;else break}else o++},i.parseID3PES=function(l,d){if(d.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=_({},d,{type:this._avcTrack?D.MetadataSchema.emsg:D.MetadataSchema.audioId3});l.samples.push(r)},n}();function g(n,i,t,l){return{key:n,frame:!1,pts:i,dts:t,units:[],debug:l,length:0}}function E(n,i){return(n[i+10]&31)<<8|n[i+11]}function a(n,i,t,l){var d={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(n[i+1]&15)<<8|n[i+2],c=i+3+r-4,f=(n[i+10]&15)<<8|n[i+11];for(i+=12+f;i<c;){var o=(n[i+1]&31)<<8|n[i+2];switch(n[i]){case 207:if(!l){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=o);break;case 21:d.id3===-1&&(d.id3=o);break;case 219:if(!l){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=o);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):d.audio===-1&&(d.audio=o,d.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((n[i+3]&15)<<8|n[i+4])+5}return d}function e(n){var i=0,t,l,d,r,c,f=n.data;if(!n||n.size===0)return null;for(;f[0].length<19&&f.length>1;){var o=new Uint8Array(f[0].length+f[1].length);o.set(f[0]),o.set(f[1],f[0].length),f[0]=o,f.splice(1,1)}t=f[0];var v=(t[0]<<16)+(t[1]<<8)+t[2];if(v===1){if(l=(t[4]<<8)+t[5],l&&l>n.size-6)return null;var m=t[7];m&192&&(r=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,m&64?(c=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,r-c>60*9e4&&(A.logger.warn(Math.round((r-c)/9e4)+"s delta between PTS and DTS, align them"),r=c)):c=r),d=t[8];var O=d+9;if(n.size<=O)return null;n.size-=O;for(var b=new Uint8Array(n.size),M=0,F=f.length;M<F;M++){t=f[M];var w=t.byteLength;if(O)if(O>w){O-=w;continue}else t=t.subarray(O),w-=O,O=0;b.set(t,i),i+=w}return l&&(l-=d+3),{data:b,pts:r,dts:c,len:l}}return null}function s(n,i){if(n.units.length&&n.frame){if(n.pts===void 0){var t=i.samples,l=t.length;if(l){var d=t[l-1];n.pts=d.pts,n.dts=d.dts}else{i.dropped++;return}}i.samples.push(n)}n.debug.length&&A.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function u(n){for(var i=n.byteLength,t=[],l=1;l<i-2;)n[l]===0&&n[l+1]===0&&n[l+2]===3?(t.push(l+2),l+=2):l++;if(t.length===0)return n;var d=i-t.length,r=new Uint8Array(d),c=0;for(l=0;l<d;c++,l++)c===t[0]&&(c++,t.shift()),r[l]=n[c];return r}P.default=T},"./src/errors.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"ErrorTypes",function(){return R}),h.d(P,"ErrorDetails",function(){return p});var R;(function(S){S.NETWORK_ERROR="networkError",S.MEDIA_ERROR="mediaError",S.KEY_SYSTEM_ERROR="keySystemError",S.MUX_ERROR="muxError",S.OTHER_ERROR="otherError"})(R||(R={}));var p;(function(S){S.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",S.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",S.KEY_SYSTEM_NO_SESSION="keySystemNoSession",S.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",S.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",S.MANIFEST_LOAD_ERROR="manifestLoadError",S.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",S.MANIFEST_PARSING_ERROR="manifestParsingError",S.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",S.LEVEL_EMPTY_ERROR="levelEmptyError",S.LEVEL_LOAD_ERROR="levelLoadError",S.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",S.LEVEL_SWITCH_ERROR="levelSwitchError",S.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",S.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",S.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",S.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",S.FRAG_LOAD_ERROR="fragLoadError",S.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",S.FRAG_DECRYPT_ERROR="fragDecryptError",S.FRAG_PARSING_ERROR="fragParsingError",S.REMUX_ALLOC_ERROR="remuxAllocError",S.KEY_LOAD_ERROR="keyLoadError",S.KEY_LOAD_TIMEOUT="keyLoadTimeOut",S.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",S.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",S.BUFFER_APPEND_ERROR="bufferAppendError",S.BUFFER_APPENDING_ERROR="bufferAppendingError",S.BUFFER_STALLED_ERROR="bufferStalledError",S.BUFFER_FULL_ERROR="bufferFullError",S.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",S.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",S.INTERNAL_EXCEPTION="internalException",S.INTERNAL_ABORTED="aborted",S.UNKNOWN="unknown"})(p||(p={}))},"./src/events.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"Events",function(){return R});var R;(function(p){p.MEDIA_ATTACHING="hlsMediaAttaching",p.MEDIA_ATTACHED="hlsMediaAttached",p.MEDIA_DETACHING="hlsMediaDetaching",p.MEDIA_DETACHED="hlsMediaDetached",p.BUFFER_RESET="hlsBufferReset",p.BUFFER_CODECS="hlsBufferCodecs",p.BUFFER_CREATED="hlsBufferCreated",p.BUFFER_APPENDING="hlsBufferAppending",p.BUFFER_APPENDED="hlsBufferAppended",p.BUFFER_EOS="hlsBufferEos",p.BUFFER_FLUSHING="hlsBufferFlushing",p.BUFFER_FLUSHED="hlsBufferFlushed",p.MANIFEST_LOADING="hlsManifestLoading",p.MANIFEST_LOADED="hlsManifestLoaded",p.MANIFEST_PARSED="hlsManifestParsed",p.LEVEL_SWITCHING="hlsLevelSwitching",p.LEVEL_SWITCHED="hlsLevelSwitched",p.LEVEL_LOADING="hlsLevelLoading",p.LEVEL_LOADED="hlsLevelLoaded",p.LEVEL_UPDATED="hlsLevelUpdated",p.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",p.LEVELS_UPDATED="hlsLevelsUpdated",p.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",p.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",p.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",p.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",p.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",p.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",p.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",p.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",p.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",p.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",p.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",p.CUES_PARSED="hlsCuesParsed",p.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",p.INIT_PTS_FOUND="hlsInitPtsFound",p.FRAG_LOADING="hlsFragLoading",p.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",p.FRAG_LOADED="hlsFragLoaded",p.FRAG_DECRYPTED="hlsFragDecrypted",p.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",p.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",p.FRAG_PARSING_METADATA="hlsFragParsingMetadata",p.FRAG_PARSED="hlsFragParsed",p.FRAG_BUFFERED="hlsFragBuffered",p.FRAG_CHANGED="hlsFragChanged",p.FPS_DROP="hlsFpsDrop",p.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",p.ERROR="hlsError",p.DESTROYING="hlsDestroying",p.KEY_LOADING="hlsKeyLoading",p.KEY_LOADED="hlsKeyLoaded",p.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",p.BACK_BUFFER_REACHED="hlsBackBufferReached"})(R||(R={}))},"./src/hls.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return i});var R=h("./node_modules/url-toolkit/src/url-toolkit.js"),p=h.n(R),S=h("./src/loader/playlist-loader.ts"),I=h("./src/loader/key-loader.ts"),x=h("./src/controller/id3-track-controller.ts"),L=h("./src/controller/latency-controller.ts"),A=h("./src/controller/level-controller.ts"),y=h("./src/controller/fragment-tracker.ts"),D=h("./src/controller/stream-controller.ts"),_=h("./src/is-supported.ts"),T=h("./src/utils/logger.ts"),g=h("./src/config.ts"),E=h("./node_modules/eventemitter3/index.js"),a=h.n(E),e=h("./src/events.ts"),s=h("./src/errors.ts");function u(t,l){for(var d=0;d<l.length;d++){var r=l[d];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,l,d){return l&&u(t.prototype,l),d&&u(t,d),Object.defineProperty(t,"prototype",{writable:!1}),t}var i=function(){t.isSupported=function(){return Object(_.isSupported)()};function t(d){d===void 0&&(d={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new E.EventEmitter,this._autoLevelCapping=void 0,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;var r=this.config=Object(g.mergeConfig)(t.DefaultConfig,d);this.userConfig=d,Object(T.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(g.enableStreamingMode)(r);var c=r.abrController,f=r.bufferController,o=r.capLevelController,v=r.fpsController,m=this.abrController=new c(this),O=this.bufferController=new f(this),b=this.capLevelController=new o(this),M=new v(this),F=new S.default(this),w=new I.default(this),C=new x.default(this),U=this.levelController=new A.default(this),B=new y.FragmentTracker(this),N=this.streamController=new D.default(this,B);b.setStreamController(N),M.setStreamController(N);var k=[F,w,U,N];this.networkControllers=k;var j=[m,O,b,M,C,B];this.audioTrackController=this.createController(r.audioTrackController,null,k),this.createController(r.audioStreamController,B,k),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,k),this.createController(r.subtitleStreamController,B,k),this.createController(r.timelineController,null,j),this.emeController=this.createController(r.emeController,null,j),this.cmcdController=this.createController(r.cmcdController,null,j),this.latencyController=this.createController(L.default,null,j),this.coreComponents=j}var l=t.prototype;return l.createController=function(r,c,f){if(r){var o=c?new r(this,c):new r(this);return f&&f.push(o),o}return null},l.on=function(r,c,f){f===void 0&&(f=this),this._emitter.on(r,c,f)},l.once=function(r,c,f){f===void 0&&(f=this),this._emitter.once(r,c,f)},l.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},l.off=function(r,c,f,o){f===void 0&&(f=this),this._emitter.off(r,c,f,o)},l.listeners=function(r){return this._emitter.listeners(r)},l.emit=function(r,c,f){return this._emitter.emit(r,c,f)},l.trigger=function(r,c){if(this.config.debug)return this.emit(r,r,c);try{return this.emit(r,r,c)}catch(f){T.logger.error("An internal error happened while handling event "+r+'. Error message: "'+f.message+'". Here is a stacktrace:',f),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:f})}return!1},l.listenerCount=function(r){return this._emitter.listenerCount(r)},l.destroy=function(){T.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},l.attachMedia=function(r){T.logger.log("attachMedia"),this._media=r,this.trigger(e.Events.MEDIA_ATTACHING,{media:r})},l.detachMedia=function(){T.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},l.loadSource=function(r){this.stopLoad();var c=this.media,f=this.url,o=this.url=R.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});T.logger.log("loadSource:"+o),c&&f&&f!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(e.Events.MANIFEST_LOADING,{url:r})},l.startLoad=function(r){r===void 0&&(r=-1),T.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(c){c.startLoad(r)})},l.stopLoad=function(){T.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},l.swapAudioCodec=function(){T.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},l.recoverMediaError=function(){T.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},l.removeLevel=function(r,c){c===void 0&&(c=0),this.levelController.removeLevel(r,c)},n(t,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){T.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){T.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){T.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){T.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){T.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var c=!!r;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(T.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,c=this.config.minAutoBitrate;if(!r)return 0;for(var f=r.length,o=0;o<f;o++)if(r[o].maxBitrate>=c)return o;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,c=this.autoLevelCapping,f;return c===-1&&r&&r.length?f=r.length-1:f=c,f}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var c=this.audioTrackController;c&&(c.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var c=this.subtitleTrackController;c&&(c.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:g.hlsDefaultConfig},set:function(r){t.defaultConfig=r}}]),t}();i.defaultConfig=void 0},"./src/is-supported.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isSupported",function(){return S}),h.d(P,"changeTypeSupported",function(){return I});var R=h("./src/utils/mediasource-helper.ts");function p(){return self.SourceBuffer||self.WebKitSourceBuffer}function S(){var x=Object(R.getMediaSource)();if(!x)return!1;var L=p(),A=x&&typeof x.isTypeSupported=="function"&&x.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!L||L.prototype&&typeof L.prototype.appendBuffer=="function"&&typeof L.prototype.remove=="function";return!!A&&!!y}function I(){var x,L=p();return typeof(L==null||(x=L.prototype)===null||x===void 0?void 0:x.changeType)=="function"}},"./src/loader/date-range.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"DateRangeAttribute",function(){return A}),h.d(P,"DateRange",function(){return y});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/attr-list.ts"),S=h("./src/utils/logger.ts");function I(){return I=Object.assign?Object.assign.bind():function(D){for(var _=1;_<arguments.length;_++){var T=arguments[_];for(var g in T)Object.prototype.hasOwnProperty.call(T,g)&&(D[g]=T[g])}return D},I.apply(this,arguments)}function x(D,_){for(var T=0;T<_.length;T++){var g=_[T];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(D,g.key,g)}}function L(D,_,T){return _&&x(D.prototype,_),T&&x(D,T),Object.defineProperty(D,"prototype",{writable:!1}),D}var A;(function(D){D.ID="ID",D.CLASS="CLASS",D.START_DATE="START-DATE",D.DURATION="DURATION",D.END_DATE="END-DATE",D.END_ON_NEXT="END-ON-NEXT",D.PLANNED_DURATION="PLANNED-DURATION",D.SCTE35_OUT="SCTE35-OUT",D.SCTE35_IN="SCTE35-IN"})(A||(A={}));var y=function(){function D(_,T){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,T){var g=T.attr;for(var E in g)if(Object.prototype.hasOwnProperty.call(_,E)&&_[E]!==g[E]){S.logger.warn('DATERANGE tag attribute: "'+E+'" does not match for tags with ID: "'+_.ID+'"'),this._badValueForSameId=E;break}_=I(new p.AttrList({}),g,_)}if(this.attr=_,this._startDate=new Date(_[A.START_DATE]),A.END_DATE in this.attr){var a=new Date(this.attr[A.END_DATE]);Object(R.isFiniteNumber)(a.getTime())&&(this._endDate=a)}}return L(D,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var T=this.duration;return T!==null?new Date(this._startDate.getTime()+T*1e3):null}},{key:"duration",get:function(){if(A.DURATION in this.attr){var T=this.attr.decimalFloatingPoint(A.DURATION);if(Object(R.isFiniteNumber)(T))return T}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return A.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(A.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(A.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(R.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),D}()},"./src/loader/fragment-loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return T}),h.d(P,"LoadError",function(){return E});var R=h("./src/polyfills/number.ts"),p=h("./src/errors.ts");function S(a,e){a.prototype=Object.create(e.prototype),a.prototype.constructor=a,y(a,e)}function I(a){var e=typeof Map=="function"?new Map:void 0;return I=function(u){if(u===null||!A(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(u))return e.get(u);e.set(u,n)}function n(){return x(u,arguments,D(this).constructor)}return n.prototype=Object.create(u.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),y(n,u)},I(a)}function x(a,e,s){return L()?x=Reflect.construct.bind():x=function(n,i,t){var l=[null];l.push.apply(l,i);var d=Function.bind.apply(n,l),r=new d;return t&&y(r,t.prototype),r},x.apply(null,arguments)}function L(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function A(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function y(a,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,n){return u.__proto__=n,u},y(a,e)}function D(a){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},D(a)}var _=Math.pow(2,17),T=function(){function a(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=a.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(u,n){var i=this,t=u.url;if(!t)return Promise.reject(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var l=this.config,d=l.fLoader,r=l.loader;return new Promise(function(c,f){i.loader&&i.loader.destroy();var o=i.loader=u.loader=d?new d(l):new r(l),v=g(u),m={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:u.sn==="initSegment"?1/0:_};u.stats=o.stats,o.load(v,m,{onSuccess:function(b,M,F,w){i.resetLoader(u,o),c({frag:u,part:null,payload:b.data,networkDetails:w})},onError:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,response:b,networkDetails:F}))},onAbort:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,networkDetails:F}))},onTimeout:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,networkDetails:F}))},onProgress:function(b,M,F,w){n&&n({frag:u,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(u,n,i){var t=this;this.abort();var l=this.config,d=l.fLoader,r=l.loader;return new Promise(function(c,f){t.loader&&t.loader.destroy();var o=t.loader=u.loader=d?new d(l):new r(l),v=g(u,n),m={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:_};n.stats=o.stats,o.load(v,m,{onSuccess:function(b,M,F,w){t.resetLoader(u,o),t.updateStatsFromPart(u,n);var C={frag:u,part:n,payload:b.data,networkDetails:w};i(C),c(C)},onError:function(b,M,F){t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,part:n,response:b,networkDetails:F}))},onAbort:function(b,M,F){u.stats.aborted=n.stats.aborted,t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,part:n,networkDetails:F}))},onTimeout:function(b,M,F){t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,part:n,networkDetails:F}))}})})},e.updateStatsFromPart=function(u,n){var i=u.stats,t=n.stats,l=t.total;if(i.loaded+=t.loaded,l){var d=Math.round(u.duration/n.duration),r=Math.min(Math.round(i.loaded/l),d),c=d-r,f=c*Math.round(i.loaded/r);i.total=i.loaded+f}else i.total=Math.max(i.loaded,i.total);var o=i.loading,v=t.loading;o.start?o.first+=v.first-v.start:(o.start=v.start,o.first=v.first),o.end=v.end},e.resetLoader=function(u,n){u.loader=null,this.loader===n&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),n.destroy()},a}();function g(a,e){e===void 0&&(e=null);var s=e||a,u={frag:a,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},n=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(R.isFiniteNumber)(n)&&Object(R.isFiniteNumber)(i)&&(u.rangeStart=n,u.rangeEnd=i),u}var E=function(a){S(e,a);function e(s){for(var u,n=arguments.length,i=new Array(n>1?n-1:0),t=1;t<n;t++)i[t-1]=arguments[t];return u=a.call.apply(a,[this].concat(i))||this,u.data=void 0,u.data=s,u}return e}(I(Error))},"./src/loader/fragment.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"ElementaryStreamTypes",function(){return T}),h.d(P,"BaseSegment",function(){return g}),h.d(P,"Fragment",function(){return E}),h.d(P,"Part",function(){return a});var R=h("./src/polyfills/number.ts"),p=h("./node_modules/url-toolkit/src/url-toolkit.js"),S=h.n(p),I=h("./src/utils/logger.ts"),x=h("./src/loader/level-key.ts"),L=h("./src/loader/load-stats.ts");function A(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,y(e,s)}function y(e,s){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},y(e,s)}function D(e,s){for(var u=0;u<s.length;u++){var n=s[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _(e,s,u){return s&&D(e.prototype,s),u&&D(e,u),Object.defineProperty(e,"prototype",{writable:!1}),e}var T;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(T||(T={}));var g=function(){function e(u){var n;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(n={},n[T.AUDIO]=null,n[T.VIDEO]=null,n[T.AUDIOVIDEO]=null,n),this.baseurl=u}var s=e.prototype;return s.setByteRange=function(n,i){var t=n.split("@",2),l=[];t.length===1?l[0]=i?i.byteRangeEndOffset:0:l[0]=parseInt(t[1]),l[1]=parseInt(t[0])+l[0],this._byteRange=l},_(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(p.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),e}(),E=function(e){A(s,e);function s(n,i){var t;return t=e.call(this,i)||this,t._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new L.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=n,t}var u=s.prototype;return u.createInitializationVector=function(i){for(var t=new Uint8Array(16),l=12;l<16;l++)t[l]=i>>8*(15-l)&255;return t},u.setDecryptDataFromLevelKey=function(i,t){var l=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(l=x.LevelKey.fromURI(i.uri),l.method=i.method,l.iv=this.createInitializationVector(t),l.keyFormat="identity"),l},u.setElementaryStreamInfo=function(i,t,l,d,r,c){c===void 0&&(c=!1);var f=this.elementaryStreams,o=f[i];if(!o){f[i]={startPTS:t,endPTS:l,startDTS:d,endDTS:r,partial:c};return}o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,l),o.startDTS=Math.min(o.startDTS,d),o.endDTS=Math.max(o.endDTS,r)},u.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[T.AUDIO]=null,i[T.VIDEO]=null,i[T.AUDIOVIDEO]=null},_(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(R.isFiniteNumber)(this.programDateTime))return null;var i=Object(R.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),s}(g),a=function(e){A(s,e);function s(u,n,i,t,l){var d;d=e.call(this,i)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new L.LoadStats,d.duration=u.decimalFloatingPoint("DURATION"),d.gap=u.bool("GAP"),d.independent=u.bool("INDEPENDENT"),d.relurl=u.enumeratedString("URI"),d.fragment=n,d.index=t;var r=u.enumeratedString("BYTERANGE");return r&&d.setByteRange(r,l),l&&(d.fragOffset=l.fragOffset+l.duration),d}return _(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var n=this.elementaryStreams;return!!(n.audio||n.video||n.audiovideo)}}]),s}(g)},"./src/loader/key-loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return I});var R=h("./src/events.ts"),p=h("./src/errors.ts"),S=h("./src/utils/logger.ts"),I=function(){function x(A){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=A,this.registerListeners()}var L=x.prototype;return L.startLoad=function(y){},L.stopLoad=function(){this.destroyInternalLoaders()},L.registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},L.unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},L.destroyInternalLoaders=function(){for(var y in this.loaders){var D=this.loaders[y];D&&D.destroy()}this.loaders={}},L.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},L.onKeyLoading=function(y,D){var _=D.frag,T=_.type,g=this.loaders[T];if(!_.decryptdata){S.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var E=_.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var a=this.hls.config;if(g&&(S.logger.warn("abort previous key loader for type:"+T),g.abort()),!E){S.logger.warn("key uri is falsy");return}var e=a.loader,s=_.loader=this.loaders[T]=new e(a);this.decrypturl=E,this.decryptkey=null;var u={url:E,frag:_,responseType:"arraybuffer"},n={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:a.fragLoadingRetryDelay,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(u,n,i)}else this.decryptkey&&(_.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:_}))},L.loadsuccess=function(y,D,_){var T=_.frag;if(!T.decryptdata){S.logger.error("after key load, decryptdata unset");return}this.decryptkey=T.decryptdata.key=new Uint8Array(y.data),T.loader=null,delete this.loaders[T.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:T})},L.loaderror=function(y,D){var _=D.frag,T=_.loader;T&&T.abort(),delete this.loaders[_.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:_,response:y})},L.loadtimeout=function(y,D){var _=D.frag,T=_.loader;T&&T.abort(),delete this.loaders[_.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:_})},x}()},"./src/loader/level-details.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"LevelDetails",function(){return x});var R=h("./src/polyfills/number.ts");function p(L,A){for(var y=0;y<A.length;y++){var D=A[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(L,D.key,D)}}function S(L,A,y){return A&&p(L.prototype,A),y&&p(L,y),Object.defineProperty(L,"prototype",{writable:!1}),L}var I=10,x=function(){function L(y){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.needSidxRanges=!1,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.fragments=[],this.dateRanges={},this.url=y}var A=L.prototype;return A.reloaded=function(D){if(!D){this.advanced=!0,this.updated=!0;return}var _=this.lastPartSn-D.lastPartSn,T=this.lastPartIndex-D.lastPartIndex;this.updated=this.endSN!==D.endSN||!!T||!!_,this.advanced=this.endSN>D.endSN||_>0||_===0&&T>0,this.updated||this.advanced?this.misses=Math.floor(D.misses*.6):this.misses=D.misses+1,this.availabilityDelay=D.availabilityDelay},S(L,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var D=this.driftEndTime-this.driftStartTime;if(D>0){var _=this.driftEnd-this.driftStart;return _*1e3/D}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var D;return(D=this.fragments)!==null&&D!==void 0&&D.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"LevelKey",function(){return x});var R=h("./node_modules/url-toolkit/src/url-toolkit.js"),p=h.n(R);function S(L,A){for(var y=0;y<A.length;y++){var D=A[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(L,D.key,D)}}function I(L,A,y){return A&&S(L.prototype,A),y&&S(L,y),Object.defineProperty(L,"prototype",{writable:!1}),L}var x=function(){L.fromURL=function(y,D){return new L(y,D)},L.fromURI=function(y){return new L(y)};function L(A,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(R.buildAbsoluteURL)(A,y,{alwaysNormalize:!0}):this._uri=A}return I(L,[{key:"uri",get:function(){return this._uri}}]),L}()},"./src/loader/load-stats.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"LoadStats",function(){return R});var R=function(){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}}},"./src/loader/m3u8-parser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return u});var R=h("./src/polyfills/number.ts"),p=h("./node_modules/url-toolkit/src/url-toolkit.js"),S=h.n(p),I=h("./src/loader/date-range.ts"),x=h("./src/loader/fragment.ts"),L=h("./src/loader/level-details.ts"),A=h("./src/loader/level-key.ts"),y=h("./src/utils/attr-list.ts"),D=h("./src/utils/logger.ts"),_=h("./src/utils/codecs.ts"),T=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,g=/#EXT-X-MEDIA:(.*)/g,E=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|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("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function s(r){var c,f;return e.test((c=(f=p.parseURL(r))===null||f===void 0?void 0:f.path)!=null?c:"")}var u=function(){function r(){}return r.findGroup=function(f,o){for(var v=0;v<f.length;v++){var m=f[v];if(m.id===o)return m}},r.convertAVC1ToAVCOTI=function(f){var o=f.split(".");if(o.length>2){var v=o.shift()+".";return v+=parseInt(o.shift()).toString(16),v+=("000"+parseInt(o.shift()).toString(16)).slice(-4),v}return f},r.resolve=function(f,o){return p.buildAbsoluteURL(o,f,{alwaysNormalize:!0})},r.parseMasterPlaylist=function(f,o){var v=[],m={},O=!1;T.lastIndex=0;for(var b;(b=T.exec(f))!=null;)if(b[1]){var M=new y.AttrList(b[1]),F={attrs:M,bitrate:M.decimalInteger("AVERAGE-BANDWIDTH")||M.decimalInteger("BANDWIDTH"),name:M.NAME,url:r.resolve(b[2],o)},w=M.decimalResolution("RESOLUTION");w&&(F.width=w.width,F.height=w.height),n((M.CODECS||"").split(/[ ,]+/).filter(function(U){return U}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=r.convertAVC1ToAVCOTI(F.videoCodec)),v.push(F)}else if(b[3]){var C=new y.AttrList(b[3]);C["DATA-ID"]&&(O=!0,m[C["DATA-ID"]]=C)}return{levels:v,sessionData:O?m:null}},r.parseMasterPlaylistMedia=function(f,o,v,m){m===void 0&&(m=[]);var O,b=[],M=0;for(g.lastIndex=0;(O=g.exec(f))!==null;){var F=new y.AttrList(O[1]);if(F.TYPE===v){var w={attrs:F,bitrate:0,id:M++,groupId:F["GROUP-ID"],instreamId:F["INSTREAM-ID"],name:F.NAME||F.LANGUAGE||"",type:v,default:F.bool("DEFAULT"),autoselect:F.bool("AUTOSELECT"),forced:F.bool("FORCED"),lang:F.LANGUAGE,url:F.URI?r.resolve(F.URI,o):""};if(m.length){var C=r.findGroup(m,w.groupId)||m[0];i(w,C,"audioCodec"),i(w,C,"textCodec")}b.push(w)}}return b},r.parseLevelPlaylist=function(f,o,v,m,O){var b=new L.LevelDetails(o),M=b.fragments,F=null,w=0,C=0,U=0,B=0,N=null,k=new x.Fragment(m,o),j,H,V,Y=-1,Q=!1;for(E.lastIndex=0,b.m3u8=f;(j=E.exec(f))!==null;){Q&&(Q=!1,k=new x.Fragment(m,o),k.start=U,k.sn=w,k.cc=B,k.level=v,F&&(k.initSegment=F,k.rawProgramDateTime=F.rawProgramDateTime,F.rawProgramDateTime=null));var J=j[1];if(J){k.duration=parseFloat(J);var z=(" "+j[2]).slice(1);k.title=z||null,k.tagList.push(z?["INF",J,z]:["INF",J])}else if(j[3])Object(R.isFiniteNumber)(k.duration)&&(k.start=U,V&&(k.levelkey=V),k.sn=w,k.level=v,k.cc=B,k.urlId=O,M.push(k),k.relurl=(" "+j[3]).slice(1),l(k,N),N=k,U+=k.duration,w++,C=0,Q=!0);else if(j[4]){var q=(" "+j[4]).slice(1);N?k.setByteRange(q,N):k.setByteRange(q)}else if(j[5])k.rawProgramDateTime=(" "+j[5]).slice(1),k.tagList.push(["PROGRAM-DATE-TIME",k.rawProgramDateTime]),Y===-1&&(Y=M.length);else{if(j=j[0].match(a),!j){D.logger.warn("No matches on slow regex match for level playlist!");continue}for(H=1;H<j.length&&typeof j[H]=="undefined";H++);var re=(" "+j[H]).slice(1),X=(" "+j[H+1]).slice(1),le=j[H+2]?(" "+j[H+2]).slice(1):"";switch(re){case"PLAYLIST-TYPE":b.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":w=b.startSN=parseInt(X);break;case"SKIP":{var ne=new y.AttrList(X),te=ne.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(te)){b.skippedSegments=te;for(var ee=te;ee--;)M.unshift(null);w+=te}var $=ne.enumeratedString("RECENTLY-REMOVED-DATERANGES");$&&(b.recentlyRemovedDateranges=$.split(" "));break}case"TARGETDURATION":b.targetduration=parseFloat(X);break;case"VERSION":b.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(X||le)&&k.tagList.push(le?[X,le]:[X]);break;case"DISCONTINUITY":B++,k.tagList.push(["DIS"]);break;case"GAP":k.tagList.push([re]);break;case"BITRATE":k.tagList.push([re,X]);break;case"DATERANGE":{var Z=new y.AttrList(X),ue=new I.DateRange(Z,b.dateRanges[Z.ID]);ue.isValid||b.skippedSegments?b.dateRanges[ue.id]=ue:D.logger.warn('Ignoring invalid DATERANGE tag: "'+X+'"'),k.tagList.push(["EXT-X-DATERANGE",X]);break}case"DISCONTINUITY-SEQUENCE":B=parseInt(X);break;case"KEY":{var he,se=new y.AttrList(X),me=se.enumeratedString("METHOD"),pe=se.URI,Ee=se.hexadecimalInteger("IV"),ae=se.enumeratedString("KEYFORMATVERSIONS"),fe=se.enumeratedString("KEYID"),ge=(he=se.enumeratedString("KEYFORMAT"))!=null?he:"identity",ve=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ve.indexOf(ge)>-1){D.logger.warn("Keyformat "+ge+" is not supported from the manifest");continue}else if(ge!=="identity")continue;me&&(V=A.LevelKey.fromURL(o,pe),pe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(me)>=0&&(V.method=me,V.keyFormat=ge,fe&&(V.keyID=fe),ae&&(V.keyFormatVersions=ae),V.iv=Ee));break}case"START":{var Te=new y.AttrList(X),_e=Te.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(_e)&&(b.startTimeOffset=_e);break}case"MAP":{var Oe=new y.AttrList(X);if(k.duration){var xe=new x.Fragment(m,o);d(xe,Oe,v,V),F=xe,k.initSegment=F,F.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=F.rawProgramDateTime)}else d(k,Oe,v,V),F=k,Q=!0;break}case"SERVER-CONTROL":{var ye=new y.AttrList(X);b.canBlockReload=ye.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=ye.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&ye.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=ye.optionalFloat("PART-HOLD-BACK",0),b.holdBack=ye.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var W=new y.AttrList(X);b.partTarget=W.decimalFloatingPoint("PART-TARGET");break}case"PART":{var G=b.partList;G||(G=b.partList=[]);var oe=C>0?G[G.length-1]:void 0,de=C++,ce=new x.Part(new y.AttrList(X),k,o,de,oe);G.push(ce),k.duration+=ce.duration;break}case"PRELOAD-HINT":{var Se=new y.AttrList(X);b.preloadHint=Se;break}case"RENDITION-REPORT":{var ie=new y.AttrList(X);b.renditionReports=b.renditionReports||[],b.renditionReports.push(ie);break}default:D.logger.warn("line parsed but not handled: "+j);break}}}N&&!N.relurl?(M.pop(),U-=N.duration,b.partList&&(b.fragmentHint=N)):b.partList&&(l(k,N),k.cc=B,b.fragmentHint=k);var Ae=M.length,De=M[0],Le=M[Ae-1];if(U+=b.skippedSegments*b.targetduration,U>0&&Ae&&Le){b.averagetargetduration=U/Ae;var Ce=Le.sn;b.endSN=Ce!=="initSegment"?Ce:0,De&&(b.startCC=De.cc,De.initSegment||b.fragments.every(function(Pe){return Pe.relurl&&s(Pe.relurl)})&&(D.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),k=new x.Fragment(m,o),k.relurl=Le.relurl,k.level=v,k.sn="initSegment",De.initSegment=k,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(U+=b.fragmentHint.duration),b.totalduration=U,b.endCC=B,Y>0&&t(M,Y),b},r}();function n(r,c){["video","audio","text"].forEach(function(f){var o=r.filter(function(m){return Object(_.isCodecType)(m,f)});if(o.length){var v=o.filter(function(m){return m.lastIndexOf("avc1",0)===0||m.lastIndexOf("mp4a",0)===0});c[f+"Codec"]=v.length>0?v[0]:o[0],r=r.filter(function(m){return o.indexOf(m)===-1})}}),c.unknownCodecs=r}function i(r,c,f){var o=c[f];o&&(r[f]=o)}function t(r,c){for(var f=r[c],o=c;o--;){var v=r[o];if(!v)return;v.programDateTime=f.programDateTime-v.duration*1e3,f=v}}function l(r,c){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):c!=null&&c.programDateTime&&(r.programDateTime=c.endProgramDateTime),Object(R.isFiniteNumber)(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function d(r,c,f,o){r.relurl=c.URI,c.BYTERANGE&&r.setByteRange(c.BYTERANGE),r.level=f,r.sn="initSegment",o&&(r.levelkey=o),r.initSegment=null}},"./src/loader/playlist-loader.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),S=h("./src/errors.ts"),I=h("./src/utils/logger.ts"),x=h("./src/utils/mp4-tools.ts"),L=h("./src/loader/m3u8-parser.ts"),A=h("./src/types/loader.ts"),y=h("./src/utils/attr-list.ts");function D(g){var E=g.type;switch(E){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function _(g,E){var a=g.url;return(a===void 0||a.indexOf("data:")===0)&&(a=E.url),a}var T=function(){function g(a){this.hls=void 0,this.loaders=Object.create(null),this.hls=a,this.registerListeners()}var E=g.prototype;return E.startLoad=function(e){},E.stopLoad=function(){this.destroyInternalLoaders()},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.createInternalLoader=function(e){var s=this.hls.config,u=s.pLoader,n=s.loader,i=u||n,t=new i(s);return e.loader=t,this.loaders[e.type]=t,t},E.getInternalLoader=function(e){return this.loaders[e.type]},E.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},E.destroyInternalLoaders=function(){for(var e in this.loaders){var s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.onManifestLoading=function(e,s){var u=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:u,deliveryDirectives:null})},E.onLevelLoading=function(e,s){var u=s.id,n=s.level,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:null,level:n,responseType:"text",type:A.PlaylistContextType.LEVEL,url:i,deliveryDirectives:t})},E.onAudioTrackLoading=function(e,s){var u=s.id,n=s.groupId,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:n,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:t})},E.onSubtitleTrackLoading=function(e,s){var u=s.id,n=s.groupId,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:n,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:t})},E.load=function(e){var s,u=this.hls.config,n=this.getInternalLoader(e);if(n){var i=n.context;if(i&&i.url===e.url){I.logger.trace("[playlist-loader]: playlist request ongoing");return}I.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),n.abort()}var t,l,d,r;switch(e.type){case A.PlaylistContextType.MANIFEST:t=u.manifestLoadingMaxRetry,l=u.manifestLoadingTimeOut,d=u.manifestLoadingRetryDelay,r=u.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:t=0,l=u.levelLoadingTimeOut;break;default:t=u.levelLoadingMaxRetry,l=u.levelLoadingTimeOut,d=u.levelLoadingRetryDelay,r=u.levelLoadingMaxRetryTimeout;break}if(n=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var c;if(e.type===A.PlaylistContextType.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===A.PlaylistContextType.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===A.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){var f=c.partTarget,o=c.targetduration;f&&o&&(l=Math.min(Math.max(f*3,o*.8)*1e3,l))}}var v={timeout:l,maxRetry:t,retryDelay:d,maxRetryDelay:r,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};n.load(e,v,m)},E.loadsuccess=function(e,s,u,n){if(n===void 0&&(n=null),u.isSidxRequest){this.handleSidxRequest(e,u),this.handlePlaylistLoaded(e,s,u,n);return}this.resetInternalLoader(u.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,u,"no EXTM3U delimiter",n);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,u,n):this.handleMasterPlaylist(e,s,u,n)},E.loaderror=function(e,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!1,e)},E.loadtimeout=function(e,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!0)},E.handleMasterPlaylist=function(e,s,u,n){var i=this.hls,t=e.data,l=_(e,u),d=L.default.parseMasterPlaylist(t,l),r=d.levels,c=d.sessionData;if(!r.length){this.handleManifestParsingError(e,u,"no level found in manifest",n);return}var f=r.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),o=r.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),v=L.default.parseMasterPlaylistMedia(t,l,"AUDIO",f),m=L.default.parseMasterPlaylistMedia(t,l,"SUBTITLES",o),O=L.default.parseMasterPlaylistMedia(t,l,"CLOSED-CAPTIONS");if(v.length){var b=v.some(function(M){return!M.url});!b&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(I.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(p.Events.MANIFEST_LOADED,{levels:r,audioTracks:v,subtitles:m,captions:O,url:l,stats:s,networkDetails:n,sessionData:c})},E.handleTrackOrLevelPlaylist=function(e,s,u,n){var i=this.hls,t=u.id,l=u.level,d=u.type,r=_(e,u),c=Object(R.isFiniteNumber)(t)?t:0,f=Object(R.isFiniteNumber)(l)?l:c,o=D(u),v=L.default.parseLevelPlaylist(e.data,r,f,o,c);if(!v.fragments.length){i.trigger(p.Events.ERROR,{type:S.ErrorTypes.NETWORK_ERROR,details:S.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:r,reason:"no fragments found in level",level:typeof u.level=="number"?u.level:void 0});return}if(d===A.PlaylistContextType.MANIFEST){var m={attrs:new y.AttrList({}),bitrate:0,details:v,name:"",url:r};i.trigger(p.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:r,stats:s,networkDetails:n,sessionData:null})}if(s.parsing.end=performance.now(),v.needSidxRanges){var O,b=(O=v.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:b,isSidxRequest:!0,type:d,level:l,levelDetails:v,id:t,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}u.levelDetails=v,this.handlePlaylistLoaded(e,s,u,n)},E.handleSidxRequest=function(e,s){var u=new Uint8Array(e.data),n=Object(x.findBox)(u,["sidx"])[0];if(!!n){var i=Object(x.parseSegmentIndex)(n);if(!!i){var t=i.references,l=s.levelDetails;t.forEach(function(d,r){var c=d.info,f=l.fragments[r];if(f.byteRange.length===0&&f.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),f.initSegment){var o=Object(x.findBox)(u,["moov"])[0],v=o?o.length:null;f.initSegment.setByteRange(String(v)+"@0")}})}}},E.handleManifestParsingError=function(e,s,u,n){this.hls.trigger(p.Events.ERROR,{type:S.ErrorTypes.NETWORK_ERROR,details:S.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===A.PlaylistContextType.MANIFEST,url:e.url,reason:u,response:e,context:s,networkDetails:n})},E.handleNetworkError=function(e,s,u,n){u===void 0&&(u=!1),I.logger.warn("[playlist-loader]: A network "+(u?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=S.ErrorDetails.UNKNOWN,t=!1,l=this.getInternalLoader(e);switch(e.type){case A.PlaylistContextType.MANIFEST:i=u?S.ErrorDetails.MANIFEST_LOAD_TIMEOUT:S.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case A.PlaylistContextType.LEVEL:i=u?S.ErrorDetails.LEVEL_LOAD_TIMEOUT:S.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case A.PlaylistContextType.AUDIO_TRACK:i=u?S.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:S.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:i=u?S.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:S.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}l&&this.resetInternalLoader(e.type);var d={type:S.ErrorTypes.NETWORK_ERROR,details:i,fatal:t,url:e.url,loader:l,context:e,networkDetails:s};n&&(d.response=n),this.hls.trigger(p.Events.ERROR,d)},E.handlePlaylistLoaded=function(e,s,u,n){var i=u.type,t=u.level,l=u.id,d=u.groupId,r=u.loader,c=u.levelDetails,f=u.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(e,u,"invalid target duration",n);return}if(!!r)switch(c.live&&(r.getCacheAge&&(c.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0)),i){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:c,level:t||0,id:l||0,stats:s,networkDetails:n,deliveryDirectives:f});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:c,id:l||0,groupId:d||"",stats:s,networkDetails:n,deliveryDirectives:f});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:c,id:l||0,groupId:d||"",stats:s,networkDetails:n,deliveryDirectives:f});break}},g}();P.default=T},"./src/polyfills/number.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isFiniteNumber",function(){return R}),h.d(P,"MAX_SAFE_INTEGER",function(){return p});var R=Number.isFinite||function(S){return typeof S=="number"&&isFinite(S)},p=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(K,P,h){"use strict";h.r(P);var R=function(){function p(){}return p.getSilentFrame=function(I,x){switch(I){case"mp4a.40.2":if(x===1)return new Uint8Array([0,200,0,128,35,128]);if(x===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(x===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(x===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(x===5)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(x===6)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]);break;default:if(x===1)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(x===2)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(x===3)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]);break}},p}();P.default=R},"./src/remux/mp4-generator.ts":function(K,P,h){"use strict";h.r(P);var R=Math.pow(2,32)-1,p=function(){function S(){}return S.init=function(){S.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:[]};var x;for(x in S.types)S.types.hasOwnProperty(x)&&(S.types[x]=[x.charCodeAt(0),x.charCodeAt(1),x.charCodeAt(2),x.charCodeAt(3)]);var L=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]),A=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]);S.HDLR_TYPES={video:L,audio:A};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),D=new Uint8Array([0,0,0,0,0,0,0,0]);S.STTS=S.STSC=S.STCO=D,S.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),S.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),S.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),S.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var _=new Uint8Array([105,115,111,109]),T=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);S.FTYP=S.box(S.types.ftyp,_,g,_,T),S.DINF=S.box(S.types.dinf,S.box(S.types.dref,y))},S.box=function(x){for(var L=8,A=arguments.length,y=new Array(A>1?A-1:0),D=1;D<A;D++)y[D-1]=arguments[D];for(var _=y.length,T=_;_--;)L+=y[_].byteLength;var g=new Uint8Array(L);for(g[0]=L>>24&255,g[1]=L>>16&255,g[2]=L>>8&255,g[3]=L&255,g.set(x,4),_=0,L=8;_<T;_++)g.set(y[_],L),L+=y[_].byteLength;return g},S.hdlr=function(x){return S.box(S.types.hdlr,S.HDLR_TYPES[x])},S.mdat=function(x){return S.box(S.types.mdat,x)},S.mdhd=function(x,L){L*=x;var A=Math.floor(L/(R+1)),y=Math.floor(L%(R+1));return S.box(S.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,x>>24&255,x>>16&255,x>>8&255,x&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},S.mdia=function(x){return S.box(S.types.mdia,S.mdhd(x.timescale,x.duration),S.hdlr(x.type),S.minf(x))},S.mfhd=function(x){return S.box(S.types.mfhd,new Uint8Array([0,0,0,0,x>>24,x>>16&255,x>>8&255,x&255]))},S.minf=function(x){return x.type==="audio"?S.box(S.types.minf,S.box(S.types.smhd,S.SMHD),S.DINF,S.stbl(x)):S.box(S.types.minf,S.box(S.types.vmhd,S.VMHD),S.DINF,S.stbl(x))},S.moof=function(x,L,A){return S.box(S.types.moof,S.mfhd(x),S.traf(A,L))},S.moov=function(x){for(var L=x.length,A=[];L--;)A[L]=S.trak(x[L]);return S.box.apply(null,[S.types.moov,S.mvhd(x[0].timescale,x[0].duration)].concat(A).concat(S.mvex(x)))},S.mvex=function(x){for(var L=x.length,A=[];L--;)A[L]=S.trex(x[L]);return S.box.apply(null,[S.types.mvex].concat(A))},S.mvhd=function(x,L){L*=x;var A=Math.floor(L/(R+1)),y=Math.floor(L%(R+1)),D=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,x>>24&255,x>>16&255,x>>8&255,x&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,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 S.box(S.types.mvhd,D)},S.sdtp=function(x){var L=x.samples||[],A=new Uint8Array(4+L.length),y,D;for(y=0;y<L.length;y++)D=L[y].flags,A[y+4]=D.dependsOn<<4|D.isDependedOn<<2|D.hasRedundancy;return S.box(S.types.sdtp,A)},S.stbl=function(x){return S.box(S.types.stbl,S.stsd(x),S.box(S.types.stts,S.STTS),S.box(S.types.stsc,S.STSC),S.box(S.types.stsz,S.STSZ),S.box(S.types.stco,S.STCO))},S.avc1=function(x){var L=[],A=[],y,D,_;for(y=0;y<x.sps.length;y++)D=x.sps[y],_=D.byteLength,L.push(_>>>8&255),L.push(_&255),L=L.concat(Array.prototype.slice.call(D));for(y=0;y<x.pps.length;y++)D=x.pps[y],_=D.byteLength,A.push(_>>>8&255),A.push(_&255),A=A.concat(Array.prototype.slice.call(D));var T=S.box(S.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|x.sps.length].concat(L).concat([x.pps.length]).concat(A))),g=x.width,E=x.height,a=x.pixelRatio[0],e=x.pixelRatio[1];return S.box(S.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,g>>8&255,g&255,E>>8&255,E&255,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]),T,S.box(S.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),S.box(S.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,e>>24,e>>16&255,e>>8&255,e&255])))},S.esds=function(x){var L=x.config.length;return new Uint8Array([0,0,0,0,3,23+L,0,1,0,4,15+L,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([L]).concat(x.config).concat([6,1,2]))},S.mp4a=function(x){var L=x.samplerate;return S.box(S.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,x.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]),S.box(S.types.esds,S.esds(x)))},S.mp3=function(x){var L=x.samplerate;return S.box(S.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,x.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]))},S.stsd=function(x){return x.type==="audio"?x.segmentCodec==="mp3"&&x.codec==="mp3"?S.box(S.types.stsd,S.STSD,S.mp3(x)):S.box(S.types.stsd,S.STSD,S.mp4a(x)):S.box(S.types.stsd,S.STSD,S.avc1(x))},S.tkhd=function(x){var L=x.id,A=x.duration*x.timescale,y=x.width,D=x.height,_=Math.floor(A/(R+1)),T=Math.floor(A%(R+1));return S.box(S.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,L>>24&255,L>>16&255,L>>8&255,L&255,0,0,0,0,_>>24,_>>16&255,_>>8&255,_&255,T>>24,T>>16&255,T>>8&255,T&255,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,y>>8&255,y&255,0,0,D>>8&255,D&255,0,0]))},S.traf=function(x,L){var A=S.sdtp(x),y=x.id,D=Math.floor(L/(R+1)),_=Math.floor(L%(R+1));return S.box(S.types.traf,S.box(S.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),S.box(S.types.tfdt,new Uint8Array([1,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,_>>24,_>>16&255,_>>8&255,_&255])),S.trun(x,A.length+16+20+8+16+8+8),A)},S.trak=function(x){return x.duration=x.duration||4294967295,S.box(S.types.trak,S.tkhd(x),S.mdia(x))},S.trex=function(x){var L=x.id;return S.box(S.types.trex,new Uint8Array([0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},S.trun=function(x,L){var A=x.samples||[],y=A.length,D=12+16*y,_=new Uint8Array(D),T,g,E,a,e,s;for(L+=8+D,_.set([x.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,L>>>24&255,L>>>16&255,L>>>8&255,L&255],0),T=0;T<y;T++)g=A[T],E=g.duration,a=g.size,e=g.flags,s=g.cts,_.set([E>>>24&255,E>>>16&255,E>>>8&255,E&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*T);return S.box(S.types.trun,_)},S.initSegment=function(x){S.types||S.init();var L=S.moov(x),A=new Uint8Array(S.FTYP.byteLength+L.byteLength);return A.set(S.FTYP),A.set(L,S.FTYP.byteLength),A},S}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0,P.default=p},"./src/remux/mp4-remuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return e}),h.d(P,"normalizePts",function(){return s}),h.d(P,"flushTextTrackMetadataCueSamples",function(){return n}),h.d(P,"flushTextTrackUserdataCueSamples",function(){return i});var R=h("./src/polyfills/number.ts"),p=h("./src/remux/aac-helper.ts"),S=h("./src/remux/mp4-generator.ts"),I=h("./src/events.ts"),x=h("./src/errors.ts"),L=h("./src/utils/logger.ts"),A=h("./src/types/loader.ts"),y=h("./src/utils/timescale-conversion.ts");function D(){return D=Object.assign?Object.assign.bind():function(d){for(var r=1;r<arguments.length;r++){var c=arguments[r];for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(d[f]=c[f])}return d},D.apply(this,arguments)}var _=10*1e3,T=1024,g=1152,E=null,a=null,e=function(){function d(c,f,o,v){if(v===void 0&&(v=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=c,this.config=f,this.typeSupported=o,this.ISGenerated=!1,E===null){var m=navigator.userAgent||"",O=m.match(/Chrome\/(\d+)/i);E=O?parseInt(O[1]):0}if(a===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);a=b?parseInt(b[1]):0}}var r=d.prototype;return r.destroy=function(){},r.resetTimeStamp=function(f){L.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},r.resetNextTimestamp=function(){L.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){L.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},r.getVideoStartPts=function(f){var o=!1,v=f.reduce(function(m,O){var b=O.pts-m;return b<-4294967296?(o=!0,s(m,O.pts)):b>0?m:O.pts},f[0].pts);return o&&L.logger.debug("PTS rollover detected"),v},r.remux=function(f,o,v,m,O,b,M,F){var w,C,U,B,N,k,j=O,H=O,V=f.pid>-1,Y=o.pid>-1,Q=o.samples.length,J=f.samples.length>0,z=M&&Q>0||Q>1,q=(!V||J)&&(!Y||z)||this.ISGenerated||M;if(q){this.ISGenerated||(U=this.generateIS(f,o,O));var re=this.isVideoContiguous,X=-1,le;if(z&&(X=u(o.samples),!re&&this.config.forceKeyFrameOnDiscontinuity))if(k=!0,X>0){L.logger.warn("[mp4-remuxer]: Dropped "+X+" out of "+Q+" video samples due to a missing keyframe");var ne=this.getVideoStartPts(o.samples);o.samples=o.samples.slice(X),o.dropped+=X,H+=(o.samples[0].pts-ne)/o.inputTimeScale,le=H}else X===-1&&(L.logger.warn("[mp4-remuxer]: No keyframe found out of "+Q+" video samples"),k=!1);if(this.ISGenerated){if(J&&z){var te=this.getVideoStartPts(o.samples),ee=s(f.samples[0].pts,te)-te,$=ee/o.inputTimeScale;j+=Math.max(0,$),H+=Math.max(0,-$)}if(J){if(f.samplerate||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),U=this.generateIS(f,o,O)),C=this.remuxAudio(f,j,this.isAudioContiguous,b,Y||z||F===A.PlaylistLevelType.AUDIO?H:void 0),z){var Z=C?C.endPTS-C.startPTS:0;o.inputTimeScale||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),U=this.generateIS(f,o,O)),w=this.remuxVideo(o,H,re,Z)}}else z&&(w=this.remuxVideo(o,H,re,0));w&&(w.firstKeyFrame=X,w.independent=X!==-1,w.firstKeyFramePTS=le)}}return this.ISGenerated&&(v.samples.length&&(N=n(v,O,this._initPTS,this._initDTS)),m.samples.length&&(B=i(m,O,this._initPTS))),{audio:C,video:w,initSegment:U,independent:k,text:B,id3:N}},r.generateIS=function(f,o,v){var m=f.samples,O=o.samples,b=this.typeSupported,M={},F=!Object(R.isFiniteNumber)(this._initPTS),w="audio/mp4",C,U,B;if(F&&(C=U=1/0),f.config&&m.length){switch(f.timescale=f.samplerate,f.segmentCodec){case"mp3":b.mpeg?(w="audio/mpeg",f.codec=""):b.mp3&&(f.codec="mp3");break}M.audio={id:"audio",container:w,codec:f.codec,initSegment:f.segmentCodec==="mp3"&&b.mpeg?new Uint8Array(0):S.default.initSegment([f]),metadata:{channelCount:f.channelCount}},F&&(B=f.inputTimeScale,C=U=m[0].pts-Math.round(B*v))}if(o.sps&&o.pps&&O.length&&(o.timescale=o.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:o.codec,initSegment:S.default.initSegment([o]),metadata:{width:o.width,height:o.height}},F)){B=o.inputTimeScale;var N=this.getVideoStartPts(O),k=Math.round(B*v);U=Math.min(U,s(O[0].dts,N)-k),C=Math.min(C,N-k)}if(Object.keys(M).length)return this.ISGenerated=!0,F&&(this._initPTS=C,this._initDTS=U),{tracks:M,initPTS:C,timescale:B}},r.remuxVideo=function(f,o,v,m){var O=f.inputTimeScale,b=f.samples,M=[],F=b.length,w=this._initPTS,C=this.nextAvcDts,U=8,B=this.videoSampleDuration,N,k,j=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,V=!1;if(!v||C===null){var Y=o*O,Q=b[0].pts-s(b[0].dts,b[0].pts);C=Y-Q}for(var J=0;J<F;J++){var z=b[J];z.pts=s(z.pts-w,C),z.dts=s(z.dts-w,C),z.dts<b[J>0?J-1:J].dts&&(V=!0)}V&&b.sort(function(we,Xe){var Qe=we.dts-Xe.dts,qe=we.pts-Xe.pts;return Qe||qe}),N=b[0].dts,k=b[b.length-1].dts;var q=k-N,re=q?Math.round(q/(F-1)):B||f.inputTimeScale/30;if(v){var X=N-C,le=X>re,ne=X<-1;if(le||ne){le?L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms ("+X+"dts) hole between fragments detected, filling it"):L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-X,!0)+" ms ("+X+"dts) overlapping between fragments detected"),N=C;var te=b[0].pts-X;b[0].dts=N,b[0].pts=te,L.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(te,!0)+"/"+Object(y.toMsFromMpegTsClock)(N,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms")}}N=Math.max(0,N);for(var ee=0,$=0,Z=0;Z<F;Z++){for(var ue=b[Z],he=ue.units,se=he.length,me=0,pe=0;pe<se;pe++)me+=he[pe].data.length;$+=me,ee+=se,ue.length=me,ue.dts=Math.max(ue.dts,N),j=Math.min(ue.pts,j),H=Math.max(ue.pts,H)}k=b[F-1].dts;var Ee=$+4*ee+8,ae;try{ae=new Uint8Array(Ee)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:x.ErrorTypes.MUX_ERROR,details:x.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ee,reason:"fail allocating video mdat "+Ee});return}var fe=new DataView(ae.buffer);fe.setUint32(0,Ee),ae.set(S.default.types.mdat,4);for(var ge=!1,ve=Number.POSITIVE_INFINITY,Te=Number.POSITIVE_INFINITY,_e=Number.NEGATIVE_INFINITY,Oe=Number.NEGATIVE_INFINITY,xe=0;xe<F;xe++){for(var ye=b[xe],W=ye.units,G=0,oe=0,de=W.length;oe<de;oe++){var ce=W[oe],Se=ce.data,ie=ce.data.byteLength;fe.setUint32(U,ie),U+=4,ae.set(Se,U),U+=ie,G+=4+ie}var Ae=void 0;if(xe<F-1)B=b[xe+1].dts-ye.dts,Ae=b[xe+1].pts-ye.pts;else{var De=this.config,Le=xe>0?ye.dts-b[xe-1].dts:re;if(Ae=xe>0?ye.pts-b[xe-1].pts:re,De.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ce=Math.floor(De.maxBufferHole*O),Pe=(m?j+m*O:this.nextAudioPts)-ye.pts;Pe>Ce?(B=Pe-Le,B<0?B=Le:ge=!0,L.logger.log("[mp4-remuxer]: It is approximately "+Pe/90+" ms to the next segment; using duration "+B/90+" ms for the last video frame.")):B=Le}else B=Le}var Ie=Math.round(ye.pts-ye.dts);ve=Math.min(ve,B),_e=Math.max(_e,B),Te=Math.min(Te,Ae),Oe=Math.max(Oe,Ae),M.push(new t(ye.key,B,G,Ie))}if(M.length){if(E){if(E<70){var Ve=M[0].flags;Ve.dependsOn=2,Ve.isNonSync=0}}else if(a&&Oe-Te<_e-ve&&re/_e<.025&&M[0].cts===0){L.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Be=N,Re=0,Fe=M.length;Re<Fe;Re++){var ke=Be+M[Re].duration,Ne=Be+M[Re].cts;if(Re<Fe-1){var Ye=ke+M[Re+1].cts;M[Re].duration=Ye-Ne}else M[Re].duration=Re?M[Re-1].duration:re;M[Re].cts=0,Be=ke}}}console.assert(B!==null,"mp4SampleDuration must be computed"),B=ge||!B?re:B,this.nextAvcDts=C=k+B,this.videoSampleDuration=B,this.isVideoContiguous=!0;var ze=S.default.moof(f.sequenceNumber++,N,D({},f,{samples:M})),$e="video",Ze={data1:ze,data2:ae,startPTS:j/O,endPTS:(H+B)/O,startDTS:N/O,endDTS:C/O,type:$e,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(ae.length,"MDAT length must not be zero"),Ze},r.remuxAudio=function(f,o,v,m,O){var b=f.inputTimeScale,M=f.samplerate?f.samplerate:b,F=b/M,w=f.segmentCodec==="aac"?T:g,C=w*F,U=this._initPTS,B=f.segmentCodec==="mp3"&&this.typeSupported.mpeg,N=[],k=O!==void 0,j=f.samples,H=B?0:8,V=this.nextAudioPts||-1,Y=o*b;if(this.isAudioContiguous=v=v||j.length&&V>0&&(m&&Math.abs(Y-V)<9e3||Math.abs(s(j[0].pts-U,Y)-V)<20*C),j.forEach(function(ce){ce.pts=s(ce.pts-U,Y)}),!v||V<0){if(j=j.filter(function(ce){return ce.pts>=0}),!j.length)return;O===0?V=0:m&&!k?V=Math.max(0,Y):V=j[0].pts}if(f.segmentCodec==="aac")for(var Q=this.config.maxAudioFramesDrift,J=0,z=V;J<j.length;J++){var q=j[J],re=q.pts,X=re-z,le=Math.abs(1e3*X/b);if(X<=-Q*C&&k)J===0&&(L.logger.warn("Audio frame @ "+(re/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*X/b)+" ms."),this.nextAudioPts=V=z=re);else if(X>=Q*C&&le<_&&k){var ne=Math.round(X/C);z=re-ne*C,z<0&&(ne--,z+=C),J===0&&(this.nextAudioPts=V=z),L.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(z/b).toFixed(3)+"s due to "+Math.round(1e3*X/b)+" ms gap.");for(var te=0;te<ne;te++){var ee=Math.max(z,0),$=p.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);$||(L.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),$=q.unit.subarray()),j.splice(J,0,{unit:$,pts:ee}),z+=C,J++}}q.pts=z,z+=C}for(var Z=null,ue=null,he,se=0,me=j.length;me--;)se+=j[me].unit.byteLength;for(var pe=0,Ee=j.length;pe<Ee;pe++){var ae=j[pe],fe=ae.unit,ge=ae.pts;if(ue!==null){var ve=N[pe-1];ve.duration=Math.round((ge-ue)/F)}else if(v&&f.segmentCodec==="aac"&&(ge=V),Z=ge,se>0){se+=H;try{he=new Uint8Array(se)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:x.ErrorTypes.MUX_ERROR,details:x.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:se,reason:"fail allocating audio mdat "+se});return}if(!B){var Te=new DataView(he.buffer);Te.setUint32(0,se),he.set(S.default.types.mdat,4)}}else return;he.set(fe,H);var _e=fe.byteLength;H+=_e,N.push(new t(!0,w,_e,0)),ue=ge}var Oe=N.length;if(!!Oe){var xe=N[N.length-1];this.nextAudioPts=V=ue+F*xe.duration;var ye=B?new Uint8Array(0):S.default.moof(f.sequenceNumber++,Z/F,D({},f,{samples:N}));f.samples=[];var W=Z/b,G=V/b,oe="audio",de={data1:ye,data2:he,startPTS:W,endPTS:G,startDTS:W,endDTS:G,type:oe,hasAudio:!0,hasVideo:!1,nb:Oe};return this.isAudioContiguous=!0,console.assert(he.length,"MDAT length must not be zero"),de}},r.remuxEmptyAudio=function(f,o,v,m){var O=f.inputTimeScale,b=f.samplerate?f.samplerate:O,M=O/b,F=this.nextAudioPts,w=(F!==null?F:m.startDTS*O)+this._initDTS,C=m.endDTS*O+this._initDTS,U=M*T,B=Math.ceil((C-w)/U),N=p.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(L.logger.warn("[mp4-remuxer]: remux empty Audio"),!N){L.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var k=[],j=0;j<B;j++){var H=w+j*U;k.push({unit:N,pts:H,dts:H})}return f.samples=k,this.remuxAudio(f,o,v,!1)},d}();function s(d,r){var c;if(r===null)return d;for(r<d?c=-8589934592:c=8589934592;Math.abs(d-r)>4294967296;)d+=c;return d}function u(d){for(var r=0;r<d.length;r++)if(d[r].key)return r;return-1}function n(d,r,c,f){var o=d.samples.length;if(!!o){for(var v=d.inputTimeScale,m=0;m<o;m++){var O=d.samples[m];O.pts=s(O.pts-c,r*v)/v,O.dts=s(O.dts-f,r*v)/v}var b=d.samples;return d.samples=[],{samples:b}}}function i(d,r,c){var f=d.samples.length;if(!!f){for(var o=d.inputTimeScale,v=0;v<f;v++){var m=d.samples[v];m.pts=s(m.pts-c,r*o)/o}d.samples.sort(function(b,M){return b.pts-M.pts});var O=d.samples;return d.samples=[],{samples:O}}}var t=function(r,c,f,o){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=f,this.cts=o,this.flags=new l(r)},l=function(r){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=r?2:1,this.isNonSync=r?0:1}},"./src/remux/passthrough-remuxer.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/polyfills/number.ts"),p=h("./src/remux/mp4-remuxer.ts"),S=h("./src/utils/mp4-tools.ts"),I=h("./src/loader/fragment.ts"),x=h("./src/utils/logger.ts"),L=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var D=y.prototype;return D.destroy=function(){},D.resetTimeStamp=function(T){this.initPTS=T,this.lastEndTime=null},D.resetNextTimestamp=function(){this.lastEndTime=null},D.resetInitSegment=function(T,g,E){this.audioCodec=g,this.videoCodec=E,this.generateInitSegment(T),this.emitInitSegment=!0},D.generateInitSegment=function(T){var g=this.audioCodec,E=this.videoCodec;if(!T||!T.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=Object(S.parseInitSegment)(T);g||(g=A(a.audio,I.ElementaryStreamTypes.AUDIO)),E||(E=A(a.video,I.ElementaryStreamTypes.VIDEO));var e={};a.audio&&a.video?e.audiovideo={container:"video/mp4",codec:g+","+E,initSegment:T,id:"main"}:a.audio?e.audio={container:"audio/mp4",codec:g,initSegment:T,id:"audio"}:a.video?e.video={container:"video/mp4",codec:E,initSegment:T,id:"main"}:x.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},D.remux=function(T,g,E,a,e){var s,u=this.initPTS,n=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:E,initSegment:void 0};Object(R.isFiniteNumber)(n)||(n=this.lastEndTime=e||0);var t=g.samples;if(!t||!t.length)return i;var l={initPTS:void 0,timescale:1},d=this.initData;if((!d||!d.length)&&(this.generateInitSegment(t),d=this.initData),!d||!d.length)return x.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1);var r=Object(S.getStartDTS)(d,t);Object(R.isFiniteNumber)(u)||(this.initPTS=l.initPTS=u=r-e);var c=Object(S.getDuration)(t,d),f=T?r-u:n,o=f+c;Object(S.offsetStartDTS)(d,t,u),c>0?this.lastEndTime=o:(x.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!d.audio,m=!!d.video,O="";v&&(O+="audio"),m&&(O+="video");var b={data1:t,startPTS:f,startDTS:f,endPTS:o,endDTS:o,type:O,hasAudio:v,hasVideo:m,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=l;var M=(s=this.initPTS)!=null?s:0;return i.id3=Object(p.flushTextTrackMetadataCueSamples)(E,e,M,M),a.samples.length&&(i.text=Object(p.flushTextTrackUserdataCueSamples)(a,e,M)),i},y}();function A(y,D){var _=y==null?void 0:y.codec;return _&&_.length>4?_:_==="hvc1"||_==="hev1"?"hvc1.1.c.L120.90":_==="av01"?"av01.0.04M.08":_==="avc1"||D===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}P.default=L},"./src/task-loop.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var S=p.prototype;return S.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},S.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},S.onHandlerDestroyed=function(){},S.hasInterval=function(){return!!this._tickInterval},S.hasNextTick=function(){return!!this._tickTimer},S.setInterval=function(x){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,x),!0)},S.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},S.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},S.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},S.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},S.doTick=function(){},p}()},"./src/types/cmcd.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"CMCDVersion",function(){return R}),h.d(P,"CMCDObjectType",function(){return p}),h.d(P,"CMCDStreamingFormat",function(){return S}),h.d(P,"CMCDStreamType",function(){return I});var R=1,p;(function(x){x.MANIFEST="m",x.AUDIO="a",x.VIDEO="v",x.MUXED="av",x.INIT="i",x.CAPTION="c",x.TIMED_TEXT="tt",x.KEY="k",x.OTHER="o"})(p||(p={}));var S;(function(x){x.DASH="d",x.HLS="h",x.SMOOTH="s",x.OTHER="o"})(S||(S={}));var I;(function(x){x.VOD="v",x.LIVE="l"})(I||(I={}))},"./src/types/demuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"MetadataSchema",function(){return R});var R;(function(p){p.audioId3="org.id3",p.dateRange="com.apple.quicktime.HLS",p.emsg="https://aomedia.org/emsg/ID3"})(R||(R={}))},"./src/types/level.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"HlsSkip",function(){return S}),h.d(P,"getSkipValue",function(){return I}),h.d(P,"HlsUrlParameters",function(){return x}),h.d(P,"Level",function(){return L});function R(A,y){for(var D=0;D<y.length;D++){var _=y[D];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(A,_.key,_)}}function p(A,y,D){return y&&R(A.prototype,y),D&&R(A,D),Object.defineProperty(A,"prototype",{writable:!1}),A}var S;(function(A){A.No="",A.Yes="YES",A.v2="v2"})(S||(S={}));function I(A,y){var D=A.canSkipUntil,_=A.canSkipDateRanges,T=A.endSN,g=y!==void 0?y-T:0;return D&&g<D?_?S.v2:S.Yes:S.No}var x=function(){function A(D,_,T){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=D,this.part=_,this.skip=T}var y=A.prototype;return y.addDirectives=function(_){var T=new self.URL(_);return this.msn!==void 0&&T.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&T.searchParams.set("_HLS_part",this.part.toString()),this.skip&&T.searchParams.set("_HLS_skip",this.skip),T.toString()},A}(),L=function(){function A(y){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=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(D){return D}).join(",").replace(/\.[^.,]+/g,"")}return p(A,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(D){var _=D%this.url.length;this._urlId!==_&&(this.details=void 0,this._urlId=_)}}]),A}()},"./src/types/loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"PlaylistContextType",function(){return R}),h.d(P,"PlaylistLevelType",function(){return p});var R;(function(S){S.MANIFEST="manifest",S.LEVEL="level",S.AUDIO_TRACK="audioTrack",S.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var p;(function(S){S.MAIN="main",S.AUDIO="audio",S.SUBTITLE="subtitle"})(p||(p={}))},"./src/types/transmuxer.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"ChunkMetadata",function(){return R});var R=function(I,x,L,A,y,D){A===void 0&&(A=0),y===void 0&&(y=-1),D===void 0&&(D=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=p(),this.buffering={audio:p(),video:p(),audiovideo:p()},this.level=I,this.sn=x,this.id=L,this.size=A,this.part=y,this.partial=D};function p(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"AttrList",function(){return S});var R=/^(\d+)x(\d+)$/,p=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,S=function(){function I(L){typeof L=="string"&&(L=I.parseAttrList(L));for(var A in L)L.hasOwnProperty(A)&&(this[A]=L[A])}var x=I.prototype;return x.decimalInteger=function(A){var y=parseInt(this[A],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},x.hexadecimalInteger=function(A){if(this[A]){var y=(this[A]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var D=new Uint8Array(y.length/2),_=0;_<y.length/2;_++)D[_]=parseInt(y.slice(_*2,_*2+2),16);return D}else return null},x.hexadecimalIntegerAsNumber=function(A){var y=parseInt(this[A],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},x.decimalFloatingPoint=function(A){return parseFloat(this[A])},x.optionalFloat=function(A,y){var D=this[A];return D?parseFloat(D):y},x.enumeratedString=function(A){return this[A]},x.bool=function(A){return this[A]==="YES"},x.decimalResolution=function(A){var y=R.exec(this[A]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},I.parseAttrList=function(A){var y,D={},_='"';for(p.lastIndex=0;(y=p.exec(A))!==null;){var T=y[2];T.indexOf(_)===0&&T.lastIndexOf(_)===T.length-1&&(T=T.slice(1,-1)),D[y[1]]=T}return D},I}()},"./src/utils/binary-search.ts":function(K,P,h){"use strict";h.r(P);var R={search:function(S,I){for(var x=0,L=S.length-1,A=null,y=null;x<=L;){A=(x+L)/2|0,y=S[A];var D=I(y);if(D>0)x=A+1;else if(D<0)L=A-1;else return y}return null}};P.default=R},"./src/utils/buffer-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"BufferHelper",function(){return S});var R=h("./src/utils/logger.ts"),p={length:0,start:function(){return 0},end:function(){return 0}},S=function(){function I(){}return I.isBuffered=function(L,A){try{if(L){for(var y=I.getBuffered(L),D=0;D<y.length;D++)if(A>=y.start(D)&&A<=y.end(D))return!0}}catch{}return!1},I.bufferInfo=function(L,A,y){try{if(L){var D=I.getBuffered(L),_=[],T;for(T=0;T<D.length;T++)_.push({start:D.start(T),end:D.end(T)});return this.bufferedInfo(_,A,y)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},I.bufferedInfo=function(L,A,y){A=Math.max(0,A),L.sort(function(t,l){var d=t.start-l.start;return d||l.end-t.end});var D=[];if(y)for(var _=0;_<L.length;_++){var T=D.length;if(T){var g=D[T-1].end;L[_].start-g<y?L[_].end>g&&(D[T-1].end=L[_].end):D.push(L[_])}else D.push(L[_])}else D=L;for(var E=0,a,e=A,s=A,u=0;u<D.length;u++){var n=D[u].start,i=D[u].end;if(A+y>=n&&A<i)e=n,s=i,E=s-A;else if(A+y<n){a=n;break}}return{len:E,start:e||0,end:s||0,nextStart:a}},I.getBuffered=function(L){try{return L.buffered}catch(A){return R.logger.log("failed to get media.buffered",A),p}},I}()},"./src/utils/cea-608-parser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"Row",function(){return s}),h.d(P,"CaptionScreen",function(){return u});var R=h("./src/utils/logger.ts"),p={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},S=function(c){var f=c;return p.hasOwnProperty(c)&&(f=p[c]),String.fromCharCode(f)},I=15,x=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},D={25:2,26:4,29:6,30:8,31:10,27:13,28:15},_=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],T;(function(r){r[r.ERROR=0]="ERROR",r[r.TEXT=1]="TEXT",r[r.WARNING=2]="WARNING",r[r.INFO=2]="INFO",r[r.DEBUG=3]="DEBUG",r[r.DATA=3]="DATA"})(T||(T={}));var g=function(){function r(){this.time=null,this.verboseLevel=T.ERROR}var c=r.prototype;return c.log=function(o,v){this.verboseLevel>=o&&R.logger.log(this.time+" ["+o+"] "+v)},r}(),E=function(c){for(var f=[],o=0;o<c.length;o++)f.push(c[o].toString(16));return f},a=function(){function r(f,o,v,m,O){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=f||"white",this.underline=o||!1,this.italics=v||!1,this.background=m||"black",this.flash=O||!1}var c=r.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(o){for(var v=["foreground","underline","italics","background","flash"],m=0;m<v.length;m++){var O=v[m];o.hasOwnProperty(O)&&(this[O]=o[O])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},c.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},r}(),e=function(){function r(f,o,v,m,O,b){this.uchar=void 0,this.penState=void 0,this.uchar=f||" ",this.penState=new a(o,v,m,O,b)}var c=r.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(o,v){this.uchar=o,this.penState.copy(v)},c.setPenState=function(o){this.penState.copy(o)},c.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},c.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},r}(),s=function(){function r(f){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<x;o++)this.chars.push(new e);this.logger=f,this.pos=0,this.currPenState=new a}var c=r.prototype;return c.equals=function(o){for(var v=!0,m=0;m<x;m++)if(!this.chars[m].equals(o.chars[m])){v=!1;break}return v},c.copy=function(o){for(var v=0;v<x;v++)this.chars[v].copy(o.chars[v])},c.isEmpty=function(){for(var o=!0,v=0;v<x;v++)if(!this.chars[v].isEmpty()){o=!1;break}return o},c.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(T.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>x&&(this.logger.log(T.DEBUG,"Too large cursor position "+this.pos),this.pos=x)},c.moveCursor=function(o){var v=this.pos+o;if(o>1)for(var m=this.pos+1;m<v+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(v)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(o){o>=144&&this.backSpace();var v=S(o);if(this.pos>=x){this.logger.log(T.ERROR,"Cannot insert "+o.toString(16)+" ("+v+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(v,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(o){var v;for(v=o;v<x;v++)this.chars[v].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var o=[],v=!0,m=0;m<x;m++){var O=this.chars[m].uchar;O!==" "&&(v=!1),o.push(O)}return v?"":o.join("")},c.setPenStyles=function(o){this.currPenState.setStyles(o);var v=this.chars[this.pos];v.setPenState(this.currPenState)},r}(),u=function(){function r(f){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<I;o++)this.rows.push(new s(f));this.logger=f,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=r.prototype;return c.reset=function(){for(var o=0;o<I;o++)this.rows[o].clear();this.currRow=I-1},c.equals=function(o){for(var v=!0,m=0;m<I;m++)if(!this.rows[m].equals(o.rows[m])){v=!1;break}return v},c.copy=function(o){for(var v=0;v<I;v++)this.rows[v].copy(o.rows[v])},c.isEmpty=function(){for(var o=!0,v=0;v<I;v++)if(!this.rows[v].isEmpty()){o=!1;break}return o},c.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},c.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},c.insertChar=function(o){var v=this.rows[this.currRow];v.insertChar(o)},c.setPen=function(o){var v=this.rows[this.currRow];v.setPenStyles(o)},c.moveCursor=function(o){var v=this.rows[this.currRow];v.moveCursor(o)},c.setCursor=function(o){this.logger.log(T.INFO,"setCursor: "+o);var v=this.rows[this.currRow];v.setCursor(o)},c.setPAC=function(o){this.logger.log(T.INFO,"pacData = "+JSON.stringify(o));var v=o.row-1;if(this.nrRollUpRows&&v<this.nrRollUpRows-1&&(v=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==v){for(var m=0;m<I;m++)this.rows[m].clear();var O=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var M=b.rows[O].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var w=0;w<this.nrRollUpRows;w++)this.rows[v-this.nrRollUpRows+w+1].copy(b.rows[O+w])}}this.currRow=v;var C=this.rows[this.currRow];if(o.indent!==null){var U=o.indent,B=Math.max(U-1,0);C.setCursor(o.indent),o.color=C.chars[B].penState.foreground}var N={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(N)},c.setBkgData=function(o){this.logger.log(T.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},c.setRollUpRows=function(o){this.nrRollUpRows=o},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(T.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(T.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,v=this.rows.splice(o,1)[0];v.clear(),this.rows.splice(this.currRow,0,v),this.logger.log(T.INFO,"Rolling up")},c.getDisplayText=function(o){o=o||!1;for(var v=[],m="",O=-1,b=0;b<I;b++){var M=this.rows[b].getTextString();M&&(O=b+1,o?v.push("Row "+O+": '"+M+"'"):v.push(M.trim()))}return v.length>0&&(o?m="["+v.join(" | ")+"]":m=v.join(`
|
|
19
|
-
`)),m},c.getTextAndFormat=function(){return this.rows},r}(),n=function(){function r(f,o,v){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=f,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new u(v),this.nonDisplayedMemory=new u(v),this.lastOutputScreen=new u(v),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=v}var c=r.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(o){this.outputFilter=o},c.setPAC=function(o){this.writeScreen.setPAC(o)},c.setBkgData=function(o){this.writeScreen.setBkgData(o)},c.setMode=function(o){o!==this.mode&&(this.mode=o,this.logger.log(T.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o)},c.insertChars=function(o){for(var v=0;v<o.length;v++)this.writeScreen.insertChar(o[v]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(T.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(T.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(T.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){this.logger.log(T.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(T.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(o){this.logger.log(T.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},c.ccFON=function(){this.logger.log(T.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(T.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(T.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(T.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(T.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(T.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(T.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(T.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(T.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(o){this.logger.log(T.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},c.ccMIDROW=function(o){var v={flash:!1};if(v.underline=o%2===1,v.italics=o>=46,v.italics)v.foreground="white";else{var m=Math.floor(o/2)-16,O=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=O[m]}this.logger.log(T.INFO,"MIDROW: "+JSON.stringify(v)),this.writeScreen.setPen(v)},c.outputDataUpdate=function(o){o===void 0&&(o=!1);var v=this.logger.time;v!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=v:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,v,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:v),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},r}(),i=function(){function r(f,o,v){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new g;this.channels=[null,new n(f,o,m),new n(f+1,v,m)],this.cmdHistory=d(),this.logger=m}var c=r.prototype;return c.getHandler=function(o){return this.channels[o].getHandler()},c.setHandler=function(o,v){this.channels[o].setHandler(v)},c.addData=function(o,v){var m,O,b,M=!1;this.logger.time=o;for(var F=0;F<v.length;F+=2)if(O=v[F]&127,b=v[F+1]&127,!(O===0&&b===0)){if(this.logger.log(T.DATA,"["+E([v[F],v[F+1]])+"] -> ("+E([O,b])+")"),m=this.parseCmd(O,b),m||(m=this.parseMidrow(O,b)),m||(m=this.parsePAC(O,b)),m||(m=this.parseBackgroundAttributes(O,b)),!m&&(M=this.parseChars(O,b),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(T.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(T.WARNING,"Couldn't parse cleaned data "+E([O,b])+" orig: "+E([v[F],v[F+1]]))}},c.parseCmd=function(o,v){var m=this.cmdHistory,O=(o===20||o===28||o===21||o===29)&&v>=32&&v<=47,b=(o===23||o===31)&&v>=33&&v<=35;if(!(O||b))return!1;if(l(o,v,m))return t(null,null,m),this.logger.log(T.DEBUG,"Repeated command ("+E([o,v])+") is dropped"),!0;var M=o===20||o===21||o===23?1:2,F=this.channels[M];return o===20||o===21||o===28||o===29?v===32?F.ccRCL():v===33?F.ccBS():v===34?F.ccAOF():v===35?F.ccAON():v===36?F.ccDER():v===37?F.ccRU(2):v===38?F.ccRU(3):v===39?F.ccRU(4):v===40?F.ccFON():v===41?F.ccRDC():v===42?F.ccTR():v===43?F.ccRTD():v===44?F.ccEDM():v===45?F.ccCR():v===46?F.ccENM():v===47&&F.ccEOC():F.ccTO(v-32),t(o,v,m),this.currentChannel=M,!0},c.parseMidrow=function(o,v){var m=0;if((o===17||o===25)&&v>=32&&v<=47){if(o===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(T.ERROR,"Mismatch channel in midrow parsing"),!1;var O=this.channels[m];return O?(O.ccMIDROW(v),this.logger.log(T.DEBUG,"MIDROW ("+E([o,v])+")"),!0):!1}return!1},c.parsePAC=function(o,v){var m,O=this.cmdHistory,b=(o>=17&&o<=23||o>=25&&o<=31)&&v>=64&&v<=127,M=(o===16||o===24)&&v>=64&&v<=95;if(!(b||M))return!1;if(l(o,v,O))return t(null,null,O),!0;var F=o<=23?1:2;v>=64&&v<=95?m=F===1?L[o]:y[o]:m=F===1?A[o]:D[o];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(m,v)),t(o,v,O),this.currentChannel=F,!0):!1},c.interpretPAC=function(o,v){var m,O={color:null,italics:!1,indent:null,underline:!1,row:o};return v>95?m=v-96:m=v-64,O.underline=(m&1)===1,m<=13?O.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(O.italics=!0,O.color="white"):O.indent=Math.floor((m-16)/2)*4,O},c.parseChars=function(o,v){var m,O=null,b=null;if(o>=25?(m=2,b=o-8):(m=1,b=o),b>=17&&b<=19){var M;b===17?M=v+80:b===18?M=v+112:M=v+144,this.logger.log(T.INFO,"Special char '"+S(M)+"' in channel "+m),O=[M]}else o>=32&&o<=127&&(O=v===0?[o]:[o,v]);if(O){var F=E(O);this.logger.log(T.DEBUG,"Char codes = "+F.join(",")),t(o,v,this.cmdHistory)}return O},c.parseBackgroundAttributes=function(o,v){var m=(o===16||o===24)&&v>=32&&v<=47,O=(o===23||o===31)&&v>=45&&v<=47;if(!(m||O))return!1;var b,M={};o===16||o===24?(b=Math.floor((v-32)/2),M.background=_[b],v%2===1&&(M.background=M.background+"_semi")):v===45?M.background="transparent":(M.foreground="black",v===47&&(M.underline=!0));var F=o<=23?1:2,w=this.channels[F];return w.setBkgData(M),t(o,v,this.cmdHistory),!0},c.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var v=this.channels[o];v&&v.reset()}this.cmdHistory=d()},c.cueSplitAtTime=function(o){for(var v=0;v<this.channels.length;v++){var m=this.channels[v];m&&m.cueSplitAtTime(o)}},r}();function t(r,c,f){f.a=r,f.b=c}function l(r,c,f){return f.a===r&&f.b===c}function d(){return{a:null,b:null}}P.default=i},"./src/utils/codecs.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"isCodecType",function(){return p}),h.d(P,"isCodecSupportedInMp4",function(){return S});var R={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,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,dvav:!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}};function p(I,x){var L=R[x];return!!L&&L[I.slice(0,4)]===!0}function S(I,x){return MediaSource.isTypeSupported((x||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/vttparser.ts"),p=h("./src/utils/webvtt-parser.ts"),S=h("./src/utils/texttrack-utils.ts"),I=/\s/,x={newCue:function(A,y,D,_){for(var T=[],g,E,a,e,s,u=self.VTTCue||self.TextTrackCue,n=0;n<_.rows.length;n++)if(g=_.rows[n],a=!0,e=0,s="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)I.test(g.chars[i].uchar)&&a?e++:(s+=g.chars[i].uchar,a=!1);g.cueStartTime=y,y===D&&(D+=1e-4),e>=16?e--:e++;var t=Object(R.fixLineBreaks)(s.trim()),l=Object(p.generateCueId)(y,D,t);(!A||!A.cues||!A.cues.getCueById(l))&&(E=new u(y,D,t),E.id=l,E.line=n+1,E.align="left",E.position=10+Math.min(80,Math.floor(e*8/32)*10),T.push(E))}return A&&T.length&&(T.sort(function(d,r){return d.line==="auto"||r.line==="auto"?0:d.line>8&&r.line>8?r.line-d.line:d.line-r.line}),T.forEach(function(d){return Object(S.addCueToTrack)(A,d)})),T}};P.default=x},"./src/utils/discontinuities.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"findFirstFragWithCC",function(){return I}),h.d(P,"shouldAlignOnDiscontinuities",function(){return x}),h.d(P,"findDiscontinuousReferenceFrag",function(){return L}),h.d(P,"adjustSlidingStart",function(){return y}),h.d(P,"alignStream",function(){return D}),h.d(P,"alignPDT",function(){return T}),h.d(P,"alignFragmentByPDTDelta",function(){return g}),h.d(P,"alignMediaPlaylistByPDT",function(){return E});var R=h("./src/polyfills/number.ts"),p=h("./src/utils/logger.ts"),S=h("./src/controller/level-helper.ts");function I(a,e){for(var s=null,u=0,n=a.length;u<n;u++){var i=a[u];if(i&&i.cc===e){s=i;break}}return s}function x(a,e,s){return!!(e.details&&(s.endCC>s.startCC||a&&a.cc<s.startCC))}function L(a,e){var s=a.fragments,u=e.fragments;if(!u.length||!s.length){p.logger.log("No fragments to align");return}var n=I(s,u[0].cc);if(!n||n&&!n.startPTS){p.logger.log("No frag in previous level to align on");return}return n}function A(a,e){if(a){var s=a.start+e;a.start=a.startPTS=s,a.endPTS=s+a.duration}}function y(a,e){for(var s=e.fragments,u=0,n=s.length;u<n;u++)A(s[u],a);e.fragmentHint&&A(e.fragmentHint,a),e.alignedSliding=!0}function D(a,e,s){!e||(_(a,s,e),!s.alignedSliding&&e.details&&T(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(S.adjustSliding)(e.details,s))}function _(a,e,s){if(x(a,s,e)){var u=L(s.details,e);u&&Object(R.isFiniteNumber)(u.start)&&(p.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(u.start,e))}}function T(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,u=a.fragments[0].programDateTime,n=(u-s)/1e3+e.fragments[0].start;n&&Object(R.isFiniteNumber)(n)&&(p.logger.log("Adjusting PTS using programDateTime delta "+(u-s)+"ms, sliding:"+n.toFixed(3)+" "+a.url+" "),y(n,a))}}function g(a,e){var s=a.programDateTime;if(!!s){var u=(s-e)/1e3;a.start=a.startPTS=u,a.endPTS=u+a.duration}}function E(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,u=e.fragments[0].start,n=s-u*1e3;a.fragments.forEach(function(i){g(i,n)}),a.fragmentHint&&g(a.fragmentHint,n),a.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/ewma.ts"),p=function(){function S(x,L,A){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=A,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new R.default(x),this.fast_=new R.default(L)}var I=S.prototype;return I.update=function(L,A){var y=this.slow_,D=this.fast_;this.slow_.halfLife!==L&&(this.slow_=new R.default(L,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==A&&(this.fast_=new R.default(A,D.getEstimate(),D.getTotalWeight()))},I.sample=function(L,A){L=Math.max(L,this.minDelayMs_);var y=8*A,D=L/1e3,_=y/D;this.fast_.sample(D,_),this.slow_.sample(D,_)},I.canEstimate=function(){var L=this.fast_;return L&&L.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},S}();P.default=p},"./src/utils/ewma.ts":function(K,P,h){"use strict";h.r(P);var R=function(){function p(I,x,L){x===void 0&&(x=0),L===void 0&&(L=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=I,this.alpha_=I?Math.exp(Math.log(.5)/I):0,this.estimate_=x,this.totalWeight_=L}var S=p.prototype;return S.sample=function(x,L){var A=Math.pow(this.alpha_,x);this.estimate_=L*(1-A)+A*this.estimate_,this.totalWeight_+=x},S.getTotalWeight=function(){return this.totalWeight_},S.getEstimate=function(){if(this.alpha_){var x=1-Math.pow(this.alpha_,this.totalWeight_);if(x)return this.estimate_/x}return this.estimate_},p}();P.default=R},"./src/utils/fetch-loader.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"fetchSupported",function(){return g});var R=h("./src/polyfills/number.ts"),p=h("./src/loader/load-stats.ts"),S=h("./src/demux/chunk-cache.ts");function I(u,n){u.prototype=Object.create(n.prototype),u.prototype.constructor=u,D(u,n)}function x(u){var n=typeof Map=="function"?new Map:void 0;return x=function(t){if(t===null||!y(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n!="undefined"){if(n.has(t))return n.get(t);n.set(t,l)}function l(){return L(t,arguments,_(this).constructor)}return l.prototype=Object.create(t.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),D(l,t)},x(u)}function L(u,n,i){return A()?L=Reflect.construct.bind():L=function(l,d,r){var c=[null];c.push.apply(c,d);var f=Function.bind.apply(l,c),o=new f;return r&&D(o,r.prototype),o},L.apply(null,arguments)}function A(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function D(u,n){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,l){return t.__proto__=l,t},D(u,n)}function _(u){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},_(u)}function T(){return T=Object.assign?Object.assign.bind():function(u){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(u[t]=i[t])}return u},T.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var E=function(){function u(i){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=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new p.LoadStats}var n=u.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(t,l,d){var r=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var f=a(t,this.controller.signal),o=d.onProgress,v=t.responseType==="arraybuffer",m=v?"byteLength":"length";this.context=t,this.config=l,this.callbacks=d,this.request=this.fetchSetup(t,f),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){r.abortInternal(),d.onTimeout(c,t,r.response)},l.timeout),self.fetch(this.request).then(function(O){if(r.response=r.loader=O,!O.ok){var b=O.status,M=O.statusText;throw new s(M||"fetch, bad network response",b,O)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(O.headers.get("Content-Length")||"0"),o&&Object(R.isFiniteNumber)(l.highWaterMark)?r.loadProgressively(O,c,t,l.highWaterMark,o):v?O.arrayBuffer():O.text()}).then(function(O){var b=r.response;self.clearTimeout(r.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=O[m];var M={url:b.url,data:O};o&&!Object(R.isFiniteNumber)(l.highWaterMark)&&o(c,t,O,b),d.onSuccess(M,c,t,b)}).catch(function(O){if(self.clearTimeout(r.requestTimeout),!c.aborted){var b=O&&O.code||0,M=O?O.message:null;d.onError({code:b,text:M},t,O?O.details:null)}})},n.getCacheAge=function(){var t=null;if(this.response){var l=this.response.headers.get("age");t=l?parseFloat(l):null}return t},n.loadProgressively=function(t,l,d,r,c){r===void 0&&(r=0);var f=new S.default,o=t.body.getReader(),v=function m(){return o.read().then(function(O){if(O.done)return f.dataLength&&c(l,d,f.flush(),t),Promise.resolve(new ArrayBuffer(0));var b=O.value,M=b.length;return l.loaded+=M,M<r||f.dataLength?(f.push(b),f.dataLength>=r&&c(l,d,f.flush(),t)):c(l,d,b,t),m()}).catch(function(){return Promise.reject()})};return v()},u}();function a(u,n){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:n,headers:new self.Headers(T({},u.headers))};return u.rangeEnd&&i.headers.set("Range","bytes="+u.rangeStart+"-"+String(u.rangeEnd-1)),i}function e(u,n){return new self.Request(u.url,n)}var s=function(u){I(n,u);function n(i,t,l){var d;return d=u.call(this,i)||this,d.code=void 0,d.details=void 0,d.code=t,d.details=l,d}return n}(x(Error));P.default=E},"./src/utils/imsc1-ttml-parser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"IMSC1_CODEC",function(){return y}),h.d(P,"parseIMSC1",function(){return g});var R=h("./src/utils/mp4-tools.ts"),p=h("./src/utils/vttparser.ts"),S=h("./src/utils/vttcue.ts"),I=h("./src/demux/id3.ts"),x=h("./src/utils/timescale-conversion.ts"),L=h("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(r){for(var c=1;c<arguments.length;c++){var f=arguments[c];for(var o in f)Object.prototype.hasOwnProperty.call(f,o)&&(r[o]=f[o])}return r},A.apply(this,arguments)}var y="stpp.ttml.im1t",D=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,_=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,T={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(r,c,f,o,v){var m=Object(R.findBox)(new Uint8Array(r),["mdat"]);if(m.length===0){v(new Error("Could not parse IMSC1 mdat"));return}var O=m.map(function(M){return Object(I.utf8ArrayToStr)(M)}),b=Object(x.toTimescaleFromScale)(c,1,f);try{O.forEach(function(M){return o(E(M,b))})}catch(M){v(M)}}function E(r,c){var f=new DOMParser,o=f.parseFromString(r,"text/xml"),v=o.getElementsByTagName("tt")[0];if(!v)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(m).reduce(function(C,U){return C[U]=v.getAttribute("ttp:"+U)||m[U],C},{}),b=v.getAttribute("xml:space")!=="preserve",M=e(a(v,"styling","style")),F=e(a(v,"layout","region")),w=a(v,"body","[begin]");return[].map.call(w,function(C){var U=s(C,b);if(!U||!C.hasAttribute("begin"))return null;var B=t(C.getAttribute("begin"),O),N=t(C.getAttribute("dur"),O),k=t(C.getAttribute("end"),O);if(B===null)throw i(C);if(k===null){if(N===null)throw i(C);k=B+N}var j=new S.default(B-c,k-c,U);j.id=Object(L.generateCueId)(j.startTime,j.endTime,j.text);var H=F[C.getAttribute("region")],V=M[C.getAttribute("style")];j.position=10,j.size=80;var Y=u(H,V,M),Q=Y.textAlign;if(Q){var J=T[Q];J&&(j.lineAlign=J),j.align=Q}return A(j,Y),j}).filter(function(C){return C!==null})}function a(r,c,f){var o=r.getElementsByTagName(c)[0];return o?[].slice.call(o.querySelectorAll(f)):[]}function e(r){return r.reduce(function(c,f){var o=f.getAttribute("xml:id");return o&&(c[o]=f),c},{})}function s(r,c){return[].slice.call(r.childNodes).reduce(function(f,o,v){var m;return o.nodeName==="br"&&v?f+`
|
|
20
|
-
`:(m=o.childNodes)!==null&&m!==void 0&&m.length?s(o,c):c?f+o.textContent.trim().replace(/\s+/g," "):f+o.textContent},"")}function u(r,c,f){var o="http://www.w3.org/ns/ttml#styling",v=null,m=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],O=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return O&&f.hasOwnProperty(O)&&(v=f[O]),m.reduce(function(b,M){var F=n(c,o,M)||n(r,o,M)||n(v,o,M);return F&&(b[M]=F),b},{})}function n(r,c,f){return r&&r.hasAttributeNS(c,f)?r.getAttributeNS(c,f):null}function i(r){return new Error("Could not parse ttml timestamp "+r)}function t(r,c){if(!r)return null;var f=Object(p.parseTimeStamp)(r);return f===null&&(D.test(r)?f=l(r,c):_.test(r)&&(f=d(r,c))),f}function l(r,c){var f=D.exec(r),o=(f[4]|0)+(f[5]|0)/c.subFrameRate;return(f[1]|0)*3600+(f[2]|0)*60+(f[3]|0)+o/c.frameRate}function d(r,c){var f=_.exec(r),o=Number(f[1]),v=f[2];switch(v){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/c.frameRate;case"t":return o/c.tickRate}return o}},"./src/utils/logger.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"enableLogs",function(){return L}),h.d(P,"logger",function(){return A});var R=function(){},p={trace:R,debug:R,log:R,warn:R,info:R,error:R},S=p;function I(y){var D=self.console[y];return D?D.bind(self.console,"["+y+"] >"):R}function x(y){for(var D=arguments.length,_=new Array(D>1?D-1:0),T=1;T<D;T++)_[T-1]=arguments[T];_.forEach(function(g){S[g]=y[g]?y[g].bind(y):I(g)})}function L(y){if(self.console&&y===!0||typeof y=="object"){x(y,"debug","log","info","warn","error");try{S.log()}catch{S=p}}else S=p}var A=S},"./src/utils/mediakeys-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"KeySystems",function(){return R}),h.d(P,"requestMediaKeySystemAccess",function(){return p});var R;(function(S){S.WIDEVINE="com.widevine.alpha",S.PLAYREADY="com.microsoft.playready"})(R||(R={}));var p=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"RemuxerTrackIdConfig",function(){return L}),h.d(P,"bin2str",function(){return A}),h.d(P,"readUint16",function(){return y}),h.d(P,"readUint32",function(){return D}),h.d(P,"readSint32",function(){return _}),h.d(P,"writeUint32",function(){return T}),h.d(P,"findBox",function(){return g}),h.d(P,"parseSegmentIndex",function(){return E}),h.d(P,"parseInitSegment",function(){return a}),h.d(P,"getStartDTS",function(){return e}),h.d(P,"getDuration",function(){return s}),h.d(P,"computeRawDurationFromSamples",function(){return u}),h.d(P,"offsetStartDTS",function(){return n}),h.d(P,"segmentValidRange",function(){return i}),h.d(P,"appendUint8Array",function(){return t}),h.d(P,"parseSamples",function(){return l}),h.d(P,"parseSEIMessageFromNALu",function(){return c}),h.d(P,"parseEmsg",function(){return o});var R=h("./src/utils/typed-array.ts"),p=h("./src/loader/fragment.ts"),S=h("./src/demux/id3.ts"),I=Math.pow(2,32)-1,x=[].push,L={video:1,audio:2,id3:3,text:4};function A(v){return String.fromCharCode.apply(null,v)}function y(v,m){var O=v[m]<<8|v[m+1];return O<0?65536+O:O}function D(v,m){var O=_(v,m);return O<0?4294967296+O:O}function _(v,m){return v[m]<<24|v[m+1]<<16|v[m+2]<<8|v[m+3]}function T(v,m,O){v[m]=O>>24,v[m+1]=O>>16&255,v[m+2]=O>>8&255,v[m+3]=O&255}function g(v,m){var O=[];if(!m.length)return O;for(var b=v.byteLength,M=0;M<b;){var F=D(v,M),w=A(v.subarray(M+4,M+8)),C=F>1?M+F:b;if(w===m[0])if(m.length===1)O.push(v.subarray(M+8,C));else{var U=g(v.subarray(M+8,C),m.slice(1));U.length&&x.apply(O,U)}M=C}return O}function E(v){var m=[],O=v[0],b=8,M=D(v,b);b+=4;var F=0,w=0;O===0?b+=8:b+=16,b+=2;var C=v.length+w,U=y(v,b);b+=2;for(var B=0;B<U;B++){var N=b,k=D(v,N);N+=4;var j=k&2147483647,H=(k&2147483648)>>>31;if(H===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var V=D(v,N);N+=4,m.push({referenceSize:j,subsegmentDuration:V,info:{duration:V/M,start:C,end:C+j-1}}),C+=j,N+=4,b=N}return{earliestPresentationTime:F,timescale:M,version:O,referencesCount:U,references:m}}function a(v){for(var m=[],O=g(v,["moov","trak"]),b=0;b<O.length;b++){var M=O[b],F=g(M,["tkhd"])[0];if(F){var w=F[0],C=w===0?12:20,U=D(F,C),B=g(M,["mdia","mdhd"])[0];if(B){w=B[0],C=w===0?12:20;var N=D(B,C),k=g(M,["mdia","hdlr"])[0];if(k){var j=A(k.subarray(8,12)),H={soun:p.ElementaryStreamTypes.AUDIO,vide:p.ElementaryStreamTypes.VIDEO}[j];if(H){var V=g(M,["mdia","minf","stbl","stsd"])[0],Y=void 0;V&&(Y=A(V.subarray(12,16))),m[U]={timescale:N,type:H},m[H]={timescale:N,id:U,codec:Y}}}}}}var Q=g(v,["moov","mvex","trex"]);return Q.forEach(function(J){var z=D(J,4),q=m[z];q&&(q.default={duration:D(J,12),flags:D(J,20)})}),m}function e(v,m){return g(m,["moof","traf"]).reduce(function(O,b){var M=g(b,["tfdt"])[0],F=M[0],w=g(b,["tfhd"]).reduce(function(C,U){var B=D(U,4),N=v[B];if(N){var k=D(M,4);F===1&&(k*=Math.pow(2,32),k+=D(M,8));var j=N.timescale||9e4,H=k/j;if(isFinite(H)&&(C===null||H<C))return H}return C},null);return w!==null&&isFinite(w)&&(O===null||w<O)?w:O},null)||0}function s(v,m){for(var O=0,b=0,M=0,F=g(v,["moof","traf"]),w=0;w<F.length;w++){var C=F[w],U=g(C,["tfhd"])[0],B=D(U,4),N=m[B];if(!!N){var k=N.default,j=D(U,0)|(k==null?void 0:k.flags),H=k==null?void 0:k.duration;j&8&&(j&2?H=D(U,12):H=D(U,8));for(var V=N.timescale||9e4,Y=g(C,["trun"]),Q=0;Q<Y.length;Q++){if(O=u(Y[Q]),!O&&H){var J=D(Y[Q],4);O=H*J}N.type===p.ElementaryStreamTypes.VIDEO?b+=O/V:N.type===p.ElementaryStreamTypes.AUDIO&&(M+=O/V)}}}if(b===0&&M===0){for(var z=0,q=g(v,["sidx"]),re=0;re<q.length;re++){var X=E(q[re]);X!=null&&X.references&&(z+=X.references.reduce(function(le,ne){return le+ne.info.duration||0},0))}return z}return b||M}function u(v){var m=D(v,0),O=8;m&1&&(O+=4),m&4&&(O+=4);for(var b=0,M=D(v,4),F=0;F<M;F++){if(m&256){var w=D(v,O);b+=w,O+=4}m&512&&(O+=4),m&1024&&(O+=4),m&2048&&(O+=4)}return b}function n(v,m,O){g(m,["moof","traf"]).forEach(function(b){g(b,["tfhd"]).forEach(function(M){var F=D(M,4),w=v[F];if(!!w){var C=w.timescale||9e4;g(b,["tfdt"]).forEach(function(U){var B=U[0],N=D(U,4);if(B===0)N-=O*C,N=Math.max(N,0),T(U,4,N);else{N*=Math.pow(2,32),N+=D(U,8),N-=O*C,N=Math.max(N,0);var k=Math.floor(N/(I+1)),j=Math.floor(N%(I+1));T(U,4,k),T(U,8,j)}})}})})}function i(v){var m={valid:null,remainder:null},O=g(v,["moof"]);if(O){if(O.length<2)return m.remainder=v,m}else return m;var b=O[O.length-1];return m.valid=Object(R.sliceUint8)(v,0,b.byteOffset-8),m.remainder=Object(R.sliceUint8)(v,b.byteOffset-8),m}function t(v,m){var O=new Uint8Array(v.length+m.length);return O.set(v),O.set(m,v.length),O}function l(v,m){var O=[],b=m.samples,M=m.timescale,F=m.id,w=!1,C=g(b,["moof"]);return C.map(function(U){var B=U.byteOffset-8,N=g(U,["traf"]);N.map(function(k){var j=g(k,["tfdt"]).map(function(H){var V=H[0],Y=D(H,4);return V===1&&(Y*=Math.pow(2,32),Y+=D(H,8)),Y/M})[0];return j!==void 0&&(v=j),g(k,["tfhd"]).map(function(H){var V=D(H,4),Y=D(H,0)&16777215,Q=(Y&1)!==0,J=(Y&2)!==0,z=(Y&8)!==0,q=0,re=(Y&16)!==0,X=0,le=(Y&32)!==0,ne=8;V===F&&(Q&&(ne+=8),J&&(ne+=4),z&&(q=D(H,ne),ne+=4),re&&(X=D(H,ne),ne+=4),le&&(ne+=4),m.type==="video"&&(w=d(m.codec)),g(k,["trun"]).map(function(te){var ee=te[0],$=D(te,0)&16777215,Z=($&1)!==0,ue=0,he=($&4)!==0,se=($&256)!==0,me=0,pe=($&512)!==0,Ee=0,ae=($&1024)!==0,fe=($&2048)!==0,ge=0,ve=D(te,4),Te=8;Z&&(ue=D(te,Te),Te+=4),he&&(Te+=4);for(var _e=ue+B,Oe=0;Oe<ve;Oe++){if(se?(me=D(te,Te),Te+=4):me=q,pe?(Ee=D(te,Te),Te+=4):Ee=X,ae&&(Te+=4),fe&&(ee===0?ge=D(te,Te):ge=_(te,Te),Te+=4),m.type===p.ElementaryStreamTypes.VIDEO)for(var xe=0;xe<Ee;){var ye=D(b,_e);_e+=4;var W=b[_e]&31;if(r(w,W)){var G=b.subarray(_e,_e+ye);c(G,v+ge/M,O)}_e+=ye,xe+=ye+4}v+=me/M}}))})})}),O}function d(v){if(!v)return!1;var m=v.indexOf("."),O=m<0?v:v.substring(0,m);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}function r(v,m){return v?m===39||m===40:m===6}function c(v,m,O){var b=f(v),M=0;M++;for(var F=0,w=0,C=!1,U=0;M<b.length;){F=0;do{if(M>=b.length)break;U=b[M++],F+=U}while(U===255);w=0;do{if(M>=b.length)break;U=b[M++],w+=U}while(U===255);var B=b.length-M;if(!C&&F===4&&M<b.length){C=!0;var N=b[M++];if(N===181){var k=y(b,M);if(M+=2,k===49){var j=D(b,M);if(M+=4,j===1195456820){var H=b[M++];if(H===3){var V=b[M++],Y=31&V,Q=64&V,J=Q?2+Y*3:0,z=new Uint8Array(J);if(Q){z[0]=V;for(var q=1;q<J;q++)z[q]=b[M++]}O.push({type:H,payloadType:F,pts:m,bytes:z})}}}}}else if(F===5&&w<B){if(C=!0,w>16){for(var re=[],X=0;X<16;X++){var le=b[M++].toString(16);re.push(le.length==1?"0"+le:le),(X===3||X===5||X===7||X===9)&&re.push("-")}for(var ne=w-16,te=new Uint8Array(ne),ee=0;ee<ne;ee++)te[ee]=b[M++];O.push({payloadType:F,pts:m,uuid:re.join(""),userData:Object(S.utf8ArrayToStr)(te),userDataBytes:te})}}else if(w<B)M+=w;else if(w>B)break}}function f(v){for(var m=v.byteLength,O=[],b=1;b<m-2;)v[b]===0&&v[b+1]===0&&v[b+2]===3?(O.push(b+2),b+=2):b++;if(O.length===0)return v;var M=m-O.length,F=new Uint8Array(M),w=0;for(b=0;b<M;w++,b++)w===O[0]&&(w++,O.shift()),F[b]=v[w];return F}function o(v){var m=v[0],O="",b="",M=0,F=0,w=0,C=0,U=0,B=0;if(m===0){for(;A(v.subarray(B,B+1))!=="\0";)O+=A(v.subarray(B,B+1)),B+=1;for(O+=A(v.subarray(B,B+1)),B+=1;A(v.subarray(B,B+1))!=="\0";)b+=A(v.subarray(B,B+1)),B+=1;b+=A(v.subarray(B,B+1)),B+=1,M=D(v,12),F=D(v,16),C=D(v,20),U=D(v,24),B=28}else if(m===1){B+=4,M=D(v,B),B+=4;var N=D(v,B);B+=4;var k=D(v,B);for(B+=4,w=Math.pow(2,32)*N+k,Number.isSafeInteger(w)||(w=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),C=D(v,B),B+=4,U=D(v,B),B+=4;A(v.subarray(B,B+1))!=="\0";)O+=A(v.subarray(B,B+1)),B+=1;for(O+=A(v.subarray(B,B+1)),B+=1;A(v.subarray(B,B+1))!=="\0";)b+=A(v.subarray(B,B+1)),B+=1;b+=A(v.subarray(B,B+1)),B+=1}var j=v.subarray(B,v.byteLength);return{schemeIdUri:O,value:b,timeScale:M,presentationTime:w,presentationTimeDelta:F,eventDuration:C,id:U,payload:j}}},"./src/utils/output-filter.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"default",function(){return R});var R=function(){function p(I,x){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=I,this.trackName=x}var S=p.prototype;return S.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},S.newCue=function(x,L,A){(this.startTime===null||this.startTime>x)&&(this.startTime=x),this.endTime=L,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},S.reset=function(){this.cueRanges=[],this.startTime=null},p}()},"./src/utils/texttrack-utils.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"sendAddTrackEvent",function(){return p}),h.d(P,"addCueToTrack",function(){return S}),h.d(P,"clearCurrentCues",function(){return I}),h.d(P,"removeCuesInRange",function(){return x}),h.d(P,"getCuesInRange",function(){return A});var R=h("./src/utils/logger.ts");function p(y,D){var _;try{_=new Event("addtrack")}catch{_=document.createEvent("Event"),_.initEvent("addtrack",!1,!1)}_.track=y,D.dispatchEvent(_)}function S(y,D){var _=y.mode;if(_==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(D.id))try{if(y.addCue(D),!y.cues.getCueById(D.id))throw new Error("addCue is failed for: "+D)}catch(g){R.logger.debug("[texttrack-utils]: "+g);var T=new self.TextTrackCue(D.startTime,D.endTime,D.text);T.id=D.id,y.addCue(T)}_==="disabled"&&(y.mode=_)}function I(y){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues)for(var _=y.cues.length;_--;)y.removeCue(y.cues[_]);D==="disabled"&&(y.mode=D)}function x(y,D,_,T){var g=y.mode;if(g==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var E=A(y.cues,D,_),a=0;a<E.length;a++)(!T||T(E[a]))&&y.removeCue(E[a]);g==="disabled"&&(y.mode=g)}function L(y,D){if(D<y[0].startTime)return 0;var _=y.length-1;if(D>y[_].endTime)return-1;for(var T=0,g=_;T<=g;){var E=Math.floor((g+T)/2);if(D<y[E].startTime)g=E-1;else if(D>y[E].startTime&&T<_)T=E+1;else return E}return y[T].startTime-D<D-y[g].startTime?T:g}function A(y,D,_){var T=[],g=L(y,D);if(g>-1)for(var E=g,a=y.length;E<a;E++){var e=y[E];if(e.startTime>=D&&e.endTime<=_)T.push(e);else if(e.startTime>_)return T}return T}},"./src/utils/time-ranges.ts":function(K,P,h){"use strict";h.r(P);var R={toString:function(S){for(var I="",x=S.length,L=0;L<x;L++)I+="["+S.start(L).toFixed(3)+","+S.end(L).toFixed(3)+"]";return I}};P.default=R},"./src/utils/timescale-conversion.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"toTimescaleFromBase",function(){return p}),h.d(P,"toTimescaleFromScale",function(){return S}),h.d(P,"toMsFromMpegTsClock",function(){return I}),h.d(P,"toMpegTsClockFromTimescale",function(){return x});var R=9e4;function p(L,A,y,D){y===void 0&&(y=1),D===void 0&&(D=!1);var _=L*A*y;return D?Math.round(_):_}function S(L,A,y,D){return y===void 0&&(y=1),D===void 0&&(D=!1),p(L,A,1/y,D)}function I(L,A){return A===void 0&&(A=!1),p(L,1e3,1/R,A)}function x(L,A){return A===void 0&&(A=1),p(L,R,1/A)}},"./src/utils/typed-array.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"sliceUint8",function(){return R});function R(p,S,I){return Uint8Array.prototype.slice?p.slice(S,I):new Uint8Array(Array.prototype.slice.call(p,S,I))}},"./src/utils/vttcue.ts":function(K,P,h){"use strict";h.r(P),P.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],p=["start","middle","end","left","right"];function S(y,D){if(typeof D!="string"||!Array.isArray(y))return!1;var _=D.toLowerCase();return~y.indexOf(_)?_:!1}function I(y){return S(R,y)}function x(y){return S(p,y)}function L(y){for(var D=arguments.length,_=new Array(D>1?D-1:0),T=1;T<D;T++)_[T-1]=arguments[T];for(var g=1;g<arguments.length;g++){var E=arguments[g];for(var a in E)y[a]=E[a]}return y}function A(y,D,_){var T=this,g={enumerable:!0};T.hasBeenReset=!1;var E="",a=!1,e=y,s=D,u=_,n=null,i="",t=!0,l="auto",d="start",r=50,c="middle",f=50,o="middle";Object.defineProperty(T,"id",L({},g,{get:function(){return E},set:function(m){E=""+m}})),Object.defineProperty(T,"pauseOnExit",L({},g,{get:function(){return a},set:function(m){a=!!m}})),Object.defineProperty(T,"startTime",L({},g,{get:function(){return e},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");e=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"endTime",L({},g,{get:function(){return s},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");s=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"text",L({},g,{get:function(){return u},set:function(m){u=""+m,this.hasBeenReset=!0}})),Object.defineProperty(T,"region",L({},g,{get:function(){return n},set:function(m){n=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"vertical",L({},g,{get:function(){return i},set:function(m){var O=I(m);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=O,this.hasBeenReset=!0}})),Object.defineProperty(T,"snapToLines",L({},g,{get:function(){return t},set:function(m){t=!!m,this.hasBeenReset=!0}})),Object.defineProperty(T,"line",L({},g,{get:function(){return l},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"lineAlign",L({},g,{get:function(){return d},set:function(m){var O=x(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");d=O,this.hasBeenReset=!0}})),Object.defineProperty(T,"position",L({},g,{get:function(){return r},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");r=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"positionAlign",L({},g,{get:function(){return c},set:function(m){var O=x(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");c=O,this.hasBeenReset=!0}})),Object.defineProperty(T,"size",L({},g,{get:function(){return f},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");f=m,this.hasBeenReset=!0}})),Object.defineProperty(T,"align",L({},g,{get:function(){return o},set:function(m){var O=x(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");o=O,this.hasBeenReset=!0}})),T.displayState=void 0}return A.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},A}()},"./src/utils/vttparser.ts":function(K,P,h){"use strict";h.r(P),h.d(P,"parseTimeStamp",function(){return S}),h.d(P,"fixLineBreaks",function(){return D}),h.d(P,"VTTParser",function(){return _});var R=h("./src/utils/vttcue.ts"),p=function(){function T(){}var g=T.prototype;return g.decode=function(a,e){if(!a)return"";if(typeof a!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(a))},T}();function S(T){function g(a,e,s,u){return(a|0)*3600+(e|0)*60+(s|0)+parseFloat(u||0)}var E=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return E?parseFloat(E[2])>59?g(E[2],E[3],0,E[4]):g(E[1],E[2],E[3],E[4]):null}var I=function(){function T(){this.values=Object.create(null)}var g=T.prototype;return g.set=function(a,e){!this.get(a)&&e!==""&&(this.values[a]=e)},g.get=function(a,e,s){return s?this.has(a)?this.values[a]:e[s]:this.has(a)?this.values[a]:e},g.has=function(a){return a in this.values},g.alt=function(a,e,s){for(var u=0;u<s.length;++u)if(e===s[u]){this.set(a,e);break}},g.integer=function(a,e){/^-?\d+$/.test(e)&&this.set(a,parseInt(e,10))},g.percent=function(a,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(a,s),!0}return!1},T}();function x(T,g,E,a){var e=a?T.split(a):[T];for(var s in e)if(typeof e[s]=="string"){var u=e[s].split(E);if(u.length===2){var n=u[0],i=u[1];g(n,i)}}}var L=new R.default(0,0,""),A=L.align==="middle"?"middle":"center";function y(T,g,E){var a=T;function e(){var n=S(T);if(n===null)throw new Error("Malformed timestamp: "+a);return T=T.replace(/^[^\sa-zA-Z-]+/,""),n}function s(n,i){var t=new I;x(n,function(r,c){var f;switch(r){case"region":for(var o=E.length-1;o>=0;o--)if(E[o].id===c){t.set(r,E[o].region);break}break;case"vertical":t.alt(r,c,["rl","lr"]);break;case"line":f=c.split(","),t.integer(r,f[0]),t.percent(r,f[0])&&t.set("snapToLines",!1),t.alt(r,f[0],["auto"]),f.length===2&&t.alt("lineAlign",f[1],["start",A,"end"]);break;case"position":f=c.split(","),t.percent(r,f[0]),f.length===2&&t.alt("positionAlign",f[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":t.percent(r,c);break;case"align":t.alt(r,c,["start",A,"end","left","right"]);break}},/:/,/\s/),i.region=t.get("region",null),i.vertical=t.get("vertical","");var l=t.get("line","auto");l==="auto"&&L.line===-1&&(l=-1),i.line=l,i.lineAlign=t.get("lineAlign","start"),i.snapToLines=t.get("snapToLines",!0),i.size=t.get("size",100),i.align=t.get("align",A);var d=t.get("position","auto");d==="auto"&&L.position===50&&(d=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=d}function u(){T=T.replace(/^\s+/,"")}if(u(),g.startTime=e(),u(),T.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+a);T=T.slice(3),u(),g.endTime=e(),u(),s(T,g)}function D(T){return T.replace(/<br(?: \/)?>/gi,`
|
|
21
|
-
`)}var
|
|
18
|
+
initSegmentChange: `+H);var Y=new I.TransmuxConfig(u,n,s,l,c);this.configureTransmuxer(Y)}if(this.frag=i,this.part=t,O)O.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:r,state:V},e instanceof ArrayBuffer?[e]:[]);else if(m){var Q=m.push(e,M,r,V);Object(I.isPromise)(Q)?Q.then(function(J){v.handleTransmuxComplete(J)}):this.handleTransmuxComplete(Q)}},E.flush=function(e){var s=this;e.transmuxing.start=self.performance.now();var u=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(u){var i=u.flush(e);Object(I.isPromise)(i)?i.then(function(t){s.handleFlushResult(t,e)}):this.handleFlushResult(i,e)}},E.handleFlushResult=function(e,s){var u=this;e.forEach(function(n){u.handleTransmuxComplete(n)}),this.onFlush(s)},E.onWorkerMessage=function(e){var s=e.data,u=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":T.logger[s.data.logType]&&T.logger[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,u.trigger(s.event,s.data);break}}},E.configureTransmuxer=function(e){var s=this.worker,u=this.transmuxer;s?s.postMessage({cmd:"configure",config:e}):u&&u.configure(e)},E.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return _});var P=h("./src/demux/transmuxer.ts"),p=h("./src/events.ts"),x=h("./src/utils/logger.ts"),I=h("./node_modules/eventemitter3/index.js"),T=h.n(I);function _(S){var g=new I.EventEmitter,E=function(s,u){S.postMessage({event:s,data:u})};g.on(p.Events.FRAG_DECRYPTED,E),g.on(p.Events.ERROR,E);var a=function(){var s=function(i){var t=function(d){E("workerLog",{logType:i,message:d})};x.logger[i]=t};for(var u in x.logger)s(u)};S.addEventListener("message",function(e){var s=e.data;switch(s.cmd){case"init":{var u=JSON.parse(s.config);S.transmuxer=new P.default(g,s.typeSupported,u,s.vendor,s.id),Object(x.enableLogs)(u.debug),a(),E("init",null);break}case"configure":{S.transmuxer.configure(s.config);break}case"demux":{var n=S.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(P.isPromise)(n)?n.then(function(l){A(S,l)}):A(S,n);break}case"flush":{var i=s.chunkMeta,t=S.transmuxer.flush(i);Object(P.isPromise)(t)?t.then(function(l){D(S,l,i)}):D(S,t,i);break}default:break}})}function A(S,g){if(L(g.remuxResult))return!1;var E=[],a=g.remuxResult,e=a.audio,s=a.video;return e&&y(E,e),s&&y(E,s),S.postMessage({event:"transmuxComplete",data:g},E),!0}function y(S,g){g.data1&&S.push(g.data1.buffer),g.data2&&S.push(g.data2.buffer)}function D(S,g,E){var a=g.reduce(function(e,s){return A(S,s)||e},!1);a||S.postMessage({event:"transmuxComplete",data:g[0]}),S.postMessage({event:"flush",data:E})}function L(S){return!S.audio&&!S.video&&!S.text&&!S.id3&&!S.initSegment}},"./src/demux/transmuxer.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return E}),h.d(R,"isPromise",function(){return s}),h.d(R,"TransmuxConfig",function(){return u}),h.d(R,"TransmuxState",function(){return n});var P=h("./src/events.ts"),p=h("./src/errors.ts"),x=h("./src/crypt/decrypter.ts"),I=h("./src/demux/aacdemuxer.ts"),T=h("./src/demux/mp4demuxer.ts"),_=h("./src/demux/tsdemuxer.ts"),A=h("./src/demux/mp3demuxer.ts"),y=h("./src/remux/mp4-remuxer.ts"),D=h("./src/remux/passthrough-remuxer.ts"),L=h("./src/utils/logger.ts"),S;try{S=self.performance.now.bind(self.performance)}catch{L.logger.debug("Unable to use Performance API on this environment"),S=self.Date.now}var g=[{demux:_.default,remux:y.default},{demux:T.default,remux:D.default},{demux:I.default,remux:y.default},{demux:A.default,remux:y.default}],E=function(){function i(l,d,r,c,f){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=l,this.typeSupported=d,this.config=r,this.vendor=c,this.id=f}var t=i.prototype;return t.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},t.push=function(d,r,c,f){var o=this,v=c.transmuxing;v.executeStart=S();var m=new Uint8Array(d),O=this.config,b=this.currentTransmuxState,M=this.transmuxConfig;f&&(this.currentTransmuxState=f);var F=f||b,w=F.contiguous,C=F.discontinuity,U=F.trackSwitch,B=F.accurateTimeOffset,N=F.timeOffset,k=F.initSegmentChange,j=M.audioCodec,H=M.videoCodec,V=M.defaultInitPts,Y=M.duration,Q=M.initSegmentData;(C||U||k)&&this.resetInitSegment(Q,j,H,Y),(C||k)&&this.resetInitialTimestamp(V),w||this.resetContiguity();var J=a(m,r);if(J&&J.method==="AES-128"){var z=this.getDecrypter();if(O.enableSoftwareAES){var q=z.softwareDecrypt(m,J.key.buffer,J.iv.buffer);if(!q)return v.executeEnd=S(),e(c);m=new Uint8Array(q)}else return this.decryptionPromise=z.webCryptoDecrypt(m,J.key.buffer,J.iv.buffer).then(function(le){var ne=o.push(le,null,c);return o.decryptionPromise=null,ne}),this.decryptionPromise}this.needsProbing(m,C,U)&&this.configureTransmuxer(m,M);var re=this.transmux(m,J,N,B,c),X=this.currentTransmuxState;return X.contiguous=!0,X.discontinuity=!1,X.trackSwitch=!1,v.executeEnd=S(),re},t.flush=function(d){var r=this,c=d.transmuxing;c.executeStart=S();var f=this.decrypter,o=this.currentTransmuxState,v=this.decryptionPromise;if(v)return v.then(function(){return r.flush(d)});var m=[],O=o.timeOffset;if(f){var b=f.flush();b&&m.push(this.push(b,null,d))}var M=this.demuxer,F=this.remuxer;if(!M||!F)return this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),c.executeEnd=S(),[e(d)];var w=M.flush(O);return s(w)?w.then(function(C){return r.flushRemux(m,C,d),m}):(this.flushRemux(m,w,d),m)},t.flushRemux=function(d,r,c){var f=r.audioTrack,o=r.videoTrack,v=r.id3Track,m=r.textTrack,O=this.currentTransmuxState,b=O.accurateTimeOffset,M=O.timeOffset;L.logger.log("[transmuxer.ts]: Flushed fragment "+c.sn+(c.part>-1?" p: "+c.part:"")+" of level "+c.level);var F=this.remuxer.remux(f,o,v,m,M,b,!0,this.id);d.push({remuxResult:F,chunkMeta:c}),c.transmuxing.executeEnd=S()},t.resetInitialTimestamp=function(d){var r=this.demuxer,c=this.remuxer;!r||!c||(r.resetTimeStamp(d),c.resetTimeStamp(d))},t.resetContiguity=function(){var d=this.demuxer,r=this.remuxer;!d||!r||(d.resetContiguity(),r.resetNextTimestamp())},t.resetInitSegment=function(d,r,c,f){var o=this.demuxer,v=this.remuxer;!o||!v||(o.resetInitSegment(d,r,c,f),v.resetInitSegment(d,r,c))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(d,r,c,f,o){var v;return r&&r.method==="SAMPLE-AES"?v=this.transmuxSampleAes(d,r,c,f,o):v=this.transmuxUnencrypted(d,c,f,o),v},t.transmuxUnencrypted=function(d,r,c,f){var o=this.demuxer.demux(d,r,!1,!this.config.progressive),v=o.audioTrack,m=o.videoTrack,O=o.id3Track,b=o.textTrack,M=this.remuxer.remux(v,m,O,b,r,c,!1,this.id);return{remuxResult:M,chunkMeta:f}},t.transmuxSampleAes=function(d,r,c,f,o){var v=this;return this.demuxer.demuxSampleAes(d,r,c).then(function(m){var O=v.remuxer.remux(m.audioTrack,m.videoTrack,m.id3Track,m.textTrack,c,f,!1,v.id);return{remuxResult:O,chunkMeta:o}})},t.configureTransmuxer=function(d,r){for(var c=this.config,f=this.observer,o=this.typeSupported,v=this.vendor,m=r.audioCodec,O=r.defaultInitPts,b=r.duration,M=r.initSegmentData,F=r.videoCodec,w,C=0,U=g.length;C<U;C++)if(g[C].demux.probe(d)){w=g[C];break}w||(L.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:T.default,remux:D.default});var B=this.demuxer,N=this.remuxer,k=w.remux,j=w.demux;(!N||!(N instanceof k))&&(this.remuxer=new k(f,c,o,v)),(!B||!(B instanceof j))&&(this.demuxer=new j(f,c,o),this.probe=j.probe),this.resetInitSegment(M,m,F,b),this.resetInitialTimestamp(O)},t.needsProbing=function(d,r,c){return!this.demuxer||!this.remuxer||r||c},t.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new x.default(this.observer,this.config)),d},i}();function a(i,t){var l=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(l=t),l}var e=function(t){return{remuxResult:{},chunkMeta:t}};function s(i){return"then"in i&&i.then instanceof Function}var u=function(t,l,d,r,c){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=l,this.initSegmentData=d,this.duration=r,this.defaultInitPts=c},n=function(t,l,d,r,c,f){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=l,this.accurateTimeOffset=d,this.trackSwitch=r,this.timeOffset=c,this.initSegmentChange=f}},"./src/demux/tsdemuxer.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"discardEPB",function(){return u});var P=h("./src/demux/adts.ts"),p=h("./src/demux/mpegaudio.ts"),x=h("./src/demux/exp-golomb.ts"),I=h("./src/demux/sample-aes.ts"),T=h("./src/events.ts"),_=h("./src/utils/mp4-tools.ts"),A=h("./src/utils/logger.ts"),y=h("./src/errors.ts"),D=h("./src/types/demuxer.ts");function L(){return L=Object.assign?Object.assign.bind():function(n){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(n[l]=t[l])}return n},L.apply(this,arguments)}var S=function(){function n(t,l,d){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=l,this.typeSupported=d}n.probe=function(l){return l[0]===71&&l[188]===71},n.createTrack=function(l,d){return{container:l==="video"||l==="audio"?"video/mp2t":void 0,type:l,id:_.RemuxerTrackIdConfig[l],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:l==="audio"?d:void 0}};var i=n.prototype;return i.resetInitSegment=function(l,d,r,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video"),this._audioTrack=n.createTrack("audio",c),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=d,this.videoCodec=r,this._duration=c},i.resetTimeStamp=function(){},i.resetContiguity=function(){var l=this._audioTrack,d=this._avcTrack,r=this._id3Track;l&&(l.pesData=null),d&&(d.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null},i.demux=function(l,d,r,c){r===void 0&&(r=!1),c===void 0&&(c=!1),r||(this.sampleAes=null);var f,o=this._avcTrack,v=this._audioTrack,m=this._id3Track,O=this._txtTrack,b=o.pid,M=o.pesData,F=v.pid,w=m.pid,C=v.pesData,U=m.pesData,B=null,N=this.pmtParsed,k=this._pmtId,j=l.length;if(this.remainderData&&(l=Object(_.appendUint8Array)(this.remainderData,l),j=l.length,this.remainderData=null),j<188&&!c)return this.remainderData=l,{audioTrack:v,videoTrack:o,id3Track:m,textTrack:O};j-=j%188,j<l.byteLength&&!c&&(this.remainderData=new Uint8Array(l.buffer,j,l.buffer.byteLength-j));for(var H=0,V=0;V<j;V+=188)if(l[V]===71){var Y=!!(l[V+1]&64),Q=((l[V+1]&31)<<8)+l[V+2],J=(l[V+3]&48)>>4,z=void 0;if(J>1){if(z=V+5+l[V+4],z===V+188)continue}else z=V+4;switch(Q){case b:Y&&(M&&(f=e(M))&&this.parseAVCPES(o,O,f,!1),M={data:[],size:0}),M&&(M.data.push(l.subarray(z,V+188)),M.size+=V+188-z);break;case F:if(Y){if(C&&(f=e(C)))switch(v.segmentCodec){case"aac":this.parseAACPES(v,f);break;case"mp3":this.parseMPEGPES(v,f);break}C={data:[],size:0}}C&&(C.data.push(l.subarray(z,V+188)),C.size+=V+188-z);break;case w:Y&&(U&&(f=e(U))&&this.parseID3PES(m,f),U={data:[],size:0}),U&&(U.data.push(l.subarray(z,V+188)),U.size+=V+188-z);break;case 0:Y&&(z+=l[z]+1),k=this._pmtId=E(l,z);break;case k:{Y&&(z+=l[z]+1);var q=a(l,z,this.typeSupported,r);b=q.avc,b>0&&(o.pid=b),F=q.audio,F>0&&(v.pid=F,v.segmentCodec=q.segmentCodec),w=q.id3,w>0&&(m.pid=w),B!==null&&!N&&(A.logger.log("unknown PID '"+B+"' in TS found"),B=null),N=this.pmtParsed=!0;break}case 17:case 8191:break;default:B=Q;break}}else H++;H>0&&this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+H+" TS packet/s that do not start with 0x47"}),o.pesData=M,v.pesData=C,m.pesData=U;var re={audioTrack:v,videoTrack:o,id3Track:m,textTrack:O};return c&&this.extractRemainingSamples(re),re},i.flush=function(){var l=this.remainderData;this.remainderData=null;var d;return l?d=this.demux(l,-1,!1,!0):d={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},i.extractRemainingSamples=function(l){var d=l.audioTrack,r=l.videoTrack,c=l.id3Track,f=l.textTrack,o=r.pesData,v=d.pesData,m=c.pesData,O;if(o&&(O=e(o))?(this.parseAVCPES(r,f,O,!0),r.pesData=null):r.pesData=o,v&&(O=e(v))){switch(d.segmentCodec){case"aac":this.parseAACPES(d,O);break;case"mp3":this.parseMPEGPES(d,O);break}d.pesData=null}else v!=null&&v.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=v;m&&(O=e(m))?(this.parseID3PES(c,O),c.pesData=null):c.pesData=m},i.demuxSampleAes=function(l,d,r){var c=this.demux(l,r,!0,!this.config.progressive),f=this.sampleAes=new I.default(this.observer,this.config,d);return this.decrypt(c,f)},i.decrypt=function(l,d){return new Promise(function(r){var c=l.audioTrack,f=l.videoTrack;c.samples&&c.segmentCodec==="aac"?d.decryptAacSamples(c.samples,0,function(){f.samples?d.decryptAvcSamples(f.samples,0,0,function(){r(l)}):r(l)}):f.samples&&d.decryptAvcSamples(f.samples,0,0,function(){r(l)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(l,d,r,c){var f=this,o=this.parseAVCNALu(l,r.data),v=!1,m=this.avcSample,O,b=!1;r.data=null,m&&o.length&&!l.audFound&&(s(m,l),m=this.avcSample=g(!1,r.pts,r.dts,"")),o.forEach(function(M){switch(M.type){case 1:{O=!0,m||(m=f.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="NDR "),m.frame=!0;var F=M.data;if(b&&F.length>4){var w=new x.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(m.key=!0)}break}case 5:O=!0,m||(m=f.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{O=!0,v&&m&&(m.debug+="SEI "),Object(_.parseSEIMessageFromNALu)(u(M.data),r.pts,d.samples);break}case 7:if(O=!0,b=!0,v&&m&&(m.debug+="SPS "),!l.sps){var C=new x.default(M.data),U=C.readSPS();l.width=U.width,l.height=U.height,l.pixelRatio=U.pixelRatio,l.sps=[M.data],l.duration=f._duration;for(var B=M.data.subarray(1,4),N="avc1.",k=0;k<3;k++){var j=B[k].toString(16);j.length<2&&(j="0"+j),N+=j}l.codec=N}break;case 8:O=!0,v&&m&&(m.debug+="PPS "),l.pps||(l.pps=[M.data]);break;case 9:O=!1,l.audFound=!0,m&&s(m,l),m=f.avcSample=g(!1,r.pts,r.dts,v?"AUD ":"");break;case 12:O=!0;break;default:O=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&O){var H=m.units;H.push(M)}}),c&&m&&(s(m,l),this.avcSample=null)},i.getLastNalUnit=function(l){var d,r=this.avcSample,c;if((!r||r.units.length===0)&&(r=l[l.length-1]),(d=r)!==null&&d!==void 0&&d.units){var f=r.units;c=f[f.length-1]}return c},i.parseAVCNALu=function(l,d){var r=d.byteLength,c=l.naluState||0,f=c,o=[],v=0,m,O,b,M=-1,F=0;for(c===-1&&(M=0,F=d[0]&31,c=0,v=1);v<r;){if(m=d[v++],!c){c=m?0:1;continue}if(c===1){c=m?0:2;continue}if(!m)c=3;else if(m===1){if(M>=0){var w={data:d.subarray(M,v-c-1),type:F};o.push(w)}else{var C=this.getLastNalUnit(l.samples);if(C&&(f&&v<=4-f&&C.state&&(C.data=C.data.subarray(0,C.data.byteLength-f)),O=v-c-1,O>0)){var U=new Uint8Array(C.data.byteLength+O);U.set(C.data,0),U.set(d.subarray(0,O),C.data.byteLength),C.data=U,C.state=0}}v<r?(b=d[v]&31,M=v,F=b,c=0):c=-1}else c=0}if(M>=0&&c>=0){var B={data:d.subarray(M,r),type:F,state:c};o.push(B)}if(o.length===0){var N=this.getLastNalUnit(l.samples);if(N){var k=new Uint8Array(N.data.byteLength+d.byteLength);k.set(N.data,0),k.set(d,N.data.byteLength),N.data=k}}return l.naluState=c,o},i.parseAACPES=function(l,d){var r=0,c=this.aacOverFlow,f=d.data;if(c){this.aacOverFlow=null;var o=c.missing,v=c.sample.unit.byteLength;if(o===-1){var m=new Uint8Array(v+f.byteLength);m.set(c.sample.unit,0),m.set(f,v),f=m}else{var O=v-o;c.sample.unit.set(f.subarray(0,o),O),l.samples.push(c.sample),r=c.missing}}var b,M;for(b=r,M=f.length;b<M-1&&!P.isHeader(f,b);b++);if(b!==r){var F,w;if(b<M-1?(F="AAC PES did not start with ADTS header,offset:"+b,w=!1):(F="no ADTS header found in AAC PES",w=!0),A.logger.warn("parsing error:"+F),this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:w,reason:F}),w)return}P.initTrackConfig(l,this.observer,f,b,this.audioCodec);var C;if(d.pts!==void 0)C=d.pts;else if(c){var U=P.getFrameDuration(l.samplerate);C=c.sample.pts+U}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var B=0,N;b<M;)if(N=P.appendFrame(l,f,b,C,B),b+=N.length,N.missing){this.aacOverFlow=N;break}else for(B++;b<M-1&&!P.isHeader(f,b);b++);},i.parseMPEGPES=function(l,d){var r=d.data,c=r.length,f=0,o=0,v=d.pts;if(v===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<c;)if(p.isHeader(r,o)){var m=p.appendFrame(l,r,o,v,f);if(m)o+=m.length,f++;else break}else o++},i.parseID3PES=function(l,d){if(d.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=L({},d,{type:this._avcTrack?D.MetadataSchema.emsg:D.MetadataSchema.audioId3});l.samples.push(r)},n}();function g(n,i,t,l){return{key:n,frame:!1,pts:i,dts:t,units:[],debug:l,length:0}}function E(n,i){return(n[i+10]&31)<<8|n[i+11]}function a(n,i,t,l){var d={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(n[i+1]&15)<<8|n[i+2],c=i+3+r-4,f=(n[i+10]&15)<<8|n[i+11];for(i+=12+f;i<c;){var o=(n[i+1]&31)<<8|n[i+2];switch(n[i]){case 207:if(!l){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=o);break;case 21:d.id3===-1&&(d.id3=o);break;case 219:if(!l){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=o);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):d.audio===-1&&(d.audio=o,d.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((n[i+3]&15)<<8|n[i+4])+5}return d}function e(n){var i=0,t,l,d,r,c,f=n.data;if(!n||n.size===0)return null;for(;f[0].length<19&&f.length>1;){var o=new Uint8Array(f[0].length+f[1].length);o.set(f[0]),o.set(f[1],f[0].length),f[0]=o,f.splice(1,1)}t=f[0];var v=(t[0]<<16)+(t[1]<<8)+t[2];if(v===1){if(l=(t[4]<<8)+t[5],l&&l>n.size-6)return null;var m=t[7];m&192&&(r=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,m&64?(c=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,r-c>60*9e4&&(A.logger.warn(Math.round((r-c)/9e4)+"s delta between PTS and DTS, align them"),r=c)):c=r),d=t[8];var O=d+9;if(n.size<=O)return null;n.size-=O;for(var b=new Uint8Array(n.size),M=0,F=f.length;M<F;M++){t=f[M];var w=t.byteLength;if(O)if(O>w){O-=w;continue}else t=t.subarray(O),w-=O,O=0;b.set(t,i),i+=w}return l&&(l-=d+3),{data:b,pts:r,dts:c,len:l}}return null}function s(n,i){if(n.units.length&&n.frame){if(n.pts===void 0){var t=i.samples,l=t.length;if(l){var d=t[l-1];n.pts=d.pts,n.dts=d.dts}else{i.dropped++;return}}i.samples.push(n)}n.debug.length&&A.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function u(n){for(var i=n.byteLength,t=[],l=1;l<i-2;)n[l]===0&&n[l+1]===0&&n[l+2]===3?(t.push(l+2),l+=2):l++;if(t.length===0)return n;var d=i-t.length,r=new Uint8Array(d),c=0;for(l=0;l<d;c++,l++)c===t[0]&&(c++,t.shift()),r[l]=n[c];return r}R.default=S},"./src/errors.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"ErrorTypes",function(){return P}),h.d(R,"ErrorDetails",function(){return p});var P;(function(x){x.NETWORK_ERROR="networkError",x.MEDIA_ERROR="mediaError",x.KEY_SYSTEM_ERROR="keySystemError",x.MUX_ERROR="muxError",x.OTHER_ERROR="otherError"})(P||(P={}));var p;(function(x){x.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",x.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",x.KEY_SYSTEM_NO_SESSION="keySystemNoSession",x.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",x.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",x.MANIFEST_LOAD_ERROR="manifestLoadError",x.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",x.MANIFEST_PARSING_ERROR="manifestParsingError",x.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",x.LEVEL_EMPTY_ERROR="levelEmptyError",x.LEVEL_LOAD_ERROR="levelLoadError",x.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",x.LEVEL_SWITCH_ERROR="levelSwitchError",x.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",x.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",x.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",x.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",x.FRAG_LOAD_ERROR="fragLoadError",x.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",x.FRAG_DECRYPT_ERROR="fragDecryptError",x.FRAG_PARSING_ERROR="fragParsingError",x.REMUX_ALLOC_ERROR="remuxAllocError",x.KEY_LOAD_ERROR="keyLoadError",x.KEY_LOAD_TIMEOUT="keyLoadTimeOut",x.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",x.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",x.BUFFER_APPEND_ERROR="bufferAppendError",x.BUFFER_APPENDING_ERROR="bufferAppendingError",x.BUFFER_STALLED_ERROR="bufferStalledError",x.BUFFER_FULL_ERROR="bufferFullError",x.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",x.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",x.INTERNAL_EXCEPTION="internalException",x.INTERNAL_ABORTED="aborted",x.UNKNOWN="unknown"})(p||(p={}))},"./src/events.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"Events",function(){return P});var P;(function(p){p.MEDIA_ATTACHING="hlsMediaAttaching",p.MEDIA_ATTACHED="hlsMediaAttached",p.MEDIA_DETACHING="hlsMediaDetaching",p.MEDIA_DETACHED="hlsMediaDetached",p.BUFFER_RESET="hlsBufferReset",p.BUFFER_CODECS="hlsBufferCodecs",p.BUFFER_CREATED="hlsBufferCreated",p.BUFFER_APPENDING="hlsBufferAppending",p.BUFFER_APPENDED="hlsBufferAppended",p.BUFFER_EOS="hlsBufferEos",p.BUFFER_FLUSHING="hlsBufferFlushing",p.BUFFER_FLUSHED="hlsBufferFlushed",p.MANIFEST_LOADING="hlsManifestLoading",p.MANIFEST_LOADED="hlsManifestLoaded",p.MANIFEST_PARSED="hlsManifestParsed",p.LEVEL_SWITCHING="hlsLevelSwitching",p.LEVEL_SWITCHED="hlsLevelSwitched",p.LEVEL_LOADING="hlsLevelLoading",p.LEVEL_LOADED="hlsLevelLoaded",p.LEVEL_UPDATED="hlsLevelUpdated",p.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",p.LEVELS_UPDATED="hlsLevelsUpdated",p.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",p.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",p.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",p.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",p.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",p.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",p.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",p.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",p.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",p.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",p.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",p.CUES_PARSED="hlsCuesParsed",p.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",p.INIT_PTS_FOUND="hlsInitPtsFound",p.FRAG_LOADING="hlsFragLoading",p.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",p.FRAG_LOADED="hlsFragLoaded",p.FRAG_DECRYPTED="hlsFragDecrypted",p.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",p.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",p.FRAG_PARSING_METADATA="hlsFragParsingMetadata",p.FRAG_PARSED="hlsFragParsed",p.FRAG_BUFFERED="hlsFragBuffered",p.FRAG_CHANGED="hlsFragChanged",p.FPS_DROP="hlsFpsDrop",p.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",p.ERROR="hlsError",p.DESTROYING="hlsDestroying",p.KEY_LOADING="hlsKeyLoading",p.KEY_LOADED="hlsKeyLoaded",p.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",p.BACK_BUFFER_REACHED="hlsBackBufferReached"})(P||(P={}))},"./src/hls.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return i});var P=h("./node_modules/url-toolkit/src/url-toolkit.js"),p=h.n(P),x=h("./src/loader/playlist-loader.ts"),I=h("./src/loader/key-loader.ts"),T=h("./src/controller/id3-track-controller.ts"),_=h("./src/controller/latency-controller.ts"),A=h("./src/controller/level-controller.ts"),y=h("./src/controller/fragment-tracker.ts"),D=h("./src/controller/stream-controller.ts"),L=h("./src/is-supported.ts"),S=h("./src/utils/logger.ts"),g=h("./src/config.ts"),E=h("./node_modules/eventemitter3/index.js"),a=h.n(E),e=h("./src/events.ts"),s=h("./src/errors.ts");function u(t,l){for(var d=0;d<l.length;d++){var r=l[d];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,l,d){return l&&u(t.prototype,l),d&&u(t,d),Object.defineProperty(t,"prototype",{writable:!1}),t}var i=function(){t.isSupported=function(){return Object(L.isSupported)()};function t(d){d===void 0&&(d={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new E.EventEmitter,this._autoLevelCapping=void 0,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;var r=this.config=Object(g.mergeConfig)(t.DefaultConfig,d);this.userConfig=d,Object(S.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(g.enableStreamingMode)(r);var c=r.abrController,f=r.bufferController,o=r.capLevelController,v=r.fpsController,m=this.abrController=new c(this),O=this.bufferController=new f(this),b=this.capLevelController=new o(this),M=new v(this),F=new x.default(this),w=new I.default(this),C=new T.default(this),U=this.levelController=new A.default(this),B=new y.FragmentTracker(this),N=this.streamController=new D.default(this,B);b.setStreamController(N),M.setStreamController(N);var k=[F,w,U,N];this.networkControllers=k;var j=[m,O,b,M,C,B];this.audioTrackController=this.createController(r.audioTrackController,null,k),this.createController(r.audioStreamController,B,k),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,k),this.createController(r.subtitleStreamController,B,k),this.createController(r.timelineController,null,j),this.emeController=this.createController(r.emeController,null,j),this.cmcdController=this.createController(r.cmcdController,null,j),this.latencyController=this.createController(_.default,null,j),this.coreComponents=j}var l=t.prototype;return l.createController=function(r,c,f){if(r){var o=c?new r(this,c):new r(this);return f&&f.push(o),o}return null},l.on=function(r,c,f){f===void 0&&(f=this),this._emitter.on(r,c,f)},l.once=function(r,c,f){f===void 0&&(f=this),this._emitter.once(r,c,f)},l.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},l.off=function(r,c,f,o){f===void 0&&(f=this),this._emitter.off(r,c,f,o)},l.listeners=function(r){return this._emitter.listeners(r)},l.emit=function(r,c,f){return this._emitter.emit(r,c,f)},l.trigger=function(r,c){if(this.config.debug)return this.emit(r,r,c);try{return this.emit(r,r,c)}catch(f){S.logger.error("An internal error happened while handling event "+r+'. Error message: "'+f.message+'". Here is a stacktrace:',f),this.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:f})}return!1},l.listenerCount=function(r){return this._emitter.listenerCount(r)},l.destroy=function(){S.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},l.attachMedia=function(r){S.logger.log("attachMedia"),this._media=r,this.trigger(e.Events.MEDIA_ATTACHING,{media:r})},l.detachMedia=function(){S.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},l.loadSource=function(r){this.stopLoad();var c=this.media,f=this.url,o=this.url=P.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});S.logger.log("loadSource:"+o),c&&f&&f!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(e.Events.MANIFEST_LOADING,{url:r})},l.startLoad=function(r){r===void 0&&(r=-1),S.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(c){c.startLoad(r)})},l.stopLoad=function(){S.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},l.swapAudioCodec=function(){S.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},l.recoverMediaError=function(){S.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},l.removeLevel=function(r,c){c===void 0&&(c=0),this.levelController.removeLevel(r,c)},n(t,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){S.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){S.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){S.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){S.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){S.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var c=!!r;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(S.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,c=this.config.minAutoBitrate;if(!r)return 0;for(var f=r.length,o=0;o<f;o++)if(r[o].maxBitrate>=c)return o;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,c=this.autoLevelCapping,f;return c===-1&&r&&r.length?f=r.length-1:f=c,f}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var c=this.audioTrackController;c&&(c.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var c=this.subtitleTrackController;c&&(c.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:g.hlsDefaultConfig},set:function(r){t.defaultConfig=r}}]),t}();i.defaultConfig=void 0},"./src/is-supported.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"isSupported",function(){return x}),h.d(R,"changeTypeSupported",function(){return I});var P=h("./src/utils/mediasource-helper.ts");function p(){return self.SourceBuffer||self.WebKitSourceBuffer}function x(){var T=Object(P.getMediaSource)();if(!T)return!1;var _=p(),A=T&&typeof T.isTypeSupported=="function"&&T.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!_||_.prototype&&typeof _.prototype.appendBuffer=="function"&&typeof _.prototype.remove=="function";return!!A&&!!y}function I(){var T,_=p();return typeof(_==null||(T=_.prototype)===null||T===void 0?void 0:T.changeType)=="function"}},"./src/loader/date-range.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"DateRangeAttribute",function(){return A}),h.d(R,"DateRange",function(){return y});var P=h("./src/polyfills/number.ts"),p=h("./src/utils/attr-list.ts"),x=h("./src/utils/logger.ts");function I(){return I=Object.assign?Object.assign.bind():function(D){for(var L=1;L<arguments.length;L++){var S=arguments[L];for(var g in S)Object.prototype.hasOwnProperty.call(S,g)&&(D[g]=S[g])}return D},I.apply(this,arguments)}function T(D,L){for(var S=0;S<L.length;S++){var g=L[S];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(D,g.key,g)}}function _(D,L,S){return L&&T(D.prototype,L),S&&T(D,S),Object.defineProperty(D,"prototype",{writable:!1}),D}var A;(function(D){D.ID="ID",D.CLASS="CLASS",D.START_DATE="START-DATE",D.DURATION="DURATION",D.END_DATE="END-DATE",D.END_ON_NEXT="END-ON-NEXT",D.PLANNED_DURATION="PLANNED-DURATION",D.SCTE35_OUT="SCTE35-OUT",D.SCTE35_IN="SCTE35-IN"})(A||(A={}));var y=function(){function D(L,S){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,S){var g=S.attr;for(var E in g)if(Object.prototype.hasOwnProperty.call(L,E)&&L[E]!==g[E]){x.logger.warn('DATERANGE tag attribute: "'+E+'" does not match for tags with ID: "'+L.ID+'"'),this._badValueForSameId=E;break}L=I(new p.AttrList({}),g,L)}if(this.attr=L,this._startDate=new Date(L[A.START_DATE]),A.END_DATE in this.attr){var a=new Date(this.attr[A.END_DATE]);Object(P.isFiniteNumber)(a.getTime())&&(this._endDate=a)}}return _(D,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var S=this.duration;return S!==null?new Date(this._startDate.getTime()+S*1e3):null}},{key:"duration",get:function(){if(A.DURATION in this.attr){var S=this.attr.decimalFloatingPoint(A.DURATION);if(Object(P.isFiniteNumber)(S))return S}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return A.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(A.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(A.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(P.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),D}()},"./src/loader/fragment-loader.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return S}),h.d(R,"LoadError",function(){return E});var P=h("./src/polyfills/number.ts"),p=h("./src/errors.ts");function x(a,e){a.prototype=Object.create(e.prototype),a.prototype.constructor=a,y(a,e)}function I(a){var e=typeof Map=="function"?new Map:void 0;return I=function(u){if(u===null||!A(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(u))return e.get(u);e.set(u,n)}function n(){return T(u,arguments,D(this).constructor)}return n.prototype=Object.create(u.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),y(n,u)},I(a)}function T(a,e,s){return _()?T=Reflect.construct.bind():T=function(n,i,t){var l=[null];l.push.apply(l,i);var d=Function.bind.apply(n,l),r=new d;return t&&y(r,t.prototype),r},T.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function A(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function y(a,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,n){return u.__proto__=n,u},y(a,e)}function D(a){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},D(a)}var L=Math.pow(2,17),S=function(){function a(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var e=a.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(u,n){var i=this,t=u.url;if(!t)return Promise.reject(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var l=this.config,d=l.fLoader,r=l.loader;return new Promise(function(c,f){i.loader&&i.loader.destroy();var o=i.loader=u.loader=d?new d(l):new r(l),v=g(u),m={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:u.sn==="initSegment"?1/0:L};u.stats=o.stats,o.load(v,m,{onSuccess:function(b,M,F,w){i.resetLoader(u,o),c({frag:u,part:null,payload:b.data,networkDetails:w})},onError:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,response:b,networkDetails:F}))},onAbort:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,networkDetails:F}))},onTimeout:function(b,M,F){i.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,networkDetails:F}))},onProgress:function(b,M,F,w){n&&n({frag:u,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(u,n,i){var t=this;this.abort();var l=this.config,d=l.fLoader,r=l.loader;return new Promise(function(c,f){t.loader&&t.loader.destroy();var o=t.loader=u.loader=d?new d(l):new r(l),v=g(u,n),m={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:L};n.stats=o.stats,o.load(v,m,{onSuccess:function(b,M,F,w){t.resetLoader(u,o),t.updateStatsFromPart(u,n);var C={frag:u,part:n,payload:b.data,networkDetails:w};i(C),c(C)},onError:function(b,M,F){t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,part:n,response:b,networkDetails:F}))},onAbort:function(b,M,F){u.stats.aborted=n.stats.aborted,t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,part:n,networkDetails:F}))},onTimeout:function(b,M,F){t.resetLoader(u,o),f(new E({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,part:n,networkDetails:F}))}})})},e.updateStatsFromPart=function(u,n){var i=u.stats,t=n.stats,l=t.total;if(i.loaded+=t.loaded,l){var d=Math.round(u.duration/n.duration),r=Math.min(Math.round(i.loaded/l),d),c=d-r,f=c*Math.round(i.loaded/r);i.total=i.loaded+f}else i.total=Math.max(i.loaded,i.total);var o=i.loading,v=t.loading;o.start?o.first+=v.first-v.start:(o.start=v.start,o.first=v.first),o.end=v.end},e.resetLoader=function(u,n){u.loader=null,this.loader===n&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),n.destroy()},a}();function g(a,e){e===void 0&&(e=null);var s=e||a,u={frag:a,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},n=s.byteRangeStartOffset,i=s.byteRangeEndOffset;return Object(P.isFiniteNumber)(n)&&Object(P.isFiniteNumber)(i)&&(u.rangeStart=n,u.rangeEnd=i),u}var E=function(a){x(e,a);function e(s){for(var u,n=arguments.length,i=new Array(n>1?n-1:0),t=1;t<n;t++)i[t-1]=arguments[t];return u=a.call.apply(a,[this].concat(i))||this,u.data=void 0,u.data=s,u}return e}(I(Error))},"./src/loader/fragment.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"ElementaryStreamTypes",function(){return S}),h.d(R,"BaseSegment",function(){return g}),h.d(R,"Fragment",function(){return E}),h.d(R,"Part",function(){return a});var P=h("./src/polyfills/number.ts"),p=h("./node_modules/url-toolkit/src/url-toolkit.js"),x=h.n(p),I=h("./src/utils/logger.ts"),T=h("./src/loader/level-key.ts"),_=h("./src/loader/load-stats.ts");function A(e,s){e.prototype=Object.create(s.prototype),e.prototype.constructor=e,y(e,s)}function y(e,s){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},y(e,s)}function D(e,s){for(var u=0;u<s.length;u++){var n=s[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function L(e,s,u){return s&&D(e.prototype,s),u&&D(e,u),Object.defineProperty(e,"prototype",{writable:!1}),e}var S;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(S||(S={}));var g=function(){function e(u){var n;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(n={},n[S.AUDIO]=null,n[S.VIDEO]=null,n[S.AUDIOVIDEO]=null,n),this.baseurl=u}var s=e.prototype;return s.setByteRange=function(n,i){var t=n.split("@",2),l=[];t.length===1?l[0]=i?i.byteRangeEndOffset:0:l[0]=parseInt(t[1]),l[1]=parseInt(t[0])+l[0],this._byteRange=l},L(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(p.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),e}(),E=function(e){A(s,e);function s(n,i){var t;return t=e.call(this,i)||this,t._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new _.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=n,t}var u=s.prototype;return u.createInitializationVector=function(i){for(var t=new Uint8Array(16),l=12;l<16;l++)t[l]=i>>8*(15-l)&255;return t},u.setDecryptDataFromLevelKey=function(i,t){var l=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(l=T.LevelKey.fromURI(i.uri),l.method=i.method,l.iv=this.createInitializationVector(t),l.keyFormat="identity"),l},u.setElementaryStreamInfo=function(i,t,l,d,r,c){c===void 0&&(c=!1);var f=this.elementaryStreams,o=f[i];if(!o){f[i]={startPTS:t,endPTS:l,startDTS:d,endDTS:r,partial:c};return}o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,l),o.startDTS=Math.min(o.startDTS,d),o.endDTS=Math.max(o.endDTS,r)},u.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[S.AUDIO]=null,i[S.VIDEO]=null,i[S.AUDIOVIDEO]=null},L(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(P.isFiniteNumber)(this.programDateTime))return null;var i=Object(P.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),s}(g),a=function(e){A(s,e);function s(u,n,i,t,l){var d;d=e.call(this,i)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new _.LoadStats,d.duration=u.decimalFloatingPoint("DURATION"),d.gap=u.bool("GAP"),d.independent=u.bool("INDEPENDENT"),d.relurl=u.enumeratedString("URI"),d.fragment=n,d.index=t;var r=u.enumeratedString("BYTERANGE");return r&&d.setByteRange(r,l),l&&(d.fragOffset=l.fragOffset+l.duration),d}return L(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var n=this.elementaryStreams;return!!(n.audio||n.video||n.audiovideo)}}]),s}(g)},"./src/loader/key-loader.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return I});var P=h("./src/events.ts"),p=h("./src/errors.ts"),x=h("./src/utils/logger.ts"),I=function(){function T(A){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=A,this.registerListeners()}var _=T.prototype;return _.startLoad=function(y){},_.stopLoad=function(){this.destroyInternalLoaders()},_.registerListeners=function(){this.hls.on(P.Events.KEY_LOADING,this.onKeyLoading,this)},_.unregisterListeners=function(){this.hls.off(P.Events.KEY_LOADING,this.onKeyLoading)},_.destroyInternalLoaders=function(){for(var y in this.loaders){var D=this.loaders[y];D&&D.destroy()}this.loaders={}},_.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},_.onKeyLoading=function(y,D){var L=D.frag,S=L.type,g=this.loaders[S];if(!L.decryptdata){x.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var E=L.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var a=this.hls.config;if(g&&(x.logger.warn("abort previous key loader for type:"+S),g.abort()),!E){x.logger.warn("key uri is falsy");return}var e=a.loader,s=L.loader=this.loaders[S]=new e(a);this.decrypturl=E,this.decryptkey=null;var u={url:E,frag:L,responseType:"arraybuffer"},n={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:a.fragLoadingRetryDelay,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(u,n,i)}else this.decryptkey&&(L.decryptdata.key=this.decryptkey,this.hls.trigger(P.Events.KEY_LOADED,{frag:L}))},_.loadsuccess=function(y,D,L){var S=L.frag;if(!S.decryptdata){x.logger.error("after key load, decryptdata unset");return}this.decryptkey=S.decryptdata.key=new Uint8Array(y.data),S.loader=null,delete this.loaders[S.type],this.hls.trigger(P.Events.KEY_LOADED,{frag:S})},_.loaderror=function(y,D){var L=D.frag,S=L.loader;S&&S.abort(),delete this.loaders[L.type],this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:L,response:y})},_.loadtimeout=function(y,D){var L=D.frag,S=L.loader;S&&S.abort(),delete this.loaders[L.type],this.hls.trigger(P.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:L})},T}()},"./src/loader/level-details.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"LevelDetails",function(){return T});var P=h("./src/polyfills/number.ts");function p(_,A){for(var y=0;y<A.length;y++){var D=A[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function x(_,A,y){return A&&p(_.prototype,A),y&&p(_,y),Object.defineProperty(_,"prototype",{writable:!1}),_}var I=10,T=function(){function _(y){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.needSidxRanges=!1,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.fragments=[],this.dateRanges={},this.url=y}var A=_.prototype;return A.reloaded=function(D){if(!D){this.advanced=!0,this.updated=!0;return}var L=this.lastPartSn-D.lastPartSn,S=this.lastPartIndex-D.lastPartIndex;this.updated=this.endSN!==D.endSN||!!S||!!L,this.advanced=this.endSN>D.endSN||L>0||L===0&&S>0,this.updated||this.advanced?this.misses=Math.floor(D.misses*.6):this.misses=D.misses+1,this.availabilityDelay=D.availabilityDelay},x(_,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(P.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var D=this.driftEndTime-this.driftStartTime;if(D>0){var L=this.driftEnd-this.driftStart;return L*1e3/D}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var D;return(D=this.fragments)!==null&&D!==void 0&&D.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var D;return(D=this.partList)!==null&&D!==void 0&&D.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),_}()},"./src/loader/level-key.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"LevelKey",function(){return T});var P=h("./node_modules/url-toolkit/src/url-toolkit.js"),p=h.n(P);function x(_,A){for(var y=0;y<A.length;y++){var D=A[y];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function I(_,A,y){return A&&x(_.prototype,A),y&&x(_,y),Object.defineProperty(_,"prototype",{writable:!1}),_}var T=function(){_.fromURL=function(y,D){return new _(y,D)},_.fromURI=function(y){return new _(y)};function _(A,y){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,y?this._uri=Object(P.buildAbsoluteURL)(A,y,{alwaysNormalize:!0}):this._uri=A}return I(_,[{key:"uri",get:function(){return this._uri}}]),_}()},"./src/loader/load-stats.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"LoadStats",function(){return P});var P=function(){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}}},"./src/loader/m3u8-parser.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return u});var P=h("./src/polyfills/number.ts"),p=h("./node_modules/url-toolkit/src/url-toolkit.js"),x=h.n(p),I=h("./src/loader/date-range.ts"),T=h("./src/loader/fragment.ts"),_=h("./src/loader/level-details.ts"),A=h("./src/loader/level-key.ts"),y=h("./src/utils/attr-list.ts"),D=h("./src/utils/logger.ts"),L=h("./src/utils/codecs.ts"),S=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,g=/#EXT-X-MEDIA:(.*)/g,E=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|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("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function s(r){var c,f;return e.test((c=(f=p.parseURL(r))===null||f===void 0?void 0:f.path)!=null?c:"")}var u=function(){function r(){}return r.findGroup=function(f,o){for(var v=0;v<f.length;v++){var m=f[v];if(m.id===o)return m}},r.convertAVC1ToAVCOTI=function(f){var o=f.split(".");if(o.length>2){var v=o.shift()+".";return v+=parseInt(o.shift()).toString(16),v+=("000"+parseInt(o.shift()).toString(16)).slice(-4),v}return f},r.resolve=function(f,o){return p.buildAbsoluteURL(o,f,{alwaysNormalize:!0})},r.parseMasterPlaylist=function(f,o){var v=[],m={},O=!1;S.lastIndex=0;for(var b;(b=S.exec(f))!=null;)if(b[1]){var M=new y.AttrList(b[1]),F={attrs:M,bitrate:M.decimalInteger("AVERAGE-BANDWIDTH")||M.decimalInteger("BANDWIDTH"),name:M.NAME,url:r.resolve(b[2],o)},w=M.decimalResolution("RESOLUTION");w&&(F.width=w.width,F.height=w.height),n((M.CODECS||"").split(/[ ,]+/).filter(function(U){return U}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=r.convertAVC1ToAVCOTI(F.videoCodec)),v.push(F)}else if(b[3]){var C=new y.AttrList(b[3]);C["DATA-ID"]&&(O=!0,m[C["DATA-ID"]]=C)}return{levels:v,sessionData:O?m:null}},r.parseMasterPlaylistMedia=function(f,o,v,m){m===void 0&&(m=[]);var O,b=[],M=0;for(g.lastIndex=0;(O=g.exec(f))!==null;){var F=new y.AttrList(O[1]);if(F.TYPE===v){var w={attrs:F,bitrate:0,id:M++,groupId:F["GROUP-ID"],instreamId:F["INSTREAM-ID"],name:F.NAME||F.LANGUAGE||"",type:v,default:F.bool("DEFAULT"),autoselect:F.bool("AUTOSELECT"),forced:F.bool("FORCED"),lang:F.LANGUAGE,url:F.URI?r.resolve(F.URI,o):""};if(m.length){var C=r.findGroup(m,w.groupId)||m[0];i(w,C,"audioCodec"),i(w,C,"textCodec")}b.push(w)}}return b},r.parseLevelPlaylist=function(f,o,v,m,O){var b=new _.LevelDetails(o),M=b.fragments,F=null,w=0,C=0,U=0,B=0,N=null,k=new T.Fragment(m,o),j,H,V,Y=-1,Q=!1;for(E.lastIndex=0,b.m3u8=f;(j=E.exec(f))!==null;){Q&&(Q=!1,k=new T.Fragment(m,o),k.start=U,k.sn=w,k.cc=B,k.level=v,F&&(k.initSegment=F,k.rawProgramDateTime=F.rawProgramDateTime,F.rawProgramDateTime=null));var J=j[1];if(J){k.duration=parseFloat(J);var z=(" "+j[2]).slice(1);k.title=z||null,k.tagList.push(z?["INF",J,z]:["INF",J])}else if(j[3])Object(P.isFiniteNumber)(k.duration)&&(k.start=U,V&&(k.levelkey=V),k.sn=w,k.level=v,k.cc=B,k.urlId=O,M.push(k),k.relurl=(" "+j[3]).slice(1),l(k,N),N=k,U+=k.duration,w++,C=0,Q=!0);else if(j[4]){var q=(" "+j[4]).slice(1);N?k.setByteRange(q,N):k.setByteRange(q)}else if(j[5])k.rawProgramDateTime=(" "+j[5]).slice(1),k.tagList.push(["PROGRAM-DATE-TIME",k.rawProgramDateTime]),Y===-1&&(Y=M.length);else{if(j=j[0].match(a),!j){D.logger.warn("No matches on slow regex match for level playlist!");continue}for(H=1;H<j.length&&typeof j[H]=="undefined";H++);var re=(" "+j[H]).slice(1),X=(" "+j[H+1]).slice(1),le=j[H+2]?(" "+j[H+2]).slice(1):"";switch(re){case"PLAYLIST-TYPE":b.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":w=b.startSN=parseInt(X);break;case"SKIP":{var ne=new y.AttrList(X),te=ne.decimalInteger("SKIPPED-SEGMENTS");if(Object(P.isFiniteNumber)(te)){b.skippedSegments=te;for(var ee=te;ee--;)M.unshift(null);w+=te}var $=ne.enumeratedString("RECENTLY-REMOVED-DATERANGES");$&&(b.recentlyRemovedDateranges=$.split(" "));break}case"TARGETDURATION":b.targetduration=parseFloat(X);break;case"VERSION":b.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(X||le)&&k.tagList.push(le?[X,le]:[X]);break;case"DISCONTINUITY":B++,k.tagList.push(["DIS"]);break;case"GAP":k.tagList.push([re]);break;case"BITRATE":k.tagList.push([re,X]);break;case"DATERANGE":{var Z=new y.AttrList(X),ue=new I.DateRange(Z,b.dateRanges[Z.ID]);ue.isValid||b.skippedSegments?b.dateRanges[ue.id]=ue:D.logger.warn('Ignoring invalid DATERANGE tag: "'+X+'"'),k.tagList.push(["EXT-X-DATERANGE",X]);break}case"DISCONTINUITY-SEQUENCE":B=parseInt(X);break;case"KEY":{var he,se=new y.AttrList(X),me=se.enumeratedString("METHOD"),pe=se.URI,Ee=se.hexadecimalInteger("IV"),ae=se.enumeratedString("KEYFORMATVERSIONS"),fe=se.enumeratedString("KEYID"),ge=(he=se.enumeratedString("KEYFORMAT"))!=null?he:"identity",ve=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ve.indexOf(ge)>-1){D.logger.warn("Keyformat "+ge+" is not supported from the manifest");continue}else if(ge!=="identity")continue;me&&(V=A.LevelKey.fromURL(o,pe),pe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(me)>=0&&(V.method=me,V.keyFormat=ge,fe&&(V.keyID=fe),ae&&(V.keyFormatVersions=ae),V.iv=Ee));break}case"START":{var Te=new y.AttrList(X),Le=Te.decimalFloatingPoint("TIME-OFFSET");Object(P.isFiniteNumber)(Le)&&(b.startTimeOffset=Le);break}case"MAP":{var Oe=new y.AttrList(X);if(k.duration){var xe=new T.Fragment(m,o);d(xe,Oe,v,V),F=xe,k.initSegment=F,F.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=F.rawProgramDateTime)}else d(k,Oe,v,V),F=k,Q=!0;break}case"SERVER-CONTROL":{var ye=new y.AttrList(X);b.canBlockReload=ye.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=ye.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&ye.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=ye.optionalFloat("PART-HOLD-BACK",0),b.holdBack=ye.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var W=new y.AttrList(X);b.partTarget=W.decimalFloatingPoint("PART-TARGET");break}case"PART":{var G=b.partList;G||(G=b.partList=[]);var oe=C>0?G[G.length-1]:void 0,de=C++,ce=new T.Part(new y.AttrList(X),k,o,de,oe);G.push(ce),k.duration+=ce.duration;break}case"PRELOAD-HINT":{var Se=new y.AttrList(X);b.preloadHint=Se;break}case"RENDITION-REPORT":{var ie=new y.AttrList(X);b.renditionReports=b.renditionReports||[],b.renditionReports.push(ie);break}default:D.logger.warn("line parsed but not handled: "+j);break}}}N&&!N.relurl?(M.pop(),U-=N.duration,b.partList&&(b.fragmentHint=N)):b.partList&&(l(k,N),k.cc=B,b.fragmentHint=k);var Ae=M.length,De=M[0],_e=M[Ae-1];if(U+=b.skippedSegments*b.targetduration,U>0&&Ae&&_e){b.averagetargetduration=U/Ae;var Ce=_e.sn;b.endSN=Ce!=="initSegment"?Ce:0,De&&(b.startCC=De.cc,De.initSegment||b.fragments.every(function(Re){return Re.relurl&&s(Re.relurl)})&&(D.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),k=new T.Fragment(m,o),k.relurl=_e.relurl,k.level=v,k.sn="initSegment",De.initSegment=k,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(U+=b.fragmentHint.duration),b.totalduration=U,b.endCC=B,Y>0&&t(M,Y),b},r}();function n(r,c){["video","audio","text"].forEach(function(f){var o=r.filter(function(m){return Object(L.isCodecType)(m,f)});if(o.length){var v=o.filter(function(m){return m.lastIndexOf("avc1",0)===0||m.lastIndexOf("mp4a",0)===0});c[f+"Codec"]=v.length>0?v[0]:o[0],r=r.filter(function(m){return o.indexOf(m)===-1})}}),c.unknownCodecs=r}function i(r,c,f){var o=c[f];o&&(r[f]=o)}function t(r,c){for(var f=r[c],o=c;o--;){var v=r[o];if(!v)return;v.programDateTime=f.programDateTime-v.duration*1e3,f=v}}function l(r,c){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):c!=null&&c.programDateTime&&(r.programDateTime=c.endProgramDateTime),Object(P.isFiniteNumber)(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function d(r,c,f,o){r.relurl=c.URI,c.BYTERANGE&&r.setByteRange(c.BYTERANGE),r.level=f,r.sn="initSegment",o&&(r.levelkey=o),r.initSegment=null}},"./src/loader/playlist-loader.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/polyfills/number.ts"),p=h("./src/events.ts"),x=h("./src/errors.ts"),I=h("./src/utils/logger.ts"),T=h("./src/utils/mp4-tools.ts"),_=h("./src/loader/m3u8-parser.ts"),A=h("./src/types/loader.ts"),y=h("./src/utils/attr-list.ts");function D(g){var E=g.type;switch(E){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function L(g,E){var a=g.url;return(a===void 0||a.indexOf("data:")===0)&&(a=E.url),a}var S=function(){function g(a){this.hls=void 0,this.loaders=Object.create(null),this.hls=a,this.registerListeners()}var E=g.prototype;return E.startLoad=function(e){},E.stopLoad=function(){this.destroyInternalLoaders()},E.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.createInternalLoader=function(e){var s=this.hls.config,u=s.pLoader,n=s.loader,i=u||n,t=new i(s);return e.loader=t,this.loaders[e.type]=t,t},E.getInternalLoader=function(e){return this.loaders[e.type]},E.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},E.destroyInternalLoaders=function(){for(var e in this.loaders){var s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.onManifestLoading=function(e,s){var u=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:u,deliveryDirectives:null})},E.onLevelLoading=function(e,s){var u=s.id,n=s.level,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:null,level:n,responseType:"text",type:A.PlaylistContextType.LEVEL,url:i,deliveryDirectives:t})},E.onAudioTrackLoading=function(e,s){var u=s.id,n=s.groupId,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:n,level:null,responseType:"text",type:A.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:t})},E.onSubtitleTrackLoading=function(e,s){var u=s.id,n=s.groupId,i=s.url,t=s.deliveryDirectives;this.load({id:u,groupId:n,level:null,responseType:"text",type:A.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:t})},E.load=function(e){var s,u=this.hls.config,n=this.getInternalLoader(e);if(n){var i=n.context;if(i&&i.url===e.url){I.logger.trace("[playlist-loader]: playlist request ongoing");return}I.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),n.abort()}var t,l,d,r;switch(e.type){case A.PlaylistContextType.MANIFEST:t=u.manifestLoadingMaxRetry,l=u.manifestLoadingTimeOut,d=u.manifestLoadingRetryDelay,r=u.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:t=0,l=u.levelLoadingTimeOut;break;default:t=u.levelLoadingMaxRetry,l=u.levelLoadingTimeOut,d=u.levelLoadingRetryDelay,r=u.levelLoadingMaxRetryTimeout;break}if(n=this.createInternalLoader(e),(s=e.deliveryDirectives)!==null&&s!==void 0&&s.part){var c;if(e.type===A.PlaylistContextType.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===A.PlaylistContextType.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===A.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){var f=c.partTarget,o=c.targetduration;f&&o&&(l=Math.min(Math.max(f*3,o*.8)*1e3,l))}}var v={timeout:l,maxRetry:t,retryDelay:d,maxRetryDelay:r,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};n.load(e,v,m)},E.loadsuccess=function(e,s,u,n){if(n===void 0&&(n=null),u.isSidxRequest){this.handleSidxRequest(e,u),this.handlePlaylistLoaded(e,s,u,n);return}this.resetInternalLoader(u.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,u,"no EXTM3U delimiter",n);return}s.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,s,u,n):this.handleMasterPlaylist(e,s,u,n)},E.loaderror=function(e,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!1,e)},E.loadtimeout=function(e,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!0)},E.handleMasterPlaylist=function(e,s,u,n){var i=this.hls,t=e.data,l=L(e,u),d=_.default.parseMasterPlaylist(t,l),r=d.levels,c=d.sessionData;if(!r.length){this.handleManifestParsingError(e,u,"no level found in manifest",n);return}var f=r.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),o=r.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),v=_.default.parseMasterPlaylistMedia(t,l,"AUDIO",f),m=_.default.parseMasterPlaylistMedia(t,l,"SUBTITLES",o),O=_.default.parseMasterPlaylistMedia(t,l,"CLOSED-CAPTIONS");if(v.length){var b=v.some(function(M){return!M.url});!b&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(I.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}i.trigger(p.Events.MANIFEST_LOADED,{levels:r,audioTracks:v,subtitles:m,captions:O,url:l,stats:s,networkDetails:n,sessionData:c})},E.handleTrackOrLevelPlaylist=function(e,s,u,n){var i=this.hls,t=u.id,l=u.level,d=u.type,r=L(e,u),c=Object(P.isFiniteNumber)(t)?t:0,f=Object(P.isFiniteNumber)(l)?l:c,o=D(u),v=_.default.parseLevelPlaylist(e.data,r,f,o,c);if(!v.fragments.length){i.trigger(p.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:r,reason:"no fragments found in level",level:typeof u.level=="number"?u.level:void 0});return}if(d===A.PlaylistContextType.MANIFEST){var m={attrs:new y.AttrList({}),bitrate:0,details:v,name:"",url:r};i.trigger(p.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:r,stats:s,networkDetails:n,sessionData:null})}if(s.parsing.end=performance.now(),v.needSidxRanges){var O,b=(O=v.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:b,isSidxRequest:!0,type:d,level:l,levelDetails:v,id:t,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}u.levelDetails=v,this.handlePlaylistLoaded(e,s,u,n)},E.handleSidxRequest=function(e,s){var u=new Uint8Array(e.data),n=Object(T.findBox)(u,["sidx"])[0];if(!!n){var i=Object(T.parseSegmentIndex)(n);if(!!i){var t=i.references,l=s.levelDetails;t.forEach(function(d,r){var c=d.info,f=l.fragments[r];if(f.byteRange.length===0&&f.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),f.initSegment){var o=Object(T.findBox)(u,["moov"])[0],v=o?o.length:null;f.initSegment.setByteRange(String(v)+"@0")}})}}},E.handleManifestParsingError=function(e,s,u,n){this.hls.trigger(p.Events.ERROR,{type:x.ErrorTypes.NETWORK_ERROR,details:x.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===A.PlaylistContextType.MANIFEST,url:e.url,reason:u,response:e,context:s,networkDetails:n})},E.handleNetworkError=function(e,s,u,n){u===void 0&&(u=!1),I.logger.warn("[playlist-loader]: A network "+(u?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=x.ErrorDetails.UNKNOWN,t=!1,l=this.getInternalLoader(e);switch(e.type){case A.PlaylistContextType.MANIFEST:i=u?x.ErrorDetails.MANIFEST_LOAD_TIMEOUT:x.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case A.PlaylistContextType.LEVEL:i=u?x.ErrorDetails.LEVEL_LOAD_TIMEOUT:x.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case A.PlaylistContextType.AUDIO_TRACK:i=u?x.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:x.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:i=u?x.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:x.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}l&&this.resetInternalLoader(e.type);var d={type:x.ErrorTypes.NETWORK_ERROR,details:i,fatal:t,url:e.url,loader:l,context:e,networkDetails:s};n&&(d.response=n),this.hls.trigger(p.Events.ERROR,d)},E.handlePlaylistLoaded=function(e,s,u,n){var i=u.type,t=u.level,l=u.id,d=u.groupId,r=u.loader,c=u.levelDetails,f=u.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(e,u,"invalid target duration",n);return}if(!!r)switch(c.live&&(r.getCacheAge&&(c.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0)),i){case A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:c,level:t||0,id:l||0,stats:s,networkDetails:n,deliveryDirectives:f});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:c,id:l||0,groupId:d||"",stats:s,networkDetails:n,deliveryDirectives:f});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:c,id:l||0,groupId:d||"",stats:s,networkDetails:n,deliveryDirectives:f});break}},g}();R.default=S},"./src/polyfills/number.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"isFiniteNumber",function(){return P}),h.d(R,"MAX_SAFE_INTEGER",function(){return p});var P=Number.isFinite||function(x){return typeof x=="number"&&isFinite(x)},p=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(K,R,h){"use strict";h.r(R);var P=function(){function p(){}return p.getSilentFrame=function(I,T){switch(I){case"mp4a.40.2":if(T===1)return new Uint8Array([0,200,0,128,35,128]);if(T===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(T===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(T===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(T===5)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(T===6)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]);break;default:if(T===1)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(T===2)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(T===3)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]);break}},p}();R.default=P},"./src/remux/mp4-generator.ts":function(K,R,h){"use strict";h.r(R);var P=Math.pow(2,32)-1,p=function(){function x(){}return x.init=function(){x.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:[]};var T;for(T in x.types)x.types.hasOwnProperty(T)&&(x.types[T]=[T.charCodeAt(0),T.charCodeAt(1),T.charCodeAt(2),T.charCodeAt(3)]);var _=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]),A=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]);x.HDLR_TYPES={video:_,audio:A};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),D=new Uint8Array([0,0,0,0,0,0,0,0]);x.STTS=x.STSC=x.STCO=D,x.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),x.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),x.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),x.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var L=new Uint8Array([105,115,111,109]),S=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);x.FTYP=x.box(x.types.ftyp,L,g,L,S),x.DINF=x.box(x.types.dinf,x.box(x.types.dref,y))},x.box=function(T){for(var _=8,A=arguments.length,y=new Array(A>1?A-1:0),D=1;D<A;D++)y[D-1]=arguments[D];for(var L=y.length,S=L;L--;)_+=y[L].byteLength;var g=new Uint8Array(_);for(g[0]=_>>24&255,g[1]=_>>16&255,g[2]=_>>8&255,g[3]=_&255,g.set(T,4),L=0,_=8;L<S;L++)g.set(y[L],_),_+=y[L].byteLength;return g},x.hdlr=function(T){return x.box(x.types.hdlr,x.HDLR_TYPES[T])},x.mdat=function(T){return x.box(x.types.mdat,T)},x.mdhd=function(T,_){_*=T;var A=Math.floor(_/(P+1)),y=Math.floor(_%(P+1));return x.box(x.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},x.mdia=function(T){return x.box(x.types.mdia,x.mdhd(T.timescale,T.duration),x.hdlr(T.type),x.minf(T))},x.mfhd=function(T){return x.box(x.types.mfhd,new Uint8Array([0,0,0,0,T>>24,T>>16&255,T>>8&255,T&255]))},x.minf=function(T){return T.type==="audio"?x.box(x.types.minf,x.box(x.types.smhd,x.SMHD),x.DINF,x.stbl(T)):x.box(x.types.minf,x.box(x.types.vmhd,x.VMHD),x.DINF,x.stbl(T))},x.moof=function(T,_,A){return x.box(x.types.moof,x.mfhd(T),x.traf(A,_))},x.moov=function(T){for(var _=T.length,A=[];_--;)A[_]=x.trak(T[_]);return x.box.apply(null,[x.types.moov,x.mvhd(T[0].timescale,T[0].duration)].concat(A).concat(x.mvex(T)))},x.mvex=function(T){for(var _=T.length,A=[];_--;)A[_]=x.trex(T[_]);return x.box.apply(null,[x.types.mvex].concat(A))},x.mvhd=function(T,_){_*=T;var A=Math.floor(_/(P+1)),y=Math.floor(_%(P+1)),D=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,T&255,A>>24,A>>16&255,A>>8&255,A&255,y>>24,y>>16&255,y>>8&255,y&255,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 x.box(x.types.mvhd,D)},x.sdtp=function(T){var _=T.samples||[],A=new Uint8Array(4+_.length),y,D;for(y=0;y<_.length;y++)D=_[y].flags,A[y+4]=D.dependsOn<<4|D.isDependedOn<<2|D.hasRedundancy;return x.box(x.types.sdtp,A)},x.stbl=function(T){return x.box(x.types.stbl,x.stsd(T),x.box(x.types.stts,x.STTS),x.box(x.types.stsc,x.STSC),x.box(x.types.stsz,x.STSZ),x.box(x.types.stco,x.STCO))},x.avc1=function(T){var _=[],A=[],y,D,L;for(y=0;y<T.sps.length;y++)D=T.sps[y],L=D.byteLength,_.push(L>>>8&255),_.push(L&255),_=_.concat(Array.prototype.slice.call(D));for(y=0;y<T.pps.length;y++)D=T.pps[y],L=D.byteLength,A.push(L>>>8&255),A.push(L&255),A=A.concat(Array.prototype.slice.call(D));var S=x.box(x.types.avcC,new Uint8Array([1,_[3],_[4],_[5],255,224|T.sps.length].concat(_).concat([T.pps.length]).concat(A))),g=T.width,E=T.height,a=T.pixelRatio[0],e=T.pixelRatio[1];return x.box(x.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,g>>8&255,g&255,E>>8&255,E&255,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,x.box(x.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),x.box(x.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,e>>24,e>>16&255,e>>8&255,e&255])))},x.esds=function(T){var _=T.config.length;return new Uint8Array([0,0,0,0,3,23+_,0,1,0,4,15+_,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([_]).concat(T.config).concat([6,1,2]))},x.mp4a=function(T){var _=T.samplerate;return x.box(x.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,_>>8&255,_&255,0,0]),x.box(x.types.esds,x.esds(T)))},x.mp3=function(T){var _=T.samplerate;return x.box(x.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,_>>8&255,_&255,0,0]))},x.stsd=function(T){return T.type==="audio"?T.segmentCodec==="mp3"&&T.codec==="mp3"?x.box(x.types.stsd,x.STSD,x.mp3(T)):x.box(x.types.stsd,x.STSD,x.mp4a(T)):x.box(x.types.stsd,x.STSD,x.avc1(T))},x.tkhd=function(T){var _=T.id,A=T.duration*T.timescale,y=T.width,D=T.height,L=Math.floor(A/(P+1)),S=Math.floor(A%(P+1));return x.box(x.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,_>>24&255,_>>16&255,_>>8&255,_&255,0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,S>>24,S>>16&255,S>>8&255,S&255,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,y>>8&255,y&255,0,0,D>>8&255,D&255,0,0]))},x.traf=function(T,_){var A=x.sdtp(T),y=T.id,D=Math.floor(_/(P+1)),L=Math.floor(_%(P+1));return x.box(x.types.traf,x.box(x.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),x.box(x.types.tfdt,new Uint8Array([1,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,L>>24,L>>16&255,L>>8&255,L&255])),x.trun(T,A.length+16+20+8+16+8+8),A)},x.trak=function(T){return T.duration=T.duration||4294967295,x.box(x.types.trak,x.tkhd(T),x.mdia(T))},x.trex=function(T){var _=T.id;return x.box(x.types.trex,new Uint8Array([0,0,0,0,_>>24,_>>16&255,_>>8&255,_&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},x.trun=function(T,_){var A=T.samples||[],y=A.length,D=12+16*y,L=new Uint8Array(D),S,g,E,a,e,s;for(_+=8+D,L.set([T.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,_>>>24&255,_>>>16&255,_>>>8&255,_&255],0),S=0;S<y;S++)g=A[S],E=g.duration,a=g.size,e=g.flags,s=g.cts,L.set([E>>>24&255,E>>>16&255,E>>>8&255,E&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*S);return x.box(x.types.trun,L)},x.initSegment=function(T){x.types||x.init();var _=x.moov(T),A=new Uint8Array(x.FTYP.byteLength+_.byteLength);return A.set(x.FTYP),A.set(_,x.FTYP.byteLength),A},x}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0,R.default=p},"./src/remux/mp4-remuxer.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return e}),h.d(R,"normalizePts",function(){return s}),h.d(R,"flushTextTrackMetadataCueSamples",function(){return n}),h.d(R,"flushTextTrackUserdataCueSamples",function(){return i});var P=h("./src/polyfills/number.ts"),p=h("./src/remux/aac-helper.ts"),x=h("./src/remux/mp4-generator.ts"),I=h("./src/events.ts"),T=h("./src/errors.ts"),_=h("./src/utils/logger.ts"),A=h("./src/types/loader.ts"),y=h("./src/utils/timescale-conversion.ts");function D(){return D=Object.assign?Object.assign.bind():function(d){for(var r=1;r<arguments.length;r++){var c=arguments[r];for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(d[f]=c[f])}return d},D.apply(this,arguments)}var L=10*1e3,S=1024,g=1152,E=null,a=null,e=function(){function d(c,f,o,v){if(v===void 0&&(v=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=c,this.config=f,this.typeSupported=o,this.ISGenerated=!1,E===null){var m=navigator.userAgent||"",O=m.match(/Chrome\/(\d+)/i);E=O?parseInt(O[1]):0}if(a===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);a=b?parseInt(b[1]):0}}var r=d.prototype;return r.destroy=function(){},r.resetTimeStamp=function(f){_.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},r.resetNextTimestamp=function(){_.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){_.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},r.getVideoStartPts=function(f){var o=!1,v=f.reduce(function(m,O){var b=O.pts-m;return b<-4294967296?(o=!0,s(m,O.pts)):b>0?m:O.pts},f[0].pts);return o&&_.logger.debug("PTS rollover detected"),v},r.remux=function(f,o,v,m,O,b,M,F){var w,C,U,B,N,k,j=O,H=O,V=f.pid>-1,Y=o.pid>-1,Q=o.samples.length,J=f.samples.length>0,z=M&&Q>0||Q>1,q=(!V||J)&&(!Y||z)||this.ISGenerated||M;if(q){this.ISGenerated||(U=this.generateIS(f,o,O));var re=this.isVideoContiguous,X=-1,le;if(z&&(X=u(o.samples),!re&&this.config.forceKeyFrameOnDiscontinuity))if(k=!0,X>0){_.logger.warn("[mp4-remuxer]: Dropped "+X+" out of "+Q+" video samples due to a missing keyframe");var ne=this.getVideoStartPts(o.samples);o.samples=o.samples.slice(X),o.dropped+=X,H+=(o.samples[0].pts-ne)/o.inputTimeScale,le=H}else X===-1&&(_.logger.warn("[mp4-remuxer]: No keyframe found out of "+Q+" video samples"),k=!1);if(this.ISGenerated){if(J&&z){var te=this.getVideoStartPts(o.samples),ee=s(f.samples[0].pts,te)-te,$=ee/o.inputTimeScale;j+=Math.max(0,$),H+=Math.max(0,-$)}if(J){if(f.samplerate||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),U=this.generateIS(f,o,O)),C=this.remuxAudio(f,j,this.isAudioContiguous,b,Y||z||F===A.PlaylistLevelType.AUDIO?H:void 0),z){var Z=C?C.endPTS-C.startPTS:0;o.inputTimeScale||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),U=this.generateIS(f,o,O)),w=this.remuxVideo(o,H,re,Z)}}else z&&(w=this.remuxVideo(o,H,re,0));w&&(w.firstKeyFrame=X,w.independent=X!==-1,w.firstKeyFramePTS=le)}}return this.ISGenerated&&(v.samples.length&&(N=n(v,O,this._initPTS,this._initDTS)),m.samples.length&&(B=i(m,O,this._initPTS))),{audio:C,video:w,initSegment:U,independent:k,text:B,id3:N}},r.generateIS=function(f,o,v){var m=f.samples,O=o.samples,b=this.typeSupported,M={},F=!Object(P.isFiniteNumber)(this._initPTS),w="audio/mp4",C,U,B;if(F&&(C=U=1/0),f.config&&m.length){switch(f.timescale=f.samplerate,f.segmentCodec){case"mp3":b.mpeg?(w="audio/mpeg",f.codec=""):b.mp3&&(f.codec="mp3");break}M.audio={id:"audio",container:w,codec:f.codec,initSegment:f.segmentCodec==="mp3"&&b.mpeg?new Uint8Array(0):x.default.initSegment([f]),metadata:{channelCount:f.channelCount}},F&&(B=f.inputTimeScale,C=U=m[0].pts-Math.round(B*v))}if(o.sps&&o.pps&&O.length&&(o.timescale=o.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:o.codec,initSegment:x.default.initSegment([o]),metadata:{width:o.width,height:o.height}},F)){B=o.inputTimeScale;var N=this.getVideoStartPts(O),k=Math.round(B*v);U=Math.min(U,s(O[0].dts,N)-k),C=Math.min(C,N-k)}if(Object.keys(M).length)return this.ISGenerated=!0,F&&(this._initPTS=C,this._initDTS=U),{tracks:M,initPTS:C,timescale:B}},r.remuxVideo=function(f,o,v,m){var O=f.inputTimeScale,b=f.samples,M=[],F=b.length,w=this._initPTS,C=this.nextAvcDts,U=8,B=this.videoSampleDuration,N,k,j=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,V=!1;if(!v||C===null){var Y=o*O,Q=b[0].pts-s(b[0].dts,b[0].pts);C=Y-Q}for(var J=0;J<F;J++){var z=b[J];z.pts=s(z.pts-w,C),z.dts=s(z.dts-w,C),z.dts<b[J>0?J-1:J].dts&&(V=!0)}V&&b.sort(function(we,Xe){var Qe=we.dts-Xe.dts,et=we.pts-Xe.pts;return Qe||et}),N=b[0].dts,k=b[b.length-1].dts;var q=k-N,re=q?Math.round(q/(F-1)):B||f.inputTimeScale/30;if(v){var X=N-C,le=X>re,ne=X<-1;if(le||ne){le?_.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms ("+X+"dts) hole between fragments detected, filling it"):_.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-X,!0)+" ms ("+X+"dts) overlapping between fragments detected"),N=C;var te=b[0].pts-X;b[0].dts=N,b[0].pts=te,_.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(te,!0)+"/"+Object(y.toMsFromMpegTsClock)(N,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(X,!0)+" ms")}}N=Math.max(0,N);for(var ee=0,$=0,Z=0;Z<F;Z++){for(var ue=b[Z],he=ue.units,se=he.length,me=0,pe=0;pe<se;pe++)me+=he[pe].data.length;$+=me,ee+=se,ue.length=me,ue.dts=Math.max(ue.dts,N),j=Math.min(ue.pts,j),H=Math.max(ue.pts,H)}k=b[F-1].dts;var Ee=$+4*ee+8,ae;try{ae=new Uint8Array(Ee)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ee,reason:"fail allocating video mdat "+Ee});return}var fe=new DataView(ae.buffer);fe.setUint32(0,Ee),ae.set(x.default.types.mdat,4);for(var ge=!1,ve=Number.POSITIVE_INFINITY,Te=Number.POSITIVE_INFINITY,Le=Number.NEGATIVE_INFINITY,Oe=Number.NEGATIVE_INFINITY,xe=0;xe<F;xe++){for(var ye=b[xe],W=ye.units,G=0,oe=0,de=W.length;oe<de;oe++){var ce=W[oe],Se=ce.data,ie=ce.data.byteLength;fe.setUint32(U,ie),U+=4,ae.set(Se,U),U+=ie,G+=4+ie}var Ae=void 0;if(xe<F-1)B=b[xe+1].dts-ye.dts,Ae=b[xe+1].pts-ye.pts;else{var De=this.config,_e=xe>0?ye.dts-b[xe-1].dts:re;if(Ae=xe>0?ye.pts-b[xe-1].pts:re,De.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ce=Math.floor(De.maxBufferHole*O),Re=(m?j+m*O:this.nextAudioPts)-ye.pts;Re>Ce?(B=Re-_e,B<0?B=_e:ge=!0,_.logger.log("[mp4-remuxer]: It is approximately "+Re/90+" ms to the next segment; using duration "+B/90+" ms for the last video frame.")):B=_e}else B=_e}var Ie=Math.round(ye.pts-ye.dts);ve=Math.min(ve,B),Le=Math.max(Le,B),Te=Math.min(Te,Ae),Oe=Math.max(Oe,Ae),M.push(new t(ye.key,B,G,Ie))}if(M.length){if(E){if(E<70){var Ve=M[0].flags;Ve.dependsOn=2,Ve.isNonSync=0}}else if(a&&Oe-Te<Le-ve&&re/Le<.025&&M[0].cts===0){_.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ke=N,Pe=0,Fe=M.length;Pe<Fe;Pe++){var Ne=ke+M[Pe].duration,Ke=ke+M[Pe].cts;if(Pe<Fe-1){var Ye=Ne+M[Pe+1].cts;M[Pe].duration=Ye-Ke}else M[Pe].duration=Pe?M[Pe-1].duration:re;M[Pe].cts=0,ke=Ne}}}console.assert(B!==null,"mp4SampleDuration must be computed"),B=ge||!B?re:B,this.nextAvcDts=C=k+B,this.videoSampleDuration=B,this.isVideoContiguous=!0;var ze=x.default.moof(f.sequenceNumber++,N,D({},f,{samples:M})),Ze="video",qe={data1:ze,data2:ae,startPTS:j/O,endPTS:(H+B)/O,startDTS:N/O,endDTS:C/O,type:Ze,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(ae.length,"MDAT length must not be zero"),qe},r.remuxAudio=function(f,o,v,m,O){var b=f.inputTimeScale,M=f.samplerate?f.samplerate:b,F=b/M,w=f.segmentCodec==="aac"?S:g,C=w*F,U=this._initPTS,B=f.segmentCodec==="mp3"&&this.typeSupported.mpeg,N=[],k=O!==void 0,j=f.samples,H=B?0:8,V=this.nextAudioPts||-1,Y=o*b;if(this.isAudioContiguous=v=v||j.length&&V>0&&(m&&Math.abs(Y-V)<9e3||Math.abs(s(j[0].pts-U,Y)-V)<20*C),j.forEach(function(ce){ce.pts=s(ce.pts-U,Y)}),!v||V<0){if(j=j.filter(function(ce){return ce.pts>=0}),!j.length)return;O===0?V=0:m&&!k?V=Math.max(0,Y):V=j[0].pts}if(f.segmentCodec==="aac")for(var Q=this.config.maxAudioFramesDrift,J=0,z=V;J<j.length;J++){var q=j[J],re=q.pts,X=re-z,le=Math.abs(1e3*X/b);if(X<=-Q*C&&k)J===0&&(_.logger.warn("Audio frame @ "+(re/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*X/b)+" ms."),this.nextAudioPts=V=z=re);else if(X>=Q*C&&le<L&&k){var ne=Math.round(X/C);z=re-ne*C,z<0&&(ne--,z+=C),J===0&&(this.nextAudioPts=V=z),_.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(z/b).toFixed(3)+"s due to "+Math.round(1e3*X/b)+" ms gap.");for(var te=0;te<ne;te++){var ee=Math.max(z,0),$=p.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);$||(_.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),$=q.unit.subarray()),j.splice(J,0,{unit:$,pts:ee}),z+=C,J++}}q.pts=z,z+=C}for(var Z=null,ue=null,he,se=0,me=j.length;me--;)se+=j[me].unit.byteLength;for(var pe=0,Ee=j.length;pe<Ee;pe++){var ae=j[pe],fe=ae.unit,ge=ae.pts;if(ue!==null){var ve=N[pe-1];ve.duration=Math.round((ge-ue)/F)}else if(v&&f.segmentCodec==="aac"&&(ge=V),Z=ge,se>0){se+=H;try{he=new Uint8Array(se)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:se,reason:"fail allocating audio mdat "+se});return}if(!B){var Te=new DataView(he.buffer);Te.setUint32(0,se),he.set(x.default.types.mdat,4)}}else return;he.set(fe,H);var Le=fe.byteLength;H+=Le,N.push(new t(!0,w,Le,0)),ue=ge}var Oe=N.length;if(!!Oe){var xe=N[N.length-1];this.nextAudioPts=V=ue+F*xe.duration;var ye=B?new Uint8Array(0):x.default.moof(f.sequenceNumber++,Z/F,D({},f,{samples:N}));f.samples=[];var W=Z/b,G=V/b,oe="audio",de={data1:ye,data2:he,startPTS:W,endPTS:G,startDTS:W,endDTS:G,type:oe,hasAudio:!0,hasVideo:!1,nb:Oe};return this.isAudioContiguous=!0,console.assert(he.length,"MDAT length must not be zero"),de}},r.remuxEmptyAudio=function(f,o,v,m){var O=f.inputTimeScale,b=f.samplerate?f.samplerate:O,M=O/b,F=this.nextAudioPts,w=(F!==null?F:m.startDTS*O)+this._initDTS,C=m.endDTS*O+this._initDTS,U=M*S,B=Math.ceil((C-w)/U),N=p.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(_.logger.warn("[mp4-remuxer]: remux empty Audio"),!N){_.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var k=[],j=0;j<B;j++){var H=w+j*U;k.push({unit:N,pts:H,dts:H})}return f.samples=k,this.remuxAudio(f,o,v,!1)},d}();function s(d,r){var c;if(r===null)return d;for(r<d?c=-8589934592:c=8589934592;Math.abs(d-r)>4294967296;)d+=c;return d}function u(d){for(var r=0;r<d.length;r++)if(d[r].key)return r;return-1}function n(d,r,c,f){var o=d.samples.length;if(!!o){for(var v=d.inputTimeScale,m=0;m<o;m++){var O=d.samples[m];O.pts=s(O.pts-c,r*v)/v,O.dts=s(O.dts-f,r*v)/v}var b=d.samples;return d.samples=[],{samples:b}}}function i(d,r,c){var f=d.samples.length;if(!!f){for(var o=d.inputTimeScale,v=0;v<f;v++){var m=d.samples[v];m.pts=s(m.pts-c,r*o)/o}d.samples.sort(function(b,M){return b.pts-M.pts});var O=d.samples;return d.samples=[],{samples:O}}}var t=function(r,c,f,o){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=f,this.cts=o,this.flags=new l(r)},l=function(r){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=r?2:1,this.isNonSync=r?0:1}},"./src/remux/passthrough-remuxer.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/polyfills/number.ts"),p=h("./src/remux/mp4-remuxer.ts"),x=h("./src/utils/mp4-tools.ts"),I=h("./src/loader/fragment.ts"),T=h("./src/utils/logger.ts"),_=function(){function y(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var D=y.prototype;return D.destroy=function(){},D.resetTimeStamp=function(S){this.initPTS=S,this.lastEndTime=null},D.resetNextTimestamp=function(){this.lastEndTime=null},D.resetInitSegment=function(S,g,E){this.audioCodec=g,this.videoCodec=E,this.generateInitSegment(S),this.emitInitSegment=!0},D.generateInitSegment=function(S){var g=this.audioCodec,E=this.videoCodec;if(!S||!S.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=Object(x.parseInitSegment)(S);g||(g=A(a.audio,I.ElementaryStreamTypes.AUDIO)),E||(E=A(a.video,I.ElementaryStreamTypes.VIDEO));var e={};a.audio&&a.video?e.audiovideo={container:"video/mp4",codec:g+","+E,initSegment:S,id:"main"}:a.audio?e.audio={container:"audio/mp4",codec:g,initSegment:S,id:"audio"}:a.video?e.video={container:"video/mp4",codec:E,initSegment:S,id:"main"}:T.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},D.remux=function(S,g,E,a,e){var s,u=this.initPTS,n=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:E,initSegment:void 0};Object(P.isFiniteNumber)(n)||(n=this.lastEndTime=e||0);var t=g.samples;if(!t||!t.length)return i;var l={initPTS:void 0,timescale:1},d=this.initData;if((!d||!d.length)&&(this.generateInitSegment(t),d=this.initData),!d||!d.length)return T.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1);var r=Object(x.getStartDTS)(d,t);Object(P.isFiniteNumber)(u)||(this.initPTS=l.initPTS=u=r-e);var c=Object(x.getDuration)(t,d),f=S?r-u:n,o=f+c;Object(x.offsetStartDTS)(d,t,u),c>0?this.lastEndTime=o:(T.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!d.audio,m=!!d.video,O="";v&&(O+="audio"),m&&(O+="video");var b={data1:t,startPTS:f,startDTS:f,endPTS:o,endDTS:o,type:O,hasAudio:v,hasVideo:m,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=l;var M=(s=this.initPTS)!=null?s:0;return i.id3=Object(p.flushTextTrackMetadataCueSamples)(E,e,M,M),a.samples.length&&(i.text=Object(p.flushTextTrackUserdataCueSamples)(a,e,M)),i},y}();function A(y,D){var L=y==null?void 0:y.codec;return L&&L.length>4?L:L==="hvc1"||L==="hev1"?"hvc1.1.c.L120.90":L==="av01"?"av01.0.04M.08":L==="avc1"||D===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}R.default=_},"./src/task-loop.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return P});var P=function(){function p(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var x=p.prototype;return x.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},x.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},x.onHandlerDestroyed=function(){},x.hasInterval=function(){return!!this._tickInterval},x.hasNextTick=function(){return!!this._tickTimer},x.setInterval=function(T){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,T),!0)},x.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},x.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},x.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},x.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},x.doTick=function(){},p}()},"./src/types/cmcd.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"CMCDVersion",function(){return P}),h.d(R,"CMCDObjectType",function(){return p}),h.d(R,"CMCDStreamingFormat",function(){return x}),h.d(R,"CMCDStreamType",function(){return I});var P=1,p;(function(T){T.MANIFEST="m",T.AUDIO="a",T.VIDEO="v",T.MUXED="av",T.INIT="i",T.CAPTION="c",T.TIMED_TEXT="tt",T.KEY="k",T.OTHER="o"})(p||(p={}));var x;(function(T){T.DASH="d",T.HLS="h",T.SMOOTH="s",T.OTHER="o"})(x||(x={}));var I;(function(T){T.VOD="v",T.LIVE="l"})(I||(I={}))},"./src/types/demuxer.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"MetadataSchema",function(){return P});var P;(function(p){p.audioId3="org.id3",p.dateRange="com.apple.quicktime.HLS",p.emsg="https://aomedia.org/emsg/ID3"})(P||(P={}))},"./src/types/level.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"HlsSkip",function(){return x}),h.d(R,"getSkipValue",function(){return I}),h.d(R,"HlsUrlParameters",function(){return T}),h.d(R,"Level",function(){return _});function P(A,y){for(var D=0;D<y.length;D++){var L=y[D];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(A,L.key,L)}}function p(A,y,D){return y&&P(A.prototype,y),D&&P(A,D),Object.defineProperty(A,"prototype",{writable:!1}),A}var x;(function(A){A.No="",A.Yes="YES",A.v2="v2"})(x||(x={}));function I(A,y){var D=A.canSkipUntil,L=A.canSkipDateRanges,S=A.endSN,g=y!==void 0?y-S:0;return D&&g<D?L?x.v2:x.Yes:x.No}var T=function(){function A(D,L,S){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=D,this.part=L,this.skip=S}var y=A.prototype;return y.addDirectives=function(L){var S=new self.URL(L);return this.msn!==void 0&&S.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&S.searchParams.set("_HLS_part",this.part.toString()),this.skip&&S.searchParams.set("_HLS_skip",this.skip),S.toString()},A}(),_=function(){function A(y){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=[y.url],this.attrs=y.attrs,this.bitrate=y.bitrate,y.details&&(this.details=y.details),this.id=y.id||0,this.name=y.name,this.width=y.width||0,this.height=y.height||0,this.audioCodec=y.audioCodec,this.videoCodec=y.videoCodec,this.unknownCodecs=y.unknownCodecs,this.codecSet=[y.videoCodec,y.audioCodec].filter(function(D){return D}).join(",").replace(/\.[^.,]+/g,"")}return p(A,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(D){var L=D%this.url.length;this._urlId!==L&&(this.details=void 0,this._urlId=L)}}]),A}()},"./src/types/loader.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"PlaylistContextType",function(){return P}),h.d(R,"PlaylistLevelType",function(){return p});var P;(function(x){x.MANIFEST="manifest",x.LEVEL="level",x.AUDIO_TRACK="audioTrack",x.SUBTITLE_TRACK="subtitleTrack"})(P||(P={}));var p;(function(x){x.MAIN="main",x.AUDIO="audio",x.SUBTITLE="subtitle"})(p||(p={}))},"./src/types/transmuxer.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"ChunkMetadata",function(){return P});var P=function(I,T,_,A,y,D){A===void 0&&(A=0),y===void 0&&(y=-1),D===void 0&&(D=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=p(),this.buffering={audio:p(),video:p(),audiovideo:p()},this.level=I,this.sn=T,this.id=_,this.size=A,this.part=y,this.partial=D};function p(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"AttrList",function(){return x});var P=/^(\d+)x(\d+)$/,p=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,x=function(){function I(_){typeof _=="string"&&(_=I.parseAttrList(_));for(var A in _)_.hasOwnProperty(A)&&(this[A]=_[A])}var T=I.prototype;return T.decimalInteger=function(A){var y=parseInt(this[A],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},T.hexadecimalInteger=function(A){if(this[A]){var y=(this[A]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var D=new Uint8Array(y.length/2),L=0;L<y.length/2;L++)D[L]=parseInt(y.slice(L*2,L*2+2),16);return D}else return null},T.hexadecimalIntegerAsNumber=function(A){var y=parseInt(this[A],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},T.decimalFloatingPoint=function(A){return parseFloat(this[A])},T.optionalFloat=function(A,y){var D=this[A];return D?parseFloat(D):y},T.enumeratedString=function(A){return this[A]},T.bool=function(A){return this[A]==="YES"},T.decimalResolution=function(A){var y=P.exec(this[A]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},I.parseAttrList=function(A){var y,D={},L='"';for(p.lastIndex=0;(y=p.exec(A))!==null;){var S=y[2];S.indexOf(L)===0&&S.lastIndexOf(L)===S.length-1&&(S=S.slice(1,-1)),D[y[1]]=S}return D},I}()},"./src/utils/binary-search.ts":function(K,R,h){"use strict";h.r(R);var P={search:function(x,I){for(var T=0,_=x.length-1,A=null,y=null;T<=_;){A=(T+_)/2|0,y=x[A];var D=I(y);if(D>0)T=A+1;else if(D<0)_=A-1;else return y}return null}};R.default=P},"./src/utils/buffer-helper.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"BufferHelper",function(){return x});var P=h("./src/utils/logger.ts"),p={length:0,start:function(){return 0},end:function(){return 0}},x=function(){function I(){}return I.isBuffered=function(_,A){try{if(_){for(var y=I.getBuffered(_),D=0;D<y.length;D++)if(A>=y.start(D)&&A<=y.end(D))return!0}}catch{}return!1},I.bufferInfo=function(_,A,y){try{if(_){var D=I.getBuffered(_),L=[],S;for(S=0;S<D.length;S++)L.push({start:D.start(S),end:D.end(S)});return this.bufferedInfo(L,A,y)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},I.bufferedInfo=function(_,A,y){A=Math.max(0,A),_.sort(function(t,l){var d=t.start-l.start;return d||l.end-t.end});var D=[];if(y)for(var L=0;L<_.length;L++){var S=D.length;if(S){var g=D[S-1].end;_[L].start-g<y?_[L].end>g&&(D[S-1].end=_[L].end):D.push(_[L])}else D.push(_[L])}else D=_;for(var E=0,a,e=A,s=A,u=0;u<D.length;u++){var n=D[u].start,i=D[u].end;if(A+y>=n&&A<i)e=n,s=i,E=s-A;else if(A+y<n){a=n;break}}return{len:E,start:e||0,end:s||0,nextStart:a}},I.getBuffered=function(_){try{return _.buffered}catch(A){return P.logger.log("failed to get media.buffered",A),p}},I}()},"./src/utils/cea-608-parser.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"Row",function(){return s}),h.d(R,"CaptionScreen",function(){return u});var P=h("./src/utils/logger.ts"),p={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},x=function(c){var f=c;return p.hasOwnProperty(c)&&(f=p[c]),String.fromCharCode(f)},I=15,T=100,_={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},D={25:2,26:4,29:6,30:8,31:10,27:13,28:15},L=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],S;(function(r){r[r.ERROR=0]="ERROR",r[r.TEXT=1]="TEXT",r[r.WARNING=2]="WARNING",r[r.INFO=2]="INFO",r[r.DEBUG=3]="DEBUG",r[r.DATA=3]="DATA"})(S||(S={}));var g=function(){function r(){this.time=null,this.verboseLevel=S.ERROR}var c=r.prototype;return c.log=function(o,v){this.verboseLevel>=o&&P.logger.log(this.time+" ["+o+"] "+v)},r}(),E=function(c){for(var f=[],o=0;o<c.length;o++)f.push(c[o].toString(16));return f},a=function(){function r(f,o,v,m,O){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=f||"white",this.underline=o||!1,this.italics=v||!1,this.background=m||"black",this.flash=O||!1}var c=r.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(o){for(var v=["foreground","underline","italics","background","flash"],m=0;m<v.length;m++){var O=v[m];o.hasOwnProperty(O)&&(this[O]=o[O])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},c.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},r}(),e=function(){function r(f,o,v,m,O,b){this.uchar=void 0,this.penState=void 0,this.uchar=f||" ",this.penState=new a(o,v,m,O,b)}var c=r.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(o,v){this.uchar=o,this.penState.copy(v)},c.setPenState=function(o){this.penState.copy(o)},c.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},c.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},r}(),s=function(){function r(f){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<T;o++)this.chars.push(new e);this.logger=f,this.pos=0,this.currPenState=new a}var c=r.prototype;return c.equals=function(o){for(var v=!0,m=0;m<T;m++)if(!this.chars[m].equals(o.chars[m])){v=!1;break}return v},c.copy=function(o){for(var v=0;v<T;v++)this.chars[v].copy(o.chars[v])},c.isEmpty=function(){for(var o=!0,v=0;v<T;v++)if(!this.chars[v].isEmpty()){o=!1;break}return o},c.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(S.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>T&&(this.logger.log(S.DEBUG,"Too large cursor position "+this.pos),this.pos=T)},c.moveCursor=function(o){var v=this.pos+o;if(o>1)for(var m=this.pos+1;m<v+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(v)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(o){o>=144&&this.backSpace();var v=x(o);if(this.pos>=T){this.logger.log(S.ERROR,"Cannot insert "+o.toString(16)+" ("+v+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(v,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(o){var v;for(v=o;v<T;v++)this.chars[v].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var o=[],v=!0,m=0;m<T;m++){var O=this.chars[m].uchar;O!==" "&&(v=!1),o.push(O)}return v?"":o.join("")},c.setPenStyles=function(o){this.currPenState.setStyles(o);var v=this.chars[this.pos];v.setPenState(this.currPenState)},r}(),u=function(){function r(f){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<I;o++)this.rows.push(new s(f));this.logger=f,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=r.prototype;return c.reset=function(){for(var o=0;o<I;o++)this.rows[o].clear();this.currRow=I-1},c.equals=function(o){for(var v=!0,m=0;m<I;m++)if(!this.rows[m].equals(o.rows[m])){v=!1;break}return v},c.copy=function(o){for(var v=0;v<I;v++)this.rows[v].copy(o.rows[v])},c.isEmpty=function(){for(var o=!0,v=0;v<I;v++)if(!this.rows[v].isEmpty()){o=!1;break}return o},c.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},c.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},c.insertChar=function(o){var v=this.rows[this.currRow];v.insertChar(o)},c.setPen=function(o){var v=this.rows[this.currRow];v.setPenStyles(o)},c.moveCursor=function(o){var v=this.rows[this.currRow];v.moveCursor(o)},c.setCursor=function(o){this.logger.log(S.INFO,"setCursor: "+o);var v=this.rows[this.currRow];v.setCursor(o)},c.setPAC=function(o){this.logger.log(S.INFO,"pacData = "+JSON.stringify(o));var v=o.row-1;if(this.nrRollUpRows&&v<this.nrRollUpRows-1&&(v=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==v){for(var m=0;m<I;m++)this.rows[m].clear();var O=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var M=b.rows[O].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var w=0;w<this.nrRollUpRows;w++)this.rows[v-this.nrRollUpRows+w+1].copy(b.rows[O+w])}}this.currRow=v;var C=this.rows[this.currRow];if(o.indent!==null){var U=o.indent,B=Math.max(U-1,0);C.setCursor(o.indent),o.color=C.chars[B].penState.foreground}var N={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(N)},c.setBkgData=function(o){this.logger.log(S.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},c.setRollUpRows=function(o){this.nrRollUpRows=o},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(S.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(S.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,v=this.rows.splice(o,1)[0];v.clear(),this.rows.splice(this.currRow,0,v),this.logger.log(S.INFO,"Rolling up")},c.getDisplayText=function(o){o=o||!1;for(var v=[],m="",O=-1,b=0;b<I;b++){var M=this.rows[b].getTextString();M&&(O=b+1,o?v.push("Row "+O+": '"+M+"'"):v.push(M.trim()))}return v.length>0&&(o?m="["+v.join(" | ")+"]":m=v.join(`
|
|
19
|
+
`)),m},c.getTextAndFormat=function(){return this.rows},r}(),n=function(){function r(f,o,v){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=f,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new u(v),this.nonDisplayedMemory=new u(v),this.lastOutputScreen=new u(v),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=v}var c=r.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(o){this.outputFilter=o},c.setPAC=function(o){this.writeScreen.setPAC(o)},c.setBkgData=function(o){this.writeScreen.setBkgData(o)},c.setMode=function(o){o!==this.mode&&(this.mode=o,this.logger.log(S.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o)},c.insertChars=function(o){for(var v=0;v<o.length;v++)this.writeScreen.insertChar(o[v]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(S.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(S.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(S.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){this.logger.log(S.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(S.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(o){this.logger.log(S.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},c.ccFON=function(){this.logger.log(S.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(S.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(S.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(S.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(S.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(S.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(S.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(S.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(S.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(o){this.logger.log(S.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},c.ccMIDROW=function(o){var v={flash:!1};if(v.underline=o%2===1,v.italics=o>=46,v.italics)v.foreground="white";else{var m=Math.floor(o/2)-16,O=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=O[m]}this.logger.log(S.INFO,"MIDROW: "+JSON.stringify(v)),this.writeScreen.setPen(v)},c.outputDataUpdate=function(o){o===void 0&&(o=!1);var v=this.logger.time;v!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=v:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,v,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:v),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},r}(),i=function(){function r(f,o,v){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new g;this.channels=[null,new n(f,o,m),new n(f+1,v,m)],this.cmdHistory=d(),this.logger=m}var c=r.prototype;return c.getHandler=function(o){return this.channels[o].getHandler()},c.setHandler=function(o,v){this.channels[o].setHandler(v)},c.addData=function(o,v){var m,O,b,M=!1;this.logger.time=o;for(var F=0;F<v.length;F+=2)if(O=v[F]&127,b=v[F+1]&127,!(O===0&&b===0)){if(this.logger.log(S.DATA,"["+E([v[F],v[F+1]])+"] -> ("+E([O,b])+")"),m=this.parseCmd(O,b),m||(m=this.parseMidrow(O,b)),m||(m=this.parsePAC(O,b)),m||(m=this.parseBackgroundAttributes(O,b)),!m&&(M=this.parseChars(O,b),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(S.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(S.WARNING,"Couldn't parse cleaned data "+E([O,b])+" orig: "+E([v[F],v[F+1]]))}},c.parseCmd=function(o,v){var m=this.cmdHistory,O=(o===20||o===28||o===21||o===29)&&v>=32&&v<=47,b=(o===23||o===31)&&v>=33&&v<=35;if(!(O||b))return!1;if(l(o,v,m))return t(null,null,m),this.logger.log(S.DEBUG,"Repeated command ("+E([o,v])+") is dropped"),!0;var M=o===20||o===21||o===23?1:2,F=this.channels[M];return o===20||o===21||o===28||o===29?v===32?F.ccRCL():v===33?F.ccBS():v===34?F.ccAOF():v===35?F.ccAON():v===36?F.ccDER():v===37?F.ccRU(2):v===38?F.ccRU(3):v===39?F.ccRU(4):v===40?F.ccFON():v===41?F.ccRDC():v===42?F.ccTR():v===43?F.ccRTD():v===44?F.ccEDM():v===45?F.ccCR():v===46?F.ccENM():v===47&&F.ccEOC():F.ccTO(v-32),t(o,v,m),this.currentChannel=M,!0},c.parseMidrow=function(o,v){var m=0;if((o===17||o===25)&&v>=32&&v<=47){if(o===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(S.ERROR,"Mismatch channel in midrow parsing"),!1;var O=this.channels[m];return O?(O.ccMIDROW(v),this.logger.log(S.DEBUG,"MIDROW ("+E([o,v])+")"),!0):!1}return!1},c.parsePAC=function(o,v){var m,O=this.cmdHistory,b=(o>=17&&o<=23||o>=25&&o<=31)&&v>=64&&v<=127,M=(o===16||o===24)&&v>=64&&v<=95;if(!(b||M))return!1;if(l(o,v,O))return t(null,null,O),!0;var F=o<=23?1:2;v>=64&&v<=95?m=F===1?_[o]:y[o]:m=F===1?A[o]:D[o];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(m,v)),t(o,v,O),this.currentChannel=F,!0):!1},c.interpretPAC=function(o,v){var m,O={color:null,italics:!1,indent:null,underline:!1,row:o};return v>95?m=v-96:m=v-64,O.underline=(m&1)===1,m<=13?O.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(O.italics=!0,O.color="white"):O.indent=Math.floor((m-16)/2)*4,O},c.parseChars=function(o,v){var m,O=null,b=null;if(o>=25?(m=2,b=o-8):(m=1,b=o),b>=17&&b<=19){var M;b===17?M=v+80:b===18?M=v+112:M=v+144,this.logger.log(S.INFO,"Special char '"+x(M)+"' in channel "+m),O=[M]}else o>=32&&o<=127&&(O=v===0?[o]:[o,v]);if(O){var F=E(O);this.logger.log(S.DEBUG,"Char codes = "+F.join(",")),t(o,v,this.cmdHistory)}return O},c.parseBackgroundAttributes=function(o,v){var m=(o===16||o===24)&&v>=32&&v<=47,O=(o===23||o===31)&&v>=45&&v<=47;if(!(m||O))return!1;var b,M={};o===16||o===24?(b=Math.floor((v-32)/2),M.background=L[b],v%2===1&&(M.background=M.background+"_semi")):v===45?M.background="transparent":(M.foreground="black",v===47&&(M.underline=!0));var F=o<=23?1:2,w=this.channels[F];return w.setBkgData(M),t(o,v,this.cmdHistory),!0},c.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var v=this.channels[o];v&&v.reset()}this.cmdHistory=d()},c.cueSplitAtTime=function(o){for(var v=0;v<this.channels.length;v++){var m=this.channels[v];m&&m.cueSplitAtTime(o)}},r}();function t(r,c,f){f.a=r,f.b=c}function l(r,c,f){return f.a===r&&f.b===c}function d(){return{a:null,b:null}}R.default=i},"./src/utils/codecs.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"isCodecType",function(){return p}),h.d(R,"isCodecSupportedInMp4",function(){return x});var P={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,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,dvav:!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}};function p(I,T){var _=P[T];return!!_&&_[I.slice(0,4)]===!0}function x(I,T){return MediaSource.isTypeSupported((T||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/utils/vttparser.ts"),p=h("./src/utils/webvtt-parser.ts"),x=h("./src/utils/texttrack-utils.ts"),I=/\s/,T={newCue:function(A,y,D,L){for(var S=[],g,E,a,e,s,u=self.VTTCue||self.TextTrackCue,n=0;n<L.rows.length;n++)if(g=L.rows[n],a=!0,e=0,s="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)I.test(g.chars[i].uchar)&&a?e++:(s+=g.chars[i].uchar,a=!1);g.cueStartTime=y,y===D&&(D+=1e-4),e>=16?e--:e++;var t=Object(P.fixLineBreaks)(s.trim()),l=Object(p.generateCueId)(y,D,t);(!A||!A.cues||!A.cues.getCueById(l))&&(E=new u(y,D,t),E.id=l,E.line=n+1,E.align="left",E.position=10+Math.min(80,Math.floor(e*8/32)*10),S.push(E))}return A&&S.length&&(S.sort(function(d,r){return d.line==="auto"||r.line==="auto"?0:d.line>8&&r.line>8?r.line-d.line:d.line-r.line}),S.forEach(function(d){return Object(x.addCueToTrack)(A,d)})),S}};R.default=T},"./src/utils/discontinuities.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"findFirstFragWithCC",function(){return I}),h.d(R,"shouldAlignOnDiscontinuities",function(){return T}),h.d(R,"findDiscontinuousReferenceFrag",function(){return _}),h.d(R,"adjustSlidingStart",function(){return y}),h.d(R,"alignStream",function(){return D}),h.d(R,"alignPDT",function(){return S}),h.d(R,"alignFragmentByPDTDelta",function(){return g}),h.d(R,"alignMediaPlaylistByPDT",function(){return E});var P=h("./src/polyfills/number.ts"),p=h("./src/utils/logger.ts"),x=h("./src/controller/level-helper.ts");function I(a,e){for(var s=null,u=0,n=a.length;u<n;u++){var i=a[u];if(i&&i.cc===e){s=i;break}}return s}function T(a,e,s){return!!(e.details&&(s.endCC>s.startCC||a&&a.cc<s.startCC))}function _(a,e){var s=a.fragments,u=e.fragments;if(!u.length||!s.length){p.logger.log("No fragments to align");return}var n=I(s,u[0].cc);if(!n||n&&!n.startPTS){p.logger.log("No frag in previous level to align on");return}return n}function A(a,e){if(a){var s=a.start+e;a.start=a.startPTS=s,a.endPTS=s+a.duration}}function y(a,e){for(var s=e.fragments,u=0,n=s.length;u<n;u++)A(s[u],a);e.fragmentHint&&A(e.fragmentHint,a),e.alignedSliding=!0}function D(a,e,s){!e||(L(a,s,e),!s.alignedSliding&&e.details&&S(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Object(x.adjustSliding)(e.details,s))}function L(a,e,s){if(T(a,s,e)){var u=_(s.details,e);u&&Object(P.isFiniteNumber)(u.start)&&(p.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),y(u.start,e))}}function S(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,u=a.fragments[0].programDateTime,n=(u-s)/1e3+e.fragments[0].start;n&&Object(P.isFiniteNumber)(n)&&(p.logger.log("Adjusting PTS using programDateTime delta "+(u-s)+"ms, sliding:"+n.toFixed(3)+" "+a.url+" "),y(n,a))}}function g(a,e){var s=a.programDateTime;if(!!s){var u=(s-e)/1e3;a.start=a.startPTS=u,a.endPTS=u+a.duration}}function E(a,e){if(!(!e.fragments.length||!a.hasProgramDateTime||!e.hasProgramDateTime)){var s=e.fragments[0].programDateTime,u=e.fragments[0].start,n=s-u*1e3;a.fragments.forEach(function(i){g(i,n)}),a.fragmentHint&&g(a.fragmentHint,n),a.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/utils/ewma.ts"),p=function(){function x(T,_,A){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=A,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new P.default(T),this.fast_=new P.default(_)}var I=x.prototype;return I.update=function(_,A){var y=this.slow_,D=this.fast_;this.slow_.halfLife!==_&&(this.slow_=new P.default(_,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==A&&(this.fast_=new P.default(A,D.getEstimate(),D.getTotalWeight()))},I.sample=function(_,A){_=Math.max(_,this.minDelayMs_);var y=8*A,D=_/1e3,L=y/D;this.fast_.sample(D,L),this.slow_.sample(D,L)},I.canEstimate=function(){var _=this.fast_;return _&&_.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},x}();R.default=p},"./src/utils/ewma.ts":function(K,R,h){"use strict";h.r(R);var P=function(){function p(I,T,_){T===void 0&&(T=0),_===void 0&&(_=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=I,this.alpha_=I?Math.exp(Math.log(.5)/I):0,this.estimate_=T,this.totalWeight_=_}var x=p.prototype;return x.sample=function(T,_){var A=Math.pow(this.alpha_,T);this.estimate_=_*(1-A)+A*this.estimate_,this.totalWeight_+=T},x.getTotalWeight=function(){return this.totalWeight_},x.getEstimate=function(){if(this.alpha_){var T=1-Math.pow(this.alpha_,this.totalWeight_);if(T)return this.estimate_/T}return this.estimate_},p}();R.default=P},"./src/utils/fetch-loader.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"fetchSupported",function(){return g});var P=h("./src/polyfills/number.ts"),p=h("./src/loader/load-stats.ts"),x=h("./src/demux/chunk-cache.ts");function I(u,n){u.prototype=Object.create(n.prototype),u.prototype.constructor=u,D(u,n)}function T(u){var n=typeof Map=="function"?new Map:void 0;return T=function(t){if(t===null||!y(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n!="undefined"){if(n.has(t))return n.get(t);n.set(t,l)}function l(){return _(t,arguments,L(this).constructor)}return l.prototype=Object.create(t.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),D(l,t)},T(u)}function _(u,n,i){return A()?_=Reflect.construct.bind():_=function(l,d,r){var c=[null];c.push.apply(c,d);var f=Function.bind.apply(l,c),o=new f;return r&&D(o,r.prototype),o},_.apply(null,arguments)}function A(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function y(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function D(u,n){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,l){return t.__proto__=l,t},D(u,n)}function L(u){return L=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},L(u)}function S(){return S=Object.assign?Object.assign.bind():function(u){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(u[t]=i[t])}return u},S.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var E=function(){function u(i){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=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new p.LoadStats}var n=u.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(t,l,d){var r=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var f=a(t,this.controller.signal),o=d.onProgress,v=t.responseType==="arraybuffer",m=v?"byteLength":"length";this.context=t,this.config=l,this.callbacks=d,this.request=this.fetchSetup(t,f),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){r.abortInternal(),d.onTimeout(c,t,r.response)},l.timeout),self.fetch(this.request).then(function(O){if(r.response=r.loader=O,!O.ok){var b=O.status,M=O.statusText;throw new s(M||"fetch, bad network response",b,O)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(O.headers.get("Content-Length")||"0"),o&&Object(P.isFiniteNumber)(l.highWaterMark)?r.loadProgressively(O,c,t,l.highWaterMark,o):v?O.arrayBuffer():O.text()}).then(function(O){var b=r.response;self.clearTimeout(r.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=O[m];var M={url:b.url,data:O};o&&!Object(P.isFiniteNumber)(l.highWaterMark)&&o(c,t,O,b),d.onSuccess(M,c,t,b)}).catch(function(O){if(self.clearTimeout(r.requestTimeout),!c.aborted){var b=O&&O.code||0,M=O?O.message:null;d.onError({code:b,text:M},t,O?O.details:null)}})},n.getCacheAge=function(){var t=null;if(this.response){var l=this.response.headers.get("age");t=l?parseFloat(l):null}return t},n.loadProgressively=function(t,l,d,r,c){r===void 0&&(r=0);var f=new x.default,o=t.body.getReader(),v=function m(){return o.read().then(function(O){if(O.done)return f.dataLength&&c(l,d,f.flush(),t),Promise.resolve(new ArrayBuffer(0));var b=O.value,M=b.length;return l.loaded+=M,M<r||f.dataLength?(f.push(b),f.dataLength>=r&&c(l,d,f.flush(),t)):c(l,d,b,t),m()}).catch(function(){return Promise.reject()})};return v()},u}();function a(u,n){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:n,headers:new self.Headers(S({},u.headers))};return u.rangeEnd&&i.headers.set("Range","bytes="+u.rangeStart+"-"+String(u.rangeEnd-1)),i}function e(u,n){return new self.Request(u.url,n)}var s=function(u){I(n,u);function n(i,t,l){var d;return d=u.call(this,i)||this,d.code=void 0,d.details=void 0,d.code=t,d.details=l,d}return n}(T(Error));R.default=E},"./src/utils/imsc1-ttml-parser.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"IMSC1_CODEC",function(){return y}),h.d(R,"parseIMSC1",function(){return g});var P=h("./src/utils/mp4-tools.ts"),p=h("./src/utils/vttparser.ts"),x=h("./src/utils/vttcue.ts"),I=h("./src/demux/id3.ts"),T=h("./src/utils/timescale-conversion.ts"),_=h("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(r){for(var c=1;c<arguments.length;c++){var f=arguments[c];for(var o in f)Object.prototype.hasOwnProperty.call(f,o)&&(r[o]=f[o])}return r},A.apply(this,arguments)}var y="stpp.ttml.im1t",D=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,L=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,S={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(r,c,f,o,v){var m=Object(P.findBox)(new Uint8Array(r),["mdat"]);if(m.length===0){v(new Error("Could not parse IMSC1 mdat"));return}var O=m.map(function(M){return Object(I.utf8ArrayToStr)(M)}),b=Object(T.toTimescaleFromScale)(c,1,f);try{O.forEach(function(M){return o(E(M,b))})}catch(M){v(M)}}function E(r,c){var f=new DOMParser,o=f.parseFromString(r,"text/xml"),v=o.getElementsByTagName("tt")[0];if(!v)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(m).reduce(function(C,U){return C[U]=v.getAttribute("ttp:"+U)||m[U],C},{}),b=v.getAttribute("xml:space")!=="preserve",M=e(a(v,"styling","style")),F=e(a(v,"layout","region")),w=a(v,"body","[begin]");return[].map.call(w,function(C){var U=s(C,b);if(!U||!C.hasAttribute("begin"))return null;var B=t(C.getAttribute("begin"),O),N=t(C.getAttribute("dur"),O),k=t(C.getAttribute("end"),O);if(B===null)throw i(C);if(k===null){if(N===null)throw i(C);k=B+N}var j=new x.default(B-c,k-c,U);j.id=Object(_.generateCueId)(j.startTime,j.endTime,j.text);var H=F[C.getAttribute("region")],V=M[C.getAttribute("style")];j.position=10,j.size=80;var Y=u(H,V,M),Q=Y.textAlign;if(Q){var J=S[Q];J&&(j.lineAlign=J),j.align=Q}return A(j,Y),j}).filter(function(C){return C!==null})}function a(r,c,f){var o=r.getElementsByTagName(c)[0];return o?[].slice.call(o.querySelectorAll(f)):[]}function e(r){return r.reduce(function(c,f){var o=f.getAttribute("xml:id");return o&&(c[o]=f),c},{})}function s(r,c){return[].slice.call(r.childNodes).reduce(function(f,o,v){var m;return o.nodeName==="br"&&v?f+`
|
|
20
|
+
`:(m=o.childNodes)!==null&&m!==void 0&&m.length?s(o,c):c?f+o.textContent.trim().replace(/\s+/g," "):f+o.textContent},"")}function u(r,c,f){var o="http://www.w3.org/ns/ttml#styling",v=null,m=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],O=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return O&&f.hasOwnProperty(O)&&(v=f[O]),m.reduce(function(b,M){var F=n(c,o,M)||n(r,o,M)||n(v,o,M);return F&&(b[M]=F),b},{})}function n(r,c,f){return r&&r.hasAttributeNS(c,f)?r.getAttributeNS(c,f):null}function i(r){return new Error("Could not parse ttml timestamp "+r)}function t(r,c){if(!r)return null;var f=Object(p.parseTimeStamp)(r);return f===null&&(D.test(r)?f=l(r,c):L.test(r)&&(f=d(r,c))),f}function l(r,c){var f=D.exec(r),o=(f[4]|0)+(f[5]|0)/c.subFrameRate;return(f[1]|0)*3600+(f[2]|0)*60+(f[3]|0)+o/c.frameRate}function d(r,c){var f=L.exec(r),o=Number(f[1]),v=f[2];switch(v){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/c.frameRate;case"t":return o/c.tickRate}return o}},"./src/utils/logger.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"enableLogs",function(){return _}),h.d(R,"logger",function(){return A});var P=function(){},p={trace:P,debug:P,log:P,warn:P,info:P,error:P},x=p;function I(y){var D=self.console[y];return D?D.bind(self.console,"["+y+"] >"):P}function T(y){for(var D=arguments.length,L=new Array(D>1?D-1:0),S=1;S<D;S++)L[S-1]=arguments[S];L.forEach(function(g){x[g]=y[g]?y[g].bind(y):I(g)})}function _(y){if(self.console&&y===!0||typeof y=="object"){T(y,"debug","log","info","warn","error");try{x.log()}catch{x=p}}else x=p}var A=x},"./src/utils/mediakeys-helper.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"KeySystems",function(){return P}),h.d(R,"requestMediaKeySystemAccess",function(){return p});var P;(function(x){x.WIDEVINE="com.widevine.alpha",x.PLAYREADY="com.microsoft.playready"})(P||(P={}));var p=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"getMediaSource",function(){return P});function P(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"RemuxerTrackIdConfig",function(){return _}),h.d(R,"bin2str",function(){return A}),h.d(R,"readUint16",function(){return y}),h.d(R,"readUint32",function(){return D}),h.d(R,"readSint32",function(){return L}),h.d(R,"writeUint32",function(){return S}),h.d(R,"findBox",function(){return g}),h.d(R,"parseSegmentIndex",function(){return E}),h.d(R,"parseInitSegment",function(){return a}),h.d(R,"getStartDTS",function(){return e}),h.d(R,"getDuration",function(){return s}),h.d(R,"computeRawDurationFromSamples",function(){return u}),h.d(R,"offsetStartDTS",function(){return n}),h.d(R,"segmentValidRange",function(){return i}),h.d(R,"appendUint8Array",function(){return t}),h.d(R,"parseSamples",function(){return l}),h.d(R,"parseSEIMessageFromNALu",function(){return c}),h.d(R,"parseEmsg",function(){return o});var P=h("./src/utils/typed-array.ts"),p=h("./src/loader/fragment.ts"),x=h("./src/demux/id3.ts"),I=Math.pow(2,32)-1,T=[].push,_={video:1,audio:2,id3:3,text:4};function A(v){return String.fromCharCode.apply(null,v)}function y(v,m){var O=v[m]<<8|v[m+1];return O<0?65536+O:O}function D(v,m){var O=L(v,m);return O<0?4294967296+O:O}function L(v,m){return v[m]<<24|v[m+1]<<16|v[m+2]<<8|v[m+3]}function S(v,m,O){v[m]=O>>24,v[m+1]=O>>16&255,v[m+2]=O>>8&255,v[m+3]=O&255}function g(v,m){var O=[];if(!m.length)return O;for(var b=v.byteLength,M=0;M<b;){var F=D(v,M),w=A(v.subarray(M+4,M+8)),C=F>1?M+F:b;if(w===m[0])if(m.length===1)O.push(v.subarray(M+8,C));else{var U=g(v.subarray(M+8,C),m.slice(1));U.length&&T.apply(O,U)}M=C}return O}function E(v){var m=[],O=v[0],b=8,M=D(v,b);b+=4;var F=0,w=0;O===0?b+=8:b+=16,b+=2;var C=v.length+w,U=y(v,b);b+=2;for(var B=0;B<U;B++){var N=b,k=D(v,N);N+=4;var j=k&2147483647,H=(k&2147483648)>>>31;if(H===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var V=D(v,N);N+=4,m.push({referenceSize:j,subsegmentDuration:V,info:{duration:V/M,start:C,end:C+j-1}}),C+=j,N+=4,b=N}return{earliestPresentationTime:F,timescale:M,version:O,referencesCount:U,references:m}}function a(v){for(var m=[],O=g(v,["moov","trak"]),b=0;b<O.length;b++){var M=O[b],F=g(M,["tkhd"])[0];if(F){var w=F[0],C=w===0?12:20,U=D(F,C),B=g(M,["mdia","mdhd"])[0];if(B){w=B[0],C=w===0?12:20;var N=D(B,C),k=g(M,["mdia","hdlr"])[0];if(k){var j=A(k.subarray(8,12)),H={soun:p.ElementaryStreamTypes.AUDIO,vide:p.ElementaryStreamTypes.VIDEO}[j];if(H){var V=g(M,["mdia","minf","stbl","stsd"])[0],Y=void 0;V&&(Y=A(V.subarray(12,16))),m[U]={timescale:N,type:H},m[H]={timescale:N,id:U,codec:Y}}}}}}var Q=g(v,["moov","mvex","trex"]);return Q.forEach(function(J){var z=D(J,4),q=m[z];q&&(q.default={duration:D(J,12),flags:D(J,20)})}),m}function e(v,m){return g(m,["moof","traf"]).reduce(function(O,b){var M=g(b,["tfdt"])[0],F=M[0],w=g(b,["tfhd"]).reduce(function(C,U){var B=D(U,4),N=v[B];if(N){var k=D(M,4);F===1&&(k*=Math.pow(2,32),k+=D(M,8));var j=N.timescale||9e4,H=k/j;if(isFinite(H)&&(C===null||H<C))return H}return C},null);return w!==null&&isFinite(w)&&(O===null||w<O)?w:O},null)||0}function s(v,m){for(var O=0,b=0,M=0,F=g(v,["moof","traf"]),w=0;w<F.length;w++){var C=F[w],U=g(C,["tfhd"])[0],B=D(U,4),N=m[B];if(!!N){var k=N.default,j=D(U,0)|(k==null?void 0:k.flags),H=k==null?void 0:k.duration;j&8&&(j&2?H=D(U,12):H=D(U,8));for(var V=N.timescale||9e4,Y=g(C,["trun"]),Q=0;Q<Y.length;Q++){if(O=u(Y[Q]),!O&&H){var J=D(Y[Q],4);O=H*J}N.type===p.ElementaryStreamTypes.VIDEO?b+=O/V:N.type===p.ElementaryStreamTypes.AUDIO&&(M+=O/V)}}}if(b===0&&M===0){for(var z=0,q=g(v,["sidx"]),re=0;re<q.length;re++){var X=E(q[re]);X!=null&&X.references&&(z+=X.references.reduce(function(le,ne){return le+ne.info.duration||0},0))}return z}return b||M}function u(v){var m=D(v,0),O=8;m&1&&(O+=4),m&4&&(O+=4);for(var b=0,M=D(v,4),F=0;F<M;F++){if(m&256){var w=D(v,O);b+=w,O+=4}m&512&&(O+=4),m&1024&&(O+=4),m&2048&&(O+=4)}return b}function n(v,m,O){g(m,["moof","traf"]).forEach(function(b){g(b,["tfhd"]).forEach(function(M){var F=D(M,4),w=v[F];if(!!w){var C=w.timescale||9e4;g(b,["tfdt"]).forEach(function(U){var B=U[0],N=D(U,4);if(B===0)N-=O*C,N=Math.max(N,0),S(U,4,N);else{N*=Math.pow(2,32),N+=D(U,8),N-=O*C,N=Math.max(N,0);var k=Math.floor(N/(I+1)),j=Math.floor(N%(I+1));S(U,4,k),S(U,8,j)}})}})})}function i(v){var m={valid:null,remainder:null},O=g(v,["moof"]);if(O){if(O.length<2)return m.remainder=v,m}else return m;var b=O[O.length-1];return m.valid=Object(P.sliceUint8)(v,0,b.byteOffset-8),m.remainder=Object(P.sliceUint8)(v,b.byteOffset-8),m}function t(v,m){var O=new Uint8Array(v.length+m.length);return O.set(v),O.set(m,v.length),O}function l(v,m){var O=[],b=m.samples,M=m.timescale,F=m.id,w=!1,C=g(b,["moof"]);return C.map(function(U){var B=U.byteOffset-8,N=g(U,["traf"]);N.map(function(k){var j=g(k,["tfdt"]).map(function(H){var V=H[0],Y=D(H,4);return V===1&&(Y*=Math.pow(2,32),Y+=D(H,8)),Y/M})[0];return j!==void 0&&(v=j),g(k,["tfhd"]).map(function(H){var V=D(H,4),Y=D(H,0)&16777215,Q=(Y&1)!==0,J=(Y&2)!==0,z=(Y&8)!==0,q=0,re=(Y&16)!==0,X=0,le=(Y&32)!==0,ne=8;V===F&&(Q&&(ne+=8),J&&(ne+=4),z&&(q=D(H,ne),ne+=4),re&&(X=D(H,ne),ne+=4),le&&(ne+=4),m.type==="video"&&(w=d(m.codec)),g(k,["trun"]).map(function(te){var ee=te[0],$=D(te,0)&16777215,Z=($&1)!==0,ue=0,he=($&4)!==0,se=($&256)!==0,me=0,pe=($&512)!==0,Ee=0,ae=($&1024)!==0,fe=($&2048)!==0,ge=0,ve=D(te,4),Te=8;Z&&(ue=D(te,Te),Te+=4),he&&(Te+=4);for(var Le=ue+B,Oe=0;Oe<ve;Oe++){if(se?(me=D(te,Te),Te+=4):me=q,pe?(Ee=D(te,Te),Te+=4):Ee=X,ae&&(Te+=4),fe&&(ee===0?ge=D(te,Te):ge=L(te,Te),Te+=4),m.type===p.ElementaryStreamTypes.VIDEO)for(var xe=0;xe<Ee;){var ye=D(b,Le);Le+=4;var W=b[Le]&31;if(r(w,W)){var G=b.subarray(Le,Le+ye);c(G,v+ge/M,O)}Le+=ye,xe+=ye+4}v+=me/M}}))})})}),O}function d(v){if(!v)return!1;var m=v.indexOf("."),O=m<0?v:v.substring(0,m);return O==="hvc1"||O==="hev1"||O==="dvh1"||O==="dvhe"}function r(v,m){return v?m===39||m===40:m===6}function c(v,m,O){var b=f(v),M=0;M++;for(var F=0,w=0,C=!1,U=0;M<b.length;){F=0;do{if(M>=b.length)break;U=b[M++],F+=U}while(U===255);w=0;do{if(M>=b.length)break;U=b[M++],w+=U}while(U===255);var B=b.length-M;if(!C&&F===4&&M<b.length){C=!0;var N=b[M++];if(N===181){var k=y(b,M);if(M+=2,k===49){var j=D(b,M);if(M+=4,j===1195456820){var H=b[M++];if(H===3){var V=b[M++],Y=31&V,Q=64&V,J=Q?2+Y*3:0,z=new Uint8Array(J);if(Q){z[0]=V;for(var q=1;q<J;q++)z[q]=b[M++]}O.push({type:H,payloadType:F,pts:m,bytes:z})}}}}}else if(F===5&&w<B){if(C=!0,w>16){for(var re=[],X=0;X<16;X++){var le=b[M++].toString(16);re.push(le.length==1?"0"+le:le),(X===3||X===5||X===7||X===9)&&re.push("-")}for(var ne=w-16,te=new Uint8Array(ne),ee=0;ee<ne;ee++)te[ee]=b[M++];O.push({payloadType:F,pts:m,uuid:re.join(""),userData:Object(x.utf8ArrayToStr)(te),userDataBytes:te})}}else if(w<B)M+=w;else if(w>B)break}}function f(v){for(var m=v.byteLength,O=[],b=1;b<m-2;)v[b]===0&&v[b+1]===0&&v[b+2]===3?(O.push(b+2),b+=2):b++;if(O.length===0)return v;var M=m-O.length,F=new Uint8Array(M),w=0;for(b=0;b<M;w++,b++)w===O[0]&&(w++,O.shift()),F[b]=v[w];return F}function o(v){var m=v[0],O="",b="",M=0,F=0,w=0,C=0,U=0,B=0;if(m===0){for(;A(v.subarray(B,B+1))!=="\0";)O+=A(v.subarray(B,B+1)),B+=1;for(O+=A(v.subarray(B,B+1)),B+=1;A(v.subarray(B,B+1))!=="\0";)b+=A(v.subarray(B,B+1)),B+=1;b+=A(v.subarray(B,B+1)),B+=1,M=D(v,12),F=D(v,16),C=D(v,20),U=D(v,24),B=28}else if(m===1){B+=4,M=D(v,B),B+=4;var N=D(v,B);B+=4;var k=D(v,B);for(B+=4,w=Math.pow(2,32)*N+k,Number.isSafeInteger(w)||(w=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),C=D(v,B),B+=4,U=D(v,B),B+=4;A(v.subarray(B,B+1))!=="\0";)O+=A(v.subarray(B,B+1)),B+=1;for(O+=A(v.subarray(B,B+1)),B+=1;A(v.subarray(B,B+1))!=="\0";)b+=A(v.subarray(B,B+1)),B+=1;b+=A(v.subarray(B,B+1)),B+=1}var j=v.subarray(B,v.byteLength);return{schemeIdUri:O,value:b,timeScale:M,presentationTime:w,presentationTimeDelta:F,eventDuration:C,id:U,payload:j}}},"./src/utils/output-filter.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"default",function(){return P});var P=function(){function p(I,T){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=I,this.trackName=T}var x=p.prototype;return x.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},x.newCue=function(T,_,A){(this.startTime===null||this.startTime>T)&&(this.startTime=T),this.endTime=_,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},x.reset=function(){this.cueRanges=[],this.startTime=null},p}()},"./src/utils/texttrack-utils.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"sendAddTrackEvent",function(){return p}),h.d(R,"addCueToTrack",function(){return x}),h.d(R,"clearCurrentCues",function(){return I}),h.d(R,"removeCuesInRange",function(){return T}),h.d(R,"getCuesInRange",function(){return A});var P=h("./src/utils/logger.ts");function p(y,D){var L;try{L=new Event("addtrack")}catch{L=document.createEvent("Event"),L.initEvent("addtrack",!1,!1)}L.track=y,D.dispatchEvent(L)}function x(y,D){var L=y.mode;if(L==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(D.id))try{if(y.addCue(D),!y.cues.getCueById(D.id))throw new Error("addCue is failed for: "+D)}catch(g){P.logger.debug("[texttrack-utils]: "+g);var S=new self.TextTrackCue(D.startTime,D.endTime,D.text);S.id=D.id,y.addCue(S)}L==="disabled"&&(y.mode=L)}function I(y){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues)for(var L=y.cues.length;L--;)y.removeCue(y.cues[L]);D==="disabled"&&(y.mode=D)}function T(y,D,L,S){var g=y.mode;if(g==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var E=A(y.cues,D,L),a=0;a<E.length;a++)(!S||S(E[a]))&&y.removeCue(E[a]);g==="disabled"&&(y.mode=g)}function _(y,D){if(D<y[0].startTime)return 0;var L=y.length-1;if(D>y[L].endTime)return-1;for(var S=0,g=L;S<=g;){var E=Math.floor((g+S)/2);if(D<y[E].startTime)g=E-1;else if(D>y[E].startTime&&S<L)S=E+1;else return E}return y[S].startTime-D<D-y[g].startTime?S:g}function A(y,D,L){var S=[],g=_(y,D);if(g>-1)for(var E=g,a=y.length;E<a;E++){var e=y[E];if(e.startTime>=D&&e.endTime<=L)S.push(e);else if(e.startTime>L)return S}return S}},"./src/utils/time-ranges.ts":function(K,R,h){"use strict";h.r(R);var P={toString:function(x){for(var I="",T=x.length,_=0;_<T;_++)I+="["+x.start(_).toFixed(3)+","+x.end(_).toFixed(3)+"]";return I}};R.default=P},"./src/utils/timescale-conversion.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"toTimescaleFromBase",function(){return p}),h.d(R,"toTimescaleFromScale",function(){return x}),h.d(R,"toMsFromMpegTsClock",function(){return I}),h.d(R,"toMpegTsClockFromTimescale",function(){return T});var P=9e4;function p(_,A,y,D){y===void 0&&(y=1),D===void 0&&(D=!1);var L=_*A*y;return D?Math.round(L):L}function x(_,A,y,D){return y===void 0&&(y=1),D===void 0&&(D=!1),p(_,A,1/y,D)}function I(_,A){return A===void 0&&(A=!1),p(_,1e3,1/P,A)}function T(_,A){return A===void 0&&(A=1),p(_,P,1/A)}},"./src/utils/typed-array.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"sliceUint8",function(){return P});function P(p,x,I){return Uint8Array.prototype.slice?p.slice(x,I):new Uint8Array(Array.prototype.slice.call(p,x,I))}},"./src/utils/vttcue.ts":function(K,R,h){"use strict";h.r(R),R.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var P=["","lr","rl"],p=["start","middle","end","left","right"];function x(y,D){if(typeof D!="string"||!Array.isArray(y))return!1;var L=D.toLowerCase();return~y.indexOf(L)?L:!1}function I(y){return x(P,y)}function T(y){return x(p,y)}function _(y){for(var D=arguments.length,L=new Array(D>1?D-1:0),S=1;S<D;S++)L[S-1]=arguments[S];for(var g=1;g<arguments.length;g++){var E=arguments[g];for(var a in E)y[a]=E[a]}return y}function A(y,D,L){var S=this,g={enumerable:!0};S.hasBeenReset=!1;var E="",a=!1,e=y,s=D,u=L,n=null,i="",t=!0,l="auto",d="start",r=50,c="middle",f=50,o="middle";Object.defineProperty(S,"id",_({},g,{get:function(){return E},set:function(m){E=""+m}})),Object.defineProperty(S,"pauseOnExit",_({},g,{get:function(){return a},set:function(m){a=!!m}})),Object.defineProperty(S,"startTime",_({},g,{get:function(){return e},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");e=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"endTime",_({},g,{get:function(){return s},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");s=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"text",_({},g,{get:function(){return u},set:function(m){u=""+m,this.hasBeenReset=!0}})),Object.defineProperty(S,"region",_({},g,{get:function(){return n},set:function(m){n=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"vertical",_({},g,{get:function(){return i},set:function(m){var O=I(m);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"snapToLines",_({},g,{get:function(){return t},set:function(m){t=!!m,this.hasBeenReset=!0}})),Object.defineProperty(S,"line",_({},g,{get:function(){return l},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");l=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"lineAlign",_({},g,{get:function(){return d},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");d=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"position",_({},g,{get:function(){return r},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");r=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"positionAlign",_({},g,{get:function(){return c},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");c=O,this.hasBeenReset=!0}})),Object.defineProperty(S,"size",_({},g,{get:function(){return f},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");f=m,this.hasBeenReset=!0}})),Object.defineProperty(S,"align",_({},g,{get:function(){return o},set:function(m){var O=T(m);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");o=O,this.hasBeenReset=!0}})),S.displayState=void 0}return A.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},A}()},"./src/utils/vttparser.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"parseTimeStamp",function(){return x}),h.d(R,"fixLineBreaks",function(){return D}),h.d(R,"VTTParser",function(){return L});var P=h("./src/utils/vttcue.ts"),p=function(){function S(){}var g=S.prototype;return g.decode=function(a,e){if(!a)return"";if(typeof a!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(a))},S}();function x(S){function g(a,e,s,u){return(a|0)*3600+(e|0)*60+(s|0)+parseFloat(u||0)}var E=S.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return E?parseFloat(E[2])>59?g(E[2],E[3],0,E[4]):g(E[1],E[2],E[3],E[4]):null}var I=function(){function S(){this.values=Object.create(null)}var g=S.prototype;return g.set=function(a,e){!this.get(a)&&e!==""&&(this.values[a]=e)},g.get=function(a,e,s){return s?this.has(a)?this.values[a]:e[s]:this.has(a)?this.values[a]:e},g.has=function(a){return a in this.values},g.alt=function(a,e,s){for(var u=0;u<s.length;++u)if(e===s[u]){this.set(a,e);break}},g.integer=function(a,e){/^-?\d+$/.test(e)&&this.set(a,parseInt(e,10))},g.percent=function(a,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var s=parseFloat(e);if(s>=0&&s<=100)return this.set(a,s),!0}return!1},S}();function T(S,g,E,a){var e=a?S.split(a):[S];for(var s in e)if(typeof e[s]=="string"){var u=e[s].split(E);if(u.length===2){var n=u[0],i=u[1];g(n,i)}}}var _=new P.default(0,0,""),A=_.align==="middle"?"middle":"center";function y(S,g,E){var a=S;function e(){var n=x(S);if(n===null)throw new Error("Malformed timestamp: "+a);return S=S.replace(/^[^\sa-zA-Z-]+/,""),n}function s(n,i){var t=new I;T(n,function(r,c){var f;switch(r){case"region":for(var o=E.length-1;o>=0;o--)if(E[o].id===c){t.set(r,E[o].region);break}break;case"vertical":t.alt(r,c,["rl","lr"]);break;case"line":f=c.split(","),t.integer(r,f[0]),t.percent(r,f[0])&&t.set("snapToLines",!1),t.alt(r,f[0],["auto"]),f.length===2&&t.alt("lineAlign",f[1],["start",A,"end"]);break;case"position":f=c.split(","),t.percent(r,f[0]),f.length===2&&t.alt("positionAlign",f[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":t.percent(r,c);break;case"align":t.alt(r,c,["start",A,"end","left","right"]);break}},/:/,/\s/),i.region=t.get("region",null),i.vertical=t.get("vertical","");var l=t.get("line","auto");l==="auto"&&_.line===-1&&(l=-1),i.line=l,i.lineAlign=t.get("lineAlign","start"),i.snapToLines=t.get("snapToLines",!0),i.size=t.get("size",100),i.align=t.get("align",A);var d=t.get("position","auto");d==="auto"&&_.position===50&&(d=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=d}function u(){S=S.replace(/^\s+/,"")}if(u(),g.startTime=e(),u(),S.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+a);S=S.slice(3),u(),g.endTime=e(),u(),s(S,g)}function D(S){return S.replace(/<br(?: \/)?>/gi,`
|
|
21
|
+
`)}var L=function(){function S(){this.state="INITIAL",this.buffer="",this.decoder=new p,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var g=S.prototype;return g.parse=function(a){var e=this;a&&(e.buffer+=e.decoder.decode(a,{stream:!0}));function s(){var d=e.buffer,r=0;for(d=D(d);r<d.length&&d[r]!=="\r"&&d[r]!==`
|
|
22
22
|
`;)++r;var c=d.slice(0,r);return d[r]==="\r"&&++r,d[r]===`
|
|
23
|
-
`&&++r,e.buffer=d.slice(r),c}function u(d){
|
|
23
|
+
`&&++r,e.buffer=d.slice(r),c}function u(d){T(d,function(r,c){},/:/)}try{var n="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;n=s();var i=n.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var t=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(t?t=!1:n=s(),e.state){case"HEADER":/:/.test(n)?u(n):n||(e.state="ID");continue;case"NOTE":n||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){e.state="NOTE";break}if(!n)continue;if(e.cue=new P.default(0,0,""),e.state="CUE",n.indexOf("-->")===-1){e.cue.id=n;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{y(n,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var l=n.indexOf("-->")!==-1;if(!n||l&&(t=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
|
24
24
|
`),e.cue.text+=n}continue;case"BADCUE":n||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},g.flush=function(){var a=this;try{if((a.cue||a.state==="HEADER")&&(a.buffer+=`
|
|
25
25
|
|
|
26
|
-
`,a.parse()),a.state==="INITIAL"||a.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){a.onparsingerror&&a.onparsingerror(e)}return a.onflush&&a.onflush(),this},
|
|
26
|
+
`,a.parse()),a.state==="INITIAL"||a.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){a.onparsingerror&&a.onparsingerror(e)}return a.onflush&&a.onflush(),this},S}()},"./src/utils/webvtt-parser.ts":function(K,R,h){"use strict";h.r(R),h.d(R,"generateCueId",function(){return L}),h.d(R,"parseWebVTT",function(){return g});var P=h("./src/polyfills/number.ts"),p=h("./src/utils/vttparser.ts"),x=h("./src/demux/id3.ts"),I=h("./src/utils/timescale-conversion.ts"),T=h("./src/remux/mp4-remuxer.ts"),_=/\r\n|\n\r|\n|\r/g,A=function(a,e,s){return s===void 0&&(s=0),a.slice(s,s+e.length)===e},y=function(a){var e=parseInt(a.slice(-3)),s=parseInt(a.slice(-6,-4)),u=parseInt(a.slice(-9,-7)),n=a.length>9?parseInt(a.substring(0,a.indexOf(":"))):0;if(!Object(P.isFiniteNumber)(e)||!Object(P.isFiniteNumber)(s)||!Object(P.isFiniteNumber)(u)||!Object(P.isFiniteNumber)(n))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+a);return e+=1e3*s,e+=60*1e3*u,e+=60*60*1e3*n,e},D=function(a){for(var e=5381,s=a.length;s;)e=e*33^a.charCodeAt(--s);return(e>>>0).toString()};function L(E,a,e){return D(E.toString())+D(a.toString())+D(e)}var S=function(a,e,s){var u=a[e],n=a[u.prevCC];if(!n||!n.new&&u.new){a.ccOffset=a.presentationOffset=u.start,u.new=!1;return}for(;(i=n)!==null&&i!==void 0&&i.new;){var i;a.ccOffset+=u.start-n.start,u.new=!1,u=n,n=a[u.prevCC]}a.presentationOffset=s};function g(E,a,e,s,u,n,i,t){var l=new p.VTTParser,d=Object(x.utf8ArrayToStr)(new Uint8Array(E)).trim().replace(_,`
|
|
27
27
|
`).split(`
|
|
28
|
-
`),r=[],c=Object(I.toMpegTsClockFromTimescale)(a,e),f="00:00.000",o=0,v=0,m,O=!0;l.oncue=function(b){var M=s[u],F=s.ccOffset,w=(o-c)/9e4;M!=null&&M.new&&(v!==void 0?F=s.ccOffset=M.start:
|
|
29
|
-
`)}),l.flush()}},"./src/utils/xhr-loader.ts":function(K,P,h){"use strict";h.r(P);var R=h("./src/utils/logger.ts"),p=h("./src/loader/load-stats.ts"),S=/^age:\s*[\d.]+\s*$/m,I=function(){function x(A){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=A?A.xhrSetup:null,this.stats=new p.LoadStats,this.retryDelay=0}var L=x.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},L.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(y,D,_){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=D,this.callbacks=_,this.retryDelay=D.retryDelay,this.loadInternal()},L.loadInternal=function(){var y=this.config,D=this.context;if(!!y){var _=this.loader=new self.XMLHttpRequest,T=this.stats;T.loading.first=0,T.loaded=0;var g=this.xhrSetup;try{if(g)try{g(_,D.url)}catch{_.open("GET",D.url,!0),g(_,D.url)}_.readyState||_.open("GET",D.url,!0);var E=this.context.headers;if(E)for(var a in E)_.setRequestHeader(a,E[a])}catch(e){this.callbacks.onError({code:_.status,text:e.message},D,_);return}D.rangeEnd&&_.setRequestHeader("Range","bytes="+D.rangeStart+"-"+(D.rangeEnd-1)),_.onreadystatechange=this.readystatechange.bind(this),_.onprogress=this.loadprogress.bind(this),_.responseType=D.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),_.send()}},L.readystatechange=function(){var y=this.context,D=this.loader,_=this.stats;if(!(!y||!D)){var T=D.readyState,g=this.config;if(!_.aborted&&T>=2)if(self.clearTimeout(this.requestTimeout),_.loading.first===0&&(_.loading.first=Math.max(self.performance.now(),_.loading.start)),T===4){D.onreadystatechange=null,D.onprogress=null;var E=D.status;if(E>=200&&E<300){_.loading.end=Math.max(self.performance.now(),_.loading.first);var a,e;if(y.responseType==="arraybuffer"?(a=D.response,e=a.byteLength):(a=D.responseText,e=a.length),_.loaded=_.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(_,y,a,D),!this.callbacks)return;var u={url:D.responseURL,data:a};this.callbacks.onSuccess(u,_,y,D)}else _.retry>=g.maxRetry||E>=400&&E<499?(R.logger.error(E+" while loading "+y.url),this.callbacks.onError({code:E,text:D.statusText},y,D)):(R.logger.warn(E+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,g.maxRetryDelay),_.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},L.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(y){var D=this.stats;D.loaded=y.loaded,y.lengthComputable&&(D.total=y.total)},L.getCacheAge=function(){var y=null;if(this.loader&&S.test(this.loader.getAllResponseHeaders())){var D=this.loader.getResponseHeader("age");y=D?parseFloat(D):null}return y},x}();P.default=I}}).default})});var gt=tt(Et()),Ue=tt(it());var ut=tt(it());var Me=(K,P,h,R)=>{K.addEventListener(P,h,R),K.addEventListener("teardown",()=>{K.removeEventListener(P,h)},{once:!0})},ot=(K,P)=>K in P;function Tt(K,P,h){P&&h>P&&(h=P);for(let R=0;R<K.length;R++)if(K.start(R)<=h&&K.end(R)>=h)return!0;return!1}var ft={ANY:"any",MUTED:"muted"},jt=Object.values(ft),xt=K=>typeof K=="boolean"||typeof K=="string"&&jt.includes(K),Wt=(K,P,h)=>{let R=!1,p=!1,S=xt(P)?P:!!P,I=()=>{R||Me(K,"playing",()=>{R=!0},{once:!0})};if(I(),Me(K,"loadstart",()=>{R=!1,I(),lt(K,S)},{once:!0}),Me(K,"loadstart",()=>{h||(p=!Number.isFinite(K.duration)),lt(K,S)},{once:!0}),h&&h.once(ut.default.Events.LEVEL_LOADED,(L,A)=>{var y;p=(y=A.details.live)!=null?y:!1}),!S){let L=()=>{!p||(h!=null&&h.liveSyncPosition?K.currentTime=h.liveSyncPosition:Number.isFinite(K.seekable.end(0))&&(K.currentTime=K.seekable.end(0)))};h&&Me(K,"play",()=>{K.preload==="metadata"?h.once(ut.default.Events.LEVEL_UPDATED,L):L()},{once:!0})}return L=>{R||(S=xt(L)?L:!!L,lt(K,S))}},lt=(K,P)=>{if(!P)return;let h=K.muted,R=()=>K.muted=h;switch(P){case ft.ANY:K.play().catch(p=>{K.muted=!0,K.play().catch(R)});break;case ft.MUTED:K.muted=!0,K.play().catch(R);break;default:K.play().catch(()=>{});break}};var je=class extends Error{constructor(h,R=je.MEDIA_ERR_CUSTOM,p){var S;super(h);this.name="MediaError",this.code=R,this.fatal=p!=null?p:R>=je.MEDIA_ERR_NETWORK&&R<=je.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(S=je.defaultMessages[this.code])!=null?S:"")}},be=je;be.MEDIA_ERR_ABORTED=1,be.MEDIA_ERR_NETWORK=2,be.MEDIA_ERR_DECODE=3,be.MEDIA_ERR_SRC_NOT_SUPPORTED=4,be.MEDIA_ERR_ENCRYPTED=5,be.MEDIA_ERR_CUSTOM=100,be.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var We=tt(it());function St(K,P){P.on(We.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(p,{tracks:S})=>{S.forEach(I=>{var A;let x=(A=I.subtitleTrack)!=null?A:I.closedCaptions,L=P.subtitleTracks.findIndex(({lang:y,name:D,type:_})=>y==(x==null?void 0:x.lang)&&D===I.label&&_.toLowerCase()===I.kind);Dt(K,I.kind,I.label,x==null?void 0:x.lang,`${I.kind}${L}`)})});let h=()=>{var I;if(!P.subtitleTracks.length)return;let p=Array.from(K.textTracks).find(x=>x.id&&x.mode==="showing"&&["subtitles","captions"].includes(x.kind)),S=`${(I=P.subtitleTracks[P.subtitleTrack])==null?void 0:I.type.toLowerCase()}${P.subtitleTrack}`;if(p&&(P.subtitleTrack<0||(p==null?void 0:p.id)!==S)){let x=P.subtitleTracks.findIndex(({lang:L,name:A,type:y})=>L==p.language&&A===p.label&&y.toLowerCase()===p.kind);P.subtitleTrack=x}p&&(p==null?void 0:p.id)===S&&p.cues&&Array.from(p.cues).forEach(x=>{p.addCue(x)})};K.textTracks.addEventListener("change",h),P.on(We.default.Events.CUES_PARSED,(p,{track:S,type:I,cues:x})=>{let L=K.textTracks.getTrackById(S);if(!L)return;let A=L.mode==="disabled";A&&(L.mode="hidden"),x.forEach(y=>{var D;(D=L.cues)!=null&&D.getCueById(y.id)||L.addCue(y)}),A&&(L.mode="disabled")}),P.once(We.default.Events.DESTROYING,()=>{K.textTracks.removeEventListener("change",h),K.querySelectorAll("track[data-removeondestroy]").forEach(S=>{S.remove()})});let R=()=>{Array.from(K.textTracks).forEach(p=>{var S,I;if(!["subtitles","caption"].includes(p.kind)&&p.label==="thumbnails"){if(!((S=p.cues)!=null&&S.length)){let x=K.querySelector('track[label="thumbnails"]'),L=(I=x==null?void 0:x.getAttribute("src"))!=null?I:"";x==null||x.removeAttribute("src"),setTimeout(()=>{x==null||x.setAttribute("src",L)},0)}p.mode!=="hidden"&&(p.mode="hidden")}})};P.once(We.default.Events.MANIFEST_LOADED,R),P.once(We.default.Events.MEDIA_ATTACHED,R)}function Dt(K,P,h,R,p){let S=document.createElement("track");return S.kind=P,S.label=h,R&&(S.srclang=R),p&&(S.id=p),S.track.mode="disabled",S.setAttribute("data-removeondestroy",""),K.append(S),S.track}function Gt(K,P){let h=Array.prototype.find.call(K.querySelectorAll("track"),R=>R.track===P);h==null||h.remove()}var _t,At,Ht=(At=(_t=globalThis==null?void 0:globalThis.navigator)==null?void 0:_t.userAgent)!=null?At:"",Vt=Ht.toLowerCase().indexOf("android")!==-1,bt="mux.com",Lt,Ot,ct=(Ot=(Lt=Ue.default).isSupported)==null?void 0:Ot.call(Lt),Rt=Vt,vr=()=>gt.default.utils.now(),dt={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ge={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},ht={HLS:Ge.M3U8},gr=Object.keys(ht),mr=[...Object.values(Ge),"hls","HLS"],Yt=K=>{let P=K.indexOf("?");if(P<0)return[K];let h=K.slice(0,P),R=K.slice(P);return[h,R]},pr=(K,{domain:P=bt}={})=>{if(!K)return;let[h,R=""]=Yt(K);return`https://stream.${P}/${h}.m3u8${R}`},zt=K=>{let P="";try{P=new URL(K).pathname}catch{console.error("invalid url")}let h=P.lastIndexOf(".");if(h<0)return"";let p=P.slice(h+1).toUpperCase();return ot(p,Ge)?Ge[p]:""},Pt=K=>{let P=K.type;if(P){let R=P.toUpperCase();return ot(R,ht)?ht[R]:P}let{src:h}=K;return h?zt(h):""},Xt=K=>{if([dt.LIVE,dt.LL_LIVE].includes(K)){let P={backBufferLength:12};return K===dt.LL_LIVE?{...P,maxFragLookUpTolerance:.001}:P}return{}},He=new WeakMap,yr=K=>{var P;return(P=He.get(K))==null?void 0:P.error},Qt=(K,P)=>{P&&(P.detachMedia(),P.destroy()),(K==null?void 0:K.mux)&&!K.mux.deleted&&(K.mux.destroy(),delete K.mux),K&&(K.removeAttribute("src"),K.load(),K.removeEventListener("error",Mt),K.removeEventListener("error",vt),K.removeEventListener("durationchange",It),He.delete(K),K.dispatchEvent(new Event("teardown")))},Jt=(K,P)=>{var y;let{debug:h,preferMse:R,streamType:p,startTime:S=-1}=K,I=Pt(K),x=I===Ge.M3U8,L=!I||((y=P==null?void 0:P.canPlayType(I))!=null?y:!0);if(x&&!(!x||L&&!((R||Rt)&&ct))&&ct){let D={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},_=Xt(p);return new Ue.default({debug:h,startPosition:S,...D,..._})}},$t=({playbackId:K,src:P,customDomain:h})=>{if(K)return!0;if(typeof P!="string")return!1;let R=new URL(P).hostname.toLocaleLowerCase();return R.includes(bt)||!!h&&R.includes(h.toLocaleLowerCase())},Zt=(K,P,h)=>{let{envKey:R}=K,p=$t(K);if((R||p)&&P){let{playerInitTime:S,playerSoftwareName:I,playerSoftwareVersion:x,beaconCollectionDomain:L,metadata:A,debug:y}=K,D=_=>typeof _.player_error_code=="string"?!1:typeof K.errorTranslator=="function"?K.errorTranslator(_):_;gt.default.monitor(P,{debug:y,beaconCollectionDomain:L,hlsjs:h,Hls:h?Ue.default:void 0,automaticErrorTracking:!1,errorTranslator:D,data:{...R?{env_key:R}:{},player_software_name:I,player_software:I,player_software_version:x,player_init_time:S,...A}})}},qt=(K,P,h)=>{var y,D;if(!P){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:R,streamType:p}=K,S=Pt(K),I=S===Ge.M3U8,x=!S||((y=P==null?void 0:P.canPlayType(S))!=null?y:!0),L=!I||x&&!((R||Rt)&&ct),{src:A}=K;if(P&&x&&L)typeof A=="string"?(P.setAttribute("src",A),K.startTime&&(((D=He.get(P))!=null?D:{}).startTime=K.startTime,P.addEventListener("durationchange",It,{once:!0}))):P.removeAttribute("src"),P.addEventListener("error",Mt),P.addEventListener("error",vt);else if(h&&A){switch(h.on(Ue.default.Events.ERROR,(_,T)=>{let g={[Ue.default.ErrorTypes.NETWORK_ERROR]:be.MEDIA_ERR_NETWORK,[Ue.default.ErrorTypes.MEDIA_ERROR]:be.MEDIA_ERR_DECODE},E=new be("",g[T.type]);E.fatal=T.fatal,E.data=T,P.dispatchEvent(new CustomEvent("error",{detail:E}))}),P.addEventListener("error",vt),St(P,h),P.preload){case"none":Me(P,"play",()=>h.loadSource(A),{once:!0});break;case"metadata":let _=h.config.maxBufferLength,T=h.config.maxBufferSize;h.config.maxBufferLength=1,h.config.maxBufferSize=1,Me(P,"play",()=>{h.config.maxBufferLength=_,h.config.maxBufferSize=T},{once:!0}),h.loadSource(A);break;default:h.loadSource(A)}h.attachMedia(P)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function It(K){var R;let P=K.target,h=(R=He.get(P))==null?void 0:R.startTime;if(!!h&&Tt(P.seekable,P.duration,h)){let p=P.preload==="auto";p&&(P.preload="none"),P.currentTime=h,p&&(P.preload="auto")}}async function Mt(K){if(!K.isTrusted)return;K.stopImmediatePropagation();let P=K.target;if(!(P!=null&&P.error))return;let{message:h,code:R}=P.error,p=new be(h,R);if(P.src&&(R!==be.MEDIA_ERR_DECODE||R!==void 0)){let{status:S}=await fetch(P.src);p.data={response:{code:S}}}P.dispatchEvent(new CustomEvent("error",{detail:p}))}function vt(K){var R,p;if(!(K instanceof CustomEvent)||!(K.detail instanceof be))return;let P=K.target,h=K.detail;!h||!h.fatal||(((R=He.get(P))!=null?R:{}).error=h,(p=P.mux)==null||p.emit("error",{player_error_code:h.code,player_error_message:h.message}))}var Er=(K,P,h)=>{Qt(P,h),He.set(P,{});let R=Jt(K,P);return Zt(K,P,R),qt(K,P,R),R};})();
|
|
28
|
+
`),r=[],c=Object(I.toMpegTsClockFromTimescale)(a,e),f="00:00.000",o=0,v=0,m,O=!0;l.oncue=function(b){var M=s[u],F=s.ccOffset,w=(o-c)/9e4;M!=null&&M.new&&(v!==void 0?F=s.ccOffset=M.start:S(s,u,w)),w&&(F=w-s.presentationOffset);var C=b.endTime-b.startTime,U=Object(T.normalizePts)((b.startTime+F-v)*9e4,n*9e4)/9e4;b.startTime=Math.max(U,0),b.endTime=Math.max(U+C,0);var B=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(B)),b.id||(b.id=L(b.startTime,b.endTime,B)),b.endTime>0&&r.push(b)},l.onparsingerror=function(b){m=b},l.onflush=function(){if(m){t(m);return}i(r)},d.forEach(function(b){if(O)if(A(b,"X-TIMESTAMP-MAP=")){O=!1,b.slice(16).split(",").forEach(function(M){A(M,"LOCAL:")?f=M.slice(6):A(M,"MPEGTS:")&&(o=parseInt(M.slice(7)))});try{v=y(f)/1e3}catch(M){m=M}return}else b===""&&(O=!1);l.parse(b+`
|
|
29
|
+
`)}),l.flush()}},"./src/utils/xhr-loader.ts":function(K,R,h){"use strict";h.r(R);var P=h("./src/utils/logger.ts"),p=h("./src/loader/load-stats.ts"),x=/^age:\s*[\d.]+\s*$/m,I=function(){function T(A){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=A?A.xhrSetup:null,this.stats=new p.LoadStats,this.retryDelay=0}var _=T.prototype;return _.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},_.abortInternal=function(){var y=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),y&&(y.onreadystatechange=null,y.onprogress=null,y.readyState!==4&&(this.stats.aborted=!0,y.abort()))},_.abort=function(){var y;this.abortInternal(),(y=this.callbacks)!==null&&y!==void 0&&y.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},_.load=function(y,D,L){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=y,this.config=D,this.callbacks=L,this.retryDelay=D.retryDelay,this.loadInternal()},_.loadInternal=function(){var y=this.config,D=this.context;if(!!y){var L=this.loader=new self.XMLHttpRequest,S=this.stats;S.loading.first=0,S.loaded=0;var g=this.xhrSetup;try{if(g)try{g(L,D.url)}catch{L.open("GET",D.url,!0),g(L,D.url)}L.readyState||L.open("GET",D.url,!0);var E=this.context.headers;if(E)for(var a in E)L.setRequestHeader(a,E[a])}catch(e){this.callbacks.onError({code:L.status,text:e.message},D,L);return}D.rangeEnd&&L.setRequestHeader("Range","bytes="+D.rangeStart+"-"+(D.rangeEnd-1)),L.onreadystatechange=this.readystatechange.bind(this),L.onprogress=this.loadprogress.bind(this),L.responseType=D.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),L.send()}},_.readystatechange=function(){var y=this.context,D=this.loader,L=this.stats;if(!(!y||!D)){var S=D.readyState,g=this.config;if(!L.aborted&&S>=2)if(self.clearTimeout(this.requestTimeout),L.loading.first===0&&(L.loading.first=Math.max(self.performance.now(),L.loading.start)),S===4){D.onreadystatechange=null,D.onprogress=null;var E=D.status;if(E>=200&&E<300){L.loading.end=Math.max(self.performance.now(),L.loading.first);var a,e;if(y.responseType==="arraybuffer"?(a=D.response,e=a.byteLength):(a=D.responseText,e=a.length),L.loaded=L.total=e,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(L,y,a,D),!this.callbacks)return;var u={url:D.responseURL,data:a};this.callbacks.onSuccess(u,L,y,D)}else L.retry>=g.maxRetry||E>=400&&E<499?(P.logger.error(E+" while loading "+y.url),this.callbacks.onError({code:E,text:D.statusText},y,D)):(P.logger.warn(E+" while loading "+y.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,g.maxRetryDelay),L.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},_.loadtimeout=function(){P.logger.warn("timeout while loading "+this.context.url);var y=this.callbacks;y&&(this.abortInternal(),y.onTimeout(this.stats,this.context,this.loader))},_.loadprogress=function(y){var D=this.stats;D.loaded=y.loaded,y.lengthComputable&&(D.total=y.total)},_.getCacheAge=function(){var y=null;if(this.loader&&x.test(this.loader.getAllResponseHeaders())){var D=this.loader.getResponseHeader("age");y=D?parseFloat(D):null}return y},T}();R.default=I}}).default})});var mt=rt(Tt()),Be=rt(nt());var We=class extends Error{constructor(h,P=We.MEDIA_ERR_CUSTOM,p){var x;super(h);this.name="MediaError",this.code=P,this.fatal=p!=null?p:P>=We.MEDIA_ERR_NETWORK&&P<=We.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(x=We.defaultMessages[this.code])!=null?x:"")}},be=We;be.MEDIA_ERR_ABORTED=1,be.MEDIA_ERR_NETWORK=2,be.MEDIA_ERR_DECODE=3,be.MEDIA_ERR_SRC_NOT_SUPPORTED=4,be.MEDIA_ERR_ENCRYPTED=5,be.MEDIA_ERR_CUSTOM=100,be.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var vt=rt(nt());var ft=(K,R)=>K in R,at={ANY:"any",MUTED:"muted"},$e={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},dt={MSE:"mse",NATIVE:"native"},Me={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},st={HLS:Me.M3U8},ar=Object.keys(st),sr=[...Object.values(Me),"hls","HLS"];var Ue=(K,R,h,P)=>{K.addEventListener(R,h,P),K.addEventListener("teardown",()=>{K.removeEventListener(R,h)},{once:!0})};function xt(K,R,h){R&&h>R&&(h=R);for(let P=0;P<K.length;P++)if(K.start(P)<=h&&K.end(P)>=h)return!0;return!1}var St=K=>{let R=K.indexOf("?");if(R<0)return[K];let h=K.slice(0,R),P=K.slice(R);return[h,P]},ct=K=>{let R=K.type;if(R){let P=R.toUpperCase();return ft(P,st)?st[P]:R}let{src:h}=K;return h?Vt(h):""},Vt=K=>{let R="";try{R=new URL(K).pathname}catch{console.error("invalid url")}let h=R.lastIndexOf(".");if(h<0)return"";let p=R.slice(h+1).toUpperCase();return ft(p,Me)?Me[p]:""};var Yt=Object.values(at),Dt=K=>typeof K=="boolean"||typeof K=="string"&&Yt.includes(K),Lt=({autoplay:K},R,h)=>{if(!R)return()=>{};let P=!1,p=!1,x=Dt(K)?K:!!K,I=()=>{P||Ue(R,"playing",()=>{P=!0},{once:!0})};if(I(),Ue(R,"loadstart",()=>{P=!1,I(),ht(R,x)},{once:!0}),Ue(R,"loadstart",()=>{h||(p=!Number.isFinite(R.duration)),ht(R,x)},{once:!0}),h&&h.once(vt.default.Events.LEVEL_LOADED,(_,A)=>{var y;p=(y=A.details.live)!=null?y:!1}),!x){let _=()=>{!p||(h!=null&&h.liveSyncPosition?R.currentTime=h.liveSyncPosition:Number.isFinite(R.seekable.end(0))&&(R.currentTime=R.seekable.end(0)))};h&&Ue(R,"play",()=>{R.preload==="metadata"?h.once(vt.default.Events.LEVEL_UPDATED,_):_()},{once:!0})}return _=>{P||(x=Dt(_)?_:!!_,ht(R,x))}},ht=(K,R)=>{if(!R)return;let h=K.muted,P=()=>K.muted=h;switch(R){case at.ANY:K.play().catch(()=>{K.muted=!0,K.play().catch(P)});break;case at.MUTED:K.muted=!0,K.play().catch(P);break;default:K.play().catch(()=>{});break}};var At=({preload:K,src:R},h,P)=>{if(!h)return()=>{};let p=D=>{D!=null&&["","none","metadata","auto"].includes(D)?h.setAttribute("preload",D):h.removeAttribute("preload")};if(!P)return p(K),p;let x=!1,I=!1,T=P.config.maxBufferLength,_=P.config.maxBufferSize,A=D=>{p(D);let L=D!=null?D:h.preload;I||L==="none"||(L==="metadata"?(P.config.maxBufferLength=1,P.config.maxBufferSize=1):(P.config.maxBufferLength=T,P.config.maxBufferSize=_),y())},y=()=>{!x&&R&&(x=!0,P.loadSource(R))};return Ue(h,"play",()=>{I=!0,P.config.maxBufferLength=T,P.config.maxBufferSize=_,y()},{once:!0}),A(K),A};var Ge=rt(nt());function _t(K,R){R.on(Ge.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(p,{tracks:x})=>{x.forEach(I=>{var A;let T=(A=I.subtitleTrack)!=null?A:I.closedCaptions,_=R.subtitleTracks.findIndex(({lang:y,name:D,type:L})=>y==(T==null?void 0:T.lang)&&D===I.label&&L.toLowerCase()===I.kind);Ot(K,I.kind,I.label,T==null?void 0:T.lang,`${I.kind}${_}`)})});let h=()=>{var I;if(!R.subtitleTracks.length)return;let p=Array.from(K.textTracks).find(T=>T.id&&T.mode==="showing"&&["subtitles","captions"].includes(T.kind)),x=`${(I=R.subtitleTracks[R.subtitleTrack])==null?void 0:I.type.toLowerCase()}${R.subtitleTrack}`;if(p&&(R.subtitleTrack<0||(p==null?void 0:p.id)!==x)){let T=R.subtitleTracks.findIndex(({lang:_,name:A,type:y})=>_==p.language&&A===p.label&&y.toLowerCase()===p.kind);R.subtitleTrack=T}p&&(p==null?void 0:p.id)===x&&p.cues&&Array.from(p.cues).forEach(T=>{p.addCue(T)})};K.textTracks.addEventListener("change",h),R.on(Ge.default.Events.CUES_PARSED,(p,{track:x,cues:I})=>{let T=K.textTracks.getTrackById(x);if(!T)return;let _=T.mode==="disabled";_&&(T.mode="hidden"),I.forEach(A=>{var y;(y=T.cues)!=null&&y.getCueById(A.id)||T.addCue(A)}),_&&(T.mode="disabled")}),R.once(Ge.default.Events.DESTROYING,()=>{K.textTracks.removeEventListener("change",h),K.querySelectorAll("track[data-removeondestroy]").forEach(x=>{x.remove()})});let P=()=>{Array.from(K.textTracks).forEach(p=>{var x,I;if(!["subtitles","caption"].includes(p.kind)&&p.label==="thumbnails"){if(!((x=p.cues)!=null&&x.length)){let T=K.querySelector('track[label="thumbnails"]'),_=(I=T==null?void 0:T.getAttribute("src"))!=null?I:"";T==null||T.removeAttribute("src"),setTimeout(()=>{T==null||T.setAttribute("src",_)},0)}p.mode!=="hidden"&&(p.mode="hidden")}})};R.once(Ge.default.Events.MANIFEST_LOADED,P),R.once(Ge.default.Events.MEDIA_ATTACHED,P)}function Ot(K,R,h,P,p){let x=document.createElement("track");return x.kind=R,x.label=h,P&&(x.srclang=P),p&&(x.id=p),x.track.mode="disabled",x.setAttribute("data-removeondestroy",""),K.append(x),x.track}function zt(K,R){let h=Array.prototype.find.call(K.querySelectorAll("track"),P=>P.track===R);h==null||h.remove()}var bt,Pt,Xt=(Pt=(bt=globalThis==null?void 0:globalThis.navigator)==null?void 0:bt.userAgent)!=null?Pt:"",Qt=Xt.toLowerCase().indexOf("android")!==-1,He=new WeakMap,Mt="mux.com",Rt,It,Ct=(It=(Rt=Be.default).isSupported)==null?void 0:It.call(Rt),Jt=Qt,_r=()=>mt.default.utils.now(),Or=(K,{domain:R=Mt}={})=>{if(!K)return;let[h,P=""]=St(K);return`https://stream.${R}/${h}.m3u8${P}`},br=K=>{var R;return(R=He.get(K))==null?void 0:R.error},Pr=(K,R,h)=>{$t(R,h),He.set(R,{});let P=Zt(K,R);tr(K,R,P),rr(K,R,P);let p=Lt(K,R,P),x=At(K,R,P);return{engine:P,setAutoplay:p,setPreload:x}},$t=(K,R)=>{let h=R==null?void 0:R.engine;h&&(h.detachMedia(),h.destroy()),(K==null?void 0:K.mux)&&!K.mux.deleted&&(K.mux.destroy(),delete K.mux),K&&(K.removeAttribute("src"),K.load(),K.removeEventListener("error",Ut),K.removeEventListener("error",gt),K.removeEventListener("durationchange",wt),He.delete(K),K.dispatchEvent(new Event("teardown")))};function Ft(K,R){var A;let h=ct(K);if(!(h===Me.M3U8))return!0;let p=!h||((A=R==null?void 0:R.canPlayType(h))!=null?A:!0),{preferPlayback:x}=K,I=x===dt.MSE,T=x===dt.NATIVE;return p&&(T||!(Ct&&(I||Jt)))}var Zt=(K,R)=>{let{debug:h,streamType:P,startTime:p=-1}=K,I=ct(K)===Me.M3U8,T=Ft(K,R);if(I&&!T&&Ct){let _={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},A=qt(P);return new Be.default({debug:h,startPosition:p,..._,...A})}},qt=K=>[$e.LIVE,$e.DVR].includes(K)?{backBufferLength:8}:[$e.LL_LIVE,$e.LL_DVR].includes(K)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},er=({playbackId:K,src:R,customDomain:h})=>{if(K)return!0;if(typeof R!="string")return!1;let P=window==null?void 0:window.location.href,p=new URL(R,P).hostname.toLocaleLowerCase();return p.includes(Mt)||!!h&&p.includes(h.toLocaleLowerCase())},tr=(K,R,h)=>{let{envKey:P}=K,p=er(K);if((P||p)&&R){let{playerInitTime:x,playerSoftwareName:I,playerSoftwareVersion:T,beaconCollectionDomain:_,metadata:A,debug:y}=K,D=L=>typeof L.player_error_code=="string"?!1:typeof K.errorTranslator=="function"?K.errorTranslator(L):L;mt.default.monitor(R,{debug:y,beaconCollectionDomain:_,hlsjs:h,Hls:h?Be.default:void 0,automaticErrorTracking:!1,errorTranslator:D,data:{...P?{env_key:P}:{},player_software_name:I,player_software:I,player_software_version:T,player_init_time:x,...A}})}},rr=(K,R,h)=>{var x;if(!R){console.warn("attempting to load media before mediaEl exists");return}let P=Ft(K,R),{src:p}=K;R&&P?(typeof p=="string"?(R.setAttribute("src",p),K.startTime&&(((x=He.get(R))!=null?x:{}).startTime=K.startTime,R.addEventListener("durationchange",wt,{once:!0}))):R.removeAttribute("src"),R.addEventListener("error",Ut),R.addEventListener("error",gt)):h&&p?(h.on(Be.default.Events.ERROR,(I,T)=>{let _={[Be.default.ErrorTypes.NETWORK_ERROR]:be.MEDIA_ERR_NETWORK,[Be.default.ErrorTypes.MEDIA_ERROR]:be.MEDIA_ERR_DECODE},A=new be("",_[T.type]);A.fatal=T.fatal,A.data=T,R.dispatchEvent(new CustomEvent("error",{detail:A}))}),R.addEventListener("error",gt),_t(R,h),h.attachMedia(R)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function wt(K){var P;let R=K.target,h=(P=He.get(R))==null?void 0:P.startTime;if(!!h&&xt(R.seekable,R.duration,h)){let p=R.preload==="auto";p&&(R.preload="none"),R.currentTime=h,p&&(R.preload="auto")}}async function Ut(K){if(!K.isTrusted)return;K.stopImmediatePropagation();let R=K.target;if(!(R!=null&&R.error))return;let{message:h,code:P}=R.error,p=new be(h,P);if(R.src&&(P!==be.MEDIA_ERR_DECODE||P!==void 0))try{let{status:x}=await fetch(R.src);p.data={response:{code:x}}}catch{}R.dispatchEvent(new CustomEvent("error",{detail:p}))}function gt(K){var P,p;if(!(K instanceof CustomEvent)||!(K.detail instanceof be))return;let R=K.target,h=K.detail;!h||!h.fatal||(((P=He.get(R))!=null?P:{}).error=h,(p=R.mux)==null||p.emit("error",{player_error_code:h.code,player_error_message:h.message}))}})();
|
|
30
30
|
//# sourceMappingURL=playback-core.js.map
|