@mux/mux-player 0.1.0-beta.23 → 0.1.0-beta.26

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +38 -36
  3. package/coverage/lcov-report/index.html +31 -31
  4. package/coverage/lcov-report/src/dialog.ts.html +1 -1
  5. package/coverage/lcov-report/src/errors.ts.html +1 -1
  6. package/coverage/lcov-report/src/helpers.ts.html +30 -9
  7. package/coverage/lcov-report/src/html.ts.html +159 -9
  8. package/coverage/lcov-report/src/index.html +52 -52
  9. package/coverage/lcov-report/src/index.ts.html +156 -27
  10. package/coverage/lcov-report/src/logger.ts.html +1 -1
  11. package/coverage/lcov-report/src/media-chrome/dialog.ts.html +1 -1
  12. package/coverage/lcov-report/src/media-chrome/index.html +1 -1
  13. package/coverage/lcov-report/src/media-chrome/time-display.ts.html +1 -1
  14. package/coverage/lcov-report/src/media-theme-mux/icons/airplay.svg.html +1 -1
  15. package/coverage/lcov-report/src/media-theme-mux/icons/captions-off.svg.html +1 -1
  16. package/coverage/lcov-report/src/media-theme-mux/icons/captions-on.svg.html +1 -1
  17. package/coverage/lcov-report/src/media-theme-mux/icons/cast-enter.svg.html +103 -0
  18. package/coverage/lcov-report/src/media-theme-mux/icons/cast-exit.svg.html +106 -0
  19. package/coverage/lcov-report/src/media-theme-mux/icons/fullscreen-enter.svg.html +1 -1
  20. package/coverage/lcov-report/src/media-theme-mux/icons/fullscreen-exit.svg.html +1 -1
  21. package/coverage/lcov-report/src/media-theme-mux/icons/index.html +33 -3
  22. package/coverage/lcov-report/src/media-theme-mux/icons/pause.svg.html +1 -1
  23. package/coverage/lcov-report/src/media-theme-mux/icons/pip-enter.svg.html +1 -1
  24. package/coverage/lcov-report/src/media-theme-mux/icons/pip-exit.svg.html +1 -1
  25. package/coverage/lcov-report/src/media-theme-mux/icons/play.svg.html +1 -1
  26. package/coverage/lcov-report/src/media-theme-mux/icons/seek-backward.svg.html +1 -1
  27. package/coverage/lcov-report/src/media-theme-mux/icons/seek-forward.svg.html +1 -1
  28. package/coverage/lcov-report/src/media-theme-mux/icons/volume-high.svg.html +1 -1
  29. package/coverage/lcov-report/src/media-theme-mux/icons/volume-low.svg.html +1 -1
  30. package/coverage/lcov-report/src/media-theme-mux/icons/volume-medium.svg.html +1 -1
  31. package/coverage/lcov-report/src/media-theme-mux/icons/volume-off.svg.html +1 -1
  32. package/coverage/lcov-report/src/media-theme-mux/icons.ts.html +18 -6
  33. package/coverage/lcov-report/src/media-theme-mux/index.html +26 -26
  34. package/coverage/lcov-report/src/media-theme-mux/media-theme-mux.ts.html +342 -177
  35. package/coverage/lcov-report/src/media-theme-mux/styles.css.html +117 -18
  36. package/coverage/lcov-report/src/styles.css.html +1 -1
  37. package/coverage/lcov-report/src/template.ts.html +128 -65
  38. package/coverage/lcov-report/src/utils.ts.html +1 -1
  39. package/coverage/lcov-report/src/video-api.ts.html +91 -13
  40. package/coverage/lcov.info +1595 -1273
  41. package/dist/index.cjs.js +503 -343
  42. package/dist/index.mjs +296 -228
  43. package/dist/mux-player.js +556 -396
  44. package/dist/mux-player.mjs +556 -396
  45. package/dist/tsconfig.tsbuildinfo +1 -1
  46. package/dist/types/helpers.d.ts +1 -0
  47. package/dist/types/html.d.ts +5 -0
  48. package/dist/types/index.d.ts +5 -3
  49. package/dist/types/media-theme-mux/icons.d.ts +2 -0
  50. package/dist/types/media-theme-mux/media-theme-mux.d.ts +32 -12
  51. package/dist/types/template.d.ts +0 -1
  52. package/dist/types/video-api.d.ts +4 -0
  53. package/dist/types-ts3.4/helpers.d.ts +1 -0
  54. package/dist/types-ts3.4/html.d.ts +5 -0
  55. package/dist/types-ts3.4/index.d.ts +4 -3
  56. package/dist/types-ts3.4/media-theme-mux/icons.d.ts +2 -0
  57. package/dist/types-ts3.4/media-theme-mux/media-theme-mux.d.ts +32 -12
  58. package/dist/types-ts3.4/template.d.ts +0 -1
  59. package/dist/types-ts3.4/video-api.d.ts +2 -0
  60. package/package.json +5 -5
  61. package/src/helpers.ts +7 -0
  62. package/src/html.ts +50 -0
  63. package/src/index.ts +58 -15
  64. package/src/media-theme-mux/icons/cast-enter.svg +6 -0
  65. package/src/media-theme-mux/icons/cast-exit.svg +7 -0
  66. package/src/media-theme-mux/icons.ts +4 -0
  67. package/src/media-theme-mux/media-theme-mux.ts +179 -124
  68. package/src/media-theme-mux/styles.css +47 -14
  69. package/src/template.ts +78 -57
  70. package/src/types.d.ts +3 -0
  71. package/src/video-api.ts +27 -1
  72. package/test/player.test.js +34 -0
  73. package/test/template.test.js +6 -4
@@ -1,32 +1,32 @@
1
- (()=>{var so=Object.create;var ii=Object.defineProperty;var oo=Object.getOwnPropertyDescriptor;var lo=Object.getOwnPropertyNames;var uo=Object.getPrototypeOf,co=Object.prototype.hasOwnProperty;var fo=v=>ii(v,"__esModule",{value:!0});var rn=(v,e)=>()=>(e||v((e={exports:{}}).exports,e),e.exports);var ho=(v,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of lo(e))!co.call(v,l)&&l!=="default"&&ii(v,l,{get:()=>e[l],enumerable:!(t=oo(e,l))||t.enumerable});return v},mr=v=>ho(fo(ii(v!=null?so(uo(v)):{},"default",v&&v.__esModule&&"default"in v?{get:()=>v.default,enumerable:!0}:{value:v,enumerable:!0})),v);var ni=(v,e,t)=>{if(!e.has(v))throw TypeError("Cannot "+t)};var Ye=(v,e,t)=>(ni(v,e,"read from private field"),t?t.call(v):e.get(v)),He=(v,e,t)=>{if(e.has(v))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(v):e.set(v,t)},Et=(v,e,t,l)=>(ni(v,e,"write to private field"),l?l.call(v,t):e.set(v,t),t);var Be=(v,e,t)=>(ni(v,e,"access private method"),t);var nn=rn((gr,ai)=>{(function(){var v=!1;(function(e,t){typeof gr=="object"&&typeof ai=="object"?ai.exports=t():typeof v=="function"&&v.amd?v("mux",[],t):typeof gr=="object"?gr.mux=t():e.mux=t()})(typeof self!="undefined"?self:this,function(){return function(e){function t(n){if(l[n])return l[n].exports;var h=l[n]={i:n,l:!1,exports:{}};return e[n].call(h.exports,h,h.exports,t),h.l=!0,h.exports}var l={};return t.m=e,t.c=l,t.d=function(n,h,R){t.o(n,h)||Object.defineProperty(n,h,{configurable:!1,enumerable:!0,get:R})},t.n=function(n){var h=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(h,"a",h),h},t.o=function(n,h){return Object.prototype.hasOwnProperty.call(n,h)},t.p="",t(t.s=18)}([function(e,t,l){(function(n){var h;h=typeof window!="undefined"?window:n!==void 0?n:typeof self!="undefined"?self:{},e.exports=h}).call(t,l(20))},function(e,t){function l(k,N,B){switch(B.length){case 0:return k.call(N);case 1:return k.call(N,B[0]);case 2:return k.call(N,B[0],B[1]);case 3:return k.call(N,B[0],B[1],B[2])}return k.apply(N,B)}function n(k,N){for(var B=-1,K=Array(k);++B<k;)K[B]=N(B);return K}function h(k,N){var B=w(k)||b(k)?n(k.length,String):[],K=B.length,W=!!K;for(var F in k)!N&&!c.call(k,F)||W&&(F=="length"||E(F,K))||B.push(F);return B}function R(k,N,B){var K=k[N];c.call(k,N)&&D(K,B)&&(B!==void 0||N in k)||(k[N]=B)}function T(k){if(!M(k))return O(k);var N=[];for(var B in Object(k))c.call(k,B)&&B!="constructor"&&N.push(B);return N}function L(k,N){return N=C(N===void 0?k.length-1:N,0),function(){for(var B=arguments,K=-1,W=C(B.length-N,0),F=Array(W);++K<W;)F[K]=B[N+K];K=-1;for(var H=Array(N+1);++K<N;)H[K]=B[K];return H[N]=F,l(k,this,H)}}function _(k,N,B,K){B||(B={});for(var W=-1,F=N.length;++W<F;){var H=N[W],Y=K?K(B[H],k[H],H,B,k):void 0;R(B,H,Y===void 0?k[H]:Y)}return B}function E(k,N){return!!(N=N==null?o:N)&&(typeof k=="number"||g.test(k))&&k>-1&&k%1==0&&k<N}function I(k,N,B){if(!i(B))return!1;var K=typeof N;return!!(K=="number"?A(B)&&E(N,B.length):K=="string"&&N in B)&&D(B[N],k)}function M(k){var N=k&&k.constructor;return k===(typeof N=="function"&&N.prototype||f)}function D(k,N){return k===N||k!==k&&N!==N}function b(k){return u(k)&&c.call(k,"callee")&&(!S.call(k,"callee")||x.call(k)==y)}function A(k){return k!=null&&s(k.length)&&!r(k)}function u(k){return a(k)&&A(k)}function r(k){var N=i(k)?x.call(k):"";return N==p||N==m}function s(k){return typeof k=="number"&&k>-1&&k%1==0&&k<=o}function i(k){var N=typeof k;return!!k&&(N=="object"||N=="function")}function a(k){return!!k&&typeof k=="object"}function d(k){return A(k)?h(k):T(k)}var o=9007199254740991,y="[object Arguments]",p="[object Function]",m="[object GeneratorFunction]",g=/^(?:0|[1-9]\d*)$/,f=Object.prototype,c=f.hasOwnProperty,x=f.toString,S=f.propertyIsEnumerable,O=function(k,N){return function(B){return k(N(B))}}(Object.keys,Object),C=Math.max,P=!S.call({valueOf:1},"valueOf"),w=Array.isArray,U=function(k){return L(function(N,B){var K=-1,W=B.length,F=W>1?B[W-1]:void 0,H=W>2?B[2]:void 0;for(F=k.length>3&&typeof F=="function"?(W--,F):void 0,H&&I(B[0],B[1],H)&&(F=W<3?void 0:F,W=1),N=Object(N);++K<W;){var Y=B[K];Y&&k(N,Y,K,F)}return N})}(function(k,N){if(P||M(N)||A(N))return void _(N,d(N),k);for(var B in N)c.call(N,B)&&R(k,B,N[B])});e.exports=U},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(0),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R={};R.now=function(){var T=h.default.performance,L=T&&T.timing;return L&&typeof L.navigationStart=="number"&&typeof T.now=="function"?L.navigationStart+T.now():Date.now()},t.default=R},function(e,t,l){"use strict";function n(h,R,T){T=T===void 0?1:T,h[R]=h[R]||0,h[R]+=T}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(21),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R=h.default.methodFactory;h.default.methodFactory=function(T,L,_){var E=R(T,L,_);return function(){for(var I=["[mux]"],M=0;M<arguments.length;M++)I.push(arguments[M]);E.apply(void 0,I)}},h.default.setLevel(h.default.getLevel()),t.default=h.default},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(T){return R(T)[0]},h=function(T){return R(T)[1]},R=function(T){if(typeof T!="string"||T==="")return["localhost"];var L=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=T.match(L)||[],E=_[4],I=void 0;return E&&(I=(E.match(/[^\.]+\.[^\.]+$/)||[])[0]),[E,I]};t.extractHostnameAndDomain=R,t.extractHostname=n,t.extractDomain=h},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(R){var T=16*Math.random()|0;return(R==="x"?T:3&T|8).toString(16)})},h=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};t.generateUUID=n,t.generateShortID=h},function(e,t,l){"use strict";function n(R){R=R||"";var T={};return R.trim().split(/[\r\n]+/).forEach(function(L){if(L){var _=L.split(": "),E=_.shift();E&&(h.indexOf(E.toLowerCase())>=0||E.toLowerCase().indexOf("x-litix-")===0)&&(T[E]=_.join(": "))}}),T}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var h=["x-cdn","content-type"]},function(e,t,l){"use strict";var n=SyntaxError,h=Function,R=TypeError,T=function(c){try{return h('"use strict"; return ('+c+").constructor;")()}catch{}},L=Object.getOwnPropertyDescriptor;if(L)try{L({},"")}catch{L=null}var _=function(){throw new R},E=L?function(){try{return arguments.callee,_}catch{try{return L(arguments,"callee").get}catch{return _}}}():_,I=l(43)(),M=Object.getPrototypeOf||function(c){return c.__proto__},D={},b=typeof Uint8Array=="undefined"?void 0:M(Uint8Array),A={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":I?M([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":D,"%AsyncGenerator%":D,"%AsyncGeneratorFunction%":D,"%AsyncIteratorPrototype%":D,"%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%":h,"%GeneratorFunction%":D,"%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%":I?M(M([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&I?M(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"&&I?M(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":I?M(""[Symbol.iterator]()):void 0,"%Symbol%":I?Symbol:void 0,"%SyntaxError%":n,"%ThrowTypeError%":E,"%TypedArray%":b,"%TypeError%":R,"%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},u=function c(x){var S;if(x==="%AsyncFunction%")S=T("async function () {}");else if(x==="%GeneratorFunction%")S=T("function* () {}");else if(x==="%AsyncGeneratorFunction%")S=T("async function* () {}");else if(x==="%AsyncGenerator%"){var O=c("%AsyncGeneratorFunction%");O&&(S=O.prototype)}else if(x==="%AsyncIteratorPrototype%"){var C=c("%AsyncGenerator%");C&&(S=M(C.prototype))}return A[x]=S,S},r={"%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=l(9),i=l(46),a=s.call(Function.call,Array.prototype.concat),d=s.call(Function.apply,Array.prototype.splice),o=s.call(Function.call,String.prototype.replace),y=s.call(Function.call,String.prototype.slice),p=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,m=/\\(\\)?/g,g=function(c){var x=y(c,0,1),S=y(c,-1);if(x==="%"&&S!=="%")throw new n("invalid intrinsic syntax, expected closing `%`");if(S==="%"&&x!=="%")throw new n("invalid intrinsic syntax, expected opening `%`");var O=[];return o(c,p,function(C,P,w,U){O[O.length]=w?o(U,m,"$1"):P||C}),O},f=function(c,x){var S,O=c;if(i(r,O)&&(S=r[O],O="%"+S[0]+"%"),i(A,O)){var C=A[O];if(C===D&&(C=u(O)),C===void 0&&!x)throw new R("intrinsic "+c+" exists, but is not available. Please file an issue!");return{alias:S,name:O,value:C}}throw new n("intrinsic "+c+" does not exist!")};e.exports=function(c,x){if(typeof c!="string"||c.length===0)throw new R("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof x!="boolean")throw new R('"allowMissing" argument must be a boolean');var S=g(c),O=S.length>0?S[0]:"",C=f("%"+O+"%",x),P=C.name,w=C.value,U=!1,k=C.alias;k&&(O=k[0],d(S,a([0,1],k)));for(var N=1,B=!0;N<S.length;N+=1){var K=S[N],W=y(K,0,1),F=y(K,-1);if((W==='"'||W==="'"||W==="`"||F==='"'||F==="'"||F==="`")&&W!==F)throw new n("property names with quotes must have matching quotes");if(K!=="constructor"&&B||(U=!0),O+="."+K,P="%"+O+"%",i(A,P))w=A[P];else if(w!=null){if(!(K in w)){if(!x)throw new R("base intrinsic for "+c+" exists, but the property is not available.");return}if(L&&N+1>=S.length){var H=L(w,K);B=!!H,w=B&&"get"in H&&!("originalValue"in H.get)?H.get:w[K]}else B=i(w,K),w=w[K];B&&!U&&(A[P]=w)}}return w}},function(e,t,l){"use strict";var n=l(45);e.exports=Function.prototype.bind||n},function(e,t,l){"use strict";var n=String.prototype.replace,h=/%20/g,R={RFC1738:"RFC1738",RFC3986:"RFC3986"};e.exports={default:R.RFC3986,formatters:{RFC1738:function(T){return n.call(T,h,"+")},RFC3986:function(T){return String(T)}},RFC1738:R.RFC1738,RFC3986:R.RFC3986}},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findMediaElement=t.getMuxPlayerId=void 0;var n=l(6),h=function(T){return T&&T.nodeName!==void 0?(T.muxId||(T.muxId=T.id||(0,n.generateShortID)()),T.muxId):T},R=function(T){var L=void 0;return T&&T.nodeName!==void 0?(L=T,T=h(L)):L=document.querySelector(T),[L,T,L&&L.nodeName?L.nodeName.toLowerCase():""]};t.getMuxPlayerId=h,t.findMediaElement=R},function(e,t,l){"use strict";function n(){return(R.default.doNotTrack||R.default.navigator&&(R.default.navigator.doNotTrack||R.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var h=l(0),R=function(T){return T&&T.__esModule?T:{default:T}}(h)},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(0),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R={};R.exists=function(){var T=h.default.performance;return(T&&T.timing)!==void 0},R.domContentLoadedEventEnd=function(){var T=h.default.performance,L=T&&T.timing;return L&&L.domContentLoadedEventEnd},R.navigationStart=function(){var T=h.default.performance,L=T&&T.timing;return L&&L.navigationStart},t.default=R},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(h){var R={};for(var T in h){var L=h[T];L["DATA-ID"].search("io.litix.data.")!==-1&&(R[L["DATA-ID"].replace("io.litix.data.","")]=L.VALUE)}return R};t.default=n},function(e,t,l){"use strict";var n=l(41),h=l(51),R=l(10);e.exports={formats:R,parse:h,stringify:n}},function(e,t,l){"use strict";var n=l(10),h=Object.prototype.hasOwnProperty,R=Array.isArray,T=function(){for(var i=[],a=0;a<256;++a)i.push("%"+((a<16?"0":"")+a.toString(16)).toUpperCase());return i}(),L=function(i){for(;i.length>1;){var a=i.pop(),d=a.obj[a.prop];if(R(d)){for(var o=[],y=0;y<d.length;++y)d[y]!==void 0&&o.push(d[y]);a.obj[a.prop]=o}}},_=function(i,a){for(var d=a&&a.plainObjects?Object.create(null):{},o=0;o<i.length;++o)i[o]!==void 0&&(d[o]=i[o]);return d},E=function i(a,d,o){if(!d)return a;if(typeof d!="object"){if(R(a))a.push(d);else{if(!a||typeof a!="object")return[a,d];(o&&(o.plainObjects||o.allowPrototypes)||!h.call(Object.prototype,d))&&(a[d]=!0)}return a}if(!a||typeof a!="object")return[a].concat(d);var y=a;return R(a)&&!R(d)&&(y=_(a,o)),R(a)&&R(d)?(d.forEach(function(p,m){if(h.call(a,m)){var g=a[m];g&&typeof g=="object"&&p&&typeof p=="object"?a[m]=i(g,p,o):a.push(p)}else a[m]=p}),a):Object.keys(d).reduce(function(p,m){var g=d[m];return h.call(p,m)?p[m]=i(p[m],g,o):p[m]=g,p},y)},I=function(i,a){return Object.keys(a).reduce(function(d,o){return d[o]=a[o],d},i)},M=function(i,a,d){var o=i.replace(/\+/g," ");if(d==="iso-8859-1")return o.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(o)}catch{return o}},D=function(i,a,d,o,y){if(i.length===0)return i;var p=i;if(typeof i=="symbol"?p=Symbol.prototype.toString.call(i):typeof i!="string"&&(p=String(i)),d==="iso-8859-1")return escape(p).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});for(var m="",g=0;g<p.length;++g){var f=p.charCodeAt(g);f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||y===n.RFC1738&&(f===40||f===41)?m+=p.charAt(g):f<128?m+=T[f]:f<2048?m+=T[192|f>>6]+T[128|63&f]:f<55296||f>=57344?m+=T[224|f>>12]+T[128|f>>6&63]+T[128|63&f]:(g+=1,f=65536+((1023&f)<<10|1023&p.charCodeAt(g)),m+=T[240|f>>18]+T[128|f>>12&63]+T[128|f>>6&63]+T[128|63&f])}return m},b=function(i){for(var a=[{obj:{o:i},prop:"o"}],d=[],o=0;o<a.length;++o)for(var y=a[o],p=y.obj[y.prop],m=Object.keys(p),g=0;g<m.length;++g){var f=m[g],c=p[f];typeof c=="object"&&c!==null&&d.indexOf(c)===-1&&(a.push({obj:p,prop:f}),d.push(c))}return L(a),i},A=function(i){return Object.prototype.toString.call(i)==="[object RegExp]"},u=function(i){return!(!i||typeof i!="object")&&!!(i.constructor&&i.constructor.isBuffer&&i.constructor.isBuffer(i))},r=function(i,a){return[].concat(i,a)},s=function(i,a){if(R(i)){for(var d=[],o=0;o<i.length;o+=1)d.push(a(i[o]));return d}return a(i)};e.exports={arrayToObject:_,assign:I,combine:r,compact:b,decode:M,encode:D,isBuffer:u,isRegExp:A,maybeMap:s,merge:E}},function(e,t,l){"use strict";function n(A){return A&&A.__esModule?A:{default:A}}function h(A){var u={};for(var r in A)A.hasOwnProperty(r)&&(u[A[r]]=r);return u}function R(A){var u={},r={};return Object.keys(A).forEach(function(s){var i=!1;if(A.hasOwnProperty(s)&&A[s]!==void 0){var a=s.split("_"),d=a[0],o=M[d];o||(L.default.info("Data key word `"+a[0]+"` not expected in "+s),o=d+"_"),a.splice(1).forEach(function(y){y==="url"&&(i=!0),b[y]?o+=b[y]:Number(y)&&Math.floor(Number(y))===Number(y)?o+=y:(L.default.info("Data key word `"+y+"` not expected in "+s),o+="_"+y+"_")}),i?r[o]=A[s]:u[o]=A[s]}}),(0,E.default)(u,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=R;var T=l(4),L=n(T),_=l(1),E=n(_),I={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"},M=h(I),D={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"},b=h(D)},function(e,t,l){"use strict";e.exports=l(19).default},function(e,t,l){"use strict";function n(m){return m&&m.__esModule?m:{default:m}}Object.defineProperty(t,"__esModule",{value:!0});var h=function(){function m(g,f){var c=[],x=!0,S=!1,O=void 0;try{for(var C,P=g[Symbol.iterator]();!(x=(C=P.next()).done)&&(c.push(C.value),!f||c.length!==f);x=!0);}catch(w){S=!0,O=w}finally{try{!x&&P.return&&P.return()}finally{if(S)throw O}}return c}return function(g,f){if(Array.isArray(g))return g;if(Symbol.iterator in Object(g))return m(g,f);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),R=l(0),T=n(R),L=l(11),_=l(4),E=n(_),I=l(12),M=n(I),D=l(2),b=n(D),A=l(22),u=n(A),r=l(58),s=n(r),i=l(59),a=n(i),d=l(64),o=n(d),y={},p=function m(g){var f=arguments;typeof g=="string"?m.hasOwnProperty(g)?T.default.setTimeout(function(){f=Array.prototype.splice.call(f,1),m[g].apply(null,f)},0):E.default.warn("`"+g+"` is an unknown task"):typeof g=="function"?T.default.setTimeout(function(){g(m)},0):E.default.warn("`"+g+"` is invalid.")};p.loaded=b.default.now(),p.NAME="mux-embed",p.VERSION="4.8.0",p.API_VERSION="2.1",p.PLAYER_TRACKED=!1,p.monitor=function(m,g){return(0,s.default)(p,m,g)},p.destroyMonitor=function(m){var g=(0,L.findMediaElement)(m),f=h(g,1),c=f[0];c&&c.mux&&typeof c.mux.destroy=="function"?c.mux.destroy():E.default.error("A video element monitor for `"+m+"` has not been initialized via `mux.monitor`.")},p.addHLSJS=function(m,g){var f=(0,L.getMuxPlayerId)(m);y[f]?y[f].addHLSJS(g):E.default.error("A monitor for `"+f+"` has not been initialized.")},p.addDashJS=function(m,g){var f=(0,L.getMuxPlayerId)(m);y[f]?y[f].addDashJS(g):E.default.error("A monitor for `"+f+"` has not been initialized.")},p.removeHLSJS=function(m){var g=(0,L.getMuxPlayerId)(m);y[g]?y[g].removeHLSJS():E.default.error("A monitor for `"+g+"` has not been initialized.")},p.removeDashJS=function(m){var g=(0,L.getMuxPlayerId)(m);y[g]?y[g].removeDashJS():E.default.error("A monitor for `"+g+"` has not been initialized.")},p.init=function(m,g){(0,M.default)()&&g&&g.respectDoNotTrack&&E.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=(0,L.getMuxPlayerId)(m);y[f]=new u.default(p,f,g)},p.emit=function(m,g,f){var c=(0,L.getMuxPlayerId)(m);y[c]?(y[c].emit(g,f),g==="destroy"&&delete y[c]):E.default.error("A monitor for `"+c+"` has not been initialized.")},T.default!==void 0&&typeof T.default.addEventListener=="function"&&T.default.addEventListener("pagehide",function(m){m.persisted||(p.WINDOW_UNLOADING=!0)},!1),p.checkDoNotTrack=M.default,p.log=E.default,p.utils=a.default,p.events=o.default,t.default=p},function(e,t){var l;l=function(){return this}();try{l=l||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(l=window)}e.exports=l},function(e,t,l){var n,h;(function(R,T){"use strict";n=T,(h=typeof n=="function"?n.call(t,l,t,e):n)!==void 0&&(e.exports=h)})(0,function(){"use strict";function R(a,d){var o=a[d];if(typeof o.bind=="function")return o.bind(a);try{return Function.prototype.bind.call(o,a)}catch{return function(){return Function.prototype.apply.apply(o,[a,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 L(a){return a==="debug"&&(a="log"),typeof console!==b&&(a==="trace"&&A?T:console[a]!==void 0?R(console,a):console.log!==void 0?R(console,"log"):D)}function _(a,d){for(var o=0;o<u.length;o++){var y=u[o];this[y]=o<a?D:this.methodFactory(y,a,d)}this.log=this.debug}function E(a,d,o){return function(){typeof console!==b&&(_.call(this,d,o),this[a].apply(this,arguments))}}function I(a,d,o){return L(a)||E.apply(this,arguments)}function M(a,d,o){function y(S){var O=(u[S]||"silent").toUpperCase();if(typeof window!==b&&c){try{return void(window.localStorage[c]=O)}catch{}try{window.document.cookie=encodeURIComponent(c)+"="+O+";"}catch{}}}function p(){var S;if(typeof window!==b&&c){try{S=window.localStorage[c]}catch{}if(typeof S===b)try{var O=window.document.cookie,C=O.indexOf(encodeURIComponent(c)+"=");C!==-1&&(S=/^([^;]+)/.exec(O.slice(C))[1])}catch{}return f.levels[S]===void 0&&(S=void 0),S}}function m(){if(typeof window!==b&&c){try{return void window.localStorage.removeItem(c)}catch{}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var g,f=this;d=d==null?"WARN":d;var c="loglevel";typeof a=="string"?c+=":"+a:typeof a=="symbol"&&(c=void 0),f.name=a,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=o||I,f.getLevel=function(){return g},f.setLevel=function(S,O){if(typeof S=="string"&&f.levels[S.toUpperCase()]!==void 0&&(S=f.levels[S.toUpperCase()]),!(typeof S=="number"&&S>=0&&S<=f.levels.SILENT))throw"log.setLevel() called with invalid level: "+S;if(g=S,O!==!1&&y(S),_.call(f,S,a),typeof console===b&&S<f.levels.SILENT)return"No console available for logging"},f.setDefaultLevel=function(S){d=S,p()||f.setLevel(S,!1)},f.resetLevel=function(){f.setLevel(d,!1),m()},f.enableAll=function(S){f.setLevel(f.levels.TRACE,S)},f.disableAll=function(S){f.setLevel(f.levels.SILENT,S)};var x=p();x==null&&(x=d),f.setLevel(x,!1)}var D=function(){},b="undefined",A=typeof window!==b&&typeof window.navigator!==b&&/Trident\/|MSIE /.test(window.navigator.userAgent),u=["trace","debug","info","warn","error"],r=new M,s={};r.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var d=s[a];return d||(d=s[a]=new M(a,r.getLevel(),r.methodFactory)),d};var i=typeof window!==b?window.log:void 0;return r.noConflict=function(){return typeof window!==b&&window.log===r&&(window.log=i),r},r.getLoggers=function(){return s},r.default=r,r})},function(e,t,l){"use strict";function n(Q){return Q&&Q.__esModule?Q:{default:Q}}Object.defineProperty(t,"__esModule",{value:!0});var h=function(){function Q(te,ee){var he=[],Se=!0,pe=!1,Te=void 0;try{for(var Ie,Ue=te[Symbol.iterator]();!(Se=(Ie=Ue.next()).done)&&(he.push(Ie.value),!ee||he.length!==ee);Se=!0);}catch(Ee){pe=!0,Te=Ee}finally{try{!Se&&Ue.return&&Ue.return()}finally{if(pe)throw Te}}return he}return function(te,ee){if(Array.isArray(te))return te;if(Symbol.iterator in Object(te))return Q(te,ee);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),R=l(4),T=n(R),L=l(1),_=n(L),E=l(6),I=l(5),M=l(0),D=n(M),b=l(13),A=n(b),u=l(3),r=n(u),s=l(23),i=l(24),a=l(25),d=n(a),o=l(26),y=n(o),p=l(27),m=n(p),g=l(28),f=n(g),c=l(29),x=n(c),S=l(30),O=n(S),C=l(31),P=n(C),w=l(32),U=n(w),k=l(33),N=n(k),B=l(34),K=n(B),W=l(35),F=n(W),H=l(36),Y=n(H),$=l(37),Z=n($),q=l(38),oe=n(q),X=l(39),ie=n(X),fe=l(57),ue=n(fe),Ae=["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"],re=function(Q,te,ee){var he=this;this.DOM_CONTENT_LOADED_EVENT_END=A.default.domContentLoadedEventEnd(),this.NAVIGATION_START=A.default.navigationStart();var Se={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(Ee){return Ee}};this.mux=Q,this.id=te,ee=(0,_.default)(Se,ee),ee.data=ee.data||{},ee.data.property_key&&(ee.data.env_key=ee.data.property_key,delete ee.data.property_key),T.default.setLevel(ee.debug?"debug":"warn"),this.getPlayheadTime=ee.getPlayheadTime,this.getStateData=ee.getStateData||function(){},this.getAdData=ee.getAdData||function(){},this.minimumRebufferDuration=ee.minimumRebufferDuration,this.sustainedRebufferThreshold=ee.sustainedRebufferThreshold,this.playbackHeartbeatTime=ee.playbackHeartbeatTime,this.disableRebufferTracking=ee.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=ee.errorTranslator,this.playbackEventDispatcher=new ie.default(Q,ee.data.env_key,ee),this.data={player_instance_id:(0,E.generateUUID)(),mux_sample_rate:ee.sampleRate,beacon_domain:ee.beaconCollectionDomain?ee.beaconCollectionDomain:ee.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(Ee,ye){ye=(0,_.default)({viewer_time:this.mux.utils.now()},ye),this.oldEmit(Ee,ye)};var pe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(Ee,ye){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,ye),this._initializeViewData(),this.one("play",pe),this.one("adbreakstart",pe)});var Te=function(Ee){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",Ee)}.bind(this);if(this.on("videochange",function(Ee,ye){Te(ye)}),this.on("programchange",function(Ee,ye){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."),Te((0,_.default)(ye,{view_program_changed:!0})),pe(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(Ee,ye){this.currentFragmentPDT=ye.currentFragmentPDT,this.currentFragmentStart=ye.currentFragmentStart}),this.on("destroy",this.destroy),D.default!==void 0&&typeof D.default.addEventListener=="function"&&typeof D.default.removeEventListener=="function"){var Ie=function(Ee){Ee.persisted||he.destroy()};D.default.addEventListener("pagehide",Ie,!1),this.on("destroy",function(){D.default.removeEventListener("pagehide",Ie)})}this.on("playerready",function(Ee,ye){(0,_.default)(this.data,ye)}),Ae.forEach(function(Ee){he.on(Ee,function(ye,Ne){Ee.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,Ne),this._sanitizeData()}),he.on("after"+Ee,function(){(Ee!=="error"||this.viewErrored)&&this.send(Ee)})}),this.on("viewend",function(Ee,ye){(0,_.default)(he.data,ye)});var Ue=function(Ee){var ye=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ye-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",Ue),m.default.apply(this),oe.default.apply(this),F.default.apply(this),O.default.apply(this),y.default.apply(this),K.default.apply(this),f.default.apply(this),x.default.apply(this),Y.default.apply(this),P.default.apply(this),U.default.apply(this),N.default.apply(this),Z.default.apply(this),ue.default.apply(this),ee.hlsjs&&this.addHLSJS(ee),ee.dashjs&&this.addDashJS(ee),this.emit("viewinit",ee.data)};(0,_.default)(re.prototype,d.default.prototype),(0,_.default)(re.prototype,O.default.prototype),(0,_.default)(re.prototype,F.default.prototype),(0,_.default)(re.prototype,y.default.prototype),(0,_.default)(re.prototype,f.default.prototype),(0,_.default)(re.prototype,x.default.prototype),(0,_.default)(re.prototype,Y.default.prototype),(0,_.default)(re.prototype,U.default.prototype),(0,_.default)(re.prototype,N.default.prototype),re.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(),D.default.clearTimeout(this._heartBeatTimeout))},re.prototype.send=function(Q){var te=(0,_.default)({},this.data),ee=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(te.video_source_is_live===void 0&&(te.player_source_duration===1/0||te.video_source_duration===1/0?te.video_source_is_live=!0:(te.player_source_duration>0||te.video_source_duration>0)&&(te.video_source_is_live=!1)),te.video_source_is_live||ee.forEach(function(Ie){te[Ie]=void 0}),te.video_source_url=te.video_source_url||te.player_source_url,te.video_source_url){var he=(0,I.extractHostnameAndDomain)(te.video_source_url),Se=h(he,2),pe=Se[0],Te=Se[1];te.video_source_domain=Te,te.video_source_hostname=pe}delete te.ad_request_id,this.playbackEventDispatcher.send(Q,te),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},re.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},re.prototype._sanitizeData=function(){var Q=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(te){var ee=parseInt(Q.data[te],10);Q.data[te]=isNaN(ee)?void 0:ee}),["player_source_url","video_source_url"].forEach(function(te){if(Q.data[te]){var ee=Q.data[te].toLowerCase();ee.indexOf("data:")!==0&&ee.indexOf("blob:")!==0||(Q.data[te]="MSE style URL")}})},re.prototype._resetVideoData=function(Q,te){var ee=this;Object.keys(this.data).forEach(function(he){he.indexOf("video_")===0&&delete ee.data[he]})},re.prototype._resetViewData=function(){var Q=this;Object.keys(this.data).forEach(function(te){te.indexOf("view_")===0&&delete Q.data[te]}),this.data.view_sequence_number=1},re.prototype._resetErrorData=function(Q,te){delete this.data.player_error_code,delete this.data.player_error_message},re.prototype._initializeViewData=function(){var Q=this,te=this.data.view_id=(0,E.generateUUID)(),ee=function(){te===Q.data.view_id&&(0,r.default)(Q.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",ee):ee()},re.prototype._restartHeartBeat=function(){var Q=this;D.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=D.default.setTimeout(function(){Q.data.player_is_paused||Q.emit("hb")},1e4))},re.prototype.addHLSJS=function(Q){return Q.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=Q.hlsjs,void(0,s.monitorHlsJs)(this.mux,this.id,Q.hlsjs,{},Q.Hls||D.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},re.prototype.removeHLSJS=function(){this.hlsjs&&((0,s.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},re.prototype.addDashJS=function(Q){return Q.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=Q.dashjs,void(0,i.monitorDashJS)(this.mux,this.id,Q.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},re.prototype.removeDashJS=function(){this.dashjs&&((0,i.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},t.default=re},function(e,t,l){"use strict";function n(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(t,"__esModule",{value:!0}),t.stopMonitoringHlsJs=t.monitorHlsJs=void 0;var h=l(7),R=n(h),T=l(13),L=n(T),_=l(5),E=l(14),I=n(E),M=function(u){if(!u)return{};var r=L.default.navigationStart(),s=u.loading,i=s?s.start:u.trequest,a=s?s.first:u.tfirst,d=s?s.end:u.tload;return{bytesLoaded:u.total,requestStart:Math.round(r+i),responseStart:Math.round(r+a),responseEnd:Math.round(r+d)}},D=function(u){if(u&&typeof u.getAllResponseHeaders=="function")return(0,R.default)(u.getAllResponseHeaders())},b=function(u,r,s){var i=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),a=u.log,d=u.utils.secondsToMs,o=function(C){var P=parseInt(i.version),w=void 0;return P===1&&C.programDateTime!==null&&(w=C.programDateTime),P===0&&C.pdt!==null&&(w=C.pdt),w};if(!L.default.exists())return void a.warn("performance timing not supported. Not tracking HLS.js.");var y=function(C,P){return u.emit(r,C,P)},p=function(C,P){var w=P.levels,U=P.audioTracks,k=P.url,N=P.stats,B=P.networkDetails,K=P.sessionData,W={},F={},H={};H=(0,I.default)(K),w.forEach(function(X,ie){W[ie]={width:X.width,height:X.height,bitrate:X.bitrate,attrs:X.attrs}}),U.forEach(function(X,ie){F[ie]={name:X.name,language:X.lang,bitrate:X.bitrate}});var Y=M(N),$=Y.bytesLoaded,Z=Y.requestStart,q=Y.responseStart,oe=Y.responseEnd;H.request_event_type=C,H.request_bytes_loaded=$,H.request_start=Z,H.request_response_start=q,H.request_response_end=oe,H.request_type="manifest",H.request_hostname=(0,_.extractHostname)(k),H.request_response_headers=D(B),H.request_rendition_lists={media:W,audio:F,video:{}},y("requestcompleted",H)};s.on(i.Events.MANIFEST_LOADED,p);var m=function(C,P){var w=P.details,U=P.level,k=P.networkDetails,N=P.stats,B=M(N),K=B.bytesLoaded,W=B.requestStart,F=B.responseStart,H=B.responseEnd,Y=w.fragments[w.fragments.length-1],$=o(Y)+d(Y.duration);y("requestcompleted",{request_event_type:C,request_bytes_loaded:K,request_start:W,request_response_start:F,request_response_end:H,request_current_level:U,request_type:"manifest",request_hostname:(0,_.extractHostname)(w.url),request_response_headers:D(k),video_holdback:w.holdBack&&d(w.holdBack),video_part_holdback:w.partHoldBack&&d(w.partHoldBack),video_part_target_duration:w.partTarget&&d(w.partTarget),video_target_duration:w.targetduration&&d(w.targetduration),video_source_is_live:w.live,player_manifest_newest_program_time:isNaN($)?void 0:$})};s.on(i.Events.LEVEL_LOADED,m);var g=function(C,P){var w=P.details,U=P.networkDetails,k=P.stats,N=M(k),B=N.bytesLoaded,K=N.requestStart,W=N.responseStart,F=N.responseEnd;y("requestcompleted",{request_event_type:C,request_bytes_loaded:B,request_start:K,request_response_start:W,request_response_end:F,request_type:"manifest",request_hostname:(0,_.extractHostname)(w.url),request_response_headers:D(U)})};s.on(i.Events.AUDIO_TRACK_LOADED,g);var f=function(C,P){var w=P.stats,U=P.networkDetails,k=P.frag,N=M(w),B=N.bytesLoaded,K=N.requestStart,W=N.responseStart,F=N.responseEnd,H={request_event_type:C,request_bytes_loaded:B,request_start:K,request_response_start:W,request_response_end:F,request_hostname:U?(0,_.extractHostname)(U.responseURL):void 0,request_response_headers:D(U),request_media_duration:k.duration};k.type==="main"?(H.request_type="media",H.request_current_level=k.level,H.request_video_width=(s.levels[k.level]||{}).width,H.request_video_height=(s.levels[k.level]||{}).height):H.request_type=k.type,y("requestcompleted",H)};s.on(i.Events.FRAG_LOADED,f);var c=function(C,P){var w=P.frag,U=w.start,k=o(w),N={currentFragmentPDT:k,currentFragmentStart:d(U)};y("fragmentchange",N)};s.on(i.Events.FRAG_CHANGED,c);var x=function(C,P){var w=P.type,U=P.details,k=P.response,N=P.fatal,B=P.context,K=P.frag;if(U===i.ErrorDetails.MANIFEST_LOAD_ERROR||U===i.ErrorDetails.MANIFEST_LOAD_TIMEOUT||U===i.ErrorDetails.FRAG_LOAD_ERROR||U===i.ErrorDetails.FRAG_LOAD_TIMEOUT||U===i.ErrorDetails.LEVEL_LOAD_ERROR||U===i.ErrorDetails.LEVEL_LOAD_TIMEOUT){var W=K&&K.url||B&&B.url||"";y("requestfailed",{request_error:U,request_url:W,request_hostname:(0,_.extractHostname)(W),request_type:U===i.ErrorDetails.FRAG_LOAD_ERROR||U===i.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:k&&k.code,request_error_text:k&&k.text})}N&&y("error",{player_error_code:w,player_error_message:U})};s.on(i.Events.ERROR,x);var S=function(C,P){var w=P.frag,U=w&&w._url||"";y("requestcanceled",{request_cancel:C,request_url:U,request_type:"media",request_hostname:(0,_.extractHostname)(U)})};s.on(i.Events.FRAG_LOAD_EMERGENCY_ABORTED,S);var O=function(C,P){var w=P.level,U=s.levels[w];if(U&&U.attrs&&U.attrs.BANDWIDTH){var k=U.attrs.BANDWIDTH;k?y("renditionchange",{video_source_bitrate:k,video_source_width:U.width,video_source_height:U.height}):a.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};s.on(i.Events.LEVEL_SWITCHED,O),s._stopMuxMonitor=function(){s.off(i.Events.MANIFEST_LOADED,p),s.off(i.Events.LEVEL_LOADED,m),s.off(i.Events.AUDIO_TRACK_LOADED,g),s.off(i.Events.FRAG_LOADED,f),s.off(i.Events.FRAG_CHANGED,c),s.off(i.Events.ERROR,x),s.off(i.Events.FRAG_LOAD_EMERGENCY_ABORTED,S),s.off(i.Events.LEVEL_SWITCHED,O),s.off(i.Events.DESTROYING,s._stopMuxMonitor),delete s._stopMuxMonitor},s.on(i.Events.DESTROYING,s._stopMuxMonitor)},A=function(u){u&&typeof u._stopMuxMonitor=="function"&&u._stopMuxMonitor()};t.monitorHlsJs=b,t.stopMonitoringHlsJs=A},function(e,t,l){"use strict";function n(b){return b&&b.__esModule?b:{default:b}}Object.defineProperty(t,"__esModule",{value:!0}),t.stopMonitoringDashJS=t.monitorDashJS=void 0;var h=l(0),R=n(h),T=l(7),L=n(T),_=l(5),E=function(b,A){if(!b||typeof b.getRequests!="function")return{};var u=b.getRequests({state:"executed"});if(u.length===0)return{};var r=u[u.length-1],s=(0,_.extractHostname)(r.url),i=r.bytesLoaded,a=new Date(r.requestStartDate).getTime(),d=new Date(r.firstByteDate).getTime(),o=new Date(r.requestEndDate).getTime(),y=isNaN(r.duration)?0:r.duration,p=typeof A.getMetricsFor=="function"?A.getMetricsFor(r.mediaType).HttpList:A.getDashMetrics().getHttpRequests(r.mediaType),m=void 0;return p.length>0&&(m=(0,L.default)(p[p.length-1]._responseHeaders||"")),{requestStart:a,requestResponseStart:d,requestResponseEnd:o,requestBytesLoaded:i,requestResponseHeaders:m,requestMediaDuration:y,requestHostname:s}},I=function(b,A){var u=A.getQualityFor(b),r=A.getCurrentTrackFor(b),s=r.bitrateList;return s?{currentLevel:u,renditionWidth:s[u].width||null,renditionHeight:s[u].height||null,renditionBitrate:s[u].bandwidth}:{}},M=function(b,A,u){var r=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],b.log);if(!u||!u.on)return void r.warn("Invalid dash.js player reference. Monitoring blocked.");var s=function(f,c){return b.emit(A,f,c)},i=function(f){var c=f.type,x=f.data,S=x||{},O=S.url;s("requestcompleted",{request_event_type:c,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,_.extractHostname)(O)})};u.on("manifestLoaded",i);var a={},d=function(f){var c=f.type,x=f.fragmentModel,S=f.chunk,O=S||{},C=O.mediaInfo,P=C||{},w=P.type,U=P.bitrateList;U=U||[];var k={};U.forEach(function($,Z){k[Z]={},k[Z].width=$.width,k[Z].height=$.height,k[Z].bitrate=$.bandwidth,k[Z].attrs={}}),w==="video"?a.video=k:w==="audio"?a.audio=k:a.media=k;var N=E(x,u),B=N.requestStart,K=N.requestResponseStart,W=N.requestResponseEnd,F=N.requestResponseHeaders,H=N.requestMediaDuration,Y=N.requestHostname;s("requestcompleted",{request_event_type:c,request_start:B,request_response_start:K,request_response_end:W,request_bytes_loaded:-1,request_type:w+"_init",request_response_headers:F,request_hostname:Y,request_media_duration:H,request_rendition_lists:a})};u.on("initFragmentLoaded",d);var o=function(f){var c=f.type,x=f.fragmentModel,S=f.chunk,O=S||{},C=O.mediaInfo,P=O.start,w=C||{},U=w.type,k=E(x,u),N=k.requestStart,B=k.requestResponseStart,K=k.requestResponseEnd,W=k.requestBytesLoaded,F=k.requestResponseHeaders,H=k.requestMediaDuration,Y=k.requestHostname,$=I(U,u),Z=$.currentLevel,q=$.renditionWidth,oe=$.renditionHeight,X=$.renditionBitrate;s("requestcompleted",{request_event_type:c,request_start:N,request_response_start:B,request_response_end:K,request_bytes_loaded:W,request_type:U,request_response_headers:F,request_hostname:Y,request_media_start_time:P,request_media_duration:H,request_current_level:Z,request_labeled_bitrate:X,request_video_width:q,request_video_height:oe})};u.on("mediaFragmentLoaded",o);var y={video:void 0,audio:void 0,totalBitrate:void 0},p=function(){if(y.video&&typeof y.video.bitrate=="number"){if(!y.video.width||!y.video.height)return void r.warn("have bitrate info for video but missing width/height");var f=y.video.bitrate;return y.audio&&typeof y.audio.bitrate=="number"&&(f+=y.audio.bitrate),f!==y.totalBitrate?(y.totalBitrate=f,{video_source_bitrate:f,video_source_height:y.video.height,video_source_width:y.video.width}):void 0}},m=function(f,c,x){if(typeof f.newQuality!="number")return void r.warn("missing evt.newQuality in qualityChangeRendered event",f);var S=f.mediaType;if(S==="audio"||S==="video"){var O=u.getBitrateInfoListFor(S).find(function(P){return P.qualityIndex===f.newQuality});if(!O||typeof O.bitrate!="number")return void r.warn("missing bitrate info for "+S);y[S]=O;var C=p();C&&s("renditionchange",C)}};u.on("qualityChangeRendered",m);var g=function(f){var c=f.error,x=f.event;x=x||{};var S=x.request||{},O=R.default.event&&R.default.event.currentTarget||{};s("requestfailed",{request_error:c+"_"+x.id+"_"+S.type,request_url:x.url,request_hostname:(0,_.extractHostname)(x.url),request_type:S.mediaType,request_error_code:O.status,request_error_type:O.statusText})};u.on("error",g),u._stopMuxMonitor=function(){u.off("manifestLoaded",i),u.off("initFragmentLoaded",d),u.off("mediaFragmentLoaded",o),u.off("qualityChangeRendered",m),u.off("error",g),delete u._stopMuxMonitor}},D=function(b){b&&typeof b._stopMuxMonitor=="function"&&b._stopMuxMonitor()};t.monitorDashJS=M,t.stopMonitoringDashJS=D},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){},h=0;n.prototype.on=function(R,T,L){return T._eventEmitterGuid=T._eventEmitterGuid||++h,this._listeners=this._listeners||{},this._listeners[R]=this._listeners[R]||[],L&&(T=T.bind(L)),this._listeners[R].push(T),T},n.prototype.off=function(R,T){var L=this._listeners&&this._listeners[R];L&&L.forEach(function(_,E){_._eventEmitterGuid===T._eventEmitterGuid&&L.splice(E,1)})},n.prototype.one=function(R,T,L){var _=this;T._eventEmitterGuid=T._eventEmitterGuid||++h;var E=function I(){_.off(R,I),T.apply(L||this,arguments)};E._eventEmitterGuid=T._eventEmitterGuid,this.on(R,E)},n.prototype.emit=function(R,T){var L=this;if(this._listeners){T=T||{};var _=this._listeners["before*"]||[],E=this._listeners[R]||[],I=this._listeners["after"+R]||[],M=function(D,b){D=D.slice(),D.forEach(function(A){A.call(L,{type:R},b)})};M(_,T),M(E,T),M(I,T)}},t.default=n},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(0),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R=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,L){this._playbackHeartbeatInterval!==null&&(h.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:L.viewer_time}),this._playbackHeartbeatInterval=null)})};R.prototype._startPlaybackHeartbeatInterval=function(){var T=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=h.default.setInterval(function(){T.emit("playbackheartbeat")},this.playbackHeartbeatTime))},R.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(h.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},t.default=R},function(e,t,l){"use strict";function n(){var h=this;this.on("viewinit",function(){h.viewErrored=!1}),this.on("error",function(){try{var R=h.errorTranslator({player_error_code:h.data.player_error_code,player_error_message:h.data.player_error_message});R?(h.data.player_error_code=R.player_error_code,h.data.player_error_message=R.player_error_message,h.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message)}catch(T){h.mux.log.warn("Exception in error translator callback.",T),h.viewErrored=!0}})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(3),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};R.prototype._updateWatchTime=function(T,L){var _=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,h.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},R.prototype._clearWatchTimeState=function(T,L){this._updateWatchTime(T,L),this._watchTimeTrackerLastCheckedTime=null},t.default=R},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(3),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R=function(){this._playbackTimeTrackerLastPlayheadPosition=-1,this.on("playbackheartbeat",this._updatePlaybackTime),this.on("playbackheartbeatend",this._clearPlaybackTimeState),this.on("seeking",this._clearPlaybackTimeState)};R.prototype._updatePlaybackTime=function(){var T=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&T>this._playbackTimeTrackerLastPlayheadPosition){var L=T-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&(0,h.default)(this.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=T},R.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},t.default=R},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=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)})};n.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)},n.prototype._updatePlayheadTime=function(h,R){var T=this,L=function(){T.currentFragmentPDT&&T.currentFragmentStart&&(T.data.player_program_time=T.currentFragmentPDT+T.data.player_playhead_time-T.currentFragmentStart)};if(R&&R.player_playhead_time)this.data.player_playhead_time=R.player_playhead_time,L(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,L(),this._updateMaxPlayheadPosition())}},t.default=n},function(e,t,l){"use strict";function n(){var T=this;if(!this.disableRebufferTracking){var L=void 0,_=function(){if(L){var E=T.data.viewer_time-L;(0,R.default)(T.data,"view_rebuffer_duration",E),L=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 _()}),this.on("rebufferstart",function(){L||((0,R.default)(T.data,"view_rebuffer_count",1),L=T.data.viewer_time,T.one("rebufferend",function(){_(),L=void 0}))})}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var h=l(3),R=function(T){return T&&T.__esModule?T:{default:T}}(h)},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(2),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R=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:h.default.now()})}))};R.prototype._checkIfRebuffering=function(T,L){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(T,L):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(L.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(T,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))},R.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},R.prototype._prepareRebufferTrackerState=function(T){this._lastCheckedTime=T,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=T},R.prototype._cleanupRebufferTracker=function(T,L){var _=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 E=this.data.player_playhead_time-this._lastPlayheadTime,I=L.viewer_time-this._lastPlayheadTimeUpdatedTime;E>0&&I-E>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+I-E}))}_?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()},t.default=R},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(2),h=function(T){return T&&T.__esModule?T:{default:T}}(n),R=function(){this.on("viewinit",function(){var T=this.data,L=T.view_id;if(!T.view_program_changed){var _=function(E,I){var M=I.viewer_time;E.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(M||h.default.now(),L):E.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(M||h.default.now(),L)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};R.prototype.calculateTimeToFirstFrame=function(T,L){L===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))},t.default=R},function(e,t,l){"use strict";function n(){var T=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var L=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];L.forEach(function(E){T.on(E,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var I=this.data.player_playhead_time-this._lastPlayheadPosition;if(I<0)return void(this._lastPlayheadPosition=-1);var M=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),D=Math.max(0,M-1),b=Math.max(0,1-M);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,D),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,b),(0,R.default)(this.data,"view_total_content_playback_time",I),(0,R.default)(this.data,"view_total_upscaling",D*I),(0,R.default)(this.data,"view_total_downscaling",b*I)}this._lastPlayheadPosition=-1})}),_.forEach(function(E){T.on(E,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(t,"__esModule",{value:!0}),t.default=n;var h=l(3),R=function(T){return T&&T.__esModule?T:{default:T}}(h)},function(e,t,l){"use strict";function n(M){return M&&M.__esModule?M:{default:M}}function h(){this.isSeeking=!1,this.on("seeking",function(M,D){(0,I.default)(this.data,D),this._lastSeekingTime=T.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var M=this._lastSeekingTime||T.default.now(),D=T.default.now()-M;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",D);var b=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(b,D)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=h;var R=l(2),T=n(R),L=l(3),_=n(L),E=l(1),I=n(E)},function(e,t,l){"use strict";function n(b){return b&&b.__esModule?b:{default:b}}Object.defineProperty(t,"__esModule",{value:!0});var h=function(){function b(A,u){var r=[],s=!0,i=!1,a=void 0;try{for(var d,o=A[Symbol.iterator]();!(s=(d=o.next()).done)&&(r.push(d.value),!u||r.length!==u);s=!0);}catch(y){i=!0,a=y}finally{try{!s&&o.return&&o.return()}finally{if(i)throw a}}return r}return function(A,u){if(Array.isArray(A))return A;if(Symbol.iterator in Object(A))return b(A,u);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),R=l(3),T=n(R),L=l(5),_=l(1),E=n(_),I=function(b,A){b.push(A),b.sort(function(u,r){return u.viewer_time-r.viewer_time})},M=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],D=function(){var b=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}),M.forEach(function(u){return b.on(u,b._updateAdData)});var A=function(){b.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",A),this.on("playing",A),this.on("viewend",A),this.on("adrequest",function(u,r){r=(0,E.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},r),I(this._adRequests,r),(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(u,r){r=(0,E.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},r),I(this._adResponses,r);var s=this.findAdRequest(r.ad_request_id);s&&(0,T.default)(this.data,"view_ad_request_time",Math.max(0,r.viewer_time-s.viewer_time))}),this.on("adplay",function(u,r){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,r.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,r.viewer_time-this.data.view_start)),this._prerollPlayTime=r.viewer_time)}),this.on("adplaying",function(u,r){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=r.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=r.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};D.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},D.prototype.findAdRequest=function(b){for(var A=0;A<this._adRequests.length;A++)if(this._adRequests[A].ad_request_id===b)return this._adRequests[A]},D.prototype._updateAdData=function(b,A){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&A.ad_tag_url){var u=(0,L.extractHostnameAndDomain)(A.ad_tag_url),r=h(u,2),s=r[0],i=r[1];this.data.view_preroll_ad_tag_domain=i,this.data.view_preroll_ad_tag_hostname=s}if(!this.data.view_preroll_ad_asset_hostname&&A.ad_asset_url){var a=(0,L.extractHostnameAndDomain)(A.ad_asset_url),d=h(a,2),o=d[0],y=d[1];this.data.view_preroll_ad_asset_domain=y,this.data.view_preroll_ad_asset_hostname=o}}},t.default=D},function(e,t,l){"use strict";function n(E){return E&&E.__esModule?E:{default:E}}function h(){var E=this,I=void 0,M=void 0,D=function(){E.disableRebufferTracking||((0,_.default)(E.data,"view_waiting_rebuffer_count",1),I=T.default.now(),M=window.setInterval(function(){if(I){var s=T.default.now();(0,_.default)(E.data,"view_waiting_rebuffer_duration",s-I),I=s}},250))},b=function(){E.disableRebufferTracking||I&&((0,_.default)(E.data,"view_waiting_rebuffer_duration",T.default.now()-I),I=!1,window.clearInterval(M))},A=!1,u=function(){A=!0},r=function(){A=!1,b()};this.on("waiting",function(){A&&D()}),this.on("playing",function(){b(),u()}),this.on("pause",r),this.on("seeking",r)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=h;var R=l(2),T=n(R),L=l(3),_=n(L)},function(e,t,l){"use strict";function n(M){return M&&M.__esModule?M:{default:M}}function h(){var M=this;this.one("playbackheartbeat",E),this.on("playbackheartbeatend",function(){M.off("before*",I),M.one("playbackheartbeat",E)})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=h;var R=l(1),T=n(R),L=l(2),_=n(L),E=function(){this.lastWallClockTime=_.default.now(),this.on("before*",I)},I=function(M){var D=_.default.now(),b=this.lastWallClockTime;this.lastWallClockTime=D,D-b>3e4&&(this.emit("devicesleep",{viewer_time:b}),(0,T.default)(this.data,{viewer_time:b}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:D}),(0,T.default)(this.data,{viewer_time:D}),this.send("devicewake"))}},function(e,t,l){"use strict";function n(c){return c&&c.__esModule?c:{default:c}}Object.defineProperty(t,"__esModule",{value:!0});var h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},R=l(0),T=n(R),L=l(40),_=l(4),E=n(_),I=l(53),M=n(I),D=l(12),b=n(D),A=l(54),u=n(A),r=l(17),s=n(r),i=l(55),a=n(i),d=l(1),o=n(d),y=["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"],p=["viewstart","error","ended","viewend"],m=function(c,x){var S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=c,this.envKey=x,this.eventQueue=new a.default((0,M.default)(x,S)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=S.sampleRate,this.disableCookies=S.disableCookies,this.respectDoNotTrack=S.respectDoNotTrack;var O=S.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 C=(0,u.default)();C&&(this.pageLevelData=(0,o.default)(this.pageLevelData,{viewer_connection_type:C})),T.default!==void 0&&T.default.location&&T.default.location.href&&(this.pageLevelData.page_url=T.default.location.href),this.viewerData=this.disableCookies?{}:(0,L.getAndUpdateViewerData)()};m.prototype.send=function(c,x){if(c){if(this.respectDoNotTrack&&(0,b.default)())return E.default.info("Not sending `"+c+"` because Do Not Track is enabled");if(!x||(x===void 0?"undefined":h(x))!=="object")return E.default.error("A data object was expected in send() but was not provided");var S=this.disableCookies?{}:(0,L.getAndUpdateSessionData)(),O={};(0,o.default)(O,this.pageLevelData),(0,o.default)(O,x),(0,o.default)(O,S),(0,o.default)(O,this.viewerData),O.event=c,O.env_key=this.envKey,O.user_id&&(O.viewer_user_id=O.user_id,delete O.user_id);var C=O.mux_sample_number>=this.sampleRate,P=this._deduplicateBeaconData(c,O),w=(0,s.default)(P);if(this.lastEventTime=this.mux.utils.now(),C)return E.default.info("Not sending event due to sample rate restriction",c,O,w);if(this.envKey||E.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",c,O,w),!this.rateLimited){if(E.default.info("Sending event",c,O,w),this.rateLimited=!this.eventQueue.queueEvent(c,w),this.mux.WINDOW_UNLOADING&&c==="viewend")this.eventQueue.destroy(!0);else if((p.indexOf(c)>=0||this.mux.WINDOW_VISIBLE===!1&&c==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return O.event="eventrateexceeded",w=(0,s.default)(O),this.eventQueue.queueEvent(O.event,w),E.default.error("Beaconing disabled due to rate limit.")}}},m.prototype.destroy=function(){this.eventQueue.destroy(!1)};var g=function(c,x,S,O){return!(!c||x.indexOf("request_")!==0)&&(x==="request_response_headers"||(S===void 0?"undefined":h(S))!=="object"||(O===void 0?"undefined":h(O))!=="object"||Object.keys(S||{}).length!==Object.keys(O||{}).length)},f=function(c,x){return c==="renditionchange"&&x.indexOf("video_source_")===0};m.prototype._deduplicateBeaconData=function(c,x){var S=this,O={},C=x.view_id;if(!C||c==="viewstart"||c==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)O=(0,o.default)({},x),C&&(this.previousBeaconData=O),C&&c==="viewend"&&(this.previousBeaconData=null);else{var P=c.indexOf("request")===0;Object.keys(x).forEach(function(w){var U=x[w];(U!==S.previousBeaconData[w]||y.indexOf(w)>-1||g(P,w,U,S.previousBeaconData[w])||f(c,w))&&(O[w]=U,S.previousBeaconData[w]=U)})}return O},t.default=m},function(e,t,l){"use strict";function n(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(t,"__esModule",{value:!0}),t.getAndUpdateSessionData=t.getAndUpdateViewerData=void 0;var h=l(15),R=n(h),T=l(52),L=n(T),_=l(6),E=l(2),I=n(E),M=function(){var u=void 0;try{u=R.default.parse(L.default.get("muxData")||"")}catch{u={}}return u},D=function(u){try{L.default.set("muxData",R.default.stringify(u),{expires:7300})}catch{}},b=function(){var u=M();return u.mux_viewer_id=u.mux_viewer_id||(0,_.generateUUID)(),u.msn=u.msn||Math.random(),D(u),{mux_viewer_id:u.mux_viewer_id,mux_sample_number:u.msn}},A=function(){var u=M(),r=I.default.now();return u.session_start&&(u.sst=u.session_start,delete u.session_start),u.session_id&&(u.sid=u.session_id,delete u.session_id),u.session_expires&&(u.sex=u.session_expires,delete u.session_expires),(!u.sex||u.sex<r)&&(u.sid=(0,_.generateUUID)(),u.sst=r),u.sex=r+15e5,D(u),{session_id:u.sid,session_start:u.sst,session_expires:u.sex}};t.getAndUpdateViewerData=b,t.getAndUpdateSessionData=A},function(e,t,l){"use strict";var n=l(42),h=l(16),R=l(10),T=Object.prototype.hasOwnProperty,L={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,d){return a+"["+d+"]"},repeat:function(a){return a}},_=Array.isArray,E=String.prototype.split,I=Array.prototype.push,M=function(a,d){I.apply(a,_(d)?d:[d])},D=Date.prototype.toISOString,b=R.default,A={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:h.encode,encodeValuesOnly:!1,format:b,formatter:R.formatters[b],indices:!1,serializeDate:function(a){return D.call(a)},skipNulls:!1,strictNullHandling:!1},u=function(a){return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||typeof a=="symbol"||typeof a=="bigint"},r={},s=function a(d,o,y,p,m,g,f,c,x,S,O,C,P,w,U){for(var k=d,N=U,B=0,K=!1;(N=N.get(r))!==void 0&&!K;){var W=N.get(d);if(B+=1,W!==void 0){if(W===B)throw new RangeError("Cyclic object value");K=!0}N.get(r)===void 0&&(B=0)}if(typeof f=="function"?k=f(o,k):k instanceof Date?k=S(k):y==="comma"&&_(k)&&(k=h.maybeMap(k,function(re){return re instanceof Date?S(re):re})),k===null){if(p)return g&&!P?g(o,A.encoder,w,"key",O):o;k=""}if(u(k)||h.isBuffer(k)){if(g){var F=P?o:g(o,A.encoder,w,"key",O);if(y==="comma"&&P){for(var H=E.call(String(k),","),Y="",$=0;$<H.length;++$)Y+=($===0?"":",")+C(g(H[$],A.encoder,w,"value",O));return[C(F)+"="+Y]}return[C(F)+"="+C(g(k,A.encoder,w,"value",O))]}return[C(o)+"="+C(String(k))]}var Z=[];if(k===void 0)return Z;var q;if(y==="comma"&&_(k))q=[{value:k.length>0?k.join(",")||null:void 0}];else if(_(f))q=f;else{var oe=Object.keys(k);q=c?oe.sort(c):oe}for(var X=0;X<q.length;++X){var ie=q[X],fe=typeof ie=="object"&&ie.value!==void 0?ie.value:k[ie];if(!m||fe!==null){var ue=_(k)?typeof y=="function"?y(o,ie):o:o+(x?"."+ie:"["+ie+"]");U.set(d,B);var Ae=n();Ae.set(r,U),M(Z,a(fe,ue,y,p,m,g,f,c,x,S,O,C,P,w,Ae))}}return Z},i=function(a){if(!a)return A;if(a.encoder!==null&&a.encoder!==void 0&&typeof a.encoder!="function")throw new TypeError("Encoder has to be a function.");var d=a.charset||A.charset;if(a.charset!==void 0&&a.charset!=="utf-8"&&a.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var o=R.default;if(a.format!==void 0){if(!T.call(R.formatters,a.format))throw new TypeError("Unknown format option provided.");o=a.format}var y=R.formatters[o],p=A.filter;return(typeof a.filter=="function"||_(a.filter))&&(p=a.filter),{addQueryPrefix:typeof a.addQueryPrefix=="boolean"?a.addQueryPrefix:A.addQueryPrefix,allowDots:a.allowDots===void 0?A.allowDots:!!a.allowDots,charset:d,charsetSentinel:typeof a.charsetSentinel=="boolean"?a.charsetSentinel:A.charsetSentinel,delimiter:a.delimiter===void 0?A.delimiter:a.delimiter,encode:typeof a.encode=="boolean"?a.encode:A.encode,encoder:typeof a.encoder=="function"?a.encoder:A.encoder,encodeValuesOnly:typeof a.encodeValuesOnly=="boolean"?a.encodeValuesOnly:A.encodeValuesOnly,filter:p,format:o,formatter:y,serializeDate:typeof a.serializeDate=="function"?a.serializeDate:A.serializeDate,skipNulls:typeof a.skipNulls=="boolean"?a.skipNulls:A.skipNulls,sort:typeof a.sort=="function"?a.sort:null,strictNullHandling:typeof a.strictNullHandling=="boolean"?a.strictNullHandling:A.strictNullHandling}};e.exports=function(a,d){var o,y,p=a,m=i(d);typeof m.filter=="function"?(y=m.filter,p=y("",p)):_(m.filter)&&(y=m.filter,o=y);var g=[];if(typeof p!="object"||p===null)return"";var f;f=d&&d.arrayFormat in L?d.arrayFormat:d&&"indices"in d?d.indices?"indices":"repeat":"indices";var c=L[f];o||(o=Object.keys(p)),m.sort&&o.sort(m.sort);for(var x=n(),S=0;S<o.length;++S){var O=o[S];m.skipNulls&&p[O]===null||M(g,s(p[O],O,c,m.strictNullHandling,m.skipNulls,m.encode?m.encoder:null,m.filter,m.sort,m.allowDots,m.serializeDate,m.format,m.formatter,m.encodeValuesOnly,m.charset,x))}var C=g.join(m.delimiter),P=m.addQueryPrefix===!0?"?":"";return m.charsetSentinel&&(m.charset==="iso-8859-1"?P+="utf8=%26%2310003%3B&":P+="utf8=%E2%9C%93&"),C.length>0?P+C:""}},function(e,t,l){"use strict";var n=l(8),h=l(47),R=l(49),T=n("%TypeError%"),L=n("%WeakMap%",!0),_=n("%Map%",!0),E=h("WeakMap.prototype.get",!0),I=h("WeakMap.prototype.set",!0),M=h("WeakMap.prototype.has",!0),D=h("Map.prototype.get",!0),b=h("Map.prototype.set",!0),A=h("Map.prototype.has",!0),u=function(a,d){for(var o,y=a;(o=y.next)!==null;y=o)if(o.key===d)return y.next=o.next,o.next=a.next,a.next=o,o},r=function(a,d){var o=u(a,d);return o&&o.value},s=function(a,d,o){var y=u(a,d);y?y.value=o:a.next={key:d,next:a.next,value:o}},i=function(a,d){return!!u(a,d)};e.exports=function(){var a,d,o,y={assert:function(p){if(!y.has(p))throw new T("Side channel does not contain "+R(p))},get:function(p){if(L&&p&&(typeof p=="object"||typeof p=="function")){if(a)return E(a,p)}else if(_){if(d)return D(d,p)}else if(o)return r(o,p)},has:function(p){if(L&&p&&(typeof p=="object"||typeof p=="function")){if(a)return M(a,p)}else if(_){if(d)return A(d,p)}else if(o)return i(o,p);return!1},set:function(p,m){L&&p&&(typeof p=="object"||typeof p=="function")?(a||(a=new L),I(a,p,m)):_?(d||(d=new _),b(d,p,m)):(o||(o={key:{},next:null}),s(o,p,m))}};return y}},function(e,t,l){"use strict";var n=typeof Symbol!="undefined"&&Symbol,h=l(44);e.exports=function(){return typeof n=="function"&&typeof Symbol=="function"&&typeof n("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&h()}},function(e,t,l){"use strict";e.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var n={},h=Symbol("test"),R=Object(h);if(typeof h=="string"||Object.prototype.toString.call(h)!=="[object Symbol]"||Object.prototype.toString.call(R)!=="[object Symbol]")return!1;n[h]=42;for(h in n)return!1;if(typeof Object.keys=="function"&&Object.keys(n).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(n).length!==0)return!1;var T=Object.getOwnPropertySymbols(n);if(T.length!==1||T[0]!==h||!Object.prototype.propertyIsEnumerable.call(n,h))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var L=Object.getOwnPropertyDescriptor(n,h);if(L.value!==42||L.enumerable!==!0)return!1}return!0}},function(e,t,l){"use strict";var n=Array.prototype.slice,h=Object.prototype.toString;e.exports=function(R){var T=this;if(typeof T!="function"||h.call(T)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+T);for(var L,_=n.call(arguments,1),E=function(){if(this instanceof L){var A=T.apply(this,_.concat(n.call(arguments)));return Object(A)===A?A:this}return T.apply(R,_.concat(n.call(arguments)))},I=Math.max(0,T.length-_.length),M=[],D=0;D<I;D++)M.push("$"+D);if(L=Function("binder","return function ("+M.join(",")+"){ return binder.apply(this,arguments); }")(E),T.prototype){var b=function(){};b.prototype=T.prototype,L.prototype=new b,b.prototype=null}return L}},function(e,t,l){"use strict";var n=l(9);e.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},function(e,t,l){"use strict";var n=l(8),h=l(48),R=h(n("String.prototype.indexOf"));e.exports=function(T,L){var _=n(T,!!L);return typeof _=="function"&&R(T,".prototype.")>-1?h(_):_}},function(e,t,l){"use strict";var n=l(9),h=l(8),R=h("%Function.prototype.apply%"),T=h("%Function.prototype.call%"),L=h("%Reflect.apply%",!0)||n.call(T,R),_=h("%Object.getOwnPropertyDescriptor%",!0),E=h("%Object.defineProperty%",!0),I=h("%Math.max%");if(E)try{E({},"a",{value:1})}catch{E=null}e.exports=function(D){var b=L(n,T,arguments);return _&&E&&_(b,"length").configurable&&E(b,"length",{value:1+I(0,D.length-(arguments.length-1))}),b};var M=function(){return L(n,R,arguments)};E?E(e.exports,"apply",{value:M}):e.exports.apply=M},function(e,t,l){function n(G,V){if(G===1/0||G===-1/0||G!==G||G&&G>-1e3&&G<1e3||he.call(/e/,V))return V;var de=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof G=="number"){var ce=G<0?-Ie(-G):Ie(G);if(ce!==G){var Me=String(ce),Re=re.call(V,Me.length+1);return Q.call(Me,de,"$&_")+"."+Q.call(Q.call(Re,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Q.call(V,de,"$&_")}function h(G,V,de){var ce=(de.quoteStyle||V)==="double"?'"':"'";return ce+G+ce}function R(G){return Q.call(String(G),/"/g,"&quot;")}function T(G){return!(r(G)!=="[object Array]"||be&&typeof G=="object"&&be in G)}function L(G){return!(r(G)!=="[object Date]"||be&&typeof G=="object"&&be in G)}function _(G){return!(r(G)!=="[object RegExp]"||be&&typeof G=="object"&&be in G)}function E(G){return!(r(G)!=="[object Error]"||be&&typeof G=="object"&&be in G)}function I(G){return!(r(G)!=="[object String]"||be&&typeof G=="object"&&be in G)}function M(G){return!(r(G)!=="[object Number]"||be&&typeof G=="object"&&be in G)}function D(G){return!(r(G)!=="[object Boolean]"||be&&typeof G=="object"&&be in G)}function b(G){if(Ne)return G&&typeof G=="object"&&G instanceof Symbol;if(typeof G=="symbol")return!0;if(!G||typeof G!="object"||!ye)return!1;try{return ye.call(G),!0}catch{}return!1}function A(G){if(!G||typeof G!="object"||!Ue)return!1;try{return Ue.call(G),!0}catch{}return!1}function u(G,V){return et.call(G,V)}function r(G){return fe.call(G)}function s(G){if(G.name)return G.name;var V=Ae.call(ue.call(G),/^function\s*([\w$]+)/);return V?V[1]:null}function i(G,V){if(G.indexOf)return G.indexOf(V);for(var de=0,ce=G.length;de<ce;de++)if(G[de]===V)return de;return-1}function a(G){if(!N||!G||typeof G!="object")return!1;try{N.call(G);try{F.call(G)}catch{return!0}return G instanceof Map}catch{}return!1}function d(G){if(!$||!G||typeof G!="object")return!1;try{$.call(G,$);try{q.call(G,q)}catch{return!0}return G instanceof WeakMap}catch{}return!1}function o(G){if(!X||!G||typeof G!="object")return!1;try{return X.call(G),!0}catch{}return!1}function y(G){if(!F||!G||typeof G!="object")return!1;try{F.call(G);try{N.call(G)}catch{return!0}return G instanceof Set}catch{}return!1}function p(G){if(!q||!G||typeof G!="object")return!1;try{q.call(G,q);try{$.call(G,$)}catch{return!0}return G instanceof WeakSet}catch{}return!1}function m(G){return!(!G||typeof G!="object")&&(typeof HTMLElement!="undefined"&&G instanceof HTMLElement||typeof G.nodeName=="string"&&typeof G.getAttribute=="function")}function g(G,V){if(G.length>V.maxStringLength){var de=G.length-V.maxStringLength,ce="... "+de+" more character"+(de>1?"s":"");return g(re.call(G,0,V.maxStringLength),V)+ce}return h(Q.call(Q.call(G,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,f),"single",V)}function f(G){var V=G.charCodeAt(0),de={8:"b",9:"t",10:"n",12:"f",13:"r"}[V];return de?"\\"+de:"\\x"+(V<16?"0":"")+te.call(V.toString(16))}function c(G){return"Object("+G+")"}function x(G){return G+" { ? }"}function S(G,V,de,ce){return G+" ("+V+") {"+(ce?P(de,ce):pe.call(de,", "))+"}"}function O(G){for(var V=0;V<G.length;V++)if(i(G[V],`
2
- `)>=0)return!1;return!0}function C(G,V){var de;if(G.indent===" ")de=" ";else{if(!(typeof G.indent=="number"&&G.indent>0))return null;de=pe.call(Array(G.indent+1)," ")}return{base:de,prev:pe.call(Array(V+1),de)}}function P(G,V){if(G.length===0)return"";var de=`
3
- `+V.prev+V.base;return de+pe.call(G,","+de)+`
4
- `+V.prev}function w(G,V){var de=T(G),ce=[];if(de){ce.length=G.length;for(var Me=0;Me<G.length;Me++)ce[Me]=u(G,Me)?V(G[Me],G):""}var Re,le=typeof Ee=="function"?Ee(G):[];if(Ne){Re={};for(var Qe=0;Qe<le.length;Qe++)Re["$"+le[Qe]]=le[Qe]}for(var je in G)u(G,je)&&(de&&String(Number(je))===je&&je<G.length||Ne&&Re["$"+je]instanceof Symbol||(he.call(/[^\w$]/,je)?ce.push(V(je,G)+": "+V(G[je],G)):ce.push(je+": "+V(G[je],G))));if(typeof Ee=="function")for(var tt=0;tt<le.length;tt++)Ze.call(G,le[tt])&&ce.push("["+V(le[tt])+"]: "+V(G[le[tt]],G));return ce}var U=typeof Map=="function"&&Map.prototype,k=Object.getOwnPropertyDescriptor&&U?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,N=U&&k&&typeof k.get=="function"?k.get:null,B=U&&Map.prototype.forEach,K=typeof Set=="function"&&Set.prototype,W=Object.getOwnPropertyDescriptor&&K?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,F=K&&W&&typeof W.get=="function"?W.get:null,H=K&&Set.prototype.forEach,Y=typeof WeakMap=="function"&&WeakMap.prototype,$=Y?WeakMap.prototype.has:null,Z=typeof WeakSet=="function"&&WeakSet.prototype,q=Z?WeakSet.prototype.has:null,oe=typeof WeakRef=="function"&&WeakRef.prototype,X=oe?WeakRef.prototype.deref:null,ie=Boolean.prototype.valueOf,fe=Object.prototype.toString,ue=Function.prototype.toString,Ae=String.prototype.match,re=String.prototype.slice,Q=String.prototype.replace,te=String.prototype.toUpperCase,ee=String.prototype.toLowerCase,he=RegExp.prototype.test,Se=Array.prototype.concat,pe=Array.prototype.join,Te=Array.prototype.slice,Ie=Math.floor,Ue=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ee=Object.getOwnPropertySymbols,ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ne=typeof Symbol=="function"&&typeof Symbol.iterator=="object",be=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ne?"object":"symbol")?Symbol.toStringTag:null,Ze=Object.prototype.propertyIsEnumerable,we=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(G){return G.__proto__}:null),$e=l(50).custom,qe=$e&&b($e)?$e:null;e.exports=function G(V,de,ce,Me){function Re(Ot,vr,ao){if(vr&&(Me=Te.call(Me),Me.push(vr)),ao){var tn={depth:le.depth};return u(le,"quoteStyle")&&(tn.quoteStyle=le.quoteStyle),G(Ot,tn,ce+1,Me)}return G(Ot,le,ce+1,Me)}var le=de||{};if(u(le,"quoteStyle")&&le.quoteStyle!=="single"&&le.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(u(le,"maxStringLength")&&(typeof le.maxStringLength=="number"?le.maxStringLength<0&&le.maxStringLength!==1/0:le.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Qe=!u(le,"customInspect")||le.customInspect;if(typeof Qe!="boolean"&&Qe!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(u(le,"indent")&&le.indent!==null&&le.indent!==" "&&!(parseInt(le.indent,10)===le.indent&&le.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(u(le,"numericSeparator")&&typeof le.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var je=le.numericSeparator;if(V===void 0)return"undefined";if(V===null)return"null";if(typeof V=="boolean")return V?"true":"false";if(typeof V=="string")return g(V,le);if(typeof V=="number"){if(V===0)return 1/0/V>0?"0":"-0";var tt=String(V);return je?n(V,tt):tt}if(typeof V=="bigint"){var Ht=String(V)+"n";return je?n(V,Ht):Ht}var cr=le.depth===void 0?5:le.depth;if(ce===void 0&&(ce=0),ce>=cr&&cr>0&&typeof V=="object")return T(V)?"[Array]":"[Object]";var dt=C(le,ce);if(Me===void 0)Me=[];else if(i(Me,V)>=0)return"[Circular]";if(typeof V=="function"){var fr=s(V),Mt=w(V,Re);return"[Function"+(fr?": "+fr:" (anonymous)")+"]"+(Mt.length>0?" { "+pe.call(Mt,", ")+" }":"")}if(b(V)){var Gt=Ne?Q.call(String(V),/^(Symbol\(.*\))_[^)]*$/,"$1"):ye.call(V);return typeof V!="object"||Ne?Gt:c(Gt)}if(m(V)){for(var Rt="<"+ee.call(String(V.nodeName)),Vt=V.attributes||[],hr=0;hr<Vt.length;hr++)Rt+=" "+Vt[hr].name+"="+h(R(Vt[hr].value),"double",le);return Rt+=">",V.childNodes&&V.childNodes.length&&(Rt+="..."),Rt+="</"+ee.call(String(V.nodeName))+">"}if(T(V)){if(V.length===0)return"[]";var Zr=w(V,Re);return dt&&!O(Zr)?"["+P(Zr,dt)+"]":"[ "+pe.call(Zr,", ")+" ]"}if(E(V)){var qr=w(V,Re);return"cause"in V&&!Ze.call(V,"cause")?"{ ["+String(V)+"] "+pe.call(Se.call("[cause]: "+Re(V.cause),qr),", ")+" }":qr.length===0?"["+String(V)+"]":"{ ["+String(V)+"] "+pe.call(qr,", ")+" }"}if(typeof V=="object"&&Qe){if(qe&&typeof V[qe]=="function")return V[qe]();if(Qe!=="symbol"&&typeof V.inspect=="function")return V.inspect()}if(a(V)){var Ji=[];return B.call(V,function(Ot,vr){Ji.push(Re(vr,V,!0)+" => "+Re(Ot,V))}),S("Map",N.call(V),Ji,dt)}if(y(V)){var Zi=[];return H.call(V,function(Ot){Zi.push(Re(Ot,V))}),S("Set",F.call(V),Zi,dt)}if(d(V))return x("WeakMap");if(p(V))return x("WeakSet");if(o(V))return x("WeakRef");if(M(V))return c(Re(Number(V)));if(A(V))return c(Re(Ue.call(V)));if(D(V))return c(ie.call(V));if(I(V))return c(Re(String(V)));if(!L(V)&&!_(V)){var ei=w(V,Re),qi=we?we(V)===Object.prototype:V instanceof Object||V.constructor===Object,ti=V instanceof Object?"":"null prototype",en=!qi&&be&&Object(V)===V&&be in V?re.call(r(V),8,-1):ti?"Object":"",no=qi||typeof V.constructor!="function"?"":V.constructor.name?V.constructor.name+" ":"",ri=no+(en||ti?"["+pe.call(Se.call([],en||[],ti||[]),": ")+"] ":"");return ei.length===0?ri+"{}":dt?ri+"{"+P(ei,dt)+"}":ri+"{ "+pe.call(ei,", ")+" }"}return String(V)};var et=Object.prototype.hasOwnProperty||function(G){return G in this}},function(e,t){},function(e,t,l){"use strict";var n=l(16),h=Object.prototype.hasOwnProperty,R=Array.isArray,T={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:n.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},L=function(b){return b.replace(/&#(\d+);/g,function(A,u){return String.fromCharCode(parseInt(u,10))})},_=function(b,A){return b&&typeof b=="string"&&A.comma&&b.indexOf(",")>-1?b.split(","):b},E=function(b,A){var u,r={},s=A.ignoreQueryPrefix?b.replace(/^\?/,""):b,i=A.parameterLimit===1/0?void 0:A.parameterLimit,a=s.split(A.delimiter,i),d=-1,o=A.charset;if(A.charsetSentinel)for(u=0;u<a.length;++u)a[u].indexOf("utf8=")===0&&(a[u]==="utf8=%E2%9C%93"?o="utf-8":a[u]==="utf8=%26%2310003%3B"&&(o="iso-8859-1"),d=u,u=a.length);for(u=0;u<a.length;++u)if(u!==d){var y,p,m=a[u],g=m.indexOf("]="),f=g===-1?m.indexOf("="):g+1;f===-1?(y=A.decoder(m,T.decoder,o,"key"),p=A.strictNullHandling?null:""):(y=A.decoder(m.slice(0,f),T.decoder,o,"key"),p=n.maybeMap(_(m.slice(f+1),A),function(c){return A.decoder(c,T.decoder,o,"value")})),p&&A.interpretNumericEntities&&o==="iso-8859-1"&&(p=L(p)),m.indexOf("[]=")>-1&&(p=R(p)?[p]:p),h.call(r,y)?r[y]=n.combine(r[y],p):r[y]=p}return r},I=function(b,A,u,r){for(var s=r?A:_(A,u),i=b.length-1;i>=0;--i){var a,d=b[i];if(d==="[]"&&u.parseArrays)a=[].concat(s);else{a=u.plainObjects?Object.create(null):{};var o=d.charAt(0)==="["&&d.charAt(d.length-1)==="]"?d.slice(1,-1):d,y=parseInt(o,10);u.parseArrays||o!==""?!isNaN(y)&&d!==o&&String(y)===o&&y>=0&&u.parseArrays&&y<=u.arrayLimit?(a=[],a[y]=s):o!=="__proto__"&&(a[o]=s):a={0:s}}s=a}return s},M=function(b,A,u,r){if(b){var s=u.allowDots?b.replace(/\.([^.[]+)/g,"[$1]"):b,i=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,d=u.depth>0&&i.exec(s),o=d?s.slice(0,d.index):s,y=[];if(o){if(!u.plainObjects&&h.call(Object.prototype,o)&&!u.allowPrototypes)return;y.push(o)}for(var p=0;u.depth>0&&(d=a.exec(s))!==null&&p<u.depth;){if(p+=1,!u.plainObjects&&h.call(Object.prototype,d[1].slice(1,-1))&&!u.allowPrototypes)return;y.push(d[1])}return d&&y.push("["+s.slice(d.index)+"]"),I(y,A,u,r)}},D=function(b){if(!b)return T;if(b.decoder!==null&&b.decoder!==void 0&&typeof b.decoder!="function")throw new TypeError("Decoder has to be a function.");if(b.charset!==void 0&&b.charset!=="utf-8"&&b.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var A=b.charset===void 0?T.charset:b.charset;return{allowDots:b.allowDots===void 0?T.allowDots:!!b.allowDots,allowPrototypes:typeof b.allowPrototypes=="boolean"?b.allowPrototypes:T.allowPrototypes,allowSparse:typeof b.allowSparse=="boolean"?b.allowSparse:T.allowSparse,arrayLimit:typeof b.arrayLimit=="number"?b.arrayLimit:T.arrayLimit,charset:A,charsetSentinel:typeof b.charsetSentinel=="boolean"?b.charsetSentinel:T.charsetSentinel,comma:typeof b.comma=="boolean"?b.comma:T.comma,decoder:typeof b.decoder=="function"?b.decoder:T.decoder,delimiter:typeof b.delimiter=="string"||n.isRegExp(b.delimiter)?b.delimiter:T.delimiter,depth:typeof b.depth=="number"||b.depth===!1?+b.depth:T.depth,ignoreQueryPrefix:b.ignoreQueryPrefix===!0,interpretNumericEntities:typeof b.interpretNumericEntities=="boolean"?b.interpretNumericEntities:T.interpretNumericEntities,parameterLimit:typeof b.parameterLimit=="number"?b.parameterLimit:T.parameterLimit,parseArrays:b.parseArrays!==!1,plainObjects:typeof b.plainObjects=="boolean"?b.plainObjects:T.plainObjects,strictNullHandling:typeof b.strictNullHandling=="boolean"?b.strictNullHandling:T.strictNullHandling}};e.exports=function(b,A){var u=D(A);if(b===""||b===null||b===void 0)return u.plainObjects?Object.create(null):{};for(var r=typeof b=="string"?E(b,u):b,s=u.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a<i.length;++a){var d=i[a],o=M(d,r[d],u,typeof b=="string");s=n.merge(s,o,u)}return u.allowSparse===!0?s:n.compact(s)}},function(e,t,l){"use strict";var n,h,R=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 L=!1;if(n=T,(h=typeof n=="function"?n.call(t,l,t,e):n)!==void 0&&(e.exports=h),L=!0,R(t)==="object"&&(e.exports=T(),L=!0),!L){var _=window.Cookies,E=window.Cookies=T();E.noConflict=function(){return window.Cookies=_,E}}})(function(){function T(_){function E(I,M,D){var b;if(typeof document!="undefined"){if(arguments.length>1){if(D=L({path:"/"},E.defaults,D),typeof D.expires=="number"){var A=new Date;A.setMilliseconds(A.getMilliseconds()+864e5*D.expires),D.expires=A}try{b=JSON.stringify(M),/^[\{\[]/.test(b)&&(M=b)}catch{}return M=_.write?_.write(M,I):encodeURIComponent(String(M)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),I=encodeURIComponent(String(I)),I=I.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),I=I.replace(/[\(\)]/g,escape),document.cookie=[I,"=",M,D.expires?"; expires="+D.expires.toUTCString():"",D.path?"; path="+D.path:"",D.domain?"; domain="+D.domain:"",D.secure?"; secure":""].join("")}I||(b={});for(var u=document.cookie?document.cookie.split("; "):[],r=/(%[0-9A-Z]{2})+/g,s=0;s<u.length;s++){var i=u[s].split("="),a=i.slice(1).join("=");a.charAt(0)==='"'&&(a=a.slice(1,-1));try{var d=i[0].replace(r,decodeURIComponent);if(a=_.read?_.read(a,d):_(a,d)||a.replace(r,decodeURIComponent),this.json)try{a=JSON.parse(a)}catch{}if(I===d){b=a;break}I||(b[d]=a)}catch{}}return b}}return E.set=E,E.get=function(I){return E.call(E,I)},E.getJSON=function(){return E.apply({json:!0},[].slice.call(arguments))},E.defaults={},E.remove=function(I,M){E(I,"",L(M,{expires:-1}))},E.withConverter=T,E}var L=function(){for(var _=0,E={};_<arguments.length;_++){var I=arguments[_];for(var M in I)E[M]=I[M]}return E};return T(function(){})})},function(e,t,l){"use strict";function n(h,R){var T=R.beaconCollectionDomain,L=R.beaconDomain;if(T)return"https://"+T;h=h||"inferred";var _=L||"litix.io";return h.match(/^[a-z0-9]+$/)?"https://"+h+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(0),h=function(L){return L&&L.__esModule?L:{default:L}}(n),R=function(){var L=void 0;switch(T()){case"cellular":L="cellular";break;case"ethernet":L="wired";break;case"wifi":L="wifi";break;case void 0:break;default:L="other"}return L},T=function(){var L=h.default.navigator,_=L&&(L.connection||L.mozConnection||L.webkitConnection);return _&&_.type};t.default=R},function(e,t,l){"use strict";function n(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(t,"__esModule",{value:!0});var h=l(0),R=n(h),T=l(4),L=n(T),_=l(56),E=n(_),I=l(1),M=n(I),D=l(17),b=n(D),A=l(2),u=n(A),r=!!R.default.XMLHttpRequest&&"withCredentials"in new R.default.XMLHttpRequest,s={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},i=function(a,d){this._beaconUrl=a||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,M.default)({},s,d)};i.prototype.queueEvent=function(a,d){var o=(0,M.default)({},d);return r?(this._eventQueue.length<=this._options.maxQueueLength||a==="eventrateexceeded")&&(this._eventQueue.push(o),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(E.default.send(this._beaconUrl,o),!0)},i.prototype.flushEvents=function(){r&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},i.prototype.destroy=function(){var a=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,a?this._clearBeaconQueue():this.flushEvents(),R.default.clearTimeout(this._sendTimeout)},i.prototype._clearBeaconQueue=function(){var a=R.default.navigator,d=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,o=this._eventQueue.slice(d);d>0&&(0,M.default)(o[o.length-1],(0,b.default)({mux_view_message:"event queue truncated"}));var y=this._createPayload(o);if(a.sendBeacon)a.sendBeacon(this._beaconUrl,y);else if(R.default.XMLHttpRequest){var p=new R.default.XMLHttpRequest;p.open("POST",this._beaconUrl),p.setRequestHeader("Content-Type","application/json"),p.send(y)}else E.default.send(this._beaconUrl,o[o.length-1])},i.prototype._sendBeaconQueue=function(){var a=this;if(R.default.XMLHttpRequest&&!this._postInFlight){var d=new R.default.XMLHttpRequest,o=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,d.onreadystatechange=function(){d.readyState===4&&(d.status!==200?(a._eventQueue=o.concat(a._eventQueue),a._failureCount+=1,L.default.info("Error sending beacon: "+d.status),L.default.info(d.responseText)):a._failureCount=0,a._roundTripTime=u.default.now()-p,a._postInFlight=!1)},d.open("POST",this._beaconUrl),d.setRequestHeader("Content-Type","application/json");var y=this._createPayload(o),p=u.default.now();d.send(y)}},i.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var a=Math.pow(2,this._failureCount-1);return(1+(a*=Math.random()))*this._options.baseTimeBetweenBeacons},i.prototype._startBeaconSending=function(){var a=this;R.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=R.default.setTimeout(function(){a._eventQueue.length&&a._sendBeaconQueue(),a._startBeaconSending()},this._getNextBeaconTime()))},i.prototype._createPayload=function(a){var d={transmission_timestamp:Math.round(u.default.now())};return this._roundTripTime&&(d.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:d,events:a})},t.default=i},function(e,t,l){"use strict";function n(E){return E&&E.__esModule?E:{default:E}}Object.defineProperty(t,"__esModule",{value:!0});var h=l(15),R=n(h),T=l(0),L=n(T),_={};_.send=function(E,I){function M(){D.src=A+(b?"&rc="+b:"")}var D=new Image,b=0,A=E+"?"+R.default.stringify(I);return D.addEventListener("error",function(){b>3||L.default.setTimeout(function(){b++,M()},5e3*b)}),M(),D},t.default=_},function(e,t,l){"use strict";function n(){function h(A,u){var r=u.request_start,s=u.request_response_start,i=u.request_response_end,a=u.request_bytes_loaded;I++;var d=void 0,o=void 0;if(s?(d=s-r,o=i-s):o=i-r,o>0&&a>0){var y=a/o*8e3;M++,_+=a,E+=o,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,y),this.data.view_average_request_throughput=_/E*8e3,this.data.view_request_count=I,d>0&&(L+=d,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,d),this.data.view_average_request_latency=L/M)}}function R(A,u){I++,D++,this.data.view_request_count=I,this.data.view_request_failed_count=D}function T(A,u){I++,b++,this.data.view_request_count=I,this.data.view_request_canceled_count=b}var L=0,_=0,E=0,I=0,M=0,D=0,b=0;this.on("requestcompleted",h),this.on("requestfailed",R),this.on("requestcanceled",T)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,l){"use strict";function n(M,D,b){var A=(0,_.findMediaElement)(D),u=R(A,3),r=u[0],s=u[1],i=u[2],a=M.log,d=M.utils.getComputedStyle,o=M.utils.secondsToMs,y={automaticErrorTracking:!0};if(!r)return a.error("No element was found with the `"+s+"` query selector.");if(i!=="video"&&i!=="audio")return a.error("The element of `"+s+"` was not a media element.");b=(0,L.default)(y,b),b.data=(0,L.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},b.data),b.getPlayheadTime=function(){return o(r.currentTime)},b.getStateData=function(){var m=this.hlsjs&&this.hlsjs.url,g=this.dashjs&&h(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:r.paused,player_playhead_time:o(r.currentTime),player_width:parseInt(d(r,"width")),player_height:parseInt(d(r,"height")),player_autoplay_on:r.autoplay,player_preload_on:r.preload,video_poster_url:r.poster,video_source_url:m||g||r.currentSrc,video_source_duration:o(r.duration),video_source_height:r.videoHeight,video_source_width:r.videoWidth}},r.mux=r.mux||{},r.mux.deleted=!1,r.mux.emit=function(m,g){M.emit(s,m,g)};var p=function(){a.error("The monitor for this video element has already been destroyed.")};r.mux.destroy=function(){Object.keys(r.mux.listeners).forEach(function(m){r.removeEventListener(m,r.mux.listeners[m],!1)}),delete r.mux.listeners,r.mux.destroy=p,r.mux.swapElement=p,r.mux.emit=p,r.mux.addHLSJS=p,r.mux.addDashJS=p,r.mux.removeHLSJS=p,r.mux.removeDashJS=p,r.mux.deleted=!0,M.emit(s,"destroy")},r.mux.swapElement=function(m){var g=(0,_.findMediaElement)(m),f=R(g,3),c=f[0],x=f[1],S=f[2];return c?S!=="video"&&S!=="audio"?M.log.error("The element of `"+x+"` was not a media element."):(c.muxId=r.muxId,delete r.muxId,c.mux=c.mux||{},c.mux.listeners=(0,L.default)({},r.mux.listeners),delete r.mux.listeners,Object.keys(c.mux.listeners).forEach(function(O){r.removeEventListener(O,c.mux.listeners[O],!1),c.addEventListener(O,c.mux.listeners[O],!1)}),c.mux.swapElement=r.mux.swapElement,c.mux.destroy=r.mux.destroy,delete r.mux,void(r=c)):M.log.error("No element was found with the `"+x+"` query selector.")},r.mux.addHLSJS=function(m){M.addHLSJS(s,m)},r.mux.addDashJS=function(m){M.addDashJS(s,m)},r.mux.removeHLSJS=function(){M.removeHLSJS(s)},r.mux.removeDashJS=function(){M.removeDashJS(s)},M.init(s,b),M.emit(s,"playerready"),r.paused||(M.emit(s,"play"),r.readyState>2&&M.emit(s,"playing")),r.mux.listeners={},E.forEach(function(m){(m!=="error"||b.automaticErrorTracking)&&(r.mux.listeners[m]=function(){var g={};if(m==="error"){if(!r.error||r.error.code===1)return;g.player_error_code=r.error.code,g.player_error_message=I[r.error.code]||r.error.message}M.emit(s,m,g)},r.addEventListener(m,r.mux.listeners[m],!1))})}Object.defineProperty(t,"__esModule",{value:!0});var h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},R=function(){function M(D,b){var A=[],u=!0,r=!1,s=void 0;try{for(var i,a=D[Symbol.iterator]();!(u=(i=a.next()).done)&&(A.push(i.value),!b||A.length!==b);u=!0);}catch(d){r=!0,s=d}finally{try{!u&&a.return&&a.return()}finally{if(r)throw s}}return A}return function(D,b){if(Array.isArray(D))return D;if(Symbol.iterator in Object(D))return M(D,b);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=n;var T=l(1),L=function(M){return M&&M.__esModule?M:{default:M}}(T),_=l(11),E=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],I={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(e,t,l){"use strict";function n(y){return y&&y.__esModule?y:{default:y}}Object.defineProperty(t,"__esModule",{value:!0});var h=l(60),R=n(h),T=l(3),L=n(T),_=l(61),E=n(_),I=l(62),M=n(I),D=l(1),b=n(D),A=l(7),u=n(A),r=l(5),s=l(2),i=n(s),a=l(63),d=n(a),o={};o.safeCall=R.default,o.safeIncrement=L.default,o.getComputedStyle=E.default,o.secondsToMs=M.default,o.assign=b.default,o.headersStringToObject=u.default,o.extractHostnameAndDomain=r.extractHostnameAndDomain,o.extractHostname=r.extractHostname,o.now=i.default.now,o.manifestParser=d.default,t.default=o},function(e,t,l){"use strict";function n(T,L,_,E){var I=E;if(T&&typeof T[L]=="function")try{I=T[L].apply(T,_)}catch(M){R.default.info("safeCall error",M)}return I}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var h=l(4),R=function(T){return T&&T.__esModule?T:{default:T}}(h)},function(e,t,l){"use strict";function n(L,_){if(L&&_&&R.default&&typeof R.default.getComputedStyle=="function"){var E=void 0;return T&&T.has(L)&&(E=T.get(L)),E||(E=R.default.getComputedStyle(L,null),T&&T.set(L,E)),E.getPropertyValue(_)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var h=l(0),R=function(L){return L&&L.__esModule?L:{default:L}}(h),T=void 0;R.default&&R.default.WeakMap&&(T=new WeakMap)},function(e,t,l){"use strict";function n(h){return Math.floor(1e3*h)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,l){"use strict";function n(i){return i&&i.__esModule?i:{default:i}}Object.defineProperty(t,"__esModule",{value:!0});var h=l(1),R=n(h),T=l(14),L=n(T),_={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"},E=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};E.prototype.process=function(i){var a=void 0;for(this.buffer+=i,a=this.buffer.indexOf(`
5
- `);a>-1;a=this.buffer.indexOf(`
6
- `))this.processLine(this.buffer.substring(0,a)),this.buffer=this.buffer.substring(a+1)},E.prototype.processLine=function(i){var a=i.indexOf(":"),d=r(i,a),o=d[0],y=d.length===2?D(d[1]):void 0;if(o[0]!=="#")this.currentUri.uri=o,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(o){case _.TARGET_DURATION:if(!isFinite(y)||y<0)return;this.manifest.targetDuration=y,this.setHoldBack();break;case _.PART_INF:I(this.manifest,d),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:I(this.manifest,d),this.setHoldBack();break;case _.INF:y===0?this.currentUri.duration=.01:y>0&&(this.currentUri.duration=y);break;case _.PROGRAM_DATE_TIME:var p=y,m=new Date(p);this.manifest.dateTimeString||(this.manifest.dateTimeString=p,this.manifest.dateTimeObject=m),this.currentUri.dateTimeString=p,this.currentUri.dateTimeObject=m;break;case _.VERSION:I(this.manifest,d);break;case _.SESSION_DATA:var g=s(d[1]),f=(0,L.default)(g);(0,R.default)(this.manifest.sessionData,f)}},E.prototype.setHoldBack=function(){var i=this.manifest,a=i.serverControl,d=i.targetDuration,o=i.partTargetDuration;if(a){var y="holdBack",p="partHoldBack",m=d&&3*d,g=o&&2*o;d&&!a.hasOwnProperty(y)&&(a[y]=m),m&&a[y]<m&&(a[y]=m),o&&!a.hasOwnProperty(p)&&(a[p]=3*o),o&&a[p]<g&&(a[p]=g)}};var I=function(i,a){var d=M(a[0].replace("#EXT-X-","")),o=void 0;u(a[1])?(o={},o=(0,R.default)(A(a[1]),o)):o=D(a[1]),i[d]=o},M=function(i){return i.toLowerCase().replace(/-(\w)/g,function(a){return a[1].toUpperCase()})},D=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var a=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(a)?i:a},b=function(i){var a={},d=i.split("=");return d.length>1&&(a[M(d[0])]=D(d[1])),a},A=function(i){for(var a=i.split(","),d={},o=0;a.length>o;o++){var y=a[o],p=b(y);d=(0,R.default)(p,d)}return d},u=function(i){return i.indexOf("=")>-1},r=function(i,a){return a===-1?[i]:[i.substring(0,a),i.substring(a+1)]},s=function(i){var a={};if(i){var d=i.search(",");return[i.slice(0,d),i.slice(d+1)].forEach(function(o,y){for(var p=o.replace(/['"]+/g,"").split("="),m=0;m<p.length;m++)p[m]==="DATA-ID"&&(a["DATA-ID"]=p[1-m]),p[m]==="VALUE"&&(a.VALUE=p[1-m])}),{data:a}}};t.default=E},function(e,t,l){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={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"};t.default=n}])})})()});var pr=rn(($t,si)=>{typeof window!="undefined"&&function(e,t){typeof $t=="object"&&typeof si=="object"?si.exports=t():typeof define=="function"&&define.amd?define([],t):typeof $t=="object"?$t.Hls=t():e.Hls=t()}($t,function(){return function(v){var e={};function t(l){if(e[l])return e[l].exports;var n=e[l]={i:l,l:!1,exports:{}};return v[l].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=v,t.c=e,t.d=function(l,n,h){t.o(l,n)||Object.defineProperty(l,n,{enumerable:!0,get:h})},t.r=function(l){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(l,"__esModule",{value:!0})},t.t=function(l,n){if(n&1&&(l=t(l)),n&8||n&4&&typeof l=="object"&&l&&l.__esModule)return l;var h=Object.create(null);if(t.r(h),Object.defineProperty(h,"default",{enumerable:!0,value:l}),n&2&&typeof l!="string")for(var R in l)t.d(h,R,function(T){return l[T]}.bind(null,R));return h},t.n=function(l){var n=l&&l.__esModule?function(){return l.default}:function(){return l};return t.d(n,"a",n),n},t.o=function(l,n){return Object.prototype.hasOwnProperty.call(l,n)},t.p="/dist/",t(t.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(v,e,t){"use strict";var l=Object.prototype.hasOwnProperty,n="~";function h(){}Object.create&&(h.prototype=Object.create(null),new h().__proto__||(n=!1));function R(E,I,M){this.fn=E,this.context=I,this.once=M||!1}function T(E,I,M,D,b){if(typeof M!="function")throw new TypeError("The listener must be a function");var A=new R(M,D||E,b),u=n?n+I:I;return E._events[u]?E._events[u].fn?E._events[u]=[E._events[u],A]:E._events[u].push(A):(E._events[u]=A,E._eventsCount++),E}function L(E,I){--E._eventsCount==0?E._events=new h:delete E._events[I]}function _(){this._events=new h,this._eventsCount=0}_.prototype.eventNames=function(){var I=[],M,D;if(this._eventsCount===0)return I;for(D in M=this._events)l.call(M,D)&&I.push(n?D.slice(1):D);return Object.getOwnPropertySymbols?I.concat(Object.getOwnPropertySymbols(M)):I},_.prototype.listeners=function(I){var M=n?n+I:I,D=this._events[M];if(!D)return[];if(D.fn)return[D.fn];for(var b=0,A=D.length,u=new Array(A);b<A;b++)u[b]=D[b].fn;return u},_.prototype.listenerCount=function(I){var M=n?n+I:I,D=this._events[M];return D?D.fn?1:D.length:0},_.prototype.emit=function(I,M,D,b,A,u){var r=n?n+I:I;if(!this._events[r])return!1;var s=this._events[r],i=arguments.length,a,d;if(s.fn){switch(s.once&&this.removeListener(I,s.fn,void 0,!0),i){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,M),!0;case 3:return s.fn.call(s.context,M,D),!0;case 4:return s.fn.call(s.context,M,D,b),!0;case 5:return s.fn.call(s.context,M,D,b,A),!0;case 6:return s.fn.call(s.context,M,D,b,A,u),!0}for(d=1,a=new Array(i-1);d<i;d++)a[d-1]=arguments[d];s.fn.apply(s.context,a)}else{var o=s.length,y;for(d=0;d<o;d++)switch(s[d].once&&this.removeListener(I,s[d].fn,void 0,!0),i){case 1:s[d].fn.call(s[d].context);break;case 2:s[d].fn.call(s[d].context,M);break;case 3:s[d].fn.call(s[d].context,M,D);break;case 4:s[d].fn.call(s[d].context,M,D,b);break;default:if(!a)for(y=1,a=new Array(i-1);y<i;y++)a[y-1]=arguments[y];s[d].fn.apply(s[d].context,a)}}return!0},_.prototype.on=function(I,M,D){return T(this,I,M,D,!1)},_.prototype.once=function(I,M,D){return T(this,I,M,D,!0)},_.prototype.removeListener=function(I,M,D,b){var A=n?n+I:I;if(!this._events[A])return this;if(!M)return L(this,A),this;var u=this._events[A];if(u.fn)u.fn===M&&(!b||u.once)&&(!D||u.context===D)&&L(this,A);else{for(var r=0,s=[],i=u.length;r<i;r++)(u[r].fn!==M||b&&!u[r].once||D&&u[r].context!==D)&&s.push(u[r]);s.length?this._events[A]=s.length===1?s[0]:s:L(this,A)}return this},_.prototype.removeAllListeners=function(I){var M;return I?(M=n?n+I:I,this._events[M]&&L(this,M)):(this._events=new h,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=n,_.EventEmitter=_,v.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(v,e,t){(function(l){var n=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,h=/^([^\/?#]*)([^]*)$/,R=/(?:\/|^)\.(?=\/)/g,T=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,L={buildAbsoluteURL:function(_,E,I){if(I=I||{},_=_.trim(),E=E.trim(),!E){if(!I.alwaysNormalize)return _;var M=L.parseURL(_);if(!M)throw new Error("Error trying to parse base URL.");return M.path=L.normalizePath(M.path),L.buildURLFromParts(M)}var D=L.parseURL(E);if(!D)throw new Error("Error trying to parse relative URL.");if(D.scheme)return I.alwaysNormalize?(D.path=L.normalizePath(D.path),L.buildURLFromParts(D)):E;var b=L.parseURL(_);if(!b)throw new Error("Error trying to parse base URL.");if(!b.netLoc&&b.path&&b.path[0]!=="/"){var A=h.exec(b.path);b.netLoc=A[1],b.path=A[2]}b.netLoc&&!b.path&&(b.path="/");var u={scheme:b.scheme,netLoc:D.netLoc,path:null,params:D.params,query:D.query,fragment:D.fragment};if(!D.netLoc&&(u.netLoc=b.netLoc,D.path[0]!=="/"))if(!D.path)u.path=b.path,D.params||(u.params=b.params,D.query||(u.query=b.query));else{var r=b.path,s=r.substring(0,r.lastIndexOf("/")+1)+D.path;u.path=L.normalizePath(s)}return u.path===null&&(u.path=I.alwaysNormalize?L.normalizePath(D.path):D.path),L.buildURLFromParts(u)},parseURL:function(_){var E=n.exec(_);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(R,"");_.length!==(_=_.replace(T,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};v.exports=L})(this)},"./node_modules/webworkify-webpack/index.js":function(v,e,t){function l(I){var M={};function D(A){if(M[A])return M[A].exports;var u=M[A]={i:A,l:!1,exports:{}};return I[A].call(u.exports,u,u.exports,D),u.l=!0,u.exports}D.m=I,D.c=M,D.i=function(A){return A},D.d=function(A,u,r){D.o(A,u)||Object.defineProperty(A,u,{configurable:!1,enumerable:!0,get:r})},D.r=function(A){Object.defineProperty(A,"__esModule",{value:!0})},D.n=function(A){var u=A&&A.__esModule?function(){return A.default}:function(){return A};return D.d(u,"a",u),u},D.o=function(A,u){return Object.prototype.hasOwnProperty.call(A,u)},D.p="/",D.oe=function(A){throw console.error(A),A};var b=D(D.s=ENTRY_MODULE);return b.default||b}var n="[\\.|\\-|\\+|\\w|/|@]+",h="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";function R(I){return(I+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function T(I){return!isNaN(1*I)}function L(I,M,D){var b={};b[D]=[];var A=M.toString(),u=A.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return b;for(var r=u[1],s=new RegExp("(\\\\n|\\W)"+R(r)+h,"g"),i;i=s.exec(A);)i[3]!=="dll-reference"&&b[D].push(i[3]);for(s=new RegExp("\\("+R(r)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+h,"g");i=s.exec(A);)I[i[2]]||(b[D].push(i[1]),I[i[2]]=t(i[1]).m),b[i[2]]=b[i[2]]||[],b[i[2]].push(i[4]);for(var a=Object.keys(b),d=0;d<a.length;d++)for(var o=0;o<b[a[d]].length;o++)T(b[a[d]][o])&&(b[a[d]][o]=1*b[a[d]][o]);return b}function _(I){var M=Object.keys(I);return M.reduce(function(D,b){return D||I[b].length>0},!1)}function E(I,M){for(var D={main:[M]},b={main:[]},A={main:{}};_(D);)for(var u=Object.keys(D),r=0;r<u.length;r++){var s=u[r],i=D[s],a=i.pop();if(A[s]=A[s]||{},!(A[s][a]||!I[s][a])){A[s][a]=!0,b[s]=b[s]||[],b[s].push(a);for(var d=L(I,I[s][a],s),o=Object.keys(d),y=0;y<o.length;y++)D[o[y]]=D[o[y]]||[],D[o[y]]=D[o[y]].concat(d[o[y]])}}return b}v.exports=function(I,M){M=M||{};var D={main:t.m},b=M.all?{main:Object.keys(D.main)}:E(D,I),A="";Object.keys(b).filter(function(a){return a!=="main"}).forEach(function(a){for(var d=0;b[a][d];)d++;b[a].push(d),D[a][d]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",A=A+"var "+a+" = ("+l.toString().replace("ENTRY_MODULE",JSON.stringify(d))+")({"+b[a].map(function(o){return""+JSON.stringify(o)+": "+D[a][o].toString()}).join(",")+`});
7
- `}),A=A+"new (("+l.toString().replace("ENTRY_MODULE",JSON.stringify(I))+")({"+b.main.map(function(a){return""+JSON.stringify(a)+": "+D.main[a].toString()}).join(",")+"}))(self);";var u=new window.Blob([A],{type:"text/javascript"});if(M.bare)return u;var r=window.URL||window.webkitURL||window.mozURL||window.msURL,s=r.createObjectURL(u),i=new window.Worker(s);return i.objectURL=s,i}},"./src/config.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"hlsDefaultConfig",function(){return y}),t.d(e,"mergeConfig",function(){return m}),t.d(e,"enableStreamingMode",function(){return g});var l=t("./src/controller/abr-controller.ts"),n=t("./src/controller/audio-stream-controller.ts"),h=t("./src/controller/audio-track-controller.ts"),R=t("./src/controller/subtitle-stream-controller.ts"),T=t("./src/controller/subtitle-track-controller.ts"),L=t("./src/controller/buffer-controller.ts"),_=t("./src/controller/timeline-controller.ts"),E=t("./src/controller/cap-level-controller.ts"),I=t("./src/controller/fps-controller.ts"),M=t("./src/controller/eme-controller.ts"),D=t("./src/controller/cmcd-controller.ts"),b=t("./src/utils/xhr-loader.ts"),A=t("./src/utils/fetch-loader.ts"),u=t("./src/utils/cues.ts"),r=t("./src/utils/mediakeys-helper.ts"),s=t("./src/utils/logger.ts");function i(){return i=Object.assign||function(f){for(var c=1;c<arguments.length;c++){var x=arguments[c];for(var S in x)Object.prototype.hasOwnProperty.call(x,S)&&(f[S]=x[S])}return f},i.apply(this,arguments)}function a(f,c){var x=Object.keys(f);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(f);c&&(S=S.filter(function(O){return Object.getOwnPropertyDescriptor(f,O).enumerable})),x.push.apply(x,S)}return x}function d(f){for(var c=1;c<arguments.length;c++){var x=arguments[c]!=null?arguments[c]:{};c%2?a(Object(x),!0).forEach(function(S){o(f,S,x[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(x)):a(Object(x)).forEach(function(S){Object.defineProperty(f,S,Object.getOwnPropertyDescriptor(x,S))})}return f}function o(f,c,x){return c in f?Object.defineProperty(f,c,{value:x,enumerable:!0,configurable:!0,writable:!0}):f[c]=x,f}var y=d(d({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!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:b.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:l.default,bufferController:L.default,capLevelController:E.default,fpsController:I.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:r.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},p()),{},{subtitleStreamController:R.SubtitleStreamController,subtitleTrackController:T.default,timelineController:_.TimelineController,audioStreamController:n.default,audioTrackController:h.default,emeController:M.default,cmcdController:D.default});function p(){return{cueHandler:u.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function m(f,c){if((c.liveSyncDurationCount||c.liveMaxLatencyDurationCount)&&(c.liveSyncDuration||c.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(c.liveMaxLatencyDurationCount!==void 0&&(c.liveSyncDurationCount===void 0||c.liveMaxLatencyDurationCount<=c.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(c.liveMaxLatencyDuration!==void 0&&(c.liveSyncDuration===void 0||c.liveMaxLatencyDuration<=c.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return i({},f,c)}function g(f){var c=f.loader;if(c!==A.default&&c!==b.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),f.progressive=!1;else{var x=Object(A.fetchSupported)();x&&(f.loader=A.default,f.progressive=!0,f.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/polyfills/number.ts"),n=t("./src/utils/ewma-bandwidth-estimator.ts"),h=t("./src/events.ts"),R=t("./src/utils/buffer-helper.ts"),T=t("./src/errors.ts"),L=t("./src/types/loader.ts"),_=t("./src/utils/logger.ts");function E(D,b){for(var A=0;A<b.length;A++){var u=b[A];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(D,u.key,u)}}function I(D,b,A){return b&&E(D.prototype,b),A&&E(D,A),D}var M=function(){function D(A){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=A;var u=A.config;this.bwEstimator=new n.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var b=D.prototype;return b.registerListeners=function(){var u=this.hls;u.on(h.Events.FRAG_LOADING,this.onFragLoading,this),u.on(h.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(h.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(h.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(h.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var u=this.hls;u.off(h.Events.FRAG_LOADING,this.onFragLoading,this),u.off(h.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(h.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(h.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(h.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},b.onFragLoading=function(u,r){var s=r.frag;if(s.type===L.PlaylistLevelType.MAIN&&!this.timer){var i;this.fragCurrent=s,this.partCurrent=(i=r.part)!=null?i:null,this.timer=self.setInterval(this.onCheck,100)}},b.onLevelLoaded=function(u,r){var s=this.hls.config;r.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},b._abandonRulesCheck=function(){var u=this.fragCurrent,r=this.partCurrent,s=this.hls,i=s.autoLevelEnabled,a=s.config,d=s.media;if(!(!u||!d)){var o=r?r.stats:u.stats,y=r?r.duration:u.duration;if(o.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!i||d.paused||!d.playbackRate||!d.readyState)){var p=performance.now()-o.loading.start,m=Math.abs(d.playbackRate);if(!(p<=500*y/m)){var g=s.levels,f=s.minAutoLevel,c=g[u.level],x=o.total||Math.max(o.loaded,Math.round(y*c.maxBitrate/8)),S=Math.max(1,o.bwEstimate?o.bwEstimate/8:o.loaded*1e3/p),O=(x-o.loaded)/S,C=d.currentTime,P=(R.BufferHelper.bufferInfo(d,C,a.maxBufferHole).end-C)/m;if(!(P>=2*y/m||O<=P)){var w=Number.POSITIVE_INFINITY,U;for(U=u.level-1;U>f;U--){var k=g[U].maxBitrate;if(w=y*k/(8*.8*S),w<P)break}if(!(w>=O)){var N=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+u.sn+(r?" part "+r.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+U+`
8
- Current BW estimate: `+(Object(l.isFiniteNumber)(N)?(N/1024).toFixed(3):"Unknown")+` Kb/s
9
- Estimated load time for current fragment: `+O.toFixed(3)+` s
1
+ (()=>{var Io=Object.create;var gi=Object.defineProperty;var Mo=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var Co=Object.getPrototypeOf,Oo=Object.prototype.hasOwnProperty;var Po=f=>gi(f,"__esModule",{value:!0});var yn=(f,e)=>()=>(e||f((e={exports:{}}).exports,e),e.exports);var ko=(f,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ro(e))!Oo.call(f,a)&&a!=="default"&&gi(f,a,{get:()=>e[a],enumerable:!(t=Mo(e,a))||t.enumerable});return f},_r=f=>ko(Po(gi(f!=null?Io(Co(f)):{},"default",f&&f.__esModule&&"default"in f?{get:()=>f.default,enumerable:!0}:{value:f,enumerable:!0})),f);var Ei=(f,e,t)=>{if(!e.has(f))throw TypeError("Cannot "+t)};var Ve=(f,e,t)=>(Ei(f,e,"read from private field"),t?t.call(f):e.get(f)),$e=(f,e,t)=>{if(e.has(f))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(f):e.set(f,t)},_t=(f,e,t,a)=>(Ei(f,e,"write to private field"),a?a.call(f,t):e.set(f,t),t);var Ne=(f,e,t)=>(Ei(f,e,"access private method"),t);var Tn=yn((xr,yi)=>{(function(){var f=!1;(function(e,t){typeof xr=="object"&&typeof yi=="object"?yi.exports=t():typeof f=="function"&&f.amd?f("mux",[],t):typeof xr=="object"?xr.mux=t():e.mux=t()})(typeof self!="undefined"?self:this,function(){return function(e){function t(i){if(a[i])return a[i].exports;var c=a[i]={i,l:!1,exports:{}};return e[i].call(c.exports,c,c.exports,t),c.l=!0,c.exports}var a={};return t.m=e,t.c=a,t.d=function(i,c,R){t.o(i,c)||Object.defineProperty(i,c,{configurable:!1,enumerable:!0,get:R})},t.n=function(i){var c=i&&i.__esModule?function(){return i.default}:function(){return i};return t.d(c,"a",c),c},t.o=function(i,c){return Object.prototype.hasOwnProperty.call(i,c)},t.p="",t(t.s=18)}([function(e,t,a){(function(i){var c;c=typeof window!="undefined"?window:i!==void 0?i:typeof self!="undefined"?self:{},e.exports=c}).call(t,a(20))},function(e,t){function a(k,N,B){switch(B.length){case 0:return k.call(N);case 1:return k.call(N,B[0]);case 2:return k.call(N,B[0],B[1]);case 3:return k.call(N,B[0],B[1],B[2])}return k.apply(N,B)}function i(k,N){for(var B=-1,K=Array(k);++B<k;)K[B]=N(B);return K}function c(k,N){var B=w(k)||b(k)?i(k.length,String):[],K=B.length,H=!!K;for(var F in k)!N&&!h.call(k,F)||H&&(F=="length"||y(F,K))||B.push(F);return B}function R(k,N,B){var K=k[N];h.call(k,N)&&D(K,B)&&(B!==void 0||N in k)||(k[N]=B)}function E(k){if(!M(k))return C(k);var N=[];for(var B in Object(k))h.call(k,B)&&B!="constructor"&&N.push(B);return N}function L(k,N){return N=O(N===void 0?k.length-1:N,0),function(){for(var B=arguments,K=-1,H=O(B.length-N,0),F=Array(H);++K<H;)F[K]=B[N+K];K=-1;for(var W=Array(N+1);++K<N;)W[K]=B[K];return W[N]=F,a(k,this,W)}}function _(k,N,B,K){B||(B={});for(var H=-1,F=N.length;++H<F;){var W=N[H],Y=K?K(B[W],k[W],W,B,k):void 0;R(B,W,Y===void 0?k[W]:Y)}return B}function y(k,N){return!!(N=N==null?l:N)&&(typeof k=="number"||p.test(k))&&k>-1&&k%1==0&&k<N}function I(k,N,B){if(!n(B))return!1;var K=typeof N;return!!(K=="number"?A(B)&&y(N,B.length):K=="string"&&N in B)&&D(B[N],k)}function M(k){var N=k&&k.constructor;return k===(typeof N=="function"&&N.prototype||v)}function D(k,N){return k===N||k!==k&&N!==N}function b(k){return u(k)&&h.call(k,"callee")&&(!S.call(k,"callee")||x.call(k)==T)}function A(k){return k!=null&&o(k.length)&&!r(k)}function u(k){return s(k)&&A(k)}function r(k){var N=n(k)?x.call(k):"";return N==g||N==m}function o(k){return typeof k=="number"&&k>-1&&k%1==0&&k<=l}function n(k){var N=typeof k;return!!k&&(N=="object"||N=="function")}function s(k){return!!k&&typeof k=="object"}function d(k){return A(k)?c(k):E(k)}var l=9007199254740991,T="[object Arguments]",g="[object Function]",m="[object GeneratorFunction]",p=/^(?:0|[1-9]\d*)$/,v=Object.prototype,h=v.hasOwnProperty,x=v.toString,S=v.propertyIsEnumerable,C=function(k,N){return function(B){return k(N(B))}}(Object.keys,Object),O=Math.max,P=!S.call({valueOf:1},"valueOf"),w=Array.isArray,U=function(k){return L(function(N,B){var K=-1,H=B.length,F=H>1?B[H-1]:void 0,W=H>2?B[2]:void 0;for(F=k.length>3&&typeof F=="function"?(H--,F):void 0,W&&I(B[0],B[1],W)&&(F=H<3?void 0:F,H=1),N=Object(N);++K<H;){var Y=B[K];Y&&k(N,Y,K,F)}return N})}(function(k,N){if(P||M(N)||A(N))return void _(N,d(N),k);for(var B in N)h.call(N,B)&&R(k,B,N[B])});e.exports=U},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(0),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R={};R.now=function(){var E=c.default.performance,L=E&&E.timing;return L&&typeof L.navigationStart=="number"&&typeof E.now=="function"?L.navigationStart+E.now():Date.now()},t.default=R},function(e,t,a){"use strict";function i(c,R,E){E=E===void 0?1:E,c[R]=c[R]||0,c[R]+=E}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(21),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R=c.default.methodFactory;c.default.methodFactory=function(E,L,_){var y=R(E,L,_);return function(){for(var I=["[mux]"],M=0;M<arguments.length;M++)I.push(arguments[M]);y.apply(void 0,I)}},c.default.setLevel(c.default.getLevel()),t.default=c.default},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(E){return R(E)[0]},c=function(E){return R(E)[1]},R=function(E){if(typeof E!="string"||E==="")return["localhost"];var L=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=E.match(L)||[],y=_[4],I=void 0;return y&&(I=(y.match(/[^\.]+\.[^\.]+$/)||[])[0]),[y,I]};t.extractHostnameAndDomain=R,t.extractHostname=i,t.extractDomain=c},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(R){var E=16*Math.random()|0;return(R==="x"?E:3&E|8).toString(16)})},c=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};t.generateUUID=i,t.generateShortID=c},function(e,t,a){"use strict";function i(R){R=R||"";var E={};return R.trim().split(/[\r\n]+/).forEach(function(L){if(L){var _=L.split(": "),y=_.shift();y&&(c.indexOf(y.toLowerCase())>=0||y.toLowerCase().indexOf("x-litix-")===0)&&(E[y]=_.join(": "))}}),E}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var c=["x-cdn","content-type"]},function(e,t,a){"use strict";var i=SyntaxError,c=Function,R=TypeError,E=function(h){try{return c('"use strict"; return ('+h+").constructor;")()}catch{}},L=Object.getOwnPropertyDescriptor;if(L)try{L({},"")}catch{L=null}var _=function(){throw new R},y=L?function(){try{return arguments.callee,_}catch{try{return L(arguments,"callee").get}catch{return _}}}():_,I=a(43)(),M=Object.getPrototypeOf||function(h){return h.__proto__},D={},b=typeof Uint8Array=="undefined"?void 0:M(Uint8Array),A={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":I?M([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":D,"%AsyncGenerator%":D,"%AsyncGeneratorFunction%":D,"%AsyncIteratorPrototype%":D,"%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%":c,"%GeneratorFunction%":D,"%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%":I?M(M([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&I?M(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"&&I?M(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":I?M(""[Symbol.iterator]()):void 0,"%Symbol%":I?Symbol:void 0,"%SyntaxError%":i,"%ThrowTypeError%":y,"%TypedArray%":b,"%TypeError%":R,"%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},u=function h(x){var S;if(x==="%AsyncFunction%")S=E("async function () {}");else if(x==="%GeneratorFunction%")S=E("function* () {}");else if(x==="%AsyncGeneratorFunction%")S=E("async function* () {}");else if(x==="%AsyncGenerator%"){var C=h("%AsyncGeneratorFunction%");C&&(S=C.prototype)}else if(x==="%AsyncIteratorPrototype%"){var O=h("%AsyncGenerator%");O&&(S=M(O.prototype))}return A[x]=S,S},r={"%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"]},o=a(9),n=a(46),s=o.call(Function.call,Array.prototype.concat),d=o.call(Function.apply,Array.prototype.splice),l=o.call(Function.call,String.prototype.replace),T=o.call(Function.call,String.prototype.slice),g=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,m=/\\(\\)?/g,p=function(h){var x=T(h,0,1),S=T(h,-1);if(x==="%"&&S!=="%")throw new i("invalid intrinsic syntax, expected closing `%`");if(S==="%"&&x!=="%")throw new i("invalid intrinsic syntax, expected opening `%`");var C=[];return l(h,g,function(O,P,w,U){C[C.length]=w?l(U,m,"$1"):P||O}),C},v=function(h,x){var S,C=h;if(n(r,C)&&(S=r[C],C="%"+S[0]+"%"),n(A,C)){var O=A[C];if(O===D&&(O=u(C)),O===void 0&&!x)throw new R("intrinsic "+h+" exists, but is not available. Please file an issue!");return{alias:S,name:C,value:O}}throw new i("intrinsic "+h+" does not exist!")};e.exports=function(h,x){if(typeof h!="string"||h.length===0)throw new R("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof x!="boolean")throw new R('"allowMissing" argument must be a boolean');var S=p(h),C=S.length>0?S[0]:"",O=v("%"+C+"%",x),P=O.name,w=O.value,U=!1,k=O.alias;k&&(C=k[0],d(S,s([0,1],k)));for(var N=1,B=!0;N<S.length;N+=1){var K=S[N],H=T(K,0,1),F=T(K,-1);if((H==='"'||H==="'"||H==="`"||F==='"'||F==="'"||F==="`")&&H!==F)throw new i("property names with quotes must have matching quotes");if(K!=="constructor"&&B||(U=!0),C+="."+K,P="%"+C+"%",n(A,P))w=A[P];else if(w!=null){if(!(K in w)){if(!x)throw new R("base intrinsic for "+h+" exists, but the property is not available.");return}if(L&&N+1>=S.length){var W=L(w,K);B=!!W,w=B&&"get"in W&&!("originalValue"in W.get)?W.get:w[K]}else B=n(w,K),w=w[K];B&&!U&&(A[P]=w)}}return w}},function(e,t,a){"use strict";var i=a(45);e.exports=Function.prototype.bind||i},function(e,t,a){"use strict";var i=String.prototype.replace,c=/%20/g,R={RFC1738:"RFC1738",RFC3986:"RFC3986"};e.exports={default:R.RFC3986,formatters:{RFC1738:function(E){return i.call(E,c,"+")},RFC3986:function(E){return String(E)}},RFC1738:R.RFC1738,RFC3986:R.RFC3986}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findMediaElement=t.getMuxPlayerId=void 0;var i=a(6),c=function(E){return E&&E.nodeName!==void 0?(E.muxId||(E.muxId=E.id||(0,i.generateShortID)()),E.muxId):E},R=function(E){var L=void 0;return E&&E.nodeName!==void 0?(L=E,E=c(L)):L=document.querySelector(E),[L,E,L&&L.nodeName?L.nodeName.toLowerCase():""]};t.getMuxPlayerId=c,t.findMediaElement=R},function(e,t,a){"use strict";function i(){return(R.default.doNotTrack||R.default.navigator&&(R.default.navigator.doNotTrack||R.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var c=a(0),R=function(E){return E&&E.__esModule?E:{default:E}}(c)},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(0),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R={};R.exists=function(){var E=c.default.performance;return(E&&E.timing)!==void 0},R.domContentLoadedEventEnd=function(){var E=c.default.performance,L=E&&E.timing;return L&&L.domContentLoadedEventEnd},R.navigationStart=function(){var E=c.default.performance,L=E&&E.timing;return L&&L.navigationStart},t.default=R},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(c){var R={};for(var E in c){var L=c[E];L["DATA-ID"].search("io.litix.data.")!==-1&&(R[L["DATA-ID"].replace("io.litix.data.","")]=L.VALUE)}return R};t.default=i},function(e,t,a){"use strict";var i=a(41),c=a(51),R=a(10);e.exports={formats:R,parse:c,stringify:i}},function(e,t,a){"use strict";var i=a(10),c=Object.prototype.hasOwnProperty,R=Array.isArray,E=function(){for(var n=[],s=0;s<256;++s)n.push("%"+((s<16?"0":"")+s.toString(16)).toUpperCase());return n}(),L=function(n){for(;n.length>1;){var s=n.pop(),d=s.obj[s.prop];if(R(d)){for(var l=[],T=0;T<d.length;++T)d[T]!==void 0&&l.push(d[T]);s.obj[s.prop]=l}}},_=function(n,s){for(var d=s&&s.plainObjects?Object.create(null):{},l=0;l<n.length;++l)n[l]!==void 0&&(d[l]=n[l]);return d},y=function n(s,d,l){if(!d)return s;if(typeof d!="object"){if(R(s))s.push(d);else{if(!s||typeof s!="object")return[s,d];(l&&(l.plainObjects||l.allowPrototypes)||!c.call(Object.prototype,d))&&(s[d]=!0)}return s}if(!s||typeof s!="object")return[s].concat(d);var T=s;return R(s)&&!R(d)&&(T=_(s,l)),R(s)&&R(d)?(d.forEach(function(g,m){if(c.call(s,m)){var p=s[m];p&&typeof p=="object"&&g&&typeof g=="object"?s[m]=n(p,g,l):s.push(g)}else s[m]=g}),s):Object.keys(d).reduce(function(g,m){var p=d[m];return c.call(g,m)?g[m]=n(g[m],p,l):g[m]=p,g},T)},I=function(n,s){return Object.keys(s).reduce(function(d,l){return d[l]=s[l],d},n)},M=function(n,s,d){var l=n.replace(/\+/g," ");if(d==="iso-8859-1")return l.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(l)}catch{return l}},D=function(n,s,d,l,T){if(n.length===0)return n;var g=n;if(typeof n=="symbol"?g=Symbol.prototype.toString.call(n):typeof n!="string"&&(g=String(n)),d==="iso-8859-1")return escape(g).replace(/%u[0-9a-f]{4}/gi,function(h){return"%26%23"+parseInt(h.slice(2),16)+"%3B"});for(var m="",p=0;p<g.length;++p){var v=g.charCodeAt(p);v===45||v===46||v===95||v===126||v>=48&&v<=57||v>=65&&v<=90||v>=97&&v<=122||T===i.RFC1738&&(v===40||v===41)?m+=g.charAt(p):v<128?m+=E[v]:v<2048?m+=E[192|v>>6]+E[128|63&v]:v<55296||v>=57344?m+=E[224|v>>12]+E[128|v>>6&63]+E[128|63&v]:(p+=1,v=65536+((1023&v)<<10|1023&g.charCodeAt(p)),m+=E[240|v>>18]+E[128|v>>12&63]+E[128|v>>6&63]+E[128|63&v])}return m},b=function(n){for(var s=[{obj:{o:n},prop:"o"}],d=[],l=0;l<s.length;++l)for(var T=s[l],g=T.obj[T.prop],m=Object.keys(g),p=0;p<m.length;++p){var v=m[p],h=g[v];typeof h=="object"&&h!==null&&d.indexOf(h)===-1&&(s.push({obj:g,prop:v}),d.push(h))}return L(s),n},A=function(n){return Object.prototype.toString.call(n)==="[object RegExp]"},u=function(n){return!(!n||typeof n!="object")&&!!(n.constructor&&n.constructor.isBuffer&&n.constructor.isBuffer(n))},r=function(n,s){return[].concat(n,s)},o=function(n,s){if(R(n)){for(var d=[],l=0;l<n.length;l+=1)d.push(s(n[l]));return d}return s(n)};e.exports={arrayToObject:_,assign:I,combine:r,compact:b,decode:M,encode:D,isBuffer:u,isRegExp:A,maybeMap:o,merge:y}},function(e,t,a){"use strict";function i(A){return A&&A.__esModule?A:{default:A}}function c(A){var u={};for(var r in A)A.hasOwnProperty(r)&&(u[A[r]]=r);return u}function R(A){var u={},r={};return Object.keys(A).forEach(function(o){var n=!1;if(A.hasOwnProperty(o)&&A[o]!==void 0){var s=o.split("_"),d=s[0],l=M[d];l||(L.default.info("Data key word `"+s[0]+"` not expected in "+o),l=d+"_"),s.splice(1).forEach(function(T){T==="url"&&(n=!0),b[T]?l+=b[T]:Number(T)&&Math.floor(Number(T))===Number(T)?l+=T:(L.default.info("Data key word `"+T+"` not expected in "+o),l+="_"+T+"_")}),n?r[l]=A[o]:u[l]=A[o]}}),(0,y.default)(u,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=R;var E=a(4),L=i(E),_=a(1),y=i(_),I={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"},M=c(I),D={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"},b=c(D)},function(e,t,a){"use strict";e.exports=a(19).default},function(e,t,a){"use strict";function i(m){return m&&m.__esModule?m:{default:m}}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function m(p,v){var h=[],x=!0,S=!1,C=void 0;try{for(var O,P=p[Symbol.iterator]();!(x=(O=P.next()).done)&&(h.push(O.value),!v||h.length!==v);x=!0);}catch(w){S=!0,C=w}finally{try{!x&&P.return&&P.return()}finally{if(S)throw C}}return h}return function(p,v){if(Array.isArray(p))return p;if(Symbol.iterator in Object(p))return m(p,v);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),R=a(0),E=i(R),L=a(11),_=a(4),y=i(_),I=a(12),M=i(I),D=a(2),b=i(D),A=a(22),u=i(A),r=a(58),o=i(r),n=a(59),s=i(n),d=a(64),l=i(d),T={},g=function m(p){var v=arguments;typeof p=="string"?m.hasOwnProperty(p)?E.default.setTimeout(function(){v=Array.prototype.splice.call(v,1),m[p].apply(null,v)},0):y.default.warn("`"+p+"` is an unknown task"):typeof p=="function"?E.default.setTimeout(function(){p(m)},0):y.default.warn("`"+p+"` is invalid.")};g.loaded=b.default.now(),g.NAME="mux-embed",g.VERSION="4.8.0",g.API_VERSION="2.1",g.PLAYER_TRACKED=!1,g.monitor=function(m,p){return(0,o.default)(g,m,p)},g.destroyMonitor=function(m){var p=(0,L.findMediaElement)(m),v=c(p,1),h=v[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():y.default.error("A video element monitor for `"+m+"` has not been initialized via `mux.monitor`.")},g.addHLSJS=function(m,p){var v=(0,L.getMuxPlayerId)(m);T[v]?T[v].addHLSJS(p):y.default.error("A monitor for `"+v+"` has not been initialized.")},g.addDashJS=function(m,p){var v=(0,L.getMuxPlayerId)(m);T[v]?T[v].addDashJS(p):y.default.error("A monitor for `"+v+"` has not been initialized.")},g.removeHLSJS=function(m){var p=(0,L.getMuxPlayerId)(m);T[p]?T[p].removeHLSJS():y.default.error("A monitor for `"+p+"` has not been initialized.")},g.removeDashJS=function(m){var p=(0,L.getMuxPlayerId)(m);T[p]?T[p].removeDashJS():y.default.error("A monitor for `"+p+"` has not been initialized.")},g.init=function(m,p){(0,M.default)()&&p&&p.respectDoNotTrack&&y.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var v=(0,L.getMuxPlayerId)(m);T[v]=new u.default(g,v,p)},g.emit=function(m,p,v){var h=(0,L.getMuxPlayerId)(m);T[h]?(T[h].emit(p,v),p==="destroy"&&delete T[h]):y.default.error("A monitor for `"+h+"` has not been initialized.")},E.default!==void 0&&typeof E.default.addEventListener=="function"&&E.default.addEventListener("pagehide",function(m){m.persisted||(g.WINDOW_UNLOADING=!0)},!1),g.checkDoNotTrack=M.default,g.log=y.default,g.utils=s.default,g.events=l.default,t.default=g},function(e,t){var a;a=function(){return this}();try{a=a||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(a=window)}e.exports=a},function(e,t,a){var i,c;(function(R,E){"use strict";i=E,(c=typeof i=="function"?i.call(t,a,t,e):i)!==void 0&&(e.exports=c)})(0,function(){"use strict";function R(s,d){var l=s[d];if(typeof l.bind=="function")return l.bind(s);try{return Function.prototype.bind.call(l,s)}catch{return function(){return Function.prototype.apply.apply(l,[s,arguments])}}}function E(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function L(s){return s==="debug"&&(s="log"),typeof console!==b&&(s==="trace"&&A?E:console[s]!==void 0?R(console,s):console.log!==void 0?R(console,"log"):D)}function _(s,d){for(var l=0;l<u.length;l++){var T=u[l];this[T]=l<s?D:this.methodFactory(T,s,d)}this.log=this.debug}function y(s,d,l){return function(){typeof console!==b&&(_.call(this,d,l),this[s].apply(this,arguments))}}function I(s,d,l){return L(s)||y.apply(this,arguments)}function M(s,d,l){function T(S){var C=(u[S]||"silent").toUpperCase();if(typeof window!==b&&h){try{return void(window.localStorage[h]=C)}catch{}try{window.document.cookie=encodeURIComponent(h)+"="+C+";"}catch{}}}function g(){var S;if(typeof window!==b&&h){try{S=window.localStorage[h]}catch{}if(typeof S===b)try{var C=window.document.cookie,O=C.indexOf(encodeURIComponent(h)+"=");O!==-1&&(S=/^([^;]+)/.exec(C.slice(O))[1])}catch{}return v.levels[S]===void 0&&(S=void 0),S}}function m(){if(typeof window!==b&&h){try{return void window.localStorage.removeItem(h)}catch{}try{window.document.cookie=encodeURIComponent(h)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var p,v=this;d=d==null?"WARN":d;var h="loglevel";typeof s=="string"?h+=":"+s:typeof s=="symbol"&&(h=void 0),v.name=s,v.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},v.methodFactory=l||I,v.getLevel=function(){return p},v.setLevel=function(S,C){if(typeof S=="string"&&v.levels[S.toUpperCase()]!==void 0&&(S=v.levels[S.toUpperCase()]),!(typeof S=="number"&&S>=0&&S<=v.levels.SILENT))throw"log.setLevel() called with invalid level: "+S;if(p=S,C!==!1&&T(S),_.call(v,S,s),typeof console===b&&S<v.levels.SILENT)return"No console available for logging"},v.setDefaultLevel=function(S){d=S,g()||v.setLevel(S,!1)},v.resetLevel=function(){v.setLevel(d,!1),m()},v.enableAll=function(S){v.setLevel(v.levels.TRACE,S)},v.disableAll=function(S){v.setLevel(v.levels.SILENT,S)};var x=g();x==null&&(x=d),v.setLevel(x,!1)}var D=function(){},b="undefined",A=typeof window!==b&&typeof window.navigator!==b&&/Trident\/|MSIE /.test(window.navigator.userAgent),u=["trace","debug","info","warn","error"],r=new M,o={};r.getLogger=function(s){if(typeof s!="symbol"&&typeof s!="string"||s==="")throw new TypeError("You must supply a name when creating a logger.");var d=o[s];return d||(d=o[s]=new M(s,r.getLevel(),r.methodFactory)),d};var n=typeof window!==b?window.log:void 0;return r.noConflict=function(){return typeof window!==b&&window.log===r&&(window.log=n),r},r.getLoggers=function(){return o},r.default=r,r})},function(e,t,a){"use strict";function i(Z){return Z&&Z.__esModule?Z:{default:Z}}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function Z(te,ee){var he=[],xe=!0,ge=!1,Ae=void 0;try{for(var Me,Be=te[Symbol.iterator]();!(xe=(Me=Be.next()).done)&&(he.push(Me.value),!ee||he.length!==ee);xe=!0);}catch(Ee){ge=!0,Ae=Ee}finally{try{!xe&&Be.return&&Be.return()}finally{if(ge)throw Ae}}return he}return function(te,ee){if(Array.isArray(te))return te;if(Symbol.iterator in Object(te))return Z(te,ee);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),R=a(4),E=i(R),L=a(1),_=i(L),y=a(6),I=a(5),M=a(0),D=i(M),b=a(13),A=i(b),u=a(3),r=i(u),o=a(23),n=a(24),s=a(25),d=i(s),l=a(26),T=i(l),g=a(27),m=i(g),p=a(28),v=i(p),h=a(29),x=i(h),S=a(30),C=i(S),O=a(31),P=i(O),w=a(32),U=i(w),k=a(33),N=i(k),B=a(34),K=i(B),H=a(35),F=i(H),W=a(36),Y=i(W),$=a(37),J=i($),q=a(38),oe=i(q),X=a(39),ie=i(X),fe=a(57),ue=i(fe),_e=["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"],re=function(Z,te,ee){var he=this;this.DOM_CONTENT_LOADED_EVENT_END=A.default.domContentLoadedEventEnd(),this.NAVIGATION_START=A.default.navigationStart();var xe={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(Ee){return Ee}};this.mux=Z,this.id=te,ee=(0,_.default)(xe,ee),ee.data=ee.data||{},ee.data.property_key&&(ee.data.env_key=ee.data.property_key,delete ee.data.property_key),E.default.setLevel(ee.debug?"debug":"warn"),this.getPlayheadTime=ee.getPlayheadTime,this.getStateData=ee.getStateData||function(){},this.getAdData=ee.getAdData||function(){},this.minimumRebufferDuration=ee.minimumRebufferDuration,this.sustainedRebufferThreshold=ee.sustainedRebufferThreshold,this.playbackHeartbeatTime=ee.playbackHeartbeatTime,this.disableRebufferTracking=ee.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=ee.errorTranslator,this.playbackEventDispatcher=new ie.default(Z,ee.data.env_key,ee),this.data={player_instance_id:(0,y.generateUUID)(),mux_sample_rate:ee.sampleRate,beacon_domain:ee.beaconCollectionDomain?ee.beaconCollectionDomain:ee.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(Ee,ye){ye=(0,_.default)({viewer_time:this.mux.utils.now()},ye),this.oldEmit(Ee,ye)};var ge=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(Ee,ye){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,ye),this._initializeViewData(),this.one("play",ge),this.one("adbreakstart",ge)});var Ae=function(Ee){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",Ee)}.bind(this);if(this.on("videochange",function(Ee,ye){Ae(ye)}),this.on("programchange",function(Ee,ye){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."),Ae((0,_.default)(ye,{view_program_changed:!0})),ge(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(Ee,ye){this.currentFragmentPDT=ye.currentFragmentPDT,this.currentFragmentStart=ye.currentFragmentStart}),this.on("destroy",this.destroy),D.default!==void 0&&typeof D.default.addEventListener=="function"&&typeof D.default.removeEventListener=="function"){var Me=function(Ee){Ee.persisted||he.destroy()};D.default.addEventListener("pagehide",Me,!1),this.on("destroy",function(){D.default.removeEventListener("pagehide",Me)})}this.on("playerready",function(Ee,ye){(0,_.default)(this.data,ye)}),_e.forEach(function(Ee){he.on(Ee,function(ye,Fe){Ee.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,Fe),this._sanitizeData()}),he.on("after"+Ee,function(){(Ee!=="error"||this.viewErrored)&&this.send(Ee)})}),this.on("viewend",function(Ee,ye){(0,_.default)(he.data,ye)});var Be=function(Ee){var ye=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ye-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",Be),m.default.apply(this),oe.default.apply(this),F.default.apply(this),C.default.apply(this),T.default.apply(this),K.default.apply(this),v.default.apply(this),x.default.apply(this),Y.default.apply(this),P.default.apply(this),U.default.apply(this),N.default.apply(this),J.default.apply(this),ue.default.apply(this),ee.hlsjs&&this.addHLSJS(ee),ee.dashjs&&this.addDashJS(ee),this.emit("viewinit",ee.data)};(0,_.default)(re.prototype,d.default.prototype),(0,_.default)(re.prototype,C.default.prototype),(0,_.default)(re.prototype,F.default.prototype),(0,_.default)(re.prototype,T.default.prototype),(0,_.default)(re.prototype,v.default.prototype),(0,_.default)(re.prototype,x.default.prototype),(0,_.default)(re.prototype,Y.default.prototype),(0,_.default)(re.prototype,U.default.prototype),(0,_.default)(re.prototype,N.default.prototype),re.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(),D.default.clearTimeout(this._heartBeatTimeout))},re.prototype.send=function(Z){var te=(0,_.default)({},this.data),ee=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(te.video_source_is_live===void 0&&(te.player_source_duration===1/0||te.video_source_duration===1/0?te.video_source_is_live=!0:(te.player_source_duration>0||te.video_source_duration>0)&&(te.video_source_is_live=!1)),te.video_source_is_live||ee.forEach(function(Me){te[Me]=void 0}),te.video_source_url=te.video_source_url||te.player_source_url,te.video_source_url){var he=(0,I.extractHostnameAndDomain)(te.video_source_url),xe=c(he,2),ge=xe[0],Ae=xe[1];te.video_source_domain=Ae,te.video_source_hostname=ge}delete te.ad_request_id,this.playbackEventDispatcher.send(Z,te),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},re.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},re.prototype._sanitizeData=function(){var Z=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(te){var ee=parseInt(Z.data[te],10);Z.data[te]=isNaN(ee)?void 0:ee}),["player_source_url","video_source_url"].forEach(function(te){if(Z.data[te]){var ee=Z.data[te].toLowerCase();ee.indexOf("data:")!==0&&ee.indexOf("blob:")!==0||(Z.data[te]="MSE style URL")}})},re.prototype._resetVideoData=function(Z,te){var ee=this;Object.keys(this.data).forEach(function(he){he.indexOf("video_")===0&&delete ee.data[he]})},re.prototype._resetViewData=function(){var Z=this;Object.keys(this.data).forEach(function(te){te.indexOf("view_")===0&&delete Z.data[te]}),this.data.view_sequence_number=1},re.prototype._resetErrorData=function(Z,te){delete this.data.player_error_code,delete this.data.player_error_message},re.prototype._initializeViewData=function(){var Z=this,te=this.data.view_id=(0,y.generateUUID)(),ee=function(){te===Z.data.view_id&&(0,r.default)(Z.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",ee):ee()},re.prototype._restartHeartBeat=function(){var Z=this;D.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=D.default.setTimeout(function(){Z.data.player_is_paused||Z.emit("hb")},1e4))},re.prototype.addHLSJS=function(Z){return Z.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=Z.hlsjs,void(0,o.monitorHlsJs)(this.mux,this.id,Z.hlsjs,{},Z.Hls||D.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},re.prototype.removeHLSJS=function(){this.hlsjs&&((0,o.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},re.prototype.addDashJS=function(Z){return Z.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=Z.dashjs,void(0,n.monitorDashJS)(this.mux,this.id,Z.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},re.prototype.removeDashJS=function(){this.dashjs&&((0,n.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},t.default=re},function(e,t,a){"use strict";function i(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(t,"__esModule",{value:!0}),t.stopMonitoringHlsJs=t.monitorHlsJs=void 0;var c=a(7),R=i(c),E=a(13),L=i(E),_=a(5),y=a(14),I=i(y),M=function(u){if(!u)return{};var r=L.default.navigationStart(),o=u.loading,n=o?o.start:u.trequest,s=o?o.first:u.tfirst,d=o?o.end:u.tload;return{bytesLoaded:u.total,requestStart:Math.round(r+n),responseStart:Math.round(r+s),responseEnd:Math.round(r+d)}},D=function(u){if(u&&typeof u.getAllResponseHeaders=="function")return(0,R.default)(u.getAllResponseHeaders())},b=function(u,r,o){var n=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),s=u.log,d=u.utils.secondsToMs,l=function(O){var P=parseInt(n.version),w=void 0;return P===1&&O.programDateTime!==null&&(w=O.programDateTime),P===0&&O.pdt!==null&&(w=O.pdt),w};if(!L.default.exists())return void s.warn("performance timing not supported. Not tracking HLS.js.");var T=function(O,P){return u.emit(r,O,P)},g=function(O,P){var w=P.levels,U=P.audioTracks,k=P.url,N=P.stats,B=P.networkDetails,K=P.sessionData,H={},F={},W={};W=(0,I.default)(K),w.forEach(function(X,ie){H[ie]={width:X.width,height:X.height,bitrate:X.bitrate,attrs:X.attrs}}),U.forEach(function(X,ie){F[ie]={name:X.name,language:X.lang,bitrate:X.bitrate}});var Y=M(N),$=Y.bytesLoaded,J=Y.requestStart,q=Y.responseStart,oe=Y.responseEnd;W.request_event_type=O,W.request_bytes_loaded=$,W.request_start=J,W.request_response_start=q,W.request_response_end=oe,W.request_type="manifest",W.request_hostname=(0,_.extractHostname)(k),W.request_response_headers=D(B),W.request_rendition_lists={media:H,audio:F,video:{}},T("requestcompleted",W)};o.on(n.Events.MANIFEST_LOADED,g);var m=function(O,P){var w=P.details,U=P.level,k=P.networkDetails,N=P.stats,B=M(N),K=B.bytesLoaded,H=B.requestStart,F=B.responseStart,W=B.responseEnd,Y=w.fragments[w.fragments.length-1],$=l(Y)+d(Y.duration);T("requestcompleted",{request_event_type:O,request_bytes_loaded:K,request_start:H,request_response_start:F,request_response_end:W,request_current_level:U,request_type:"manifest",request_hostname:(0,_.extractHostname)(w.url),request_response_headers:D(k),video_holdback:w.holdBack&&d(w.holdBack),video_part_holdback:w.partHoldBack&&d(w.partHoldBack),video_part_target_duration:w.partTarget&&d(w.partTarget),video_target_duration:w.targetduration&&d(w.targetduration),video_source_is_live:w.live,player_manifest_newest_program_time:isNaN($)?void 0:$})};o.on(n.Events.LEVEL_LOADED,m);var p=function(O,P){var w=P.details,U=P.networkDetails,k=P.stats,N=M(k),B=N.bytesLoaded,K=N.requestStart,H=N.responseStart,F=N.responseEnd;T("requestcompleted",{request_event_type:O,request_bytes_loaded:B,request_start:K,request_response_start:H,request_response_end:F,request_type:"manifest",request_hostname:(0,_.extractHostname)(w.url),request_response_headers:D(U)})};o.on(n.Events.AUDIO_TRACK_LOADED,p);var v=function(O,P){var w=P.stats,U=P.networkDetails,k=P.frag,N=M(w),B=N.bytesLoaded,K=N.requestStart,H=N.responseStart,F=N.responseEnd,W={request_event_type:O,request_bytes_loaded:B,request_start:K,request_response_start:H,request_response_end:F,request_hostname:U?(0,_.extractHostname)(U.responseURL):void 0,request_response_headers:D(U),request_media_duration:k.duration};k.type==="main"?(W.request_type="media",W.request_current_level=k.level,W.request_video_width=(o.levels[k.level]||{}).width,W.request_video_height=(o.levels[k.level]||{}).height):W.request_type=k.type,T("requestcompleted",W)};o.on(n.Events.FRAG_LOADED,v);var h=function(O,P){var w=P.frag,U=w.start,k=l(w),N={currentFragmentPDT:k,currentFragmentStart:d(U)};T("fragmentchange",N)};o.on(n.Events.FRAG_CHANGED,h);var x=function(O,P){var w=P.type,U=P.details,k=P.response,N=P.fatal,B=P.context,K=P.frag;if(U===n.ErrorDetails.MANIFEST_LOAD_ERROR||U===n.ErrorDetails.MANIFEST_LOAD_TIMEOUT||U===n.ErrorDetails.FRAG_LOAD_ERROR||U===n.ErrorDetails.FRAG_LOAD_TIMEOUT||U===n.ErrorDetails.LEVEL_LOAD_ERROR||U===n.ErrorDetails.LEVEL_LOAD_TIMEOUT){var H=K&&K.url||B&&B.url||"";T("requestfailed",{request_error:U,request_url:H,request_hostname:(0,_.extractHostname)(H),request_type:U===n.ErrorDetails.FRAG_LOAD_ERROR||U===n.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:k&&k.code,request_error_text:k&&k.text})}N&&T("error",{player_error_code:w,player_error_message:U})};o.on(n.Events.ERROR,x);var S=function(O,P){var w=P.frag,U=w&&w._url||"";T("requestcanceled",{request_cancel:O,request_url:U,request_type:"media",request_hostname:(0,_.extractHostname)(U)})};o.on(n.Events.FRAG_LOAD_EMERGENCY_ABORTED,S);var C=function(O,P){var w=P.level,U=o.levels[w];if(U&&U.attrs&&U.attrs.BANDWIDTH){var k=U.attrs.BANDWIDTH;k?T("renditionchange",{video_source_bitrate:k,video_source_width:U.width,video_source_height:U.height}):s.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};o.on(n.Events.LEVEL_SWITCHED,C),o._stopMuxMonitor=function(){o.off(n.Events.MANIFEST_LOADED,g),o.off(n.Events.LEVEL_LOADED,m),o.off(n.Events.AUDIO_TRACK_LOADED,p),o.off(n.Events.FRAG_LOADED,v),o.off(n.Events.FRAG_CHANGED,h),o.off(n.Events.ERROR,x),o.off(n.Events.FRAG_LOAD_EMERGENCY_ABORTED,S),o.off(n.Events.LEVEL_SWITCHED,C),o.off(n.Events.DESTROYING,o._stopMuxMonitor),delete o._stopMuxMonitor},o.on(n.Events.DESTROYING,o._stopMuxMonitor)},A=function(u){u&&typeof u._stopMuxMonitor=="function"&&u._stopMuxMonitor()};t.monitorHlsJs=b,t.stopMonitoringHlsJs=A},function(e,t,a){"use strict";function i(b){return b&&b.__esModule?b:{default:b}}Object.defineProperty(t,"__esModule",{value:!0}),t.stopMonitoringDashJS=t.monitorDashJS=void 0;var c=a(0),R=i(c),E=a(7),L=i(E),_=a(5),y=function(b,A){if(!b||typeof b.getRequests!="function")return{};var u=b.getRequests({state:"executed"});if(u.length===0)return{};var r=u[u.length-1],o=(0,_.extractHostname)(r.url),n=r.bytesLoaded,s=new Date(r.requestStartDate).getTime(),d=new Date(r.firstByteDate).getTime(),l=new Date(r.requestEndDate).getTime(),T=isNaN(r.duration)?0:r.duration,g=typeof A.getMetricsFor=="function"?A.getMetricsFor(r.mediaType).HttpList:A.getDashMetrics().getHttpRequests(r.mediaType),m=void 0;return g.length>0&&(m=(0,L.default)(g[g.length-1]._responseHeaders||"")),{requestStart:s,requestResponseStart:d,requestResponseEnd:l,requestBytesLoaded:n,requestResponseHeaders:m,requestMediaDuration:T,requestHostname:o}},I=function(b,A){var u=A.getQualityFor(b),r=A.getCurrentTrackFor(b),o=r.bitrateList;return o?{currentLevel:u,renditionWidth:o[u].width||null,renditionHeight:o[u].height||null,renditionBitrate:o[u].bandwidth}:{}},M=function(b,A,u){var r=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],b.log);if(!u||!u.on)return void r.warn("Invalid dash.js player reference. Monitoring blocked.");var o=function(v,h){return b.emit(A,v,h)},n=function(v){var h=v.type,x=v.data,S=x||{},C=S.url;o("requestcompleted",{request_event_type:h,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,_.extractHostname)(C)})};u.on("manifestLoaded",n);var s={},d=function(v){var h=v.type,x=v.fragmentModel,S=v.chunk,C=S||{},O=C.mediaInfo,P=O||{},w=P.type,U=P.bitrateList;U=U||[];var k={};U.forEach(function($,J){k[J]={},k[J].width=$.width,k[J].height=$.height,k[J].bitrate=$.bandwidth,k[J].attrs={}}),w==="video"?s.video=k:w==="audio"?s.audio=k:s.media=k;var N=y(x,u),B=N.requestStart,K=N.requestResponseStart,H=N.requestResponseEnd,F=N.requestResponseHeaders,W=N.requestMediaDuration,Y=N.requestHostname;o("requestcompleted",{request_event_type:h,request_start:B,request_response_start:K,request_response_end:H,request_bytes_loaded:-1,request_type:w+"_init",request_response_headers:F,request_hostname:Y,request_media_duration:W,request_rendition_lists:s})};u.on("initFragmentLoaded",d);var l=function(v){var h=v.type,x=v.fragmentModel,S=v.chunk,C=S||{},O=C.mediaInfo,P=C.start,w=O||{},U=w.type,k=y(x,u),N=k.requestStart,B=k.requestResponseStart,K=k.requestResponseEnd,H=k.requestBytesLoaded,F=k.requestResponseHeaders,W=k.requestMediaDuration,Y=k.requestHostname,$=I(U,u),J=$.currentLevel,q=$.renditionWidth,oe=$.renditionHeight,X=$.renditionBitrate;o("requestcompleted",{request_event_type:h,request_start:N,request_response_start:B,request_response_end:K,request_bytes_loaded:H,request_type:U,request_response_headers:F,request_hostname:Y,request_media_start_time:P,request_media_duration:W,request_current_level:J,request_labeled_bitrate:X,request_video_width:q,request_video_height:oe})};u.on("mediaFragmentLoaded",l);var T={video:void 0,audio:void 0,totalBitrate:void 0},g=function(){if(T.video&&typeof T.video.bitrate=="number"){if(!T.video.width||!T.video.height)return void r.warn("have bitrate info for video but missing width/height");var v=T.video.bitrate;return T.audio&&typeof T.audio.bitrate=="number"&&(v+=T.audio.bitrate),v!==T.totalBitrate?(T.totalBitrate=v,{video_source_bitrate:v,video_source_height:T.video.height,video_source_width:T.video.width}):void 0}},m=function(v,h,x){if(typeof v.newQuality!="number")return void r.warn("missing evt.newQuality in qualityChangeRendered event",v);var S=v.mediaType;if(S==="audio"||S==="video"){var C=u.getBitrateInfoListFor(S).find(function(P){return P.qualityIndex===v.newQuality});if(!C||typeof C.bitrate!="number")return void r.warn("missing bitrate info for "+S);T[S]=C;var O=g();O&&o("renditionchange",O)}};u.on("qualityChangeRendered",m);var p=function(v){var h=v.error,x=v.event;x=x||{};var S=x.request||{},C=R.default.event&&R.default.event.currentTarget||{};o("requestfailed",{request_error:h+"_"+x.id+"_"+S.type,request_url:x.url,request_hostname:(0,_.extractHostname)(x.url),request_type:S.mediaType,request_error_code:C.status,request_error_type:C.statusText})};u.on("error",p),u._stopMuxMonitor=function(){u.off("manifestLoaded",n),u.off("initFragmentLoaded",d),u.off("mediaFragmentLoaded",l),u.off("qualityChangeRendered",m),u.off("error",p),delete u._stopMuxMonitor}},D=function(b){b&&typeof b._stopMuxMonitor=="function"&&b._stopMuxMonitor()};t.monitorDashJS=M,t.stopMonitoringDashJS=D},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){},c=0;i.prototype.on=function(R,E,L){return E._eventEmitterGuid=E._eventEmitterGuid||++c,this._listeners=this._listeners||{},this._listeners[R]=this._listeners[R]||[],L&&(E=E.bind(L)),this._listeners[R].push(E),E},i.prototype.off=function(R,E){var L=this._listeners&&this._listeners[R];L&&L.forEach(function(_,y){_._eventEmitterGuid===E._eventEmitterGuid&&L.splice(y,1)})},i.prototype.one=function(R,E,L){var _=this;E._eventEmitterGuid=E._eventEmitterGuid||++c;var y=function I(){_.off(R,I),E.apply(L||this,arguments)};y._eventEmitterGuid=E._eventEmitterGuid,this.on(R,y)},i.prototype.emit=function(R,E){var L=this;if(this._listeners){E=E||{};var _=this._listeners["before*"]||[],y=this._listeners[R]||[],I=this._listeners["after"+R]||[],M=function(D,b){D=D.slice(),D.forEach(function(A){A.call(L,{type:R},b)})};M(_,E),M(y,E),M(I,E)}},t.default=i},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(0),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R=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(E,L){this._playbackHeartbeatInterval!==null&&(c.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:L.viewer_time}),this._playbackHeartbeatInterval=null)})};R.prototype._startPlaybackHeartbeatInterval=function(){var E=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=c.default.setInterval(function(){E.emit("playbackheartbeat")},this.playbackHeartbeatTime))},R.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(c.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},t.default=R},function(e,t,a){"use strict";function i(){var c=this;this.on("viewinit",function(){c.viewErrored=!1}),this.on("error",function(){try{var R=c.errorTranslator({player_error_code:c.data.player_error_code,player_error_message:c.data.player_error_message});R?(c.data.player_error_code=R.player_error_code,c.data.player_error_message=R.player_error_message,c.viewErrored=!0):(delete c.data.player_error_code,delete c.data.player_error_message)}catch(E){c.mux.log.warn("Exception in error translator callback.",E),c.viewErrored=!0}})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(3),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};R.prototype._updateWatchTime=function(E,L){var _=L.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,c.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},R.prototype._clearWatchTimeState=function(E,L){this._updateWatchTime(E,L),this._watchTimeTrackerLastCheckedTime=null},t.default=R},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(3),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R=function(){this._playbackTimeTrackerLastPlayheadPosition=-1,this.on("playbackheartbeat",this._updatePlaybackTime),this.on("playbackheartbeatend",this._clearPlaybackTimeState),this.on("seeking",this._clearPlaybackTimeState)};R.prototype._updatePlaybackTime=function(){var E=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&E>this._playbackTimeTrackerLastPlayheadPosition){var L=E-this._playbackTimeTrackerLastPlayheadPosition;L<=1e3&&(0,c.default)(this.data,"view_content_playback_time",L)}this._playbackTimeTrackerLastPlayheadPosition=E},R.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},t.default=R},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=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)})};i.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)},i.prototype._updatePlayheadTime=function(c,R){var E=this,L=function(){E.currentFragmentPDT&&E.currentFragmentStart&&(E.data.player_program_time=E.currentFragmentPDT+E.data.player_playhead_time-E.currentFragmentStart)};if(R&&R.player_playhead_time)this.data.player_playhead_time=R.player_playhead_time,L(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,L(),this._updateMaxPlayheadPosition())}},t.default=i},function(e,t,a){"use strict";function i(){var E=this;if(!this.disableRebufferTracking){var L=void 0,_=function(){if(L){var y=E.data.viewer_time-L;(0,R.default)(E.data,"view_rebuffer_duration",y),L=E.data.viewer_time}E.data.view_watch_time>=0&&E.data.view_rebuffer_count>0&&(E.data.view_rebuffer_frequency=E.data.view_rebuffer_count/E.data.view_watch_time,E.data.view_rebuffer_percentage=E.data.view_rebuffer_duration/E.data.view_watch_time)};this.on("playbackheartbeat",function(){return _()}),this.on("rebufferstart",function(){L||((0,R.default)(E.data,"view_rebuffer_count",1),L=E.data.viewer_time,E.one("rebufferend",function(){_(),L=void 0}))})}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var c=a(3),R=function(E){return E&&E.__esModule?E:{default:E}}(c)},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(2),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R=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:c.default.now()})}))};R.prototype._checkIfRebuffering=function(E,L){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(E,L):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(L.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(E,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))},R.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},R.prototype._prepareRebufferTrackerState=function(E){this._lastCheckedTime=E,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=E},R.prototype._cleanupRebufferTracker=function(E,L){var _=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,I=L.viewer_time-this._lastPlayheadTimeUpdatedTime;y>0&&I-y>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+I-y}))}_?this._prepareRebufferTrackerState(L.viewer_time):this._clearRebufferTrackerState()},t.default=R},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(2),c=function(E){return E&&E.__esModule?E:{default:E}}(i),R=function(){this.on("viewinit",function(){var E=this.data,L=E.view_id;if(!E.view_program_changed){var _=function(y,I){var M=I.viewer_time;y.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(M||c.default.now(),L):y.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(M||c.default.now(),L)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};R.prototype.calculateTimeToFirstFrame=function(E,L){L===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:E}),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))},t.default=R},function(e,t,a){"use strict";function i(){var E=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var L=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];L.forEach(function(y){E.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 I=this.data.player_playhead_time-this._lastPlayheadPosition;if(I<0)return void(this._lastPlayheadPosition=-1);var M=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),D=Math.max(0,M-1),b=Math.max(0,1-M);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,D),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,b),(0,R.default)(this.data,"view_total_content_playback_time",I),(0,R.default)(this.data,"view_total_upscaling",D*I),(0,R.default)(this.data,"view_total_downscaling",b*I)}this._lastPlayheadPosition=-1})}),_.forEach(function(y){E.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(t,"__esModule",{value:!0}),t.default=i;var c=a(3),R=function(E){return E&&E.__esModule?E:{default:E}}(c)},function(e,t,a){"use strict";function i(M){return M&&M.__esModule?M:{default:M}}function c(){this.isSeeking=!1,this.on("seeking",function(M,D){(0,I.default)(this.data,D),this._lastSeekingTime=E.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var M=this._lastSeekingTime||E.default.now(),D=E.default.now()-M;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",D);var b=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(b,D)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var R=a(2),E=i(R),L=a(3),_=i(L),y=a(1),I=i(y)},function(e,t,a){"use strict";function i(b){return b&&b.__esModule?b:{default:b}}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function b(A,u){var r=[],o=!0,n=!1,s=void 0;try{for(var d,l=A[Symbol.iterator]();!(o=(d=l.next()).done)&&(r.push(d.value),!u||r.length!==u);o=!0);}catch(T){n=!0,s=T}finally{try{!o&&l.return&&l.return()}finally{if(n)throw s}}return r}return function(A,u){if(Array.isArray(A))return A;if(Symbol.iterator in Object(A))return b(A,u);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),R=a(3),E=i(R),L=a(5),_=a(1),y=i(_),I=function(b,A){b.push(A),b.sort(function(u,r){return u.viewer_time-r.viewer_time})},M=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],D=function(){var b=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}),M.forEach(function(u){return b.on(u,b._updateAdData)});var A=function(){b.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",A),this.on("playing",A),this.on("viewend",A),this.on("adrequest",function(u,r){r=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},r),I(this._adRequests,r),(0,E.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,E.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(u,r){r=(0,y.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},r),I(this._adResponses,r);var o=this.findAdRequest(r.ad_request_id);o&&(0,E.default)(this.data,"view_ad_request_time",Math.max(0,r.viewer_time-o.viewer_time))}),this.on("adplay",function(u,r){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,E.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,r.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,r.viewer_time-this.data.view_start)),this._prerollPlayTime=r.viewer_time)}),this.on("adplaying",function(u,r){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=r.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=r.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};D.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},D.prototype.findAdRequest=function(b){for(var A=0;A<this._adRequests.length;A++)if(this._adRequests[A].ad_request_id===b)return this._adRequests[A]},D.prototype._updateAdData=function(b,A){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&A.ad_tag_url){var u=(0,L.extractHostnameAndDomain)(A.ad_tag_url),r=c(u,2),o=r[0],n=r[1];this.data.view_preroll_ad_tag_domain=n,this.data.view_preroll_ad_tag_hostname=o}if(!this.data.view_preroll_ad_asset_hostname&&A.ad_asset_url){var s=(0,L.extractHostnameAndDomain)(A.ad_asset_url),d=c(s,2),l=d[0],T=d[1];this.data.view_preroll_ad_asset_domain=T,this.data.view_preroll_ad_asset_hostname=l}}},t.default=D},function(e,t,a){"use strict";function i(y){return y&&y.__esModule?y:{default:y}}function c(){var y=this,I=void 0,M=void 0,D=function(){y.disableRebufferTracking||((0,_.default)(y.data,"view_waiting_rebuffer_count",1),I=E.default.now(),M=window.setInterval(function(){if(I){var o=E.default.now();(0,_.default)(y.data,"view_waiting_rebuffer_duration",o-I),I=o}},250))},b=function(){y.disableRebufferTracking||I&&((0,_.default)(y.data,"view_waiting_rebuffer_duration",E.default.now()-I),I=!1,window.clearInterval(M))},A=!1,u=function(){A=!0},r=function(){A=!1,b()};this.on("waiting",function(){A&&D()}),this.on("playing",function(){b(),u()}),this.on("pause",r),this.on("seeking",r)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var R=a(2),E=i(R),L=a(3),_=i(L)},function(e,t,a){"use strict";function i(M){return M&&M.__esModule?M:{default:M}}function c(){var M=this;this.one("playbackheartbeat",y),this.on("playbackheartbeatend",function(){M.off("before*",I),M.one("playbackheartbeat",y)})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var R=a(1),E=i(R),L=a(2),_=i(L),y=function(){this.lastWallClockTime=_.default.now(),this.on("before*",I)},I=function(M){var D=_.default.now(),b=this.lastWallClockTime;this.lastWallClockTime=D,D-b>3e4&&(this.emit("devicesleep",{viewer_time:b}),(0,E.default)(this.data,{viewer_time:b}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:D}),(0,E.default)(this.data,{viewer_time:D}),this.send("devicewake"))}},function(e,t,a){"use strict";function i(h){return h&&h.__esModule?h:{default:h}}Object.defineProperty(t,"__esModule",{value:!0});var c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},R=a(0),E=i(R),L=a(40),_=a(4),y=i(_),I=a(53),M=i(I),D=a(12),b=i(D),A=a(54),u=i(A),r=a(17),o=i(r),n=a(55),s=i(n),d=a(1),l=i(d),T=["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"],g=["viewstart","error","ended","viewend"],m=function(h,x){var S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=h,this.envKey=x,this.eventQueue=new s.default((0,M.default)(x,S)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=S.sampleRate,this.disableCookies=S.disableCookies,this.respectDoNotTrack=S.respectDoNotTrack;var C=S.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:C.name,viewer_application_version:C.version,viewer_application_engine:C.layout,viewer_device_name:C.product,viewer_device_category:"",viewer_device_manufacturer:C.manufacturer,viewer_os_family:C.os&&C.os.family,viewer_os_architecture:C.os&&C.os.architecture,viewer_os_version:C.os&&C.os.version};var O=(0,u.default)();O&&(this.pageLevelData=(0,l.default)(this.pageLevelData,{viewer_connection_type:O})),E.default!==void 0&&E.default.location&&E.default.location.href&&(this.pageLevelData.page_url=E.default.location.href),this.viewerData=this.disableCookies?{}:(0,L.getAndUpdateViewerData)()};m.prototype.send=function(h,x){if(h){if(this.respectDoNotTrack&&(0,b.default)())return y.default.info("Not sending `"+h+"` because Do Not Track is enabled");if(!x||(x===void 0?"undefined":c(x))!=="object")return y.default.error("A data object was expected in send() but was not provided");var S=this.disableCookies?{}:(0,L.getAndUpdateSessionData)(),C={};(0,l.default)(C,this.pageLevelData),(0,l.default)(C,x),(0,l.default)(C,S),(0,l.default)(C,this.viewerData),C.event=h,C.env_key=this.envKey,C.user_id&&(C.viewer_user_id=C.user_id,delete C.user_id);var O=C.mux_sample_number>=this.sampleRate,P=this._deduplicateBeaconData(h,C),w=(0,o.default)(P);if(this.lastEventTime=this.mux.utils.now(),O)return y.default.info("Not sending event due to sample rate restriction",h,C,w);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",h,C,w),!this.rateLimited){if(y.default.info("Sending event",h,C,w),this.rateLimited=!this.eventQueue.queueEvent(h,w),this.mux.WINDOW_UNLOADING&&h==="viewend")this.eventQueue.destroy(!0);else if((g.indexOf(h)>=0||this.mux.WINDOW_VISIBLE===!1&&h==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return C.event="eventrateexceeded",w=(0,o.default)(C),this.eventQueue.queueEvent(C.event,w),y.default.error("Beaconing disabled due to rate limit.")}}},m.prototype.destroy=function(){this.eventQueue.destroy(!1)};var p=function(h,x,S,C){return!(!h||x.indexOf("request_")!==0)&&(x==="request_response_headers"||(S===void 0?"undefined":c(S))!=="object"||(C===void 0?"undefined":c(C))!=="object"||Object.keys(S||{}).length!==Object.keys(C||{}).length)},v=function(h,x){return h==="renditionchange"&&x.indexOf("video_source_")===0};m.prototype._deduplicateBeaconData=function(h,x){var S=this,C={},O=x.view_id;if(!O||h==="viewstart"||h==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)C=(0,l.default)({},x),O&&(this.previousBeaconData=C),O&&h==="viewend"&&(this.previousBeaconData=null);else{var P=h.indexOf("request")===0;Object.keys(x).forEach(function(w){var U=x[w];(U!==S.previousBeaconData[w]||T.indexOf(w)>-1||p(P,w,U,S.previousBeaconData[w])||v(h,w))&&(C[w]=U,S.previousBeaconData[w]=U)})}return C},t.default=m},function(e,t,a){"use strict";function i(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(t,"__esModule",{value:!0}),t.getAndUpdateSessionData=t.getAndUpdateViewerData=void 0;var c=a(15),R=i(c),E=a(52),L=i(E),_=a(6),y=a(2),I=i(y),M=function(){var u=void 0;try{u=R.default.parse(L.default.get("muxData")||"")}catch{u={}}return u},D=function(u){try{L.default.set("muxData",R.default.stringify(u),{expires:7300})}catch{}},b=function(){var u=M();return u.mux_viewer_id=u.mux_viewer_id||(0,_.generateUUID)(),u.msn=u.msn||Math.random(),D(u),{mux_viewer_id:u.mux_viewer_id,mux_sample_number:u.msn}},A=function(){var u=M(),r=I.default.now();return u.session_start&&(u.sst=u.session_start,delete u.session_start),u.session_id&&(u.sid=u.session_id,delete u.session_id),u.session_expires&&(u.sex=u.session_expires,delete u.session_expires),(!u.sex||u.sex<r)&&(u.sid=(0,_.generateUUID)(),u.sst=r),u.sex=r+15e5,D(u),{session_id:u.sid,session_start:u.sst,session_expires:u.sex}};t.getAndUpdateViewerData=b,t.getAndUpdateSessionData=A},function(e,t,a){"use strict";var i=a(42),c=a(16),R=a(10),E=Object.prototype.hasOwnProperty,L={brackets:function(s){return s+"[]"},comma:"comma",indices:function(s,d){return s+"["+d+"]"},repeat:function(s){return s}},_=Array.isArray,y=String.prototype.split,I=Array.prototype.push,M=function(s,d){I.apply(s,_(d)?d:[d])},D=Date.prototype.toISOString,b=R.default,A={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:c.encode,encodeValuesOnly:!1,format:b,formatter:R.formatters[b],indices:!1,serializeDate:function(s){return D.call(s)},skipNulls:!1,strictNullHandling:!1},u=function(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="symbol"||typeof s=="bigint"},r={},o=function s(d,l,T,g,m,p,v,h,x,S,C,O,P,w,U){for(var k=d,N=U,B=0,K=!1;(N=N.get(r))!==void 0&&!K;){var H=N.get(d);if(B+=1,H!==void 0){if(H===B)throw new RangeError("Cyclic object value");K=!0}N.get(r)===void 0&&(B=0)}if(typeof v=="function"?k=v(l,k):k instanceof Date?k=S(k):T==="comma"&&_(k)&&(k=c.maybeMap(k,function(re){return re instanceof Date?S(re):re})),k===null){if(g)return p&&!P?p(l,A.encoder,w,"key",C):l;k=""}if(u(k)||c.isBuffer(k)){if(p){var F=P?l:p(l,A.encoder,w,"key",C);if(T==="comma"&&P){for(var W=y.call(String(k),","),Y="",$=0;$<W.length;++$)Y+=($===0?"":",")+O(p(W[$],A.encoder,w,"value",C));return[O(F)+"="+Y]}return[O(F)+"="+O(p(k,A.encoder,w,"value",C))]}return[O(l)+"="+O(String(k))]}var J=[];if(k===void 0)return J;var q;if(T==="comma"&&_(k))q=[{value:k.length>0?k.join(",")||null:void 0}];else if(_(v))q=v;else{var oe=Object.keys(k);q=h?oe.sort(h):oe}for(var X=0;X<q.length;++X){var ie=q[X],fe=typeof ie=="object"&&ie.value!==void 0?ie.value:k[ie];if(!m||fe!==null){var ue=_(k)?typeof T=="function"?T(l,ie):l:l+(x?"."+ie:"["+ie+"]");U.set(d,B);var _e=i();_e.set(r,U),M(J,s(fe,ue,T,g,m,p,v,h,x,S,C,O,P,w,_e))}}return J},n=function(s){if(!s)return A;if(s.encoder!==null&&s.encoder!==void 0&&typeof s.encoder!="function")throw new TypeError("Encoder has to be a function.");var d=s.charset||A.charset;if(s.charset!==void 0&&s.charset!=="utf-8"&&s.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var l=R.default;if(s.format!==void 0){if(!E.call(R.formatters,s.format))throw new TypeError("Unknown format option provided.");l=s.format}var T=R.formatters[l],g=A.filter;return(typeof s.filter=="function"||_(s.filter))&&(g=s.filter),{addQueryPrefix:typeof s.addQueryPrefix=="boolean"?s.addQueryPrefix:A.addQueryPrefix,allowDots:s.allowDots===void 0?A.allowDots:!!s.allowDots,charset:d,charsetSentinel:typeof s.charsetSentinel=="boolean"?s.charsetSentinel:A.charsetSentinel,delimiter:s.delimiter===void 0?A.delimiter:s.delimiter,encode:typeof s.encode=="boolean"?s.encode:A.encode,encoder:typeof s.encoder=="function"?s.encoder:A.encoder,encodeValuesOnly:typeof s.encodeValuesOnly=="boolean"?s.encodeValuesOnly:A.encodeValuesOnly,filter:g,format:l,formatter:T,serializeDate:typeof s.serializeDate=="function"?s.serializeDate:A.serializeDate,skipNulls:typeof s.skipNulls=="boolean"?s.skipNulls:A.skipNulls,sort:typeof s.sort=="function"?s.sort:null,strictNullHandling:typeof s.strictNullHandling=="boolean"?s.strictNullHandling:A.strictNullHandling}};e.exports=function(s,d){var l,T,g=s,m=n(d);typeof m.filter=="function"?(T=m.filter,g=T("",g)):_(m.filter)&&(T=m.filter,l=T);var p=[];if(typeof g!="object"||g===null)return"";var v;v=d&&d.arrayFormat in L?d.arrayFormat:d&&"indices"in d?d.indices?"indices":"repeat":"indices";var h=L[v];l||(l=Object.keys(g)),m.sort&&l.sort(m.sort);for(var x=i(),S=0;S<l.length;++S){var C=l[S];m.skipNulls&&g[C]===null||M(p,o(g[C],C,h,m.strictNullHandling,m.skipNulls,m.encode?m.encoder:null,m.filter,m.sort,m.allowDots,m.serializeDate,m.format,m.formatter,m.encodeValuesOnly,m.charset,x))}var O=p.join(m.delimiter),P=m.addQueryPrefix===!0?"?":"";return m.charsetSentinel&&(m.charset==="iso-8859-1"?P+="utf8=%26%2310003%3B&":P+="utf8=%E2%9C%93&"),O.length>0?P+O:""}},function(e,t,a){"use strict";var i=a(8),c=a(47),R=a(49),E=i("%TypeError%"),L=i("%WeakMap%",!0),_=i("%Map%",!0),y=c("WeakMap.prototype.get",!0),I=c("WeakMap.prototype.set",!0),M=c("WeakMap.prototype.has",!0),D=c("Map.prototype.get",!0),b=c("Map.prototype.set",!0),A=c("Map.prototype.has",!0),u=function(s,d){for(var l,T=s;(l=T.next)!==null;T=l)if(l.key===d)return T.next=l.next,l.next=s.next,s.next=l,l},r=function(s,d){var l=u(s,d);return l&&l.value},o=function(s,d,l){var T=u(s,d);T?T.value=l:s.next={key:d,next:s.next,value:l}},n=function(s,d){return!!u(s,d)};e.exports=function(){var s,d,l,T={assert:function(g){if(!T.has(g))throw new E("Side channel does not contain "+R(g))},get:function(g){if(L&&g&&(typeof g=="object"||typeof g=="function")){if(s)return y(s,g)}else if(_){if(d)return D(d,g)}else if(l)return r(l,g)},has:function(g){if(L&&g&&(typeof g=="object"||typeof g=="function")){if(s)return M(s,g)}else if(_){if(d)return A(d,g)}else if(l)return n(l,g);return!1},set:function(g,m){L&&g&&(typeof g=="object"||typeof g=="function")?(s||(s=new L),I(s,g,m)):_?(d||(d=new _),b(d,g,m)):(l||(l={key:{},next:null}),o(l,g,m))}};return T}},function(e,t,a){"use strict";var i=typeof Symbol!="undefined"&&Symbol,c=a(44);e.exports=function(){return typeof i=="function"&&typeof Symbol=="function"&&typeof i("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&c()}},function(e,t,a){"use strict";e.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var i={},c=Symbol("test"),R=Object(c);if(typeof c=="string"||Object.prototype.toString.call(c)!=="[object Symbol]"||Object.prototype.toString.call(R)!=="[object Symbol]")return!1;i[c]=42;for(c in i)return!1;if(typeof Object.keys=="function"&&Object.keys(i).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(i).length!==0)return!1;var E=Object.getOwnPropertySymbols(i);if(E.length!==1||E[0]!==c||!Object.prototype.propertyIsEnumerable.call(i,c))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var L=Object.getOwnPropertyDescriptor(i,c);if(L.value!==42||L.enumerable!==!0)return!1}return!0}},function(e,t,a){"use strict";var i=Array.prototype.slice,c=Object.prototype.toString;e.exports=function(R){var E=this;if(typeof E!="function"||c.call(E)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+E);for(var L,_=i.call(arguments,1),y=function(){if(this instanceof L){var A=E.apply(this,_.concat(i.call(arguments)));return Object(A)===A?A:this}return E.apply(R,_.concat(i.call(arguments)))},I=Math.max(0,E.length-_.length),M=[],D=0;D<I;D++)M.push("$"+D);if(L=Function("binder","return function ("+M.join(",")+"){ return binder.apply(this,arguments); }")(y),E.prototype){var b=function(){};b.prototype=E.prototype,L.prototype=new b,b.prototype=null}return L}},function(e,t,a){"use strict";var i=a(9);e.exports=i.call(Function.call,Object.prototype.hasOwnProperty)},function(e,t,a){"use strict";var i=a(8),c=a(48),R=c(i("String.prototype.indexOf"));e.exports=function(E,L){var _=i(E,!!L);return typeof _=="function"&&R(E,".prototype.")>-1?c(_):_}},function(e,t,a){"use strict";var i=a(9),c=a(8),R=c("%Function.prototype.apply%"),E=c("%Function.prototype.call%"),L=c("%Reflect.apply%",!0)||i.call(E,R),_=c("%Object.getOwnPropertyDescriptor%",!0),y=c("%Object.defineProperty%",!0),I=c("%Math.max%");if(y)try{y({},"a",{value:1})}catch{y=null}e.exports=function(D){var b=L(i,E,arguments);return _&&y&&_(b,"length").configurable&&y(b,"length",{value:1+I(0,D.length-(arguments.length-1))}),b};var M=function(){return L(i,R,arguments)};y?y(e.exports,"apply",{value:M}):e.exports.apply=M},function(e,t,a){function i(G,V){if(G===1/0||G===-1/0||G!==G||G&&G>-1e3&&G<1e3||he.call(/e/,V))return V;var de=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof G=="number"){var ce=G<0?-Me(-G):Me(G);if(ce!==G){var Re=String(ce),Ce=re.call(V,Re.length+1);return Z.call(Re,de,"$&_")+"."+Z.call(Z.call(Ce,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Z.call(V,de,"$&_")}function c(G,V,de){var ce=(de.quoteStyle||V)==="double"?'"':"'";return ce+G+ce}function R(G){return Z.call(String(G),/"/g,"&quot;")}function E(G){return!(r(G)!=="[object Array]"||Se&&typeof G=="object"&&Se in G)}function L(G){return!(r(G)!=="[object Date]"||Se&&typeof G=="object"&&Se in G)}function _(G){return!(r(G)!=="[object RegExp]"||Se&&typeof G=="object"&&Se in G)}function y(G){return!(r(G)!=="[object Error]"||Se&&typeof G=="object"&&Se in G)}function I(G){return!(r(G)!=="[object String]"||Se&&typeof G=="object"&&Se in G)}function M(G){return!(r(G)!=="[object Number]"||Se&&typeof G=="object"&&Se in G)}function D(G){return!(r(G)!=="[object Boolean]"||Se&&typeof G=="object"&&Se in G)}function b(G){if(Fe)return G&&typeof G=="object"&&G instanceof Symbol;if(typeof G=="symbol")return!0;if(!G||typeof G!="object"||!ye)return!1;try{return ye.call(G),!0}catch{}return!1}function A(G){if(!G||typeof G!="object"||!Be)return!1;try{return Be.call(G),!0}catch{}return!1}function u(G,V){return tt.call(G,V)}function r(G){return fe.call(G)}function o(G){if(G.name)return G.name;var V=_e.call(ue.call(G),/^function\s*([\w$]+)/);return V?V[1]:null}function n(G,V){if(G.indexOf)return G.indexOf(V);for(var de=0,ce=G.length;de<ce;de++)if(G[de]===V)return de;return-1}function s(G){if(!N||!G||typeof G!="object")return!1;try{N.call(G);try{F.call(G)}catch{return!0}return G instanceof Map}catch{}return!1}function d(G){if(!$||!G||typeof G!="object")return!1;try{$.call(G,$);try{q.call(G,q)}catch{return!0}return G instanceof WeakMap}catch{}return!1}function l(G){if(!X||!G||typeof G!="object")return!1;try{return X.call(G),!0}catch{}return!1}function T(G){if(!F||!G||typeof G!="object")return!1;try{F.call(G);try{N.call(G)}catch{return!0}return G instanceof Set}catch{}return!1}function g(G){if(!q||!G||typeof G!="object")return!1;try{q.call(G,q);try{$.call(G,$)}catch{return!0}return G instanceof WeakSet}catch{}return!1}function m(G){return!(!G||typeof G!="object")&&(typeof HTMLElement!="undefined"&&G instanceof HTMLElement||typeof G.nodeName=="string"&&typeof G.getAttribute=="function")}function p(G,V){if(G.length>V.maxStringLength){var de=G.length-V.maxStringLength,ce="... "+de+" more character"+(de>1?"s":"");return p(re.call(G,0,V.maxStringLength),V)+ce}return c(Z.call(Z.call(G,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,v),"single",V)}function v(G){var V=G.charCodeAt(0),de={8:"b",9:"t",10:"n",12:"f",13:"r"}[V];return de?"\\"+de:"\\x"+(V<16?"0":"")+te.call(V.toString(16))}function h(G){return"Object("+G+")"}function x(G){return G+" { ? }"}function S(G,V,de,ce){return G+" ("+V+") {"+(ce?P(de,ce):ge.call(de,", "))+"}"}function C(G){for(var V=0;V<G.length;V++)if(n(G[V],`
2
+ `)>=0)return!1;return!0}function O(G,V){var de;if(G.indent===" ")de=" ";else{if(!(typeof G.indent=="number"&&G.indent>0))return null;de=ge.call(Array(G.indent+1)," ")}return{base:de,prev:ge.call(Array(V+1),de)}}function P(G,V){if(G.length===0)return"";var de=`
3
+ `+V.prev+V.base;return de+ge.call(G,","+de)+`
4
+ `+V.prev}function w(G,V){var de=E(G),ce=[];if(de){ce.length=G.length;for(var Re=0;Re<G.length;Re++)ce[Re]=u(G,Re)?V(G[Re],G):""}var Ce,le=typeof Ee=="function"?Ee(G):[];if(Fe){Ce={};for(var Ze=0;Ze<le.length;Ze++)Ce["$"+le[Ze]]=le[Ze]}for(var We in G)u(G,We)&&(de&&String(Number(We))===We&&We<G.length||Fe&&Ce["$"+We]instanceof Symbol||(he.call(/[^\w$]/,We)?ce.push(V(We,G)+": "+V(G[We],G)):ce.push(We+": "+V(G[We],G))));if(typeof Ee=="function")for(var rt=0;rt<le.length;rt++)qe.call(G,le[rt])&&ce.push("["+V(le[rt])+"]: "+V(G[le[rt]],G));return ce}var U=typeof Map=="function"&&Map.prototype,k=Object.getOwnPropertyDescriptor&&U?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,N=U&&k&&typeof k.get=="function"?k.get:null,B=U&&Map.prototype.forEach,K=typeof Set=="function"&&Set.prototype,H=Object.getOwnPropertyDescriptor&&K?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,F=K&&H&&typeof H.get=="function"?H.get:null,W=K&&Set.prototype.forEach,Y=typeof WeakMap=="function"&&WeakMap.prototype,$=Y?WeakMap.prototype.has:null,J=typeof WeakSet=="function"&&WeakSet.prototype,q=J?WeakSet.prototype.has:null,oe=typeof WeakRef=="function"&&WeakRef.prototype,X=oe?WeakRef.prototype.deref:null,ie=Boolean.prototype.valueOf,fe=Object.prototype.toString,ue=Function.prototype.toString,_e=String.prototype.match,re=String.prototype.slice,Z=String.prototype.replace,te=String.prototype.toUpperCase,ee=String.prototype.toLowerCase,he=RegExp.prototype.test,xe=Array.prototype.concat,ge=Array.prototype.join,Ae=Array.prototype.slice,Me=Math.floor,Be=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ee=Object.getOwnPropertySymbols,ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Fe=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Se=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Fe?"object":"symbol")?Symbol.toStringTag:null,qe=Object.prototype.propertyIsEnumerable,Ue=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(G){return G.__proto__}:null),ze=a(50).custom,et=ze&&b(ze)?ze:null;e.exports=function G(V,de,ce,Re){function Ce(Ft,Sr,Do){if(Sr&&(Re=Ae.call(Re),Re.push(Sr)),Do){var En={depth:le.depth};return u(le,"quoteStyle")&&(En.quoteStyle=le.quoteStyle),G(Ft,En,ce+1,Re)}return G(Ft,le,ce+1,Re)}var le=de||{};if(u(le,"quoteStyle")&&le.quoteStyle!=="single"&&le.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(u(le,"maxStringLength")&&(typeof le.maxStringLength=="number"?le.maxStringLength<0&&le.maxStringLength!==1/0:le.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ze=!u(le,"customInspect")||le.customInspect;if(typeof Ze!="boolean"&&Ze!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(u(le,"indent")&&le.indent!==null&&le.indent!==" "&&!(parseInt(le.indent,10)===le.indent&&le.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(u(le,"numericSeparator")&&typeof le.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var We=le.numericSeparator;if(V===void 0)return"undefined";if(V===null)return"null";if(typeof V=="boolean")return V?"true":"false";if(typeof V=="string")return p(V,le);if(typeof V=="number"){if(V===0)return 1/0/V>0?"0":"-0";var rt=String(V);return We?i(V,rt):rt}if(typeof V=="bigint"){var qt=String(V)+"n";return We?i(V,qt):qt}var Tr=le.depth===void 0?5:le.depth;if(ce===void 0&&(ce=0),ce>=Tr&&Tr>0&&typeof V=="object")return E(V)?"[Array]":"[Object]";var mt=O(le,ce);if(Re===void 0)Re=[];else if(n(Re,V)>=0)return"[Circular]";if(typeof V=="function"){var br=o(V),Nt=w(V,Ce);return"[Function"+(br?": "+br:" (anonymous)")+"]"+(Nt.length>0?" { "+ge.call(Nt,", ")+" }":"")}if(b(V)){var er=Fe?Z.call(String(V),/^(Symbol\(.*\))_[^)]*$/,"$1"):ye.call(V);return typeof V!="object"||Fe?er:h(er)}if(m(V)){for(var Bt="<"+ee.call(String(V.nodeName)),tr=V.attributes||[],Ar=0;Ar<tr.length;Ar++)Bt+=" "+tr[Ar].name+"="+c(R(tr[Ar].value),"double",le);return Bt+=">",V.childNodes&&V.childNodes.length&&(Bt+="..."),Bt+="</"+ee.call(String(V.nodeName))+">"}if(E(V)){if(V.length===0)return"[]";var fi=w(V,Ce);return mt&&!C(fi)?"["+P(fi,mt)+"]":"[ "+ge.call(fi,", ")+" ]"}if(y(V)){var hi=w(V,Ce);return"cause"in V&&!qe.call(V,"cause")?"{ ["+String(V)+"] "+ge.call(xe.call("[cause]: "+Ce(V.cause),hi),", ")+" }":hi.length===0?"["+String(V)+"]":"{ ["+String(V)+"] "+ge.call(hi,", ")+" }"}if(typeof V=="object"&&Ze){if(et&&typeof V[et]=="function")return V[et]();if(Ze!=="symbol"&&typeof V.inspect=="function")return V.inspect()}if(s(V)){var vn=[];return B.call(V,function(Ft,Sr){vn.push(Ce(Sr,V,!0)+" => "+Ce(Ft,V))}),S("Map",N.call(V),vn,mt)}if(T(V)){var mn=[];return W.call(V,function(Ft){mn.push(Ce(Ft,V))}),S("Set",F.call(V),mn,mt)}if(d(V))return x("WeakMap");if(g(V))return x("WeakSet");if(l(V))return x("WeakRef");if(M(V))return h(Ce(Number(V)));if(A(V))return h(Ce(Be.call(V)));if(D(V))return h(ie.call(V));if(I(V))return h(Ce(String(V)));if(!L(V)&&!_(V)){var vi=w(V,Ce),pn=Ue?Ue(V)===Object.prototype:V instanceof Object||V.constructor===Object,mi=V instanceof Object?"":"null prototype",gn=!pn&&Se&&Object(V)===V&&Se in V?re.call(r(V),8,-1):mi?"Object":"",Lo=pn||typeof V.constructor!="function"?"":V.constructor.name?V.constructor.name+" ":"",pi=Lo+(gn||mi?"["+ge.call(xe.call([],gn||[],mi||[]),": ")+"] ":"");return vi.length===0?pi+"{}":mt?pi+"{"+P(vi,mt)+"}":pi+"{ "+ge.call(vi,", ")+" }"}return String(V)};var tt=Object.prototype.hasOwnProperty||function(G){return G in this}},function(e,t){},function(e,t,a){"use strict";var i=a(16),c=Object.prototype.hasOwnProperty,R=Array.isArray,E={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:i.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},L=function(b){return b.replace(/&#(\d+);/g,function(A,u){return String.fromCharCode(parseInt(u,10))})},_=function(b,A){return b&&typeof b=="string"&&A.comma&&b.indexOf(",")>-1?b.split(","):b},y=function(b,A){var u,r={},o=A.ignoreQueryPrefix?b.replace(/^\?/,""):b,n=A.parameterLimit===1/0?void 0:A.parameterLimit,s=o.split(A.delimiter,n),d=-1,l=A.charset;if(A.charsetSentinel)for(u=0;u<s.length;++u)s[u].indexOf("utf8=")===0&&(s[u]==="utf8=%E2%9C%93"?l="utf-8":s[u]==="utf8=%26%2310003%3B"&&(l="iso-8859-1"),d=u,u=s.length);for(u=0;u<s.length;++u)if(u!==d){var T,g,m=s[u],p=m.indexOf("]="),v=p===-1?m.indexOf("="):p+1;v===-1?(T=A.decoder(m,E.decoder,l,"key"),g=A.strictNullHandling?null:""):(T=A.decoder(m.slice(0,v),E.decoder,l,"key"),g=i.maybeMap(_(m.slice(v+1),A),function(h){return A.decoder(h,E.decoder,l,"value")})),g&&A.interpretNumericEntities&&l==="iso-8859-1"&&(g=L(g)),m.indexOf("[]=")>-1&&(g=R(g)?[g]:g),c.call(r,T)?r[T]=i.combine(r[T],g):r[T]=g}return r},I=function(b,A,u,r){for(var o=r?A:_(A,u),n=b.length-1;n>=0;--n){var s,d=b[n];if(d==="[]"&&u.parseArrays)s=[].concat(o);else{s=u.plainObjects?Object.create(null):{};var l=d.charAt(0)==="["&&d.charAt(d.length-1)==="]"?d.slice(1,-1):d,T=parseInt(l,10);u.parseArrays||l!==""?!isNaN(T)&&d!==l&&String(T)===l&&T>=0&&u.parseArrays&&T<=u.arrayLimit?(s=[],s[T]=o):l!=="__proto__"&&(s[l]=o):s={0:o}}o=s}return o},M=function(b,A,u,r){if(b){var o=u.allowDots?b.replace(/\.([^.[]+)/g,"[$1]"):b,n=/(\[[^[\]]*])/,s=/(\[[^[\]]*])/g,d=u.depth>0&&n.exec(o),l=d?o.slice(0,d.index):o,T=[];if(l){if(!u.plainObjects&&c.call(Object.prototype,l)&&!u.allowPrototypes)return;T.push(l)}for(var g=0;u.depth>0&&(d=s.exec(o))!==null&&g<u.depth;){if(g+=1,!u.plainObjects&&c.call(Object.prototype,d[1].slice(1,-1))&&!u.allowPrototypes)return;T.push(d[1])}return d&&T.push("["+o.slice(d.index)+"]"),I(T,A,u,r)}},D=function(b){if(!b)return E;if(b.decoder!==null&&b.decoder!==void 0&&typeof b.decoder!="function")throw new TypeError("Decoder has to be a function.");if(b.charset!==void 0&&b.charset!=="utf-8"&&b.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var A=b.charset===void 0?E.charset:b.charset;return{allowDots:b.allowDots===void 0?E.allowDots:!!b.allowDots,allowPrototypes:typeof b.allowPrototypes=="boolean"?b.allowPrototypes:E.allowPrototypes,allowSparse:typeof b.allowSparse=="boolean"?b.allowSparse:E.allowSparse,arrayLimit:typeof b.arrayLimit=="number"?b.arrayLimit:E.arrayLimit,charset:A,charsetSentinel:typeof b.charsetSentinel=="boolean"?b.charsetSentinel:E.charsetSentinel,comma:typeof b.comma=="boolean"?b.comma:E.comma,decoder:typeof b.decoder=="function"?b.decoder:E.decoder,delimiter:typeof b.delimiter=="string"||i.isRegExp(b.delimiter)?b.delimiter:E.delimiter,depth:typeof b.depth=="number"||b.depth===!1?+b.depth:E.depth,ignoreQueryPrefix:b.ignoreQueryPrefix===!0,interpretNumericEntities:typeof b.interpretNumericEntities=="boolean"?b.interpretNumericEntities:E.interpretNumericEntities,parameterLimit:typeof b.parameterLimit=="number"?b.parameterLimit:E.parameterLimit,parseArrays:b.parseArrays!==!1,plainObjects:typeof b.plainObjects=="boolean"?b.plainObjects:E.plainObjects,strictNullHandling:typeof b.strictNullHandling=="boolean"?b.strictNullHandling:E.strictNullHandling}};e.exports=function(b,A){var u=D(A);if(b===""||b===null||b===void 0)return u.plainObjects?Object.create(null):{};for(var r=typeof b=="string"?y(b,u):b,o=u.plainObjects?Object.create(null):{},n=Object.keys(r),s=0;s<n.length;++s){var d=n[s],l=M(d,r[d],u,typeof b=="string");o=i.merge(o,l,u)}return u.allowSparse===!0?o:i.compact(o)}},function(e,t,a){"use strict";var i,c,R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(E){return typeof E}:function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E};(function(E){var L=!1;if(i=E,(c=typeof i=="function"?i.call(t,a,t,e):i)!==void 0&&(e.exports=c),L=!0,R(t)==="object"&&(e.exports=E(),L=!0),!L){var _=window.Cookies,y=window.Cookies=E();y.noConflict=function(){return window.Cookies=_,y}}})(function(){function E(_){function y(I,M,D){var b;if(typeof document!="undefined"){if(arguments.length>1){if(D=L({path:"/"},y.defaults,D),typeof D.expires=="number"){var A=new Date;A.setMilliseconds(A.getMilliseconds()+864e5*D.expires),D.expires=A}try{b=JSON.stringify(M),/^[\{\[]/.test(b)&&(M=b)}catch{}return M=_.write?_.write(M,I):encodeURIComponent(String(M)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),I=encodeURIComponent(String(I)),I=I.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),I=I.replace(/[\(\)]/g,escape),document.cookie=[I,"=",M,D.expires?"; expires="+D.expires.toUTCString():"",D.path?"; path="+D.path:"",D.domain?"; domain="+D.domain:"",D.secure?"; secure":""].join("")}I||(b={});for(var u=document.cookie?document.cookie.split("; "):[],r=/(%[0-9A-Z]{2})+/g,o=0;o<u.length;o++){var n=u[o].split("="),s=n.slice(1).join("=");s.charAt(0)==='"'&&(s=s.slice(1,-1));try{var d=n[0].replace(r,decodeURIComponent);if(s=_.read?_.read(s,d):_(s,d)||s.replace(r,decodeURIComponent),this.json)try{s=JSON.parse(s)}catch{}if(I===d){b=s;break}I||(b[d]=s)}catch{}}return b}}return y.set=y,y.get=function(I){return y.call(y,I)},y.getJSON=function(){return y.apply({json:!0},[].slice.call(arguments))},y.defaults={},y.remove=function(I,M){y(I,"",L(M,{expires:-1}))},y.withConverter=E,y}var L=function(){for(var _=0,y={};_<arguments.length;_++){var I=arguments[_];for(var M in I)y[M]=I[M]}return y};return E(function(){})})},function(e,t,a){"use strict";function i(c,R){var E=R.beaconCollectionDomain,L=R.beaconDomain;if(E)return"https://"+E;c=c||"inferred";var _=L||"litix.io";return c.match(/^[a-z0-9]+$/)?"https://"+c+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=a(0),c=function(L){return L&&L.__esModule?L:{default:L}}(i),R=function(){var L=void 0;switch(E()){case"cellular":L="cellular";break;case"ethernet":L="wired";break;case"wifi":L="wifi";break;case void 0:break;default:L="other"}return L},E=function(){var L=c.default.navigator,_=L&&(L.connection||L.mozConnection||L.webkitConnection);return _&&_.type};t.default=R},function(e,t,a){"use strict";function i(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(t,"__esModule",{value:!0});var c=a(0),R=i(c),E=a(4),L=i(E),_=a(56),y=i(_),I=a(1),M=i(I),D=a(17),b=i(D),A=a(2),u=i(A),r=!!R.default.XMLHttpRequest&&"withCredentials"in new R.default.XMLHttpRequest,o={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},n=function(s,d){this._beaconUrl=s||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,M.default)({},o,d)};n.prototype.queueEvent=function(s,d){var l=(0,M.default)({},d);return r?(this._eventQueue.length<=this._options.maxQueueLength||s==="eventrateexceeded")&&(this._eventQueue.push(l),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(y.default.send(this._beaconUrl,l),!0)},n.prototype.flushEvents=function(){r&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},n.prototype.destroy=function(){var s=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,s?this._clearBeaconQueue():this.flushEvents(),R.default.clearTimeout(this._sendTimeout)},n.prototype._clearBeaconQueue=function(){var s=R.default.navigator,d=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,l=this._eventQueue.slice(d);d>0&&(0,M.default)(l[l.length-1],(0,b.default)({mux_view_message:"event queue truncated"}));var T=this._createPayload(l);if(s.sendBeacon)s.sendBeacon(this._beaconUrl,T);else if(R.default.XMLHttpRequest){var g=new R.default.XMLHttpRequest;g.open("POST",this._beaconUrl),g.setRequestHeader("Content-Type","application/json"),g.send(T)}else y.default.send(this._beaconUrl,l[l.length-1])},n.prototype._sendBeaconQueue=function(){var s=this;if(R.default.XMLHttpRequest&&!this._postInFlight){var d=new R.default.XMLHttpRequest,l=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,d.onreadystatechange=function(){d.readyState===4&&(d.status!==200?(s._eventQueue=l.concat(s._eventQueue),s._failureCount+=1,L.default.info("Error sending beacon: "+d.status),L.default.info(d.responseText)):s._failureCount=0,s._roundTripTime=u.default.now()-g,s._postInFlight=!1)},d.open("POST",this._beaconUrl),d.setRequestHeader("Content-Type","application/json");var T=this._createPayload(l),g=u.default.now();d.send(T)}},n.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var s=Math.pow(2,this._failureCount-1);return(1+(s*=Math.random()))*this._options.baseTimeBetweenBeacons},n.prototype._startBeaconSending=function(){var s=this;R.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=R.default.setTimeout(function(){s._eventQueue.length&&s._sendBeaconQueue(),s._startBeaconSending()},this._getNextBeaconTime()))},n.prototype._createPayload=function(s){var d={transmission_timestamp:Math.round(u.default.now())};return this._roundTripTime&&(d.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:d,events:s})},t.default=n},function(e,t,a){"use strict";function i(y){return y&&y.__esModule?y:{default:y}}Object.defineProperty(t,"__esModule",{value:!0});var c=a(15),R=i(c),E=a(0),L=i(E),_={};_.send=function(y,I){function M(){D.src=A+(b?"&rc="+b:"")}var D=new Image,b=0,A=y+"?"+R.default.stringify(I);return D.addEventListener("error",function(){b>3||L.default.setTimeout(function(){b++,M()},5e3*b)}),M(),D},t.default=_},function(e,t,a){"use strict";function i(){function c(A,u){var r=u.request_start,o=u.request_response_start,n=u.request_response_end,s=u.request_bytes_loaded;I++;var d=void 0,l=void 0;if(o?(d=o-r,l=n-o):l=n-r,l>0&&s>0){var T=s/l*8e3;M++,_+=s,y+=l,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,T),this.data.view_average_request_throughput=_/y*8e3,this.data.view_request_count=I,d>0&&(L+=d,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,d),this.data.view_average_request_latency=L/M)}}function R(A,u){I++,D++,this.data.view_request_count=I,this.data.view_request_failed_count=D}function E(A,u){I++,b++,this.data.view_request_count=I,this.data.view_request_canceled_count=b}var L=0,_=0,y=0,I=0,M=0,D=0,b=0;this.on("requestcompleted",c),this.on("requestfailed",R),this.on("requestcanceled",E)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i},function(e,t,a){"use strict";function i(M,D,b){var A=(0,_.findMediaElement)(D),u=R(A,3),r=u[0],o=u[1],n=u[2],s=M.log,d=M.utils.getComputedStyle,l=M.utils.secondsToMs,T={automaticErrorTracking:!0};if(!r)return s.error("No element was found with the `"+o+"` query selector.");if(n!=="video"&&n!=="audio")return s.error("The element of `"+o+"` was not a media element.");b=(0,L.default)(T,b),b.data=(0,L.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},b.data),b.getPlayheadTime=function(){return l(r.currentTime)},b.getStateData=function(){var m=this.hlsjs&&this.hlsjs.url,p=this.dashjs&&c(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:r.paused,player_playhead_time:l(r.currentTime),player_width:parseInt(d(r,"width")),player_height:parseInt(d(r,"height")),player_autoplay_on:r.autoplay,player_preload_on:r.preload,video_poster_url:r.poster,video_source_url:m||p||r.currentSrc,video_source_duration:l(r.duration),video_source_height:r.videoHeight,video_source_width:r.videoWidth}},r.mux=r.mux||{},r.mux.deleted=!1,r.mux.emit=function(m,p){M.emit(o,m,p)};var g=function(){s.error("The monitor for this video element has already been destroyed.")};r.mux.destroy=function(){Object.keys(r.mux.listeners).forEach(function(m){r.removeEventListener(m,r.mux.listeners[m],!1)}),delete r.mux.listeners,r.mux.destroy=g,r.mux.swapElement=g,r.mux.emit=g,r.mux.addHLSJS=g,r.mux.addDashJS=g,r.mux.removeHLSJS=g,r.mux.removeDashJS=g,r.mux.deleted=!0,M.emit(o,"destroy")},r.mux.swapElement=function(m){var p=(0,_.findMediaElement)(m),v=R(p,3),h=v[0],x=v[1],S=v[2];return h?S!=="video"&&S!=="audio"?M.log.error("The element of `"+x+"` was not a media element."):(h.muxId=r.muxId,delete r.muxId,h.mux=h.mux||{},h.mux.listeners=(0,L.default)({},r.mux.listeners),delete r.mux.listeners,Object.keys(h.mux.listeners).forEach(function(C){r.removeEventListener(C,h.mux.listeners[C],!1),h.addEventListener(C,h.mux.listeners[C],!1)}),h.mux.swapElement=r.mux.swapElement,h.mux.destroy=r.mux.destroy,delete r.mux,void(r=h)):M.log.error("No element was found with the `"+x+"` query selector.")},r.mux.addHLSJS=function(m){M.addHLSJS(o,m)},r.mux.addDashJS=function(m){M.addDashJS(o,m)},r.mux.removeHLSJS=function(){M.removeHLSJS(o)},r.mux.removeDashJS=function(){M.removeDashJS(o)},M.init(o,b),M.emit(o,"playerready"),r.paused||(M.emit(o,"play"),r.readyState>2&&M.emit(o,"playing")),r.mux.listeners={},y.forEach(function(m){(m!=="error"||b.automaticErrorTracking)&&(r.mux.listeners[m]=function(){var p={};if(m==="error"){if(!r.error||r.error.code===1)return;p.player_error_code=r.error.code,p.player_error_message=I[r.error.code]||r.error.message}M.emit(o,m,p)},r.addEventListener(m,r.mux.listeners[m],!1))})}Object.defineProperty(t,"__esModule",{value:!0});var c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(M){return typeof M}:function(M){return M&&typeof Symbol=="function"&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M},R=function(){function M(D,b){var A=[],u=!0,r=!1,o=void 0;try{for(var n,s=D[Symbol.iterator]();!(u=(n=s.next()).done)&&(A.push(n.value),!b||A.length!==b);u=!0);}catch(d){r=!0,o=d}finally{try{!u&&s.return&&s.return()}finally{if(r)throw o}}return A}return function(D,b){if(Array.isArray(D))return D;if(Symbol.iterator in Object(D))return M(D,b);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=i;var E=a(1),L=function(M){return M&&M.__esModule?M:{default:M}}(E),_=a(11),y=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],I={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(e,t,a){"use strict";function i(T){return T&&T.__esModule?T:{default:T}}Object.defineProperty(t,"__esModule",{value:!0});var c=a(60),R=i(c),E=a(3),L=i(E),_=a(61),y=i(_),I=a(62),M=i(I),D=a(1),b=i(D),A=a(7),u=i(A),r=a(5),o=a(2),n=i(o),s=a(63),d=i(s),l={};l.safeCall=R.default,l.safeIncrement=L.default,l.getComputedStyle=y.default,l.secondsToMs=M.default,l.assign=b.default,l.headersStringToObject=u.default,l.extractHostnameAndDomain=r.extractHostnameAndDomain,l.extractHostname=r.extractHostname,l.now=n.default.now,l.manifestParser=d.default,t.default=l},function(e,t,a){"use strict";function i(E,L,_,y){var I=y;if(E&&typeof E[L]=="function")try{I=E[L].apply(E,_)}catch(M){R.default.info("safeCall error",M)}return I}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var c=a(4),R=function(E){return E&&E.__esModule?E:{default:E}}(c)},function(e,t,a){"use strict";function i(L,_){if(L&&_&&R.default&&typeof R.default.getComputedStyle=="function"){var y=void 0;return E&&E.has(L)&&(y=E.get(L)),y||(y=R.default.getComputedStyle(L,null),E&&E.set(L,y)),y.getPropertyValue(_)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var c=a(0),R=function(L){return L&&L.__esModule?L:{default:L}}(c),E=void 0;R.default&&R.default.WeakMap&&(E=new WeakMap)},function(e,t,a){"use strict";function i(c){return Math.floor(1e3*c)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i},function(e,t,a){"use strict";function i(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(t,"__esModule",{value:!0});var c=a(1),R=i(c),E=a(14),L=i(E),_={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(n){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(n),this.manifest};y.prototype.process=function(n){var s=void 0;for(this.buffer+=n,s=this.buffer.indexOf(`
5
+ `);s>-1;s=this.buffer.indexOf(`
6
+ `))this.processLine(this.buffer.substring(0,s)),this.buffer=this.buffer.substring(s+1)},y.prototype.processLine=function(n){var s=n.indexOf(":"),d=r(n,s),l=d[0],T=d.length===2?D(d[1]):void 0;if(l[0]!=="#")this.currentUri.uri=l,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(l){case _.TARGET_DURATION:if(!isFinite(T)||T<0)return;this.manifest.targetDuration=T,this.setHoldBack();break;case _.PART_INF:I(this.manifest,d),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:I(this.manifest,d),this.setHoldBack();break;case _.INF:T===0?this.currentUri.duration=.01:T>0&&(this.currentUri.duration=T);break;case _.PROGRAM_DATE_TIME:var g=T,m=new Date(g);this.manifest.dateTimeString||(this.manifest.dateTimeString=g,this.manifest.dateTimeObject=m),this.currentUri.dateTimeString=g,this.currentUri.dateTimeObject=m;break;case _.VERSION:I(this.manifest,d);break;case _.SESSION_DATA:var p=o(d[1]),v=(0,L.default)(p);(0,R.default)(this.manifest.sessionData,v)}},y.prototype.setHoldBack=function(){var n=this.manifest,s=n.serverControl,d=n.targetDuration,l=n.partTargetDuration;if(s){var T="holdBack",g="partHoldBack",m=d&&3*d,p=l&&2*l;d&&!s.hasOwnProperty(T)&&(s[T]=m),m&&s[T]<m&&(s[T]=m),l&&!s.hasOwnProperty(g)&&(s[g]=3*l),l&&s[g]<p&&(s[g]=p)}};var I=function(n,s){var d=M(s[0].replace("#EXT-X-","")),l=void 0;u(s[1])?(l={},l=(0,R.default)(A(s[1]),l)):l=D(s[1]),n[d]=l},M=function(n){return n.toLowerCase().replace(/-(\w)/g,function(s){return s[1].toUpperCase()})},D=function(n){if(n.toLowerCase()==="yes"||n.toLowerCase()==="no")return n.toLowerCase()==="yes";var s=n.indexOf(":")!==-1?n:parseFloat(n);return isNaN(s)?n:s},b=function(n){var s={},d=n.split("=");return d.length>1&&(s[M(d[0])]=D(d[1])),s},A=function(n){for(var s=n.split(","),d={},l=0;s.length>l;l++){var T=s[l],g=b(T);d=(0,R.default)(g,d)}return d},u=function(n){return n.indexOf("=")>-1},r=function(n,s){return s===-1?[n]:[n.substring(0,s),n.substring(s+1)]},o=function(n){var s={};if(n){var d=n.search(",");return[n.slice(0,d),n.slice(d+1)].forEach(function(l,T){for(var g=l.replace(/['"]+/g,"").split("="),m=0;m<g.length;m++)g[m]==="DATA-ID"&&(s["DATA-ID"]=g[1-m]),g[m]==="VALUE"&&(s.VALUE=g[1-m])}),{data:s}}};t.default=y},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i={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"};t.default=i}])})})()});var Lr=yn((rr,Ti)=>{typeof window!="undefined"&&function(e,t){typeof rr=="object"&&typeof Ti=="object"?Ti.exports=t():typeof define=="function"&&define.amd?define([],t):typeof rr=="object"?rr.Hls=t():e.Hls=t()}(rr,function(){return function(f){var e={};function t(a){if(e[a])return e[a].exports;var i=e[a]={i:a,l:!1,exports:{}};return f[a].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=f,t.c=e,t.d=function(a,i,c){t.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:c})},t.r=function(a){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},t.t=function(a,i){if(i&1&&(a=t(a)),i&8||i&4&&typeof a=="object"&&a&&a.__esModule)return a;var c=Object.create(null);if(t.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:a}),i&2&&typeof a!="string")for(var R in a)t.d(c,R,function(E){return a[E]}.bind(null,R));return c},t.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return t.d(i,"a",i),i},t.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},t.p="/dist/",t(t.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(f,e,t){"use strict";var a=Object.prototype.hasOwnProperty,i="~";function c(){}Object.create&&(c.prototype=Object.create(null),new c().__proto__||(i=!1));function R(y,I,M){this.fn=y,this.context=I,this.once=M||!1}function E(y,I,M,D,b){if(typeof M!="function")throw new TypeError("The listener must be a function");var A=new R(M,D||y,b),u=i?i+I:I;return y._events[u]?y._events[u].fn?y._events[u]=[y._events[u],A]:y._events[u].push(A):(y._events[u]=A,y._eventsCount++),y}function L(y,I){--y._eventsCount==0?y._events=new c:delete y._events[I]}function _(){this._events=new c,this._eventsCount=0}_.prototype.eventNames=function(){var I=[],M,D;if(this._eventsCount===0)return I;for(D in M=this._events)a.call(M,D)&&I.push(i?D.slice(1):D);return Object.getOwnPropertySymbols?I.concat(Object.getOwnPropertySymbols(M)):I},_.prototype.listeners=function(I){var M=i?i+I:I,D=this._events[M];if(!D)return[];if(D.fn)return[D.fn];for(var b=0,A=D.length,u=new Array(A);b<A;b++)u[b]=D[b].fn;return u},_.prototype.listenerCount=function(I){var M=i?i+I:I,D=this._events[M];return D?D.fn?1:D.length:0},_.prototype.emit=function(I,M,D,b,A,u){var r=i?i+I:I;if(!this._events[r])return!1;var o=this._events[r],n=arguments.length,s,d;if(o.fn){switch(o.once&&this.removeListener(I,o.fn,void 0,!0),n){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,M),!0;case 3:return o.fn.call(o.context,M,D),!0;case 4:return o.fn.call(o.context,M,D,b),!0;case 5:return o.fn.call(o.context,M,D,b,A),!0;case 6:return o.fn.call(o.context,M,D,b,A,u),!0}for(d=1,s=new Array(n-1);d<n;d++)s[d-1]=arguments[d];o.fn.apply(o.context,s)}else{var l=o.length,T;for(d=0;d<l;d++)switch(o[d].once&&this.removeListener(I,o[d].fn,void 0,!0),n){case 1:o[d].fn.call(o[d].context);break;case 2:o[d].fn.call(o[d].context,M);break;case 3:o[d].fn.call(o[d].context,M,D);break;case 4:o[d].fn.call(o[d].context,M,D,b);break;default:if(!s)for(T=1,s=new Array(n-1);T<n;T++)s[T-1]=arguments[T];o[d].fn.apply(o[d].context,s)}}return!0},_.prototype.on=function(I,M,D){return E(this,I,M,D,!1)},_.prototype.once=function(I,M,D){return E(this,I,M,D,!0)},_.prototype.removeListener=function(I,M,D,b){var A=i?i+I:I;if(!this._events[A])return this;if(!M)return L(this,A),this;var u=this._events[A];if(u.fn)u.fn===M&&(!b||u.once)&&(!D||u.context===D)&&L(this,A);else{for(var r=0,o=[],n=u.length;r<n;r++)(u[r].fn!==M||b&&!u[r].once||D&&u[r].context!==D)&&o.push(u[r]);o.length?this._events[A]=o.length===1?o[0]:o:L(this,A)}return this},_.prototype.removeAllListeners=function(I){var M;return I?(M=i?i+I:I,this._events[M]&&L(this,M)):(this._events=new c,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=i,_.EventEmitter=_,f.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(f,e,t){(function(a){var i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,c=/^([^\/?#]*)([^]*)$/,R=/(?:\/|^)\.(?=\/)/g,E=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,L={buildAbsoluteURL:function(_,y,I){if(I=I||{},_=_.trim(),y=y.trim(),!y){if(!I.alwaysNormalize)return _;var M=L.parseURL(_);if(!M)throw new Error("Error trying to parse base URL.");return M.path=L.normalizePath(M.path),L.buildURLFromParts(M)}var D=L.parseURL(y);if(!D)throw new Error("Error trying to parse relative URL.");if(D.scheme)return I.alwaysNormalize?(D.path=L.normalizePath(D.path),L.buildURLFromParts(D)):y;var b=L.parseURL(_);if(!b)throw new Error("Error trying to parse base URL.");if(!b.netLoc&&b.path&&b.path[0]!=="/"){var A=c.exec(b.path);b.netLoc=A[1],b.path=A[2]}b.netLoc&&!b.path&&(b.path="/");var u={scheme:b.scheme,netLoc:D.netLoc,path:null,params:D.params,query:D.query,fragment:D.fragment};if(!D.netLoc&&(u.netLoc=b.netLoc,D.path[0]!=="/"))if(!D.path)u.path=b.path,D.params||(u.params=b.params,D.query||(u.query=b.query));else{var r=b.path,o=r.substring(0,r.lastIndexOf("/")+1)+D.path;u.path=L.normalizePath(o)}return u.path===null&&(u.path=I.alwaysNormalize?L.normalizePath(D.path):D.path),L.buildURLFromParts(u)},parseURL:function(_){var y=i.exec(_);return y?{scheme:y[1]||"",netLoc:y[2]||"",path:y[3]||"",params:y[4]||"",query:y[5]||"",fragment:y[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(R,"");_.length!==(_=_.replace(E,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};f.exports=L})(this)},"./node_modules/webworkify-webpack/index.js":function(f,e,t){function a(I){var M={};function D(A){if(M[A])return M[A].exports;var u=M[A]={i:A,l:!1,exports:{}};return I[A].call(u.exports,u,u.exports,D),u.l=!0,u.exports}D.m=I,D.c=M,D.i=function(A){return A},D.d=function(A,u,r){D.o(A,u)||Object.defineProperty(A,u,{configurable:!1,enumerable:!0,get:r})},D.r=function(A){Object.defineProperty(A,"__esModule",{value:!0})},D.n=function(A){var u=A&&A.__esModule?function(){return A.default}:function(){return A};return D.d(u,"a",u),u},D.o=function(A,u){return Object.prototype.hasOwnProperty.call(A,u)},D.p="/",D.oe=function(A){throw console.error(A),A};var b=D(D.s=ENTRY_MODULE);return b.default||b}var i="[\\.|\\-|\\+|\\w|/|@]+",c="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+i+").*?\\)";function R(I){return(I+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function E(I){return!isNaN(1*I)}function L(I,M,D){var b={};b[D]=[];var A=M.toString(),u=A.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return b;for(var r=u[1],o=new RegExp("(\\\\n|\\W)"+R(r)+c,"g"),n;n=o.exec(A);)n[3]!=="dll-reference"&&b[D].push(n[3]);for(o=new RegExp("\\("+R(r)+'\\("(dll-reference\\s('+i+'))"\\)\\)'+c,"g");n=o.exec(A);)I[n[2]]||(b[D].push(n[1]),I[n[2]]=t(n[1]).m),b[n[2]]=b[n[2]]||[],b[n[2]].push(n[4]);for(var s=Object.keys(b),d=0;d<s.length;d++)for(var l=0;l<b[s[d]].length;l++)E(b[s[d]][l])&&(b[s[d]][l]=1*b[s[d]][l]);return b}function _(I){var M=Object.keys(I);return M.reduce(function(D,b){return D||I[b].length>0},!1)}function y(I,M){for(var D={main:[M]},b={main:[]},A={main:{}};_(D);)for(var u=Object.keys(D),r=0;r<u.length;r++){var o=u[r],n=D[o],s=n.pop();if(A[o]=A[o]||{},!(A[o][s]||!I[o][s])){A[o][s]=!0,b[o]=b[o]||[],b[o].push(s);for(var d=L(I,I[o][s],o),l=Object.keys(d),T=0;T<l.length;T++)D[l[T]]=D[l[T]]||[],D[l[T]]=D[l[T]].concat(d[l[T]])}}return b}f.exports=function(I,M){M=M||{};var D={main:t.m},b=M.all?{main:Object.keys(D.main)}:y(D,I),A="";Object.keys(b).filter(function(s){return s!=="main"}).forEach(function(s){for(var d=0;b[s][d];)d++;b[s].push(d),D[s][d]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",A=A+"var "+s+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(d))+")({"+b[s].map(function(l){return""+JSON.stringify(l)+": "+D[s][l].toString()}).join(",")+`});
7
+ `}),A=A+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(I))+")({"+b.main.map(function(s){return""+JSON.stringify(s)+": "+D.main[s].toString()}).join(",")+"}))(self);";var u=new window.Blob([A],{type:"text/javascript"});if(M.bare)return u;var r=window.URL||window.webkitURL||window.mozURL||window.msURL,o=r.createObjectURL(u),n=new window.Worker(o);return n.objectURL=o,n}},"./src/config.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"hlsDefaultConfig",function(){return T}),t.d(e,"mergeConfig",function(){return m}),t.d(e,"enableStreamingMode",function(){return p});var a=t("./src/controller/abr-controller.ts"),i=t("./src/controller/audio-stream-controller.ts"),c=t("./src/controller/audio-track-controller.ts"),R=t("./src/controller/subtitle-stream-controller.ts"),E=t("./src/controller/subtitle-track-controller.ts"),L=t("./src/controller/buffer-controller.ts"),_=t("./src/controller/timeline-controller.ts"),y=t("./src/controller/cap-level-controller.ts"),I=t("./src/controller/fps-controller.ts"),M=t("./src/controller/eme-controller.ts"),D=t("./src/controller/cmcd-controller.ts"),b=t("./src/utils/xhr-loader.ts"),A=t("./src/utils/fetch-loader.ts"),u=t("./src/utils/cues.ts"),r=t("./src/utils/mediakeys-helper.ts"),o=t("./src/utils/logger.ts");function n(){return n=Object.assign||function(v){for(var h=1;h<arguments.length;h++){var x=arguments[h];for(var S in x)Object.prototype.hasOwnProperty.call(x,S)&&(v[S]=x[S])}return v},n.apply(this,arguments)}function s(v,h){var x=Object.keys(v);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(v);h&&(S=S.filter(function(C){return Object.getOwnPropertyDescriptor(v,C).enumerable})),x.push.apply(x,S)}return x}function d(v){for(var h=1;h<arguments.length;h++){var x=arguments[h]!=null?arguments[h]:{};h%2?s(Object(x),!0).forEach(function(S){l(v,S,x[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(x)):s(Object(x)).forEach(function(S){Object.defineProperty(v,S,Object.getOwnPropertyDescriptor(x,S))})}return v}function l(v,h,x){return h in v?Object.defineProperty(v,h,{value:x,enumerable:!0,configurable:!0,writable:!0}):v[h]=x,v}var T=d(d({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!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:b.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:a.default,bufferController:L.default,capLevelController:y.default,fpsController:I.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:r.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},g()),{},{subtitleStreamController:R.SubtitleStreamController,subtitleTrackController:E.default,timelineController:_.TimelineController,audioStreamController:i.default,audioTrackController:c.default,emeController:M.default,cmcdController:D.default});function g(){return{cueHandler:u.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function m(v,h){if((h.liveSyncDurationCount||h.liveMaxLatencyDurationCount)&&(h.liveSyncDuration||h.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(h.liveMaxLatencyDurationCount!==void 0&&(h.liveSyncDurationCount===void 0||h.liveMaxLatencyDurationCount<=h.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(h.liveMaxLatencyDuration!==void 0&&(h.liveSyncDuration===void 0||h.liveMaxLatencyDuration<=h.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return n({},v,h)}function p(v){var h=v.loader;if(h!==A.default&&h!==b.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),v.progressive=!1;else{var x=Object(A.fetchSupported)();x&&(v.loader=A.default,v.progressive=!0,v.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/polyfills/number.ts"),i=t("./src/utils/ewma-bandwidth-estimator.ts"),c=t("./src/events.ts"),R=t("./src/utils/buffer-helper.ts"),E=t("./src/errors.ts"),L=t("./src/types/loader.ts"),_=t("./src/utils/logger.ts");function y(D,b){for(var A=0;A<b.length;A++){var u=b[A];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(D,u.key,u)}}function I(D,b,A){return b&&y(D.prototype,b),A&&y(D,A),D}var M=function(){function D(A){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=A;var u=A.config;this.bwEstimator=new i.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var b=D.prototype;return b.registerListeners=function(){var u=this.hls;u.on(c.Events.FRAG_LOADING,this.onFragLoading,this),u.on(c.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(c.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(c.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(c.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var u=this.hls;u.off(c.Events.FRAG_LOADING,this.onFragLoading,this),u.off(c.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(c.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(c.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(c.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},b.onFragLoading=function(u,r){var o=r.frag;if(o.type===L.PlaylistLevelType.MAIN&&!this.timer){var n;this.fragCurrent=o,this.partCurrent=(n=r.part)!=null?n:null,this.timer=self.setInterval(this.onCheck,100)}},b.onLevelLoaded=function(u,r){var o=this.hls.config;r.details.live?this.bwEstimator.update(o.abrEwmaSlowLive,o.abrEwmaFastLive):this.bwEstimator.update(o.abrEwmaSlowVoD,o.abrEwmaFastVoD)},b._abandonRulesCheck=function(){var u=this.fragCurrent,r=this.partCurrent,o=this.hls,n=o.autoLevelEnabled,s=o.config,d=o.media;if(!(!u||!d)){var l=r?r.stats:u.stats,T=r?r.duration:u.duration;if(l.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!n||d.paused||!d.playbackRate||!d.readyState)){var g=performance.now()-l.loading.start,m=Math.abs(d.playbackRate);if(!(g<=500*T/m)){var p=o.levels,v=o.minAutoLevel,h=p[u.level],x=l.total||Math.max(l.loaded,Math.round(T*h.maxBitrate/8)),S=Math.max(1,l.bwEstimate?l.bwEstimate/8:l.loaded*1e3/g),C=(x-l.loaded)/S,O=d.currentTime,P=(R.BufferHelper.bufferInfo(d,O,s.maxBufferHole).end-O)/m;if(!(P>=2*T/m||C<=P)){var w=Number.POSITIVE_INFINITY,U;for(U=u.level-1;U>v;U--){var k=p[U].maxBitrate;if(w=T*k/(8*.8*S),w<P)break}if(!(w>=C)){var N=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+u.sn+(r?" part "+r.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+U+`
8
+ Current BW estimate: `+(Object(a.isFiniteNumber)(N)?(N/1024).toFixed(3):"Unknown")+` Kb/s
9
+ Estimated load time for current fragment: `+C.toFixed(3)+` s
10
10
  Estimated load time for the next fragment: `+w.toFixed(3)+` s
11
- Time to underbuffer: `+P.toFixed(3)+" s"),s.nextLoadLevel=U,this.bwEstimator.sample(p,o.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),s.trigger(h.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:r,stats:o})}}}}}},b.onFragLoaded=function(u,r){var s=r.frag,i=r.part;if(s.type===L.PlaylistLevelType.MAIN&&Object(l.isFiniteNumber)(s.sn)){var a=i?i.stats:s.stats,d=i?i.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=this.hls.levels[s.level],y=(o.loaded?o.loaded.bytes:0)+a.loaded,p=(o.loaded?o.loaded.duration:0)+d;o.loaded={bytes:y,duration:p},o.realBitrate=Math.round(8*y/p)}if(s.bitrateTest){var m={stats:a,frag:s,part:i,id:s.type};this.onFragBuffered(h.Events.FRAG_BUFFERED,m),s.bitrateTest=!1}}},b.onFragBuffered=function(u,r){var s=r.frag,i=r.part,a=i?i.stats:s.stats;if(!a.aborted&&!(s.type!==L.PlaylistLevelType.MAIN||s.sn==="initSegment")){var d=a.parsing.end-a.loading.start;this.bwEstimator.sample(d,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0}},b.onError=function(u,r){switch(r.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},b.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},b.getNextABRAutoLevel=function(){var u=this.fragCurrent,r=this.partCurrent,s=this.hls,i=s.maxAutoLevel,a=s.config,d=s.minAutoLevel,o=s.media,y=r?r.duration:u?u.duration:0,p=o?o.currentTime:0,m=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1,g=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,f=(R.BufferHelper.bufferInfo(o,p,a.maxBufferHole).end-p)/m,c=this.findBestLevel(g,d,i,f,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(c>=0)return c;_.logger.trace((f?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var x=y?Math.min(y,a.maxStarvationDelay):a.maxStarvationDelay,S=a.abrBandWidthFactor,O=a.abrBandWidthUpFactor;if(!f){var C=this.bitrateTestDelay;if(C){var P=y?Math.min(y,a.maxLoadingDelay):a.maxLoadingDelay;x=P-C,_.logger.trace("bitrate test took "+Math.round(1e3*C)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*x)+" ms"),S=O=1}}return c=this.findBestLevel(g,d,i,f+x,S,O),Math.max(c,0)},b.findBestLevel=function(u,r,s,i,a,d){for(var o,y=this.fragCurrent,p=this.partCurrent,m=this.lastLoadedFragLevel,g=this.hls.levels,f=g[m],c=!!(f!=null&&(o=f.details)!==null&&o!==void 0&&o.live),x=f==null?void 0:f.codecSet,S=p?p.duration:y?y.duration:0,O=s;O>=r;O--){var C=g[O];if(!(!C||x&&C.codecSet!==x)){var P=C.details,w=(p?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||S,U=void 0;O<=m?U=a*u:U=d*u;var k=g[O].maxBitrate,N=k*w/U;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+O+"/"+Math.round(U)+"/"+k+"/"+w+"/"+i+"/"+N),U>k&&(!N||c&&!this.bitrateTestDelay||N<i))return O}}return-1},I(D,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,r=this.bwEstimator;if(u!==-1&&(!r||!r.canEstimate()))return u;var s=this.getNextABRAutoLevel();return u!==-1&&(s=Math.min(u,s)),s},set:function(u){this._nextAutoLevel=u}}]),D}();e.default=M},"./src/controller/audio-stream-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/polyfills/number.ts"),n=t("./src/controller/base-stream-controller.ts"),h=t("./src/events.ts"),R=t("./src/utils/buffer-helper.ts"),T=t("./src/controller/fragment-tracker.ts"),L=t("./src/types/level.ts"),_=t("./src/types/loader.ts"),E=t("./src/loader/fragment.ts"),I=t("./src/demux/chunk-cache.ts"),M=t("./src/demux/transmuxer-interface.ts"),D=t("./src/types/transmuxer.ts"),b=t("./src/controller/fragment-finders.ts"),A=t("./src/utils/discontinuities.ts"),u=t("./src/errors.ts"),r=t("./src/utils/logger.ts");function s(){return s=Object.assign||function(y){for(var p=1;p<arguments.length;p++){var m=arguments[p];for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(y[g]=m[g])}return y},s.apply(this,arguments)}function i(y,p){y.prototype=Object.create(p.prototype),y.prototype.constructor=y,a(y,p)}function a(y,p){return a=Object.setPrototypeOf||function(g,f){return g.__proto__=f,g},a(y,p)}var d=100,o=function(y){i(p,y);function p(g,f){var c;return c=y.call(this,g,f,"[audio-stream-controller]")||this,c.videoBuffer=null,c.videoTrackCC=-1,c.waitingVideoCC=-1,c.audioSwitch=!1,c.trackId=-1,c.waitingData=null,c.mainDetails=null,c.bufferFlushed=!1,c._registerListeners(),c}var m=p.prototype;return m.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},m._registerListeners=function(){var f=this.hls;f.on(h.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.on(h.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(h.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(h.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(h.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),f.on(h.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.on(h.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.on(h.Events.ERROR,this.onError,this),f.on(h.Events.BUFFER_RESET,this.onBufferReset,this),f.on(h.Events.BUFFER_CREATED,this.onBufferCreated,this),f.on(h.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.on(h.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),f.on(h.Events.FRAG_BUFFERED,this.onFragBuffered,this)},m._unregisterListeners=function(){var f=this.hls;f.off(h.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.off(h.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.off(h.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(h.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(h.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),f.off(h.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.off(h.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),f.off(h.Events.ERROR,this.onError,this),f.off(h.Events.BUFFER_RESET,this.onBufferReset,this),f.off(h.Events.BUFFER_CREATED,this.onBufferCreated,this),f.off(h.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.off(h.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),f.off(h.Events.FRAG_BUFFERED,this.onFragBuffered,this)},m.onInitPtsFound=function(f,c){var x=c.frag,S=c.id,O=c.initPTS;if(S==="main"){var C=x.cc;this.initPTS[x.cc]=O,this.log("InitPTS for cc: "+C+" found from main: "+O),this.videoTrackCC=C,this.state===n.State.WAITING_INIT_PTS&&this.tick()}},m.startLoad=function(f){if(!this.levels){this.startPosition=f,this.state=n.State.STOPPED;return}var c=this.lastCurrentTime;this.stopLoad(),this.setInterval(d),this.fragLoadError=0,c>0&&f===-1?(this.log("Override startPosition with lastCurrentTime @"+c.toFixed(3)),this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=f,this.tick()},m.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_TRACK:{var f,c=this.levels,x=this.trackId,S=c==null||(f=c[x])===null||f===void 0?void 0:f.details;if(S){if(this.waitForCdnTuneIn(S))break;this.state=n.State.WAITING_INIT_PTS}break}case n.State.FRAG_LOADING_WAITING_RETRY:{var O,C=performance.now(),P=this.retryDate;(!P||C>=P||(O=this.media)!==null&&O!==void 0&&O.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=n.State.IDLE);break}case n.State.WAITING_INIT_PTS:{var w=this.waitingData;if(w){var U=w.frag,k=w.part,N=w.cache,B=w.complete;if(this.initPTS[U.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var K=N.flush(),W={frag:U,part:k,payload:K,networkDetails:null};this._handleFragmentLoadProgress(W),B&&y.prototype._handleFragmentLoadComplete.call(this,W)}else if(this.videoTrackCC!==this.waitingVideoCC)r.logger.log("Waiting fragment cc ("+U.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var F=this.getLoadPosition(),H=R.BufferHelper.bufferInfo(this.mediaBuffer,F,this.config.maxBufferHole),Y=Object(b.fragmentWithinToleranceTest)(H.end,this.config.maxFragLookUpTolerance,U);Y<0&&(r.logger.log("Waiting fragment cc ("+U.cc+") @ "+U.start+" cancelled because another fragment at "+H.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}}this.onTickEnd()},m.clearWaitingFragment=function(){var f=this.waitingData;f&&(this.fragmentTracker.removeFragment(f.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},m.onTickEnd=function(){var f=this.media;if(!(!f||!f.readyState)){var c=this.mediaBuffer?this.mediaBuffer:f,x=c.buffered;!this.loadedmetadata&&x.length&&(this.loadedmetadata=!0),this.lastCurrentTime=f.currentTime}},m.doTickIdle=function(){var f,c,x=this.hls,S=this.levels,O=this.media,C=this.trackId,P=x.config;if(!(!S||!S[C])&&!(!O&&(this.startFragRequested||!P.startFragPrefetch))){var w=S[C],U=w.details;if(!U||U.live&&this.levelLastLoaded!==C||this.waitForCdnTuneIn(U)){this.state=n.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,E.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var k=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.AUDIO);if(k!==null){var N=k.len,B=this.getMaxBufferLength(),K=this.audioSwitch;if(!(N>=B&&!K)){if(!K&&this._streamEnded(k,U)){x.trigger(h.Events.BUFFER_EOS,{type:"audio"}),this.state=n.State.ENDED;return}var W=U.fragments,F=W[0].start,H=k.end;if(K){var Y=this.getLoadPosition();H=Y,U.PTSKnown&&Y<F&&(k.end>F||k.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),O.currentTime=F+.05)}var $=this.getNextFragment(H,U);if(!$){this.bufferFlushed=!0;return}((f=$.decryptdata)===null||f===void 0?void 0:f.keyFormat)==="identity"&&!((c=$.decryptdata)!==null&&c!==void 0&&c.key)?this.loadKey($,U):this.loadFragment($,U,H)}}}},m.getMaxBufferLength=function(){var f=y.prototype.getMaxBufferLength.call(this),c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN);return c===null?f:Math.max(f,c.len)},m.onMediaDetaching=function(){this.videoBuffer=null,y.prototype.onMediaDetaching.call(this)},m.onAudioTracksUpdated=function(f,c){var x=c.audioTracks;this.resetTransmuxer(),this.levels=x.map(function(S){return new L.Level(S)})},m.onAudioTrackSwitching=function(f,c){var x=!!c.url;this.trackId=c.id;var S=this.fragCurrent;S!=null&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),x?this.setInterval(d):this.resetTransmuxer(),x?(this.audioSwitch=!0,this.state=n.State.IDLE):this.state=n.State.STOPPED,this.tick()},m.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},m.onLevelLoaded=function(f,c){this.mainDetails=c.details},m.onAudioTrackLoaded=function(f,c){var x,S=this.levels,O=c.details,C=c.id;if(!S){this.warn("Audio tracks were reset while loading level "+C);return}this.log("Track "+C+" loaded ["+O.startSN+","+O.endSN+"],duration:"+O.totalduration);var P=S[C],w=0;if(O.live||(x=P.details)!==null&&x!==void 0&&x.live){var U=this.mainDetails;if(O.fragments[0]||(O.deltaUpdateFailed=!0),O.deltaUpdateFailed||!U)return;!P.details&&O.hasProgramDateTime&&U.hasProgramDateTime?(Object(A.alignMediaPlaylistByPDT)(O,U),w=O.fragments[0].start):w=this.alignPlaylists(O,P.details)}P.details=O,this.levelLastLoaded=C,!this.startFragRequested&&(this.mainDetails||!O.live)&&this.setStartPosition(P.details,w),this.state===n.State.WAITING_TRACK&&!this.waitForCdnTuneIn(O)&&(this.state=n.State.IDLE),this.tick()},m._handleFragmentLoadProgress=function(f){var c,x=f.frag,S=f.part,O=f.payload,C=this.config,P=this.trackId,w=this.levels;if(!w){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+x.sn+" of level "+x.level+" will not be buffered");return}var U=w[P];console.assert(U,"Audio track is defined on fragment load progress");var k=U.details;console.assert(k,"Audio track details are defined on fragment load progress");var N=C.defaultAudioCodec||U.audioCodec||"mp4a.40.2",B=this.transmuxer;B||(B=this.transmuxer=new M.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var K=this.initPTS[x.cc],W=(c=x.initSegment)===null||c===void 0?void 0:c.data;if(K!==void 0){var F=!1,H=S?S.index:-1,Y=H!==-1,$=new D.ChunkMetadata(x.level,x.sn,x.stats.chunkCount,O.byteLength,H,Y);B.push(O,W,N,"",x,S,k.totalduration,F,$,K)}else{r.logger.log("Unknown video PTS for cc "+x.cc+", waiting for video PTS before demuxing audio frag "+x.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+P);var Z=this.waitingData=this.waitingData||{frag:x,part:S,cache:new I.default,complete:!1},q=Z.cache;q.push(new Uint8Array(O)),this.waitingVideoCC=this.videoTrackCC,this.state=n.State.WAITING_INIT_PTS}},m._handleFragmentLoadComplete=function(f){if(this.waitingData){this.waitingData.complete=!0;return}y.prototype._handleFragmentLoadComplete.call(this,f)},m.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},m.onBufferCreated=function(f,c){var x=c.tracks.audio;x&&(this.mediaBuffer=x.buffer),c.tracks.video&&(this.videoBuffer=c.tracks.video.buffer)},m.onFragBuffered=function(f,c){var x=c.frag,S=c.part;if(x.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(x)){this.warn("Fragment "+x.sn+(S?" p: "+S.index:"")+" of level "+x.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}x.sn!=="initSegment"&&(this.fragPrevious=x,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(h.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(x,S)}},m.onError=function(f,c){switch(c.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,c);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==n.State.ERROR&&this.state!==n.State.STOPPED&&(this.state=c.fatal?n.State.ERROR:n.State.IDLE,this.warn(c.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(c.parent==="audio"&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var x=!0,S=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);S&&S.len>.5&&(x=!this.reduceMaxBufferLength(S.len)),x&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,y.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},m.onBufferFlushed=function(f,c){var x=c.type;x===E.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},m._handleTransmuxComplete=function(f){var c,x="audio",S=this.hls,O=f.remuxResult,C=f.chunkMeta,P=this.getCurrentContext(C);if(!P){this.warn("The loading context changed while buffering fragment "+C.sn+" of level "+C.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(C.level);return}var w=P.frag,U=P.part,k=O.audio,N=O.text,B=O.id3,K=O.initSegment;if(!this.fragContextChanged(w)){if(this.state=n.State.PARSING,this.audioSwitch&&k&&this.completeAudioSwitch(),K!=null&&K.tracks&&(this._bufferInitSegment(K.tracks,w,C),S.trigger(h.Events.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:x,tracks:K.tracks})),k){var W=k.startPTS,F=k.endPTS,H=k.startDTS,Y=k.endDTS;U&&(U.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:W,endPTS:F,startDTS:H,endDTS:Y}),w.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,W,F,H,Y),this.bufferFragmentData(k,w,U,C)}if(B!=null&&(c=B.samples)!==null&&c!==void 0&&c.length){var $=s({frag:w,id:x},B);S.trigger(h.Events.FRAG_PARSING_METADATA,$)}if(N){var Z=s({frag:w,id:x},N);S.trigger(h.Events.FRAG_PARSING_USERDATA,Z)}}},m._bufferInitSegment=function(f,c,x){if(this.state===n.State.PARSING){f.video&&delete f.video;var S=f.audio;if(!!S){S.levelCodec=S.codec,S.id="audio",this.log("Init audio buffer, container:"+S.container+", codecs[parsed]=["+S.codec+"]"),this.hls.trigger(h.Events.BUFFER_CODECS,f);var O=S.initSegment;if(O!=null&&O.byteLength){var C={type:"audio",frag:c,part:null,chunkMeta:x,parent:c.type,data:O};this.hls.trigger(h.Events.BUFFER_APPENDING,C)}this.tick()}}},m.loadFragment=function(f,c,x){var S=this.fragmentTracker.getState(f);this.fragCurrent=f,(this.audioSwitch||S===T.FragmentState.NOT_LOADED||S===T.FragmentState.PARTIAL)&&(f.sn==="initSegment"?this._loadInitSegment(f):c.live&&!Object(l.isFiniteNumber)(this.initPTS[f.cc])?(this.log("Waiting for video PTS in continuity counter "+f.cc+" of live stream before loading audio fragment "+f.sn+" of level "+this.trackId),this.state=n.State.WAITING_INIT_PTS):(this.startFragRequested=!0,y.prototype.loadFragment.call(this,f,c,x)))},m.completeAudioSwitch=function(){var f=this.hls,c=this.media,x=this.trackId;c&&(this.log("Switching audio track : flushing all audio"),y.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,f.trigger(h.Events.AUDIO_TRACK_SWITCHED,{id:x})},p}(n.default);e.default=o},"./src/controller/audio-track-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/events.ts"),n=t("./src/errors.ts"),h=t("./src/controller/base-playlist-controller.ts"),R=t("./src/types/loader.ts");function T(M,D){for(var b=0;b<D.length;b++){var A=D[b];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(M,A.key,A)}}function L(M,D,b){return D&&T(M.prototype,D),b&&T(M,b),M}function _(M,D){M.prototype=Object.create(D.prototype),M.prototype.constructor=M,E(M,D)}function E(M,D){return E=Object.setPrototypeOf||function(A,u){return A.__proto__=u,A},E(M,D)}var I=function(M){_(D,M);function D(A){var u;return u=M.call(this,A,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var b=D.prototype;return b.registerListeners=function(){var u=this.hls;u.on(l.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(l.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(l.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(l.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(l.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var u=this.hls;u.off(l.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(l.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(l.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(l.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(l.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,M.prototype.destroy.call(this)},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},b.onManifestParsed=function(u,r){this.tracks=r.audioTracks||[]},b.onAudioTrackLoaded=function(u,r){var s=r.id,i=r.details,a=this.tracksInGroup[s];if(!a){this.warn("Invalid audio track id "+s);return}var d=a.details;a.details=r.details,this.log("audioTrack "+s+" loaded ["+i.startSN+"-"+i.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,r,d))},b.onLevelLoading=function(u,r){this.switchLevel(r.level)},b.onLevelSwitching=function(u,r){this.switchLevel(r.level)},b.switchLevel=function(u){var r=this.hls.levels[u];if(!!(r!=null&&r.audioGroupIds)){var s=r.audioGroupIds[r.urlId];if(this.groupId!==s){this.groupId=s;var i=this.tracks.filter(function(d){return!s||d.groupId===s});this.selectDefaultTrack&&!i.some(function(d){return d.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=i;var a={audioTracks:i};this.log("Updating audio tracks, "+i.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(l.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},b.onError=function(u,r){M.prototype.onError.call(this,u,r),!(r.fatal||!r.context)&&r.context.type===R.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},b.setAudioTrack=function(u){var r=this.tracksInGroup;if(u<0||u>=r.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=r[this.trackId];this.log("Now switching to audio-track index "+u);var i=r[u],a=i.id,d=i.groupId,o=d===void 0?"":d,y=i.name,p=i.type,m=i.url;if(this.trackId=u,this.trackName=y,this.selectDefaultTrack=!1,this.hls.trigger(l.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:o,name:y,type:p,url:m}),!(i.details&&!i.details.live)){var g=this.switchParams(i.url,s==null?void 0:s.details);this.loadPlaylist(g)}},b.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var r=this.trackName,s=this.findTrackId(r)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},b.findTrackId=function(u){for(var r=this.tracksInGroup,s=0;s<r.length;s++){var i=r[s];if((!this.selectDefaultTrack||i.default)&&(!u||u===i.name))return i.id}return-1},b.loadPlaylist=function(u){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var s=r.id,i=r.groupId,a=r.url;if(u)try{a=u.addDirectives(a)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(l.Events.AUDIO_TRACK_LOADING,{url:a,id:s,groupId:i,deliveryDirectives:u||null})}},L(D,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),D}(h.default);e.default=I},"./src/controller/base-playlist-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return L});var l=t("./src/polyfills/number.ts"),n=t("./src/types/level.ts"),h=t("./src/controller/level-helper.ts"),R=t("./src/utils/logger.ts"),T=t("./src/errors.ts"),L=function(){function _(I,M){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=R.logger.log.bind(R.logger,M+":"),this.warn=R.logger.warn.bind(R.logger,M+":"),this.hls=I}var E=_.prototype;return E.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},E.onError=function(M,D){D.fatal&&D.type===T.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},E.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},E.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},E.stopLoad=function(){this.canLoad=!1,this.clearTimer()},E.switchParams=function(M,D){var b=D==null?void 0:D.renditionReports;if(b)for(var A=0;A<b.length;A++){var u=b[A],r=""+u.URI;if(r===M.substr(-r.length)){var s=parseInt(u["LAST-MSN"]),i=parseInt(u["LAST-PART"]);if(D&&this.hls.config.lowLatencyMode){var a=Math.min(D.age-D.partTarget,D.targetduration);i!==void 0&&a>D.partTarget&&(i+=1)}if(Object(l.isFiniteNumber)(s))return new n.HlsUrlParameters(s,Object(l.isFiniteNumber)(i)?i:void 0,n.HlsSkip.No)}}},E.loadPlaylist=function(M){},E.shouldLoadTrack=function(M){return this.canLoad&&M&&!!M.url&&(!M.details||M.details.live)},E.playlistLoaded=function(M,D,b){var A=this,u=D.details,r=D.stats,s=r.loading.end?Math.max(0,self.performance.now()-r.loading.end):0;if(u.advancedDateTime=Date.now()-s,u.live||b!=null&&b.live){if(u.reloaded(b),b&&this.log("live playlist "+M+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),b&&u.fragments.length>0&&Object(h.mergeDetails)(b,u),!this.canLoad||!u.live)return;var i,a=void 0,d=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var o=this.hls.config.lowLatencyMode,y=u.lastPartSn,p=u.endSN,m=u.lastPartIndex,g=m!==-1,f=y===p,c=o?0:m;g?(a=f?p+1:y,d=f?c:m+1):a=p+1;var x=u.age,S=x+u.ageHeader,O=Math.min(S-u.partTarget,u.targetduration*1.5);if(O>0){if(b&&O>b.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+b.tuneInGoal+" to: "+O+" with playlist age: "+u.age),O=0;else{var C=Math.floor(O/u.targetduration);if(a+=C,d!==void 0){var P=Math.round(O%u.targetduration/u.partTarget);d+=P}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+x.toFixed(2)+"s goal: "+O+" skip sn "+C+" to part "+d)}u.tuneInGoal=O}if(i=this.getDeliveryDirectives(u,D.deliveryDirectives,a,d),o||!f){this.loadPlaylist(i);return}}else i=this.getDeliveryDirectives(u,D.deliveryDirectives,a,d);var w=Object(h.computeReloadInterval)(u,r);a!==void 0&&u.canBlockReload&&(w-=u.partTarget||1),this.log("reload live playlist "+M+" in "+Math.round(w)+" ms"),this.timer=self.setTimeout(function(){return A.loadPlaylist(i)},w)}else this.clearTimer()},E.getDeliveryDirectives=function(M,D,b,A){var u=Object(n.getSkipValue)(M,b);return D!=null&&D.skip&&M.deltaUpdateFailed&&(b=D.msn,A=D.part,u=n.HlsSkip.No),new n.HlsUrlParameters(b,A,u)},E.retryLoadingOrFail=function(M){var D=this,b=this.hls.config,A=this.retryCount<b.levelLoadingMaxRetry;if(A){var u;if(this.retryCount++,M.details.indexOf("LoadTimeOut")>-1&&(u=M.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+M.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*b.levelLoadingRetryDelay,b.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return D.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+M.details+'"')}}else this.warn('cannot recover from error "'+M.details+'"'),this.clearTimer(),M.fatal=!0;return A},_}()},"./src/controller/base-stream-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"State",function(){return p}),t.d(e,"default",function(){return m});var l=t("./src/polyfills/number.ts"),n=t("./src/task-loop.ts"),h=t("./src/controller/fragment-tracker.ts"),R=t("./src/utils/buffer-helper.ts"),T=t("./src/utils/logger.ts"),L=t("./src/events.ts"),_=t("./src/errors.ts"),E=t("./src/types/transmuxer.ts"),I=t("./src/utils/mp4-tools.ts"),M=t("./src/utils/discontinuities.ts"),D=t("./src/controller/fragment-finders.ts"),b=t("./src/controller/level-helper.ts"),A=t("./src/loader/fragment-loader.ts"),u=t("./src/crypt/decrypter.ts"),r=t("./src/utils/time-ranges.ts"),s=t("./src/types/loader.ts");function i(g,f){for(var c=0;c<f.length;c++){var x=f[c];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(g,x.key,x)}}function a(g,f,c){return f&&i(g.prototype,f),c&&i(g,c),g}function d(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function o(g,f){g.prototype=Object.create(f.prototype),g.prototype.constructor=g,y(g,f)}function y(g,f){return y=Object.setPrototypeOf||function(x,S){return x.__proto__=S,x},y(g,f)}var p={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},m=function(g){o(f,g);function f(x,S,O){var C;return C=g.call(this)||this,C.hls=void 0,C.fragPrevious=null,C.fragCurrent=null,C.fragmentTracker=void 0,C.transmuxer=null,C._state=p.STOPPED,C.media=void 0,C.mediaBuffer=void 0,C.config=void 0,C.bitrateTest=!1,C.lastCurrentTime=0,C.nextLoadPosition=0,C.startPosition=0,C.loadedmetadata=!1,C.fragLoadError=0,C.retryDate=0,C.levels=null,C.fragmentLoader=void 0,C.levelLastLoaded=null,C.startFragRequested=!1,C.decrypter=void 0,C.initPTS=[],C.onvseeking=null,C.onvended=null,C.logPrefix="",C.log=void 0,C.warn=void 0,C.logPrefix=O,C.log=T.logger.log.bind(T.logger,O+":"),C.warn=T.logger.warn.bind(T.logger,O+":"),C.hls=x,C.fragmentLoader=new A.default(x.config),C.fragmentTracker=S,C.config=x.config,C.decrypter=new u.default(x,x.config),x.on(L.Events.KEY_LOADED,C.onKeyLoaded,d(C)),C}var c=f.prototype;return c.doTick=function(){this.onTickEnd()},c.onTickEnd=function(){},c.startLoad=function(S){},c.stopLoad=function(){this.fragmentLoader.abort();var S=this.fragCurrent;S&&this.fragmentTracker.removeFragment(S),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=p.STOPPED},c._streamEnded=function(S,O){var C=this.fragCurrent,P=this.fragmentTracker;if(!O.live&&C&&C.sn>=O.endSN&&!S.nextStart){var w=O.partList;if(w!=null&&w.length){var U=w[w.length-1],k=R.BufferHelper.isBuffered(this.media,U.start+U.duration/2);return k}var N=P.getState(C);return N===h.FragmentState.PARTIAL||N===h.FragmentState.OK}return!1},c.onMediaAttached=function(S,O){var C=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),C.addEventListener("seeking",this.onvseeking),C.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===p.STOPPED&&this.startLoad(P.startPosition)},c.onMediaDetaching=function(){var S=this.media;S!=null&&S.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),S&&(S.removeEventListener("seeking",this.onvseeking),S.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},c.onMediaSeeking=function(){var S=this.config,O=this.fragCurrent,C=this.media,P=this.mediaBuffer,w=this.state,U=C?C.currentTime:0,k=R.BufferHelper.bufferInfo(P||C,U,S.maxBufferHole);if(this.log("media seeking to "+(Object(l.isFiniteNumber)(U)?U.toFixed(3):U)+", state: "+w),w===p.ENDED)this.resetLoadingState();else if(O&&!k.len){var N=S.maxFragLookUpTolerance,B=O.start-N,K=O.start+O.duration+N,W=U>K;(U<B||W)&&(W&&O.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),O.loader.abort()),this.resetLoadingState())}C&&(this.lastCurrentTime=U),!this.loadedmetadata&&!k.len&&(this.nextLoadPosition=this.startPosition=U),this.tickImmediate()},c.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},c.onKeyLoaded=function(S,O){if(!(this.state!==p.KEY_LOADING||O.frag!==this.fragCurrent||!this.levels)){this.state=p.IDLE;var C=this.levels[O.frag.level].details;C&&this.loadFragment(O.frag,C,O.frag.start)}},c.onHandlerDestroying=function(){this.stopLoad(),g.prototype.onHandlerDestroying.call(this)},c.onHandlerDestroyed=function(){this.state=p.STOPPED,this.hls.off(L.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,g.prototype.onHandlerDestroyed.call(this)},c.loadKey=function(S,O){this.log("Loading key for "+S.sn+" of ["+O.startSN+"-"+O.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+S.level),this.state=p.KEY_LOADING,this.fragCurrent=S,this.hls.trigger(L.Events.KEY_LOADING,{frag:S})},c.loadFragment=function(S,O,C){this._loadFragForPlayback(S,O,C)},c._loadFragForPlayback=function(S,O,C){var P=this,w=function(k){if(P.fragContextChanged(S)){P.warn("Fragment "+S.sn+(k.part?" p: "+k.part.index:"")+" of level "+S.level+" was dropped during download."),P.fragmentTracker.removeFragment(S);return}S.stats.chunkCount++,P._handleFragmentLoadProgress(k)};this._doFragLoad(S,O,C,w).then(function(U){if(!!U){P.fragLoadError=0;var k=P.state;if(P.fragContextChanged(S)){(k===p.FRAG_LOADING||k===p.BACKTRACKING||!P.fragCurrent&&k===p.PARSING)&&(P.fragmentTracker.removeFragment(S),P.state=p.IDLE);return}if("payload"in U&&(P.log("Loaded fragment "+S.sn+" of level "+S.level),P.hls.trigger(L.Events.FRAG_LOADED,U),P.state===p.BACKTRACKING)){P.fragmentTracker.backtrack(S,U),P.resetFragmentLoading(S);return}P._handleFragmentLoadComplete(U)}}).catch(function(U){P.warn(U),P.resetFragmentLoading(S)})},c.flushMainBuffer=function(S,O,C){if(C===void 0&&(C=null),!!(S-O)){var P={startOffset:S,endOffset:O,type:C};this.fragLoadError=0,this.hls.trigger(L.Events.BUFFER_FLUSHING,P)}},c._loadInitSegment=function(S){var O=this;this._doFragLoad(S).then(function(C){if(!C||O.fragContextChanged(S)||!O.levels)throw new Error("init load aborted");return C}).then(function(C){var P=O.hls,w=C.payload,U=S.decryptdata;if(w&&w.byteLength>0&&U&&U.key&&U.iv&&U.method==="AES-128"){var k=self.performance.now();return O.decrypter.webCryptoDecrypt(new Uint8Array(w),U.key.buffer,U.iv.buffer).then(function(N){var B=self.performance.now();return P.trigger(L.Events.FRAG_DECRYPTED,{frag:S,payload:N,stats:{tstart:k,tdecrypt:B}}),C.payload=N,C})}return C}).then(function(C){var P=O.fragCurrent,w=O.hls,U=O.levels;if(!U)throw new Error("init load aborted, missing levels");var k=U[S.level].details;console.assert(k,"Level details are defined when init segment is loaded");var N=S.stats;O.state=p.IDLE,O.fragLoadError=0,S.data=new Uint8Array(C.payload),N.parsing.start=N.buffering.start=self.performance.now(),N.parsing.end=N.buffering.end=self.performance.now(),C.frag===P&&w.trigger(L.Events.FRAG_BUFFERED,{stats:N,frag:P,part:null,id:S.type}),O.tick()}).catch(function(C){O.warn(C),O.resetFragmentLoading(S)})},c.fragContextChanged=function(S){var O=this.fragCurrent;return!S||!O||S.level!==O.level||S.sn!==O.sn||S.urlId!==O.urlId},c.fragBufferedComplete=function(S,O){var C=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+S.type+" sn: "+S.sn+(O?" part: "+O.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+S.level+" "+r.default.toString(R.BufferHelper.getBuffered(C))),this.state=p.IDLE,this.tick()},c._handleFragmentLoadComplete=function(S){var O=this.transmuxer;if(!!O){var C=S.frag,P=S.part,w=S.partsLoaded,U=!w||w.length===0||w.some(function(N){return!N}),k=new E.ChunkMetadata(C.level,C.sn,C.stats.chunkCount+1,0,P?P.index:-1,!U);O.flush(k)}},c._handleFragmentLoadProgress=function(S){},c._doFragLoad=function(S,O,C,P){var w=this;if(C===void 0&&(C=null),!this.levels)throw new Error("frag load aborted, missing levels");if(C=Math.max(S.start,C||0),this.config.lowLatencyMode&&O){var U=O.partList;if(U&&P){C>S.end&&O.fragmentHint&&(S=O.fragmentHint);var k=this.getNextPart(U,S,C);if(k>-1){var N=U[k];return this.log("Loading part sn: "+S.sn+" p: "+N.index+" cc: "+S.cc+" of playlist ["+O.startSN+"-"+O.endSN+"] parts [0-"+k+"-"+(U.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+S.level+", target: "+parseFloat(C.toFixed(3))),this.nextLoadPosition=N.start+N.duration,this.state=p.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:S,part:U[k],targetBufferTime:C}),this.doFragPartsLoad(S,U,k,P).catch(function(B){return w.handleFragLoadError(B)})}else if(!S.url||this.loadedEndOfParts(U,C))return Promise.resolve(null)}}return this.log("Loading fragment "+S.sn+" cc: "+S.cc+" "+(O?"of ["+O.startSN+"-"+O.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+S.level+", target: "+parseFloat(C.toFixed(3))),Object(l.isFiniteNumber)(S.sn)&&!this.bitrateTest&&(this.nextLoadPosition=S.start+S.duration),this.state=p.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:S,targetBufferTime:C}),this.fragmentLoader.load(S,P).catch(function(B){return w.handleFragLoadError(B)})},c.doFragPartsLoad=function(S,O,C,P){var w=this;return new Promise(function(U,k){var N=[],B=function K(W){var F=O[W];w.fragmentLoader.loadPart(S,F,P).then(function(H){N[F.index]=H;var Y=H.part;w.hls.trigger(L.Events.FRAG_LOADED,H);var $=O[W+1];if($&&$.fragment===S)K(W+1);else return U({frag:S,part:Y,partsLoaded:N})}).catch(k)};B(C)})},c.handleFragLoadError=function(S){var O=S.data;return O&&O.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(O.frag,O.part):this.hls.trigger(L.Events.ERROR,O),null},c._handleTransmuxerFlush=function(S){var O=this.getCurrentContext(S);if(!O||this.state!==p.PARSING){this.fragCurrent||(this.state=p.IDLE);return}var C=O.frag,P=O.part,w=O.level,U=self.performance.now();C.stats.parsing.end=U,P&&(P.stats.parsing.end=U),this.updateLevelTiming(C,P,w,S.partial)},c.getCurrentContext=function(S){var O=this.levels,C=S.level,P=S.sn,w=S.part;if(!O||!O[C])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+C+". The current chunk will not be buffered."),null;var U=O[C],k=w>-1?Object(b.getPartWith)(U,P,w):null,N=k?k.fragment:Object(b.getFragmentWithSN)(U,P,this.fragCurrent);return N?{frag:N,part:k,level:U}:null},c.bufferFragmentData=function(S,O,C,P){if(!(!S||this.state!==p.PARSING)){var w=S.data1,U=S.data2,k=w;if(w&&U&&(k=Object(I.appendUint8Array)(w,U)),!(!k||!k.length)){var N={type:S.type,frag:O,part:C,chunkMeta:P,parent:O.type,data:k};this.hls.trigger(L.Events.BUFFER_APPENDING,N),S.dropped&&S.independent&&!C&&this.flushBufferGap(O)}}},c.flushBufferGap=function(S){var O=this.media;if(!!O){if(!R.BufferHelper.isBuffered(O,O.currentTime)){this.flushMainBuffer(0,S.start);return}var C=O.currentTime,P=R.BufferHelper.bufferInfo(O,C,0),w=S.duration,U=Math.min(this.config.maxFragLookUpTolerance*2,w*.25),k=Math.max(Math.min(S.start-U,P.end-U),C+U);S.start-k>U&&this.flushMainBuffer(k,S.start)}},c.getFwdBufferInfo=function(S,O){var C=this.config,P=this.getLoadPosition();if(!Object(l.isFiniteNumber)(P))return null;var w=R.BufferHelper.bufferInfo(S,P,C.maxBufferHole);if(w.len===0&&w.nextStart!==void 0){var U=this.fragmentTracker.getBufferedFrag(P,O);if(U&&w.nextStart<U.end)return R.BufferHelper.bufferInfo(S,P,Math.max(w.nextStart,C.maxBufferHole))}return w},c.getMaxBufferLength=function(S){var O=this.config,C;return S?C=Math.max(8*O.maxBufferSize/S,O.maxBufferLength):C=O.maxBufferLength,Math.min(C,O.maxMaxBufferLength)},c.reduceMaxBufferLength=function(S){var O=this.config,C=S||O.maxBufferLength;return O.maxMaxBufferLength>=C?(O.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+O.maxMaxBufferLength+"s"),!0):!1},c.getNextFragment=function(S,O){var C,P,w=O.fragments,U=w.length;if(!U)return null;var k=this.config,N=w[0].start,B;if(O.live){var K=k.initialLiveManifestSize;if(U<K)return this.warn("Not enough fragments to start playback (have: "+U+", need: "+K+")"),null;!O.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(B=this.getInitialLiveFragment(O,w),this.startPosition=B?this.hls.liveSyncPosition||B.start:S)}else S<=N&&(B=w[0]);if(!B){var W=k.lowLatencyMode?O.partEnd:O.fragmentEnd;B=this.getFragmentAtPosition(S,W,O)}return(C=B)!==null&&C!==void 0&&C.initSegment&&!((P=B)!==null&&P!==void 0&&P.initSegment.data)&&!this.bitrateTest&&(B=B.initSegment),B},c.getNextPart=function(S,O,C){for(var P=-1,w=!1,U=!0,k=0,N=S.length;k<N;k++){var B=S[k];if(U=U&&!B.independent,P>-1&&C<B.start)break;var K=B.loaded;!K&&(w||B.independent||U)&&B.fragment===O&&(P=k),w=K}return P},c.loadedEndOfParts=function(S,O){var C=S[S.length-1];return C&&O>C.start&&C.loaded},c.getInitialLiveFragment=function(S,O){var C=this.fragPrevious,P=null;if(C){if(S.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+C.programDateTime),P=Object(D.findFragmentByPDT)(O,C.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var w=C.sn+1;if(w>=S.startSN&&w<=S.endSN){var U=O[w-S.startSN];C.cc===U.cc&&(P=U,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(D.findFragWithCC)(O,C.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var k=this.hls.liveSyncPosition;k!==null&&(P=this.getFragmentAtPosition(k,this.bitrateTest?S.fragmentEnd:S.edge,S))}return P},c.getFragmentAtPosition=function(S,O,C){var P=this.config,w=this.fragPrevious,U=C.fragments,k=C.endSN,N=C.fragmentHint,B=P.maxFragLookUpTolerance,K=!!(P.lowLatencyMode&&C.partList&&N);K&&N&&!this.bitrateTest&&(U=U.concat(N),k=N.sn);var W;if(S<O){var F=S>O-B?0:B;W=Object(D.findFragmentByPTS)(w,U,S,F)}else W=U[U.length-1];if(W){var H=W.sn-C.startSN,Y=w&&W.level===w.level,$=U[H+1],Z=this.fragmentTracker.getState(W);if(Z===h.FragmentState.BACKTRACKED){W=null;for(var q=H;U[q]&&this.fragmentTracker.getState(U[q])===h.FragmentState.BACKTRACKED;)w?W=U[q--]:W=U[--q];W||(W=$)}else w&&W.sn===w.sn&&!K&&Y&&(W.sn<k&&this.fragmentTracker.getState($)!==h.FragmentState.OK?(this.log("SN "+W.sn+" just loaded, load next one: "+$.sn),W=$):W=null)}return W},c.synchronizeToLiveEdge=function(S){var O=this.config,C=this.media;if(!!C){var P=this.hls.liveSyncPosition,w=C.currentTime,U=S.fragments[0].start,k=S.edge,N=w>=U-O.maxFragLookUpTolerance&&w<=k;if(P!==null&&C.duration>P&&(w<P||!N)){var B=O.liveMaxLatencyDuration!==void 0?O.liveMaxLatencyDuration:O.liveMaxLatencyDurationCount*S.targetduration;(!N&&C.readyState<4||w<k-B)&&(this.loadedmetadata||(this.nextLoadPosition=P),C.readyState&&(this.warn("Playback: "+w.toFixed(3)+" is located too far from the end of live sliding playlist: "+k+", reset currentTime to : "+P.toFixed(3)),C.currentTime=P))}}},c.alignPlaylists=function(S,O){var C=this.levels,P=this.levelLastLoaded,w=this.fragPrevious,U=P!==null?C[P]:null,k=S.fragments.length;if(!k)return this.warn("No fragments in live playlist"),0;var N=S.fragments[0].start,B=!O,K=S.alignedSliding&&Object(l.isFiniteNumber)(N);if(B||!K&&!N){Object(M.alignStream)(w,U,S);var W=S.fragments[0].start;return this.log("Live playlist sliding: "+W.toFixed(2)+" start-sn: "+(O?O.startSN:"na")+"->"+S.startSN+" prev-sn: "+(w?w.sn:"na")+" fragments: "+k),W}return N},c.waitForCdnTuneIn=function(S){var O=3;return S.live&&S.canBlockReload&&S.tuneInGoal>Math.max(S.partHoldBack,S.partTarget*O)},c.setStartPosition=function(S,O){var C=this.startPosition;if(C<O&&(C=-1),C===-1||this.lastCurrentTime===-1){var P=S.startTimeOffset;Object(l.isFiniteNumber)(P)?(C=O+P,P<0&&(C+=S.totalduration),C=Math.min(Math.max(O,C),O+S.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+C),this.startPosition=C):S.live?C=this.hls.liveSyncPosition||O:this.startPosition=C=0,this.lastCurrentTime=C}this.nextLoadPosition=C},c.getLoadPosition=function(){var S=this.media,O=0;return this.loadedmetadata&&S?O=S.currentTime:this.nextLoadPosition&&(O=this.nextLoadPosition),O},c.handleFragLoadAborted=function(S,O){this.transmuxer&&S.sn!=="initSegment"&&S.stats.aborted&&(this.warn("Fragment "+S.sn+(O?" part"+O.index:"")+" of level "+S.level+" was aborted"),this.resetFragmentLoading(S))},c.resetFragmentLoading=function(S){(!this.fragCurrent||!this.fragContextChanged(S))&&(this.state=p.IDLE)},c.onFragmentOrKeyLoadError=function(S,O){if(!O.fatal){var C=O.frag;if(!(!C||C.type!==S)){var P=this.fragCurrent;console.assert(P&&C.sn===P.sn&&C.level===P.level&&C.urlId===P.urlId,"Frag load error must match current frag to retry");var w=this.config;if(this.fragLoadError+1<=w.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(C.level))return;var U=Math.min(Math.pow(2,this.fragLoadError)*w.fragLoadingRetryDelay,w.fragLoadingMaxRetryTimeout);this.warn("Fragment "+C.sn+" of "+S+" "+C.level+" failed to load, retrying in "+U+"ms"),this.retryDate=self.performance.now()+U,this.fragLoadError++,this.state=p.FRAG_LOADING_WAITING_RETRY}else O.levelRetry?(S===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=p.IDLE):(T.logger.error(O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.hls.stopLoad(),this.state=p.ERROR)}}},c.afterBufferFlushed=function(S,O,C){if(!!S){var P=R.BufferHelper.getBuffered(S);this.fragmentTracker.detectEvictedFragments(O,P,C),this.state===p.ENDED&&this.resetLoadingState()}},c.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=p.IDLE},c.resetLiveStartWhenNotLoaded=function(S){if(!this.loadedmetadata){this.startFragRequested=!1;var O=this.levels?this.levels[S].details:null;if(O!=null&&O.live)return this.startPosition=-1,this.setStartPosition(O,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},c.updateLevelTiming=function(S,O,C,P){var w=this,U=C.details;console.assert(!!U,"level.details must be defined");var k=Object.keys(S.elementaryStreams).reduce(function(N,B){var K=S.elementaryStreams[B];if(K){var W=K.endPTS-K.startPTS;if(W<=0)return w.warn("Could not parse fragment "+S.sn+" "+B+" duration reliably ("+W+") resetting transmuxer to fallback to playlist timing"),w.resetTransmuxer(),N||!1;var F=P?0:Object(b.updateFragPTSDTS)(U,S,K.startPTS,K.endPTS,K.startDTS,K.endDTS);return w.hls.trigger(L.Events.LEVEL_PTS_UPDATED,{details:U,level:C,drift:F,type:B,frag:S,start:K.startPTS,end:K.endPTS}),!0}return N},!1);k?(this.state=p.PARSED,this.hls.trigger(L.Events.FRAG_PARSED,{frag:S,part:O})):this.resetLoadingState()},c.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},a(f,[{key:"state",get:function(){return this._state},set:function(S){var O=this._state;O!==S&&(this._state=S,this.log(O+"->"+S))}}]),f}(n.default)},"./src/controller/buffer-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D});var l=t("./src/polyfills/number.ts"),n=t("./src/events.ts"),h=t("./src/utils/logger.ts"),R=t("./src/errors.ts"),T=t("./src/utils/buffer-helper.ts"),L=t("./src/utils/mediasource-helper.ts"),_=t("./src/loader/fragment.ts"),E=t("./src/controller/buffer-operation-queue.ts"),I=Object(L.getMediaSource)(),M=/([ha]vc.)(?:\.[^.,]+)+/,D=function(){function b(u){var r=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=r.hls,i=r.media,a=r.mediaSource;h.logger.log("[buffer-controller]: Media source opened"),i&&(r.updateMediaElementDuration(),s.trigger(n.Events.MEDIA_ATTACHED,{media:i})),a&&a.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},this._onMediaSourceClose=function(){h.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){h.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var A=b.prototype;return A.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},A.destroy=function(){this.unregisterListeners(),this.details=null},A.registerListeners=function(){var r=this.hls;r.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(n.Events.BUFFER_RESET,this.onBufferReset,this),r.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.on(n.Events.BUFFER_EOS,this.onBufferEos,this),r.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.on(n.Events.FRAG_PARSED,this.onFragParsed,this),r.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},A.unregisterListeners=function(){var r=this.hls;r.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(n.Events.BUFFER_RESET,this.onBufferReset,this),r.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.off(n.Events.BUFFER_EOS,this.onBufferEos,this),r.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.off(n.Events.FRAG_PARSED,this.onFragParsed,this),r.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},A._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new E.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},A.onManifestParsed=function(r,s){var i=2;(s.audio&&!s.video||!s.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,h.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},A.onMediaAttaching=function(r,s){var i=this.media=s.media;if(i&&I){var a=this.mediaSource=new I;a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(a),this._objectUrl=i.src}},A.onMediaDetaching=function(){var r=this.media,s=this.mediaSource,i=this._objectUrl;if(s){if(h.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(a){h.logger.warn("[buffer-controller]: onMediaDetaching: "+a.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),r&&(i&&self.URL.revokeObjectURL(i),r.src===i?(r.removeAttribute("src"),r.load()):h.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(n.Events.MEDIA_DETACHED,void 0)},A.onBufferReset=function(){var r=this;this.getSourceBufferTypes().forEach(function(s){var i=r.sourceBuffer[s];try{i&&(r.removeBufferListeners(s),r.mediaSource&&r.mediaSource.removeSourceBuffer(i),r.sourceBuffer[s]=void 0)}catch(a){h.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",a)}}),this._initSourceBuffer()},A.onBufferCodecs=function(r,s){var i=this,a=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(d){if(a){var o=i.tracks[d];if(o&&typeof o.buffer.changeType=="function"){var y=s[d],p=y.codec,m=y.levelCodec,g=y.container,f=(o.levelCodec||o.codec).replace(M,"$1"),c=(m||p).replace(M,"$1");if(f!==c){var x=g+";codecs="+(m||p);i.appendChangeType(d,x)}}}else i.pendingTracks[d]=s[d]}),!a&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},A.appendChangeType=function(r,s){var i=this,a=this.operationQueue,d={execute:function(){var y=i.sourceBuffer[r];y&&(h.logger.log("[buffer-controller]: changing "+r+" sourceBuffer type to "+s),y.changeType(s)),a.shiftAndExecuteNext(r)},onStart:function(){},onComplete:function(){},onError:function(y){h.logger.warn("[buffer-controller]: Failed to change "+r+" SourceBuffer type",y)}};a.append(d,r)},A.onBufferAppending=function(r,s){var i=this,a=this.hls,d=this.operationQueue,o=this.tracks,y=s.data,p=s.type,m=s.frag,g=s.part,f=s.chunkMeta,c=f.buffering[p],x=self.performance.now();c.start=x;var S=m.stats.buffering,O=g?g.stats.buffering:null;S.start===0&&(S.start=x),O&&O.start===0&&(O.start=x);var C=o.audio,P=p==="audio"&&f.id===1&&(C==null?void 0:C.container)==="audio/mpeg",w={execute:function(){if(c.executeStart=self.performance.now(),P){var k=i.sourceBuffer[p];if(k){var N=m.start-k.timestampOffset;Math.abs(N)>=.1&&(h.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+m.start+" (delta: "+N+") sn: "+m.sn+")"),k.timestampOffset=m.start)}}i.appendExecutor(y,p)},onStart:function(){},onComplete:function(){var k=self.performance.now();c.executeEnd=c.end=k,S.first===0&&(S.first=k),O&&O.first===0&&(O.first=k);var N=i.sourceBuffer,B={};for(var K in N)B[K]=T.BufferHelper.getBuffered(N[K]);i.appendError=0,i.hls.trigger(n.Events.BUFFER_APPENDED,{type:p,frag:m,part:g,chunkMeta:f,parent:m.type,timeRanges:B})},onError:function(k){h.logger.error("[buffer-controller]: Error encountered while trying to append to the "+p+" SourceBuffer",k);var N={type:R.ErrorTypes.MEDIA_ERROR,parent:m.type,details:R.ErrorDetails.BUFFER_APPEND_ERROR,err:k,fatal:!1};k.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=R.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,N.details=R.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>a.config.appendErrorMaxRetry&&(h.logger.error("[buffer-controller]: Failed "+a.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),N.fatal=!0)),a.trigger(n.Events.ERROR,N)}};d.append(w,p)},A.onBufferFlushing=function(r,s){var i=this,a=this.operationQueue,d=function(y){return{execute:i.removeExecutor.bind(i,y,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(n.Events.BUFFER_FLUSHED,{type:y})},onError:function(m){h.logger.warn("[buffer-controller]: Failed to remove from "+y+" SourceBuffer",m)}}};s.type?a.append(d(s.type),s.type):this.getSourceBufferTypes().forEach(function(o){a.append(d(o),o)})},A.onFragParsed=function(r,s){var i=this,a=s.frag,d=s.part,o=[],y=d?d.elementaryStreams:a.elementaryStreams;y[_.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(y[_.ElementaryStreamTypes.AUDIO]&&o.push("audio"),y[_.ElementaryStreamTypes.VIDEO]&&o.push("video"));var p=function(){var g=self.performance.now();a.stats.buffering.end=g,d&&(d.stats.buffering.end=g);var f=d?d.stats:a.stats;i.hls.trigger(n.Events.FRAG_BUFFERED,{frag:a,part:d,stats:f,id:a.type})};o.length===0&&h.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn),this.blockBuffers(p,o)},A.onFragChanged=function(r,s){this.flushBackBuffer()},A.onBufferEos=function(r,s){var i=this,a=this.getSourceBufferTypes().reduce(function(d,o){var y=i.sourceBuffer[o];return(!s.type||s.type===o)&&y&&!y.ended&&(y.ended=!0,h.logger.log("[buffer-controller]: "+o+" sourceBuffer now EOS")),d&&!!(!y||y.ended)},!0);a&&this.blockBuffers(function(){var d=i.mediaSource;!d||d.readyState!=="open"||d.endOfStream()})},A.onLevelUpdated=function(r,s){var i=s.details;!i.fragments.length||(this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},A.flushBackBuffer=function(){var r=this.hls,s=this.details,i=this.media,a=this.sourceBuffer;if(!(!i||s===null)){var d=this.getSourceBufferTypes();if(!!d.length){var o=s.live&&r.config.liveBackBufferLength!==null?r.config.liveBackBufferLength:r.config.backBufferLength;if(!(!Object(l.isFiniteNumber)(o)||o<0)){var y=i.currentTime,p=s.levelTargetDuration,m=Math.max(o,p),g=Math.floor(y/p)*p-m;d.forEach(function(f){var c=a[f];if(c){var x=T.BufferHelper.getBuffered(c);x.length>0&&g>x.start(0)&&(r.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:g}),s.live&&r.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:g}),r.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:g,type:f}))}})}}}},A.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var r=this.details,s=this.hls,i=this.media,a=this.mediaSource,d=r.fragments[0].start+r.totalduration,o=i.duration,y=Object(l.isFiniteNumber)(a.duration)?a.duration:0;r.live&&s.config.liveDurationInfinity?(h.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),a.duration=1/0,this.updateSeekableRange(r)):(d>y&&d>o||!Object(l.isFiniteNumber)(o))&&(h.logger.log("[buffer-controller]: Updating Media Source duration to "+d.toFixed(3)),a.duration=d)}},A.updateSeekableRange=function(r){var s=this.mediaSource,i=r.fragments,a=i.length;if(a&&r.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var d=Math.max(0,i[0].start),o=Math.max(d,d+r.totalduration);s.setLiveSeekableRange(d,o)}},A.checkPendingTracks=function(){var r=this.bufferCodecEventsExpected,s=this.operationQueue,i=this.pendingTracks,a=Object.keys(i).length;if(a&&!r||a===2){this.createSourceBuffers(i),this.pendingTracks={};var d=this.getSourceBufferTypes();if(d.length===0){this.hls.trigger(n.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}d.forEach(function(o){s.executeNext(o)})}},A.createSourceBuffers=function(r){var s=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var a=0;for(var d in r)if(!s[d]){var o=r[d];if(!o)throw Error("source buffer exists for track "+d+", however track does not");var y=o.levelCodec||o.codec,p=o.container+";codecs="+y;h.logger.log("[buffer-controller]: creating sourceBuffer("+p+")");try{var m=s[d]=i.addSourceBuffer(p),g=d;this.addBufferListener(g,"updatestart",this._onSBUpdateStart),this.addBufferListener(g,"updateend",this._onSBUpdateEnd),this.addBufferListener(g,"error",this._onSBUpdateError),this.tracks[d]={buffer:m,codec:y,container:o.container,levelCodec:o.levelCodec,id:o.id},a++}catch(f){h.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+f.message),this.hls.trigger(n.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:p})}}a&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},A._onSBUpdateStart=function(r){var s=this.operationQueue,i=s.current(r);i.onStart()},A._onSBUpdateEnd=function(r){var s=this.operationQueue,i=s.current(r);i.onComplete(),s.shiftAndExecuteNext(r)},A._onSBUpdateError=function(r,s){h.logger.error("[buffer-controller]: "+r+" SourceBuffer error",s),this.hls.trigger(n.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(r);i&&i.onError(s)},A.removeExecutor=function(r,s,i){var a=this.media,d=this.mediaSource,o=this.operationQueue,y=this.sourceBuffer,p=y[r];if(!a||!d||!p){h.logger.warn("[buffer-controller]: Attempting to remove from the "+r+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(r);return}var m=Object(l.isFiniteNumber)(a.duration)?a.duration:1/0,g=Object(l.isFiniteNumber)(d.duration)?d.duration:1/0,f=Math.max(0,s),c=Math.min(i,m,g);c>f?(h.logger.log("[buffer-controller]: Removing ["+f+","+c+"] from the "+r+" SourceBuffer"),console.assert(!p.updating,r+" sourceBuffer must not be updating"),p.remove(f,c)):o.shiftAndExecuteNext(r)},A.appendExecutor=function(r,s){var i=this.operationQueue,a=this.sourceBuffer,d=a[s];if(!d){h.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),i.shiftAndExecuteNext(s);return}d.ended=!1,console.assert(!d.updating,s+" sourceBuffer must not be updating"),d.appendBuffer(r)},A.blockBuffers=function(r,s){var i=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){h.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(r);return}var a=this.operationQueue,d=s.map(function(o){return a.appendBlocker(o)});Promise.all(d).then(function(){r(),s.forEach(function(o){var y=i.sourceBuffer[o];(!y||!y.updating)&&a.shiftAndExecuteNext(o)})})},A.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},A.addBufferListener=function(r,s,i){var a=this.sourceBuffer[r];if(!!a){var d=i.bind(this,r);this.listeners[r].push({event:s,listener:d}),a.addEventListener(s,d)}},A.removeBufferListeners=function(r){var s=this.sourceBuffer[r];!s||this.listeners[r].forEach(function(i){s.removeEventListener(i.event,i.listener)})},b}()},"./src/controller/buffer-operation-queue.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return n});var l=t("./src/utils/logger.ts"),n=function(){function h(T){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=T}var R=h.prototype;return R.append=function(L,_){var E=this.queues[_];E.push(L),E.length===1&&this.buffers[_]&&this.executeNext(_)},R.insertAbort=function(L,_){var E=this.queues[_];E.unshift(L),this.executeNext(_)},R.appendBlocker=function(L){var _,E=new Promise(function(M){_=M}),I={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(I,L),E},R.executeNext=function(L){var _=this.buffers,E=this.queues,I=_[L],M=E[L];if(M.length){var D=M[0];try{D.execute()}catch(b){l.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),D.onError(b),(!I||!I.updating)&&(M.shift(),this.executeNext(L))}}},R.shiftAndExecuteNext=function(L){this.queues[L].shift(),this.executeNext(L)},R.current=function(L){return this.queues[L][0]},h}()},"./src/controller/cap-level-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/events.ts");function n(T,L){for(var _=0;_<L.length;_++){var E=L[_];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(T,E.key,E)}}function h(T,L,_){return L&&n(T.prototype,L),_&&n(T,_),T}var R=function(){function T(_){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=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var L=T.prototype;return L.setStreamController=function(E){this.streamController=E},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 E=this.hls;E.on(l.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.on(l.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.on(l.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.on(l.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.on(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var E=this.hls;E.off(l.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.off(l.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.off(l.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.off(l.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.off(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(E,I){T.isLevelAllowed(I.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(I.droppedLevel)},L.onMediaAttaching=function(E,I){this.media=I.media instanceof HTMLVideoElement?I.media:null},L.onManifestParsed=function(E,I){var M=this.hls;this.restrictedLevels=[],this.firstLevel=I.firstLevel,M.config.capLevelToPlayerSize&&I.video&&this.startCapping()},L.onBufferCodecs=function(E,I){var M=this.hls;M.config.capLevelToPlayerSize&&I.video&&this.startCapping()},L.onMediaDetaching=function(){this.stopCapping()},L.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var E=this.hls.levels;if(E.length){var I=this.hls;I.autoLevelCapping=this.getMaxLevel(E.length-1),I.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=I.autoLevelCapping}}},L.getMaxLevel=function(E){var I=this,M=this.hls.levels;if(!M.length)return-1;var D=M.filter(function(b,A){return T.isLevelAllowed(A,I.restrictedLevels)&&A<=E});return this.clientRect=null,T.getMaxLevelByMediaSize(D,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 E=this.media,I={width:0,height:0};if(E){var M=E.getBoundingClientRect();I.width=M.width,I.height=M.height,!I.width&&!I.height&&(I.width=M.right-M.left||E.width||0,I.height=M.bottom-M.top||E.height||0)}return this.clientRect=I,I},T.isLevelAllowed=function(E,I){return I===void 0&&(I=[]),I.indexOf(E)===-1},T.getMaxLevelByMediaSize=function(E,I,M){if(!E||!E.length)return-1;for(var D=function(s,i){return i?s.width!==i.width||s.height!==i.height:!0},b=E.length-1,A=0;A<E.length;A+=1){var u=E[A];if((u.width>=I||u.height>=M)&&D(u,E[A+1])){b=A;break}}return b},h(T,[{key:"mediaWidth",get:function(){return this.getDimensions().width*T.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*T.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var E=1;try{E=self.devicePixelRatio}catch{}return E}}]),T}();e.default=R},"./src/controller/cmcd-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D});var l=t("./src/events.ts"),n=t("./src/types/cmcd.ts"),h=t("./src/utils/buffer-helper.ts"),R=t("./src/utils/logger.ts");function T(b,A){for(var u=0;u<A.length;u++){var r=A[u];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(b,r.key,r)}}function L(b,A,u){return A&&T(b.prototype,A),u&&T(b,u),b}function _(b,A){var u=typeof Symbol!="undefined"&&b[Symbol.iterator]||b["@@iterator"];if(u)return(u=u.call(b)).next.bind(u);if(Array.isArray(b)||(u=E(b))||A&&b&&typeof b.length=="number"){u&&(b=u);var r=0;return function(){return r>=b.length?{done:!0}:{done:!1,value:b[r++]}}}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 E(b,A){if(!!b){if(typeof b=="string")return I(b,A);var u=Object.prototype.toString.call(b).slice(8,-1);if(u==="Object"&&b.constructor&&(u=b.constructor.name),u==="Map"||u==="Set")return Array.from(b);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return I(b,A)}}function I(b,A){(A==null||A>b.length)&&(A=b.length);for(var u=0,r=new Array(A);u<A;u++)r[u]=b[u];return r}function M(){return M=Object.assign||function(b){for(var A=1;A<arguments.length;A++){var u=arguments[A];for(var r in u)Object.prototype.hasOwnProperty.call(u,r)&&(b[r]=u[r])}return b},M.apply(this,arguments)}var D=function(){function b(u){var r=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(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(a){try{r.apply(a,{ot:n.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(d){R.logger.warn("Could not generate manifest CMCD data.",d)}},this.applyFragmentData=function(a){try{var d=a.frag,o=r.hls.levels[d.level],y=r.getObjectType(d),p={d:d.duration*1e3,ot:y};(y===n.CMCDObjectType.VIDEO||y===n.CMCDObjectType.AUDIO||y==n.CMCDObjectType.MUXED)&&(p.br=o.bitrate/1e3,p.tb=r.getTopBandwidth(y)/1e3,p.bl=r.getBufferLength(y)),r.apply(a,p)}catch(m){R.logger.warn("Could not generate segment CMCD data.",m)}},this.hls=u;var s=this.config=u.config,i=s.cmcd;i!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||b.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}var A=b.prototype;return A.registerListeners=function(){var r=this.hls;r.on(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(l.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.on(l.Events.BUFFER_CREATED,this.onBufferCreated,this)},A.unregisterListeners=function(){var r=this.hls;r.off(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(l.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.off(l.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},A.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},A.onMediaAttached=function(r,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},A.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},A.onBufferCreated=function(r,s){var i,a;this.audioBuffer=(i=s.tracks.audio)===null||i===void 0?void 0:i.buffer,this.videoBuffer=(a=s.tracks.video)===null||a===void 0?void 0:a.buffer},A.createData=function(){var r;return{v:n.CMCDVersion,sf:n.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(r=this.media)===null||r===void 0?void 0:r.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},A.apply=function(r,s){s===void 0&&(s={}),M(s,this.createData());var i=s.ot===n.CMCDObjectType.INIT||s.ot===n.CMCDObjectType.VIDEO||s.ot===n.CMCDObjectType.MUXED;if(this.starved&&i&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var a=b.toHeaders(s);if(!Object.keys(a).length)return;r.headers||(r.headers={}),M(r.headers,a)}else{var d=b.toQuery(s);if(!d)return;r.url=b.appendQueryToUri(r.url,d)}},A.getObjectType=function(r){var s=r.type;if(s==="subtitle")return n.CMCDObjectType.TIMED_TEXT;if(r.sn==="initSegment")return n.CMCDObjectType.INIT;if(s==="audio")return n.CMCDObjectType.AUDIO;if(s==="main")return this.hls.audioTracks.length?n.CMCDObjectType.VIDEO:n.CMCDObjectType.MUXED},A.getTopBandwidth=function(r){var s=0,i,a=this.hls;if(r===n.CMCDObjectType.AUDIO)i=a.audioTracks;else{var d=a.maxAutoLevel,o=d>-1?d+1:a.levels.length;i=a.levels.slice(0,o)}for(var y=_(i),p;!(p=y()).done;){var m=p.value;m.bitrate>s&&(s=m.bitrate)}return s>0?s:NaN},A.getBufferLength=function(r){var s=this.hls.media,i=r===n.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!i||!s)return NaN;var a=h.BufferHelper.bufferInfo(i,s.currentTime,this.config.maxBufferHole);return a.len*1e3},A.createPlaylistLoader=function(){var r=this.config.pLoader,s=this.applyPlaylistData,i=r||this.config.loader;return function(){function a(o){this.loader=void 0,this.loader=new i(o)}var d=a.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(y,p,m){s(y),this.loader.load(y,p,m)},L(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},A.createFragmentLoader=function(){var r=this.config.fLoader,s=this.applyFragmentData,i=r||this.config.loader;return function(){function a(o){this.loader=void 0,this.loader=new i(o)}var d=a.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(y,p,m){s(y),this.loader.load(y,p,m)},L(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},b.uuid=function(){var r=URL.createObjectURL(new Blob),s=r.toString();return URL.revokeObjectURL(r),s.substr(s.lastIndexOf("/")+1)},b.serialize=function(r){for(var s=[],i=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},a=function(P){return Math.round(P)},d=function(P){return a(P/100)*100},o=function(P){return encodeURIComponent(P)},y={br:a,d:a,bl:d,dl:d,mtp:d,nor:o,rtp:d,tb:a},p=Object.keys(r||{}).sort(),m=_(p),g;!(g=m()).done;){var f=g.value,c=r[f];if(!!i(c)&&!(f==="v"&&c===1)&&!(f=="pr"&&c===1)){var x=y[f];x&&(c=x(c));var S=typeof c,O=void 0;f==="ot"||f==="sf"||f==="st"?O=f+"="+c:S==="boolean"?O=f:S==="number"?O=f+"="+c:O=f+"="+JSON.stringify(c),s.push(O)}}return s.join(",")},b.toHeaders=function(r){for(var s=Object.keys(r),i={},a=["Object","Request","Session","Status"],d=[{},{},{},{}],o={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},y=0,p=s;y<p.length;y++){var m=p[y],g=o[m]!=null?o[m]:1;d[g][m]=r[m]}for(var f=0;f<d.length;f++){var c=b.serialize(d[f]);c&&(i["CMCD-"+a[f]]=c)}return i},b.toQuery=function(r){return"CMCD="+encodeURIComponent(b.serialize(r))},b.appendQueryToUri=function(r,s){if(!s)return r;var i=r.includes("?")?"&":"?";return""+r+i+s},b}()},"./src/controller/eme-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/events.ts"),n=t("./src/errors.ts"),h=t("./src/utils/logger.ts"),R=t("./src/utils/mediakeys-helper.ts");function T(D,b){for(var A=0;A<b.length;A++){var u=b[A];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(D,u.key,u)}}function L(D,b,A){return b&&T(D.prototype,b),A&&T(D,A),D}var _=3,E=function(b,A,u){var r={audioCapabilities:[],videoCapabilities:[]};return b.forEach(function(s){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:u.audioRobustness||""})}),A.forEach(function(s){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:u.videoRobustness||""})}),[r]},I=function(b,A,u,r){switch(b){case R.KeySystems.WIDEVINE:return E(A,u,r);default:throw new Error("Unknown key-system: "+b)}},M=function(){function D(A){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=A,this._config=A.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 b=D.prototype;return b.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},b._registerListeners=function(){this.hls.on(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(l.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(l.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b._unregisterListeners=function(){this.hls.off(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(l.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(l.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b.getLicenseServerUrl=function(u){switch(u){case R.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},b._attemptKeySystemAccess=function(u,r,s){var i=this,a=I(u,r,s,this._drmSystemOptions);h.logger.log("Requesting encrypted media key-system access");var d=this.requestMediaKeySystemAccess(u,a);this.mediaKeysPromise=d.then(function(o){return i._onMediaKeySystemAccessObtained(u,o)}),d.catch(function(o){h.logger.error('Failed to obtain key-system "'+u+'" access:',o)})},b._onMediaKeySystemAccessObtained=function(u,r){var s=this;h.logger.log('Access for key-system "'+u+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:r,mediaKeySystemDomain:u};this._mediaKeysList.push(i);var a=Promise.resolve().then(function(){return r.createMediaKeys()}).then(function(d){return i.mediaKeys=d,h.logger.log('Media-keys created for key-system "'+u+'"'),s._onMediaKeysCreated(),d});return a.catch(function(d){h.logger.error("Failed to create media-keys:",d)}),a},b._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(r){r.mediaKeysSession||(r.mediaKeysSession=r.mediaKeys.createSession(),u._onNewMediaKeySession(r.mediaKeysSession))})},b._onNewMediaKeySession=function(u){var r=this;h.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(s){r._onKeySessionMessage(u,s.message)},!1)},b._onKeySessionMessage=function(u,r){h.logger.log("Got EME message event, creating license request"),this._requestLicense(r,function(s){h.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),u.update(s)})},b.onMediaEncrypted=function(u){var r=this;if(h.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){h.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(a){!r._media||(r._attemptSetMediaKeys(a),r._generateRequestWithPreferredKeySession(u.initDataType,u.initData))};this.mediaKeysPromise.then(s).catch(s)},b._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var r=this._mediaKeysList[0];if(!r||!r.mediaKeys){h.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}h.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(r.mediaKeys),this._hasSetMediaKeys=!0}},b._generateRequestWithPreferredKeySession=function(u,r){var s=this,i=this._mediaKeysList[0];if(!i){h.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(i.mediaKeysSessionInitialized){h.logger.warn("Key-Session already initialized but requested again");return}var a=i.mediaKeysSession;if(!a){h.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!r){h.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}h.logger.log('Generating key-session request for "'+u+'" init data type'),i.mediaKeysSessionInitialized=!0,a.generateRequest(u,r).then(function(){h.logger.debug("Key-session generation succeeded")}).catch(function(d){h.logger.error("Error generating key-session request:",d),s.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},b._createLicenseXhr=function(u,r,s){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,u,r,s);var a=this._licenseXhrSetup;if(a)try{a.call(this.hls,i,u),a=void 0}catch(d){h.logger.error(d)}try{i.readyState||i.open("POST",u,!0),a&&a.call(this.hls,i,u)}catch(d){throw new Error("issue setting up KeySystem license XHR "+d)}return i},b._onLicenseRequestReadyStageChange=function(u,r,s,i){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,h.logger.log("License request succeeded");var a=u.response,d=this._licenseResponseCallback;if(d)try{a=d.call(this.hls,u,r)}catch(y){h.logger.error(y)}i(a)}else{if(h.logger.error("License Request XHR failed ("+r+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var o=_-this._requestLicenseFailureCount+1;h.logger.warn("Retrying license request, "+o+" attempts left"),this._requestLicense(s,i)}break}},b._generateLicenseRequestChallenge=function(u,r){switch(u.mediaKeySystemDomain){case R.KeySystems.WIDEVINE:return r}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},b._requestLicense=function(u,r){h.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){h.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var i=this.getLicenseServerUrl(s.mediaKeySystemDomain),a=this._createLicenseXhr(i,u,r);h.logger.log("Sending license request to URL: "+i);var d=this._generateLicenseRequestChallenge(s,u);a.send(d)}catch(o){h.logger.error("Failure requesting DRM license: "+o),this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},b.onMediaAttached=function(u,r){if(!!this._emeEnabled){var s=r.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)}},b.onMediaDetached=function(){var u=this._media,r=this._mediaKeysList;!u||(u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(r.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){}))},b.onManifestParsed=function(u,r){if(!!this._emeEnabled){var s=r.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),i=r.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(R.KeySystems.WIDEVINE,s,i)}},L(D,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),D}();e.default=M},"./src/controller/fps-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/events.ts"),n=t("./src/utils/logger.ts"),h=function(){function R(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 T=R.prototype;return T.setStreamController=function(_){this.streamController=_},T.registerListeners=function(){this.hls.on(l.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},T.unregisterListeners=function(){this.hls.off(l.Events.MEDIA_ATTACHING,this.onMediaAttaching)},T.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},T.onMediaAttaching=function(_,E){var I=this.hls.config;if(I.capLevelOnFPSDrop){var M=E.media instanceof self.HTMLVideoElement?E.media:null;this.media=M,M&&typeof M.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),I.fpsDroppedMonitoringPeriod)}},T.checkFPS=function(_,E,I){var M=performance.now();if(E){if(this.lastTime){var D=M-this.lastTime,b=I-this.lastDroppedFrames,A=E-this.lastDecodedFrames,u=1e3*b/D,r=this.hls;if(r.trigger(l.Events.FPS_DROP,{currentDropped:b,currentDecoded:A,totalDroppedFrames:I}),u>0&&b>r.config.fpsDroppedMonitoringThreshold*A){var s=r.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(r.autoLevelCapping===-1||r.autoLevelCapping>=s)&&(s=s-1,r.trigger(l.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:r.currentLevel}),r.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=M,this.lastDroppedFrames=I,this.lastDecodedFrames=E}},T.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var E=_.getVideoPlaybackQuality();this.checkFPS(_,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},R}();e.default=h},"./src/controller/fragment-finders.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"findFragmentByPDT",function(){return h}),t.d(e,"findFragmentByPTS",function(){return R}),t.d(e,"fragmentWithinToleranceTest",function(){return T}),t.d(e,"pdtWithinToleranceTest",function(){return L}),t.d(e,"findFragWithCC",function(){return _});var l=t("./src/polyfills/number.ts"),n=t("./src/utils/binary-search.ts");function h(E,I,M){if(I===null||!Array.isArray(E)||!E.length||!Object(l.isFiniteNumber)(I))return null;var D=E[0].programDateTime;if(I<(D||0))return null;var b=E[E.length-1].endProgramDateTime;if(I>=(b||0))return null;M=M||0;for(var A=0;A<E.length;++A){var u=E[A];if(L(I,M,u))return u}return null}function R(E,I,M,D){M===void 0&&(M=0),D===void 0&&(D=0);var b=null;if(E?b=I[E.sn-I[0].sn+1]||null:M===0&&I[0].start===0&&(b=I[0]),b&&T(M,D,b)===0)return b;var A=n.default.search(I,T.bind(null,M,D));return A||b}function T(E,I,M){E===void 0&&(E=0),I===void 0&&(I=0);var D=Math.min(I,M.duration+(M.deltaPTS?M.deltaPTS:0));return M.start+M.duration-D<=E?1:M.start-D>E&&M.start?-1:0}function L(E,I,M){var D=Math.min(I,M.duration+(M.deltaPTS?M.deltaPTS:0))*1e3,b=M.endProgramDateTime||0;return b-D>E}function _(E,I){return n.default.search(E,function(M){return M.cc<I?1:M.cc>I?-1:0})}},"./src/controller/fragment-tracker.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"FragmentState",function(){return h}),t.d(e,"FragmentTracker",function(){return R});var l=t("./src/events.ts"),n=t("./src/types/loader.ts"),h;(function(_){_.NOT_LOADED="NOT_LOADED",_.BACKTRACKED="BACKTRACKED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(h||(h={}));var R=function(){function _(I){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=I,this._registerListeners()}var E=_.prototype;return E._registerListeners=function(){var M=this.hls;M.on(l.Events.BUFFER_APPENDED,this.onBufferAppended,this),M.on(l.Events.FRAG_BUFFERED,this.onFragBuffered,this),M.on(l.Events.FRAG_LOADED,this.onFragLoaded,this)},E._unregisterListeners=function(){var M=this.hls;M.off(l.Events.BUFFER_APPENDED,this.onBufferAppended,this),M.off(l.Events.FRAG_BUFFERED,this.onFragBuffered,this),M.off(l.Events.FRAG_LOADED,this.onFragLoaded,this)},E.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},E.getAppendedFrag=function(M,D){if(D===n.PlaylistLevelType.MAIN){var b=this.activeFragment,A=this.activeParts;if(!b)return null;if(A)for(var u=A.length;u--;){var r=A[u],s=r?r.end:b.appendedPTS;if(r.start<=M&&s!==void 0&&M<=s)return u>9&&(this.activeParts=A.slice(u-9)),r}else if(b.start<=M&&b.appendedPTS!==void 0&&M<=b.appendedPTS)return b}return this.getBufferedFrag(M,D)},E.getBufferedFrag=function(M,D){for(var b=this.fragments,A=Object.keys(b),u=A.length;u--;){var r=b[A[u]];if((r==null?void 0:r.body.type)===D&&r.buffered){var s=r.body;if(s.start<=M&&M<=s.end)return s}}return null},E.detectEvictedFragments=function(M,D,b){var A=this;Object.keys(this.fragments).forEach(function(u){var r=A.fragments[u];if(!!r){if(!r.buffered){r.body.type===b&&A.removeFragment(r.body);return}var s=r.range[M];!s||s.time.some(function(i){var a=!A.isTimeBuffered(i.startPTS,i.endPTS,D);return a&&A.removeFragment(r.body),a})}})},E.detectPartialFragments=function(M){var D=this,b=this.timeRanges,A=M.frag,u=M.part;if(!(!b||A.sn==="initSegment")){var r=L(A),s=this.fragments[r];!s||(Object.keys(b).forEach(function(i){var a=A.elementaryStreams[i];if(!!a){var d=b[i],o=u!==null||a.partial===!0;s.range[i]=D.getBufferedTimes(A,u,o,d)}}),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},E.fragBuffered=function(M){var D=L(M),b=this.fragments[D];b&&(b.backtrack=b.loaded=null,b.buffered=!0)},E.getBufferedTimes=function(M,D,b,A){for(var u={time:[],partial:b},r=D?D.start:M.start,s=D?D.end:M.end,i=M.minEndPTS||s,a=M.maxStartPTS||r,d=0;d<A.length;d++){var o=A.start(d)-this.bufferPadding,y=A.end(d)+this.bufferPadding;if(a>=o&&i<=y){u.time.push({startPTS:Math.max(r,A.start(d)),endPTS:Math.min(s,A.end(d))});break}else if(r<y&&s>o)u.partial=!0,u.time.push({startPTS:Math.max(r,A.start(d)),endPTS:Math.min(s,A.end(d))});else if(s<=o)break}return u},E.getPartialFragment=function(M){var D=null,b,A,u,r=0,s=this.bufferPadding,i=this.fragments;return Object.keys(i).forEach(function(a){var d=i[a];!d||T(d)&&(A=d.body.start-s,u=d.body.end+s,M>=A&&M<=u&&(b=Math.min(M-A,u-M),r<=b&&(D=d.body,r=b)))}),D},E.getState=function(M){var D=L(M),b=this.fragments[D];return b?b.buffered?T(b)?h.PARTIAL:h.OK:b.backtrack?h.BACKTRACKED:h.APPENDING:h.NOT_LOADED},E.backtrack=function(M,D){var b=L(M),A=this.fragments[b];if(!A||A.backtrack)return null;var u=A.backtrack=D||A.loaded;return A.loaded=null,u},E.getBacktrackData=function(M){var D=L(M),b=this.fragments[D];if(b){var A,u=b.backtrack;if(u!=null&&(A=u.payload)!==null&&A!==void 0&&A.byteLength)return u;this.removeFragment(M)}return null},E.isTimeBuffered=function(M,D,b){for(var A,u,r=0;r<b.length;r++){if(A=b.start(r)-this.bufferPadding,u=b.end(r)+this.bufferPadding,M>=A&&D<=u)return!0;if(D<=A)return!1}return!1},E.onFragLoaded=function(M,D){var b=D.frag,A=D.part;if(!(b.sn==="initSegment"||b.bitrateTest||A)){var u=L(b);this.fragments[u]={body:b,loaded:D,backtrack:null,buffered:!1,range:Object.create(null)}}},E.onBufferAppended=function(M,D){var b=this,A=D.frag,u=D.part,r=D.timeRanges;if(A.type===n.PlaylistLevelType.MAIN)if(this.activeFragment=A,u){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(u)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(i){var a=r[i];if(b.detectEvictedFragments(i,a),!u)for(var d=0;d<a.length;d++)A.appendedPTS=Math.max(a.end(d),A.appendedPTS||0)})},E.onFragBuffered=function(M,D){this.detectPartialFragments(D)},E.hasFragment=function(M){var D=L(M);return!!this.fragments[D]},E.removeFragmentsInRange=function(M,D,b){var A=this;Object.keys(this.fragments).forEach(function(u){var r=A.fragments[u];if(!!r&&r.buffered){var s=r.body;s.type===b&&s.start<D&&s.end>M&&A.removeFragment(s)}})},E.removeFragment=function(M){var D=L(M);M.stats.loaded=0,M.clearElementaryStreamInfo(),delete this.fragments[D]},E.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function T(_){var E,I;return _.buffered&&(((E=_.range.video)===null||E===void 0?void 0:E.partial)||((I=_.range.audio)===null||I===void 0?void 0:I.partial))}function L(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"STALL_MINIMUM_DURATION_MS",function(){return T}),t.d(e,"MAX_START_GAP_JUMP",function(){return L}),t.d(e,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),t.d(e,"SKIP_BUFFER_RANGE_START",function(){return E}),t.d(e,"default",function(){return I});var l=t("./src/utils/buffer-helper.ts"),n=t("./src/errors.ts"),h=t("./src/events.ts"),R=t("./src/utils/logger.ts"),T=250,L=2,_=.1,E=.05,I=function(){function M(b,A,u,r){this.config=void 0,this.media=void 0,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=b,this.media=A,this.fragmentTracker=u,this.hls=r}var D=M.prototype;return D.destroy=function(){this.hls=this.fragmentTracker=this.media=null},D.poll=function(A){var u=this.config,r=this.media,s=this.stalled,i=r.currentTime,a=r.seeking,d=this.seeking&&!a,o=!this.seeking&&a;if(this.seeking=a,i!==A){if(this.moved=!0,s!==null){if(this.stallReported){var y=self.performance.now()-s;R.logger.warn("playback not stuck anymore @"+i+", after "+Math.round(y)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((o||d)&&(this.stalled=null),!(r.paused||r.ended||r.playbackRate===0||!l.BufferHelper.getBuffered(r).length)){var p=l.BufferHelper.bufferInfo(r,i,0),m=p.len>0,g=p.nextStart||0;if(!(!m&&!g)){if(a){var f=p.len>L,c=!g||g-i>L&&!this.fragmentTracker.getPartialFragment(i);if(f||c)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x,S=Math.max(g,p.start||0)-i,O=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,C=O==null||(x=O.details)===null||x===void 0?void 0:x.live,P=C?O.details.targetduration*2:L;if(S>0&&S<=P){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(s===null){this.stalled=w;return}var U=w-s;!a&&U>=T&&this._reportStall(p.len);var k=l.BufferHelper.bufferInfo(r,i,u.maxBufferHole);this._tryFixBufferStall(k,U)}}},D._tryFixBufferStall=function(A,u){var r=this.config,s=this.fragmentTracker,i=this.media,a=i.currentTime,d=s.getPartialFragment(a);if(d){var o=this._trySkipBufferHole(d);if(o)return}A.len>r.maxBufferHole&&u>r.highBufferWatchdogPeriod*1e3&&(R.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},D._reportStall=function(A){var u=this.hls,r=this.media,s=this.stallReported;s||(this.stallReported=!0,R.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+A+")"),u.trigger(h.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:A}))},D._trySkipBufferHole=function(A){for(var u=this.config,r=this.hls,s=this.media,i=s.currentTime,a=0,d=l.BufferHelper.getBuffered(s),o=0;o<d.length;o++){var y=d.start(o);if(i+u.maxBufferHole>=a&&i<y){var p=Math.max(y+E,s.currentTime+_);return R.logger.warn("skipping hole, adjusting currentTime from "+i+" to "+p),this.moved=!0,this.stalled=null,s.currentTime=p,A&&r.trigger(h.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+i+" to "+p,frag:A}),p}a=d.end(o)}return 0},D._tryNudgeBuffer=function(){var A=this.config,u=this.hls,r=this.media,s=r.currentTime,i=(this.nudgeRetry||0)+1;if(this.nudgeRetry=i,i<A.nudgeMaxRetry){var a=s+i*A.nudgeOffset;R.logger.warn("Nudging 'currentTime' from "+s+" to "+a),r.currentTime=a,u.trigger(h.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else R.logger.error("Playhead still not moving while enough data buffered @"+s+" after "+A.nudgeMaxRetry+" nudges"),u.trigger(h.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},M}()},"./src/controller/id3-track-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/events.ts"),n=t("./src/utils/texttrack-utils.ts"),h=t("./src/demux/id3.ts"),R=.25,T=function(){function L(E){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=E,this._registerListeners()}var _=L.prototype;return _.destroy=function(){this._unregisterListeners()},_._registerListeners=function(){var I=this.hls;I.on(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),I.on(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this),I.on(l.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),I.on(l.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._unregisterListeners=function(){var I=this.hls;I.off(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),I.off(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this),I.off(l.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),I.off(l.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.onMediaAttached=function(I,M){this.media=M.media},_.onMediaDetaching=function(){!this.id3Track||(Object(n.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},_.getID3Track=function(I){if(!!this.media){for(var M=0;M<I.length;M++){var D=I[M];if(D.kind==="metadata"&&D.label==="id3")return Object(n.sendAddTrackEvent)(D,this.media),D}return this.media.addTextTrack("metadata","id3")}},_.onFragParsingMetadata=function(I,M){if(!!this.media){var D=M.frag,b=M.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var A=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<b.length;u++){var r=h.getID3Frames(b[u].data);if(r){var s=b[u].pts,i=u<b.length-1?b[u+1].pts:D.end,a=i-s;a<=0&&(i=s+R);for(var d=0;d<r.length;d++){var o=r[d];if(!h.isTimeStampFrame(o)){var y=new A(s,i,"");y.value=o,this.id3Track.addCue(y)}}}}}},_.onBufferFlushing=function(I,M){var D=M.startOffset,b=M.endOffset,A=M.type;if(!A||A==="audio"){var u=this.id3Track;u&&Object(n.removeCuesInRange)(u,D,b)}},L}();e.default=T},"./src/controller/latency-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return L});var l=t("./src/errors.ts"),n=t("./src/events.ts"),h=t("./src/utils/logger.ts");function R(_,E){for(var I=0;I<E.length;I++){var M=E[I];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(_,M.key,M)}}function T(_,E,I){return E&&R(_.prototype,E),I&&R(_,I),_}var L=function(){function _(I){var M=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 M.timeupdate()},this.hls=I,this.config=I.config,this.registerListeners()}var E=_.prototype;return E.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},E.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(n.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(n.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(n.Events.ERROR,this.onError)},E.onMediaAttached=function(M,D){this.media=D.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},E.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},E.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},E.onLevelUpdated=function(M,D){var b=D.details;this.levelDetails=b,b.advanced&&this.timeupdate(),!b.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},E.onError=function(M,D){D.details===l.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,h.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},E.timeupdate=function(){var M=this.media,D=this.levelDetails;if(!(!M||!D)){this.currentTime=M.currentTime;var b=this.computeLatency();if(b!==null){this._latency=b;var A=this.config,u=A.lowLatencyMode,r=A.maxLiveSyncPlaybackRate;if(!(!u||r===1)){var s=this.targetLatency;if(s!==null){var i=b-s,a=Math.min(this.maxLatency,s+D.targetduration),d=i<a;if(D.live&&d&&i>.05&&this.forwardBufferLength>1){var o=Math.min(2,Math.max(1,r)),y=Math.round(2/(1+Math.exp(-.75*i-this.edgeStalled))*20)/20;M.playbackRate=Math.min(o,Math.max(1,y))}else M.playbackRate!==1&&M.playbackRate!==0&&(M.playbackRate=1)}}}}},E.estimateLiveEdge=function(){var M=this.levelDetails;return M===null?null:M.edge+M.age},E.computeLatency=function(){var M=this.estimateLiveEdge();return M===null?null:M-this.currentTime},T(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var M=this.config,D=this.levelDetails;return M.liveMaxLatencyDuration!==void 0?M.liveMaxLatencyDuration:D?M.liveMaxLatencyDurationCount*D.targetduration:0}},{key:"targetLatency",get:function(){var M=this.levelDetails;if(M===null)return null;var D=M.holdBack,b=M.partHoldBack,A=M.targetduration,u=this.config,r=u.liveSyncDuration,s=u.liveSyncDurationCount,i=u.lowLatencyMode,a=this.hls.userConfig,d=i&&b||D;(a.liveSyncDuration||a.liveSyncDurationCount||d===0)&&(d=r!==void 0?r:s*A);var o=A,y=1;return d+Math.min(this.stallCount*y,o)}},{key:"liveSyncPosition",get:function(){var M=this.estimateLiveEdge(),D=this.targetLatency,b=this.levelDetails;if(M===null||D===null||b===null)return null;var A=b.edge,u=M-D-this.edgeStalled,r=A-b.totalduration,s=A-(this.config.lowLatencyMode&&b.partTarget||b.targetduration);return Math.min(Math.max(r,u),s)}},{key:"drift",get:function(){var M=this.levelDetails;return M===null?1:M.drift}},{key:"edgeStalled",get:function(){var M=this.levelDetails;if(M===null)return 0;var D=(this.config.lowLatencyMode&&M.partTarget||M.targetduration)*3;return Math.max(M.age-D,0)}},{key:"forwardBufferLength",get:function(){var M=this.media,D=this.levelDetails;if(!M||!D)return 0;var b=M.buffered.length;return b?M.buffered.end(b-1):D.edge-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return u});var l=t("./src/types/level.ts"),n=t("./src/events.ts"),h=t("./src/errors.ts"),R=t("./src/utils/codecs.ts"),T=t("./src/controller/level-helper.ts"),L=t("./src/controller/base-playlist-controller.ts"),_=t("./src/types/loader.ts");function E(){return E=Object.assign||function(r){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])}return r},E.apply(this,arguments)}function I(r,s){for(var i=0;i<s.length;i++){var a=s[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(r,a.key,a)}}function M(r,s,i){return s&&I(r.prototype,s),i&&I(r,i),r}function D(r,s){r.prototype=Object.create(s.prototype),r.prototype.constructor=r,b(r,s)}function b(r,s){return b=Object.setPrototypeOf||function(a,d){return a.__proto__=d,a},b(r,s)}var A=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(r){D(s,r);function s(a){var d;return d=r.call(this,a,"[level-controller]")||this,d._levels=[],d._firstLevel=-1,d._startLevel=void 0,d.currentLevelIndex=-1,d.manualLevelIndex=-1,d.onParsedComplete=void 0,d._registerListeners(),d}var i=s.prototype;return i._registerListeners=function(){var d=this.hls;d.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(n.Events.ERROR,this.onError,this)},i._unregisterListeners=function(){var d=this.hls;d.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(n.Events.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,r.prototype.destroy.call(this)},i.startLoad=function(){var d=this._levels;d.forEach(function(o){o.loadError=0}),r.prototype.startLoad.call(this)},i.onManifestLoaded=function(d,o){var y=[],p=[],m=[],g,f={},c,x=!1,S=!1,O=!1;if(o.levels.forEach(function(U){var k=U.attrs;x=x||!!(U.width&&U.height),S=S||!!U.videoCodec,O=O||!!U.audioCodec,A&&U.audioCodec&&U.audioCodec.indexOf("mp4a.40.34")!==-1&&(U.audioCodec=void 0);var N=U.bitrate+"-"+U.attrs.RESOLUTION+"-"+U.attrs.CODECS;c=f[N],c?c.url.push(U.url):(c=new l.Level(U),f[N]=c,y.push(c)),k&&(k.AUDIO&&Object(T.addGroupId)(c,"audio",k.AUDIO),k.SUBTITLES&&Object(T.addGroupId)(c,"text",k.SUBTITLES))}),(x||S)&&O&&(y=y.filter(function(U){var k=U.videoCodec,N=U.width,B=U.height;return!!k||!!(N&&B)})),y=y.filter(function(U){var k=U.audioCodec,N=U.videoCodec;return(!k||Object(R.isCodecSupportedInMp4)(k,"audio"))&&(!N||Object(R.isCodecSupportedInMp4)(N,"video"))}),o.audioTracks&&(p=o.audioTracks.filter(function(U){return!U.audioCodec||Object(R.isCodecSupportedInMp4)(U.audioCodec,"audio")}),Object(T.assignTrackIdsByGroup)(p)),o.subtitles&&(m=o.subtitles,Object(T.assignTrackIdsByGroup)(m)),y.length>0){g=y[0].bitrate,y.sort(function(U,k){return U.bitrate-k.bitrate}),this._levels=y;for(var C=0;C<y.length;C++)if(y[C].bitrate===g){this._firstLevel=C,this.log("manifest loaded, "+y.length+" level(s) found, first bitrate: "+g);break}var P=O&&!S,w={levels:y,audioTracks:p,subtitleTracks:m,firstLevel:this._firstLevel,stats:o.stats,audio:O,video:S,altAudio:!P&&p.some(function(U){return!!U.url})};this.hls.trigger(n.Events.MANIFEST_PARSED,w),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(n.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:o.url,reason:"no level with compatible codecs found in manifest"})},i.onError=function(d,o){if(r.prototype.onError.call(this,d,o),!o.fatal){var y=o.context,p=this._levels[this.currentLevelIndex];if(y&&(y.type===_.PlaylistContextType.AUDIO_TRACK&&p.audioGroupIds&&y.groupId===p.audioGroupIds[p.urlId]||y.type===_.PlaylistContextType.SUBTITLE_TRACK&&p.textGroupIds&&y.groupId===p.textGroupIds[p.urlId])){this.redundantFailover(this.currentLevelIndex);return}var m=!1,g=!0,f;switch(o.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:if(o.frag){var c=this._levels[o.frag.level];c?(c.fragmentError++,c.fragmentError>this.hls.config.fragLoadingMaxRetry&&(f=o.frag.level)):f=o.frag.level}break;case h.ErrorDetails.LEVEL_LOAD_ERROR:case h.ErrorDetails.LEVEL_LOAD_TIMEOUT:y&&(y.deliveryDirectives&&(g=!1),f=y.level),m=!0;break;case h.ErrorDetails.REMUX_ALLOC_ERROR:f=o.level,m=!0;break}f!==void 0&&this.recoverLevel(o,f,m,g)}},i.recoverLevel=function(d,o,y,p){var m=d.details,g=this._levels[o];if(g.loadError++,y){var f=this.retryLoadingOrFail(d);if(f)d.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(p){var c=g.url.length;if(c>1&&g.loadError<c)d.levelRetry=!0,this.redundantFailover(o);else if(this.manualLevelIndex===-1){var x=o===0?this._levels.length-1:o-1;this.currentLevelIndex!==x&&this._levels[x].loadError===0&&(this.warn(m+": switch to "+x),d.levelRetry=!0,this.hls.nextAutoLevel=x)}}},i.redundantFailover=function(d){var o=this._levels[d],y=o.url.length;if(y>1){var p=(o.urlId+1)%y;this.warn("Switching to redundant URL-id "+p),this._levels.forEach(function(m){m.urlId=p}),this.level=d}},i.onFragLoaded=function(d,o){var y=o.frag;if(y!==void 0&&y.type===_.PlaylistLevelType.MAIN){var p=this._levels[y.level];p!==void 0&&(p.fragmentError=0,p.loadError=0)}},i.onLevelLoaded=function(d,o){var y,p=o.level,m=o.details,g=this._levels[p];if(!g){var f;this.warn("Invalid level index "+p),(f=o.deliveryDirectives)!==null&&f!==void 0&&f.skip&&(m.deltaUpdateFailed=!0);return}p===this.currentLevelIndex?(g.fragmentError===0&&(g.loadError=0,this.retryCount=0),this.playlistLoaded(p,o,g.details)):(y=o.deliveryDirectives)!==null&&y!==void 0&&y.skip&&(m.deltaUpdateFailed=!0)},i.onAudioTrackSwitched=function(d,o){var y=this.hls.levels[this.currentLevelIndex];if(!!y&&y.audioGroupIds){for(var p=-1,m=this.hls.audioTracks[o.id].groupId,g=0;g<y.audioGroupIds.length;g++)if(y.audioGroupIds[g]===m){p=g;break}p!==y.urlId&&(y.urlId=p,this.startLoad())}},i.loadPlaylist=function(d){var o=this.currentLevelIndex,y=this._levels[o];if(this.canLoad&&y&&y.url.length>0){var p=y.urlId,m=y.url[p];if(d)try{m=d.addDirectives(m)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("Attempt loading level index "+o+(d?" at sn "+d.msn+" part "+d.part:"")+" with URL-id "+p+" "+m),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:m,level:o,id:p,deliveryDirectives:d||null})}},i.removeLevel=function(d,o){var y=function(g,f){return f!==o},p=this._levels.filter(function(m,g){return g!==d?!0:m.url.length>1&&o!==void 0?(m.url=m.url.filter(y),m.audioGroupIds&&(m.audioGroupIds=m.audioGroupIds.filter(y)),m.textGroupIds&&(m.textGroupIds=m.textGroupIds.filter(y)),m.urlId=0,!0):!1}).map(function(m,g){var f=m.details;return f!=null&&f.fragments&&f.fragments.forEach(function(c){c.level=g}),m});this._levels=p,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:p})},M(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(d){var o,y=this._levels;if(y.length!==0&&!(this.currentLevelIndex===d&&(o=y[d])!==null&&o!==void 0&&o.details)){if(d<0||d>=y.length){var p=d<0;if(this.hls.trigger(n.Events.ERROR,{type:h.ErrorTypes.OTHER_ERROR,details:h.ErrorDetails.LEVEL_SWITCH_ERROR,level:d,fatal:p,reason:"invalid level idx"}),p)return;d=Math.min(d,y.length-1)}this.clearTimer();var m=this.currentLevelIndex,g=y[m],f=y[d];this.log("switching to level "+d+" from "+m),this.currentLevelIndex=d;var c=E({},f,{level:d,maxBitrate:f.maxBitrate,uri:f.uri,urlId:f.urlId});delete c._urlId,this.hls.trigger(n.Events.LEVEL_SWITCHING,c);var x=f.details;if(!x||x.live){var S=this.switchParams(f.uri,g==null?void 0:g.details);this.loadPlaylist(S)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(d){this.manualLevelIndex=d,this._startLevel===void 0&&(this._startLevel=d),d!==-1&&(this.level=d)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(d){this._firstLevel=d}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var d=this.hls.config.startLevel;return d!==void 0?d:this._firstLevel}else return this._startLevel},set:function(d){this._startLevel=d}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(d){this.level=d,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=d)}}]),s}(L.default)},"./src/controller/level-helper.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"addGroupId",function(){return h}),t.d(e,"assignTrackIdsByGroup",function(){return R}),t.d(e,"updatePTS",function(){return T}),t.d(e,"updateFragPTSDTS",function(){return _}),t.d(e,"mergeDetails",function(){return E}),t.d(e,"mapPartIntersection",function(){return I}),t.d(e,"mapFragmentIntersection",function(){return M}),t.d(e,"adjustSliding",function(){return D}),t.d(e,"addSliding",function(){return b}),t.d(e,"computeReloadInterval",function(){return A}),t.d(e,"getFragmentWithSN",function(){return u}),t.d(e,"getPartWith",function(){return r});var l=t("./src/polyfills/number.ts"),n=t("./src/utils/logger.ts");function h(s,i,a){switch(i){case"audio":s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds.push(a);break;case"text":s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds.push(a);break}}function R(s){var i={};s.forEach(function(a){var d=a.groupId||"";a.id=i[d]=i[d]||0,i[d]++})}function T(s,i,a){var d=s[i],o=s[a];L(d,o)}function L(s,i){var a=i.startPTS;if(Object(l.isFiniteNumber)(a)){var d=0,o;i.sn>s.sn?(d=a-s.start,o=s):(d=s.start-a,o=i),o.duration!==d&&(o.duration=d)}else if(i.sn>s.sn){var y=s.cc===i.cc;y&&s.minEndPTS?i.start=s.start+(s.minEndPTS-s.start):i.start=s.start+s.duration}else i.start=Math.max(s.start-i.duration,0)}function _(s,i,a,d,o,y){var p=d-a;p<=0&&(n.logger.warn("Fragment should have a positive duration",i),d=a+i.duration,y=o+i.duration);var m=a,g=d,f=i.startPTS,c=i.endPTS;if(Object(l.isFiniteNumber)(f)){var x=Math.abs(f-a);Object(l.isFiniteNumber)(i.deltaPTS)?i.deltaPTS=Math.max(x,i.deltaPTS):i.deltaPTS=x,m=Math.max(a,f),a=Math.min(a,f),o=Math.min(o,i.startDTS),g=Math.min(d,c),d=Math.max(d,c),y=Math.max(y,i.endDTS)}i.duration=d-a;var S=a-i.start;i.appendedPTS=d,i.start=i.startPTS=a,i.maxStartPTS=m,i.startDTS=o,i.endPTS=d,i.minEndPTS=g,i.endDTS=y;var O=i.sn;if(!s||O<s.startSN||O>s.endSN)return 0;var C,P=O-s.startSN,w=s.fragments;for(w[P]=i,C=P;C>0;C--)L(w[C],w[C-1]);for(C=P;C<w.length-1;C++)L(w[C],w[C+1]);return s.fragmentHint&&L(w[w.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,S}function E(s,i){for(var a=null,d=s.fragments,o=d.length-1;o>=0;o--){var y=d[o].initSegment;if(y){a=y;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var p=0,m;if(M(s,i,function(C,P){C.relurl&&(p=C.cc-P.cc),Object(l.isFiniteNumber)(C.startPTS)&&Object(l.isFiniteNumber)(C.endPTS)&&(P.start=P.startPTS=C.startPTS,P.startDTS=C.startDTS,P.appendedPTS=C.appendedPTS,P.maxStartPTS=C.maxStartPTS,P.endPTS=C.endPTS,P.endDTS=C.endDTS,P.minEndPTS=C.minEndPTS,P.duration=C.endPTS-C.startPTS,P.duration&&(m=P),i.PTSKnown=i.alignedSliding=!0),P.elementaryStreams=C.elementaryStreams,P.loader=C.loader,P.stats=C.stats,P.urlId=C.urlId,C.initSegment&&(P.initSegment=C.initSegment,a=C.initSegment)}),a){var g=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;g.forEach(function(C){var P;(!C.initSegment||C.initSegment.relurl===((P=a)===null||P===void 0?void 0:P.relurl))&&(C.initSegment=a)})}if(i.skippedSegments&&(i.deltaUpdateFailed=i.fragments.some(function(C){return!C}),i.deltaUpdateFailed)){n.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=i.skippedSegments;f--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}var c=i.fragments;if(p){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<c.length;x++)c[x].cc+=p}i.skippedSegments&&(i.startCC=i.fragments[0].cc),I(s.partList,i.partList,function(C,P){P.elementaryStreams=C.elementaryStreams,P.stats=C.stats}),m?_(i,m,m.startPTS,m.endPTS,m.startDTS,m.endDTS):D(s,i),c.length&&(i.totalduration=i.edge-c[0].start),i.driftStartTime=s.driftStartTime,i.driftStart=s.driftStart;var S=i.advancedDateTime;if(i.advanced&&S){var O=i.edge;i.driftStart||(i.driftStartTime=S,i.driftStart=O),i.driftEndTime=S,i.driftEnd=O}else i.driftEndTime=s.driftEndTime,i.driftEnd=s.driftEnd,i.advancedDateTime=s.advancedDateTime}function I(s,i,a){if(s&&i)for(var d=0,o=0,y=s.length;o<=y;o++){var p=s[o],m=i[o+d];p&&m&&p.index===m.index&&p.fragment.sn===m.fragment.sn?a(p,m):d--}}function M(s,i,a){for(var d=i.skippedSegments,o=Math.max(s.startSN,i.startSN)-i.startSN,y=(s.fragmentHint?1:0)+(d?i.endSN:Math.min(s.endSN,i.endSN))-i.startSN,p=i.startSN-s.startSN,m=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,g=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,f=o;f<=y;f++){var c=g[p+f],x=m[f];d&&!x&&f<d&&(x=i.fragments[f]=c),c&&x&&a(c,x)}}function D(s,i){var a=i.startSN+i.skippedSegments-s.startSN,d=s.fragments;a<0||a>=d.length||b(i,d[a].start)}function b(s,i){if(i){for(var a=s.fragments,d=s.skippedSegments;d<a.length;d++)a[d].start+=i;s.fragmentHint&&(s.fragmentHint.start+=i)}}function A(s,i){var a=1e3*s.levelTargetDuration,d=a/2,o=s.age,y=o>0&&o<a*3,p=i.loading.end-i.loading.start,m,g=s.availabilityDelay;if(s.updated===!1)if(y){var f=333*s.misses;m=Math.max(Math.min(d,p*2),f),s.availabilityDelay=(s.availabilityDelay||0)+m}else m=d;else y?(g=Math.min(g||a/2,o),s.availabilityDelay=g,m=g+a-o):m=a-p;return Math.round(m)}function u(s,i,a){if(!s||!s.details)return null;var d=s.details,o=d.fragments[i-d.startSN];return o||(o=d.fragmentHint,o&&o.sn===i)?o:i<d.startSN&&a&&a.sn===i?a:null}function r(s,i,a){if(!s||!s.details)return null;var d=s.details.partList;if(d)for(var o=d.length;o--;){var y=d[o];if(y.index===a&&y.fragment.sn===i)return y}return null}},"./src/controller/stream-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return d});var l=t("./src/polyfills/number.ts"),n=t("./src/controller/base-stream-controller.ts"),h=t("./src/is-supported.ts"),R=t("./src/events.ts"),T=t("./src/utils/buffer-helper.ts"),L=t("./src/controller/fragment-tracker.ts"),_=t("./src/types/loader.ts"),E=t("./src/loader/fragment.ts"),I=t("./src/demux/transmuxer-interface.ts"),M=t("./src/types/transmuxer.ts"),D=t("./src/controller/gap-controller.ts"),b=t("./src/errors.ts"),A=t("./src/utils/logger.ts");function u(o,y){for(var p=0;p<y.length;p++){var m=y[p];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(o,m.key,m)}}function r(o,y,p){return y&&u(o.prototype,y),p&&u(o,p),o}function s(o,y){o.prototype=Object.create(y.prototype),o.prototype.constructor=o,i(o,y)}function i(o,y){return i=Object.setPrototypeOf||function(m,g){return m.__proto__=g,m},i(o,y)}var a=100,d=function(o){s(y,o);function y(m,g){var f;return f=o.call(this,m,g,"[stream-controller]")||this,f.audioCodecSwap=!1,f.gapController=null,f.level=-1,f._forceStartLoad=!1,f.altAudio=!1,f.audioOnly=!1,f.fragPlaying=null,f.onvplaying=null,f.onvseeked=null,f.fragLastKbps=0,f.stalled=!1,f.couldBacktrack=!1,f.audioCodecSwitch=!1,f.videoBuffer=null,f._registerListeners(),f}var p=y.prototype;return p._registerListeners=function(){var g=this.hls;g.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),g.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),g.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.on(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),g.on(R.Events.ERROR,this.onError,this),g.on(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),g.on(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this),g.on(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),g.on(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),g.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var g=this.hls;g.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),g.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),g.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),g.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),g.off(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),g.off(R.Events.ERROR,this.onError,this),g.off(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),g.off(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),g.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),g.off(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),g.off(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),g.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},p.startLoad=function(g){if(this.levels){var f=this.lastCurrentTime,c=this.hls;if(this.stopLoad(),this.setInterval(a),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var x=c.startLevel;x===-1&&(c.config.testBandwidth?(x=0,this.bitrateTest=!0):x=c.nextAutoLevel),this.level=c.nextLoadLevel=x,this.loadedmetadata=!1}f>0&&g===-1&&(this.log("Override startPosition with lastCurrentTime @"+f.toFixed(3)),g=f),this.state=n.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=g,this.tick()}else this._forceStartLoad=!0,this.state=n.State.STOPPED},p.stopLoad=function(){this._forceStartLoad=!1,o.prototype.stopLoad.call(this)},p.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_LEVEL:{var g,f=this.levels,c=this.level,x=f==null||(g=f[c])===null||g===void 0?void 0:g.details;if(x&&(!x.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(x))break;this.state=n.State.IDLE;break}break}case n.State.FRAG_LOADING_WAITING_RETRY:{var S,O=self.performance.now(),C=this.retryDate;(!C||O>=C||(S=this.media)!==null&&S!==void 0&&S.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=n.State.IDLE)}break;default:break}this.onTickEnd()},p.onTickEnd=function(){o.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},p.doTickIdle=function(){var g,f,c=this.hls,x=this.levelLastLoaded,S=this.levels,O=this.media,C=c.config,P=c.nextLoadLevel;if(!(x===null||!O&&(this.startFragRequested||!C.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!S||!S[P])){var w=S[P];this.level=c.nextLoadLevel=P;var U=w.details;if(!U||this.state===n.State.WAITING_LEVEL||U.live&&this.levelLastLoaded!==P){this.state=n.State.WAITING_LEVEL;return}var k=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:O,_.PlaylistLevelType.MAIN);if(k!==null){var N=k.len,B=this.getMaxBufferLength(w.maxBitrate);if(!(N>=B)){if(this._streamEnded(k,U)){var K={};this.altAudio&&(K.type="video"),this.hls.trigger(R.Events.BUFFER_EOS,K),this.state=n.State.ENDED;return}var W=k.end,F=this.getNextFragment(W,U);if(this.couldBacktrack&&!this.fragPrevious&&F&&F.sn!=="initSegment"){var H=F.sn-U.startSN;H>1&&(F=U.fragments[H-1],this.fragmentTracker.removeFragment(F))}if(F&&this.fragmentTracker.getState(F)===L.FragmentState.OK&&this.nextLoadPosition>W){var Y=this.audioOnly&&!this.altAudio?E.ElementaryStreamTypes.AUDIO:E.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(O,Y,_.PlaylistLevelType.MAIN),F=this.getNextFragment(this.nextLoadPosition,U)}!F||(F.initSegment&&!F.initSegment.data&&!this.bitrateTest&&(F=F.initSegment),((g=F.decryptdata)===null||g===void 0?void 0:g.keyFormat)==="identity"&&!((f=F.decryptdata)!==null&&f!==void 0&&f.key)?this.loadKey(F,U):this.loadFragment(F,U,W))}}}},p.loadFragment=function(g,f,c){var x,S=this.fragmentTracker.getState(g);if(this.fragCurrent=g,S===L.FragmentState.BACKTRACKED){var O=this.fragmentTracker.getBacktrackData(g);if(O){this._handleFragmentLoadProgress(O),this._handleFragmentLoadComplete(O);return}else S=L.FragmentState.NOT_LOADED}S===L.FragmentState.NOT_LOADED||S===L.FragmentState.PARTIAL?g.sn==="initSegment"?this._loadInitSegment(g):this.bitrateTest?(g.bitrateTest=!0,this.log("Fragment "+g.sn+" of level "+g.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(g)):(this.startFragRequested=!0,o.prototype.loadFragment.call(this,g,f,c)):S===L.FragmentState.APPENDING?this.reduceMaxBufferLength(g.duration)&&this.fragmentTracker.removeFragment(g):((x=this.media)===null||x===void 0?void 0:x.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},p.getAppendedFrag=function(g){var f=this.fragmentTracker.getAppendedFrag(g,_.PlaylistLevelType.MAIN);return f&&"fragment"in f?f.fragment:f},p.getBufferedFrag=function(g){return this.fragmentTracker.getBufferedFrag(g,_.PlaylistLevelType.MAIN)},p.followingBufferedFrag=function(g){return g?this.getBufferedFrag(g.end+.5):null},p.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},p.nextLevelSwitch=function(){var g=this.levels,f=this.media;if(f!=null&&f.readyState){var c,x=this.getAppendedFrag(f.currentTime);if(x&&x.start>1&&this.flushMainBuffer(0,x.start-1),!f.paused&&g){var S=this.hls.nextLoadLevel,O=g[S],C=this.fragLastKbps;C&&this.fragCurrent?c=this.fragCurrent.duration*O.maxBitrate/(1e3*C)+1:c=0}else c=0;var P=this.getBufferedFrag(f.currentTime+c);if(P){var w=this.followingBufferedFrag(P);if(w){this.abortCurrentFrag();var U=w.maxStartPTS?w.maxStartPTS:w.start,k=w.duration,N=Math.max(P.end,U+Math.min(Math.max(k-this.config.maxFragLookUpTolerance,k*.5),k*.75));this.flushMainBuffer(N,Number.POSITIVE_INFINITY)}}}},p.abortCurrentFrag=function(){var g=this.fragCurrent;this.fragCurrent=null,g!=null&&g.loader&&g.loader.abort(),this.state===n.State.KEY_LOADING&&(this.state=n.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},p.flushMainBuffer=function(g,f){o.prototype.flushMainBuffer.call(this,g,f,this.altAudio?"video":null)},p.onMediaAttached=function(g,f){o.prototype.onMediaAttached.call(this,g,f);var c=f.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),c.addEventListener("playing",this.onvplaying),c.addEventListener("seeked",this.onvseeked),this.gapController=new D.default(this.config,c,this.fragmentTracker,this.hls)},p.onMediaDetaching=function(){var g=this.media;g&&(g.removeEventListener("playing",this.onvplaying),g.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),o.prototype.onMediaDetaching.call(this)},p.onMediaPlaying=function(){this.tick()},p.onMediaSeeked=function(){var g=this.media,f=g?g.currentTime:null;Object(l.isFiniteNumber)(f)&&this.log("Media seeked to "+f.toFixed(3)),this.tick()},p.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},p.onManifestParsed=function(g,f){var c=!1,x=!1,S;f.levels.forEach(function(O){S=O.audioCodec,S&&(S.indexOf("mp4a.40.2")!==-1&&(c=!0),S.indexOf("mp4a.40.5")!==-1&&(x=!0))}),this.audioCodecSwitch=c&&x&&!Object(h.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=f.levels,this.startFragRequested=!1},p.onLevelLoading=function(g,f){var c=this.levels;if(!(!c||this.state!==n.State.IDLE)){var x=c[f.level];(!x.details||x.details.live&&this.levelLastLoaded!==f.level||this.waitForCdnTuneIn(x.details))&&(this.state=n.State.WAITING_LEVEL)}},p.onLevelLoaded=function(g,f){var c,x=this.levels,S=f.level,O=f.details,C=O.totalduration;if(!x){this.warn("Levels were reset while loading level "+S);return}this.log("Level "+S+" loaded ["+O.startSN+","+O.endSN+"], cc ["+O.startCC+", "+O.endCC+"] duration:"+C);var P=this.fragCurrent;P&&(this.state===n.State.FRAG_LOADING||this.state===n.State.FRAG_LOADING_WAITING_RETRY)&&P.level!==f.level&&P.loader&&(this.state=n.State.IDLE,P.loader.abort());var w=x[S],U=0;if(O.live||(c=w.details)!==null&&c!==void 0&&c.live){if(O.fragments[0]||(O.deltaUpdateFailed=!0),O.deltaUpdateFailed)return;U=this.alignPlaylists(O,w.details)}if(w.details=O,this.levelLastLoaded=S,this.hls.trigger(R.Events.LEVEL_UPDATED,{details:O,level:S}),this.state===n.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(O))return;this.state=n.State.IDLE}this.startFragRequested?O.live&&this.synchronizeToLiveEdge(O):this.setStartPosition(O,U),this.tick()},p._handleFragmentLoadProgress=function(g){var f,c=g.frag,x=g.part,S=g.payload,O=this.levels;if(!O){this.warn("Levels were reset while fragment load was in progress. Fragment "+c.sn+" of level "+c.level+" will not be buffered");return}var C=O[c.level],P=C.details;if(!P){this.warn("Dropping fragment "+c.sn+" of level "+c.level+" after level details were reset");return}var w=C.videoCodec,U=P.PTSKnown||!P.live,k=(f=c.initSegment)===null||f===void 0?void 0:f.data,N=this._getAudioCodec(C),B=this.transmuxer=this.transmuxer||new I.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),K=x?x.index:-1,W=K!==-1,F=new M.ChunkMetadata(c.level,c.sn,c.stats.chunkCount,S.byteLength,K,W),H=this.initPTS[c.cc];B.push(S,k,N,w,c,x,P.totalduration,U,F,H)},p.onAudioTrackSwitching=function(g,f){var c=this.altAudio,x=!!f.url,S=f.id;if(!x){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var O=this.fragCurrent;O!=null&&O.loader&&(this.log("Switching to main audio track, cancel main fragment load"),O.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var C=this.hls;c&&C.trigger(R.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),C.trigger(R.Events.AUDIO_TRACK_SWITCHED,{id:S})}},p.onAudioTrackSwitched=function(g,f){var c=f.id,x=!!this.hls.audioTracks[c].url;if(x){var S=this.videoBuffer;S&&this.mediaBuffer!==S&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=S)}this.altAudio=x,this.tick()},p.onBufferCreated=function(g,f){var c=f.tracks,x,S,O=!1;for(var C in c){var P=c[C];if(P.id==="main"){if(S=C,x=P,C==="video"){var w=c[C];w&&(this.videoBuffer=w.buffer)}}else O=!0}O&&x?(this.log("Alternate track found, use "+S+".buffered to schedule main fragment loading"),this.mediaBuffer=x.buffer):this.mediaBuffer=this.media},p.onFragBuffered=function(g,f){var c=f.frag,x=f.part;if(!(c&&c.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(c)){this.warn("Fragment "+c.sn+(x?" p: "+x.index:"")+" of level "+c.level+" finished buffering, but was aborted. state: "+this.state),this.state===n.State.PARSED&&(this.state=n.State.IDLE);return}var S=x?x.stats:c.stats;this.fragLastKbps=Math.round(8*S.total/(S.buffering.end-S.loading.first)),c.sn!=="initSegment"&&(this.fragPrevious=c),this.fragBufferedComplete(c,x)}},p.onError=function(g,f){switch(f.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:case b.ErrorDetails.KEY_LOAD_ERROR:case b.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,f);break;case b.ErrorDetails.LEVEL_LOAD_ERROR:case b.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==n.State.ERROR&&(f.fatal?(this.warn(""+f.details),this.state=n.State.ERROR):!f.levelRetry&&this.state===n.State.WAITING_LEVEL&&(this.state=n.State.IDLE));break;case b.ErrorDetails.BUFFER_FULL_ERROR:if(f.parent==="main"&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var c=!0,x=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);x&&x.len>.5&&(c=!this.reduceMaxBufferLength(x.len)),c&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},p.checkBuffer=function(){var g=this.media,f=this.gapController;if(!(!g||!f||!g.readyState)){var c=T.BufferHelper.getBuffered(g);!this.loadedmetadata&&c.length?(this.loadedmetadata=!0,this.seekToStartPos()):f.poll(this.lastCurrentTime),this.lastCurrentTime=g.currentTime}},p.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},p.onBufferFlushed=function(g,f){var c=f.type;if(c!==E.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var x=(c===E.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(x,c,_.PlaylistLevelType.MAIN)}},p.onLevelsUpdated=function(g,f){this.levels=f.levels},p.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},p.seekToStartPos=function(){var g=this.media,f=g.currentTime,c=this.startPosition;if(c>=0&&f<c){if(g.seeking){A.logger.log("could not seek to "+c+", already seeking at "+f);return}var x=T.BufferHelper.getBuffered(g),S=x.length?x.start(0):0,O=S-c;O>0&&(O<this.config.maxBufferHole||O<this.config.maxFragLookUpTolerance)&&(A.logger.log("adjusting start position by "+O+" to match buffer start"),c+=O,this.startPosition=c),this.log("seek to target start position "+c+" from current time "+f),g.currentTime=c}},p._getAudioCodec=function(g){var f=this.config.defaultAudioCodec||g.audioCodec;return this.audioCodecSwap&&f&&(this.log("Swapping audio codec"),f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5"),f},p._loadBitrateTestFrag=function(g){var f=this;this._doFragLoad(g).then(function(c){var x=f.hls;if(!(!c||x.nextLoadLevel||f.fragContextChanged(g))){f.fragLoadError=0,f.state=n.State.IDLE,f.startFragRequested=!1,f.bitrateTest=!1;var S=g.stats;S.parsing.start=S.parsing.end=S.buffering.start=S.buffering.end=self.performance.now(),x.trigger(R.Events.FRAG_LOADED,c)}})},p._handleTransmuxComplete=function(g){var f,c="main",x=this.hls,S=g.remuxResult,O=g.chunkMeta,C=this.getCurrentContext(O);if(!C){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(O.level);return}var P=C.frag,w=C.part,U=C.level,k=S.video,N=S.text,B=S.id3,K=S.initSegment,W=this.altAudio?void 0:S.audio;if(!this.fragContextChanged(P)){if(this.state=n.State.PARSING,K){K.tracks&&(this._bufferInitSegment(U,K.tracks,P,O),x.trigger(R.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:c,tracks:K.tracks}));var F=K.initPTS,H=K.timescale;Object(l.isFiniteNumber)(F)&&(this.initPTS[P.cc]=F,x.trigger(R.Events.INIT_PTS_FOUND,{frag:P,id:c,initPTS:F,timescale:H}))}if(k&&S.independent!==!1){if(U.details){var Y=k.startPTS,$=k.endPTS,Z=k.startDTS,q=k.endDTS;if(w)w.elementaryStreams[k.type]={startPTS:Y,endPTS:$,startDTS:Z,endDTS:q};else if(k.firstKeyFrame&&k.independent&&(this.couldBacktrack=!0),k.dropped&&k.independent){var oe=this.getLoadPosition()+this.config.maxBufferHole;if(oe<Y){this.backtrack(P);return}P.setElementaryStreamInfo(k.type,P.start,$,P.start,q,!0)}P.setElementaryStreamInfo(k.type,Y,$,Z,q),this.bufferFragmentData(k,P,w,O)}}else if(S.independent===!1){this.backtrack(P);return}if(W){var X=W.startPTS,ie=W.endPTS,fe=W.startDTS,ue=W.endDTS;w&&(w.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:ie,startDTS:fe,endDTS:ue}),P.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,X,ie,fe,ue),this.bufferFragmentData(W,P,w,O)}if(B!=null&&(f=B.samples)!==null&&f!==void 0&&f.length){var Ae={frag:P,id:c,samples:B.samples};x.trigger(R.Events.FRAG_PARSING_METADATA,Ae)}if(N){var re={frag:P,id:c,samples:N.samples};x.trigger(R.Events.FRAG_PARSING_USERDATA,re)}}},p._bufferInitSegment=function(g,f,c,x){var S=this;if(this.state===n.State.PARSING){this.audioOnly=!!f.audio&&!f.video,this.altAudio&&!this.audioOnly&&delete f.audio;var O=f.audio,C=f.video,P=f.audiovideo;if(O){var w=g.audioCodec,U=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(w&&(w.indexOf("mp4a.40.5")!==-1?w="mp4a.40.2":w="mp4a.40.5"),O.metadata.channelCount!==1&&U.indexOf("firefox")===-1&&(w="mp4a.40.5")),U.indexOf("android")!==-1&&O.container!=="audio/mpeg"&&(w="mp4a.40.2",this.log("Android: force audio codec to "+w)),g.audioCodec&&g.audioCodec!==w&&this.log('Swapping manifest audio codec "'+g.audioCodec+'" for "'+w+'"'),O.levelCodec=w,O.id="main",this.log("Init audio buffer, container:"+O.container+", codecs[selected/level/parsed]=["+(w||"")+"/"+(g.audioCodec||"")+"/"+O.codec+"]")}C&&(C.levelCodec=g.videoCodec,C.id="main",this.log("Init video buffer, container:"+C.container+", codecs[level/parsed]=["+(g.videoCodec||"")+"/"+C.codec+"]")),P&&this.log("Init audiovideo buffer, container:"+P.container+", codecs[level/parsed]=["+(g.attrs.CODECS||"")+"/"+P.codec+"]"),this.hls.trigger(R.Events.BUFFER_CODECS,f),Object.keys(f).forEach(function(k){var N=f[k],B=N.initSegment;B!=null&&B.byteLength&&S.hls.trigger(R.Events.BUFFER_APPENDING,{type:k,data:B,frag:c,part:null,chunkMeta:x,parent:c.type})}),this.tick()}},p.backtrack=function(g){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(g);var f=this.fragmentTracker.backtrack(g);this.fragPrevious=null,this.nextLoadPosition=g.start,f?this.resetFragmentLoading(g):this.state=n.State.BACKTRACKING},p.checkFragmentChanged=function(){var g=this.media,f=null;if(g&&g.readyState>1&&g.seeking===!1){var c=g.currentTime;if(T.BufferHelper.isBuffered(g,c)?f=this.getAppendedFrag(c):T.BufferHelper.isBuffered(g,c+.1)&&(f=this.getAppendedFrag(c+.1)),f){var x=this.fragPlaying,S=f.level;(!x||f.sn!==x.sn||x.level!==S||f.urlId!==x.urlId)&&(this.hls.trigger(R.Events.FRAG_CHANGED,{frag:f}),(!x||x.level!==S)&&this.hls.trigger(R.Events.LEVEL_SWITCHED,{level:S}),this.fragPlaying=f)}}},r(y,[{key:"nextLevel",get:function(){var g=this.nextBufferedFrag;return g?g.level:-1}},{key:"currentLevel",get:function(){var g=this.media;if(g){var f=this.getAppendedFrag(g.currentTime);if(f)return f.level}return-1}},{key:"nextBufferedFrag",get:function(){var g=this.media;if(g){var f=this.getAppendedFrag(g.currentTime);return this.followingBufferedFrag(f)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),y}(n.default)},"./src/controller/subtitle-stream-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"SubtitleStreamController",function(){return r});var l=t("./src/events.ts"),n=t("./src/utils/buffer-helper.ts"),h=t("./src/controller/fragment-finders.ts"),R=t("./src/utils/discontinuities.ts"),T=t("./src/controller/level-helper.ts"),L=t("./src/controller/fragment-tracker.ts"),_=t("./src/controller/base-stream-controller.ts"),E=t("./src/types/loader.ts"),I=t("./src/types/level.ts");function M(s,i){for(var a=0;a<i.length;a++){var d=i[a];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(s,d.key,d)}}function D(s,i,a){return i&&M(s.prototype,i),a&&M(s,a),s}function b(s,i){s.prototype=Object.create(i.prototype),s.prototype.constructor=s,A(s,i)}function A(s,i){return A=Object.setPrototypeOf||function(d,o){return d.__proto__=o,d},A(s,i)}var u=500,r=function(s){b(i,s);function i(d,o){var y;return y=s.call(this,d,o,"[subtitle-stream-controller]")||this,y.levels=[],y.currentTrackId=-1,y.tracksBuffered=[],y.mainDetails=null,y._registerListeners(),y}var a=i.prototype;return a.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},a._registerListeners=function(){var o=this.hls;o.on(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(l.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(l.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(l.Events.ERROR,this.onError,this),o.on(l.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(l.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.on(l.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(l.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.on(l.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},a._unregisterListeners=function(){var o=this.hls;o.off(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(l.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(l.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(l.Events.ERROR,this.onError,this),o.off(l.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.off(l.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),o.off(l.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(l.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),o.off(l.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},a.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(u),this.tick()},a.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},a.onLevelLoaded=function(o,y){this.mainDetails=y.details},a.onSubtitleFragProcessed=function(o,y){var p=y.frag,m=y.success;if(this.fragPrevious=p,this.state=_.State.IDLE,!!m){var g=this.tracksBuffered[this.currentTrackId];if(!!g){for(var f,c=p.start,x=0;x<g.length;x++)if(c>=g[x].start&&c<=g[x].end){f=g[x];break}var S=p.start+p.duration;f?f.end=S:(f={start:c,end:S},g.push(f)),this.fragmentTracker.fragBuffered(p)}}},a.onBufferFlushing=function(o,y){var p=y.startOffset,m=y.endOffset;if(p===0&&m!==Number.POSITIVE_INFINITY){var g=this.currentTrackId,f=this.levels;if(!f.length||!f[g]||!f[g].details)return;var c=f[g].details,x=c.targetduration,S=m-x;if(S<=0)return;y.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(O){for(var C=0;C<O.length;){if(O[C].end<=S){O.shift();continue}else if(O[C].start<S)O[C].start=S;else break;C++}}),this.fragmentTracker.removeFragmentsInRange(p,S,E.PlaylistLevelType.SUBTITLE)}},a.onError=function(o,y){var p,m=y.frag;!m||m.type!==E.PlaylistLevelType.SUBTITLE||((p=this.fragCurrent)!==null&&p!==void 0&&p.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},a.onSubtitleTracksUpdated=function(o,y){var p=this,m=y.subtitleTracks;this.tracksBuffered=[],this.levels=m.map(function(g){return new I.Level(g)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(g){p.tracksBuffered[g.id]=[]}),this.mediaBuffer=null},a.onSubtitleTrackSwitch=function(o,y){if(this.currentTrackId=y.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var p=this.levels[this.currentTrackId];p!=null&&p.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,p&&this.setInterval(u)},a.onSubtitleTrackLoaded=function(o,y){var p,m=y.details,g=y.id,f=this.currentTrackId,c=this.levels;if(!!c.length){var x=c[f];if(!(g>=c.length||g!==f||!x)){if(this.mediaBuffer=this.mediaBufferTimeRanges,m.live||(p=x.details)!==null&&p!==void 0&&p.live){var S=this.mainDetails;if(m.deltaUpdateFailed||!S)return;var O=S.fragments[0];if(!x.details)m.hasProgramDateTime&&S.hasProgramDateTime?Object(R.alignMediaPlaylistByPDT)(m,S):O&&Object(T.addSliding)(m,O.start);else{var C=this.alignPlaylists(m,x.details);C===0&&O&&Object(T.addSliding)(m,O.start)}}if(x.details=m,this.levelLastLoaded=g,this.tick(),m.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var P=Object(h.findFragmentByPTS)(null,m.fragments,this.media.currentTime,0);P||(this.warn("Subtitle playlist not aligned with playback"),x.details=void 0)}}}},a._handleFragmentLoadComplete=function(o){var y=o.frag,p=o.payload,m=y.decryptdata,g=this.hls;if(!this.fragContextChanged(y)&&p&&p.byteLength>0&&m&&m.key&&m.iv&&m.method==="AES-128"){var f=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(p),m.key.buffer,m.iv.buffer).then(function(c){var x=performance.now();g.trigger(l.Events.FRAG_DECRYPTED,{frag:y,payload:c,stats:{tstart:f,tdecrypt:x}})})}},a.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var o,y=this.currentTrackId,p=this.levels;if(!p.length||!p[y]||!p[y].details)return;var m=p[y].details,g=m.targetduration,f=this.config,c=this.media,x=n.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,c.currentTime-g,f.maxBufferHole),S=x.end,O=x.len,C=this.getMaxBufferLength()+g;if(O>C)return;console.assert(m,"Subtitle track details are defined on idle subtitle stream controller tick");var P=m.fragments,w=P.length,U=m.edge,k,N=this.fragPrevious;if(S<U){var B=f.maxFragLookUpTolerance;k=Object(h.findFragmentByPTS)(N,P,S,B),!k&&N&&N.start<P[0].start&&(k=P[0])}else k=P[w-1];(o=k)!==null&&o!==void 0&&o.encrypted?this.loadKey(k,m):k&&this.fragmentTracker.getState(k)===L.FragmentState.NOT_LOADED&&this.loadFragment(k,m,S)}},a.loadFragment=function(o,y,p){this.fragCurrent=o,s.prototype.loadFragment.call(this,o,y,p)},D(i,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),i}(_.default)},"./src/controller/subtitle-track-controller.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/events.ts"),n=t("./src/utils/texttrack-utils.ts"),h=t("./src/controller/base-playlist-controller.ts"),R=t("./src/types/loader.ts");function T(D,b){for(var A=0;A<b.length;A++){var u=b[A];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(D,u.key,u)}}function L(D,b,A){return b&&T(D.prototype,b),A&&T(D,A),D}function _(D,b){D.prototype=Object.create(b.prototype),D.prototype.constructor=D,E(D,b)}function E(D,b){return E=Object.setPrototypeOf||function(u,r){return u.__proto__=r,u},E(D,b)}var I=function(D){_(b,D);function b(u){var r;return r=D.call(this,u,"[subtitle-track-controller]")||this,r.media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}var A=b.prototype;return A.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,D.prototype.destroy.call(this)},A.registerListeners=function(){var r=this.hls;r.on(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(l.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(l.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(l.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(l.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(l.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var r=this.hls;r.off(l.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(l.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(l.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(l.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(l.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(l.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(l.Events.ERROR,this.onError,this)},A.onMediaAttached=function(r,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))},A.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},A.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 r=M(this.media.textTracks);r.forEach(function(s){Object(n.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null}},A.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},A.onManifestParsed=function(r,s){this.tracks=s.subtitleTracks},A.onSubtitleTrackLoaded=function(r,s){var i=s.id,a=s.details,d=this.trackId,o=this.tracksInGroup[d];if(!o){this.warn("Invalid subtitle track id "+i);return}var y=o.details;o.details=s.details,this.log("subtitle track "+i+" loaded ["+a.startSN+"-"+a.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,s,y))},A.onLevelLoading=function(r,s){this.switchLevel(s.level)},A.onLevelSwitching=function(r,s){this.switchLevel(s.level)},A.switchLevel=function(r){var s=this.hls.levels[r];if(!!(s!=null&&s.textGroupIds)){var i=s.textGroupIds[s.urlId];if(this.groupId!==i){var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,d=this.tracks.filter(function(p){return!i||p.groupId===i});this.tracksInGroup=d;var o=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=i;var y={subtitleTracks:d};this.log("Updating subtitle tracks, "+d.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(l.Events.SUBTITLE_TRACKS_UPDATED,y),o!==-1&&this.setSubtitleTrack(o,a)}}},A.findTrackId=function(r){for(var s=this.tracksInGroup,i=0;i<s.length;i++){var a=s[i];if((!this.selectDefaultTrack||a.default)&&(!r||r===a.name))return a.id}return-1},A.onError=function(r,s){D.prototype.onError.call(this,r,s),!(s.fatal||!s.context)&&s.context.type===R.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},A.loadPlaylist=function(r){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var i=s.id,a=s.groupId,d=s.url;if(r)try{d=r.addDirectives(d)}catch(o){this.warn("Could not construct new URL with HLS Delivery Directives: "+o)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(l.Events.SUBTITLE_TRACK_LOADING,{url:d,id:i,groupId:a,deliveryDirectives:r||null})}},A.toggleTrackModes=function(r){var s=this,i=this.media,a=this.subtitleDisplay,d=this.trackId;if(!!i){var o=M(i.textTracks),y=o.filter(function(g){return g.groupId===s.groupId});if(r===-1)[].slice.call(o).forEach(function(g){g.mode="disabled"});else{var p=y[d];p&&(p.mode="disabled")}var m=y[r];m&&(m.mode=a?"showing":"hidden")}},A.setSubtitleTrack=function(r,s){var i,a=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=r;return}if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(i=a[r])!==null&&i!==void 0&&i.details)||r<-1||r>=a.length)){this.clearTimer();var d=a[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,d){var o=d.id,y=d.groupId,p=y===void 0?"":y,m=d.name,g=d.type,f=d.url;this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:p,name:m,type:g,url:f});var c=this.switchParams(d.url,s==null?void 0:s.details);this.loadPlaylist(c)}else this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:r})}},A.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var r=-1,s=M(this.media.textTracks),i=0;i<s.length;i++)if(s[i].mode==="hidden")r=i;else if(s[i].mode==="showing"){r=i;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},L(b,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,s)}}]),b}(h.default);function M(D){for(var b=[],A=0;A<D.length;A++){var u=D[A];u.kind==="subtitles"&&u.label&&b.push(D[A])}return b}e.default=I},"./src/controller/timeline-controller.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"TimelineController",function(){return M});var l=t("./src/polyfills/number.ts"),n=t("./src/events.ts"),h=t("./src/utils/cea-608-parser.ts"),R=t("./src/utils/output-filter.ts"),T=t("./src/utils/webvtt-parser.ts"),L=t("./src/utils/texttrack-utils.ts"),_=t("./src/utils/imsc1-ttml-parser.ts"),E=t("./src/types/loader.ts"),I=t("./src/utils/logger.ts"),M=function(){function u(s){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=s,this.config=s.config,this.Cues=s.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 i=new R.default(this,"textTrack1"),a=new R.default(this,"textTrack2"),d=new R.default(this,"textTrack3"),o=new R.default(this,"textTrack4");this.cea608Parser1=new h.default(1,i,a),this.cea608Parser2=new h.default(3,d,o)}s.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.on(n.Events.FRAG_LOADING,this.onFragLoading,this),s.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.on(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.on(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var r=u.prototype;return r.destroy=function(){var i=this.hls;i.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),i.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),i.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),i.off(n.Events.FRAG_LOADING,this.onFragLoading,this),i.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),i.off(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),i.off(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),i.off(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),i.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},r.addCues=function(i,a,d,o,y){for(var p=!1,m=y.length;m--;){var g=y[m],f=b(g[0],g[1],a,d);if(f>=0&&(g[0]=Math.min(g[0],a),g[1]=Math.max(g[1],d),p=!0,f/(d-a)>.5))return}if(p||y.push([a,d]),this.config.renderTextTracksNatively){var c=this.captionsTracks[i];this.Cues.newCue(c,a,d,o)}else{var x=this.Cues.newCue(null,a,d,o);this.hls.trigger(n.Events.CUES_PARSED,{type:"captions",cues:x,track:i})}},r.onInitPtsFound=function(i,a){var d=this,o=a.frag,y=a.id,p=a.initPTS,m=a.timescale,g=this.unparsedVttFrags;y==="main"&&(this.initPTS[o.cc]=p,this.timescale[o.cc]=m),g.length&&(this.unparsedVttFrags=[],g.forEach(function(f){d.onFragLoaded(n.Events.FRAG_LOADED,f)}))},r.getExistingTrack=function(i){var a=this.media;if(a)for(var d=0;d<a.textTracks.length;d++){var o=a.textTracks[d];if(o[i])return o}return null},r.createCaptionsTrack=function(i){this.config.renderTextTracksNatively?this.createNativeTrack(i):this.createNonNativeTrack(i)},r.createNativeTrack=function(i){if(!this.captionsTracks[i]){var a=this.captionsProperties,d=this.captionsTracks,o=this.media,y=a[i],p=y.label,m=y.languageCode,g=this.getExistingTrack(i);if(g)d[i]=g,Object(L.clearCurrentCues)(d[i]),Object(L.sendAddTrackEvent)(d[i],o);else{var f=this.createTextTrack("captions",p,m);f&&(f[i]=!0,d[i]=f)}}},r.createNonNativeTrack=function(i){if(!this.nonNativeCaptionsTracks[i]){var a=this.captionsProperties[i];if(!!a){var d=a.label,o={_id:i,label:d,kind:"captions",default:a.media?!!a.media.default:!1,closedCaptions:a.media};this.nonNativeCaptionsTracks[i]=o,this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[o]})}}},r.createTextTrack=function(i,a,d){var o=this.media;if(!!o)return o.addTextTrack(i,a,d)},r.onMediaAttaching=function(i,a){this.media=a.media,this._cleanTracks()},r.onMediaDetaching=function(){var i=this.captionsTracks;Object.keys(i).forEach(function(a){Object(L.clearCurrentCues)(i[a]),delete i[a]}),this.nonNativeCaptionsTracks={}},r.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())},r._cleanTracks=function(){var i=this.media;if(!!i){var a=i.textTracks;if(a)for(var d=0;d<a.length;d++)Object(L.clearCurrentCues)(a[d])}},r.onSubtitleTracksUpdated=function(i,a){var d=this;this.textTracks=[];var o=a.subtitleTracks||[],y=o.some(function(f){return f.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||y&&this.config.enableIMSC1){var p=this.tracks&&o&&this.tracks.length===o.length;if(this.tracks=o||[],this.config.renderTextTracksNatively){var m=this.media?this.media.textTracks:[];this.tracks.forEach(function(f,c){var x;if(c<m.length){for(var S=null,O=0;O<m.length;O++)if(D(m[O],f)){S=m[O];break}S&&(x=S)}x?Object(L.clearCurrentCues)(x):(x=d.createTextTrack("subtitles",f.name,f.lang),x&&(x.mode="disabled")),x&&(x.groupId=f.groupId,d.textTracks.push(x))})}else if(!p&&this.tracks&&this.tracks.length){var g=this.tracks.map(function(f){return{label:f.name,kind:f.type.toLowerCase(),default:f.default,subtitleTrack:f}});this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:g})}}},r.onManifestLoaded=function(i,a){var d=this;this.config.enableCEA708Captions&&a.captions&&a.captions.forEach(function(o){var y=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(!!y){var p="textTrack"+y[1],m=d.captionsProperties[p];!m||(m.label=o.name,o.lang&&(m.languageCode=o.lang),m.media=o)}})},r.onFragLoading=function(i,a){var d=this.cea608Parser1,o=this.cea608Parser2,y=this.lastSn,p=this.lastPartIndex;if(!(!this.enabled||!(d&&o))&&a.frag.type===E.PlaylistLevelType.MAIN){var m,g,f=a.frag.sn,c=(m=a==null||(g=a.part)===null||g===void 0?void 0:g.index)!=null?m:-1;f===y+1||f===y&&c===p+1||(d.reset(),o.reset()),this.lastSn=f,this.lastPartIndex=c}},r.onFragLoaded=function(i,a){var d=a.frag,o=a.payload,y=this.initPTS,p=this.unparsedVttFrags;if(d.type===E.PlaylistLevelType.SUBTITLE)if(o.byteLength){if(!Object(l.isFiniteNumber)(y[d.cc])){p.push(a),y.length&&this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:new Error("Missing initial subtitle PTS")});return}var m=d.decryptdata,g="stats"in a;if(m==null||m.key==null||m.method!=="AES-128"||g){var f=this.tracks[d.level],c=this.vttCCs;c[d.cc]||(c[d.cc]={start:d.start,prevCC:this.prevCC,new:!0},this.prevCC=d.cc),f&&f.textCodec===_.IMSC1_CODEC?this._parseIMSC1(d,o):this._parseVTTs(d,o,c)}}else this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:new Error("Empty subtitle payload")})},r._parseIMSC1=function(i,a){var d=this,o=this.hls;Object(_.parseIMSC1)(a,this.initPTS[i.cc],this.timescale[i.cc],function(y){d._appendCues(y,i.level),o.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},function(y){I.logger.log("Failed to parse IMSC1: "+y),o.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:y})})},r._parseVTTs=function(i,a,d){var o=this,y=this.hls;Object(T.parseWebVTT)(a,this.initPTS[i.cc],this.timescale[i.cc],d,i.cc,i.start,function(p){o._appendCues(p,i.level),y.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},function(p){o._fallbackToIMSC1(i,a),I.logger.log("Failed to parse VTT cue: "+p),y.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:p})})},r._fallbackToIMSC1=function(i,a){var d=this,o=this.tracks[i.level];o.textCodec||Object(_.parseIMSC1)(a,this.initPTS[i.cc],this.timescale[i.cc],function(){o.textCodec=_.IMSC1_CODEC,d._parseIMSC1(i,a)},function(){o.textCodec="wvtt"})},r._appendCues=function(i,a){var d=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[a];if(o.mode==="disabled")return;i.forEach(function(m){return Object(L.addCueToTrack)(o,m)})}else{var y=this.tracks[a],p=y.default?"default":"subtitles"+a;d.trigger(n.Events.CUES_PARSED,{type:"subtitles",cues:i,track:p})}},r.onFragDecrypted=function(i,a){var d=a.frag;if(d.type===E.PlaylistLevelType.SUBTITLE){if(!Object(l.isFiniteNumber)(this.initPTS[d.cc])){this.unparsedVttFrags.push(a);return}this.onFragLoaded(n.Events.FRAG_LOADED,a)}},r.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},r.onFragParsingUserdata=function(i,a){var d=this.cea608Parser1,o=this.cea608Parser2;if(!(!this.enabled||!(d&&o)))for(var y=0;y<a.samples.length;y++){var p=a.samples[y].bytes;if(p){var m=this.extractCea608Data(p);d.addData(a.samples[y].pts,m[0]),o.addData(a.samples[y].pts,m[1])}}},r.onBufferFlushing=function(i,a){var d=a.startOffset,o=a.endOffset,y=a.endOffsetSubtitles,p=a.type,m=this.media;if(!(!m||m.currentTime<o)){if(!p||p==="video"){var g=this.captionsTracks;Object.keys(g).forEach(function(c){return Object(L.removeCuesInRange)(g[c],d,o)})}if(this.config.renderTextTracksNatively&&d===0&&y!==void 0){var f=this.textTracks;Object.keys(f).forEach(function(c){return Object(L.removeCuesInRange)(f[c],d,y)})}}},r.extractCea608Data=function(i){for(var a=i[0]&31,d=2,o=[[],[]],y=0;y<a;y++){var p=i[d++],m=127&i[d++],g=127&i[d++],f=(4&p)!=0,c=3&p;m===0&&g===0||f&&(c===0||c===1)&&(o[c].push(m),o[c].push(g))}return o},u}();function D(u,r){return u&&u.label===r.name&&!(u.textTrack1||u.textTrack2)}function b(u,r,s,i){return Math.min(r,i)-Math.max(u,s)}function A(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return l});var l=function(){function n(R,T){this.subtle=void 0,this.aesIV=void 0,this.subtle=R,this.aesIV=T}var h=n.prototype;return h.decrypt=function(T,L){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},L,T)},n}()},"./src/crypt/aes-decryptor.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"removePadding",function(){return n}),t.d(e,"default",function(){return h});var l=t("./src/utils/typed-array.ts");function n(R){var T=R.byteLength,L=T&&new DataView(R.buffer).getUint8(T-1);return L?Object(l.sliceUint8)(R,0,T-L):R}var h=function(){function R(){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=R.prototype;return T.uint8ArrayToUint32Array_=function(_){for(var E=new DataView(_),I=new Uint32Array(4),M=0;M<4;M++)I[M]=E.getUint32(M*4);return I},T.initTable=function(){var _=this.sBox,E=this.invSBox,I=this.subMix,M=I[0],D=I[1],b=I[2],A=I[3],u=this.invSubMix,r=u[0],s=u[1],i=u[2],a=u[3],d=new Uint32Array(256),o=0,y=0,p=0;for(p=0;p<256;p++)p<128?d[p]=p<<1:d[p]=p<<1^283;for(p=0;p<256;p++){var m=y^y<<1^y<<2^y<<3^y<<4;m=m>>>8^m&255^99,_[o]=m,E[m]=o;var g=d[o],f=d[g],c=d[f],x=d[m]*257^m*16843008;M[o]=x<<24|x>>>8,D[o]=x<<16|x>>>16,b[o]=x<<8|x>>>24,A[o]=x,x=c*16843009^f*65537^g*257^o*16843008,r[m]=x<<24|x>>>8,s[m]=x<<16|x>>>16,i[m]=x<<8|x>>>24,a[m]=x,o?(o=g^d[d[d[c^g]]],y^=d[d[y]]):o=y=1}},T.expandKey=function(_){for(var E=this.uint8ArrayToUint32Array_(_),I=!0,M=0;M<E.length&&I;)I=E[M]===this.key[M],M++;if(!I){this.key=E;var D=this.keySize=E.length;if(D!==4&&D!==6&&D!==8)throw new Error("Invalid aes key size="+D);var b=this.ksRows=(D+6+1)*4,A,u,r=this.keySchedule=new Uint32Array(b),s=this.invKeySchedule=new Uint32Array(b),i=this.sBox,a=this.rcon,d=this.invSubMix,o=d[0],y=d[1],p=d[2],m=d[3],g,f;for(A=0;A<b;A++){if(A<D){g=r[A]=E[A];continue}f=g,A%D==0?(f=f<<8|f>>>24,f=i[f>>>24]<<24|i[f>>>16&255]<<16|i[f>>>8&255]<<8|i[f&255],f^=a[A/D|0]<<24):D>6&&A%D==4&&(f=i[f>>>24]<<24|i[f>>>16&255]<<16|i[f>>>8&255]<<8|i[f&255]),r[A]=g=(r[A-D]^f)>>>0}for(u=0;u<b;u++)A=b-u,u&3?f=r[A]:f=r[A-4],u<4||A<=4?s[u]=f:s[u]=o[i[f>>>24]]^y[i[f>>>16&255]]^p[i[f>>>8&255]]^m[i[f&255]],s[u]=s[u]>>>0}},T.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},T.decrypt=function(_,E,I){for(var M=this.keySize+6,D=this.invKeySchedule,b=this.invSBox,A=this.invSubMix,u=A[0],r=A[1],s=A[2],i=A[3],a=this.uint8ArrayToUint32Array_(I),d=a[0],o=a[1],y=a[2],p=a[3],m=new Int32Array(_),g=new Int32Array(m.length),f,c,x,S,O,C,P,w,U,k,N,B,K,W,F=this.networkToHostOrderSwap;E<m.length;){for(U=F(m[E]),k=F(m[E+1]),N=F(m[E+2]),B=F(m[E+3]),O=U^D[0],C=B^D[1],P=N^D[2],w=k^D[3],K=4,W=1;W<M;W++)f=u[O>>>24]^r[C>>16&255]^s[P>>8&255]^i[w&255]^D[K],c=u[C>>>24]^r[P>>16&255]^s[w>>8&255]^i[O&255]^D[K+1],x=u[P>>>24]^r[w>>16&255]^s[O>>8&255]^i[C&255]^D[K+2],S=u[w>>>24]^r[O>>16&255]^s[C>>8&255]^i[P&255]^D[K+3],O=f,C=c,P=x,w=S,K=K+4;f=b[O>>>24]<<24^b[C>>16&255]<<16^b[P>>8&255]<<8^b[w&255]^D[K],c=b[C>>>24]<<24^b[P>>16&255]<<16^b[w>>8&255]<<8^b[O&255]^D[K+1],x=b[P>>>24]<<24^b[w>>16&255]<<16^b[O>>8&255]<<8^b[C&255]^D[K+2],S=b[w>>>24]<<24^b[O>>16&255]<<16^b[C>>8&255]<<8^b[P&255]^D[K+3],g[E]=F(f^d),g[E+1]=F(S^o),g[E+2]=F(x^y),g[E+3]=F(c^p),d=U,o=k,y=N,p=B,E=E+4}return g.buffer},R}()},"./src/crypt/decrypter.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return E});var l=t("./src/crypt/aes-crypto.ts"),n=t("./src/crypt/fast-aes-key.ts"),h=t("./src/crypt/aes-decryptor.ts"),R=t("./src/utils/logger.ts"),T=t("./src/utils/mp4-tools.ts"),L=t("./src/utils/typed-array.ts"),_=16,E=function(){function I(D,b,A){var u=A===void 0?{}:A,r=u.removePKCS7Padding,s=r===void 0?!0:r;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=D,this.config=b,this.removePKCS7Padding=s,s)try{var i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var M=I.prototype;return M.destroy=function(){this.observer=null},M.isSync=function(){return this.config.enableSoftwareAES},M.flush=function(){var b=this.currentResult;if(!b){this.reset();return}var A=new Uint8Array(b);return this.reset(),this.removePKCS7Padding?Object(h.removePadding)(A):A},M.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},M.decrypt=function(b,A,u,r){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(b),A,u);var s=this.flush();s&&r(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(b),A,u).then(r)},M.softwareDecrypt=function(b,A,u){var r=this.currentIV,s=this.currentResult,i=this.remainderData;this.logOnce("JS AES decrypt"),i&&(b=Object(T.appendUint8Array)(i,b),this.remainderData=null);var a=this.getValidChunk(b);if(!a.length)return null;r&&(u=r);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new h.default),d.expandKey(A);var o=s;return this.currentResult=d.decrypt(a.buffer,0,u),this.currentIV=Object(L.sliceUint8)(a,-16).buffer,o||null},M.webCryptoDecrypt=function(b,A,u){var r=this,s=this.subtle;return(this.key!==A||!this.fastAesKey)&&(this.key=A,this.fastAesKey=new n.default(s,A)),this.fastAesKey.expandKey().then(function(i){if(!s)return Promise.reject(new Error("web crypto not initialized"));var a=new l.default(s,u);return a.decrypt(b.buffer,i)}).catch(function(i){return r.onWebCryptoError(i,b,A,u)})},M.onWebCryptoError=function(b,A,u,r){return R.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",b),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(A,u,r)},M.getValidChunk=function(b){var A=b,u=b.length-b.length%_;return u!==b.length&&(A=Object(L.sliceUint8)(b,0,u),this.remainderData=Object(L.sliceUint8)(b,u)),A},M.logOnce=function(b){!this.logEnabled||(R.logger.log("[decrypter.ts]: "+b),this.logEnabled=!1)},I}()},"./src/crypt/fast-aes-key.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return l});var l=function(){function n(R,T){this.subtle=void 0,this.key=void 0,this.subtle=R,this.key=T}var h=n.prototype;return h.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},n}()},"./src/demux/aacdemuxer.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/demux/base-audio-demuxer.ts"),n=t("./src/demux/adts.ts"),h=t("./src/utils/logger.ts"),R=t("./src/demux/id3.ts");function T(E,I){E.prototype=Object.create(I.prototype),E.prototype.constructor=E,L(E,I)}function L(E,I){return L=Object.setPrototypeOf||function(D,b){return D.__proto__=b,D},L(E,I)}var _=function(E){T(I,E);function I(D,b){var A;return A=E.call(this)||this,A.observer=void 0,A.config=void 0,A.observer=D,A.config=b,A}var M=I.prototype;return M.resetInitSegment=function(b,A,u){E.prototype.resetInitSegment.call(this,b,A,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:b,duration:u,inputTimeScale:9e4,dropped:0}},I.probe=function(b){if(!b)return!1;for(var A=R.getID3Data(b,0)||[],u=A.length,r=b.length;u<r;u++)if(n.probe(b,u))return h.logger.log("ADTS sync word found !"),!0;return!1},M.canParse=function(b,A){return n.canParse(b,A)},M.appendFrame=function(b,A,u){n.initTrackConfig(b,this.observer,A,u,b.manifestCodec);var r=n.appendFrame(b,A,u,this.initPTS,this.frameIndex);if(r&&r.missing===0)return r},I}(l.default);_.minProbeByteLength=9,e.default=_},"./src/demux/adts.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"getAudioConfig",function(){return R}),t.d(e,"isHeaderPattern",function(){return T}),t.d(e,"getHeaderLength",function(){return L}),t.d(e,"getFullFrameLength",function(){return _}),t.d(e,"canGetFrameLength",function(){return E}),t.d(e,"isHeader",function(){return I}),t.d(e,"canParse",function(){return M}),t.d(e,"probe",function(){return D}),t.d(e,"initTrackConfig",function(){return b}),t.d(e,"getFrameDuration",function(){return A}),t.d(e,"parseFrameHeader",function(){return u}),t.d(e,"appendFrame",function(){return r});var l=t("./src/utils/logger.ts"),n=t("./src/errors.ts"),h=t("./src/events.ts");function R(s,i,a,d){var o,y,p,m,g=navigator.userAgent.toLowerCase(),f=d,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=((i[a+2]&192)>>>6)+1;var x=(i[a+2]&60)>>>2;if(x>c.length-1){s.trigger(h.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+x});return}return p=(i[a+2]&1)<<2,p|=(i[a+3]&192)>>>6,l.logger.log("manifest codec:"+d+", ADTS type:"+o+", samplingIndex:"+x),/firefox/i.test(g)?x>=6?(o=5,m=new Array(4),y=x-3):(o=2,m=new Array(2),y=x):g.indexOf("android")!==-1?(o=2,m=new Array(2),y=x):(o=5,m=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&x>=6?y=x-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(x>=6&&p===1||/vivaldi/i.test(g))||!d&&p===1)&&(o=2,m=new Array(2)),y=x)),m[0]=o<<3,m[0]|=(x&14)>>1,m[1]|=(x&1)<<7,m[1]|=p<<3,o===5&&(m[1]|=(y&14)>>1,m[2]=(y&1)<<7,m[2]|=2<<2,m[3]=0),{config:m,samplerate:c[x],channelCount:p,codec:"mp4a.40."+o,manifestCodec:f}}function T(s,i){return s[i]===255&&(s[i+1]&246)==240}function L(s,i){return s[i+1]&1?7:9}function _(s,i){return(s[i+3]&3)<<11|s[i+4]<<3|(s[i+5]&224)>>>5}function E(s,i){return i+5<s.length}function I(s,i){return i+1<s.length&&T(s,i)}function M(s,i){return E(s,i)&&T(s,i)&&_(s,i)<=s.length-i}function D(s,i){if(I(s,i)){var a=L(s,i);if(i+a>=s.length)return!1;var d=_(s,i);if(d<=a)return!1;var o=i+d;return o===s.length||I(s,o)}return!1}function b(s,i,a,d,o){if(!s.samplerate){var y=R(i,a,d,o);if(!y)return;s.config=y.config,s.samplerate=y.samplerate,s.channelCount=y.channelCount,s.codec=y.codec,s.manifestCodec=y.manifestCodec,l.logger.log("parsed codec:"+s.codec+", rate:"+y.samplerate+", channels:"+y.channelCount)}}function A(s){return 1024*9e4/s}function u(s,i,a,d,o){var y=L(s,i),p=_(s,i);if(p-=y,p>0){var m=a+d*o;return{headerLength:y,frameLength:p,stamp:m}}}function r(s,i,a,d,o){var y=A(s.samplerate),p=u(i,a,d,o,y);if(p){var m=p.frameLength,g=p.headerLength,f=p.stamp,c=g+m,x=Math.max(0,a+c-i.length),S;x?(S=new Uint8Array(c-g),S.set(i.subarray(a+g,i.length),0)):S=i.subarray(a+g,a+c);var O={unit:S,pts:f};return x||s.samples.push(O),{sample:O,length:c,missing:x}}}},"./src/demux/base-audio-demuxer.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"initPTSFn",function(){return _});var l=t("./src/polyfills/number.ts"),n=t("./src/demux/id3.ts"),h=t("./src/demux/dummy-demuxed-track.ts"),R=t("./src/utils/mp4-tools.ts"),T=t("./src/utils/typed-array.ts"),L=function(){function E(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var I=E.prototype;return I.resetInitSegment=function(D,b,A){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},I.resetTimeStamp=function(){},I.resetContiguity=function(){},I.canParse=function(D,b){return!1},I.appendFrame=function(D,b,A){},I.demux=function(D,b){this.cachedData&&(D=Object(R.appendUint8Array)(this.cachedData,D),this.cachedData=null);var A=n.getID3Data(D,0),u=A?A.length:0,r,s,i=this._audioTrack,a=this._id3Track,d=A?n.getTimeStamp(A):void 0,o=D.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=_(d,b)),A&&A.length>0&&a.samples.push({pts:this.initPTS,dts:this.initPTS,data:A}),s=this.initPTS;u<o;){if(this.canParse(D,u)){var y=this.appendFrame(i,D,u);y?(this.frameIndex++,s=y.sample.pts,u+=y.length,r=u):u=o}else n.canParse(D,u)?(A=n.getID3Data(D,u),a.samples.push({pts:s,dts:s,data:A}),u+=A.length,r=u):u++;if(u===o&&r!==o){var p=Object(T.sliceUint8)(D,r);this.cachedData?this.cachedData=Object(R.appendUint8Array)(this.cachedData,p):this.cachedData=p}}return{audioTrack:i,avcTrack:Object(h.dummyTrack)(),id3Track:a,textTrack:Object(h.dummyTrack)()}},I.demuxSampleAes=function(D,b,A){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},I.flush=function(D){var b=this.cachedData;return b&&(this.cachedData=null,this.demux(b,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(h.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(h.dummyTrack)()}},I.destroy=function(){},E}(),_=function(I,M){return Object(l.isFiniteNumber)(I)?I*90:M*9e4};e.default=L},"./src/demux/chunk-cache.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return l});var l=function(){function h(){this.chunks=[],this.dataLength=0}var R=h.prototype;return R.push=function(L){this.chunks.push(L),this.dataLength+=L.length},R.flush=function(){var L=this.chunks,_=this.dataLength,E;if(L.length)L.length===1?E=L[0]:E=n(L,_);else return new Uint8Array(0);return this.reset(),E},R.reset=function(){this.chunks.length=0,this.dataLength=0},h}();function n(h,R){for(var T=new Uint8Array(R),L=0,_=0;_<h.length;_++){var E=h[_];T.set(E,L),L+=E.length}return T}},"./src/demux/dummy-demuxed-track.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"dummyTrack",function(){return l});function l(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/utils/logger.ts"),n=function(){function h(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 R=h.prototype;return R.loadWord=function(){var L=this.data,_=this.bytesAvailable,E=L.byteLength-_,I=new Uint8Array(4),M=Math.min(4,_);if(M===0)throw new Error("no bytes available");I.set(L.subarray(E,E+M)),this.word=new DataView(I.buffer).getUint32(0),this.bitsAvailable=M*8,this.bytesAvailable-=M},R.skipBits=function(L){var _;this.bitsAvailable>L?(this.word<<=L,this.bitsAvailable-=L):(L-=this.bitsAvailable,_=L>>3,L-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=L,this.bitsAvailable-=L)},R.readBits=function(L){var _=Math.min(this.bitsAvailable,L),E=this.word>>>32-_;return L>32&&l.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=L-_,_>0&&this.bitsAvailable?E<<_|this.readBits(_):E},R.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()},R.skipUEG=function(){this.skipBits(1+this.skipLZ())},R.skipEG=function(){this.skipBits(1+this.skipLZ())},R.readUEG=function(){var L=this.skipLZ();return this.readBits(L+1)-1},R.readEG=function(){var L=this.readUEG();return 1&L?1+L>>>1:-1*(L>>>1)},R.readBoolean=function(){return this.readBits(1)===1},R.readUByte=function(){return this.readBits(8)},R.readUShort=function(){return this.readBits(16)},R.readUInt=function(){return this.readBits(32)},R.skipScalingList=function(L){for(var _=8,E=8,I,M=0;M<L;M++)E!==0&&(I=this.readEG(),E=(_+I+256)%256),_=E===0?_:E},R.readSPS=function(){var L=0,_=0,E=0,I=0,M,D,b,A=this.readUByte.bind(this),u=this.readBits.bind(this),r=this.readUEG.bind(this),s=this.readBoolean.bind(this),i=this.skipBits.bind(this),a=this.skipEG.bind(this),d=this.skipUEG.bind(this),o=this.skipScalingList.bind(this);A();var y=A();if(u(5),i(3),A(),d(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var p=r();if(p===3&&i(1),d(),d(),i(1),s())for(D=p!==3?8:12,b=0;b<D;b++)s()&&(b<6?o(16):o(64))}d();var m=r();if(m===0)r();else if(m===1)for(i(1),a(),a(),M=r(),b=0;b<M;b++)a();d(),i(1);var g=r(),f=r(),c=u(1);c===0&&i(1),i(1),s()&&(L=r(),_=r(),E=r(),I=r());var x=[1,1];if(s()&&s()){var S=A();switch(S){case 1:x=[1,1];break;case 2:x=[12,11];break;case 3:x=[10,11];break;case 4:x=[16,11];break;case 5:x=[40,33];break;case 6:x=[24,11];break;case 7:x=[20,11];break;case 8:x=[32,11];break;case 9:x=[80,33];break;case 10:x=[18,11];break;case 11:x=[15,11];break;case 12:x=[64,33];break;case 13:x=[160,99];break;case 14:x=[4,3];break;case 15:x=[3,2];break;case 16:x=[2,1];break;case 255:{x=[A()<<8|A(),A()<<8|A()];break}}}return{width:Math.ceil((g+1)*16-L*2-_*2),height:(2-c)*(f+1)*16-(c?2:4)*(E+I),pixelRatio:x}},R.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},h}();e.default=n},"./src/demux/id3.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"isHeader",function(){return l}),t.d(e,"isFooter",function(){return n}),t.d(e,"getID3Data",function(){return h}),t.d(e,"canParse",function(){return T}),t.d(e,"getTimeStamp",function(){return L}),t.d(e,"isTimeStampFrame",function(){return _}),t.d(e,"getID3Frames",function(){return I}),t.d(e,"decodeFrame",function(){return M}),t.d(e,"utf8ArrayToStr",function(){return r}),t.d(e,"testables",function(){return s});var l=function(o,y){return y+10<=o.length&&o[y]===73&&o[y+1]===68&&o[y+2]===51&&o[y+3]<255&&o[y+4]<255&&o[y+6]<128&&o[y+7]<128&&o[y+8]<128&&o[y+9]<128},n=function(o,y){return y+10<=o.length&&o[y]===51&&o[y+1]===68&&o[y+2]===73&&o[y+3]<255&&o[y+4]<255&&o[y+6]<128&&o[y+7]<128&&o[y+8]<128&&o[y+9]<128},h=function(o,y){for(var p=y,m=0;l(o,y);){m+=10;var g=R(o,y+6);m+=g,n(o,y+10)&&(m+=10),y+=m}if(m>0)return o.subarray(p,p+m)},R=function(o,y){var p=0;return p=(o[y]&127)<<21,p|=(o[y+1]&127)<<14,p|=(o[y+2]&127)<<7,p|=o[y+3]&127,p},T=function(o,y){return l(o,y)&&R(o,y+6)+10<=o.length-y},L=function(o){for(var y=I(o),p=0;p<y.length;p++){var m=y[p];if(_(m))return u(m)}},_=function(o){return o&&o.key==="PRIV"&&o.info==="com.apple.streaming.transportStreamTimestamp"},E=function(o){var y=String.fromCharCode(o[0],o[1],o[2],o[3]),p=R(o,4),m=10;return{type:y,size:p,data:o.subarray(m,m+p)}},I=function(o){for(var y=0,p=[];l(o,y);){var m=R(o,y+6);y+=10;for(var g=y+m;y+8<g;){var f=E(o.subarray(y)),c=M(f);c&&p.push(c),y+=f.size+10}n(o,y)&&(y+=10)}return p},M=function(o){return o.type==="PRIV"?D(o):o.type[0]==="W"?A(o):b(o)},D=function(o){if(!(o.size<2)){var y=r(o.data,!0),p=new Uint8Array(o.data.subarray(y.length+1));return{key:o.type,info:y,data:p.buffer}}},b=function(o){if(!(o.size<2)){if(o.type==="TXXX"){var y=1,p=r(o.data.subarray(y),!0);y+=p.length+1;var m=r(o.data.subarray(y));return{key:o.type,info:p,data:m}}var g=r(o.data.subarray(1));return{key:o.type,data:g}}},A=function(o){if(o.type==="WXXX"){if(o.size<2)return;var y=1,p=r(o.data.subarray(y),!0);y+=p.length+1;var m=r(o.data.subarray(y));return{key:o.type,info:p,data:m}}var g=r(o.data);return{key:o.type,data:g}},u=function(o){if(o.data.byteLength===8){var y=new Uint8Array(o.data),p=y[3]&1,m=(y[4]<<23)+(y[5]<<15)+(y[6]<<7)+y[7];return m/=45,p&&(m+=4772185884e-2),Math.round(m)}},r=function(o,y){y===void 0&&(y=!1);var p=a();if(p){var m=p.decode(o);if(y){var g=m.indexOf("\0");return g!==-1?m.substring(0,g):m}return m.replace(/\0/g,"")}for(var f=o.length,c,x,S,O="",C=0;C<f;){if(c=o[C++],c===0&&y)return O;if(c===0||c===3)continue;switch(c>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:O+=String.fromCharCode(c);break;case 12:case 13:x=o[C++],O+=String.fromCharCode((c&31)<<6|x&63);break;case 14:x=o[C++],S=o[C++],O+=String.fromCharCode((c&15)<<12|(x&63)<<6|(S&63)<<0);break;default:}}return O},s={decodeTextFrame:b},i;function a(){return!i&&typeof self.TextDecoder!="undefined"&&(i=new self.TextDecoder("utf-8")),i}},"./src/demux/mp3demuxer.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/demux/base-audio-demuxer.ts"),n=t("./src/demux/id3.ts"),h=t("./src/utils/logger.ts"),R=t("./src/demux/mpegaudio.ts");function T(E,I){E.prototype=Object.create(I.prototype),E.prototype.constructor=E,L(E,I)}function L(E,I){return L=Object.setPrototypeOf||function(D,b){return D.__proto__=b,D},L(E,I)}var _=function(E){T(I,E);function I(){return E.apply(this,arguments)||this}var M=I.prototype;return M.resetInitSegment=function(b,A,u){E.prototype.resetInitSegment.call(this,b,A,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:b,duration:u,inputTimeScale:9e4,dropped:0}},I.probe=function(b){if(!b)return!1;for(var A=n.getID3Data(b,0)||[],u=A.length,r=b.length;u<r;u++)if(R.probe(b,u))return h.logger.log("MPEG Audio sync word found !"),!0;return!1},M.canParse=function(b,A){return R.canParse(b,A)},M.appendFrame=function(b,A,u){if(this.initPTS!==null)return R.appendFrame(b,A,u,this.initPTS,this.frameIndex)},I}(l.default);_.minProbeByteLength=4,e.default=_},"./src/demux/mp4demuxer.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/utils/mp4-tools.ts"),n=t("./src/demux/dummy-demuxed-track.ts"),h=function(){function R(L,_){this.remainderData=null,this.config=void 0,this.config=_}var T=R.prototype;return T.resetTimeStamp=function(){},T.resetInitSegment=function(){},T.resetContiguity=function(){},R.probe=function(_){return Object(l.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},T.demux=function(_){var E=_,I=Object(n.dummyTrack)();if(this.config.progressive){this.remainderData&&(E=Object(l.appendUint8Array)(this.remainderData,_));var M=Object(l.segmentValidRange)(E);this.remainderData=M.remainder,I.samples=M.valid||new Uint8Array}else I.samples=E;return{audioTrack:Object(n.dummyTrack)(),avcTrack:I,id3Track:Object(n.dummyTrack)(),textTrack:Object(n.dummyTrack)()}},T.flush=function(){var _=Object(n.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(n.dummyTrack)(),avcTrack:_,id3Track:Object(n.dummyTrack)(),textTrack:Object(n.dummyTrack)()}},T.demuxSampleAes=function(_,E,I){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},T.destroy=function(){},R}();h.minProbeByteLength=1024,e.default=h},"./src/demux/mpegaudio.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"appendFrame",function(){return L}),t.d(e,"parseHeader",function(){return _}),t.d(e,"isHeaderPattern",function(){return E}),t.d(e,"isHeader",function(){return I}),t.d(e,"canParse",function(){return M}),t.d(e,"probe",function(){return D});var l=null,n=[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],h=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],R=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],T=[0,1,1,4];function L(b,A,u,r,s){if(!(u+24>A.length)){var i=_(A,u);if(i&&u+i.frameLength<=A.length){var a=i.samplesPerFrame*9e4/i.sampleRate,d=r+s*a,o={unit:A.subarray(u,u+i.frameLength),pts:d,dts:d};return b.config=[],b.channelCount=i.channelCount,b.samplerate=i.sampleRate,b.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function _(b,A){var u=b[A+1]>>3&3,r=b[A+1]>>1&3,s=b[A+2]>>4&15,i=b[A+2]>>2&3;if(u!==1&&s!==0&&s!==15&&i!==3){var a=b[A+2]>>1&1,d=b[A+3]>>6,o=u===3?3-r:r===3?3:4,y=n[o*14+s-1]*1e3,p=u===3?0:u===2?1:2,m=h[p*3+i],g=d===3?1:2,f=R[u][r],c=T[r],x=f*8*c,S=Math.floor(f*y/m+a)*c;if(l===null){var O=navigator.userAgent||"",C=O.match(/Chrome\/(\d+)/i);l=C?parseInt(C[1]):0}var P=!!l&&l<=87;return P&&r===2&&y>=224e3&&d===0&&(b[A+3]=b[A+3]|128),{sampleRate:m,channelCount:g,frameLength:S,samplesPerFrame:x}}}function E(b,A){return b[A]===255&&(b[A+1]&224)==224&&(b[A+1]&6)!=0}function I(b,A){return A+1<b.length&&E(b,A)}function M(b,A){var u=4;return E(b,A)&&u<=b.length-A}function D(b,A){if(A+1<b.length&&E(b,A)){var u=4,r=_(b,A),s=u;r!=null&&r.frameLength&&(s=r.frameLength);var i=A+s;return i===b.length||I(b,i)}return!1}},"./src/demux/sample-aes.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/crypt/decrypter.ts"),n=t("./src/demux/tsdemuxer.ts"),h=function(){function R(L,_,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new l.default(L,_,{removePKCS7Padding:!1})}var T=R.prototype;return T.decryptBuffer=function(_,E){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,E)},T.decryptAacSample=function(_,E,I,M){var D=_[E].unit,b=D.subarray(16,D.length-D.length%16),A=b.buffer.slice(b.byteOffset,b.byteOffset+b.length),u=this;this.decryptBuffer(A,function(r){var s=new Uint8Array(r);D.set(s,16),M||u.decryptAacSamples(_,E+1,I)})},T.decryptAacSamples=function(_,E,I){for(;;E++){if(E>=_.length){I();return}if(!(_[E].unit.length<32)){var M=this.decrypter.isSync();if(this.decryptAacSample(_,E,I,M),!M)return}}},T.getAvcEncryptedData=function(_){for(var E=Math.floor((_.length-48)/160)*16+16,I=new Int8Array(E),M=0,D=32;D<_.length-16;D+=160,M+=16)I.set(_.subarray(D,D+16),M);return I},T.getAvcDecryptedUnit=function(_,E){for(var I=new Uint8Array(E),M=0,D=32;D<_.length-16;D+=160,M+=16)_.set(I.subarray(M,M+16),D);return _},T.decryptAvcSample=function(_,E,I,M,D,b){var A=Object(n.discardEPB)(D.data),u=this.getAvcEncryptedData(A),r=this;this.decryptBuffer(u.buffer,function(s){D.data=r.getAvcDecryptedUnit(A,s),b||r.decryptAvcSamples(_,E,I+1,M)})},T.decryptAvcSamples=function(_,E,I,M){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,I=0){if(E>=_.length){M();return}for(var D=_[E].units;!(I>=D.length);I++){var b=D[I];if(!(b.data.length<=48||b.type!==1&&b.type!==5)){var A=this.decrypter.isSync();if(this.decryptAvcSample(_,E,I,M,b,A),!A)return}}}},R}();e.default=h},"./src/demux/transmuxer-interface.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D});var l=t("./node_modules/webworkify-webpack/index.js"),n=t.n(l),h=t("./src/events.ts"),R=t("./src/demux/transmuxer.ts"),T=t("./src/utils/logger.ts"),L=t("./src/errors.ts"),_=t("./src/utils/mediasource-helper.ts"),E=t("./node_modules/eventemitter3/index.js"),I=t.n(E),M=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},D=function(){function b(u,r,s,i){var a=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=u,this.id=r,this.onTransmuxComplete=s,this.onFlush=i;var d=u.config,o=function(f,c){c=c||{},c.frag=a.frag,c.id=a.id,u.trigger(f,c)};this.observer=new E.EventEmitter,this.observer.on(h.Events.FRAG_DECRYPTED,o),this.observer.on(h.Events.ERROR,o);var y={mp4:M.isTypeSupported("video/mp4"),mpeg:M.isTypeSupported("audio/mpeg"),mp3:M.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(d.enableWorker&&typeof Worker!="undefined"){T.logger.log("demuxing in webworker");var m;try{m=this.worker=l("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),m.addEventListener("message",this.onwmsg),m.onerror=function(g){u.trigger(h.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(g.message+" ("+g.filename+":"+g.lineno+")")})},m.postMessage({cmd:"init",typeSupported:y,vendor:p,id:r,config:JSON.stringify(d)})}catch(g){T.logger.warn("Error in worker:",g),T.logger.error("Error while initializing DemuxerWorker, fallback to inline"),m&&self.URL.revokeObjectURL(m.objectURL),this.transmuxer=new R.default(this.observer,y,d,p,r),this.worker=null}}else this.transmuxer=new R.default(this.observer,y,d,p,r)}var A=b.prototype;return A.destroy=function(){var r=this.worker;if(r)r.removeEventListener("message",this.onwmsg),r.terminate(),this.worker=null;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var i=this.observer;i&&i.removeAllListeners(),this.observer=null},A.push=function(r,s,i,a,d,o,y,p,m,g){var f,c,x=this;m.transmuxing.start=self.performance.now();var S=this.transmuxer,O=this.worker,C=o?o.start:d.start,P=d.decryptdata,w=this.frag,U=!(w&&d.cc===w.cc),k=!(w&&m.level===w.level),N=w?m.sn-w.sn:-1,B=this.part?m.part-this.part.index:1,K=!k&&(N===1||N===0&&B===1),W=self.performance.now();(k||N||d.stats.parsing.start===0)&&(d.stats.parsing.start=W),o&&(B||!K)&&(o.stats.parsing.start=W);var F=!(w&&((f=d.initSegment)===null||f===void 0?void 0:f.url)===((c=w.initSegment)===null||c===void 0?void 0:c.url)),H=new R.TransmuxState(U,K,p,k,C,F);if(!K||U||F){T.logger.log("[transmuxer-interface, "+d.type+"]: Starting new transmux session for sn: "+m.sn+" p: "+m.part+" level: "+m.level+" id: "+m.id+`
11
+ Time to underbuffer: `+P.toFixed(3)+" s"),o.nextLoadLevel=U,this.bwEstimator.sample(g,l.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),o.trigger(c.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:r,stats:l})}}}}}},b.onFragLoaded=function(u,r){var o=r.frag,n=r.part;if(o.type===L.PlaylistLevelType.MAIN&&Object(a.isFiniteNumber)(o.sn)){var s=n?n.stats:o.stats,d=n?n.duration:o.duration;if(this.clearTimer(),this.lastLoadedFragLevel=o.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var l=this.hls.levels[o.level],T=(l.loaded?l.loaded.bytes:0)+s.loaded,g=(l.loaded?l.loaded.duration:0)+d;l.loaded={bytes:T,duration:g},l.realBitrate=Math.round(8*T/g)}if(o.bitrateTest){var m={stats:s,frag:o,part:n,id:o.type};this.onFragBuffered(c.Events.FRAG_BUFFERED,m),o.bitrateTest=!1}}},b.onFragBuffered=function(u,r){var o=r.frag,n=r.part,s=n?n.stats:o.stats;if(!s.aborted&&!(o.type!==L.PlaylistLevelType.MAIN||o.sn==="initSegment")){var d=s.parsing.end-s.loading.start;this.bwEstimator.sample(d,s.loaded),s.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0}},b.onError=function(u,r){switch(r.details){case E.ErrorDetails.FRAG_LOAD_ERROR:case E.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},b.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},b.getNextABRAutoLevel=function(){var u=this.fragCurrent,r=this.partCurrent,o=this.hls,n=o.maxAutoLevel,s=o.config,d=o.minAutoLevel,l=o.media,T=r?r.duration:u?u.duration:0,g=l?l.currentTime:0,m=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,p=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,v=(R.BufferHelper.bufferInfo(l,g,s.maxBufferHole).end-g)/m,h=this.findBestLevel(p,d,n,v,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(h>=0)return h;_.logger.trace((v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var x=T?Math.min(T,s.maxStarvationDelay):s.maxStarvationDelay,S=s.abrBandWidthFactor,C=s.abrBandWidthUpFactor;if(!v){var O=this.bitrateTestDelay;if(O){var P=T?Math.min(T,s.maxLoadingDelay):s.maxLoadingDelay;x=P-O,_.logger.trace("bitrate test took "+Math.round(1e3*O)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*x)+" ms"),S=C=1}}return h=this.findBestLevel(p,d,n,v+x,S,C),Math.max(h,0)},b.findBestLevel=function(u,r,o,n,s,d){for(var l,T=this.fragCurrent,g=this.partCurrent,m=this.lastLoadedFragLevel,p=this.hls.levels,v=p[m],h=!!(v!=null&&(l=v.details)!==null&&l!==void 0&&l.live),x=v==null?void 0:v.codecSet,S=g?g.duration:T?T.duration:0,C=o;C>=r;C--){var O=p[C];if(!(!O||x&&O.codecSet!==x)){var P=O.details,w=(g?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||S,U=void 0;C<=m?U=s*u:U=d*u;var k=p[C].maxBitrate,N=k*w/U;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+C+"/"+Math.round(U)+"/"+k+"/"+w+"/"+n+"/"+N),U>k&&(!N||h&&!this.bitrateTestDelay||N<n))return C}}return-1},I(D,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,r=this.bwEstimator;if(u!==-1&&(!r||!r.canEstimate()))return u;var o=this.getNextABRAutoLevel();return u!==-1&&(o=Math.min(u,o)),o},set:function(u){this._nextAutoLevel=u}}]),D}();e.default=M},"./src/controller/audio-stream-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/polyfills/number.ts"),i=t("./src/controller/base-stream-controller.ts"),c=t("./src/events.ts"),R=t("./src/utils/buffer-helper.ts"),E=t("./src/controller/fragment-tracker.ts"),L=t("./src/types/level.ts"),_=t("./src/types/loader.ts"),y=t("./src/loader/fragment.ts"),I=t("./src/demux/chunk-cache.ts"),M=t("./src/demux/transmuxer-interface.ts"),D=t("./src/types/transmuxer.ts"),b=t("./src/controller/fragment-finders.ts"),A=t("./src/utils/discontinuities.ts"),u=t("./src/errors.ts"),r=t("./src/utils/logger.ts");function o(){return o=Object.assign||function(T){for(var g=1;g<arguments.length;g++){var m=arguments[g];for(var p in m)Object.prototype.hasOwnProperty.call(m,p)&&(T[p]=m[p])}return T},o.apply(this,arguments)}function n(T,g){T.prototype=Object.create(g.prototype),T.prototype.constructor=T,s(T,g)}function s(T,g){return s=Object.setPrototypeOf||function(p,v){return p.__proto__=v,p},s(T,g)}var d=100,l=function(T){n(g,T);function g(p,v){var h;return h=T.call(this,p,v,"[audio-stream-controller]")||this,h.videoBuffer=null,h.videoTrackCC=-1,h.waitingVideoCC=-1,h.audioSwitch=!1,h.trackId=-1,h.waitingData=null,h.mainDetails=null,h.bufferFlushed=!1,h._registerListeners(),h}var m=g.prototype;return m.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},m._registerListeners=function(){var v=this.hls;v.on(c.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.on(c.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.on(c.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.on(c.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.on(c.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),v.on(c.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),v.on(c.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),v.on(c.Events.ERROR,this.onError,this),v.on(c.Events.BUFFER_RESET,this.onBufferReset,this),v.on(c.Events.BUFFER_CREATED,this.onBufferCreated,this),v.on(c.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),v.on(c.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),v.on(c.Events.FRAG_BUFFERED,this.onFragBuffered,this)},m._unregisterListeners=function(){var v=this.hls;v.off(c.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.off(c.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(c.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(c.Events.LEVEL_LOADED,this.onLevelLoaded,this),v.off(c.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),v.off(c.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),v.off(c.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),v.off(c.Events.ERROR,this.onError,this),v.off(c.Events.BUFFER_RESET,this.onBufferReset,this),v.off(c.Events.BUFFER_CREATED,this.onBufferCreated,this),v.off(c.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),v.off(c.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),v.off(c.Events.FRAG_BUFFERED,this.onFragBuffered,this)},m.onInitPtsFound=function(v,h){var x=h.frag,S=h.id,C=h.initPTS;if(S==="main"){var O=x.cc;this.initPTS[x.cc]=C,this.log("InitPTS for cc: "+O+" found from main: "+C),this.videoTrackCC=O,this.state===i.State.WAITING_INIT_PTS&&this.tick()}},m.startLoad=function(v){if(!this.levels){this.startPosition=v,this.state=i.State.STOPPED;return}var h=this.lastCurrentTime;this.stopLoad(),this.setInterval(d),this.fragLoadError=0,h>0&&v===-1?(this.log("Override startPosition with lastCurrentTime @"+h.toFixed(3)),this.state=i.State.IDLE):(this.loadedmetadata=!1,this.state=i.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=v,this.tick()},m.doTick=function(){switch(this.state){case i.State.IDLE:this.doTickIdle();break;case i.State.WAITING_TRACK:{var v,h=this.levels,x=this.trackId,S=h==null||(v=h[x])===null||v===void 0?void 0:v.details;if(S){if(this.waitForCdnTuneIn(S))break;this.state=i.State.WAITING_INIT_PTS}break}case i.State.FRAG_LOADING_WAITING_RETRY:{var C,O=performance.now(),P=this.retryDate;(!P||O>=P||(C=this.media)!==null&&C!==void 0&&C.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=i.State.IDLE);break}case i.State.WAITING_INIT_PTS:{var w=this.waitingData;if(w){var U=w.frag,k=w.part,N=w.cache,B=w.complete;if(this.initPTS[U.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=i.State.FRAG_LOADING;var K=N.flush(),H={frag:U,part:k,payload:K,networkDetails:null};this._handleFragmentLoadProgress(H),B&&T.prototype._handleFragmentLoadComplete.call(this,H)}else if(this.videoTrackCC!==this.waitingVideoCC)r.logger.log("Waiting fragment cc ("+U.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var F=this.getLoadPosition(),W=R.BufferHelper.bufferInfo(this.mediaBuffer,F,this.config.maxBufferHole),Y=Object(b.fragmentWithinToleranceTest)(W.end,this.config.maxFragLookUpTolerance,U);Y<0&&(r.logger.log("Waiting fragment cc ("+U.cc+") @ "+U.start+" cancelled because another fragment at "+W.end+" is needed"),this.clearWaitingFragment())}}else this.state=i.State.IDLE}}this.onTickEnd()},m.clearWaitingFragment=function(){var v=this.waitingData;v&&(this.fragmentTracker.removeFragment(v.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=i.State.IDLE)},m.onTickEnd=function(){var v=this.media;if(!(!v||!v.readyState)){var h=this.mediaBuffer?this.mediaBuffer:v,x=h.buffered;!this.loadedmetadata&&x.length&&(this.loadedmetadata=!0),this.lastCurrentTime=v.currentTime}},m.doTickIdle=function(){var v,h,x=this.hls,S=this.levels,C=this.media,O=this.trackId,P=x.config;if(!(!S||!S[O])&&!(!C&&(this.startFragRequested||!P.startFragPrefetch))){var w=S[O],U=w.details;if(!U||U.live&&this.levelLastLoaded!==O||this.waitForCdnTuneIn(U)){this.state=i.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,y.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var k=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.AUDIO);if(k!==null){var N=k.len,B=this.getMaxBufferLength(),K=this.audioSwitch;if(!(N>=B&&!K)){if(!K&&this._streamEnded(k,U)){x.trigger(c.Events.BUFFER_EOS,{type:"audio"}),this.state=i.State.ENDED;return}var H=U.fragments,F=H[0].start,W=k.end;if(K){var Y=this.getLoadPosition();W=Y,U.PTSKnown&&Y<F&&(k.end>F||k.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),C.currentTime=F+.05)}var $=this.getNextFragment(W,U);if(!$){this.bufferFlushed=!0;return}((v=$.decryptdata)===null||v===void 0?void 0:v.keyFormat)==="identity"&&!((h=$.decryptdata)!==null&&h!==void 0&&h.key)?this.loadKey($,U):this.loadFragment($,U,W)}}}},m.getMaxBufferLength=function(){var v=T.prototype.getMaxBufferLength.call(this),h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN);return h===null?v:Math.max(v,h.len)},m.onMediaDetaching=function(){this.videoBuffer=null,T.prototype.onMediaDetaching.call(this)},m.onAudioTracksUpdated=function(v,h){var x=h.audioTracks;this.resetTransmuxer(),this.levels=x.map(function(S){return new L.Level(S)})},m.onAudioTrackSwitching=function(v,h){var x=!!h.url;this.trackId=h.id;var S=this.fragCurrent;S!=null&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),x?this.setInterval(d):this.resetTransmuxer(),x?(this.audioSwitch=!0,this.state=i.State.IDLE):this.state=i.State.STOPPED,this.tick()},m.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},m.onLevelLoaded=function(v,h){this.mainDetails=h.details},m.onAudioTrackLoaded=function(v,h){var x,S=this.levels,C=h.details,O=h.id;if(!S){this.warn("Audio tracks were reset while loading level "+O);return}this.log("Track "+O+" loaded ["+C.startSN+","+C.endSN+"],duration:"+C.totalduration);var P=S[O],w=0;if(C.live||(x=P.details)!==null&&x!==void 0&&x.live){var U=this.mainDetails;if(C.fragments[0]||(C.deltaUpdateFailed=!0),C.deltaUpdateFailed||!U)return;!P.details&&C.hasProgramDateTime&&U.hasProgramDateTime?(Object(A.alignMediaPlaylistByPDT)(C,U),w=C.fragments[0].start):w=this.alignPlaylists(C,P.details)}P.details=C,this.levelLastLoaded=O,!this.startFragRequested&&(this.mainDetails||!C.live)&&this.setStartPosition(P.details,w),this.state===i.State.WAITING_TRACK&&!this.waitForCdnTuneIn(C)&&(this.state=i.State.IDLE),this.tick()},m._handleFragmentLoadProgress=function(v){var h,x=v.frag,S=v.part,C=v.payload,O=this.config,P=this.trackId,w=this.levels;if(!w){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+x.sn+" of level "+x.level+" will not be buffered");return}var U=w[P];console.assert(U,"Audio track is defined on fragment load progress");var k=U.details;console.assert(k,"Audio track details are defined on fragment load progress");var N=O.defaultAudioCodec||U.audioCodec||"mp4a.40.2",B=this.transmuxer;B||(B=this.transmuxer=new M.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var K=this.initPTS[x.cc],H=(h=x.initSegment)===null||h===void 0?void 0:h.data;if(K!==void 0){var F=!1,W=S?S.index:-1,Y=W!==-1,$=new D.ChunkMetadata(x.level,x.sn,x.stats.chunkCount,C.byteLength,W,Y);B.push(C,H,N,"",x,S,k.totalduration,F,$,K)}else{r.logger.log("Unknown video PTS for cc "+x.cc+", waiting for video PTS before demuxing audio frag "+x.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+P);var J=this.waitingData=this.waitingData||{frag:x,part:S,cache:new I.default,complete:!1},q=J.cache;q.push(new Uint8Array(C)),this.waitingVideoCC=this.videoTrackCC,this.state=i.State.WAITING_INIT_PTS}},m._handleFragmentLoadComplete=function(v){if(this.waitingData){this.waitingData.complete=!0;return}T.prototype._handleFragmentLoadComplete.call(this,v)},m.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},m.onBufferCreated=function(v,h){var x=h.tracks.audio;x&&(this.mediaBuffer=x.buffer),h.tracks.video&&(this.videoBuffer=h.tracks.video.buffer)},m.onFragBuffered=function(v,h){var x=h.frag,S=h.part;if(x.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(x)){this.warn("Fragment "+x.sn+(S?" p: "+S.index:"")+" of level "+x.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}x.sn!=="initSegment"&&(this.fragPrevious=x,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(c.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(x,S)}},m.onError=function(v,h){switch(h.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,h);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==i.State.ERROR&&this.state!==i.State.STOPPED&&(this.state=h.fatal?i.State.ERROR:i.State.IDLE,this.warn(h.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(h.parent==="audio"&&(this.state===i.State.PARSING||this.state===i.State.PARSED)){var x=!0,S=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);S&&S.len>.5&&(x=!this.reduceMaxBufferLength(S.len)),x&&(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}},m.onBufferFlushed=function(v,h){var x=h.type;x===y.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},m._handleTransmuxComplete=function(v){var h,x="audio",S=this.hls,C=v.remuxResult,O=v.chunkMeta,P=this.getCurrentContext(O);if(!P){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(O.level);return}var w=P.frag,U=P.part,k=C.audio,N=C.text,B=C.id3,K=C.initSegment;if(!this.fragContextChanged(w)){if(this.state=i.State.PARSING,this.audioSwitch&&k&&this.completeAudioSwitch(),K!=null&&K.tracks&&(this._bufferInitSegment(K.tracks,w,O),S.trigger(c.Events.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:x,tracks:K.tracks})),k){var H=k.startPTS,F=k.endPTS,W=k.startDTS,Y=k.endDTS;U&&(U.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:H,endPTS:F,startDTS:W,endDTS:Y}),w.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,H,F,W,Y),this.bufferFragmentData(k,w,U,O)}if(B!=null&&(h=B.samples)!==null&&h!==void 0&&h.length){var $=o({frag:w,id:x},B);S.trigger(c.Events.FRAG_PARSING_METADATA,$)}if(N){var J=o({frag:w,id:x},N);S.trigger(c.Events.FRAG_PARSING_USERDATA,J)}}},m._bufferInitSegment=function(v,h,x){if(this.state===i.State.PARSING){v.video&&delete v.video;var S=v.audio;if(!!S){S.levelCodec=S.codec,S.id="audio",this.log("Init audio buffer, container:"+S.container+", codecs[parsed]=["+S.codec+"]"),this.hls.trigger(c.Events.BUFFER_CODECS,v);var C=S.initSegment;if(C!=null&&C.byteLength){var O={type:"audio",frag:h,part:null,chunkMeta:x,parent:h.type,data:C};this.hls.trigger(c.Events.BUFFER_APPENDING,O)}this.tick()}}},m.loadFragment=function(v,h,x){var S=this.fragmentTracker.getState(v);this.fragCurrent=v,(this.audioSwitch||S===E.FragmentState.NOT_LOADED||S===E.FragmentState.PARTIAL)&&(v.sn==="initSegment"?this._loadInitSegment(v):h.live&&!Object(a.isFiniteNumber)(this.initPTS[v.cc])?(this.log("Waiting for video PTS in continuity counter "+v.cc+" of live stream before loading audio fragment "+v.sn+" of level "+this.trackId),this.state=i.State.WAITING_INIT_PTS):(this.startFragRequested=!0,T.prototype.loadFragment.call(this,v,h,x)))},m.completeAudioSwitch=function(){var v=this.hls,h=this.media,x=this.trackId;h&&(this.log("Switching audio track : flushing all audio"),T.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,v.trigger(c.Events.AUDIO_TRACK_SWITCHED,{id:x})},g}(i.default);e.default=l},"./src/controller/audio-track-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/events.ts"),i=t("./src/errors.ts"),c=t("./src/controller/base-playlist-controller.ts"),R=t("./src/types/loader.ts");function E(M,D){for(var b=0;b<D.length;b++){var A=D[b];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(M,A.key,A)}}function L(M,D,b){return D&&E(M.prototype,D),b&&E(M,b),M}function _(M,D){M.prototype=Object.create(D.prototype),M.prototype.constructor=M,y(M,D)}function y(M,D){return y=Object.setPrototypeOf||function(A,u){return A.__proto__=u,A},y(M,D)}var I=function(M){_(D,M);function D(A){var u;return u=M.call(this,A,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var b=D.prototype;return b.registerListeners=function(){var u=this.hls;u.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(a.Events.ERROR,this.onError,this)},b.unregisterListeners=function(){var u=this.hls;u.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(a.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(a.Events.ERROR,this.onError,this)},b.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,M.prototype.destroy.call(this)},b.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},b.onManifestParsed=function(u,r){this.tracks=r.audioTracks||[]},b.onAudioTrackLoaded=function(u,r){var o=r.id,n=r.details,s=this.tracksInGroup[o];if(!s){this.warn("Invalid audio track id "+o);return}var d=s.details;s.details=r.details,this.log("audioTrack "+o+" loaded ["+n.startSN+"-"+n.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,r,d))},b.onLevelLoading=function(u,r){this.switchLevel(r.level)},b.onLevelSwitching=function(u,r){this.switchLevel(r.level)},b.switchLevel=function(u){var r=this.hls.levels[u];if(!!(r!=null&&r.audioGroupIds)){var o=r.audioGroupIds[r.urlId];if(this.groupId!==o){this.groupId=o;var n=this.tracks.filter(function(d){return!o||d.groupId===o});this.selectDefaultTrack&&!n.some(function(d){return d.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;var s={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(a.Events.AUDIO_TRACKS_UPDATED,s),this.selectInitialTrack()}}},b.onError=function(u,r){M.prototype.onError.call(this,u,r),!(r.fatal||!r.context)&&r.context.type===R.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},b.setAudioTrack=function(u){var r=this.tracksInGroup;if(u<0||u>=r.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=r[this.trackId];this.log("Now switching to audio-track index "+u);var n=r[u],s=n.id,d=n.groupId,l=d===void 0?"":d,T=n.name,g=n.type,m=n.url;if(this.trackId=u,this.trackName=T,this.selectDefaultTrack=!1,this.hls.trigger(a.Events.AUDIO_TRACK_SWITCHING,{id:s,groupId:l,name:T,type:g,url:m}),!(n.details&&!n.details.live)){var p=this.switchParams(n.url,o==null?void 0:o.details);this.loadPlaylist(p)}},b.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.length,"Initial audio track should be selected when tracks are known");var r=this.trackName,o=this.findTrackId(r)||this.findTrackId();o!==-1?this.setAudioTrack(o):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},b.findTrackId=function(u){for(var r=this.tracksInGroup,o=0;o<r.length;o++){var n=r[o];if((!this.selectDefaultTrack||n.default)&&(!u||u===n.name))return n.id}return-1},b.loadPlaylist=function(u){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var o=r.id,n=r.groupId,s=r.url;if(u)try{s=u.addDirectives(s)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(a.Events.AUDIO_TRACK_LOADING,{url:s,id:o,groupId:n,deliveryDirectives:u||null})}},L(D,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),D}(c.default);e.default=I},"./src/controller/base-playlist-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return L});var a=t("./src/polyfills/number.ts"),i=t("./src/types/level.ts"),c=t("./src/controller/level-helper.ts"),R=t("./src/utils/logger.ts"),E=t("./src/errors.ts"),L=function(){function _(I,M){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=R.logger.log.bind(R.logger,M+":"),this.warn=R.logger.warn.bind(R.logger,M+":"),this.hls=I}var y=_.prototype;return y.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},y.onError=function(M,D){D.fatal&&D.type===E.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(M,D){var b=D==null?void 0:D.renditionReports;if(b)for(var A=0;A<b.length;A++){var u=b[A],r=""+u.URI;if(r===M.substr(-r.length)){var o=parseInt(u["LAST-MSN"]),n=parseInt(u["LAST-PART"]);if(D&&this.hls.config.lowLatencyMode){var s=Math.min(D.age-D.partTarget,D.targetduration);n!==void 0&&s>D.partTarget&&(n+=1)}if(Object(a.isFiniteNumber)(o))return new i.HlsUrlParameters(o,Object(a.isFiniteNumber)(n)?n:void 0,i.HlsSkip.No)}}},y.loadPlaylist=function(M){},y.shouldLoadTrack=function(M){return this.canLoad&&M&&!!M.url&&(!M.details||M.details.live)},y.playlistLoaded=function(M,D,b){var A=this,u=D.details,r=D.stats,o=r.loading.end?Math.max(0,self.performance.now()-r.loading.end):0;if(u.advancedDateTime=Date.now()-o,u.live||b!=null&&b.live){if(u.reloaded(b),b&&this.log("live playlist "+M+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),b&&u.fragments.length>0&&Object(c.mergeDetails)(b,u),!this.canLoad||!u.live)return;var n,s=void 0,d=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var l=this.hls.config.lowLatencyMode,T=u.lastPartSn,g=u.endSN,m=u.lastPartIndex,p=m!==-1,v=T===g,h=l?0:m;p?(s=v?g+1:T,d=v?h:m+1):s=g+1;var x=u.age,S=x+u.ageHeader,C=Math.min(S-u.partTarget,u.targetduration*1.5);if(C>0){if(b&&C>b.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+b.tuneInGoal+" to: "+C+" with playlist age: "+u.age),C=0;else{var O=Math.floor(C/u.targetduration);if(s+=O,d!==void 0){var P=Math.round(C%u.targetduration/u.partTarget);d+=P}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+x.toFixed(2)+"s goal: "+C+" skip sn "+O+" to part "+d)}u.tuneInGoal=C}if(n=this.getDeliveryDirectives(u,D.deliveryDirectives,s,d),l||!v){this.loadPlaylist(n);return}}else n=this.getDeliveryDirectives(u,D.deliveryDirectives,s,d);var w=Object(c.computeReloadInterval)(u,r);s!==void 0&&u.canBlockReload&&(w-=u.partTarget||1),this.log("reload live playlist "+M+" in "+Math.round(w)+" ms"),this.timer=self.setTimeout(function(){return A.loadPlaylist(n)},w)}else this.clearTimer()},y.getDeliveryDirectives=function(M,D,b,A){var u=Object(i.getSkipValue)(M,b);return D!=null&&D.skip&&M.deltaUpdateFailed&&(b=D.msn,A=D.part,u=i.HlsSkip.No),new i.HlsUrlParameters(b,A,u)},y.retryLoadingOrFail=function(M){var D=this,b=this.hls.config,A=this.retryCount<b.levelLoadingMaxRetry;if(A){var u;if(this.retryCount++,M.details.indexOf("LoadTimeOut")>-1&&(u=M.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+M.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*b.levelLoadingRetryDelay,b.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return D.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+M.details+'"')}}else this.warn('cannot recover from error "'+M.details+'"'),this.clearTimer(),M.fatal=!0;return A},_}()},"./src/controller/base-stream-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"State",function(){return g}),t.d(e,"default",function(){return m});var a=t("./src/polyfills/number.ts"),i=t("./src/task-loop.ts"),c=t("./src/controller/fragment-tracker.ts"),R=t("./src/utils/buffer-helper.ts"),E=t("./src/utils/logger.ts"),L=t("./src/events.ts"),_=t("./src/errors.ts"),y=t("./src/types/transmuxer.ts"),I=t("./src/utils/mp4-tools.ts"),M=t("./src/utils/discontinuities.ts"),D=t("./src/controller/fragment-finders.ts"),b=t("./src/controller/level-helper.ts"),A=t("./src/loader/fragment-loader.ts"),u=t("./src/crypt/decrypter.ts"),r=t("./src/utils/time-ranges.ts"),o=t("./src/types/loader.ts");function n(p,v){for(var h=0;h<v.length;h++){var x=v[h];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(p,x.key,x)}}function s(p,v,h){return v&&n(p.prototype,v),h&&n(p,h),p}function d(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function l(p,v){p.prototype=Object.create(v.prototype),p.prototype.constructor=p,T(p,v)}function T(p,v){return T=Object.setPrototypeOf||function(x,S){return x.__proto__=S,x},T(p,v)}var g={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},m=function(p){l(v,p);function v(x,S,C){var O;return O=p.call(this)||this,O.hls=void 0,O.fragPrevious=null,O.fragCurrent=null,O.fragmentTracker=void 0,O.transmuxer=null,O._state=g.STOPPED,O.media=void 0,O.mediaBuffer=void 0,O.config=void 0,O.bitrateTest=!1,O.lastCurrentTime=0,O.nextLoadPosition=0,O.startPosition=0,O.loadedmetadata=!1,O.fragLoadError=0,O.retryDate=0,O.levels=null,O.fragmentLoader=void 0,O.levelLastLoaded=null,O.startFragRequested=!1,O.decrypter=void 0,O.initPTS=[],O.onvseeking=null,O.onvended=null,O.logPrefix="",O.log=void 0,O.warn=void 0,O.logPrefix=C,O.log=E.logger.log.bind(E.logger,C+":"),O.warn=E.logger.warn.bind(E.logger,C+":"),O.hls=x,O.fragmentLoader=new A.default(x.config),O.fragmentTracker=S,O.config=x.config,O.decrypter=new u.default(x,x.config),x.on(L.Events.KEY_LOADED,O.onKeyLoaded,d(O)),O}var h=v.prototype;return h.doTick=function(){this.onTickEnd()},h.onTickEnd=function(){},h.startLoad=function(S){},h.stopLoad=function(){this.fragmentLoader.abort();var S=this.fragCurrent;S&&this.fragmentTracker.removeFragment(S),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=g.STOPPED},h._streamEnded=function(S,C){var O=this.fragCurrent,P=this.fragmentTracker;if(!C.live&&O&&O.sn>=C.endSN&&!S.nextStart){var w=C.partList;if(w!=null&&w.length){var U=w[w.length-1],k=R.BufferHelper.isBuffered(this.media,U.start+U.duration/2);return k}var N=P.getState(O);return N===c.FragmentState.PARTIAL||N===c.FragmentState.OK}return!1},h.onMediaAttached=function(S,C){var O=this.media=this.mediaBuffer=C.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),O.addEventListener("seeking",this.onvseeking),O.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===g.STOPPED&&this.startLoad(P.startPosition)},h.onMediaDetaching=function(){var S=this.media;S!=null&&S.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),S&&(S.removeEventListener("seeking",this.onvseeking),S.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},h.onMediaSeeking=function(){var S=this.config,C=this.fragCurrent,O=this.media,P=this.mediaBuffer,w=this.state,U=O?O.currentTime:0,k=R.BufferHelper.bufferInfo(P||O,U,S.maxBufferHole);if(this.log("media seeking to "+(Object(a.isFiniteNumber)(U)?U.toFixed(3):U)+", state: "+w),w===g.ENDED)this.resetLoadingState();else if(C&&!k.len){var N=S.maxFragLookUpTolerance,B=C.start-N,K=C.start+C.duration+N,H=U>K;(U<B||H)&&(H&&C.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),C.loader.abort()),this.resetLoadingState())}O&&(this.lastCurrentTime=U),!this.loadedmetadata&&!k.len&&(this.nextLoadPosition=this.startPosition=U),this.tickImmediate()},h.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},h.onKeyLoaded=function(S,C){if(!(this.state!==g.KEY_LOADING||C.frag!==this.fragCurrent||!this.levels)){this.state=g.IDLE;var O=this.levels[C.frag.level].details;O&&this.loadFragment(C.frag,O,C.frag.start)}},h.onHandlerDestroying=function(){this.stopLoad(),p.prototype.onHandlerDestroying.call(this)},h.onHandlerDestroyed=function(){this.state=g.STOPPED,this.hls.off(L.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,p.prototype.onHandlerDestroyed.call(this)},h.loadKey=function(S,C){this.log("Loading key for "+S.sn+" of ["+C.startSN+"-"+C.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+S.level),this.state=g.KEY_LOADING,this.fragCurrent=S,this.hls.trigger(L.Events.KEY_LOADING,{frag:S})},h.loadFragment=function(S,C,O){this._loadFragForPlayback(S,C,O)},h._loadFragForPlayback=function(S,C,O){var P=this,w=function(k){if(P.fragContextChanged(S)){P.warn("Fragment "+S.sn+(k.part?" p: "+k.part.index:"")+" of level "+S.level+" was dropped during download."),P.fragmentTracker.removeFragment(S);return}S.stats.chunkCount++,P._handleFragmentLoadProgress(k)};this._doFragLoad(S,C,O,w).then(function(U){if(!!U){P.fragLoadError=0;var k=P.state;if(P.fragContextChanged(S)){(k===g.FRAG_LOADING||k===g.BACKTRACKING||!P.fragCurrent&&k===g.PARSING)&&(P.fragmentTracker.removeFragment(S),P.state=g.IDLE);return}if("payload"in U&&(P.log("Loaded fragment "+S.sn+" of level "+S.level),P.hls.trigger(L.Events.FRAG_LOADED,U),P.state===g.BACKTRACKING)){P.fragmentTracker.backtrack(S,U),P.resetFragmentLoading(S);return}P._handleFragmentLoadComplete(U)}}).catch(function(U){P.warn(U),P.resetFragmentLoading(S)})},h.flushMainBuffer=function(S,C,O){if(O===void 0&&(O=null),!!(S-C)){var P={startOffset:S,endOffset:C,type:O};this.fragLoadError=0,this.hls.trigger(L.Events.BUFFER_FLUSHING,P)}},h._loadInitSegment=function(S){var C=this;this._doFragLoad(S).then(function(O){if(!O||C.fragContextChanged(S)||!C.levels)throw new Error("init load aborted");return O}).then(function(O){var P=C.hls,w=O.payload,U=S.decryptdata;if(w&&w.byteLength>0&&U&&U.key&&U.iv&&U.method==="AES-128"){var k=self.performance.now();return C.decrypter.webCryptoDecrypt(new Uint8Array(w),U.key.buffer,U.iv.buffer).then(function(N){var B=self.performance.now();return P.trigger(L.Events.FRAG_DECRYPTED,{frag:S,payload:N,stats:{tstart:k,tdecrypt:B}}),O.payload=N,O})}return O}).then(function(O){var P=C.fragCurrent,w=C.hls,U=C.levels;if(!U)throw new Error("init load aborted, missing levels");var k=U[S.level].details;console.assert(k,"Level details are defined when init segment is loaded");var N=S.stats;C.state=g.IDLE,C.fragLoadError=0,S.data=new Uint8Array(O.payload),N.parsing.start=N.buffering.start=self.performance.now(),N.parsing.end=N.buffering.end=self.performance.now(),O.frag===P&&w.trigger(L.Events.FRAG_BUFFERED,{stats:N,frag:P,part:null,id:S.type}),C.tick()}).catch(function(O){C.warn(O),C.resetFragmentLoading(S)})},h.fragContextChanged=function(S){var C=this.fragCurrent;return!S||!C||S.level!==C.level||S.sn!==C.sn||S.urlId!==C.urlId},h.fragBufferedComplete=function(S,C){var O=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+S.type+" sn: "+S.sn+(C?" part: "+C.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+S.level+" "+r.default.toString(R.BufferHelper.getBuffered(O))),this.state=g.IDLE,this.tick()},h._handleFragmentLoadComplete=function(S){var C=this.transmuxer;if(!!C){var O=S.frag,P=S.part,w=S.partsLoaded,U=!w||w.length===0||w.some(function(N){return!N}),k=new y.ChunkMetadata(O.level,O.sn,O.stats.chunkCount+1,0,P?P.index:-1,!U);C.flush(k)}},h._handleFragmentLoadProgress=function(S){},h._doFragLoad=function(S,C,O,P){var w=this;if(O===void 0&&(O=null),!this.levels)throw new Error("frag load aborted, missing levels");if(O=Math.max(S.start,O||0),this.config.lowLatencyMode&&C){var U=C.partList;if(U&&P){O>S.end&&C.fragmentHint&&(S=C.fragmentHint);var k=this.getNextPart(U,S,O);if(k>-1){var N=U[k];return this.log("Loading part sn: "+S.sn+" p: "+N.index+" cc: "+S.cc+" of playlist ["+C.startSN+"-"+C.endSN+"] parts [0-"+k+"-"+(U.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+S.level+", target: "+parseFloat(O.toFixed(3))),this.nextLoadPosition=N.start+N.duration,this.state=g.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:S,part:U[k],targetBufferTime:O}),this.doFragPartsLoad(S,U,k,P).catch(function(B){return w.handleFragLoadError(B)})}else if(!S.url||this.loadedEndOfParts(U,O))return Promise.resolve(null)}}return this.log("Loading fragment "+S.sn+" cc: "+S.cc+" "+(C?"of ["+C.startSN+"-"+C.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+S.level+", target: "+parseFloat(O.toFixed(3))),Object(a.isFiniteNumber)(S.sn)&&!this.bitrateTest&&(this.nextLoadPosition=S.start+S.duration),this.state=g.FRAG_LOADING,this.hls.trigger(L.Events.FRAG_LOADING,{frag:S,targetBufferTime:O}),this.fragmentLoader.load(S,P).catch(function(B){return w.handleFragLoadError(B)})},h.doFragPartsLoad=function(S,C,O,P){var w=this;return new Promise(function(U,k){var N=[],B=function K(H){var F=C[H];w.fragmentLoader.loadPart(S,F,P).then(function(W){N[F.index]=W;var Y=W.part;w.hls.trigger(L.Events.FRAG_LOADED,W);var $=C[H+1];if($&&$.fragment===S)K(H+1);else return U({frag:S,part:Y,partsLoaded:N})}).catch(k)};B(O)})},h.handleFragLoadError=function(S){var C=S.data;return C&&C.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(C.frag,C.part):this.hls.trigger(L.Events.ERROR,C),null},h._handleTransmuxerFlush=function(S){var C=this.getCurrentContext(S);if(!C||this.state!==g.PARSING){this.fragCurrent||(this.state=g.IDLE);return}var O=C.frag,P=C.part,w=C.level,U=self.performance.now();O.stats.parsing.end=U,P&&(P.stats.parsing.end=U),this.updateLevelTiming(O,P,w,S.partial)},h.getCurrentContext=function(S){var C=this.levels,O=S.level,P=S.sn,w=S.part;if(!C||!C[O])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+O+". The current chunk will not be buffered."),null;var U=C[O],k=w>-1?Object(b.getPartWith)(U,P,w):null,N=k?k.fragment:Object(b.getFragmentWithSN)(U,P,this.fragCurrent);return N?{frag:N,part:k,level:U}:null},h.bufferFragmentData=function(S,C,O,P){if(!(!S||this.state!==g.PARSING)){var w=S.data1,U=S.data2,k=w;if(w&&U&&(k=Object(I.appendUint8Array)(w,U)),!(!k||!k.length)){var N={type:S.type,frag:C,part:O,chunkMeta:P,parent:C.type,data:k};this.hls.trigger(L.Events.BUFFER_APPENDING,N),S.dropped&&S.independent&&!O&&this.flushBufferGap(C)}}},h.flushBufferGap=function(S){var C=this.media;if(!!C){if(!R.BufferHelper.isBuffered(C,C.currentTime)){this.flushMainBuffer(0,S.start);return}var O=C.currentTime,P=R.BufferHelper.bufferInfo(C,O,0),w=S.duration,U=Math.min(this.config.maxFragLookUpTolerance*2,w*.25),k=Math.max(Math.min(S.start-U,P.end-U),O+U);S.start-k>U&&this.flushMainBuffer(k,S.start)}},h.getFwdBufferInfo=function(S,C){var O=this.config,P=this.getLoadPosition();if(!Object(a.isFiniteNumber)(P))return null;var w=R.BufferHelper.bufferInfo(S,P,O.maxBufferHole);if(w.len===0&&w.nextStart!==void 0){var U=this.fragmentTracker.getBufferedFrag(P,C);if(U&&w.nextStart<U.end)return R.BufferHelper.bufferInfo(S,P,Math.max(w.nextStart,O.maxBufferHole))}return w},h.getMaxBufferLength=function(S){var C=this.config,O;return S?O=Math.max(8*C.maxBufferSize/S,C.maxBufferLength):O=C.maxBufferLength,Math.min(O,C.maxMaxBufferLength)},h.reduceMaxBufferLength=function(S){var C=this.config,O=S||C.maxBufferLength;return C.maxMaxBufferLength>=O?(C.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+C.maxMaxBufferLength+"s"),!0):!1},h.getNextFragment=function(S,C){var O,P,w=C.fragments,U=w.length;if(!U)return null;var k=this.config,N=w[0].start,B;if(C.live){var K=k.initialLiveManifestSize;if(U<K)return this.warn("Not enough fragments to start playback (have: "+U+", need: "+K+")"),null;!C.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(B=this.getInitialLiveFragment(C,w),this.startPosition=B?this.hls.liveSyncPosition||B.start:S)}else S<=N&&(B=w[0]);if(!B){var H=k.lowLatencyMode?C.partEnd:C.fragmentEnd;B=this.getFragmentAtPosition(S,H,C)}return(O=B)!==null&&O!==void 0&&O.initSegment&&!((P=B)!==null&&P!==void 0&&P.initSegment.data)&&!this.bitrateTest&&(B=B.initSegment),B},h.getNextPart=function(S,C,O){for(var P=-1,w=!1,U=!0,k=0,N=S.length;k<N;k++){var B=S[k];if(U=U&&!B.independent,P>-1&&O<B.start)break;var K=B.loaded;!K&&(w||B.independent||U)&&B.fragment===C&&(P=k),w=K}return P},h.loadedEndOfParts=function(S,C){var O=S[S.length-1];return O&&C>O.start&&O.loaded},h.getInitialLiveFragment=function(S,C){var O=this.fragPrevious,P=null;if(O){if(S.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+O.programDateTime),P=Object(D.findFragmentByPDT)(C,O.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var w=O.sn+1;if(w>=S.startSN&&w<=S.endSN){var U=C[w-S.startSN];O.cc===U.cc&&(P=U,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(D.findFragWithCC)(C,O.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var k=this.hls.liveSyncPosition;k!==null&&(P=this.getFragmentAtPosition(k,this.bitrateTest?S.fragmentEnd:S.edge,S))}return P},h.getFragmentAtPosition=function(S,C,O){var P=this.config,w=this.fragPrevious,U=O.fragments,k=O.endSN,N=O.fragmentHint,B=P.maxFragLookUpTolerance,K=!!(P.lowLatencyMode&&O.partList&&N);K&&N&&!this.bitrateTest&&(U=U.concat(N),k=N.sn);var H;if(S<C){var F=S>C-B?0:B;H=Object(D.findFragmentByPTS)(w,U,S,F)}else H=U[U.length-1];if(H){var W=H.sn-O.startSN,Y=w&&H.level===w.level,$=U[W+1],J=this.fragmentTracker.getState(H);if(J===c.FragmentState.BACKTRACKED){H=null;for(var q=W;U[q]&&this.fragmentTracker.getState(U[q])===c.FragmentState.BACKTRACKED;)w?H=U[q--]:H=U[--q];H||(H=$)}else w&&H.sn===w.sn&&!K&&Y&&(H.sn<k&&this.fragmentTracker.getState($)!==c.FragmentState.OK?(this.log("SN "+H.sn+" just loaded, load next one: "+$.sn),H=$):H=null)}return H},h.synchronizeToLiveEdge=function(S){var C=this.config,O=this.media;if(!!O){var P=this.hls.liveSyncPosition,w=O.currentTime,U=S.fragments[0].start,k=S.edge,N=w>=U-C.maxFragLookUpTolerance&&w<=k;if(P!==null&&O.duration>P&&(w<P||!N)){var B=C.liveMaxLatencyDuration!==void 0?C.liveMaxLatencyDuration:C.liveMaxLatencyDurationCount*S.targetduration;(!N&&O.readyState<4||w<k-B)&&(this.loadedmetadata||(this.nextLoadPosition=P),O.readyState&&(this.warn("Playback: "+w.toFixed(3)+" is located too far from the end of live sliding playlist: "+k+", reset currentTime to : "+P.toFixed(3)),O.currentTime=P))}}},h.alignPlaylists=function(S,C){var O=this.levels,P=this.levelLastLoaded,w=this.fragPrevious,U=P!==null?O[P]:null,k=S.fragments.length;if(!k)return this.warn("No fragments in live playlist"),0;var N=S.fragments[0].start,B=!C,K=S.alignedSliding&&Object(a.isFiniteNumber)(N);if(B||!K&&!N){Object(M.alignStream)(w,U,S);var H=S.fragments[0].start;return this.log("Live playlist sliding: "+H.toFixed(2)+" start-sn: "+(C?C.startSN:"na")+"->"+S.startSN+" prev-sn: "+(w?w.sn:"na")+" fragments: "+k),H}return N},h.waitForCdnTuneIn=function(S){var C=3;return S.live&&S.canBlockReload&&S.tuneInGoal>Math.max(S.partHoldBack,S.partTarget*C)},h.setStartPosition=function(S,C){var O=this.startPosition;if(O<C&&(O=-1),O===-1||this.lastCurrentTime===-1){var P=S.startTimeOffset;Object(a.isFiniteNumber)(P)?(O=C+P,P<0&&(O+=S.totalduration),O=Math.min(Math.max(C,O),C+S.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+O),this.startPosition=O):S.live?O=this.hls.liveSyncPosition||C:this.startPosition=O=0,this.lastCurrentTime=O}this.nextLoadPosition=O},h.getLoadPosition=function(){var S=this.media,C=0;return this.loadedmetadata&&S?C=S.currentTime:this.nextLoadPosition&&(C=this.nextLoadPosition),C},h.handleFragLoadAborted=function(S,C){this.transmuxer&&S.sn!=="initSegment"&&S.stats.aborted&&(this.warn("Fragment "+S.sn+(C?" part"+C.index:"")+" of level "+S.level+" was aborted"),this.resetFragmentLoading(S))},h.resetFragmentLoading=function(S){(!this.fragCurrent||!this.fragContextChanged(S))&&(this.state=g.IDLE)},h.onFragmentOrKeyLoadError=function(S,C){if(!C.fatal){var O=C.frag;if(!(!O||O.type!==S)){var P=this.fragCurrent;console.assert(P&&O.sn===P.sn&&O.level===P.level&&O.urlId===P.urlId,"Frag load error must match current frag to retry");var w=this.config;if(this.fragLoadError+1<=w.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(O.level))return;var U=Math.min(Math.pow(2,this.fragLoadError)*w.fragLoadingRetryDelay,w.fragLoadingMaxRetryTimeout);this.warn("Fragment "+O.sn+" of "+S+" "+O.level+" failed to load, retrying in "+U+"ms"),this.retryDate=self.performance.now()+U,this.fragLoadError++,this.state=g.FRAG_LOADING_WAITING_RETRY}else C.levelRetry?(S===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=g.IDLE):(E.logger.error(C.details+" reaches max retry, redispatch as fatal ..."),C.fatal=!0,this.hls.stopLoad(),this.state=g.ERROR)}}},h.afterBufferFlushed=function(S,C,O){if(!!S){var P=R.BufferHelper.getBuffered(S);this.fragmentTracker.detectEvictedFragments(C,P,O),this.state===g.ENDED&&this.resetLoadingState()}},h.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=g.IDLE},h.resetLiveStartWhenNotLoaded=function(S){if(!this.loadedmetadata){this.startFragRequested=!1;var C=this.levels?this.levels[S].details:null;if(C!=null&&C.live)return this.startPosition=-1,this.setStartPosition(C,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},h.updateLevelTiming=function(S,C,O,P){var w=this,U=O.details;console.assert(!!U,"level.details must be defined");var k=Object.keys(S.elementaryStreams).reduce(function(N,B){var K=S.elementaryStreams[B];if(K){var H=K.endPTS-K.startPTS;if(H<=0)return w.warn("Could not parse fragment "+S.sn+" "+B+" duration reliably ("+H+") resetting transmuxer to fallback to playlist timing"),w.resetTransmuxer(),N||!1;var F=P?0:Object(b.updateFragPTSDTS)(U,S,K.startPTS,K.endPTS,K.startDTS,K.endDTS);return w.hls.trigger(L.Events.LEVEL_PTS_UPDATED,{details:U,level:O,drift:F,type:B,frag:S,start:K.startPTS,end:K.endPTS}),!0}return N},!1);k?(this.state=g.PARSED,this.hls.trigger(L.Events.FRAG_PARSED,{frag:S,part:C})):this.resetLoadingState()},h.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},s(v,[{key:"state",get:function(){return this._state},set:function(S){var C=this._state;C!==S&&(this._state=S,this.log(C+"->"+S))}}]),v}(i.default)},"./src/controller/buffer-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D});var a=t("./src/polyfills/number.ts"),i=t("./src/events.ts"),c=t("./src/utils/logger.ts"),R=t("./src/errors.ts"),E=t("./src/utils/buffer-helper.ts"),L=t("./src/utils/mediasource-helper.ts"),_=t("./src/loader/fragment.ts"),y=t("./src/controller/buffer-operation-queue.ts"),I=Object(L.getMediaSource)(),M=/([ha]vc.)(?:\.[^.,]+)+/,D=function(){function b(u){var r=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 o=r.hls,n=r.media,s=r.mediaSource;c.logger.log("[buffer-controller]: Media source opened"),n&&(r.updateMediaElementDuration(),o.trigger(i.Events.MEDIA_ATTACHED,{media:n})),s&&s.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},this._onMediaSourceClose=function(){c.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){c.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var A=b.prototype;return A.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},A.destroy=function(){this.unregisterListeners(),this.details=null},A.registerListeners=function(){var r=this.hls;r.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(i.Events.BUFFER_RESET,this.onBufferReset,this),r.on(i.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.on(i.Events.BUFFER_EOS,this.onBufferEos,this),r.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.on(i.Events.FRAG_PARSED,this.onFragParsed,this),r.on(i.Events.FRAG_CHANGED,this.onFragChanged,this)},A.unregisterListeners=function(){var r=this.hls;r.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),r.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(i.Events.BUFFER_RESET,this.onBufferReset,this),r.off(i.Events.BUFFER_APPENDING,this.onBufferAppending,this),r.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),r.off(i.Events.BUFFER_EOS,this.onBufferEos,this),r.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),r.off(i.Events.FRAG_PARSED,this.onFragParsed,this),r.off(i.Events.FRAG_CHANGED,this.onFragChanged,this)},A._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new y.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},A.onManifestParsed=function(r,o){var n=2;(o.audio&&!o.video||!o.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.details=null,c.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},A.onMediaAttaching=function(r,o){var n=this.media=o.media;if(n&&I){var s=this.mediaSource=new I;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(s),this._objectUrl=n.src}},A.onMediaDetaching=function(){var r=this.media,o=this.mediaSource,n=this._objectUrl;if(o){if(c.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(s){c.logger.warn("[buffer-controller]: onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),r&&(n&&self.URL.revokeObjectURL(n),r.src===n?(r.removeAttribute("src"),r.load()):c.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(i.Events.MEDIA_DETACHED,void 0)},A.onBufferReset=function(){var r=this;this.getSourceBufferTypes().forEach(function(o){var n=r.sourceBuffer[o];try{n&&(r.removeBufferListeners(o),r.mediaSource&&r.mediaSource.removeSourceBuffer(n),r.sourceBuffer[o]=void 0)}catch(s){c.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",s)}}),this._initSourceBuffer()},A.onBufferCodecs=function(r,o){var n=this,s=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(d){if(s){var l=n.tracks[d];if(l&&typeof l.buffer.changeType=="function"){var T=o[d],g=T.codec,m=T.levelCodec,p=T.container,v=(l.levelCodec||l.codec).replace(M,"$1"),h=(m||g).replace(M,"$1");if(v!==h){var x=p+";codecs="+(m||g);n.appendChangeType(d,x)}}}else n.pendingTracks[d]=o[d]}),!s&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},A.appendChangeType=function(r,o){var n=this,s=this.operationQueue,d={execute:function(){var T=n.sourceBuffer[r];T&&(c.logger.log("[buffer-controller]: changing "+r+" sourceBuffer type to "+o),T.changeType(o)),s.shiftAndExecuteNext(r)},onStart:function(){},onComplete:function(){},onError:function(T){c.logger.warn("[buffer-controller]: Failed to change "+r+" SourceBuffer type",T)}};s.append(d,r)},A.onBufferAppending=function(r,o){var n=this,s=this.hls,d=this.operationQueue,l=this.tracks,T=o.data,g=o.type,m=o.frag,p=o.part,v=o.chunkMeta,h=v.buffering[g],x=self.performance.now();h.start=x;var S=m.stats.buffering,C=p?p.stats.buffering:null;S.start===0&&(S.start=x),C&&C.start===0&&(C.start=x);var O=l.audio,P=g==="audio"&&v.id===1&&(O==null?void 0:O.container)==="audio/mpeg",w={execute:function(){if(h.executeStart=self.performance.now(),P){var k=n.sourceBuffer[g];if(k){var N=m.start-k.timestampOffset;Math.abs(N)>=.1&&(c.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+m.start+" (delta: "+N+") sn: "+m.sn+")"),k.timestampOffset=m.start)}}n.appendExecutor(T,g)},onStart:function(){},onComplete:function(){var k=self.performance.now();h.executeEnd=h.end=k,S.first===0&&(S.first=k),C&&C.first===0&&(C.first=k);var N=n.sourceBuffer,B={};for(var K in N)B[K]=E.BufferHelper.getBuffered(N[K]);n.appendError=0,n.hls.trigger(i.Events.BUFFER_APPENDED,{type:g,frag:m,part:p,chunkMeta:v,parent:m.type,timeRanges:B})},onError:function(k){c.logger.error("[buffer-controller]: Error encountered while trying to append to the "+g+" SourceBuffer",k);var N={type:R.ErrorTypes.MEDIA_ERROR,parent:m.type,details:R.ErrorDetails.BUFFER_APPEND_ERROR,err:k,fatal:!1};k.code===DOMException.QUOTA_EXCEEDED_ERR?N.details=R.ErrorDetails.BUFFER_FULL_ERROR:(n.appendError++,N.details=R.ErrorDetails.BUFFER_APPEND_ERROR,n.appendError>s.config.appendErrorMaxRetry&&(c.logger.error("[buffer-controller]: Failed "+s.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),N.fatal=!0)),s.trigger(i.Events.ERROR,N)}};d.append(w,g)},A.onBufferFlushing=function(r,o){var n=this,s=this.operationQueue,d=function(T){return{execute:n.removeExecutor.bind(n,T,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){n.hls.trigger(i.Events.BUFFER_FLUSHED,{type:T})},onError:function(m){c.logger.warn("[buffer-controller]: Failed to remove from "+T+" SourceBuffer",m)}}};o.type?s.append(d(o.type),o.type):this.getSourceBufferTypes().forEach(function(l){s.append(d(l),l)})},A.onFragParsed=function(r,o){var n=this,s=o.frag,d=o.part,l=[],T=d?d.elementaryStreams:s.elementaryStreams;T[_.ElementaryStreamTypes.AUDIOVIDEO]?l.push("audiovideo"):(T[_.ElementaryStreamTypes.AUDIO]&&l.push("audio"),T[_.ElementaryStreamTypes.VIDEO]&&l.push("video"));var g=function(){var p=self.performance.now();s.stats.buffering.end=p,d&&(d.stats.buffering.end=p);var v=d?d.stats:s.stats;n.hls.trigger(i.Events.FRAG_BUFFERED,{frag:s,part:d,stats:v,id:s.type})};l.length===0&&c.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(g,l)},A.onFragChanged=function(r,o){this.flushBackBuffer()},A.onBufferEos=function(r,o){var n=this,s=this.getSourceBufferTypes().reduce(function(d,l){var T=n.sourceBuffer[l];return(!o.type||o.type===l)&&T&&!T.ended&&(T.ended=!0,c.logger.log("[buffer-controller]: "+l+" sourceBuffer now EOS")),d&&!!(!T||T.ended)},!0);s&&this.blockBuffers(function(){var d=n.mediaSource;!d||d.readyState!=="open"||d.endOfStream()})},A.onLevelUpdated=function(r,o){var n=o.details;!n.fragments.length||(this.details=n,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},A.flushBackBuffer=function(){var r=this.hls,o=this.details,n=this.media,s=this.sourceBuffer;if(!(!n||o===null)){var d=this.getSourceBufferTypes();if(!!d.length){var l=o.live&&r.config.liveBackBufferLength!==null?r.config.liveBackBufferLength:r.config.backBufferLength;if(!(!Object(a.isFiniteNumber)(l)||l<0)){var T=n.currentTime,g=o.levelTargetDuration,m=Math.max(l,g),p=Math.floor(T/g)*g-m;d.forEach(function(v){var h=s[v];if(h){var x=E.BufferHelper.getBuffered(h);x.length>0&&p>x.start(0)&&(r.trigger(i.Events.BACK_BUFFER_REACHED,{bufferEnd:p}),o.live&&r.trigger(i.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:p}),r.trigger(i.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:p,type:v}))}})}}}},A.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var r=this.details,o=this.hls,n=this.media,s=this.mediaSource,d=r.fragments[0].start+r.totalduration,l=n.duration,T=Object(a.isFiniteNumber)(s.duration)?s.duration:0;r.live&&o.config.liveDurationInfinity?(c.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(r)):(d>T&&d>l||!Object(a.isFiniteNumber)(l))&&(c.logger.log("[buffer-controller]: Updating Media Source duration to "+d.toFixed(3)),s.duration=d)}},A.updateSeekableRange=function(r){var o=this.mediaSource,n=r.fragments,s=n.length;if(s&&r.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var d=Math.max(0,n[0].start),l=Math.max(d,d+r.totalduration);o.setLiveSeekableRange(d,l)}},A.checkPendingTracks=function(){var r=this.bufferCodecEventsExpected,o=this.operationQueue,n=this.pendingTracks,s=Object.keys(n).length;if(s&&!r||s===2){this.createSourceBuffers(n),this.pendingTracks={};var d=this.getSourceBufferTypes();if(d.length===0){this.hls.trigger(i.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}d.forEach(function(l){o.executeNext(l)})}},A.createSourceBuffers=function(r){var o=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var s=0;for(var d in r)if(!o[d]){var l=r[d];if(!l)throw Error("source buffer exists for track "+d+", however track does not");var T=l.levelCodec||l.codec,g=l.container+";codecs="+T;c.logger.log("[buffer-controller]: creating sourceBuffer("+g+")");try{var m=o[d]=n.addSourceBuffer(g),p=d;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[d]={buffer:m,codec:T,container:l.container,levelCodec:l.levelCodec,id:l.id},s++}catch(v){c.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(i.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:g})}}s&&this.hls.trigger(i.Events.BUFFER_CREATED,{tracks:this.tracks})},A._onSBUpdateStart=function(r){var o=this.operationQueue,n=o.current(r);n.onStart()},A._onSBUpdateEnd=function(r){var o=this.operationQueue,n=o.current(r);n.onComplete(),o.shiftAndExecuteNext(r)},A._onSBUpdateError=function(r,o){c.logger.error("[buffer-controller]: "+r+" SourceBuffer error",o),this.hls.trigger(i.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var n=this.operationQueue.current(r);n&&n.onError(o)},A.removeExecutor=function(r,o,n){var s=this.media,d=this.mediaSource,l=this.operationQueue,T=this.sourceBuffer,g=T[r];if(!s||!d||!g){c.logger.warn("[buffer-controller]: Attempting to remove from the "+r+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(r);return}var m=Object(a.isFiniteNumber)(s.duration)?s.duration:1/0,p=Object(a.isFiniteNumber)(d.duration)?d.duration:1/0,v=Math.max(0,o),h=Math.min(n,m,p);h>v?(c.logger.log("[buffer-controller]: Removing ["+v+","+h+"] from the "+r+" SourceBuffer"),console.assert(!g.updating,r+" sourceBuffer must not be updating"),g.remove(v,h)):l.shiftAndExecuteNext(r)},A.appendExecutor=function(r,o){var n=this.operationQueue,s=this.sourceBuffer,d=s[o];if(!d){c.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(o);return}d.ended=!1,console.assert(!d.updating,o+" sourceBuffer must not be updating"),d.appendBuffer(r)},A.blockBuffers=function(r,o){var n=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){c.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(r);return}var s=this.operationQueue,d=o.map(function(l){return s.appendBlocker(l)});Promise.all(d).then(function(){r(),o.forEach(function(l){var T=n.sourceBuffer[l];(!T||!T.updating)&&s.shiftAndExecuteNext(l)})})},A.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},A.addBufferListener=function(r,o,n){var s=this.sourceBuffer[r];if(!!s){var d=n.bind(this,r);this.listeners[r].push({event:o,listener:d}),s.addEventListener(o,d)}},A.removeBufferListeners=function(r){var o=this.sourceBuffer[r];!o||this.listeners[r].forEach(function(n){o.removeEventListener(n.event,n.listener)})},b}()},"./src/controller/buffer-operation-queue.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return i});var a=t("./src/utils/logger.ts"),i=function(){function c(E){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=E}var R=c.prototype;return R.append=function(L,_){var y=this.queues[_];y.push(L),y.length===1&&this.buffers[_]&&this.executeNext(_)},R.insertAbort=function(L,_){var y=this.queues[_];y.unshift(L),this.executeNext(_)},R.appendBlocker=function(L){var _,y=new Promise(function(M){_=M}),I={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(I,L),y},R.executeNext=function(L){var _=this.buffers,y=this.queues,I=_[L],M=y[L];if(M.length){var D=M[0];try{D.execute()}catch(b){a.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),D.onError(b),(!I||!I.updating)&&(M.shift(),this.executeNext(L))}}},R.shiftAndExecuteNext=function(L){this.queues[L].shift(),this.executeNext(L)},R.current=function(L){return this.queues[L][0]},c}()},"./src/controller/cap-level-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/events.ts");function i(E,L){for(var _=0;_<L.length;_++){var y=L[_];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(E,y.key,y)}}function c(E,L,_){return L&&i(E.prototype,L),_&&i(E,_),E}var R=function(){function E(_){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=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var L=E.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(a.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.on(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.on(a.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.unregisterListener=function(){var y=this.hls;y.off(a.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),y.off(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),y.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),y.off(a.Events.BUFFER_CODECS,this.onBufferCodecs,this),y.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},L.onFpsDropLevelCapping=function(y,I){E.isLevelAllowed(I.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(I.droppedLevel)},L.onMediaAttaching=function(y,I){this.media=I.media instanceof HTMLVideoElement?I.media:null},L.onManifestParsed=function(y,I){var M=this.hls;this.restrictedLevels=[],this.firstLevel=I.firstLevel,M.config.capLevelToPlayerSize&&I.video&&this.startCapping()},L.onBufferCodecs=function(y,I){var M=this.hls;M.config.capLevelToPlayerSize&&I.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 I=this.hls;I.autoLevelCapping=this.getMaxLevel(y.length-1),I.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=I.autoLevelCapping}}},L.getMaxLevel=function(y){var I=this,M=this.hls.levels;if(!M.length)return-1;var D=M.filter(function(b,A){return E.isLevelAllowed(A,I.restrictedLevels)&&A<=y});return this.clientRect=null,E.getMaxLevelByMediaSize(D,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,I={width:0,height:0};if(y){var M=y.getBoundingClientRect();I.width=M.width,I.height=M.height,!I.width&&!I.height&&(I.width=M.right-M.left||y.width||0,I.height=M.bottom-M.top||y.height||0)}return this.clientRect=I,I},E.isLevelAllowed=function(y,I){return I===void 0&&(I=[]),I.indexOf(y)===-1},E.getMaxLevelByMediaSize=function(y,I,M){if(!y||!y.length)return-1;for(var D=function(o,n){return n?o.width!==n.width||o.height!==n.height:!0},b=y.length-1,A=0;A<y.length;A+=1){var u=y[A];if((u.width>=I||u.height>=M)&&D(u,y[A+1])){b=A;break}}return b},c(E,[{key:"mediaWidth",get:function(){return this.getDimensions().width*E.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*E.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var y=1;try{y=self.devicePixelRatio}catch{}return y}}]),E}();e.default=R},"./src/controller/cmcd-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D});var a=t("./src/events.ts"),i=t("./src/types/cmcd.ts"),c=t("./src/utils/buffer-helper.ts"),R=t("./src/utils/logger.ts");function E(b,A){for(var u=0;u<A.length;u++){var r=A[u];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(b,r.key,r)}}function L(b,A,u){return A&&E(b.prototype,A),u&&E(b,u),b}function _(b,A){var u=typeof Symbol!="undefined"&&b[Symbol.iterator]||b["@@iterator"];if(u)return(u=u.call(b)).next.bind(u);if(Array.isArray(b)||(u=y(b))||A&&b&&typeof b.length=="number"){u&&(b=u);var r=0;return function(){return r>=b.length?{done:!0}:{done:!1,value:b[r++]}}}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(b,A){if(!!b){if(typeof b=="string")return I(b,A);var u=Object.prototype.toString.call(b).slice(8,-1);if(u==="Object"&&b.constructor&&(u=b.constructor.name),u==="Map"||u==="Set")return Array.from(b);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return I(b,A)}}function I(b,A){(A==null||A>b.length)&&(A=b.length);for(var u=0,r=new Array(A);u<A;u++)r[u]=b[u];return r}function M(){return M=Object.assign||function(b){for(var A=1;A<arguments.length;A++){var u=arguments[A];for(var r in u)Object.prototype.hasOwnProperty.call(u,r)&&(b[r]=u[r])}return b},M.apply(this,arguments)}var D=function(){function b(u){var r=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(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(s){try{r.apply(s,{ot:i.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(d){R.logger.warn("Could not generate manifest CMCD data.",d)}},this.applyFragmentData=function(s){try{var d=s.frag,l=r.hls.levels[d.level],T=r.getObjectType(d),g={d:d.duration*1e3,ot:T};(T===i.CMCDObjectType.VIDEO||T===i.CMCDObjectType.AUDIO||T==i.CMCDObjectType.MUXED)&&(g.br=l.bitrate/1e3,g.tb=r.getTopBandwidth(T)/1e3,g.bl=r.getBufferLength(T)),r.apply(s,g)}catch(m){R.logger.warn("Could not generate segment CMCD data.",m)}},this.hls=u;var o=this.config=u.config,n=o.cmcd;n!=null&&(o.pLoader=this.createPlaylistLoader(),o.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||b.uuid(),this.cid=n.contentId,this.useHeaders=n.useHeaders===!0,this.registerListeners())}var A=b.prototype;return A.registerListeners=function(){var r=this.hls;r.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this)},A.unregisterListeners=function(){var r=this.hls;r.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),r.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},A.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},A.onMediaAttached=function(r,o){this.media=o.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},A.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},A.onBufferCreated=function(r,o){var n,s;this.audioBuffer=(n=o.tracks.audio)===null||n===void 0?void 0:n.buffer,this.videoBuffer=(s=o.tracks.video)===null||s===void 0?void 0:s.buffer},A.createData=function(){var r;return{v:i.CMCDVersion,sf:i.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(r=this.media)===null||r===void 0?void 0:r.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},A.apply=function(r,o){o===void 0&&(o={}),M(o,this.createData());var n=o.ot===i.CMCDObjectType.INIT||o.ot===i.CMCDObjectType.VIDEO||o.ot===i.CMCDObjectType.MUXED;if(this.starved&&n&&(o.bs=!0,o.su=!0,this.starved=!1),o.su==null&&(o.su=this.buffering),this.useHeaders){var s=b.toHeaders(o);if(!Object.keys(s).length)return;r.headers||(r.headers={}),M(r.headers,s)}else{var d=b.toQuery(o);if(!d)return;r.url=b.appendQueryToUri(r.url,d)}},A.getObjectType=function(r){var o=r.type;if(o==="subtitle")return i.CMCDObjectType.TIMED_TEXT;if(r.sn==="initSegment")return i.CMCDObjectType.INIT;if(o==="audio")return i.CMCDObjectType.AUDIO;if(o==="main")return this.hls.audioTracks.length?i.CMCDObjectType.VIDEO:i.CMCDObjectType.MUXED},A.getTopBandwidth=function(r){var o=0,n,s=this.hls;if(r===i.CMCDObjectType.AUDIO)n=s.audioTracks;else{var d=s.maxAutoLevel,l=d>-1?d+1:s.levels.length;n=s.levels.slice(0,l)}for(var T=_(n),g;!(g=T()).done;){var m=g.value;m.bitrate>o&&(o=m.bitrate)}return o>0?o:NaN},A.getBufferLength=function(r){var o=this.hls.media,n=r===i.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!n||!o)return NaN;var s=c.BufferHelper.bufferInfo(n,o.currentTime,this.config.maxBufferHole);return s.len*1e3},A.createPlaylistLoader=function(){var r=this.config.pLoader,o=this.applyPlaylistData,n=r||this.config.loader;return function(){function s(l){this.loader=void 0,this.loader=new n(l)}var d=s.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(T,g,m){o(T),this.loader.load(T,g,m)},L(s,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),s}()},A.createFragmentLoader=function(){var r=this.config.fLoader,o=this.applyFragmentData,n=r||this.config.loader;return function(){function s(l){this.loader=void 0,this.loader=new n(l)}var d=s.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(T,g,m){o(T),this.loader.load(T,g,m)},L(s,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),s}()},b.uuid=function(){var r=URL.createObjectURL(new Blob),o=r.toString();return URL.revokeObjectURL(r),o.substr(o.lastIndexOf("/")+1)},b.serialize=function(r){for(var o=[],n=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},s=function(P){return Math.round(P)},d=function(P){return s(P/100)*100},l=function(P){return encodeURIComponent(P)},T={br:s,d:s,bl:d,dl:d,mtp:d,nor:l,rtp:d,tb:s},g=Object.keys(r||{}).sort(),m=_(g),p;!(p=m()).done;){var v=p.value,h=r[v];if(!!n(h)&&!(v==="v"&&h===1)&&!(v=="pr"&&h===1)){var x=T[v];x&&(h=x(h));var S=typeof h,C=void 0;v==="ot"||v==="sf"||v==="st"?C=v+"="+h:S==="boolean"?C=v:S==="number"?C=v+"="+h:C=v+"="+JSON.stringify(h),o.push(C)}}return o.join(",")},b.toHeaders=function(r){for(var o=Object.keys(r),n={},s=["Object","Request","Session","Status"],d=[{},{},{},{}],l={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},T=0,g=o;T<g.length;T++){var m=g[T],p=l[m]!=null?l[m]:1;d[p][m]=r[m]}for(var v=0;v<d.length;v++){var h=b.serialize(d[v]);h&&(n["CMCD-"+s[v]]=h)}return n},b.toQuery=function(r){return"CMCD="+encodeURIComponent(b.serialize(r))},b.appendQueryToUri=function(r,o){if(!o)return r;var n=r.includes("?")?"&":"?";return""+r+n+o},b}()},"./src/controller/eme-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/events.ts"),i=t("./src/errors.ts"),c=t("./src/utils/logger.ts"),R=t("./src/utils/mediakeys-helper.ts");function E(D,b){for(var A=0;A<b.length;A++){var u=b[A];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(D,u.key,u)}}function L(D,b,A){return b&&E(D.prototype,b),A&&E(D,A),D}var _=3,y=function(b,A,u){var r={audioCapabilities:[],videoCapabilities:[]};return b.forEach(function(o){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:u.audioRobustness||""})}),A.forEach(function(o){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:u.videoRobustness||""})}),[r]},I=function(b,A,u,r){switch(b){case R.KeySystems.WIDEVINE:return y(A,u,r);default:throw new Error("Unknown key-system: "+b)}},M=function(){function D(A){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=A,this._config=A.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 b=D.prototype;return b.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},b._registerListeners=function(){this.hls.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b._unregisterListeners=function(){this.hls.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(a.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this)},b.getLicenseServerUrl=function(u){switch(u){case R.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},b._attemptKeySystemAccess=function(u,r,o){var n=this,s=I(u,r,o,this._drmSystemOptions);c.logger.log("Requesting encrypted media key-system access");var d=this.requestMediaKeySystemAccess(u,s);this.mediaKeysPromise=d.then(function(l){return n._onMediaKeySystemAccessObtained(u,l)}),d.catch(function(l){c.logger.error('Failed to obtain key-system "'+u+'" access:',l)})},b._onMediaKeySystemAccessObtained=function(u,r){var o=this;c.logger.log('Access for key-system "'+u+'" obtained');var n={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:r,mediaKeySystemDomain:u};this._mediaKeysList.push(n);var s=Promise.resolve().then(function(){return r.createMediaKeys()}).then(function(d){return n.mediaKeys=d,c.logger.log('Media-keys created for key-system "'+u+'"'),o._onMediaKeysCreated(),d});return s.catch(function(d){c.logger.error("Failed to create media-keys:",d)}),s},b._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(r){r.mediaKeysSession||(r.mediaKeysSession=r.mediaKeys.createSession(),u._onNewMediaKeySession(r.mediaKeysSession))})},b._onNewMediaKeySession=function(u){var r=this;c.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(o){r._onKeySessionMessage(u,o.message)},!1)},b._onKeySessionMessage=function(u,r){c.logger.log("Got EME message event, creating license request"),this._requestLicense(r,function(o){c.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),u.update(o)})},b.onMediaEncrypted=function(u){var r=this;if(c.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){c.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var o=function(s){!r._media||(r._attemptSetMediaKeys(s),r._generateRequestWithPreferredKeySession(u.initDataType,u.initData))};this.mediaKeysPromise.then(o).catch(o)},b._attemptSetMediaKeys=function(u){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var r=this._mediaKeysList[0];if(!r||!r.mediaKeys){c.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}c.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(r.mediaKeys),this._hasSetMediaKeys=!0}},b._generateRequestWithPreferredKeySession=function(u,r){var o=this,n=this._mediaKeysList[0];if(!n){c.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(n.mediaKeysSessionInitialized){c.logger.warn("Key-Session already initialized but requested again");return}var s=n.mediaKeysSession;if(!s){c.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!r){c.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}c.logger.log('Generating key-session request for "'+u+'" init data type'),n.mediaKeysSessionInitialized=!0,s.generateRequest(u,r).then(function(){c.logger.debug("Key-session generation succeeded")}).catch(function(d){c.logger.error("Error generating key-session request:",d),o.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},b._createLicenseXhr=function(u,r,o){var n=new XMLHttpRequest;n.responseType="arraybuffer",n.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,n,u,r,o);var s=this._licenseXhrSetup;if(s)try{s.call(this.hls,n,u),s=void 0}catch(d){c.logger.error(d)}try{n.readyState||n.open("POST",u,!0),s&&s.call(this.hls,n,u)}catch(d){throw new Error("issue setting up KeySystem license XHR "+d)}return n},b._onLicenseRequestReadyStageChange=function(u,r,o,n){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,c.logger.log("License request succeeded");var s=u.response,d=this._licenseResponseCallback;if(d)try{s=d.call(this.hls,u,r)}catch(T){c.logger.error(T)}n(s)}else{if(c.logger.error("License Request XHR failed ("+r+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var l=_-this._requestLicenseFailureCount+1;c.logger.warn("Retrying license request, "+l+" attempts left"),this._requestLicense(o,n)}break}},b._generateLicenseRequestChallenge=function(u,r){switch(u.mediaKeySystemDomain){case R.KeySystems.WIDEVINE:return r}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},b._requestLicense=function(u,r){c.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){c.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var n=this.getLicenseServerUrl(o.mediaKeySystemDomain),s=this._createLicenseXhr(n,u,r);c.logger.log("Sending license request to URL: "+n);var d=this._generateLicenseRequestChallenge(o,u);s.send(d)}catch(l){c.logger.error("Failure requesting DRM license: "+l),this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},b.onMediaAttached=function(u,r){if(!!this._emeEnabled){var o=r.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},b.onMediaDetached=function(){var u=this._media,r=this._mediaKeysList;!u||(u.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(r.map(function(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return u.setMediaKeys(null)}).catch(function(){}))},b.onManifestParsed=function(u,r){if(!!this._emeEnabled){var o=r.levels.map(function(s){return s.audioCodec}).filter(function(s){return!!s}),n=r.levels.map(function(s){return s.videoCodec}).filter(function(s){return!!s});this._attemptKeySystemAccess(R.KeySystems.WIDEVINE,o,n)}},L(D,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),D}();e.default=M},"./src/controller/fps-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/events.ts"),i=t("./src/utils/logger.ts"),c=function(){function R(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 E=R.prototype;return E.setStreamController=function(_){this.streamController=_},E.registerListeners=function(){this.hls.on(a.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},E.unregisterListeners=function(){this.hls.off(a.Events.MEDIA_ATTACHING,this.onMediaAttaching)},E.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},E.onMediaAttaching=function(_,y){var I=this.hls.config;if(I.capLevelOnFPSDrop){var M=y.media instanceof self.HTMLVideoElement?y.media:null;this.media=M,M&&typeof M.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),I.fpsDroppedMonitoringPeriod)}},E.checkFPS=function(_,y,I){var M=performance.now();if(y){if(this.lastTime){var D=M-this.lastTime,b=I-this.lastDroppedFrames,A=y-this.lastDecodedFrames,u=1e3*b/D,r=this.hls;if(r.trigger(a.Events.FPS_DROP,{currentDropped:b,currentDecoded:A,totalDroppedFrames:I}),u>0&&b>r.config.fpsDroppedMonitoringThreshold*A){var o=r.currentLevel;i.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(r.autoLevelCapping===-1||r.autoLevelCapping>=o)&&(o=o-1,r.trigger(a.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:r.currentLevel}),r.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=M,this.lastDroppedFrames=I,this.lastDecodedFrames=y}},E.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var y=_.getVideoPlaybackQuality();this.checkFPS(_,y.totalVideoFrames,y.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},R}();e.default=c},"./src/controller/fragment-finders.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"findFragmentByPDT",function(){return c}),t.d(e,"findFragmentByPTS",function(){return R}),t.d(e,"fragmentWithinToleranceTest",function(){return E}),t.d(e,"pdtWithinToleranceTest",function(){return L}),t.d(e,"findFragWithCC",function(){return _});var a=t("./src/polyfills/number.ts"),i=t("./src/utils/binary-search.ts");function c(y,I,M){if(I===null||!Array.isArray(y)||!y.length||!Object(a.isFiniteNumber)(I))return null;var D=y[0].programDateTime;if(I<(D||0))return null;var b=y[y.length-1].endProgramDateTime;if(I>=(b||0))return null;M=M||0;for(var A=0;A<y.length;++A){var u=y[A];if(L(I,M,u))return u}return null}function R(y,I,M,D){M===void 0&&(M=0),D===void 0&&(D=0);var b=null;if(y?b=I[y.sn-I[0].sn+1]||null:M===0&&I[0].start===0&&(b=I[0]),b&&E(M,D,b)===0)return b;var A=i.default.search(I,E.bind(null,M,D));return A||b}function E(y,I,M){y===void 0&&(y=0),I===void 0&&(I=0);var D=Math.min(I,M.duration+(M.deltaPTS?M.deltaPTS:0));return M.start+M.duration-D<=y?1:M.start-D>y&&M.start?-1:0}function L(y,I,M){var D=Math.min(I,M.duration+(M.deltaPTS?M.deltaPTS:0))*1e3,b=M.endProgramDateTime||0;return b-D>y}function _(y,I){return i.default.search(y,function(M){return M.cc<I?1:M.cc>I?-1:0})}},"./src/controller/fragment-tracker.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"FragmentState",function(){return c}),t.d(e,"FragmentTracker",function(){return R});var a=t("./src/events.ts"),i=t("./src/types/loader.ts"),c;(function(_){_.NOT_LOADED="NOT_LOADED",_.BACKTRACKED="BACKTRACKED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(c||(c={}));var R=function(){function _(I){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=I,this._registerListeners()}var y=_.prototype;return y._registerListeners=function(){var M=this.hls;M.on(a.Events.BUFFER_APPENDED,this.onBufferAppended,this),M.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),M.on(a.Events.FRAG_LOADED,this.onFragLoaded,this)},y._unregisterListeners=function(){var M=this.hls;M.off(a.Events.BUFFER_APPENDED,this.onBufferAppended,this),M.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),M.off(a.Events.FRAG_LOADED,this.onFragLoaded,this)},y.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},y.getAppendedFrag=function(M,D){if(D===i.PlaylistLevelType.MAIN){var b=this.activeFragment,A=this.activeParts;if(!b)return null;if(A)for(var u=A.length;u--;){var r=A[u],o=r?r.end:b.appendedPTS;if(r.start<=M&&o!==void 0&&M<=o)return u>9&&(this.activeParts=A.slice(u-9)),r}else if(b.start<=M&&b.appendedPTS!==void 0&&M<=b.appendedPTS)return b}return this.getBufferedFrag(M,D)},y.getBufferedFrag=function(M,D){for(var b=this.fragments,A=Object.keys(b),u=A.length;u--;){var r=b[A[u]];if((r==null?void 0:r.body.type)===D&&r.buffered){var o=r.body;if(o.start<=M&&M<=o.end)return o}}return null},y.detectEvictedFragments=function(M,D,b){var A=this;Object.keys(this.fragments).forEach(function(u){var r=A.fragments[u];if(!!r){if(!r.buffered){r.body.type===b&&A.removeFragment(r.body);return}var o=r.range[M];!o||o.time.some(function(n){var s=!A.isTimeBuffered(n.startPTS,n.endPTS,D);return s&&A.removeFragment(r.body),s})}})},y.detectPartialFragments=function(M){var D=this,b=this.timeRanges,A=M.frag,u=M.part;if(!(!b||A.sn==="initSegment")){var r=L(A),o=this.fragments[r];!o||(Object.keys(b).forEach(function(n){var s=A.elementaryStreams[n];if(!!s){var d=b[n],l=u!==null||s.partial===!0;o.range[n]=D.getBufferedTimes(A,u,l,d)}}),o.backtrack=o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},y.fragBuffered=function(M){var D=L(M),b=this.fragments[D];b&&(b.backtrack=b.loaded=null,b.buffered=!0)},y.getBufferedTimes=function(M,D,b,A){for(var u={time:[],partial:b},r=D?D.start:M.start,o=D?D.end:M.end,n=M.minEndPTS||o,s=M.maxStartPTS||r,d=0;d<A.length;d++){var l=A.start(d)-this.bufferPadding,T=A.end(d)+this.bufferPadding;if(s>=l&&n<=T){u.time.push({startPTS:Math.max(r,A.start(d)),endPTS:Math.min(o,A.end(d))});break}else if(r<T&&o>l)u.partial=!0,u.time.push({startPTS:Math.max(r,A.start(d)),endPTS:Math.min(o,A.end(d))});else if(o<=l)break}return u},y.getPartialFragment=function(M){var D=null,b,A,u,r=0,o=this.bufferPadding,n=this.fragments;return Object.keys(n).forEach(function(s){var d=n[s];!d||E(d)&&(A=d.body.start-o,u=d.body.end+o,M>=A&&M<=u&&(b=Math.min(M-A,u-M),r<=b&&(D=d.body,r=b)))}),D},y.getState=function(M){var D=L(M),b=this.fragments[D];return b?b.buffered?E(b)?c.PARTIAL:c.OK:b.backtrack?c.BACKTRACKED:c.APPENDING:c.NOT_LOADED},y.backtrack=function(M,D){var b=L(M),A=this.fragments[b];if(!A||A.backtrack)return null;var u=A.backtrack=D||A.loaded;return A.loaded=null,u},y.getBacktrackData=function(M){var D=L(M),b=this.fragments[D];if(b){var A,u=b.backtrack;if(u!=null&&(A=u.payload)!==null&&A!==void 0&&A.byteLength)return u;this.removeFragment(M)}return null},y.isTimeBuffered=function(M,D,b){for(var A,u,r=0;r<b.length;r++){if(A=b.start(r)-this.bufferPadding,u=b.end(r)+this.bufferPadding,M>=A&&D<=u)return!0;if(D<=A)return!1}return!1},y.onFragLoaded=function(M,D){var b=D.frag,A=D.part;if(!(b.sn==="initSegment"||b.bitrateTest||A)){var u=L(b);this.fragments[u]={body:b,loaded:D,backtrack:null,buffered:!1,range:Object.create(null)}}},y.onBufferAppended=function(M,D){var b=this,A=D.frag,u=D.part,r=D.timeRanges;if(A.type===i.PlaylistLevelType.MAIN)if(this.activeFragment=A,u){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(u)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(n){var s=r[n];if(b.detectEvictedFragments(n,s),!u)for(var d=0;d<s.length;d++)A.appendedPTS=Math.max(s.end(d),A.appendedPTS||0)})},y.onFragBuffered=function(M,D){this.detectPartialFragments(D)},y.hasFragment=function(M){var D=L(M);return!!this.fragments[D]},y.removeFragmentsInRange=function(M,D,b){var A=this;Object.keys(this.fragments).forEach(function(u){var r=A.fragments[u];if(!!r&&r.buffered){var o=r.body;o.type===b&&o.start<D&&o.end>M&&A.removeFragment(o)}})},y.removeFragment=function(M){var D=L(M);M.stats.loaded=0,M.clearElementaryStreamInfo(),delete this.fragments[D]},y.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function E(_){var y,I;return _.buffered&&(((y=_.range.video)===null||y===void 0?void 0:y.partial)||((I=_.range.audio)===null||I===void 0?void 0:I.partial))}function L(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"STALL_MINIMUM_DURATION_MS",function(){return E}),t.d(e,"MAX_START_GAP_JUMP",function(){return L}),t.d(e,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),t.d(e,"SKIP_BUFFER_RANGE_START",function(){return y}),t.d(e,"default",function(){return I});var a=t("./src/utils/buffer-helper.ts"),i=t("./src/errors.ts"),c=t("./src/events.ts"),R=t("./src/utils/logger.ts"),E=250,L=2,_=.1,y=.05,I=function(){function M(b,A,u,r){this.config=void 0,this.media=void 0,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=b,this.media=A,this.fragmentTracker=u,this.hls=r}var D=M.prototype;return D.destroy=function(){this.hls=this.fragmentTracker=this.media=null},D.poll=function(A){var u=this.config,r=this.media,o=this.stalled,n=r.currentTime,s=r.seeking,d=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,n!==A){if(this.moved=!0,o!==null){if(this.stallReported){var T=self.performance.now()-o;R.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(T)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((l||d)&&(this.stalled=null),!(r.paused||r.ended||r.playbackRate===0||!a.BufferHelper.getBuffered(r).length)){var g=a.BufferHelper.bufferInfo(r,n,0),m=g.len>0,p=g.nextStart||0;if(!(!m&&!p)){if(s){var v=g.len>L,h=!p||p-n>L&&!this.fragmentTracker.getPartialFragment(n);if(v||h)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x,S=Math.max(p,g.start||0)-n,C=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,O=C==null||(x=C.details)===null||x===void 0?void 0:x.live,P=O?C.details.targetduration*2:L;if(S>0&&S<=P){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(o===null){this.stalled=w;return}var U=w-o;!s&&U>=E&&this._reportStall(g.len);var k=a.BufferHelper.bufferInfo(r,n,u.maxBufferHole);this._tryFixBufferStall(k,U)}}},D._tryFixBufferStall=function(A,u){var r=this.config,o=this.fragmentTracker,n=this.media,s=n.currentTime,d=o.getPartialFragment(s);if(d){var l=this._trySkipBufferHole(d);if(l)return}A.len>r.maxBufferHole&&u>r.highBufferWatchdogPeriod*1e3&&(R.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},D._reportStall=function(A){var u=this.hls,r=this.media,o=this.stallReported;o||(this.stallReported=!0,R.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+A+")"),u.trigger(c.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:A}))},D._trySkipBufferHole=function(A){for(var u=this.config,r=this.hls,o=this.media,n=o.currentTime,s=0,d=a.BufferHelper.getBuffered(o),l=0;l<d.length;l++){var T=d.start(l);if(n+u.maxBufferHole>=s&&n<T){var g=Math.max(T+y,o.currentTime+_);return R.logger.warn("skipping hole, adjusting currentTime from "+n+" to "+g),this.moved=!0,this.stalled=null,o.currentTime=g,A&&r.trigger(c.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+n+" to "+g,frag:A}),g}s=d.end(l)}return 0},D._tryNudgeBuffer=function(){var A=this.config,u=this.hls,r=this.media,o=r.currentTime,n=(this.nudgeRetry||0)+1;if(this.nudgeRetry=n,n<A.nudgeMaxRetry){var s=o+n*A.nudgeOffset;R.logger.warn("Nudging 'currentTime' from "+o+" to "+s),r.currentTime=s,u.trigger(c.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else R.logger.error("Playhead still not moving while enough data buffered @"+o+" after "+A.nudgeMaxRetry+" nudges"),u.trigger(c.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},M}()},"./src/controller/id3-track-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/events.ts"),i=t("./src/utils/texttrack-utils.ts"),c=t("./src/demux/id3.ts"),R=.25,E=function(){function L(y){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=y,this._registerListeners()}var _=L.prototype;return _.destroy=function(){this._unregisterListeners()},_._registerListeners=function(){var I=this.hls;I.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),I.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),I.on(a.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),I.on(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._unregisterListeners=function(){var I=this.hls;I.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),I.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),I.off(a.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),I.off(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.onMediaAttached=function(I,M){this.media=M.media},_.onMediaDetaching=function(){!this.id3Track||(Object(i.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},_.getID3Track=function(I){if(!!this.media){for(var M=0;M<I.length;M++){var D=I[M];if(D.kind==="metadata"&&D.label==="id3")return Object(i.sendAddTrackEvent)(D,this.media),D}return this.media.addTextTrack("metadata","id3")}},_.onFragParsingMetadata=function(I,M){if(!!this.media){var D=M.frag,b=M.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var A=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<b.length;u++){var r=c.getID3Frames(b[u].data);if(r){var o=b[u].pts,n=u<b.length-1?b[u+1].pts:D.end,s=n-o;s<=0&&(n=o+R);for(var d=0;d<r.length;d++){var l=r[d];if(!c.isTimeStampFrame(l)){var T=new A(o,n,"");T.value=l,this.id3Track.addCue(T)}}}}}},_.onBufferFlushing=function(I,M){var D=M.startOffset,b=M.endOffset,A=M.type;if(!A||A==="audio"){var u=this.id3Track;u&&Object(i.removeCuesInRange)(u,D,b)}},L}();e.default=E},"./src/controller/latency-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return L});var a=t("./src/errors.ts"),i=t("./src/events.ts"),c=t("./src/utils/logger.ts");function R(_,y){for(var I=0;I<y.length;I++){var M=y[I];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(_,M.key,M)}}function E(_,y,I){return y&&R(_.prototype,y),I&&R(_,I),_}var L=function(){function _(I){var M=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 M.timeupdate()},this.hls=I,this.config=I.config,this.registerListeners()}var y=_.prototype;return y.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},y.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(i.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(i.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(i.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(i.Events.ERROR,this.onError)},y.onMediaAttached=function(M,D){this.media=D.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(M,D){var b=D.details;this.levelDetails=b,b.advanced&&this.timeupdate(),!b.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},y.onError=function(M,D){D.details===a.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,c.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},y.timeupdate=function(){var M=this.media,D=this.levelDetails;if(!(!M||!D)){this.currentTime=M.currentTime;var b=this.computeLatency();if(b!==null){this._latency=b;var A=this.config,u=A.lowLatencyMode,r=A.maxLiveSyncPlaybackRate;if(!(!u||r===1)){var o=this.targetLatency;if(o!==null){var n=b-o,s=Math.min(this.maxLatency,o+D.targetduration),d=n<s;if(D.live&&d&&n>.05&&this.forwardBufferLength>1){var l=Math.min(2,Math.max(1,r)),T=Math.round(2/(1+Math.exp(-.75*n-this.edgeStalled))*20)/20;M.playbackRate=Math.min(l,Math.max(1,T))}else M.playbackRate!==1&&M.playbackRate!==0&&(M.playbackRate=1)}}}}},y.estimateLiveEdge=function(){var M=this.levelDetails;return M===null?null:M.edge+M.age},y.computeLatency=function(){var M=this.estimateLiveEdge();return M===null?null:M-this.currentTime},E(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var M=this.config,D=this.levelDetails;return M.liveMaxLatencyDuration!==void 0?M.liveMaxLatencyDuration:D?M.liveMaxLatencyDurationCount*D.targetduration:0}},{key:"targetLatency",get:function(){var M=this.levelDetails;if(M===null)return null;var D=M.holdBack,b=M.partHoldBack,A=M.targetduration,u=this.config,r=u.liveSyncDuration,o=u.liveSyncDurationCount,n=u.lowLatencyMode,s=this.hls.userConfig,d=n&&b||D;(s.liveSyncDuration||s.liveSyncDurationCount||d===0)&&(d=r!==void 0?r:o*A);var l=A,T=1;return d+Math.min(this.stallCount*T,l)}},{key:"liveSyncPosition",get:function(){var M=this.estimateLiveEdge(),D=this.targetLatency,b=this.levelDetails;if(M===null||D===null||b===null)return null;var A=b.edge,u=M-D-this.edgeStalled,r=A-b.totalduration,o=A-(this.config.lowLatencyMode&&b.partTarget||b.targetduration);return Math.min(Math.max(r,u),o)}},{key:"drift",get:function(){var M=this.levelDetails;return M===null?1:M.drift}},{key:"edgeStalled",get:function(){var M=this.levelDetails;if(M===null)return 0;var D=(this.config.lowLatencyMode&&M.partTarget||M.targetduration)*3;return Math.max(M.age-D,0)}},{key:"forwardBufferLength",get:function(){var M=this.media,D=this.levelDetails;if(!M||!D)return 0;var b=M.buffered.length;return b?M.buffered.end(b-1):D.edge-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return u});var a=t("./src/types/level.ts"),i=t("./src/events.ts"),c=t("./src/errors.ts"),R=t("./src/utils/codecs.ts"),E=t("./src/controller/level-helper.ts"),L=t("./src/controller/base-playlist-controller.ts"),_=t("./src/types/loader.ts");function y(){return y=Object.assign||function(r){for(var o=1;o<arguments.length;o++){var n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},y.apply(this,arguments)}function I(r,o){for(var n=0;n<o.length;n++){var s=o[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(r,s.key,s)}}function M(r,o,n){return o&&I(r.prototype,o),n&&I(r,n),r}function D(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,b(r,o)}function b(r,o){return b=Object.setPrototypeOf||function(s,d){return s.__proto__=d,s},b(r,o)}var A=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(r){D(o,r);function o(s){var d;return d=r.call(this,s,"[level-controller]")||this,d._levels=[],d._firstLevel=-1,d._startLevel=void 0,d.currentLevelIndex=-1,d.manualLevelIndex=-1,d.onParsedComplete=void 0,d._registerListeners(),d}var n=o.prototype;return n._registerListeners=function(){var d=this.hls;d.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.on(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(i.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.on(i.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(i.Events.ERROR,this.onError,this)},n._unregisterListeners=function(){var d=this.hls;d.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(i.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.off(i.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(i.Events.ERROR,this.onError,this)},n.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,r.prototype.destroy.call(this)},n.startLoad=function(){var d=this._levels;d.forEach(function(l){l.loadError=0}),r.prototype.startLoad.call(this)},n.onManifestLoaded=function(d,l){var T=[],g=[],m=[],p,v={},h,x=!1,S=!1,C=!1;if(l.levels.forEach(function(U){var k=U.attrs;x=x||!!(U.width&&U.height),S=S||!!U.videoCodec,C=C||!!U.audioCodec,A&&U.audioCodec&&U.audioCodec.indexOf("mp4a.40.34")!==-1&&(U.audioCodec=void 0);var N=U.bitrate+"-"+U.attrs.RESOLUTION+"-"+U.attrs.CODECS;h=v[N],h?h.url.push(U.url):(h=new a.Level(U),v[N]=h,T.push(h)),k&&(k.AUDIO&&Object(E.addGroupId)(h,"audio",k.AUDIO),k.SUBTITLES&&Object(E.addGroupId)(h,"text",k.SUBTITLES))}),(x||S)&&C&&(T=T.filter(function(U){var k=U.videoCodec,N=U.width,B=U.height;return!!k||!!(N&&B)})),T=T.filter(function(U){var k=U.audioCodec,N=U.videoCodec;return(!k||Object(R.isCodecSupportedInMp4)(k,"audio"))&&(!N||Object(R.isCodecSupportedInMp4)(N,"video"))}),l.audioTracks&&(g=l.audioTracks.filter(function(U){return!U.audioCodec||Object(R.isCodecSupportedInMp4)(U.audioCodec,"audio")}),Object(E.assignTrackIdsByGroup)(g)),l.subtitles&&(m=l.subtitles,Object(E.assignTrackIdsByGroup)(m)),T.length>0){p=T[0].bitrate,T.sort(function(U,k){return U.bitrate-k.bitrate}),this._levels=T;for(var O=0;O<T.length;O++)if(T[O].bitrate===p){this._firstLevel=O,this.log("manifest loaded, "+T.length+" level(s) found, first bitrate: "+p);break}var P=C&&!S,w={levels:T,audioTracks:g,subtitleTracks:m,firstLevel:this._firstLevel,stats:l.stats,audio:C,video:S,altAudio:!P&&g.some(function(U){return!!U.url})};this.hls.trigger(i.Events.MANIFEST_PARSED,w),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(i.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:l.url,reason:"no level with compatible codecs found in manifest"})},n.onError=function(d,l){if(r.prototype.onError.call(this,d,l),!l.fatal){var T=l.context,g=this._levels[this.currentLevelIndex];if(T&&(T.type===_.PlaylistContextType.AUDIO_TRACK&&g.audioGroupIds&&T.groupId===g.audioGroupIds[g.urlId]||T.type===_.PlaylistContextType.SUBTITLE_TRACK&&g.textGroupIds&&T.groupId===g.textGroupIds[g.urlId])){this.redundantFailover(this.currentLevelIndex);return}var m=!1,p=!0,v;switch(l.details){case c.ErrorDetails.FRAG_LOAD_ERROR:case c.ErrorDetails.FRAG_LOAD_TIMEOUT:case c.ErrorDetails.KEY_LOAD_ERROR:case c.ErrorDetails.KEY_LOAD_TIMEOUT:if(l.frag){var h=this._levels[l.frag.level];h?(h.fragmentError++,h.fragmentError>this.hls.config.fragLoadingMaxRetry&&(v=l.frag.level)):v=l.frag.level}break;case c.ErrorDetails.LEVEL_LOAD_ERROR:case c.ErrorDetails.LEVEL_LOAD_TIMEOUT:T&&(T.deliveryDirectives&&(p=!1),v=T.level),m=!0;break;case c.ErrorDetails.REMUX_ALLOC_ERROR:v=l.level,m=!0;break}v!==void 0&&this.recoverLevel(l,v,m,p)}},n.recoverLevel=function(d,l,T,g){var m=d.details,p=this._levels[l];if(p.loadError++,T){var v=this.retryLoadingOrFail(d);if(v)d.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(g){var h=p.url.length;if(h>1&&p.loadError<h)d.levelRetry=!0,this.redundantFailover(l);else if(this.manualLevelIndex===-1){var x=l===0?this._levels.length-1:l-1;this.currentLevelIndex!==x&&this._levels[x].loadError===0&&(this.warn(m+": switch to "+x),d.levelRetry=!0,this.hls.nextAutoLevel=x)}}},n.redundantFailover=function(d){var l=this._levels[d],T=l.url.length;if(T>1){var g=(l.urlId+1)%T;this.warn("Switching to redundant URL-id "+g),this._levels.forEach(function(m){m.urlId=g}),this.level=d}},n.onFragLoaded=function(d,l){var T=l.frag;if(T!==void 0&&T.type===_.PlaylistLevelType.MAIN){var g=this._levels[T.level];g!==void 0&&(g.fragmentError=0,g.loadError=0)}},n.onLevelLoaded=function(d,l){var T,g=l.level,m=l.details,p=this._levels[g];if(!p){var v;this.warn("Invalid level index "+g),(v=l.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(m.deltaUpdateFailed=!0);return}g===this.currentLevelIndex?(p.fragmentError===0&&(p.loadError=0,this.retryCount=0),this.playlistLoaded(g,l,p.details)):(T=l.deliveryDirectives)!==null&&T!==void 0&&T.skip&&(m.deltaUpdateFailed=!0)},n.onAudioTrackSwitched=function(d,l){var T=this.hls.levels[this.currentLevelIndex];if(!!T&&T.audioGroupIds){for(var g=-1,m=this.hls.audioTracks[l.id].groupId,p=0;p<T.audioGroupIds.length;p++)if(T.audioGroupIds[p]===m){g=p;break}g!==T.urlId&&(T.urlId=g,this.startLoad())}},n.loadPlaylist=function(d){var l=this.currentLevelIndex,T=this._levels[l];if(this.canLoad&&T&&T.url.length>0){var g=T.urlId,m=T.url[g];if(d)try{m=d.addDirectives(m)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Attempt loading level index "+l+(d?" at sn "+d.msn+" part "+d.part:"")+" with URL-id "+g+" "+m),this.clearTimer(),this.hls.trigger(i.Events.LEVEL_LOADING,{url:m,level:l,id:g,deliveryDirectives:d||null})}},n.removeLevel=function(d,l){var T=function(p,v){return v!==l},g=this._levels.filter(function(m,p){return p!==d?!0:m.url.length>1&&l!==void 0?(m.url=m.url.filter(T),m.audioGroupIds&&(m.audioGroupIds=m.audioGroupIds.filter(T)),m.textGroupIds&&(m.textGroupIds=m.textGroupIds.filter(T)),m.urlId=0,!0):!1}).map(function(m,p){var v=m.details;return v!=null&&v.fragments&&v.fragments.forEach(function(h){h.level=p}),m});this._levels=g,this.hls.trigger(i.Events.LEVELS_UPDATED,{levels:g})},M(o,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(d){var l,T=this._levels;if(T.length!==0&&!(this.currentLevelIndex===d&&(l=T[d])!==null&&l!==void 0&&l.details)){if(d<0||d>=T.length){var g=d<0;if(this.hls.trigger(i.Events.ERROR,{type:c.ErrorTypes.OTHER_ERROR,details:c.ErrorDetails.LEVEL_SWITCH_ERROR,level:d,fatal:g,reason:"invalid level idx"}),g)return;d=Math.min(d,T.length-1)}this.clearTimer();var m=this.currentLevelIndex,p=T[m],v=T[d];this.log("switching to level "+d+" from "+m),this.currentLevelIndex=d;var h=y({},v,{level:d,maxBitrate:v.maxBitrate,uri:v.uri,urlId:v.urlId});delete h._urlId,this.hls.trigger(i.Events.LEVEL_SWITCHING,h);var x=v.details;if(!x||x.live){var S=this.switchParams(v.uri,p==null?void 0:p.details);this.loadPlaylist(S)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(d){this.manualLevelIndex=d,this._startLevel===void 0&&(this._startLevel=d),d!==-1&&(this.level=d)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(d){this._firstLevel=d}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var d=this.hls.config.startLevel;return d!==void 0?d:this._firstLevel}else return this._startLevel},set:function(d){this._startLevel=d}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(d){this.level=d,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=d)}}]),o}(L.default)},"./src/controller/level-helper.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"addGroupId",function(){return c}),t.d(e,"assignTrackIdsByGroup",function(){return R}),t.d(e,"updatePTS",function(){return E}),t.d(e,"updateFragPTSDTS",function(){return _}),t.d(e,"mergeDetails",function(){return y}),t.d(e,"mapPartIntersection",function(){return I}),t.d(e,"mapFragmentIntersection",function(){return M}),t.d(e,"adjustSliding",function(){return D}),t.d(e,"addSliding",function(){return b}),t.d(e,"computeReloadInterval",function(){return A}),t.d(e,"getFragmentWithSN",function(){return u}),t.d(e,"getPartWith",function(){return r});var a=t("./src/polyfills/number.ts"),i=t("./src/utils/logger.ts");function c(o,n,s){switch(n){case"audio":o.audioGroupIds||(o.audioGroupIds=[]),o.audioGroupIds.push(s);break;case"text":o.textGroupIds||(o.textGroupIds=[]),o.textGroupIds.push(s);break}}function R(o){var n={};o.forEach(function(s){var d=s.groupId||"";s.id=n[d]=n[d]||0,n[d]++})}function E(o,n,s){var d=o[n],l=o[s];L(d,l)}function L(o,n){var s=n.startPTS;if(Object(a.isFiniteNumber)(s)){var d=0,l;n.sn>o.sn?(d=s-o.start,l=o):(d=o.start-s,l=n),l.duration!==d&&(l.duration=d)}else if(n.sn>o.sn){var T=o.cc===n.cc;T&&o.minEndPTS?n.start=o.start+(o.minEndPTS-o.start):n.start=o.start+o.duration}else n.start=Math.max(o.start-n.duration,0)}function _(o,n,s,d,l,T){var g=d-s;g<=0&&(i.logger.warn("Fragment should have a positive duration",n),d=s+n.duration,T=l+n.duration);var m=s,p=d,v=n.startPTS,h=n.endPTS;if(Object(a.isFiniteNumber)(v)){var x=Math.abs(v-s);Object(a.isFiniteNumber)(n.deltaPTS)?n.deltaPTS=Math.max(x,n.deltaPTS):n.deltaPTS=x,m=Math.max(s,v),s=Math.min(s,v),l=Math.min(l,n.startDTS),p=Math.min(d,h),d=Math.max(d,h),T=Math.max(T,n.endDTS)}n.duration=d-s;var S=s-n.start;n.appendedPTS=d,n.start=n.startPTS=s,n.maxStartPTS=m,n.startDTS=l,n.endPTS=d,n.minEndPTS=p,n.endDTS=T;var C=n.sn;if(!o||C<o.startSN||C>o.endSN)return 0;var O,P=C-o.startSN,w=o.fragments;for(w[P]=n,O=P;O>0;O--)L(w[O],w[O-1]);for(O=P;O<w.length-1;O++)L(w[O],w[O+1]);return o.fragmentHint&&L(w[w.length-1],o.fragmentHint),o.PTSKnown=o.alignedSliding=!0,S}function y(o,n){for(var s=null,d=o.fragments,l=d.length-1;l>=0;l--){var T=d[l].initSegment;if(T){s=T;break}}o.fragmentHint&&delete o.fragmentHint.endPTS;var g=0,m;if(M(o,n,function(O,P){O.relurl&&(g=O.cc-P.cc),Object(a.isFiniteNumber)(O.startPTS)&&Object(a.isFiniteNumber)(O.endPTS)&&(P.start=P.startPTS=O.startPTS,P.startDTS=O.startDTS,P.appendedPTS=O.appendedPTS,P.maxStartPTS=O.maxStartPTS,P.endPTS=O.endPTS,P.endDTS=O.endDTS,P.minEndPTS=O.minEndPTS,P.duration=O.endPTS-O.startPTS,P.duration&&(m=P),n.PTSKnown=n.alignedSliding=!0),P.elementaryStreams=O.elementaryStreams,P.loader=O.loader,P.stats=O.stats,P.urlId=O.urlId,O.initSegment&&(P.initSegment=O.initSegment,s=O.initSegment)}),s){var p=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;p.forEach(function(O){var P;(!O.initSegment||O.initSegment.relurl===((P=s)===null||P===void 0?void 0:P.relurl))&&(O.initSegment=s)})}if(n.skippedSegments&&(n.deltaUpdateFailed=n.fragments.some(function(O){return!O}),n.deltaUpdateFailed)){i.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var v=n.skippedSegments;v--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}var h=n.fragments;if(g){i.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<h.length;x++)h[x].cc+=g}n.skippedSegments&&(n.startCC=n.fragments[0].cc),I(o.partList,n.partList,function(O,P){P.elementaryStreams=O.elementaryStreams,P.stats=O.stats}),m?_(n,m,m.startPTS,m.endPTS,m.startDTS,m.endDTS):D(o,n),h.length&&(n.totalduration=n.edge-h[0].start),n.driftStartTime=o.driftStartTime,n.driftStart=o.driftStart;var S=n.advancedDateTime;if(n.advanced&&S){var C=n.edge;n.driftStart||(n.driftStartTime=S,n.driftStart=C),n.driftEndTime=S,n.driftEnd=C}else n.driftEndTime=o.driftEndTime,n.driftEnd=o.driftEnd,n.advancedDateTime=o.advancedDateTime}function I(o,n,s){if(o&&n)for(var d=0,l=0,T=o.length;l<=T;l++){var g=o[l],m=n[l+d];g&&m&&g.index===m.index&&g.fragment.sn===m.fragment.sn?s(g,m):d--}}function M(o,n,s){for(var d=n.skippedSegments,l=Math.max(o.startSN,n.startSN)-n.startSN,T=(o.fragmentHint?1:0)+(d?n.endSN:Math.min(o.endSN,n.endSN))-n.startSN,g=n.startSN-o.startSN,m=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,p=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments,v=l;v<=T;v++){var h=p[g+v],x=m[v];d&&!x&&v<d&&(x=n.fragments[v]=h),h&&x&&s(h,x)}}function D(o,n){var s=n.startSN+n.skippedSegments-o.startSN,d=o.fragments;s<0||s>=d.length||b(n,d[s].start)}function b(o,n){if(n){for(var s=o.fragments,d=o.skippedSegments;d<s.length;d++)s[d].start+=n;o.fragmentHint&&(o.fragmentHint.start+=n)}}function A(o,n){var s=1e3*o.levelTargetDuration,d=s/2,l=o.age,T=l>0&&l<s*3,g=n.loading.end-n.loading.start,m,p=o.availabilityDelay;if(o.updated===!1)if(T){var v=333*o.misses;m=Math.max(Math.min(d,g*2),v),o.availabilityDelay=(o.availabilityDelay||0)+m}else m=d;else T?(p=Math.min(p||s/2,l),o.availabilityDelay=p,m=p+s-l):m=s-g;return Math.round(m)}function u(o,n,s){if(!o||!o.details)return null;var d=o.details,l=d.fragments[n-d.startSN];return l||(l=d.fragmentHint,l&&l.sn===n)?l:n<d.startSN&&s&&s.sn===n?s:null}function r(o,n,s){if(!o||!o.details)return null;var d=o.details.partList;if(d)for(var l=d.length;l--;){var T=d[l];if(T.index===s&&T.fragment.sn===n)return T}return null}},"./src/controller/stream-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return d});var a=t("./src/polyfills/number.ts"),i=t("./src/controller/base-stream-controller.ts"),c=t("./src/is-supported.ts"),R=t("./src/events.ts"),E=t("./src/utils/buffer-helper.ts"),L=t("./src/controller/fragment-tracker.ts"),_=t("./src/types/loader.ts"),y=t("./src/loader/fragment.ts"),I=t("./src/demux/transmuxer-interface.ts"),M=t("./src/types/transmuxer.ts"),D=t("./src/controller/gap-controller.ts"),b=t("./src/errors.ts"),A=t("./src/utils/logger.ts");function u(l,T){for(var g=0;g<T.length;g++){var m=T[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(l,m.key,m)}}function r(l,T,g){return T&&u(l.prototype,T),g&&u(l,g),l}function o(l,T){l.prototype=Object.create(T.prototype),l.prototype.constructor=l,n(l,T)}function n(l,T){return n=Object.setPrototypeOf||function(m,p){return m.__proto__=p,m},n(l,T)}var s=100,d=function(l){o(T,l);function T(m,p){var v;return v=l.call(this,m,p,"[stream-controller]")||this,v.audioCodecSwap=!1,v.gapController=null,v.level=-1,v._forceStartLoad=!1,v.altAudio=!1,v.audioOnly=!1,v.fragPlaying=null,v.onvplaying=null,v.onvseeked=null,v.fragLastKbps=0,v.stalled=!1,v.couldBacktrack=!1,v.audioCodecSwitch=!1,v.videoBuffer=null,v._registerListeners(),v}var g=T.prototype;return g._registerListeners=function(){var p=this.hls;p.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),p.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.on(R.Events.ERROR,this.onError,this),p.on(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.on(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this),p.on(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.on(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g._unregisterListeners=function(){var p=this.hls;p.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(R.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),p.off(R.Events.ERROR,this.onError,this),p.off(R.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),p.off(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),p.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),p.off(R.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),p.off(R.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),p.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},g.startLoad=function(p){if(this.levels){var v=this.lastCurrentTime,h=this.hls;if(this.stopLoad(),this.setInterval(s),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var x=h.startLevel;x===-1&&(h.config.testBandwidth?(x=0,this.bitrateTest=!0):x=h.nextAutoLevel),this.level=h.nextLoadLevel=x,this.loadedmetadata=!1}v>0&&p===-1&&(this.log("Override startPosition with lastCurrentTime @"+v.toFixed(3)),p=v),this.state=i.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()}else this._forceStartLoad=!0,this.state=i.State.STOPPED},g.stopLoad=function(){this._forceStartLoad=!1,l.prototype.stopLoad.call(this)},g.doTick=function(){switch(this.state){case i.State.IDLE:this.doTickIdle();break;case i.State.WAITING_LEVEL:{var p,v=this.levels,h=this.level,x=v==null||(p=v[h])===null||p===void 0?void 0:p.details;if(x&&(!x.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(x))break;this.state=i.State.IDLE;break}break}case i.State.FRAG_LOADING_WAITING_RETRY:{var S,C=self.performance.now(),O=this.retryDate;(!O||C>=O||(S=this.media)!==null&&S!==void 0&&S.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=i.State.IDLE)}break;default:break}this.onTickEnd()},g.onTickEnd=function(){l.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},g.doTickIdle=function(){var p,v,h=this.hls,x=this.levelLastLoaded,S=this.levels,C=this.media,O=h.config,P=h.nextLoadLevel;if(!(x===null||!C&&(this.startFragRequested||!O.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!S||!S[P])){var w=S[P];this.level=h.nextLoadLevel=P;var U=w.details;if(!U||this.state===i.State.WAITING_LEVEL||U.live&&this.levelLastLoaded!==P){this.state=i.State.WAITING_LEVEL;return}var k=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:C,_.PlaylistLevelType.MAIN);if(k!==null){var N=k.len,B=this.getMaxBufferLength(w.maxBitrate);if(!(N>=B)){if(this._streamEnded(k,U)){var K={};this.altAudio&&(K.type="video"),this.hls.trigger(R.Events.BUFFER_EOS,K),this.state=i.State.ENDED;return}var H=k.end,F=this.getNextFragment(H,U);if(this.couldBacktrack&&!this.fragPrevious&&F&&F.sn!=="initSegment"){var W=F.sn-U.startSN;W>1&&(F=U.fragments[W-1],this.fragmentTracker.removeFragment(F))}if(F&&this.fragmentTracker.getState(F)===L.FragmentState.OK&&this.nextLoadPosition>H){var Y=this.audioOnly&&!this.altAudio?y.ElementaryStreamTypes.AUDIO:y.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(C,Y,_.PlaylistLevelType.MAIN),F=this.getNextFragment(this.nextLoadPosition,U)}!F||(F.initSegment&&!F.initSegment.data&&!this.bitrateTest&&(F=F.initSegment),((p=F.decryptdata)===null||p===void 0?void 0:p.keyFormat)==="identity"&&!((v=F.decryptdata)!==null&&v!==void 0&&v.key)?this.loadKey(F,U):this.loadFragment(F,U,H))}}}},g.loadFragment=function(p,v,h){var x,S=this.fragmentTracker.getState(p);if(this.fragCurrent=p,S===L.FragmentState.BACKTRACKED){var C=this.fragmentTracker.getBacktrackData(p);if(C){this._handleFragmentLoadProgress(C),this._handleFragmentLoadComplete(C);return}else S=L.FragmentState.NOT_LOADED}S===L.FragmentState.NOT_LOADED||S===L.FragmentState.PARTIAL?p.sn==="initSegment"?this._loadInitSegment(p):this.bitrateTest?(p.bitrateTest=!0,this.log("Fragment "+p.sn+" of level "+p.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(p)):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,p,v,h)):S===L.FragmentState.APPENDING?this.reduceMaxBufferLength(p.duration)&&this.fragmentTracker.removeFragment(p):((x=this.media)===null||x===void 0?void 0:x.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},g.getAppendedFrag=function(p){var v=this.fragmentTracker.getAppendedFrag(p,_.PlaylistLevelType.MAIN);return v&&"fragment"in v?v.fragment:v},g.getBufferedFrag=function(p){return this.fragmentTracker.getBufferedFrag(p,_.PlaylistLevelType.MAIN)},g.followingBufferedFrag=function(p){return p?this.getBufferedFrag(p.end+.5):null},g.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},g.nextLevelSwitch=function(){var p=this.levels,v=this.media;if(v!=null&&v.readyState){var h,x=this.getAppendedFrag(v.currentTime);if(x&&x.start>1&&this.flushMainBuffer(0,x.start-1),!v.paused&&p){var S=this.hls.nextLoadLevel,C=p[S],O=this.fragLastKbps;O&&this.fragCurrent?h=this.fragCurrent.duration*C.maxBitrate/(1e3*O)+1:h=0}else h=0;var P=this.getBufferedFrag(v.currentTime+h);if(P){var w=this.followingBufferedFrag(P);if(w){this.abortCurrentFrag();var U=w.maxStartPTS?w.maxStartPTS:w.start,k=w.duration,N=Math.max(P.end,U+Math.min(Math.max(k-this.config.maxFragLookUpTolerance,k*.5),k*.75));this.flushMainBuffer(N,Number.POSITIVE_INFINITY)}}}},g.abortCurrentFrag=function(){var p=this.fragCurrent;this.fragCurrent=null,p!=null&&p.loader&&p.loader.abort(),this.state===i.State.KEY_LOADING&&(this.state=i.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},g.flushMainBuffer=function(p,v){l.prototype.flushMainBuffer.call(this,p,v,this.altAudio?"video":null)},g.onMediaAttached=function(p,v){l.prototype.onMediaAttached.call(this,p,v);var h=v.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),h.addEventListener("playing",this.onvplaying),h.addEventListener("seeked",this.onvseeked),this.gapController=new D.default(this.config,h,this.fragmentTracker,this.hls)},g.onMediaDetaching=function(){var p=this.media;p&&(p.removeEventListener("playing",this.onvplaying),p.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),l.prototype.onMediaDetaching.call(this)},g.onMediaPlaying=function(){this.tick()},g.onMediaSeeked=function(){var p=this.media,v=p?p.currentTime:null;Object(a.isFiniteNumber)(v)&&this.log("Media seeked to "+v.toFixed(3)),this.tick()},g.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},g.onManifestParsed=function(p,v){var h=!1,x=!1,S;v.levels.forEach(function(C){S=C.audioCodec,S&&(S.indexOf("mp4a.40.2")!==-1&&(h=!0),S.indexOf("mp4a.40.5")!==-1&&(x=!0))}),this.audioCodecSwitch=h&&x&&!Object(c.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=v.levels,this.startFragRequested=!1},g.onLevelLoading=function(p,v){var h=this.levels;if(!(!h||this.state!==i.State.IDLE)){var x=h[v.level];(!x.details||x.details.live&&this.levelLastLoaded!==v.level||this.waitForCdnTuneIn(x.details))&&(this.state=i.State.WAITING_LEVEL)}},g.onLevelLoaded=function(p,v){var h,x=this.levels,S=v.level,C=v.details,O=C.totalduration;if(!x){this.warn("Levels were reset while loading level "+S);return}this.log("Level "+S+" loaded ["+C.startSN+","+C.endSN+"], cc ["+C.startCC+", "+C.endCC+"] duration:"+O);var P=this.fragCurrent;P&&(this.state===i.State.FRAG_LOADING||this.state===i.State.FRAG_LOADING_WAITING_RETRY)&&P.level!==v.level&&P.loader&&(this.state=i.State.IDLE,P.loader.abort());var w=x[S],U=0;if(C.live||(h=w.details)!==null&&h!==void 0&&h.live){if(C.fragments[0]||(C.deltaUpdateFailed=!0),C.deltaUpdateFailed)return;U=this.alignPlaylists(C,w.details)}if(w.details=C,this.levelLastLoaded=S,this.hls.trigger(R.Events.LEVEL_UPDATED,{details:C,level:S}),this.state===i.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(C))return;this.state=i.State.IDLE}this.startFragRequested?C.live&&this.synchronizeToLiveEdge(C):this.setStartPosition(C,U),this.tick()},g._handleFragmentLoadProgress=function(p){var v,h=p.frag,x=p.part,S=p.payload,C=this.levels;if(!C){this.warn("Levels were reset while fragment load was in progress. Fragment "+h.sn+" of level "+h.level+" will not be buffered");return}var O=C[h.level],P=O.details;if(!P){this.warn("Dropping fragment "+h.sn+" of level "+h.level+" after level details were reset");return}var w=O.videoCodec,U=P.PTSKnown||!P.live,k=(v=h.initSegment)===null||v===void 0?void 0:v.data,N=this._getAudioCodec(O),B=this.transmuxer=this.transmuxer||new I.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),K=x?x.index:-1,H=K!==-1,F=new M.ChunkMetadata(h.level,h.sn,h.stats.chunkCount,S.byteLength,K,H),W=this.initPTS[h.cc];B.push(S,k,N,w,h,x,P.totalduration,U,F,W)},g.onAudioTrackSwitching=function(p,v){var h=this.altAudio,x=!!v.url,S=v.id;if(!x){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var C=this.fragCurrent;C!=null&&C.loader&&(this.log("Switching to main audio track, cancel main fragment load"),C.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var O=this.hls;h&&O.trigger(R.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),O.trigger(R.Events.AUDIO_TRACK_SWITCHED,{id:S})}},g.onAudioTrackSwitched=function(p,v){var h=v.id,x=!!this.hls.audioTracks[h].url;if(x){var S=this.videoBuffer;S&&this.mediaBuffer!==S&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=S)}this.altAudio=x,this.tick()},g.onBufferCreated=function(p,v){var h=v.tracks,x,S,C=!1;for(var O in h){var P=h[O];if(P.id==="main"){if(S=O,x=P,O==="video"){var w=h[O];w&&(this.videoBuffer=w.buffer)}}else C=!0}C&&x?(this.log("Alternate track found, use "+S+".buffered to schedule main fragment loading"),this.mediaBuffer=x.buffer):this.mediaBuffer=this.media},g.onFragBuffered=function(p,v){var h=v.frag,x=v.part;if(!(h&&h.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(h)){this.warn("Fragment "+h.sn+(x?" p: "+x.index:"")+" of level "+h.level+" finished buffering, but was aborted. state: "+this.state),this.state===i.State.PARSED&&(this.state=i.State.IDLE);return}var S=x?x.stats:h.stats;this.fragLastKbps=Math.round(8*S.total/(S.buffering.end-S.loading.first)),h.sn!=="initSegment"&&(this.fragPrevious=h),this.fragBufferedComplete(h,x)}},g.onError=function(p,v){switch(v.details){case b.ErrorDetails.FRAG_LOAD_ERROR:case b.ErrorDetails.FRAG_LOAD_TIMEOUT:case b.ErrorDetails.KEY_LOAD_ERROR:case b.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,v);break;case b.ErrorDetails.LEVEL_LOAD_ERROR:case b.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==i.State.ERROR&&(v.fatal?(this.warn(""+v.details),this.state=i.State.ERROR):!v.levelRetry&&this.state===i.State.WAITING_LEVEL&&(this.state=i.State.IDLE));break;case b.ErrorDetails.BUFFER_FULL_ERROR:if(v.parent==="main"&&(this.state===i.State.PARSING||this.state===i.State.PARSED)){var h=!0,x=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);x&&x.len>.5&&(h=!this.reduceMaxBufferLength(x.len)),h&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},g.checkBuffer=function(){var p=this.media,v=this.gapController;if(!(!p||!v||!p.readyState)){var h=E.BufferHelper.getBuffered(p);!this.loadedmetadata&&h.length?(this.loadedmetadata=!0,this.seekToStartPos()):v.poll(this.lastCurrentTime),this.lastCurrentTime=p.currentTime}},g.onFragLoadEmergencyAborted=function(){this.state=i.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},g.onBufferFlushed=function(p,v){var h=v.type;if(h!==y.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var x=(h===y.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(x,h,_.PlaylistLevelType.MAIN)}},g.onLevelsUpdated=function(p,v){this.levels=v.levels},g.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},g.seekToStartPos=function(){var p=this.media,v=p.currentTime,h=this.startPosition;if(h>=0&&v<h){if(p.seeking){A.logger.log("could not seek to "+h+", already seeking at "+v);return}var x=E.BufferHelper.getBuffered(p),S=x.length?x.start(0):0,C=S-h;C>0&&(C<this.config.maxBufferHole||C<this.config.maxFragLookUpTolerance)&&(A.logger.log("adjusting start position by "+C+" to match buffer start"),h+=C,this.startPosition=h),this.log("seek to target start position "+h+" from current time "+v),p.currentTime=h}},g._getAudioCodec=function(p){var v=this.config.defaultAudioCodec||p.audioCodec;return this.audioCodecSwap&&v&&(this.log("Swapping audio codec"),v.indexOf("mp4a.40.5")!==-1?v="mp4a.40.2":v="mp4a.40.5"),v},g._loadBitrateTestFrag=function(p){var v=this;this._doFragLoad(p).then(function(h){var x=v.hls;if(!(!h||x.nextLoadLevel||v.fragContextChanged(p))){v.fragLoadError=0,v.state=i.State.IDLE,v.startFragRequested=!1,v.bitrateTest=!1;var S=p.stats;S.parsing.start=S.parsing.end=S.buffering.start=S.buffering.end=self.performance.now(),x.trigger(R.Events.FRAG_LOADED,h)}})},g._handleTransmuxComplete=function(p){var v,h="main",x=this.hls,S=p.remuxResult,C=p.chunkMeta,O=this.getCurrentContext(C);if(!O){this.warn("The loading context changed while buffering fragment "+C.sn+" of level "+C.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(C.level);return}var P=O.frag,w=O.part,U=O.level,k=S.video,N=S.text,B=S.id3,K=S.initSegment,H=this.altAudio?void 0:S.audio;if(!this.fragContextChanged(P)){if(this.state=i.State.PARSING,K){K.tracks&&(this._bufferInitSegment(U,K.tracks,P,C),x.trigger(R.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:h,tracks:K.tracks}));var F=K.initPTS,W=K.timescale;Object(a.isFiniteNumber)(F)&&(this.initPTS[P.cc]=F,x.trigger(R.Events.INIT_PTS_FOUND,{frag:P,id:h,initPTS:F,timescale:W}))}if(k&&S.independent!==!1){if(U.details){var Y=k.startPTS,$=k.endPTS,J=k.startDTS,q=k.endDTS;if(w)w.elementaryStreams[k.type]={startPTS:Y,endPTS:$,startDTS:J,endDTS:q};else if(k.firstKeyFrame&&k.independent&&(this.couldBacktrack=!0),k.dropped&&k.independent){var oe=this.getLoadPosition()+this.config.maxBufferHole;if(oe<Y){this.backtrack(P);return}P.setElementaryStreamInfo(k.type,P.start,$,P.start,q,!0)}P.setElementaryStreamInfo(k.type,Y,$,J,q),this.bufferFragmentData(k,P,w,C)}}else if(S.independent===!1){this.backtrack(P);return}if(H){var X=H.startPTS,ie=H.endPTS,fe=H.startDTS,ue=H.endDTS;w&&(w.elementaryStreams[y.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:ie,startDTS:fe,endDTS:ue}),P.setElementaryStreamInfo(y.ElementaryStreamTypes.AUDIO,X,ie,fe,ue),this.bufferFragmentData(H,P,w,C)}if(B!=null&&(v=B.samples)!==null&&v!==void 0&&v.length){var _e={frag:P,id:h,samples:B.samples};x.trigger(R.Events.FRAG_PARSING_METADATA,_e)}if(N){var re={frag:P,id:h,samples:N.samples};x.trigger(R.Events.FRAG_PARSING_USERDATA,re)}}},g._bufferInitSegment=function(p,v,h,x){var S=this;if(this.state===i.State.PARSING){this.audioOnly=!!v.audio&&!v.video,this.altAudio&&!this.audioOnly&&delete v.audio;var C=v.audio,O=v.video,P=v.audiovideo;if(C){var w=p.audioCodec,U=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(w&&(w.indexOf("mp4a.40.5")!==-1?w="mp4a.40.2":w="mp4a.40.5"),C.metadata.channelCount!==1&&U.indexOf("firefox")===-1&&(w="mp4a.40.5")),U.indexOf("android")!==-1&&C.container!=="audio/mpeg"&&(w="mp4a.40.2",this.log("Android: force audio codec to "+w)),p.audioCodec&&p.audioCodec!==w&&this.log('Swapping manifest audio codec "'+p.audioCodec+'" for "'+w+'"'),C.levelCodec=w,C.id="main",this.log("Init audio buffer, container:"+C.container+", codecs[selected/level/parsed]=["+(w||"")+"/"+(p.audioCodec||"")+"/"+C.codec+"]")}O&&(O.levelCodec=p.videoCodec,O.id="main",this.log("Init video buffer, container:"+O.container+", codecs[level/parsed]=["+(p.videoCodec||"")+"/"+O.codec+"]")),P&&this.log("Init audiovideo buffer, container:"+P.container+", codecs[level/parsed]=["+(p.attrs.CODECS||"")+"/"+P.codec+"]"),this.hls.trigger(R.Events.BUFFER_CODECS,v),Object.keys(v).forEach(function(k){var N=v[k],B=N.initSegment;B!=null&&B.byteLength&&S.hls.trigger(R.Events.BUFFER_APPENDING,{type:k,data:B,frag:h,part:null,chunkMeta:x,parent:h.type})}),this.tick()}},g.backtrack=function(p){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(p);var v=this.fragmentTracker.backtrack(p);this.fragPrevious=null,this.nextLoadPosition=p.start,v?this.resetFragmentLoading(p):this.state=i.State.BACKTRACKING},g.checkFragmentChanged=function(){var p=this.media,v=null;if(p&&p.readyState>1&&p.seeking===!1){var h=p.currentTime;if(E.BufferHelper.isBuffered(p,h)?v=this.getAppendedFrag(h):E.BufferHelper.isBuffered(p,h+.1)&&(v=this.getAppendedFrag(h+.1)),v){var x=this.fragPlaying,S=v.level;(!x||v.sn!==x.sn||x.level!==S||v.urlId!==x.urlId)&&(this.hls.trigger(R.Events.FRAG_CHANGED,{frag:v}),(!x||x.level!==S)&&this.hls.trigger(R.Events.LEVEL_SWITCHED,{level:S}),this.fragPlaying=v)}}},r(T,[{key:"nextLevel",get:function(){var p=this.nextBufferedFrag;return p?p.level:-1}},{key:"currentLevel",get:function(){var p=this.media;if(p){var v=this.getAppendedFrag(p.currentTime);if(v)return v.level}return-1}},{key:"nextBufferedFrag",get:function(){var p=this.media;if(p){var v=this.getAppendedFrag(p.currentTime);return this.followingBufferedFrag(v)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),T}(i.default)},"./src/controller/subtitle-stream-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"SubtitleStreamController",function(){return r});var a=t("./src/events.ts"),i=t("./src/utils/buffer-helper.ts"),c=t("./src/controller/fragment-finders.ts"),R=t("./src/utils/discontinuities.ts"),E=t("./src/controller/level-helper.ts"),L=t("./src/controller/fragment-tracker.ts"),_=t("./src/controller/base-stream-controller.ts"),y=t("./src/types/loader.ts"),I=t("./src/types/level.ts");function M(o,n){for(var s=0;s<n.length;s++){var d=n[s];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(o,d.key,d)}}function D(o,n,s){return n&&M(o.prototype,n),s&&M(o,s),o}function b(o,n){o.prototype=Object.create(n.prototype),o.prototype.constructor=o,A(o,n)}function A(o,n){return A=Object.setPrototypeOf||function(d,l){return d.__proto__=l,d},A(o,n)}var u=500,r=function(o){b(n,o);function n(d,l){var T;return T=o.call(this,d,l,"[subtitle-stream-controller]")||this,T.levels=[],T.currentTrackId=-1,T.tracksBuffered=[],T.mainDetails=null,T._registerListeners(),T}var s=n.prototype;return s.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},s._registerListeners=function(){var l=this.hls;l.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(a.Events.ERROR,this.onError,this),l.on(a.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(a.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.on(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.on(a.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.on(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},s._unregisterListeners=function(){var l=this.hls;l.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),l.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(a.Events.ERROR,this.onError,this),l.off(a.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(a.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),l.off(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),l.off(a.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),l.off(a.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},s.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(u),this.tick()},s.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},s.onLevelLoaded=function(l,T){this.mainDetails=T.details},s.onSubtitleFragProcessed=function(l,T){var g=T.frag,m=T.success;if(this.fragPrevious=g,this.state=_.State.IDLE,!!m){var p=this.tracksBuffered[this.currentTrackId];if(!!p){for(var v,h=g.start,x=0;x<p.length;x++)if(h>=p[x].start&&h<=p[x].end){v=p[x];break}var S=g.start+g.duration;v?v.end=S:(v={start:h,end:S},p.push(v)),this.fragmentTracker.fragBuffered(g)}}},s.onBufferFlushing=function(l,T){var g=T.startOffset,m=T.endOffset;if(g===0&&m!==Number.POSITIVE_INFINITY){var p=this.currentTrackId,v=this.levels;if(!v.length||!v[p]||!v[p].details)return;var h=v[p].details,x=h.targetduration,S=m-x;if(S<=0)return;T.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(C){for(var O=0;O<C.length;){if(C[O].end<=S){C.shift();continue}else if(C[O].start<S)C[O].start=S;else break;O++}}),this.fragmentTracker.removeFragmentsInRange(g,S,y.PlaylistLevelType.SUBTITLE)}},s.onError=function(l,T){var g,m=T.frag;!m||m.type!==y.PlaylistLevelType.SUBTITLE||((g=this.fragCurrent)!==null&&g!==void 0&&g.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},s.onSubtitleTracksUpdated=function(l,T){var g=this,m=T.subtitleTracks;this.tracksBuffered=[],this.levels=m.map(function(p){return new I.Level(p)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(p){g.tracksBuffered[p.id]=[]}),this.mediaBuffer=null},s.onSubtitleTrackSwitch=function(l,T){if(this.currentTrackId=T.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var g=this.levels[this.currentTrackId];g!=null&&g.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,g&&this.setInterval(u)},s.onSubtitleTrackLoaded=function(l,T){var g,m=T.details,p=T.id,v=this.currentTrackId,h=this.levels;if(!!h.length){var x=h[v];if(!(p>=h.length||p!==v||!x)){if(this.mediaBuffer=this.mediaBufferTimeRanges,m.live||(g=x.details)!==null&&g!==void 0&&g.live){var S=this.mainDetails;if(m.deltaUpdateFailed||!S)return;var C=S.fragments[0];if(!x.details)m.hasProgramDateTime&&S.hasProgramDateTime?Object(R.alignMediaPlaylistByPDT)(m,S):C&&Object(E.addSliding)(m,C.start);else{var O=this.alignPlaylists(m,x.details);O===0&&C&&Object(E.addSliding)(m,C.start)}}if(x.details=m,this.levelLastLoaded=p,this.tick(),m.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var P=Object(c.findFragmentByPTS)(null,m.fragments,this.media.currentTime,0);P||(this.warn("Subtitle playlist not aligned with playback"),x.details=void 0)}}}},s._handleFragmentLoadComplete=function(l){var T=l.frag,g=l.payload,m=T.decryptdata,p=this.hls;if(!this.fragContextChanged(T)&&g&&g.byteLength>0&&m&&m.key&&m.iv&&m.method==="AES-128"){var v=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(g),m.key.buffer,m.iv.buffer).then(function(h){var x=performance.now();p.trigger(a.Events.FRAG_DECRYPTED,{frag:T,payload:h,stats:{tstart:v,tdecrypt:x}})})}},s.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var l,T=this.currentTrackId,g=this.levels;if(!g.length||!g[T]||!g[T].details)return;var m=g[T].details,p=m.targetduration,v=this.config,h=this.media,x=i.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,h.currentTime-p,v.maxBufferHole),S=x.end,C=x.len,O=this.getMaxBufferLength()+p;if(C>O)return;console.assert(m,"Subtitle track details are defined on idle subtitle stream controller tick");var P=m.fragments,w=P.length,U=m.edge,k,N=this.fragPrevious;if(S<U){var B=v.maxFragLookUpTolerance;k=Object(c.findFragmentByPTS)(N,P,S,B),!k&&N&&N.start<P[0].start&&(k=P[0])}else k=P[w-1];(l=k)!==null&&l!==void 0&&l.encrypted?this.loadKey(k,m):k&&this.fragmentTracker.getState(k)===L.FragmentState.NOT_LOADED&&this.loadFragment(k,m,S)}},s.loadFragment=function(l,T,g){this.fragCurrent=l,o.prototype.loadFragment.call(this,l,T,g)},D(n,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),n}(_.default)},"./src/controller/subtitle-track-controller.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/events.ts"),i=t("./src/utils/texttrack-utils.ts"),c=t("./src/controller/base-playlist-controller.ts"),R=t("./src/types/loader.ts");function E(D,b){for(var A=0;A<b.length;A++){var u=b[A];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(D,u.key,u)}}function L(D,b,A){return b&&E(D.prototype,b),A&&E(D,A),D}function _(D,b){D.prototype=Object.create(b.prototype),D.prototype.constructor=D,y(D,b)}function y(D,b){return y=Object.setPrototypeOf||function(u,r){return u.__proto__=r,u},y(D,b)}var I=function(D){_(b,D);function b(u){var r;return r=D.call(this,u,"[subtitle-track-controller]")||this,r.media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}var A=b.prototype;return A.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,D.prototype.destroy.call(this)},A.registerListeners=function(){var r=this.hls;r.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(a.Events.ERROR,this.onError,this)},A.unregisterListeners=function(){var r=this.hls;r.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(a.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(a.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(a.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(a.Events.ERROR,this.onError,this)},A.onMediaAttached=function(r,o){this.media=o.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))},A.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},A.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 r=M(this.media.textTracks);r.forEach(function(o){Object(i.clearCurrentCues)(o)}),this.subtitleTrack=-1,this.media=null}},A.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},A.onManifestParsed=function(r,o){this.tracks=o.subtitleTracks},A.onSubtitleTrackLoaded=function(r,o){var n=o.id,s=o.details,d=this.trackId,l=this.tracksInGroup[d];if(!l){this.warn("Invalid subtitle track id "+n);return}var T=l.details;l.details=o.details,this.log("subtitle track "+n+" loaded ["+s.startSN+"-"+s.endSN+"]"),n===this.trackId&&(this.retryCount=0,this.playlistLoaded(n,o,T))},A.onLevelLoading=function(r,o){this.switchLevel(o.level)},A.onLevelSwitching=function(r,o){this.switchLevel(o.level)},A.switchLevel=function(r){var o=this.hls.levels[r];if(!!(o!=null&&o.textGroupIds)){var n=o.textGroupIds[o.urlId];if(this.groupId!==n){var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,d=this.tracks.filter(function(g){return!n||g.groupId===n});this.tracksInGroup=d;var l=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=n;var T={subtitleTracks:d};this.log("Updating subtitle tracks, "+d.length+' track(s) found in "'+n+'" group-id'),this.hls.trigger(a.Events.SUBTITLE_TRACKS_UPDATED,T),l!==-1&&this.setSubtitleTrack(l,s)}}},A.findTrackId=function(r){for(var o=this.tracksInGroup,n=0;n<o.length;n++){var s=o[n];if((!this.selectDefaultTrack||s.default)&&(!r||r===s.name))return s.id}return-1},A.onError=function(r,o){D.prototype.onError.call(this,r,o),!(o.fatal||!o.context)&&o.context.type===R.PlaylistContextType.SUBTITLE_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},A.loadPlaylist=function(r){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var n=o.id,s=o.groupId,d=o.url;if(r)try{d=r.addDirectives(d)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("Loading subtitle playlist for id "+n),this.hls.trigger(a.Events.SUBTITLE_TRACK_LOADING,{url:d,id:n,groupId:s,deliveryDirectives:r||null})}},A.toggleTrackModes=function(r){var o=this,n=this.media,s=this.subtitleDisplay,d=this.trackId;if(!!n){var l=M(n.textTracks),T=l.filter(function(p){return p.groupId===o.groupId});if(r===-1)[].slice.call(l).forEach(function(p){p.mode="disabled"});else{var g=T[d];g&&(g.mode="disabled")}var m=T[r];m&&(m.mode=s?"showing":"hidden")}},A.setSubtitleTrack=function(r,o){var n,s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=r;return}if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(n=s[r])!==null&&n!==void 0&&n.details)||r<-1||r>=s.length)){this.clearTimer();var d=s[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,d){var l=d.id,T=d.groupId,g=T===void 0?"":T,m=d.name,p=d.type,v=d.url;this.hls.trigger(a.Events.SUBTITLE_TRACK_SWITCH,{id:l,groupId:g,name:m,type:p,url:v});var h=this.switchParams(d.url,o==null?void 0:o.details);this.loadPlaylist(h)}else this.hls.trigger(a.Events.SUBTITLE_TRACK_SWITCH,{id:r})}},A.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var r=-1,o=M(this.media.textTracks),n=0;n<o.length;n++)if(o[n].mode==="hidden")r=n;else if(o[n].mode==="showing"){r=n;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},L(b,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,o)}}]),b}(c.default);function M(D){for(var b=[],A=0;A<D.length;A++){var u=D[A];u.kind==="subtitles"&&u.label&&b.push(D[A])}return b}e.default=I},"./src/controller/timeline-controller.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"TimelineController",function(){return M});var a=t("./src/polyfills/number.ts"),i=t("./src/events.ts"),c=t("./src/utils/cea-608-parser.ts"),R=t("./src/utils/output-filter.ts"),E=t("./src/utils/webvtt-parser.ts"),L=t("./src/utils/texttrack-utils.ts"),_=t("./src/utils/imsc1-ttml-parser.ts"),y=t("./src/types/loader.ts"),I=t("./src/utils/logger.ts"),M=function(){function u(o){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=o,this.config=o.config,this.Cues=o.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 R.default(this,"textTrack1"),s=new R.default(this,"textTrack2"),d=new R.default(this,"textTrack3"),l=new R.default(this,"textTrack4");this.cea608Parser1=new c.default(1,n,s),this.cea608Parser2=new c.default(3,d,l)}o.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),o.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(i.Events.FRAG_LOADING,this.onFragLoading,this),o.on(i.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(i.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),o.on(i.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),o.on(i.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.on(i.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),o.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var r=u.prototype;return r.destroy=function(){var n=this.hls;n.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(i.Events.FRAG_LOADING,this.onFragLoading,this),n.off(i.Events.FRAG_LOADED,this.onFragLoaded,this),n.off(i.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.off(i.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.off(i.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(i.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},r.addCues=function(n,s,d,l,T){for(var g=!1,m=T.length;m--;){var p=T[m],v=b(p[0],p[1],s,d);if(v>=0&&(p[0]=Math.min(p[0],s),p[1]=Math.max(p[1],d),g=!0,v/(d-s)>.5))return}if(g||T.push([s,d]),this.config.renderTextTracksNatively){var h=this.captionsTracks[n];this.Cues.newCue(h,s,d,l)}else{var x=this.Cues.newCue(null,s,d,l);this.hls.trigger(i.Events.CUES_PARSED,{type:"captions",cues:x,track:n})}},r.onInitPtsFound=function(n,s){var d=this,l=s.frag,T=s.id,g=s.initPTS,m=s.timescale,p=this.unparsedVttFrags;T==="main"&&(this.initPTS[l.cc]=g,this.timescale[l.cc]=m),p.length&&(this.unparsedVttFrags=[],p.forEach(function(v){d.onFragLoaded(i.Events.FRAG_LOADED,v)}))},r.getExistingTrack=function(n){var s=this.media;if(s)for(var d=0;d<s.textTracks.length;d++){var l=s.textTracks[d];if(l[n])return l}return null},r.createCaptionsTrack=function(n){this.config.renderTextTracksNatively?this.createNativeTrack(n):this.createNonNativeTrack(n)},r.createNativeTrack=function(n){if(!this.captionsTracks[n]){var s=this.captionsProperties,d=this.captionsTracks,l=this.media,T=s[n],g=T.label,m=T.languageCode,p=this.getExistingTrack(n);if(p)d[n]=p,Object(L.clearCurrentCues)(d[n]),Object(L.sendAddTrackEvent)(d[n],l);else{var v=this.createTextTrack("captions",g,m);v&&(v[n]=!0,d[n]=v)}}},r.createNonNativeTrack=function(n){if(!this.nonNativeCaptionsTracks[n]){var s=this.captionsProperties[n];if(!!s){var d=s.label,l={_id:n,label:d,kind:"captions",default:s.media?!!s.media.default:!1,closedCaptions:s.media};this.nonNativeCaptionsTracks[n]=l,this.hls.trigger(i.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[l]})}}},r.createTextTrack=function(n,s,d){var l=this.media;if(!!l)return l.addTextTrack(n,s,d)},r.onMediaAttaching=function(n,s){this.media=s.media,this._cleanTracks()},r.onMediaDetaching=function(){var n=this.captionsTracks;Object.keys(n).forEach(function(s){Object(L.clearCurrentCues)(n[s]),delete n[s]}),this.nonNativeCaptionsTracks={}},r.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())},r._cleanTracks=function(){var n=this.media;if(!!n){var s=n.textTracks;if(s)for(var d=0;d<s.length;d++)Object(L.clearCurrentCues)(s[d])}},r.onSubtitleTracksUpdated=function(n,s){var d=this;this.textTracks=[];var l=s.subtitleTracks||[],T=l.some(function(v){return v.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||T&&this.config.enableIMSC1){var g=this.tracks&&l&&this.tracks.length===l.length;if(this.tracks=l||[],this.config.renderTextTracksNatively){var m=this.media?this.media.textTracks:[];this.tracks.forEach(function(v,h){var x;if(h<m.length){for(var S=null,C=0;C<m.length;C++)if(D(m[C],v)){S=m[C];break}S&&(x=S)}x?Object(L.clearCurrentCues)(x):(x=d.createTextTrack("subtitles",v.name,v.lang),x&&(x.mode="disabled")),x&&(x.groupId=v.groupId,d.textTracks.push(x))})}else if(!g&&this.tracks&&this.tracks.length){var p=this.tracks.map(function(v){return{label:v.name,kind:v.type.toLowerCase(),default:v.default,subtitleTrack:v}});this.hls.trigger(i.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:p})}}},r.onManifestLoaded=function(n,s){var d=this;this.config.enableCEA708Captions&&s.captions&&s.captions.forEach(function(l){var T=/(?:CC|SERVICE)([1-4])/.exec(l.instreamId);if(!!T){var g="textTrack"+T[1],m=d.captionsProperties[g];!m||(m.label=l.name,l.lang&&(m.languageCode=l.lang),m.media=l)}})},r.onFragLoading=function(n,s){var d=this.cea608Parser1,l=this.cea608Parser2,T=this.lastSn,g=this.lastPartIndex;if(!(!this.enabled||!(d&&l))&&s.frag.type===y.PlaylistLevelType.MAIN){var m,p,v=s.frag.sn,h=(m=s==null||(p=s.part)===null||p===void 0?void 0:p.index)!=null?m:-1;v===T+1||v===T&&h===g+1||(d.reset(),l.reset()),this.lastSn=v,this.lastPartIndex=h}},r.onFragLoaded=function(n,s){var d=s.frag,l=s.payload,T=this.initPTS,g=this.unparsedVttFrags;if(d.type===y.PlaylistLevelType.SUBTITLE)if(l.byteLength){if(!Object(a.isFiniteNumber)(T[d.cc])){g.push(s),T.length&&this.hls.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:new Error("Missing initial subtitle PTS")});return}var m=d.decryptdata,p="stats"in s;if(m==null||m.key==null||m.method!=="AES-128"||p){var v=this.tracks[d.level],h=this.vttCCs;h[d.cc]||(h[d.cc]={start:d.start,prevCC:this.prevCC,new:!0},this.prevCC=d.cc),v&&v.textCodec===_.IMSC1_CODEC?this._parseIMSC1(d,l):this._parseVTTs(d,l,h)}}else this.hls.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:new Error("Empty subtitle payload")})},r._parseIMSC1=function(n,s){var d=this,l=this.hls;Object(_.parseIMSC1)(s,this.initPTS[n.cc],this.timescale[n.cc],function(T){d._appendCues(T,n.level),l.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(T){I.logger.log("Failed to parse IMSC1: "+T),l.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:T})})},r._parseVTTs=function(n,s,d){var l=this,T=this.hls;Object(E.parseWebVTT)(s,this.initPTS[n.cc],this.timescale[n.cc],d,n.cc,n.start,function(g){l._appendCues(g,n.level),T.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},function(g){l._fallbackToIMSC1(n,s),I.logger.log("Failed to parse VTT cue: "+g),T.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:g})})},r._fallbackToIMSC1=function(n,s){var d=this,l=this.tracks[n.level];l.textCodec||Object(_.parseIMSC1)(s,this.initPTS[n.cc],this.timescale[n.cc],function(){l.textCodec=_.IMSC1_CODEC,d._parseIMSC1(n,s)},function(){l.textCodec="wvtt"})},r._appendCues=function(n,s){var d=this.hls;if(this.config.renderTextTracksNatively){var l=this.textTracks[s];if(l.mode==="disabled")return;n.forEach(function(m){return Object(L.addCueToTrack)(l,m)})}else{var T=this.tracks[s],g=T.default?"default":"subtitles"+s;d.trigger(i.Events.CUES_PARSED,{type:"subtitles",cues:n,track:g})}},r.onFragDecrypted=function(n,s){var d=s.frag;if(d.type===y.PlaylistLevelType.SUBTITLE){if(!Object(a.isFiniteNumber)(this.initPTS[d.cc])){this.unparsedVttFrags.push(s);return}this.onFragLoaded(i.Events.FRAG_LOADED,s)}},r.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},r.onFragParsingUserdata=function(n,s){var d=this.cea608Parser1,l=this.cea608Parser2;if(!(!this.enabled||!(d&&l)))for(var T=0;T<s.samples.length;T++){var g=s.samples[T].bytes;if(g){var m=this.extractCea608Data(g);d.addData(s.samples[T].pts,m[0]),l.addData(s.samples[T].pts,m[1])}}},r.onBufferFlushing=function(n,s){var d=s.startOffset,l=s.endOffset,T=s.endOffsetSubtitles,g=s.type,m=this.media;if(!(!m||m.currentTime<l)){if(!g||g==="video"){var p=this.captionsTracks;Object.keys(p).forEach(function(h){return Object(L.removeCuesInRange)(p[h],d,l)})}if(this.config.renderTextTracksNatively&&d===0&&T!==void 0){var v=this.textTracks;Object.keys(v).forEach(function(h){return Object(L.removeCuesInRange)(v[h],d,T)})}}},r.extractCea608Data=function(n){for(var s=n[0]&31,d=2,l=[[],[]],T=0;T<s;T++){var g=n[d++],m=127&n[d++],p=127&n[d++],v=(4&g)!=0,h=3&g;m===0&&p===0||v&&(h===0||h===1)&&(l[h].push(m),l[h].push(p))}return l},u}();function D(u,r){return u&&u.label===r.name&&!(u.textTrack1||u.textTrack2)}function b(u,r,o,n){return Math.min(r,n)-Math.max(u,o)}function A(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return a});var a=function(){function i(R,E){this.subtle=void 0,this.aesIV=void 0,this.subtle=R,this.aesIV=E}var c=i.prototype;return c.decrypt=function(E,L){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},L,E)},i}()},"./src/crypt/aes-decryptor.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"removePadding",function(){return i}),t.d(e,"default",function(){return c});var a=t("./src/utils/typed-array.ts");function i(R){var E=R.byteLength,L=E&&new DataView(R.buffer).getUint8(E-1);return L?Object(a.sliceUint8)(R,0,E-L):R}var c=function(){function R(){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 E=R.prototype;return E.uint8ArrayToUint32Array_=function(_){for(var y=new DataView(_),I=new Uint32Array(4),M=0;M<4;M++)I[M]=y.getUint32(M*4);return I},E.initTable=function(){var _=this.sBox,y=this.invSBox,I=this.subMix,M=I[0],D=I[1],b=I[2],A=I[3],u=this.invSubMix,r=u[0],o=u[1],n=u[2],s=u[3],d=new Uint32Array(256),l=0,T=0,g=0;for(g=0;g<256;g++)g<128?d[g]=g<<1:d[g]=g<<1^283;for(g=0;g<256;g++){var m=T^T<<1^T<<2^T<<3^T<<4;m=m>>>8^m&255^99,_[l]=m,y[m]=l;var p=d[l],v=d[p],h=d[v],x=d[m]*257^m*16843008;M[l]=x<<24|x>>>8,D[l]=x<<16|x>>>16,b[l]=x<<8|x>>>24,A[l]=x,x=h*16843009^v*65537^p*257^l*16843008,r[m]=x<<24|x>>>8,o[m]=x<<16|x>>>16,n[m]=x<<8|x>>>24,s[m]=x,l?(l=p^d[d[d[h^p]]],T^=d[d[T]]):l=T=1}},E.expandKey=function(_){for(var y=this.uint8ArrayToUint32Array_(_),I=!0,M=0;M<y.length&&I;)I=y[M]===this.key[M],M++;if(!I){this.key=y;var D=this.keySize=y.length;if(D!==4&&D!==6&&D!==8)throw new Error("Invalid aes key size="+D);var b=this.ksRows=(D+6+1)*4,A,u,r=this.keySchedule=new Uint32Array(b),o=this.invKeySchedule=new Uint32Array(b),n=this.sBox,s=this.rcon,d=this.invSubMix,l=d[0],T=d[1],g=d[2],m=d[3],p,v;for(A=0;A<b;A++){if(A<D){p=r[A]=y[A];continue}v=p,A%D==0?(v=v<<8|v>>>24,v=n[v>>>24]<<24|n[v>>>16&255]<<16|n[v>>>8&255]<<8|n[v&255],v^=s[A/D|0]<<24):D>6&&A%D==4&&(v=n[v>>>24]<<24|n[v>>>16&255]<<16|n[v>>>8&255]<<8|n[v&255]),r[A]=p=(r[A-D]^v)>>>0}for(u=0;u<b;u++)A=b-u,u&3?v=r[A]:v=r[A-4],u<4||A<=4?o[u]=v:o[u]=l[n[v>>>24]]^T[n[v>>>16&255]]^g[n[v>>>8&255]]^m[n[v&255]],o[u]=o[u]>>>0}},E.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},E.decrypt=function(_,y,I){for(var M=this.keySize+6,D=this.invKeySchedule,b=this.invSBox,A=this.invSubMix,u=A[0],r=A[1],o=A[2],n=A[3],s=this.uint8ArrayToUint32Array_(I),d=s[0],l=s[1],T=s[2],g=s[3],m=new Int32Array(_),p=new Int32Array(m.length),v,h,x,S,C,O,P,w,U,k,N,B,K,H,F=this.networkToHostOrderSwap;y<m.length;){for(U=F(m[y]),k=F(m[y+1]),N=F(m[y+2]),B=F(m[y+3]),C=U^D[0],O=B^D[1],P=N^D[2],w=k^D[3],K=4,H=1;H<M;H++)v=u[C>>>24]^r[O>>16&255]^o[P>>8&255]^n[w&255]^D[K],h=u[O>>>24]^r[P>>16&255]^o[w>>8&255]^n[C&255]^D[K+1],x=u[P>>>24]^r[w>>16&255]^o[C>>8&255]^n[O&255]^D[K+2],S=u[w>>>24]^r[C>>16&255]^o[O>>8&255]^n[P&255]^D[K+3],C=v,O=h,P=x,w=S,K=K+4;v=b[C>>>24]<<24^b[O>>16&255]<<16^b[P>>8&255]<<8^b[w&255]^D[K],h=b[O>>>24]<<24^b[P>>16&255]<<16^b[w>>8&255]<<8^b[C&255]^D[K+1],x=b[P>>>24]<<24^b[w>>16&255]<<16^b[C>>8&255]<<8^b[O&255]^D[K+2],S=b[w>>>24]<<24^b[C>>16&255]<<16^b[O>>8&255]<<8^b[P&255]^D[K+3],p[y]=F(v^d),p[y+1]=F(S^l),p[y+2]=F(x^T),p[y+3]=F(h^g),d=U,l=k,T=N,g=B,y=y+4}return p.buffer},R}()},"./src/crypt/decrypter.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return y});var a=t("./src/crypt/aes-crypto.ts"),i=t("./src/crypt/fast-aes-key.ts"),c=t("./src/crypt/aes-decryptor.ts"),R=t("./src/utils/logger.ts"),E=t("./src/utils/mp4-tools.ts"),L=t("./src/utils/typed-array.ts"),_=16,y=function(){function I(D,b,A){var u=A===void 0?{}:A,r=u.removePKCS7Padding,o=r===void 0?!0:r;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=D,this.config=b,this.removePKCS7Padding=o,o)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var M=I.prototype;return M.destroy=function(){this.observer=null},M.isSync=function(){return this.config.enableSoftwareAES},M.flush=function(){var b=this.currentResult;if(!b){this.reset();return}var A=new Uint8Array(b);return this.reset(),this.removePKCS7Padding?Object(c.removePadding)(A):A},M.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},M.decrypt=function(b,A,u,r){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(b),A,u);var o=this.flush();o&&r(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(b),A,u).then(r)},M.softwareDecrypt=function(b,A,u){var r=this.currentIV,o=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(b=Object(E.appendUint8Array)(n,b),this.remainderData=null);var s=this.getValidChunk(b);if(!s.length)return null;r&&(u=r);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new c.default),d.expandKey(A);var l=o;return this.currentResult=d.decrypt(s.buffer,0,u),this.currentIV=Object(L.sliceUint8)(s,-16).buffer,l||null},M.webCryptoDecrypt=function(b,A,u){var r=this,o=this.subtle;return(this.key!==A||!this.fastAesKey)&&(this.key=A,this.fastAesKey=new i.default(o,A)),this.fastAesKey.expandKey().then(function(n){if(!o)return Promise.reject(new Error("web crypto not initialized"));var s=new a.default(o,u);return s.decrypt(b.buffer,n)}).catch(function(n){return r.onWebCryptoError(n,b,A,u)})},M.onWebCryptoError=function(b,A,u,r){return R.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",b),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(A,u,r)},M.getValidChunk=function(b){var A=b,u=b.length-b.length%_;return u!==b.length&&(A=Object(L.sliceUint8)(b,0,u),this.remainderData=Object(L.sliceUint8)(b,u)),A},M.logOnce=function(b){!this.logEnabled||(R.logger.log("[decrypter.ts]: "+b),this.logEnabled=!1)},I}()},"./src/crypt/fast-aes-key.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return a});var a=function(){function i(R,E){this.subtle=void 0,this.key=void 0,this.subtle=R,this.key=E}var c=i.prototype;return c.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},i}()},"./src/demux/aacdemuxer.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/demux/base-audio-demuxer.ts"),i=t("./src/demux/adts.ts"),c=t("./src/utils/logger.ts"),R=t("./src/demux/id3.ts");function E(y,I){y.prototype=Object.create(I.prototype),y.prototype.constructor=y,L(y,I)}function L(y,I){return L=Object.setPrototypeOf||function(D,b){return D.__proto__=b,D},L(y,I)}var _=function(y){E(I,y);function I(D,b){var A;return A=y.call(this)||this,A.observer=void 0,A.config=void 0,A.observer=D,A.config=b,A}var M=I.prototype;return M.resetInitSegment=function(b,A,u){y.prototype.resetInitSegment.call(this,b,A,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:b,duration:u,inputTimeScale:9e4,dropped:0}},I.probe=function(b){if(!b)return!1;for(var A=R.getID3Data(b,0)||[],u=A.length,r=b.length;u<r;u++)if(i.probe(b,u))return c.logger.log("ADTS sync word found !"),!0;return!1},M.canParse=function(b,A){return i.canParse(b,A)},M.appendFrame=function(b,A,u){i.initTrackConfig(b,this.observer,A,u,b.manifestCodec);var r=i.appendFrame(b,A,u,this.initPTS,this.frameIndex);if(r&&r.missing===0)return r},I}(a.default);_.minProbeByteLength=9,e.default=_},"./src/demux/adts.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"getAudioConfig",function(){return R}),t.d(e,"isHeaderPattern",function(){return E}),t.d(e,"getHeaderLength",function(){return L}),t.d(e,"getFullFrameLength",function(){return _}),t.d(e,"canGetFrameLength",function(){return y}),t.d(e,"isHeader",function(){return I}),t.d(e,"canParse",function(){return M}),t.d(e,"probe",function(){return D}),t.d(e,"initTrackConfig",function(){return b}),t.d(e,"getFrameDuration",function(){return A}),t.d(e,"parseFrameHeader",function(){return u}),t.d(e,"appendFrame",function(){return r});var a=t("./src/utils/logger.ts"),i=t("./src/errors.ts"),c=t("./src/events.ts");function R(o,n,s,d){var l,T,g,m,p=navigator.userAgent.toLowerCase(),v=d,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];l=((n[s+2]&192)>>>6)+1;var x=(n[s+2]&60)>>>2;if(x>h.length-1){o.trigger(c.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+x});return}return g=(n[s+2]&1)<<2,g|=(n[s+3]&192)>>>6,a.logger.log("manifest codec:"+d+", ADTS type:"+l+", samplingIndex:"+x),/firefox/i.test(p)?x>=6?(l=5,m=new Array(4),T=x-3):(l=2,m=new Array(2),T=x):p.indexOf("android")!==-1?(l=2,m=new Array(2),T=x):(l=5,m=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&x>=6?T=x-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(x>=6&&g===1||/vivaldi/i.test(p))||!d&&g===1)&&(l=2,m=new Array(2)),T=x)),m[0]=l<<3,m[0]|=(x&14)>>1,m[1]|=(x&1)<<7,m[1]|=g<<3,l===5&&(m[1]|=(T&14)>>1,m[2]=(T&1)<<7,m[2]|=2<<2,m[3]=0),{config:m,samplerate:h[x],channelCount:g,codec:"mp4a.40."+l,manifestCodec:v}}function E(o,n){return o[n]===255&&(o[n+1]&246)==240}function L(o,n){return o[n+1]&1?7:9}function _(o,n){return(o[n+3]&3)<<11|o[n+4]<<3|(o[n+5]&224)>>>5}function y(o,n){return n+5<o.length}function I(o,n){return n+1<o.length&&E(o,n)}function M(o,n){return y(o,n)&&E(o,n)&&_(o,n)<=o.length-n}function D(o,n){if(I(o,n)){var s=L(o,n);if(n+s>=o.length)return!1;var d=_(o,n);if(d<=s)return!1;var l=n+d;return l===o.length||I(o,l)}return!1}function b(o,n,s,d,l){if(!o.samplerate){var T=R(n,s,d,l);if(!T)return;o.config=T.config,o.samplerate=T.samplerate,o.channelCount=T.channelCount,o.codec=T.codec,o.manifestCodec=T.manifestCodec,a.logger.log("parsed codec:"+o.codec+", rate:"+T.samplerate+", channels:"+T.channelCount)}}function A(o){return 1024*9e4/o}function u(o,n,s,d,l){var T=L(o,n),g=_(o,n);if(g-=T,g>0){var m=s+d*l;return{headerLength:T,frameLength:g,stamp:m}}}function r(o,n,s,d,l){var T=A(o.samplerate),g=u(n,s,d,l,T);if(g){var m=g.frameLength,p=g.headerLength,v=g.stamp,h=p+m,x=Math.max(0,s+h-n.length),S;x?(S=new Uint8Array(h-p),S.set(n.subarray(s+p,n.length),0)):S=n.subarray(s+p,s+h);var C={unit:S,pts:v};return x||o.samples.push(C),{sample:C,length:h,missing:x}}}},"./src/demux/base-audio-demuxer.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"initPTSFn",function(){return _});var a=t("./src/polyfills/number.ts"),i=t("./src/demux/id3.ts"),c=t("./src/demux/dummy-demuxed-track.ts"),R=t("./src/utils/mp4-tools.ts"),E=t("./src/utils/typed-array.ts"),L=function(){function y(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var I=y.prototype;return I.resetInitSegment=function(D,b,A){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},I.resetTimeStamp=function(){},I.resetContiguity=function(){},I.canParse=function(D,b){return!1},I.appendFrame=function(D,b,A){},I.demux=function(D,b){this.cachedData&&(D=Object(R.appendUint8Array)(this.cachedData,D),this.cachedData=null);var A=i.getID3Data(D,0),u=A?A.length:0,r,o,n=this._audioTrack,s=this._id3Track,d=A?i.getTimeStamp(A):void 0,l=D.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=_(d,b)),A&&A.length>0&&s.samples.push({pts:this.initPTS,dts:this.initPTS,data:A}),o=this.initPTS;u<l;){if(this.canParse(D,u)){var T=this.appendFrame(n,D,u);T?(this.frameIndex++,o=T.sample.pts,u+=T.length,r=u):u=l}else i.canParse(D,u)?(A=i.getID3Data(D,u),s.samples.push({pts:o,dts:o,data:A}),u+=A.length,r=u):u++;if(u===l&&r!==l){var g=Object(E.sliceUint8)(D,r);this.cachedData?this.cachedData=Object(R.appendUint8Array)(this.cachedData,g):this.cachedData=g}}return{audioTrack:n,avcTrack:Object(c.dummyTrack)(),id3Track:s,textTrack:Object(c.dummyTrack)()}},I.demuxSampleAes=function(D,b,A){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},I.flush=function(D){var b=this.cachedData;return b&&(this.cachedData=null,this.demux(b,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(c.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(c.dummyTrack)()}},I.destroy=function(){},y}(),_=function(I,M){return Object(a.isFiniteNumber)(I)?I*90:M*9e4};e.default=L},"./src/demux/chunk-cache.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return a});var a=function(){function c(){this.chunks=[],this.dataLength=0}var R=c.prototype;return R.push=function(L){this.chunks.push(L),this.dataLength+=L.length},R.flush=function(){var L=this.chunks,_=this.dataLength,y;if(L.length)L.length===1?y=L[0]:y=i(L,_);else return new Uint8Array(0);return this.reset(),y},R.reset=function(){this.chunks.length=0,this.dataLength=0},c}();function i(c,R){for(var E=new Uint8Array(R),L=0,_=0;_<c.length;_++){var y=c[_];E.set(y,L),L+=y.length}return E}},"./src/demux/dummy-demuxed-track.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"dummyTrack",function(){return a});function a(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/utils/logger.ts"),i=function(){function c(E){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=E,this.bytesAvailable=E.byteLength,this.word=0,this.bitsAvailable=0}var R=c.prototype;return R.loadWord=function(){var L=this.data,_=this.bytesAvailable,y=L.byteLength-_,I=new Uint8Array(4),M=Math.min(4,_);if(M===0)throw new Error("no bytes available");I.set(L.subarray(y,y+M)),this.word=new DataView(I.buffer).getUint32(0),this.bitsAvailable=M*8,this.bytesAvailable-=M},R.skipBits=function(L){var _;this.bitsAvailable>L?(this.word<<=L,this.bitsAvailable-=L):(L-=this.bitsAvailable,_=L>>3,L-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=L,this.bitsAvailable-=L)},R.readBits=function(L){var _=Math.min(this.bitsAvailable,L),y=this.word>>>32-_;return L>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=L-_,_>0&&this.bitsAvailable?y<<_|this.readBits(_):y},R.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()},R.skipUEG=function(){this.skipBits(1+this.skipLZ())},R.skipEG=function(){this.skipBits(1+this.skipLZ())},R.readUEG=function(){var L=this.skipLZ();return this.readBits(L+1)-1},R.readEG=function(){var L=this.readUEG();return 1&L?1+L>>>1:-1*(L>>>1)},R.readBoolean=function(){return this.readBits(1)===1},R.readUByte=function(){return this.readBits(8)},R.readUShort=function(){return this.readBits(16)},R.readUInt=function(){return this.readBits(32)},R.skipScalingList=function(L){for(var _=8,y=8,I,M=0;M<L;M++)y!==0&&(I=this.readEG(),y=(_+I+256)%256),_=y===0?_:y},R.readSPS=function(){var L=0,_=0,y=0,I=0,M,D,b,A=this.readUByte.bind(this),u=this.readBits.bind(this),r=this.readUEG.bind(this),o=this.readBoolean.bind(this),n=this.skipBits.bind(this),s=this.skipEG.bind(this),d=this.skipUEG.bind(this),l=this.skipScalingList.bind(this);A();var T=A();if(u(5),n(3),A(),d(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){var g=r();if(g===3&&n(1),d(),d(),n(1),o())for(D=g!==3?8:12,b=0;b<D;b++)o()&&(b<6?l(16):l(64))}d();var m=r();if(m===0)r();else if(m===1)for(n(1),s(),s(),M=r(),b=0;b<M;b++)s();d(),n(1);var p=r(),v=r(),h=u(1);h===0&&n(1),n(1),o()&&(L=r(),_=r(),y=r(),I=r());var x=[1,1];if(o()&&o()){var S=A();switch(S){case 1:x=[1,1];break;case 2:x=[12,11];break;case 3:x=[10,11];break;case 4:x=[16,11];break;case 5:x=[40,33];break;case 6:x=[24,11];break;case 7:x=[20,11];break;case 8:x=[32,11];break;case 9:x=[80,33];break;case 10:x=[18,11];break;case 11:x=[15,11];break;case 12:x=[64,33];break;case 13:x=[160,99];break;case 14:x=[4,3];break;case 15:x=[3,2];break;case 16:x=[2,1];break;case 255:{x=[A()<<8|A(),A()<<8|A()];break}}}return{width:Math.ceil((p+1)*16-L*2-_*2),height:(2-h)*(v+1)*16-(h?2:4)*(y+I),pixelRatio:x}},R.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},c}();e.default=i},"./src/demux/id3.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"isHeader",function(){return a}),t.d(e,"isFooter",function(){return i}),t.d(e,"getID3Data",function(){return c}),t.d(e,"canParse",function(){return E}),t.d(e,"getTimeStamp",function(){return L}),t.d(e,"isTimeStampFrame",function(){return _}),t.d(e,"getID3Frames",function(){return I}),t.d(e,"decodeFrame",function(){return M}),t.d(e,"utf8ArrayToStr",function(){return r}),t.d(e,"testables",function(){return o});var a=function(l,T){return T+10<=l.length&&l[T]===73&&l[T+1]===68&&l[T+2]===51&&l[T+3]<255&&l[T+4]<255&&l[T+6]<128&&l[T+7]<128&&l[T+8]<128&&l[T+9]<128},i=function(l,T){return T+10<=l.length&&l[T]===51&&l[T+1]===68&&l[T+2]===73&&l[T+3]<255&&l[T+4]<255&&l[T+6]<128&&l[T+7]<128&&l[T+8]<128&&l[T+9]<128},c=function(l,T){for(var g=T,m=0;a(l,T);){m+=10;var p=R(l,T+6);m+=p,i(l,T+10)&&(m+=10),T+=m}if(m>0)return l.subarray(g,g+m)},R=function(l,T){var g=0;return g=(l[T]&127)<<21,g|=(l[T+1]&127)<<14,g|=(l[T+2]&127)<<7,g|=l[T+3]&127,g},E=function(l,T){return a(l,T)&&R(l,T+6)+10<=l.length-T},L=function(l){for(var T=I(l),g=0;g<T.length;g++){var m=T[g];if(_(m))return u(m)}},_=function(l){return l&&l.key==="PRIV"&&l.info==="com.apple.streaming.transportStreamTimestamp"},y=function(l){var T=String.fromCharCode(l[0],l[1],l[2],l[3]),g=R(l,4),m=10;return{type:T,size:g,data:l.subarray(m,m+g)}},I=function(l){for(var T=0,g=[];a(l,T);){var m=R(l,T+6);T+=10;for(var p=T+m;T+8<p;){var v=y(l.subarray(T)),h=M(v);h&&g.push(h),T+=v.size+10}i(l,T)&&(T+=10)}return g},M=function(l){return l.type==="PRIV"?D(l):l.type[0]==="W"?A(l):b(l)},D=function(l){if(!(l.size<2)){var T=r(l.data,!0),g=new Uint8Array(l.data.subarray(T.length+1));return{key:l.type,info:T,data:g.buffer}}},b=function(l){if(!(l.size<2)){if(l.type==="TXXX"){var T=1,g=r(l.data.subarray(T),!0);T+=g.length+1;var m=r(l.data.subarray(T));return{key:l.type,info:g,data:m}}var p=r(l.data.subarray(1));return{key:l.type,data:p}}},A=function(l){if(l.type==="WXXX"){if(l.size<2)return;var T=1,g=r(l.data.subarray(T),!0);T+=g.length+1;var m=r(l.data.subarray(T));return{key:l.type,info:g,data:m}}var p=r(l.data);return{key:l.type,data:p}},u=function(l){if(l.data.byteLength===8){var T=new Uint8Array(l.data),g=T[3]&1,m=(T[4]<<23)+(T[5]<<15)+(T[6]<<7)+T[7];return m/=45,g&&(m+=4772185884e-2),Math.round(m)}},r=function(l,T){T===void 0&&(T=!1);var g=s();if(g){var m=g.decode(l);if(T){var p=m.indexOf("\0");return p!==-1?m.substring(0,p):m}return m.replace(/\0/g,"")}for(var v=l.length,h,x,S,C="",O=0;O<v;){if(h=l[O++],h===0&&T)return C;if(h===0||h===3)continue;switch(h>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:C+=String.fromCharCode(h);break;case 12:case 13:x=l[O++],C+=String.fromCharCode((h&31)<<6|x&63);break;case 14:x=l[O++],S=l[O++],C+=String.fromCharCode((h&15)<<12|(x&63)<<6|(S&63)<<0);break;default:}}return C},o={decodeTextFrame:b},n;function s(){return!n&&typeof self.TextDecoder!="undefined"&&(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/demux/base-audio-demuxer.ts"),i=t("./src/demux/id3.ts"),c=t("./src/utils/logger.ts"),R=t("./src/demux/mpegaudio.ts");function E(y,I){y.prototype=Object.create(I.prototype),y.prototype.constructor=y,L(y,I)}function L(y,I){return L=Object.setPrototypeOf||function(D,b){return D.__proto__=b,D},L(y,I)}var _=function(y){E(I,y);function I(){return y.apply(this,arguments)||this}var M=I.prototype;return M.resetInitSegment=function(b,A,u){y.prototype.resetInitSegment.call(this,b,A,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:b,duration:u,inputTimeScale:9e4,dropped:0}},I.probe=function(b){if(!b)return!1;for(var A=i.getID3Data(b,0)||[],u=A.length,r=b.length;u<r;u++)if(R.probe(b,u))return c.logger.log("MPEG Audio sync word found !"),!0;return!1},M.canParse=function(b,A){return R.canParse(b,A)},M.appendFrame=function(b,A,u){if(this.initPTS!==null)return R.appendFrame(b,A,u,this.initPTS,this.frameIndex)},I}(a.default);_.minProbeByteLength=4,e.default=_},"./src/demux/mp4demuxer.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/utils/mp4-tools.ts"),i=t("./src/demux/dummy-demuxed-track.ts"),c=function(){function R(L,_){this.remainderData=null,this.config=void 0,this.config=_}var E=R.prototype;return E.resetTimeStamp=function(){},E.resetInitSegment=function(){},E.resetContiguity=function(){},R.probe=function(_){return Object(a.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},E.demux=function(_){var y=_,I=Object(i.dummyTrack)();if(this.config.progressive){this.remainderData&&(y=Object(a.appendUint8Array)(this.remainderData,_));var M=Object(a.segmentValidRange)(y);this.remainderData=M.remainder,I.samples=M.valid||new Uint8Array}else I.samples=y;return{audioTrack:Object(i.dummyTrack)(),avcTrack:I,id3Track:Object(i.dummyTrack)(),textTrack:Object(i.dummyTrack)()}},E.flush=function(){var _=Object(i.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(i.dummyTrack)(),avcTrack:_,id3Track:Object(i.dummyTrack)(),textTrack:Object(i.dummyTrack)()}},E.demuxSampleAes=function(_,y,I){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},E.destroy=function(){},R}();c.minProbeByteLength=1024,e.default=c},"./src/demux/mpegaudio.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"appendFrame",function(){return L}),t.d(e,"parseHeader",function(){return _}),t.d(e,"isHeaderPattern",function(){return y}),t.d(e,"isHeader",function(){return I}),t.d(e,"canParse",function(){return M}),t.d(e,"probe",function(){return D});var a=null,i=[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],c=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],R=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],E=[0,1,1,4];function L(b,A,u,r,o){if(!(u+24>A.length)){var n=_(A,u);if(n&&u+n.frameLength<=A.length){var s=n.samplesPerFrame*9e4/n.sampleRate,d=r+o*s,l={unit:A.subarray(u,u+n.frameLength),pts:d,dts:d};return b.config=[],b.channelCount=n.channelCount,b.samplerate=n.sampleRate,b.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}}function _(b,A){var u=b[A+1]>>3&3,r=b[A+1]>>1&3,o=b[A+2]>>4&15,n=b[A+2]>>2&3;if(u!==1&&o!==0&&o!==15&&n!==3){var s=b[A+2]>>1&1,d=b[A+3]>>6,l=u===3?3-r:r===3?3:4,T=i[l*14+o-1]*1e3,g=u===3?0:u===2?1:2,m=c[g*3+n],p=d===3?1:2,v=R[u][r],h=E[r],x=v*8*h,S=Math.floor(v*T/m+s)*h;if(a===null){var C=navigator.userAgent||"",O=C.match(/Chrome\/(\d+)/i);a=O?parseInt(O[1]):0}var P=!!a&&a<=87;return P&&r===2&&T>=224e3&&d===0&&(b[A+3]=b[A+3]|128),{sampleRate:m,channelCount:p,frameLength:S,samplesPerFrame:x}}}function y(b,A){return b[A]===255&&(b[A+1]&224)==224&&(b[A+1]&6)!=0}function I(b,A){return A+1<b.length&&y(b,A)}function M(b,A){var u=4;return y(b,A)&&u<=b.length-A}function D(b,A){if(A+1<b.length&&y(b,A)){var u=4,r=_(b,A),o=u;r!=null&&r.frameLength&&(o=r.frameLength);var n=A+o;return n===b.length||I(b,n)}return!1}},"./src/demux/sample-aes.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/crypt/decrypter.ts"),i=t("./src/demux/tsdemuxer.ts"),c=function(){function R(L,_,y){this.keyData=void 0,this.decrypter=void 0,this.keyData=y,this.decrypter=new a.default(L,_,{removePKCS7Padding:!1})}var E=R.prototype;return E.decryptBuffer=function(_,y){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,y)},E.decryptAacSample=function(_,y,I,M){var D=_[y].unit,b=D.subarray(16,D.length-D.length%16),A=b.buffer.slice(b.byteOffset,b.byteOffset+b.length),u=this;this.decryptBuffer(A,function(r){var o=new Uint8Array(r);D.set(o,16),M||u.decryptAacSamples(_,y+1,I)})},E.decryptAacSamples=function(_,y,I){for(;;y++){if(y>=_.length){I();return}if(!(_[y].unit.length<32)){var M=this.decrypter.isSync();if(this.decryptAacSample(_,y,I,M),!M)return}}},E.getAvcEncryptedData=function(_){for(var y=Math.floor((_.length-48)/160)*16+16,I=new Int8Array(y),M=0,D=32;D<_.length-16;D+=160,M+=16)I.set(_.subarray(D,D+16),M);return I},E.getAvcDecryptedUnit=function(_,y){for(var I=new Uint8Array(y),M=0,D=32;D<_.length-16;D+=160,M+=16)_.set(I.subarray(M,M+16),D);return _},E.decryptAvcSample=function(_,y,I,M,D,b){var A=Object(i.discardEPB)(D.data),u=this.getAvcEncryptedData(A),r=this;this.decryptBuffer(u.buffer,function(o){D.data=r.getAvcDecryptedUnit(A,o),b||r.decryptAvcSamples(_,y,I+1,M)})},E.decryptAvcSamples=function(_,y,I,M){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;y++,I=0){if(y>=_.length){M();return}for(var D=_[y].units;!(I>=D.length);I++){var b=D[I];if(!(b.data.length<=48||b.type!==1&&b.type!==5)){var A=this.decrypter.isSync();if(this.decryptAvcSample(_,y,I,M,b,A),!A)return}}}},R}();e.default=c},"./src/demux/transmuxer-interface.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D});var a=t("./node_modules/webworkify-webpack/index.js"),i=t.n(a),c=t("./src/events.ts"),R=t("./src/demux/transmuxer.ts"),E=t("./src/utils/logger.ts"),L=t("./src/errors.ts"),_=t("./src/utils/mediasource-helper.ts"),y=t("./node_modules/eventemitter3/index.js"),I=t.n(y),M=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},D=function(){function b(u,r,o,n){var s=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=u,this.id=r,this.onTransmuxComplete=o,this.onFlush=n;var d=u.config,l=function(v,h){h=h||{},h.frag=s.frag,h.id=s.id,u.trigger(v,h)};this.observer=new y.EventEmitter,this.observer.on(c.Events.FRAG_DECRYPTED,l),this.observer.on(c.Events.ERROR,l);var T={mp4:M.isTypeSupported("video/mp4"),mpeg:M.isTypeSupported("audio/mpeg"),mp3:M.isTypeSupported('audio/mp4; codecs="mp3"')},g=navigator.vendor;if(d.enableWorker&&typeof Worker!="undefined"){E.logger.log("demuxing in webworker");var m;try{m=this.worker=a("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),m.addEventListener("message",this.onwmsg),m.onerror=function(p){u.trigger(c.Events.ERROR,{type:L.ErrorTypes.OTHER_ERROR,details:L.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},m.postMessage({cmd:"init",typeSupported:T,vendor:g,id:r,config:JSON.stringify(d)})}catch(p){E.logger.warn("Error in worker:",p),E.logger.error("Error while initializing DemuxerWorker, fallback to inline"),m&&self.URL.revokeObjectURL(m.objectURL),this.transmuxer=new R.default(this.observer,T,d,g,r),this.worker=null}}else this.transmuxer=new R.default(this.observer,T,d,g,r)}var A=b.prototype;return A.destroy=function(){var r=this.worker;if(r)r.removeEventListener("message",this.onwmsg),r.terminate(),this.worker=null;else{var o=this.transmuxer;o&&(o.destroy(),this.transmuxer=null)}var n=this.observer;n&&n.removeAllListeners(),this.observer=null},A.push=function(r,o,n,s,d,l,T,g,m,p){var v,h,x=this;m.transmuxing.start=self.performance.now();var S=this.transmuxer,C=this.worker,O=l?l.start:d.start,P=d.decryptdata,w=this.frag,U=!(w&&d.cc===w.cc),k=!(w&&m.level===w.level),N=w?m.sn-w.sn:-1,B=this.part?m.part-this.part.index:1,K=!k&&(N===1||N===0&&B===1),H=self.performance.now();(k||N||d.stats.parsing.start===0)&&(d.stats.parsing.start=H),l&&(B||!K)&&(l.stats.parsing.start=H);var F=!(w&&((v=d.initSegment)===null||v===void 0?void 0:v.url)===((h=w.initSegment)===null||h===void 0?void 0:h.url)),W=new R.TransmuxState(U,K,g,k,O,F);if(!K||U||F){E.logger.log("[transmuxer-interface, "+d.type+"]: Starting new transmux session for sn: "+m.sn+" p: "+m.part+" level: "+m.level+" id: "+m.id+`
13
13
  discontinuity: `+U+`
14
14
  trackSwitch: `+k+`
15
15
  contiguous: `+K+`
16
- accurateTimeOffset: `+p+`
17
- timeOffset: `+C+`
18
- initSegmentChange: `+F);var Y=new R.TransmuxConfig(i,a,s,y,g);this.configureTransmuxer(Y)}if(this.frag=d,this.part=o,O)O.postMessage({cmd:"demux",data:r,decryptdata:P,chunkMeta:m,state:H},r instanceof ArrayBuffer?[r]:[]);else if(S){var $=S.push(r,P,m,H);Object(R.isPromise)($)?$.then(function(Z){x.handleTransmuxComplete(Z)}):this.handleTransmuxComplete($)}},A.flush=function(r){var s=this;r.transmuxing.start=self.performance.now();var i=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:r});else if(i){var d=i.flush(r);Object(R.isPromise)(d)?d.then(function(o){s.handleFlushResult(o,r)}):this.handleFlushResult(d,r)}},A.handleFlushResult=function(r,s){var i=this;r.forEach(function(a){i.handleTransmuxComplete(a)}),this.onFlush(s)},A.onWorkerMessage=function(r){var s=r.data,i=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}default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,i.trigger(s.event,s.data);break}}},A.configureTransmuxer=function(r){var s=this.worker,i=this.transmuxer;s?s.postMessage({cmd:"configure",config:r}):i&&i.configure(r)},A.handleTransmuxComplete=function(r){r.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(r)},b}()},"./src/demux/transmuxer-worker.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return L});var l=t("./src/demux/transmuxer.ts"),n=t("./src/events.ts"),h=t("./src/utils/logger.ts"),R=t("./node_modules/eventemitter3/index.js"),T=t.n(R);function L(D){var b=new R.EventEmitter,A=function(r,s){D.postMessage({event:r,data:s})};b.on(n.Events.FRAG_DECRYPTED,A),b.on(n.Events.ERROR,A),D.addEventListener("message",function(u){var r=u.data;switch(r.cmd){case"init":{var s=JSON.parse(r.config);D.transmuxer=new l.default(b,r.typeSupported,s,r.vendor,r.id),Object(h.enableLogs)(s.debug),A("init",null);break}case"configure":{D.transmuxer.configure(r.config);break}case"demux":{var i=D.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);Object(l.isPromise)(i)?i.then(function(o){_(D,o)}):_(D,i);break}case"flush":{var a=r.chunkMeta,d=D.transmuxer.flush(a);Object(l.isPromise)(d)?d.then(function(o){I(D,o,a)}):I(D,d,a);break}default:break}})}function _(D,b){if(!M(b.remuxResult)){var A=[],u=b.remuxResult,r=u.audio,s=u.video;r&&E(A,r),s&&E(A,s),D.postMessage({event:"transmuxComplete",data:b},A)}}function E(D,b){b.data1&&D.push(b.data1.buffer),b.data2&&D.push(b.data2.buffer)}function I(D,b,A){b.forEach(function(u){_(D,u)}),D.postMessage({event:"flush",data:A})}function M(D){return!D.audio&&!D.video&&!D.text&&!D.id3&&!D.initSegment}},"./src/demux/transmuxer.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return s}),t.d(e,"isPromise",function(){return d}),t.d(e,"TransmuxConfig",function(){return o}),t.d(e,"TransmuxState",function(){return y});var l=t("./src/events.ts"),n=t("./src/errors.ts"),h=t("./src/crypt/decrypter.ts"),R=t("./src/demux/aacdemuxer.ts"),T=t("./src/demux/mp4demuxer.ts"),L=t("./src/demux/tsdemuxer.ts"),_=t("./src/demux/mp3demuxer.ts"),E=t("./src/remux/mp4-remuxer.ts"),I=t("./src/remux/passthrough-remuxer.ts"),M=t("./src/demux/chunk-cache.ts"),D=t("./src/utils/mp4-tools.ts"),b=t("./src/utils/logger.ts"),A;try{A=self.performance.now.bind(self.performance)}catch{b.logger.debug("Unable to use Performance API on this environment"),A=self.Date.now}var u=[{demux:L.default,remux:E.default},{demux:T.default,remux:I.default},{demux:R.default,remux:E.default},{demux:_.default,remux:E.default}],r=1024;u.forEach(function(p){var m=p.demux;r=Math.max(r,m.minProbeByteLength)});var s=function(){function p(g,f,c,x,S){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.cache=new M.default,this.observer=g,this.typeSupported=f,this.config=c,this.vendor=x,this.id=S}var m=p.prototype;return m.configure=function(f){this.transmuxConfig=f,this.decrypter&&this.decrypter.reset()},m.push=function(f,c,x,S){var O=this,C=x.transmuxing;C.executeStart=A();var P=new Uint8Array(f),w=this.cache,U=this.config,k=this.currentTransmuxState,N=this.transmuxConfig;S&&(this.currentTransmuxState=S);var B=i(P,c);if(B&&B.method==="AES-128"){var K=this.getDecrypter();if(U.enableSoftwareAES){var W=K.softwareDecrypt(P,B.key.buffer,B.iv.buffer);if(!W)return C.executeEnd=A(),a(x);P=new Uint8Array(W)}else return this.decryptionPromise=K.webCryptoDecrypt(P,B.key.buffer,B.iv.buffer).then(function(ee){var he=O.push(ee,null,x);return O.decryptionPromise=null,he}),this.decryptionPromise}var F=S||k,H=F.contiguous,Y=F.discontinuity,$=F.trackSwitch,Z=F.accurateTimeOffset,q=F.timeOffset,oe=F.initSegmentChange,X=N.audioCodec,ie=N.videoCodec,fe=N.defaultInitPts,ue=N.duration,Ae=N.initSegmentData;if((Y||$||oe)&&this.resetInitSegment(Ae,X,ie,ue),(Y||oe)&&this.resetInitialTimestamp(fe),H||this.resetContiguity(),this.needsProbing(P,Y,$)){if(w.dataLength){var re=w.flush();P=Object(D.appendUint8Array)(re,P)}this.configureTransmuxer(P,N)}var Q=this.transmux(P,B,q,Z,x),te=this.currentTransmuxState;return te.contiguous=!0,te.discontinuity=!1,te.trackSwitch=!1,C.executeEnd=A(),Q},m.flush=function(f){var c=this,x=f.transmuxing;x.executeStart=A();var S=this.decrypter,O=this.cache,C=this.currentTransmuxState,P=this.decryptionPromise;if(P)return P.then(function(){return c.flush(f)});var w=[],U=C.timeOffset;if(S){var k=S.flush();k&&w.push(this.push(k,null,f))}var N=O.dataLength;O.reset();var B=this.demuxer,K=this.remuxer;if(!B||!K)return N>=r&&this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),x.executeEnd=A(),[a(f)];var W=B.flush(U);return d(W)?W.then(function(F){return c.flushRemux(w,F,f),w}):(this.flushRemux(w,W,f),w)},m.flushRemux=function(f,c,x){var S=c.audioTrack,O=c.avcTrack,C=c.id3Track,P=c.textTrack,w=this.currentTransmuxState,U=w.accurateTimeOffset,k=w.timeOffset;b.logger.log("[transmuxer.ts]: Flushed fragment "+x.sn+(x.part>-1?" p: "+x.part:"")+" of level "+x.level);var N=this.remuxer.remux(S,O,C,P,k,U,!0,this.id);f.push({remuxResult:N,chunkMeta:x}),x.transmuxing.executeEnd=A()},m.resetInitialTimestamp=function(f){var c=this.demuxer,x=this.remuxer;!c||!x||(c.resetTimeStamp(f),x.resetTimeStamp(f))},m.resetContiguity=function(){var f=this.demuxer,c=this.remuxer;!f||!c||(f.resetContiguity(),c.resetNextTimestamp())},m.resetInitSegment=function(f,c,x,S){var O=this.demuxer,C=this.remuxer;!O||!C||(O.resetInitSegment(c,x,S),C.resetInitSegment(f,c,x))},m.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},m.transmux=function(f,c,x,S,O){var C;return c&&c.method==="SAMPLE-AES"?C=this.transmuxSampleAes(f,c,x,S,O):C=this.transmuxUnencrypted(f,x,S,O),C},m.transmuxUnencrypted=function(f,c,x,S){var O=this.demuxer.demux(f,c,!1,!this.config.progressive),C=O.audioTrack,P=O.avcTrack,w=O.id3Track,U=O.textTrack,k=this.remuxer.remux(C,P,w,U,c,x,!1,this.id);return{remuxResult:k,chunkMeta:S}},m.transmuxSampleAes=function(f,c,x,S,O){var C=this;return this.demuxer.demuxSampleAes(f,c,x).then(function(P){var w=C.remuxer.remux(P.audioTrack,P.avcTrack,P.id3Track,P.textTrack,x,S,!1,C.id);return{remuxResult:w,chunkMeta:O}})},m.configureTransmuxer=function(f,c){for(var x=this.config,S=this.observer,O=this.typeSupported,C=this.vendor,P=c.audioCodec,w=c.defaultInitPts,U=c.duration,k=c.initSegmentData,N=c.videoCodec,B,K=0,W=u.length;K<W;K++)if(u[K].demux.probe(f)){B=u[K];break}B||(b.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:T.default,remux:I.default});var F=this.demuxer,H=this.remuxer,Y=B.remux,$=B.demux;(!H||!(H instanceof Y))&&(this.remuxer=new Y(S,x,O,C)),(!F||!(F instanceof $))&&(this.demuxer=new $(S,x,O),this.probe=$.probe),this.resetInitSegment(k,P,N,U),this.resetInitialTimestamp(w)},m.needsProbing=function(f,c,x){return!this.demuxer||!this.remuxer||c||x},m.getDecrypter=function(){var f=this.decrypter;return f||(f=this.decrypter=new h.default(this.observer,this.config)),f},p}();function i(p,m){var g=null;return p.byteLength>0&&m!=null&&m.key!=null&&m.iv!==null&&m.method!=null&&(g=m),g}var a=function(m){return{remuxResult:{},chunkMeta:m}};function d(p){return"then"in p&&p.then instanceof Function}var o=function(m,g,f,c,x){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=m,this.videoCodec=g,this.initSegmentData=f,this.duration=c,this.defaultInitPts=x},y=function(m,g,f,c,x,S){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=m,this.contiguous=g,this.accurateTimeOffset=f,this.trackSwitch=c,this.timeOffset=x,this.initSegmentChange=S}},"./src/demux/tsdemuxer.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"discardEPB",function(){return a});var l=t("./src/demux/adts.ts"),n=t("./src/demux/mpegaudio.ts"),h=t("./src/demux/exp-golomb.ts"),R=t("./src/demux/id3.ts"),T=t("./src/demux/sample-aes.ts"),L=t("./src/events.ts"),_=t("./src/utils/mp4-tools.ts"),E=t("./src/utils/logger.ts"),I=t("./src/errors.ts"),M={video:1,audio:2,id3:3,text:4},D=function(){function d(y,p,m){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.aacLastPTS=null,this._initPTS=null,this._initDTS=null,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=y,this.config=p,this.typeSupported=m}d.probe=function(p){var m=d.syncOffset(p);return m<0?!1:(m&&E.logger.warn("MPEG2-TS detected but first sync word found @ offset "+m+", junk ahead ?"),!0)},d.syncOffset=function(p){for(var m=Math.min(1e3,p.length-3*188),g=0;g<m;){if(p[g]===71&&p[g+188]===71&&p[g+2*188]===71)return g;g++}return-1},d.createTrack=function(p,m){return{container:p==="video"||p==="audio"?"video/mp2t":void 0,type:p,id:M[p],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:p==="audio"?m:void 0}};var o=d.prototype;return o.resetInitSegment=function(p,m,g){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=d.createTrack("video",g),this._audioTrack=d.createTrack("audio",g),this._id3Track=d.createTrack("id3",g),this._txtTrack=d.createTrack("text",g),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=p,this.videoCodec=m,this._duration=g},o.resetTimeStamp=function(){},o.resetContiguity=function(){var p=this._audioTrack,m=this._avcTrack,g=this._id3Track;p&&(p.pesData=null),m&&(m.pesData=null),g&&(g.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},o.demux=function(p,m,g,f){g===void 0&&(g=!1),f===void 0&&(f=!1),g||(this.sampleAes=null);var c,x=this._avcTrack,S=this._audioTrack,O=this._id3Track,C=x.pid,P=x.pesData,w=S.pid,U=O.pid,k=S.pesData,N=O.pesData,B=!1,K=this.pmtParsed,W=this._pmtId,F=p.length;if(this.remainderData&&(p=Object(_.appendUint8Array)(this.remainderData,p),F=p.length,this.remainderData=null),F<188&&!f)return this.remainderData=p,{audioTrack:S,avcTrack:x,id3Track:O,textTrack:this._txtTrack};var H=Math.max(0,d.syncOffset(p));F-=(F+H)%188,F<p.byteLength&&!f&&(this.remainderData=new Uint8Array(p.buffer,F,p.buffer.byteLength-F));for(var Y=0,$=H;$<F;$+=188)if(p[$]===71){var Z=!!(p[$+1]&64),q=((p[$+1]&31)<<8)+p[$+2],oe=(p[$+3]&48)>>4,X=void 0;if(oe>1){if(X=$+5+p[$+4],X===$+188)continue}else X=$+4;switch(q){case C:Z&&(P&&(c=r(P))&&this.parseAVCPES(c,!1),P={data:[],size:0}),P&&(P.data.push(p.subarray(X,$+188)),P.size+=$+188-X);break;case w:Z&&(k&&(c=r(k))&&(S.isAAC?this.parseAACPES(c):this.parseMPEGPES(c)),k={data:[],size:0}),k&&(k.data.push(p.subarray(X,$+188)),k.size+=$+188-X);break;case U:Z&&(N&&(c=r(N))&&this.parseID3PES(c),N={data:[],size:0}),N&&(N.data.push(p.subarray(X,$+188)),N.size+=$+188-X);break;case 0:Z&&(X+=p[X]+1),W=this._pmtId=A(p,X);break;case W:{Z&&(X+=p[X]+1);var ie=u(p,X,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,g);C=ie.avc,C>0&&(x.pid=C),w=ie.audio,w>0&&(S.pid=w,S.isAAC=ie.isAAC),U=ie.id3,U>0&&(O.pid=U),B&&!K&&(E.logger.log("reparse from beginning"),B=!1,$=H-188),K=this.pmtParsed=!0;break}case 17:case 8191:break;default:B=!0;break}}else Y++;Y>0&&this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),x.pesData=P,S.pesData=k,O.pesData=N;var fe={audioTrack:S,avcTrack:x,id3Track:O,textTrack:this._txtTrack};return f&&this.extractRemainingSamples(fe),fe},o.flush=function(){var p=this.remainderData;this.remainderData=null;var m;return p?m=this.demux(p,-1,!1,!0):m={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(m),this.sampleAes?this.decrypt(m,this.sampleAes):m},o.extractRemainingSamples=function(p){var m=p.audioTrack,g=p.avcTrack,f=p.id3Track,c=g.pesData,x=m.pesData,S=f.pesData,O;c&&(O=r(c))?(this.parseAVCPES(O,!0),g.pesData=null):g.pesData=c,x&&(O=r(x))?(m.isAAC?this.parseAACPES(O):this.parseMPEGPES(O),m.pesData=null):(x!=null&&x.size&&E.logger.log("last AAC PES packet truncated,might overlap between fragments"),m.pesData=x),S&&(O=r(S))?(this.parseID3PES(O),f.pesData=null):f.pesData=S},o.demuxSampleAes=function(p,m,g){var f=this.demux(p,g,!0,!this.config.progressive),c=this.sampleAes=new T.default(this.observer,this.config,m);return this.decrypt(f,c)},o.decrypt=function(p,m){return new Promise(function(g){var f=p.audioTrack,c=p.avcTrack;f.samples&&f.isAAC?m.decryptAacSamples(f.samples,0,function(){c.samples?m.decryptAvcSamples(c.samples,0,0,function(){g(p)}):g(p)}):c.samples&&m.decryptAvcSamples(c.samples,0,0,function(){g(p)})})},o.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},o.parseAVCPES=function(p,m){var g=this,f=this._avcTrack,c=this.parseAVCNALu(p.data),x=!1,S=this.avcSample,O,C=!1;p.data=null,S&&c.length&&!f.audFound&&(s(S,f),S=this.avcSample=b(!1,p.pts,p.dts,"")),c.forEach(function(P){switch(P.type){case 1:{O=!0,S||(S=g.avcSample=b(!0,p.pts,p.dts,"")),x&&(S.debug+="NDR "),S.frame=!0;var w=P.data;if(C&&w.length>4){var U=new h.default(w).readSliceType();(U===2||U===4||U===7||U===9)&&(S.key=!0)}break}case 5:O=!0,S||(S=g.avcSample=b(!0,p.pts,p.dts,"")),x&&(S.debug+="IDR "),S.key=!0,S.frame=!0;break;case 6:{O=!0,x&&S&&(S.debug+="SEI ");var k=new h.default(a(P.data));k.readUByte();for(var N=0,B=0,K=!1,W=0;!K&&k.bytesAvailable>1;){N=0;do W=k.readUByte(),N+=W;while(W===255);B=0;do W=k.readUByte(),B+=W;while(W===255);if(N===4&&k.bytesAvailable!==0){K=!0;var F=k.readUByte();if(F===181){var H=k.readUShort();if(H===49){var Y=k.readUInt();if(Y===1195456820){var $=k.readUByte();if($===3){for(var Z=k.readUByte(),q=k.readUByte(),oe=31&Z,X=[Z,q],ie=0;ie<oe;ie++)X.push(k.readUByte()),X.push(k.readUByte()),X.push(k.readUByte());i(g._txtTrack.samples,{type:3,pts:p.pts,bytes:X})}}}}}else if(N===5&&k.bytesAvailable!==0){if(K=!0,B>16){for(var fe=[],ue=0;ue<16;ue++)fe.push(k.readUByte().toString(16)),(ue===3||ue===5||ue===7||ue===9)&&fe.push("-");for(var Ae=B-16,re=new Uint8Array(Ae),Q=0;Q<Ae;Q++)re[Q]=k.readUByte();i(g._txtTrack.samples,{pts:p.pts,payloadType:N,uuid:fe.join(""),userData:Object(R.utf8ArrayToStr)(re),userDataBytes:re})}}else if(B<k.bytesAvailable)for(var te=0;te<B;te++)k.readUByte()}break}case 7:if(O=!0,C=!0,x&&S&&(S.debug+="SPS "),!f.sps){var ee=new h.default(P.data),he=ee.readSPS();f.width=he.width,f.height=he.height,f.pixelRatio=he.pixelRatio,f.sps=[P.data],f.duration=g._duration;for(var Se=P.data.subarray(1,4),pe="avc1.",Te=0;Te<3;Te++){var Ie=Se[Te].toString(16);Ie.length<2&&(Ie="0"+Ie),pe+=Ie}f.codec=pe}break;case 8:O=!0,x&&S&&(S.debug+="PPS "),f.pps||(f.pps=[P.data]);break;case 9:O=!1,f.audFound=!0,S&&s(S,f),S=g.avcSample=b(!1,p.pts,p.dts,x?"AUD ":"");break;case 12:O=!1;break;default:O=!1,S&&(S.debug+="unknown NAL "+P.type+" ");break}if(S&&O){var Ue=S.units;Ue.push(P)}}),m&&S&&(s(S,f),this.avcSample=null)},o.getLastNalUnit=function(){var p,m=this.avcSample,g;if(!m||m.units.length===0){var f=this._avcTrack.samples;m=f[f.length-1]}if((p=m)!==null&&p!==void 0&&p.units){var c=m.units;g=c[c.length-1]}return g},o.parseAVCNALu=function(p){var m=p.byteLength,g=this._avcTrack,f=g.naluState||0,c=f,x=[],S=0,O,C,P,w=-1,U=0;for(f===-1&&(w=0,U=p[0]&31,f=0,S=1);S<m;){if(O=p[S++],!f){f=O?0:1;continue}if(f===1){f=O?0:2;continue}if(!O)f=3;else if(O===1){if(w>=0){var k={data:p.subarray(w,S-f-1),type:U};x.push(k)}else{var N=this.getLastNalUnit();if(N&&(c&&S<=4-c&&N.state&&(N.data=N.data.subarray(0,N.data.byteLength-c)),C=S-f-1,C>0)){var B=new Uint8Array(N.data.byteLength+C);B.set(N.data,0),B.set(p.subarray(0,C),N.data.byteLength),N.data=B,N.state=0}}S<m?(P=p[S]&31,w=S,U=P,f=0):f=-1}else f=0}if(w>=0&&f>=0){var K={data:p.subarray(w,m),type:U,state:f};x.push(K)}if(x.length===0){var W=this.getLastNalUnit();if(W){var F=new Uint8Array(W.data.byteLength+p.byteLength);F.set(W.data,0),F.set(p,W.data.byteLength),W.data=F}}return g.naluState=f,x},o.parseAACPES=function(p){var m=0,g=this._audioTrack,f=this.aacOverFlow,c=p.data;if(f){this.aacOverFlow=null;var x=f.sample.unit.byteLength,S=Math.min(f.missing,x),O=x-S;f.sample.unit.set(c.subarray(0,S),O),g.samples.push(f.sample),m=f.missing}var C,P;for(C=m,P=c.length;C<P-1&&!l.isHeader(c,C);C++);if(C!==m){var w,U;if(C<P-1?(w="AAC PES did not start with ADTS header,offset:"+C,U=!1):(w="no ADTS header found in AAC PES",U=!0),E.logger.warn("parsing error:"+w),this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:U,reason:w}),U)return}l.initTrackConfig(g,this.observer,c,C,this.audioCodec);var k;if(p.pts!==void 0)k=p.pts;else if(f){var N=l.getFrameDuration(g.samplerate);k=f.sample.pts+N}else{E.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var B=0;C<P;)if(l.isHeader(c,C)){if(C+5<P){var K=l.appendFrame(g,c,C,k,B);if(K)if(K.missing)this.aacOverFlow=K;else{C+=K.length,B++;continue}}break}else C++},o.parseMPEGPES=function(p){var m=p.data,g=m.length,f=0,c=0,x=p.pts;if(x===void 0){E.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<g;)if(n.isHeader(m,c)){var S=n.appendFrame(this._audioTrack,m,c,x,f);if(S)c+=S.length,f++;else break}else c++},o.parseID3PES=function(p){if(p.pts===void 0){E.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(p)},d}();D.minProbeByteLength=188;function b(d,o,y,p){return{key:d,frame:!1,pts:o,dts:y,units:[],debug:p,length:0}}function A(d,o){return(d[o+10]&31)<<8|d[o+11]}function u(d,o,y,p){var m={audio:-1,avc:-1,id3:-1,isAAC:!0},g=(d[o+1]&15)<<8|d[o+2],f=o+3+g-4,c=(d[o+10]&15)<<8|d[o+11];for(o+=12+c;o<f;){var x=(d[o+1]&31)<<8|d[o+2];switch(d[o]){case 207:if(!p){E.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:m.audio===-1&&(m.audio=x);break;case 21:m.id3===-1&&(m.id3=x);break;case 219:if(!p){E.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:m.avc===-1&&(m.avc=x);break;case 3:case 4:y?m.audio===-1&&(m.audio=x,m.isAAC=!1):E.logger.log("MPEG audio found, not supported in this browser");break;case 36:E.logger.warn("Unsupported HEVC stream type found");break;default:break}o+=((d[o+3]&15)<<8|d[o+4])+5}return m}function r(d){var o=0,y,p,m,g,f,c=d.data;if(!d||d.size===0)return null;for(;c[0].length<19&&c.length>1;){var x=new Uint8Array(c[0].length+c[1].length);x.set(c[0]),x.set(c[1],c[0].length),c[0]=x,c.splice(1,1)}y=c[0];var S=(y[0]<<16)+(y[1]<<8)+y[2];if(S===1){if(p=(y[4]<<8)+y[5],p&&p>d.size-6)return null;var O=y[7];O&192&&(g=(y[9]&14)*536870912+(y[10]&255)*4194304+(y[11]&254)*16384+(y[12]&255)*128+(y[13]&254)/2,O&64?(f=(y[14]&14)*536870912+(y[15]&255)*4194304+(y[16]&254)*16384+(y[17]&255)*128+(y[18]&254)/2,g-f>60*9e4&&(E.logger.warn(Math.round((g-f)/9e4)+"s delta between PTS and DTS, align them"),g=f)):f=g),m=y[8];var C=m+9;if(d.size<=C)return null;d.size-=C;for(var P=new Uint8Array(d.size),w=0,U=c.length;w<U;w++){y=c[w];var k=y.byteLength;if(C)if(C>k){C-=k;continue}else y=y.subarray(C),k-=C,C=0;P.set(y,o),o+=k}return p&&(p-=m+3),{data:P,pts:g,dts:f,len:p}}return null}function s(d,o){if(d.units.length&&d.frame){if(d.pts===void 0){var y=o.samples,p=y.length;if(p){var m=y[p-1];d.pts=m.pts,d.dts=m.dts}else{o.dropped++;return}}o.samples.push(d)}d.debug.length&&E.logger.log(d.pts+"/"+d.dts+":"+d.debug)}function i(d,o){var y=d.length;if(y>0){if(o.pts>=d[y-1].pts)d.push(o);else for(var p=y-1;p>=0;p--)if(o.pts<d[p].pts){d.splice(p,0,o);break}}else d.push(o)}function a(d){for(var o=d.byteLength,y=[],p=1;p<o-2;)d[p]===0&&d[p+1]===0&&d[p+2]===3?(y.push(p+2),p+=2):p++;if(y.length===0)return d;var m=o-y.length,g=new Uint8Array(m),f=0;for(p=0;p<m;f++,p++)f===y[0]&&(f++,y.shift()),g[p]=d[f];return g}e.default=D},"./src/errors.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"ErrorTypes",function(){return l}),t.d(e,"ErrorDetails",function(){return n});var l;(function(h){h.NETWORK_ERROR="networkError",h.MEDIA_ERROR="mediaError",h.KEY_SYSTEM_ERROR="keySystemError",h.MUX_ERROR="muxError",h.OTHER_ERROR="otherError"})(l||(l={}));var n;(function(h){h.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",h.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",h.KEY_SYSTEM_NO_SESSION="keySystemNoSession",h.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",h.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",h.MANIFEST_LOAD_ERROR="manifestLoadError",h.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",h.MANIFEST_PARSING_ERROR="manifestParsingError",h.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",h.LEVEL_EMPTY_ERROR="levelEmptyError",h.LEVEL_LOAD_ERROR="levelLoadError",h.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",h.LEVEL_SWITCH_ERROR="levelSwitchError",h.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",h.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",h.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",h.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",h.FRAG_LOAD_ERROR="fragLoadError",h.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",h.FRAG_DECRYPT_ERROR="fragDecryptError",h.FRAG_PARSING_ERROR="fragParsingError",h.REMUX_ALLOC_ERROR="remuxAllocError",h.KEY_LOAD_ERROR="keyLoadError",h.KEY_LOAD_TIMEOUT="keyLoadTimeOut",h.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",h.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",h.BUFFER_APPEND_ERROR="bufferAppendError",h.BUFFER_APPENDING_ERROR="bufferAppendingError",h.BUFFER_STALLED_ERROR="bufferStalledError",h.BUFFER_FULL_ERROR="bufferFullError",h.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",h.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",h.INTERNAL_EXCEPTION="internalException",h.INTERNAL_ABORTED="aborted",h.UNKNOWN="unknown"})(n||(n={}))},"./src/events.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"Events",function(){return l});var l;(function(n){n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached"})(l||(l={}))},"./src/hls.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return d});var l=t("./node_modules/url-toolkit/src/url-toolkit.js"),n=t.n(l),h=t("./src/loader/playlist-loader.ts"),R=t("./src/loader/key-loader.ts"),T=t("./src/controller/id3-track-controller.ts"),L=t("./src/controller/latency-controller.ts"),_=t("./src/controller/level-controller.ts"),E=t("./src/controller/fragment-tracker.ts"),I=t("./src/controller/stream-controller.ts"),M=t("./src/is-supported.ts"),D=t("./src/utils/logger.ts"),b=t("./src/config.ts"),A=t("./node_modules/eventemitter3/index.js"),u=t.n(A),r=t("./src/events.ts"),s=t("./src/errors.ts");function i(o,y){for(var p=0;p<y.length;p++){var m=y[p];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(o,m.key,m)}}function a(o,y,p){return y&&i(o.prototype,y),p&&i(o,p),o}var d=function(){o.isSupported=function(){return Object(M.isSupported)()};function o(p){p===void 0&&(p={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new A.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 m=this.config=Object(b.mergeConfig)(o.DefaultConfig,p);this.userConfig=p,Object(D.enableLogs)(m.debug),this._autoLevelCapping=-1,m.progressive&&Object(b.enableStreamingMode)(m);var g=m.abrController,f=m.bufferController,c=m.capLevelController,x=m.fpsController,S=this.abrController=new g(this),O=this.bufferController=new f(this),C=this.capLevelController=new c(this),P=new x(this),w=new h.default(this),U=new R.default(this),k=new T.default(this),N=this.levelController=new _.default(this),B=new E.FragmentTracker(this),K=this.streamController=new I.default(this,B);C.setStreamController(K),P.setStreamController(K);var W=[N,K];this.networkControllers=W;var F=[w,U,S,O,C,P,k,B];this.audioTrackController=this.createController(m.audioTrackController,null,W),this.createController(m.audioStreamController,B,W),this.subtitleTrackController=this.createController(m.subtitleTrackController,null,W),this.createController(m.subtitleStreamController,B,W),this.createController(m.timelineController,null,F),this.emeController=this.createController(m.emeController,null,F),this.cmcdController=this.createController(m.cmcdController,null,F),this.latencyController=this.createController(L.default,null,F),this.coreComponents=F}var y=o.prototype;return y.createController=function(m,g,f){if(m){var c=g?new m(this,g):new m(this);return f&&f.push(c),c}return null},y.on=function(m,g,f){f===void 0&&(f=this),this._emitter.on(m,g,f)},y.once=function(m,g,f){f===void 0&&(f=this),this._emitter.once(m,g,f)},y.removeAllListeners=function(m){this._emitter.removeAllListeners(m)},y.off=function(m,g,f,c){f===void 0&&(f=this),this._emitter.off(m,g,f,c)},y.listeners=function(m){return this._emitter.listeners(m)},y.emit=function(m,g,f){return this._emitter.emit(m,g,f)},y.trigger=function(m,g){if(this.config.debug)return this.emit(m,m,g);try{return this.emit(m,m,g)}catch(f){D.logger.error("An internal error happened while handling event "+m+'. Error message: "'+f.message+'". Here is a stacktrace:',f),this.trigger(r.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:m,error:f})}return!1},y.listenerCount=function(m){return this._emitter.listenerCount(m)},y.destroy=function(){D.logger.log("destroy"),this.trigger(r.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(m){return m.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(m){return m.destroy()}),this.coreComponents.length=0},y.attachMedia=function(m){D.logger.log("attachMedia"),this._media=m,this.trigger(r.Events.MEDIA_ATTACHING,{media:m})},y.detachMedia=function(){D.logger.log("detachMedia"),this.trigger(r.Events.MEDIA_DETACHING,void 0),this._media=null},y.loadSource=function(m){this.stopLoad();var g=this.media,f=this.url,c=this.url=l.buildAbsoluteURL(self.location.href,m,{alwaysNormalize:!0});D.logger.log("loadSource:"+c),g&&f&&f!==c&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(g)),this.trigger(r.Events.MANIFEST_LOADING,{url:m})},y.startLoad=function(m){m===void 0&&(m=-1),D.logger.log("startLoad("+m+")"),this.networkControllers.forEach(function(g){g.startLoad(m)})},y.stopLoad=function(){D.logger.log("stopLoad"),this.networkControllers.forEach(function(m){m.stopLoad()})},y.swapAudioCodec=function(){D.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},y.recoverMediaError=function(){D.logger.log("recoverMediaError");var m=this._media;this.detachMedia(),m&&this.attachMedia(m)},y.removeLevel=function(m,g){g===void 0&&(g=0),this.levelController.removeLevel(m,g)},a(o,[{key:"levels",get:function(){var m=this.levelController.levels;return m||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(m){D.logger.log("set currentLevel:"+m),this.loadLevel=m,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(m){D.logger.log("set nextLevel:"+m),this.levelController.manualLevel=m,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(m){D.logger.log("set loadLevel:"+m),this.levelController.manualLevel=m}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(m){this.levelController.nextLoadLevel=m}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(m){D.logger.log("set firstLevel:"+m),this.levelController.firstLevel=m}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(m){D.logger.log("set startLevel:"+m),m!==-1&&(m=Math.max(m,this.minAutoLevel)),this.levelController.startLevel=m}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(m){var g=!!m;g!==this.config.capLevelToPlayerSize&&(g?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=g)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(m){this._autoLevelCapping!==m&&(D.logger.log("set autoLevelCapping:"+m),this._autoLevelCapping=m)}},{key:"bandwidthEstimate",get:function(){var m=this.abrController.bwEstimator;return m?m.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var m=this.levels,g=this.config.minAutoBitrate;if(!m)return 0;for(var f=m.length,c=0;c<f;c++)if(m[c].maxBitrate>g)return c;return 0}},{key:"maxAutoLevel",get:function(){var m=this.levels,g=this.autoLevelCapping,f;return g===-1&&m&&m.length?f=m.length-1:f=g,f}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(m){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,m)}},{key:"audioTracks",get:function(){var m=this.audioTrackController;return m?m.audioTracks:[]}},{key:"audioTrack",get:function(){var m=this.audioTrackController;return m?m.audioTrack:-1},set:function(m){var g=this.audioTrackController;g&&(g.audioTrack=m)}},{key:"subtitleTracks",get:function(){var m=this.subtitleTrackController;return m?m.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var m=this.subtitleTrackController;return m?m.subtitleTrack:-1},set:function(m){var g=this.subtitleTrackController;g&&(g.subtitleTrack=m)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var m=this.subtitleTrackController;return m?m.subtitleDisplay:!1},set:function(m){var g=this.subtitleTrackController;g&&(g.subtitleDisplay=m)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(m){this.config.lowLatencyMode=m}},{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.1.5"}},{key:"Events",get:function(){return r.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return o.defaultConfig?o.defaultConfig:b.hlsDefaultConfig},set:function(m){o.defaultConfig=m}}]),o}();d.defaultConfig=void 0},"./src/is-supported.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"isSupported",function(){return h}),t.d(e,"changeTypeSupported",function(){return R});var l=t("./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function h(){var T=Object(l.getMediaSource)();if(!T)return!1;var L=n(),_=T&&typeof T.isTypeSupported=="function"&&T.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),E=!L||L.prototype&&typeof L.prototype.appendBuffer=="function"&&typeof L.prototype.remove=="function";return!!_&&!!E}function R(){var T,L=n();return typeof(L==null||(T=L.prototype)===null||T===void 0?void 0:T.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D}),t.d(e,"LoadError",function(){return A});var l=t("./src/polyfills/number.ts"),n=t("./src/errors.ts");function h(u,r){u.prototype=Object.create(r.prototype),u.prototype.constructor=u,E(u,r)}function R(u){var r=typeof Map=="function"?new Map:void 0;return R=function(i){if(i===null||!_(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r!="undefined"){if(r.has(i))return r.get(i);r.set(i,a)}function a(){return T(i,arguments,I(this).constructor)}return a.prototype=Object.create(i.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),E(a,i)},R(u)}function T(u,r,s){return L()?T=Reflect.construct:T=function(a,d,o){var y=[null];y.push.apply(y,d);var p=Function.bind.apply(a,y),m=new p;return o&&E(m,o.prototype),m},T.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 _(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function E(u,r){return E=Object.setPrototypeOf||function(i,a){return i.__proto__=a,i},E(u,r)}function I(u){return I=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},I(u)}var M=Math.pow(2,17),D=function(){function u(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var r=u.prototype;return r.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},r.abort=function(){this.loader&&this.loader.abort()},r.load=function(i,a){var d=this,o=i.url;if(!o)return Promise.reject(new A({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:i,networkDetails:null},"Fragment does not have a "+(o?"part list":"url")));this.abort();var y=this.config,p=y.fLoader,m=y.loader;return new Promise(function(g,f){d.loader&&d.loader.destroy();var c=d.loader=i.loader=p?new p(y):new m(y),x=b(i),S={timeout:y.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:y.fragLoadingMaxRetryTimeout,highWaterMark:M};i.stats=c.stats,c.load(x,S,{onSuccess:function(C,P,w,U){d.resetLoader(i,c),g({frag:i,part:null,payload:C.data,networkDetails:U})},onError:function(C,P,w){d.resetLoader(i,c),f(new A({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:i,response:C,networkDetails:w}))},onAbort:function(C,P,w){d.resetLoader(i,c),f(new A({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:i,networkDetails:w}))},onTimeout:function(C,P,w){d.resetLoader(i,c),f(new A({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:i,networkDetails:w}))},onProgress:function(C,P,w,U){a&&a({frag:i,part:null,payload:w,networkDetails:U})}})})},r.loadPart=function(i,a,d){var o=this;this.abort();var y=this.config,p=y.fLoader,m=y.loader;return new Promise(function(g,f){o.loader&&o.loader.destroy();var c=o.loader=i.loader=p?new p(y):new m(y),x=b(i,a),S={timeout:y.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:y.fragLoadingMaxRetryTimeout,highWaterMark:M};a.stats=c.stats,c.load(x,S,{onSuccess:function(C,P,w,U){o.resetLoader(i,c),o.updateStatsFromPart(i,a);var k={frag:i,part:a,payload:C.data,networkDetails:U};d(k),g(k)},onError:function(C,P,w){o.resetLoader(i,c),f(new A({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:i,part:a,response:C,networkDetails:w}))},onAbort:function(C,P,w){i.stats.aborted=a.stats.aborted,o.resetLoader(i,c),f(new A({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:i,part:a,networkDetails:w}))},onTimeout:function(C,P,w){o.resetLoader(i,c),f(new A({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:i,part:a,networkDetails:w}))}})})},r.updateStatsFromPart=function(i,a){var d=i.stats,o=a.stats,y=o.total;if(d.loaded+=o.loaded,y){var p=Math.round(i.duration/a.duration),m=Math.min(Math.round(d.loaded/y),p),g=p-m,f=g*Math.round(d.loaded/m);d.total=d.loaded+f}else d.total=Math.max(d.loaded,d.total);var c=d.loading,x=o.loading;c.start?c.first+=x.first-x.start:(c.start=x.start,c.first=x.first),c.end=x.end},r.resetLoader=function(i,a){i.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},u}();function b(u,r){r===void 0&&(r=null);var s=r||u,i={frag:u,part:r,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},a=s.byteRangeStartOffset,d=s.byteRangeEndOffset;return Object(l.isFiniteNumber)(a)&&Object(l.isFiniteNumber)(d)&&(i.rangeStart=a,i.rangeEnd=d),i}var A=function(u){h(r,u);function r(s){for(var i,a=arguments.length,d=new Array(a>1?a-1:0),o=1;o<a;o++)d[o-1]=arguments[o];return i=u.call.apply(u,[this].concat(d))||this,i.data=void 0,i.data=s,i}return r}(R(Error))},"./src/loader/fragment.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"ElementaryStreamTypes",function(){return D}),t.d(e,"BaseSegment",function(){return b}),t.d(e,"Fragment",function(){return A}),t.d(e,"Part",function(){return u});var l=t("./src/polyfills/number.ts"),n=t("./node_modules/url-toolkit/src/url-toolkit.js"),h=t.n(n),R=t("./src/utils/logger.ts"),T=t("./src/loader/level-key.ts"),L=t("./src/loader/load-stats.ts");function _(r,s){r.prototype=Object.create(s.prototype),r.prototype.constructor=r,E(r,s)}function E(r,s){return E=Object.setPrototypeOf||function(a,d){return a.__proto__=d,a},E(r,s)}function I(r,s){for(var i=0;i<s.length;i++){var a=s[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(r,a.key,a)}}function M(r,s,i){return s&&I(r.prototype,s),i&&I(r,i),r}var D;(function(r){r.AUDIO="audio",r.VIDEO="video",r.AUDIOVIDEO="audiovideo"})(D||(D={}));var b=function(){function r(i){var a;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(a={},a[D.AUDIO]=null,a[D.VIDEO]=null,a[D.AUDIOVIDEO]=null,a),this.baseurl=i}var s=r.prototype;return s.setByteRange=function(a,d){var o=a.split("@",2),y=[];o.length===1?y[0]=d?d.byteRangeEndOffset:0:y[0]=parseInt(o[1]),y[1]=parseInt(o[0])+y[0],this._byteRange=y},M(r,[{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(n.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(a){this._url=a}}]),r}(),A=function(r){_(s,r);function s(a,d){var o;return o=r.call(this,d)||this,o._decryptdata=null,o.rawProgramDateTime=null,o.programDateTime=null,o.tagList=[],o.duration=0,o.sn=0,o.levelkey=void 0,o.type=void 0,o.loader=null,o.level=-1,o.cc=0,o.startPTS=void 0,o.endPTS=void 0,o.appendedPTS=void 0,o.startDTS=void 0,o.endDTS=void 0,o.start=0,o.deltaPTS=void 0,o.maxStartPTS=void 0,o.minEndPTS=void 0,o.stats=new L.LoadStats,o.urlId=0,o.data=void 0,o.bitrateTest=!1,o.title=null,o.initSegment=null,o.type=a,o}var i=s.prototype;return i.createInitializationVector=function(d){for(var o=new Uint8Array(16),y=12;y<16;y++)o[y]=d>>8*(15-y)&255;return o},i.setDecryptDataFromLevelKey=function(d,o){var y=d;return(d==null?void 0:d.method)==="AES-128"&&d.uri&&!d.iv&&(y=T.LevelKey.fromURI(d.uri),y.method=d.method,y.iv=this.createInitializationVector(o),y.keyFormat="identity"),y},i.setElementaryStreamInfo=function(d,o,y,p,m,g){g===void 0&&(g=!1);var f=this.elementaryStreams,c=f[d];if(!c){f[d]={startPTS:o,endPTS:y,startDTS:p,endDTS:m,partial:g};return}c.startPTS=Math.min(c.startPTS,o),c.endPTS=Math.max(c.endPTS,y),c.startDTS=Math.min(c.startDTS,p),c.endDTS=Math.max(c.endDTS,m)},i.clearElementaryStreamInfo=function(){var d=this.elementaryStreams;d[D.AUDIO]=null,d[D.VIDEO]=null,d[D.AUDIOVIDEO]=null},M(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var d=this.sn;typeof d!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&R.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),d=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,d)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(l.isFiniteNumber)(this.programDateTime))return null;var d=Object(l.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+d*1e3}},{key:"encrypted",get:function(){var d;return!!((d=this.decryptdata)!==null&&d!==void 0&&d.keyFormat&&this.decryptdata.uri)}}]),s}(b),u=function(r){_(s,r);function s(i,a,d,o,y){var p;p=r.call(this,d)||this,p.fragOffset=0,p.duration=0,p.gap=!1,p.independent=!1,p.relurl=void 0,p.fragment=void 0,p.index=void 0,p.stats=new L.LoadStats,p.duration=i.decimalFloatingPoint("DURATION"),p.gap=i.bool("GAP"),p.independent=i.bool("INDEPENDENT"),p.relurl=i.enumeratedString("URI"),p.fragment=a,p.index=o;var m=i.enumeratedString("BYTERANGE");return m&&p.setByteRange(m,y),y&&(p.fragOffset=y.fragOffset+y.duration),p}return M(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 a=this.elementaryStreams;return!!(a.audio||a.video||a.audiovideo)}}]),s}(b)},"./src/loader/key-loader.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return R});var l=t("./src/events.ts"),n=t("./src/errors.ts"),h=t("./src/utils/logger.ts"),R=function(){function T(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this._registerListeners()}var L=T.prototype;return L._registerListeners=function(){this.hls.on(l.Events.KEY_LOADING,this.onKeyLoading,this)},L._unregisterListeners=function(){this.hls.off(l.Events.KEY_LOADING,this.onKeyLoading)},L.destroy=function(){this._unregisterListeners();for(var E in this.loaders){var I=this.loaders[E];I&&I.destroy()}this.loaders={}},L.onKeyLoading=function(E,I){var M=I.frag,D=M.type,b=this.loaders[D];if(!M.decryptdata){h.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var A=M.decryptdata.uri;if(A!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(b&&(h.logger.warn("abort previous key loader for type:"+D),b.abort()),!A){h.logger.warn("key uri is falsy");return}var r=u.loader,s=M.loader=this.loaders[D]=new r(u);this.decrypturl=A,this.decryptkey=null;var i={url:A,frag:M,responseType:"arraybuffer"},a={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(i,a,d)}else this.decryptkey&&(M.decryptdata.key=this.decryptkey,this.hls.trigger(l.Events.KEY_LOADED,{frag:M}))},L.loadsuccess=function(E,I,M){var D=M.frag;if(!D.decryptdata){h.logger.error("after key load, decryptdata unset");return}this.decryptkey=D.decryptdata.key=new Uint8Array(E.data),D.loader=null,delete this.loaders[D.type],this.hls.trigger(l.Events.KEY_LOADED,{frag:D})},L.loaderror=function(E,I){var M=I.frag,D=M.loader;D&&D.abort(),delete this.loaders[M.type],this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:M,response:E})},L.loadtimeout=function(E,I){var M=I.frag,D=M.loader;D&&D.abort(),delete this.loaders[M.type],this.hls.trigger(l.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:M})},T}()},"./src/loader/level-details.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"LevelDetails",function(){return T});var l=t("./src/polyfills/number.ts");function n(L,_){for(var E=0;E<_.length;E++){var I=_[E];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function h(L,_,E){return _&&n(L.prototype,_),E&&n(L,E),L}var R=10,T=function(){function L(E){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.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.url=E}var _=L.prototype;return _.reloaded=function(I){if(!I){this.advanced=!0,this.updated=!0;return}var M=this.lastPartSn-I.lastPartSn,D=this.lastPartIndex-I.lastPartIndex;this.updated=this.endSN!==I.endSN||!!D||!!M,this.advanced=this.endSN>I.endSN||M>0||M===0&&D>0,this.updated||this.advanced?this.misses=Math.floor(I.misses*.6):this.misses=I.misses+1,this.availabilityDelay=I.availabilityDelay},h(L,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(l.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||R}},{key:"drift",get:function(){var I=this.driftEndTime-this.driftStartTime;if(I>0){var M=this.driftEnd-this.driftStart;return M*1e3/I}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var I;return(I=this.partList)!==null&&I!==void 0&&I.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var I;return(I=this.fragments)!==null&&I!==void 0&&I.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 I;return(I=this.partList)!==null&&I!==void 0&&I.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var I;return(I=this.partList)!==null&&I!==void 0&&I.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"LevelKey",function(){return T});var l=t("./node_modules/url-toolkit/src/url-toolkit.js"),n=t.n(l);function h(L,_){for(var E=0;E<_.length;E++){var I=_[E];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function R(L,_,E){return _&&h(L.prototype,_),E&&h(L,E),L}var T=function(){L.fromURL=function(E,I){return new L(E,I)},L.fromURI=function(E){return new L(E)};function L(_,E){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,E?this._uri=Object(l.buildAbsoluteURL)(_,E,{alwaysNormalize:!0}):this._uri=_}return R(L,[{key:"uri",get:function(){return this._uri}}]),L}()},"./src/loader/load-stats.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"LoadStats",function(){return l});var l=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(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return s});var l=t("./src/polyfills/number.ts"),n=t("./node_modules/url-toolkit/src/url-toolkit.js"),h=t.n(n),R=t("./src/loader/fragment.ts"),T=t("./src/loader/level-details.ts"),L=t("./src/loader/level-key.ts"),_=t("./src/utils/attr-list.ts"),E=t("./src/utils/logger.ts"),I=t("./src/utils/codecs.ts"),M=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,D=/#EXT-X-MEDIA:(.*)/g,b=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-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function r(y){var p,m;return u.test((p=(m=n.parseURL(y))===null||m===void 0?void 0:m.path)!=null?p:"")}var s=function(){function y(){}return y.findGroup=function(m,g){for(var f=0;f<m.length;f++){var c=m[f];if(c.id===g)return c}},y.convertAVC1ToAVCOTI=function(m){var g=m.split(".");if(g.length>2){var f=g.shift()+".";return f+=parseInt(g.shift()).toString(16),f+=("000"+parseInt(g.shift()).toString(16)).substr(-4),f}return m},y.resolve=function(m,g){return n.buildAbsoluteURL(g,m,{alwaysNormalize:!0})},y.parseMasterPlaylist=function(m,g){var f=[],c={},x=!1;M.lastIndex=0;for(var S;(S=M.exec(m))!=null;)if(S[1]){var O=new _.AttrList(S[1]),C={attrs:O,bitrate:O.decimalInteger("AVERAGE-BANDWIDTH")||O.decimalInteger("BANDWIDTH"),name:O.NAME,url:y.resolve(S[2],g)},P=O.decimalResolution("RESOLUTION");P&&(C.width=P.width,C.height=P.height),i((O.CODECS||"").split(/[ ,]+/).filter(function(U){return U}),C),C.videoCodec&&C.videoCodec.indexOf("avc1")!==-1&&(C.videoCodec=y.convertAVC1ToAVCOTI(C.videoCodec)),f.push(C)}else if(S[3]){var w=new _.AttrList(S[3]);w["DATA-ID"]&&(x=!0,c[w["DATA-ID"]]=w)}return{levels:f,sessionData:x?c:null}},y.parseMasterPlaylistMedia=function(m,g,f,c){c===void 0&&(c=[]);var x,S=[],O=0;for(D.lastIndex=0;(x=D.exec(m))!==null;){var C=new _.AttrList(x[1]);if(C.TYPE===f){var P={attrs:C,bitrate:0,id:O++,groupId:C["GROUP-ID"],instreamId:C["INSTREAM-ID"],name:C.NAME||C.LANGUAGE||"",type:f,default:C.bool("DEFAULT"),autoselect:C.bool("AUTOSELECT"),forced:C.bool("FORCED"),lang:C.LANGUAGE,url:C.URI?y.resolve(C.URI,g):""};if(c.length){var w=y.findGroup(c,P.groupId)||c[0];a(P,w,"audioCodec"),a(P,w,"textCodec")}S.push(P)}}return S},y.parseLevelPlaylist=function(m,g,f,c,x){var S=new T.LevelDetails(g),O=S.fragments,C=null,P=0,w=0,U=0,k=0,N=null,B=new R.Fragment(c,g),K,W,F,H=-1,Y=!1;for(b.lastIndex=0,S.m3u8=m;(K=b.exec(m))!==null;){Y&&(Y=!1,B=new R.Fragment(c,g),B.start=U,B.sn=P,B.cc=k,B.level=f,C&&(B.initSegment=C,B.rawProgramDateTime=C.rawProgramDateTime));var $=K[1];if($){B.duration=parseFloat($);var Z=(" "+K[2]).slice(1);B.title=Z||null,B.tagList.push(Z?["INF",$,Z]:["INF",$])}else if(K[3])Object(l.isFiniteNumber)(B.duration)&&(B.start=U,F&&(B.levelkey=F),B.sn=P,B.level=f,B.cc=k,B.urlId=x,O.push(B),B.relurl=(" "+K[3]).slice(1),o(B,N),N=B,U+=B.duration,P++,w=0,Y=!0);else if(K[4]){var q=(" "+K[4]).slice(1);N?B.setByteRange(q,N):B.setByteRange(q)}else if(K[5])B.rawProgramDateTime=(" "+K[5]).slice(1),B.tagList.push(["PROGRAM-DATE-TIME",B.rawProgramDateTime]),H===-1&&(H=O.length);else{if(K=K[0].match(A),!K){E.logger.warn("No matches on slow regex match for level playlist!");continue}for(W=1;W<K.length&&typeof K[W]=="undefined";W++);var oe=(" "+K[W]).slice(1),X=(" "+K[W+1]).slice(1),ie=K[W+2]?(" "+K[W+2]).slice(1):"";switch(oe){case"PLAYLIST-TYPE":S.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":P=S.startSN=parseInt(X);break;case"SKIP":{var fe=new _.AttrList(X),ue=fe.decimalInteger("SKIPPED-SEGMENTS");if(Object(l.isFiniteNumber)(ue)){S.skippedSegments=ue;for(var Ae=ue;Ae--;)O.unshift(null);P+=ue}var re=fe.enumeratedString("RECENTLY-REMOVED-DATERANGES");re&&(S.recentlyRemovedDateranges=re.split(" "));break}case"TARGETDURATION":S.targetduration=parseFloat(X);break;case"VERSION":S.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":S.live=!1;break;case"#":(X||ie)&&B.tagList.push(ie?[X,ie]:[X]);break;case"DIS":k++;case"GAP":B.tagList.push([oe]);break;case"BITRATE":B.tagList.push([oe,X]);break;case"DISCONTINUITY-SEQ":k=parseInt(X);break;case"KEY":{var Q,te=new _.AttrList(X),ee=te.enumeratedString("METHOD"),he=te.URI,Se=te.hexadecimalInteger("IV"),pe=te.enumeratedString("KEYFORMATVERSIONS"),Te=te.enumeratedString("KEYID"),Ie=(Q=te.enumeratedString("KEYFORMAT"))!=null?Q:"identity",Ue=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ue.indexOf(Ie)>-1){E.logger.warn("Keyformat "+Ie+" is not supported from the manifest");continue}else if(Ie!=="identity")continue;ee&&(F=L.LevelKey.fromURL(g,he),he&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ee)>=0&&(F.method=ee,F.keyFormat=Ie,Te&&(F.keyID=Te),pe&&(F.keyFormatVersions=pe),F.iv=Se));break}case"START":{var Ee=new _.AttrList(X),ye=Ee.decimalFloatingPoint("TIME-OFFSET");Object(l.isFiniteNumber)(ye)&&(S.startTimeOffset=ye);break}case"MAP":{var Ne=new _.AttrList(X);B.relurl=Ne.URI,Ne.BYTERANGE&&B.setByteRange(Ne.BYTERANGE),B.level=f,B.sn="initSegment",F&&(B.levelkey=F),B.initSegment=null,C=B,Y=!0;break}case"SERVER-CONTROL":{var be=new _.AttrList(X);S.canBlockReload=be.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=be.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&be.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=be.optionalFloat("PART-HOLD-BACK",0),S.holdBack=be.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Ze=new _.AttrList(X);S.partTarget=Ze.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=S.partList;we||(we=S.partList=[]);var $e=w>0?we[we.length-1]:void 0,qe=w++,et=new R.Part(new _.AttrList(X),B,g,qe,$e);we.push(et),B.duration+=et.duration;break}case"PRELOAD-HINT":{var G=new _.AttrList(X);S.preloadHint=G;break}case"RENDITION-REPORT":{var V=new _.AttrList(X);S.renditionReports=S.renditionReports||[],S.renditionReports.push(V);break}default:E.logger.warn("line parsed but not handled: "+K);break}}}N&&!N.relurl?(O.pop(),U-=N.duration,S.partList&&(S.fragmentHint=N)):S.partList&&(o(B,N),B.cc=k,S.fragmentHint=B);var de=O.length,ce=O[0],Me=O[de-1];if(U+=S.skippedSegments*S.targetduration,U>0&&de&&Me){S.averagetargetduration=U/de;var Re=Me.sn;S.endSN=Re!=="initSegment"?Re:0,ce&&(S.startCC=ce.cc,ce.initSegment||S.fragments.every(function(le){return le.relurl&&r(le.relurl)})&&(E.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),B=new R.Fragment(c,g),B.relurl=Me.relurl,B.level=f,B.sn="initSegment",ce.initSegment=B,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(U+=S.fragmentHint.duration),S.totalduration=U,S.endCC=k,H>0&&d(O,H),S},y}();function i(y,p){["video","audio","text"].forEach(function(m){var g=y.filter(function(c){return Object(I.isCodecType)(c,m)});if(g.length){var f=g.filter(function(c){return c.lastIndexOf("avc1",0)===0||c.lastIndexOf("mp4a",0)===0});p[m+"Codec"]=f.length>0?f[0]:g[0],y=y.filter(function(c){return g.indexOf(c)===-1})}}),p.unknownCodecs=y}function a(y,p,m){var g=p[m];g&&(y[m]=g)}function d(y,p){for(var m=y[p],g=p;g--;){var f=y[g];if(!f)return;f.programDateTime=m.programDateTime-f.duration*1e3,m=f}}function o(y,p){y.rawProgramDateTime?y.programDateTime=Date.parse(y.rawProgramDateTime):p!=null&&p.programDateTime&&(y.programDateTime=p.endProgramDateTime),Object(l.isFiniteNumber)(y.programDateTime)||(y.programDateTime=null,y.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/polyfills/number.ts"),n=t("./src/events.ts"),h=t("./src/errors.ts"),R=t("./src/utils/logger.ts"),T=t("./src/utils/mp4-tools.ts"),L=t("./src/loader/m3u8-parser.ts"),_=t("./src/types/loader.ts"),E=t("./src/utils/attr-list.ts");function I(b){var A=b.type;switch(A){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function M(b,A){var u=b.url;return(u===void 0||u.indexOf("data:")===0)&&(u=A.url),u}var D=function(){function b(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var A=b.prototype;return A.registerListeners=function(){var r=this.hls;r.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.on(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},A.unregisterListeners=function(){var r=this.hls;r.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.off(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},A.createInternalLoader=function(r){var s=this.hls.config,i=s.pLoader,a=s.loader,d=i||a,o=new d(s);return r.loader=o,this.loaders[r.type]=o,o},A.getInternalLoader=function(r){return this.loaders[r.type]},A.resetInternalLoader=function(r){this.loaders[r]&&delete this.loaders[r]},A.destroyInternalLoaders=function(){for(var r in this.loaders){var s=this.loaders[r];s&&s.destroy(),this.resetInternalLoader(r)}},A.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},A.onManifestLoading=function(r,s){var i=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},A.onLevelLoading=function(r,s){var i=s.id,a=s.level,d=s.url,o=s.deliveryDirectives;this.load({id:i,groupId:null,level:a,responseType:"text",type:_.PlaylistContextType.LEVEL,url:d,deliveryDirectives:o})},A.onAudioTrackLoading=function(r,s){var i=s.id,a=s.groupId,d=s.url,o=s.deliveryDirectives;this.load({id:i,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:d,deliveryDirectives:o})},A.onSubtitleTrackLoading=function(r,s){var i=s.id,a=s.groupId,d=s.url,o=s.deliveryDirectives;this.load({id:i,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:d,deliveryDirectives:o})},A.load=function(r){var s,i=this.hls.config,a=this.getInternalLoader(r);if(a){var d=a.context;if(d&&d.url===r.url){R.logger.trace("[playlist-loader]: playlist request ongoing");return}R.logger.log("[playlist-loader]: aborting previous loader for type: "+r.type),a.abort()}var o,y,p,m;switch(r.type){case _.PlaylistContextType.MANIFEST:o=i.manifestLoadingMaxRetry,y=i.manifestLoadingTimeOut,p=i.manifestLoadingRetryDelay,m=i.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:o=0,y=i.levelLoadingTimeOut;break;default:o=i.levelLoadingMaxRetry,y=i.levelLoadingTimeOut,p=i.levelLoadingRetryDelay,m=i.levelLoadingMaxRetryTimeout;break}if(a=this.createInternalLoader(r),(s=r.deliveryDirectives)!==null&&s!==void 0&&s.part){var g;if(r.type===_.PlaylistContextType.LEVEL&&r.level!==null?g=this.hls.levels[r.level].details:r.type===_.PlaylistContextType.AUDIO_TRACK&&r.id!==null?g=this.hls.audioTracks[r.id].details:r.type===_.PlaylistContextType.SUBTITLE_TRACK&&r.id!==null&&(g=this.hls.subtitleTracks[r.id].details),g){var f=g.partTarget,c=g.targetduration;f&&c&&(y=Math.min(Math.max(f*3,c*.8)*1e3,y))}}var x={timeout:y,maxRetry:o,retryDelay:p,maxRetryDelay:m,highWaterMark:0},S={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(r,x,S)},A.loadsuccess=function(r,s,i,a){if(a===void 0&&(a=null),i.isSidxRequest){this.handleSidxRequest(r,i),this.handlePlaylistLoaded(r,s,i,a);return}this.resetInternalLoader(i.type);var d=r.data;if(d.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(r,i,"no EXTM3U delimiter",a);return}s.parsing.start=performance.now(),d.indexOf("#EXTINF:")>0||d.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(r,s,i,a):this.handleMasterPlaylist(r,s,i,a)},A.loaderror=function(r,s,i){i===void 0&&(i=null),this.handleNetworkError(s,i,!1,r)},A.loadtimeout=function(r,s,i){i===void 0&&(i=null),this.handleNetworkError(s,i,!0)},A.handleMasterPlaylist=function(r,s,i,a){var d=this.hls,o=r.data,y=M(r,i),p=L.default.parseMasterPlaylist(o,y),m=p.levels,g=p.sessionData;if(!m.length){this.handleManifestParsingError(r,i,"no level found in manifest",a);return}var f=m.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),c=m.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),x=L.default.parseMasterPlaylistMedia(o,y,"AUDIO",f),S=L.default.parseMasterPlaylistMedia(o,y,"SUBTITLES",c),O=L.default.parseMasterPlaylistMedia(o,y,"CLOSED-CAPTIONS");if(x.length){var C=x.some(function(P){return!P.url});!C&&m[0].audioCodec&&!m[0].attrs.AUDIO&&(R.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),x.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new E.AttrList({}),bitrate:0,url:""}))}d.trigger(n.Events.MANIFEST_LOADED,{levels:m,audioTracks:x,subtitles:S,captions:O,url:y,stats:s,networkDetails:a,sessionData:g})},A.handleTrackOrLevelPlaylist=function(r,s,i,a){var d=this.hls,o=i.id,y=i.level,p=i.type,m=M(r,i),g=Object(l.isFiniteNumber)(o)?o:0,f=Object(l.isFiniteNumber)(y)?y:g,c=I(i),x=L.default.parseLevelPlaylist(r.data,m,f,c,g);if(!x.fragments.length){d.trigger(n.Events.ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:m,reason:"no fragments found in level",level:typeof i.level=="number"?i.level:void 0});return}if(p===_.PlaylistContextType.MANIFEST){var S={attrs:new E.AttrList({}),bitrate:0,details:x,name:"",url:m};d.trigger(n.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:m,stats:s,networkDetails:a,sessionData:null})}if(s.parsing.end=performance.now(),x.needSidxRanges){var O,C=(O=x.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:C,isSidxRequest:!0,type:p,level:y,levelDetails:x,id:o,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}i.levelDetails=x,this.handlePlaylistLoaded(r,s,i,a)},A.handleSidxRequest=function(r,s){var i=Object(T.parseSegmentIndex)(new Uint8Array(r.data));if(!!i){var a=i.references,d=s.levelDetails;a.forEach(function(o,y){var p=o.info,m=d.fragments[y];m.byteRange.length===0&&m.setByteRange(String(1+p.end-p.start)+"@"+String(p.start)),m.initSegment&&m.initSegment.setByteRange(String(i.moovEndOffset)+"@0")})}},A.handleManifestParsingError=function(r,s,i,a){this.hls.trigger(n.Events.ERROR,{type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===_.PlaylistContextType.MANIFEST,url:r.url,reason:i,response:r,context:s,networkDetails:a})},A.handleNetworkError=function(r,s,i,a){i===void 0&&(i=!1),R.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+r.type+" level: "+r.level+" id: "+r.id+' group-id: "'+r.groupId+'"');var d=h.ErrorDetails.UNKNOWN,o=!1,y=this.getInternalLoader(r);switch(r.type){case _.PlaylistContextType.MANIFEST:d=i?h.ErrorDetails.MANIFEST_LOAD_TIMEOUT:h.ErrorDetails.MANIFEST_LOAD_ERROR,o=!0;break;case _.PlaylistContextType.LEVEL:d=i?h.ErrorDetails.LEVEL_LOAD_TIMEOUT:h.ErrorDetails.LEVEL_LOAD_ERROR,o=!1;break;case _.PlaylistContextType.AUDIO_TRACK:d=i?h.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,o=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:d=i?h.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:h.ErrorDetails.SUBTITLE_LOAD_ERROR,o=!1;break}y&&this.resetInternalLoader(r.type);var p={type:h.ErrorTypes.NETWORK_ERROR,details:d,fatal:o,url:r.url,loader:y,context:r,networkDetails:s};a&&(p.response=a),this.hls.trigger(n.Events.ERROR,p)},A.handlePlaylistLoaded=function(r,s,i,a){var d=i.type,o=i.level,y=i.id,p=i.groupId,m=i.loader,g=i.levelDetails,f=i.deliveryDirectives;if(!(g!=null&&g.targetduration)){this.handleManifestParsingError(r,i,"invalid target duration",a);return}if(!!m)switch(g.live&&(m.getCacheAge&&(g.ageHeader=m.getCacheAge()||0),(!m.getCacheAge||isNaN(g.ageHeader))&&(g.ageHeader=0)),d){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:g,level:o||0,id:y||0,stats:s,networkDetails:a,deliveryDirectives:f});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,{details:g,id:y||0,groupId:p||"",stats:s,networkDetails:a,deliveryDirectives:f});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADED,{details:g,id:y||0,groupId:p||"",stats:s,networkDetails:a,deliveryDirectives:f});break}},b}();e.default=D},"./src/polyfills/number.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"isFiniteNumber",function(){return l}),t.d(e,"MAX_SAFE_INTEGER",function(){return n});var l=Number.isFinite||function(h){return typeof h=="number"&&isFinite(h)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(v,e,t){"use strict";t.r(e);var l=function(){function n(){}return n.getSilentFrame=function(R,T){switch(R){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}},n}();e.default=l},"./src/remux/mp4-generator.ts":function(v,e,t){"use strict";t.r(e);var l=Math.pow(2,32)-1,n=function(){function h(){}return h.init=function(){h.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 h.types)h.types.hasOwnProperty(T)&&(h.types[T]=[T.charCodeAt(0),T.charCodeAt(1),T.charCodeAt(2),T.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]),_=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]);h.HDLR_TYPES={video:L,audio:_};var E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),I=new Uint8Array([0,0,0,0,0,0,0,0]);h.STTS=h.STSC=h.STCO=I,h.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),h.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),h.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),h.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var M=new Uint8Array([105,115,111,109]),D=new Uint8Array([97,118,99,49]),b=new Uint8Array([0,0,0,1]);h.FTYP=h.box(h.types.ftyp,M,b,M,D),h.DINF=h.box(h.types.dinf,h.box(h.types.dref,E))},h.box=function(T){for(var L=8,_=arguments.length,E=new Array(_>1?_-1:0),I=1;I<_;I++)E[I-1]=arguments[I];for(var M=E.length,D=M;M--;)L+=E[M].byteLength;var b=new Uint8Array(L);for(b[0]=L>>24&255,b[1]=L>>16&255,b[2]=L>>8&255,b[3]=L&255,b.set(T,4),M=0,L=8;M<D;M++)b.set(E[M],L),L+=E[M].byteLength;return b},h.hdlr=function(T){return h.box(h.types.hdlr,h.HDLR_TYPES[T])},h.mdat=function(T){return h.box(h.types.mdat,T)},h.mdhd=function(T,L){L*=T;var _=Math.floor(L/(l+1)),E=Math.floor(L%(l+1));return h.box(h.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,_>>24,_>>16&255,_>>8&255,_&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},h.mdia=function(T){return h.box(h.types.mdia,h.mdhd(T.timescale,T.duration),h.hdlr(T.type),h.minf(T))},h.mfhd=function(T){return h.box(h.types.mfhd,new Uint8Array([0,0,0,0,T>>24,T>>16&255,T>>8&255,T&255]))},h.minf=function(T){return T.type==="audio"?h.box(h.types.minf,h.box(h.types.smhd,h.SMHD),h.DINF,h.stbl(T)):h.box(h.types.minf,h.box(h.types.vmhd,h.VMHD),h.DINF,h.stbl(T))},h.moof=function(T,L,_){return h.box(h.types.moof,h.mfhd(T),h.traf(_,L))},h.moov=function(T){for(var L=T.length,_=[];L--;)_[L]=h.trak(T[L]);return h.box.apply(null,[h.types.moov,h.mvhd(T[0].timescale,T[0].duration)].concat(_).concat(h.mvex(T)))},h.mvex=function(T){for(var L=T.length,_=[];L--;)_[L]=h.trex(T[L]);return h.box.apply(null,[h.types.mvex].concat(_))},h.mvhd=function(T,L){L*=T;var _=Math.floor(L/(l+1)),E=Math.floor(L%(l+1)),I=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,T>>24&255,T>>16&255,T>>8&255,T&255,_>>24,_>>16&255,_>>8&255,_&255,E>>24,E>>16&255,E>>8&255,E&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 h.box(h.types.mvhd,I)},h.sdtp=function(T){var L=T.samples||[],_=new Uint8Array(4+L.length),E,I;for(E=0;E<L.length;E++)I=L[E].flags,_[E+4]=I.dependsOn<<4|I.isDependedOn<<2|I.hasRedundancy;return h.box(h.types.sdtp,_)},h.stbl=function(T){return h.box(h.types.stbl,h.stsd(T),h.box(h.types.stts,h.STTS),h.box(h.types.stsc,h.STSC),h.box(h.types.stsz,h.STSZ),h.box(h.types.stco,h.STCO))},h.avc1=function(T){var L=[],_=[],E,I,M;for(E=0;E<T.sps.length;E++)I=T.sps[E],M=I.byteLength,L.push(M>>>8&255),L.push(M&255),L=L.concat(Array.prototype.slice.call(I));for(E=0;E<T.pps.length;E++)I=T.pps[E],M=I.byteLength,_.push(M>>>8&255),_.push(M&255),_=_.concat(Array.prototype.slice.call(I));var D=h.box(h.types.avcC,new Uint8Array([1,L[3],L[4],L[5],252|3,224|T.sps.length].concat(L).concat([T.pps.length]).concat(_))),b=T.width,A=T.height,u=T.pixelRatio[0],r=T.pixelRatio[1];return h.box(h.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,b>>8&255,b&255,A>>8&255,A&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]),D,h.box(h.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),h.box(h.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,r>>24,r>>16&255,r>>8&255,r&255])))},h.esds=function(T){var L=T.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(T.config).concat([6,1,2]))},h.mp4a=function(T){var L=T.samplerate;return h.box(h.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,L>>8&255,L&255,0,0]),h.box(h.types.esds,h.esds(T)))},h.mp3=function(T){var L=T.samplerate;return h.box(h.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,L>>8&255,L&255,0,0]))},h.stsd=function(T){return T.type==="audio"?!T.isAAC&&T.codec==="mp3"?h.box(h.types.stsd,h.STSD,h.mp3(T)):h.box(h.types.stsd,h.STSD,h.mp4a(T)):h.box(h.types.stsd,h.STSD,h.avc1(T))},h.tkhd=function(T){var L=T.id,_=T.duration*T.timescale,E=T.width,I=T.height,M=Math.floor(_/(l+1)),D=Math.floor(_%(l+1));return h.box(h.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,M>>24,M>>16&255,M>>8&255,M&255,D>>24,D>>16&255,D>>8&255,D&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,E>>8&255,E&255,0,0,I>>8&255,I&255,0,0]))},h.traf=function(T,L){var _=h.sdtp(T),E=T.id,I=Math.floor(L/(l+1)),M=Math.floor(L%(l+1));return h.box(h.types.traf,h.box(h.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),h.box(h.types.tfdt,new Uint8Array([1,0,0,0,I>>24,I>>16&255,I>>8&255,I&255,M>>24,M>>16&255,M>>8&255,M&255])),h.trun(T,_.length+16+20+8+16+8+8),_)},h.trak=function(T){return T.duration=T.duration||4294967295,h.box(h.types.trak,h.tkhd(T),h.mdia(T))},h.trex=function(T){var L=T.id;return h.box(h.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]))},h.trun=function(T,L){var _=T.samples||[],E=_.length,I=12+16*E,M=new Uint8Array(I),D,b,A,u,r,s;for(L+=8+I,M.set([0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,L>>>24&255,L>>>16&255,L>>>8&255,L&255],0),D=0;D<E;D++)b=_[D],A=b.duration,u=b.size,r=b.flags,s=b.cts,M.set([A>>>24&255,A>>>16&255,A>>>8&255,A&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,r.isLeading<<2|r.dependsOn,r.isDependedOn<<6|r.hasRedundancy<<4|r.paddingValue<<1|r.isNonSync,r.degradPrio&240<<8,r.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*D);return h.box(h.types.trun,M)},h.initSegment=function(T){h.types||h.init();var L=h.moov(T),_=new Uint8Array(h.FTYP.byteLength+L.byteLength);return _.set(h.FTYP),_.set(L,h.FTYP.byteLength),_},h}();n.types=void 0,n.HDLR_TYPES=void 0,n.STTS=void 0,n.STSC=void 0,n.STCO=void 0,n.STSZ=void 0,n.VMHD=void 0,n.SMHD=void 0,n.STSD=void 0,n.FTYP=void 0,n.DINF=void 0,e.default=n},"./src/remux/mp4-remuxer.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return s}),t.d(e,"normalizePts",function(){return i});var l=t("./src/polyfills/number.ts"),n=t("./src/remux/aac-helper.ts"),h=t("./src/remux/mp4-generator.ts"),R=t("./src/events.ts"),T=t("./src/errors.ts"),L=t("./src/utils/logger.ts"),_=t("./src/types/loader.ts"),E=t("./src/utils/timescale-conversion.ts");function I(){return I=Object.assign||function(y){for(var p=1;p<arguments.length;p++){var m=arguments[p];for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(y[g]=m[g])}return y},I.apply(this,arguments)}var M=10*1e3,D=1024,b=1152,A=null,u=null,r=!1,s=function(){function y(m,g,f,c){if(c===void 0&&(c=""),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.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=m,this.config=g,this.typeSupported=f,this.ISGenerated=!1,A===null){var x=navigator.userAgent||"",S=x.match(/Chrome\/(\d+)/i);A=S?parseInt(S[1]):0}if(u===null){var O=navigator.userAgent.match(/Safari\/(\d+)/i);u=O?parseInt(O[1]):0}r=!!A&&A<75||!!u&&u<600}var p=y.prototype;return p.destroy=function(){},p.resetTimeStamp=function(g){L.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=g},p.resetNextTimestamp=function(){L.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},p.resetInitSegment=function(){L.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},p.getVideoStartPts=function(g){var f=!1,c=g.reduce(function(x,S){var O=S.pts-x;return O<-4294967296?(f=!0,i(x,S.pts)):O>0?x:S.pts},g[0].pts);return f&&L.logger.debug("PTS rollover detected"),c},p.remux=function(g,f,c,x,S,O,C,P){var w,U,k,N,B,K,W=S,F=S,H=g.pid>-1,Y=f.pid>-1,$=f.samples.length,Z=g.samples.length>0,q=$>1,oe=(!H||Z)&&(!Y||q)||this.ISGenerated||C;if(oe){this.ISGenerated||(k=this.generateIS(g,f,S));var X=this.isVideoContiguous,ie=-1;if(q&&(ie=a(f.samples),!X&&this.config.forceKeyFrameOnDiscontinuity))if(K=!0,ie>0){L.logger.warn("[mp4-remuxer]: Dropped "+ie+" out of "+$+" video samples due to a missing keyframe");var fe=this.getVideoStartPts(f.samples);f.samples=f.samples.slice(ie),f.dropped+=ie,F+=(f.samples[0].pts-fe)/(f.timescale||9e4)}else ie===-1&&(L.logger.warn("[mp4-remuxer]: No keyframe found out of "+$+" video samples"),K=!1);if(this.ISGenerated){if(Z&&q){var ue=this.getVideoStartPts(f.samples),Ae=i(g.samples[0].pts,ue)-ue,re=Ae/f.inputTimeScale;W+=Math.max(0,re),F+=Math.max(0,-re)}if(Z){if(g.samplerate||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),k=this.generateIS(g,f,S)),U=this.remuxAudio(g,W,this.isAudioContiguous,O,Y||q||P===_.PlaylistLevelType.AUDIO?F:void 0),q){var Q=U?U.endPTS-U.startPTS:0;f.inputTimeScale||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),k=this.generateIS(g,f,S)),w=this.remuxVideo(f,F,X,Q)}}else q&&(w=this.remuxVideo(f,F,X,0));w&&(w.firstKeyFrame=ie,w.independent=ie!==-1)}}return this.ISGenerated&&(c.samples.length&&(B=this.remuxID3(c,S)),x.samples.length&&(N=this.remuxText(x,S))),{audio:U,video:w,initSegment:k,independent:K,text:N,id3:B}},p.generateIS=function(g,f,c){var x=g.samples,S=f.samples,O=this.typeSupported,C={},P=!Object(l.isFiniteNumber)(this._initPTS),w="audio/mp4",U,k,N;if(P&&(U=k=1/0),g.config&&x.length&&(g.timescale=g.samplerate,g.isAAC||(O.mpeg?(w="audio/mpeg",g.codec=""):O.mp3&&(g.codec="mp3")),C.audio={id:"audio",container:w,codec:g.codec,initSegment:!g.isAAC&&O.mpeg?new Uint8Array(0):h.default.initSegment([g]),metadata:{channelCount:g.channelCount}},P&&(N=g.inputTimeScale,U=k=x[0].pts-Math.round(N*c))),f.sps&&f.pps&&S.length&&(f.timescale=f.inputTimeScale,C.video={id:"main",container:"video/mp4",codec:f.codec,initSegment:h.default.initSegment([f]),metadata:{width:f.width,height:f.height}},P)){N=f.inputTimeScale;var B=this.getVideoStartPts(S),K=Math.round(N*c);k=Math.min(k,i(S[0].dts,B)-K),U=Math.min(U,B-K)}if(Object.keys(C).length)return this.ISGenerated=!0,P&&(this._initPTS=U,this._initDTS=k),{tracks:C,initPTS:U,timescale:N}},p.remuxVideo=function(g,f,c,x){var S=g.inputTimeScale,O=g.samples,C=[],P=O.length,w=this._initPTS,U=this.nextAvcDts,k=8,N,B,K,W=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,H=0,Y=!1;if(!c||U===null){var $=f*S,Z=O[0].pts-i(O[0].dts,O[0].pts);U=$-Z}for(var q=0;q<P;q++){var oe=O[q];if(oe.pts=i(oe.pts-w,U),oe.dts=i(oe.dts-w,U),oe.dts>oe.pts){var X=9e4*.2;H=Math.max(Math.min(H,oe.pts-oe.dts),-1*X)}oe.dts<O[q>0?q-1:q].dts&&(Y=!0)}Y&&O.sort(function(Mt,Gt){var Rt=Mt.dts-Gt.dts,Vt=Mt.pts-Gt.pts;return Rt||Vt}),B=O[0].dts,K=O[O.length-1].dts;var ie=Math.round((K-B)/(P-1));if(H<0){if(H<ie*-2){L.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(E.toMsFromMpegTsClock)(-ie,!0)+" ms");for(var fe=H,ue=0;ue<P;ue++)O[ue].dts=fe=Math.max(fe,O[ue].pts-ie),O[ue].pts=Math.max(fe,O[ue].pts)}else{L.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(E.toMsFromMpegTsClock)(H,!0)+" ms to overcome this issue");for(var Ae=0;Ae<P;Ae++)O[Ae].dts=O[Ae].dts+H}B=O[0].dts}if(c){var re=B-U,Q=re>ie,te=re<-1;if(Q||te){Q?L.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):L.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),B=U;var ee=O[0].pts-re;O[0].dts=B,O[0].pts=ee,L.logger.log("Video: First PTS/DTS adjusted: "+Object(E.toMsFromMpegTsClock)(ee,!0)+"/"+Object(E.toMsFromMpegTsClock)(B,!0)+", delta: "+Object(E.toMsFromMpegTsClock)(re,!0)+" ms")}}r&&(B=Math.max(0,B));for(var he=0,Se=0,pe=0;pe<P;pe++){for(var Te=O[pe],Ie=Te.units,Ue=Ie.length,Ee=0,ye=0;ye<Ue;ye++)Ee+=Ie[ye].data.length;Se+=Ee,he+=Ue,Te.length=Ee,Te.dts=Math.max(Te.dts,B),Te.pts=Math.max(Te.pts,Te.dts,0),W=Math.min(Te.pts,W),F=Math.max(Te.pts,F)}K=O[P-1].dts;var Ne=Se+4*he+8,be;try{be=new Uint8Array(Ne)}catch{this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:T.ErrorTypes.MUX_ERROR,details:T.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ne,reason:"fail allocating video mdat "+Ne});return}var Ze=new DataView(be.buffer);Ze.setUint32(0,Ne),be.set(h.default.types.mdat,4);for(var we=0;we<P;we++){for(var $e=O[we],qe=$e.units,et=0,G=0,V=qe.length;G<V;G++){var de=qe[G],ce=de.data,Me=de.data.byteLength;Ze.setUint32(k,Me),k+=4,be.set(ce,k),k+=Me,et+=4+Me}if(we<P-1)N=O[we+1].dts-$e.dts;else{var Re=this.config,le=$e.dts-O[we>0?we-1:we].dts;if(Re.stretchShortVideoTrack&&this.nextAudioPts!==null){var Qe=Math.floor(Re.maxBufferHole*S),je=(x?W+x*S:this.nextAudioPts)-$e.pts;je>Qe?(N=je-le,N<0&&(N=le),L.logger.log("[mp4-remuxer]: It is approximately "+je/90+" ms to the next segment; using duration "+N/90+" ms for the last video frame.")):N=le}else N=le}var tt=Math.round($e.pts-$e.dts);C.push(new d($e.key,N,et,tt))}if(C.length&&A&&A<70){var Ht=C[0].flags;Ht.dependsOn=2,Ht.isNonSync=0}console.assert(N!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=U=K+N,this.isVideoContiguous=!0;var cr=h.default.moof(g.sequenceNumber++,B,I({},g,{samples:C})),dt="video",fr={data1:cr,data2:be,startPTS:W/S,endPTS:(F+N)/S,startDTS:B/S,endDTS:U/S,type:dt,hasAudio:!1,hasVideo:!0,nb:C.length,dropped:g.dropped};return g.samples=[],g.dropped=0,console.assert(be.length,"MDAT length must not be zero"),fr},p.remuxAudio=function(g,f,c,x,S){var O=g.inputTimeScale,C=g.samplerate?g.samplerate:O,P=O/C,w=g.isAAC?D:b,U=w*P,k=this._initPTS,N=!g.isAAC&&this.typeSupported.mpeg,B=[],K=g.samples,W=N?0:8,F=this.nextAudioPts||-1,H=f*O;if(this.isAudioContiguous=c=c||K.length&&F>0&&(x&&Math.abs(H-F)<9e3||Math.abs(i(K[0].pts-k,H)-F)<20*U),K.forEach(function(ce){ce.pts=i(ce.pts-k,H)}),!c||F<0){if(K=K.filter(function(ce){return ce.pts>=0}),!K.length)return;S===0?F=0:x?F=Math.max(0,H):F=K[0].pts}if(g.isAAC)for(var Y=S!==void 0,$=this.config.maxAudioFramesDrift,Z=0,q=F;Z<K.length;Z++){var oe=K[Z],X=oe.pts,ie=X-q,fe=Math.abs(1e3*ie/O);if(ie<=-$*U&&Y)Z===0&&(L.logger.warn("Audio frame @ "+(X/O).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ie/O)+" ms."),this.nextAudioPts=F=q=X);else if(ie>=$*U&&fe<M&&Y){var ue=Math.round(ie/U);q=X-ue*U,q<0&&(ue--,q+=U),Z===0&&(this.nextAudioPts=F=q),L.logger.warn("[mp4-remuxer]: Injecting "+ue+" audio frame @ "+(q/O).toFixed(3)+"s due to "+Math.round(1e3*ie/O)+" ms gap.");for(var Ae=0;Ae<ue;Ae++){var re=Math.max(q,0),Q=n.default.getSilentFrame(g.manifestCodec||g.codec,g.channelCount);Q||(L.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Q=oe.unit.subarray()),K.splice(Z,0,{unit:Q,pts:re}),q+=U,Z++}}oe.pts=q,q+=U}for(var te=null,ee=null,he,Se=0,pe=K.length;pe--;)Se+=K[pe].unit.byteLength;for(var Te=0,Ie=K.length;Te<Ie;Te++){var Ue=K[Te],Ee=Ue.unit,ye=Ue.pts;if(ee!==null){var Ne=B[Te-1];Ne.duration=Math.round((ye-ee)/P)}else if(c&&g.isAAC&&(ye=F),te=ye,Se>0){Se+=W;try{he=new Uint8Array(Se)}catch{this.observer.emit(R.Events.ERROR,R.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(!N){var be=new DataView(he.buffer);be.setUint32(0,Se),he.set(h.default.types.mdat,4)}}else return;he.set(Ee,W);var Ze=Ee.byteLength;W+=Ze,B.push(new d(!0,w,Ze,0)),ee=ye}var we=B.length;if(!!we){var $e=B[B.length-1];this.nextAudioPts=F=ee+P*$e.duration;var qe=N?new Uint8Array(0):h.default.moof(g.sequenceNumber++,te/P,I({},g,{samples:B}));g.samples=[];var et=te/O,G=F/O,V="audio",de={data1:qe,data2:he,startPTS:et,endPTS:G,startDTS:et,endDTS:G,type:V,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert(he.length,"MDAT length must not be zero"),de}},p.remuxEmptyAudio=function(g,f,c,x){var S=g.inputTimeScale,O=g.samplerate?g.samplerate:S,C=S/O,P=this.nextAudioPts,w=(P!==null?P:x.startDTS*S)+this._initDTS,U=x.endDTS*S+this._initDTS,k=C*D,N=Math.ceil((U-w)/k),B=n.default.getSilentFrame(g.manifestCodec||g.codec,g.channelCount);if(L.logger.warn("[mp4-remuxer]: remux empty Audio"),!B){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=[],W=0;W<N;W++){var F=w+W*k;K.push({unit:B,pts:F,dts:F})}return g.samples=K,this.remuxAudio(g,f,c,!1)},p.remuxID3=function(g,f){var c=g.samples.length;if(!!c){for(var x=g.inputTimeScale,S=this._initPTS,O=this._initDTS,C=0;C<c;C++){var P=g.samples[C];P.pts=i(P.pts-S,f*x)/x,P.dts=i(P.dts-O,f*x)/x}var w=g.samples;return g.samples=[],{samples:w}}},p.remuxText=function(g,f){var c=g.samples.length;if(!!c){for(var x=g.inputTimeScale,S=this._initPTS,O=0;O<c;O++){var C=g.samples[O];C.pts=i(C.pts-S,f*x)/x}g.samples.sort(function(w,U){return w.pts-U.pts});var P=g.samples;return g.samples=[],{samples:P}}},y}();function i(y,p){var m;if(p===null)return y;for(p<y?m=-8589934592:m=8589934592;Math.abs(y-p)>4294967296;)y+=m;return y}function a(y){for(var p=0;p<y.length;p++)if(y[p].key)return p;return-1}var d=function(p,m,g,f){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=g,this.cts=f,this.flags=new o(p)},o=function(p){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=p?2:1,this.isNonSync=p?0:1}},"./src/remux/passthrough-remuxer.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/polyfills/number.ts"),n=t("./src/utils/mp4-tools.ts"),h=t("./src/loader/fragment.ts"),R=t("./src/utils/logger.ts"),T=function(){function E(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var I=E.prototype;return I.destroy=function(){},I.resetTimeStamp=function(D){this.initPTS=D,this.lastEndDTS=null},I.resetNextTimestamp=function(){this.lastEndDTS=null},I.resetInitSegment=function(D,b,A){this.audioCodec=b,this.videoCodec=A,this.generateInitSegment(D),this.emitInitSegment=!0},I.generateInitSegment=function(D){var b=this.audioCodec,A=this.videoCodec;if(!D||!D.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(n.parseInitSegment)(D);b||(b=_(u.audio,h.ElementaryStreamTypes.AUDIO)),A||(A=_(u.video,h.ElementaryStreamTypes.VIDEO));var r={};u.audio&&u.video?r.audiovideo={container:"video/mp4",codec:b+","+A,initSegment:D,id:"main"}:u.audio?r.audio={container:"audio/mp4",codec:b,initSegment:D,id:"audio"}:u.video?r.video={container:"video/mp4",codec:A,initSegment:D,id:"main"}:R.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r},I.remux=function(D,b,A,u,r){var s=this.initPTS,i=this.lastEndDTS,a={audio:void 0,video:void 0,text:u,id3:A,initSegment:void 0};Object(l.isFiniteNumber)(i)||(i=this.lastEndDTS=r||0);var d=b.samples;if(!d||!d.length)return a;var o={initPTS:void 0,timescale:1},y=this.initData;if((!y||!y.length)&&(this.generateInitSegment(d),y=this.initData),!y||!y.length)return R.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),a;this.emitInitSegment&&(o.tracks=this.initTracks,this.emitInitSegment=!1),Object(l.isFiniteNumber)(s)||(this.initPTS=o.initPTS=s=L(y,d,i));var p=Object(n.getDuration)(d,y),m=i,g=p+m;Object(n.offsetStartDTS)(y,d,s),p>0?this.lastEndDTS=g:(R.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var f=!!y.audio,c=!!y.video,x="";f&&(x+="audio"),c&&(x+="video");var S={data1:d,startPTS:m,startDTS:m,endPTS:g,endDTS:g,type:x,hasAudio:f,hasVideo:c,nb:1,dropped:0};return a.audio=S.type==="audio"?S:void 0,a.video=S.type!=="audio"?S:void 0,a.text=u,a.id3=A,a.initSegment=o,a},E}(),L=function(I,M,D){return Object(n.getStartDTS)(I,M)-D};function _(E,I){var M=E==null?void 0:E.codec;return M&&M.length>4?M:M==="hvc1"?"hvc1.1.c.L120.90":M==="av01"?"av01.0.04M.08":M==="avc1"||I===h.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}e.default=T},"./src/task-loop.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return l});var l=function(){function n(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var h=n.prototype;return h.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},h.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},h.onHandlerDestroyed=function(){},h.hasInterval=function(){return!!this._tickInterval},h.hasNextTick=function(){return!!this._tickTimer},h.setInterval=function(T){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,T),!0)},h.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},h.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},h.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},h.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},h.doTick=function(){},n}()},"./src/types/cmcd.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"CMCDVersion",function(){return l}),t.d(e,"CMCDObjectType",function(){return n}),t.d(e,"CMCDStreamingFormat",function(){return h}),t.d(e,"CMCDStreamType",function(){return R});var l=1,n;(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"})(n||(n={}));var h;(function(T){T.DASH="d",T.HLS="h",T.SMOOTH="s",T.OTHER="o"})(h||(h={}));var R;(function(T){T.VOD="v",T.LIVE="l"})(R||(R={}))},"./src/types/level.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"HlsSkip",function(){return h}),t.d(e,"getSkipValue",function(){return R}),t.d(e,"HlsUrlParameters",function(){return T}),t.d(e,"Level",function(){return L});function l(_,E){for(var I=0;I<E.length;I++){var M=E[I];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(_,M.key,M)}}function n(_,E,I){return E&&l(_.prototype,E),I&&l(_,I),_}var h;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(h||(h={}));function R(_,E){var I=_.canSkipUntil,M=_.canSkipDateRanges,D=_.endSN,b=E!==void 0?E-D:0;return I&&b<I?M?h.v2:h.Yes:h.No}var T=function(){function _(I,M,D){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=I,this.part=M,this.skip=D}var E=_.prototype;return E.addDirectives=function(M){var D=new self.URL(M);return this.msn!==void 0&&D.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&D.searchParams.set("_HLS_part",this.part.toString()),this.skip&&D.searchParams.set("_HLS_skip",this.skip),D.toString()},_}(),L=function(){function _(E){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=[E.url],this.attrs=E.attrs,this.bitrate=E.bitrate,E.details&&(this.details=E.details),this.id=E.id||0,this.name=E.name,this.width=E.width||0,this.height=E.height||0,this.audioCodec=E.audioCodec,this.videoCodec=E.videoCodec,this.unknownCodecs=E.unknownCodecs,this.codecSet=[E.videoCodec,E.audioCodec].filter(function(I){return I}).join(",").replace(/\.[^.,]+/g,"")}return n(_,[{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(I){var M=I%this.url.length;this._urlId!==M&&(this.details=void 0,this._urlId=M)}}]),_}()},"./src/types/loader.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"PlaylistContextType",function(){return l}),t.d(e,"PlaylistLevelType",function(){return n});var l;(function(h){h.MANIFEST="manifest",h.LEVEL="level",h.AUDIO_TRACK="audioTrack",h.SUBTITLE_TRACK="subtitleTrack"})(l||(l={}));var n;(function(h){h.MAIN="main",h.AUDIO="audio",h.SUBTITLE="subtitle"})(n||(n={}))},"./src/types/transmuxer.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"ChunkMetadata",function(){return l});var l=function(R,T,L,_,E,I){_===void 0&&(_=0),E===void 0&&(E=-1),I===void 0&&(I=!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=n(),this.buffering={audio:n(),video:n(),audiovideo:n()},this.level=R,this.sn=T,this.id=L,this.size=_,this.part=E,this.partial=I};function n(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"AttrList",function(){return h});var l=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,h=function(){function R(L){typeof L=="string"&&(L=R.parseAttrList(L));for(var _ in L)L.hasOwnProperty(_)&&(this[_]=L[_])}var T=R.prototype;return T.decimalInteger=function(_){var E=parseInt(this[_],10);return E>Number.MAX_SAFE_INTEGER?1/0:E},T.hexadecimalInteger=function(_){if(this[_]){var E=(this[_]||"0x").slice(2);E=(E.length&1?"0":"")+E;for(var I=new Uint8Array(E.length/2),M=0;M<E.length/2;M++)I[M]=parseInt(E.slice(M*2,M*2+2),16);return I}else return null},T.hexadecimalIntegerAsNumber=function(_){var E=parseInt(this[_],16);return E>Number.MAX_SAFE_INTEGER?1/0:E},T.decimalFloatingPoint=function(_){return parseFloat(this[_])},T.optionalFloat=function(_,E){var I=this[_];return I?parseFloat(I):E},T.enumeratedString=function(_){return this[_]},T.bool=function(_){return this[_]==="YES"},T.decimalResolution=function(_){var E=l.exec(this[_]);if(E!==null)return{width:parseInt(E[1],10),height:parseInt(E[2],10)}},R.parseAttrList=function(_){var E,I={},M='"';for(n.lastIndex=0;(E=n.exec(_))!==null;){var D=E[2];D.indexOf(M)===0&&D.lastIndexOf(M)===D.length-1&&(D=D.slice(1,-1)),I[E[1]]=D}return I},R}()},"./src/utils/binary-search.ts":function(v,e,t){"use strict";t.r(e);var l={search:function(h,R){for(var T=0,L=h.length-1,_=null,E=null;T<=L;){_=(T+L)/2|0,E=h[_];var I=R(E);if(I>0)T=_+1;else if(I<0)L=_-1;else return E}return null}};e.default=l},"./src/utils/buffer-helper.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"BufferHelper",function(){return h});var l=t("./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},h=function(){function R(){}return R.isBuffered=function(L,_){try{if(L){for(var E=R.getBuffered(L),I=0;I<E.length;I++)if(_>=E.start(I)&&_<=E.end(I))return!0}}catch{}return!1},R.bufferInfo=function(L,_,E){try{if(L){var I=R.getBuffered(L),M=[],D;for(D=0;D<I.length;D++)M.push({start:I.start(D),end:I.end(D)});return this.bufferedInfo(M,_,E)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},R.bufferedInfo=function(L,_,E){_=Math.max(0,_),L.sort(function(o,y){var p=o.start-y.start;return p||y.end-o.end});var I=[];if(E)for(var M=0;M<L.length;M++){var D=I.length;if(D){var b=I[D-1].end;L[M].start-b<E?L[M].end>b&&(I[D-1].end=L[M].end):I.push(L[M])}else I.push(L[M])}else I=L;for(var A=0,u,r=_,s=_,i=0;i<I.length;i++){var a=I[i].start,d=I[i].end;if(_+E>=a&&_<d)r=a,s=d,A=s-_;else if(_+E<a){u=a;break}}return{len:A,start:r||0,end:s||0,nextStart:u}},R.getBuffered=function(L){try{return L.buffered}catch(_){return l.logger.log("failed to get media.buffered",_),n}},R}()},"./src/utils/cea-608-parser.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"Row",function(){return s}),t.d(e,"CaptionScreen",function(){return i});var l=t("./src/utils/logger.ts"),n={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},h=function(g){var f=g;return n.hasOwnProperty(g)&&(f=n[g]),String.fromCharCode(f)},R=15,T=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},E={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},I={25:2,26:4,29:6,30:8,31:10,27:13,28:15},M=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],D;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(D||(D={}));var b=function(){function m(){this.time=null,this.verboseLevel=D.ERROR}var g=m.prototype;return g.log=function(c,x){this.verboseLevel>=c&&l.logger.log(this.time+" ["+c+"] "+x)},m}(),A=function(g){for(var f=[],c=0;c<g.length;c++)f.push(g[c].toString(16));return f},u=function(){function m(f,c,x,S,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=c||!1,this.italics=x||!1,this.background=S||"black",this.flash=O||!1}var g=m.prototype;return g.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},g.setStyles=function(c){for(var x=["foreground","underline","italics","background","flash"],S=0;S<x.length;S++){var O=x[S];c.hasOwnProperty(O)&&(this[O]=c[O])}},g.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},g.equals=function(c){return this.foreground===c.foreground&&this.underline===c.underline&&this.italics===c.italics&&this.background===c.background&&this.flash===c.flash},g.copy=function(c){this.foreground=c.foreground,this.underline=c.underline,this.italics=c.italics,this.background=c.background,this.flash=c.flash},g.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),r=function(){function m(f,c,x,S,O,C){this.uchar=void 0,this.penState=void 0,this.uchar=f||" ",this.penState=new u(c,x,S,O,C)}var g=m.prototype;return g.reset=function(){this.uchar=" ",this.penState.reset()},g.setChar=function(c,x){this.uchar=c,this.penState.copy(x)},g.setPenState=function(c){this.penState.copy(c)},g.equals=function(c){return this.uchar===c.uchar&&this.penState.equals(c.penState)},g.copy=function(c){this.uchar=c.uchar,this.penState.copy(c.penState)},g.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),s=function(){function m(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 c=0;c<T;c++)this.chars.push(new r);this.logger=f,this.pos=0,this.currPenState=new u}var g=m.prototype;return g.equals=function(c){for(var x=!0,S=0;S<T;S++)if(!this.chars[S].equals(c.chars[S])){x=!1;break}return x},g.copy=function(c){for(var x=0;x<T;x++)this.chars[x].copy(c.chars[x])},g.isEmpty=function(){for(var c=!0,x=0;x<T;x++)if(!this.chars[x].isEmpty()){c=!1;break}return c},g.setCursor=function(c){this.pos!==c&&(this.pos=c),this.pos<0?(this.logger.log(D.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>T&&(this.logger.log(D.DEBUG,"Too large cursor position "+this.pos),this.pos=T)},g.moveCursor=function(c){var x=this.pos+c;if(c>1)for(var S=this.pos+1;S<x+1;S++)this.chars[S].setPenState(this.currPenState);this.setCursor(x)},g.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},g.insertChar=function(c){c>=144&&this.backSpace();var x=h(c);if(this.pos>=T){this.logger.log(D.ERROR,"Cannot insert "+c.toString(16)+" ("+x+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(x,this.currPenState),this.moveCursor(1)},g.clearFromPos=function(c){var x;for(x=c;x<T;x++)this.chars[x].reset()},g.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},g.clearToEndOfRow=function(){this.clearFromPos(this.pos)},g.getTextString=function(){for(var c=[],x=!0,S=0;S<T;S++){var O=this.chars[S].uchar;O!==" "&&(x=!1),c.push(O)}return x?"":c.join("")},g.setPenStyles=function(c){this.currPenState.setStyles(c);var x=this.chars[this.pos];x.setPenState(this.currPenState)},m}(),i=function(){function m(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 c=0;c<R;c++)this.rows.push(new s(f));this.logger=f,this.currRow=R-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var g=m.prototype;return g.reset=function(){for(var c=0;c<R;c++)this.rows[c].clear();this.currRow=R-1},g.equals=function(c){for(var x=!0,S=0;S<R;S++)if(!this.rows[S].equals(c.rows[S])){x=!1;break}return x},g.copy=function(c){for(var x=0;x<R;x++)this.rows[x].copy(c.rows[x])},g.isEmpty=function(){for(var c=!0,x=0;x<R;x++)if(!this.rows[x].isEmpty()){c=!1;break}return c},g.backSpace=function(){var c=this.rows[this.currRow];c.backSpace()},g.clearToEndOfRow=function(){var c=this.rows[this.currRow];c.clearToEndOfRow()},g.insertChar=function(c){var x=this.rows[this.currRow];x.insertChar(c)},g.setPen=function(c){var x=this.rows[this.currRow];x.setPenStyles(c)},g.moveCursor=function(c){var x=this.rows[this.currRow];x.moveCursor(c)},g.setCursor=function(c){this.logger.log(D.INFO,"setCursor: "+c);var x=this.rows[this.currRow];x.setCursor(c)},g.setPAC=function(c){this.logger.log(D.INFO,"pacData = "+JSON.stringify(c));var x=c.row-1;if(this.nrRollUpRows&&x<this.nrRollUpRows-1&&(x=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==x){for(var S=0;S<R;S++)this.rows[S].clear();var O=this.currRow+1-this.nrRollUpRows,C=this.lastOutputScreen;if(C){var P=C.rows[O].cueStartTime,w=this.logger.time;if(P&&w!==null&&P<w)for(var U=0;U<this.nrRollUpRows;U++)this.rows[x-this.nrRollUpRows+U+1].copy(C.rows[O+U])}}this.currRow=x;var k=this.rows[this.currRow];if(c.indent!==null){var N=c.indent,B=Math.max(N-1,0);k.setCursor(c.indent),c.color=k.chars[B].penState.foreground}var K={foreground:c.color,underline:c.underline,italics:c.italics,background:"black",flash:!1};this.setPen(K)},g.setBkgData=function(c){this.logger.log(D.INFO,"bkgData = "+JSON.stringify(c)),this.backSpace(),this.setPen(c),this.insertChar(32)},g.setRollUpRows=function(c){this.nrRollUpRows=c},g.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(D.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(D.TEXT,this.getDisplayText());var c=this.currRow+1-this.nrRollUpRows,x=this.rows.splice(c,1)[0];x.clear(),this.rows.splice(this.currRow,0,x),this.logger.log(D.INFO,"Rolling up")},g.getDisplayText=function(c){c=c||!1;for(var x=[],S="",O=-1,C=0;C<R;C++){var P=this.rows[C].getTextString();P&&(O=C+1,c?x.push("Row "+O+": '"+P+"'"):x.push(P.trim()))}return x.length>0&&(c?S="["+x.join(" | ")+"]":S=x.join(`
19
- `)),S},g.getTextAndFormat=function(){return this.rows},m}(),a=function(){function m(f,c,x){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=c,this.mode=null,this.verbose=0,this.displayedMemory=new i(x),this.nonDisplayedMemory=new i(x),this.lastOutputScreen=new i(x),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=x}var g=m.prototype;return g.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},g.getHandler=function(){return this.outputFilter},g.setHandler=function(c){this.outputFilter=c},g.setPAC=function(c){this.writeScreen.setPAC(c)},g.setBkgData=function(c){this.writeScreen.setBkgData(c)},g.setMode=function(c){c!==this.mode&&(this.mode=c,this.logger.log(D.INFO,"MODE="+c),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=c)},g.insertChars=function(c){for(var x=0;x<c.length;x++)this.writeScreen.insertChar(c[x]);var S=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(D.INFO,S+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(D.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},g.ccRCL=function(){this.logger.log(D.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},g.ccBS=function(){this.logger.log(D.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},g.ccAOF=function(){},g.ccAON=function(){},g.ccDER=function(){this.logger.log(D.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},g.ccRU=function(c){this.logger.log(D.INFO,"RU("+c+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(c)},g.ccFON=function(){this.logger.log(D.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},g.ccRDC=function(){this.logger.log(D.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},g.ccTR=function(){this.logger.log(D.INFO,"TR"),this.setMode("MODE_TEXT")},g.ccRTD=function(){this.logger.log(D.INFO,"RTD"),this.setMode("MODE_TEXT")},g.ccEDM=function(){this.logger.log(D.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},g.ccCR=function(){this.logger.log(D.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},g.ccENM=function(){this.logger.log(D.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},g.ccEOC=function(){if(this.logger.log(D.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var c=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=c,this.writeScreen=this.nonDisplayedMemory,this.logger.log(D.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},g.ccTO=function(c){this.logger.log(D.INFO,"TO("+c+") - Tab Offset"),this.writeScreen.moveCursor(c)},g.ccMIDROW=function(c){var x={flash:!1};if(x.underline=c%2==1,x.italics=c>=46,x.italics)x.foreground="white";else{var S=Math.floor(c/2)-16,O=["white","green","blue","cyan","red","yellow","magenta"];x.foreground=O[S]}this.logger.log(D.INFO,"MIDROW: "+JSON.stringify(x)),this.writeScreen.setPen(x)},g.outputDataUpdate=function(c){c===void 0&&(c=!1);var x=this.logger.time;x!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=x:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,x,this.lastOutputScreen),c&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:x),this.lastOutputScreen.copy(this.displayedMemory))},g.cueSplitAtTime=function(c){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,c,this.displayedMemory),this.cueStartTime=c))},m}(),d=function(){function m(f,c,x){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var S=new b;this.channels=[null,new a(f,c,S),new a(f+1,x,S)],this.cmdHistory=p(),this.logger=S}var g=m.prototype;return g.getHandler=function(c){return this.channels[c].getHandler()},g.setHandler=function(c,x){this.channels[c].setHandler(x)},g.addData=function(c,x){var S,O,C,P=!1;this.logger.time=c;for(var w=0;w<x.length;w+=2)if(O=x[w]&127,C=x[w+1]&127,!(O===0&&C===0)){if(this.logger.log(D.DATA,"["+A([x[w],x[w+1]])+"] -> ("+A([O,C])+")"),S=this.parseCmd(O,C),S||(S=this.parseMidrow(O,C)),S||(S=this.parsePAC(O,C)),S||(S=this.parseBackgroundAttributes(O,C)),!S&&(P=this.parseChars(O,C),P)){var U=this.currentChannel;if(U&&U>0){var k=this.channels[U];k.insertChars(P)}else this.logger.log(D.WARNING,"No channel found yet. TEXT-MODE?")}!S&&!P&&this.logger.log(D.WARNING,"Couldn't parse cleaned data "+A([O,C])+" orig: "+A([x[w],x[w+1]]))}},g.parseCmd=function(c,x){var S=this.cmdHistory,O=(c===20||c===28||c===21||c===29)&&x>=32&&x<=47,C=(c===23||c===31)&&x>=33&&x<=35;if(!(O||C))return!1;if(y(c,x,S))return o(null,null,S),this.logger.log(D.DEBUG,"Repeated command ("+A([c,x])+") is dropped"),!0;var P=c===20||c===21||c===23?1:2,w=this.channels[P];return c===20||c===21||c===28||c===29?x===32?w.ccRCL():x===33?w.ccBS():x===34?w.ccAOF():x===35?w.ccAON():x===36?w.ccDER():x===37?w.ccRU(2):x===38?w.ccRU(3):x===39?w.ccRU(4):x===40?w.ccFON():x===41?w.ccRDC():x===42?w.ccTR():x===43?w.ccRTD():x===44?w.ccEDM():x===45?w.ccCR():x===46?w.ccENM():x===47&&w.ccEOC():w.ccTO(x-32),o(c,x,S),this.currentChannel=P,!0},g.parseMidrow=function(c,x){var S=0;if((c===17||c===25)&&x>=32&&x<=47){if(c===17?S=1:S=2,S!==this.currentChannel)return this.logger.log(D.ERROR,"Mismatch channel in midrow parsing"),!1;var O=this.channels[S];return O?(O.ccMIDROW(x),this.logger.log(D.DEBUG,"MIDROW ("+A([c,x])+")"),!0):!1}return!1},g.parsePAC=function(c,x){var S,O=this.cmdHistory,C=(c>=17&&c<=23||c>=25&&c<=31)&&x>=64&&x<=127,P=(c===16||c===24)&&x>=64&&x<=95;if(!(C||P))return!1;if(y(c,x,O))return o(null,null,O),!0;var w=c<=23?1:2;x>=64&&x<=95?S=w===1?L[c]:E[c]:S=w===1?_[c]:I[c];var U=this.channels[w];return U?(U.setPAC(this.interpretPAC(S,x)),o(c,x,O),this.currentChannel=w,!0):!1},g.interpretPAC=function(c,x){var S,O={color:null,italics:!1,indent:null,underline:!1,row:c};return x>95?S=x-96:S=x-64,O.underline=(S&1)==1,S<=13?O.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(S/2)]:S<=15?(O.italics=!0,O.color="white"):O.indent=Math.floor((S-16)/2)*4,O},g.parseChars=function(c,x){var S,O=null,C=null;if(c>=25?(S=2,C=c-8):(S=1,C=c),C>=17&&C<=19){var P;C===17?P=x+80:C===18?P=x+112:P=x+144,this.logger.log(D.INFO,"Special char '"+h(P)+"' in channel "+S),O=[P]}else c>=32&&c<=127&&(O=x===0?[c]:[c,x]);if(O){var w=A(O);this.logger.log(D.DEBUG,"Char codes = "+w.join(",")),o(c,x,this.cmdHistory)}return O},g.parseBackgroundAttributes=function(c,x){var S=(c===16||c===24)&&x>=32&&x<=47,O=(c===23||c===31)&&x>=45&&x<=47;if(!(S||O))return!1;var C,P={};c===16||c===24?(C=Math.floor((x-32)/2),P.background=M[C],x%2==1&&(P.background=P.background+"_semi")):x===45?P.background="transparent":(P.foreground="black",x===47&&(P.underline=!0));var w=c<=23?1:2,U=this.channels[w];return U.setBkgData(P),o(c,x,this.cmdHistory),!0},g.reset=function(){for(var c=0;c<Object.keys(this.channels).length;c++){var x=this.channels[c];x&&x.reset()}this.cmdHistory=p()},g.cueSplitAtTime=function(c){for(var x=0;x<this.channels.length;x++){var S=this.channels[x];S&&S.cueSplitAtTime(c)}},m}();function o(m,g,f){f.a=m,f.b=g}function y(m,g,f){return f.a===m&&f.b===g}function p(){return{a:null,b:null}}e.default=d},"./src/utils/codecs.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"isCodecType",function(){return n}),t.d(e,"isCodecSupportedInMp4",function(){return h});var l={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 n(R,T){var L=l[T];return!!L&&L[R.slice(0,4)]===!0}function h(R,T){return MediaSource.isTypeSupported((T||"video")+'/mp4;codecs="'+R+'"')}},"./src/utils/cues.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/utils/vttparser.ts"),n=t("./src/utils/webvtt-parser.ts"),h=t("./src/utils/texttrack-utils.ts"),R=/\s/,T={newCue:function(_,E,I,M){for(var D=[],b,A,u,r,s,i=self.VTTCue||self.TextTrackCue,a=0;a<M.rows.length;a++)if(b=M.rows[a],u=!0,r=0,s="",!b.isEmpty()){for(var d=0;d<b.chars.length;d++)R.test(b.chars[d].uchar)&&u?r++:(s+=b.chars[d].uchar,u=!1);b.cueStartTime=E,E===I&&(I+=1e-4),r>=16?r--:r++;var o=Object(l.fixLineBreaks)(s.trim()),y=Object(n.generateCueId)(E,I,o);(!_||!_.cues||!_.cues.getCueById(y))&&(A=new i(E,I,o),A.id=y,A.line=a+1,A.align="left",A.position=10+Math.min(80,Math.floor(r*8/32)*10),D.push(A))}return _&&D.length&&(D.sort(function(p,m){return p.line==="auto"||m.line==="auto"?0:p.line>8&&m.line>8?m.line-p.line:p.line-m.line}),D.forEach(function(p){return Object(h.addCueToTrack)(_,p)})),D}};e.default=T},"./src/utils/discontinuities.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"findFirstFragWithCC",function(){return R}),t.d(e,"shouldAlignOnDiscontinuities",function(){return T}),t.d(e,"findDiscontinuousReferenceFrag",function(){return L}),t.d(e,"adjustSlidingStart",function(){return E}),t.d(e,"alignStream",function(){return I}),t.d(e,"alignPDT",function(){return D}),t.d(e,"alignFragmentByPDTDelta",function(){return b}),t.d(e,"alignMediaPlaylistByPDT",function(){return A});var l=t("./src/polyfills/number.ts"),n=t("./src/utils/logger.ts"),h=t("./src/controller/level-helper.ts");function R(u,r){for(var s=null,i=0,a=u.length;i<a;i++){var d=u[i];if(d&&d.cc===r){s=d;break}}return s}function T(u,r,s){return!!(r.details&&(s.endCC>s.startCC||u&&u.cc<s.startCC))}function L(u,r){var s=u.fragments,i=r.fragments;if(!i.length||!s.length){n.logger.log("No fragments to align");return}var a=R(s,i[0].cc);if(!a||a&&!a.startPTS){n.logger.log("No frag in previous level to align on");return}return a}function _(u,r){if(u){var s=u.start+r;u.start=u.startPTS=s,u.endPTS=s+u.duration}}function E(u,r){for(var s=r.fragments,i=0,a=s.length;i<a;i++)_(s[i],u);r.fragmentHint&&_(r.fragmentHint,u),r.alignedSliding=!0}function I(u,r,s){!r||(M(u,s,r),!s.alignedSliding&&r.details&&D(s,r.details),!s.alignedSliding&&r.details&&!s.skippedSegments&&Object(h.adjustSliding)(r.details,s))}function M(u,r,s){if(T(u,s,r)){var i=L(s.details,r);i&&Object(l.isFiniteNumber)(i.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+r.url),E(i.start,r))}}function D(u,r){if(!(!r.fragments.length||!u.hasProgramDateTime||!r.hasProgramDateTime)){var s=r.fragments[0].programDateTime,i=u.fragments[0].programDateTime,a=(i-s)/1e3+r.fragments[0].start;a&&Object(l.isFiniteNumber)(a)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(i-s)+"ms, sliding:"+a.toFixed(3)+" "+u.url+" "),E(a,u))}}function b(u,r){var s=u.programDateTime;if(!!s){var i=(s-r)/1e3;u.start=u.startPTS=i,u.endPTS=i+u.duration}}function A(u,r){if(!(!r.fragments.length||!u.hasProgramDateTime||!r.hasProgramDateTime)){var s=r.fragments[0].programDateTime,i=r.fragments[0].start,a=s-i*1e3;u.fragments.forEach(function(d){b(d,a)}),u.fragmentHint&&b(u.fragmentHint,a),u.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/utils/ewma.ts"),n=function(){function h(T,L,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new l.default(T),this.fast_=new l.default(L)}var R=h.prototype;return R.update=function(L,_){var E=this.slow_,I=this.fast_;this.slow_.halfLife!==L&&(this.slow_=new l.default(L,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new l.default(_,I.getEstimate(),I.getTotalWeight()))},R.sample=function(L,_){L=Math.max(L,this.minDelayMs_);var E=8*_,I=L/1e3,M=E/I;this.fast_.sample(I,M),this.slow_.sample(I,M)},R.canEstimate=function(){var L=this.fast_;return L&&L.getTotalWeight()>=this.minWeight_},R.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},R.destroy=function(){},h}();e.default=n},"./src/utils/ewma.ts":function(v,e,t){"use strict";t.r(e);var l=function(){function n(R,T,L){T===void 0&&(T=0),L===void 0&&(L=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=R,this.alpha_=R?Math.exp(Math.log(.5)/R):0,this.estimate_=T,this.totalWeight_=L}var h=n.prototype;return h.sample=function(T,L){var _=Math.pow(this.alpha_,T);this.estimate_=L*(1-_)+_*this.estimate_,this.totalWeight_+=T},h.getTotalWeight=function(){return this.totalWeight_},h.getEstimate=function(){if(this.alpha_){var T=1-Math.pow(this.alpha_,this.totalWeight_);if(T)return this.estimate_/T}return this.estimate_},n}();e.default=l},"./src/utils/fetch-loader.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"fetchSupported",function(){return b});var l=t("./src/polyfills/number.ts"),n=t("./src/loader/load-stats.ts"),h=t("./src/demux/chunk-cache.ts");function R(i,a){i.prototype=Object.create(a.prototype),i.prototype.constructor=i,I(i,a)}function T(i){var a=typeof Map=="function"?new Map:void 0;return T=function(o){if(o===null||!E(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(o))return a.get(o);a.set(o,y)}function y(){return L(o,arguments,M(this).constructor)}return y.prototype=Object.create(o.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),I(y,o)},T(i)}function L(i,a,d){return _()?L=Reflect.construct:L=function(y,p,m){var g=[null];g.push.apply(g,p);var f=Function.bind.apply(y,g),c=new f;return m&&I(c,m.prototype),c},L.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 E(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function I(i,a){return I=Object.setPrototypeOf||function(o,y){return o.__proto__=y,o},I(i,a)}function M(i){return M=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},M(i)}function D(){return D=Object.assign||function(i){for(var a=1;a<arguments.length;a++){var d=arguments[a];for(var o in d)Object.prototype.hasOwnProperty.call(d,o)&&(i[o]=d[o])}return i},D.apply(this,arguments)}function b(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var A=function(){function i(d){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=d.fetchSetup||r,this.controller=new self.AbortController,this.stats=new n.LoadStats}var a=i.prototype;return a.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},a.abortInternal=function(){var o=this.response;(!o||!o.ok)&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var o;this.abortInternal(),(o=this.callbacks)!==null&&o!==void 0&&o.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(o,y,p){var m=this,g=this.stats;if(g.loading.start)throw new Error("Loader can only be used once.");g.loading.start=self.performance.now();var f=u(o,this.controller.signal),c=p.onProgress,x=o.responseType==="arraybuffer",S=x?"byteLength":"length";this.context=o,this.config=y,this.callbacks=p,this.request=this.fetchSetup(o,f),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){m.abortInternal(),p.onTimeout(g,o,m.response)},y.timeout),self.fetch(this.request).then(function(O){if(m.response=m.loader=O,!O.ok){var C=O.status,P=O.statusText;throw new s(P||"fetch, bad network response",C,O)}return g.loading.first=Math.max(self.performance.now(),g.loading.start),g.total=parseInt(O.headers.get("Content-Length")||"0"),c&&Object(l.isFiniteNumber)(y.highWaterMark)?m.loadProgressively(O,g,o,y.highWaterMark,c):x?O.arrayBuffer():O.text()}).then(function(O){var C=m.response;self.clearTimeout(m.requestTimeout),g.loading.end=Math.max(self.performance.now(),g.loading.first),g.loaded=g.total=O[S];var P={url:C.url,data:O};c&&!Object(l.isFiniteNumber)(y.highWaterMark)&&c(g,o,O,C),p.onSuccess(P,g,o,C)}).catch(function(O){if(self.clearTimeout(m.requestTimeout),!g.aborted){var C=O.code||0;p.onError({code:C,text:O.message},o,O.details)}})},a.getCacheAge=function(){var o=null;if(this.response){var y=this.response.headers.get("age");o=y?parseFloat(y):null}return o},a.loadProgressively=function(o,y,p,m,g){m===void 0&&(m=0);var f=new h.default,c=o.body.getReader(),x=function S(){return c.read().then(function(O){if(O.done)return f.dataLength&&g(y,p,f.flush(),o),Promise.resolve(new ArrayBuffer(0));var C=O.value,P=C.length;return y.loaded+=P,P<m||f.dataLength?(f.push(C),f.dataLength>=m&&g(y,p,f.flush(),o)):g(y,p,C,o),S()}).catch(function(){return Promise.reject()})};return x()},i}();function u(i,a){var d={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(D({},i.headers))};return i.rangeEnd&&d.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),d}function r(i,a){return new self.Request(i.url,a)}var s=function(i){R(a,i);function a(d,o,y){var p;return p=i.call(this,d)||this,p.code=void 0,p.details=void 0,p.code=o,p.details=y,p}return a}(T(Error));e.default=A},"./src/utils/imsc1-ttml-parser.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"IMSC1_CODEC",function(){return E}),t.d(e,"parseIMSC1",function(){return b});var l=t("./src/utils/mp4-tools.ts"),n=t("./src/utils/vttparser.ts"),h=t("./src/utils/vttcue.ts"),R=t("./src/demux/id3.ts"),T=t("./src/utils/timescale-conversion.ts"),L=t("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign||function(m){for(var g=1;g<arguments.length;g++){var f=arguments[g];for(var c in f)Object.prototype.hasOwnProperty.call(f,c)&&(m[c]=f[c])}return m},_.apply(this,arguments)}var E="stpp.ttml.im1t",I=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,M=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,D={left:"start",center:"center",right:"end",start:"start",end:"end"};function b(m,g,f,c,x){var S=Object(l.findBox)(new Uint8Array(m),["mdat"]);if(S.length===0){x(new Error("Could not parse IMSC1 mdat"));return}var O=S[0],C=Object(R.utf8ArrayToStr)(new Uint8Array(m,O.start,O.end-O.start)),P=Object(T.toTimescaleFromScale)(g,1,f);try{c(A(C,P))}catch(w){x(w)}}function A(m,g){var f=new DOMParser,c=f.parseFromString(m,"text/xml"),x=c.getElementsByTagName("tt")[0];if(!x)throw new Error("Invalid ttml");var S={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},O=Object.keys(S).reduce(function(k,N){return k[N]=x.getAttribute("ttp:"+N)||S[N],k},{}),C=x.getAttribute("xml:space")!=="preserve",P=r(u(x,"styling","style")),w=r(u(x,"layout","region")),U=u(x,"body","[begin]");return[].map.call(U,function(k){var N=s(k,C);if(!N||!k.hasAttribute("begin"))return null;var B=o(k.getAttribute("begin"),O),K=o(k.getAttribute("dur"),O),W=o(k.getAttribute("end"),O);if(B===null)throw d(k);if(W===null){if(K===null)throw d(k);W=B+K}var F=new h.default(B-g,W-g,N);F.id=Object(L.generateCueId)(F.startTime,F.endTime,F.text);var H=w[k.getAttribute("region")],Y=P[k.getAttribute("style")];F.position=10,F.size=80;var $=i(H,Y),Z=$.textAlign;if(Z){var q=D[Z];q&&(F.lineAlign=q),F.align=Z}return _(F,$),F}).filter(function(k){return k!==null})}function u(m,g,f){var c=m.getElementsByTagName(g)[0];return c?[].slice.call(c.querySelectorAll(f)):[]}function r(m){return m.reduce(function(g,f){var c=f.getAttribute("xml:id");return c&&(g[c]=f),g},{})}function s(m,g){return[].slice.call(m.childNodes).reduce(function(f,c,x){var S;return c.nodeName==="br"&&x?f+`
20
- `:(S=c.childNodes)!==null&&S!==void 0&&S.length?s(c,g):g?f+c.textContent.trim().replace(/\s+/g," "):f+c.textContent},"")}function i(m,g){var f="http://www.w3.org/ns/ttml#styling",c=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return c.reduce(function(x,S){var O=a(g,f,S)||a(m,f,S);return O&&(x[S]=O),x},{})}function a(m,g,f){return m.hasAttributeNS(g,f)?m.getAttributeNS(g,f):null}function d(m){return new Error("Could not parse ttml timestamp "+m)}function o(m,g){if(!m)return null;var f=Object(n.parseTimeStamp)(m);return f===null&&(I.test(m)?f=y(m,g):M.test(m)&&(f=p(m,g))),f}function y(m,g){var f=I.exec(m),c=(f[4]|0)+(f[5]|0)/g.subFrameRate;return(f[1]|0)*3600+(f[2]|0)*60+(f[3]|0)+c/g.frameRate}function p(m,g){var f=M.exec(m),c=Number(f[1]),x=f[2];switch(x){case"h":return c*3600;case"m":return c*60;case"ms":return c*1e3;case"f":return c/g.frameRate;case"t":return c/g.tickRate}return c}},"./src/utils/logger.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"enableLogs",function(){return L}),t.d(e,"logger",function(){return _});var l=function(){},n={trace:l,debug:l,log:l,warn:l,info:l,error:l},h=n;function R(E){var I=self.console[E];return I?I.bind(self.console,"["+E+"] >"):l}function T(E){for(var I=arguments.length,M=new Array(I>1?I-1:0),D=1;D<I;D++)M[D-1]=arguments[D];M.forEach(function(b){h[b]=E[b]?E[b].bind(E):R(b)})}function L(E){if(self.console&&E===!0||typeof E=="object"){T(E,"debug","log","info","warn","error");try{h.log()}catch{h=n}}else h=n}var _=h},"./src/utils/mediakeys-helper.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"KeySystems",function(){return l}),t.d(e,"requestMediaKeySystemAccess",function(){return n});var l;(function(h){h.WIDEVINE="com.widevine.alpha",h.PLAYREADY="com.microsoft.playready"})(l||(l={}));var n=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"getMediaSource",function(){return l});function l(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"bin2str",function(){return T}),t.d(e,"readUint16",function(){return L}),t.d(e,"readUint32",function(){return _}),t.d(e,"writeUint32",function(){return E}),t.d(e,"findBox",function(){return I}),t.d(e,"parseSegmentIndex",function(){return M}),t.d(e,"parseInitSegment",function(){return D}),t.d(e,"getStartDTS",function(){return b}),t.d(e,"getDuration",function(){return A}),t.d(e,"computeRawDurationFromSamples",function(){return u}),t.d(e,"offsetStartDTS",function(){return r}),t.d(e,"segmentValidRange",function(){return s}),t.d(e,"appendUint8Array",function(){return i});var l=t("./src/utils/typed-array.ts"),n=t("./src/loader/fragment.ts"),h=Math.pow(2,32)-1,R=[].push;function T(a){return String.fromCharCode.apply(null,a)}function L(a,d){"data"in a&&(d+=a.start,a=a.data);var o=a[d]<<8|a[d+1];return o<0?65536+o:o}function _(a,d){"data"in a&&(d+=a.start,a=a.data);var o=a[d]<<24|a[d+1]<<16|a[d+2]<<8|a[d+3];return o<0?4294967296+o:o}function E(a,d,o){"data"in a&&(d+=a.start,a=a.data),a[d]=o>>24,a[d+1]=o>>16&255,a[d+2]=o>>8&255,a[d+3]=o&255}function I(a,d){var o=[];if(!d.length)return o;var y,p,m;"data"in a?(y=a.data,p=a.start,m=a.end):(y=a,p=0,m=y.byteLength);for(var g=p;g<m;){var f=_(y,g),c=T(y.subarray(g+4,g+8)),x=f>1?g+f:m;if(c===d[0])if(d.length===1)o.push({data:y,start:g+8,end:x});else{var S=I({data:y,start:g+8,end:x},d.slice(1));S.length&&R.apply(o,S)}g=x}return o}function M(a){var d=I(a,["moov"]),o=d[0],y=o?o.end:null,p=I(a,["sidx"]);if(!p||!p[0])return null;var m=[],g=p[0],f=g.data[0],c=f===0?8:16,x=_(g,c);c+=4;var S=0,O=0;f===0?c+=8:c+=16,c+=2;var C=g.end+O,P=L(g,c);c+=2;for(var w=0;w<P;w++){var U=c,k=_(g,U);U+=4;var N=k&2147483647,B=(k&2147483648)>>>31;if(B===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var K=_(g,U);U+=4,m.push({referenceSize:N,subsegmentDuration:K,info:{duration:K/x,start:C,end:C+N-1}}),C+=N,U+=4,c=U}return{earliestPresentationTime:S,timescale:x,version:f,referencesCount:P,references:m,moovEndOffset:y}}function D(a){for(var d=[],o=I(a,["moov","trak"]),y=0;y<o.length;y++){var p=o[y],m=I(p,["tkhd"])[0];if(m){var g=m.data[m.start],f=g===0?12:20,c=_(m,f),x=I(p,["mdia","mdhd"])[0];if(x){g=x.data[x.start],f=g===0?12:20;var S=_(x,f),O=I(p,["mdia","hdlr"])[0];if(O){var C=T(O.data.subarray(O.start+8,O.start+12)),P={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[C];if(P){var w=I(p,["mdia","minf","stbl","stsd"])[0],U=void 0;w&&(U=T(w.data.subarray(w.start+12,w.start+16))),d[c]={timescale:S,type:P},d[P]={timescale:S,id:c,codec:U}}}}}}var k=I(a,["moov","mvex","trex"]);return k.forEach(function(N){var B=_(N,4),K=d[B];K&&(K.default={duration:_(N,12),flags:_(N,20)})}),d}function b(a,d){return I(d,["moof","traf"]).reduce(function(o,y){var p=I(y,["tfdt"])[0],m=p.data[p.start],g=I(y,["tfhd"]).reduce(function(f,c){var x=_(c,4),S=a[x];if(S){var O=_(p,4);m===1&&(O*=Math.pow(2,32),O+=_(p,8));var C=S.timescale||9e4,P=O/C;if(isFinite(P)&&(f===null||P<f))return P}return f},null);return g!==null&&isFinite(g)&&(o===null||g<o)?g:o},null)||0}function A(a,d){for(var o=0,y=0,p=0,m=I(a,["moof","traf"]),g=0;g<m.length;g++){var f=m[g],c=I(f,["tfhd"])[0],x=_(c,4),S=d[x];if(!!S){var O=S.default,C=_(c,0)|(O==null?void 0:O.flags),P=O==null?void 0:O.duration;C&8&&(C&2?P=_(c,12):P=_(c,8));for(var w=S.timescale||9e4,U=I(f,["trun"]),k=0;k<U.length;k++){if(o=u(U[k]),!o&&P){var N=_(U[k],4);o=P*N}S.type===n.ElementaryStreamTypes.VIDEO?y+=o/w:S.type===n.ElementaryStreamTypes.AUDIO&&(p+=o/w)}}}if(y===0&&p===0){var B=M(a);if(B!=null&&B.references)return B.references.reduce(function(K,W){return K+W.info.duration||0},0)}return y||p}function u(a){var d=_(a,0),o=8;d&1&&(o+=4),d&4&&(o+=4);for(var y=0,p=_(a,4),m=0;m<p;m++){if(d&256){var g=_(a,o);y+=g,o+=4}d&512&&(o+=4),d&1024&&(o+=4),d&2048&&(o+=4)}return y}function r(a,d,o){I(d,["moof","traf"]).forEach(function(y){I(y,["tfhd"]).forEach(function(p){var m=_(p,4),g=a[m];if(!!g){var f=g.timescale||9e4;I(y,["tfdt"]).forEach(function(c){var x=c.data[c.start],S=_(c,4);if(x===0)E(c,4,S-o*f);else{S*=Math.pow(2,32),S+=_(c,8),S-=o*f,S=Math.max(S,0);var O=Math.floor(S/(h+1)),C=Math.floor(S%(h+1));E(c,4,O),E(c,8,C)}})}})})}function s(a){var d={valid:null,remainder:null},o=I(a,["moof"]);if(o){if(o.length<2)return d.remainder=a,d}else return d;var y=o[o.length-1];return d.valid=Object(l.sliceUint8)(a,0,y.start-8),d.remainder=Object(l.sliceUint8)(a,y.start-8),d}function i(a,d){var o=new Uint8Array(a.length+d.length);return o.set(a),o.set(d,a.length),o}},"./src/utils/output-filter.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"default",function(){return l});var l=function(){function n(R,T){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=R,this.trackName=T}var h=n.prototype;return h.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},h.newCue=function(T,L,_){(this.startTime===null||this.startTime>T)&&(this.startTime=T),this.endTime=L,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},h.reset=function(){this.cueRanges=[],this.startTime=null},n}()},"./src/utils/texttrack-utils.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"sendAddTrackEvent",function(){return n}),t.d(e,"addCueToTrack",function(){return h}),t.d(e,"clearCurrentCues",function(){return R}),t.d(e,"removeCuesInRange",function(){return T}),t.d(e,"getCuesInRange",function(){return _});var l=t("./src/utils/logger.ts");function n(E,I){var M;try{M=new Event("addtrack")}catch{M=document.createEvent("Event"),M.initEvent("addtrack",!1,!1)}M.track=E,I.dispatchEvent(M)}function h(E,I){var M=E.mode;if(M==="disabled"&&(E.mode="hidden"),E.cues&&!E.cues.getCueById(I.id))try{if(E.addCue(I),!E.cues.getCueById(I.id))throw new Error("addCue is failed for: "+I)}catch(b){l.logger.debug("[texttrack-utils]: "+b);var D=new self.TextTrackCue(I.startTime,I.endTime,I.text);D.id=I.id,E.addCue(D)}M==="disabled"&&(E.mode=M)}function R(E){var I=E.mode;if(I==="disabled"&&(E.mode="hidden"),E.cues)for(var M=E.cues.length;M--;)E.removeCue(E.cues[M]);I==="disabled"&&(E.mode=I)}function T(E,I,M){var D=E.mode;if(D==="disabled"&&(E.mode="hidden"),E.cues&&E.cues.length>0)for(var b=_(E.cues,I,M),A=0;A<b.length;A++)E.removeCue(b[A]);D==="disabled"&&(E.mode=D)}function L(E,I){if(I<E[0].startTime)return 0;var M=E.length-1;if(I>E[M].endTime)return-1;for(var D=0,b=M;D<=b;){var A=Math.floor((b+D)/2);if(I<E[A].startTime)b=A-1;else if(I>E[A].startTime&&D<M)D=A+1;else return A}return E[D].startTime-I<I-E[b].startTime?D:b}function _(E,I,M){var D=[],b=L(E,I);if(b>-1)for(var A=b,u=E.length;A<u;A++){var r=E[A];if(r.startTime>=I&&r.endTime<=M)D.push(r);else if(r.startTime>M)return D}return D}},"./src/utils/time-ranges.ts":function(v,e,t){"use strict";t.r(e);var l={toString:function(h){for(var R="",T=h.length,L=0;L<T;L++)R+="["+h.start(L).toFixed(3)+","+h.end(L).toFixed(3)+"]";return R}};e.default=l},"./src/utils/timescale-conversion.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"toTimescaleFromBase",function(){return n}),t.d(e,"toTimescaleFromScale",function(){return h}),t.d(e,"toMsFromMpegTsClock",function(){return R}),t.d(e,"toMpegTsClockFromTimescale",function(){return T});var l=9e4;function n(L,_,E,I){E===void 0&&(E=1),I===void 0&&(I=!1);var M=L*_*E;return I?Math.round(M):M}function h(L,_,E,I){return E===void 0&&(E=1),I===void 0&&(I=!1),n(L,_,1/E,I)}function R(L,_){return _===void 0&&(_=!1),n(L,1e3,1/l,_)}function T(L,_){return _===void 0&&(_=1),n(L,l,1/_)}},"./src/utils/typed-array.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"sliceUint8",function(){return l});function l(n,h,R){return Uint8Array.prototype.slice?n.slice(h,R):new Uint8Array(Array.prototype.slice.call(n,h,R))}},"./src/utils/vttcue.ts":function(v,e,t){"use strict";t.r(e),e.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var l=["","lr","rl"],n=["start","middle","end","left","right"];function h(E,I){if(typeof I!="string"||!Array.isArray(E))return!1;var M=I.toLowerCase();return~E.indexOf(M)?M:!1}function R(E){return h(l,E)}function T(E){return h(n,E)}function L(E){for(var I=arguments.length,M=new Array(I>1?I-1:0),D=1;D<I;D++)M[D-1]=arguments[D];for(var b=1;b<arguments.length;b++){var A=arguments[b];for(var u in A)E[u]=A[u]}return E}function _(E,I,M){var D=this,b={enumerable:!0};D.hasBeenReset=!1;var A="",u=!1,r=E,s=I,i=M,a=null,d="",o=!0,y="auto",p="start",m=50,g="middle",f=50,c="middle";Object.defineProperty(D,"id",L({},b,{get:function(){return A},set:function(S){A=""+S}})),Object.defineProperty(D,"pauseOnExit",L({},b,{get:function(){return u},set:function(S){u=!!S}})),Object.defineProperty(D,"startTime",L({},b,{get:function(){return r},set:function(S){if(typeof S!="number")throw new TypeError("Start time must be set to a number.");r=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"endTime",L({},b,{get:function(){return s},set:function(S){if(typeof S!="number")throw new TypeError("End time must be set to a number.");s=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"text",L({},b,{get:function(){return i},set:function(S){i=""+S,this.hasBeenReset=!0}})),Object.defineProperty(D,"region",L({},b,{get:function(){return a},set:function(S){a=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"vertical",L({},b,{get:function(){return d},set:function(S){var O=R(S);if(O===!1)throw new SyntaxError("An invalid or illegal string was specified.");d=O,this.hasBeenReset=!0}})),Object.defineProperty(D,"snapToLines",L({},b,{get:function(){return o},set:function(S){o=!!S,this.hasBeenReset=!0}})),Object.defineProperty(D,"line",L({},b,{get:function(){return y},set:function(S){if(typeof S!="number"&&S!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");y=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"lineAlign",L({},b,{get:function(){return p},set:function(S){var O=T(S);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");p=O,this.hasBeenReset=!0}})),Object.defineProperty(D,"position",L({},b,{get:function(){return m},set:function(S){if(S<0||S>100)throw new Error("Position must be between 0 and 100.");m=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"positionAlign",L({},b,{get:function(){return g},set:function(S){var O=T(S);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");g=O,this.hasBeenReset=!0}})),Object.defineProperty(D,"size",L({},b,{get:function(){return f},set:function(S){if(S<0||S>100)throw new Error("Size must be between 0 and 100.");f=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"align",L({},b,{get:function(){return c},set:function(S){var O=T(S);if(!O)throw new SyntaxError("An invalid or illegal string was specified.");c=O,this.hasBeenReset=!0}})),D.displayState=void 0}return _.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"parseTimeStamp",function(){return h}),t.d(e,"fixLineBreaks",function(){return I}),t.d(e,"VTTParser",function(){return M});var l=t("./src/utils/vttcue.ts"),n=function(){function D(){}var b=D.prototype;return b.decode=function(u,r){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},D}();function h(D){function b(u,r,s,i){return(u|0)*3600+(r|0)*60+(s|0)+parseFloat(i||0)}var A=D.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return A?parseFloat(A[2])>59?b(A[2],A[3],0,A[4]):b(A[1],A[2],A[3],A[4]):null}var R=function(){function D(){this.values=Object.create(null)}var b=D.prototype;return b.set=function(u,r){!this.get(u)&&r!==""&&(this.values[u]=r)},b.get=function(u,r,s){return s?this.has(u)?this.values[u]:r[s]:this.has(u)?this.values[u]:r},b.has=function(u){return u in this.values},b.alt=function(u,r,s){for(var i=0;i<s.length;++i)if(r===s[i]){this.set(u,r);break}},b.integer=function(u,r){/^-?\d+$/.test(r)&&this.set(u,parseInt(r,10))},b.percent=function(u,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var s=parseFloat(r);if(s>=0&&s<=100)return this.set(u,s),!0}return!1},D}();function T(D,b,A,u){var r=u?D.split(u):[D];for(var s in r)if(typeof r[s]=="string"){var i=r[s].split(A);if(i.length===2){var a=i[0],d=i[1];b(a,d)}}}var L=new l.default(0,0,""),_=L.align==="middle"?"middle":"center";function E(D,b,A){var u=D;function r(){var a=h(D);if(a===null)throw new Error("Malformed timestamp: "+u);return D=D.replace(/^[^\sa-zA-Z-]+/,""),a}function s(a,d){var o=new R;T(a,function(m,g){var f;switch(m){case"region":for(var c=A.length-1;c>=0;c--)if(A[c].id===g){o.set(m,A[c].region);break}break;case"vertical":o.alt(m,g,["rl","lr"]);break;case"line":f=g.split(","),o.integer(m,f[0]),o.percent(m,f[0])&&o.set("snapToLines",!1),o.alt(m,f[0],["auto"]),f.length===2&&o.alt("lineAlign",f[1],["start",_,"end"]);break;case"position":f=g.split(","),o.percent(m,f[0]),f.length===2&&o.alt("positionAlign",f[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":o.percent(m,g);break;case"align":o.alt(m,g,["start",_,"end","left","right"]);break}},/:/,/\s/),d.region=o.get("region",null),d.vertical=o.get("vertical","");var y=o.get("line","auto");y==="auto"&&L.line===-1&&(y=-1),d.line=y,d.lineAlign=o.get("lineAlign","start"),d.snapToLines=o.get("snapToLines",!0),d.size=o.get("size",100),d.align=o.get("align",_);var p=o.get("position","auto");p==="auto"&&L.position===50&&(p=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=p}function i(){D=D.replace(/^\s+/,"")}if(i(),b.startTime=r(),i(),D.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);D=D.substr(3),i(),b.endTime=r(),i(),s(D,b)}function I(D){return D.replace(/<br(?: \/)?>/gi,`
21
- `)}var M=function(){function D(){this.state="INITIAL",this.buffer="",this.decoder=new n,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var b=D.prototype;return b.parse=function(u){var r=this;u&&(r.buffer+=r.decoder.decode(u,{stream:!0}));function s(){var p=r.buffer,m=0;for(p=I(p);m<p.length&&p[m]!=="\r"&&p[m]!==`
22
- `;)++m;var g=p.substr(0,m);return p[m]==="\r"&&++m,p[m]===`
23
- `&&++m,r.buffer=p.substr(m),g}function i(p){T(p,function(m,g){},/:/)}try{var a="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer))return this;a=s();var d=a.match(/^()?WEBVTT([ \t].*)?$/);if(!d||!d[0])throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var o=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;switch(o?o=!1:a=s(),r.state){case"HEADER":/:/.test(a)?i(a):a||(r.state="ID");continue;case"NOTE":a||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){r.state="NOTE";break}if(!a)continue;if(r.cue=new l.default(0,0,""),r.state="CUE",a.indexOf("-->")===-1){r.cue.id=a;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{E(a,r.cue,r.regionList)}catch{r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":{var y=a.indexOf("-->")!==-1;if(!a||y&&(o=!0)){r.oncue&&r.cue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}if(r.cue===null)continue;r.cue.text&&(r.cue.text+=`
24
- `),r.cue.text+=a}continue;case"BADCUE":a||(r.state="ID")}}}catch{r.state==="CUETEXT"&&r.cue&&r.oncue&&r.oncue(r.cue),r.cue=null,r.state=r.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},b.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
25
-
26
- `,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(r){u.onparsingerror&&u.onparsingerror(r)}return u.onflush&&u.onflush(),this},D}()},"./src/utils/webvtt-parser.ts":function(v,e,t){"use strict";t.r(e),t.d(e,"generateCueId",function(){return M}),t.d(e,"parseWebVTT",function(){return b});var l=t("./src/polyfills/number.ts"),n=t("./src/utils/vttparser.ts"),h=t("./src/demux/id3.ts"),R=t("./src/utils/timescale-conversion.ts"),T=t("./src/remux/mp4-remuxer.ts"),L=/\r\n|\n\r|\n|\r/g,_=function(u,r,s){return s===void 0&&(s=0),u.substr(s,r.length)===r},E=function(u){var r=parseInt(u.substr(-3)),s=parseInt(u.substr(-6,2)),i=parseInt(u.substr(-9,2)),a=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(l.isFiniteNumber)(r)||!Object(l.isFiniteNumber)(s)||!Object(l.isFiniteNumber)(i)||!Object(l.isFiniteNumber)(a))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return r+=1e3*s,r+=60*1e3*i,r+=60*60*1e3*a,r},I=function(u){for(var r=5381,s=u.length;s;)r=r*33^u.charCodeAt(--s);return(r>>>0).toString()};function M(A,u,r){return I(A.toString())+I(u.toString())+I(r)}var D=function(u,r,s){var i=u[r],a=u[i.prevCC];if(!a||!a.new&&i.new){u.ccOffset=u.presentationOffset=i.start,i.new=!1;return}for(;(d=a)!==null&&d!==void 0&&d.new;){var d;u.ccOffset+=i.start-a.start,i.new=!1,i=a,a=u[i.prevCC]}u.presentationOffset=s};function b(A,u,r,s,i,a,d,o){var y=new n.VTTParser,p=Object(h.utf8ArrayToStr)(new Uint8Array(A)).trim().replace(L,`
16
+ accurateTimeOffset: `+g+`
17
+ timeOffset: `+O+`
18
+ initSegmentChange: `+F);var Y=new R.TransmuxConfig(n,s,o,T,p);this.configureTransmuxer(Y)}if(this.frag=d,this.part=l,C)C.postMessage({cmd:"demux",data:r,decryptdata:P,chunkMeta:m,state:W},r instanceof ArrayBuffer?[r]:[]);else if(S){var $=S.push(r,P,m,W);Object(R.isPromise)($)?$.then(function(J){x.handleTransmuxComplete(J)}):this.handleTransmuxComplete($)}},A.flush=function(r){var o=this;r.transmuxing.start=self.performance.now();var n=this.transmuxer,s=this.worker;if(s)s.postMessage({cmd:"flush",chunkMeta:r});else if(n){var d=n.flush(r);Object(R.isPromise)(d)?d.then(function(l){o.handleFlushResult(l,r)}):this.handleFlushResult(d,r)}},A.handleFlushResult=function(r,o){var n=this;r.forEach(function(s){n.handleTransmuxComplete(s)}),this.onFlush(o)},A.onWorkerMessage=function(r){var o=r.data,n=this.hls;switch(o.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(o.data);break}case"flush":{this.onFlush(o.data);break}default:{o.data=o.data||{},o.data.frag=this.frag,o.data.id=this.id,n.trigger(o.event,o.data);break}}},A.configureTransmuxer=function(r){var o=this.worker,n=this.transmuxer;o?o.postMessage({cmd:"configure",config:r}):n&&n.configure(r)},A.handleTransmuxComplete=function(r){r.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(r)},b}()},"./src/demux/transmuxer-worker.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return L});var a=t("./src/demux/transmuxer.ts"),i=t("./src/events.ts"),c=t("./src/utils/logger.ts"),R=t("./node_modules/eventemitter3/index.js"),E=t.n(R);function L(D){var b=new R.EventEmitter,A=function(r,o){D.postMessage({event:r,data:o})};b.on(i.Events.FRAG_DECRYPTED,A),b.on(i.Events.ERROR,A),D.addEventListener("message",function(u){var r=u.data;switch(r.cmd){case"init":{var o=JSON.parse(r.config);D.transmuxer=new a.default(b,r.typeSupported,o,r.vendor,r.id),Object(c.enableLogs)(o.debug),A("init",null);break}case"configure":{D.transmuxer.configure(r.config);break}case"demux":{var n=D.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);Object(a.isPromise)(n)?n.then(function(l){_(D,l)}):_(D,n);break}case"flush":{var s=r.chunkMeta,d=D.transmuxer.flush(s);Object(a.isPromise)(d)?d.then(function(l){I(D,l,s)}):I(D,d,s);break}default:break}})}function _(D,b){if(!M(b.remuxResult)){var A=[],u=b.remuxResult,r=u.audio,o=u.video;r&&y(A,r),o&&y(A,o),D.postMessage({event:"transmuxComplete",data:b},A)}}function y(D,b){b.data1&&D.push(b.data1.buffer),b.data2&&D.push(b.data2.buffer)}function I(D,b,A){b.forEach(function(u){_(D,u)}),D.postMessage({event:"flush",data:A})}function M(D){return!D.audio&&!D.video&&!D.text&&!D.id3&&!D.initSegment}},"./src/demux/transmuxer.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return o}),t.d(e,"isPromise",function(){return d}),t.d(e,"TransmuxConfig",function(){return l}),t.d(e,"TransmuxState",function(){return T});var a=t("./src/events.ts"),i=t("./src/errors.ts"),c=t("./src/crypt/decrypter.ts"),R=t("./src/demux/aacdemuxer.ts"),E=t("./src/demux/mp4demuxer.ts"),L=t("./src/demux/tsdemuxer.ts"),_=t("./src/demux/mp3demuxer.ts"),y=t("./src/remux/mp4-remuxer.ts"),I=t("./src/remux/passthrough-remuxer.ts"),M=t("./src/demux/chunk-cache.ts"),D=t("./src/utils/mp4-tools.ts"),b=t("./src/utils/logger.ts"),A;try{A=self.performance.now.bind(self.performance)}catch{b.logger.debug("Unable to use Performance API on this environment"),A=self.Date.now}var u=[{demux:L.default,remux:y.default},{demux:E.default,remux:I.default},{demux:R.default,remux:y.default},{demux:_.default,remux:y.default}],r=1024;u.forEach(function(g){var m=g.demux;r=Math.max(r,m.minProbeByteLength)});var o=function(){function g(p,v,h,x,S){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.cache=new M.default,this.observer=p,this.typeSupported=v,this.config=h,this.vendor=x,this.id=S}var m=g.prototype;return m.configure=function(v){this.transmuxConfig=v,this.decrypter&&this.decrypter.reset()},m.push=function(v,h,x,S){var C=this,O=x.transmuxing;O.executeStart=A();var P=new Uint8Array(v),w=this.cache,U=this.config,k=this.currentTransmuxState,N=this.transmuxConfig;S&&(this.currentTransmuxState=S);var B=n(P,h);if(B&&B.method==="AES-128"){var K=this.getDecrypter();if(U.enableSoftwareAES){var H=K.softwareDecrypt(P,B.key.buffer,B.iv.buffer);if(!H)return O.executeEnd=A(),s(x);P=new Uint8Array(H)}else return this.decryptionPromise=K.webCryptoDecrypt(P,B.key.buffer,B.iv.buffer).then(function(ee){var he=C.push(ee,null,x);return C.decryptionPromise=null,he}),this.decryptionPromise}var F=S||k,W=F.contiguous,Y=F.discontinuity,$=F.trackSwitch,J=F.accurateTimeOffset,q=F.timeOffset,oe=F.initSegmentChange,X=N.audioCodec,ie=N.videoCodec,fe=N.defaultInitPts,ue=N.duration,_e=N.initSegmentData;if((Y||$||oe)&&this.resetInitSegment(_e,X,ie,ue),(Y||oe)&&this.resetInitialTimestamp(fe),W||this.resetContiguity(),this.needsProbing(P,Y,$)){if(w.dataLength){var re=w.flush();P=Object(D.appendUint8Array)(re,P)}this.configureTransmuxer(P,N)}var Z=this.transmux(P,B,q,J,x),te=this.currentTransmuxState;return te.contiguous=!0,te.discontinuity=!1,te.trackSwitch=!1,O.executeEnd=A(),Z},m.flush=function(v){var h=this,x=v.transmuxing;x.executeStart=A();var S=this.decrypter,C=this.cache,O=this.currentTransmuxState,P=this.decryptionPromise;if(P)return P.then(function(){return h.flush(v)});var w=[],U=O.timeOffset;if(S){var k=S.flush();k&&w.push(this.push(k,null,v))}var N=C.dataLength;C.reset();var B=this.demuxer,K=this.remuxer;if(!B||!K)return N>=r&&this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),x.executeEnd=A(),[s(v)];var H=B.flush(U);return d(H)?H.then(function(F){return h.flushRemux(w,F,v),w}):(this.flushRemux(w,H,v),w)},m.flushRemux=function(v,h,x){var S=h.audioTrack,C=h.avcTrack,O=h.id3Track,P=h.textTrack,w=this.currentTransmuxState,U=w.accurateTimeOffset,k=w.timeOffset;b.logger.log("[transmuxer.ts]: Flushed fragment "+x.sn+(x.part>-1?" p: "+x.part:"")+" of level "+x.level);var N=this.remuxer.remux(S,C,O,P,k,U,!0,this.id);v.push({remuxResult:N,chunkMeta:x}),x.transmuxing.executeEnd=A()},m.resetInitialTimestamp=function(v){var h=this.demuxer,x=this.remuxer;!h||!x||(h.resetTimeStamp(v),x.resetTimeStamp(v))},m.resetContiguity=function(){var v=this.demuxer,h=this.remuxer;!v||!h||(v.resetContiguity(),h.resetNextTimestamp())},m.resetInitSegment=function(v,h,x,S){var C=this.demuxer,O=this.remuxer;!C||!O||(C.resetInitSegment(h,x,S),O.resetInitSegment(v,h,x))},m.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},m.transmux=function(v,h,x,S,C){var O;return h&&h.method==="SAMPLE-AES"?O=this.transmuxSampleAes(v,h,x,S,C):O=this.transmuxUnencrypted(v,x,S,C),O},m.transmuxUnencrypted=function(v,h,x,S){var C=this.demuxer.demux(v,h,!1,!this.config.progressive),O=C.audioTrack,P=C.avcTrack,w=C.id3Track,U=C.textTrack,k=this.remuxer.remux(O,P,w,U,h,x,!1,this.id);return{remuxResult:k,chunkMeta:S}},m.transmuxSampleAes=function(v,h,x,S,C){var O=this;return this.demuxer.demuxSampleAes(v,h,x).then(function(P){var w=O.remuxer.remux(P.audioTrack,P.avcTrack,P.id3Track,P.textTrack,x,S,!1,O.id);return{remuxResult:w,chunkMeta:C}})},m.configureTransmuxer=function(v,h){for(var x=this.config,S=this.observer,C=this.typeSupported,O=this.vendor,P=h.audioCodec,w=h.defaultInitPts,U=h.duration,k=h.initSegmentData,N=h.videoCodec,B,K=0,H=u.length;K<H;K++)if(u[K].demux.probe(v)){B=u[K];break}B||(b.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),B={demux:E.default,remux:I.default});var F=this.demuxer,W=this.remuxer,Y=B.remux,$=B.demux;(!W||!(W instanceof Y))&&(this.remuxer=new Y(S,x,C,O)),(!F||!(F instanceof $))&&(this.demuxer=new $(S,x,C),this.probe=$.probe),this.resetInitSegment(k,P,N,U),this.resetInitialTimestamp(w)},m.needsProbing=function(v,h,x){return!this.demuxer||!this.remuxer||h||x},m.getDecrypter=function(){var v=this.decrypter;return v||(v=this.decrypter=new c.default(this.observer,this.config)),v},g}();function n(g,m){var p=null;return g.byteLength>0&&m!=null&&m.key!=null&&m.iv!==null&&m.method!=null&&(p=m),p}var s=function(m){return{remuxResult:{},chunkMeta:m}};function d(g){return"then"in g&&g.then instanceof Function}var l=function(m,p,v,h,x){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=m,this.videoCodec=p,this.initSegmentData=v,this.duration=h,this.defaultInitPts=x},T=function(m,p,v,h,x,S){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=m,this.contiguous=p,this.accurateTimeOffset=v,this.trackSwitch=h,this.timeOffset=x,this.initSegmentChange=S}},"./src/demux/tsdemuxer.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"discardEPB",function(){return s});var a=t("./src/demux/adts.ts"),i=t("./src/demux/mpegaudio.ts"),c=t("./src/demux/exp-golomb.ts"),R=t("./src/demux/id3.ts"),E=t("./src/demux/sample-aes.ts"),L=t("./src/events.ts"),_=t("./src/utils/mp4-tools.ts"),y=t("./src/utils/logger.ts"),I=t("./src/errors.ts"),M={video:1,audio:2,id3:3,text:4},D=function(){function d(T,g,m){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.aacLastPTS=null,this._initPTS=null,this._initDTS=null,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=g,this.typeSupported=m}d.probe=function(g){var m=d.syncOffset(g);return m<0?!1:(m&&y.logger.warn("MPEG2-TS detected but first sync word found @ offset "+m+", junk ahead ?"),!0)},d.syncOffset=function(g){for(var m=Math.min(1e3,g.length-3*188),p=0;p<m;){if(g[p]===71&&g[p+188]===71&&g[p+2*188]===71)return p;p++}return-1},d.createTrack=function(g,m){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:M[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:g==="audio"?m:void 0}};var l=d.prototype;return l.resetInitSegment=function(g,m,p){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=d.createTrack("video",p),this._audioTrack=d.createTrack("audio",p),this._id3Track=d.createTrack("id3",p),this._txtTrack=d.createTrack("text",p),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=g,this.videoCodec=m,this._duration=p},l.resetTimeStamp=function(){},l.resetContiguity=function(){var g=this._audioTrack,m=this._avcTrack,p=this._id3Track;g&&(g.pesData=null),m&&(m.pesData=null),p&&(p.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},l.demux=function(g,m,p,v){p===void 0&&(p=!1),v===void 0&&(v=!1),p||(this.sampleAes=null);var h,x=this._avcTrack,S=this._audioTrack,C=this._id3Track,O=x.pid,P=x.pesData,w=S.pid,U=C.pid,k=S.pesData,N=C.pesData,B=!1,K=this.pmtParsed,H=this._pmtId,F=g.length;if(this.remainderData&&(g=Object(_.appendUint8Array)(this.remainderData,g),F=g.length,this.remainderData=null),F<188&&!v)return this.remainderData=g,{audioTrack:S,avcTrack:x,id3Track:C,textTrack:this._txtTrack};var W=Math.max(0,d.syncOffset(g));F-=(F+W)%188,F<g.byteLength&&!v&&(this.remainderData=new Uint8Array(g.buffer,F,g.buffer.byteLength-F));for(var Y=0,$=W;$<F;$+=188)if(g[$]===71){var J=!!(g[$+1]&64),q=((g[$+1]&31)<<8)+g[$+2],oe=(g[$+3]&48)>>4,X=void 0;if(oe>1){if(X=$+5+g[$+4],X===$+188)continue}else X=$+4;switch(q){case O:J&&(P&&(h=r(P))&&this.parseAVCPES(h,!1),P={data:[],size:0}),P&&(P.data.push(g.subarray(X,$+188)),P.size+=$+188-X);break;case w:J&&(k&&(h=r(k))&&(S.isAAC?this.parseAACPES(h):this.parseMPEGPES(h)),k={data:[],size:0}),k&&(k.data.push(g.subarray(X,$+188)),k.size+=$+188-X);break;case U:J&&(N&&(h=r(N))&&this.parseID3PES(h),N={data:[],size:0}),N&&(N.data.push(g.subarray(X,$+188)),N.size+=$+188-X);break;case 0:J&&(X+=g[X]+1),H=this._pmtId=A(g,X);break;case H:{J&&(X+=g[X]+1);var ie=u(g,X,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,p);O=ie.avc,O>0&&(x.pid=O),w=ie.audio,w>0&&(S.pid=w,S.isAAC=ie.isAAC),U=ie.id3,U>0&&(C.pid=U),B&&!K&&(y.logger.log("reparse from beginning"),B=!1,$=W-188),K=this.pmtParsed=!0;break}case 17:case 8191:break;default:B=!0;break}}else Y++;Y>0&&this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),x.pesData=P,S.pesData=k,C.pesData=N;var fe={audioTrack:S,avcTrack:x,id3Track:C,textTrack:this._txtTrack};return v&&this.extractRemainingSamples(fe),fe},l.flush=function(){var g=this.remainderData;this.remainderData=null;var m;return g?m=this.demux(g,-1,!1,!0):m={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(m),this.sampleAes?this.decrypt(m,this.sampleAes):m},l.extractRemainingSamples=function(g){var m=g.audioTrack,p=g.avcTrack,v=g.id3Track,h=p.pesData,x=m.pesData,S=v.pesData,C;h&&(C=r(h))?(this.parseAVCPES(C,!0),p.pesData=null):p.pesData=h,x&&(C=r(x))?(m.isAAC?this.parseAACPES(C):this.parseMPEGPES(C),m.pesData=null):(x!=null&&x.size&&y.logger.log("last AAC PES packet truncated,might overlap between fragments"),m.pesData=x),S&&(C=r(S))?(this.parseID3PES(C),v.pesData=null):v.pesData=S},l.demuxSampleAes=function(g,m,p){var v=this.demux(g,p,!0,!this.config.progressive),h=this.sampleAes=new E.default(this.observer,this.config,m);return this.decrypt(v,h)},l.decrypt=function(g,m){return new Promise(function(p){var v=g.audioTrack,h=g.avcTrack;v.samples&&v.isAAC?m.decryptAacSamples(v.samples,0,function(){h.samples?m.decryptAvcSamples(h.samples,0,0,function(){p(g)}):p(g)}):h.samples&&m.decryptAvcSamples(h.samples,0,0,function(){p(g)})})},l.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},l.parseAVCPES=function(g,m){var p=this,v=this._avcTrack,h=this.parseAVCNALu(g.data),x=!1,S=this.avcSample,C,O=!1;g.data=null,S&&h.length&&!v.audFound&&(o(S,v),S=this.avcSample=b(!1,g.pts,g.dts,"")),h.forEach(function(P){switch(P.type){case 1:{C=!0,S||(S=p.avcSample=b(!0,g.pts,g.dts,"")),x&&(S.debug+="NDR "),S.frame=!0;var w=P.data;if(O&&w.length>4){var U=new c.default(w).readSliceType();(U===2||U===4||U===7||U===9)&&(S.key=!0)}break}case 5:C=!0,S||(S=p.avcSample=b(!0,g.pts,g.dts,"")),x&&(S.debug+="IDR "),S.key=!0,S.frame=!0;break;case 6:{C=!0,x&&S&&(S.debug+="SEI ");var k=new c.default(s(P.data));k.readUByte();for(var N=0,B=0,K=!1,H=0;!K&&k.bytesAvailable>1;){N=0;do H=k.readUByte(),N+=H;while(H===255);B=0;do H=k.readUByte(),B+=H;while(H===255);if(N===4&&k.bytesAvailable!==0){K=!0;var F=k.readUByte();if(F===181){var W=k.readUShort();if(W===49){var Y=k.readUInt();if(Y===1195456820){var $=k.readUByte();if($===3){for(var J=k.readUByte(),q=k.readUByte(),oe=31&J,X=[J,q],ie=0;ie<oe;ie++)X.push(k.readUByte()),X.push(k.readUByte()),X.push(k.readUByte());n(p._txtTrack.samples,{type:3,pts:g.pts,bytes:X})}}}}}else if(N===5&&k.bytesAvailable!==0){if(K=!0,B>16){for(var fe=[],ue=0;ue<16;ue++)fe.push(k.readUByte().toString(16)),(ue===3||ue===5||ue===7||ue===9)&&fe.push("-");for(var _e=B-16,re=new Uint8Array(_e),Z=0;Z<_e;Z++)re[Z]=k.readUByte();n(p._txtTrack.samples,{pts:g.pts,payloadType:N,uuid:fe.join(""),userData:Object(R.utf8ArrayToStr)(re),userDataBytes:re})}}else if(B<k.bytesAvailable)for(var te=0;te<B;te++)k.readUByte()}break}case 7:if(C=!0,O=!0,x&&S&&(S.debug+="SPS "),!v.sps){var ee=new c.default(P.data),he=ee.readSPS();v.width=he.width,v.height=he.height,v.pixelRatio=he.pixelRatio,v.sps=[P.data],v.duration=p._duration;for(var xe=P.data.subarray(1,4),ge="avc1.",Ae=0;Ae<3;Ae++){var Me=xe[Ae].toString(16);Me.length<2&&(Me="0"+Me),ge+=Me}v.codec=ge}break;case 8:C=!0,x&&S&&(S.debug+="PPS "),v.pps||(v.pps=[P.data]);break;case 9:C=!1,v.audFound=!0,S&&o(S,v),S=p.avcSample=b(!1,g.pts,g.dts,x?"AUD ":"");break;case 12:C=!1;break;default:C=!1,S&&(S.debug+="unknown NAL "+P.type+" ");break}if(S&&C){var Be=S.units;Be.push(P)}}),m&&S&&(o(S,v),this.avcSample=null)},l.getLastNalUnit=function(){var g,m=this.avcSample,p;if(!m||m.units.length===0){var v=this._avcTrack.samples;m=v[v.length-1]}if((g=m)!==null&&g!==void 0&&g.units){var h=m.units;p=h[h.length-1]}return p},l.parseAVCNALu=function(g){var m=g.byteLength,p=this._avcTrack,v=p.naluState||0,h=v,x=[],S=0,C,O,P,w=-1,U=0;for(v===-1&&(w=0,U=g[0]&31,v=0,S=1);S<m;){if(C=g[S++],!v){v=C?0:1;continue}if(v===1){v=C?0:2;continue}if(!C)v=3;else if(C===1){if(w>=0){var k={data:g.subarray(w,S-v-1),type:U};x.push(k)}else{var N=this.getLastNalUnit();if(N&&(h&&S<=4-h&&N.state&&(N.data=N.data.subarray(0,N.data.byteLength-h)),O=S-v-1,O>0)){var B=new Uint8Array(N.data.byteLength+O);B.set(N.data,0),B.set(g.subarray(0,O),N.data.byteLength),N.data=B,N.state=0}}S<m?(P=g[S]&31,w=S,U=P,v=0):v=-1}else v=0}if(w>=0&&v>=0){var K={data:g.subarray(w,m),type:U,state:v};x.push(K)}if(x.length===0){var H=this.getLastNalUnit();if(H){var F=new Uint8Array(H.data.byteLength+g.byteLength);F.set(H.data,0),F.set(g,H.data.byteLength),H.data=F}}return p.naluState=v,x},l.parseAACPES=function(g){var m=0,p=this._audioTrack,v=this.aacOverFlow,h=g.data;if(v){this.aacOverFlow=null;var x=v.sample.unit.byteLength,S=Math.min(v.missing,x),C=x-S;v.sample.unit.set(h.subarray(0,S),C),p.samples.push(v.sample),m=v.missing}var O,P;for(O=m,P=h.length;O<P-1&&!a.isHeader(h,O);O++);if(O!==m){var w,U;if(O<P-1?(w="AAC PES did not start with ADTS header,offset:"+O,U=!1):(w="no ADTS header found in AAC PES",U=!0),y.logger.warn("parsing error:"+w),this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:U,reason:w}),U)return}a.initTrackConfig(p,this.observer,h,O,this.audioCodec);var k;if(g.pts!==void 0)k=g.pts;else if(v){var N=a.getFrameDuration(p.samplerate);k=v.sample.pts+N}else{y.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var B=0;O<P;)if(a.isHeader(h,O)){if(O+5<P){var K=a.appendFrame(p,h,O,k,B);if(K)if(K.missing)this.aacOverFlow=K;else{O+=K.length,B++;continue}}break}else O++},l.parseMPEGPES=function(g){var m=g.data,p=m.length,v=0,h=0,x=g.pts;if(x===void 0){y.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;h<p;)if(i.isHeader(m,h)){var S=i.appendFrame(this._audioTrack,m,h,x,v);if(S)h+=S.length,v++;else break}else h++},l.parseID3PES=function(g){if(g.pts===void 0){y.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(g)},d}();D.minProbeByteLength=188;function b(d,l,T,g){return{key:d,frame:!1,pts:l,dts:T,units:[],debug:g,length:0}}function A(d,l){return(d[l+10]&31)<<8|d[l+11]}function u(d,l,T,g){var m={audio:-1,avc:-1,id3:-1,isAAC:!0},p=(d[l+1]&15)<<8|d[l+2],v=l+3+p-4,h=(d[l+10]&15)<<8|d[l+11];for(l+=12+h;l<v;){var x=(d[l+1]&31)<<8|d[l+2];switch(d[l]){case 207:if(!g){y.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:m.audio===-1&&(m.audio=x);break;case 21:m.id3===-1&&(m.id3=x);break;case 219:if(!g){y.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:m.avc===-1&&(m.avc=x);break;case 3:case 4:T?m.audio===-1&&(m.audio=x,m.isAAC=!1):y.logger.log("MPEG audio found, not supported in this browser");break;case 36:y.logger.warn("Unsupported HEVC stream type found");break;default:break}l+=((d[l+3]&15)<<8|d[l+4])+5}return m}function r(d){var l=0,T,g,m,p,v,h=d.data;if(!d||d.size===0)return null;for(;h[0].length<19&&h.length>1;){var x=new Uint8Array(h[0].length+h[1].length);x.set(h[0]),x.set(h[1],h[0].length),h[0]=x,h.splice(1,1)}T=h[0];var S=(T[0]<<16)+(T[1]<<8)+T[2];if(S===1){if(g=(T[4]<<8)+T[5],g&&g>d.size-6)return null;var C=T[7];C&192&&(p=(T[9]&14)*536870912+(T[10]&255)*4194304+(T[11]&254)*16384+(T[12]&255)*128+(T[13]&254)/2,C&64?(v=(T[14]&14)*536870912+(T[15]&255)*4194304+(T[16]&254)*16384+(T[17]&255)*128+(T[18]&254)/2,p-v>60*9e4&&(y.logger.warn(Math.round((p-v)/9e4)+"s delta between PTS and DTS, align them"),p=v)):v=p),m=T[8];var O=m+9;if(d.size<=O)return null;d.size-=O;for(var P=new Uint8Array(d.size),w=0,U=h.length;w<U;w++){T=h[w];var k=T.byteLength;if(O)if(O>k){O-=k;continue}else T=T.subarray(O),k-=O,O=0;P.set(T,l),l+=k}return g&&(g-=m+3),{data:P,pts:p,dts:v,len:g}}return null}function o(d,l){if(d.units.length&&d.frame){if(d.pts===void 0){var T=l.samples,g=T.length;if(g){var m=T[g-1];d.pts=m.pts,d.dts=m.dts}else{l.dropped++;return}}l.samples.push(d)}d.debug.length&&y.logger.log(d.pts+"/"+d.dts+":"+d.debug)}function n(d,l){var T=d.length;if(T>0){if(l.pts>=d[T-1].pts)d.push(l);else for(var g=T-1;g>=0;g--)if(l.pts<d[g].pts){d.splice(g,0,l);break}}else d.push(l)}function s(d){for(var l=d.byteLength,T=[],g=1;g<l-2;)d[g]===0&&d[g+1]===0&&d[g+2]===3?(T.push(g+2),g+=2):g++;if(T.length===0)return d;var m=l-T.length,p=new Uint8Array(m),v=0;for(g=0;g<m;v++,g++)v===T[0]&&(v++,T.shift()),p[g]=d[v];return p}e.default=D},"./src/errors.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"ErrorTypes",function(){return a}),t.d(e,"ErrorDetails",function(){return i});var a;(function(c){c.NETWORK_ERROR="networkError",c.MEDIA_ERROR="mediaError",c.KEY_SYSTEM_ERROR="keySystemError",c.MUX_ERROR="muxError",c.OTHER_ERROR="otherError"})(a||(a={}));var i;(function(c){c.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",c.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",c.KEY_SYSTEM_NO_SESSION="keySystemNoSession",c.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",c.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",c.MANIFEST_LOAD_ERROR="manifestLoadError",c.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",c.MANIFEST_PARSING_ERROR="manifestParsingError",c.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",c.LEVEL_EMPTY_ERROR="levelEmptyError",c.LEVEL_LOAD_ERROR="levelLoadError",c.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",c.LEVEL_SWITCH_ERROR="levelSwitchError",c.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",c.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",c.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",c.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",c.FRAG_LOAD_ERROR="fragLoadError",c.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",c.FRAG_DECRYPT_ERROR="fragDecryptError",c.FRAG_PARSING_ERROR="fragParsingError",c.REMUX_ALLOC_ERROR="remuxAllocError",c.KEY_LOAD_ERROR="keyLoadError",c.KEY_LOAD_TIMEOUT="keyLoadTimeOut",c.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",c.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",c.BUFFER_APPEND_ERROR="bufferAppendError",c.BUFFER_APPENDING_ERROR="bufferAppendingError",c.BUFFER_STALLED_ERROR="bufferStalledError",c.BUFFER_FULL_ERROR="bufferFullError",c.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",c.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",c.INTERNAL_EXCEPTION="internalException",c.INTERNAL_ABORTED="aborted",c.UNKNOWN="unknown"})(i||(i={}))},"./src/events.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"Events",function(){return a});var a;(function(i){i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached"})(a||(a={}))},"./src/hls.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return d});var a=t("./node_modules/url-toolkit/src/url-toolkit.js"),i=t.n(a),c=t("./src/loader/playlist-loader.ts"),R=t("./src/loader/key-loader.ts"),E=t("./src/controller/id3-track-controller.ts"),L=t("./src/controller/latency-controller.ts"),_=t("./src/controller/level-controller.ts"),y=t("./src/controller/fragment-tracker.ts"),I=t("./src/controller/stream-controller.ts"),M=t("./src/is-supported.ts"),D=t("./src/utils/logger.ts"),b=t("./src/config.ts"),A=t("./node_modules/eventemitter3/index.js"),u=t.n(A),r=t("./src/events.ts"),o=t("./src/errors.ts");function n(l,T){for(var g=0;g<T.length;g++){var m=T[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(l,m.key,m)}}function s(l,T,g){return T&&n(l.prototype,T),g&&n(l,g),l}var d=function(){l.isSupported=function(){return Object(M.isSupported)()};function l(g){g===void 0&&(g={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new A.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 m=this.config=Object(b.mergeConfig)(l.DefaultConfig,g);this.userConfig=g,Object(D.enableLogs)(m.debug),this._autoLevelCapping=-1,m.progressive&&Object(b.enableStreamingMode)(m);var p=m.abrController,v=m.bufferController,h=m.capLevelController,x=m.fpsController,S=this.abrController=new p(this),C=this.bufferController=new v(this),O=this.capLevelController=new h(this),P=new x(this),w=new c.default(this),U=new R.default(this),k=new E.default(this),N=this.levelController=new _.default(this),B=new y.FragmentTracker(this),K=this.streamController=new I.default(this,B);O.setStreamController(K),P.setStreamController(K);var H=[N,K];this.networkControllers=H;var F=[w,U,S,C,O,P,k,B];this.audioTrackController=this.createController(m.audioTrackController,null,H),this.createController(m.audioStreamController,B,H),this.subtitleTrackController=this.createController(m.subtitleTrackController,null,H),this.createController(m.subtitleStreamController,B,H),this.createController(m.timelineController,null,F),this.emeController=this.createController(m.emeController,null,F),this.cmcdController=this.createController(m.cmcdController,null,F),this.latencyController=this.createController(L.default,null,F),this.coreComponents=F}var T=l.prototype;return T.createController=function(m,p,v){if(m){var h=p?new m(this,p):new m(this);return v&&v.push(h),h}return null},T.on=function(m,p,v){v===void 0&&(v=this),this._emitter.on(m,p,v)},T.once=function(m,p,v){v===void 0&&(v=this),this._emitter.once(m,p,v)},T.removeAllListeners=function(m){this._emitter.removeAllListeners(m)},T.off=function(m,p,v,h){v===void 0&&(v=this),this._emitter.off(m,p,v,h)},T.listeners=function(m){return this._emitter.listeners(m)},T.emit=function(m,p,v){return this._emitter.emit(m,p,v)},T.trigger=function(m,p){if(this.config.debug)return this.emit(m,m,p);try{return this.emit(m,m,p)}catch(v){D.logger.error("An internal error happened while handling event "+m+'. Error message: "'+v.message+'". Here is a stacktrace:',v),this.trigger(r.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:m,error:v})}return!1},T.listenerCount=function(m){return this._emitter.listenerCount(m)},T.destroy=function(){D.logger.log("destroy"),this.trigger(r.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(m){return m.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(m){return m.destroy()}),this.coreComponents.length=0},T.attachMedia=function(m){D.logger.log("attachMedia"),this._media=m,this.trigger(r.Events.MEDIA_ATTACHING,{media:m})},T.detachMedia=function(){D.logger.log("detachMedia"),this.trigger(r.Events.MEDIA_DETACHING,void 0),this._media=null},T.loadSource=function(m){this.stopLoad();var p=this.media,v=this.url,h=this.url=a.buildAbsoluteURL(self.location.href,m,{alwaysNormalize:!0});D.logger.log("loadSource:"+h),p&&v&&v!==h&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(p)),this.trigger(r.Events.MANIFEST_LOADING,{url:m})},T.startLoad=function(m){m===void 0&&(m=-1),D.logger.log("startLoad("+m+")"),this.networkControllers.forEach(function(p){p.startLoad(m)})},T.stopLoad=function(){D.logger.log("stopLoad"),this.networkControllers.forEach(function(m){m.stopLoad()})},T.swapAudioCodec=function(){D.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},T.recoverMediaError=function(){D.logger.log("recoverMediaError");var m=this._media;this.detachMedia(),m&&this.attachMedia(m)},T.removeLevel=function(m,p){p===void 0&&(p=0),this.levelController.removeLevel(m,p)},s(l,[{key:"levels",get:function(){var m=this.levelController.levels;return m||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(m){D.logger.log("set currentLevel:"+m),this.loadLevel=m,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(m){D.logger.log("set nextLevel:"+m),this.levelController.manualLevel=m,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(m){D.logger.log("set loadLevel:"+m),this.levelController.manualLevel=m}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(m){this.levelController.nextLoadLevel=m}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(m){D.logger.log("set firstLevel:"+m),this.levelController.firstLevel=m}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(m){D.logger.log("set startLevel:"+m),m!==-1&&(m=Math.max(m,this.minAutoLevel)),this.levelController.startLevel=m}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(m){var p=!!m;p!==this.config.capLevelToPlayerSize&&(p?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=p)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(m){this._autoLevelCapping!==m&&(D.logger.log("set autoLevelCapping:"+m),this._autoLevelCapping=m)}},{key:"bandwidthEstimate",get:function(){var m=this.abrController.bwEstimator;return m?m.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var m=this.levels,p=this.config.minAutoBitrate;if(!m)return 0;for(var v=m.length,h=0;h<v;h++)if(m[h].maxBitrate>p)return h;return 0}},{key:"maxAutoLevel",get:function(){var m=this.levels,p=this.autoLevelCapping,v;return p===-1&&m&&m.length?v=m.length-1:v=p,v}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(m){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,m)}},{key:"audioTracks",get:function(){var m=this.audioTrackController;return m?m.audioTracks:[]}},{key:"audioTrack",get:function(){var m=this.audioTrackController;return m?m.audioTrack:-1},set:function(m){var p=this.audioTrackController;p&&(p.audioTrack=m)}},{key:"subtitleTracks",get:function(){var m=this.subtitleTrackController;return m?m.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var m=this.subtitleTrackController;return m?m.subtitleTrack:-1},set:function(m){var p=this.subtitleTrackController;p&&(p.subtitleTrack=m)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var m=this.subtitleTrackController;return m?m.subtitleDisplay:!1},set:function(m){var p=this.subtitleTrackController;p&&(p.subtitleDisplay=m)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(m){this.config.lowLatencyMode=m}},{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.1.5"}},{key:"Events",get:function(){return r.Events}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return l.defaultConfig?l.defaultConfig:b.hlsDefaultConfig},set:function(m){l.defaultConfig=m}}]),l}();d.defaultConfig=void 0},"./src/is-supported.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"isSupported",function(){return c}),t.d(e,"changeTypeSupported",function(){return R});var a=t("./src/utils/mediasource-helper.ts");function i(){return self.SourceBuffer||self.WebKitSourceBuffer}function c(){var E=Object(a.getMediaSource)();if(!E)return!1;var L=i(),_=E&&typeof E.isTypeSupported=="function"&&E.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),y=!L||L.prototype&&typeof L.prototype.appendBuffer=="function"&&typeof L.prototype.remove=="function";return!!_&&!!y}function R(){var E,L=i();return typeof(L==null||(E=L.prototype)===null||E===void 0?void 0:E.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return D}),t.d(e,"LoadError",function(){return A});var a=t("./src/polyfills/number.ts"),i=t("./src/errors.ts");function c(u,r){u.prototype=Object.create(r.prototype),u.prototype.constructor=u,y(u,r)}function R(u){var r=typeof Map=="function"?new Map:void 0;return R=function(n){if(n===null||!_(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r!="undefined"){if(r.has(n))return r.get(n);r.set(n,s)}function s(){return E(n,arguments,I(this).constructor)}return s.prototype=Object.create(n.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),y(s,n)},R(u)}function E(u,r,o){return L()?E=Reflect.construct:E=function(s,d,l){var T=[null];T.push.apply(T,d);var g=Function.bind.apply(s,T),m=new g;return l&&y(m,l.prototype),m},E.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 _(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function y(u,r){return y=Object.setPrototypeOf||function(n,s){return n.__proto__=s,n},y(u,r)}function I(u){return I=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},I(u)}var M=Math.pow(2,17),D=function(){function u(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var r=u.prototype;return r.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},r.abort=function(){this.loader&&this.loader.abort()},r.load=function(n,s){var d=this,l=n.url;if(!l)return Promise.reject(new A({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,networkDetails:null},"Fragment does not have a "+(l?"part list":"url")));this.abort();var T=this.config,g=T.fLoader,m=T.loader;return new Promise(function(p,v){d.loader&&d.loader.destroy();var h=d.loader=n.loader=g?new g(T):new m(T),x=b(n),S={timeout:T.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:T.fragLoadingMaxRetryTimeout,highWaterMark:M};n.stats=h.stats,h.load(x,S,{onSuccess:function(O,P,w,U){d.resetLoader(n,h),p({frag:n,part:null,payload:O.data,networkDetails:U})},onError:function(O,P,w){d.resetLoader(n,h),v(new A({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,response:O,networkDetails:w}))},onAbort:function(O,P,w){d.resetLoader(n,h),v(new A({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,networkDetails:w}))},onTimeout:function(O,P,w){d.resetLoader(n,h),v(new A({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,networkDetails:w}))},onProgress:function(O,P,w,U){s&&s({frag:n,part:null,payload:w,networkDetails:U})}})})},r.loadPart=function(n,s,d){var l=this;this.abort();var T=this.config,g=T.fLoader,m=T.loader;return new Promise(function(p,v){l.loader&&l.loader.destroy();var h=l.loader=n.loader=g?new g(T):new m(T),x=b(n,s),S={timeout:T.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:T.fragLoadingMaxRetryTimeout,highWaterMark:M};s.stats=h.stats,h.load(x,S,{onSuccess:function(O,P,w,U){l.resetLoader(n,h),l.updateStatsFromPart(n,s);var k={frag:n,part:s,payload:O.data,networkDetails:U};d(k),p(k)},onError:function(O,P,w){l.resetLoader(n,h),v(new A({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,part:s,response:O,networkDetails:w}))},onAbort:function(O,P,w){n.stats.aborted=s.stats.aborted,l.resetLoader(n,h),v(new A({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:s,networkDetails:w}))},onTimeout:function(O,P,w){l.resetLoader(n,h),v(new A({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,part:s,networkDetails:w}))}})})},r.updateStatsFromPart=function(n,s){var d=n.stats,l=s.stats,T=l.total;if(d.loaded+=l.loaded,T){var g=Math.round(n.duration/s.duration),m=Math.min(Math.round(d.loaded/T),g),p=g-m,v=p*Math.round(d.loaded/m);d.total=d.loaded+v}else d.total=Math.max(d.loaded,d.total);var h=d.loading,x=l.loading;h.start?h.first+=x.first-x.start:(h.start=x.start,h.first=x.first),h.end=x.end},r.resetLoader=function(n,s){n.loader=null,this.loader===s&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),s.destroy()},u}();function b(u,r){r===void 0&&(r=null);var o=r||u,n={frag:u,part:r,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},s=o.byteRangeStartOffset,d=o.byteRangeEndOffset;return Object(a.isFiniteNumber)(s)&&Object(a.isFiniteNumber)(d)&&(n.rangeStart=s,n.rangeEnd=d),n}var A=function(u){c(r,u);function r(o){for(var n,s=arguments.length,d=new Array(s>1?s-1:0),l=1;l<s;l++)d[l-1]=arguments[l];return n=u.call.apply(u,[this].concat(d))||this,n.data=void 0,n.data=o,n}return r}(R(Error))},"./src/loader/fragment.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"ElementaryStreamTypes",function(){return D}),t.d(e,"BaseSegment",function(){return b}),t.d(e,"Fragment",function(){return A}),t.d(e,"Part",function(){return u});var a=t("./src/polyfills/number.ts"),i=t("./node_modules/url-toolkit/src/url-toolkit.js"),c=t.n(i),R=t("./src/utils/logger.ts"),E=t("./src/loader/level-key.ts"),L=t("./src/loader/load-stats.ts");function _(r,o){r.prototype=Object.create(o.prototype),r.prototype.constructor=r,y(r,o)}function y(r,o){return y=Object.setPrototypeOf||function(s,d){return s.__proto__=d,s},y(r,o)}function I(r,o){for(var n=0;n<o.length;n++){var s=o[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(r,s.key,s)}}function M(r,o,n){return o&&I(r.prototype,o),n&&I(r,n),r}var D;(function(r){r.AUDIO="audio",r.VIDEO="video",r.AUDIOVIDEO="audiovideo"})(D||(D={}));var b=function(){function r(n){var s;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(s={},s[D.AUDIO]=null,s[D.VIDEO]=null,s[D.AUDIOVIDEO]=null,s),this.baseurl=n}var o=r.prototype;return o.setByteRange=function(s,d){var l=s.split("@",2),T=[];l.length===1?T[0]=d?d.byteRangeEndOffset:0:T[0]=parseInt(l[1]),T[1]=parseInt(l[0])+T[0],this._byteRange=T},M(r,[{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(i.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(s){this._url=s}}]),r}(),A=function(r){_(o,r);function o(s,d){var l;return l=r.call(this,d)||this,l._decryptdata=null,l.rawProgramDateTime=null,l.programDateTime=null,l.tagList=[],l.duration=0,l.sn=0,l.levelkey=void 0,l.type=void 0,l.loader=null,l.level=-1,l.cc=0,l.startPTS=void 0,l.endPTS=void 0,l.appendedPTS=void 0,l.startDTS=void 0,l.endDTS=void 0,l.start=0,l.deltaPTS=void 0,l.maxStartPTS=void 0,l.minEndPTS=void 0,l.stats=new L.LoadStats,l.urlId=0,l.data=void 0,l.bitrateTest=!1,l.title=null,l.initSegment=null,l.type=s,l}var n=o.prototype;return n.createInitializationVector=function(d){for(var l=new Uint8Array(16),T=12;T<16;T++)l[T]=d>>8*(15-T)&255;return l},n.setDecryptDataFromLevelKey=function(d,l){var T=d;return(d==null?void 0:d.method)==="AES-128"&&d.uri&&!d.iv&&(T=E.LevelKey.fromURI(d.uri),T.method=d.method,T.iv=this.createInitializationVector(l),T.keyFormat="identity"),T},n.setElementaryStreamInfo=function(d,l,T,g,m,p){p===void 0&&(p=!1);var v=this.elementaryStreams,h=v[d];if(!h){v[d]={startPTS:l,endPTS:T,startDTS:g,endDTS:m,partial:p};return}h.startPTS=Math.min(h.startPTS,l),h.endPTS=Math.max(h.endPTS,T),h.startDTS=Math.min(h.startDTS,g),h.endDTS=Math.max(h.endDTS,m)},n.clearElementaryStreamInfo=function(){var d=this.elementaryStreams;d[D.AUDIO]=null,d[D.VIDEO]=null,d[D.AUDIOVIDEO]=null},M(o,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var d=this.sn;typeof d!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&R.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),d=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,d)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(a.isFiniteNumber)(this.programDateTime))return null;var d=Object(a.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+d*1e3}},{key:"encrypted",get:function(){var d;return!!((d=this.decryptdata)!==null&&d!==void 0&&d.keyFormat&&this.decryptdata.uri)}}]),o}(b),u=function(r){_(o,r);function o(n,s,d,l,T){var g;g=r.call(this,d)||this,g.fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new L.LoadStats,g.duration=n.decimalFloatingPoint("DURATION"),g.gap=n.bool("GAP"),g.independent=n.bool("INDEPENDENT"),g.relurl=n.enumeratedString("URI"),g.fragment=s,g.index=l;var m=n.enumeratedString("BYTERANGE");return m&&g.setByteRange(m,T),T&&(g.fragOffset=T.fragOffset+T.duration),g}return M(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var s=this.elementaryStreams;return!!(s.audio||s.video||s.audiovideo)}}]),o}(b)},"./src/loader/key-loader.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return R});var a=t("./src/events.ts"),i=t("./src/errors.ts"),c=t("./src/utils/logger.ts"),R=function(){function E(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this._registerListeners()}var L=E.prototype;return L._registerListeners=function(){this.hls.on(a.Events.KEY_LOADING,this.onKeyLoading,this)},L._unregisterListeners=function(){this.hls.off(a.Events.KEY_LOADING,this.onKeyLoading)},L.destroy=function(){this._unregisterListeners();for(var y in this.loaders){var I=this.loaders[y];I&&I.destroy()}this.loaders={}},L.onKeyLoading=function(y,I){var M=I.frag,D=M.type,b=this.loaders[D];if(!M.decryptdata){c.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var A=M.decryptdata.uri;if(A!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(b&&(c.logger.warn("abort previous key loader for type:"+D),b.abort()),!A){c.logger.warn("key uri is falsy");return}var r=u.loader,o=M.loader=this.loaders[D]=new r(u);this.decrypturl=A,this.decryptkey=null;var n={url:A,frag:M,responseType:"arraybuffer"},s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(n,s,d)}else this.decryptkey&&(M.decryptdata.key=this.decryptkey,this.hls.trigger(a.Events.KEY_LOADED,{frag:M}))},L.loadsuccess=function(y,I,M){var D=M.frag;if(!D.decryptdata){c.logger.error("after key load, decryptdata unset");return}this.decryptkey=D.decryptdata.key=new Uint8Array(y.data),D.loader=null,delete this.loaders[D.type],this.hls.trigger(a.Events.KEY_LOADED,{frag:D})},L.loaderror=function(y,I){var M=I.frag,D=M.loader;D&&D.abort(),delete this.loaders[M.type],this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:M,response:y})},L.loadtimeout=function(y,I){var M=I.frag,D=M.loader;D&&D.abort(),delete this.loaders[M.type],this.hls.trigger(a.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:M})},E}()},"./src/loader/level-details.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"LevelDetails",function(){return E});var a=t("./src/polyfills/number.ts");function i(L,_){for(var y=0;y<_.length;y++){var I=_[y];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function c(L,_,y){return _&&i(L.prototype,_),y&&i(L,y),L}var R=10,E=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.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.url=y}var _=L.prototype;return _.reloaded=function(I){if(!I){this.advanced=!0,this.updated=!0;return}var M=this.lastPartSn-I.lastPartSn,D=this.lastPartIndex-I.lastPartIndex;this.updated=this.endSN!==I.endSN||!!D||!!M,this.advanced=this.endSN>I.endSN||M>0||M===0&&D>0,this.updated||this.advanced?this.misses=Math.floor(I.misses*.6):this.misses=I.misses+1,this.availabilityDelay=I.availabilityDelay},c(L,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(a.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||R}},{key:"drift",get:function(){var I=this.driftEndTime-this.driftStartTime;if(I>0){var M=this.driftEnd-this.driftStart;return M*1e3/I}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var I;return(I=this.partList)!==null&&I!==void 0&&I.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var I;return(I=this.fragments)!==null&&I!==void 0&&I.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 I;return(I=this.partList)!==null&&I!==void 0&&I.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var I;return(I=this.partList)!==null&&I!==void 0&&I.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"LevelKey",function(){return E});var a=t("./node_modules/url-toolkit/src/url-toolkit.js"),i=t.n(a);function c(L,_){for(var y=0;y<_.length;y++){var I=_[y];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(L,I.key,I)}}function R(L,_,y){return _&&c(L.prototype,_),y&&c(L,y),L}var E=function(){L.fromURL=function(y,I){return new L(y,I)},L.fromURI=function(y){return new L(y)};function L(_,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(a.buildAbsoluteURL)(_,y,{alwaysNormalize:!0}):this._uri=_}return R(L,[{key:"uri",get:function(){return this._uri}}]),L}()},"./src/loader/load-stats.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"LoadStats",function(){return a});var a=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(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return o});var a=t("./src/polyfills/number.ts"),i=t("./node_modules/url-toolkit/src/url-toolkit.js"),c=t.n(i),R=t("./src/loader/fragment.ts"),E=t("./src/loader/level-details.ts"),L=t("./src/loader/level-key.ts"),_=t("./src/utils/attr-list.ts"),y=t("./src/utils/logger.ts"),I=t("./src/utils/codecs.ts"),M=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,D=/#EXT-X-MEDIA:(.*)/g,b=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-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function r(T){var g,m;return u.test((g=(m=i.parseURL(T))===null||m===void 0?void 0:m.path)!=null?g:"")}var o=function(){function T(){}return T.findGroup=function(m,p){for(var v=0;v<m.length;v++){var h=m[v];if(h.id===p)return h}},T.convertAVC1ToAVCOTI=function(m){var p=m.split(".");if(p.length>2){var v=p.shift()+".";return v+=parseInt(p.shift()).toString(16),v+=("000"+parseInt(p.shift()).toString(16)).substr(-4),v}return m},T.resolve=function(m,p){return i.buildAbsoluteURL(p,m,{alwaysNormalize:!0})},T.parseMasterPlaylist=function(m,p){var v=[],h={},x=!1;M.lastIndex=0;for(var S;(S=M.exec(m))!=null;)if(S[1]){var C=new _.AttrList(S[1]),O={attrs:C,bitrate:C.decimalInteger("AVERAGE-BANDWIDTH")||C.decimalInteger("BANDWIDTH"),name:C.NAME,url:T.resolve(S[2],p)},P=C.decimalResolution("RESOLUTION");P&&(O.width=P.width,O.height=P.height),n((C.CODECS||"").split(/[ ,]+/).filter(function(U){return U}),O),O.videoCodec&&O.videoCodec.indexOf("avc1")!==-1&&(O.videoCodec=T.convertAVC1ToAVCOTI(O.videoCodec)),v.push(O)}else if(S[3]){var w=new _.AttrList(S[3]);w["DATA-ID"]&&(x=!0,h[w["DATA-ID"]]=w)}return{levels:v,sessionData:x?h:null}},T.parseMasterPlaylistMedia=function(m,p,v,h){h===void 0&&(h=[]);var x,S=[],C=0;for(D.lastIndex=0;(x=D.exec(m))!==null;){var O=new _.AttrList(x[1]);if(O.TYPE===v){var P={attrs:O,bitrate:0,id:C++,groupId:O["GROUP-ID"],instreamId:O["INSTREAM-ID"],name:O.NAME||O.LANGUAGE||"",type:v,default:O.bool("DEFAULT"),autoselect:O.bool("AUTOSELECT"),forced:O.bool("FORCED"),lang:O.LANGUAGE,url:O.URI?T.resolve(O.URI,p):""};if(h.length){var w=T.findGroup(h,P.groupId)||h[0];s(P,w,"audioCodec"),s(P,w,"textCodec")}S.push(P)}}return S},T.parseLevelPlaylist=function(m,p,v,h,x){var S=new E.LevelDetails(p),C=S.fragments,O=null,P=0,w=0,U=0,k=0,N=null,B=new R.Fragment(h,p),K,H,F,W=-1,Y=!1;for(b.lastIndex=0,S.m3u8=m;(K=b.exec(m))!==null;){Y&&(Y=!1,B=new R.Fragment(h,p),B.start=U,B.sn=P,B.cc=k,B.level=v,O&&(B.initSegment=O,B.rawProgramDateTime=O.rawProgramDateTime));var $=K[1];if($){B.duration=parseFloat($);var J=(" "+K[2]).slice(1);B.title=J||null,B.tagList.push(J?["INF",$,J]:["INF",$])}else if(K[3])Object(a.isFiniteNumber)(B.duration)&&(B.start=U,F&&(B.levelkey=F),B.sn=P,B.level=v,B.cc=k,B.urlId=x,C.push(B),B.relurl=(" "+K[3]).slice(1),l(B,N),N=B,U+=B.duration,P++,w=0,Y=!0);else if(K[4]){var q=(" "+K[4]).slice(1);N?B.setByteRange(q,N):B.setByteRange(q)}else if(K[5])B.rawProgramDateTime=(" "+K[5]).slice(1),B.tagList.push(["PROGRAM-DATE-TIME",B.rawProgramDateTime]),W===-1&&(W=C.length);else{if(K=K[0].match(A),!K){y.logger.warn("No matches on slow regex match for level playlist!");continue}for(H=1;H<K.length&&typeof K[H]=="undefined";H++);var oe=(" "+K[H]).slice(1),X=(" "+K[H+1]).slice(1),ie=K[H+2]?(" "+K[H+2]).slice(1):"";switch(oe){case"PLAYLIST-TYPE":S.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":P=S.startSN=parseInt(X);break;case"SKIP":{var fe=new _.AttrList(X),ue=fe.decimalInteger("SKIPPED-SEGMENTS");if(Object(a.isFiniteNumber)(ue)){S.skippedSegments=ue;for(var _e=ue;_e--;)C.unshift(null);P+=ue}var re=fe.enumeratedString("RECENTLY-REMOVED-DATERANGES");re&&(S.recentlyRemovedDateranges=re.split(" "));break}case"TARGETDURATION":S.targetduration=parseFloat(X);break;case"VERSION":S.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":S.live=!1;break;case"#":(X||ie)&&B.tagList.push(ie?[X,ie]:[X]);break;case"DIS":k++;case"GAP":B.tagList.push([oe]);break;case"BITRATE":B.tagList.push([oe,X]);break;case"DISCONTINUITY-SEQ":k=parseInt(X);break;case"KEY":{var Z,te=new _.AttrList(X),ee=te.enumeratedString("METHOD"),he=te.URI,xe=te.hexadecimalInteger("IV"),ge=te.enumeratedString("KEYFORMATVERSIONS"),Ae=te.enumeratedString("KEYID"),Me=(Z=te.enumeratedString("KEYFORMAT"))!=null?Z:"identity",Be=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Be.indexOf(Me)>-1){y.logger.warn("Keyformat "+Me+" is not supported from the manifest");continue}else if(Me!=="identity")continue;ee&&(F=L.LevelKey.fromURL(p,he),he&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ee)>=0&&(F.method=ee,F.keyFormat=Me,Ae&&(F.keyID=Ae),ge&&(F.keyFormatVersions=ge),F.iv=xe));break}case"START":{var Ee=new _.AttrList(X),ye=Ee.decimalFloatingPoint("TIME-OFFSET");Object(a.isFiniteNumber)(ye)&&(S.startTimeOffset=ye);break}case"MAP":{var Fe=new _.AttrList(X);B.relurl=Fe.URI,Fe.BYTERANGE&&B.setByteRange(Fe.BYTERANGE),B.level=v,B.sn="initSegment",F&&(B.levelkey=F),B.initSegment=null,O=B,Y=!0;break}case"SERVER-CONTROL":{var Se=new _.AttrList(X);S.canBlockReload=Se.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=Se.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&Se.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=Se.optionalFloat("PART-HOLD-BACK",0),S.holdBack=Se.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var qe=new _.AttrList(X);S.partTarget=qe.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ue=S.partList;Ue||(Ue=S.partList=[]);var ze=w>0?Ue[Ue.length-1]:void 0,et=w++,tt=new R.Part(new _.AttrList(X),B,p,et,ze);Ue.push(tt),B.duration+=tt.duration;break}case"PRELOAD-HINT":{var G=new _.AttrList(X);S.preloadHint=G;break}case"RENDITION-REPORT":{var V=new _.AttrList(X);S.renditionReports=S.renditionReports||[],S.renditionReports.push(V);break}default:y.logger.warn("line parsed but not handled: "+K);break}}}N&&!N.relurl?(C.pop(),U-=N.duration,S.partList&&(S.fragmentHint=N)):S.partList&&(l(B,N),B.cc=k,S.fragmentHint=B);var de=C.length,ce=C[0],Re=C[de-1];if(U+=S.skippedSegments*S.targetduration,U>0&&de&&Re){S.averagetargetduration=U/de;var Ce=Re.sn;S.endSN=Ce!=="initSegment"?Ce:0,ce&&(S.startCC=ce.cc,ce.initSegment||S.fragments.every(function(le){return le.relurl&&r(le.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),B=new R.Fragment(h,p),B.relurl=Re.relurl,B.level=v,B.sn="initSegment",ce.initSegment=B,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(U+=S.fragmentHint.duration),S.totalduration=U,S.endCC=k,W>0&&d(C,W),S},T}();function n(T,g){["video","audio","text"].forEach(function(m){var p=T.filter(function(h){return Object(I.isCodecType)(h,m)});if(p.length){var v=p.filter(function(h){return h.lastIndexOf("avc1",0)===0||h.lastIndexOf("mp4a",0)===0});g[m+"Codec"]=v.length>0?v[0]:p[0],T=T.filter(function(h){return p.indexOf(h)===-1})}}),g.unknownCodecs=T}function s(T,g,m){var p=g[m];p&&(T[m]=p)}function d(T,g){for(var m=T[g],p=g;p--;){var v=T[p];if(!v)return;v.programDateTime=m.programDateTime-v.duration*1e3,m=v}}function l(T,g){T.rawProgramDateTime?T.programDateTime=Date.parse(T.rawProgramDateTime):g!=null&&g.programDateTime&&(T.programDateTime=g.endProgramDateTime),Object(a.isFiniteNumber)(T.programDateTime)||(T.programDateTime=null,T.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/polyfills/number.ts"),i=t("./src/events.ts"),c=t("./src/errors.ts"),R=t("./src/utils/logger.ts"),E=t("./src/utils/mp4-tools.ts"),L=t("./src/loader/m3u8-parser.ts"),_=t("./src/types/loader.ts"),y=t("./src/utils/attr-list.ts");function I(b){var A=b.type;switch(A){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function M(b,A){var u=b.url;return(u===void 0||u.indexOf("data:")===0)&&(u=A.url),u}var D=function(){function b(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var A=b.prototype;return A.registerListeners=function(){var r=this.hls;r.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(i.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.on(i.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},A.unregisterListeners=function(){var r=this.hls;r.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(i.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),r.off(i.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},A.createInternalLoader=function(r){var o=this.hls.config,n=o.pLoader,s=o.loader,d=n||s,l=new d(o);return r.loader=l,this.loaders[r.type]=l,l},A.getInternalLoader=function(r){return this.loaders[r.type]},A.resetInternalLoader=function(r){this.loaders[r]&&delete this.loaders[r]},A.destroyInternalLoaders=function(){for(var r in this.loaders){var o=this.loaders[r];o&&o.destroy(),this.resetInternalLoader(r)}},A.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},A.onManifestLoading=function(r,o){var n=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:n,deliveryDirectives:null})},A.onLevelLoading=function(r,o){var n=o.id,s=o.level,d=o.url,l=o.deliveryDirectives;this.load({id:n,groupId:null,level:s,responseType:"text",type:_.PlaylistContextType.LEVEL,url:d,deliveryDirectives:l})},A.onAudioTrackLoading=function(r,o){var n=o.id,s=o.groupId,d=o.url,l=o.deliveryDirectives;this.load({id:n,groupId:s,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:d,deliveryDirectives:l})},A.onSubtitleTrackLoading=function(r,o){var n=o.id,s=o.groupId,d=o.url,l=o.deliveryDirectives;this.load({id:n,groupId:s,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:d,deliveryDirectives:l})},A.load=function(r){var o,n=this.hls.config,s=this.getInternalLoader(r);if(s){var d=s.context;if(d&&d.url===r.url){R.logger.trace("[playlist-loader]: playlist request ongoing");return}R.logger.log("[playlist-loader]: aborting previous loader for type: "+r.type),s.abort()}var l,T,g,m;switch(r.type){case _.PlaylistContextType.MANIFEST:l=n.manifestLoadingMaxRetry,T=n.manifestLoadingTimeOut,g=n.manifestLoadingRetryDelay,m=n.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:l=0,T=n.levelLoadingTimeOut;break;default:l=n.levelLoadingMaxRetry,T=n.levelLoadingTimeOut,g=n.levelLoadingRetryDelay,m=n.levelLoadingMaxRetryTimeout;break}if(s=this.createInternalLoader(r),(o=r.deliveryDirectives)!==null&&o!==void 0&&o.part){var p;if(r.type===_.PlaylistContextType.LEVEL&&r.level!==null?p=this.hls.levels[r.level].details:r.type===_.PlaylistContextType.AUDIO_TRACK&&r.id!==null?p=this.hls.audioTracks[r.id].details:r.type===_.PlaylistContextType.SUBTITLE_TRACK&&r.id!==null&&(p=this.hls.subtitleTracks[r.id].details),p){var v=p.partTarget,h=p.targetduration;v&&h&&(T=Math.min(Math.max(v*3,h*.8)*1e3,T))}}var x={timeout:T,maxRetry:l,retryDelay:g,maxRetryDelay:m,highWaterMark:0},S={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(r,x,S)},A.loadsuccess=function(r,o,n,s){if(s===void 0&&(s=null),n.isSidxRequest){this.handleSidxRequest(r,n),this.handlePlaylistLoaded(r,o,n,s);return}this.resetInternalLoader(n.type);var d=r.data;if(d.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(r,n,"no EXTM3U delimiter",s);return}o.parsing.start=performance.now(),d.indexOf("#EXTINF:")>0||d.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(r,o,n,s):this.handleMasterPlaylist(r,o,n,s)},A.loaderror=function(r,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!1,r)},A.loadtimeout=function(r,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!0)},A.handleMasterPlaylist=function(r,o,n,s){var d=this.hls,l=r.data,T=M(r,n),g=L.default.parseMasterPlaylist(l,T),m=g.levels,p=g.sessionData;if(!m.length){this.handleManifestParsingError(r,n,"no level found in manifest",s);return}var v=m.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),h=m.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),x=L.default.parseMasterPlaylistMedia(l,T,"AUDIO",v),S=L.default.parseMasterPlaylistMedia(l,T,"SUBTITLES",h),C=L.default.parseMasterPlaylistMedia(l,T,"CLOSED-CAPTIONS");if(x.length){var O=x.some(function(P){return!P.url});!O&&m[0].audioCodec&&!m[0].attrs.AUDIO&&(R.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),x.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new y.AttrList({}),bitrate:0,url:""}))}d.trigger(i.Events.MANIFEST_LOADED,{levels:m,audioTracks:x,subtitles:S,captions:C,url:T,stats:o,networkDetails:s,sessionData:p})},A.handleTrackOrLevelPlaylist=function(r,o,n,s){var d=this.hls,l=n.id,T=n.level,g=n.type,m=M(r,n),p=Object(a.isFiniteNumber)(l)?l:0,v=Object(a.isFiniteNumber)(T)?T:p,h=I(n),x=L.default.parseLevelPlaylist(r.data,m,v,h,p);if(!x.fragments.length){d.trigger(i.Events.ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:m,reason:"no fragments found in level",level:typeof n.level=="number"?n.level:void 0});return}if(g===_.PlaylistContextType.MANIFEST){var S={attrs:new y.AttrList({}),bitrate:0,details:x,name:"",url:m};d.trigger(i.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:m,stats:o,networkDetails:s,sessionData:null})}if(o.parsing.end=performance.now(),x.needSidxRanges){var C,O=(C=x.fragments[0].initSegment)===null||C===void 0?void 0:C.url;this.load({url:O,isSidxRequest:!0,type:g,level:T,levelDetails:x,id:l,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}n.levelDetails=x,this.handlePlaylistLoaded(r,o,n,s)},A.handleSidxRequest=function(r,o){var n=Object(E.parseSegmentIndex)(new Uint8Array(r.data));if(!!n){var s=n.references,d=o.levelDetails;s.forEach(function(l,T){var g=l.info,m=d.fragments[T];m.byteRange.length===0&&m.setByteRange(String(1+g.end-g.start)+"@"+String(g.start)),m.initSegment&&m.initSegment.setByteRange(String(n.moovEndOffset)+"@0")})}},A.handleManifestParsingError=function(r,o,n,s){this.hls.trigger(i.Events.ERROR,{type:c.ErrorTypes.NETWORK_ERROR,details:c.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:r.url,reason:n,response:r,context:o,networkDetails:s})},A.handleNetworkError=function(r,o,n,s){n===void 0&&(n=!1),R.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+r.type+" level: "+r.level+" id: "+r.id+' group-id: "'+r.groupId+'"');var d=c.ErrorDetails.UNKNOWN,l=!1,T=this.getInternalLoader(r);switch(r.type){case _.PlaylistContextType.MANIFEST:d=n?c.ErrorDetails.MANIFEST_LOAD_TIMEOUT:c.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case _.PlaylistContextType.LEVEL:d=n?c.ErrorDetails.LEVEL_LOAD_TIMEOUT:c.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case _.PlaylistContextType.AUDIO_TRACK:d=n?c.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:c.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:d=n?c.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:c.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1;break}T&&this.resetInternalLoader(r.type);var g={type:c.ErrorTypes.NETWORK_ERROR,details:d,fatal:l,url:r.url,loader:T,context:r,networkDetails:o};s&&(g.response=s),this.hls.trigger(i.Events.ERROR,g)},A.handlePlaylistLoaded=function(r,o,n,s){var d=n.type,l=n.level,T=n.id,g=n.groupId,m=n.loader,p=n.levelDetails,v=n.deliveryDirectives;if(!(p!=null&&p.targetduration)){this.handleManifestParsingError(r,n,"invalid target duration",s);return}if(!!m)switch(p.live&&(m.getCacheAge&&(p.ageHeader=m.getCacheAge()||0),(!m.getCacheAge||isNaN(p.ageHeader))&&(p.ageHeader=0)),d){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(i.Events.LEVEL_LOADED,{details:p,level:l||0,id:T||0,stats:o,networkDetails:s,deliveryDirectives:v});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(i.Events.AUDIO_TRACK_LOADED,{details:p,id:T||0,groupId:g||"",stats:o,networkDetails:s,deliveryDirectives:v});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADED,{details:p,id:T||0,groupId:g||"",stats:o,networkDetails:s,deliveryDirectives:v});break}},b}();e.default=D},"./src/polyfills/number.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"isFiniteNumber",function(){return a}),t.d(e,"MAX_SAFE_INTEGER",function(){return i});var a=Number.isFinite||function(c){return typeof c=="number"&&isFinite(c)},i=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(f,e,t){"use strict";t.r(e);var a=function(){function i(){}return i.getSilentFrame=function(R,E){switch(R){case"mp4a.40.2":if(E===1)return new Uint8Array([0,200,0,128,35,128]);if(E===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(E===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(E===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(E===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(E===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(E===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(E===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(E===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}},i}();e.default=a},"./src/remux/mp4-generator.ts":function(f,e,t){"use strict";t.r(e);var a=Math.pow(2,32)-1,i=function(){function c(){}return c.init=function(){c.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 E;for(E in c.types)c.types.hasOwnProperty(E)&&(c.types[E]=[E.charCodeAt(0),E.charCodeAt(1),E.charCodeAt(2),E.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]),_=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]);c.HDLR_TYPES={video:L,audio:_};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),I=new Uint8Array([0,0,0,0,0,0,0,0]);c.STTS=c.STSC=c.STCO=I,c.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),c.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),c.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),c.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var M=new Uint8Array([105,115,111,109]),D=new Uint8Array([97,118,99,49]),b=new Uint8Array([0,0,0,1]);c.FTYP=c.box(c.types.ftyp,M,b,M,D),c.DINF=c.box(c.types.dinf,c.box(c.types.dref,y))},c.box=function(E){for(var L=8,_=arguments.length,y=new Array(_>1?_-1:0),I=1;I<_;I++)y[I-1]=arguments[I];for(var M=y.length,D=M;M--;)L+=y[M].byteLength;var b=new Uint8Array(L);for(b[0]=L>>24&255,b[1]=L>>16&255,b[2]=L>>8&255,b[3]=L&255,b.set(E,4),M=0,L=8;M<D;M++)b.set(y[M],L),L+=y[M].byteLength;return b},c.hdlr=function(E){return c.box(c.types.hdlr,c.HDLR_TYPES[E])},c.mdat=function(E){return c.box(c.types.mdat,E)},c.mdhd=function(E,L){L*=E;var _=Math.floor(L/(a+1)),y=Math.floor(L%(a+1));return c.box(c.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,E>>24&255,E>>16&255,E>>8&255,E&255,_>>24,_>>16&255,_>>8&255,_&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},c.mdia=function(E){return c.box(c.types.mdia,c.mdhd(E.timescale,E.duration),c.hdlr(E.type),c.minf(E))},c.mfhd=function(E){return c.box(c.types.mfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255]))},c.minf=function(E){return E.type==="audio"?c.box(c.types.minf,c.box(c.types.smhd,c.SMHD),c.DINF,c.stbl(E)):c.box(c.types.minf,c.box(c.types.vmhd,c.VMHD),c.DINF,c.stbl(E))},c.moof=function(E,L,_){return c.box(c.types.moof,c.mfhd(E),c.traf(_,L))},c.moov=function(E){for(var L=E.length,_=[];L--;)_[L]=c.trak(E[L]);return c.box.apply(null,[c.types.moov,c.mvhd(E[0].timescale,E[0].duration)].concat(_).concat(c.mvex(E)))},c.mvex=function(E){for(var L=E.length,_=[];L--;)_[L]=c.trex(E[L]);return c.box.apply(null,[c.types.mvex].concat(_))},c.mvhd=function(E,L){L*=E;var _=Math.floor(L/(a+1)),y=Math.floor(L%(a+1)),I=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,E>>24&255,E>>16&255,E>>8&255,E&255,_>>24,_>>16&255,_>>8&255,_&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 c.box(c.types.mvhd,I)},c.sdtp=function(E){var L=E.samples||[],_=new Uint8Array(4+L.length),y,I;for(y=0;y<L.length;y++)I=L[y].flags,_[y+4]=I.dependsOn<<4|I.isDependedOn<<2|I.hasRedundancy;return c.box(c.types.sdtp,_)},c.stbl=function(E){return c.box(c.types.stbl,c.stsd(E),c.box(c.types.stts,c.STTS),c.box(c.types.stsc,c.STSC),c.box(c.types.stsz,c.STSZ),c.box(c.types.stco,c.STCO))},c.avc1=function(E){var L=[],_=[],y,I,M;for(y=0;y<E.sps.length;y++)I=E.sps[y],M=I.byteLength,L.push(M>>>8&255),L.push(M&255),L=L.concat(Array.prototype.slice.call(I));for(y=0;y<E.pps.length;y++)I=E.pps[y],M=I.byteLength,_.push(M>>>8&255),_.push(M&255),_=_.concat(Array.prototype.slice.call(I));var D=c.box(c.types.avcC,new Uint8Array([1,L[3],L[4],L[5],252|3,224|E.sps.length].concat(L).concat([E.pps.length]).concat(_))),b=E.width,A=E.height,u=E.pixelRatio[0],r=E.pixelRatio[1];return c.box(c.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,b>>8&255,b&255,A>>8&255,A&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]),D,c.box(c.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),c.box(c.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,r>>24,r>>16&255,r>>8&255,r&255])))},c.esds=function(E){var L=E.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(E.config).concat([6,1,2]))},c.mp4a=function(E){var L=E.samplerate;return c.box(c.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,E.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]),c.box(c.types.esds,c.esds(E)))},c.mp3=function(E){var L=E.samplerate;return c.box(c.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,E.channelCount,0,16,0,0,0,0,L>>8&255,L&255,0,0]))},c.stsd=function(E){return E.type==="audio"?!E.isAAC&&E.codec==="mp3"?c.box(c.types.stsd,c.STSD,c.mp3(E)):c.box(c.types.stsd,c.STSD,c.mp4a(E)):c.box(c.types.stsd,c.STSD,c.avc1(E))},c.tkhd=function(E){var L=E.id,_=E.duration*E.timescale,y=E.width,I=E.height,M=Math.floor(_/(a+1)),D=Math.floor(_%(a+1));return c.box(c.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,M>>24,M>>16&255,M>>8&255,M&255,D>>24,D>>16&255,D>>8&255,D&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,I>>8&255,I&255,0,0]))},c.traf=function(E,L){var _=c.sdtp(E),y=E.id,I=Math.floor(L/(a+1)),M=Math.floor(L%(a+1));return c.box(c.types.traf,c.box(c.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),c.box(c.types.tfdt,new Uint8Array([1,0,0,0,I>>24,I>>16&255,I>>8&255,I&255,M>>24,M>>16&255,M>>8&255,M&255])),c.trun(E,_.length+16+20+8+16+8+8),_)},c.trak=function(E){return E.duration=E.duration||4294967295,c.box(c.types.trak,c.tkhd(E),c.mdia(E))},c.trex=function(E){var L=E.id;return c.box(c.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]))},c.trun=function(E,L){var _=E.samples||[],y=_.length,I=12+16*y,M=new Uint8Array(I),D,b,A,u,r,o;for(L+=8+I,M.set([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),D=0;D<y;D++)b=_[D],A=b.duration,u=b.size,r=b.flags,o=b.cts,M.set([A>>>24&255,A>>>16&255,A>>>8&255,A&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,r.isLeading<<2|r.dependsOn,r.isDependedOn<<6|r.hasRedundancy<<4|r.paddingValue<<1|r.isNonSync,r.degradPrio&240<<8,r.degradPrio&15,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*D);return c.box(c.types.trun,M)},c.initSegment=function(E){c.types||c.init();var L=c.moov(E),_=new Uint8Array(c.FTYP.byteLength+L.byteLength);return _.set(c.FTYP),_.set(L,c.FTYP.byteLength),_},c}();i.types=void 0,i.HDLR_TYPES=void 0,i.STTS=void 0,i.STSC=void 0,i.STCO=void 0,i.STSZ=void 0,i.VMHD=void 0,i.SMHD=void 0,i.STSD=void 0,i.FTYP=void 0,i.DINF=void 0,e.default=i},"./src/remux/mp4-remuxer.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return o}),t.d(e,"normalizePts",function(){return n});var a=t("./src/polyfills/number.ts"),i=t("./src/remux/aac-helper.ts"),c=t("./src/remux/mp4-generator.ts"),R=t("./src/events.ts"),E=t("./src/errors.ts"),L=t("./src/utils/logger.ts"),_=t("./src/types/loader.ts"),y=t("./src/utils/timescale-conversion.ts");function I(){return I=Object.assign||function(T){for(var g=1;g<arguments.length;g++){var m=arguments[g];for(var p in m)Object.prototype.hasOwnProperty.call(m,p)&&(T[p]=m[p])}return T},I.apply(this,arguments)}var M=10*1e3,D=1024,b=1152,A=null,u=null,r=!1,o=function(){function T(m,p,v,h){if(h===void 0&&(h=""),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.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=m,this.config=p,this.typeSupported=v,this.ISGenerated=!1,A===null){var x=navigator.userAgent||"",S=x.match(/Chrome\/(\d+)/i);A=S?parseInt(S[1]):0}if(u===null){var C=navigator.userAgent.match(/Safari\/(\d+)/i);u=C?parseInt(C[1]):0}r=!!A&&A<75||!!u&&u<600}var g=T.prototype;return g.destroy=function(){},g.resetTimeStamp=function(p){L.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=p},g.resetNextTimestamp=function(){L.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},g.resetInitSegment=function(){L.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},g.getVideoStartPts=function(p){var v=!1,h=p.reduce(function(x,S){var C=S.pts-x;return C<-4294967296?(v=!0,n(x,S.pts)):C>0?x:S.pts},p[0].pts);return v&&L.logger.debug("PTS rollover detected"),h},g.remux=function(p,v,h,x,S,C,O,P){var w,U,k,N,B,K,H=S,F=S,W=p.pid>-1,Y=v.pid>-1,$=v.samples.length,J=p.samples.length>0,q=$>1,oe=(!W||J)&&(!Y||q)||this.ISGenerated||O;if(oe){this.ISGenerated||(k=this.generateIS(p,v,S));var X=this.isVideoContiguous,ie=-1;if(q&&(ie=s(v.samples),!X&&this.config.forceKeyFrameOnDiscontinuity))if(K=!0,ie>0){L.logger.warn("[mp4-remuxer]: Dropped "+ie+" out of "+$+" video samples due to a missing keyframe");var fe=this.getVideoStartPts(v.samples);v.samples=v.samples.slice(ie),v.dropped+=ie,F+=(v.samples[0].pts-fe)/(v.timescale||9e4)}else ie===-1&&(L.logger.warn("[mp4-remuxer]: No keyframe found out of "+$+" video samples"),K=!1);if(this.ISGenerated){if(J&&q){var ue=this.getVideoStartPts(v.samples),_e=n(p.samples[0].pts,ue)-ue,re=_e/v.inputTimeScale;H+=Math.max(0,re),F+=Math.max(0,-re)}if(J){if(p.samplerate||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),k=this.generateIS(p,v,S)),U=this.remuxAudio(p,H,this.isAudioContiguous,C,Y||q||P===_.PlaylistLevelType.AUDIO?F:void 0),q){var Z=U?U.endPTS-U.startPTS:0;v.inputTimeScale||(L.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),k=this.generateIS(p,v,S)),w=this.remuxVideo(v,F,X,Z)}}else q&&(w=this.remuxVideo(v,F,X,0));w&&(w.firstKeyFrame=ie,w.independent=ie!==-1)}}return this.ISGenerated&&(h.samples.length&&(B=this.remuxID3(h,S)),x.samples.length&&(N=this.remuxText(x,S))),{audio:U,video:w,initSegment:k,independent:K,text:N,id3:B}},g.generateIS=function(p,v,h){var x=p.samples,S=v.samples,C=this.typeSupported,O={},P=!Object(a.isFiniteNumber)(this._initPTS),w="audio/mp4",U,k,N;if(P&&(U=k=1/0),p.config&&x.length&&(p.timescale=p.samplerate,p.isAAC||(C.mpeg?(w="audio/mpeg",p.codec=""):C.mp3&&(p.codec="mp3")),O.audio={id:"audio",container:w,codec:p.codec,initSegment:!p.isAAC&&C.mpeg?new Uint8Array(0):c.default.initSegment([p]),metadata:{channelCount:p.channelCount}},P&&(N=p.inputTimeScale,U=k=x[0].pts-Math.round(N*h))),v.sps&&v.pps&&S.length&&(v.timescale=v.inputTimeScale,O.video={id:"main",container:"video/mp4",codec:v.codec,initSegment:c.default.initSegment([v]),metadata:{width:v.width,height:v.height}},P)){N=v.inputTimeScale;var B=this.getVideoStartPts(S),K=Math.round(N*h);k=Math.min(k,n(S[0].dts,B)-K),U=Math.min(U,B-K)}if(Object.keys(O).length)return this.ISGenerated=!0,P&&(this._initPTS=U,this._initDTS=k),{tracks:O,initPTS:U,timescale:N}},g.remuxVideo=function(p,v,h,x){var S=p.inputTimeScale,C=p.samples,O=[],P=C.length,w=this._initPTS,U=this.nextAvcDts,k=8,N,B,K,H=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,W=0,Y=!1;if(!h||U===null){var $=v*S,J=C[0].pts-n(C[0].dts,C[0].pts);U=$-J}for(var q=0;q<P;q++){var oe=C[q];if(oe.pts=n(oe.pts-w,U),oe.dts=n(oe.dts-w,U),oe.dts>oe.pts){var X=9e4*.2;W=Math.max(Math.min(W,oe.pts-oe.dts),-1*X)}oe.dts<C[q>0?q-1:q].dts&&(Y=!0)}Y&&C.sort(function(Nt,er){var Bt=Nt.dts-er.dts,tr=Nt.pts-er.pts;return Bt||tr}),B=C[0].dts,K=C[C.length-1].dts;var ie=Math.round((K-B)/(P-1));if(W<0){if(W<ie*-2){L.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(y.toMsFromMpegTsClock)(-ie,!0)+" ms");for(var fe=W,ue=0;ue<P;ue++)C[ue].dts=fe=Math.max(fe,C[ue].pts-ie),C[ue].pts=Math.max(fe,C[ue].pts)}else{L.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(y.toMsFromMpegTsClock)(W,!0)+" ms to overcome this issue");for(var _e=0;_e<P;_e++)C[_e].dts=C[_e].dts+W}B=C[0].dts}if(h){var re=B-U,Z=re>ie,te=re<-1;if(Z||te){Z?L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):L.logger.warn("AVC: "+Object(y.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),B=U;var ee=C[0].pts-re;C[0].dts=B,C[0].pts=ee,L.logger.log("Video: First PTS/DTS adjusted: "+Object(y.toMsFromMpegTsClock)(ee,!0)+"/"+Object(y.toMsFromMpegTsClock)(B,!0)+", delta: "+Object(y.toMsFromMpegTsClock)(re,!0)+" ms")}}r&&(B=Math.max(0,B));for(var he=0,xe=0,ge=0;ge<P;ge++){for(var Ae=C[ge],Me=Ae.units,Be=Me.length,Ee=0,ye=0;ye<Be;ye++)Ee+=Me[ye].data.length;xe+=Ee,he+=Be,Ae.length=Ee,Ae.dts=Math.max(Ae.dts,B),Ae.pts=Math.max(Ae.pts,Ae.dts,0),H=Math.min(Ae.pts,H),F=Math.max(Ae.pts,F)}K=C[P-1].dts;var Fe=xe+4*he+8,Se;try{Se=new Uint8Array(Fe)}catch{this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:E.ErrorTypes.MUX_ERROR,details:E.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Fe,reason:"fail allocating video mdat "+Fe});return}var qe=new DataView(Se.buffer);qe.setUint32(0,Fe),Se.set(c.default.types.mdat,4);for(var Ue=0;Ue<P;Ue++){for(var ze=C[Ue],et=ze.units,tt=0,G=0,V=et.length;G<V;G++){var de=et[G],ce=de.data,Re=de.data.byteLength;qe.setUint32(k,Re),k+=4,Se.set(ce,k),k+=Re,tt+=4+Re}if(Ue<P-1)N=C[Ue+1].dts-ze.dts;else{var Ce=this.config,le=ze.dts-C[Ue>0?Ue-1:Ue].dts;if(Ce.stretchShortVideoTrack&&this.nextAudioPts!==null){var Ze=Math.floor(Ce.maxBufferHole*S),We=(x?H+x*S:this.nextAudioPts)-ze.pts;We>Ze?(N=We-le,N<0&&(N=le),L.logger.log("[mp4-remuxer]: It is approximately "+We/90+" ms to the next segment; using duration "+N/90+" ms for the last video frame.")):N=le}else N=le}var rt=Math.round(ze.pts-ze.dts);O.push(new d(ze.key,N,tt,rt))}if(O.length&&A&&A<70){var qt=O[0].flags;qt.dependsOn=2,qt.isNonSync=0}console.assert(N!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=U=K+N,this.isVideoContiguous=!0;var Tr=c.default.moof(p.sequenceNumber++,B,I({},p,{samples:O})),mt="video",br={data1:Tr,data2:Se,startPTS:H/S,endPTS:(F+N)/S,startDTS:B/S,endDTS:U/S,type:mt,hasAudio:!1,hasVideo:!0,nb:O.length,dropped:p.dropped};return p.samples=[],p.dropped=0,console.assert(Se.length,"MDAT length must not be zero"),br},g.remuxAudio=function(p,v,h,x,S){var C=p.inputTimeScale,O=p.samplerate?p.samplerate:C,P=C/O,w=p.isAAC?D:b,U=w*P,k=this._initPTS,N=!p.isAAC&&this.typeSupported.mpeg,B=[],K=p.samples,H=N?0:8,F=this.nextAudioPts||-1,W=v*C;if(this.isAudioContiguous=h=h||K.length&&F>0&&(x&&Math.abs(W-F)<9e3||Math.abs(n(K[0].pts-k,W)-F)<20*U),K.forEach(function(ce){ce.pts=n(ce.pts-k,W)}),!h||F<0){if(K=K.filter(function(ce){return ce.pts>=0}),!K.length)return;S===0?F=0:x?F=Math.max(0,W):F=K[0].pts}if(p.isAAC)for(var Y=S!==void 0,$=this.config.maxAudioFramesDrift,J=0,q=F;J<K.length;J++){var oe=K[J],X=oe.pts,ie=X-q,fe=Math.abs(1e3*ie/C);if(ie<=-$*U&&Y)J===0&&(L.logger.warn("Audio frame @ "+(X/C).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ie/C)+" ms."),this.nextAudioPts=F=q=X);else if(ie>=$*U&&fe<M&&Y){var ue=Math.round(ie/U);q=X-ue*U,q<0&&(ue--,q+=U),J===0&&(this.nextAudioPts=F=q),L.logger.warn("[mp4-remuxer]: Injecting "+ue+" audio frame @ "+(q/C).toFixed(3)+"s due to "+Math.round(1e3*ie/C)+" ms gap.");for(var _e=0;_e<ue;_e++){var re=Math.max(q,0),Z=i.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);Z||(L.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Z=oe.unit.subarray()),K.splice(J,0,{unit:Z,pts:re}),q+=U,J++}}oe.pts=q,q+=U}for(var te=null,ee=null,he,xe=0,ge=K.length;ge--;)xe+=K[ge].unit.byteLength;for(var Ae=0,Me=K.length;Ae<Me;Ae++){var Be=K[Ae],Ee=Be.unit,ye=Be.pts;if(ee!==null){var Fe=B[Ae-1];Fe.duration=Math.round((ye-ee)/P)}else if(h&&p.isAAC&&(ye=F),te=ye,xe>0){xe+=H;try{he=new Uint8Array(xe)}catch{this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:E.ErrorTypes.MUX_ERROR,details:E.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:xe,reason:"fail allocating audio mdat "+xe});return}if(!N){var Se=new DataView(he.buffer);Se.setUint32(0,xe),he.set(c.default.types.mdat,4)}}else return;he.set(Ee,H);var qe=Ee.byteLength;H+=qe,B.push(new d(!0,w,qe,0)),ee=ye}var Ue=B.length;if(!!Ue){var ze=B[B.length-1];this.nextAudioPts=F=ee+P*ze.duration;var et=N?new Uint8Array(0):c.default.moof(p.sequenceNumber++,te/P,I({},p,{samples:B}));p.samples=[];var tt=te/C,G=F/C,V="audio",de={data1:et,data2:he,startPTS:tt,endPTS:G,startDTS:tt,endDTS:G,type:V,hasAudio:!0,hasVideo:!1,nb:Ue};return this.isAudioContiguous=!0,console.assert(he.length,"MDAT length must not be zero"),de}},g.remuxEmptyAudio=function(p,v,h,x){var S=p.inputTimeScale,C=p.samplerate?p.samplerate:S,O=S/C,P=this.nextAudioPts,w=(P!==null?P:x.startDTS*S)+this._initDTS,U=x.endDTS*S+this._initDTS,k=O*D,N=Math.ceil((U-w)/k),B=i.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(L.logger.warn("[mp4-remuxer]: remux empty Audio"),!B){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=[],H=0;H<N;H++){var F=w+H*k;K.push({unit:B,pts:F,dts:F})}return p.samples=K,this.remuxAudio(p,v,h,!1)},g.remuxID3=function(p,v){var h=p.samples.length;if(!!h){for(var x=p.inputTimeScale,S=this._initPTS,C=this._initDTS,O=0;O<h;O++){var P=p.samples[O];P.pts=n(P.pts-S,v*x)/x,P.dts=n(P.dts-C,v*x)/x}var w=p.samples;return p.samples=[],{samples:w}}},g.remuxText=function(p,v){var h=p.samples.length;if(!!h){for(var x=p.inputTimeScale,S=this._initPTS,C=0;C<h;C++){var O=p.samples[C];O.pts=n(O.pts-S,v*x)/x}p.samples.sort(function(w,U){return w.pts-U.pts});var P=p.samples;return p.samples=[],{samples:P}}},T}();function n(T,g){var m;if(g===null)return T;for(g<T?m=-8589934592:m=8589934592;Math.abs(T-g)>4294967296;)T+=m;return T}function s(T){for(var g=0;g<T.length;g++)if(T[g].key)return g;return-1}var d=function(g,m,p,v){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=p,this.cts=v,this.flags=new l(g)},l=function(g){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=g?2:1,this.isNonSync=g?0:1}},"./src/remux/passthrough-remuxer.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/polyfills/number.ts"),i=t("./src/utils/mp4-tools.ts"),c=t("./src/loader/fragment.ts"),R=t("./src/utils/logger.ts"),E=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.lastEndDTS=null}var I=y.prototype;return I.destroy=function(){},I.resetTimeStamp=function(D){this.initPTS=D,this.lastEndDTS=null},I.resetNextTimestamp=function(){this.lastEndDTS=null},I.resetInitSegment=function(D,b,A){this.audioCodec=b,this.videoCodec=A,this.generateInitSegment(D),this.emitInitSegment=!0},I.generateInitSegment=function(D){var b=this.audioCodec,A=this.videoCodec;if(!D||!D.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(i.parseInitSegment)(D);b||(b=_(u.audio,c.ElementaryStreamTypes.AUDIO)),A||(A=_(u.video,c.ElementaryStreamTypes.VIDEO));var r={};u.audio&&u.video?r.audiovideo={container:"video/mp4",codec:b+","+A,initSegment:D,id:"main"}:u.audio?r.audio={container:"audio/mp4",codec:b,initSegment:D,id:"audio"}:u.video?r.video={container:"video/mp4",codec:A,initSegment:D,id:"main"}:R.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r},I.remux=function(D,b,A,u,r){var o=this.initPTS,n=this.lastEndDTS,s={audio:void 0,video:void 0,text:u,id3:A,initSegment:void 0};Object(a.isFiniteNumber)(n)||(n=this.lastEndDTS=r||0);var d=b.samples;if(!d||!d.length)return s;var l={initPTS:void 0,timescale:1},T=this.initData;if((!T||!T.length)&&(this.generateInitSegment(d),T=this.initData),!T||!T.length)return R.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),s;this.emitInitSegment&&(l.tracks=this.initTracks,this.emitInitSegment=!1),Object(a.isFiniteNumber)(o)||(this.initPTS=l.initPTS=o=L(T,d,n));var g=Object(i.getDuration)(d,T),m=n,p=g+m;Object(i.offsetStartDTS)(T,d,o),g>0?this.lastEndDTS=p:(R.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!T.audio,h=!!T.video,x="";v&&(x+="audio"),h&&(x+="video");var S={data1:d,startPTS:m,startDTS:m,endPTS:p,endDTS:p,type:x,hasAudio:v,hasVideo:h,nb:1,dropped:0};return s.audio=S.type==="audio"?S:void 0,s.video=S.type!=="audio"?S:void 0,s.text=u,s.id3=A,s.initSegment=l,s},y}(),L=function(I,M,D){return Object(i.getStartDTS)(I,M)-D};function _(y,I){var M=y==null?void 0:y.codec;return M&&M.length>4?M:M==="hvc1"?"hvc1.1.c.L120.90":M==="av01"?"av01.0.04M.08":M==="avc1"||I===c.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}e.default=E},"./src/task-loop.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return a});var a=function(){function i(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var c=i.prototype;return c.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},c.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},c.onHandlerDestroyed=function(){},c.hasInterval=function(){return!!this._tickInterval},c.hasNextTick=function(){return!!this._tickTimer},c.setInterval=function(E){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,E),!0)},c.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},c.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},c.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},c.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},c.doTick=function(){},i}()},"./src/types/cmcd.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"CMCDVersion",function(){return a}),t.d(e,"CMCDObjectType",function(){return i}),t.d(e,"CMCDStreamingFormat",function(){return c}),t.d(e,"CMCDStreamType",function(){return R});var a=1,i;(function(E){E.MANIFEST="m",E.AUDIO="a",E.VIDEO="v",E.MUXED="av",E.INIT="i",E.CAPTION="c",E.TIMED_TEXT="tt",E.KEY="k",E.OTHER="o"})(i||(i={}));var c;(function(E){E.DASH="d",E.HLS="h",E.SMOOTH="s",E.OTHER="o"})(c||(c={}));var R;(function(E){E.VOD="v",E.LIVE="l"})(R||(R={}))},"./src/types/level.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"HlsSkip",function(){return c}),t.d(e,"getSkipValue",function(){return R}),t.d(e,"HlsUrlParameters",function(){return E}),t.d(e,"Level",function(){return L});function a(_,y){for(var I=0;I<y.length;I++){var M=y[I];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(_,M.key,M)}}function i(_,y,I){return y&&a(_.prototype,y),I&&a(_,I),_}var c;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(c||(c={}));function R(_,y){var I=_.canSkipUntil,M=_.canSkipDateRanges,D=_.endSN,b=y!==void 0?y-D:0;return I&&b<I?M?c.v2:c.Yes:c.No}var E=function(){function _(I,M,D){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=I,this.part=M,this.skip=D}var y=_.prototype;return y.addDirectives=function(M){var D=new self.URL(M);return this.msn!==void 0&&D.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&D.searchParams.set("_HLS_part",this.part.toString()),this.skip&&D.searchParams.set("_HLS_skip",this.skip),D.toString()},_}(),L=function(){function _(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(I){return I}).join(",").replace(/\.[^.,]+/g,"")}return i(_,[{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(I){var M=I%this.url.length;this._urlId!==M&&(this.details=void 0,this._urlId=M)}}]),_}()},"./src/types/loader.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"PlaylistContextType",function(){return a}),t.d(e,"PlaylistLevelType",function(){return i});var a;(function(c){c.MANIFEST="manifest",c.LEVEL="level",c.AUDIO_TRACK="audioTrack",c.SUBTITLE_TRACK="subtitleTrack"})(a||(a={}));var i;(function(c){c.MAIN="main",c.AUDIO="audio",c.SUBTITLE="subtitle"})(i||(i={}))},"./src/types/transmuxer.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"ChunkMetadata",function(){return a});var a=function(R,E,L,_,y,I){_===void 0&&(_=0),y===void 0&&(y=-1),I===void 0&&(I=!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=i(),this.buffering={audio:i(),video:i(),audiovideo:i()},this.level=R,this.sn=E,this.id=L,this.size=_,this.part=y,this.partial=I};function i(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"AttrList",function(){return c});var a=/^(\d+)x(\d+)$/,i=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,c=function(){function R(L){typeof L=="string"&&(L=R.parseAttrList(L));for(var _ in L)L.hasOwnProperty(_)&&(this[_]=L[_])}var E=R.prototype;return E.decimalInteger=function(_){var y=parseInt(this[_],10);return y>Number.MAX_SAFE_INTEGER?1/0:y},E.hexadecimalInteger=function(_){if(this[_]){var y=(this[_]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var I=new Uint8Array(y.length/2),M=0;M<y.length/2;M++)I[M]=parseInt(y.slice(M*2,M*2+2),16);return I}else return null},E.hexadecimalIntegerAsNumber=function(_){var y=parseInt(this[_],16);return y>Number.MAX_SAFE_INTEGER?1/0:y},E.decimalFloatingPoint=function(_){return parseFloat(this[_])},E.optionalFloat=function(_,y){var I=this[_];return I?parseFloat(I):y},E.enumeratedString=function(_){return this[_]},E.bool=function(_){return this[_]==="YES"},E.decimalResolution=function(_){var y=a.exec(this[_]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},R.parseAttrList=function(_){var y,I={},M='"';for(i.lastIndex=0;(y=i.exec(_))!==null;){var D=y[2];D.indexOf(M)===0&&D.lastIndexOf(M)===D.length-1&&(D=D.slice(1,-1)),I[y[1]]=D}return I},R}()},"./src/utils/binary-search.ts":function(f,e,t){"use strict";t.r(e);var a={search:function(c,R){for(var E=0,L=c.length-1,_=null,y=null;E<=L;){_=(E+L)/2|0,y=c[_];var I=R(y);if(I>0)E=_+1;else if(I<0)L=_-1;else return y}return null}};e.default=a},"./src/utils/buffer-helper.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"BufferHelper",function(){return c});var a=t("./src/utils/logger.ts"),i={length:0,start:function(){return 0},end:function(){return 0}},c=function(){function R(){}return R.isBuffered=function(L,_){try{if(L){for(var y=R.getBuffered(L),I=0;I<y.length;I++)if(_>=y.start(I)&&_<=y.end(I))return!0}}catch{}return!1},R.bufferInfo=function(L,_,y){try{if(L){var I=R.getBuffered(L),M=[],D;for(D=0;D<I.length;D++)M.push({start:I.start(D),end:I.end(D)});return this.bufferedInfo(M,_,y)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},R.bufferedInfo=function(L,_,y){_=Math.max(0,_),L.sort(function(l,T){var g=l.start-T.start;return g||T.end-l.end});var I=[];if(y)for(var M=0;M<L.length;M++){var D=I.length;if(D){var b=I[D-1].end;L[M].start-b<y?L[M].end>b&&(I[D-1].end=L[M].end):I.push(L[M])}else I.push(L[M])}else I=L;for(var A=0,u,r=_,o=_,n=0;n<I.length;n++){var s=I[n].start,d=I[n].end;if(_+y>=s&&_<d)r=s,o=d,A=o-_;else if(_+y<s){u=s;break}}return{len:A,start:r||0,end:o||0,nextStart:u}},R.getBuffered=function(L){try{return L.buffered}catch(_){return a.logger.log("failed to get media.buffered",_),i}},R}()},"./src/utils/cea-608-parser.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"Row",function(){return o}),t.d(e,"CaptionScreen",function(){return n});var a=t("./src/utils/logger.ts"),i={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},c=function(p){var v=p;return i.hasOwnProperty(p)&&(v=i[p]),String.fromCharCode(v)},R=15,E=100,L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={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},I={25:2,26:4,29:6,30:8,31:10,27:13,28:15},M=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],D;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(D||(D={}));var b=function(){function m(){this.time=null,this.verboseLevel=D.ERROR}var p=m.prototype;return p.log=function(h,x){this.verboseLevel>=h&&a.logger.log(this.time+" ["+h+"] "+x)},m}(),A=function(p){for(var v=[],h=0;h<p.length;h++)v.push(p[h].toString(16));return v},u=function(){function m(v,h,x,S,C){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=v||"white",this.underline=h||!1,this.italics=x||!1,this.background=S||"black",this.flash=C||!1}var p=m.prototype;return p.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},p.setStyles=function(h){for(var x=["foreground","underline","italics","background","flash"],S=0;S<x.length;S++){var C=x[S];h.hasOwnProperty(C)&&(this[C]=h[C])}},p.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},p.equals=function(h){return this.foreground===h.foreground&&this.underline===h.underline&&this.italics===h.italics&&this.background===h.background&&this.flash===h.flash},p.copy=function(h){this.foreground=h.foreground,this.underline=h.underline,this.italics=h.italics,this.background=h.background,this.flash=h.flash},p.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),r=function(){function m(v,h,x,S,C,O){this.uchar=void 0,this.penState=void 0,this.uchar=v||" ",this.penState=new u(h,x,S,C,O)}var p=m.prototype;return p.reset=function(){this.uchar=" ",this.penState.reset()},p.setChar=function(h,x){this.uchar=h,this.penState.copy(x)},p.setPenState=function(h){this.penState.copy(h)},p.equals=function(h){return this.uchar===h.uchar&&this.penState.equals(h.penState)},p.copy=function(h){this.uchar=h.uchar,this.penState.copy(h.penState)},p.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),o=function(){function m(v){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var h=0;h<E;h++)this.chars.push(new r);this.logger=v,this.pos=0,this.currPenState=new u}var p=m.prototype;return p.equals=function(h){for(var x=!0,S=0;S<E;S++)if(!this.chars[S].equals(h.chars[S])){x=!1;break}return x},p.copy=function(h){for(var x=0;x<E;x++)this.chars[x].copy(h.chars[x])},p.isEmpty=function(){for(var h=!0,x=0;x<E;x++)if(!this.chars[x].isEmpty()){h=!1;break}return h},p.setCursor=function(h){this.pos!==h&&(this.pos=h),this.pos<0?(this.logger.log(D.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>E&&(this.logger.log(D.DEBUG,"Too large cursor position "+this.pos),this.pos=E)},p.moveCursor=function(h){var x=this.pos+h;if(h>1)for(var S=this.pos+1;S<x+1;S++)this.chars[S].setPenState(this.currPenState);this.setCursor(x)},p.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},p.insertChar=function(h){h>=144&&this.backSpace();var x=c(h);if(this.pos>=E){this.logger.log(D.ERROR,"Cannot insert "+h.toString(16)+" ("+x+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(x,this.currPenState),this.moveCursor(1)},p.clearFromPos=function(h){var x;for(x=h;x<E;x++)this.chars[x].reset()},p.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},p.clearToEndOfRow=function(){this.clearFromPos(this.pos)},p.getTextString=function(){for(var h=[],x=!0,S=0;S<E;S++){var C=this.chars[S].uchar;C!==" "&&(x=!1),h.push(C)}return x?"":h.join("")},p.setPenStyles=function(h){this.currPenState.setStyles(h);var x=this.chars[this.pos];x.setPenState(this.currPenState)},m}(),n=function(){function m(v){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var h=0;h<R;h++)this.rows.push(new o(v));this.logger=v,this.currRow=R-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var p=m.prototype;return p.reset=function(){for(var h=0;h<R;h++)this.rows[h].clear();this.currRow=R-1},p.equals=function(h){for(var x=!0,S=0;S<R;S++)if(!this.rows[S].equals(h.rows[S])){x=!1;break}return x},p.copy=function(h){for(var x=0;x<R;x++)this.rows[x].copy(h.rows[x])},p.isEmpty=function(){for(var h=!0,x=0;x<R;x++)if(!this.rows[x].isEmpty()){h=!1;break}return h},p.backSpace=function(){var h=this.rows[this.currRow];h.backSpace()},p.clearToEndOfRow=function(){var h=this.rows[this.currRow];h.clearToEndOfRow()},p.insertChar=function(h){var x=this.rows[this.currRow];x.insertChar(h)},p.setPen=function(h){var x=this.rows[this.currRow];x.setPenStyles(h)},p.moveCursor=function(h){var x=this.rows[this.currRow];x.moveCursor(h)},p.setCursor=function(h){this.logger.log(D.INFO,"setCursor: "+h);var x=this.rows[this.currRow];x.setCursor(h)},p.setPAC=function(h){this.logger.log(D.INFO,"pacData = "+JSON.stringify(h));var x=h.row-1;if(this.nrRollUpRows&&x<this.nrRollUpRows-1&&(x=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==x){for(var S=0;S<R;S++)this.rows[S].clear();var C=this.currRow+1-this.nrRollUpRows,O=this.lastOutputScreen;if(O){var P=O.rows[C].cueStartTime,w=this.logger.time;if(P&&w!==null&&P<w)for(var U=0;U<this.nrRollUpRows;U++)this.rows[x-this.nrRollUpRows+U+1].copy(O.rows[C+U])}}this.currRow=x;var k=this.rows[this.currRow];if(h.indent!==null){var N=h.indent,B=Math.max(N-1,0);k.setCursor(h.indent),h.color=k.chars[B].penState.foreground}var K={foreground:h.color,underline:h.underline,italics:h.italics,background:"black",flash:!1};this.setPen(K)},p.setBkgData=function(h){this.logger.log(D.INFO,"bkgData = "+JSON.stringify(h)),this.backSpace(),this.setPen(h),this.insertChar(32)},p.setRollUpRows=function(h){this.nrRollUpRows=h},p.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(D.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(D.TEXT,this.getDisplayText());var h=this.currRow+1-this.nrRollUpRows,x=this.rows.splice(h,1)[0];x.clear(),this.rows.splice(this.currRow,0,x),this.logger.log(D.INFO,"Rolling up")},p.getDisplayText=function(h){h=h||!1;for(var x=[],S="",C=-1,O=0;O<R;O++){var P=this.rows[O].getTextString();P&&(C=O+1,h?x.push("Row "+C+": '"+P+"'"):x.push(P.trim()))}return x.length>0&&(h?S="["+x.join(" | ")+"]":S=x.join(`
19
+ `)),S},p.getTextAndFormat=function(){return this.rows},m}(),s=function(){function m(v,h,x){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=v,this.outputFilter=h,this.mode=null,this.verbose=0,this.displayedMemory=new n(x),this.nonDisplayedMemory=new n(x),this.lastOutputScreen=new n(x),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=x}var p=m.prototype;return p.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[R-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},p.getHandler=function(){return this.outputFilter},p.setHandler=function(h){this.outputFilter=h},p.setPAC=function(h){this.writeScreen.setPAC(h)},p.setBkgData=function(h){this.writeScreen.setBkgData(h)},p.setMode=function(h){h!==this.mode&&(this.mode=h,this.logger.log(D.INFO,"MODE="+h),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=h)},p.insertChars=function(h){for(var x=0;x<h.length;x++)this.writeScreen.insertChar(h[x]);var S=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(D.INFO,S+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(D.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},p.ccRCL=function(){this.logger.log(D.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},p.ccBS=function(){this.logger.log(D.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},p.ccAOF=function(){},p.ccAON=function(){},p.ccDER=function(){this.logger.log(D.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},p.ccRU=function(h){this.logger.log(D.INFO,"RU("+h+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(h)},p.ccFON=function(){this.logger.log(D.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},p.ccRDC=function(){this.logger.log(D.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},p.ccTR=function(){this.logger.log(D.INFO,"TR"),this.setMode("MODE_TEXT")},p.ccRTD=function(){this.logger.log(D.INFO,"RTD"),this.setMode("MODE_TEXT")},p.ccEDM=function(){this.logger.log(D.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},p.ccCR=function(){this.logger.log(D.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},p.ccENM=function(){this.logger.log(D.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},p.ccEOC=function(){if(this.logger.log(D.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var h=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=h,this.writeScreen=this.nonDisplayedMemory,this.logger.log(D.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},p.ccTO=function(h){this.logger.log(D.INFO,"TO("+h+") - Tab Offset"),this.writeScreen.moveCursor(h)},p.ccMIDROW=function(h){var x={flash:!1};if(x.underline=h%2==1,x.italics=h>=46,x.italics)x.foreground="white";else{var S=Math.floor(h/2)-16,C=["white","green","blue","cyan","red","yellow","magenta"];x.foreground=C[S]}this.logger.log(D.INFO,"MIDROW: "+JSON.stringify(x)),this.writeScreen.setPen(x)},p.outputDataUpdate=function(h){h===void 0&&(h=!1);var x=this.logger.time;x!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=x:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,x,this.lastOutputScreen),h&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:x),this.lastOutputScreen.copy(this.displayedMemory))},p.cueSplitAtTime=function(h){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,h,this.displayedMemory),this.cueStartTime=h))},m}(),d=function(){function m(v,h,x){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var S=new b;this.channels=[null,new s(v,h,S),new s(v+1,x,S)],this.cmdHistory=g(),this.logger=S}var p=m.prototype;return p.getHandler=function(h){return this.channels[h].getHandler()},p.setHandler=function(h,x){this.channels[h].setHandler(x)},p.addData=function(h,x){var S,C,O,P=!1;this.logger.time=h;for(var w=0;w<x.length;w+=2)if(C=x[w]&127,O=x[w+1]&127,!(C===0&&O===0)){if(this.logger.log(D.DATA,"["+A([x[w],x[w+1]])+"] -> ("+A([C,O])+")"),S=this.parseCmd(C,O),S||(S=this.parseMidrow(C,O)),S||(S=this.parsePAC(C,O)),S||(S=this.parseBackgroundAttributes(C,O)),!S&&(P=this.parseChars(C,O),P)){var U=this.currentChannel;if(U&&U>0){var k=this.channels[U];k.insertChars(P)}else this.logger.log(D.WARNING,"No channel found yet. TEXT-MODE?")}!S&&!P&&this.logger.log(D.WARNING,"Couldn't parse cleaned data "+A([C,O])+" orig: "+A([x[w],x[w+1]]))}},p.parseCmd=function(h,x){var S=this.cmdHistory,C=(h===20||h===28||h===21||h===29)&&x>=32&&x<=47,O=(h===23||h===31)&&x>=33&&x<=35;if(!(C||O))return!1;if(T(h,x,S))return l(null,null,S),this.logger.log(D.DEBUG,"Repeated command ("+A([h,x])+") is dropped"),!0;var P=h===20||h===21||h===23?1:2,w=this.channels[P];return h===20||h===21||h===28||h===29?x===32?w.ccRCL():x===33?w.ccBS():x===34?w.ccAOF():x===35?w.ccAON():x===36?w.ccDER():x===37?w.ccRU(2):x===38?w.ccRU(3):x===39?w.ccRU(4):x===40?w.ccFON():x===41?w.ccRDC():x===42?w.ccTR():x===43?w.ccRTD():x===44?w.ccEDM():x===45?w.ccCR():x===46?w.ccENM():x===47&&w.ccEOC():w.ccTO(x-32),l(h,x,S),this.currentChannel=P,!0},p.parseMidrow=function(h,x){var S=0;if((h===17||h===25)&&x>=32&&x<=47){if(h===17?S=1:S=2,S!==this.currentChannel)return this.logger.log(D.ERROR,"Mismatch channel in midrow parsing"),!1;var C=this.channels[S];return C?(C.ccMIDROW(x),this.logger.log(D.DEBUG,"MIDROW ("+A([h,x])+")"),!0):!1}return!1},p.parsePAC=function(h,x){var S,C=this.cmdHistory,O=(h>=17&&h<=23||h>=25&&h<=31)&&x>=64&&x<=127,P=(h===16||h===24)&&x>=64&&x<=95;if(!(O||P))return!1;if(T(h,x,C))return l(null,null,C),!0;var w=h<=23?1:2;x>=64&&x<=95?S=w===1?L[h]:y[h]:S=w===1?_[h]:I[h];var U=this.channels[w];return U?(U.setPAC(this.interpretPAC(S,x)),l(h,x,C),this.currentChannel=w,!0):!1},p.interpretPAC=function(h,x){var S,C={color:null,italics:!1,indent:null,underline:!1,row:h};return x>95?S=x-96:S=x-64,C.underline=(S&1)==1,S<=13?C.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(S/2)]:S<=15?(C.italics=!0,C.color="white"):C.indent=Math.floor((S-16)/2)*4,C},p.parseChars=function(h,x){var S,C=null,O=null;if(h>=25?(S=2,O=h-8):(S=1,O=h),O>=17&&O<=19){var P;O===17?P=x+80:O===18?P=x+112:P=x+144,this.logger.log(D.INFO,"Special char '"+c(P)+"' in channel "+S),C=[P]}else h>=32&&h<=127&&(C=x===0?[h]:[h,x]);if(C){var w=A(C);this.logger.log(D.DEBUG,"Char codes = "+w.join(",")),l(h,x,this.cmdHistory)}return C},p.parseBackgroundAttributes=function(h,x){var S=(h===16||h===24)&&x>=32&&x<=47,C=(h===23||h===31)&&x>=45&&x<=47;if(!(S||C))return!1;var O,P={};h===16||h===24?(O=Math.floor((x-32)/2),P.background=M[O],x%2==1&&(P.background=P.background+"_semi")):x===45?P.background="transparent":(P.foreground="black",x===47&&(P.underline=!0));var w=h<=23?1:2,U=this.channels[w];return U.setBkgData(P),l(h,x,this.cmdHistory),!0},p.reset=function(){for(var h=0;h<Object.keys(this.channels).length;h++){var x=this.channels[h];x&&x.reset()}this.cmdHistory=g()},p.cueSplitAtTime=function(h){for(var x=0;x<this.channels.length;x++){var S=this.channels[x];S&&S.cueSplitAtTime(h)}},m}();function l(m,p,v){v.a=m,v.b=p}function T(m,p,v){return v.a===m&&v.b===p}function g(){return{a:null,b:null}}e.default=d},"./src/utils/codecs.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"isCodecType",function(){return i}),t.d(e,"isCodecSupportedInMp4",function(){return c});var a={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 i(R,E){var L=a[E];return!!L&&L[R.slice(0,4)]===!0}function c(R,E){return MediaSource.isTypeSupported((E||"video")+'/mp4;codecs="'+R+'"')}},"./src/utils/cues.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/utils/vttparser.ts"),i=t("./src/utils/webvtt-parser.ts"),c=t("./src/utils/texttrack-utils.ts"),R=/\s/,E={newCue:function(_,y,I,M){for(var D=[],b,A,u,r,o,n=self.VTTCue||self.TextTrackCue,s=0;s<M.rows.length;s++)if(b=M.rows[s],u=!0,r=0,o="",!b.isEmpty()){for(var d=0;d<b.chars.length;d++)R.test(b.chars[d].uchar)&&u?r++:(o+=b.chars[d].uchar,u=!1);b.cueStartTime=y,y===I&&(I+=1e-4),r>=16?r--:r++;var l=Object(a.fixLineBreaks)(o.trim()),T=Object(i.generateCueId)(y,I,l);(!_||!_.cues||!_.cues.getCueById(T))&&(A=new n(y,I,l),A.id=T,A.line=s+1,A.align="left",A.position=10+Math.min(80,Math.floor(r*8/32)*10),D.push(A))}return _&&D.length&&(D.sort(function(g,m){return g.line==="auto"||m.line==="auto"?0:g.line>8&&m.line>8?m.line-g.line:g.line-m.line}),D.forEach(function(g){return Object(c.addCueToTrack)(_,g)})),D}};e.default=E},"./src/utils/discontinuities.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"findFirstFragWithCC",function(){return R}),t.d(e,"shouldAlignOnDiscontinuities",function(){return E}),t.d(e,"findDiscontinuousReferenceFrag",function(){return L}),t.d(e,"adjustSlidingStart",function(){return y}),t.d(e,"alignStream",function(){return I}),t.d(e,"alignPDT",function(){return D}),t.d(e,"alignFragmentByPDTDelta",function(){return b}),t.d(e,"alignMediaPlaylistByPDT",function(){return A});var a=t("./src/polyfills/number.ts"),i=t("./src/utils/logger.ts"),c=t("./src/controller/level-helper.ts");function R(u,r){for(var o=null,n=0,s=u.length;n<s;n++){var d=u[n];if(d&&d.cc===r){o=d;break}}return o}function E(u,r,o){return!!(r.details&&(o.endCC>o.startCC||u&&u.cc<o.startCC))}function L(u,r){var o=u.fragments,n=r.fragments;if(!n.length||!o.length){i.logger.log("No fragments to align");return}var s=R(o,n[0].cc);if(!s||s&&!s.startPTS){i.logger.log("No frag in previous level to align on");return}return s}function _(u,r){if(u){var o=u.start+r;u.start=u.startPTS=o,u.endPTS=o+u.duration}}function y(u,r){for(var o=r.fragments,n=0,s=o.length;n<s;n++)_(o[n],u);r.fragmentHint&&_(r.fragmentHint,u),r.alignedSliding=!0}function I(u,r,o){!r||(M(u,o,r),!o.alignedSliding&&r.details&&D(o,r.details),!o.alignedSliding&&r.details&&!o.skippedSegments&&Object(c.adjustSliding)(r.details,o))}function M(u,r,o){if(E(u,o,r)){var n=L(o.details,r);n&&Object(a.isFiniteNumber)(n.start)&&(i.logger.log("Adjusting PTS using last level due to CC increase within current level "+r.url),y(n.start,r))}}function D(u,r){if(!(!r.fragments.length||!u.hasProgramDateTime||!r.hasProgramDateTime)){var o=r.fragments[0].programDateTime,n=u.fragments[0].programDateTime,s=(n-o)/1e3+r.fragments[0].start;s&&Object(a.isFiniteNumber)(s)&&(i.logger.log("Adjusting PTS using programDateTime delta "+(n-o)+"ms, sliding:"+s.toFixed(3)+" "+u.url+" "),y(s,u))}}function b(u,r){var o=u.programDateTime;if(!!o){var n=(o-r)/1e3;u.start=u.startPTS=n,u.endPTS=n+u.duration}}function A(u,r){if(!(!r.fragments.length||!u.hasProgramDateTime||!r.hasProgramDateTime)){var o=r.fragments[0].programDateTime,n=r.fragments[0].start,s=o-n*1e3;u.fragments.forEach(function(d){b(d,s)}),u.fragmentHint&&b(u.fragmentHint,s),u.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/utils/ewma.ts"),i=function(){function c(E,L,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new a.default(E),this.fast_=new a.default(L)}var R=c.prototype;return R.update=function(L,_){var y=this.slow_,I=this.fast_;this.slow_.halfLife!==L&&(this.slow_=new a.default(L,y.getEstimate(),y.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new a.default(_,I.getEstimate(),I.getTotalWeight()))},R.sample=function(L,_){L=Math.max(L,this.minDelayMs_);var y=8*_,I=L/1e3,M=y/I;this.fast_.sample(I,M),this.slow_.sample(I,M)},R.canEstimate=function(){var L=this.fast_;return L&&L.getTotalWeight()>=this.minWeight_},R.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},R.destroy=function(){},c}();e.default=i},"./src/utils/ewma.ts":function(f,e,t){"use strict";t.r(e);var a=function(){function i(R,E,L){E===void 0&&(E=0),L===void 0&&(L=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=R,this.alpha_=R?Math.exp(Math.log(.5)/R):0,this.estimate_=E,this.totalWeight_=L}var c=i.prototype;return c.sample=function(E,L){var _=Math.pow(this.alpha_,E);this.estimate_=L*(1-_)+_*this.estimate_,this.totalWeight_+=E},c.getTotalWeight=function(){return this.totalWeight_},c.getEstimate=function(){if(this.alpha_){var E=1-Math.pow(this.alpha_,this.totalWeight_);if(E)return this.estimate_/E}return this.estimate_},i}();e.default=a},"./src/utils/fetch-loader.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"fetchSupported",function(){return b});var a=t("./src/polyfills/number.ts"),i=t("./src/loader/load-stats.ts"),c=t("./src/demux/chunk-cache.ts");function R(n,s){n.prototype=Object.create(s.prototype),n.prototype.constructor=n,I(n,s)}function E(n){var s=typeof Map=="function"?new Map:void 0;return E=function(l){if(l===null||!y(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof s!="undefined"){if(s.has(l))return s.get(l);s.set(l,T)}function T(){return L(l,arguments,M(this).constructor)}return T.prototype=Object.create(l.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),I(T,l)},E(n)}function L(n,s,d){return _()?L=Reflect.construct:L=function(T,g,m){var p=[null];p.push.apply(p,g);var v=Function.bind.apply(T,p),h=new v;return m&&I(h,m.prototype),h},L.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 y(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function I(n,s){return I=Object.setPrototypeOf||function(l,T){return l.__proto__=T,l},I(n,s)}function M(n){return M=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},M(n)}function D(){return D=Object.assign||function(n){for(var s=1;s<arguments.length;s++){var d=arguments[s];for(var l in d)Object.prototype.hasOwnProperty.call(d,l)&&(n[l]=d[l])}return n},D.apply(this,arguments)}function b(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var A=function(){function n(d){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=d.fetchSetup||r,this.controller=new self.AbortController,this.stats=new i.LoadStats}var s=n.prototype;return s.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},s.abortInternal=function(){var l=this.response;(!l||!l.ok)&&(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var l;this.abortInternal(),(l=this.callbacks)!==null&&l!==void 0&&l.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(l,T,g){var m=this,p=this.stats;if(p.loading.start)throw new Error("Loader can only be used once.");p.loading.start=self.performance.now();var v=u(l,this.controller.signal),h=g.onProgress,x=l.responseType==="arraybuffer",S=x?"byteLength":"length";this.context=l,this.config=T,this.callbacks=g,this.request=this.fetchSetup(l,v),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){m.abortInternal(),g.onTimeout(p,l,m.response)},T.timeout),self.fetch(this.request).then(function(C){if(m.response=m.loader=C,!C.ok){var O=C.status,P=C.statusText;throw new o(P||"fetch, bad network response",O,C)}return p.loading.first=Math.max(self.performance.now(),p.loading.start),p.total=parseInt(C.headers.get("Content-Length")||"0"),h&&Object(a.isFiniteNumber)(T.highWaterMark)?m.loadProgressively(C,p,l,T.highWaterMark,h):x?C.arrayBuffer():C.text()}).then(function(C){var O=m.response;self.clearTimeout(m.requestTimeout),p.loading.end=Math.max(self.performance.now(),p.loading.first),p.loaded=p.total=C[S];var P={url:O.url,data:C};h&&!Object(a.isFiniteNumber)(T.highWaterMark)&&h(p,l,C,O),g.onSuccess(P,p,l,O)}).catch(function(C){if(self.clearTimeout(m.requestTimeout),!p.aborted){var O=C.code||0;g.onError({code:O,text:C.message},l,C.details)}})},s.getCacheAge=function(){var l=null;if(this.response){var T=this.response.headers.get("age");l=T?parseFloat(T):null}return l},s.loadProgressively=function(l,T,g,m,p){m===void 0&&(m=0);var v=new c.default,h=l.body.getReader(),x=function S(){return h.read().then(function(C){if(C.done)return v.dataLength&&p(T,g,v.flush(),l),Promise.resolve(new ArrayBuffer(0));var O=C.value,P=O.length;return T.loaded+=P,P<m||v.dataLength?(v.push(O),v.dataLength>=m&&p(T,g,v.flush(),l)):p(T,g,O,l),S()}).catch(function(){return Promise.reject()})};return x()},n}();function u(n,s){var d={method:"GET",mode:"cors",credentials:"same-origin",signal:s,headers:new self.Headers(D({},n.headers))};return n.rangeEnd&&d.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),d}function r(n,s){return new self.Request(n.url,s)}var o=function(n){R(s,n);function s(d,l,T){var g;return g=n.call(this,d)||this,g.code=void 0,g.details=void 0,g.code=l,g.details=T,g}return s}(E(Error));e.default=A},"./src/utils/imsc1-ttml-parser.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"IMSC1_CODEC",function(){return y}),t.d(e,"parseIMSC1",function(){return b});var a=t("./src/utils/mp4-tools.ts"),i=t("./src/utils/vttparser.ts"),c=t("./src/utils/vttcue.ts"),R=t("./src/demux/id3.ts"),E=t("./src/utils/timescale-conversion.ts"),L=t("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign||function(m){for(var p=1;p<arguments.length;p++){var v=arguments[p];for(var h in v)Object.prototype.hasOwnProperty.call(v,h)&&(m[h]=v[h])}return m},_.apply(this,arguments)}var y="stpp.ttml.im1t",I=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,M=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,D={left:"start",center:"center",right:"end",start:"start",end:"end"};function b(m,p,v,h,x){var S=Object(a.findBox)(new Uint8Array(m),["mdat"]);if(S.length===0){x(new Error("Could not parse IMSC1 mdat"));return}var C=S[0],O=Object(R.utf8ArrayToStr)(new Uint8Array(m,C.start,C.end-C.start)),P=Object(E.toTimescaleFromScale)(p,1,v);try{h(A(O,P))}catch(w){x(w)}}function A(m,p){var v=new DOMParser,h=v.parseFromString(m,"text/xml"),x=h.getElementsByTagName("tt")[0];if(!x)throw new Error("Invalid ttml");var S={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},C=Object.keys(S).reduce(function(k,N){return k[N]=x.getAttribute("ttp:"+N)||S[N],k},{}),O=x.getAttribute("xml:space")!=="preserve",P=r(u(x,"styling","style")),w=r(u(x,"layout","region")),U=u(x,"body","[begin]");return[].map.call(U,function(k){var N=o(k,O);if(!N||!k.hasAttribute("begin"))return null;var B=l(k.getAttribute("begin"),C),K=l(k.getAttribute("dur"),C),H=l(k.getAttribute("end"),C);if(B===null)throw d(k);if(H===null){if(K===null)throw d(k);H=B+K}var F=new c.default(B-p,H-p,N);F.id=Object(L.generateCueId)(F.startTime,F.endTime,F.text);var W=w[k.getAttribute("region")],Y=P[k.getAttribute("style")];F.position=10,F.size=80;var $=n(W,Y),J=$.textAlign;if(J){var q=D[J];q&&(F.lineAlign=q),F.align=J}return _(F,$),F}).filter(function(k){return k!==null})}function u(m,p,v){var h=m.getElementsByTagName(p)[0];return h?[].slice.call(h.querySelectorAll(v)):[]}function r(m){return m.reduce(function(p,v){var h=v.getAttribute("xml:id");return h&&(p[h]=v),p},{})}function o(m,p){return[].slice.call(m.childNodes).reduce(function(v,h,x){var S;return h.nodeName==="br"&&x?v+`
20
+ `:(S=h.childNodes)!==null&&S!==void 0&&S.length?o(h,p):p?v+h.textContent.trim().replace(/\s+/g," "):v+h.textContent},"")}function n(m,p){var v="http://www.w3.org/ns/ttml#styling",h=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return h.reduce(function(x,S){var C=s(p,v,S)||s(m,v,S);return C&&(x[S]=C),x},{})}function s(m,p,v){return m.hasAttributeNS(p,v)?m.getAttributeNS(p,v):null}function d(m){return new Error("Could not parse ttml timestamp "+m)}function l(m,p){if(!m)return null;var v=Object(i.parseTimeStamp)(m);return v===null&&(I.test(m)?v=T(m,p):M.test(m)&&(v=g(m,p))),v}function T(m,p){var v=I.exec(m),h=(v[4]|0)+(v[5]|0)/p.subFrameRate;return(v[1]|0)*3600+(v[2]|0)*60+(v[3]|0)+h/p.frameRate}function g(m,p){var v=M.exec(m),h=Number(v[1]),x=v[2];switch(x){case"h":return h*3600;case"m":return h*60;case"ms":return h*1e3;case"f":return h/p.frameRate;case"t":return h/p.tickRate}return h}},"./src/utils/logger.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"enableLogs",function(){return L}),t.d(e,"logger",function(){return _});var a=function(){},i={trace:a,debug:a,log:a,warn:a,info:a,error:a},c=i;function R(y){var I=self.console[y];return I?I.bind(self.console,"["+y+"] >"):a}function E(y){for(var I=arguments.length,M=new Array(I>1?I-1:0),D=1;D<I;D++)M[D-1]=arguments[D];M.forEach(function(b){c[b]=y[b]?y[b].bind(y):R(b)})}function L(y){if(self.console&&y===!0||typeof y=="object"){E(y,"debug","log","info","warn","error");try{c.log()}catch{c=i}}else c=i}var _=c},"./src/utils/mediakeys-helper.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"KeySystems",function(){return a}),t.d(e,"requestMediaKeySystemAccess",function(){return i});var a;(function(c){c.WIDEVINE="com.widevine.alpha",c.PLAYREADY="com.microsoft.playready"})(a||(a={}));var i=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"getMediaSource",function(){return a});function a(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"bin2str",function(){return E}),t.d(e,"readUint16",function(){return L}),t.d(e,"readUint32",function(){return _}),t.d(e,"writeUint32",function(){return y}),t.d(e,"findBox",function(){return I}),t.d(e,"parseSegmentIndex",function(){return M}),t.d(e,"parseInitSegment",function(){return D}),t.d(e,"getStartDTS",function(){return b}),t.d(e,"getDuration",function(){return A}),t.d(e,"computeRawDurationFromSamples",function(){return u}),t.d(e,"offsetStartDTS",function(){return r}),t.d(e,"segmentValidRange",function(){return o}),t.d(e,"appendUint8Array",function(){return n});var a=t("./src/utils/typed-array.ts"),i=t("./src/loader/fragment.ts"),c=Math.pow(2,32)-1,R=[].push;function E(s){return String.fromCharCode.apply(null,s)}function L(s,d){"data"in s&&(d+=s.start,s=s.data);var l=s[d]<<8|s[d+1];return l<0?65536+l:l}function _(s,d){"data"in s&&(d+=s.start,s=s.data);var l=s[d]<<24|s[d+1]<<16|s[d+2]<<8|s[d+3];return l<0?4294967296+l:l}function y(s,d,l){"data"in s&&(d+=s.start,s=s.data),s[d]=l>>24,s[d+1]=l>>16&255,s[d+2]=l>>8&255,s[d+3]=l&255}function I(s,d){var l=[];if(!d.length)return l;var T,g,m;"data"in s?(T=s.data,g=s.start,m=s.end):(T=s,g=0,m=T.byteLength);for(var p=g;p<m;){var v=_(T,p),h=E(T.subarray(p+4,p+8)),x=v>1?p+v:m;if(h===d[0])if(d.length===1)l.push({data:T,start:p+8,end:x});else{var S=I({data:T,start:p+8,end:x},d.slice(1));S.length&&R.apply(l,S)}p=x}return l}function M(s){var d=I(s,["moov"]),l=d[0],T=l?l.end:null,g=I(s,["sidx"]);if(!g||!g[0])return null;var m=[],p=g[0],v=p.data[0],h=v===0?8:16,x=_(p,h);h+=4;var S=0,C=0;v===0?h+=8:h+=16,h+=2;var O=p.end+C,P=L(p,h);h+=2;for(var w=0;w<P;w++){var U=h,k=_(p,U);U+=4;var N=k&2147483647,B=(k&2147483648)>>>31;if(B===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var K=_(p,U);U+=4,m.push({referenceSize:N,subsegmentDuration:K,info:{duration:K/x,start:O,end:O+N-1}}),O+=N,U+=4,h=U}return{earliestPresentationTime:S,timescale:x,version:v,referencesCount:P,references:m,moovEndOffset:T}}function D(s){for(var d=[],l=I(s,["moov","trak"]),T=0;T<l.length;T++){var g=l[T],m=I(g,["tkhd"])[0];if(m){var p=m.data[m.start],v=p===0?12:20,h=_(m,v),x=I(g,["mdia","mdhd"])[0];if(x){p=x.data[x.start],v=p===0?12:20;var S=_(x,v),C=I(g,["mdia","hdlr"])[0];if(C){var O=E(C.data.subarray(C.start+8,C.start+12)),P={soun:i.ElementaryStreamTypes.AUDIO,vide:i.ElementaryStreamTypes.VIDEO}[O];if(P){var w=I(g,["mdia","minf","stbl","stsd"])[0],U=void 0;w&&(U=E(w.data.subarray(w.start+12,w.start+16))),d[h]={timescale:S,type:P},d[P]={timescale:S,id:h,codec:U}}}}}}var k=I(s,["moov","mvex","trex"]);return k.forEach(function(N){var B=_(N,4),K=d[B];K&&(K.default={duration:_(N,12),flags:_(N,20)})}),d}function b(s,d){return I(d,["moof","traf"]).reduce(function(l,T){var g=I(T,["tfdt"])[0],m=g.data[g.start],p=I(T,["tfhd"]).reduce(function(v,h){var x=_(h,4),S=s[x];if(S){var C=_(g,4);m===1&&(C*=Math.pow(2,32),C+=_(g,8));var O=S.timescale||9e4,P=C/O;if(isFinite(P)&&(v===null||P<v))return P}return v},null);return p!==null&&isFinite(p)&&(l===null||p<l)?p:l},null)||0}function A(s,d){for(var l=0,T=0,g=0,m=I(s,["moof","traf"]),p=0;p<m.length;p++){var v=m[p],h=I(v,["tfhd"])[0],x=_(h,4),S=d[x];if(!!S){var C=S.default,O=_(h,0)|(C==null?void 0:C.flags),P=C==null?void 0:C.duration;O&8&&(O&2?P=_(h,12):P=_(h,8));for(var w=S.timescale||9e4,U=I(v,["trun"]),k=0;k<U.length;k++){if(l=u(U[k]),!l&&P){var N=_(U[k],4);l=P*N}S.type===i.ElementaryStreamTypes.VIDEO?T+=l/w:S.type===i.ElementaryStreamTypes.AUDIO&&(g+=l/w)}}}if(T===0&&g===0){var B=M(s);if(B!=null&&B.references)return B.references.reduce(function(K,H){return K+H.info.duration||0},0)}return T||g}function u(s){var d=_(s,0),l=8;d&1&&(l+=4),d&4&&(l+=4);for(var T=0,g=_(s,4),m=0;m<g;m++){if(d&256){var p=_(s,l);T+=p,l+=4}d&512&&(l+=4),d&1024&&(l+=4),d&2048&&(l+=4)}return T}function r(s,d,l){I(d,["moof","traf"]).forEach(function(T){I(T,["tfhd"]).forEach(function(g){var m=_(g,4),p=s[m];if(!!p){var v=p.timescale||9e4;I(T,["tfdt"]).forEach(function(h){var x=h.data[h.start],S=_(h,4);if(x===0)y(h,4,S-l*v);else{S*=Math.pow(2,32),S+=_(h,8),S-=l*v,S=Math.max(S,0);var C=Math.floor(S/(c+1)),O=Math.floor(S%(c+1));y(h,4,C),y(h,8,O)}})}})})}function o(s){var d={valid:null,remainder:null},l=I(s,["moof"]);if(l){if(l.length<2)return d.remainder=s,d}else return d;var T=l[l.length-1];return d.valid=Object(a.sliceUint8)(s,0,T.start-8),d.remainder=Object(a.sliceUint8)(s,T.start-8),d}function n(s,d){var l=new Uint8Array(s.length+d.length);return l.set(s),l.set(d,s.length),l}},"./src/utils/output-filter.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"default",function(){return a});var a=function(){function i(R,E){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=R,this.trackName=E}var c=i.prototype;return c.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},c.newCue=function(E,L,_){(this.startTime===null||this.startTime>E)&&(this.startTime=E),this.endTime=L,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},c.reset=function(){this.cueRanges=[],this.startTime=null},i}()},"./src/utils/texttrack-utils.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"sendAddTrackEvent",function(){return i}),t.d(e,"addCueToTrack",function(){return c}),t.d(e,"clearCurrentCues",function(){return R}),t.d(e,"removeCuesInRange",function(){return E}),t.d(e,"getCuesInRange",function(){return _});var a=t("./src/utils/logger.ts");function i(y,I){var M;try{M=new Event("addtrack")}catch{M=document.createEvent("Event"),M.initEvent("addtrack",!1,!1)}M.track=y,I.dispatchEvent(M)}function c(y,I){var M=y.mode;if(M==="disabled"&&(y.mode="hidden"),y.cues&&!y.cues.getCueById(I.id))try{if(y.addCue(I),!y.cues.getCueById(I.id))throw new Error("addCue is failed for: "+I)}catch(b){a.logger.debug("[texttrack-utils]: "+b);var D=new self.TextTrackCue(I.startTime,I.endTime,I.text);D.id=I.id,y.addCue(D)}M==="disabled"&&(y.mode=M)}function R(y){var I=y.mode;if(I==="disabled"&&(y.mode="hidden"),y.cues)for(var M=y.cues.length;M--;)y.removeCue(y.cues[M]);I==="disabled"&&(y.mode=I)}function E(y,I,M){var D=y.mode;if(D==="disabled"&&(y.mode="hidden"),y.cues&&y.cues.length>0)for(var b=_(y.cues,I,M),A=0;A<b.length;A++)y.removeCue(b[A]);D==="disabled"&&(y.mode=D)}function L(y,I){if(I<y[0].startTime)return 0;var M=y.length-1;if(I>y[M].endTime)return-1;for(var D=0,b=M;D<=b;){var A=Math.floor((b+D)/2);if(I<y[A].startTime)b=A-1;else if(I>y[A].startTime&&D<M)D=A+1;else return A}return y[D].startTime-I<I-y[b].startTime?D:b}function _(y,I,M){var D=[],b=L(y,I);if(b>-1)for(var A=b,u=y.length;A<u;A++){var r=y[A];if(r.startTime>=I&&r.endTime<=M)D.push(r);else if(r.startTime>M)return D}return D}},"./src/utils/time-ranges.ts":function(f,e,t){"use strict";t.r(e);var a={toString:function(c){for(var R="",E=c.length,L=0;L<E;L++)R+="["+c.start(L).toFixed(3)+","+c.end(L).toFixed(3)+"]";return R}};e.default=a},"./src/utils/timescale-conversion.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"toTimescaleFromBase",function(){return i}),t.d(e,"toTimescaleFromScale",function(){return c}),t.d(e,"toMsFromMpegTsClock",function(){return R}),t.d(e,"toMpegTsClockFromTimescale",function(){return E});var a=9e4;function i(L,_,y,I){y===void 0&&(y=1),I===void 0&&(I=!1);var M=L*_*y;return I?Math.round(M):M}function c(L,_,y,I){return y===void 0&&(y=1),I===void 0&&(I=!1),i(L,_,1/y,I)}function R(L,_){return _===void 0&&(_=!1),i(L,1e3,1/a,_)}function E(L,_){return _===void 0&&(_=1),i(L,a,1/_)}},"./src/utils/typed-array.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"sliceUint8",function(){return a});function a(i,c,R){return Uint8Array.prototype.slice?i.slice(c,R):new Uint8Array(Array.prototype.slice.call(i,c,R))}},"./src/utils/vttcue.ts":function(f,e,t){"use strict";t.r(e),e.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var a=["","lr","rl"],i=["start","middle","end","left","right"];function c(y,I){if(typeof I!="string"||!Array.isArray(y))return!1;var M=I.toLowerCase();return~y.indexOf(M)?M:!1}function R(y){return c(a,y)}function E(y){return c(i,y)}function L(y){for(var I=arguments.length,M=new Array(I>1?I-1:0),D=1;D<I;D++)M[D-1]=arguments[D];for(var b=1;b<arguments.length;b++){var A=arguments[b];for(var u in A)y[u]=A[u]}return y}function _(y,I,M){var D=this,b={enumerable:!0};D.hasBeenReset=!1;var A="",u=!1,r=y,o=I,n=M,s=null,d="",l=!0,T="auto",g="start",m=50,p="middle",v=50,h="middle";Object.defineProperty(D,"id",L({},b,{get:function(){return A},set:function(S){A=""+S}})),Object.defineProperty(D,"pauseOnExit",L({},b,{get:function(){return u},set:function(S){u=!!S}})),Object.defineProperty(D,"startTime",L({},b,{get:function(){return r},set:function(S){if(typeof S!="number")throw new TypeError("Start time must be set to a number.");r=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"endTime",L({},b,{get:function(){return o},set:function(S){if(typeof S!="number")throw new TypeError("End time must be set to a number.");o=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"text",L({},b,{get:function(){return n},set:function(S){n=""+S,this.hasBeenReset=!0}})),Object.defineProperty(D,"region",L({},b,{get:function(){return s},set:function(S){s=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"vertical",L({},b,{get:function(){return d},set:function(S){var C=R(S);if(C===!1)throw new SyntaxError("An invalid or illegal string was specified.");d=C,this.hasBeenReset=!0}})),Object.defineProperty(D,"snapToLines",L({},b,{get:function(){return l},set:function(S){l=!!S,this.hasBeenReset=!0}})),Object.defineProperty(D,"line",L({},b,{get:function(){return T},set:function(S){if(typeof S!="number"&&S!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");T=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"lineAlign",L({},b,{get:function(){return g},set:function(S){var C=E(S);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");g=C,this.hasBeenReset=!0}})),Object.defineProperty(D,"position",L({},b,{get:function(){return m},set:function(S){if(S<0||S>100)throw new Error("Position must be between 0 and 100.");m=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"positionAlign",L({},b,{get:function(){return p},set:function(S){var C=E(S);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");p=C,this.hasBeenReset=!0}})),Object.defineProperty(D,"size",L({},b,{get:function(){return v},set:function(S){if(S<0||S>100)throw new Error("Size must be between 0 and 100.");v=S,this.hasBeenReset=!0}})),Object.defineProperty(D,"align",L({},b,{get:function(){return h},set:function(S){var C=E(S);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");h=C,this.hasBeenReset=!0}})),D.displayState=void 0}return _.prototype.getCueAsHTML=function(){var y=self.WebVTT;return y.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"parseTimeStamp",function(){return c}),t.d(e,"fixLineBreaks",function(){return I}),t.d(e,"VTTParser",function(){return M});var a=t("./src/utils/vttcue.ts"),i=function(){function D(){}var b=D.prototype;return b.decode=function(u,r){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},D}();function c(D){function b(u,r,o,n){return(u|0)*3600+(r|0)*60+(o|0)+parseFloat(n||0)}var A=D.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return A?parseFloat(A[2])>59?b(A[2],A[3],0,A[4]):b(A[1],A[2],A[3],A[4]):null}var R=function(){function D(){this.values=Object.create(null)}var b=D.prototype;return b.set=function(u,r){!this.get(u)&&r!==""&&(this.values[u]=r)},b.get=function(u,r,o){return o?this.has(u)?this.values[u]:r[o]:this.has(u)?this.values[u]:r},b.has=function(u){return u in this.values},b.alt=function(u,r,o){for(var n=0;n<o.length;++n)if(r===o[n]){this.set(u,r);break}},b.integer=function(u,r){/^-?\d+$/.test(r)&&this.set(u,parseInt(r,10))},b.percent=function(u,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var o=parseFloat(r);if(o>=0&&o<=100)return this.set(u,o),!0}return!1},D}();function E(D,b,A,u){var r=u?D.split(u):[D];for(var o in r)if(typeof r[o]=="string"){var n=r[o].split(A);if(n.length===2){var s=n[0],d=n[1];b(s,d)}}}var L=new a.default(0,0,""),_=L.align==="middle"?"middle":"center";function y(D,b,A){var u=D;function r(){var s=c(D);if(s===null)throw new Error("Malformed timestamp: "+u);return D=D.replace(/^[^\sa-zA-Z-]+/,""),s}function o(s,d){var l=new R;E(s,function(m,p){var v;switch(m){case"region":for(var h=A.length-1;h>=0;h--)if(A[h].id===p){l.set(m,A[h].region);break}break;case"vertical":l.alt(m,p,["rl","lr"]);break;case"line":v=p.split(","),l.integer(m,v[0]),l.percent(m,v[0])&&l.set("snapToLines",!1),l.alt(m,v[0],["auto"]),v.length===2&&l.alt("lineAlign",v[1],["start",_,"end"]);break;case"position":v=p.split(","),l.percent(m,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":l.percent(m,p);break;case"align":l.alt(m,p,["start",_,"end","left","right"]);break}},/:/,/\s/),d.region=l.get("region",null),d.vertical=l.get("vertical","");var T=l.get("line","auto");T==="auto"&&L.line===-1&&(T=-1),d.line=T,d.lineAlign=l.get("lineAlign","start"),d.snapToLines=l.get("snapToLines",!0),d.size=l.get("size",100),d.align=l.get("align",_);var g=l.get("position","auto");g==="auto"&&L.position===50&&(g=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=g}function n(){D=D.replace(/^\s+/,"")}if(n(),b.startTime=r(),n(),D.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);D=D.substr(3),n(),b.endTime=r(),n(),o(D,b)}function I(D){return D.replace(/<br(?: \/)?>/gi,`
21
+ `)}var M=function(){function D(){this.state="INITIAL",this.buffer="",this.decoder=new i,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var b=D.prototype;return b.parse=function(u){var r=this;u&&(r.buffer+=r.decoder.decode(u,{stream:!0}));function o(){var g=r.buffer,m=0;for(g=I(g);m<g.length&&g[m]!=="\r"&&g[m]!==`
22
+ `;)++m;var p=g.substr(0,m);return g[m]==="\r"&&++m,g[m]===`
23
+ `&&++m,r.buffer=g.substr(m),p}function n(g){E(g,function(m,p){},/:/)}try{var s="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer))return this;s=o();var d=s.match(/^()?WEBVTT([ \t].*)?$/);if(!d||!d[0])throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var l=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;switch(l?l=!1:s=o(),r.state){case"HEADER":/:/.test(s)?n(s):s||(r.state="ID");continue;case"NOTE":s||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(s)){r.state="NOTE";break}if(!s)continue;if(r.cue=new a.default(0,0,""),r.state="CUE",s.indexOf("-->")===-1){r.cue.id=s;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{y(s,r.cue,r.regionList)}catch{r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":{var T=s.indexOf("-->")!==-1;if(!s||T&&(l=!0)){r.oncue&&r.cue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}if(r.cue===null)continue;r.cue.text&&(r.cue.text+=`
24
+ `),r.cue.text+=s}continue;case"BADCUE":s||(r.state="ID")}}}catch{r.state==="CUETEXT"&&r.cue&&r.oncue&&r.oncue(r.cue),r.cue=null,r.state=r.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},b.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
25
+
26
+ `,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(r){u.onparsingerror&&u.onparsingerror(r)}return u.onflush&&u.onflush(),this},D}()},"./src/utils/webvtt-parser.ts":function(f,e,t){"use strict";t.r(e),t.d(e,"generateCueId",function(){return M}),t.d(e,"parseWebVTT",function(){return b});var a=t("./src/polyfills/number.ts"),i=t("./src/utils/vttparser.ts"),c=t("./src/demux/id3.ts"),R=t("./src/utils/timescale-conversion.ts"),E=t("./src/remux/mp4-remuxer.ts"),L=/\r\n|\n\r|\n|\r/g,_=function(u,r,o){return o===void 0&&(o=0),u.substr(o,r.length)===r},y=function(u){var r=parseInt(u.substr(-3)),o=parseInt(u.substr(-6,2)),n=parseInt(u.substr(-9,2)),s=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object(a.isFiniteNumber)(r)||!Object(a.isFiniteNumber)(o)||!Object(a.isFiniteNumber)(n)||!Object(a.isFiniteNumber)(s))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return r+=1e3*o,r+=60*1e3*n,r+=60*60*1e3*s,r},I=function(u){for(var r=5381,o=u.length;o;)r=r*33^u.charCodeAt(--o);return(r>>>0).toString()};function M(A,u,r){return I(A.toString())+I(u.toString())+I(r)}var D=function(u,r,o){var n=u[r],s=u[n.prevCC];if(!s||!s.new&&n.new){u.ccOffset=u.presentationOffset=n.start,n.new=!1;return}for(;(d=s)!==null&&d!==void 0&&d.new;){var d;u.ccOffset+=n.start-s.start,n.new=!1,n=s,s=u[n.prevCC]}u.presentationOffset=o};function b(A,u,r,o,n,s,d,l){var T=new i.VTTParser,g=Object(c.utf8ArrayToStr)(new Uint8Array(A)).trim().replace(L,`
27
27
  `).split(`
28
- `),m=[],g=Object(R.toMpegTsClockFromTimescale)(u,r),f="00:00.000",c=0,x=0,S,O=!0,C=!1;y.oncue=function(P){var w=s[i],U=s.ccOffset,k=(c-g)/9e4;if(w!=null&&w.new&&(x!==void 0?U=s.ccOffset=w.start:D(s,i,k)),k&&(U=k-s.presentationOffset),C){var N=P.endTime-P.startTime,B=Object(T.normalizePts)((P.startTime+U-x)*9e4,a*9e4)/9e4;P.startTime=B,P.endTime=B+N}var K=P.text.trim();P.text=decodeURIComponent(encodeURIComponent(K)),P.id||(P.id=M(P.startTime,P.endTime,K)),P.endTime>0&&m.push(P)},y.onparsingerror=function(P){S=P},y.onflush=function(){if(S){o(S);return}d(m)},p.forEach(function(P){if(O)if(_(P,"X-TIMESTAMP-MAP=")){O=!1,C=!0,P.substr(16).split(",").forEach(function(w){_(w,"LOCAL:")?f=w.substr(6):_(w,"MPEGTS:")&&(c=parseInt(w.substr(7)))});try{x=E(f)/1e3}catch(w){C=!1,S=w}return}else P===""&&(O=!1);y.parse(P+`
29
- `)}),y.flush()}},"./src/utils/xhr-loader.ts":function(v,e,t){"use strict";t.r(e);var l=t("./src/utils/logger.ts"),n=t("./src/loader/load-stats.ts"),h=/^age:\s*[\d.]+\s*$/m,R=function(){function T(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var L=T.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var E=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),E&&(E.onreadystatechange=null,E.onprogress=null,E.readyState!==4&&(this.stats.aborted=!0,E.abort()))},L.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(E,I,M){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=E,this.config=I,this.callbacks=M,this.retryDelay=I.retryDelay,this.loadInternal()},L.loadInternal=function(){var E=this.config,I=this.context;if(!!E){var M=this.loader=new self.XMLHttpRequest,D=this.stats;D.loading.first=0,D.loaded=0;var b=this.xhrSetup;try{if(b)try{b(M,I.url)}catch{M.open("GET",I.url,!0),b(M,I.url)}M.readyState||M.open("GET",I.url,!0);var A=this.context.headers;if(A)for(var u in A)M.setRequestHeader(u,A[u])}catch(r){this.callbacks.onError({code:M.status,text:r.message},I,M);return}I.rangeEnd&&M.setRequestHeader("Range","bytes="+I.rangeStart+"-"+(I.rangeEnd-1)),M.onreadystatechange=this.readystatechange.bind(this),M.onprogress=this.loadprogress.bind(this),M.responseType=I.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout),M.send()}},L.readystatechange=function(){var E=this.context,I=this.loader,M=this.stats;if(!(!E||!I)){var D=I.readyState,b=this.config;if(!M.aborted&&D>=2)if(self.clearTimeout(this.requestTimeout),M.loading.first===0&&(M.loading.first=Math.max(self.performance.now(),M.loading.start)),D===4){I.onreadystatechange=null,I.onprogress=null;var A=I.status;if(A>=200&&A<300){M.loading.end=Math.max(self.performance.now(),M.loading.first);var u,r;if(E.responseType==="arraybuffer"?(u=I.response,r=u.byteLength):(u=I.responseText,r=u.length),M.loaded=M.total=r,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(M,E,u,I),!this.callbacks)return;var i={url:I.responseURL,data:u};this.callbacks.onSuccess(i,M,E,I)}else M.retry>=b.maxRetry||A>=400&&A<499?(l.logger.error(A+" while loading "+E.url),this.callbacks.onError({code:A,text:I.statusText},E,I)):(l.logger.warn(A+" while loading "+E.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,b.maxRetryDelay),M.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout)}},L.loadtimeout=function(){l.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(E){var I=this.stats;I.loaded=E.loaded,E.lengthComputable&&(I.total=E.total)},L.getCacheAge=function(){var E=null;if(this.loader&&h.test(this.loader.getAllResponseHeaders())){var I=this.loader.getResponseHeader("age");E=I?parseFloat(I):null}return E},T}();e.default=R}}).default})});var oi=mr(nn()),ct=mr(pr()),li=mr(pr()),Ct=mr(pr()),an=(v,e,t)=>{if(!e.has(v))throw TypeError("Cannot "+t)},vo=(v,e,t)=>(an(v,e,"read from private field"),t?t.call(v):e.get(v)),mo=(v,e,t)=>{if(e.has(v))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(v):e.set(v,t)},go=(v,e,t,l)=>(an(v,e,"write to private field"),l?l.call(v,t):e.set(v,t),t);if(typeof DocumentFragment=="undefined"){class v{}globalThis.DocumentFragment=v}globalThis.customElements||(globalThis.customElements={get(v){},define(v,e,t){},upgrade(v){},whenDefined(v){return Promise.resolve(globalThis.HTMLElement)}});var Er;if(!globalThis.CustomEvent){class v{constructor(t,l={}){mo(this,Er,void 0),go(this,Er,l==null?void 0:l.detail)}get detail(){vo(this,Er)}initCustomEvent(t,l,n,h){}}Er=new WeakMap,globalThis.CustomEvent=v}if(!globalThis.EventTarget){class v{addEventListener(){}removeEventListener(){}dispatchEvent(t){return!0}}globalThis.EventTarget=v}if(!globalThis.HTMLElement){class v extends EventTarget{}globalThis.HTMLElement=v}if(!globalThis.HTMLVideoElement){class v extends EventTarget{}globalThis.HTMLVideoElement=v}var sn,on;if(!((sn=globalThis.document)==null?void 0:sn.createElement)){let v=(on=globalThis.document)!=null?on:{};v.createElement=function(e,t){return new HTMLElement},globalThis.document=v}var ui={ANY:"any",MUTED:"muted"},po=Object.values(ui),ln=v=>typeof v=="boolean"||typeof v=="string"&&po.includes(v),un=(v,e,t)=>{let l=!1,n=!1,h=ln(e)?e:!!e,R=()=>{v.addEventListener("playing",()=>{l=!0},{once:!0})};if(R(),v.addEventListener("loadstart",()=>{l=!1,R(),di(v,h)},{once:!0}),v.addEventListener("loadedmetadata",()=>{t||(n=!Number.isFinite(v.duration)),di(v,h)},{once:!0}),t&&t.once(li.default.Events.LEVEL_LOADED,(T,L)=>{var _;n=(_=L.details.live)!=null?_:!1}),!h){let T=()=>{!n||((t==null?void 0:t.liveSyncPosition)?v.currentTime=t.liveSyncPosition:Number.isFinite(v.seekable.end(0))&&(v.currentTime=v.seekable.end(0)))};v.addEventListener("play",()=>{t&&v.preload==="metadata"?t.once(li.default.Events.LEVEL_UPDATED,T):t&&T()},{once:!0})}return T=>{l||(h=ln(T)?T:!!T,di(v,h))}},di=(v,e)=>{if(!e)return;let t=v.muted,l=()=>v.muted=t;switch(e){case ui.ANY:v.play().catch(n=>{v.muted=!0,v.play().catch(l)});break;case ui.MUTED:v.muted=!0,v.play().catch(l);break;default:v.play().catch(()=>{});break}},Yt=class extends Error{constructor(v,e=Yt.MEDIA_ERR_CUSTOM,t){super(v);var l;this.name="MediaError",this.code=e,this.fatal=t!=null?t:e>=Yt.MEDIA_ERR_NETWORK&&e<=Yt.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(l=Yt.defaultMessages[this.code])!=null?l:"")}},Oe=Yt;Oe.MEDIA_ERR_ABORTED=1,Oe.MEDIA_ERR_NETWORK=2,Oe.MEDIA_ERR_DECODE=3,Oe.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Oe.MEDIA_ERR_ENCRYPTED=5,Oe.MEDIA_ERR_CUSTOM=100,Oe.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."};function Eo(v,e){e.on(Ct.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(n,{tracks:h})=>{h.forEach(R=>{var T;let L=(T=R.subtitleTrack)!=null?T:R.closedCaptions,_=e.subtitleTracks.findIndex(({lang:E,name:I,type:M})=>E==(L==null?void 0:L.lang)&&I===R.label&&M.toLowerCase()===R.kind);yo(v,R.kind,R.label,L==null?void 0:L.lang,`${R.kind}${_}`)})});let t=()=>{var n;if(!e.subtitleTracks.length)return;let h=Array.from(v.textTracks).find(T=>T.id&&T.mode==="showing"&&["subtitles","captions"].includes(T.kind)),R=`${(n=e.subtitleTracks[e.subtitleTrack])==null?void 0:n.type.toLowerCase()}${e.subtitleTrack}`;if(h&&(e.subtitleTrack<0||(h==null?void 0:h.id)!==R)){let T=e.subtitleTracks.findIndex(({lang:L,name:_,type:E})=>L==h.language&&_===h.label&&E.toLowerCase()===h.kind);e.subtitleTrack=T}h&&(h==null?void 0:h.id)===R&&h.cues&&Array.from(h.cues).forEach(T=>{h.addCue(T)})};v.textTracks.addEventListener("change",t),e.on(Ct.default.Events.CUES_PARSED,(n,{track:h,type:R,cues:T})=>{let L=v.textTracks.getTrackById(h);if(!L)return;let _=L.mode==="disabled";_&&(L.mode="hidden"),T.forEach(E=>{var I;((I=L.cues)==null?void 0:I.getCueById(E.id))||L.addCue(E)}),_&&(L.mode="disabled")}),e.on(Ct.default.Events.DESTROYING,()=>{v.textTracks.removeEventListener("change",t),v.querySelectorAll("track").forEach(n=>{!(n.id&&["subtitles","captions"].includes(n.kind))||!e.subtitleTracks.some(({type:h},R)=>n.id===`${h.toLowerCase()}${R}`)||v.removeChild(n)})});let l=()=>{Array.from(v.textTracks).forEach(n=>{var h,R;if(!["subtitles","caption"].includes(n.kind)&&n.label==="thumbnails"){if(!((h=n.cues)==null?void 0:h.length)){let T=v.querySelector('track[label="thumbnails"]'),L=(R=T==null?void 0:T.getAttribute("src"))!=null?R:"";T==null||T.removeAttribute("src"),setTimeout(()=>{T==null||T.setAttribute("src",L)},0)}n.mode!=="hidden"&&(n.mode="hidden")}})};e.once(Ct.default.Events.MANIFEST_LOADED,l),e.once(Ct.default.Events.MEDIA_ATTACHED,l)}function yo(v,e,t,l,n){let h=document.createElement("track");return h.kind=e,h.label=t,l&&(h.srclang=l),n&&(h.id=n),h.track.mode="disabled",v.appendChild(h),h.track}var dn=(v,e)=>v in e,cn="mux.com",fn=()=>oi.default.utils.now(),ve={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Pt={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},ci={HLS:Pt.M3U8},Qu=Object.keys(ci),Ju=[...Object.values(Pt),"hls","HLS"],To=v=>{let e=v.indexOf("?");if(e<0)return[v];let t=v.slice(0,e),l=v.slice(e);return[t,l]},hn=(v,{domain:e=cn}={})=>{if(!v)return;let[t,l=""]=To(v);return`https://stream.${e}/${t}.m3u8${l}`},bo=v=>{let e="";try{e=new URL(v).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let l=e.slice(t+1).toUpperCase();return dn(l,Pt)?Pt[l]:""},vn=v=>{let e=v.type;if(e){let l=e.toUpperCase();return dn(l,ci)?ci[l]:e}let{src:t}=v;return t?bo(t):""},Ao=v=>{if([ve.LIVE,ve.LL_LIVE].includes(v)){let e={backBufferLength:12};return v===ve.LL_LIVE?{...e,maxFragLookUpTolerance:.001}:e}return{}},yr=new WeakMap,mn=v=>{var e;return(e=yr.get(v))==null?void 0:e.error},fi=(v,e)=>{e&&(e.detachMedia(),e.destroy()),(v==null?void 0:v.mux)&&!v.mux.deleted&&(v.mux.destroy(),v.mux),v&&(v.removeEventListener("error",gn),v.removeEventListener("error",hi),yr.delete(v))},So=(v,e)=>{var t,l,n;let{debug:h,preferMse:R,streamType:T,startTime:L=-1}=v,_=vn(v),E=_===Pt.M3U8,I=!_||((t=e==null?void 0:e.canPlayType(_))!=null?t:!0),M=ct.default.isSupported(),D=((n=(l=window==null?void 0:window.navigator)==null?void 0:l.userAgent)!=null?n:"").toLowerCase().indexOf("android")!==-1&&T===ve.LL_LIVE;if(E&&!(!E||I&&!((R||D)&&M))&&M){let b={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},A=Ao(T);return new ct.default({debug:h,startPosition:L,...b,...A})}},_o=({playbackId:v,src:e,customDomain:t})=>{if(v)return!0;if(typeof e!="string")return!1;let l=new URL(e).hostname.toLocaleLowerCase();return l.includes(cn)||!!t&&l.includes(t.toLocaleLowerCase())},xo=(v,e,t)=>{let{envKey:l}=v,n=_o(v);if((l||n)&&e){let{playerInitTime:h,playerSoftwareName:R,playerSoftwareVersion:T,beaconCollectionDomain:L,metadata:_,debug:E}=v,I=M=>typeof M.player_error_code=="string"?!1:typeof v.errorTranslator=="function"?v.errorTranslator(M):M;oi.default.monitor(e,{debug:E,beaconCollectionDomain:L,hlsjs:t,Hls:t?ct.default:void 0,automaticErrorTracking:!1,errorTranslator:I,data:{...l?{env_key:l}:{},player_software_name:R,player_software_version:T,player_init_time:h,..._}})}},Lo=(v,e,t)=>{var l,n,h;if(!e){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:R,streamType:T}=v,L=vn(v),_=L===Pt.M3U8,E=!L||((l=e==null?void 0:e.canPlayType(L))!=null?l:!0),I=ct.default.isSupported(),M=((h=(n=window==null?void 0:window.navigator)==null?void 0:n.userAgent)!=null?h:"").toLowerCase().indexOf("android")!==-1&&T===ve.LL_LIVE,D=!_||E&&!((R||M)&&I),{src:b}=v;if(e&&E&&D){if(typeof b=="string"){let{startTime:A}=v;if(e.setAttribute("src",b),A){let u=({target:r})=>{r.currentTime=A,r.removeEventListener("loadedmetadata",u)};e.addEventListener("loadedmetadata",u)}}else e.removeAttribute("src");e.addEventListener("error",gn),e.addEventListener("error",hi)}else if(t&&b){switch(t.on(ct.default.Events.ERROR,(A,u)=>{let r={[ct.default.ErrorTypes.NETWORK_ERROR]:Oe.MEDIA_ERR_NETWORK,[ct.default.ErrorTypes.MEDIA_ERROR]:Oe.MEDIA_ERR_DECODE},s=new Oe("",r[u.type]);s.fatal=u.fatal,s.data=u,e.dispatchEvent(new CustomEvent("error",{detail:s}))}),e.addEventListener("error",hi),Eo(e,t),e.preload){case"none":e.addEventListener("play",()=>t.loadSource(b),{once:!0});break;case"metadata":let A=t.config.maxBufferLength,u=t.config.maxBufferSize;t.config.maxBufferLength=1,t.config.maxBufferSize=1,e.addEventListener("play",()=>{t.config.maxBufferLength=A,t.config.maxBufferSize=u},{once:!0}),t.loadSource(b);break;default:t.loadSource(b)}t.attachMedia(e)}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.")};async function gn(v){if(!v.isTrusted)return;v.stopImmediatePropagation();let e=v.target;if(!(e==null?void 0:e.error))return;let{message:t,code:l}=e.error,n=new Oe(t,l);if(e.src&&(l!==Oe.MEDIA_ERR_DECODE||l!==void 0)){let{status:h}=await fetch(e.src);n.data={response:{code:h}}}e.dispatchEvent(new CustomEvent("error",{detail:n}))}function hi(v){var e;if(!(v instanceof CustomEvent)||!(v.detail instanceof Oe))return;let t=v.target,l=v.detail;if(!l||!l.fatal)return;let n=yr.get(t);n&&(n.error=l),(e=t.mux)==null||e.emit("error",{player_error_code:l.code,player_error_message:l.message})}var pn=(v,e,t)=>{fi(e,t),yr.set(e,{});let l=So(v,e);return xo(v,e,l),Lo(v,e,l),l};var se={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_CAPTIONS_REQUEST:"mediashowcaptionsrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_CAPTIONS_REQUEST:"mediadisablecaptionsrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},zt={MEDIA_AIRPLAY_UNAVAILABLE:"mediaairplayunavailablechange",MEDIA_PIP_UNAVAILABLE:"mediapipunavailablechange",MEDIA_PAUSED:"mediapausedchange",MEDIA_HAS_PLAYED:"mediahasplayedchange",MEDIA_MUTED:"mediamutedchange",MEDIA_VOLUME_LEVEL:"mediavolumelevelchange",MEDIA_VOLUME:"mediavolumechange",MEDIA_VOLUME_UNAVAILABLE:"mediavolumeunavailablechange",MEDIA_IS_PIP:"mediaispipchange",MEDIA_IS_CASTING:"mediaiscastingchange",MEDIA_CAPTIONS_LIST:"mediacaptionslistchange",MEDIA_SUBTITLES_LIST:"mediasubtitleslistchange",MEDIA_CAPTIONS_SHOWING:"mediacaptionsshowingchange",MEDIA_SUBTITLES_SHOWING:"mediasubtitlesshowingchange",MEDIA_IS_FULLSCREEN:"mediaisfullscreenchange",MEDIA_PLAYBACK_RATE:"mediaplaybackratechange",MEDIA_CURRENT_TIME:"mediacurrenttimechange",MEDIA_DURATION:"mediadurationchange",MEDIA_SEEKABLE:"mediaseekablechange",MEDIA_PREVIEW_IMAGE:"mediapreviewimagechange",MEDIA_PREVIEW_COORDS:"mediapreviewcoordschange",MEDIA_LOADING:"medialoadingchange",USER_INACTIVE:"userinactivechange"},j={MEDIA_AIRPLAY_UNAVAILABLE:"media-airplay-unavailable",MEDIA_PIP_UNAVAILABLE:"media-pip-unavailable",MEDIA_CAST_UNAVAILABLE:"media-cast-unavailable",MEDIA_PAUSED:"media-paused",MEDIA_HAS_PLAYED:"media-has-played",MEDIA_MUTED:"media-muted",MEDIA_VOLUME_LEVEL:"media-volume-level",MEDIA_VOLUME:"media-volume",MEDIA_VOLUME_UNAVAILABLE:"media-volume-unavailable",MEDIA_IS_PIP:"media-is-pip",MEDIA_IS_CASTING:"media-is-casting",MEDIA_CAPTIONS_LIST:"media-captions-list",MEDIA_SUBTITLES_LIST:"media-subtitles-list",MEDIA_CAPTIONS_SHOWING:"media-captions-showing",MEDIA_SUBTITLES_SHOWING:"media-subtitles-showing",MEDIA_IS_FULLSCREEN:"media-is-fullscreen",MEDIA_PLAYBACK_RATE:"media-playback-rate",MEDIA_CURRENT_TIME:"media-current-time",MEDIA_DURATION:"media-duration",MEDIA_SEEKABLE:"media-seekable",MEDIA_PREVIEW_IMAGE:"media-preview-image",MEDIA_PREVIEW_COORDS:"media-preview-coords",MEDIA_CHROME_ATTRIBUTES:"media-chrome-attributes",MEDIA_CONTROLLER:"media-controller",MEDIA_LOADING:"media-loading",MEDIA_BUFFERED:"media-buffered"},qu=Object.entries(zt).reduce((v,[e,t])=>{let l=j[e];return l&&(v[t]=l),v},{userinactivechange:"user-inactive"}),En=Object.entries(j).reduce((v,[e,t])=>{let l=zt[e];return l&&(v[t]=l),v},{"user-inactive":"userinactivechange"}),kt={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},yt={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var vi={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},rt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"};var Ge={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:v=1}={})=>`current playback rate ${v}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},Ce={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",AIRPLAY:()=>"air play",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:v=30}={})=>`seek forward ${v} seconds`,SEEK_BACK_N_SECS:({seekOffset:v=30}={})=>`seek back ${v} seconds`},Io={...Ge,...Ce};var Mo=v=>typeof v=="number"&&!Number.isNaN(v)&&Number.isFinite(v),yn=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],Ro=(v,e)=>{let t=v===1?yn[e].singular:yn[e].plural;return`${v} ${t}`},Tt=v=>{if(!Mo(v))return"";let e=Math.abs(v),t=e!==v,l=new Date(0,0,0,0,0,e,0);return`${[l.getHours(),l.getMinutes(),l.getSeconds()].map((n,h)=>n&&Ro(n,h)).filter(n=>n).join(", ")}${t?" remaining":""}`};function ft(v,e){let t=!1;v<0&&(t=!0,v=0-v),v=v<0?0:v;let l=Math.floor(v%60),n=Math.floor(v/60%60),h=Math.floor(v/3600),R=Math.floor(e/60%60),T=Math.floor(e/3600);return(isNaN(v)||v===1/0)&&(h=n=l="-"),h=h>0||T>0?h+":":"",n=((h||R>=10)&&n<10?"0"+n:n)+":",l=l<10?"0"+l:l,(t?"-":"")+h+n+l}var Tn={HTMLElement:function(){this.addEventListener=()=>{},this.removeEventListener=()=>{},this.dispatchEvent=()=>{}},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){}},Co={createElement:function(){return new Tn.HTMLElement}},bn=typeof window=="undefined"||typeof window.customElements=="undefined",J=bn?Tn:window,z=bn?Co:window.document;function ne(v,e){J.customElements.get(v)||(J.customElements.define(v,e),J[e.name]=e)}var An=z.createElement("template");An.innerHTML=`
28
+ `),m=[],p=Object(R.toMpegTsClockFromTimescale)(u,r),v="00:00.000",h=0,x=0,S,C=!0,O=!1;T.oncue=function(P){var w=o[n],U=o.ccOffset,k=(h-p)/9e4;if(w!=null&&w.new&&(x!==void 0?U=o.ccOffset=w.start:D(o,n,k)),k&&(U=k-o.presentationOffset),O){var N=P.endTime-P.startTime,B=Object(E.normalizePts)((P.startTime+U-x)*9e4,s*9e4)/9e4;P.startTime=B,P.endTime=B+N}var K=P.text.trim();P.text=decodeURIComponent(encodeURIComponent(K)),P.id||(P.id=M(P.startTime,P.endTime,K)),P.endTime>0&&m.push(P)},T.onparsingerror=function(P){S=P},T.onflush=function(){if(S){l(S);return}d(m)},g.forEach(function(P){if(C)if(_(P,"X-TIMESTAMP-MAP=")){C=!1,O=!0,P.substr(16).split(",").forEach(function(w){_(w,"LOCAL:")?v=w.substr(6):_(w,"MPEGTS:")&&(h=parseInt(w.substr(7)))});try{x=y(v)/1e3}catch(w){O=!1,S=w}return}else P===""&&(C=!1);T.parse(P+`
29
+ `)}),T.flush()}},"./src/utils/xhr-loader.ts":function(f,e,t){"use strict";t.r(e);var a=t("./src/utils/logger.ts"),i=t("./src/loader/load-stats.ts"),c=/^age:\s*[\d.]+\s*$/m,R=function(){function E(_){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=_?_.xhrSetup:null,this.stats=new i.LoadStats,this.retryDelay=0}var L=E.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,I,M){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=I,this.callbacks=M,this.retryDelay=I.retryDelay,this.loadInternal()},L.loadInternal=function(){var y=this.config,I=this.context;if(!!y){var M=this.loader=new self.XMLHttpRequest,D=this.stats;D.loading.first=0,D.loaded=0;var b=this.xhrSetup;try{if(b)try{b(M,I.url)}catch{M.open("GET",I.url,!0),b(M,I.url)}M.readyState||M.open("GET",I.url,!0);var A=this.context.headers;if(A)for(var u in A)M.setRequestHeader(u,A[u])}catch(r){this.callbacks.onError({code:M.status,text:r.message},I,M);return}I.rangeEnd&&M.setRequestHeader("Range","bytes="+I.rangeStart+"-"+(I.rangeEnd-1)),M.onreadystatechange=this.readystatechange.bind(this),M.onprogress=this.loadprogress.bind(this),M.responseType=I.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),y.timeout),M.send()}},L.readystatechange=function(){var y=this.context,I=this.loader,M=this.stats;if(!(!y||!I)){var D=I.readyState,b=this.config;if(!M.aborted&&D>=2)if(self.clearTimeout(this.requestTimeout),M.loading.first===0&&(M.loading.first=Math.max(self.performance.now(),M.loading.start)),D===4){I.onreadystatechange=null,I.onprogress=null;var A=I.status;if(A>=200&&A<300){M.loading.end=Math.max(self.performance.now(),M.loading.first);var u,r;if(y.responseType==="arraybuffer"?(u=I.response,r=u.byteLength):(u=I.responseText,r=u.length),M.loaded=M.total=r,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(M,y,u,I),!this.callbacks)return;var n={url:I.responseURL,data:u};this.callbacks.onSuccess(n,M,y,I)}else M.retry>=b.maxRetry||A>=400&&A<499?(a.logger.error(A+" while loading "+y.url),this.callbacks.onError({code:A,text:I.statusText},y,I)):(a.logger.warn(A+" 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,b.maxRetryDelay),M.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout)}},L.loadtimeout=function(){a.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 I=this.stats;I.loaded=y.loaded,y.lengthComputable&&(I.total=y.total)},L.getCacheAge=function(){var y=null;if(this.loader&&c.test(this.loader.getAllResponseHeaders())){var I=this.loader.getResponseHeader("age");y=I?parseFloat(I):null}return y},E}();e.default=R}}).default})});var bi=_r(Tn()),pt=_r(Lr()),Ai=_r(Lr()),jt=_r(Lr()),bn=(f,e,t)=>{if(!e.has(f))throw TypeError("Cannot "+t)},wo=(f,e,t)=>(bn(f,e,"read from private field"),t?t.call(f):e.get(f)),Uo=(f,e,t)=>{if(e.has(f))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(f):e.set(f,t)},No=(f,e,t,a)=>(bn(f,e,"write to private field"),a?a.call(f,t):e.set(f,t),t);if(typeof DocumentFragment=="undefined"){class f{}globalThis.DocumentFragment=f}globalThis.customElements||(globalThis.customElements={get(f){},define(f,e,t){},upgrade(f){},whenDefined(f){return Promise.resolve(globalThis.HTMLElement)}});var Dr;if(!globalThis.CustomEvent){class f{constructor(t,a={}){Uo(this,Dr,void 0),No(this,Dr,a==null?void 0:a.detail)}get detail(){wo(this,Dr)}initCustomEvent(t,a,i,c){}}Dr=new WeakMap,globalThis.CustomEvent=f}if(!globalThis.EventTarget){class f{addEventListener(){}removeEventListener(){}dispatchEvent(t){return!0}}globalThis.EventTarget=f}if(!globalThis.HTMLElement){class f extends EventTarget{}globalThis.HTMLElement=f}if(!globalThis.HTMLVideoElement){class f extends EventTarget{}globalThis.HTMLVideoElement=f}var An,Sn;if(!((An=globalThis.document)==null?void 0:An.createElement)){let f=(Sn=globalThis.document)!=null?Sn:{};f.createElement=function(e,t){return new HTMLElement},globalThis.document=f}var Si={ANY:"any",MUTED:"muted"},Bo=Object.values(Si),_n=f=>typeof f=="boolean"||typeof f=="string"&&Bo.includes(f),xn=(f,e,t)=>{let a=!1,i=!1,c=_n(e)?e:!!e,R=()=>{f.addEventListener("playing",()=>{a=!0},{once:!0})};if(R(),f.addEventListener("loadstart",()=>{a=!1,R(),_i(f,c)},{once:!0}),f.addEventListener("loadedmetadata",()=>{t||(i=!Number.isFinite(f.duration)),_i(f,c)},{once:!0}),t&&t.once(Ai.default.Events.LEVEL_LOADED,(E,L)=>{var _;i=(_=L.details.live)!=null?_:!1}),!c){let E=()=>{!i||((t==null?void 0:t.liveSyncPosition)?f.currentTime=t.liveSyncPosition:Number.isFinite(f.seekable.end(0))&&(f.currentTime=f.seekable.end(0)))};f.addEventListener("play",()=>{t&&f.preload==="metadata"?t.once(Ai.default.Events.LEVEL_UPDATED,E):t&&E()},{once:!0})}return E=>{a||(c=_n(E)?E:!!E,_i(f,c))}},_i=(f,e)=>{if(!e)return;let t=f.muted,a=()=>f.muted=t;switch(e){case Si.ANY:f.play().catch(i=>{f.muted=!0,f.play().catch(a)});break;case Si.MUTED:f.muted=!0,f.play().catch(a);break;default:f.play().catch(()=>{});break}},ir=class extends Error{constructor(f,e=ir.MEDIA_ERR_CUSTOM,t){super(f);var a;this.name="MediaError",this.code=e,this.fatal=t!=null?t:e>=ir.MEDIA_ERR_NETWORK&&e<=ir.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(a=ir.defaultMessages[this.code])!=null?a:"")}},Oe=ir;Oe.MEDIA_ERR_ABORTED=1,Oe.MEDIA_ERR_NETWORK=2,Oe.MEDIA_ERR_DECODE=3,Oe.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Oe.MEDIA_ERR_ENCRYPTED=5,Oe.MEDIA_ERR_CUSTOM=100,Oe.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."};function Fo(f,e){e.on(jt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(i,{tracks:c})=>{c.forEach(R=>{var E;let L=(E=R.subtitleTrack)!=null?E:R.closedCaptions,_=e.subtitleTracks.findIndex(({lang:y,name:I,type:M})=>y==(L==null?void 0:L.lang)&&I===R.label&&M.toLowerCase()===R.kind);xi(f,R.kind,R.label,L==null?void 0:L.lang,`${R.kind}${_}`)})});let t=()=>{var i;if(!e.subtitleTracks.length)return;let c=Array.from(f.textTracks).find(E=>E.id&&E.mode==="showing"&&["subtitles","captions"].includes(E.kind)),R=`${(i=e.subtitleTracks[e.subtitleTrack])==null?void 0:i.type.toLowerCase()}${e.subtitleTrack}`;if(c&&(e.subtitleTrack<0||(c==null?void 0:c.id)!==R)){let E=e.subtitleTracks.findIndex(({lang:L,name:_,type:y})=>L==c.language&&_===c.label&&y.toLowerCase()===c.kind);e.subtitleTrack=E}c&&(c==null?void 0:c.id)===R&&c.cues&&Array.from(c.cues).forEach(E=>{c.addCue(E)})};f.textTracks.addEventListener("change",t),e.on(jt.default.Events.CUES_PARSED,(i,{track:c,type:R,cues:E})=>{let L=f.textTracks.getTrackById(c);if(!L)return;let _=L.mode==="disabled";_&&(L.mode="hidden"),E.forEach(y=>{var I;((I=L.cues)==null?void 0:I.getCueById(y.id))||L.addCue(y)}),_&&(L.mode="disabled")}),e.on(jt.default.Events.DESTROYING,()=>{f.textTracks.removeEventListener("change",t),f.querySelectorAll("track[data-removeondestroy]").forEach(i=>{i.remove()})});let a=()=>{Array.from(f.textTracks).forEach(i=>{var c,R;if(!["subtitles","caption"].includes(i.kind)&&i.label==="thumbnails"){if(!((c=i.cues)==null?void 0:c.length)){let E=f.querySelector('track[label="thumbnails"]'),L=(R=E==null?void 0:E.getAttribute("src"))!=null?R:"";E==null||E.removeAttribute("src"),setTimeout(()=>{E==null||E.setAttribute("src",L)},0)}i.mode!=="hidden"&&(i.mode="hidden")}})};e.once(jt.default.Events.MANIFEST_LOADED,a),e.once(jt.default.Events.MEDIA_ATTACHED,a)}function xi(f,e,t,a,i){let c=document.createElement("track");return c.kind=e,c.label=t,a&&(c.srclang=a),i&&(c.id=i),c.track.mode="disabled",c.setAttribute("data-removeondestroy",""),f.append(c),c.track}function Ln(f,e){let t=Array.prototype.find.call(f.querySelectorAll("track"),a=>a.track===e);t==null||t.remove()}var Dn=(f,e)=>f in e,In="mux.com",Mn=()=>bi.default.utils.now(),ve={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Kt={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Li={HLS:Kt.M3U8},Ad=Object.keys(Li),Sd=[...Object.values(Kt),"hls","HLS"],jo=f=>{let e=f.indexOf("?");if(e<0)return[f];let t=f.slice(0,e),a=f.slice(e);return[t,a]},Rn=(f,{domain:e=In}={})=>{if(!f)return;let[t,a=""]=jo(f);return`https://stream.${e}/${t}.m3u8${a}`},Ko=f=>{let e="";try{e=new URL(f).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let a=e.slice(t+1).toUpperCase();return Dn(a,Kt)?Kt[a]:""},Cn=f=>{let e=f.type;if(e){let a=e.toUpperCase();return Dn(a,Li)?Li[a]:e}let{src:t}=f;return t?Ko(t):""},Ho=f=>{if([ve.LIVE,ve.LL_LIVE].includes(f)){let e={backBufferLength:12};return f===ve.LL_LIVE?{...e,maxFragLookUpTolerance:.001}:e}return{}},Ir=new WeakMap,On=f=>{var e;return(e=Ir.get(f))==null?void 0:e.error},Di=(f,e)=>{e&&(e.detachMedia(),e.destroy()),(f==null?void 0:f.mux)&&!f.mux.deleted&&(f.mux.destroy(),f.mux),f&&(f.removeEventListener("error",Pn),f.removeEventListener("error",Ii),Ir.delete(f))},Wo=(f,e)=>{var t,a,i;let{debug:c,preferMse:R,streamType:E,startTime:L=-1}=f,_=Cn(f),y=_===Kt.M3U8,I=!_||((t=e==null?void 0:e.canPlayType(_))!=null?t:!0),M=pt.default.isSupported(),D=((i=(a=window==null?void 0:window.navigator)==null?void 0:a.userAgent)!=null?i:"").toLowerCase().indexOf("android")!==-1&&E===ve.LL_LIVE;if(y&&!(!y||I&&!((R||D)&&M))&&M){let b={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},A=Ho(E);return new pt.default({debug:c,startPosition:L,...b,...A})}},Go=({playbackId:f,src:e,customDomain:t})=>{if(f)return!0;if(typeof e!="string")return!1;let a=new URL(e).hostname.toLocaleLowerCase();return a.includes(In)||!!t&&a.includes(t.toLocaleLowerCase())},Vo=(f,e,t)=>{let{envKey:a}=f,i=Go(f);if((a||i)&&e){let{playerInitTime:c,playerSoftwareName:R,playerSoftwareVersion:E,beaconCollectionDomain:L,metadata:_,debug:y}=f,I=M=>typeof M.player_error_code=="string"?!1:typeof f.errorTranslator=="function"?f.errorTranslator(M):M;bi.default.monitor(e,{debug:y,beaconCollectionDomain:L,hlsjs:t,Hls:t?pt.default:void 0,automaticErrorTracking:!1,errorTranslator:I,data:{...a?{env_key:a}:{},player_software_name:R,player_software_version:E,player_init_time:c,..._}})}},$o=(f,e,t)=>{var a,i,c;if(!e){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:R,streamType:E}=f,L=Cn(f),_=L===Kt.M3U8,y=!L||((a=e==null?void 0:e.canPlayType(L))!=null?a:!0),I=pt.default.isSupported(),M=((c=(i=window==null?void 0:window.navigator)==null?void 0:i.userAgent)!=null?c:"").toLowerCase().indexOf("android")!==-1&&E===ve.LL_LIVE,D=!_||y&&!((R||M)&&I),{src:b}=f;if(e&&y&&D){if(typeof b=="string"){let{startTime:A}=f;if(e.setAttribute("src",b),A){let u=({target:r})=>{r.currentTime=A,r.removeEventListener("loadedmetadata",u)};e.addEventListener("loadedmetadata",u)}}else e.removeAttribute("src");e.addEventListener("error",Pn),e.addEventListener("error",Ii)}else if(t&&b){switch(t.on(pt.default.Events.ERROR,(A,u)=>{let r={[pt.default.ErrorTypes.NETWORK_ERROR]:Oe.MEDIA_ERR_NETWORK,[pt.default.ErrorTypes.MEDIA_ERROR]:Oe.MEDIA_ERR_DECODE},o=new Oe("",r[u.type]);o.fatal=u.fatal,o.data=u,e.dispatchEvent(new CustomEvent("error",{detail:o}))}),e.addEventListener("error",Ii),Fo(e,t),e.preload){case"none":e.addEventListener("play",()=>t.loadSource(b),{once:!0});break;case"metadata":let A=t.config.maxBufferLength,u=t.config.maxBufferSize;t.config.maxBufferLength=1,t.config.maxBufferSize=1,e.addEventListener("play",()=>{t.config.maxBufferLength=A,t.config.maxBufferSize=u},{once:!0}),t.loadSource(b);break;default:t.loadSource(b)}t.attachMedia(e)}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.")};async function Pn(f){if(!f.isTrusted)return;f.stopImmediatePropagation();let e=f.target;if(!(e==null?void 0:e.error))return;let{message:t,code:a}=e.error,i=new Oe(t,a);if(e.src&&(a!==Oe.MEDIA_ERR_DECODE||a!==void 0)){let{status:c}=await fetch(e.src);i.data={response:{code:c}}}e.dispatchEvent(new CustomEvent("error",{detail:i}))}function Ii(f){var e;if(!(f instanceof CustomEvent)||!(f.detail instanceof Oe))return;let t=f.target,a=f.detail;if(!a||!a.fatal)return;let i=Ir.get(t);i&&(i.error=a),(e=t.mux)==null||e.emit("error",{player_error_code:a.code,player_error_message:a.message})}var kn=(f,e,t)=>{Di(e,t),Ir.set(e,{});let a=Wo(f,e);return Vo(f,e,a),$o(f,e,a),a};var ne={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_CAPTIONS_REQUEST:"mediashowcaptionsrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_CAPTIONS_REQUEST:"mediadisablecaptionsrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},nr={MEDIA_AIRPLAY_UNAVAILABLE:"mediaairplayunavailablechange",MEDIA_PIP_UNAVAILABLE:"mediapipunavailablechange",MEDIA_PAUSED:"mediapausedchange",MEDIA_HAS_PLAYED:"mediahasplayedchange",MEDIA_MUTED:"mediamutedchange",MEDIA_VOLUME_LEVEL:"mediavolumelevelchange",MEDIA_VOLUME:"mediavolumechange",MEDIA_VOLUME_UNAVAILABLE:"mediavolumeunavailablechange",MEDIA_IS_PIP:"mediaispipchange",MEDIA_IS_CASTING:"mediaiscastingchange",MEDIA_CAPTIONS_LIST:"mediacaptionslistchange",MEDIA_SUBTITLES_LIST:"mediasubtitleslistchange",MEDIA_CAPTIONS_SHOWING:"mediacaptionsshowingchange",MEDIA_SUBTITLES_SHOWING:"mediasubtitlesshowingchange",MEDIA_IS_FULLSCREEN:"mediaisfullscreenchange",MEDIA_PLAYBACK_RATE:"mediaplaybackratechange",MEDIA_CURRENT_TIME:"mediacurrenttimechange",MEDIA_DURATION:"mediadurationchange",MEDIA_SEEKABLE:"mediaseekablechange",MEDIA_PREVIEW_IMAGE:"mediapreviewimagechange",MEDIA_PREVIEW_COORDS:"mediapreviewcoordschange",MEDIA_LOADING:"medialoadingchange",USER_INACTIVE:"userinactivechange"},j={MEDIA_AIRPLAY_UNAVAILABLE:"media-airplay-unavailable",MEDIA_PIP_UNAVAILABLE:"media-pip-unavailable",MEDIA_CAST_UNAVAILABLE:"media-cast-unavailable",MEDIA_PAUSED:"media-paused",MEDIA_HAS_PLAYED:"media-has-played",MEDIA_MUTED:"media-muted",MEDIA_VOLUME_LEVEL:"media-volume-level",MEDIA_VOLUME:"media-volume",MEDIA_VOLUME_UNAVAILABLE:"media-volume-unavailable",MEDIA_IS_PIP:"media-is-pip",MEDIA_IS_CASTING:"media-is-casting",MEDIA_CAPTIONS_LIST:"media-captions-list",MEDIA_SUBTITLES_LIST:"media-subtitles-list",MEDIA_CAPTIONS_SHOWING:"media-captions-showing",MEDIA_SUBTITLES_SHOWING:"media-subtitles-showing",MEDIA_IS_FULLSCREEN:"media-is-fullscreen",MEDIA_PLAYBACK_RATE:"media-playback-rate",MEDIA_CURRENT_TIME:"media-current-time",MEDIA_DURATION:"media-duration",MEDIA_SEEKABLE:"media-seekable",MEDIA_PREVIEW_TIME:"media-preview-time",MEDIA_PREVIEW_IMAGE:"media-preview-image",MEDIA_PREVIEW_COORDS:"media-preview-coords",MEDIA_CHROME_ATTRIBUTES:"media-chrome-attributes",MEDIA_CONTROLLER:"media-controller",MEDIA_LOADING:"media-loading",MEDIA_BUFFERED:"media-buffered"},xd=Object.entries(nr).reduce((f,[e,t])=>{let a=j[e];return a&&(f[t]=a),f},{userinactivechange:"user-inactive"}),wn=Object.entries(j).reduce((f,[e,t])=>{let a=nr[e];return a&&(f[t]=a),f},{"user-inactive":"userinactivechange"}),Ht={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},xt={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Mi={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},it={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"};var Ye={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:f=1}={})=>`current playback rate ${f}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading"},Pe={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",AIRPLAY:()=>"air play",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:f=30}={})=>`seek forward ${f} seconds`,SEEK_BACK_N_SECS:({seekOffset:f=30}={})=>`seek back ${f} seconds`},zo={...Ye,...Pe};var Xo=f=>typeof f=="number"&&!Number.isNaN(f)&&Number.isFinite(f),Un=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],Qo=(f,e)=>{let t=f===1?Un[e].singular:Un[e].plural;return`${f} ${t}`},Lt=f=>{if(!Xo(f))return"";let e=Math.abs(f),t=e!==f,a=new Date(0,0,0,0,0,e,0);return`${[a.getHours(),a.getMinutes(),a.getSeconds()].map((i,c)=>i&&Qo(i,c)).filter(i=>i).join(", ")}${t?" remaining":""}`};function nt(f,e){let t=!1;f<0&&(t=!0,f=0-f),f=f<0?0:f;let a=Math.floor(f%60),i=Math.floor(f/60%60),c=Math.floor(f/3600),R=Math.floor(e/60%60),E=Math.floor(e/3600);return(isNaN(f)||f===1/0)&&(c=i=a="-"),c=c>0||E>0?c+":":"",i=((c||R>=10)&&i<10?"0"+i:i)+":",a=a<10?"0"+a:a,(t?"-":"")+c+i+a}var Nn={HTMLElement:function(){this.addEventListener=()=>{},this.removeEventListener=()=>{},this.dispatchEvent=()=>{}},customElements:{get:function(){},define:function(){},whenDefined:function(){}},CustomEvent:function(){}},Jo={createElement:function(){return new Nn.HTMLElement}},Bn=typeof window=="undefined"||typeof window.customElements=="undefined",Q=Bn?Nn:window,z=Bn?Jo:window.document;function ae(f,e){Q.customElements.get(f)||(Q.customElements.define(f,e),Q[e.name]=e)}var Fn=z.createElement("template");Fn.innerHTML=`
30
30
  <style>
31
31
  :host {
32
32
  display: inline-block;
@@ -89,28 +89,28 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
89
89
  height: 24px;
90
90
  }
91
91
  </style>
92
- `;var Sn=["Enter"," "],mi=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(e={}){super();let t=this.attachShadow({mode:"open"}),l=An.content.cloneNode(!0);this.nativeEl=l;let n=e.slotTemplate;n||(n=z.createElement("template"),n.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(n.content.cloneNode(!0)),t.appendChild(l),this.addEventListener("click",R=>{this.handleClick(R)});let h=R=>{let{key:T}=R;if(!Sn.includes(T)){this.removeEventListener("keyup",h);return}this.handleClick(R)};this.addEventListener("keydown",R=>{let{metaKey:T,altKey:L,key:_}=R;if(T||L||!Sn.includes(_)){this.removeEventListener("keyup",h);return}this.addEventListener("keyup",h)})}attributeChangedCallback(e,t,l){var n,h;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(n=R==null?void 0:R.unassociateElement)==null||n.call(R,this)}if(l){let R=z.getElementById(l);(h=R==null?void 0:R.associateElement)==null||h.call(R,this)}}}connectedCallback(){var e;this.setAttribute("role","button"),this.setAttribute("tabindex",0);let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let l=z.getElementById(t);(e=l==null?void 0:l.associateElement)==null||e.call(l,this)}}disconnectedCallback(){var e;if(this.getAttribute(j.MEDIA_CONTROLLER)){let t=z.getElementById(mediaControllerId);(e=t==null?void 0:t.unassociateElement)==null||e.call(t,this)}}handleClick(){}};ne("media-chrome-button",mi);var ke=mi;var Po='<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 18"><defs><style>.cls-1{fill:var(--media-icon-color, #eee);}</style></defs><title>Mux Player SVG Icons_v2</title><path class="cls-1" d="M10.19,11.22a.25.25,0,0,0-.38,0L4.35,17.59a.25.25,0,0,0,.19.41H15.46a.25.25,0,0,0,.19-.41Z"/><path class="cls-1" d="M19,0H1A1,1,0,0,0,0,1V14a1,1,0,0,0,1,1H3.94L5,13.75H1.25V1.25h17.5v12.5H15L16.06,15H19a1,1,0,0,0,1-1V1A1,1,0,0,0,19,0Z"/></svg>',_n=z.createElement("template");_n.innerHTML=`
92
+ `;var Ri=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(e={}){super();let t=this.attachShadow({mode:"open"}),a=Fn.content.cloneNode(!0);this.nativeEl=a;let i=e.slotTemplate;i||(i=z.createElement("template"),i.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(i.content.cloneNode(!0)),t.appendChild(a),this.addEventListener("click",R=>{this.handleClick(R)});let c=R=>{let{key:E}=R;if(!this.keysUsed.includes(E)){this.removeEventListener("keyup",c);return}this.handleClick(R)};this.addEventListener("keydown",R=>{let{metaKey:E,altKey:L,key:_}=R;if(E||L||!this.keysUsed.includes(_)){this.removeEventListener("keyup",c);return}this.addEventListener("keyup",c)})}attributeChangedCallback(e,t,a){var i,c;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(i=R==null?void 0:R.unassociateElement)==null||i.call(R,this)}if(a){let R=z.getElementById(a);(c=R==null?void 0:R.associateElement)==null||c.call(R,this)}}}connectedCallback(){var e;this.setAttribute("role","button"),this.setAttribute("tabindex",0);let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.associateElement)==null||e.call(a,this)}}disconnectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.unassociateElement)==null||e.call(a,this)}}get keysUsed(){return["Enter"," "]}handleClick(){}};ae("media-chrome-button",Ri);var we=Ri;var qo='<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 18"><defs><style>.cls-1{fill:var(--media-icon-color, #eee);}</style></defs><title>Mux Player SVG Icons_v2</title><path class="cls-1" d="M10.19,11.22a.25.25,0,0,0-.38,0L4.35,17.59a.25.25,0,0,0,.19.41H15.46a.25.25,0,0,0,.19-.41Z"/><path class="cls-1" d="M19,0H1A1,1,0,0,0,0,1V14a1,1,0,0,0,1,1H3.94L5,13.75H1.25V1.25h17.5v12.5H15L16.06,15H19a1,1,0,0,0,1-1V1A1,1,0,0,0,19,0Z"/></svg>',jn=z.createElement("template");jn.innerHTML=`
93
93
  <style>
94
94
  </style>
95
95
 
96
- <slot name="airplay">${Po}</slot>
97
- `;var xn=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:_n,...e})}connectedCallback(){this.setAttribute("aria-label",Ce.AIRPLAY()),super.connectedCallback()}handleClick(e){let t=new J.CustomEvent(se.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(t)}};ne("media-airplay-button",xn);var ko='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',wo='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',Ln=z.createElement("template");Ln.innerHTML=`
96
+ <slot name="airplay">${qo}</slot>
97
+ `;var Kn=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:jn,...e})}connectedCallback(){this.setAttribute("aria-label",Pe.AIRPLAY()),super.connectedCallback()}handleClick(e){let t=new Q.CustomEvent(ne.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(t)}};ae("media-airplay-button",Kn);var el='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',tl='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',Hn=z.createElement("template");Hn.innerHTML=`
98
98
  <style>
99
99
  :host([${j.MEDIA_IS_CASTING}]) slot:not([name=exit]) > *,
100
100
  :host([${j.MEDIA_IS_CASTING}]) ::slotted(:not([slot=exit])) {
101
- display: none;
101
+ display: none !important;
102
102
  }
103
103
 
104
104
  /* Double negative, but safer if display doesn't equal 'block' */
105
105
  :host(:not([${j.MEDIA_IS_CASTING}])) slot:not([name=enter]) > *,
106
106
  :host(:not([${j.MEDIA_IS_CASTING}])) ::slotted(:not([slot=enter])) {
107
- display: none;
107
+ display: none !important;
108
108
  }
109
109
  </style>
110
110
 
111
- <slot name="enter">${ko}</slot>
112
- <slot name="exit">${wo}</slot>
113
- `;var Dn=v=>{let e=v.getAttribute(j.MEDIA_IS_CASTING)!=null?Ce.EXIT_CAST():Ce.ENTER_CAST();v.setAttribute("aria-label",e)},In=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_IS_CASTING,j.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Ln,...e})}connectedCallback(){Dn(this),super.connectedCallback()}attributeChangedCallback(e,t,l){e===j.MEDIA_IS_CASTING&&Dn(this),super.attributeChangedCallback(e,t,l)}handleClick(e){let t=this.getAttribute(j.MEDIA_IS_CASTING)!=null?se.MEDIA_EXIT_CAST_REQUEST:se.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new J.CustomEvent(t,{composed:!0,bubbles:!0}))}};ne("media-cast-button",In);var Mn=z.createElement("template");Mn.innerHTML=`
111
+ <slot name="enter">${el}</slot>
112
+ <slot name="exit">${tl}</slot>
113
+ `;var Wn=f=>{let e=f.getAttribute(j.MEDIA_IS_CASTING)!=null?Pe.EXIT_CAST():Pe.ENTER_CAST();f.setAttribute("aria-label",e)},Gn=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_IS_CASTING,j.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Hn,...e})}connectedCallback(){Wn(this),super.connectedCallback()}attributeChangedCallback(e,t,a){e===j.MEDIA_IS_CASTING&&Wn(this),super.attributeChangedCallback(e,t,a)}handleClick(e){let t=this.getAttribute(j.MEDIA_IS_CASTING)!=null?ne.MEDIA_EXIT_CAST_REQUEST:ne.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new Q.CustomEvent(t,{composed:!0,bubbles:!0}))}};ae("media-cast-button",Gn);var Vn=z.createElement("template");Vn.innerHTML=`
114
114
  <style>
115
115
  :host {
116
116
  display: inline-block;
@@ -121,7 +121,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
121
121
  pointer-events: auto;
122
122
  }
123
123
  </style>
124
- `;var Rn=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER,j.MEDIA_PAUSED]}constructor(e={}){super();let t=this.attachShadow({mode:"open"}),l=Mn.content.cloneNode(!0);this.nativeEl=l;let n=e.slotTemplate;n||(n=z.createElement("template"),n.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(n.content.cloneNode(!0)),t.appendChild(l),this._pointerType=void 0;let h=R=>{this._pointerType=R.pointerType};this.addEventListener("pointerdown",h),this.addEventListener("click",R=>{let{pointerType:T=this._pointerType}=R;if(this._pointerType=void 0,T===vi.TOUCH){this.handleTap(R);return}else if(T===vi.MOUSE){this.handleMouseClick(R);return}})}attributeChangedCallback(e,t,l){var n,h;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(n=R==null?void 0:R.unassociateElement)==null||n.call(R,this)}if(l){let R=z.getElementById(l);(h=R==null?void 0:R.associateElement)==null||h.call(R,this)}}}connectedCallback(){var e;this.setAttribute("tabindex",-1),this.setAttribute("aria-hidden",!0);let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let l=z.getElementById(t);(e=l==null?void 0:l.associateElement)==null||e.call(l,this)}}disconnectedCallback(){var e;if(this.getAttribute(j.MEDIA_CONTROLLER)){let t=z.getElementById(mediaControllerId);(e=t==null?void 0:t.unassociateElement)==null||e.call(t,this)}}handleTap(e){}handleMouseClick(e){let t=this.getAttribute(j.MEDIA_PAUSED)!=null?se.MEDIA_PLAY_REQUEST:se.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new J.CustomEvent(t,{composed:!0,bubbles:!0}))}};ne("media-gesture-receiver",Rn);var Tr=(v,e,t=".value")=>{let l=v.querySelector(t);!l||(l.textContent=e)},Uo=(v,e)=>{let t=`slot[name="${e}"]`,l=v.shadowRoot.querySelector(t);return l?l.children:[]},br=(v,e)=>Uo(v,e)[0],bt=(v,e)=>!v||!e?!1:v.contains(e)?!0:bt(v,e.getRootNode().host);var On=z.createElement("template");On.innerHTML=`
124
+ `;var $n=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER,j.MEDIA_PAUSED]}constructor(e={}){super();let t=this.attachShadow({mode:"open"}),a=Vn.content.cloneNode(!0);this.nativeEl=a;let i=e.slotTemplate;i||(i=z.createElement("template"),i.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(i.content.cloneNode(!0)),t.appendChild(a),this._pointerType=void 0;let c=R=>{this._pointerType=R.pointerType};this.addEventListener("pointerdown",c),this.addEventListener("click",R=>{let{pointerType:E=this._pointerType}=R;if(this._pointerType=void 0,E===Mi.TOUCH){this.handleTap(R);return}else if(E===Mi.MOUSE){this.handleMouseClick(R);return}})}attributeChangedCallback(e,t,a){var i,c;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(i=R==null?void 0:R.unassociateElement)==null||i.call(R,this)}if(a){let R=z.getElementById(a);(c=R==null?void 0:R.associateElement)==null||c.call(R,this)}}}connectedCallback(){var e;this.setAttribute("tabindex",-1),this.setAttribute("aria-hidden",!0);let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.associateElement)==null||e.call(a,this)}}disconnectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.unassociateElement)==null||e.call(a,this)}}handleTap(){}handleMouseClick(){let e=this.getAttribute(j.MEDIA_PAUSED)!=null?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new Q.CustomEvent(e,{composed:!0,bubbles:!0}))}};ae("media-gesture-receiver",$n);var Mr=(f,e,t=".value")=>{let a=f.querySelector(t);!a||(a.textContent=e)},rl=(f,e)=>{let t=`slot[name="${e}"]`,a=f.shadowRoot.querySelector(t);return a?a.children:[]},Rr=(f,e)=>rl(f,e)[0],Dt=(f,e)=>!f||!e?!1:f.contains(e)?!0:Dt(f,e.getRootNode().host);function ct(f,e){var t,a;let i;for(i of f.querySelectorAll("style"))for(let c of(a=(t=i.sheet)==null?void 0:t.cssRules)!=null?a:[])if(c.selectorText===e)return c;return(i==null?void 0:i.sheet)?(i.sheet.insertRule(`${e}{}`,i.sheet.cssRules.length),i.sheet.cssRules[i.sheet.cssRules.length-1]):{style:{setProperty:()=>{}}}}var Yn=z.createElement("template");Yn.innerHTML=`
125
125
  <style>
126
126
  :host {
127
127
  box-sizing: border-box;
@@ -241,7 +241,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
241
241
  <span part="layer centered-layer">
242
242
  <slot name="centered-chrome"></slot>
243
243
  </span>
244
- `;var No=Object.values(j),gi=class extends J.HTMLElement{constructor(){super();let e=this.attachShadow({mode:"open"});this.shadowRoot.appendChild(On.content.cloneNode(!0));let t=(h,R)=>{let T=this.media;for(let L of h)L.type==="childList"&&(L.removedNodes.forEach(_=>{if(_.slot=="media"&&L.target==this){let E=L.previousSibling&&L.previousSibling.previousElementSibling;if(!E||!T)this.mediaUnsetCallback(_);else{let I=E.slot!=="media";for(;(E=E.previousSibling)!==null;)E.slot=="media"&&(I=!1);I&&this.mediaUnsetCallback(_)}}}),T&&L.addedNodes.forEach(_=>{_==T&&this.handleMediaUpdated(T).then(E=>this.mediaSetCallback(E))}))};new MutationObserver(t).observe(this,{childList:!0,subtree:!0});let l=this.media,n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){this.mediaUnsetCallback(l);return}this.media&&(l=this.media,this.handleMediaUpdated(this.media).then(h=>this.mediaSetCallback(h)))})}static get observedAttributes(){return["autohide","gestures-disabled"].concat(No)}attributeChangedCallback(e,t,l){e.toLowerCase()=="autohide"&&(this.autohide=l)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}mediaSetCallback(e){this._mediaClickPlayToggle=t=>{let l=e.paused?se.MEDIA_PLAY_REQUEST:se.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new J.CustomEvent(l,{composed:!0,bubbles:!0}))}}handleMediaUpdated(e){let t=h=>Promise.resolve(h),l=h=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',h),Promise.reject(h));if(!e)return l(e);let n=e.nodeName.toLowerCase();return n.includes("-")?J.customElements.whenDefined(n).then(()=>t(e)):t(e)}mediaUnsetCallback(e){}connectedCallback(){let e=this.getAttribute("audio")!=null?Ge.AUDIO_PLAYER():Ge.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",e),this.media&&this.handleMediaUpdated(this.media).then(h=>this.mediaSetCallback(h)),this.setAttribute("user-inactive","user-inactive");let t=()=>{if(this.autohide<0)return;this.setAttribute("user-inactive","user-inactive");let h=new J.CustomEvent(zt.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(h)},l=()=>{this.removeAttribute("user-inactive");let h=new J.CustomEvent(zt.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(h)},n=()=>{l(),J.clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=J.setTimeout(()=>{t()},this.autohide*1e3))};this.addEventListener("keyup",h=>{n()}),this.addEventListener("pointerup",h=>{h.pointerType==="touch"&&([this,this.media].includes(h.target)&&!this.hasAttribute("user-inactive")?t():n())}),this.addEventListener("pointermove",h=>{h.pointerType==="mouse"&&(!bt(this,h.target)||(l(),J.clearTimeout(this._inactiveTimeout),[this,this.media].includes(h.target)&&n()))}),this.addEventListener("mouseleave",h=>{t()}),this.addEventListener("keyup",h=>{this.setAttribute("media-keyboard-control","")}),this.addEventListener("mouseup",h=>{this.removeAttribute("media-keyboard-control")})}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};ne("media-container-temp",gi);var Cn=gi;var Ke={enter:"requestFullscreen",exit:"exitFullscreen",event:"fullscreenchange",element:"fullscreenElement",error:"fullscreenerror"};z.fullscreenElement===void 0&&(Ke.enter="webkitRequestFullScreen",Ke.exit=z.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",Ke.event="webkitfullscreenchange",Ke.element="webkitFullscreenElement",Ke.error="webkitfullscreenerror");function Ar(v,e=!1){return v.split("_").map(function(t,l){return(l||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}var Sr=(v="")=>v.split(/\s+/),Pn=(v="")=>{let[e,t]=v.split(":"),l=t?decodeURIComponent(t):void 0;return{language:e,label:l}},Bo=(v="",e={})=>Sr(v).map(t=>{let l=Pn(t);return{...e,...l}}),Fo=v=>Array.isArray(v)?v.map(e=>typeof e=="string"?Pn(e):e):typeof v=="string"?Bo(v):[v],jo=({label:v,language:e}={})=>v?`${e}:${encodeURIComponent(v)}`:e,Je=(v=[])=>Array.prototype.map.call(v,jo).join(" "),Ko=(v,e)=>t=>t[v]===e,kn=v=>{let e=Object.entries(v).map(([t,l])=>Ko(t,l));return t=>e.every(l=>l(t))},Xt=(v,e=[],t=[])=>{let l=Fo(t).map(kn),n=h=>l.some(R=>R(h));Array.from(e).filter(n).forEach(h=>{h.mode=v})},wt=(v,e=()=>!0)=>{if(!(v==null?void 0:v.textTracks))return[];let t=typeof e=="function"?e:kn(e);return Array.from(v.textTracks).filter(t)};var pi=class extends Cn{constructor(){super();Qo||(this._airplayUnavailable=rt.UNSUPPORTED),Jo||(this._castUnavailable=rt.UNSUPPORTED),zo||(this._pipUnavailable=rt.UNSUPPORTED),Jt!==void 0?Jt||(this._volumeUnavailable=rt.UNSUPPORTED):Xo.then(()=>{Jt||(this._volumeUnavailable=rt.UNSUPPORTED,this.propagateMediaState(j.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associatedElements=[],this.associateElement(this);let e={MEDIA_PLAY_REQUEST:()=>this.media.play(),MEDIA_PAUSE_REQUEST:()=>this.media.pause(),MEDIA_MUTE_REQUEST:()=>this.media.muted=!0,MEDIA_UNMUTE_REQUEST:()=>{let t=this.media;t.muted=!1,t.volume===0&&(t.volume=.25)},MEDIA_VOLUME_REQUEST:t=>{let l=this.media,n=t.detail;l.volume=n,n>0&&l.muted&&(l.muted=!1);try{J.localStorage.setItem("media-chrome-pref-volume",n.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:()=>{let t=this.media;z.pictureInPictureElement&&z.exitPictureInPicture(),super[Ke.enter]?super[Ke.enter]():t.webkitEnterFullscreen?t.webkitEnterFullscreen():t.requestFullscreen?t.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{z[Ke.exit]()},MEDIA_ENTER_PIP_REQUEST:()=>{let t=this.media;!z.pictureInPictureEnabled||(z[Ke.element]&&z[Ke.exit](),t.requestPictureInPicture())},MEDIA_EXIT_PIP_REQUEST:()=>{z.pictureInPictureElement&&z.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:()=>{var t;let l=this.media;!((t=globalThis.CastableVideoElement)==null?void 0:t.castEnabled)||(z[Ke.element]&&z[Ke.exit](),l.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var t;((t=globalThis.CastableVideoElement)==null?void 0:t.castElement)&&globalThis.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:t=>{let l=this.media,n=t.detail;(l.readyState>0||l.readyState===void 0)&&(l.currentTime=n)},MEDIA_PLAYBACK_RATE_REQUEST:t=>{this.media.playbackRate=t.detail},MEDIA_PREVIEW_REQUEST:t=>{var l;let n=this.media;if(!n)return;let[h]=wt(n,{kind:kt.METADATA,label:"thumbnails"});if(!(h&&h.cues))return;let R=t.detail;if(R===null){this.propagateMediaState(j.MEDIA_PREVIEW_IMAGE,void 0),this.propagateMediaState(j.MEDIA_PREVIEW_COORDS,void 0);return}let T=Array.prototype.find.call(h.cues,I=>I.startTime>=R);if(!T)return;let L=/'^(?:[a-z]+:)?\/\//i.test(T.text)||(l=n.querySelector('track[label="thumbnails"]'))==null?void 0:l.src,_=new URL(T.text,L),E=new URLSearchParams(_.hash).get("#xywh");this.propagateMediaState(j.MEDIA_PREVIEW_IMAGE,_.href),this.propagateMediaState(j.MEDIA_PREVIEW_COORDS,E.split(",").join(" "))},MEDIA_SHOW_CAPTIONS_REQUEST:t=>{let l=xr(this),{detail:n=[]}=t;Xt(yt.SHOWING,l,n)},MEDIA_DISABLE_CAPTIONS_REQUEST:t=>{let l=xr(this),{detail:n=[]}=t;Xt(yt.DISABLED,l,n)},MEDIA_SHOW_SUBTITLES_REQUEST:t=>{let l=_r(this),{detail:n=[]}=t;Xt(yt.SHOWING,l,n)},MEDIA_DISABLE_SUBTITLES_REQUEST:t=>{let l=_r(this),{detail:n=[]}=t;Xt(yt.DISABLED,l,n)},MEDIA_AIRPLAY_REQUEST:t=>{let{media:l}=this;if(l){if(!(l.webkitShowPlaybackTargetPicker&&J.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}l.webkitShowPlaybackTargetPicker()}}};if(Object.keys(e).forEach(t=>{let l=`_handle${Ar(t,!0)}`;this[l]=n=>{if(n.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}e[t](n,this.media)},this.addEventListener(se[t],this[l])}),this._mediaStatePropagators={"play,pause,emptied":()=>{this.propagateMediaState(j.MEDIA_PAUSED,wn(this))},"playing,emptied":()=>{var t;this.propagateMediaState(j.MEDIA_HAS_PLAYED,!((t=this.media)==null?void 0:t.paused))},volumechange:()=>{this.propagateMediaState(j.MEDIA_MUTED,Un(this)),this.propagateMediaState(j.MEDIA_VOLUME,Nn(this)),this.propagateMediaState(j.MEDIA_VOLUME_LEVEL,Bn(this))},[Ke.event]:t=>{let l=!!z[Ke.element]&&(t==null?void 0:t.target),n=bt(this,l);this.propagateMediaState(j.MEDIA_IS_FULLSCREEN,n)},"enterpictureinpicture,leavepictureinpicture":t=>{var l;let n;if(t)n=t.type=="enterpictureinpicture";else{let h=(l=this.getRootNode().pictureInPictureElement)!=null?l:z.pictureInPictureElement;n=this.media&&bt(this.media,h)}this.propagateMediaState(j.MEDIA_IS_PIP,n)},"entercast,leavecast,castchange":t=>{var l;let n=(l=globalThis.CastableVideoElement)==null?void 0:l.castElement,h=this.media&&bt(this.media,n);(t==null?void 0:t.type)==="castchange"&&(t==null?void 0:t.detail)==="CONNECTING"&&(h="connecting"),this.propagateMediaState(j.MEDIA_IS_CASTING,h)},"timeupdate,loadedmetadata":()=>{this.propagateMediaState(j.MEDIA_CURRENT_TIME,Fn(this))},"durationchange,loadedmetadata,emptied":()=>{this.propagateMediaState(j.MEDIA_DURATION,jn(this))},"loadedmetadata,emptied,progress":()=>{var t;this.propagateMediaState(j.MEDIA_SEEKABLE,(t=Kn(this))==null?void 0:t.join(":"))},"progress,emptied":()=>{var t;this.propagateMediaState(j.MEDIA_BUFFERED,Zo((t=this.media)==null?void 0:t.buffered))},"ratechange,loadstart":()=>{this.propagateMediaState(j.MEDIA_PLAYBACK_RATE,Wn(this))},"waiting,playing,emptied":()=>{var t;let l=((t=this.media)==null?void 0:t.readyState)<3;this.propagateMediaState(j.MEDIA_LOADING,l)}},this._airplayUnavailable!==rt.UNSUPPORTED){let t=l=>{(l==null?void 0:l.availability)==="available"?this._airplayUnavailable=void 0:(l==null?void 0:l.availability)==="not-available"&&(this._airplayUnavailable=rt.UNAVAILABLE),this.propagateMediaState(j.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable)};this._mediaStatePropagators.webkitplaybacktargetavailabilitychanged=t}if(this._castUnavailable!==rt.UNSUPPORTED){let t=()=>{var l;let n=(l=globalThis.CastableVideoElement)==null?void 0:l.castState;(n==null?void 0:n.includes("CONNECT"))?this._castUnavailable=void 0:this._castUnavailable=rt.UNAVAILABLE,this.propagateMediaState(j.MEDIA_CAST_UNAVAILABLE,this._castUnavailable)};this._mediaStatePropagators.castchange=t}this._textTrackMediaStatePropagators={"addtrack,removetrack,loadstart":()=>{this.propagateMediaState(j.MEDIA_CAPTIONS_LIST,Je(xr(this))||void 0),this.propagateMediaState(j.MEDIA_SUBTITLES_LIST,Je(_r(this))||void 0),this.propagateMediaState(j.MEDIA_CAPTIONS_SHOWING,Je(yi(this))||void 0),this.propagateMediaState(j.MEDIA_SUBTITLES_SHOWING,Je(Ei(this))||void 0)},change:()=>{this.propagateMediaState(j.MEDIA_CAPTIONS_SHOWING,Je(yi(this))||void 0),this.propagateMediaState(j.MEDIA_SUBTITLES_SHOWING,Je(Ei(this))||void 0)}}}mediaSetCallback(e){super.mediaSetCallback(e),Object.keys(this._mediaStatePropagators).forEach(t=>{let l=t.split(","),n=this._mediaStatePropagators[t];l.forEach(h=>{(h==Ke.event?this.getRootNode():e).addEventListener(h,n)}),n()}),Object.entries(this._textTrackMediaStatePropagators).forEach(([t,l])=>{t.split(",").forEach(n=>{e.textTracks&&e.textTracks.addEventListener(n,l)}),l()});try{let t=J.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t)}catch(t){console.debug("Error getting volume pref",t)}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys(this._mediaStatePropagators).forEach(t=>{let l=t.split(","),n=this._mediaStatePropagators[t];l.forEach(h=>{(h==Ke.event?this.getRootNode():e).removeEventListener(h,n)})}),Object.entries(this._textTrackMediaStatePropagators).forEach(([t,l])=>{t.split(",").forEach(n=>{e.textTracks&&e.textTracks.removeEventListener(n,l)}),l()}),this.propagateMediaState(j.MEDIA_PAUSED,!0)}propagateMediaState(e,t){Fe(this.mediaStateReceivers,e,t);let l=new J.CustomEvent(En[e],{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(l)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let l=this.registerMediaStateReceiver.bind(this),n=this.unregisterMediaStateReceiver.bind(this),h=Vo(e,l,n);Object.keys(se).forEach(R=>{e.addEventListener(se[R],this[`_handle${Ar(R,!0)}`])}),t.set(e,h)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;!t.has(e)||(t.get(e)(),t.delete(e),Object.keys(se).forEach(l=>{e.removeEventListener(se[l],this[`_handle${Ar(l,!0)}`])}))}registerMediaStateReceiver(e){var t;if(!e)return;let l=this.mediaStateReceivers;l.indexOf(e)>-1||(l.push(e),Fe([e],j.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable),Fe([e],j.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable),Fe([e],j.MEDIA_CAST_UNAVAILABLE,this._castUnavailable),Fe([e],j.MEDIA_PIP_UNAVAILABLE,this._pipUnavailable),this.media&&(Fe([e],j.MEDIA_CAPTIONS_LIST,Je(xr(this))||void 0),Fe([e],j.MEDIA_SUBTITLES_LIST,Je(_r(this))||void 0),Fe([e],j.MEDIA_CAPTIONS_SHOWING,Je(yi(this))||void 0),Fe([e],j.MEDIA_SUBTITLES_SHOWING,Je(Ei(this))||void 0),Fe([e],j.MEDIA_PAUSED,wn(this)),Fe([e],j.MEDIA_MUTED,Un(this)),Fe([e],j.MEDIA_VOLUME,Nn(this)),Fe([e],j.MEDIA_VOLUME_LEVEL,Bn(this)),Fe([e],j.MEDIA_IS_FULLSCREEN,this.hasAttribute(j.MEDIA_IS_FULLSCREEN)),Fe([e],j.MEDIA_IS_CASTING,this.hasAttribute(j.MEDIA_IS_CASTING)),Fe([e],j.MEDIA_CURRENT_TIME,Fn(this)),Fe([e],j.MEDIA_DURATION,jn(this)),Fe([e],j.MEDIA_SEEKABLE,(t=Kn(this))==null?void 0:t.join(":")),Fe([e],j.MEDIA_PLAYBACK_RATE,Wn(this))))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,l=t.indexOf(e);l<0||t.splice(l,1)}},wn=v=>v.media?v.media.paused:!0,Un=v=>!!(v.media&&v.media.muted),Nn=v=>{let e=v.media;return e?e.volume:1},Bn=v=>{let e="high";if(!v.media)return e;let{muted:t,volume:l}=v.media;return l===0||t?e="off":l<.5?e="low":l<.75&&(e="medium"),e},Fn=v=>{let e=v.media;return e?e.currentTime:0},jn=v=>{let e=v==null?void 0:v.media;return Number.isFinite(e==null?void 0:e.duration)?e.duration:NaN},Kn=v=>{var e;let t=v==null?void 0:v.media;if(!((e=t==null?void 0:t.seekable)==null?void 0:e.length))return;let l=t.seekable.start(0),n=t.seekable.end(t.seekable.length-1);if(!(!l&&!n))return[Number(l.toFixed(3)),Number(n.toFixed(3))]},Wn=v=>{let e=v.media;return e?e.playbackRate:1},_r=v=>wt(v.media,{kind:kt.SUBTITLES}),xr=v=>wt(v.media,{kind:kt.CAPTIONS}),Ei=v=>wt(v.media,{kind:kt.SUBTITLES,mode:yt.SHOWING}),yi=v=>wt(v.media,{kind:kt.CAPTIONS,mode:yt.SHOWING}),Wo=Object.values(j),Hn=v=>{var e,t,l,n;let{observedAttributes:h}=v.constructor;!h&&((e=v.nodeName)==null?void 0:e.includes("-"))&&(J.customElements.upgrade(v),{observedAttributes:h}=v.constructor);let R=(n=(l=(t=v==null?void 0:v.getAttribute)==null?void 0:t.call(v,j.MEDIA_CHROME_ATTRIBUTES))==null?void 0:l.split)==null?void 0:n.call(l,/\s+/);return Array.isArray(h||R)?(h||R).filter(T=>Wo.includes(T)):[]},Ti=v=>!!Hn(v).length,Ho=async(v,e,t)=>(v.isConnected||await Vn(0),t==null?v.removeAttribute(e):typeof t=="boolean"?t?v.setAttribute(e,""):v.removeAttribute(e):Number.isNaN(t)?v.removeAttribute(e):v.setAttribute(e,t)),Go=v=>{var e;return!!((e=v.closest)==null?void 0:e.call(v,'*[slot="media"]'))},Qt=(v,e)=>{if(Go(v))return;let t=(n,h)=>{var R,T;Ti(n)&&h(n);let{children:L=[]}=n!=null?n:{},_=(T=(R=n==null?void 0:n.shadowRoot)==null?void 0:R.children)!=null?T:[];[...L,..._].forEach(E=>Qt(E,h))},l=v==null?void 0:v.nodeName.toLowerCase();if(l.includes("-")&&!Ti(v)){J.customElements.whenDefined(l).then(()=>{t(v,e)});return}t(v,e)},Fe=(v,e,t)=>{v.forEach(l=>{!Hn(l).includes(e)||Ho(l,e,t)})},Vo=(v,e,t)=>{Qt(v,e);let l=T=>{var L;let _=(L=T==null?void 0:T.composedPath()[0])!=null?L:T.target;e(_)},n=T=>{var L;let _=(L=T==null?void 0:T.composedPath()[0])!=null?L:T.target;t(_)};v.addEventListener(se.REGISTER_MEDIA_STATE_RECEIVER,l),v.addEventListener(se.UNREGISTER_MEDIA_STATE_RECEIVER,n);let h=(T,L)=>{T.forEach(_=>{let{addedNodes:E=[],removedNodes:I=[],type:M,target:D,attributeName:b}=_;M==="childList"?(Array.prototype.forEach.call(E,A=>Qt(A,e)),Array.prototype.forEach.call(I,A=>Qt(A,t))):M==="attributes"&&b===j.MEDIA_CHROME_ATTRIBUTES&&(Ti(D)?e(D):t(D))})},R=new MutationObserver(h);return R.observe(v,{childList:!0,attributes:!0,subtree:!0}),()=>{Qt(v,t),R.disconnect(),v.removeEventListener(se.REGISTER_MEDIA_STATE_RECEIVER,l),v.removeEventListener(se.UNREGISTER_MEDIA_STATE_RECEIVER,n)}},bi,Gn=()=>{var v,e;return bi||(bi=(e=(v=z)==null?void 0:v.createElement)==null?void 0:e.call(v,"video"),bi)},$o=async(v=Gn())=>{if(!v)return!1;let e=v.volume;return v.volume=e/2+.1,await Vn(0),v.volume!==e},Vn=v=>new Promise((e,t)=>setTimeout(e,v)),Yo=(v=Gn())=>typeof(v==null?void 0:v.requestPictureInPicture)=="function",zo=Yo(),Jt,Xo=$o().then(v=>(Jt=v,Jt)),Qo=!!J.WebKitPlaybackTargetAvailabilityEvent,Jo=!!J.chrome;function Zo(v=[]){return Array.from(v).map((e,t)=>[Number(v.start(t).toFixed(3)),Number(v.end(t).toFixed(3))].join(":")).join(" ")}ne("media-controller",pi);var Zt=pi;var $n=z.createElement("template"),Yn=`
244
+ `;var il=Object.values(j),Ci=class extends Q.HTMLElement{constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Yn.content.cloneNode(!0));let e=i=>{let c=this.media;for(let R of i)R.type==="childList"&&(R.removedNodes.forEach(E=>{if(E.slot=="media"&&R.target==this){let L=R.previousSibling&&R.previousSibling.previousElementSibling;if(!L||!c)this.mediaUnsetCallback(E);else{let _=L.slot!=="media";for(;(L=L.previousSibling)!==null;)L.slot=="media"&&(_=!1);_&&this.mediaUnsetCallback(E)}}}),c&&R.addedNodes.forEach(E=>{E==c&&this.handleMediaUpdated(c).then(L=>this.mediaSetCallback(L))}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let t=this.media,a=this.querySelector(":scope > slot[slot=media]");a&&a.addEventListener("slotchange",()=>{if(!a.assignedElements({flatten:!0}).length){this.mediaUnsetCallback(t);return}this.media&&(t=this.media,this.handleMediaUpdated(this.media).then(i=>this.mediaSetCallback(i)))})}static get observedAttributes(){return["autohide","gestures-disabled"].concat(il)}attributeChangedCallback(e,t,a){e.toLowerCase()=="autohide"&&(this.autohide=a)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}mediaSetCallback(e){this._mediaClickPlayToggle=()=>{let t=e.paused?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new Q.CustomEvent(t,{composed:!0,bubbles:!0}))}}handleMediaUpdated(e){let t=c=>Promise.resolve(c),a=c=>(console.error('<media-chrome>: Media element set with slot="media" does not appear to be compatible.',c),Promise.reject(c));if(!e)return a(e);let i=e.nodeName.toLowerCase();return i.includes("-")?Q.customElements.whenDefined(i).then(()=>t(e)):t(e)}mediaUnsetCallback(){}connectedCallback(){let e=this.getAttribute("audio")!=null?Ye.AUDIO_PLAYER():Ye.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",e),this.media&&this.handleMediaUpdated(this.media).then(c=>this.mediaSetCallback(c)),this.setAttribute("user-inactive","user-inactive");let t=()=>{if(this.autohide<0)return;this.setAttribute("user-inactive","user-inactive");let c=new Q.CustomEvent(nr.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(c)},a=()=>{this.removeAttribute("user-inactive");let c=new Q.CustomEvent(nr.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(c)},i=()=>{a(),Q.clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=Q.setTimeout(()=>{t()},this.autohide*1e3))};this.addEventListener("keyup",()=>{i()}),this.addEventListener("pointerup",c=>{c.pointerType==="touch"&&([this,this.media].includes(c.target)&&!this.hasAttribute("user-inactive")?t():i())}),this.addEventListener("pointermove",c=>{c.pointerType==="mouse"&&(!Dt(this,c.target)||(a(),Q.clearTimeout(this._inactiveTimeout),[this,this.media].includes(c.target)&&i()))}),this.addEventListener("mouseleave",()=>{t()}),this.addEventListener("keyup",()=>{this.setAttribute("media-keyboard-control","")}),this.addEventListener("mouseup",()=>{this.removeAttribute("media-keyboard-control")})}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};ae("media-container-temp",Ci);var zn=Ci;var Ge={enter:"requestFullscreen",exit:"exitFullscreen",event:"fullscreenchange",element:"fullscreenElement",error:"fullscreenerror"};z.fullscreenElement===void 0&&(Ge.enter="webkitRequestFullScreen",Ge.exit=z.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",Ge.event="webkitfullscreenchange",Ge.element="webkitFullscreenElement",Ge.error="webkitfullscreenerror");function Cr(f,e=!1){return f.split("_").map(function(t,a){return(a||e?t[0].toUpperCase():t[0].toLowerCase())+t.slice(1).toLowerCase()}).join("")}var Or=(f="")=>f.split(/\s+/),Xn=(f="")=>{let[e,t]=f.split(":"),a=t?decodeURIComponent(t):void 0;return{language:e,label:a}},nl=(f="",e={})=>Or(f).map(t=>{let a=Xn(t);return{...e,...a}}),al=f=>Array.isArray(f)?f.map(e=>typeof e=="string"?Xn(e):e):typeof f=="string"?nl(f):[f],sl=({label:f,language:e}={})=>f?`${e}:${encodeURIComponent(f)}`:e,Je=(f=[])=>Array.prototype.map.call(f,sl).join(" "),ol=(f,e)=>t=>t[f]===e,Qn=f=>{let e=Object.entries(f).map(([t,a])=>ol(t,a));return t=>e.every(a=>a(t))},ar=(f,e=[],t=[])=>{let a=al(t).map(Qn),i=c=>a.some(R=>R(c));Array.from(e).filter(i).forEach(c=>{c.mode=f})},Wt=(f,e=()=>!0)=>{if(!(f==null?void 0:f.textTracks))return[];let t=typeof e=="function"?e:Qn(e);return Array.from(f.textTracks).filter(t)};var ll=(f,e,t)=>{if(!e.has(f))throw TypeError("Cannot "+t)},Zn=(f,e,t)=>{if(e.has(f))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(f):e.set(f,t)},Gt=(f,e,t)=>(ll(f,e,"access private method"),t),Vt,sr,Pr,Oi,Jn=["Enter"," ","f","m","k","ArrowLeft","ArrowRight"],ul=10,Pi=class extends zn{constructor(){super();Zn(this,Vt),Zn(this,Pr),El||(this._airplayUnavailable=it.UNSUPPORTED),yl||(this._castUnavailable=it.UNSUPPORTED),pl||(this._pipUnavailable=it.UNSUPPORTED),lr!==void 0?lr||(this._volumeUnavailable=it.UNSUPPORTED):gl.then(()=>{lr||(this._volumeUnavailable=it.UNSUPPORTED,this.propagateMediaState(j.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable))}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associatedElements=[],this.associateElement(this);let e={MEDIA_PLAY_REQUEST:()=>this.media.play(),MEDIA_PAUSE_REQUEST:()=>this.media.pause(),MEDIA_MUTE_REQUEST:()=>this.media.muted=!0,MEDIA_UNMUTE_REQUEST:()=>{let t=this.media;t.muted=!1,t.volume===0&&(t.volume=.25)},MEDIA_VOLUME_REQUEST:t=>{let a=this.media,i=t.detail;a.volume=i,i>0&&a.muted&&(a.muted=!1);try{Q.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}},MEDIA_ENTER_FULLSCREEN_REQUEST:()=>{let t=this.media;z.pictureInPictureElement&&z.exitPictureInPicture(),super[Ge.enter]?super[Ge.enter]():t.webkitEnterFullscreen?t.webkitEnterFullscreen():t.requestFullscreen?t.requestFullscreen():console.warn("MediaChrome: Fullscreen not supported")},MEDIA_EXIT_FULLSCREEN_REQUEST:()=>{z[Ge.exit]()},MEDIA_ENTER_PIP_REQUEST:()=>{let t=this.media;!z.pictureInPictureEnabled||(z[Ge.element]&&z[Ge.exit](),t.requestPictureInPicture())},MEDIA_EXIT_PIP_REQUEST:()=>{z.pictureInPictureElement&&z.exitPictureInPicture()},MEDIA_ENTER_CAST_REQUEST:()=>{var t;let a=this.media;!((t=globalThis.CastableVideoElement)==null?void 0:t.castEnabled)||(z[Ge.element]&&z[Ge.exit](),a.requestCast())},MEDIA_EXIT_CAST_REQUEST:async()=>{var t;((t=globalThis.CastableVideoElement)==null?void 0:t.castElement)&&globalThis.CastableVideoElement.exitCast()},MEDIA_SEEK_REQUEST:t=>{let a=this.media,i=t.detail;(a.readyState>0||a.readyState===void 0)&&(a.currentTime=i)},MEDIA_PLAYBACK_RATE_REQUEST:t=>{this.media.playbackRate=t.detail},MEDIA_PREVIEW_REQUEST:t=>{var a;let i=this.media;if(!i)return;let c=t.detail;c===null&&this.propagateMediaState(j.MEDIA_PREVIEW_TIME,void 0),this.propagateMediaState(j.MEDIA_PREVIEW_TIME,c);let[R]=Wt(i,{kind:Ht.METADATA,label:"thumbnails"});if(!(R&&R.cues))return;if(c===null){this.propagateMediaState(j.MEDIA_PREVIEW_IMAGE,void 0),this.propagateMediaState(j.MEDIA_PREVIEW_COORDS,void 0);return}let E=Array.prototype.find.call(R.cues,I=>I.startTime>=c);if(!E)return;let L=/'^(?:[a-z]+:)?\/\//i.test(E.text)||(a=i.querySelector('track[label="thumbnails"]'))==null?void 0:a.src,_=new URL(E.text,L),y=new URLSearchParams(_.hash).get("#xywh");this.propagateMediaState(j.MEDIA_PREVIEW_IMAGE,_.href),this.propagateMediaState(j.MEDIA_PREVIEW_COORDS,y.split(",").join(" "))},MEDIA_SHOW_CAPTIONS_REQUEST:t=>{let a=wr(this),{detail:i=[]}=t;ar(xt.SHOWING,a,i)},MEDIA_DISABLE_CAPTIONS_REQUEST:t=>{let a=wr(this),{detail:i=[]}=t;ar(xt.DISABLED,a,i)},MEDIA_SHOW_SUBTITLES_REQUEST:t=>{let a=kr(this),{detail:i=[]}=t;ar(xt.SHOWING,a,i)},MEDIA_DISABLE_SUBTITLES_REQUEST:t=>{let a=kr(this),{detail:i=[]}=t;ar(xt.DISABLED,a,i)},MEDIA_AIRPLAY_REQUEST:()=>{let{media:t}=this;if(t){if(!(t.webkitShowPlaybackTargetPicker&&Q.WebKitPlaybackTargetAvailabilityEvent)){console.warn("received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}}};if(Object.keys(e).forEach(t=>{let a=`_handle${Cr(t,!0)}`;this[a]=i=>{if(i.stopPropagation(),!this.media){console.warn("MediaController: No media available.");return}e[t](i,this.media)},this.addEventListener(ne[t],this[a])}),this._mediaStatePropagators={"play,pause,emptied":()=>{this.propagateMediaState(j.MEDIA_PAUSED,qn(this))},"playing,emptied":()=>{var t;this.propagateMediaState(j.MEDIA_HAS_PLAYED,!((t=this.media)==null?void 0:t.paused))},volumechange:()=>{this.propagateMediaState(j.MEDIA_MUTED,ea(this)),this.propagateMediaState(j.MEDIA_VOLUME,ta(this)),this.propagateMediaState(j.MEDIA_VOLUME_LEVEL,ra(this))},[Ge.event]:t=>{let a=!!z[Ge.element]&&(t==null?void 0:t.target),i=Dt(this,a);this.propagateMediaState(j.MEDIA_IS_FULLSCREEN,i)},"enterpictureinpicture,leavepictureinpicture":t=>{var a;let i;if(t)i=t.type=="enterpictureinpicture";else{let c=(a=this.getRootNode().pictureInPictureElement)!=null?a:z.pictureInPictureElement;i=this.media&&Dt(this.media,c)}this.propagateMediaState(j.MEDIA_IS_PIP,i)},"entercast,leavecast,castchange":t=>{var a;let i=(a=globalThis.CastableVideoElement)==null?void 0:a.castElement,c=this.media&&Dt(this.media,i);(t==null?void 0:t.type)==="castchange"&&(t==null?void 0:t.detail)==="CONNECTING"&&(c="connecting"),this.propagateMediaState(j.MEDIA_IS_CASTING,c)},"timeupdate,loadedmetadata":()=>{this.propagateMediaState(j.MEDIA_CURRENT_TIME,ia(this))},"durationchange,loadedmetadata,emptied":()=>{this.propagateMediaState(j.MEDIA_DURATION,na(this))},"loadedmetadata,emptied,progress":()=>{var t;this.propagateMediaState(j.MEDIA_SEEKABLE,(t=aa(this))==null?void 0:t.join(":"))},"progress,emptied":()=>{var t;this.propagateMediaState(j.MEDIA_BUFFERED,Tl((t=this.media)==null?void 0:t.buffered))},"ratechange,loadstart":()=>{this.propagateMediaState(j.MEDIA_PLAYBACK_RATE,sa(this))},"waiting,playing,emptied":()=>{var t;let a=((t=this.media)==null?void 0:t.readyState)<3;this.propagateMediaState(j.MEDIA_LOADING,a)}},this._airplayUnavailable!==it.UNSUPPORTED){let t=a=>{(a==null?void 0:a.availability)==="available"?this._airplayUnavailable=void 0:(a==null?void 0:a.availability)==="not-available"&&(this._airplayUnavailable=it.UNAVAILABLE),this.propagateMediaState(j.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable)};this._mediaStatePropagators.webkitplaybacktargetavailabilitychanged=t}if(this._castUnavailable!==it.UNSUPPORTED){let t=()=>{var a;let i=(a=globalThis.CastableVideoElement)==null?void 0:a.castState;(i==null?void 0:i.includes("CONNECT"))?this._castUnavailable=void 0:this._castUnavailable=it.UNAVAILABLE,this.propagateMediaState(j.MEDIA_CAST_UNAVAILABLE,this._castUnavailable)};this._mediaStatePropagators.castchange=t}this._textTrackMediaStatePropagators={"addtrack,removetrack,loadstart":()=>{this.propagateMediaState(j.MEDIA_CAPTIONS_LIST,Je(wr(this))||void 0),this.propagateMediaState(j.MEDIA_SUBTITLES_LIST,Je(kr(this))||void 0),this.propagateMediaState(j.MEDIA_CAPTIONS_SHOWING,Je(wi(this))||void 0),this.propagateMediaState(j.MEDIA_SUBTITLES_SHOWING,Je(ki(this))||void 0)},change:()=>{this.propagateMediaState(j.MEDIA_CAPTIONS_SHOWING,Je(wi(this))||void 0),this.propagateMediaState(j.MEDIA_SUBTITLES_SHOWING,Je(ki(this))||void 0)}},this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat("nohotkeys")}attributeChangedCallback(e,t,a){e==="nohotkeys"&&(a!==t&&a===""?this.disableHotkeys():a!==t&&a===null&&this.enableHotkeys()),super.attributeChangedCallback(e,t,a)}mediaSetCallback(e){super.mediaSetCallback(e),Object.keys(this._mediaStatePropagators).forEach(t=>{let a=t.split(","),i=this._mediaStatePropagators[t];a.forEach(c=>{(c==Ge.event?this.getRootNode():e).addEventListener(c,i)}),i()}),Object.entries(this._textTrackMediaStatePropagators).forEach(([t,a])=>{t.split(",").forEach(i=>{e.textTracks&&e.textTracks.addEventListener(i,a)}),a()});try{let t=Q.localStorage.getItem("media-chrome-pref-volume");t!==null&&(e.volume=t)}catch(t){console.debug("Error getting volume pref",t)}}mediaUnsetCallback(e){super.mediaUnsetCallback(e),Object.keys(this._mediaStatePropagators).forEach(t=>{let a=t.split(","),i=this._mediaStatePropagators[t];a.forEach(c=>{(c==Ge.event?this.getRootNode():e).removeEventListener(c,i)})}),Object.entries(this._textTrackMediaStatePropagators).forEach(([t,a])=>{t.split(",").forEach(i=>{e.textTracks&&e.textTracks.removeEventListener(i,a)}),a()}),this.propagateMediaState(j.MEDIA_PAUSED,!0)}propagateMediaState(e,t){je(this.mediaStateReceivers,e,t);let a=new Q.CustomEvent(wn[e],{composed:!0,bubbles:!0,detail:t});this.dispatchEvent(a)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let a=this.registerMediaStateReceiver.bind(this),i=this.unregisterMediaStateReceiver.bind(this),c=hl(e,a,i);Object.keys(ne).forEach(R=>{e.addEventListener(ne[R],this[`_handle${Cr(R,!0)}`])}),t.set(e,c)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;!t.has(e)||(t.get(e)(),t.delete(e),Object.keys(ne).forEach(a=>{e.removeEventListener(ne[a],this[`_handle${Cr(a,!0)}`])}))}registerMediaStateReceiver(e){var t;if(!e)return;let a=this.mediaStateReceivers;a.indexOf(e)>-1||(a.push(e),je([e],j.MEDIA_VOLUME_UNAVAILABLE,this._volumeUnavailable),je([e],j.MEDIA_AIRPLAY_UNAVAILABLE,this._airplayUnavailable),je([e],j.MEDIA_CAST_UNAVAILABLE,this._castUnavailable),je([e],j.MEDIA_PIP_UNAVAILABLE,this._pipUnavailable),this.media&&(je([e],j.MEDIA_CAPTIONS_LIST,Je(wr(this))||void 0),je([e],j.MEDIA_SUBTITLES_LIST,Je(kr(this))||void 0),je([e],j.MEDIA_CAPTIONS_SHOWING,Je(wi(this))||void 0),je([e],j.MEDIA_SUBTITLES_SHOWING,Je(ki(this))||void 0),je([e],j.MEDIA_PAUSED,qn(this)),je([e],j.MEDIA_MUTED,ea(this)),je([e],j.MEDIA_VOLUME,ta(this)),je([e],j.MEDIA_VOLUME_LEVEL,ra(this)),je([e],j.MEDIA_IS_FULLSCREEN,this.hasAttribute(j.MEDIA_IS_FULLSCREEN)),je([e],j.MEDIA_IS_CASTING,this.hasAttribute(j.MEDIA_IS_CASTING)),je([e],j.MEDIA_CURRENT_TIME,ia(this)),je([e],j.MEDIA_DURATION,na(this)),je([e],j.MEDIA_SEEKABLE,(t=aa(this))==null?void 0:t.join(":")),je([e],j.MEDIA_PLAYBACK_RATE,sa(this))))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,a=t.indexOf(e);a<0||t.splice(a,1)}enableHotkeys(){this.addEventListener("keydown",Gt(this,Pr,Oi))}disableHotkeys(){this.removeEventListener("keydown",Gt(this,Pr,Oi)),this.removeEventListener("keyup",Gt(this,Vt,sr))}keyboardShortcutHandler(e){var t,a,i,c;if(((c=(i=(t=e.target.getAttribute("keysused"))==null?void 0:t.split(" "))!=null?i:(a=e.target)==null?void 0:a.keysUsed)!=null?c:[]).map(M=>M==="Space"?" ":M).filter(Boolean).includes(e.key))return;let R,E,L,_,y,I=ul;switch(e.key){case" ":case"k":R=this.getAttribute(j.MEDIA_PAUSED)!=null?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new Q.CustomEvent(R,{composed:!0,bubbles:!0}));break;case"m":R=this.getAttribute(j.MEDIA_VOLUME_LEVEL)==="off"?ne.MEDIA_UNMUTE_REQUEST:ne.MEDIA_MUTE_REQUEST,this.dispatchEvent(new Q.CustomEvent(R,{composed:!0,bubbles:!0}));break;case"f":R=this.getAttribute(j.MEDIA_IS_FULLSCREEN)!=null?ne.MEDIA_EXIT_FULLSCREEN_REQUEST:ne.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new Q.CustomEvent(R,{composed:!0,bubbles:!0}));break;case"ArrowLeft":E=this.getAttribute(j.MEDIA_CURRENT_TIME),L=E&&!Number.isNaN(+E)?+E:DEFAULT_TIME,_=Math.max(L-I,0),y=new Q.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:_}),this.dispatchEvent(y);break;case"ArrowRight":E=this.getAttribute(j.MEDIA_CURRENT_TIME),L=E&&!Number.isNaN(+E)?+E:DEFAULT_TIME,_=Math.max(L+I,0),y=new Q.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:_}),this.dispatchEvent(y);break;default:break}}};Vt=new WeakSet,sr=function(f){let{key:e}=f;if(!Jn.includes(e)){this.removeEventListener("keyup",Gt(this,Vt,sr));return}this.keyboardShortcutHandler(f)},Pr=new WeakSet,Oi=function(f){let{metaKey:e,altKey:t,key:a}=f;if(e||t||!Jn.includes(a)){this.removeEventListener("keyup",Gt(this,Vt,sr));return}this.addEventListener("keyup",Gt(this,Vt,sr))};var qn=f=>f.media?f.media.paused:!0,ea=f=>!!(f.media&&f.media.muted),ta=f=>{let e=f.media;return e?e.volume:1},ra=f=>{let e="high";if(!f.media)return e;let{muted:t,volume:a}=f.media;return a===0||t?e="off":a<.5?e="low":a<.75&&(e="medium"),e},ia=f=>{let e=f.media;return e?e.currentTime:0},na=f=>{let e=f==null?void 0:f.media;return Number.isFinite(e==null?void 0:e.duration)?e.duration:NaN},aa=f=>{var e;let t=f==null?void 0:f.media;if(!((e=t==null?void 0:t.seekable)==null?void 0:e.length))return;let a=t.seekable.start(0),i=t.seekable.end(t.seekable.length-1);if(!(!a&&!i))return[Number(a.toFixed(3)),Number(i.toFixed(3))]},sa=f=>{let e=f.media;return e?e.playbackRate:1},kr=f=>Wt(f.media,{kind:Ht.SUBTITLES}),wr=f=>Wt(f.media,{kind:Ht.CAPTIONS}),ki=f=>Wt(f.media,{kind:Ht.SUBTITLES,mode:xt.SHOWING}),wi=f=>Wt(f.media,{kind:Ht.CAPTIONS,mode:xt.SHOWING}),dl=Object.values(j),oa=f=>{var e,t,a,i;let{observedAttributes:c}=f.constructor;!c&&((e=f.nodeName)==null?void 0:e.includes("-"))&&(Q.customElements.upgrade(f),{observedAttributes:c}=f.constructor);let R=(i=(a=(t=f==null?void 0:f.getAttribute)==null?void 0:t.call(f,j.MEDIA_CHROME_ATTRIBUTES))==null?void 0:a.split)==null?void 0:i.call(a,/\s+/);return Array.isArray(c||R)?(c||R).filter(E=>dl.includes(E)):[]},Ui=f=>!!oa(f).length,cl=async(f,e,t)=>(f.isConnected||await ua(0),t==null?f.removeAttribute(e):typeof t=="boolean"?t?f.setAttribute(e,""):f.removeAttribute(e):Number.isNaN(t)?f.removeAttribute(e):f.setAttribute(e,t)),fl=f=>{var e;return!!((e=f.closest)==null?void 0:e.call(f,'*[slot="media"]'))},or=(f,e)=>{if(fl(f))return;let t=(i,c)=>{var R,E;Ui(i)&&c(i);let{children:L=[]}=i!=null?i:{},_=(E=(R=i==null?void 0:i.shadowRoot)==null?void 0:R.children)!=null?E:[];[...L,..._].forEach(y=>or(y,c))},a=f==null?void 0:f.nodeName.toLowerCase();if(a.includes("-")&&!Ui(f)){Q.customElements.whenDefined(a).then(()=>{t(f,e)});return}t(f,e)},je=(f,e,t)=>{f.forEach(a=>{!oa(a).includes(e)||cl(a,e,t)})},hl=(f,e,t)=>{or(f,e);let a=E=>{var L;let _=(L=E==null?void 0:E.composedPath()[0])!=null?L:E.target;e(_)},i=E=>{var L;let _=(L=E==null?void 0:E.composedPath()[0])!=null?L:E.target;t(_)};f.addEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,a),f.addEventListener(ne.UNREGISTER_MEDIA_STATE_RECEIVER,i);let c=E=>{E.forEach(L=>{let{addedNodes:_=[],removedNodes:y=[],type:I,target:M,attributeName:D}=L;I==="childList"?(Array.prototype.forEach.call(_,b=>or(b,e)),Array.prototype.forEach.call(y,b=>or(b,t))):I==="attributes"&&D===j.MEDIA_CHROME_ATTRIBUTES&&(Ui(M)?e(M):t(M))})},R=new MutationObserver(c);return R.observe(f,{childList:!0,attributes:!0,subtree:!0}),()=>{or(f,t),R.disconnect(),f.removeEventListener(ne.REGISTER_MEDIA_STATE_RECEIVER,a),f.removeEventListener(ne.UNREGISTER_MEDIA_STATE_RECEIVER,i)}},Ni,la=()=>{var f,e;return Ni||(Ni=(e=(f=z)==null?void 0:f.createElement)==null?void 0:e.call(f,"video"),Ni)},vl=async(f=la())=>{if(!f)return!1;let e=f.volume;return f.volume=e/2+.1,await ua(0),f.volume!==e},ua=f=>new Promise(e=>setTimeout(e,f)),ml=(f=la())=>typeof(f==null?void 0:f.requestPictureInPicture)=="function",pl=ml(),lr,gl=vl().then(f=>(lr=f,lr)),El=!!Q.WebKitPlaybackTargetAvailabilityEvent,yl=!!Q.chrome;function Tl(f=[]){return Array.from(f).map((e,t)=>[Number(f.start(t).toFixed(3)),Number(f.end(t).toFixed(3))].join(":")).join(" ")}ae("media-controller",Pi);var ur=Pi;var da=z.createElement("template"),ca=`
245
245
  height: var(--thumb-height);
246
246
  width: var(--media-range-thumb-width, 10px);
247
247
  border: var(--media-range-thumb-border, none);
@@ -252,19 +252,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
252
252
  transition: var(--media-range-thumb-transition, none);
253
253
  transform: var(--media-range-thumb-transform, none);
254
254
  opacity: var(--media-range-thumb-opacity, 1);
255
- `,Ai=`
255
+ `,Ur=`
256
256
  width: var(--media-range-track-width, 100%);
257
257
  min-width: 40px;
258
258
  height: var(--track-height);
259
259
  border: var(--media-range-track-border, none);
260
260
  border-radius: var(--media-range-track-border-radius, 0);
261
- background: var(--media-range-track-background-internal, var(--media-range-track-background, #eee));
262
-
261
+ background: var(--media-range-track-progress-internal, var(--media-range-track-background, #eee));
263
262
  box-shadow: var(--media-range-track-box-shadow, none);
264
263
  transition: var(--media-range-track-transition, none);
265
264
  transform: translate(var(--media-range-track-translate-x, 0), var(--media-range-track-translate-y, 0));
266
265
  cursor: pointer;
267
- `;$n.innerHTML=`
266
+ `;da.innerHTML=`
268
267
  <style>
269
268
  :host {
270
269
  --thumb-height: var(--media-range-thumb-height, 10px);
@@ -278,9 +277,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
278
277
  transition: background 0.15s linear;
279
278
  height: 44px;
280
279
  width: 100px;
281
- padding: 0 10px;
282
-
280
+ padding-left: var(--media-range-padding-left, 10px);
281
+ padding-right: var(--media-range-padding-right, 10px);
283
282
  pointer-events: auto;
283
+ /* needed for vertical align issue 1px off */
284
+ font-size: 0;
284
285
  }
285
286
 
286
287
  :host(:hover) {
@@ -304,19 +305,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
304
305
  /* Special styling for WebKit/Blink */
305
306
  input[type=range]::-webkit-slider-thumb {
306
307
  -webkit-appearance: none;
307
- ${Yn}
308
+ ${ca}
308
309
  /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
309
310
  margin-top: calc(calc(0px - var(--thumb-height) + var(--track-height)) / 2);
310
311
  }
311
312
 
312
313
  /* The thumb is not positioned relative to the track in Firefox */
313
314
  input[type=range]::-moz-range-thumb {
314
- ${Yn}
315
+ ${ca}
315
316
  translate: var(--media-range-track-translate-x, 0) var(--media-range-track-translate-y, 0);
316
317
  }
317
318
 
318
- input[type=range]::-webkit-slider-runnable-track { ${Ai} }
319
- input[type=range]::-moz-range-track { ${Ai} }
319
+ input[type=range]::-webkit-slider-runnable-track { ${Ur} }
320
+ input[type=range]::-moz-range-track { ${Ur} }
320
321
  input[type=range]::-ms-track {
321
322
  /* Reset */
322
323
  width: 100%;
@@ -326,7 +327,53 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
326
327
  border-color: transparent;
327
328
  color: transparent;
328
329
 
329
- ${Ai}
330
+ ${Ur}
331
+ }
332
+
333
+ #background,
334
+ #pointer {
335
+ ${Ur}
336
+ width: auto;
337
+ position: absolute;
338
+ top: 50%;
339
+ transform: translate(var(--media-range-track-translate-x, 0px), calc(var(--media-range-track-translate-y, 0px) - 50%));
340
+ left: var(--media-range-padding-left, 10px);
341
+ right: var(--media-range-padding-right, 10px);
342
+ background: var(--media-range-track-background, #333);
343
+ }
344
+
345
+ #pointer {
346
+ min-width: auto;
347
+ right: auto;
348
+ background: var(--media-range-track-pointer-background);
349
+ border-right: var(--media-range-track-pointer-border-right);
350
+ transition: visibility .25s, opacity .25s;
351
+ visibility: hidden;
352
+ opacity: 0;
353
+ }
354
+
355
+ :host(:hover) #pointer {
356
+ transition: visibility .5s, opacity .5s;
357
+ visibility: visible;
358
+ opacity: 1;
359
+ }
360
+
361
+ #hoverzone {
362
+ /* Add z-index so it overlaps the top of the control buttons if they are right under. */
363
+ z-index: 1;
364
+ display: var(--media-time-range-hover-display, none);
365
+ box-sizing: border-box;
366
+ position: absolute;
367
+ left: var(--media-range-padding-left, 10px);
368
+ right: var(--media-range-padding-right, 10px);
369
+ bottom: var(--media-time-range-hover-bottom, -5px);
370
+ height: var(--media-time-range-hover-height, max(calc(100% + 5px), 20px));
371
+ }
372
+
373
+ #range {
374
+ z-index: 2;
375
+ position: relative;
376
+ height: var(--media-range-track-height, 4px);
330
377
  }
331
378
 
332
379
  /*
@@ -358,8 +405,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
358
405
  background-color: #777;
359
406
  }
360
407
  </style>
361
- <input id="range" type="range" min="0" max="1000" step="1" value="0">
362
- `;var Si=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild($n.content.cloneNode(!0)),this.range=this.shadowRoot.querySelector("#range"),this.range.addEventListener("input",this.updateBar.bind(this))}attributeChangedCallback(e,t,l){var n,h;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(n=R==null?void 0:R.unassociateElement)==null||n.call(R,this)}if(l){let R=z.getElementById(l);(h=R==null?void 0:R.associateElement)==null||h.call(R,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let l=z.getElementById(t);(e=l==null?void 0:l.associateElement)==null||e.call(l,this)}this.updateBar()}disconnectedCallback(){var e;if(this.getAttribute(j.MEDIA_CONTROLLER)){let t=z.getElementById(mediaControllerId);(e=t==null?void 0:t.unassociateElement)==null||e.call(t,this)}}updateBar(){let e=this.getBarColors(),t="linear-gradient(to right, ",l=0;e.forEach(n=>{n[1]<l||(t=t+`${n[0]} ${l}%, ${n[0]} ${n[1]}%,`,l=n[1])}),t=t.slice(0,t.length-1)+")",this.style.setProperty("--media-range-track-background-internal",t)}getBarColors(){let e=this.range,t=e.value-e.min,l=e.max-e.min,n=t/l*100;return[["var(--media-range-bar-color, #fff)",n],["var(--media-range-track-background, #333)",100]]}};ne("media-chrome-range",Si);var qt=Si;var zn=z.createElement("template");zn.innerHTML=`
408
+ <div id="background"></div>
409
+ <div id="pointer"></div>
410
+ <div id="hoverzone"></div>
411
+ <input id="range" type="range" min="0" max="1000" step="any" value="0">
412
+ `;var Bi=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(da.content.cloneNode(!0)),this.range=this.shadowRoot.querySelector("#range"),this.range.addEventListener("input",this.updateBar.bind(this))}attributeChangedCallback(e,t,a){var i,c;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(i=R==null?void 0:R.unassociateElement)==null||i.call(R,this)}if(a){let R=z.getElementById(a);(c=R==null?void 0:R.associateElement)==null||c.call(R,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.associateElement)==null||e.call(a,this)}this.updateBar()}disconnectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.unassociateElement)==null||e.call(a,this)}}updatePointerBar(e){let t=this.range.getBoundingClientRect(),a=(e.clientX-t.left)/t.width;a=Math.max(0,Math.min(1,a));let{style:i}=ct(this.shadowRoot,"#pointer");i.setProperty("width",`${a*t.width}px`)}updateBar(){let e=this.getBarColors(),t="linear-gradient(to right, ",a=0;e.forEach(c=>{c[1]<a||(t=t+`${c[0]} ${a}%, ${c[0]} ${c[1]}%,`,a=c[1])}),t=t.slice(0,t.length-1)+")";let{style:i}=ct(this.shadowRoot,":host");i.setProperty("--media-range-track-progress-internal",t)}getBarColors(){let e=this.range,t=e.value-e.min,a=e.max-e.min,i=t/a*100,c=0;if(e.value>e.min&&e.value<e.max){let R=getComputedStyle(this).getPropertyValue("--media-range-thumb-width")||"10px";c=parseInt(R)*(.5-i/100)/e.offsetWidth*100}return[["var(--media-range-bar-color, #fff)",i+c],["transparent",100]]}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};ae("media-chrome-range",Bi);var dr=Bi;var fa=z.createElement("template");fa.innerHTML=`
363
413
  <style>
364
414
  :host {
365
415
  /* Need position to display above video for some reason */
@@ -378,7 +428,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
378
428
  </style>
379
429
 
380
430
  <slot></slot>
381
- `;var Xn=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(zn.content.cloneNode(!0))}attributeChangedCallback(e,t,l){var n,h;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(n=R==null?void 0:R.unassociateElement)==null||n.call(R,this)}if(l){let R=z.getElementById(l);(h=R==null?void 0:R.associateElement)==null||h.call(R,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let l=z.getElementById(t);(e=l==null?void 0:l.associateElement)==null||e.call(l,this)}}disconnectedCallback(){var e;if(this.getAttribute(j.MEDIA_CONTROLLER)){let t=z.getElementById(mediaControllerId);(e=t==null?void 0:t.unassociateElement)==null||e.call(t,this)}}};ne("media-control-bar",Xn);var Qn=z.createElement("template");Qn.innerHTML=`
431
+ `;var ha=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(fa.content.cloneNode(!0))}attributeChangedCallback(e,t,a){var i,c;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(i=R==null?void 0:R.unassociateElement)==null||i.call(R,this)}if(a){let R=z.getElementById(a);(c=R==null?void 0:R.associateElement)==null||c.call(R,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.associateElement)==null||e.call(a,this)}}disconnectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.unassociateElement)==null||e.call(a,this)}}};ae("media-control-bar",ha);var va=z.createElement("template");va.innerHTML=`
382
432
  <style>
383
433
  :host {
384
434
  display: inline-flex;
@@ -421,7 +471,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
421
471
  <span id="container">
422
472
  <slot></slot>
423
473
  </span>
424
- `;var _i=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Qn.content.cloneNode(!0)),this.container=this.shadowRoot.querySelector("#container")}attributeChangedCallback(e,t,l){var n,h;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(n=R==null?void 0:R.unassociateElement)==null||n.call(R,this)}if(l){let R=z.getElementById(l);(h=R==null?void 0:R.associateElement)==null||h.call(R,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let l=z.getElementById(t);(e=l==null?void 0:l.associateElement)==null||e.call(l,this)}}disconnectedCallback(){var e;if(this.getAttribute(j.MEDIA_CONTROLLER)){let t=z.getElementById(mediaControllerId);(e=t==null?void 0:t.unassociateElement)==null||e.call(t,this)}}};ne("media-text-display",_i);var Ut=_i;var Jn=class extends Ut{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME]}attributeChangedCallback(e,t,l){e===j.MEDIA_CURRENT_TIME&&(this.container.innerHTML=ft(l)),super.attributeChangedCallback(e,t,l)}};ne("media-current-time-display",Jn);var Zn=class extends Ut{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_DURATION]}attributeChangedCallback(e,t,l){e===j.MEDIA_DURATION&&(this.container.innerHTML=ft(l)),super.attributeChangedCallback(e,t,l)}};ne("media-duration-display",Zn);var qo="&nbsp;/&nbsp;",el=(v,{timesSep:e=qo}={})=>{var t,l,n;let h=v.getAttribute("remaining")!=null,R=v.getAttribute("show-duration")!=null,T=(t=v.mediaCurrentTime)!=null?t:0,L=(n=(l=v.mediaDuration)!=null?l:v.mediaSeekableEnd)!=null?n:0,_=h?ft(0-(L-T)):ft(T);return R?`${_}${e}${ft(L)}`:_},tl="video not loaded, unknown time.",rl=v=>{let e=v.mediaCurrentTime,t=v.mediaDuration||v.mediaSeekableEnd;if(e==null||t==null){v.setAttribute("aria-valuetext",tl);return}let l=v.hasAttribute("remaining"),n=v.hasAttribute("show-duration"),h=l?Tt(0-(t-e)):Tt(e);if(!n){v.setAttribute("aria-valuetext",h);return}let R=Tt(t),T=`${h} of ${R}`;v.setAttribute("aria-valuetext",T)},qn=class extends Ut{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME,j.MEDIA_DURATION,j.MEDIA_SEEKABLE,"remaining","show-duration"]}connectedCallback(){this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Ge.PLAYBACK_TIME()),this.setAttribute("tabindex",0),super.connectedCallback()}attributeChangedCallback(e,t,l){if([j.MEDIA_CURRENT_TIME,j.MEDIA_DURATION,j.MEDIA_SEEKABLE,"remaining","show-duration"].includes(e)){let n=el(this);rl(this),this.container.innerHTML=n}super.attributeChangedCallback(e,t,l)}get mediaDuration(){let e=this.getAttribute(j.MEDIA_DURATION);return e!=null?+e:void 0}get mediaCurrentTime(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME);return e!=null?+e:void 0}get mediaSeekable(){let e=this.getAttribute(j.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}get mediaSeekableEnd(){var e;let[,t]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t]=(e=this.mediaSeekable)!=null?e:[];return t}};ne("media-time-display",qn);var il=`
474
+ `;var Fi=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(va.content.cloneNode(!0)),this.container=this.shadowRoot.querySelector("#container")}attributeChangedCallback(e,t,a){var i,c;if(e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(i=R==null?void 0:R.unassociateElement)==null||i.call(R,this)}if(a){let R=z.getElementById(a);(c=R==null?void 0:R.associateElement)==null||c.call(R,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.associateElement)==null||e.call(a,this)}}disconnectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.unassociateElement)==null||e.call(a,this)}}};ae("media-text-display",Fi);var gt=Fi;var ma=class extends gt{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME]}attributeChangedCallback(e,t,a){e===j.MEDIA_CURRENT_TIME&&(this.container.innerHTML=nt(a)),super.attributeChangedCallback(e,t,a)}};ae("media-current-time-display",ma);var pa=class extends gt{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_DURATION]}attributeChangedCallback(e,t,a){e===j.MEDIA_DURATION&&(this.container.innerHTML=nt(a)),super.attributeChangedCallback(e,t,a)}};ae("media-duration-display",pa);var bl="&nbsp;/&nbsp;",Al=(f,{timesSep:e=bl}={})=>{var t,a,i;let c=f.getAttribute("remaining")!=null,R=f.getAttribute("show-duration")!=null,E=(t=f.mediaCurrentTime)!=null?t:0,L=(i=(a=f.mediaDuration)!=null?a:f.mediaSeekableEnd)!=null?i:0,_=c?nt(0-(L-E)):nt(E);return R?`${_}${e}${nt(L)}`:_},Sl="video not loaded, unknown time.",_l=f=>{let e=f.mediaCurrentTime,t=f.mediaDuration||f.mediaSeekableEnd;if(e==null||t==null){f.setAttribute("aria-valuetext",Sl);return}let a=f.hasAttribute("remaining"),i=f.hasAttribute("show-duration"),c=a?Lt(0-(t-e)):Lt(e);if(!i){f.setAttribute("aria-valuetext",c);return}let R=Lt(t),E=`${c} of ${R}`;f.setAttribute("aria-valuetext",E)},ga=class extends gt{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME,j.MEDIA_DURATION,j.MEDIA_SEEKABLE,"remaining","show-duration"]}connectedCallback(){this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Ye.PLAYBACK_TIME()),this.setAttribute("tabindex",0),super.connectedCallback()}attributeChangedCallback(e,t,a){if([j.MEDIA_CURRENT_TIME,j.MEDIA_DURATION,j.MEDIA_SEEKABLE,"remaining","show-duration"].includes(e)){let i=Al(this);_l(this),this.container.innerHTML=i}super.attributeChangedCallback(e,t,a)}get mediaDuration(){let e=this.getAttribute(j.MEDIA_DURATION);return e!=null?+e:void 0}get mediaCurrentTime(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME);return e!=null?+e:void 0}get mediaSeekable(){let e=this.getAttribute(j.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}get mediaSeekableEnd(){var e;let[,t]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t]=(e=this.mediaSeekable)!=null?e:[];return t}};ae("media-time-display",ga);var xl=`
425
475
  <svg
426
476
  aria-hidden="true"
427
477
  xmlns:svg="http://www.w3.org/2000/svg"
@@ -451,7 +501,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
451
501
  <path class="icon" d="M 2,20 L 22,20" stroke-width="4" stroke="var(--media-icon-color, #eee)" id="path24"/>
452
502
  </g>
453
503
  </svg>
454
- `,nl=`
504
+ `,Ll=`
455
505
  <svg
456
506
  aria-hidden="true"
457
507
  xmlns:svg="http://www.w3.org/2000/svg"
@@ -480,108 +530,108 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
480
530
  id="path22" />
481
531
  </g>
482
532
  </svg>
483
- `,ea=z.createElement("template");ea.innerHTML=`
533
+ `,Ea=z.createElement("template");Ea.innerHTML=`
484
534
  <style>
485
535
  :host([aria-checked="true"]) slot:not([name=on]) > *,
486
536
  :host([aria-checked="true"]) ::slotted(:not([slot=on])) {
487
- display: none;
537
+ display: none !important;
488
538
  }
489
539
 
490
540
  /* Double negative, but safer if display doesn't equal 'block' */
491
541
  :host(:not([aria-checked="true"])) slot:not([name=off]) > *,
492
542
  :host(:not([aria-checked="true"])) ::slotted(:not([slot=off])) {
493
- display: none;
543
+ display: none !important;
494
544
  }
495
545
  </style>
496
546
 
497
- <slot name="on">${il}</slot>
498
- <slot name="off">${nl}</slot>
499
- `;var ta=v=>{v.setAttribute("aria-checked",ra(v))},ra=v=>{let e=!!v.getAttribute(j.MEDIA_CAPTIONS_SHOWING),t=!v.hasAttribute("no-subtitles-fallback")&&!!v.getAttribute(j.MEDIA_SUBTITLES_SHOWING);return e||t},ia=class extends ke{static get observedAttributes(){return[...super.observedAttributes,"no-subtitles-fallback","default-showing",j.MEDIA_CAPTIONS_LIST,j.MEDIA_CAPTIONS_SHOWING,j.MEDIA_SUBTITLES_LIST,j.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:ea,...e});this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Ge.CLOSED_CAPTIONS()),ta(this)}attributeChangedCallback(e,t,l){if([j.MEDIA_CAPTIONS_SHOWING,j.MEDIA_SUBTITLES_SHOWING].includes(e)&&ta(this),this.hasAttribute("default-showing")&&this.getAttribute("aria-checked")!=="true"){let n=!this.hasAttribute("no-subtitles-fallback");if((n?[j.MEDIA_CAPTIONS_LIST,j.MEDIA_SUBTITLES_LIST]:[j.MEDIA_CAPTIONS_LIST]).includes(e)){let h=!!this.getAttribute(j.MEDIA_CAPTIONS_LIST)||!!(n&&this.getAttribute(j.MEDIA_SUBTITLES_LIST));this._captionsReady!==h&&(this._captionsReady=h,this._captionsReady&&this.handleClick())}}super.attributeChangedCallback(e,t,l)}handleClick(e){var t,l,n,h;if(ra(this)){let R=this.getAttribute(j.MEDIA_CAPTIONS_SHOWING);if(R){let L=new J.CustomEvent(se.MEDIA_DISABLE_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});this.dispatchEvent(L)}let T=this.getAttribute(j.MEDIA_SUBTITLES_SHOWING);if(T&&!this.hasAttribute("no-subtitles-fallback")){let L=new J.CustomEvent(se.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:T});this.dispatchEvent(L)}}else{let[R]=(l=Sr((t=this.getAttribute(j.MEDIA_CAPTIONS_LIST))!=null?t:""))!=null?l:[];if(R){let T=new J.CustomEvent(se.MEDIA_SHOW_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});this.dispatchEvent(T)}else if(this.hasAttribute("no-subtitles-fallback"))console.error("Attempting to enable closed captions but none are available! Please verify your media content if this is unexpected.");else{let[T]=(h=Sr((n=this.getAttribute(j.MEDIA_SUBTITLES_LIST))!=null?n:""))!=null?h:[];if(T){let L=new J.CustomEvent(se.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:T});this.dispatchEvent(L)}}}}};ne("media-captions-button",ia);var xi=30,al=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="-3 -3 24 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(7.4 17.6)">${xi}</text><path d="M8.52,3V0l5.61,4-5.61,4V5A5.54,5.54,0,0,0,6.6,15.48V17.6A7.5,7.5,0,0,1,8.52,3Z"/></svg>`,na=z.createElement("template");na.innerHTML=`
500
- <slot name="forward">${al}</slot>
501
- `;var sl=0,aa=v=>{let e=Math.abs(+v.getAttribute("seek-offset")),t=Ce.SEEK_FORWARD_N_SECS({seekOffset:e});v.setAttribute("aria-label",t)},sa=v=>{let e=br(v,"forward"),t=v.getAttribute("seek-offset");Tr(e,t)},oa=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME,"seek-offset"]}constructor(e={}){super({slotTemplate:na,...e})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",xi),aa(this),sa(this),super.connectedCallback()}attributeChangedCallback(e,t,l){e==="seek-offset"&&(l==null&&this.setAttribute("seek-offset",xi),sa(this),aa(this))}handleClick(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME),t=+this.getAttribute("seek-offset"),l=(e&&!Number.isNaN(+e)?+e:sl)+t,n=new J.CustomEvent(se.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:l});this.dispatchEvent(n)}};ne("media-seek-forward-button",oa);var ol=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
547
+ <slot name="on">${xl}</slot>
548
+ <slot name="off">${Ll}</slot>
549
+ `;var ya=f=>{f.setAttribute("aria-checked",Ta(f))},Ta=f=>{let e=!!f.getAttribute(j.MEDIA_CAPTIONS_SHOWING),t=!f.hasAttribute("no-subtitles-fallback")&&!!f.getAttribute(j.MEDIA_SUBTITLES_SHOWING);return e||t},ba=class extends we{static get observedAttributes(){return[...super.observedAttributes,"no-subtitles-fallback","default-showing",j.MEDIA_CAPTIONS_LIST,j.MEDIA_CAPTIONS_SHOWING,j.MEDIA_SUBTITLES_LIST,j.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Ea,...e});this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Ye.CLOSED_CAPTIONS()),ya(this)}attributeChangedCallback(e,t,a){if([j.MEDIA_CAPTIONS_SHOWING,j.MEDIA_SUBTITLES_SHOWING].includes(e)&&ya(this),this.hasAttribute("default-showing")&&this.getAttribute("aria-checked")!=="true"){let i=!this.hasAttribute("no-subtitles-fallback");if((i?[j.MEDIA_CAPTIONS_LIST,j.MEDIA_SUBTITLES_LIST]:[j.MEDIA_CAPTIONS_LIST]).includes(e)){let c=!!this.getAttribute(j.MEDIA_CAPTIONS_LIST)||!!(i&&this.getAttribute(j.MEDIA_SUBTITLES_LIST));this._captionsReady!==c&&(this._captionsReady=c,this._captionsReady&&this.handleClick())}}super.attributeChangedCallback(e,t,a)}handleClick(e){var t,a,i,c;if(Ta(this)){let R=this.getAttribute(j.MEDIA_CAPTIONS_SHOWING);if(R){let L=new Q.CustomEvent(ne.MEDIA_DISABLE_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});this.dispatchEvent(L)}let E=this.getAttribute(j.MEDIA_SUBTITLES_SHOWING);if(E&&!this.hasAttribute("no-subtitles-fallback")){let L=new Q.CustomEvent(ne.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:E});this.dispatchEvent(L)}}else{let[R]=(a=Or((t=this.getAttribute(j.MEDIA_CAPTIONS_LIST))!=null?t:""))!=null?a:[];if(R){let E=new Q.CustomEvent(ne.MEDIA_SHOW_CAPTIONS_REQUEST,{composed:!0,bubbles:!0,detail:R});this.dispatchEvent(E)}else if(this.hasAttribute("no-subtitles-fallback"))console.error("Attempting to enable closed captions but none are available! Please verify your media content if this is unexpected.");else{let[E]=(c=Or((i=this.getAttribute(j.MEDIA_SUBTITLES_LIST))!=null?i:""))!=null?c:[];if(E){let L=new Q.CustomEvent(ne.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:E});this.dispatchEvent(L)}}}}};ae("media-captions-button",ba);var ji=30,Dl=`<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="-3 -3 24 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(7.4 17.6)">${ji}</text><path d="M8.52,3V0l5.61,4-5.61,4V5A5.54,5.54,0,0,0,6.6,15.48V17.6A7.5,7.5,0,0,1,8.52,3Z"/></svg>`,Aa=z.createElement("template");Aa.innerHTML=`
550
+ <slot name="forward">${Dl}</slot>
551
+ `;var Il=0,Sa=f=>{let e=Math.abs(+f.getAttribute("seek-offset")),t=Pe.SEEK_FORWARD_N_SECS({seekOffset:e});f.setAttribute("aria-label",t)},_a=f=>{let e=Rr(f,"forward"),t=f.getAttribute("seek-offset");Mr(e,t)},xa=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME,"seek-offset"]}constructor(e={}){super({slotTemplate:Aa,...e})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",ji),Sa(this),_a(this),super.connectedCallback()}attributeChangedCallback(e,t,a){e==="seek-offset"&&(a==null&&this.setAttribute("seek-offset",ji),_a(this),Sa(this))}handleClick(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME),t=+this.getAttribute("seek-offset"),a=(e&&!Number.isNaN(+e)?+e:Il)+t,i=new Q.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:a});this.dispatchEvent(i)}};ae("media-seek-forward-button",xa);var Ml=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
502
552
  <path d="M0 0h24v24H0z" fill="none"/>
503
553
  <path class="icon" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
504
- </svg>`,ll=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
554
+ </svg>`,Rl=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
505
555
  <path d="M0 0h24v24H0z" fill="none"/>
506
556
  <path class="icon" d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>
507
- </svg>`,la=z.createElement("template");la.innerHTML=`
557
+ </svg>`,La=z.createElement("template");La.innerHTML=`
508
558
  <style>
509
559
  :host([${j.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]) > *,
510
560
  :host([${j.MEDIA_IS_FULLSCREEN}]) ::slotted(:not([slot=exit])) {
511
- display: none;
561
+ display: none !important;
512
562
  }
513
563
 
514
564
  /* Double negative, but safer if display doesn't equal 'block' */
515
565
  :host(:not([${j.MEDIA_IS_FULLSCREEN}])) slot:not([name=enter]) > *,
516
566
  :host(:not([${j.MEDIA_IS_FULLSCREEN}])) ::slotted(:not([slot=enter])) {
517
- display: none;
567
+ display: none !important;
518
568
  }
519
569
  </style>
520
570
 
521
- <slot name="enter">${ol}</slot>
522
- <slot name="exit">${ll}</slot>
523
- `;var ua=v=>{let e=v.getAttribute(j.MEDIA_IS_FULLSCREEN)!=null?Ce.EXIT_FULLSCREEN():Ce.ENTER_FULLSCREEN();v.setAttribute("aria-label",e)},da=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_IS_FULLSCREEN]}constructor(e={}){super({slotTemplate:la,...e})}connectedCallback(){ua(this),super.connectedCallback()}attributeChangedCallback(e,t,l){e===j.MEDIA_IS_FULLSCREEN&&ua(this),super.attributeChangedCallback(e,t,l)}handleClick(e){let t=this.getAttribute(j.MEDIA_IS_FULLSCREEN)!=null?se.MEDIA_EXIT_FULLSCREEN_REQUEST:se.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new J.CustomEvent(t,{composed:!0,bubbles:!0}))}};ne("media-fullscreen-button",da);var ul='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',ca='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',dl='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',fa=z.createElement("template");fa.innerHTML=`
571
+ <slot name="enter">${Ml}</slot>
572
+ <slot name="exit">${Rl}</slot>
573
+ `;var Da=f=>{let e=f.getAttribute(j.MEDIA_IS_FULLSCREEN)!=null?Pe.EXIT_FULLSCREEN():Pe.ENTER_FULLSCREEN();f.setAttribute("aria-label",e)},Ia=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_IS_FULLSCREEN]}constructor(e={}){super({slotTemplate:La,...e})}connectedCallback(){Da(this),super.connectedCallback()}attributeChangedCallback(e,t,a){e===j.MEDIA_IS_FULLSCREEN&&Da(this),super.attributeChangedCallback(e,t,a)}handleClick(e){let t=this.getAttribute(j.MEDIA_IS_FULLSCREEN)!=null?ne.MEDIA_EXIT_FULLSCREEN_REQUEST:ne.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new Q.CustomEvent(t,{composed:!0,bubbles:!0}))}};ae("media-fullscreen-button",Ia);var Cl='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',Ma='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',Ol='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',Ra=z.createElement("template");Ra.innerHTML=`
524
574
  <style>
525
575
  /* Default to High slot/icon. */
526
576
  :host(:not([${j.MEDIA_VOLUME_LEVEL}])) slot:not([name=high]) > *,
527
577
  :host(:not([${j.MEDIA_VOLUME_LEVEL}])) ::slotted(:not([slot=high])),
528
578
  :host([${j.MEDIA_VOLUME_LEVEL}=high]) slot:not([name=high]) > *,
529
579
  :host([${j.MEDIA_VOLUME_LEVEL}=high]) ::slotted(:not([slot=high])) {
530
- display: none;
580
+ display: none !important;
531
581
  }
532
582
 
533
583
  :host([${j.MEDIA_VOLUME_LEVEL}=off]) slot:not([name=off]) > *,
534
584
  :host([${j.MEDIA_VOLUME_LEVEL}=off]) ::slotted(:not([slot=off])) {
535
- display: none;
585
+ display: none !important;
536
586
  }
537
587
 
538
588
  :host([${j.MEDIA_VOLUME_LEVEL}=low]) slot:not([name=low]) > *,
539
589
  :host([${j.MEDIA_VOLUME_LEVEL}=low]) ::slotted(:not([slot=low])) {
540
- display: none;
590
+ display: none !important;
541
591
  }
542
592
 
543
593
  :host([${j.MEDIA_VOLUME_LEVEL}=medium]) slot:not([name=medium]) > *,
544
594
  :host([${j.MEDIA_VOLUME_LEVEL}=medium]) ::slotted(:not([slot=medium])) {
545
- display: none;
595
+ display: none !important;
546
596
  }
547
597
  </style>
548
598
 
549
- <slot name="off">${ul}</slot>
550
- <slot name="low">${ca}</slot>
551
- <slot name="medium">${ca}</slot>
552
- <slot name="high">${dl}</slot>
553
- `;var ha=v=>{let e=v.getAttribute(j.MEDIA_VOLUME_LEVEL)==="off"?Ce.UNMUTE():Ce.MUTE();v.setAttribute("aria-label",e)},va=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:fa,...e})}connectedCallback(){ha(this),super.connectedCallback()}attributeChangedCallback(e,t,l){e===j.MEDIA_VOLUME_LEVEL&&ha(this),super.attributeChangedCallback(e,t,l)}handleClick(e){let t=this.getAttribute(j.MEDIA_VOLUME_LEVEL)==="off"?se.MEDIA_UNMUTE_REQUEST:se.MEDIA_MUTE_REQUEST;this.dispatchEvent(new J.CustomEvent(t,{composed:!0,bubbles:!0}))}};ne("media-mute-button",va);var ma='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98V5c0-1.1-.9-2-2-2zm0 16.01H3V4.98h18v14.03z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',ga=z.createElement("template");ga.innerHTML=`
599
+ <slot name="off">${Cl}</slot>
600
+ <slot name="low">${Ma}</slot>
601
+ <slot name="medium">${Ma}</slot>
602
+ <slot name="high">${Ol}</slot>
603
+ `;var Ca=f=>{let e=f.getAttribute(j.MEDIA_VOLUME_LEVEL)==="off"?Pe.UNMUTE():Pe.MUTE();f.setAttribute("aria-label",e)},Oa=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Ra,...e})}connectedCallback(){Ca(this),super.connectedCallback()}attributeChangedCallback(e,t,a){e===j.MEDIA_VOLUME_LEVEL&&Ca(this),super.attributeChangedCallback(e,t,a)}handleClick(e){let t=this.getAttribute(j.MEDIA_VOLUME_LEVEL)==="off"?ne.MEDIA_UNMUTE_REQUEST:ne.MEDIA_MUTE_REQUEST;this.dispatchEvent(new Q.CustomEvent(t,{composed:!0,bubbles:!0}))}};ae("media-mute-button",Oa);var Pa='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98V5c0-1.1-.9-2-2-2zm0 16.01H3V4.98h18v14.03z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',ka=z.createElement("template");ka.innerHTML=`
554
604
  <style>
555
605
  :host([${j.MEDIA_IS_PIP}]) slot:not([name=exit]) > *,
556
606
  :host([${j.MEDIA_IS_PIP}]) ::slotted(:not([slot=exit])) {
557
- display: none;
607
+ display: none !important;
558
608
  }
559
609
 
560
610
  /* Double negative, but safer if display doesn't equal 'block' */
561
611
  :host(:not([${j.MEDIA_IS_PIP}])) slot:not([name=enter]) > *,
562
612
  :host(:not([${j.MEDIA_IS_PIP}])) ::slotted(:not([slot=enter])) {
563
- display: none;
613
+ display: none !important;
564
614
  }
565
615
  </style>
566
616
 
567
- <slot name="enter">${ma}</slot>
568
- <slot name="exit">${ma}</slot>
569
- `;var pa=v=>{let e=v.getAttribute(j.MEDIA_IS_PIP)!=null?Ce.EXIT_PIP():Ce.ENTER_PIP();v.setAttribute("aria-label",e)},Ea=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_IS_PIP,j.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:ga,...e})}connectedCallback(){pa(this),super.connectedCallback()}attributeChangedCallback(e,t,l){e===j.MEDIA_IS_PIP&&pa(this),super.attributeChangedCallback(e,t,l)}handleClick(e){let t=this.getAttribute(j.MEDIA_IS_PIP)!=null?se.MEDIA_EXIT_PIP_REQUEST:se.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new J.CustomEvent(t,{composed:!0,bubbles:!0}))}};ne("media-pip-button",Ea);var cl='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M8 5v14l11-7z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',fl='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',ya=z.createElement("template");ya.innerHTML=`
617
+ <slot name="enter">${Pa}</slot>
618
+ <slot name="exit">${Pa}</slot>
619
+ `;var wa=f=>{let e=f.getAttribute(j.MEDIA_IS_PIP)!=null?Pe.EXIT_PIP():Pe.ENTER_PIP();f.setAttribute("aria-label",e)},Ua=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_IS_PIP,j.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:ka,...e})}connectedCallback(){wa(this),super.connectedCallback()}attributeChangedCallback(e,t,a){e===j.MEDIA_IS_PIP&&wa(this),super.attributeChangedCallback(e,t,a)}handleClick(e){let t=this.getAttribute(j.MEDIA_IS_PIP)!=null?ne.MEDIA_EXIT_PIP_REQUEST:ne.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new Q.CustomEvent(t,{composed:!0,bubbles:!0}))}};ae("media-pip-button",Ua);var Pl='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M8 5v14l11-7z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',kl='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path class="icon" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/><path d="M0 0h24v24H0z" fill="none"/></svg>',Na=z.createElement("template");Na.innerHTML=`
570
620
  <style>
571
621
  :host([${j.MEDIA_PAUSED}]) slot[name=pause] > *,
572
622
  :host([${j.MEDIA_PAUSED}]) ::slotted([slot=pause]) {
573
- display: none;
623
+ display: none !important;
574
624
  }
575
625
 
576
626
  :host(:not([${j.MEDIA_PAUSED}])) slot[name=play] > *,
577
627
  :host(:not([${j.MEDIA_PAUSED}])) ::slotted([slot=play]) {
578
- display: none;
628
+ display: none !important;
579
629
  }
580
630
  </style>
581
631
 
582
- <slot name="play">${cl}</slot>
583
- <slot name="pause">${fl}</slot>
584
- `;var Ta=v=>{let e=v.getAttribute(j.MEDIA_PAUSED)!=null?Ce.PLAY():Ce.PAUSE();v.setAttribute("aria-label",e)},ba=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_PAUSED]}constructor(e={}){super({slotTemplate:ya,...e})}connectedCallback(){Ta(this),super.connectedCallback()}attributeChangedCallback(e,t,l){e===j.MEDIA_PAUSED&&Ta(this),super.attributeChangedCallback(e,t,l)}handleClick(e){let t=this.getAttribute(j.MEDIA_PAUSED)!=null?se.MEDIA_PLAY_REQUEST:se.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new J.CustomEvent(t,{composed:!0,bubbles:!0}))}};ne("media-play-button",ba);var Aa=[1,1.25,1.5,1.75,2],Lr=1,Sa=z.createElement("template");Sa.innerHTML=`
632
+ <slot name="play">${Pl}</slot>
633
+ <slot name="pause">${kl}</slot>
634
+ `;var Ba=f=>{let e=f.getAttribute(j.MEDIA_PAUSED)!=null?Pe.PLAY():Pe.PAUSE();f.setAttribute("aria-label",e)},Fa=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_PAUSED]}constructor(e={}){super({slotTemplate:Na,...e})}connectedCallback(){Ba(this),super.connectedCallback()}attributeChangedCallback(e,t,a){e===j.MEDIA_PAUSED&&Ba(this),super.attributeChangedCallback(e,t,a)}handleClick(e){let t=this.getAttribute(j.MEDIA_PAUSED)!=null?ne.MEDIA_PLAY_REQUEST:ne.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new Q.CustomEvent(t,{composed:!0,bubbles:!0}))}};ae("media-play-button",Fa);var ja=[1,1.25,1.5,1.75,2],Nr=1,Ka=z.createElement("template");Ka.innerHTML=`
585
635
  <style>
586
636
  :host {
587
637
  font-size: 14px;
@@ -595,7 +645,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
595
645
  </style>
596
646
 
597
647
  <span id="container"></span>
598
- `;var _a=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_PLAYBACK_RATE,"rates"]}constructor(e={}){super({slotTemplate:Sa,...e});this._rates=Aa,this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${Lr}x`}attributeChangedCallback(e,t,l){if(e==="rates"){let n=(l!=null?l:"").trim().split(/\s*,?\s+/).map(h=>Number(h)).filter(h=>!Number.isNaN(h)).sort((h,R)=>h-R);this._rates=n.length?n:Aa;return}if(e===j.MEDIA_PLAYBACK_RATE){let n=l?+l:Number.NaN,h=Number.isNaN(n)?Lr:n;this.container.innerHTML=`${h}x`,this.setAttribute("aria-label",Ge.PLAYBACK_RATE({playbackRate:h}));return}super.attributeChangedCallback(e,t,l)}handleClick(e){var t,l;let n=+this.getAttribute(j.MEDIA_PLAYBACK_RATE)||Lr,h=(l=(t=this._rates.find(T=>T>n))!=null?t:this._rates[0])!=null?l:Lr,R=new J.CustomEvent(se.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:h});this.dispatchEvent(R)}};ne("media-playback-rate-button",_a);var xa=z.createElement("template");xa.innerHTML=`
648
+ `;var Ha=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_PLAYBACK_RATE,"rates"]}constructor(e={}){super({slotTemplate:Ka,...e});this._rates=ja,this.container=this.shadowRoot.querySelector("#container"),this.container.innerHTML=`${Nr}x`}attributeChangedCallback(e,t,a){if(e==="rates"){let i=(a!=null?a:"").trim().split(/\s*,?\s+/).map(c=>Number(c)).filter(c=>!Number.isNaN(c)).sort((c,R)=>c-R);this._rates=i.length?i:ja;return}if(e===j.MEDIA_PLAYBACK_RATE){let i=a?+a:Number.NaN,c=Number.isNaN(i)?Nr:i;this.container.innerHTML=`${c}x`,this.setAttribute("aria-label",Ye.PLAYBACK_RATE({playbackRate:c}));return}super.attributeChangedCallback(e,t,a)}handleClick(e){var t,a;let i=+this.getAttribute(j.MEDIA_PLAYBACK_RATE)||Nr,c=(a=(t=this._rates.find(E=>E>i))!=null?t:this._rates[0])!=null?a:Nr,R=new Q.CustomEvent(ne.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:c});this.dispatchEvent(R)}};ae("media-playback-rate-button",Ha);var Wa=z.createElement("template");Wa.innerHTML=`
599
649
  <style>
600
650
  :host {
601
651
  pointer-events: none;
@@ -621,75 +671,117 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
621
671
  </style>
622
672
 
623
673
  <img aria-hidden="true" id="image"/>
624
- `;var hl=(v,e)=>{v.style["background-image"]=`url('${e}')`},La=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_HAS_PLAYED,"placeholder-src","src"]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(xa.content.cloneNode(!0)),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,l){e==="src"&&this.image.setAttribute("src",l),e==="placeholder-src"&&hl(this.image,l)}};ne("media-poster-image",La);var vl="video not loaded, unknown time.",Li=v=>{let e=v.range,t=Tt(+e.value),l=Tt(+e.max),n=t&&l?`${t} of ${l}`:vl;e.setAttribute("aria-valuetext",n)},Da=z.createElement("template");Da.innerHTML=`
674
+ `;var wl=(f,e)=>{f.style["background-image"]=`url('${e}')`},Ga=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_HAS_PLAYED,"placeholder-src","src"]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Wa.content.cloneNode(!0)),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,a){e==="src"&&this.image.setAttribute("src",a),e==="placeholder-src"&&wl(this.image,a)}};ae("media-poster-image",Ga);var Ul="video not loaded, unknown time.",Ki=f=>{let e=f.range,t=Lt(+e.value),a=Lt(+e.max),i=t&&a?`${t} of ${a}`:Ul;e.setAttribute("aria-valuetext",i)},Va=z.createElement("template");Va.innerHTML=`
625
675
  <style>
626
- #thumbnailContainer {
676
+ :host {
677
+ --media-preview-background-color: rgba(20,20,30, .5);
678
+ --media-preview-background: var(--media-control-background,
679
+ var(--media-preview-background-color));
680
+ --media-preview-border-radius: 3px;
681
+ --media-box-padding-left: 10px;
682
+ --media-box-padding-right: 10px;
683
+ color: #fff;
684
+ }
685
+
686
+ [part~="box"] {
687
+ display: flex;
688
+ flex-direction: column;
689
+ align-items: center;
627
690
  position: absolute;
628
691
  left: 0;
629
- top: 0;
692
+ bottom: 100%;
693
+ }
694
+
695
+ [part~="preview-box"] {
630
696
  transition: visibility .25s, opacity .25s;
631
697
  visibility: hidden;
632
698
  opacity: 0;
633
699
  }
634
700
 
635
- media-thumbnail-preview {
636
- --thumb-preview-min-width: var(--media-thumbnail-preview-min-width, 120px);
637
- --thumb-preview-max-width: var(--media-thumbnail-preview-max-width, 180px);
638
- --thumb-preview-min-height: var(--media-thumbnail-preview-min-height, 80px);
639
- --thumb-preview-max-height: var(--media-thumbnail-preview-max-height, 160px);
640
- --thumb-preview-border: 2px solid #fff;
641
- transform-origin: 50% 100%;
642
- position: absolute;
643
- bottom: calc(100% + 5px);
644
- border: var(--media-thumbnail-preview-border, var(--thumb-preview-border, 2px solid #fff));
645
- border-radius: var(--media-thumbnail-preview-border-radius, 2px);
646
- background-color: #000;
701
+ media-preview-thumbnail,
702
+ ::slotted(media-preview-thumbnail) {
703
+ visibility: hidden;
704
+ transition: visibility 0s .25s;
705
+ background: var(--media-preview-time-background, var(--media-preview-background));
706
+ box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgba(0,0,0, .2));
707
+ max-width: var(--media-preview-thumbnail-max-width, 180px);
708
+ max-height: var(--media-preview-thumbnail-max-height, 160px);
709
+ min-width: var(--media-preview-thumbnail-min-width, 120px);
710
+ min-height: var(--media-preview-thumbnail-min-height, 80px);
711
+ border: var(--media-preview-thumbnail-border);
712
+ border-radius: var(--media-preview-thumbnail-border-radius,
713
+ var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
647
714
  }
648
715
 
649
- /*
650
- This is a downward triangle. Commented out for now because it would also
651
- require scaling the px properties below in JS; bottom and border-width.
652
- */
653
- /* media-thumbnail-preview::after {
654
- content: "";
655
- display: block;
656
- width: 0;
657
- height: 0;
658
- position: absolute;
659
- left: 50%;
660
- transform: translateX(-50%);
661
- bottom: -10px;
662
- border-left: 10px solid transparent;
663
- border-right: 10px solid transparent;
664
- border-top: 10px solid #fff;
665
- } */
666
-
667
- :host([${j.MEDIA_PREVIEW_IMAGE}]:hover) #thumbnailContainer {
716
+ :host([${j.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
717
+ :host([${j.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) {
718
+ transition-delay: 0s;
719
+ visibility: visible;
720
+ }
721
+
722
+ media-preview-time-display,
723
+ ::slotted(media-preview-time-display) {
724
+ color: unset;
725
+ min-width: 0;
726
+ /* delay changing these CSS props until the preview box transition is ended */
727
+ transition: min-width 0s .25s, border-radius 0s .25s;
728
+ background: var(--media-preview-time-background, var(--media-preview-background));
729
+ border-radius: var(--media-preview-time-border-radius,
730
+ var(--media-preview-border-radius) var(--media-preview-border-radius)
731
+ var(--media-preview-border-radius) var(--media-preview-border-radius));
732
+ padding: var(--media-preview-time-padding, 1px 10px 0);
733
+ margin: var(--media-preview-time-margin, 0 0 10px);
734
+ text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgba(0,0,0, .75));
735
+ }
736
+
737
+ :host([${j.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
738
+ :host([${j.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
739
+ transition-delay: 0s;
740
+ min-width: 100%;
741
+ border-radius: var(--media-preview-time-border-radius,
742
+ 0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
743
+ }
744
+
745
+ :host([${j.MEDIA_PREVIEW_IMAGE}]:hover) [part~="preview-box"],
746
+ :host([${j.MEDIA_PREVIEW_TIME}]:hover) [part~="preview-box"] {
668
747
  transition: visibility .5s, opacity .5s;
669
748
  visibility: visible;
670
749
  opacity: 1;
671
750
  }
751
+
752
+ :host([${j.MEDIA_PREVIEW_TIME}]:hover) {
753
+ --media-time-range-hover-display: block;
754
+ }
672
755
  </style>
673
- <div id="thumbnailContainer">
674
- <media-thumbnail-preview></media-thumbnail-preview>
675
- </div>
676
- `;var Di=class extends qt{static get observedAttributes(){return[...super.observedAttributes,"thumbnails",j.MEDIA_DURATION,j.MEDIA_SEEKABLE,j.MEDIA_CURRENT_TIME,j.MEDIA_PREVIEW_IMAGE,j.MEDIA_BUFFERED]}constructor(){super();this.shadowRoot.appendChild(Da.content.cloneNode(!0)),this.range.addEventListener("input",()=>{let e=this.range.value,t=new J.CustomEvent(se.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}),this.enableThumbnails()}connectedCallback(){this.range.setAttribute("aria-label",Ge.SEEK()),super.connectedCallback()}attributeChangedCallback(e,t,l){var n,h,R,T,L;e===j.MEDIA_CURRENT_TIME&&(this.range.value=this.mediaCurrentTime,Li(this),this.updateBar()),e===j.MEDIA_DURATION&&(this.range.max=Math.floor((h=(n=this.mediaSeekableEnd)!=null?n:this.mediaDuration)!=null?h:1e3),Li(this),this.updateBar()),e===j.MEDIA_SEEKABLE&&(this.range.min=(R=this.mediaSeekableStart)!=null?R:0,this.range.max=Math.floor((L=(T=this.mediaSeekableEnd)!=null?T:this.mediaDuration)!=null?L:1e3),Li(this),this.updateBar()),e===j.MEDIA_BUFFERED&&this.updateBar(),super.attributeChangedCallback(e,t,l)}get mediaDuration(){let e=this.getAttribute(j.MEDIA_DURATION);return e!=null?+e:void 0}get mediaCurrentTime(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME);return e!=null?+e:void 0}get mediaBuffered(){let e=this.getAttribute(j.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(l=>+l)):[]}get mediaSeekable(){let e=this.getAttribute(j.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}get mediaSeekableEnd(){var e;let[,t]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t]=(e=this.mediaSeekable)!=null?e:[];return t}getBarColors(){var e;let t=super.getBarColors(),{range:l}=this,n=this.mediaCurrentTime,h=l.max-l.min,R=this.mediaBuffered;if(!R.length||!Number.isFinite(h)||h<=0)return t;let[,T=l.min]=(e=R.find(([_,E])=>_<=n&&n<=E))!=null?e:[],L=(T-l.min)/h*100;return t.splice(1,0,["var(--media-time-buffered-color, #777)",L]),t}enableThumbnails(){this.thumbnailPreview=this.shadowRoot.querySelector("media-thumbnail-preview"),this.shadowRoot.querySelector("#thumbnailContainer").classList.add("enabled");let e,t=()=>{e=R=>{let T=+this.getAttribute(j.MEDIA_DURATION);if(!T)return;let L=this.range.getBoundingClientRect(),_=(R.clientX-L.left)/L.width;_=Math.max(0,Math.min(1,_));let E=L.left-this.getBoundingClientRect().left+_*L.width,I=getComputedStyle(this.thumbnailPreview),M=parseInt(I.getPropertyValue("--thumb-preview-min-width")),D=parseInt(I.getPropertyValue("--thumb-preview-max-width")),b=parseInt(I.getPropertyValue("--thumb-preview-min-height")),A=parseInt(I.getPropertyValue("--thumb-preview-max-height")),{clientWidth:u,clientHeight:r}=this.thumbnailPreview,s=Math.min(D/u,A/r),i=Math.max(M/u,b/r),a=E-u/2,d=s<1?s:i>1?i:1;this.thumbnailPreview.style.transform=`translateX(${a}px) scale(${d})`;let o=parseInt(I.getPropertyValue("--media-thumbnail-preview-border"));Number.isNaN(o)&&(o=parseInt(I.getPropertyValue("--thumb-preview-border"))),this.thumbnailPreview.style.borderWidth=`${Math.round(o/d)}px`,this.thumbnailPreview.style.borderRadius=`${Math.round(o/d)}px`;let y=_*T,p=new J.CustomEvent(se.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:y});this.dispatchEvent(p)},J.addEventListener("pointermove",e,!1)},l=()=>{J.removeEventListener("pointermove",e);let R=new J.CustomEvent(se.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:null});this.dispatchEvent(R)},n=!1,h=R=>{let T=this.getAttribute(j.MEDIA_DURATION);if(!n&&T){n=!0,t();let L=_=>{_.composedPath().includes(this)||(J.removeEventListener("pointermove",L),n=!1,l())};J.addEventListener("pointermove",L,!1)}};this.addEventListener("pointermove",h,!1)}};ne("media-time-range",Di);var Ii=Di;var Ia=class extends Ii{constructor(){super();console.warn("MediaChrome: <media-progress-range> is deprecated. Use <media-time-range> instead.")}};ne("media-progress-range",Ia);var Mi=30,ml=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="-3 -3 24 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(1.68 17.6)">${Mi}</text><path d="M9.48,3V0L3.87,4l5.61,4V5a5.54,5.54,0,0,1,1.92,10.5V17.6A7.5,7.5,0,0,0,9.48,3Z"/></svg>`,Ma=z.createElement("template");Ma.innerHTML=`
677
- <slot name="backward">${ml}</slot>
678
- `;var gl=0,Ra=v=>{let e=Math.abs(+v.getAttribute("seek-offset")),t=Ce.SEEK_BACK_N_SECS({seekOffset:e});v.setAttribute("aria-label",t)},Oa=v=>{let e=br(v,"backward"),t=v.getAttribute("seek-offset");Tr(e,t)},Ca=class extends ke{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME]}constructor(e={}){super({slotTemplate:Ma,...e})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",Mi),Ra(this),Oa(this),super.connectedCallback()}attributeChangedCallback(e,t,l){e==="seek-offset"&&(l==null&&this.setAttribute("seek-offset",Mi),Oa(this),Ra(this))}handleClick(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME),t=+this.getAttribute("seek-offset"),l=e&&!Number.isNaN(+e)?+e:gl,n=Math.max(l-t,0),h=new J.CustomEvent(se.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:n});this.dispatchEvent(h)}};ne("media-seek-backward-button",Ca);var Pa=z.createElement("template");Pa.innerHTML=`
756
+ <span part="box preview-box">
757
+ <slot name="preview">
758
+ <media-preview-thumbnail></media-preview-thumbnail>
759
+ <media-preview-time-display></media-preview-time-display>
760
+ </slot>
761
+ </span>
762
+ <span part="box current-box">
763
+ <slot name="current">
764
+ <!-- Example: add the current time to the playhead -->
765
+ <!-- <media-current-time-display></media-current-time-display> -->
766
+ </slot>
767
+ </span>
768
+ `;var Hi=class extends dr{static get observedAttributes(){return[...super.observedAttributes,"thumbnails",j.MEDIA_PAUSED,j.MEDIA_DURATION,j.MEDIA_SEEKABLE,j.MEDIA_CURRENT_TIME,j.MEDIA_PREVIEW_IMAGE,j.MEDIA_PREVIEW_TIME,j.MEDIA_BUFFERED,j.MEDIA_PLAYBACK_RATE]}constructor(){super();this.shadowRoot.appendChild(Va.content.cloneNode(!0)),this.range.addEventListener("input",()=>{cancelAnimationFrame(this._refreshId);let e=this.range.value,t=new Q.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}),this._refreshBar=()=>{let e=(performance.now()-this._updateTimestamp)/1e3;this.range.value=this.mediaCurrentTime+e*this.mediaPlaybackRate,this.updateBar(),this.updateCurrentBox(),this._refreshId=requestAnimationFrame(this._refreshBar)},this._enableBoxes()}connectedCallback(){this.range.setAttribute("aria-label",Ye.SEEK()),super.connectedCallback()}disconnectedCallback(){cancelAnimationFrame(this._refreshId),super.disconnectedCallback()}attributeChangedCallback(e,t,a){var i,c,R,E,L;(e===j.MEDIA_CURRENT_TIME||e===j.MEDIA_PAUSED)&&(this._updateTimestamp=performance.now(),this.range.value=this.mediaCurrentTime,Ki(this),this.updateBar(),this.updateCurrentBox(),cancelAnimationFrame(this._refreshId),this.mediaPaused||(this._refreshId=requestAnimationFrame(this._refreshBar))),e===j.MEDIA_DURATION&&(this.range.max=Math.floor((c=(i=this.mediaSeekableEnd)!=null?i:this.mediaDuration)!=null?c:1e3),Ki(this),this.updateBar(),this.updateCurrentBox()),e===j.MEDIA_SEEKABLE&&(this.range.min=(R=this.mediaSeekableStart)!=null?R:0,this.range.max=Math.floor((L=(E=this.mediaSeekableEnd)!=null?E:this.mediaDuration)!=null?L:1e3),Ki(this),this.updateBar()),e===j.MEDIA_BUFFERED&&this.updateBar(),super.attributeChangedCallback(e,t,a)}get mediaPaused(){return this.hasAttribute(j.MEDIA_PAUSED)}get mediaDuration(){let e=this.getAttribute(j.MEDIA_DURATION);return e!=null?+e:void 0}get mediaCurrentTime(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME);return e!=null?+e:void 0}get mediaPlaybackRate(){let e=this.getAttribute(j.MEDIA_PLAYBACK_RATE);return e!=null?+e:1}get mediaBuffered(){let e=this.getAttribute(j.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(a=>+a)):[]}get mediaSeekable(){let e=this.getAttribute(j.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}get mediaSeekableEnd(){var e;let[,t]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t]=(e=this.mediaSeekable)!=null?e:[];return t}getBarColors(){var e;let t=super.getBarColors(),{range:a}=this,i=a.max-a.min,c=this.mediaBuffered;if(!c.length||!Number.isFinite(i)||i<=0)return t;let R=this.mediaCurrentTime,[,E=a.min]=(e=c.find(([_,y])=>_<=R&&R<=y))!=null?e:[],L=(E-a.min)/i*100;return t.splice(1,0,["var(--media-time-buffered-color, rgba(255,255,255, .4))",L]),t}updateCurrentBox(){let e=this.shadowRoot.querySelector('[part~="current-box"]'),t=this.range.value/(this.range.max-this.range.min),a=$a(this,e,t),{style:i}=ct(this.shadowRoot,'[part~="current-box"]');i.transform=`translateX(${a}px)`}_enableBoxes(){let e=this.shadowRoot.querySelectorAll('[part~="box"]'),t=this.shadowRoot.querySelector('[part~="preview-box"]'),a,i=()=>{a=L=>{if([...e].some(u=>L.composedPath().includes(u)))return;this.updatePointerBar(L);let _=+this.getAttribute(j.MEDIA_DURATION);if(!_)return;let y=this.range.getBoundingClientRect(),I=(L.clientX-y.left)/y.width;I=Math.max(0,Math.min(1,I));let M=$a(this,t,I),{style:D}=ct(this.shadowRoot,'[part~="preview-box"]');D.transform=`translateX(${M}px)`;let b=I*_,A=new Q.CustomEvent(ne.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:b});this.dispatchEvent(A)},Q.addEventListener("pointermove",a,!1)},c=()=>{Q.removeEventListener("pointermove",a);let L=new Q.CustomEvent(ne.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:null});this.dispatchEvent(L)},R=!1,E=()=>{let L=this.getAttribute(j.MEDIA_DURATION);if(!R&&L){R=!0,i();let _=y=>{(!y.composedPath().includes(this)||[...e].some(I=>y.composedPath().includes(I)))&&(Q.removeEventListener("pointermove",_),R=!1,c())};Q.addEventListener("pointermove",_,!1)}};this.addEventListener("pointermove",E,!1)}};function $a(f,e,t){var a;let i=f.getBoundingClientRect(),c=f.range.getBoundingClientRect(),R=parseInt(getComputedStyle(f).getPropertyValue("--media-box-padding-left")),E=parseInt(getComputedStyle(f).getPropertyValue("--media-box-padding-right")),L=R+t*c.width,_=e.offsetWidth,y=L-_/2,I=((a=f.getAttribute("media-bounds")?z.getElementById(f.getAttribute("media-bounds")):f.parentElement)!=null?a:f).getBoundingClientRect(),M=i.left-I.left,D=I.right-i.left-_-E,b=R-M;return Math.max(b,Math.min(y,D))}ae("media-time-range",Hi);var Wi=Hi;var Ya=class extends Wi{constructor(){super();console.warn("MediaChrome: <media-progress-range> is deprecated. Use <media-time-range> instead.")}};ae("media-progress-range",Ya);var Gi=30,Nl=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="-3 -3 24 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(1.68 17.6)">${Gi}</text><path d="M9.48,3V0L3.87,4l5.61,4V5a5.54,5.54,0,0,1,1.92,10.5V17.6A7.5,7.5,0,0,0,9.48,3Z"/></svg>`,za=z.createElement("template");za.innerHTML=`
769
+ <slot name="backward">${Nl}</slot>
770
+ `;var Bl=0,Xa=f=>{let e=Math.abs(+f.getAttribute("seek-offset")),t=Pe.SEEK_BACK_N_SECS({seekOffset:e});f.setAttribute("aria-label",t)},Qa=f=>{let e=Rr(f,"backward"),t=f.getAttribute("seek-offset");Mr(e,t)},Za=class extends we{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_CURRENT_TIME]}constructor(e={}){super({slotTemplate:za,...e})}connectedCallback(){this.hasAttribute("seek-offset")||this.setAttribute("seek-offset",Gi),Xa(this),Qa(this),super.connectedCallback()}attributeChangedCallback(e,t,a){e==="seek-offset"&&(a==null&&this.setAttribute("seek-offset",Gi),Qa(this),Xa(this))}handleClick(){let e=this.getAttribute(j.MEDIA_CURRENT_TIME),t=+this.getAttribute("seek-offset"),a=e&&!Number.isNaN(+e)?+e:Bl,i=Math.max(a-t,0),c=new Q.CustomEvent(ne.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i});this.dispatchEvent(c)}};ae("media-seek-backward-button",Za);var Ja=class extends gt{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,a){e===j.MEDIA_PREVIEW_TIME&&a!=null&&(this.container.textContent=nt(a)),super.attributeChangedCallback(e,t,a)}};ae("media-preview-time-display",Ja);var qa=z.createElement("template");qa.innerHTML=`
679
771
  <style>
680
772
  :host {
681
- background-color: #000;
682
- height: auto;
683
- width: auto;
773
+ box-sizing: border-box;
774
+ display: inline-block;
775
+ overflow: hidden;
684
776
  }
685
777
 
686
778
  img {
687
- display: block;
688
- object-fit: none;
779
+ display: none;
780
+ position: relative;
689
781
  }
690
782
  </style>
691
783
  <img crossorigin loading="eager" decoding="async" />
692
- `;var ka=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER,"time",j.MEDIA_PREVIEW_IMAGE,j.MEDIA_PREVIEW_COORDS]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Pa.content.cloneNode(!0))}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let l=z.getElementById(t);(e=l==null?void 0:l.associateElement)==null||e.call(l,this)}}disconnectedCallback(){var e;if(this.getAttribute(j.MEDIA_CONTROLLER)){let t=z.getElementById(mediaControllerId);(e=t==null?void 0:t.unassociateElement)==null||e.call(t,this)}}attributeChangedCallback(e,t,l){var n,h;if(["time",j.MEDIA_PREVIEW_IMAGE,j.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(n=R==null?void 0:R.unassociateElement)==null||n.call(R,this)}if(l){let R=z.getElementById(l);(h=R==null?void 0:R.associateElement)==null||h.call(R,this)}}}update(){let e=this.getAttribute(j.MEDIA_PREVIEW_COORDS),t=this.getAttribute(j.MEDIA_PREVIEW_IMAGE);if(!(e&&t))return;let l=this.shadowRoot.querySelector("img"),[n,h,R,T]=e.split(/\s+/).map(E=>+E),L=t,_=()=>{l.style.height=`${T}px`,l.style["aspect-ratio"]=`${R} / ${T}`};l.src!==L&&(l.onload=_,l.src=L,_()),_(),l.style["object-position"]=`-${n}px -${h}px`}};ne("media-thumbnail-preview",ka);var wa=z.createElement("template"),pl=`
784
+ `;var es=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER,"time",j.MEDIA_PREVIEW_IMAGE,j.MEDIA_PREVIEW_COORDS]}constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(qa.content.cloneNode(!0))}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.associateElement)==null||e.call(a,this)}}disconnectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.unassociateElement)==null||e.call(a,this)}}attributeChangedCallback(e,t,a){var i,c;if(["time",j.MEDIA_PREVIEW_IMAGE,j.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===j.MEDIA_CONTROLLER){if(t){let R=z.getElementById(t);(i=R==null?void 0:R.unassociateElement)==null||i.call(R,this)}if(a){let R=z.getElementById(a);(c=R==null?void 0:R.associateElement)==null||c.call(R,this)}}}update(){let e=this.getAttribute(j.MEDIA_PREVIEW_COORDS),t=this.getAttribute(j.MEDIA_PREVIEW_IMAGE);if(!(e&&t))return;let[a,i,c,R]=e.split(/\s+/).map(l=>+l),E=t.split("#")[0],L=getComputedStyle(this),{maxWidth:_,maxHeight:y,minWidth:I,minHeight:M}=L,D=Math.min(parseInt(_)/c,parseInt(y)/R),b=Math.max(parseInt(I)/c,parseInt(M)/R),A=D<1,u=A?D:b>1?b:1,{style:r}=ct(this.shadowRoot,":host"),o=ct(this.shadowRoot,"img").style,n=this.shadowRoot.querySelector("img"),s=A?"min":"max";r.setProperty(`${s}-width`,"initial","important"),r.setProperty(`${s}-height`,"initial","important"),r.width=`${c*u}px`,r.height=`${R*u}px`;let d=()=>{o.width=`${this.imgWidth*u}px`,o.height=`${this.imgHeight*u}px`,o.display="block"};n.src!==E&&(n.onload=()=>{this.imgWidth=n.naturalWidth,this.imgHeight=n.naturalHeight,d()},n.src=E,d()),d(),o.transform=`translate(-${a*u}px, -${i*u}px)`}};ae("media-preview-thumbnail",es);var ts=z.createElement("template"),Fl=`
693
785
  <svg aria-hidden="true" viewBox="0 0 100 100">
694
786
  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
695
787
  <animateTransform
@@ -702,7 +794,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
702
794
  repeatCount="indefinite" />
703
795
  </path>
704
796
  </svg>
705
- `;wa.innerHTML=`
797
+ `;ts.innerHTML=`
706
798
  <style>
707
799
  :host {
708
800
  display: inline-block;
@@ -739,9 +831,9 @@ svg, img, ::slotted(svg), ::slotted(img) {
739
831
  }
740
832
  </style>
741
833
 
742
- <slot name="loading">${pl}</slot>
743
- <div id="status" role="status" aria-live="polite">${Ge.MEDIA_LOADING()}</div>
744
- `;var El=500,Ua=class extends J.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER,j.MEDIA_PAUSED,j.MEDIA_LOADING,"loading-delay"]}constructor(){super();let e=this.attachShadow({mode:"open"}),t=wa.content.cloneNode(!0);e.appendChild(t)}attributeChangedCallback(e,t,l){var n,h,R;if(e===j.MEDIA_LOADING||e===j.MEDIA_PAUSED){let T=this.getAttribute(j.MEDIA_PAUSED)!=null,L=this.getAttribute(j.MEDIA_LOADING)!=null,_=!T&&L;if(!_)this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0),this.removeAttribute("is-loading");else if(!this.loadingDelayHandle&&_){let E=+((n=this.getAttribute("loading-delay"))!=null?n:El);this.loadingDelayHandle=setTimeout(()=>{this.setAttribute("is-loading",""),this.loadingDelayHandle=void 0},E)}}else if(e===j.MEDIA_CONTROLLER){if(t){let T=z.getElementById(t);(h=T==null?void 0:T.unassociateElement)==null||h.call(T,this)}if(l){let T=z.getElementById(l);(R=T==null?void 0:T.associateElement)==null||R.call(T,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let l=z.getElementById(t);(e=l==null?void 0:l.associateElement)==null||e.call(l,this)}}disconnectedCallback(){var e;if(this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0),this.getAttribute(j.MEDIA_CONTROLLER)){let t=z.getElementById(mediaControllerId);(e=t==null?void 0:t.unassociateElement)==null||e.call(t,this)}}};ne("media-loading-indicator",Ua);var Na=z.createElement("template");Na.innerHTML=`
834
+ <slot name="loading">${Fl}</slot>
835
+ <div id="status" role="status" aria-live="polite">${Ye.MEDIA_LOADING()}</div>
836
+ `;var jl=500,rs=class extends Q.HTMLElement{static get observedAttributes(){return[j.MEDIA_CONTROLLER,j.MEDIA_PAUSED,j.MEDIA_LOADING,"loading-delay"]}constructor(){super();let e=this.attachShadow({mode:"open"}),t=ts.content.cloneNode(!0);e.appendChild(t)}attributeChangedCallback(e,t,a){var i,c,R;if(e===j.MEDIA_LOADING||e===j.MEDIA_PAUSED){let E=this.getAttribute(j.MEDIA_PAUSED)!=null,L=this.getAttribute(j.MEDIA_LOADING)!=null,_=!E&&L;if(!_)this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0),this.removeAttribute("is-loading");else if(!this.loadingDelayHandle&&_){let y=+((i=this.getAttribute("loading-delay"))!=null?i:jl);this.loadingDelayHandle=setTimeout(()=>{this.setAttribute("is-loading",""),this.loadingDelayHandle=void 0},y)}}else if(e===j.MEDIA_CONTROLLER){if(t){let E=z.getElementById(t);(c=E==null?void 0:E.unassociateElement)==null||c.call(E,this)}if(a){let E=z.getElementById(a);(R=E==null?void 0:E.associateElement)==null||R.call(E,this)}}}connectedCallback(){var e;let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.associateElement)==null||e.call(a,this)}}disconnectedCallback(){var e;this.loadingDelayHandle&&(clearTimeout(this.loadingDelayHandle),this.loadingDelayHandle=void 0);let t=this.getAttribute(j.MEDIA_CONTROLLER);if(t){let a=z.getElementById(t);(e=a==null?void 0:a.unassociateElement)==null||e.call(a,this)}}};ae("media-loading-indicator",rs);var is=z.createElement("template");is.innerHTML=`
745
837
  <style>
746
838
  :host {
747
839
 
@@ -749,37 +841,80 @@ svg, img, ::slotted(svg), ::slotted(img) {
749
841
  </style>
750
842
 
751
843
  <slot></slot>
752
- `;var Ba=class extends J.HTMLElement{constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Na.content.cloneNode(!0))}};ne("media-title-bar",Ba);var yl=100,Tl=v=>{var e;if(v.getAttribute(j.MEDIA_MUTED)!=null)return 0;let t=+((e=v.getAttribute(j.MEDIA_VOLUME))!=null?e:1);return Math.round(t*v.range.max)},bl=({value:v,max:e})=>`${Math.round(v/e*100)}%`,Fa=class extends qt{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_VOLUME,j.MEDIA_MUTED,j.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super();this.range.max=yl,this.range.addEventListener("input",()=>{let e=this.range.value/this.range.max,t=new J.CustomEvent(se.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){this.range.setAttribute("aria-label",Ge.VOLUME()),super.connectedCallback()}attributeChangedCallback(e,t,l){if(e===j.MEDIA_VOLUME||e===j.MEDIA_MUTED){let n=Tl(this);this.range.value=n,this.range.setAttribute("aria-valuetext",bl(this.range)),this.updateBar()}super.attributeChangedCallback(e,t,l)}};ne("media-volume-range",Fa);var Al=Object.defineProperty,Sl=(v,e,t)=>e in v?Al(v,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):v[e]=t,_l=(v,e,t)=>(Sl(v,typeof e!="symbol"?e+"":e,t),t),Ri=class extends J.HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){this.render()}render(){this.shadowRoot.textContent="";let e=z.createElement("template");e.innerHTML=this.constructor.template,this.shadowRoot.append(e.content.cloneNode(!0))}get mediaController(){return this.shadowRoot.querySelector("media-controller")}};_l(Ri,"template",""),ne("media-theme",Ri);var ja=class extends Zt{};J.customElements.get("media-chrome")||J.customElements.define("media-chrome",ja);var Ka=class extends Zt{constructor(){super();console.warn("MediaChrome: <media-container> is deprecated. Use <media-controller>.")}};J.customElements.get("media-container")||J.customElements.define("media-container",Ka);var Dr=new Map;function Ir(v){if(Dr.has(v))return Dr.get(v);let e=v.length,t=0,l=0,n=0,h=[];for(let R=0;R<e;R+=1){let T=v[R],L=v[R+1],_=v[R-1];T==="{"&&L==="{"&&_!=="\\"?(n+=1,n===1&&(l=R),R+=1):T==="}"&&L==="}"&&_!=="\\"&&n&&(n-=1,n===0&&(l>t&&(h.push(Object.freeze({type:"string",start:t,end:l,value:v.slice(t,l)})),t=l),h.push(Object.freeze({type:"part",start:l,end:R+2,value:v.slice(t+2,R).trim()})),R+=1,t=R+1))}return t<e&&h.push(Object.freeze({type:"string",start:t,end:e,value:v.slice(t,e)})),Dr.set(v,Object.freeze(h)),Dr.get(v)}var At=new WeakMap,Wa=new WeakMap,it=class{constructor(e,t){this.expression=t,At.set(this,e),e.updateParent("")}get attributeName(){return At.get(this).attr.name}get attributeNamespace(){return At.get(this).attr.namespaceURI}get value(){return Wa.get(this)}set value(e){Wa.set(this,e||""),At.get(this).updateParent(e)}get element(){return At.get(this).element}get booleanValue(){return At.get(this).booleanValue}set booleanValue(e){At.get(this).booleanValue=e}},Mr=class{constructor(e,t){this.element=e,this.attr=t,this.partList=[]}get booleanValue(){return this.element.hasAttributeNS(this.attr.namespaceURI,this.attr.name)}set booleanValue(e){if(this.partList.length!==1)throw new DOMException("Operation not supported","NotSupportedError");this.partList[0].value=e?"":null}append(e){this.partList.push(e)}updateParent(e){if(this.partList.length===1&&e===null)this.element.removeAttributeNS(this.attr.namespaceURI,this.attr.name);else{let t=this.partList.map(l=>typeof l=="string"?l:l.value).join("");this.element.setAttributeNS(this.attr.namespaceURI,this.attr.name,t)}}};var ht=new WeakMap,lt=class{constructor(e,t){this.expression=t,ht.set(this,[e]),e.textContent=""}get value(){return ht.get(this).map(e=>e.textContent).join("")}set value(e){this.replace(e)}get previousSibling(){return ht.get(this)[0].previousSibling}get nextSibling(){return ht.get(this)[ht.get(this).length-1].nextSibling}replace(...e){let t=e.map(l=>typeof l=="string"?new Text(l):l);t.length||t.push(new Text("")),ht.get(this)[0].before(...t);for(let l of ht.get(this))l.remove();ht.set(this,t)}};function er(v){return{processCallback(e,t,l){var n;if(!(typeof l!="object"||!l)){for(let h of t)if(h.expression in l){let R=(n=l[h.expression])!==null&&n!==void 0?n:"";v(h,R)}}}}}function Oi(v,e){v.value=String(e)}function Ha(v,e){return typeof e=="boolean"&&v instanceof it&&typeof v.element[v.attributeName]=="boolean"?(v.booleanValue=e,!0):!1}var Ci=er(Oi),xl=er((v,e)=>{Ha(v,e)||Oi(v,e)});function*Ll(v){let e=v.ownerDocument.createTreeWalker(v,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null,!1),t;for(;t=e.nextNode();)if(t instanceof Element&&t.hasAttributes())for(let l=0;l<t.attributes.length;l+=1){let n=t.attributes.item(l);if(n&&n.value.includes("{{")){let h=new Mr(t,n);for(let R of Ir(n.value))if(R.type==="string")h.append(R.value);else{let T=new it(h,R.value);h.append(T),yield T}}}else if(t instanceof Text&&t.textContent&&t.textContent.includes("{{")){let l=Ir(t.textContent);for(let n=0;n<l.length;n+=1){let h=l[n];h.end<t.textContent.length&&t.splitText(h.end),h.type==="part"&&(yield new lt(t,h.value));break}}}var Rr=new WeakMap,Or=new WeakMap,vt=class extends DocumentFragment{constructor(e,t,l=Ci){var n,h;super();Object.getPrototypeOf(this)!==vt.prototype&&Object.setPrototypeOf(this,vt.prototype),this.appendChild(e.content.cloneNode(!0)),Or.set(this,Array.from(Ll(this))),Rr.set(this,l),(h=(n=Rr.get(this)).createCallback)===null||h===void 0||h.call(n,this,Or.get(this),t),Rr.get(this).processCallback(this,Or.get(this),t)}update(e){Rr.get(this).processCallback(this,Or.get(this),e)}};var tr=new WeakMap,Cr=class{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let l=tr.get(this.element);l&&l.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=tr.get(this.element);t&&t.delete(this.type)}}static for(e){tr.has(e.element)||tr.set(e.element,new Map);let t=e.attributeName.slice(2),l=tr.get(e.element);return l&&l.has(t)?l.get(t):new Cr(e.element,t)}};function Dl(v,e){return v instanceof it&&v.attributeName.startsWith("on")?(Cr.for(v).set(e),v.element.removeAttributeNS(v.attributeNamespace,v.attributeName),!0):!1}function Il(v,e){return e instanceof ki&&v instanceof lt?(e.renderInto(v),!0):!1}function Ml(v,e){return e instanceof DocumentFragment&&v instanceof lt?(e.childNodes.length&&v.replace(...e.childNodes),!0):!1}function Rl(v,e){if(v instanceof it){let t=v.attributeNamespace,l=v.element.getAttributeNS(t,v.attributeName);return String(e)!==l&&(v.value=String(e)),!0}return v.value=String(e),!0}function Ol(v,e){if(typeof e=="boolean"&&v instanceof it){let t=v.attributeNamespace,l=v.element.hasAttributeNS(t,v.attributeName);return e!==l&&(v.booleanValue=e),!0}return!1}function Cl(v,e){return e===!1&&v instanceof lt?(v.replace(""),!0):!1}function Pl(v,e){Ol(v,e)||Dl(v,e)||Cl(v,e)||Il(v,e)||Ml(v,e)||Rl(v,e)}var Pi=new WeakMap,Ga=new WeakMap,Va=new WeakMap,ki=class{constructor(e,t,l){this.strings=e;this.values=t;this.processor=l}get template(){if(Pi.has(this.strings))return Pi.get(this.strings);{let e=document.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((l,n,h)=>l+n+(h<t?`{{ ${h} }}`:""),""),Pi.set(this.strings,e),e}}renderInto(e){let t=this.template;if(Ga.get(e)!==t){Ga.set(e,t);let n=new vt(t,this.values,this.processor);Va.set(e,n),e instanceof lt?e.replace(...n.children):e.appendChild(n);return}let l=Va.get(e);l&&l.update(this.values)}},kl=er(Pl);function _e(v,...e){return new ki(v,e,kl)}function rr(v,e){v.renderInto(e)}function Ve(v,e){let t=document.createElement("template");return t.innerHTML=v,new vt(t,e)}var $a=`
844
+ `;var ns=class extends Q.HTMLElement{constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(is.content.cloneNode(!0))}};ae("media-title-bar",ns);var Kl=100,Hl=f=>{var e;if(f.getAttribute(j.MEDIA_MUTED)!=null)return 0;let t=+((e=f.getAttribute(j.MEDIA_VOLUME))!=null?e:1);return Math.round(t*f.range.max)},Wl=({value:f,max:e})=>`${Math.round(f/e*100)}%`,as=class extends dr{static get observedAttributes(){return[...super.observedAttributes,j.MEDIA_VOLUME,j.MEDIA_MUTED,j.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super();this.range.max=Kl,this.range.addEventListener("input",()=>{let e=this.range.value/this.range.max,t=new Q.CustomEvent(ne.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){this.range.setAttribute("aria-label",Ye.VOLUME()),super.connectedCallback()}attributeChangedCallback(e,t,a){if(e===j.MEDIA_VOLUME||e===j.MEDIA_MUTED){let i=Hl(this);this.range.value=i,this.range.setAttribute("aria-valuetext",Wl(this.range)),this.updateBar()}super.attributeChangedCallback(e,t,a)}};ae("media-volume-range",as);var Gl=Object.defineProperty,Vl=(f,e,t)=>e in f?Gl(f,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[e]=t,$l=(f,e,t)=>(Vl(f,typeof e!="symbol"?e+"":e,t),t),Br=class extends Q.HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){this.render()}render(){this.shadowRoot.textContent="";let e=z.createElement("template");e.innerHTML=this.constructor.template,this.shadowRoot.append(e.content.cloneNode(!0))}get mediaController(){return this.shadowRoot.querySelector("media-controller")}};$l(Br,"template",""),ae("media-theme",Br);var Vi=Br;var ss=class extends ur{};Q.customElements.get("media-chrome")||Q.customElements.define("media-chrome",ss);var os=class extends ur{constructor(){super();console.warn("MediaChrome: <media-container> is deprecated. Use <media-controller>.")}};Q.customElements.get("media-container")||Q.customElements.define("media-container",os);var Yl=Object.defineProperty,zl=(f,e,t)=>e in f?Yl(f,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[e]=t,Fr=(f,e,t)=>(zl(f,typeof e!="symbol"?e+"":e,t),t),$i=(f,e,t)=>{if(!e.has(f))throw TypeError("Cannot "+t)},se=(f,e,t)=>($i(f,e,"read from private field"),t?t.call(f):e.get(f)),De=(f,e,t)=>{if(e.has(f))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(f):e.set(f,t)},Xe=(f,e,t,a)=>($i(f,e,"write to private field"),a?a.call(f,t):e.set(f,t),t),Ke=(f,e,t)=>($i(f,e,"access private method"),t),Xl=()=>{try{return"0.8.4"}catch{}return"UNKNOWN"},Ql=Xl(),Zl=()=>Ql,Jl=f=>{var e,t,a,i,c,R,E,L,_,y,I,M,D,b,A,u,r,o,n,s,d,l,T,g,m,p,v,h,x,S,C,O,P,w,U,k,N,B,K,H;return e=class extends f{constructor(){super();De(this,v),De(this,x),De(this,C),De(this,P),De(this,U),De(this,N),De(this,K),Fr(this,"castEnabled",!1),De(this,d,{paused:!1}),De(this,l,void 0),De(this,T,{}),De(this,g,void 0),De(this,m,void 0),De(this,p,void 0),e.instances.add(this),Ke(this,U,k).call(this)}static get castElement(){return se(e,t)}static get castEnabled(){return se(e,a)}static get castState(){var F;return(F=se(e,_,y))==null?void 0:F.getCastState()}static async exitCast(){let F=!0;try{await se(e,_,y).endCurrentSession(F)}catch(W){console.error(W);return}}get castPlayer(){if(e.castElement===this)return se(this,l)}attributeChangedCallback(F){if(this.castPlayer)switch(F){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(F={}){var W;Ke(W=e,n,s).call(W,F),Xe(e,t,this),Object.entries(se(this,T)).forEach(([Y,$])=>{se(this,l).controller.addEventListener(Y,$)});try{await se(e,_,y).requestSession()}catch{Xe(e,t,void 0);return}se(this,d).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Y){console.error(Y)}}async load(){var F,W;if(!this.castPlayer)return super.load();let Y=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),$=[...this.querySelectorAll("track")].filter(({kind:X,src:ie})=>ie&&(X==="subtitles"||X==="captions")),J=[],q=0;$.length&&(Y.tracks=$.map(X=>{let ie=++q;J.length===0&&X.track.mode==="showing"&&J.push(ie);let fe=new chrome.cast.media.Track(ie,chrome.cast.media.TrackType.TEXT);return fe.trackContentId=X.src,fe.trackContentType="text/vtt",fe.subtype=X.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,fe.name=X.label,fe.language=X.srclang,fe})),this.castStreamType==="live"?Y.streamType=chrome.cast.media.StreamType.LIVE:Y.streamType=chrome.cast.media.StreamType.BUFFERED,Y.metadata=new chrome.cast.media.GenericMediaMetadata,Y.metadata.title=this.title,Y.metadata.images=[{url:this.poster}];let oe=new chrome.cast.media.LoadRequest(Y);oe.currentTime=(F=super.currentTime)!=null?F:0,oe.autoplay=!se(this,d).paused,oe.activeTrackIds=J,await((W=se(e,I,M))==null?void 0:W.loadMedia(oe)),this.dispatchEvent(new Event("volumechange"))}play(){var F;if(this.castPlayer){this.castPlayer.isPaused&&((F=this.castPlayer.controller)==null||F.playOrPause());return}return super.play()}pause(){var F;if(this.castPlayer){this.castPlayer.isPaused||(F=this.castPlayer.controller)==null||F.playOrPause();return}super.pause()}get castSrc(){var F,W,Y;return(Y=(W=this.getAttribute("cast-src"))!=null?W:(F=this.querySelector("source"))==null?void 0:F.src)!=null?Y:this.currentSrc}set castSrc(F){this.castSrc!=F&&this.setAttribute("cast-src",`${F}`)}get castContentType(){var F;return(F=this.getAttribute("cast-content-type"))!=null?F:void 0}set castContentType(F){this.setAttribute("cast-content-type",`${F}`)}get castStreamType(){var F;return(F=this.getAttribute("cast-stream-type"))!=null?F:void 0}set castStreamType(F){this.setAttribute("cast-stream-type",`${F}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var F;return this.castPlayer?(F=this.castPlayer)==null?void 0:F.isMuted:super.muted}set muted(F){var W;if(this.castPlayer){(F&&!this.castPlayer.isMuted||!F&&this.castPlayer.isMuted)&&((W=this.castPlayer.controller)==null||W.muteOrUnmute());return}super.muted=F}get volume(){var F,W;return this.castPlayer?(W=(F=this.castPlayer)==null?void 0:F.volumeLevel)!=null?W:1:super.volume}set volume(F){var W;if(this.castPlayer){this.castPlayer.volumeLevel=F,(W=this.castPlayer.controller)==null||W.setVolumeLevel();return}super.volume=F}get duration(){var F,W;return this.castPlayer&&se(this,v,h)?(W=(F=this.castPlayer)==null?void 0:F.duration)!=null?W:NaN:super.duration}get currentTime(){var F,W;return this.castPlayer&&se(this,v,h)?(W=(F=this.castPlayer)==null?void 0:F.currentTime)!=null?W:0:super.currentTime}set currentTime(F){var W;if(this.castPlayer){this.castPlayer.currentTime=F,(W=this.castPlayer.controller)==null||W.seek();return}super.currentTime=F}get onentercast(){return se(this,g)}set onentercast(F){se(this,g)&&(this.removeEventListener("entercast",se(this,g)),Xe(this,g,null)),typeof F=="function"&&(Xe(this,g,F),this.addEventListener("entercast",F))}get onleavecast(){return se(this,m)}set onleavecast(F){se(this,m)&&(this.removeEventListener("leavecast",se(this,m)),Xe(this,m,null)),typeof F=="function"&&(Xe(this,m,F),this.addEventListener("leavecast",F))}get oncastchange(){return se(this,p)}set oncastchange(F){se(this,p)&&(this.removeEventListener("castchange",se(this,p)),Xe(this,p,null)),typeof F=="function"&&(Xe(this,p,F),this.addEventListener("castchange",F))}},t=new WeakMap,a=new WeakMap,i=new WeakMap,c=new WeakSet,R=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},E=new WeakSet,L=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,y=function(){if(se(e,E,L))return cast.framework.CastContext.getInstance()},I=new WeakSet,M=function(){var F;return(F=se(e,_,y))==null?void 0:F.getCurrentSession()},D=new WeakSet,b=function(){var F;return(F=se(e,I,M))==null?void 0:F.getSessionObj().media[0]},A=new WeakSet,u=function(F){return new Promise((W,Y)=>{se(e,D,b).editTracksInfo(F,W,Y)})},r=new WeakSet,o=function(F){return new Promise((W,Y)=>{se(e,D,b).getStatus(F,W,Y)})},n=new WeakSet,s=function(F){return se(e,_,y).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...F})},d=new WeakMap,l=new WeakMap,T=new WeakMap,g=new WeakMap,m=new WeakMap,p=new WeakMap,v=new WeakSet,h=function(){var F;return(F=this.castPlayer)==null?void 0:F.isMediaLoaded},x=new WeakSet,S=function(){se(e,t)===this&&(Object.entries(se(this,T)).forEach(([F,W])=>{se(this,l).controller.removeEventListener(F,W)}),Xe(e,t,void 0),this.muted=se(this,l).isMuted,this.currentTime=se(this,l).savedPlayerState.currentTime,se(this,l).savedPlayerState.isPaused===!1&&this.play())},C=new WeakSet,O=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:se(e,_,y).getCastState()}))},P=new WeakSet,w=async function(){var F,W;let{SESSION_RESUMED:Y}=cast.framework.SessionState;if(se(e,_,y).getSessionState()===Y&&this.castSrc===((F=se(e,D,b))==null?void 0:F.media.contentId)){Xe(e,t,this),Object.entries(se(this,T)).forEach(([$,J])=>{se(this,l).controller.addEventListener($,J)});try{await Ke(W=e,r,o).call(W,new chrome.cast.media.GetStatusRequest)}catch($){console.error($)}se(this,T)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),se(this,T)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},U=new WeakSet,k=function(){var F;!se(e,E,L)||this.castEnabled||(this.castEnabled=!0,Ke(F=e,n,s).call(F),this.textTracks.addEventListener("change",Ke(this,K,H).bind(this)),Ke(this,C,O).call(this),Xe(this,l,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(se(this,l)),Xe(this,T,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:W})=>{W===!1&&Ke(this,x,S).call(this),this.dispatchEvent(new Event(W?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!se(this,v,h)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var W,Y;((W=this.castPlayer)==null?void 0:W.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Y=this.castPlayer)==null?void 0:Y.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!se(this,v,h)||(await Promise.resolve(),Ke(this,N,B).call(this))}}))},N=new WeakSet,B=function(){Ke(this,K,H).call(this)},K=new WeakSet,H=async function(){var F,W,Y,$,J,q;if(!this.castPlayer)return;let oe=((W=(F=se(this,l).mediaInfo)==null?void 0:F.tracks)!=null?W:[]).filter(({type:Z})=>Z===chrome.cast.media.TrackType.TEXT),X=[...this.textTracks].filter(({kind:Z})=>Z==="subtitles"||Z==="captions"),ie=oe.map(({language:Z,name:te,trackId:ee})=>{var he;let{mode:xe}=(he=X.find(ge=>ge.language===Z&&ge.label===te))!=null?he:{};return xe?{mode:xe,trackId:ee}:!1}).filter(Boolean),fe=ie.filter(({mode:Z})=>Z!=="showing").map(({trackId:Z})=>Z),ue=ie.find(({mode:Z})=>Z==="showing"),_e=(J=($=(Y=se(e,I,M))==null?void 0:Y.getSessionObj().media[0])==null?void 0:$.activeTrackIds)!=null?J:[],re=_e;if(_e.length&&(re=re.filter(Z=>!fe.includes(Z))),(ue==null?void 0:ue.trackId)&&(re=[...re,ue.trackId]),re=[...new Set(re)],!((Z,te)=>Z.length===te.length&&Z.every(ee=>te.includes(ee)))(_e,re))try{let Z=new chrome.cast.media.EditTracksInfoRequest(re);await Ke(q=e,A,u).call(q,Z)}catch(Z){console.error(Z)}},De(e,c),De(e,E),De(e,_),De(e,I),De(e,D),De(e,A),De(e,r),De(e,n),Fr(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Fr(e,"instances",new Set),De(e,t,void 0),De(e,a,!1),Fr(e,"initCast",()=>{var F;se(e,c,R)?se(e,E,L)?se(F=e,i).call(F,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var W;return se(W=e,i).call(W,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var W;return se(W=e,i).call(W,chrome.cast.isAvailable)})}}),De(e,i,F=>{if(F){Xe(e,a,!0);let{CAST_STATE_CHANGED:W}=cast.framework.CastContextEventType;se(e,_,y).addEventListener(W,$=>{e.instances.forEach(J=>{var q;return Ke(q=J,C,O).call(q,$)})});let{SESSION_STATE_CHANGED:Y}=cast.framework.CastContextEventType;se(e,_,y).addEventListener(Y,$=>{e.instances.forEach(J=>{var q;return Ke(q=J,P,w).call(q,$)})}),e.instances.forEach($=>{var J;return Ke(J=$,U,k).call(J)})}}),e},Yi=Jl(HTMLVideoElement);customElements.get("castable-video")||(customElements.define("castable-video",Yi,{extends:"video"}),globalThis.CastableVideoElement=Yi);Yi.initCast();var zi=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],ls=document.createElement("template");ls.innerHTML=`
845
+ <style>
846
+ :host {
847
+ display: inline-block;
848
+ line-height: 0;
849
+ width: auto;
850
+ height: auto;
851
+ }
852
+
853
+ video {
854
+ max-width: 100%;
855
+ max-height: 100%;
856
+ min-width: 100%;
857
+ min-height: 100%;
858
+ }
859
+ </style>
860
+ <video is="castable-video" part="video" crossorigin></video>
861
+ <slot></slot>
862
+ `;var jr,cr,Kr,Hr,Xi,$t=class extends HTMLElement{constructor(){super();De(this,cr),De(this,Hr),De(this,jr,void 0),this.attachShadow({mode:"open"}),this.isConnected&&Ke(this,cr,Kr).call(this)}static get observedAttributes(){let f=[],e=a=>a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(a=>{let i=!1;try{typeof this.prototype[a]=="function"&&(i=!0)}catch{}!i&&a!==a.toUpperCase()&&f.push(a.toLowerCase(),e(a))});let t=Object.getPrototypeOf(this).observedAttributes;return t&&(f=f.concat(t)),f}attributeChangedCallback(f,e,t){Ke(this,cr,Kr).call(this),Ke(this,Hr,Xi).call(this,f,e,t)}connectedCallback(){Ke(this,cr,Kr).call(this)}};jr=new WeakMap,cr=new WeakSet,Kr=function(){if(se(this,jr))return;Xe(this,jr,!0),this.shadowRoot.append(ls.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),zi.forEach(e=>{this.nativeEl.addEventListener(e,t=>{this.dispatchEvent(new CustomEvent(t.type,{detail:t.detail}))})});let f=this.shadowRoot.querySelector("slot");f.addEventListener("slotchange",()=>{f.assignedElements().forEach(e=>{!["track","source"].includes(e.localName)||this.nativeEl.append(e)})}),Array.prototype.forEach.call(this.attributes,e=>{Ke(this,Hr,Xi).call(this,e.name,null,e.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},Hr=new WeakSet,Xi=function(f,e,t){let a=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),i=eu(a,f),c=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;i&&!c?typeof this[i]=="boolean"?t===null?this[i]=!1:this[i]=!0:this[i]=t:t===null?this.nativeEl.removeAttribute(f):["id","class"].indexOf(f)===-1&&this.nativeEl.setAttribute(f,t)};var us=[],ds=document.createElement("video",{is:"castable-video"}),ql=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let f=Object.getPrototypeOf(ds);f&&f!==HTMLElement.prototype;f=Object.getPrototypeOf(f))Object.getOwnPropertyNames(f).forEach(e=>{ql.indexOf(e)===-1&&us.push(e)});us.forEach(f=>{if(!(f in $t.prototype))if(typeof ds[f]=="function")$t.prototype[f]=function(){return this.nativeEl[f].apply(this.nativeEl,arguments)};else{let e={get(){return this.nativeEl[f]}};f!==f.toUpperCase()&&(e.set=function(t){this.nativeEl[f]=t}),Object.defineProperty($t.prototype,f,e)}});function eu(f,e){let t=null;return f.forEach(a=>{a.toLowerCase()==e.toLowerCase()&&(t=a)}),t}globalThis.customElements.get("custom-video")||(globalThis.customElements.define("custom-video",$t),globalThis.CustomVideoElement=$t);var cs=$t,me={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_MSE:"prefer-mse",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},tu=Object.values(me),ru=Zl(),iu="mux-video",Qi=class extends cs{constructor(){super();this.__metadata={},this.__playerInitTime=Mn()}static get observedAttributes(){var f;return[...tu,...(f=cs.observedAttributes)!=null?f:[]]}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){var f;return(f=this.__playerSoftwareName)!=null?f:iu}set playerSoftwareName(f){this.__playerSoftwareName=f}get playerSoftwareVersion(){var f;return(f=this.__playerSoftwareVersion)!=null?f:ru}set playerSoftwareVersion(f){this.__playerSoftwareVersion=f}get hls(){return console.warn("<mux-video>.hls is deprecated, please use ._hls instead"),this._hls}get _hls(){return this.__hls}get mux(){return this.nativeEl.mux}get error(){var f;return(f=On(this.nativeEl))!=null?f:null}get errorTranslator(){return this.__errorTranslator}set errorTranslator(f){this.__errorTranslator=f}get src(){return this.getAttribute("src")}set src(f){f!==this.src&&(f==null?this.removeAttribute("src"):this.setAttribute("src",f))}get type(){var f;return(f=this.getAttribute(me.TYPE))!=null?f:void 0}set type(f){f!==this.type&&(f?this.setAttribute(me.TYPE,f):this.removeAttribute(me.TYPE))}get autoplay(){let f=this.getAttribute("autoplay");return f===null?!1:f===""?!0:f}set autoplay(f){let e=this.autoplay;f!==e&&(f?this.setAttribute("autoplay",typeof f=="string"?f:""):this.removeAttribute("autoplay"))}get debug(){return this.getAttribute(me.DEBUG)!=null}set debug(f){f!==this.debug&&(f?this.setAttribute(me.DEBUG,""):this.removeAttribute(me.DEBUG))}get startTime(){let f=this.getAttribute(me.START_TIME);if(f==null)return;let e=+f;return Number.isNaN(e)?void 0:e}set startTime(f){f!==this.startTime&&(f==null?this.removeAttribute(me.START_TIME):this.setAttribute(me.START_TIME,`${f}`))}get playbackId(){var f;return(f=this.getAttribute(me.PLAYBACK_ID))!=null?f:void 0}set playbackId(f){f!==this.playbackId&&(f?this.setAttribute(me.PLAYBACK_ID,f):this.removeAttribute(me.PLAYBACK_ID))}get customDomain(){var f;return(f=this.getAttribute(me.CUSTOM_DOMAIN))!=null?f:void 0}set customDomain(f){f!==this.customDomain&&(f?this.setAttribute(me.CUSTOM_DOMAIN,f):this.removeAttribute(me.CUSTOM_DOMAIN))}get envKey(){var f;return(f=this.getAttribute(me.ENV_KEY))!=null?f:void 0}set envKey(f){f!==this.envKey&&(f?this.setAttribute(me.ENV_KEY,f):this.removeAttribute(me.ENV_KEY))}get beaconCollectionDomain(){var f;return(f=this.getAttribute(me.BEACON_COLLECTION_DOMAIN))!=null?f:void 0}set beaconCollectionDomain(f){f!==this.beaconCollectionDomain&&(f?this.setAttribute(me.BEACON_COLLECTION_DOMAIN,f):this.removeAttribute(me.BEACON_COLLECTION_DOMAIN))}get streamType(){var f;return(f=this.getAttribute(me.STREAM_TYPE))!=null?f:void 0}set streamType(f){f!==this.streamType&&(f?this.setAttribute(me.STREAM_TYPE,f):this.removeAttribute(me.STREAM_TYPE))}get preferMse(){return this.getAttribute(me.PREFER_MSE)!=null}set preferMse(f){f?this.setAttribute(me.PREFER_MSE,""):this.removeAttribute(me.PREFER_MSE)}get metadata(){let f=this.getAttribute(me.METADATA_VIDEO_ID),e=this.getAttribute(me.METADATA_VIDEO_TITLE),t=this.getAttribute(me.METADATA_VIEWER_USER_ID);return{...this.__metadata,...f!=null?{video_id:f}:{},...e!=null?{video_title:e}:{},...t!=null?{viewer_user_id:t}:{}}}set metadata(f){this.__metadata=f!=null?f:{},this.mux&&this.mux.emit("hb",this.__metadata)}load(){let f=kn(this,this.nativeEl,this.__hls);this.__hls=f;let e=xn(this.nativeEl,this.autoplay,f);this.__updateAutoplay=e}unload(){Di(this.nativeEl,this.__hls),this.__hls=void 0}attributeChangedCallback(f,e,t){var a;switch(super.attributeChangedCallback(f,e,t),f){case me.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case me.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":let i=!!e,c=!!t;!i&&c?this.load():i&&!c?this.unload():i&&c&&(this.unload(),this.load());break;case"autoplay":if(t===e)break;(a=this.__updateAutoplay)==null||a.call(this,this.autoplay);break;case me.PLAYBACK_ID:this.src=Rn(t!=null?t:void 0,{domain:this.customDomain});break;case me.DEBUG:let R=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=R);break;case me.METADATA_URL:t&&fetch(t).then(E=>E.json()).then(E=>this.metadata=E).catch(E=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;default:break}}disconnectedCallback(){this.unload()}};globalThis.customElements.get("mux-video")||(globalThis.customElements.define("mux-video",Qi),globalThis.MuxVideoElement=Qi);var fs=Qi;var nu="en",It={code:nu};var hs="en";function pe(f,e=!0){var i,c;let t=e&&(c=(i=It)==null?void 0:i[f])!=null?c:f,a=e?It.code:hs;return new vs(t,a)}var vs=class{constructor(e,t=(a=>(a=It.code)!=null?a:hs)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,a)=>{var i;return(i=e[a])!=null?i:""})}toString(){return this.message}};function ms(f){let e="";return Object.entries(f).forEach(([t,a])=>{a!=null&&(e+=`${au(t)}: ${a}; `)}),e?e.trim():void 0}function au(f){return f.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function ps(f){return f.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Mt(f){if(f==null)return;let e=+f;return Number.isNaN(e)?void 0:e}function Wr(f){let e=su(f).toString();return e?"?"+e:""}function su(f){let e={};for(let t in f)f[t]!=null&&(e[t]=f[t]);return new URLSearchParams(e)}function fr(f){let t=f.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),a=decodeURIComponent(atob(t).split("").map(function(i){return"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(a)}var Zi=(f,e)=>!f||!e?!1:f.contains(e)?!0:Zi(f,e.getRootNode().host);var Ji="mux.com",ou=()=>{try{return"0.1.0-beta.26"}catch{}return"UNKNOWN"},lu=ou(),Gr=()=>lu,qi=(f,{token:e,domain:t=Ji}={})=>`https://stream.${t}/${f}.m3u8${Wr(!!e?{token:e}:{redundant_streams:!0})}`,gs=(f,{token:e,thumbnailTime:t,domain:a=Ji}={})=>{let i=e==null?t:void 0;return`https://image.${a}/${f}/thumbnail.jpg${Wr({token:e,time:i})}`},Es=(f,{token:e,domain:t=Ji}={})=>`https://image.${t}/${f}/storyboard.vtt${Wr({token:e})}`;function en(f){if(f&&/^media-theme-[\w-]+$/.test(f))return f}var uu={crossorigin:"crossOrigin",playsinline:"playsInline"};function ys(f){var e;return(e=uu[f])!=null?e:ps(f)}var Ts=f=>{var t,a;let{media:e}=f;return(a=(t=e==null?void 0:e._hls)==null?void 0:t.liveSyncPosition)!=null?a:(e==null?void 0:e.seekable.length)?e==null?void 0:e.seekable.end(e.seekable.length-1):void 0},tn=f=>{let e=Ts(f);if(e==null){console.warn("attempting to seek to live but cannot determine live edge time!");return}f.currentTime=e},du=1,cu=5,bs=3,As=.5,Ss=f=>{var c;let{streamType:e}=f,t=Ts(f),a=(c=f.media)==null?void 0:c.currentTime;if(t==null||a==null)return!1;let i=t-a;return e===ve.LL_LIVE||e===ve.LL_DVR?i<=du*(bs+As):e===ve.LIVE||e===ve.DVR?i<=cu*(bs+As):!1};var _s=`[mux-player ${Gr()}]`;function at(...f){console.warn(_s,...f)}function Et(...f){console.error(_s,...f)}function Vr(f){var t;let e=(t=f.message)!=null?t:"";if(f.file){let a="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${pe("Read more: ")}
863
+ ${a}${f.file}`}at(e)}var ke={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",SRC:"src",POSTER:"poster",PRELOAD:"preload"},Rt={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},fu=zi.filter(f=>f!=="error"),hu=Object.values(ke),vu=Object.values(Rt);function xs(f){f.querySelectorAll(":scope > track").forEach(e=>{var t;(t=f.media)==null||t.append(e.cloneNode())}),fu.forEach(e=>{var t;(t=f.media)==null||t.addEventListener(e,a=>{f.dispatchEvent(new Event(a.type))})})}var Ls=class extends HTMLElement{static get observedAttributes(){return[...hu,...vu]}constructor(){super();this.querySelectorAll(":scope > track").forEach(a=>{var i;(i=this.media)==null||i.append(a.cloneNode())});let e=a=>{for(let i of a)i.type==="childList"&&(i.removedNodes.forEach(c=>{var E,L;let R=(E=this.media)==null?void 0:E.querySelector(`track[src="${c.src}"]`);R&&((L=this.media)==null||L.removeChild(R))}),i.addedNodes.forEach(c=>{var R;(R=this.media)==null||R.append(c.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,a){switch(e){case Rt.MUTED:{this.media&&(this.media.muted=a!=null,this.media.defaultMuted=a!=null);return}case Rt.VOLUME:{let i=+a;this.media&&!Number.isNaN(i)&&(this.media.volume=i);return}case Rt.PLAYBACKRATE:{let i=+a;this.media&&!Number.isNaN(i)&&(this.media.playbackRate=i,this.media.defaultPlaybackRate=i);return}}}play(){var e;return(e=this.media)==null?void 0:e.play()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get video(){return at("<mux-player>.video is deprecated, please use .media instead"),this.media}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e;return(e=this.media)==null?void 0:e.buffered}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e;return(e=this.media)==null?void 0:e.videoWidth}get videoHeight(){var e;return(e=this.media)==null?void 0:e.videoHeight}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get src(){return yt(this,ke.SRC)}set src(e){this.setAttribute(ke.SRC,`${e}`)}get poster(){var e;return(e=yt(this,ke.POSTER))!=null?e:""}set poster(e){this.setAttribute(ke.POSTER,`${e}`)}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=Mt(this.getAttribute(Rt.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(Rt.PLAYBACKRATE,`${e}`):this.removeAttribute(Rt.PLAYBACKRATE)}get crossOrigin(){return yt(this,ke.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(ke.CROSSORIGIN,`${e}`)}get autoplay(){return yt(this,ke.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(ke.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(ke.AUTOPLAY)}get loop(){return yt(this,ke.LOOP)!=null}set loop(e){e?this.setAttribute(ke.LOOP,""):this.removeAttribute(ke.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=Boolean(e))}get defaultMuted(){return yt(this,ke.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(ke.MUTED,""):this.removeAttribute(ke.MUTED)}get playsInline(){return yt(this,ke.PLAYSINLINE)!=null}set playsInline(e){e?this.setAttribute(ke.PLAYSINLINE,""):this.removeAttribute(ke.PLAYSINLINE)}get preload(){return yt(this,ke.PRELOAD)}set preload(e){e?this.setAttribute(ke.PRELOAD,e):this.removeAttribute(ke.PRELOAD)}};function yt(f,e){return f.media?f.media.getAttribute(e):f.getAttribute(e)}var rn=Ls;var $r=new Map;function Yr(f){if($r.has(f))return $r.get(f);let e=f.length,t=0,a=0,i=0,c=[];for(let R=0;R<e;R+=1){let E=f[R],L=f[R+1],_=f[R-1];E==="{"&&L==="{"&&_!=="\\"?(i+=1,i===1&&(a=R),R+=1):E==="}"&&L==="}"&&_!=="\\"&&i&&(i-=1,i===0&&(a>t&&(c.push(Object.freeze({type:"string",start:t,end:a,value:f.slice(t,a)})),t=a),c.push(Object.freeze({type:"part",start:a,end:R+2,value:f.slice(t+2,R).trim()})),R+=1,t=R+1))}return t<e&&c.push(Object.freeze({type:"string",start:t,end:e,value:f.slice(t,e)})),$r.set(f,Object.freeze(c)),$r.get(f)}var Ct=new WeakMap,Ds=new WeakMap,st=class{constructor(e,t){this.expression=t,Ct.set(this,e),e.updateParent("")}get attributeName(){return Ct.get(this).attr.name}get attributeNamespace(){return Ct.get(this).attr.namespaceURI}get value(){return Ds.get(this)}set value(e){Ds.set(this,e||""),Ct.get(this).updateParent(e)}get element(){return Ct.get(this).element}get booleanValue(){return Ct.get(this).booleanValue}set booleanValue(e){Ct.get(this).booleanValue=e}},zr=class{constructor(e,t){this.element=e,this.attr=t,this.partList=[]}get booleanValue(){return this.element.hasAttributeNS(this.attr.namespaceURI,this.attr.name)}set booleanValue(e){if(this.partList.length!==1)throw new DOMException("Operation not supported","NotSupportedError");this.partList[0].value=e?"":null}append(e){this.partList.push(e)}updateParent(e){if(this.partList.length===1&&e===null)this.element.removeAttributeNS(this.attr.namespaceURI,this.attr.name);else{let t=this.partList.map(a=>typeof a=="string"?a:a.value).join("");this.element.setAttributeNS(this.attr.namespaceURI,this.attr.name,t)}}};var Tt=new WeakMap,ft=class{constructor(e,t){this.expression=t,Tt.set(this,[e]),e.textContent=""}get value(){return Tt.get(this).map(e=>e.textContent).join("")}set value(e){this.replace(e)}get previousSibling(){return Tt.get(this)[0].previousSibling}get nextSibling(){return Tt.get(this)[Tt.get(this).length-1].nextSibling}replace(...e){let t=e.map(a=>typeof a=="string"?new Text(a):a);t.length||t.push(new Text("")),Tt.get(this)[0].before(...t);for(let a of Tt.get(this))a.remove();Tt.set(this,t)}};function hr(f){return{processCallback(e,t,a){var i;if(!(typeof a!="object"||!a)){for(let c of t)if(c.expression in a){let R=(i=a[c.expression])!==null&&i!==void 0?i:"";f(c,R)}}}}}function nn(f,e){f.value=String(e)}function Is(f,e){return typeof e=="boolean"&&f instanceof st&&typeof f.element[f.attributeName]=="boolean"?(f.booleanValue=e,!0):!1}var an=hr(nn),mu=hr((f,e)=>{Is(f,e)||nn(f,e)});function*pu(f){let e=f.ownerDocument.createTreeWalker(f,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null,!1),t;for(;t=e.nextNode();)if(t instanceof Element&&t.hasAttributes())for(let a=0;a<t.attributes.length;a+=1){let i=t.attributes.item(a);if(i&&i.value.includes("{{")){let c=new zr(t,i);for(let R of Yr(i.value))if(R.type==="string")c.append(R.value);else{let E=new st(c,R.value);c.append(E),yield E}}}else if(t instanceof Text&&t.textContent&&t.textContent.includes("{{")){let a=Yr(t.textContent);for(let i=0;i<a.length;i+=1){let c=a[i];c.end<t.textContent.length&&t.splitText(c.end),c.type==="part"&&(yield new ft(t,c.value));break}}}var Xr=new WeakMap,Qr=new WeakMap,bt=class extends DocumentFragment{constructor(e,t,a=an){var i,c;super();Object.getPrototypeOf(this)!==bt.prototype&&Object.setPrototypeOf(this,bt.prototype),this.appendChild(e.content.cloneNode(!0)),Qr.set(this,Array.from(pu(this))),Xr.set(this,a),(c=(i=Xr.get(this)).createCallback)===null||c===void 0||c.call(i,this,Qr.get(this),t),Xr.get(this).processCallback(this,Qr.get(this),t)}update(e){Xr.get(this).processCallback(this,Qr.get(this),e)}};var vr=new WeakMap,Zr=class{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let a=vr.get(this.element);a&&a.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=vr.get(this.element);t&&t.delete(this.type)}}static for(e){vr.has(e.element)||vr.set(e.element,new Map);let t=e.attributeName.slice(2),a=vr.get(e.element);return a&&a.has(t)?a.get(t):new Zr(e.element,t)}};function gu(f,e){return f instanceof st&&f.attributeName.startsWith("on")?(Zr.for(f).set(e),f.element.removeAttributeNS(f.attributeNamespace,f.attributeName),!0):!1}function Eu(f,e){return e instanceof Jr&&f instanceof ft?(e.renderInto(f),!0):!1}function yu(f,e){return e instanceof DocumentFragment&&f instanceof ft?(e.childNodes.length&&f.replace(...e.childNodes),!0):!1}function Tu(f,e){if(f instanceof st){let t=f.attributeNamespace,a=f.element.getAttributeNS(t,f.attributeName);return String(e)!==a&&(f.value=String(e)),!0}return f.value=String(e),!0}function bu(f,e){if(typeof e=="boolean"&&f instanceof st){let t=f.attributeNamespace,a=f.element.hasAttributeNS(t,f.attributeName);return e!==a&&(f.booleanValue=e),!0}return!1}function Au(f,e){return e===!1&&f instanceof ft?(f.replace(""),!0):!1}function Su(f,e){bu(f,e)||gu(f,e)||Au(f,e)||Eu(f,e)||yu(f,e)||Tu(f,e)}var sn=new WeakMap,Ms=new WeakMap,Rs=new WeakMap,Jr=class{constructor(e,t,a){this.strings=e;this.values=t;this.processor=a}get template(){if(sn.has(this.strings))return sn.get(this.strings);{let e=document.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((a,i,c)=>a+i+(c<t?`{{ ${c} }}`:""),""),sn.set(this.strings,e),e}}renderInto(e){let t=this.template;if(Ms.get(e)!==t){Ms.set(e,t);let i=new bt(t,this.values,this.processor);Rs.set(e,i),e instanceof ft?e.replace(...i.children):e.appendChild(i);return}let a=Rs.get(e);a&&a.update(this.values)}},Cs=new Map,_u=hr(Su);function Te(f,...e){let t=[""],a=[],i,c=!1,R=(E,L=[])=>{t[t.length-1]=t[t.length-1]+E[0],L.forEach((_,y)=>{(i=_==null?void 0:_.$static$)!==void 0?(i.forEach(I=>{R(I.strings,I.values)}),t[t.length-1]=t[t.length-1]+E[y+1],c=!0):(a.push(_),t.push(E[y+1]))})};if(R(f,e),c){let E=t.join("$$html$$");f=Cs.get(E),f===void 0&&(t.raw=t,Cs.set(E,f=t)),e=a}return new Jr(f,e,_u)}function qr(f,e){f.renderInto(e)}function He(f,e){let t=document.createElement("template");return t.innerHTML=f,new bt(t,e)}var on=(...f)=>({$static$:f.map(e=>e instanceof Jr?e:/\w-/.test(e)?{strings:[e]}:{strings:[]})});var Os=`
753
864
  :host {
754
865
  cursor: pointer;
755
866
  }
756
867
  media-time-display {
757
868
  color: inherit;
758
869
  }
759
- `,Ya=document.createElement("template");Ya.innerHTML=`
870
+ `,Ps=document.createElement("template");Ps.innerHTML=`
760
871
  <style>
761
- ${$a}
872
+ ${Os}
762
873
  </style>
763
874
  <media-time-display show-duration></media-time-display>
764
- `;var za=["Enter"," "],ir=class extends HTMLElement{constructor(){super();var e,t;this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0)),this.timeDisplayEl=(t=this.shadowRoot)==null?void 0:t.querySelector("media-time-display")}toggleTimeDisplay(){var e,t,l;((e=this.timeDisplayEl)==null?void 0:e.hasAttribute("remaining"))?(t=this.timeDisplayEl)==null||t.removeAttribute("remaining"):(l=this.timeDisplayEl)==null||l.setAttribute("remaining","")}connectedCallback(){let e=t=>{let{key:l}=t;if(!za.includes(l)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",t=>{let{metaKey:l,altKey:n,key:h}=t;if(l||n||!za.includes(h)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)}),this.addEventListener("click",this.toggleTimeDisplay)}};ir.styles=$a,ir.template=Ya;globalThis.customElements.get("mxp-time-display")||(globalThis.customElements.define("mxp-time-display",ir),globalThis.MxpTimeDisplay=ir);var Xa=`:host(:not([audio])) {
875
+ `;var ks=["Enter"," "],mr=class extends HTMLElement{constructor(){super();var e,t;this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0)),this.timeDisplayEl=(t=this.shadowRoot)==null?void 0:t.querySelector("media-time-display")}toggleTimeDisplay(){var e,t,a;((e=this.timeDisplayEl)==null?void 0:e.hasAttribute("remaining"))?(t=this.timeDisplayEl)==null||t.removeAttribute("remaining"):(a=this.timeDisplayEl)==null||a.setAttribute("remaining","")}connectedCallback(){let e=t=>{let{key:a}=t;if(!ks.includes(a)){this.removeEventListener("keyup",e);return}this.toggleTimeDisplay()};this.addEventListener("keydown",t=>{let{metaKey:a,altKey:i,key:c}=t;if(a||i||!ks.includes(c)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)}),this.addEventListener("click",this.toggleTimeDisplay)}};mr.styles=Os,mr.template=Ps;globalThis.customElements.get("mxp-time-display")||(globalThis.customElements.define("mxp-time-display",mr),globalThis.MxpTimeDisplay=mr);var ws=`:host(:not([audio])) {
765
876
  --secondary-color: transparent;
766
877
  }
767
878
 
768
879
  :host {
769
- color: var(--primary-color);
770
- --media-icon-color: var(--primary-color);
771
- --media-range-thumb-background: var(--primary-color);
772
- --media-range-bar-color: var(--primary-color);
880
+ --_primary-color: var(--primary-color, #fff);
881
+
882
+ --media-icon-color: var(--_primary-color);
883
+ --media-range-thumb-background: var(--_primary-color);
884
+ --media-range-bar-color: var(--_primary-color);
773
885
  --media-control-background: var(--secondary-color);
774
886
  --media-control-hover-background: var(--secondary-color);
775
- --media-time-buffered-color: rgba(255, 255, 255, 0.7);
887
+ --media-time-buffered-color: rgba(255, 255, 255, 0.4);
776
888
  --media-range-track-background: rgba(255, 255, 255, 0.5);
777
889
  --media-range-track-border-radius: 3px;
890
+ --media-preview-thumbnail-border: 1px solid #fff;
891
+ --media-preview-thumbnail-border-radius: 2px;
892
+ --media-preview-time-margin: 5px 0 2px;
893
+ color: var(--_primary-color);
778
894
  display: inline-block;
779
895
  width: 100%;
780
896
  height: 100%;
781
897
  }
782
898
 
899
+ :host(.two-tone:not([audio])) {
900
+ --mux-time-range-padding: 0px; /* px is needed in calc() */
901
+ --media-preview-thumbnail-border: 0;
902
+ --media-preview-thumbnail-border-radius: 2px 2px 0 0;
903
+ --media-preview-time-border-radius: 0 0 2px 2px;
904
+ --media-preview-time-margin: 0 0 8px;
905
+ --media-preview-time-text-shadow: none;
906
+ }
907
+
908
+ :host([audio]) {
909
+ --media-preview-time-border-radius: 3px;
910
+ --media-preview-time-margin: 0 0 5px;
911
+ --media-preview-time-text-shadow: none;
912
+ }
913
+
914
+ :host(.two-tone:not([audio])) media-time-range {
915
+ --media-range-track-border-radius: 0;
916
+ }
917
+
783
918
  :host([audio]) ::slotted([slot='media']) {
784
919
  height: 0px;
785
920
  }
@@ -817,13 +952,26 @@ media-controller {
817
952
  height: 100%;
818
953
  }
819
954
 
955
+ :host media-time-range {
956
+ color: var(--_primary-color);
957
+ }
958
+
820
959
  :host(:not([audio])) media-time-range {
821
- padding: var(--mux-time-range-padding, 0 10px);
822
- z-index: 10;
960
+ --media-range-padding-left: var(--mux-time-range-padding, 10px);
961
+ --media-range-padding-right: var(--mux-time-range-padding, 10px);
823
962
  width: 100%;
824
- height: 22px;
825
- --media-range-track-translate-y: 6px;
826
- background: linear-gradient(180deg, transparent, transparent 15px, var(--media-control-background) 15px);
963
+ z-index: 10;
964
+ height: 10px;
965
+ bottom: -2px;
966
+ background: linear-gradient(
967
+ 180deg,
968
+ transparent,
969
+ transparent 3px,
970
+ var(--media-control-background) 3px,
971
+ var(--media-control-background) 8px,
972
+ transparent 8px,
973
+ transparent
974
+ );
827
975
  }
828
976
 
829
977
  media-control-bar {
@@ -834,10 +982,6 @@ media-control-bar :is([role='button'], [role='switch'], button) {
834
982
  height: 44px;
835
983
  }
836
984
 
837
- media-cast-button {
838
- width: 40px;
839
- }
840
-
841
985
  .size-extra-small media-control-bar [role='button'],
842
986
  .size-extra-small media-control-bar [role='switch'] {
843
987
  height: auto;
@@ -929,7 +1073,7 @@ media-time-display {
929
1073
  :is(media-time-display, media-text-display, media-playback-rate-button) {
930
1074
  color: inherit;
931
1075
  }
932
- `;var Qa=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="airplay">
1076
+ `;var Us=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="airplay">
933
1077
  <path
934
1078
  d="M10.19 11.22a.25.25 0 0 0-.38 0l-5.46 6.37a.25.25 0 0 0 .19.41h10.92a.25.25 0 0 0 .19-.41Z"
935
1079
  />
@@ -937,47 +1081,60 @@ media-time-display {
937
1081
  d="M19 0H1a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h2.94L5 13.75H1.25V1.25h17.5v12.5H15L16.06 15H19a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1Z"
938
1082
  />
939
1083
  </svg>
940
- `;var Ja=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="off">
1084
+ `;var Ns=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="off">
941
1085
  <path
942
1086
  d="M19.83 2.68a2.58 2.58 0 0 0-2.3-2.5C15.72.06 12.86 0 10 0S4.28.06 2.47.18a2.58 2.58 0 0 0-2.3 2.5 115.86 115.86 0 0 0 0 12.64 2.58 2.58 0 0 0 2.3 2.5c1.81.12 4.67.18 7.53.18s5.72-.06 7.53-.18a2.58 2.58 0 0 0 2.3-2.5 115.86 115.86 0 0 0 0-12.64Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18s-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11 122.5 122.5 0 0 1 0-12.42 1.11 1.11 0 0 1 .91-1.11C4.24 1.57 7 1.5 10 1.5s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11 122.5 122.5 0 0 1 0 12.42ZM7.84 11a1.55 1.55 0 0 1-.76.18 1.57 1.57 0 0 1-.71-.18 1.69 1.69 0 0 1-.57-.42 2.1 2.1 0 0 1-.38-.58 2.47 2.47 0 0 1 0-1.64 2 2 0 0 1 .39-.66 1.73 1.73 0 0 1 .58-.42 1.81 1.81 0 0 1 .73-.16 1.68 1.68 0 0 1 .7.14 1.39 1.39 0 0 1 .51.39l1.08-.89a2.18 2.18 0 0 0-.47-.44A2.81 2.81 0 0 0 8.4 6a2.91 2.91 0 0 0-.58-.15 2.71 2.71 0 0 0-.56 0A4.08 4.08 0 0 0 5.88 6a3.27 3.27 0 0 0-1.09.67 3.14 3.14 0 0 0-.71 1.06 3.62 3.62 0 0 0-.26 1.39 3.57 3.57 0 0 0 .26 1.38 3 3 0 0 0 .71 1.06 3.27 3.27 0 0 0 1.09.67 3.85 3.85 0 0 0 1.38.23 3.2 3.2 0 0 0 1.28-.27 2.49 2.49 0 0 0 1-.83l-1.17-.88a1.42 1.42 0 0 1-.53.52Zm6.62 0a1.58 1.58 0 0 1-.76.18A1.54 1.54 0 0 1 13 11a1.69 1.69 0 0 1-.57-.42A2.12 2.12 0 0 1 12 10a2.29 2.29 0 0 1 .39-2.3 1.84 1.84 0 0 1 1.32-.58 1.71 1.71 0 0 1 .7.14 1.39 1.39 0 0 1 .51.39L16 6.73a2.43 2.43 0 0 0-.47-.44A3.22 3.22 0 0 0 15 6a3 3 0 0 0-.57-.15 2.87 2.87 0 0 0-.57 0A4.06 4.06 0 0 0 12.5 6a3.17 3.17 0 0 0-1.09.67 3 3 0 0 0-.72 1.06 3.62 3.62 0 0 0-.25 1.39 3.57 3.57 0 0 0 .25 1.38 2.93 2.93 0 0 0 .72 1.06 3.17 3.17 0 0 0 1.09.67 3.83 3.83 0 0 0 1.37.23 3.16 3.16 0 0 0 1.28-.27 2.45 2.45 0 0 0 1-.83L15 10.51a1.49 1.49 0 0 1-.54.49Z"
943
1087
  />
944
1088
  </svg>
945
- `;var Za=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="on">
1089
+ `;var Bs=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="on">
946
1090
  <path
947
1091
  d="M19.83 2.68a2.58 2.58 0 0 0-2.3-2.5C13.91-.06 6.09-.06 2.47.18a2.58 2.58 0 0 0-2.3 2.5 115.86 115.86 0 0 0 0 12.64 2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5 115.86 115.86 0 0 0 0-12.64ZM8.42 12.78a3.63 3.63 0 0 1-1.51.32 4.76 4.76 0 0 1-1.63-.27A4 4 0 0 1 4 12a3.67 3.67 0 0 1-.84-1.26 4.23 4.23 0 0 1-.3-1.63 4.28 4.28 0 0 1 .3-1.64A3.53 3.53 0 0 1 4 6.26a3.89 3.89 0 0 1 1.29-.8 4.76 4.76 0 0 1 1.63-.27 4.06 4.06 0 0 1 .67.06 4.57 4.57 0 0 1 .68.18 3.59 3.59 0 0 1 .64.34 2.7 2.7 0 0 1 .55.52l-1.27 1a1.79 1.79 0 0 0-.6-.46 2 2 0 0 0-.83-.16 2 2 0 0 0-1.56.69 2.35 2.35 0 0 0-.46.77 2.78 2.78 0 0 0-.16 1 2.74 2.74 0 0 0 .16 1 2.39 2.39 0 0 0 .46.77 2.07 2.07 0 0 0 .67.5 2 2 0 0 0 .84.18 1.87 1.87 0 0 0 .9-.21 1.78 1.78 0 0 0 .65-.6l1.38 1a2.88 2.88 0 0 1-1.22 1.01Zm7.52 0a3.63 3.63 0 0 1-1.51.32 4.76 4.76 0 0 1-1.63-.27 3.89 3.89 0 0 1-1.28-.83 3.55 3.55 0 0 1-.85-1.26 4.23 4.23 0 0 1-.3-1.63 4.28 4.28 0 0 1 .3-1.64 3.43 3.43 0 0 1 .85-1.25 3.75 3.75 0 0 1 1.28-.8 4.76 4.76 0 0 1 1.63-.27 4 4 0 0 1 .67.06 4.27 4.27 0 0 1 .68.18 3.59 3.59 0 0 1 .64.34 2.46 2.46 0 0 1 .55.52l-1.27 1a1.79 1.79 0 0 0-.6-.46 2 2 0 0 0-.83-.16 2 2 0 0 0-1.56.69 2.35 2.35 0 0 0-.46.77 3 3 0 0 0-.16 1 3 3 0 0 0 .16 1 2.58 2.58 0 0 0 .46.77 2.07 2.07 0 0 0 .67.5 2 2 0 0 0 .84.18 1.87 1.87 0 0 0 .9-.21 1.78 1.78 0 0 0 .65-.6l1.38 1a2.82 2.82 0 0 1-1.21 1.05Z"
948
1092
  />
949
1093
  </svg>
950
- `;var qa=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="enter">
1094
+ `;var Fs=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="enter">
1095
+ <path d="M0 12.5V14C2.2056 14 4 15.7944 4 18H5.5C5.5 14.9624 3.0376 12.5 0 12.5Z"/>
1096
+ <path d="M0 15.5V18H2.5C2.5 16.6193 1.3807 15.5 0 15.5Z"/>
1097
+ <path d="M0 9.5V11C3.8599 11 7 14.1402 7 18H8.5C8.5 13.3055 4.6945 9.5 0 9.5Z"/>
1098
+ <path d="M19 -0.000213623H1C0.4478 -0.000213623 0 0.447386 0 0.999786V7.98359C0.4243 7.98359 0.8396 8.01859 1.25 8.06979V1.24979H18.75V16.75H9.9302C9.9814 17.1604 10.0164 17.5757 10.0164 18H19C19.5523 18 20 17.5522 20 17V0.999786C20 0.447386 19.5523 -0.000213623 19 -0.000213623Z"/>
1099
+ </svg>
1100
+ `;var js=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="exit">
1101
+ <path d="M0 12.5V14C2.2056 14 4 15.7944 4 18H5.5C5.5 14.9624 3.0376 12.5 0 12.5Z" />
1102
+ <path d="M0 15.5V18H2.5C2.5 16.6193 1.3807 15.5 0 15.5Z" />
1103
+ <path d="M0 9.5V11C3.8599 11 7 14.1402 7 18H8.5C8.5 13.3055 4.6945 9.5 0 9.5Z" />
1104
+ <path d="M19 -0.000198364H1C0.4478 -0.000198364 0 0.447402 0 0.999802V7.9836C0.4243 7.9836 0.8396 8.0186 1.25 8.0698V1.2498H18.75V16.75H9.9302C9.9814 17.1604 10.0164 17.5757 10.0164 18H19C19.5523 18 20 17.5522 20 17V0.999802C20 0.447402 19.5523 -0.000198364 19 -0.000198364Z" />
1105
+ <path d="M17.5 2.4998H2.5V8.311C6.0193 9.2171 8.783 11.9807 9.689 15.5001H17.5V2.4998Z" />
1106
+ </svg>
1107
+ `;var Ks=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="enter">
951
1108
  <path
952
1109
  d="M17.25 11.5a.76.76 0 0 0-.75.75v4.25h-4.25a.75.75 0 0 0 0 1.5h5a.76.76 0 0 0 .75-.75v-5a.76.76 0 0 0-.75-.75Zm0-11.5h-5a.76.76 0 0 0-.75.75.76.76 0 0 0 .75.75h4.25v4.25a.75.75 0 0 0 1.5 0v-5a.76.76 0 0 0-.75-.75ZM5.75 16.5H1.5v-4.25a.76.76 0 0 0-.75-.75.76.76 0 0 0-.75.75v5a.76.76 0 0 0 .75.75h5a.75.75 0 0 0 0-1.5Zm0-16.5h-5A.76.76 0 0 0 0 .75v5a.76.76 0 0 0 .75.75.76.76 0 0 0 .75-.75V1.5h4.25A.76.76 0 0 0 6.5.75.76.76 0 0 0 5.75 0Z"
953
1110
  />
954
1111
  </svg>
955
- `;var es=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="exit">
1112
+ `;var Hs=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="exit">
956
1113
  <path
957
1114
  d="M17.25 11.5h-5a.76.76 0 0 0-.75.75v5a.75.75 0 0 0 1.5 0V13h4.25a.75.75 0 0 0 0-1.5Zm-5-5h5a.75.75 0 0 0 0-1.5H13V.75a.75.75 0 0 0-1.5 0v5a.76.76 0 0 0 .75.75Zm-6.5 5h-5a.75.75 0 0 0 0 1.5H5v4.25a.75.75 0 0 0 1.5 0v-5a.76.76 0 0 0-.75-.75Zm0-11.5A.76.76 0 0 0 5 .75V5H.75a.75.75 0 0 0 0 1.5h5a.76.76 0 0 0 .75-.75v-5A.76.76 0 0 0 5.75 0Z"
958
1115
  />
959
1116
  </svg>
960
- `;var ts=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="pause">
1117
+ `;var Ws=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="pause">
961
1118
  <path
962
1119
  d="M3 16.5a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v15ZM11.5 1a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5h-3Z"
963
1120
  />
964
1121
  </svg>
965
- `;var rs=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="enter">
1122
+ `;var Gs=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="enter">
966
1123
  <path
967
1124
  d="M19 0H1a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h6.75v-1.25h-6.5V1.25h17.5v6.5H20V1a1 1 0 0 0-1-1Zm0 10h-8a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-6a1 1 0 0 0-1-1Zm-.5 6.5h-7v-5h7Z"
968
1125
  />
969
1126
  </svg>
970
- `;var is=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="exit">
1127
+ `;var Vs=`<svg aria-hidden="true" viewBox="0 0 20 18" slot="exit">
971
1128
  <path
972
1129
  d="M19 0H1a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h6.75v-1.25h-6.5V1.25h17.5v6.5H20V1a1 1 0 0 0-1-1Zm0 10h-8a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-6a1 1 0 0 0-1-1Zm-.5 6.5h-7v-5h7Z"
973
1130
  />
974
1131
  </svg>
975
- `;var ns=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="play">
1132
+ `;var $s=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="play">
976
1133
  <path
977
1134
  d="m3.73 17.93 14.05-8.54a.46.46 0 0 0 0-.78L3.73.07A.48.48 0 0 0 3 .46v17.07a.48.48 0 0 0 .73.4Z"
978
1135
  />
979
1136
  </svg>
980
- `;var as=`<svg aria-hidden="true" viewBox="0 0 16 18" slot="backward">
1137
+ `;var Ys=`<svg aria-hidden="true" viewBox="0 0 16 18" slot="backward">
981
1138
  <path
982
1139
  d="M8.75 3.42H4.68l2.14-2.14A.75.75 0 0 0 5.76.22L2.22 3.75a.77.77 0 0 0 0 1.07l3.54 3.53a.75.75 0 0 0 1.06 0 .75.75 0 0 0 0-1.06L4.45 4.92h4.3A5.75 5.75 0 0 1 11 16a.75.75 0 0 0 .29 1.44.72.72 0 0 0 .29-.06A7.25 7.25 0 0 0 8.75 3.42Z"
983
1140
  />
@@ -990,7 +1147,7 @@ media-time-display {
990
1147
  </text>
991
1148
  <path style="fill: none" d="M0 0h16v18H0z" />
992
1149
  </svg>
993
- `;var ss=`<svg aria-hidden="true" viewBox="0 0 16 18" slot="forward">
1150
+ `;var zs=`<svg aria-hidden="true" viewBox="0 0 16 18" slot="forward">
994
1151
  <path
995
1152
  d="M7.25 3.42h4.07L9.18 1.28A.75.75 0 0 1 10.24.22l3.54 3.53a.77.77 0 0 1 0 1.07l-3.54 3.53a.75.75 0 0 1-1.06 0 .75.75 0 0 1 0-1.06l2.37-2.37h-4.3A5.75 5.75 0 0 0 5 16a.75.75 0 0 1-.29 1.44.72.72 0 0 1-.29-.06A7.25 7.25 0 0 1 7.25 3.42Z"
996
1153
  />
@@ -1003,264 +1160,264 @@ media-time-display {
1003
1160
  </text>
1004
1161
  <path style="fill: none" d="M0 0h16v18H0z" />
1005
1162
  </svg>
1006
- `;var os=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="high">
1163
+ `;var Xs=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="high">
1007
1164
  <path
1008
1165
  d="m8.14 1.86-4 4a.49.49 0 0 1-.35.14H.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.5.5 0 0 0 .85-.36V2.21a.5.5 0 0 0-.86-.35ZM10.88.3v1.52A7.52 7.52 0 0 1 16.47 9a7.52 7.52 0 0 1-5.59 7.18v1.52A9 9 0 0 0 18 9 9 9 0 0 0 10.88.3ZM14.44 9a5.49 5.49 0 0 0-3.56-5.1v1.66a3.93 3.93 0 0 1 0 6.88v1.66A5.49 5.49 0 0 0 14.44 9Z"
1009
1166
  />
1010
1167
  <path style="fill: none" d="M0 0h18v18H0z" />
1011
1168
  </svg>
1012
- `;var ls=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="low">
1169
+ `;var Qs=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="low">
1013
1170
  <path
1014
1171
  d="m8.14 1.86-4 4a.49.49 0 0 1-.35.14H.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.5.5 0 0 0 .85-.36V2.21a.5.5 0 0 0-.86-.35ZM14.44 9a5.49 5.49 0 0 0-3.56-5.1v1.66a3.93 3.93 0 0 1 0 6.88v1.66A5.49 5.49 0 0 0 14.44 9Z"
1015
1172
  />
1016
1173
  <path style="fill: none" d="M0 0h18v18H0z" />
1017
1174
  </svg>
1018
- `;var us=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="medium">
1175
+ `;var Zs=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="medium">
1019
1176
  <path
1020
1177
  d="m8.14 1.86-4 4a.49.49 0 0 1-.35.14H.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.5.5 0 0 0 .85-.36V2.21a.5.5 0 0 0-.86-.35ZM14.44 9a5.49 5.49 0 0 0-3.56-5.1v1.66a3.93 3.93 0 0 1 0 6.88v1.66A5.49 5.49 0 0 0 14.44 9Z"
1021
1178
  />
1022
1179
  <path style="fill: none" d="M0 0h18v18H0z" />
1023
1180
  </svg>
1024
- `;var ds=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="off">
1181
+ `;var Js=`<svg aria-hidden="true" viewBox="0 0 18 18" slot="off">
1025
1182
  <path
1026
1183
  d="m0 1.05 4.48 4.47-.33.33a.49.49 0 0 1-.36.15H.25a.25.25 0 0 0-.25.25v5.5a.25.25 0 0 0 .25.25h3.54a.49.49 0 0 1 .36.15l4 4a.48.48 0 0 0 .36.15.5.5 0 0 0 .5-.5v-5.75l4.67 4.66a7.71 7.71 0 0 1-2.79 1.47v1.52a9.32 9.32 0 0 0 3.87-1.91L17 18l1-1L1.06 0Zm5.36 5.36L7.75 8.8V14L5 11.26a1.74 1.74 0 0 0-1.24-.51H1.25v-3.5h2.54A1.74 1.74 0 0 0 5 6.74ZM16.47 9a7.19 7.19 0 0 1-.89 3.47l1.11 1.1A8.64 8.64 0 0 0 18 9 9 9 0 0 0 10.88.3v1.52A7.52 7.52 0 0 1 16.47 9ZM9 5.88V2.21a.5.5 0 0 0-.5-.5.48.48 0 0 0-.36.15L6.56 3.44ZM12.91 9a4.28 4.28 0 0 1-.07.72l1.22 1.22A5.2 5.2 0 0 0 14.44 9a5.49 5.49 0 0 0-3.56-5.1v1.66A4 4 0 0 1 12.91 9Z"
1027
1184
  />
1028
1185
  <path style="fill: none" d="M0 0h18v18H0z" />
1029
1186
  </svg>
1030
- `;var cs=()=>Ve(Qa),fs=()=>Ve(Ja),hs=()=>Ve(Za),vs=()=>Ve(qa),ms=()=>Ve(es),gs=()=>Ve(ts),ps=()=>Ve(rs),Es=()=>Ve(is),ys=()=>Ve(ns),Ts=v=>Ve(as,v),bs=v=>Ve(ss,v),As=()=>Ve(os),Ss=()=>Ve(ls),_s=()=>Ve(us),xs=()=>Ve(ds);var ut={LG:"large",SM:"small",XS:"extra-small"},Ls=v=>_e`
1031
- <style>
1032
- ${Xa}
1033
- </style>
1034
-
1035
- <media-controller audio="${v.audio||!1}" class="size-${v.playerSize}">
1036
- <slot name="media" slot="media"></slot>
1037
- <media-loading-indicator slot="centered-chrome" no-auto-hide></media-loading-indicator>
1038
- ${Jl(v)}
1039
- <slot></slot>
1040
- </media-controller>
1041
- `,Jl=v=>{let{streamType:e,playerSize:t,audio:l}=v;if(l)switch(e){case ve.LIVE:case ve.LL_LIVE:return eu(v);case ve.DVR:case ve.LL_DVR:return ql(v);case ve.ON_DEMAND:default:return Zl(v)}switch(e){case ve.LIVE:case ve.LL_LIVE:switch(t){case ut.LG:return au(v);case ut.SM:return nu(v);case ut.XS:return iu(v)}case ve.DVR:case ve.LL_DVR:switch(t){case ut.LG:return lu(v);case ut.SM:return ou(v);case ut.XS:return su(v)}case ve.ON_DEMAND:default:switch(t){case ut.LG:return ru(v);case ut.SM:return tu(v);case ut.XS:return wi(v)}}},Xe=()=>_e`
1042
- <media-play-button>
1043
- ${ys()}
1044
- ${gs()}
1187
+ `;var qs=()=>He(Us),eo=()=>He(Ns),to=()=>He(Bs),ro=()=>He(Fs),io=()=>He(js),no=()=>He(Ks),ao=()=>He(Hs),so=()=>He(Ws),oo=()=>He(Gs),lo=()=>He(Vs),uo=()=>He($s),co=f=>He(Ys,f),fo=f=>He(zs,f),ho=()=>He(Xs),vo=()=>He(Qs),mo=()=>He(Zs),po=()=>He(Js);var ht={LG:"large",SM:"small",XS:"extra-small"},Ie={mediaChrome:"layer media-layer poster-layer vertical-layer centered-layer",centerPlay:"center play button",centerSeekBackward:"center seek-backward button",centerSeekForward:"center seek-forward button",play:"play button",seekBackward:"seek-backward button",seekForward:"seek-forward button",mute:"mute button",captions:"captions button",airplay:"airplay button",pip:"pip button",fullscreen:"fullscreen button",cast:"cast button",playbackRate:"playbackrate button",volumeRange:"volume range",timeRange:"time range",timeDisplay:"time display"},ln=class extends Vi{static get observedAttributes(){return["audio","nohotkeys","stream-type","player-size","default-hidden-captions","forward-seek-offset","backward-seek-offset"]}attributeChangedCallback(){this.render()}render(){let e={audio:this.hasAttribute("audio"),nohotkeys:this.hasAttribute("nohotkeys"),streamType:this.getAttribute("stream-type"),playerSize:this.getAttribute("player-size"),defaultHiddenCaptions:this.hasAttribute("default-hidden-captions"),forwardSeekOffset:this.getAttribute("forward-seek-offset"),backwardSeekOffset:this.getAttribute("backward-seek-offset")};qr(Te`
1188
+ <style>
1189
+ ${ws}
1190
+ </style>
1191
+ <media-controller
1192
+ nohotkeys="${e.nohotkeys||!1}"
1193
+ audio="${e.audio||!1}"
1194
+ class="size-${e.playerSize}"
1195
+ exportparts="${Ie.mediaChrome.split(" ").join(", ")}"
1196
+ >
1197
+ <slot name="media" slot="media"></slot>
1198
+ <media-loading-indicator slot="centered-chrome" no-auto-hide></media-loading-indicator>
1199
+ ${Wu(e)}
1200
+ <slot></slot>
1201
+ </media-controller>
1202
+ `,this.shadowRoot)}};customElements.get("media-theme-mux")||customElements.define("media-theme-mux",ln);var Wu=f=>{let{streamType:e,playerSize:t,audio:a}=f;if(a)switch(e){case ve.LIVE:case ve.LL_LIVE:return $u();case ve.DVR:case ve.LL_DVR:return Vu(f);case ve.ON_DEMAND:default:return Gu(f)}switch(e){case ve.LIVE:case ve.LL_LIVE:switch(t){case ht.LG:return Zu(f);case ht.SM:return Qu(f);case ht.XS:return Xu(f)}case ve.DVR:case ve.LL_DVR:switch(t){case ht.LG:return ed(f);case ht.SM:return qu(f);case ht.XS:return Ju(f)}case ve.ON_DEMAND:default:switch(t){case ht.LG:return zu(f);case ht.SM:return Yu(f);case ht.XS:return un(f)}}},Qe=({part:f=Ie.play}={})=>Te`
1203
+ <media-play-button part="${f}">
1204
+ ${uo()}
1205
+ ${so()}
1045
1206
  </media-play-button>
1046
- `,Nt=v=>_e`
1047
- <media-seek-backward-button seek-offset="${v.backwardSeekOffset}">
1048
- ${Ts({value:v.backwardSeekOffset})}
1207
+ `,Yt=({backwardSeekOffset:f,part:e=Ie.seekBackward})=>Te`
1208
+ <media-seek-backward-button seek-offset="${f}" part="${e}">
1209
+ ${co({value:f})}
1049
1210
  </media-seek-backward-button>
1050
- `,Bt=v=>_e`
1051
- <media-seek-forward-button seek-offset="${v.forwardSeekOffset}">
1052
- ${bs({value:v.forwardSeekOffset})}
1211
+ `,zt=({forwardSeekOffset:f,part:e=Ie.seekForward})=>Te`
1212
+ <media-seek-forward-button seek-offset="${f}" part="${e}">
1213
+ ${fo({value:f})}
1053
1214
  </media-seek-forward-button>
1054
- `,nt=()=>_e`
1055
- <media-mute-button>
1056
- ${As()}
1057
- ${_s()}
1058
- ${Ss()}
1059
- ${xs()}
1215
+ `,ot=()=>Te`
1216
+ <media-mute-button part="${Ie.mute}">
1217
+ ${ho()}
1218
+ ${mo()}
1219
+ ${vo()}
1220
+ ${po()}
1060
1221
  </media-mute-button>
1061
- `,St=v=>_e`
1062
- <media-captions-button default-showing="${!v.defaultHiddenCaptions}" >
1063
- ${fs()}
1064
- ${hs()}
1065
- </media-captions-button>`,at=()=>_e`
1066
- <media-airplay-button>
1067
- ${cs()}
1068
- </media-airplay-button>`,_t=()=>_e`
1069
- <media-pip-button>
1070
- ${ps()}
1071
- ${Es()}
1072
- </media-pip-button>`,xt=()=>_e`
1073
- <media-fullscreen-button>
1074
- ${vs()}
1075
- ${ms()}
1076
- </media-fullscreen-button>`,Zl=v=>_e`
1222
+ `,Ot=f=>Te`
1223
+ <media-captions-button default-showing="${!f.defaultHiddenCaptions}" part="${Ie.captions}">
1224
+ ${eo()}
1225
+ ${to()}
1226
+ </media-captions-button>`,lt=()=>Te`
1227
+ <media-airplay-button part="${Ie.airplay}">
1228
+ ${qs()}
1229
+ </media-airplay-button>`,Pt=()=>Te`
1230
+ <media-pip-button part="${Ie.pip}">
1231
+ ${oo()}
1232
+ ${lo()}
1233
+ </media-pip-button>`,kt=()=>Te`
1234
+ <media-fullscreen-button part="${Ie.fullscreen}">
1235
+ ${no()}
1236
+ ${ao()}
1237
+ </media-fullscreen-button>`,ut=()=>Te`
1238
+ <media-cast-button part="${Ie.cast}">
1239
+ ${ro()}
1240
+ ${io()}
1241
+ </media-cast-button>`,ei=()=>Te`
1242
+ <media-playback-rate-button part="${Ie.playbackRate}">
1243
+ </media-playback-rate-button>`,vt=()=>Te`
1244
+ <media-volume-range part="${Ie.volumeRange}">
1245
+ </media-volume-range>`,Xt=()=>Te`
1246
+ <media-time-range part="${Ie.timeRange}">
1247
+ </media-time-range>`,ti=()=>Te`
1248
+ <mxp-time-display part="${Ie.timeDisplay}">
1249
+ </mxp-time-display>`,Gu=f=>Te`
1077
1250
  <media-control-bar>
1078
- ${Xe()} ${Nt(v)} ${Bt(v)}
1079
- <mxp-time-display></mxp-time-display>
1080
- <media-time-range></media-time-range>
1081
- ${nt()}
1082
- <media-volume-range></media-volume-range>
1083
- <media-playback-rate-button></media-playback-rate-button>
1084
- ${at()}
1085
- <media-cast-button></media-cast-button>
1251
+ ${Qe()}
1252
+ ${Yt(f)}
1253
+ ${zt(f)}
1254
+ ${ti()}
1255
+ ${Xt()}
1256
+ ${ot()}
1257
+ ${vt()}
1258
+ ${ei()}
1259
+ ${lt()}
1260
+ ${ut()}
1086
1261
  </media-control-bar>
1087
- `,ql=v=>_e`
1262
+ `,Vu=f=>Te`
1088
1263
  <media-control-bar>
1089
- ${Xe()}
1264
+ ${Qe()}
1090
1265
  <slot name="seek-to-live-button"></slot>
1091
- ${Nt(v)} ${Bt(v)}
1092
- <mxp-time-display></mxp-time-display>
1093
- <media-time-range></media-time-range>
1094
- ${nt()}
1095
- <media-volume-range></media-volume-range>
1096
- <media-playback-rate-button></media-playback-rate-button>
1097
- ${at()}
1098
- <media-cast-button></media-cast-button>
1266
+ ${Yt(f)}
1267
+ ${zt(f)}
1268
+ ${ti()}
1269
+ ${Xt()}
1270
+ ${ot()}
1271
+ ${vt()}
1272
+ ${ei()}
1273
+ ${lt()}
1274
+ ${ut()}
1099
1275
  </media-control-bar>
1100
- `,eu=v=>_e`
1276
+ `,$u=()=>Te`
1101
1277
  <media-control-bar>
1102
- ${Xe()}
1278
+ ${Qe()}
1103
1279
  <slot name="seek-to-live-button"></slot>
1104
- ${nt()}
1105
- <media-volume-range></media-volume-range>
1106
- ${at()}
1107
- <media-cast-button></media-cast-button>
1280
+ ${ot()}
1281
+ ${vt()}
1282
+ ${lt()}
1283
+ ${ut()}
1108
1284
  </media-control-bar>
1109
- `,wi=v=>_e`
1285
+ `,un=f=>Te`
1110
1286
  <media-control-bar slot="top-chrome">
1111
- ${St(v)}
1287
+ ${Ot(f)}
1112
1288
  <div class="mxp-spacer"></div>
1113
- ${at()}
1114
- <media-cast-button></media-cast-button>
1115
- ${_t()}
1289
+ ${lt()}
1290
+ ${ut()}
1291
+ ${Pt()}
1116
1292
  </media-control-bar>
1117
1293
  <div slot="centered-chrome" class="mxp-center-controls">
1118
- ${Xe()}
1294
+ ${Qe({part:Ie.centerPlay})}
1119
1295
  </div>
1120
1296
  <media-control-bar>
1121
- ${nt()}
1297
+ ${ot()}
1122
1298
  <div class="mxp-spacer"></div>
1123
- ${xt()}
1299
+ ${kt()}
1124
1300
  </media-control-bar>
1125
- `,tu=v=>_e`
1301
+ `,Yu=f=>Te`
1126
1302
  <media-control-bar slot="top-chrome" style="justify-content: flex-end;">
1127
- ${St(v)}
1128
- ${at()}
1129
- <media-cast-button></media-cast-button>
1130
- ${_t()}
1303
+ ${Ot(f)}
1304
+ ${lt()}
1305
+ ${ut()}
1306
+ ${Pt()}
1131
1307
  </media-control-bar>
1132
1308
  <div slot="centered-chrome" class="mxp-center-controls">
1133
- ${Nt(v)}
1134
- ${Xe()}
1135
- ${Bt(v)}
1309
+ ${Yt({...f,part:Ie.centerSeekBackward})}
1310
+ ${Qe({part:Ie.centerPlay})}
1311
+ ${zt({...f,part:Ie.centerSeekForward})}
1136
1312
  </div>
1137
- <media-time-range></media-time-range>
1313
+ ${Xt()}
1138
1314
  <media-control-bar>
1139
- <mxp-time-display></mxp-time-display>
1140
- ${nt()}
1141
- <media-volume-range></media-volume-range>
1315
+ ${ti()}
1316
+ ${ot()}
1317
+ ${vt()}
1142
1318
  <div class="mxp-spacer"></div>
1143
- <media-playback-rate-button></media-playback-rate-button>
1144
- ${xt()}
1319
+ ${ei()}
1320
+ ${kt()}
1145
1321
  <div class="mxp-padding-2"></div>
1146
1322
  </media-control-bar>
1147
- `,ru=v=>_e`
1323
+ `,zu=f=>Te`
1148
1324
  <div slot="centered-chrome" class="mxp-center-controls">
1149
- ${Xe()}
1325
+ ${Qe({part:Ie.centerPlay})}
1150
1326
  </div>
1151
- <media-time-range></media-time-range>
1327
+ ${Xt()}
1152
1328
  <media-control-bar>
1153
- ${Xe()}
1154
- ${Nt(v)}
1155
- ${Bt(v)}
1156
- <mxp-time-display></mxp-time-display>
1157
- ${nt()}
1158
- <media-volume-range></media-volume-range>
1329
+ ${Qe()}
1330
+ ${Yt(f)}
1331
+ ${zt(f)}
1332
+ ${ti()}
1333
+ ${ot()}
1334
+ ${vt()}
1159
1335
  <div class="mxp-spacer"></div>
1160
- <media-playback-rate-button></media-playback-rate-button>
1161
- ${St(v)}
1162
- ${at()}
1163
- <media-cast-button></media-cast-button>
1164
- ${_t()}
1165
- ${xt()}
1336
+ ${ei()}
1337
+ ${Ot(f)}
1338
+ ${lt()}
1339
+ ${ut()}
1340
+ ${Pt()}
1341
+ ${kt()}
1166
1342
  <div class="mxp-padding-2"></div>
1167
1343
  </media-control-bar>
1168
- `,iu=wi,nu=v=>_e`
1344
+ `,Xu=un,Qu=f=>Te`
1169
1345
  <media-control-bar slot="top-chrome">
1170
1346
  <slot name="seek-to-live-button"></slot>
1171
1347
  <div class="mxp-spacer"></div>
1172
- ${St(v)}
1173
- ${at()}
1174
- <media-cast-button></media-cast-button>
1175
- ${_t()}
1348
+ ${Ot(f)}
1349
+ ${lt()}
1350
+ ${ut()}
1351
+ ${Pt()}
1176
1352
  </media-control-bar>
1177
1353
  <div slot="centered-chrome" class="mxp-center-controls">
1178
- ${Xe()}
1354
+ ${Qe({part:Ie.centerPlay})}
1179
1355
  </div>
1180
1356
  <media-control-bar>
1181
- ${nt()}
1182
- <media-volume-range></media-volume-range>
1357
+ ${ot()}
1358
+ ${vt()}
1183
1359
  <div class="mxp-spacer"></div>
1184
- ${xt()}
1360
+ ${kt()}
1185
1361
  </media-control-bar>
1186
- `,au=v=>_e`
1362
+ `,Zu=f=>Te`
1187
1363
  <media-control-bar slot="top-chrome">
1188
1364
  <slot name="seek-to-live-button"></slot>
1189
1365
  </media-control-bar>
1190
1366
  <div slot="centered-chrome" class="mxp-center-controls">
1191
- ${Xe()}
1367
+ ${Qe({part:Ie.centerPlay})}
1192
1368
  </div>
1193
1369
  <media-control-bar>
1194
- ${nt()}
1195
- <media-volume-range></media-volume-range>
1370
+ ${ot()}
1371
+ ${vt()}
1196
1372
  <div class="mxp-spacer"></div>
1197
- ${St(v)}
1198
- ${at()}
1199
- <media-cast-button></media-cast-button>
1200
- ${_t()}
1201
- ${xt()}
1373
+ ${Ot(f)}
1374
+ ${lt()}
1375
+ ${ut()}
1376
+ ${Pt()}
1377
+ ${kt()}
1202
1378
  </media-control-bar>
1203
- `,su=wi,ou=v=>_e`
1379
+ `,Ju=un,qu=f=>Te`
1204
1380
  <media-control-bar slot="top-chrome" style="justify-content: flex-end;">
1205
- ${St(v)}
1206
- ${at()}
1207
- <media-cast-button></media-cast-button>
1208
- ${_t()}
1381
+ ${Ot(f)}
1382
+ ${lt()}
1383
+ ${ut()}
1384
+ ${Pt()}
1209
1385
  </media-control-bar>
1210
1386
  <div slot="centered-chrome" class="mxp-center-controls">
1211
- ${Nt(v)}
1212
- ${Xe()}
1213
- ${Bt(v)}
1387
+ ${Yt({...f,part:Ie.centerSeekBackward})}
1388
+ ${Qe({part:Ie.centerPlay})}
1389
+ ${zt({...f,part:Ie.centerSeekForward})}
1214
1390
  </div>
1215
- <media-time-range></media-time-range>
1391
+ ${Xt()}
1216
1392
  <media-control-bar>
1217
- ${nt()}
1218
- <media-volume-range></media-volume-range>
1393
+ ${ot()}
1394
+ ${vt()}
1219
1395
  <slot name="seek-to-live-button"></slot>
1220
1396
  <div class="mxp-spacer"></div>
1221
- ${xt()}
1397
+ ${kt()}
1222
1398
  <div class="mxp-padding-2"></div>
1223
1399
  </media-control-bar>
1224
- `,lu=v=>_e`
1400
+ `,ed=f=>Te`
1225
1401
  <div slot="centered-chrome" class="mxp-center-controls">
1226
- ${Xe()}
1402
+ ${Qe({part:Ie.centerPlay})}
1227
1403
  </div>
1228
- <media-time-range></media-time-range>
1404
+ ${Xt()}
1229
1405
  <media-control-bar>
1230
- ${Xe()}
1231
- ${Nt(v)}
1232
- ${Bt(v)}
1233
- ${nt()}
1234
- <media-volume-range></media-volume-range>
1406
+ ${Qe()}
1407
+ ${Yt(f)}
1408
+ ${zt(f)}
1409
+ ${ot()}
1410
+ ${vt()}
1235
1411
  <slot name="seek-to-live-button"></slot>
1236
1412
  <div class="mxp-spacer"></div>
1237
- ${St(v)}
1238
- ${at()}
1239
- <media-cast-button></media-cast-button>
1240
- ${_t()}
1241
- ${xt()}
1413
+ ${Ot(f)}
1414
+ ${lt()}
1415
+ ${ut()}
1416
+ ${Pt()}
1417
+ ${kt()}
1242
1418
  <div class="mxp-padding-2"></div>
1243
1419
  </media-control-bar>
1244
- `;function Ds(v,e){return{audio:v.hasAttribute("audio"),streamType:v.getAttribute("stream-type"),playerSize:v.getAttribute("player-size"),defaultHiddenCaptions:v.hasAttribute("default-hidden-captions"),forwardSeekOffset:v.getAttribute("forward-seek-offset"),backwardSeekOffset:v.getAttribute("backward-seek-offset"),...e}}var Ui=class extends HTMLElement{static get observedAttributes(){return["audio","stream-type","player-size","default-hidden-captions","forward-seek-offset","backward-seek-offset"]}constructor(){super();this.attachShadow({mode:"open"}),rr(Ls(Ds(this)),this.shadowRoot)}attributeChangedCallback(){rr(Ls(Ds(this)),this.shadowRoot)}};customElements.get("media-theme-mux")||customElements.define("media-theme-mux",Ui);var Is=Ui;var uu=Object.defineProperty,du=(v,e,t)=>e in v?uu(v,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):v[e]=t,Pr=(v,e,t)=>(du(v,typeof e!="symbol"?e+"":e,t),t),Ni=(v,e,t)=>{if(!e.has(v))throw TypeError("Cannot "+t)},ae=(v,e,t)=>(Ni(v,e,"read from private field"),t?t.call(v):e.get(v)),Le=(v,e,t)=>{if(e.has(v))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(v):e.set(v,t)},ze=(v,e,t,l)=>(Ni(v,e,"write to private field"),l?l.call(v,t):e.set(v,t),t),We=(v,e,t)=>(Ni(v,e,"access private method"),t),cu=()=>{try{return"0.8.1"}catch{}return"UNKNOWN"},fu=cu(),hu=()=>fu,vu=v=>{var e,t,l,n,h,R,T,L,_,E,I,M,D,b,A,u,r,s,i,a,d,o,y,p,m,g,f,c,x,S,O,C,P,w,U,k,N,B,K,W;return e=class extends v{constructor(){super();Le(this,f),Le(this,x),Le(this,O),Le(this,P),Le(this,U),Le(this,N),Le(this,K),Pr(this,"castEnabled",!1),Le(this,d,{paused:!1}),Le(this,o,void 0),Le(this,y,{}),Le(this,p,void 0),Le(this,m,void 0),Le(this,g,void 0),e.instances.add(this),We(this,U,k).call(this)}static get castElement(){return ae(e,t)}static get castEnabled(){return ae(e,l)}static get castState(){var F;return(F=ae(e,_,E))==null?void 0:F.getCastState()}static async exitCast(){let F=!0;try{await ae(e,_,E).endCurrentSession(F)}catch(H){console.error(H);return}}get castPlayer(){if(e.castElement===this)return ae(this,o)}attributeChangedCallback(F){if(this.castPlayer)switch(F){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(F={}){var H;We(H=e,i,a).call(H,F),ze(e,t,this),Object.entries(ae(this,y)).forEach(([Y,$])=>{ae(this,o).controller.addEventListener(Y,$)});try{await ae(e,_,E).requestSession()}catch{ze(e,t,void 0);return}ae(this,d).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Y){console.error(Y)}}async load(){var F,H;if(!this.castPlayer)return super.load();let Y=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),$=[...this.querySelectorAll("track")].filter(({kind:X,src:ie})=>ie&&(X==="subtitles"||X==="captions")),Z=[],q=0;$.length&&(Y.tracks=$.map(X=>{let ie=++q;Z.length===0&&X.track.mode==="showing"&&Z.push(ie);let fe=new chrome.cast.media.Track(ie,chrome.cast.media.TrackType.TEXT);return fe.trackContentId=X.src,fe.trackContentType="text/vtt",fe.subtype=X.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,fe.name=X.label,fe.language=X.srclang,fe})),this.castStreamType==="live"?Y.streamType=chrome.cast.media.StreamType.LIVE:Y.streamType=chrome.cast.media.StreamType.BUFFERED,Y.metadata=new chrome.cast.media.GenericMediaMetadata,Y.metadata.title=this.title,Y.metadata.images=[{url:this.poster}];let oe=new chrome.cast.media.LoadRequest(Y);oe.currentTime=(F=super.currentTime)!=null?F:0,oe.autoplay=!ae(this,d).paused,oe.activeTrackIds=Z,await((H=ae(e,I,M))==null?void 0:H.loadMedia(oe)),this.dispatchEvent(new Event("volumechange"))}play(){var F;if(this.castPlayer){this.castPlayer.isPaused&&((F=this.castPlayer.controller)==null||F.playOrPause());return}return super.play()}pause(){var F;if(this.castPlayer){this.castPlayer.isPaused||(F=this.castPlayer.controller)==null||F.playOrPause();return}super.pause()}get castSrc(){var F,H,Y;return(Y=(H=this.getAttribute("cast-src"))!=null?H:(F=this.querySelector("source"))==null?void 0:F.src)!=null?Y:this.currentSrc}set castSrc(F){this.castSrc!=F&&this.setAttribute("cast-src",`${F}`)}get castContentType(){var F;return(F=this.getAttribute("cast-content-type"))!=null?F:void 0}set castContentType(F){this.setAttribute("cast-content-type",`${F}`)}get castStreamType(){var F;return(F=this.getAttribute("cast-stream-type"))!=null?F:void 0}set castStreamType(F){this.setAttribute("cast-stream-type",`${F}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var F;return this.castPlayer?(F=this.castPlayer)==null?void 0:F.isMuted:super.muted}set muted(F){var H;if(this.castPlayer){(F&&!this.castPlayer.isMuted||!F&&this.castPlayer.isMuted)&&((H=this.castPlayer.controller)==null||H.muteOrUnmute());return}super.muted=F}get volume(){var F,H;return this.castPlayer?(H=(F=this.castPlayer)==null?void 0:F.volumeLevel)!=null?H:1:super.volume}set volume(F){var H;if(this.castPlayer){this.castPlayer.volumeLevel=F,(H=this.castPlayer.controller)==null||H.setVolumeLevel();return}super.volume=F}get duration(){var F,H;return this.castPlayer&&ae(this,f,c)?(H=(F=this.castPlayer)==null?void 0:F.duration)!=null?H:NaN:super.duration}get currentTime(){var F,H;return this.castPlayer&&ae(this,f,c)?(H=(F=this.castPlayer)==null?void 0:F.currentTime)!=null?H:0:super.currentTime}set currentTime(F){var H;if(this.castPlayer){this.castPlayer.currentTime=F,(H=this.castPlayer.controller)==null||H.seek();return}super.currentTime=F}get onentercast(){return ae(this,p)}set onentercast(F){ae(this,p)&&(this.removeEventListener("entercast",ae(this,p)),ze(this,p,null)),typeof F=="function"&&(ze(this,p,F),this.addEventListener("entercast",F))}get onleavecast(){return ae(this,m)}set onleavecast(F){ae(this,m)&&(this.removeEventListener("leavecast",ae(this,m)),ze(this,m,null)),typeof F=="function"&&(ze(this,m,F),this.addEventListener("leavecast",F))}get oncastchange(){return ae(this,g)}set oncastchange(F){ae(this,g)&&(this.removeEventListener("castchange",ae(this,g)),ze(this,g,null)),typeof F=="function"&&(ze(this,g,F),this.addEventListener("castchange",F))}},t=new WeakMap,l=new WeakMap,n=new WeakMap,h=new WeakSet,R=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},T=new WeakSet,L=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,E=function(){if(ae(e,T,L))return cast.framework.CastContext.getInstance()},I=new WeakSet,M=function(){var F;return(F=ae(e,_,E))==null?void 0:F.getCurrentSession()},D=new WeakSet,b=function(){var F;return(F=ae(e,I,M))==null?void 0:F.getSessionObj().media[0]},A=new WeakSet,u=function(F){return new Promise((H,Y)=>{ae(e,D,b).editTracksInfo(F,H,Y)})},r=new WeakSet,s=function(F){return new Promise((H,Y)=>{ae(e,D,b).getStatus(F,H,Y)})},i=new WeakSet,a=function(F){return ae(e,_,E).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...F})},d=new WeakMap,o=new WeakMap,y=new WeakMap,p=new WeakMap,m=new WeakMap,g=new WeakMap,f=new WeakSet,c=function(){var F;return(F=this.castPlayer)==null?void 0:F.isMediaLoaded},x=new WeakSet,S=function(){ae(e,t)===this&&(Object.entries(ae(this,y)).forEach(([F,H])=>{ae(this,o).controller.removeEventListener(F,H)}),ze(e,t,void 0),this.muted=ae(this,o).isMuted,this.currentTime=ae(this,o).savedPlayerState.currentTime,ae(this,o).savedPlayerState.isPaused===!1&&this.play())},O=new WeakSet,C=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:ae(e,_,E).getCastState()}))},P=new WeakSet,w=async function(){var F,H;let{SESSION_RESUMED:Y}=cast.framework.SessionState;if(ae(e,_,E).getSessionState()===Y&&this.castSrc===((F=ae(e,D,b))==null?void 0:F.media.contentId)){ze(e,t,this),Object.entries(ae(this,y)).forEach(([$,Z])=>{ae(this,o).controller.addEventListener($,Z)});try{await We(H=e,r,s).call(H,new chrome.cast.media.GetStatusRequest)}catch($){console.error($)}ae(this,y)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),ae(this,y)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},U=new WeakSet,k=function(){var F;!ae(e,T,L)||this.castEnabled||(this.castEnabled=!0,We(F=e,i,a).call(F),this.textTracks.addEventListener("change",We(this,K,W).bind(this)),We(this,O,C).call(this),ze(this,o,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(ae(this,o)),ze(this,y,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:H})=>{H===!1&&We(this,x,S).call(this),this.dispatchEvent(new Event(H?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!ae(this,f,c)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var H,Y;((H=this.castPlayer)==null?void 0:H.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Y=this.castPlayer)==null?void 0:Y.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!ae(this,f,c)||(await Promise.resolve(),We(this,N,B).call(this))}}))},N=new WeakSet,B=function(){We(this,K,W).call(this)},K=new WeakSet,W=async function(){var F,H,Y,$,Z,q;if(!this.castPlayer)return;let oe=((H=(F=ae(this,o).mediaInfo)==null?void 0:F.tracks)!=null?H:[]).filter(({type:Q})=>Q===chrome.cast.media.TrackType.TEXT),X=[...this.textTracks].filter(({kind:Q})=>Q==="subtitles"||Q==="captions"),ie=oe.map(({language:Q,name:te,trackId:ee})=>{var he;let{mode:Se}=(he=X.find(pe=>pe.language===Q&&pe.label===te))!=null?he:{};return Se?{mode:Se,trackId:ee}:!1}).filter(Boolean),fe=ie.filter(({mode:Q})=>Q!=="showing").map(({trackId:Q})=>Q),ue=ie.find(({mode:Q})=>Q==="showing"),Ae=(Z=($=(Y=ae(e,I,M))==null?void 0:Y.getSessionObj().media[0])==null?void 0:$.activeTrackIds)!=null?Z:[],re=Ae;if(Ae.length&&(re=re.filter(Q=>!fe.includes(Q))),(ue==null?void 0:ue.trackId)&&(re=[...re,ue.trackId]),re=[...new Set(re)],!((Q,te)=>Q.length===te.length&&Q.every(ee=>te.includes(ee)))(Ae,re))try{let Q=new chrome.cast.media.EditTracksInfoRequest(re);await We(q=e,A,u).call(q,Q)}catch(Q){console.error(Q)}},Le(e,h),Le(e,T),Le(e,_),Le(e,I),Le(e,D),Le(e,A),Le(e,r),Le(e,i),Pr(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Pr(e,"instances",new Set),Le(e,t,void 0),Le(e,l,!1),Pr(e,"initCast",()=>{var F;ae(e,h,R)?ae(e,T,L)?ae(F=e,n).call(F,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var H;return ae(H=e,n).call(H,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var H;return ae(H=e,n).call(H,chrome.cast.isAvailable)})}}),Le(e,n,F=>{if(F){ze(e,l,!0);let{CAST_STATE_CHANGED:H}=cast.framework.CastContextEventType;ae(e,_,E).addEventListener(H,$=>{e.instances.forEach(Z=>{var q;return We(q=Z,O,C).call(q,$)})});let{SESSION_STATE_CHANGED:Y}=cast.framework.CastContextEventType;ae(e,_,E).addEventListener(Y,$=>{e.instances.forEach(Z=>{var q;return We(q=Z,P,w).call(q,$)})}),e.instances.forEach($=>{var Z;return We(Z=$,U,k).call(Z)})}}),e},Bi=vu(HTMLVideoElement);customElements.get("castable-video")||(customElements.define("castable-video",Bi,{extends:"video"}),globalThis.CastableVideoElement=Bi);Bi.initCast();var Fi=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Ms=document.createElement("template");Ms.innerHTML=`
1245
- <style>
1246
- :host {
1247
- display: inline-block;
1248
- line-height: 0;
1249
- width: auto;
1250
- height: auto;
1251
- }
1252
-
1253
- video {
1254
- max-width: 100%;
1255
- max-height: 100%;
1256
- min-width: 100%;
1257
- min-height: 100%;
1258
- }
1259
- </style>
1260
- <video is="castable-video" part="video" crossorigin></video>
1261
- <slot></slot>
1262
- `;var kr,wr,Ur,ji,Nr,Ki,Ft=class extends HTMLElement{constructor(){super();Le(this,Ur),Le(this,Nr),Le(this,kr,void 0),Le(this,wr,void 0),this.attachShadow({mode:"open"}),this.isConnected&&We(this,Ur,ji).call(this)}static get observedAttributes(){let v=[],e=l=>l.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(l=>{let n=!1;try{typeof this.prototype[l]=="function"&&(n=!0)}catch{}!n&&l!==l.toUpperCase()&&v.push(l.toLowerCase(),e(l))});let t=Object.getPrototypeOf(this).observedAttributes;return t&&(v=v.concat(t)),v}attributeChangedCallback(v,e,t){!ae(this,kr)&&!this.isConnected&&(ze(this,kr,!0),We(this,Ur,ji).call(this)),We(this,Nr,Ki).call(this,v,e,t)}connectedCallback(){}};kr=new WeakMap,wr=new WeakMap,Ur=new WeakSet,ji=function(){if(ae(this,wr))return;ze(this,wr,!0),this.shadowRoot.append(Ms.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),Fi.forEach(e=>{this.nativeEl.addEventListener(e,t=>{this.dispatchEvent(new CustomEvent(t.type,{detail:t.detail}))})});let v=this.shadowRoot.querySelector("slot");v.addEventListener("slotchange",()=>{v.assignedElements().forEach(e=>{!["track","source"].includes(e.localName)||this.nativeEl.append(e)})}),Array.prototype.forEach.call(this.attributes,e=>{We(this,Nr,Ki).call(this,e.name,null,e.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},Nr=new WeakSet,Ki=function(v,e,t){let l=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),n=gu(l,v),h=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;n&&!h?typeof this[n]=="boolean"?t===null?this[n]=!1:this[n]=!0:this[n]=t:t===null?this.nativeEl.removeAttribute(v):["id","class"].indexOf(v)===-1&&this.nativeEl.setAttribute(v,t)};var Rs=[],Os=document.createElement("video",{is:"castable-video"}),mu=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let v=Object.getPrototypeOf(Os);v&&v!==HTMLElement.prototype;v=Object.getPrototypeOf(v))Object.getOwnPropertyNames(v).forEach(e=>{mu.indexOf(e)===-1&&Rs.push(e)});Rs.forEach(v=>{if(!(v in Ft.prototype))if(typeof Os[v]=="function")Ft.prototype[v]=function(){return this.nativeEl[v].apply(this.nativeEl,arguments)};else{let e={get(){return this.nativeEl[v]}};v!==v.toUpperCase()&&(e.set=function(t){this.nativeEl[v]=t}),Object.defineProperty(Ft.prototype,v,e)}});function gu(v,e){let t=null;return v.forEach(l=>{l.toLowerCase()==e.toLowerCase()&&(t=l)}),t}globalThis.customElements.get("custom-video")||(globalThis.customElements.define("custom-video",Ft),globalThis.CustomVideoElement=Ft);var Cs=Ft,me={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_MSE:"prefer-mse",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},pu=Object.values(me),Eu=hu(),yu="mux-video",Wi=class extends Cs{constructor(){super();this.__metadata={},this.__playerInitTime=fn()}static get observedAttributes(){var v;return[...pu,...(v=Cs.observedAttributes)!=null?v:[]]}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){var v;return(v=this.__playerSoftwareName)!=null?v:yu}set playerSoftwareName(v){this.__playerSoftwareName=v}get playerSoftwareVersion(){var v;return(v=this.__playerSoftwareVersion)!=null?v:Eu}set playerSoftwareVersion(v){this.__playerSoftwareVersion=v}get hls(){return console.warn("<mux-video>.hls is deprecated, please use ._hls instead"),this._hls}get _hls(){return this.__hls}get mux(){return this.nativeEl.mux}get error(){var v;return(v=mn(this.nativeEl))!=null?v:null}get errorTranslator(){return this.__errorTranslator}set errorTranslator(v){this.__errorTranslator=v}get src(){return this.getAttribute("src")}set src(v){v!==this.src&&(v==null?this.removeAttribute("src"):this.setAttribute("src",v))}get type(){var v;return(v=this.getAttribute(me.TYPE))!=null?v:void 0}set type(v){v!==this.type&&(v?this.setAttribute(me.TYPE,v):this.removeAttribute(me.TYPE))}get autoplay(){let v=this.getAttribute("autoplay");return v===null?!1:v===""?!0:v}set autoplay(v){let e=this.autoplay;v!==e&&(v?this.setAttribute("autoplay",typeof v=="string"?v:""):this.removeAttribute("autoplay"))}get debug(){return this.getAttribute(me.DEBUG)!=null}set debug(v){v!==this.debug&&(v?this.setAttribute(me.DEBUG,""):this.removeAttribute(me.DEBUG))}get startTime(){let v=this.getAttribute(me.START_TIME);if(v==null)return;let e=+v;return Number.isNaN(e)?void 0:e}set startTime(v){v!==this.startTime&&(v==null?this.removeAttribute(me.START_TIME):this.setAttribute(me.START_TIME,`${v}`))}get playbackId(){var v;return(v=this.getAttribute(me.PLAYBACK_ID))!=null?v:void 0}set playbackId(v){v!==this.playbackId&&(v?this.setAttribute(me.PLAYBACK_ID,v):this.removeAttribute(me.PLAYBACK_ID))}get customDomain(){var v;return(v=this.getAttribute(me.CUSTOM_DOMAIN))!=null?v:void 0}set customDomain(v){v!==this.customDomain&&(v?this.setAttribute(me.CUSTOM_DOMAIN,v):this.removeAttribute(me.CUSTOM_DOMAIN))}get envKey(){var v;return(v=this.getAttribute(me.ENV_KEY))!=null?v:void 0}set envKey(v){v!==this.envKey&&(v?this.setAttribute(me.ENV_KEY,v):this.removeAttribute(me.ENV_KEY))}get beaconCollectionDomain(){var v;return(v=this.getAttribute(me.BEACON_COLLECTION_DOMAIN))!=null?v:void 0}set beaconCollectionDomain(v){v!==this.beaconCollectionDomain&&(v?this.setAttribute(me.BEACON_COLLECTION_DOMAIN,v):this.removeAttribute(me.BEACON_COLLECTION_DOMAIN))}get streamType(){var v;return(v=this.getAttribute(me.STREAM_TYPE))!=null?v:void 0}set streamType(v){v!==this.streamType&&(v?this.setAttribute(me.STREAM_TYPE,v):this.removeAttribute(me.STREAM_TYPE))}get preferMse(){return this.getAttribute(me.PREFER_MSE)!=null}set preferMse(v){v?this.setAttribute(me.PREFER_MSE,""):this.removeAttribute(me.PREFER_MSE)}get metadata(){let v=this.getAttribute(me.METADATA_VIDEO_ID),e=this.getAttribute(me.METADATA_VIDEO_TITLE),t=this.getAttribute(me.METADATA_VIEWER_USER_ID);return{...this.__metadata,...v!=null?{video_id:v}:{},...e!=null?{video_title:e}:{},...t!=null?{viewer_user_id:t}:{}}}set metadata(v){this.__metadata=v!=null?v:{},this.mux&&this.mux.emit("hb",this.__metadata)}load(){let v=pn(this,this.nativeEl,this.__hls);this.__hls=v;let e=un(this.nativeEl,this.autoplay,v);this.__updateAutoplay=e}unload(){fi(this.nativeEl,this.__hls),this.__hls=void 0}attributeChangedCallback(v,e,t){var l;switch(v){case me.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case me.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":let n=!!e,h=!!t;!n&&h?this.load():n&&!h?this.unload():n&&h&&(this.unload(),this.load());break;case"autoplay":if(t===e)break;(l=this.__updateAutoplay)==null||l.call(this,this.autoplay);break;case me.PLAYBACK_ID:this.src=hn(t!=null?t:void 0,{domain:this.customDomain});break;case me.DEBUG:let R=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=R);break;case me.METADATA_URL:t&&fetch(t).then(T=>T.json()).then(T=>this.metadata=T).catch(T=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;default:break}super.attributeChangedCallback(v,e,t)}disconnectedCallback(){this.unload()}};globalThis.customElements.get("mux-video")||(globalThis.customElements.define("mux-video",Wi),globalThis.MuxVideoElement=Wi);var Ps=Wi;var Tu="en",Lt={code:Tu};var ks="en";function ge(v,e=!0){var n,h;let t=e&&(h=(n=Lt)==null?void 0:n[v])!=null?h:v,l=e?Lt.code:ks;return new ws(t,l)}var ws=class{constructor(e,t=(l=>(l=Lt.code)!=null?l:ks)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,l)=>{var n;return(n=e[l])!=null?n:""})}toString(){return this.message}};function Us(v){let e="";return Object.entries(v).forEach(([t,l])=>{l!=null&&(e+=`${bu(t)}: ${l}; `)}),e?e.trim():void 0}function bu(v){return v.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Ns(v){return v.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function nr(v){if(v==null)return;let e=+v;return Number.isNaN(e)?void 0:e}function Br(v){let e=Au(v).toString();return e?"?"+e:""}function Au(v){let e={};for(let t in v)v[t]!=null&&(e[t]=v[t]);return new URLSearchParams(e)}function ar(v){let t=v.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),l=decodeURIComponent(atob(t).split("").map(function(n){return"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(l)}var Hi=(v,e)=>!v||!e?!1:v.contains(e)?!0:Hi(v,e.getRootNode().host);var Gi="mux.com",Su=()=>{try{return"0.1.0-beta.23"}catch{}return"UNKNOWN"},_u=Su(),Fr=()=>_u,Vi=(v,{token:e,domain:t=Gi}={})=>`https://stream.${t}/${v}.m3u8${Br(!!e?{token:e}:{redundant_streams:!0})}`,Bs=(v,{token:e,thumbnailTime:t,domain:l=Gi}={})=>{let n=e==null?t:void 0;return`https://image.${l}/${v}/thumbnail.jpg${Br({token:e,time:n})}`},Fs=(v,{token:e,domain:t=Gi}={})=>`https://image.${t}/${v}/storyboard.vtt${Br({token:e})}`,xu={crossorigin:"crossOrigin",playsinline:"playsInline"};function js(v){var e;return(e=xu[v])!=null?e:Ns(v)}var Ks=v=>{var t,l;let{media:e}=v;return(l=(t=e==null?void 0:e._hls)==null?void 0:t.liveSyncPosition)!=null?l:(e==null?void 0:e.seekable.length)?e==null?void 0:e.seekable.end(e.seekable.length-1):void 0},$i=v=>{let e=Ks(v);if(e==null){console.warn("attempting to seek to live but cannot determine live edge time!");return}v.currentTime=e},Lu=1,Du=5,Ws=3,Hs=.5,Gs=v=>{var h;let{streamType:e}=v,t=Ks(v),l=(h=v.media)==null?void 0:h.currentTime;if(t==null||l==null)return!1;let n=t-l;return e===ve.LL_LIVE||e===ve.LL_DVR?n<=Lu*(Ws+Hs):e===ve.LIVE||e===ve.DVR?n<=Du*(Ws+Hs):!1};var Vs=`[mux-player ${Fr()}]`;function st(...v){console.warn(Vs,...v)}function Dt(...v){console.error(Vs,...v)}function jr(v){var t;let e=(t=v.message)!=null?t:"";if(v.file){let l="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${ge("Read more: ")}
1263
- ${l}${v.file}`}st(e)}var Pe={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",SRC:"src",POSTER:"poster",PRELOAD:"preload"},Kr={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},Iu=Fi.filter(v=>v!=="error"),Mu=Object.values(Pe),Ru=Object.values(Kr);function $s(v){v.querySelectorAll(":scope > track").forEach(e=>{var t;(t=v.media)==null||t.append(e.cloneNode())}),Iu.forEach(e=>{var t;(t=v.media)==null||t.addEventListener(e,l=>{v.dispatchEvent(new Event(l.type))})})}var Ys=class extends HTMLElement{static get observedAttributes(){return[...Mu,...Ru]}constructor(){super();this.querySelectorAll(":scope > track").forEach(l=>{var n;(n=this.media)==null||n.append(l.cloneNode())});let e=l=>{for(let n of l)n.type==="childList"&&(n.removedNodes.forEach(h=>{var T,L;let R=(T=this.media)==null?void 0:T.querySelector(`track[src="${h.src}"]`);R&&((L=this.media)==null||L.removeChild(R))}),n.addedNodes.forEach(h=>{var R;(R=this.media)==null||R.append(h.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,l){switch(e){case Kr.MUTED:{this.media&&(this.media.muted=l!=null);return}case Kr.VOLUME:{let n=+l;this.media&&!Number.isNaN(n)&&(this.media.volume=n);return}case Kr.PLAYBACKRATE:{let n=+l;this.media&&!Number.isNaN(n)&&(this.media.playbackRate=n);return}}}play(){var e;return(e=this.media)==null?void 0:e.play()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get video(){return st("<mux-player>.video is deprecated, please use .media instead"),this.media}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e;return(e=this.media)==null?void 0:e.buffered}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e;return(e=this.media)==null?void 0:e.videoWidth}get videoHeight(){var e;return(e=this.media)==null?void 0:e.videoHeight}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get src(){return mt(this,Pe.SRC)}set src(e){this.setAttribute(Pe.SRC,`${e}`)}get poster(){var e;return(e=mt(this,Pe.POSTER))!=null?e:""}set poster(e){this.setAttribute(Pe.POSTER,`${e}`)}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get crossOrigin(){return mt(this,Pe.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Pe.CROSSORIGIN,`${e}`)}get autoplay(){return mt(this,Pe.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Pe.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Pe.AUTOPLAY)}get loop(){return mt(this,Pe.LOOP)!=null}set loop(e){e?this.setAttribute(Pe.LOOP,""):this.removeAttribute(Pe.LOOP)}get muted(){return mt(this,Pe.MUTED)!=null}set muted(e){e?this.setAttribute(Pe.MUTED,""):this.removeAttribute(Pe.MUTED)}get playsInline(){return mt(this,Pe.PLAYSINLINE)!=null}set playsInline(e){e?this.setAttribute(Pe.PLAYSINLINE,""):this.removeAttribute(Pe.PLAYSINLINE)}get preload(){return mt(this,Pe.PRELOAD)}set preload(e){e?this.setAttribute(Pe.PRELOAD,e):this.removeAttribute(Pe.PRELOAD)}};function mt(v,e){return v.media?v.media.getAttribute(e):v.getAttribute(e)}var Yi=Ys;var zs=`
1420
+ `;var go=`
1264
1421
  :host {
1265
1422
  z-index: 100;
1266
1423
  display: flex;
@@ -1318,17 +1475,17 @@ ${l}${v.file}`}st(e)}var Pe={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
1318
1475
  text-align: center;
1319
1476
  line-height: 1.4;
1320
1477
  }
1321
- `,Xs=document.createElement("template");Xs.innerHTML=`
1478
+ `,Eo=document.createElement("template");Eo.innerHTML=`
1322
1479
  <style>
1323
- ${zs}
1480
+ ${go}
1324
1481
  </style>
1325
1482
 
1326
1483
  <div class="dialog">
1327
1484
  <slot></slot>
1328
1485
  </div>
1329
- `;var It=class extends HTMLElement{constructor(){super();var e;this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),Qs(this)}close(){!this.hasAttribute("open")||(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),Ou(this))}attributeChangedCallback(e,t,l){e==="open"&&t!==l&&(l!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&Qs(this)}};It.styles=zs,It.template=Xs,It.observedAttributes=["open"];function Qs(v){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(v.dispatchEvent(e),e.defaultPrevented)return;let t=v.querySelector("[autofocus]:not([disabled])");!t&&v.tabIndex>=0&&(t=v),t||(t=Js(v.shadowRoot)),v._previouslyFocusedElement=document.activeElement,document.activeElement instanceof HTMLElement&&document.activeElement.blur(),v.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function Js(v){let t=["button","input","keygen","select","textarea"].map(function(n){return n+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let l=v==null?void 0:v.querySelector(t.join(", "));if(!l&&"attachShadow"in Element.prototype){let n=(v==null?void 0:v.querySelectorAll("*"))||[];for(let h=0;h<n.length&&!(n[h].tagName&&n[h].shadowRoot&&(l=Js(n[h].shadowRoot),l));h++);}return l}function Ou(v){v._previouslyFocusedElement instanceof HTMLElement&&v._previouslyFocusedElement.focus()}globalThis.customElements.get("media-dialog")||(globalThis.customElements.define("media-dialog",It),globalThis.MediaDialog=It);var zi=It;var Zs=document.createElement("template");Zs.innerHTML=`
1486
+ `;var wt=class extends HTMLElement{constructor(){super();var e;this.attachShadow({mode:"open"}),(e=this.shadowRoot)==null||e.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),yo(this)}close(){!this.hasAttribute("open")||(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),td(this))}attributeChangedCallback(e,t,a){e==="open"&&t!==a&&(a!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&yo(this)}};wt.styles=go,wt.template=Eo,wt.observedAttributes=["open"];function yo(f){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(f.dispatchEvent(e),e.defaultPrevented)return;let t=f.querySelector("[autofocus]:not([disabled])");!t&&f.tabIndex>=0&&(t=f),t||(t=To(f.shadowRoot)),f._previouslyFocusedElement=document.activeElement,document.activeElement instanceof HTMLElement&&document.activeElement.blur(),f.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function To(f){let t=["button","input","keygen","select","textarea"].map(function(i){return i+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let a=f==null?void 0:f.querySelector(t.join(", "));if(!a&&"attachShadow"in Element.prototype){let i=(f==null?void 0:f.querySelectorAll("*"))||[];for(let c=0;c<i.length&&!(i[c].tagName&&i[c].shadowRoot&&(a=To(i[c].shadowRoot),a));c++);}return a}function td(f){f._previouslyFocusedElement instanceof HTMLElement&&f._previouslyFocusedElement.focus()}globalThis.customElements.get("media-dialog")||(globalThis.customElements.define("media-dialog",wt),globalThis.MediaDialog=wt);var dn=wt;var bo=document.createElement("template");bo.innerHTML=`
1330
1487
  <style>
1331
- ${zi.styles}
1488
+ ${dn.styles}
1332
1489
 
1333
1490
  .close {
1334
1491
  background: none;
@@ -1357,7 +1514,7 @@ ${l}${v.file}`}st(e)}var Pe={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
1357
1514
  </svg>
1358
1515
  </button>
1359
1516
  </slot>
1360
- `;var Wr=class extends zi{constructor(){super();var e,t;(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};Wr.template=Zs;globalThis.customElements.get("mxp-dialog")||(globalThis.customElements.define("mxp-dialog",Wr),globalThis.MxpDialog=Wr);var qs=`:host {
1517
+ `;var ri=class extends dn{constructor(){super();var e,t;(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};ri.template=bo;globalThis.customElements.get("mxp-dialog")||(globalThis.customElements.define("mxp-dialog",ri),globalThis.MxpDialog=ri);var Ao=`:host {
1361
1518
  display: inline-block;
1362
1519
  }
1363
1520
 
@@ -1399,80 +1556,83 @@ media-controller {
1399
1556
  .mxp-seek-to-live-button[aria-disabled]::before {
1400
1557
  color: #fb3c4d;
1401
1558
  }
1402
- `;var eo=v=>_e`
1559
+ `;var So=f=>Te`
1403
1560
  <style>
1404
- ${qs}
1561
+ ${Ao}
1405
1562
  </style>
1406
- ${Pu(v)}
1407
- `,Pu=v=>{var e,t,l,n,h,R,T,L,_,E,I,M,D,b,A,u,r,s,i,a,d,o,y,p,m,g;return _e`
1408
- <media-theme-mux
1409
- audio="${v.audio||!1}"
1410
- style="${(e=Us({"--primary-color":v.primaryColor,"--secondary-color":v.secondaryColor,"--mux-time-range-padding":v.secondaryColor?"0":null,"--media-range-track-border-radius":v.secondaryColor?"0":null}))!=null?e:!1}"
1411
- class="size-${v.playerSize}"
1412
- stream-type="${v.streamType}"
1413
- player-size="${v.playerSize}"
1414
- default-hidden-captions="${v.defaultHiddenCaptions}"
1415
- forward-seek-offset="${v.forwardSeekOffset}"
1416
- backward-seek-offset="${v.backwardSeekOffset}"
1563
+ ${ad(f)}
1564
+ `,id=Object.values(Ie).flatMap(f=>f.split(" ")),nd=[...new Set(id)].join(", "),ad=f=>{var e,t,a,i,c,R,E,L,_,y,I,M,D,b,A,u,r,o,n,s,d,l,T;return Te`
1565
+ <${on((e=en(f.theme))!=null?e:"media-theme-mux")}
1566
+ nohotkeys="${(t=f.noHotKeys)!=null?t:!1}"
1567
+ audio="${f.audio||!1}"
1568
+ style="${(a=ms({"--primary-color":f.primaryColor,"--secondary-color":f.secondaryColor}))!=null?a:!1}"
1569
+ class="size-${f.playerSize}${f.secondaryColor?" two-tone":""}"
1570
+ stream-type="${f.streamType}"
1571
+ player-size="${f.playerSize}"
1572
+ default-hidden-captions="${f.defaultHiddenCaptions}"
1573
+ forward-seek-offset="${f.forwardSeekOffset}"
1574
+ backward-seek-offset="${f.backwardSeekOffset}"
1575
+ exportparts="seek-live, ${nd}"
1417
1576
  >
1418
1577
  <mux-video
1419
1578
  slot="media"
1420
1579
  crossorigin
1421
1580
  playsinline
1422
- autoplay="${(t=v.autoplay)!=null?t:!1}"
1423
- muted="${(l=v.muted)!=null?l:!1}"
1424
- loop="${(n=v.loop)!=null?n:!1}"
1425
- preload="${(h=v.preload)!=null?h:!1}"
1426
- debug="${(R=v.debug)!=null?R:!1}"
1427
- prefer-mse="${(T=v.preferMse)!=null?T:!1}"
1428
- start-time="${v.startTime!=null?v.startTime:!1}"
1429
- metadata-video-id="${(E=(_=v.metadataVideoId)!=null?_:(L=v.metadata)==null?void 0:L.video_id)!=null?E:!1}"
1430
- metadata-video-title="${(D=(M=v.metadataVideoTitle)!=null?M:(I=v.metadata)==null?void 0:I.video_title)!=null?D:!1}"
1431
- metadata-viewer-user-id="${(u=(A=v.metadataViewerUserId)!=null?A:(b=v.metadata)==null?void 0:b.viewer_user_id)!=null?u:!1}"
1432
- beacon-collection-domain="${(r=v.beaconCollectionDomain)!=null?r:!1}"
1433
- player-software-name="${v.playerSoftwareName}"
1434
- player-software-version="${v.playerSoftwareVersion}"
1435
- env-key="${(s=v.envKey)!=null?s:!1}"
1436
- stream-type="${(i=v.streamType)!=null?i:!1}"
1437
- custom-domain="${(a=v.customDomain)!=null?a:!1}"
1438
- src="${v.src?v.src:v.playbackId?Vi(v.playbackId,{domain:v.customDomain,token:v.tokens.playback}):!1}"
1439
- poster="${v.poster?v.poster:v.playbackId&&!v.audio?Bs(v.playbackId,{domain:v.customDomain,thumbnailTime:(d=v.thumbnailTime)!=null?d:v.startTime,token:v.tokens.thumbnail}):!1}"
1440
- cast-src="${v.src?v.src:v.playbackId?Vi(v.playbackId,{domain:v.customDomain,token:v.tokens.playback}):!1}"
1441
- cast-stream-type="${[ve.LIVE,ve.LL_LIVE].includes(v.streamType)?"live":!1}"
1581
+ autoplay="${(i=f.autoplay)!=null?i:!1}"
1582
+ muted="${(c=f.muted)!=null?c:!1}"
1583
+ loop="${(R=f.loop)!=null?R:!1}"
1584
+ preload="${(E=f.preload)!=null?E:!1}"
1585
+ debug="${(L=f.debug)!=null?L:!1}"
1586
+ prefer-mse="${(_=f.preferMse)!=null?_:!1}"
1587
+ start-time="${f.startTime!=null?f.startTime:!1}"
1588
+ metadata-video-id="${(y=f.metadataVideoId)!=null?y:!1}"
1589
+ metadata-video-title="${(I=f.metadataVideoTitle)!=null?I:!1}"
1590
+ metadata-viewer-user-id="${(M=f.metadataViewerUserId)!=null?M:!1}"
1591
+ beacon-collection-domain="${(D=f.beaconCollectionDomain)!=null?D:!1}"
1592
+ player-software-name="${f.playerSoftwareName}"
1593
+ player-software-version="${f.playerSoftwareVersion}"
1594
+ env-key="${(b=f.envKey)!=null?b:!1}"
1595
+ stream-type="${(A=f.streamType)!=null?A:!1}"
1596
+ custom-domain="${(u=f.customDomain)!=null?u:!1}"
1597
+ src="${f.src?f.src:f.playbackId?qi(f.playbackId,{domain:f.customDomain,token:f.tokens.playback}):!1}"
1598
+ poster="${f.poster?f.poster:f.playbackId&&!f.audio?gs(f.playbackId,{domain:f.customDomain,thumbnailTime:(r=f.thumbnailTime)!=null?r:f.startTime,token:f.tokens.thumbnail}):!1}"
1599
+ cast-src="${f.src?f.src:f.playbackId?qi(f.playbackId,{domain:f.customDomain,token:f.tokens.playback}):!1}"
1600
+ cast-stream-type="${[ve.LIVE,ve.LL_LIVE].includes(f.streamType)?"live":!1}"
1442
1601
  >
1443
- ${v.playbackId&&!v.audio&&![ve.LIVE,ve.LL_LIVE,ve.DVR,ve.LL_DVR].includes(v.streamType)?_e`<track
1444
- label="thumbnails"
1445
- default
1446
- kind="metadata"
1447
- src="${Fs(v.playbackId,{domain:v.customDomain,token:v.tokens.storyboard})}"
1448
- />`:_e``}
1602
+ ${f.playbackId&&!f.audio&&![ve.LIVE,ve.LL_LIVE,ve.DVR,ve.LL_DVR].includes(f.streamType)?Te`<track
1603
+ label="thumbnails"
1604
+ default
1605
+ kind="metadata"
1606
+ src="${Es(f.playbackId,{domain:f.customDomain,token:f.tokens.storyboard})}"
1607
+ />`:Te``}
1449
1608
  </mux-video>
1450
1609
  <button
1451
1610
  slot="seek-to-live-button"
1452
- aria-disabled="${v.inLiveWindow}"
1453
- onclick="${function(f){var c;if((c=v.onSeekToLive)==null||c.call(v,f),v.paused){let x=new CustomEvent("mediaplayrequest",{composed:!0,bubbles:!0});this.dispatchEvent(x)}}}"
1611
+ part="seek-live button"
1454
1612
  class="mxp-seek-to-live-button"
1613
+ aria-disabled="${f.inLiveWindow}"
1614
+ onclick="${function(g){var m;if((m=f.onSeekToLive)==null||m.call(f,g),f.paused){let p=new CustomEvent("mediaplayrequest",{composed:!0,bubbles:!0});this.dispatchEvent(p)}}}"
1455
1615
  >
1456
1616
  Live
1457
1617
  </button>
1458
1618
  <mxp-dialog
1459
1619
  no-auto-hide
1460
- open="${v.isDialogOpen}"
1461
- onclose="${v.onCloseErrorDialog}"
1462
- oninitfocus="${v.onInitFocusDialog}"
1620
+ open="${f.isDialogOpen}"
1621
+ onclose="${f.onCloseErrorDialog}"
1622
+ oninitfocus="${f.onInitFocusDialog}"
1463
1623
  >
1464
- ${((o=v.dialog)==null?void 0:o.title)?_e`<h3>${v.dialog.title}</h3>`:_e``}
1624
+ ${((o=f.dialog)==null?void 0:o.title)?Te`<h3>${f.dialog.title}</h3>`:Te``}
1465
1625
  <p>
1466
- ${(y=v.dialog)==null?void 0:y.message}
1467
- ${((p=v.dialog)==null?void 0:p.linkUrl)?_e`<a
1468
- href="${v.dialog.linkUrl}"
1469
- target="_blank"
1470
- rel="external noopener"
1471
- aria-label="${(m=v.dialog.linkText)!=null?m:""} ${ge("(opens in a new window)")}"
1472
- >${(g=v.dialog.linkText)!=null?g:v.dialog.linkUrl}</a
1473
- >`:_e``}
1626
+ ${(n=f.dialog)==null?void 0:n.message}
1627
+ ${((s=f.dialog)==null?void 0:s.linkUrl)?Te`<a
1628
+ href="${f.dialog.linkUrl}"
1629
+ target="_blank"
1630
+ rel="external noopener"
1631
+ aria-label="${(d=f.dialog.linkText)!=null?d:""} ${pe("(opens in a new window)")}"
1632
+ >${(l=f.dialog.linkText)!=null?l:f.dialog.linkUrl}</a
1633
+ >`:Te``}
1474
1634
  </p>
1475
1635
  </mxp-dialog>
1476
- </media-theme-mux>
1477
- `};function Hr(v,e,t,l,n){var T,L,_;let h={},R={};switch(v.code){case Oe.MEDIA_ERR_NETWORK:{switch(h.title=ge("Network Error",n),h.message=v.message,(T=v.data)==null?void 0:T.response.code){case 412:{h.title=ge("Video is not currently available",n),h.message=ge("The live stream or video file are not yet ready.",n),R.message=ge("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",n),R.file="412-not-playable.md";break}case 404:{h.title=ge("Video does not exist",n),h.message="",R.message=ge("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",n),R.file="404-not-found.md";break}case 403:{if(h.title=ge("Invalid playback URL",n),h.message=ge("The video URL or playback-token are formatted with incorrect or incomplete information.",n),R.message=ge("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",n),R.file="missing-signed-tokens.md",!l)break;let{exp:E,aud:I,sub:M}=ar(l),D=Date.now()>E*1e3,b=M!==t,A=I!=="v",u={timeStyle:"medium",dateStyle:"medium"};if(D){h.title=ge("Video URL has expired",n),h.message=ge("The video\u2019s secured playback-token has expired.",n),R.message=ge("This playback is using signed URLs and the playback-token has expired. Expired at: {expiredDate}. Current time: {currentDate}.",n).format({expiredDate:new Intl.DateTimeFormat(Lt.code,u).format(E*1e3),currentDate:new Intl.DateTimeFormat(Lt.code,u).format(Date.now())}),R.file="403-expired-token.md";break}if(b){h.title=ge("Video URL is formatted incorrectly",n),h.message=ge("The video\u2019s playback ID does not match the one encoded in the playback-token.",n),R.message=ge("The specified playback ID {playbackId} and the playback ID encoded in the playback-token {tokenPlaybackId} do not match.",n).format({playbackId:t,tokenPlaybackId:M}),R.file="403-playback-id-mismatch.md";break}if(A){h.title=ge("Video URL is formatted incorrectly",n),h.message=ge("The playback-token is formatted with incorrect information.",n),R.message=ge("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",n).format({tokenType:I}),R.file="403-incorrect-aud-value.md";break}R.message=ge("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",n),R.file="403-malformatted-token.md";break}}break}case Oe.MEDIA_ERR_DECODE:{let{message:E}=v;h={title:ge("Media Error",n),message:E},R.file="media-decode-error.md";break}case Oe.MEDIA_ERR_SRC_NOT_SUPPORTED:{let E=(_=(L=v.data)==null?void 0:L.response)==null?void 0:_.code;if(E>=400&&E<500){v.code=Oe.MEDIA_ERR_NETWORK,v.data={response:{code:E}},{dialog:h,devlog:R}=Hr(v,e,t,l);break}h={title:ge("Source Not Supported",n),message:v.message},R.file="media-src-not-supported.md";break}default:h={title:ge("Error",n),message:v.message};break}return e&&(h={title:ge("Your device appears to be offline",n),message:ge("Check your internet connection and try reloading this video.",n)}),{dialog:h,devlog:R}}var ku=Object.values(ve),wu=700,Uu=300,Xi={LG:"large",SM:"small",XS:"extra-small"};function Gr(v){let e=v.getBoundingClientRect();return e.width<Uu?Xi.XS:e.width<wu?Xi.SM:Xi.LG}var Nu={SRC:"src"},xe={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_MSE:"prefer-mse",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},De={DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio"};function Bu(v,e){var t,l;return{src:!v.playbackId&&v.src,poster:v.getAttribute("poster"),thumbnailTime:!v.tokens.thumbnail&&v.thumbnailTime,autoplay:v.autoplay,crossOrigin:v.crossOrigin,loop:v.loop,muted:v.muted,paused:v.paused,playsInline:v.playsInline,preload:v.preload,playbackId:v.playbackId,envKey:v.envKey,debug:v.debug,tokens:v.tokens,beaconCollectionDomain:v.beaconCollectionDomain,metadata:v.metadata,playerSoftwareName:v.playerSoftwareName,playerSoftwareVersion:v.playerSoftwareVersion,startTime:v.startTime,preferMse:v.preferMse,audio:v.audio,streamType:v.streamType,primaryColor:v.primaryColor,secondaryColor:v.secondaryColor,forwardSeekOffset:v.forwardSeekOffset,backwardSeekOffset:v.backwardSeekOffset,defaultHiddenCaptions:v.defaultHiddenCaptions,customDomain:(t=v.getAttribute(xe.CUSTOM_DOMAIN))!=null?t:void 0,playerSize:Gr((l=v.mediaController)!=null?l:v),metadataVideoId:v.getAttribute(xe.METADATA_VIDEO_ID),metadataVideoTitle:v.getAttribute(xe.METADATA_VIDEO_TITLE),metadataViewerUserId:v.getAttribute(xe.METADATA_VIEWER_USER_ID),...e}}var Fu=Object.values(xe),ju=Object.values(De),Ku=Fr(),Wu="mux-player",to={dialog:void 0,isDialogOpen:!1,inLiveWindow:!1},jt,lr,gt,Kt,ot,ur,ro,pt,sr,Wt,Qi,dr,io,$r,Hu,Yr,Gu,zr,Vu,Xr,$u,Qr,Yu,Jr,zu,Vr=class extends Yi{constructor(){super();He(this,ur);He(this,pt);He(this,Wt);He(this,dr);He(this,$r);He(this,Yr);He(this,zr);He(this,Xr);He(this,Qr);He(this,Jr);He(this,jt,!1);He(this,lr,{});He(this,gt,!0);He(this,Kt,void 0);He(this,ot,{...to,onCloseErrorDialog:()=>Be(this,pt,sr).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{Hi(this,document.activeElement)||e.preventDefault()},onSeekToLive:()=>$i(this)});this.attachShadow({mode:"open"}),this.isConnected&&Be(this,ur,ro).call(this)}static get observedAttributes(){var e;return[...(e=Yi.observedAttributes)!=null?e:[],...Fu,...ju]}get theme(){var e,t;return Array.from((t=(e=this.shadowRoot)==null?void 0:e.children)!=null?t:[]).find(({localName:l})=>l.startsWith("media-theme-"))}get mediaController(){var e,t;return(t=(e=this.theme)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("media-controller")}connectedCallback(){Be(this,dr,io).call(this),Be(this,$r,Hu).call(this)}disconnectedCallback(){Be(this,Yr,Gu).call(this)}attributeChangedCallback(e,t,l){switch(Ye(this,jt)||Be(this,ur,ro).call(this),super.attributeChangedCallback(e,t,l),[xe.PLAYBACK_ID,Nu.SRC,De.PLAYBACK_TOKEN].includes(e)&&t!==l&&Et(this,ot,{...Ye(this,ot),...to}),Be(this,Wt,Qi).call(this,{[js(e)]:l}),e){case De.THUMBNAIL_TIME:{l!=null&&this.tokens.thumbnail&&st(ge("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case De.THUMBNAIL_TOKEN:{let{aud:h}=ar(l);l&&h!=="t"&&st(ge("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:h}));break}case De.STORYBOARD_TOKEN:{let{aud:h}=ar(l);l&&h!=="s"&&st(ge("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:h}));break}case xe.PLAYBACK_ID:{l.includes("?token")&&Dt(ge("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:l})),this.streamType?this.streamType!=null&&!ku.includes(this.streamType)&&jr({file:"invalid-stream-type.md",message:ge("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand`, `live` or `ll-live`").format({streamType:this.streamType})}):jr({file:"invalid-stream-type.md",message:String(ge("No stream-type value supplied. Defaulting to `on-demand`. Please provide stream-type as either: `on-demand`, `live` or `ll-live`"))});break}}}get hasPlayed(){var e,t;return(t=(e=this.mediaController)==null?void 0:e.hasAttribute("media-has-played"))!=null?t:!1}get inLiveWindow(){return Ye(this,ot).inLiveWindow}get hls(){return st("<mux-player>.hls is deprecated, please use ._hls instead"),this._hls}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get audio(){return this.hasAttribute(De.AUDIO)}set audio(e){e||this.removeAttribute(De.AUDIO),this.setAttribute(De.AUDIO,"")}get thumbnailTime(){return nr(this.getAttribute(De.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(De.THUMBNAIL_TIME,`${e}`)}get primaryColor(){var e;return(e=this.getAttribute(De.PRIMARY_COLOR))!=null?e:void 0}set primaryColor(e){this.setAttribute(De.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e;return(e=this.getAttribute(De.SECONDARY_COLOR))!=null?e:void 0}set secondaryColor(e){this.setAttribute(De.SECONDARY_COLOR,`${e}`)}get forwardSeekOffset(){var e;return(e=nr(this.getAttribute(De.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute(De.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=nr(this.getAttribute(De.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute(De.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(De.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var e;return(e=this.getAttribute(xe.PLAYER_SOFTWARE_NAME))!=null?e:Wu}get playerSoftwareVersion(){var e;return(e=this.getAttribute(xe.PLAYER_SOFTWARE_VERSION))!=null?e:Ku}get beaconCollectionDomain(){var e;return(e=this.getAttribute(xe.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(xe.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(xe.BEACON_COLLECTION_DOMAIN))}get playbackId(){var e;return(e=this.getAttribute(xe.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){this.setAttribute(xe.PLAYBACK_ID,`${e}`)}get customDomain(){var e;return(e=this.getAttribute(xe.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(xe.CUSTOM_DOMAIN,e):this.removeAttribute(xe.CUSTOM_DOMAIN))}get envKey(){var e;return(e=or(this,xe.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(xe.ENV_KEY,`${e}`)}get debug(){return or(this,xe.DEBUG)!=null}set debug(e){e?this.setAttribute(xe.DEBUG,""):this.removeAttribute(xe.DEBUG)}get streamType(){return or(this,xe.STREAM_TYPE)}set streamType(e){this.setAttribute(xe.STREAM_TYPE,`${e}`)}get startTime(){return nr(or(this,xe.START_TIME))}set startTime(e){this.setAttribute(xe.START_TIME,`${e}`)}get preferMse(){return or(this,xe.PREFER_MSE)!=null}set preferMse(e){e?this.setAttribute(xe.PREFER_MSE,""):this.removeAttribute(xe.PREFER_MSE)}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){this.media&&(this.media.metadata=e)}get tokens(){let e=this.getAttribute(De.PLAYBACK_TOKEN),t=this.getAttribute(De.THUMBNAIL_TOKEN),l=this.getAttribute(De.STORYBOARD_TOKEN);return{...Ye(this,lr),...e!=null?{playback:e}:{},...t!=null?{thumbnail:t}:{},...l!=null?{storyboard:l}:{}}}set tokens(e){Et(this,lr,e!=null?e:{})}get playbackToken(){var e;return(e=this.getAttribute(De.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute(De.PLAYBACK_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute(De.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute(De.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute(De.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute(De.STORYBOARD_TOKEN,`${e}`)}};jt=new WeakMap,lr=new WeakMap,gt=new WeakMap,Kt=new WeakMap,ot=new WeakMap,ur=new WeakSet,ro=function(){var e,t;Ye(this,jt)||(Et(this,jt,!0),Be(this,pt,sr).call(this,{playerSize:Gr(this)}),customElements.upgrade(this.theme),this.theme instanceof Is||Dt("<media-theme-mux> failed to upgrade!"),customElements.upgrade(this.media),this.media instanceof Ps||Dt("<mux-video> failed to upgrade!"),customElements.upgrade(this.mediaController),this.mediaController instanceof Zt||Dt("<media-controller> failed to upgrade!"),$s(this),Be(this,Xr,$u).call(this),Be(this,Qr,Yu).call(this),Be(this,zr,Vu).call(this),Et(this,gt,(t=(e=this.mediaController)==null?void 0:e.hasAttribute("user-inactive"))!=null?t:!0),Be(this,Jr,zu).call(this))},pt=new WeakSet,sr=function(e){Object.assign(Ye(this,ot),e),Be(this,Wt,Qi).call(this)},Wt=new WeakSet,Qi=function(e={}){rr(eo(Bu(this,{...Ye(this,ot),...e})),this.shadowRoot)},dr=new WeakSet,io=function(){var e,t;Ye(this,ot).playerSize!=Gr((e=this.mediaController)!=null?e:this)&&Be(this,pt,sr).call(this,{playerSize:Gr((t=this.mediaController)!=null?t:this)})},$r=new WeakSet,Hu=function(){var e;Et(this,Kt,new ResizeObserver(()=>Be(this,dr,io).call(this))),Ye(this,Kt).observe((e=this.mediaController)!=null?e:this)},Yr=new WeakSet,Gu=function(){var e;(e=Ye(this,Kt))==null||e.disconnect()},zr=new WeakSet,Vu=function(){var t,l,n,h,R;(t=this.mediaController)==null||t.addEventListener("mediaplayrequest",T=>{var L;((L=T.target)==null?void 0:L.localName)==="media-play-button"&&this.streamType&&[ve.LIVE,ve.LL_LIVE,ve.DVR,ve.LL_DVR].includes(this.streamType)&&this.hasPlayed&&$i(this)});let e=()=>{let T=Gs(this),L=Ye(this,ot).inLiveWindow;T!==L&&(Be(this,pt,sr).call(this,{inLiveWindow:T}),this.dispatchEvent(new CustomEvent("inlivewindowchange",{composed:!0,bubbles:!0,detail:this.inLiveWindow})))};(l=this.media)==null||l.addEventListener("progress",e),(n=this.media)==null||n.addEventListener("waiting",e),(h=this.media)==null||h.addEventListener("timeupdate",e),(R=this.media)==null||R.addEventListener("emptied",e)},Xr=new WeakSet,$u=function(){var t;let e=l=>{let{detail:n}=l;if(n instanceof Oe||(n=new Oe(n.message,n.code,n.fatal)),!(n==null?void 0:n.fatal)){st(n),n.data&&st(`${n.name} data:`,n.data);return}let{dialog:h,devlog:R}=Hr(n,!window.navigator.onLine,this.playbackId,this.playbackToken);R.message&&jr(R),Dt(n),n.data&&Dt(`${n.name} data:`,n.data),Be(this,pt,sr).call(this,{isDialogOpen:!0,dialog:h})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(l={})=>{var h,R,T;if(!((h=this.media)==null?void 0:h.error))return l;let{devlog:n}=Hr((R=this.media)==null?void 0:R.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(T=this.media)==null?void 0:T.error.code,player_error_message:n.message?String(n.message):l.player_error_message}}),(t=this.media)==null||t.addEventListener("error",l=>{var h,R;let{detail:n}=l;if(!n){let{message:T,code:L}=(R=(h=this.media)==null?void 0:h.error)!=null?R:{};n=new Oe(T,L)}!(n==null?void 0:n.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:n}))})},Qr=new WeakSet,Yu=function(){var t,l,n,h;let e=()=>Be(this,Wt,Qi).call(this);(l=(t=this.media)==null?void 0:t.textTracks)==null||l.addEventListener("addtrack",e),(h=(n=this.media)==null?void 0:n.textTracks)==null||h.addEventListener("removetrack",e)},Jr=new WeakSet,zu=function(){var E,I;let e=this.mediaController,t=/.*Version\/.*Safari\/.*/.test(navigator.userAgent);if(/.*iPhone.*/.test(navigator.userAgent))return;let n,h=new WeakMap,R=()=>this.streamType&&[ve.LIVE,ve.LL_LIVE].includes(this.streamType)&&!this.secondaryColor&&this.offsetWidth>=800,T=(M,D)=>{if(R())return;Array.from(M&&M.activeCues||[]).forEach(A=>{if(!(!A.snapToLines||A.line<-5||A.line>=0&&A.line<10))if(!D||this.paused){let u=A.text.split(`
1478
- `).length,r=t?-2:-3;this.streamType&&[ve.LIVE,ve.LL_LIVE].includes(this.streamType)&&(r=t?-1:-2);let s=r-u;if(A.line===s)return;h.has(A)||h.set(A,A.line),A.line=0,A.line=s}else setTimeout(()=>{A.line=h.get(A)||"auto"},500)})},L=()=>{var M;T(n,(M=e==null?void 0:e.hasAttribute("user-inactive"))!=null?M:!1)},_=()=>{var b;let D=Array.from(((b=e==null?void 0:e.media)==null?void 0:b.textTracks)||[]).filter(A=>["subtitles","captions"].includes(A.kind)&&A.mode==="showing")[0];D!==n&&(n==null||n.removeEventListener("cuechange",L)),n=D,n==null||n.addEventListener("cuechange",L),T(n,Ye(this,gt))};_(),(E=e==null?void 0:e.media)==null||E.textTracks.addEventListener("change",_),(I=e==null?void 0:e.media)==null||I.textTracks.addEventListener("addtrack",_),e==null||e.addEventListener("userinactivechange",()=>{let M=e==null?void 0:e.hasAttribute("user-inactive");Ye(this,gt)!==M&&(Et(this,gt,M),T(n,Ye(this,gt)))})};function or(v,e){return v.media?v.media.getAttribute(e):v.getAttribute(e)}globalThis.customElements.get("mux-player")||(globalThis.customElements.define("mux-player",Vr),globalThis.MuxPlayerElement=Vr);var Wm=Vr;})();
1636
+ </${on((T=en(f.theme))!=null?T:"media-theme-mux")}>
1637
+ `};function ii(f,e,t,a,i){var E,L,_;let c={},R={};switch(f.code){case Oe.MEDIA_ERR_NETWORK:{switch(c.title=pe("Network Error",i),c.message=f.message,(E=f.data)==null?void 0:E.response.code){case 412:{c.title=pe("Video is not currently available",i),c.message=pe("The live stream or video file are not yet ready.",i),R.message=pe("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",i),R.file="412-not-playable.md";break}case 404:{c.title=pe("Video does not exist",i),c.message="",R.message=pe("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",i),R.file="404-not-found.md";break}case 403:{if(c.title=pe("Invalid playback URL",i),c.message=pe("The video URL or playback-token are formatted with incorrect or incomplete information.",i),R.message=pe("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",i),R.file="missing-signed-tokens.md",!a)break;let{exp:y,aud:I,sub:M}=fr(a),D=Date.now()>y*1e3,b=M!==t,A=I!=="v",u={timeStyle:"medium",dateStyle:"medium"};if(D){c.title=pe("Video URL has expired",i),c.message=pe("The video\u2019s secured playback-token has expired.",i),R.message=pe("This playback is using signed URLs and the playback-token has expired. Expired at: {expiredDate}. Current time: {currentDate}.",i).format({expiredDate:new Intl.DateTimeFormat(It.code,u).format(y*1e3),currentDate:new Intl.DateTimeFormat(It.code,u).format(Date.now())}),R.file="403-expired-token.md";break}if(b){c.title=pe("Video URL is formatted incorrectly",i),c.message=pe("The video\u2019s playback ID does not match the one encoded in the playback-token.",i),R.message=pe("The specified playback ID {playbackId} and the playback ID encoded in the playback-token {tokenPlaybackId} do not match.",i).format({playbackId:t,tokenPlaybackId:M}),R.file="403-playback-id-mismatch.md";break}if(A){c.title=pe("Video URL is formatted incorrectly",i),c.message=pe("The playback-token is formatted with incorrect information.",i),R.message=pe("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",i).format({tokenType:I}),R.file="403-incorrect-aud-value.md";break}R.message=pe("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",i),R.file="403-malformatted-token.md";break}}break}case Oe.MEDIA_ERR_DECODE:{let{message:y}=f;c={title:pe("Media Error",i),message:y},R.file="media-decode-error.md";break}case Oe.MEDIA_ERR_SRC_NOT_SUPPORTED:{let y=(_=(L=f.data)==null?void 0:L.response)==null?void 0:_.code;if(y>=400&&y<500){f.code=Oe.MEDIA_ERR_NETWORK,f.data={response:{code:y}},{dialog:c,devlog:R}=ii(f,e,t,a);break}c={title:pe("Source Not Supported",i),message:f.message},R.file="media-src-not-supported.md";break}default:c={title:pe("Error",i),message:f.message};break}return e&&(c={title:pe("Your device appears to be offline",i),message:pe("Check your internet connection and try reloading this video.",i)}),{dialog:c,devlog:R}}var sd=Object.values(ve),od=700,ld=300,cn={LG:"large",SM:"small",XS:"extra-small"};function ni(f){let e=f.getBoundingClientRect();return e.width<ld?cn.XS:e.width<od?cn.SM:cn.LG}var ud={SRC:"src"},Le={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_MSE:"prefer-mse",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},be={DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys"};function dd(f,e){var t,a;return{src:!f.playbackId&&f.src,poster:f.getAttribute("poster"),theme:f.getAttribute("theme"),thumbnailTime:!f.tokens.thumbnail&&f.thumbnailTime,autoplay:f.autoplay,crossOrigin:f.crossOrigin,loop:f.loop,noHotKeys:f.hasAttribute(be.NOHOTKEYS),muted:f.muted,paused:f.paused,playsInline:f.playsInline,preload:f.preload,playbackId:f.playbackId,envKey:f.envKey,debug:f.debug,tokens:f.tokens,beaconCollectionDomain:f.beaconCollectionDomain,metadata:f.metadata,playerSoftwareName:f.playerSoftwareName,playerSoftwareVersion:f.playerSoftwareVersion,startTime:f.startTime,preferMse:f.preferMse,audio:f.audio,streamType:f.streamType,primaryColor:f.primaryColor,secondaryColor:f.secondaryColor,forwardSeekOffset:f.forwardSeekOffset,backwardSeekOffset:f.backwardSeekOffset,defaultHiddenCaptions:f.defaultHiddenCaptions,customDomain:(t=f.getAttribute(Le.CUSTOM_DOMAIN))!=null?t:void 0,playerSize:ni((a=f.mediaController)!=null?a:f),metadataVideoId:f.getAttribute(Le.METADATA_VIDEO_ID),metadataVideoTitle:f.getAttribute(Le.METADATA_VIDEO_TITLE),metadataViewerUserId:f.getAttribute(Le.METADATA_VIEWER_USER_ID),...e}}var cd=Object.values(Le),fd=Object.values(be),hd=Gr(),vd="mux-player",_o={dialog:void 0,isDialogOpen:!1,inLiveWindow:!1},Ut,Er,At,Qt,dt,Zt,fn,St,pr,Jt,hn,yr,xo,si,md,oi,pd,li,gd,ui,Ed,di,yd,ci,Td,ai=class extends rn{constructor(){super();$e(this,Zt);$e(this,St);$e(this,Jt);$e(this,yr);$e(this,si);$e(this,oi);$e(this,li);$e(this,ui);$e(this,di);$e(this,ci);$e(this,Ut,!1);$e(this,Er,{});$e(this,At,!0);$e(this,Qt,void 0);$e(this,dt,{..._o,onCloseErrorDialog:()=>Ne(this,St,pr).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{Zi(this,document.activeElement)||e.preventDefault()},onSeekToLive:()=>tn(this)});this.attachShadow({mode:"open"}),this.isConnected&&Ne(this,Zt,fn).call(this)}static get observedAttributes(){var e;return[...(e=rn.observedAttributes)!=null?e:[],...cd,...fd]}get theme(){var e,t;return Array.from((t=(e=this.shadowRoot)==null?void 0:e.children)!=null?t:[]).find(({localName:a})=>a.startsWith("media-theme-"))}get mediaController(){var e,t;return(t=(e=this.theme)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("media-controller")}connectedCallback(){Ne(this,yr,xo).call(this),Ne(this,si,md).call(this)}disconnectedCallback(){Ne(this,oi,pd).call(this)}attributeChangedCallback(e,t,a){switch(Ve(this,Ut)||Ne(this,Zt,fn).call(this),super.attributeChangedCallback(e,t,a),[Le.PLAYBACK_ID,ud.SRC,be.PLAYBACK_TOKEN].includes(e)&&t!==a&&_t(this,dt,{...Ve(this,dt),..._o}),Ne(this,Jt,hn).call(this,{[ys(e)]:a}),e){case be.THUMBNAIL_TIME:{a!=null&&this.tokens.thumbnail&&at(pe("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case be.THUMBNAIL_TOKEN:{let{aud:c}=fr(a);a&&c!=="t"&&at(pe("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:c}));break}case be.STORYBOARD_TOKEN:{let{aud:c}=fr(a);a&&c!=="s"&&at(pe("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:c}));break}case Le.PLAYBACK_ID:{a.includes("?token")&&Et(pe("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:a})),this.streamType?this.streamType!=null&&!sd.includes(this.streamType)&&Vr({file:"invalid-stream-type.md",message:pe("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand`, `live`, `ll-live`, `live:dvr`, or `ll-live:dvr`").format({streamType:this.streamType})}):Vr({file:"invalid-stream-type.md",message:String(pe("No stream-type value supplied. Defaulting to `on-demand`. Please provide stream-type as either: `on-demand`, `live`, `ll-live`, `live:dvr`, or `ll-live:dvr`"))});break}}}get hasPlayed(){var e,t;return(t=(e=this.mediaController)==null?void 0:e.hasAttribute("media-has-played"))!=null?t:!1}get inLiveWindow(){return Ve(this,dt).inLiveWindow}get hls(){return at("<mux-player>.hls is deprecated, please use ._hls instead"),this._hls}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get audio(){return this.hasAttribute(be.AUDIO)}set audio(e){e||this.removeAttribute(be.AUDIO),this.setAttribute(be.AUDIO,"")}get nohotkeys(){return this.hasAttribute(be.NOHOTKEYS)}set nohotkeys(e){e||this.removeAttribute(be.NOHOTKEYS),this.setAttribute(be.NOHOTKEYS,"")}get thumbnailTime(){return Mt(this.getAttribute(be.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(be.THUMBNAIL_TIME,`${e}`)}get primaryColor(){var e;return(e=this.getAttribute(be.PRIMARY_COLOR))!=null?e:void 0}set primaryColor(e){this.setAttribute(be.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e;return(e=this.getAttribute(be.SECONDARY_COLOR))!=null?e:void 0}set secondaryColor(e){this.setAttribute(be.SECONDARY_COLOR,`${e}`)}get forwardSeekOffset(){var e;return(e=Mt(this.getAttribute(be.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute(be.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=Mt(this.getAttribute(be.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute(be.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(be.DEFAULT_HIDDEN_CAPTIONS)}get playerSoftwareName(){var e;return(e=this.getAttribute(Le.PLAYER_SOFTWARE_NAME))!=null?e:vd}get playerSoftwareVersion(){var e;return(e=this.getAttribute(Le.PLAYER_SOFTWARE_VERSION))!=null?e:hd}get beaconCollectionDomain(){var e;return(e=this.getAttribute(Le.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(Le.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(Le.BEACON_COLLECTION_DOMAIN))}get playbackId(){var e;return(e=this.getAttribute(Le.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){this.setAttribute(Le.PLAYBACK_ID,`${e}`)}get customDomain(){var e;return(e=this.getAttribute(Le.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(Le.CUSTOM_DOMAIN,e):this.removeAttribute(Le.CUSTOM_DOMAIN))}get envKey(){var e;return(e=gr(this,Le.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(Le.ENV_KEY,`${e}`)}get debug(){return gr(this,Le.DEBUG)!=null}set debug(e){e?this.setAttribute(Le.DEBUG,""):this.removeAttribute(Le.DEBUG)}get streamType(){return gr(this,Le.STREAM_TYPE)}set streamType(e){this.setAttribute(Le.STREAM_TYPE,`${e}`)}get startTime(){return Mt(gr(this,Le.START_TIME))}set startTime(e){this.setAttribute(Le.START_TIME,`${e}`)}get preferMse(){return gr(this,Le.PREFER_MSE)!=null}set preferMse(e){e?this.setAttribute(Le.PREFER_MSE,""):this.removeAttribute(Le.PREFER_MSE)}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){if(Ve(this,Ut)||Ne(this,Zt,fn).call(this),!this.media){Et("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata=e}get tokens(){let e=this.getAttribute(be.PLAYBACK_TOKEN),t=this.getAttribute(be.THUMBNAIL_TOKEN),a=this.getAttribute(be.STORYBOARD_TOKEN);return{...Ve(this,Er),...e!=null?{playback:e}:{},...t!=null?{thumbnail:t}:{},...a!=null?{storyboard:a}:{}}}set tokens(e){_t(this,Er,e!=null?e:{})}get playbackToken(){var e;return(e=this.getAttribute(be.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute(be.PLAYBACK_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute(be.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute(be.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute(be.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute(be.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,t,a,i){var R;let c=(R=this.media)==null?void 0:R.nativeEl;if(!!c)return xi(c,e,t,a,i)}removeTextTrack(e){var a;let t=(a=this.media)==null?void 0:a.nativeEl;if(!!t)return Ln(t,e)}get textTracks(){var e;return(e=this.media)==null?void 0:e.textTracks}};Ut=new WeakMap,Er=new WeakMap,At=new WeakMap,Qt=new WeakMap,dt=new WeakMap,Zt=new WeakSet,fn=function(){var e,t,a;if(!Ve(this,Ut)){_t(this,Ut,!0),Ne(this,St,pr).call(this,{playerSize:ni(this)});try{if(customElements.upgrade(this.theme),!(this.theme instanceof HTMLElement))throw""}catch{Et(`<${(e=this.theme)==null?void 0:e.localName}> failed to upgrade!`)}try{if(customElements.upgrade(this.media),!(this.media instanceof fs))throw""}catch{Et("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof ur))throw""}catch{Et("<media-controller> failed to upgrade!")}xs(this),Ne(this,ui,Ed).call(this),Ne(this,di,yd).call(this),Ne(this,li,gd).call(this),_t(this,At,(a=(t=this.mediaController)==null?void 0:t.hasAttribute("user-inactive"))!=null?a:!0),Ne(this,ci,Td).call(this)}},St=new WeakSet,pr=function(e){Object.assign(Ve(this,dt),e),Ne(this,Jt,hn).call(this)},Jt=new WeakSet,hn=function(e={}){qr(So(dd(this,{...Ve(this,dt),...e})),this.shadowRoot)},yr=new WeakSet,xo=function(){var e,t;Ve(this,dt).playerSize!=ni((e=this.mediaController)!=null?e:this)&&Ne(this,St,pr).call(this,{playerSize:ni((t=this.mediaController)!=null?t:this)})},si=new WeakSet,md=function(){var e;_t(this,Qt,new ResizeObserver(()=>Ne(this,yr,xo).call(this))),Ve(this,Qt).observe((e=this.mediaController)!=null?e:this)},oi=new WeakSet,pd=function(){var e;(e=Ve(this,Qt))==null||e.disconnect()},li=new WeakSet,gd=function(){var t,a,i,c,R;(t=this.mediaController)==null||t.addEventListener("mediaplayrequest",E=>{var L;((L=E.target)==null?void 0:L.localName)==="media-play-button"&&this.streamType&&[ve.LIVE,ve.LL_LIVE,ve.DVR,ve.LL_DVR].includes(this.streamType)&&this.hasPlayed&&tn(this)});let e=()=>{let E=Ss(this),L=Ve(this,dt).inLiveWindow;E!==L&&(Ne(this,St,pr).call(this,{inLiveWindow:E}),this.dispatchEvent(new CustomEvent("inlivewindowchange",{composed:!0,bubbles:!0,detail:this.inLiveWindow})))};(a=this.media)==null||a.addEventListener("progress",e),(i=this.media)==null||i.addEventListener("waiting",e),(c=this.media)==null||c.addEventListener("timeupdate",e),(R=this.media)==null||R.addEventListener("emptied",e)},ui=new WeakSet,Ed=function(){var t;let e=a=>{let{detail:i}=a;if(i instanceof Oe||(i=new Oe(i.message,i.code,i.fatal)),!(i==null?void 0:i.fatal)){at(i),i.data&&at(`${i.name} data:`,i.data);return}let{dialog:c,devlog:R}=ii(i,!window.navigator.onLine,this.playbackId,this.playbackToken);R.message&&Vr(R),Et(i),i.data&&Et(`${i.name} data:`,i.data),Ne(this,St,pr).call(this,{isDialogOpen:!0,dialog:c})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(a={})=>{var c,R,E;if(!((c=this.media)==null?void 0:c.error))return a;let{devlog:i}=ii((R=this.media)==null?void 0:R.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(E=this.media)==null?void 0:E.error.code,player_error_message:i.message?String(i.message):a.player_error_message}}),(t=this.media)==null||t.addEventListener("error",a=>{var c,R;let{detail:i}=a;if(!i){let{message:E,code:L}=(R=(c=this.media)==null?void 0:c.error)!=null?R:{};i=new Oe(E,L)}!(i==null?void 0:i.fatal)||this.dispatchEvent(new CustomEvent("error",{detail:i}))})},di=new WeakSet,yd=function(){var t,a,i,c;let e=()=>Ne(this,Jt,hn).call(this);(a=(t=this.media)==null?void 0:t.textTracks)==null||a.addEventListener("addtrack",e),(c=(i=this.media)==null?void 0:i.textTracks)==null||c.addEventListener("removetrack",e)},ci=new WeakSet,Td=function(){var y,I;let e=this.mediaController,t=/.*Version\/.*Safari\/.*/.test(navigator.userAgent);if(/.*iPhone.*/.test(navigator.userAgent))return;let i,c=new WeakMap,R=()=>this.streamType&&[ve.LIVE,ve.LL_LIVE].includes(this.streamType)&&!this.secondaryColor&&this.offsetWidth>=800,E=(M,D)=>{if(R())return;Array.from(M&&M.activeCues||[]).forEach(A=>{if(!(!A.snapToLines||A.line<-5||A.line>=0&&A.line<10))if(!D||this.paused){let u=A.text.split(`
1638
+ `).length,r=t?-2:-3;this.streamType&&[ve.LIVE,ve.LL_LIVE].includes(this.streamType)&&(r=t?-1:-2);let o=r-u;if(A.line===o)return;c.has(A)||c.set(A,A.line),A.line=0,A.line=o}else setTimeout(()=>{A.line=c.get(A)||"auto"},500)})},L=()=>{var M;E(i,(M=e==null?void 0:e.hasAttribute("user-inactive"))!=null?M:!1)},_=()=>{var b;let D=Array.from(((b=e==null?void 0:e.media)==null?void 0:b.textTracks)||[]).filter(A=>["subtitles","captions"].includes(A.kind)&&A.mode==="showing")[0];D!==i&&(i==null||i.removeEventListener("cuechange",L)),i=D,i==null||i.addEventListener("cuechange",L),E(i,Ve(this,At))};_(),(y=e==null?void 0:e.media)==null||y.textTracks.addEventListener("change",_),(I=e==null?void 0:e.media)==null||I.textTracks.addEventListener("addtrack",_),e==null||e.addEventListener("userinactivechange",()=>{let M=e==null?void 0:e.hasAttribute("user-inactive");Ve(this,At)!==M&&(_t(this,At,M),E(i,Ve(this,At)))})};function gr(f,e){return f.media?f.media.getAttribute(e):f.getAttribute(e)}globalThis.customElements.get("mux-player")||(globalThis.customElements.define("mux-player",ai),globalThis.MuxPlayerElement=ai);var Ip=ai;})();