@volcengine/veplayer-plugin 2.11.0-rc.0 → 2.11.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/ad.d.ts +3 -0
- package/esm/hlsjs.d.ts +3 -0
- package/esm/index.development.js +531 -244
- package/esm/index.production.js +1 -1
- package/esm/time-shift.d.ts +3 -0
- package/esm/veplayer.plugin.abr.development.js +1 -1
- package/esm/veplayer.plugin.abr.production.js +1 -1
- package/esm/veplayer.plugin.drm.development.js +1 -1
- package/esm/veplayer.plugin.drm.production.js +1 -1
- package/esm/veplayer.plugin.flv.development.js +1 -1
- package/esm/veplayer.plugin.flv.production.js +1 -1
- package/esm/veplayer.plugin.hls.development.js +1 -1
- package/esm/veplayer.plugin.hls.production.js +1 -1
- package/esm/veplayer.plugin.hlsjs.development.js +496 -218
- package/esm/veplayer.plugin.hlsjs.production.js +1 -1
- package/esm/veplayer.plugin.rtm.development.js +37 -28
- package/esm/veplayer.plugin.rtm.production.js +1 -1
- package/esm/veplayer.plugin.time.shift.development.js +13 -16
- package/esm/veplayer.plugin.time.shift.production.js +1 -1
- package/esm/veplayer.plugin.xgvideo.development.js +1 -1
- package/esm/veplayer.plugin.xgvideo.production.js +1 -1
- package/esm/veplayer.strategy.base.development.js +1 -1
- package/esm/veplayer.strategy.base.production.js +1 -1
- package/esm/veplayer.strategy.rtm.adaptive.buffer.development.js +1 -1
- package/esm/veplayer.strategy.rtm.adaptive.buffer.production.js +1 -1
- package/package.json +106 -2
- package/umd/ad.d.ts +3 -0
- package/umd/hlsjs.d.ts +3 -0
- package/umd/time-shift.d.ts +3 -0
- package/umd/veplayer.plugin.hlsjs.development.js +495 -217
- package/umd/veplayer.plugin.hlsjs.production.js +1 -1
- package/umd/veplayer.plugin.rtm.development.js +36 -27
- package/umd/veplayer.plugin.rtm.production.js +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function _classCallCheck$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs$1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var defineProperty$e={exports:{}},check=function(e){return e&&e.Math==Math&&e},global$s=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||function(){return this}()||commonjsGlobal||Function("return this")(),fails$A=function(e){try{return!!e()}catch(e){return!0}},fails$z=fails$A,functionBindNative=!fails$z((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),NATIVE_BIND$4=functionBindNative,FunctionPrototype$3=Function.prototype,apply$7=FunctionPrototype$3.apply,call$A=FunctionPrototype$3.call,functionApply="object"==typeof Reflect&&Reflect.apply||(NATIVE_BIND$4?call$A.bind(apply$7):function(){return call$A.apply(apply$7,arguments)}),NATIVE_BIND$3=functionBindNative,FunctionPrototype$2=Function.prototype,call$z=FunctionPrototype$2.call,uncurryThisWithBind=NATIVE_BIND$3&&FunctionPrototype$2.bind.bind(call$z,call$z),functionUncurryThis=NATIVE_BIND$3?uncurryThisWithBind:function(e){return function(){return call$z.apply(e,arguments)}},uncurryThis$E=functionUncurryThis,toString$i=uncurryThis$E({}.toString),stringSlice$5=uncurryThis$E("".slice),classofRaw$2=function(e){return stringSlice$5(toString$i(e),8,-1)},classofRaw$1=classofRaw$2,uncurryThis$D=functionUncurryThis,functionUncurryThisClause=function(e){if("Function"===classofRaw$1(e))return uncurryThis$D(e)},documentAll$2="object"==typeof document&&document.all,IS_HTMLDDA=void 0===documentAll$2&&void 0!==documentAll$2,documentAll_1={all:documentAll$2,IS_HTMLDDA:IS_HTMLDDA},$documentAll$1=documentAll_1,documentAll$1=$documentAll$1.all,isCallable$r=$documentAll$1.IS_HTMLDDA?function(e){return"function"==typeof e||e===documentAll$1}:function(e){return"function"==typeof e},objectGetOwnPropertyDescriptor={},fails$y=fails$A,descriptors=!fails$y((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),NATIVE_BIND$2=functionBindNative,call$y=Function.prototype.call,functionCall=NATIVE_BIND$2?call$y.bind(call$y):function(){return call$y.apply(call$y,arguments)},objectPropertyIsEnumerable={},$propertyIsEnumerable$2={}.propertyIsEnumerable,getOwnPropertyDescriptor$b=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$b&&!$propertyIsEnumerable$2.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$b(this,e);return!!t&&t.enumerable}:$propertyIsEnumerable$2;var match,version$1,createPropertyDescriptor$8=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},uncurryThis$C=functionUncurryThis,fails$x=fails$A,classof$h=classofRaw$2,$Object$5=Object,split$3=uncurryThis$C("".split),indexedObject=fails$x((function(){return!$Object$5("z").propertyIsEnumerable(0)}))?function(e){return"String"==classof$h(e)?split$3(e,""):$Object$5(e)}:$Object$5,isNullOrUndefined$7=function(e){return null==e},isNullOrUndefined$6=isNullOrUndefined$7,$TypeError$m=TypeError,requireObjectCoercible$8=function(e){if(isNullOrUndefined$6(e))throw $TypeError$m("Can't call method on "+e);return e},IndexedObject$3=indexedObject,requireObjectCoercible$7=requireObjectCoercible$8,toIndexedObject$c=function(e){return IndexedObject$3(requireObjectCoercible$7(e))},isCallable$q=isCallable$r,$documentAll=documentAll_1,documentAll=$documentAll.all,isObject$m=$documentAll.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:isCallable$q(e)||e===documentAll}:function(e){return"object"==typeof e?null!==e:isCallable$q(e)},path$y={},path$x=path$y,global$r=global$s,isCallable$p=isCallable$r,aFunction=function(e){return isCallable$p(e)?e:void 0},getBuiltIn$j=function(e,t){return arguments.length<2?aFunction(path$x[e])||aFunction(global$r[e]):path$x[e]&&path$x[e][t]||global$r[e]&&global$r[e][t]},uncurryThis$B=functionUncurryThis,objectIsPrototypeOf=uncurryThis$B({}.isPrototypeOf),engineUserAgent="undefined"!=typeof navigator&&String(navigator.userAgent)||"",global$q=global$s,userAgent$6=engineUserAgent,process$4=global$q.process,Deno$1=global$q.Deno,versions=process$4&&process$4.versions||Deno$1&&Deno$1.version,v8=versions&&versions.v8;v8&&(version$1=(match=v8.split("."))[0]>0&&match[0]<4?1:+(match[0]+match[1])),!version$1&&userAgent$6&&(!(match=userAgent$6.match(/Edge\/(\d+)/))||match[1]>=74)&&(match=userAgent$6.match(/Chrome\/(\d+)/))&&(version$1=+match[1]);var engineV8Version=version$1,V8_VERSION$3=engineV8Version,fails$w=fails$A,global$p=global$s,$String$5=global$p.String,symbolConstructorDetection=!!Object.getOwnPropertySymbols&&!fails$w((function(){var e=Symbol();return!$String$5(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&V8_VERSION$3&&V8_VERSION$3<41})),NATIVE_SYMBOL$5=symbolConstructorDetection,useSymbolAsUid=NATIVE_SYMBOL$5&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,getBuiltIn$i=getBuiltIn$j,isCallable$o=isCallable$r,isPrototypeOf$s=objectIsPrototypeOf,USE_SYMBOL_AS_UID$1=useSymbolAsUid,$Object$4=Object,isSymbol$5=USE_SYMBOL_AS_UID$1?function(e){return"symbol"==typeof e}:function(e){var t=getBuiltIn$i("Symbol");return isCallable$o(t)&&isPrototypeOf$s(t.prototype,$Object$4(e))},$String$4=String,tryToString$8=function(e){try{return $String$4(e)}catch(e){return"Object"}},isCallable$n=isCallable$r,tryToString$7=tryToString$8,$TypeError$l=TypeError,aCallable$l=function(e){if(isCallable$n(e))return e;throw $TypeError$l(tryToString$7(e)+" is not a function")},aCallable$k=aCallable$l,isNullOrUndefined$5=isNullOrUndefined$7,getMethod$3=function(e,t){var r=e[t];return isNullOrUndefined$5(r)?void 0:aCallable$k(r)},call$x=functionCall,isCallable$m=isCallable$r,isObject$l=isObject$m,$TypeError$k=TypeError,ordinaryToPrimitive$1=function(e,t){var r,n;if("string"===t&&isCallable$m(r=e.toString)&&!isObject$l(n=call$x(r,e)))return n;if(isCallable$m(r=e.valueOf)&&!isObject$l(n=call$x(r,e)))return n;if("string"!==t&&isCallable$m(r=e.toString)&&!isObject$l(n=call$x(r,e)))return n;throw $TypeError$k("Can't convert object to primitive value")},shared$7={exports:{}},isPure=!0,global$o=global$s,defineProperty$d=Object.defineProperty,defineGlobalProperty$1=function(e,t){try{defineProperty$d(global$o,e,{value:t,configurable:!0,writable:!0})}catch(r){global$o[e]=t}return t},global$n=global$s,defineGlobalProperty=defineGlobalProperty$1,SHARED="__core-js_shared__",store$3=global$n[SHARED]||defineGlobalProperty(SHARED,{}),sharedStore=store$3,store$2=sharedStore;(shared$7.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"});var sharedExports=shared$7.exports,requireObjectCoercible$6=requireObjectCoercible$8,$Object$3=Object,toObject$d=function(e){return $Object$3(requireObjectCoercible$6(e))},uncurryThis$A=functionUncurryThis,toObject$c=toObject$d,hasOwnProperty=uncurryThis$A({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty(toObject$c(e),t)},uncurryThis$z=functionUncurryThis,id$1=0,postfix=Math.random(),toString$h=uncurryThis$z(1..toString),uid$4=function(e){return"Symbol("+(void 0===e?"":e)+")_"+toString$h(++id$1+postfix,36)},global$m=global$s,shared$6=sharedExports,hasOwn$n=hasOwnProperty_1,uid$3=uid$4,NATIVE_SYMBOL$4=symbolConstructorDetection,USE_SYMBOL_AS_UID=useSymbolAsUid,Symbol$5=global$m.Symbol,WellKnownSymbolsStore$2=shared$6("wks"),createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol$5.for||Symbol$5:Symbol$5&&Symbol$5.withoutSetter||uid$3,wellKnownSymbol$r=function(e){return hasOwn$n(WellKnownSymbolsStore$2,e)||(WellKnownSymbolsStore$2[e]=NATIVE_SYMBOL$4&&hasOwn$n(Symbol$5,e)?Symbol$5[e]:createWellKnownSymbol("Symbol."+e)),WellKnownSymbolsStore$2[e]},call$w=functionCall,isObject$k=isObject$m,isSymbol$4=isSymbol$5,getMethod$2=getMethod$3,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$q=wellKnownSymbol$r,$TypeError$j=TypeError,TO_PRIMITIVE=wellKnownSymbol$q("toPrimitive"),toPrimitive$7=function(e,t){if(!isObject$k(e)||isSymbol$4(e))return e;var r,n=getMethod$2(e,TO_PRIMITIVE);if(n){if(void 0===t&&(t="default"),r=call$w(n,e,t),!isObject$k(r)||isSymbol$4(r))return r;throw $TypeError$j("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive$6=toPrimitive$7,isSymbol$3=isSymbol$5,toPropertyKey$4=function(e){var t=toPrimitive$6(e,"string");return isSymbol$3(t)?t:t+""},global$l=global$s,isObject$j=isObject$m,document$3=global$l.document,EXISTS$1=isObject$j(document$3)&&isObject$j(document$3.createElement),documentCreateElement$1=function(e){return EXISTS$1?document$3.createElement(e):{}},DESCRIPTORS$l=descriptors,fails$v=fails$A,createElement$1=documentCreateElement$1,ie8DomDefine=!DESCRIPTORS$l&&!fails$v((function(){return 7!=Object.defineProperty(createElement$1("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$k=descriptors,call$v=functionCall,propertyIsEnumerableModule$2=objectPropertyIsEnumerable,createPropertyDescriptor$7=createPropertyDescriptor$8,toIndexedObject$b=toIndexedObject$c,toPropertyKey$3=toPropertyKey$4,hasOwn$m=hasOwnProperty_1,IE8_DOM_DEFINE$1=ie8DomDefine,$getOwnPropertyDescriptor$2=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$k?$getOwnPropertyDescriptor$2:function(e,t){if(e=toIndexedObject$b(e),t=toPropertyKey$3(t),IE8_DOM_DEFINE$1)try{return $getOwnPropertyDescriptor$2(e,t)}catch(e){}if(hasOwn$m(e,t))return createPropertyDescriptor$7(!call$v(propertyIsEnumerableModule$2.f,e,t),e[t])};var fails$u=fails$A,isCallable$l=isCallable$r,replacement=/#|\.prototype\./,isForced$2=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&(isCallable$l(t)?fails$u(t):!!t)},normalize=isForced$2.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$2.data={},NATIVE=isForced$2.NATIVE="N",POLYFILL=isForced$2.POLYFILL="P",isForced_1=isForced$2,uncurryThis$y=functionUncurryThisClause,aCallable$j=aCallable$l,NATIVE_BIND$1=functionBindNative,bind$w=functionUncurryThisClause(functionUncurryThisClause.bind),functionBindContext=function(e,t){return aCallable$j(e),void 0===t?e:NATIVE_BIND$1?bind$w(e,t):function(){return e.apply(t,arguments)}},objectDefineProperty={},DESCRIPTORS$j=descriptors,fails$t=fails$A,v8PrototypeDefineBug=DESCRIPTORS$j&&fails$t((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),isObject$i=isObject$m,$String$3=String,$TypeError$i=TypeError,anObject$i=function(e){if(isObject$i(e))return e;throw $TypeError$i($String$3(e)+" is not an object")},DESCRIPTORS$i=descriptors,IE8_DOM_DEFINE=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG$1=v8PrototypeDefineBug,anObject$h=anObject$i,toPropertyKey$2=toPropertyKey$4,$TypeError$h=TypeError,$defineProperty$1=Object.defineProperty,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$i?V8_PROTOTYPE_DEFINE_BUG$1?function(e,t,r){if(anObject$h(e),t=toPropertyKey$2(t),anObject$h(r),"function"==typeof e&&"prototype"===t&&"value"in r&&WRITABLE in r&&!r[WRITABLE]){var n=$getOwnPropertyDescriptor$1(e,t);n&&n[WRITABLE]&&(e[t]=r.value,r={configurable:CONFIGURABLE$1 in r?r[CONFIGURABLE$1]:n[CONFIGURABLE$1],enumerable:ENUMERABLE in r?r[ENUMERABLE]:n[ENUMERABLE],writable:!1})}return $defineProperty$1(e,t,r)}:$defineProperty$1:function(e,t,r){if(anObject$h(e),t=toPropertyKey$2(t),anObject$h(r),IE8_DOM_DEFINE)try{return $defineProperty$1(e,t,r)}catch(e){}if("get"in r||"set"in r)throw $TypeError$h("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var DESCRIPTORS$h=descriptors,definePropertyModule$4=objectDefineProperty,createPropertyDescriptor$6=createPropertyDescriptor$8,createNonEnumerableProperty$9=DESCRIPTORS$h?function(e,t,r){return definePropertyModule$4.f(e,t,createPropertyDescriptor$6(1,r))}:function(e,t,r){return e[t]=r,e},global$k=global$s,apply$6=functionApply,uncurryThis$x=functionUncurryThisClause,isCallable$k=isCallable$r,getOwnPropertyDescriptor$a=objectGetOwnPropertyDescriptor.f,isForced$1=isForced_1,path$w=path$y,bind$v=functionBindContext,createNonEnumerableProperty$8=createNonEnumerableProperty$9,hasOwn$l=hasOwnProperty_1,wrapConstructor=function(e){var t=function(r,n,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,a)}return apply$6(e,this,arguments)};return t.prototype=e.prototype,t},_export=function(e,t){var r,n,a,i,s,o,l,c,u,d=e.target,f=e.global,h=e.stat,p=e.proto,y=f?global$k:h?global$k[d]:(global$k[d]||{}).prototype,g=f?path$w:path$w[d]||createNonEnumerableProperty$8(path$w,d,{})[d],v=g.prototype;for(i in t)n=!(r=isForced$1(f?i:d+(h?".":"#")+i,e.forced))&&y&&hasOwn$l(y,i),o=g[i],n&&(l=e.dontCallGetSet?(u=getOwnPropertyDescriptor$a(y,i))&&u.value:y[i]),s=n&&l?l:t[i],n&&typeof o==typeof s||(c=e.bind&&n?bind$v(s,global$k):e.wrap&&n?wrapConstructor(s):p&&isCallable$k(s)?uncurryThis$x(s):s,(e.sham||s&&s.sham||o&&o.sham)&&createNonEnumerableProperty$8(c,"sham",!0),createNonEnumerableProperty$8(g,i,c),p&&(hasOwn$l(path$w,a=d+"Prototype")||createNonEnumerableProperty$8(path$w,a,{}),createNonEnumerableProperty$8(path$w[a],i,s),e.real&&v&&(r||!v[i])&&createNonEnumerableProperty$8(v,i,s)))},$$1O=_export,DESCRIPTORS$g=descriptors,defineProperty$c=objectDefineProperty.f;$$1O({target:"Object",stat:!0,forced:Object.defineProperty!==defineProperty$c,sham:!DESCRIPTORS$g},{defineProperty:defineProperty$c});var path$v=path$y,Object$4=path$v.Object,defineProperty$b=defineProperty$e.exports=function(e,t,r){return Object$4.defineProperty(e,t,r)};Object$4.defineProperty.sham&&(defineProperty$b.sham=!0);var definePropertyExports=defineProperty$e.exports,parent$2H=definePropertyExports,defineProperty$a=parent$2H,parent$2G=defineProperty$a,defineProperty$9=parent$2G,parent$2F=defineProperty$9,defineProperty$8=parent$2F,defineProperty$7=defineProperty$8,_Object$defineProperty$1=getDefaultExportFromCjs$1(defineProperty$7),classof$g=classofRaw$2,isArray$d=Array.isArray||function(e){return"Array"==classof$g(e)},ceil$1=Math.ceil,floor$4=Math.floor,mathTrunc=Math.trunc||function(e){var t=+e;return(t>0?floor$4:ceil$1)(t)},trunc2=mathTrunc,toIntegerOrInfinity$7=function(e){var t=+e;return t!=t||0===t?0:trunc2(t)},toIntegerOrInfinity$6=toIntegerOrInfinity$7,min$4=Math.min,toLength$3=function(e){return e>0?min$4(toIntegerOrInfinity$6(e),9007199254740991):0},toLength$2=toLength$3,lengthOfArrayLike$c=function(e){return toLength$2(e.length)},$TypeError$g=TypeError,MAX_SAFE_INTEGER$1=9007199254740991,doesNotExceedSafeInteger$3=function(e){if(e>MAX_SAFE_INTEGER$1)throw $TypeError$g("Maximum allowed index exceeded");return e},toPropertyKey$1=toPropertyKey$4,definePropertyModule$3=objectDefineProperty,createPropertyDescriptor$5=createPropertyDescriptor$8,createProperty$6=function(e,t,r){var n=toPropertyKey$1(t);n in e?definePropertyModule$3.f(e,n,createPropertyDescriptor$5(0,r)):e[n]=r},wellKnownSymbol$p=wellKnownSymbol$r,TO_STRING_TAG$4=wellKnownSymbol$p("toStringTag"),test$2={};test$2[TO_STRING_TAG$4]="z";var toStringTagSupport="[object z]"===String(test$2),TO_STRING_TAG_SUPPORT$2=toStringTagSupport,isCallable$j=isCallable$r,classofRaw=classofRaw$2,wellKnownSymbol$o=wellKnownSymbol$r,TO_STRING_TAG$3=wellKnownSymbol$o("toStringTag"),$Object$2=Object,CORRECT_ARGUMENTS="Arguments"==classofRaw(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},classof$f=TO_STRING_TAG_SUPPORT$2?classofRaw:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=$Object$2(e),TO_STRING_TAG$3))?r:CORRECT_ARGUMENTS?classofRaw(t):"Object"==(n=classofRaw(t))&&isCallable$j(t.callee)?"Arguments":n},uncurryThis$w=functionUncurryThis,isCallable$i=isCallable$r,store$1=sharedStore,functionToString=uncurryThis$w(Function.toString);isCallable$i(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var inspectSource$2=store$1.inspectSource,uncurryThis$v=functionUncurryThis,fails$s=fails$A,isCallable$h=isCallable$r,classof$e=classof$f,getBuiltIn$h=getBuiltIn$j,inspectSource$1=inspectSource$2,noop$1=function(){},empty=[],construct$6=getBuiltIn$h("Reflect","construct"),constructorRegExp=/^\s*(?:class|function)\b/,exec$4=uncurryThis$v(constructorRegExp.exec),INCORRECT_TO_STRING=!constructorRegExp.exec(noop$1),isConstructorModern=function(e){if(!isCallable$h(e))return!1;try{return construct$6(noop$1,empty,e),!0}catch(e){return!1}},isConstructorLegacy=function(e){if(!isCallable$h(e))return!1;switch(classof$e(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return INCORRECT_TO_STRING||!!exec$4(constructorRegExp,inspectSource$1(e))}catch(e){return!0}};isConstructorLegacy.sham=!0;var isConstructor$4=!construct$6||fails$s((function(){var e;return isConstructorModern(isConstructorModern.call)||!isConstructorModern(Object)||!isConstructorModern((function(){e=!0}))||e}))?isConstructorLegacy:isConstructorModern,isArray$c=isArray$d,isConstructor$3=isConstructor$4,isObject$h=isObject$m,wellKnownSymbol$n=wellKnownSymbol$r,SPECIES$5=wellKnownSymbol$n("species"),$Array$3=Array,arraySpeciesConstructor$1=function(e){var t;return isArray$c(e)&&(t=e.constructor,(isConstructor$3(t)&&(t===$Array$3||isArray$c(t.prototype))||isObject$h(t)&&null===(t=t[SPECIES$5]))&&(t=void 0)),void 0===t?$Array$3:t},arraySpeciesConstructor=arraySpeciesConstructor$1,arraySpeciesCreate$3=function(e,t){return new(arraySpeciesConstructor(e))(0===t?0:t)},fails$r=fails$A,wellKnownSymbol$m=wellKnownSymbol$r,V8_VERSION$2=engineV8Version,SPECIES$4=wellKnownSymbol$m("species"),arrayMethodHasSpeciesSupport$5=function(e){return V8_VERSION$2>=51||!fails$r((function(){var t=[];return(t.constructor={})[SPECIES$4]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},$$1N=_export,fails$q=fails$A,isArray$b=isArray$d,isObject$g=isObject$m,toObject$b=toObject$d,lengthOfArrayLike$b=lengthOfArrayLike$c,doesNotExceedSafeInteger$2=doesNotExceedSafeInteger$3,createProperty$5=createProperty$6,arraySpeciesCreate$2=arraySpeciesCreate$3,arrayMethodHasSpeciesSupport$4=arrayMethodHasSpeciesSupport$5,wellKnownSymbol$l=wellKnownSymbol$r,V8_VERSION$1=engineV8Version,IS_CONCAT_SPREADABLE=wellKnownSymbol$l("isConcatSpreadable"),IS_CONCAT_SPREADABLE_SUPPORT=V8_VERSION$1>=51||!fails$q((function(){var e=[];return e[IS_CONCAT_SPREADABLE]=!1,e.concat()[0]!==e})),isConcatSpreadable=function(e){if(!isObject$g(e))return!1;var t=e[IS_CONCAT_SPREADABLE];return void 0!==t?!!t:isArray$b(e)},FORCED$a=!IS_CONCAT_SPREADABLE_SUPPORT||!arrayMethodHasSpeciesSupport$4("concat");$$1N({target:"Array",proto:!0,arity:1,forced:FORCED$a},{concat:function(e){var t,r,n,a,i,s=toObject$b(this),o=arraySpeciesCreate$2(s,0),l=0;for(t=-1,n=arguments.length;t<n;t++)if(isConcatSpreadable(i=-1===t?s:arguments[t]))for(a=lengthOfArrayLike$b(i),doesNotExceedSafeInteger$2(l+a),r=0;r<a;r++,l++)r in i&&createProperty$5(o,l,i[r]);else doesNotExceedSafeInteger$2(l+1),createProperty$5(o,l++,i);return o.length=l,o}});var classof$d=classof$f,$String$2=String,toString$g=function(e){if("Symbol"===classof$d(e))throw TypeError("Cannot convert a Symbol value to a string");return $String$2(e)},objectDefineProperties={},toIntegerOrInfinity$5=toIntegerOrInfinity$7,max$4=Math.max,min$3=Math.min,toAbsoluteIndex$4=function(e,t){var r=toIntegerOrInfinity$5(e);return r<0?max$4(r+t,0):min$3(r,t)},toIndexedObject$a=toIndexedObject$c,toAbsoluteIndex$3=toAbsoluteIndex$4,lengthOfArrayLike$a=lengthOfArrayLike$c,createMethod$6=function(e){return function(t,r,n){var a,i=toIndexedObject$a(t),s=lengthOfArrayLike$a(i),o=toAbsoluteIndex$3(n,s);if(e&&r!=r){for(;s>o;)if((a=i[o++])!=a)return!0}else for(;s>o;o++)if((e||o in i)&&i[o]===r)return e||o||0;return!e&&-1}},arrayIncludes={includes:createMethod$6(!0),indexOf:createMethod$6(!1)},hiddenKeys$6={},uncurryThis$u=functionUncurryThis,hasOwn$k=hasOwnProperty_1,toIndexedObject$9=toIndexedObject$c,indexOf$7=arrayIncludes.indexOf,hiddenKeys$5=hiddenKeys$6,push$k=uncurryThis$u([].push),objectKeysInternal=function(e,t){var r,n=toIndexedObject$9(e),a=0,i=[];for(r in n)!hasOwn$k(hiddenKeys$5,r)&&hasOwn$k(n,r)&&push$k(i,r);for(;t.length>a;)hasOwn$k(n,r=t[a++])&&(~indexOf$7(i,r)||push$k(i,r));return i},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,objectKeys$4=Object.keys||function(e){return internalObjectKeys$1(e,enumBugKeys$2)},DESCRIPTORS$f=descriptors,V8_PROTOTYPE_DEFINE_BUG=v8PrototypeDefineBug,definePropertyModule$2=objectDefineProperty,anObject$g=anObject$i,toIndexedObject$8=toIndexedObject$c,objectKeys$3=objectKeys$4;objectDefineProperties.f=DESCRIPTORS$f&&!V8_PROTOTYPE_DEFINE_BUG?Object.defineProperties:function(e,t){anObject$g(e);for(var r,n=toIndexedObject$8(t),a=objectKeys$3(t),i=a.length,s=0;i>s;)definePropertyModule$2.f(e,r=a[s++],n[r]);return e};var activeXDocument,getBuiltIn$g=getBuiltIn$j,html$2=getBuiltIn$g("document","documentElement"),shared$5=sharedExports,uid$2=uid$4,keys$6=shared$5("keys"),sharedKey$4=function(e){return keys$6[e]||(keys$6[e]=uid$2(e))},anObject$f=anObject$i,definePropertiesModule$1=objectDefineProperties,enumBugKeys$1=enumBugKeys$3,hiddenKeys$4=hiddenKeys$6,html$1=html$2,documentCreateElement=documentCreateElement$1,sharedKey$3=sharedKey$4,GT=">",LT="<",PROTOTYPE$1="prototype",SCRIPT="script",IE_PROTO$1=sharedKey$3("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return LT+SCRIPT+GT+e+LT+"/"+SCRIPT+GT},NullProtoObjectViaActiveX=function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t},NullProtoObjectViaIFrame=function(){var e,t=documentCreateElement("iframe"),r="java"+SCRIPT+":";return t.style.display="none",html$1.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(scriptTag("document.F=Object")),e.close(),e.F},NullProtoObject=function(){try{activeXDocument=new ActiveXObject("htmlfile")}catch(e){}NullProtoObject="undefined"!=typeof document?document.domain&&activeXDocument?NullProtoObjectViaActiveX(activeXDocument):NullProtoObjectViaIFrame():NullProtoObjectViaActiveX(activeXDocument);for(var e=enumBugKeys$1.length;e--;)delete NullProtoObject[PROTOTYPE$1][enumBugKeys$1[e]];return NullProtoObject()};hiddenKeys$4[IE_PROTO$1]=!0;var objectCreate=Object.create||function(e,t){var r;return null!==e?(EmptyConstructor[PROTOTYPE$1]=anObject$f(e),r=new EmptyConstructor,EmptyConstructor[PROTOTYPE$1]=null,r[IE_PROTO$1]=e):r=NullProtoObject(),void 0===t?r:definePropertiesModule$1.f(r,t)},objectGetOwnPropertyNames={},internalObjectKeys=objectKeysInternal,enumBugKeys=enumBugKeys$3,hiddenKeys$3=enumBugKeys.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys(e,hiddenKeys$3)};var objectGetOwnPropertyNamesExternal={},toAbsoluteIndex$2=toAbsoluteIndex$4,lengthOfArrayLike$9=lengthOfArrayLike$c,createProperty$4=createProperty$6,$Array$2=Array,max$3=Math.max,arraySliceSimple=function(e,t,r){for(var n=lengthOfArrayLike$9(e),a=toAbsoluteIndex$2(t,n),i=toAbsoluteIndex$2(void 0===r?n:r,n),s=$Array$2(max$3(i-a,0)),o=0;a<i;a++,o++)createProperty$4(s,o,e[a]);return s.length=o,s},classof$c=classofRaw$2,toIndexedObject$7=toIndexedObject$c,$getOwnPropertyNames$1=objectGetOwnPropertyNames.f,arraySlice$8=arraySliceSimple,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return $getOwnPropertyNames$1(e)}catch(e){return arraySlice$8(windowNames)}};objectGetOwnPropertyNamesExternal.f=function(e){return windowNames&&"Window"==classof$c(e)?getWindowNames(e):$getOwnPropertyNames$1(toIndexedObject$7(e))};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var createNonEnumerableProperty$7=createNonEnumerableProperty$9,defineBuiltIn$8=function(e,t,r,n){return n&&n.enumerable?e[t]=r:createNonEnumerableProperty$7(e,t,r),e},defineProperty$6=objectDefineProperty,defineBuiltInAccessor$5=function(e,t,r){return defineProperty$6.f(e,t,r)},wellKnownSymbolWrapped={},wellKnownSymbol$k=wellKnownSymbol$r;wellKnownSymbolWrapped.f=wellKnownSymbol$k;var set$d,get$8,has$7,path$u=path$y,hasOwn$j=hasOwnProperty_1,wrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,defineProperty$5=objectDefineProperty.f,wellKnownSymbolDefine=function(e){var t=path$u.Symbol||(path$u.Symbol={});hasOwn$j(t,e)||defineProperty$5(t,e,{value:wrappedWellKnownSymbolModule$1.f(e)})},call$u=functionCall,getBuiltIn$f=getBuiltIn$j,wellKnownSymbol$j=wellKnownSymbol$r,defineBuiltIn$7=defineBuiltIn$8,symbolDefineToPrimitive=function(){var e=getBuiltIn$f("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=wellKnownSymbol$j("toPrimitive");t&&!t[n]&&defineBuiltIn$7(t,n,(function(e){return call$u(r,this)}),{arity:1})},TO_STRING_TAG_SUPPORT$1=toStringTagSupport,classof$b=classof$f,objectToString=TO_STRING_TAG_SUPPORT$1?{}.toString:function(){return"[object "+classof$b(this)+"]"},TO_STRING_TAG_SUPPORT=toStringTagSupport,defineProperty$4=objectDefineProperty.f,createNonEnumerableProperty$6=createNonEnumerableProperty$9,hasOwn$i=hasOwnProperty_1,toString$f=objectToString,wellKnownSymbol$i=wellKnownSymbol$r,TO_STRING_TAG$2=wellKnownSymbol$i("toStringTag"),setToStringTag$9=function(e,t,r,n){if(e){var a=r?e:e.prototype;hasOwn$i(a,TO_STRING_TAG$2)||defineProperty$4(a,TO_STRING_TAG$2,{configurable:!0,value:t}),n&&!TO_STRING_TAG_SUPPORT&&createNonEnumerableProperty$6(a,"toString",toString$f)}},global$j=global$s,isCallable$g=isCallable$r,WeakMap$1=global$j.WeakMap,weakMapBasicDetection=isCallable$g(WeakMap$1)&&/native code/.test(String(WeakMap$1)),NATIVE_WEAK_MAP=weakMapBasicDetection,global$i=global$s,isObject$f=isObject$m,createNonEnumerableProperty$5=createNonEnumerableProperty$9,hasOwn$h=hasOwnProperty_1,shared$4=sharedStore,sharedKey$2=sharedKey$4,hiddenKeys$2=hiddenKeys$6,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$5=global$i.TypeError,WeakMap=global$i.WeakMap,enforce=function(e){return has$7(e)?get$8(e):set$d(e,{})},getterFor=function(e){return function(t){var r;if(!isObject$f(t)||(r=get$8(t)).type!==e)throw TypeError$5("Incompatible receiver, "+e+" required");return r}};if(NATIVE_WEAK_MAP||shared$4.state){var store=shared$4.state||(shared$4.state=new WeakMap);store.get=store.get,store.has=store.has,store.set=store.set,set$d=function(e,t){if(store.has(e))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,store.set(e,t),t},get$8=function(e){return store.get(e)||{}},has$7=function(e){return store.has(e)}}else{var STATE=sharedKey$2("state");hiddenKeys$2[STATE]=!0,set$d=function(e,t){if(hasOwn$h(e,STATE))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$5(e,STATE,t),t},get$8=function(e){return hasOwn$h(e,STATE)?e[STATE]:{}},has$7=function(e){return hasOwn$h(e,STATE)}}var internalState={set:set$d,get:get$8,has:has$7,enforce:enforce,getterFor:getterFor},bind$u=functionBindContext,uncurryThis$t=functionUncurryThis,IndexedObject$2=indexedObject,toObject$a=toObject$d,lengthOfArrayLike$8=lengthOfArrayLike$c,arraySpeciesCreate$1=arraySpeciesCreate$3,push$j=uncurryThis$t([].push),createMethod$5=function(e){var t=1==e,r=2==e,n=3==e,a=4==e,i=6==e,s=7==e,o=5==e||i;return function(l,c,u,d){for(var f,h,p=toObject$a(l),y=IndexedObject$2(p),g=bind$u(c,u),v=lengthOfArrayLike$8(y),m=0,E=d||arraySpeciesCreate$1,$=t?E(l,v):r||s?E(l,0):void 0;v>m;m++)if((o||m in y)&&(h=g(f=y[m],m,p),e))if(t)$[m]=h;else if(h)switch(e){case 3:return!0;case 5:return f;case 6:return m;case 2:push$j($,f)}else switch(e){case 4:return!1;case 7:push$j($,f)}return i?-1:n||a?a:$}},arrayIteration={forEach:createMethod$5(0),map:createMethod$5(1),filter:createMethod$5(2),some:createMethod$5(3),every:createMethod$5(4),find:createMethod$5(5),findIndex:createMethod$5(6),filterReject:createMethod$5(7)},$$1M=_export,global$h=global$s,call$t=functionCall,uncurryThis$s=functionUncurryThis,DESCRIPTORS$e=descriptors,NATIVE_SYMBOL$3=symbolConstructorDetection,fails$p=fails$A,hasOwn$g=hasOwnProperty_1,isPrototypeOf$r=objectIsPrototypeOf,anObject$e=anObject$i,toIndexedObject$6=toIndexedObject$c,toPropertyKey=toPropertyKey$4,$toString$2=toString$g,createPropertyDescriptor$4=createPropertyDescriptor$8,nativeObjectCreate=objectCreate,objectKeys$2=objectKeys$4,getOwnPropertyNamesModule$2=objectGetOwnPropertyNames,getOwnPropertyNamesExternal=objectGetOwnPropertyNamesExternal,getOwnPropertySymbolsModule$3=objectGetOwnPropertySymbols,getOwnPropertyDescriptorModule$3=objectGetOwnPropertyDescriptor,definePropertyModule$1=objectDefineProperty,definePropertiesModule=objectDefineProperties,propertyIsEnumerableModule$1=objectPropertyIsEnumerable,defineBuiltIn$6=defineBuiltIn$8,defineBuiltInAccessor$4=defineBuiltInAccessor$5,shared$3=sharedExports,sharedKey$1=sharedKey$4,hiddenKeys$1=hiddenKeys$6,uid$1=uid$4,wellKnownSymbol$h=wellKnownSymbol$r,wrappedWellKnownSymbolModule=wellKnownSymbolWrapped,defineWellKnownSymbol$l=wellKnownSymbolDefine,defineSymbolToPrimitive$1=symbolDefineToPrimitive,setToStringTag$8=setToStringTag$9,InternalStateModule$7=internalState,$forEach$1=arrayIteration.forEach,HIDDEN=sharedKey$1("hidden"),SYMBOL="Symbol",PROTOTYPE="prototype",setInternalState$7=InternalStateModule$7.set,getInternalState$2=InternalStateModule$7.getterFor(SYMBOL),ObjectPrototype$2=Object[PROTOTYPE],$Symbol=global$h.Symbol,SymbolPrototype=$Symbol&&$Symbol[PROTOTYPE],TypeError$4=global$h.TypeError,QObject=global$h.QObject,nativeGetOwnPropertyDescriptor$1=getOwnPropertyDescriptorModule$3.f,nativeDefineProperty=definePropertyModule$1.f,nativeGetOwnPropertyNames=getOwnPropertyNamesExternal.f,nativePropertyIsEnumerable=propertyIsEnumerableModule$1.f,push$i=uncurryThis$s([].push),AllSymbols=shared$3("symbols"),ObjectPrototypeSymbols=shared$3("op-symbols"),WellKnownSymbolsStore$1=shared$3("wks"),USE_SETTER=!QObject||!QObject[PROTOTYPE]||!QObject[PROTOTYPE].findChild,setSymbolDescriptor=DESCRIPTORS$e&&fails$p((function(){return 7!=nativeObjectCreate(nativeDefineProperty({},"a",{get:function(){return nativeDefineProperty(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=nativeGetOwnPropertyDescriptor$1(ObjectPrototype$2,t);n&&delete ObjectPrototype$2[t],nativeDefineProperty(e,t,r),n&&e!==ObjectPrototype$2&&nativeDefineProperty(ObjectPrototype$2,t,n)}:nativeDefineProperty,wrap=function(e,t){var r=AllSymbols[e]=nativeObjectCreate(SymbolPrototype);return setInternalState$7(r,{type:SYMBOL,tag:e,description:t}),DESCRIPTORS$e||(r.description=t),r},$defineProperty=function(e,t,r){e===ObjectPrototype$2&&$defineProperty(ObjectPrototypeSymbols,t,r),anObject$e(e);var n=toPropertyKey(t);return anObject$e(r),hasOwn$g(AllSymbols,n)?(r.enumerable?(hasOwn$g(e,HIDDEN)&&e[HIDDEN][n]&&(e[HIDDEN][n]=!1),r=nativeObjectCreate(r,{enumerable:createPropertyDescriptor$4(0,!1)})):(hasOwn$g(e,HIDDEN)||nativeDefineProperty(e,HIDDEN,createPropertyDescriptor$4(1,{})),e[HIDDEN][n]=!0),setSymbolDescriptor(e,n,r)):nativeDefineProperty(e,n,r)},$defineProperties=function(e,t){anObject$e(e);var r=toIndexedObject$6(t),n=objectKeys$2(r).concat($getOwnPropertySymbols(r));return $forEach$1(n,(function(t){DESCRIPTORS$e&&!call$t($propertyIsEnumerable$1,r,t)||$defineProperty(e,t,r[t])})),e},$create=function(e,t){return void 0===t?nativeObjectCreate(e):$defineProperties(nativeObjectCreate(e),t)},$propertyIsEnumerable$1=function(e){var t=toPropertyKey(e),r=call$t(nativePropertyIsEnumerable,this,t);return!(this===ObjectPrototype$2&&hasOwn$g(AllSymbols,t)&&!hasOwn$g(ObjectPrototypeSymbols,t))&&(!(r||!hasOwn$g(this,t)||!hasOwn$g(AllSymbols,t)||hasOwn$g(this,HIDDEN)&&this[HIDDEN][t])||r)},$getOwnPropertyDescriptor=function(e,t){var r=toIndexedObject$6(e),n=toPropertyKey(t);if(r!==ObjectPrototype$2||!hasOwn$g(AllSymbols,n)||hasOwn$g(ObjectPrototypeSymbols,n)){var a=nativeGetOwnPropertyDescriptor$1(r,n);return!a||!hasOwn$g(AllSymbols,n)||hasOwn$g(r,HIDDEN)&&r[HIDDEN][n]||(a.enumerable=!0),a}},$getOwnPropertyNames=function(e){var t=nativeGetOwnPropertyNames(toIndexedObject$6(e)),r=[];return $forEach$1(t,(function(e){hasOwn$g(AllSymbols,e)||hasOwn$g(hiddenKeys$1,e)||push$i(r,e)})),r},$getOwnPropertySymbols=function(e){var t=e===ObjectPrototype$2,r=nativeGetOwnPropertyNames(t?ObjectPrototypeSymbols:toIndexedObject$6(e)),n=[];return $forEach$1(r,(function(e){!hasOwn$g(AllSymbols,e)||t&&!hasOwn$g(ObjectPrototype$2,e)||push$i(n,AllSymbols[e])})),n};NATIVE_SYMBOL$3||(defineBuiltIn$6(SymbolPrototype=($Symbol=function(){if(isPrototypeOf$r(SymbolPrototype,this))throw TypeError$4("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?$toString$2(arguments[0]):void 0,t=uid$1(e),r=function(e){this===ObjectPrototype$2&&call$t(r,ObjectPrototypeSymbols,e),hasOwn$g(this,HIDDEN)&&hasOwn$g(this[HIDDEN],t)&&(this[HIDDEN][t]=!1),setSymbolDescriptor(this,t,createPropertyDescriptor$4(1,e))};return DESCRIPTORS$e&&USE_SETTER&&setSymbolDescriptor(ObjectPrototype$2,t,{configurable:!0,set:r}),wrap(t,e)})[PROTOTYPE],"toString",(function(){return getInternalState$2(this).tag})),defineBuiltIn$6($Symbol,"withoutSetter",(function(e){return wrap(uid$1(e),e)})),propertyIsEnumerableModule$1.f=$propertyIsEnumerable$1,definePropertyModule$1.f=$defineProperty,definePropertiesModule.f=$defineProperties,getOwnPropertyDescriptorModule$3.f=$getOwnPropertyDescriptor,getOwnPropertyNamesModule$2.f=getOwnPropertyNamesExternal.f=$getOwnPropertyNames,getOwnPropertySymbolsModule$3.f=$getOwnPropertySymbols,wrappedWellKnownSymbolModule.f=function(e){return wrap(wellKnownSymbol$h(e),e)},DESCRIPTORS$e&&defineBuiltInAccessor$4(SymbolPrototype,"description",{configurable:!0,get:function(){return getInternalState$2(this).description}})),$$1M({global:!0,constructor:!0,wrap:!0,forced:!NATIVE_SYMBOL$3,sham:!NATIVE_SYMBOL$3},{Symbol:$Symbol}),$forEach$1(objectKeys$2(WellKnownSymbolsStore$1),(function(e){defineWellKnownSymbol$l(e)})),$$1M({target:SYMBOL,stat:!0,forced:!NATIVE_SYMBOL$3},{useSetter:function(){USE_SETTER=!0},useSimple:function(){USE_SETTER=!1}}),$$1M({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3,sham:!DESCRIPTORS$e},{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor}),$$1M({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3},{getOwnPropertyNames:$getOwnPropertyNames}),defineSymbolToPrimitive$1(),setToStringTag$8($Symbol,SYMBOL),hiddenKeys$1[HIDDEN]=!0;var NATIVE_SYMBOL$2=symbolConstructorDetection,symbolRegistryDetection=NATIVE_SYMBOL$2&&!!Symbol.for&&!!Symbol.keyFor,$$1L=_export,getBuiltIn$e=getBuiltIn$j,hasOwn$f=hasOwnProperty_1,toString$e=toString$g,shared$2=sharedExports,NATIVE_SYMBOL_REGISTRY$1=symbolRegistryDetection,StringToSymbolRegistry=shared$2("string-to-symbol-registry"),SymbolToStringRegistry$1=shared$2("symbol-to-string-registry");$$1L({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY$1},{for:function(e){var t=toString$e(e);if(hasOwn$f(StringToSymbolRegistry,t))return StringToSymbolRegistry[t];var r=getBuiltIn$e("Symbol")(t);return StringToSymbolRegistry[t]=r,SymbolToStringRegistry$1[r]=t,r}});var $$1K=_export,hasOwn$e=hasOwnProperty_1,isSymbol$2=isSymbol$5,tryToString$6=tryToString$8,shared$1=sharedExports,NATIVE_SYMBOL_REGISTRY=symbolRegistryDetection,SymbolToStringRegistry=shared$1("symbol-to-string-registry");$$1K({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY},{keyFor:function(e){if(!isSymbol$2(e))throw TypeError(tryToString$6(e)+" is not a symbol");if(hasOwn$e(SymbolToStringRegistry,e))return SymbolToStringRegistry[e]}});var uncurryThis$r=functionUncurryThis,arraySlice$7=uncurryThis$r([].slice),uncurryThis$q=functionUncurryThis,isArray$a=isArray$d,isCallable$f=isCallable$r,classof$a=classofRaw$2,toString$d=toString$g,push$h=uncurryThis$q([].push),getJsonReplacerFunction=function(e){if(isCallable$f(e))return e;if(isArray$a(e)){for(var t=e.length,r=[],n=0;n<t;n++){var a=e[n];"string"==typeof a?push$h(r,a):"number"!=typeof a&&"Number"!=classof$a(a)&&"String"!=classof$a(a)||push$h(r,toString$d(a))}var i=r.length,s=!0;return function(e,t){if(s)return s=!1,t;if(isArray$a(this))return t;for(var n=0;n<i;n++)if(r[n]===e)return t}}},$$1J=_export,getBuiltIn$d=getBuiltIn$j,apply$5=functionApply,call$s=functionCall,uncurryThis$p=functionUncurryThis,fails$o=fails$A,isCallable$e=isCallable$r,isSymbol$1=isSymbol$5,arraySlice$6=arraySlice$7,getReplacerFunction=getJsonReplacerFunction,NATIVE_SYMBOL$1=symbolConstructorDetection,$String$1=String,$stringify=getBuiltIn$d("JSON","stringify"),exec$3=uncurryThis$p(/./.exec),charAt$5=uncurryThis$p("".charAt),charCodeAt$2=uncurryThis$p("".charCodeAt),replace$5=uncurryThis$p("".replace),numberToString$1=uncurryThis$p(1..toString),tester=/[\uD800-\uDFFF]/g,low=/^[\uD800-\uDBFF]$/,hi=/^[\uDC00-\uDFFF]$/,WRONG_SYMBOLS_CONVERSION=!NATIVE_SYMBOL$1||fails$o((function(){var e=getBuiltIn$d("Symbol")();return"[null]"!=$stringify([e])||"{}"!=$stringify({a:e})||"{}"!=$stringify(Object(e))})),ILL_FORMED_UNICODE=fails$o((function(){return'"\\udf06\\ud834"'!==$stringify("\udf06\ud834")||'"\\udead"'!==$stringify("\udead")})),stringifyWithSymbolsFix=function(e,t){var r=arraySlice$6(arguments),n=getReplacerFunction(t);if(isCallable$e(n)||void 0!==e&&!isSymbol$1(e))return r[1]=function(e,t){if(isCallable$e(n)&&(t=call$s(n,this,$String$1(e),t)),!isSymbol$1(t))return t},apply$5($stringify,null,r)},fixIllFormed=function(e,t,r){var n=charAt$5(r,t-1),a=charAt$5(r,t+1);return exec$3(low,e)&&!exec$3(hi,a)||exec$3(hi,e)&&!exec$3(low,n)?"\\u"+numberToString$1(charCodeAt$2(e,0),16):e};$stringify&&$$1J({target:"JSON",stat:!0,arity:3,forced:WRONG_SYMBOLS_CONVERSION||ILL_FORMED_UNICODE},{stringify:function(e,t,r){var n=arraySlice$6(arguments),a=apply$5(WRONG_SYMBOLS_CONVERSION?stringifyWithSymbolsFix:$stringify,null,n);return ILL_FORMED_UNICODE&&"string"==typeof a?replace$5(a,tester,fixIllFormed):a}});var $$1I=_export,NATIVE_SYMBOL=symbolConstructorDetection,fails$n=fails$A,getOwnPropertySymbolsModule$2=objectGetOwnPropertySymbols,toObject$9=toObject$d,FORCED$9=!NATIVE_SYMBOL||fails$n((function(){getOwnPropertySymbolsModule$2.f(1)}));$$1I({target:"Object",stat:!0,forced:FORCED$9},{getOwnPropertySymbols:function(e){var t=getOwnPropertySymbolsModule$2.f;return t?t(toObject$9(e)):[]}});var defineWellKnownSymbol$k=wellKnownSymbolDefine;defineWellKnownSymbol$k("asyncIterator");var defineWellKnownSymbol$j=wellKnownSymbolDefine;defineWellKnownSymbol$j("hasInstance");var defineWellKnownSymbol$i=wellKnownSymbolDefine;defineWellKnownSymbol$i("isConcatSpreadable");var defineWellKnownSymbol$h=wellKnownSymbolDefine;defineWellKnownSymbol$h("iterator");var defineWellKnownSymbol$g=wellKnownSymbolDefine;defineWellKnownSymbol$g("match");var defineWellKnownSymbol$f=wellKnownSymbolDefine;defineWellKnownSymbol$f("matchAll");var defineWellKnownSymbol$e=wellKnownSymbolDefine;defineWellKnownSymbol$e("replace");var defineWellKnownSymbol$d=wellKnownSymbolDefine;defineWellKnownSymbol$d("search");var defineWellKnownSymbol$c=wellKnownSymbolDefine;defineWellKnownSymbol$c("species");var defineWellKnownSymbol$b=wellKnownSymbolDefine;defineWellKnownSymbol$b("split");var defineWellKnownSymbol$a=wellKnownSymbolDefine,defineSymbolToPrimitive=symbolDefineToPrimitive;defineWellKnownSymbol$a("toPrimitive"),defineSymbolToPrimitive();var getBuiltIn$c=getBuiltIn$j,defineWellKnownSymbol$9=wellKnownSymbolDefine,setToStringTag$7=setToStringTag$9;defineWellKnownSymbol$9("toStringTag"),setToStringTag$7(getBuiltIn$c("Symbol"),"Symbol");var defineWellKnownSymbol$8=wellKnownSymbolDefine;defineWellKnownSymbol$8("unscopables");var global$g=global$s,setToStringTag$6=setToStringTag$9;setToStringTag$6(global$g.JSON,"JSON",!0);var IteratorPrototype$1,PrototypeOfArrayIteratorPrototype,arrayIterator,path$t=path$y,symbol$5=path$t.Symbol,iterators={},DESCRIPTORS$d=descriptors,hasOwn$d=hasOwnProperty_1,FunctionPrototype$1=Function.prototype,getDescriptor=DESCRIPTORS$d&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$d(FunctionPrototype$1,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$d||DESCRIPTORS$d&&getDescriptor(FunctionPrototype$1,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},fails$m=fails$A,correctPrototypeGetter=!fails$m((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),hasOwn$c=hasOwnProperty_1,isCallable$d=isCallable$r,toObject$8=toObject$d,sharedKey=sharedKey$4,CORRECT_PROTOTYPE_GETTER$1=correctPrototypeGetter,IE_PROTO=sharedKey("IE_PROTO"),$Object$1=Object,ObjectPrototype$1=$Object$1.prototype,objectGetPrototypeOf=CORRECT_PROTOTYPE_GETTER$1?$Object$1.getPrototypeOf:function(e){var t=toObject$8(e);if(hasOwn$c(t,IE_PROTO))return t[IE_PROTO];var r=t.constructor;return isCallable$d(r)&&t instanceof r?r.prototype:t instanceof $Object$1?ObjectPrototype$1:null},fails$l=fails$A,isCallable$c=isCallable$r,isObject$e=isObject$m,create$c=objectCreate,getPrototypeOf$8=objectGetPrototypeOf,defineBuiltIn$5=defineBuiltIn$8,wellKnownSymbol$g=wellKnownSymbol$r,ITERATOR$9=wellKnownSymbol$g("iterator"),BUGGY_SAFARI_ITERATORS$1=!1;[].keys&&("next"in(arrayIterator=[].keys())?(PrototypeOfArrayIteratorPrototype=getPrototypeOf$8(getPrototypeOf$8(arrayIterator)))!==Object.prototype&&(IteratorPrototype$1=PrototypeOfArrayIteratorPrototype):BUGGY_SAFARI_ITERATORS$1=!0);var NEW_ITERATOR_PROTOTYPE=!isObject$e(IteratorPrototype$1)||fails$l((function(){var e={};return IteratorPrototype$1[ITERATOR$9].call(e)!==e}));isCallable$c((IteratorPrototype$1=NEW_ITERATOR_PROTOTYPE?{}:create$c(IteratorPrototype$1))[ITERATOR$9])||defineBuiltIn$5(IteratorPrototype$1,ITERATOR$9,(function(){return this}));var iteratorsCore={IteratorPrototype:IteratorPrototype$1,BUGGY_SAFARI_ITERATORS:BUGGY_SAFARI_ITERATORS$1},IteratorPrototype=iteratorsCore.IteratorPrototype,create$b=objectCreate,createPropertyDescriptor$3=createPropertyDescriptor$8,setToStringTag$5=setToStringTag$9,Iterators$6=iterators,returnThis$1=function(){return this},iteratorCreateConstructor=function(e,t,r,n){var a=t+" Iterator";return e.prototype=create$b(IteratorPrototype,{next:createPropertyDescriptor$3(+!n,r)}),setToStringTag$5(e,a,!1,!0),Iterators$6[a]=returnThis$1,e},uncurryThis$o=functionUncurryThis,aCallable$i=aCallable$l,functionUncurryThisAccessor=function(e,t,r){try{return uncurryThis$o(aCallable$i(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}},isCallable$b=isCallable$r,$String=String,$TypeError$f=TypeError,aPossiblePrototype$1=function(e){if("object"==typeof e||isCallable$b(e))return e;throw $TypeError$f("Can't set "+$String(e)+" as a prototype")},uncurryThisAccessor=functionUncurryThisAccessor,anObject$d=anObject$i,aPossiblePrototype=aPossiblePrototype$1,objectSetPrototypeOf=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=uncurryThisAccessor(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(e){}return function(r,n){return anObject$d(r),aPossiblePrototype(n),t?e(r,n):r.__proto__=n,r}}():void 0),$$1H=_export,call$r=functionCall,FunctionName=functionName,createIteratorConstructor$1=iteratorCreateConstructor,getPrototypeOf$7=objectGetPrototypeOf,setToStringTag$4=setToStringTag$9,defineBuiltIn$4=defineBuiltIn$8,wellKnownSymbol$f=wellKnownSymbol$r,Iterators$5=iterators,IteratorsCore=iteratorsCore,PROPER_FUNCTION_NAME$1=FunctionName.PROPER;FunctionName.CONFIGURABLE,IteratorsCore.IteratorPrototype;var BUGGY_SAFARI_ITERATORS=IteratorsCore.BUGGY_SAFARI_ITERATORS,ITERATOR$8=wellKnownSymbol$f("iterator"),KEYS="keys",VALUES="values",ENTRIES="entries",returnThis=function(){return this},iteratorDefine=function(e,t,r,n,a,i,s){createIteratorConstructor$1(r,t,n);var o,l,c,u=function(e){if(e===a&&y)return y;if(!BUGGY_SAFARI_ITERATORS&&e in h)return h[e];switch(e){case KEYS:case VALUES:case ENTRIES:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",f=!1,h=e.prototype,p=h[ITERATOR$8]||h["@@iterator"]||a&&h[a],y=!BUGGY_SAFARI_ITERATORS&&p||u(a),g="Array"==t&&h.entries||p;if(g&&(o=getPrototypeOf$7(g.call(new e)))!==Object.prototype&&o.next&&(setToStringTag$4(o,d,!0,!0),Iterators$5[d]=returnThis),PROPER_FUNCTION_NAME$1&&a==VALUES&&p&&p.name!==VALUES&&(f=!0,y=function(){return call$r(p,this)}),a)if(l={values:u(VALUES),keys:i?y:u(KEYS),entries:u(ENTRIES)},s)for(c in l)(BUGGY_SAFARI_ITERATORS||f||!(c in h))&&defineBuiltIn$4(h,c,l[c]);else $$1H({target:t,proto:!0,forced:BUGGY_SAFARI_ITERATORS||f},l);return s&&h[ITERATOR$8]!==y&&defineBuiltIn$4(h,ITERATOR$8,y,{name:a}),Iterators$5[t]=y,l},createIterResultObject$3=function(e,t){return{value:e,done:t}},toIndexedObject$5=toIndexedObject$c,Iterators$4=iterators,InternalStateModule$6=internalState;objectDefineProperty.f;var defineIterator$2=iteratorDefine,createIterResultObject$2=createIterResultObject$3,ARRAY_ITERATOR="Array Iterator",setInternalState$6=InternalStateModule$6.set,getInternalState$1=InternalStateModule$6.getterFor(ARRAY_ITERATOR);defineIterator$2(Array,"Array",(function(e,t){setInternalState$6(this,{type:ARRAY_ITERATOR,target:toIndexedObject$5(e),index:0,kind:t})}),(function(){var e=getInternalState$1(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,createIterResultObject$2(void 0,!0)):createIterResultObject$2("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),Iterators$4.Arguments=Iterators$4.Array;var domIterables={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},DOMIterables$3=domIterables,global$f=global$s,classof$9=classof$f,createNonEnumerableProperty$4=createNonEnumerableProperty$9,Iterators$3=iterators,wellKnownSymbol$e=wellKnownSymbol$r,TO_STRING_TAG$1=wellKnownSymbol$e("toStringTag");for(var COLLECTION_NAME in DOMIterables$3){var Collection=global$f[COLLECTION_NAME],CollectionPrototype=Collection&&Collection.prototype;CollectionPrototype&&classof$9(CollectionPrototype)!==TO_STRING_TAG$1&&createNonEnumerableProperty$4(CollectionPrototype,TO_STRING_TAG$1,COLLECTION_NAME),Iterators$3[COLLECTION_NAME]=Iterators$3.Array}var parent$2E=symbol$5,symbol$4=parent$2E,defineWellKnownSymbol$7=wellKnownSymbolDefine;defineWellKnownSymbol$7("dispose");var parent$2D=symbol$4,symbol$3=parent$2D,defineWellKnownSymbol$6=wellKnownSymbolDefine;defineWellKnownSymbol$6("asyncDispose");var $$1G=_export,getBuiltIn$b=getBuiltIn$j,uncurryThis$n=functionUncurryThis,Symbol$4=getBuiltIn$b("Symbol"),keyFor2=Symbol$4.keyFor,thisSymbolValue$1=uncurryThis$n(Symbol$4.prototype.valueOf);$$1G({target:"Symbol",stat:!0},{isRegistered:function(e){try{return void 0!==keyFor2(thisSymbolValue$1(e))}catch(e){return!1}}});for(var $$1F=_export,shared=sharedExports,getBuiltIn$a=getBuiltIn$j,uncurryThis$m=functionUncurryThis,isSymbol=isSymbol$5,wellKnownSymbol$d=wellKnownSymbol$r,Symbol$3=getBuiltIn$a("Symbol"),$isWellKnown=Symbol$3.isWellKnown,getOwnPropertyNames4=getBuiltIn$a("Object","getOwnPropertyNames"),thisSymbolValue=uncurryThis$m(Symbol$3.prototype.valueOf),WellKnownSymbolsStore=shared("wks"),i=0,symbolKeys=getOwnPropertyNames4(Symbol$3),symbolKeysLength=symbolKeys.length;i<symbolKeysLength;i++)try{var symbolKey=symbolKeys[i];isSymbol(Symbol$3[symbolKey])&&wellKnownSymbol$d(symbolKey)}catch(e){}$$1F({target:"Symbol",stat:!0,forced:!0},{isWellKnown:function(e){if($isWellKnown&&$isWellKnown(e))return!0;try{for(var t=thisSymbolValue(e),r=0,n=getOwnPropertyNames4(WellKnownSymbolsStore),a=n.length;r<a;r++)if(WellKnownSymbolsStore[n[r]]==t)return!0}catch(e){}return!1}});var defineWellKnownSymbol$5=wellKnownSymbolDefine;defineWellKnownSymbol$5("matcher");var defineWellKnownSymbol$4=wellKnownSymbolDefine;defineWellKnownSymbol$4("metadataKey");var defineWellKnownSymbol$3=wellKnownSymbolDefine;defineWellKnownSymbol$3("observable");var defineWellKnownSymbol$2=wellKnownSymbolDefine;defineWellKnownSymbol$2("metadata");var defineWellKnownSymbol$1=wellKnownSymbolDefine;defineWellKnownSymbol$1("patternMatch");var defineWellKnownSymbol=wellKnownSymbolDefine;defineWellKnownSymbol("replaceAll");var parent$2C=symbol$3,symbol$2=parent$2C,symbol$1=symbol$2,_Symbol$1=getDefaultExportFromCjs$1(symbol$1),uncurryThis$l=functionUncurryThis,toIntegerOrInfinity$4=toIntegerOrInfinity$7,toString$c=toString$g,requireObjectCoercible$5=requireObjectCoercible$8,charAt$4=uncurryThis$l("".charAt),charCodeAt$1=uncurryThis$l("".charCodeAt),stringSlice$4=uncurryThis$l("".slice),createMethod$4=function(e){return function(t,r){var n,a,i=toString$c(requireObjectCoercible$5(t)),s=toIntegerOrInfinity$4(r),o=i.length;return s<0||s>=o?e?"":void 0:(n=charCodeAt$1(i,s))<55296||n>56319||s+1===o||(a=charCodeAt$1(i,s+1))<56320||a>57343?e?charAt$4(i,s):n:e?stringSlice$4(i,s,s+2):a-56320+(n-55296<<10)+65536}},stringMultibyte={codeAt:createMethod$4(!1),charAt:createMethod$4(!0)},charAt$3=stringMultibyte.charAt,toString$b=toString$g,InternalStateModule$5=internalState,defineIterator$1=iteratorDefine,createIterResultObject$1=createIterResultObject$3,STRING_ITERATOR="String Iterator",setInternalState$5=InternalStateModule$5.set,getInternalState=InternalStateModule$5.getterFor(STRING_ITERATOR);defineIterator$1(String,"String",(function(e){setInternalState$5(this,{type:STRING_ITERATOR,string:toString$b(e),index:0})}),(function(){var e,t=getInternalState(this),r=t.string,n=t.index;return n>=r.length?createIterResultObject$1(void 0,!0):(e=charAt$3(r,n),t.index+=e.length,createIterResultObject$1(e,!1))}));var WrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,iterator$5=WrappedWellKnownSymbolModule$1.f("iterator"),parent$2B=iterator$5,iterator$4=parent$2B,parent$2A=iterator$4,iterator$3=parent$2A,parent$2z=iterator$3,iterator$2=parent$2z,iterator$1=iterator$2,_Symbol$iterator$1=getDefaultExportFromCjs$1(iterator$1);function _typeof$1(e){return(_typeof$1="function"==typeof _Symbol$1&&"symbol"==typeof _Symbol$iterator$1?function(e){return typeof e}:function(e){return e&&"function"==typeof _Symbol$1&&e.constructor===_Symbol$1&&e!==_Symbol$1.prototype?"symbol":typeof e})(e)}var WrappedWellKnownSymbolModule=wellKnownSymbolWrapped,toPrimitive$5=WrappedWellKnownSymbolModule.f("toPrimitive"),parent$2y=toPrimitive$5,toPrimitive$4=parent$2y,parent$2x=toPrimitive$4,toPrimitive$3=parent$2x,parent$2w=toPrimitive$3,toPrimitive$2=parent$2w,toPrimitive$1=toPrimitive$2,_Symbol$toPrimitive$1=getDefaultExportFromCjs$1(toPrimitive$1);function _toPrimitive$2(e,t){if("object"!==_typeof$1(e)||null===e)return e;var r=e[_Symbol$toPrimitive$1];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof$1(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey$2(e){var t=_toPrimitive$2(e,"string");return"symbol"===_typeof$1(t)?t:String(t)}function _defineProperties$1(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),_Object$defineProperty$1(e,_toPropertyKey$2(n.key),n)}}function _createClass$1(e,t,r){return t&&_defineProperties$1(e.prototype,t),r&&_defineProperties$1(e,r),_Object$defineProperty$1(e,"prototype",{writable:!1}),e}var hasOwn$b=hasOwnProperty_1,isDataDescriptor$1=function(e){return void 0!==e&&(hasOwn$b(e,"value")||hasOwn$b(e,"writable"))},$$1E=_export,call$q=functionCall,isObject$d=isObject$m,anObject$c=anObject$i,isDataDescriptor=isDataDescriptor$1,getOwnPropertyDescriptorModule$2=objectGetOwnPropertyDescriptor,getPrototypeOf$6=objectGetPrototypeOf;function get$7(e,t){var r,n,a=arguments.length<3?e:arguments[2];return anObject$c(e)===a?e[t]:(r=getOwnPropertyDescriptorModule$2.f(e,t))?isDataDescriptor(r)?r.value:void 0===r.get?void 0:call$q(r.get,a):isObject$d(n=getPrototypeOf$6(e))?get$7(n,t,a):void 0}$$1E({target:"Reflect",stat:!0},{get:get$7});var path$s=path$y,get$6=path$s.Reflect.get,parent$2v=get$6,get$5=parent$2v,parent$2u=get$5,get$4=parent$2u,parent$2t=get$4,get$3=parent$2t,get$2=get$3,_Reflect$get=getDefaultExportFromCjs$1(get$2),uncurryThis$k=functionUncurryThis,aCallable$h=aCallable$l,isObject$c=isObject$m,hasOwn$a=hasOwnProperty_1,arraySlice$5=arraySlice$7,NATIVE_BIND=functionBindNative,$Function=Function,concat$9=uncurryThis$k([].concat),join$3=uncurryThis$k([].join),factories={},construct$5=function(e,t,r){if(!hasOwn$a(factories,t)){for(var n=[],a=0;a<t;a++)n[a]="a["+a+"]";factories[t]=$Function("C,a","return new C("+join$3(n,",")+")")}return factories[t](e,r)},functionBind=NATIVE_BIND?$Function.bind:function(e){var t=aCallable$h(this),r=t.prototype,n=arraySlice$5(arguments,1),a=function(){var r=concat$9(n,arraySlice$5(arguments));return this instanceof a?construct$5(t,r.length,r):t.apply(e,r)};return isObject$c(r)&&(a.prototype=r),a},$$1D=_export,bind$t=functionBind;$$1D({target:"Function",proto:!0,forced:Function.bind!==bind$t},{bind:bind$t});var path$r=path$y,entryVirtual$n=function(e){return path$r[e+"Prototype"]},entryVirtual$m=entryVirtual$n,bind$s=entryVirtual$m("Function").bind,isPrototypeOf$q=objectIsPrototypeOf,method$k=bind$s,FunctionPrototype=Function.prototype,bind$r=function(e){var t=e.bind;return e===FunctionPrototype||isPrototypeOf$q(FunctionPrototype,e)&&t===FunctionPrototype.bind?method$k:t},parent$2s=bind$r,bind$q=parent$2s,parent$2r=bind$q,bind$p=parent$2r,parent$2q=bind$p,bind$o=parent$2q,bind$n=bind$o,_bindInstanceProperty$1=getDefaultExportFromCjs$1(bind$n),getOwnPropertyDescriptor$9={exports:{}},$$1C=_export,fails$k=fails$A,toIndexedObject$4=toIndexedObject$c,nativeGetOwnPropertyDescriptor=objectGetOwnPropertyDescriptor.f,DESCRIPTORS$c=descriptors,FORCED$8=!DESCRIPTORS$c||fails$k((function(){nativeGetOwnPropertyDescriptor(1)}));$$1C({target:"Object",stat:!0,forced:FORCED$8,sham:!DESCRIPTORS$c},{getOwnPropertyDescriptor:function(e,t){return nativeGetOwnPropertyDescriptor(toIndexedObject$4(e),t)}});var path$q=path$y,Object$3=path$q.Object,getOwnPropertyDescriptor$8=getOwnPropertyDescriptor$9.exports=function(e,t){return Object$3.getOwnPropertyDescriptor(e,t)};Object$3.getOwnPropertyDescriptor.sham&&(getOwnPropertyDescriptor$8.sham=!0);var getOwnPropertyDescriptorExports=getOwnPropertyDescriptor$9.exports,parent$2p=getOwnPropertyDescriptorExports,getOwnPropertyDescriptor$7=parent$2p,parent$2o=getOwnPropertyDescriptor$7,getOwnPropertyDescriptor$6=parent$2o,parent$2n=getOwnPropertyDescriptor$6,getOwnPropertyDescriptor$5=parent$2n,getOwnPropertyDescriptor$4=getOwnPropertyDescriptor$5,_Object$getOwnPropertyDescriptor$1=getDefaultExportFromCjs$1(getOwnPropertyDescriptor$4),$$1B=_export,setPrototypeOf$6=objectSetPrototypeOf;$$1B({target:"Object",stat:!0},{setPrototypeOf:setPrototypeOf$6});var path$p=path$y,setPrototypeOf$5=path$p.Object.setPrototypeOf,parent$2m=setPrototypeOf$5,setPrototypeOf$4=parent$2m,parent$2l=setPrototypeOf$4,setPrototypeOf$3=parent$2l,parent$2k=setPrototypeOf$3,setPrototypeOf$2=parent$2k,setPrototypeOf$1=setPrototypeOf$2,_Object$setPrototypeOf=getDefaultExportFromCjs$1(setPrototypeOf$1),$$1A=_export,fails$j=fails$A,toObject$7=toObject$d,nativeGetPrototypeOf=objectGetPrototypeOf,CORRECT_PROTOTYPE_GETTER=correctPrototypeGetter,FAILS_ON_PRIMITIVES$2=fails$j((function(){nativeGetPrototypeOf(1)}));$$1A({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$2,sham:!CORRECT_PROTOTYPE_GETTER},{getPrototypeOf:function(e){return nativeGetPrototypeOf(toObject$7(e))}});var path$o=path$y,getPrototypeOf$5=path$o.Object.getPrototypeOf,parent$2j=getPrototypeOf$5,getPrototypeOf$4=parent$2j,parent$2i=getPrototypeOf$4,getPrototypeOf$3=parent$2i,parent$2h=getPrototypeOf$3,getPrototypeOf$2=parent$2h,getPrototypeOf$1=getPrototypeOf$2,_Object$getPrototypeOf=getDefaultExportFromCjs$1(getPrototypeOf$1);function _getPrototypeOf(e){var t;return(_getPrototypeOf=_Object$setPrototypeOf?_bindInstanceProperty$1(t=_Object$getPrototypeOf).call(t):function(e){return e.__proto__||_Object$getPrototypeOf(e)})(e)}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(){var e;"undefined"!=typeof Reflect&&_Reflect$get?_get=_bindInstanceProperty$1(e=_Reflect$get).call(e):_get=function(e,t,r){var n=_superPropBase(e,t);if(n){var a=_Object$getOwnPropertyDescriptor$1(n,t);return a.get?a.get.call(arguments.length<3?e:r):a.value}};return _get.apply(this,arguments)}var $$1z=_export,DESCRIPTORS$b=descriptors,create$a=objectCreate;$$1z({target:"Object",stat:!0,sham:!DESCRIPTORS$b},{create:create$a});var path$n=path$y,Object$2=path$n.Object,create$9=function(e,t){return Object$2.create(e,t)},parent$2g=create$9,create$8=parent$2g,parent$2f=create$8,create$7=parent$2f,parent$2e=create$7,create$6=parent$2e,create$5=create$6,_Object$create$1=getDefaultExportFromCjs$1(create$5);function _setPrototypeOf(e,t){var r;return(_setPrototypeOf=_Object$setPrototypeOf?_bindInstanceProperty$1(r=_Object$setPrototypeOf).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=_Object$create$1(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),_Object$defineProperty$1(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}var isConstructor$2=isConstructor$4,tryToString$5=tryToString$8,$TypeError$e=TypeError,aConstructor$3=function(e){if(isConstructor$2(e))return e;throw $TypeError$e(tryToString$5(e)+" is not a constructor")},$$1y=_export,getBuiltIn$9=getBuiltIn$j,apply$4=functionApply,bind$m=functionBind,aConstructor$2=aConstructor$3,anObject$b=anObject$i,isObject$b=isObject$m,create$4=objectCreate,fails$i=fails$A,nativeConstruct=getBuiltIn$9("Reflect","construct"),ObjectPrototype=Object.prototype,push$g=[].push,NEW_TARGET_BUG=fails$i((function(){function e(){}return!(nativeConstruct((function(){}),[],e)instanceof e)})),ARGS_BUG=!fails$i((function(){nativeConstruct((function(){}))})),FORCED$7=NEW_TARGET_BUG||ARGS_BUG;$$1y({target:"Reflect",stat:!0,forced:FORCED$7,sham:FORCED$7},{construct:function(e,t){aConstructor$2(e),anObject$b(t);var r=arguments.length<3?e:aConstructor$2(arguments[2]);if(ARGS_BUG&&!NEW_TARGET_BUG)return nativeConstruct(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return apply$4(push$g,n,t),new(apply$4(bind$m,e,n))}var a=r.prototype,i=create$4(isObject$b(a)?a:ObjectPrototype),s=apply$4(e,i,t);return isObject$b(s)?s:i}});var path$m=path$y,construct$4=path$m.Reflect.construct,parent$2d=construct$4,construct$3=parent$2d,parent$2c=construct$3,construct$2=parent$2c,parent$2b=construct$2,construct$1=parent$2b,construct2=construct$1,_Reflect$construct=getDefaultExportFromCjs$1(construct2);function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!_Reflect$construct)return!1;if(_Reflect$construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(_Reflect$construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof$1(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var a=_getPrototypeOf(this).constructor;r=_Reflect$construct(n,arguments,a)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}var fails$h=fails$A,arrayMethodIsStrict$7=function(e,t){var r=[][e];return!!r&&fails$h((function(){r.call(null,t||function(){return 1},1)}))},$forEach=arrayIteration.forEach,arrayMethodIsStrict$6=arrayMethodIsStrict$7,STRICT_METHOD$4=arrayMethodIsStrict$6("forEach"),arrayForEach=STRICT_METHOD$4?[].forEach:function(e){return $forEach(this,e,arguments.length>1?arguments[1]:void 0)},$$1x=_export,forEach$8=arrayForEach;$$1x({target:"Array",proto:!0,forced:[].forEach!=arrayForEach},{forEach:arrayForEach});var entryVirtual$l=entryVirtual$n,forEach$7=entryVirtual$l("Array").forEach,parent$2a=forEach$7,forEach$6=parent$2a,classof$8=classof$f,hasOwn$9=hasOwnProperty_1,isPrototypeOf$p=objectIsPrototypeOf,method$j=forEach$6,ArrayPrototype$i=Array.prototype,DOMIterables$2={DOMTokenList:!0,NodeList:!0},forEach$5=function(e){var t=e.forEach;return e===ArrayPrototype$i||isPrototypeOf$p(ArrayPrototype$i,e)&&t===ArrayPrototype$i.forEach||hasOwn$9(DOMIterables$2,classof$8(e))?method$j:t},parent$29=forEach$5,forEach$4=parent$29,parent$28=forEach$4,forEach$3=parent$28,forEach$2=forEach$3,_forEachInstanceProperty$1=getDefaultExportFromCjs$1(forEach$2),forEach$1=forEach$2,_forEachInstanceProperty=getDefaultExportFromCjs$1(forEach$1),DESCRIPTORS$a=descriptors,uncurryThis$j=functionUncurryThis,objectKeys$1=objectKeys$4,toIndexedObject$3=toIndexedObject$c,$propertyIsEnumerable=objectPropertyIsEnumerable.f,propertyIsEnumerable3=uncurryThis$j($propertyIsEnumerable),push$f=uncurryThis$j([].push),createMethod$3=function(e){return function(t){for(var r,n=toIndexedObject$3(t),a=objectKeys$1(n),i=a.length,s=0,o=[];i>s;)r=a[s++],DESCRIPTORS$a&&!propertyIsEnumerable3(n,r)||push$f(o,e?[r,n[r]]:n[r]);return o}},objectToArray={entries:createMethod$3(!0),values:createMethod$3(!1)},$$1w=_export,$values=objectToArray.values;$$1w({target:"Object",stat:!0},{values:function(e){return $values(e)}});var path$l=path$y,values$c=path$l.Object.values,parent$27=values$c,values$b=parent$27,parent$26=values$b,values$a=parent$26,parent$25=values$a,values$9=parent$25,values$8=values$9,values$7=values$8,_Object$values=getDefaultExportFromCjs$1(values$7),entryVirtual$k=entryVirtual$n,concat$8=entryVirtual$k("Array").concat,isPrototypeOf$o=objectIsPrototypeOf,method$i=concat$8,ArrayPrototype$h=Array.prototype,concat$7=function(e){var t=e.concat;return e===ArrayPrototype$h||isPrototypeOf$o(ArrayPrototype$h,e)&&t===ArrayPrototype$h.concat?method$i:t},parent$24=concat$7,concat$6=parent$24,parent$23=concat$6,concat$5=parent$23,parent$22=concat$5,concat$4=parent$22,concat$3=concat$4,concat$2=concat$3,_concatInstanceProperty=getDefaultExportFromCjs$1(concat$2),$$1v=_export,toObject$6=toObject$d,nativeKeys=objectKeys$4,fails$g=fails$A,FAILS_ON_PRIMITIVES$1=fails$g((function(){nativeKeys(1)}));$$1v({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$1},{keys:function(e){return nativeKeys(toObject$6(e))}});var path$k=path$y,keys$5=path$k.Object.keys,parent$21=keys$5,keys$4=parent$21,parent$20=keys$4,keys$3=parent$20,parent$1$=keys$3,keys$2=parent$1$,keys$1=keys$2,_Object$keys$1=getDefaultExportFromCjs$1(keys$1),path$j=path$y,getOwnPropertySymbols$5=path$j.Object.getOwnPropertySymbols,parent$1_=getOwnPropertySymbols$5,getOwnPropertySymbols$4=parent$1_,parent$1Z=getOwnPropertySymbols$4,getOwnPropertySymbols$3=parent$1Z,parent$1Y=getOwnPropertySymbols$3,getOwnPropertySymbols$2=parent$1Y,getOwnPropertySymbols$1=getOwnPropertySymbols$2,_Object$getOwnPropertySymbols$1=getDefaultExportFromCjs$1(getOwnPropertySymbols$1),$$1u=_export,$filter=arrayIteration.filter,arrayMethodHasSpeciesSupport$3=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$3=arrayMethodHasSpeciesSupport$3("filter");$$1u({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$3},{filter:function(e){return $filter(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$j=entryVirtual$n,filter$6=entryVirtual$j("Array").filter,isPrototypeOf$n=objectIsPrototypeOf,method$h=filter$6,ArrayPrototype$g=Array.prototype,filter$5=function(e){var t=e.filter;return e===ArrayPrototype$g||isPrototypeOf$n(ArrayPrototype$g,e)&&t===ArrayPrototype$g.filter?method$h:t},parent$1X=filter$5,filter$4=parent$1X,parent$1W=filter$4,filter$3=parent$1W,parent$1V=filter$3,filter$2=parent$1V,filter$1=filter$2,_filterInstanceProperty$1=getDefaultExportFromCjs$1(filter$1),DESCRIPTORS$9=descriptors,isArray$9=isArray$d,$TypeError$d=TypeError,getOwnPropertyDescriptor$3=Object.getOwnPropertyDescriptor,SILENT_ON_NON_WRITABLE_LENGTH_SET=DESCRIPTORS$9&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),arraySetLength=SILENT_ON_NON_WRITABLE_LENGTH_SET?function(e,t){if(isArray$9(e)&&!getOwnPropertyDescriptor$3(e,"length").writable)throw $TypeError$d("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},$$1t=_export,toObject$5=toObject$d,lengthOfArrayLike$7=lengthOfArrayLike$c,setArrayLength$1=arraySetLength,doesNotExceedSafeInteger$1=doesNotExceedSafeInteger$3,fails$f=fails$A,INCORRECT_TO_LENGTH=fails$f((function(){return 4294967297!==[].push.call({length:4294967296},1)})),properErrorOnNonWritableLength=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}},FORCED$6=INCORRECT_TO_LENGTH||!properErrorOnNonWritableLength();$$1t({target:"Array",proto:!0,arity:1,forced:FORCED$6},{push:function(e){var t=toObject$5(this),r=lengthOfArrayLike$7(t),n=arguments.length;doesNotExceedSafeInteger$1(r+n);for(var a=0;a<n;a++)t[r]=arguments[a],r++;return setArrayLength$1(t,r),r}});var entryVirtual$i=entryVirtual$n,push$e=entryVirtual$i("Array").push,isPrototypeOf$m=objectIsPrototypeOf,method$g=push$e,ArrayPrototype$f=Array.prototype,push$d=function(e){var t=e.push;return e===ArrayPrototype$f||isPrototypeOf$m(ArrayPrototype$f,e)&&t===ArrayPrototype$f.push?method$g:t},parent$1U=push$d,push$c=parent$1U,parent$1T=push$c,push$b=parent$1T,parent$1S=push$b,push$a=parent$1S,push$9=push$a,_pushInstanceProperty=getDefaultExportFromCjs$1(push$9),getBuiltIn$8=getBuiltIn$j,uncurryThis$i=functionUncurryThis,getOwnPropertyNamesModule$1=objectGetOwnPropertyNames,getOwnPropertySymbolsModule$1=objectGetOwnPropertySymbols,anObject$a=anObject$i,concat$1=uncurryThis$i([].concat),ownKeys$5=getBuiltIn$8("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule$1.f(anObject$a(e)),r=getOwnPropertySymbolsModule$1.f;return r?concat$1(t,r(e)):t},$$1s=_export,DESCRIPTORS$8=descriptors,ownKeys$4=ownKeys$5,toIndexedObject$2=toIndexedObject$c,getOwnPropertyDescriptorModule$1=objectGetOwnPropertyDescriptor,createProperty$3=createProperty$6;$$1s({target:"Object",stat:!0,sham:!DESCRIPTORS$8},{getOwnPropertyDescriptors:function(e){for(var t,r,n=toIndexedObject$2(e),a=getOwnPropertyDescriptorModule$1.f,i=ownKeys$4(n),s={},o=0;i.length>o;)void 0!==(r=a(n,t=i[o++]))&&createProperty$3(s,t,r);return s}});var path$i=path$y,getOwnPropertyDescriptors$5=path$i.Object.getOwnPropertyDescriptors,parent$1R=getOwnPropertyDescriptors$5,getOwnPropertyDescriptors$4=parent$1R,parent$1Q=getOwnPropertyDescriptors$4,getOwnPropertyDescriptors$3=parent$1Q,parent$1P=getOwnPropertyDescriptors$3,getOwnPropertyDescriptors$2=parent$1P,getOwnPropertyDescriptors$1=getOwnPropertyDescriptors$2,_Object$getOwnPropertyDescriptors$1=getDefaultExportFromCjs$1(getOwnPropertyDescriptors$1),defineProperties$7={exports:{}},$$1r=_export,DESCRIPTORS$7=descriptors,defineProperties$6=objectDefineProperties.f;$$1r({target:"Object",stat:!0,forced:Object.defineProperties!==defineProperties$6,sham:!DESCRIPTORS$7},{defineProperties:defineProperties$6});var path$h=path$y,Object$1=path$h.Object,defineProperties$5=defineProperties$7.exports=function(e,t){return Object$1.defineProperties(e,t)};Object$1.defineProperties.sham&&(defineProperties$5.sham=!0);var definePropertiesExports=defineProperties$7.exports,parent$1O=definePropertiesExports,defineProperties$4=parent$1O,parent$1N=defineProperties$4,defineProperties$3=parent$1N,parent$1M=defineProperties$3,defineProperties$2=parent$1M,defineProperties$1=defineProperties$2,_Object$defineProperties$1=getDefaultExportFromCjs$1(defineProperties$1);function _defineProperty$2(e,t,r){return(t=_toPropertyKey$2(t))in e?_Object$defineProperty$1(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys$3(e,t){var r=_Object$keys$1(e);if(_Object$getOwnPropertySymbols$1){var n=_Object$getOwnPropertySymbols$1(e);t&&(n=_filterInstanceProperty$1(n).call(n,(function(t){return _Object$getOwnPropertyDescriptor$1(e,t).enumerable}))),_pushInstanceProperty(r).apply(r,n)}return r}function _objectSpread2$2(e){for(var t=1;t<arguments.length;t++){var r,n,a=null!=arguments[t]?arguments[t]:{};t%2?_forEachInstanceProperty$1(r=ownKeys$3(Object(a),!0)).call(r,(function(t){_defineProperty$2(e,t,a[t])})):_Object$getOwnPropertyDescriptors$1?_Object$defineProperties$1(e,_Object$getOwnPropertyDescriptors$1(a)):_forEachInstanceProperty$1(n=ownKeys$3(Object(a))).call(n,(function(t){_Object$defineProperty$1(e,t,_Object$getOwnPropertyDescriptor$1(a,t))}))}return e}var engineIsBun="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,$TypeError$c=TypeError,validateArgumentsLength$5=function(e,t){if(e<t)throw $TypeError$c("Not enough arguments");return e},global$e=global$s,apply$3=functionApply,isCallable$a=isCallable$r,ENGINE_IS_BUN=engineIsBun,USER_AGENT=engineUserAgent,arraySlice$4=arraySlice$7,validateArgumentsLength$4=validateArgumentsLength$5,Function$2=global$e.Function,WRAP=/MSIE .\./.test(USER_AGENT)||ENGINE_IS_BUN&&function(){var e=global$e.Bun.version.split(".");return e.length<3||0==e[0]&&(e[1]<3||3==e[1]&&0==e[2])}(),schedulersFix$2=function(e,t){var r=t?2:1;return WRAP?function(n,a){var i=validateArgumentsLength$4(arguments.length,1)>r,s=isCallable$a(n)?n:Function$2(n),o=i?arraySlice$4(arguments,r):[],l=i?function(){apply$3(s,this,o)}:s;return t?e(l,a):e(l)}:e},$$1q=_export,global$d=global$s,schedulersFix$1=schedulersFix$2,setInterval$5=schedulersFix$1(global$d.setInterval,!0);$$1q({global:!0,bind:!0,forced:global$d.setInterval!==setInterval$5},{setInterval:setInterval$5});var $$1p=_export,global$c=global$s,schedulersFix=schedulersFix$2,setTimeout$6=schedulersFix(global$c.setTimeout,!0);$$1p({global:!0,bind:!0,forced:global$c.setTimeout!==setTimeout$6},{setTimeout:setTimeout$6});var path$g=path$y,setTimeout$5=path$g.setTimeout,parent$1L=setTimeout$5,setTimeout$4=parent$1L,parent$1K=setTimeout$4,setTimeout$3=parent$1K,setTimeout$2=setTimeout$3,setTimeout$1=setTimeout$2,_setTimeout=getDefaultExportFromCjs$1(setTimeout$1),keys3=keys$1,_Object$keys=getDefaultExportFromCjs$1(keys3),$$1o=_export,$includes=arrayIncludes.includes,fails$e=fails$A,BROKEN_ON_SPARSE=fails$e((function(){return!Array(1).includes()}));$$1o({target:"Array",proto:!0,forced:BROKEN_ON_SPARSE},{includes:function(e){return $includes(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$h=entryVirtual$n,includes$7=entryVirtual$h("Array").includes,isObject$a=isObject$m,classof$7=classofRaw$2,wellKnownSymbol$c=wellKnownSymbol$r,MATCH$1=wellKnownSymbol$c("match"),isRegexp=function(e){var t;return isObject$a(e)&&(void 0!==(t=e[MATCH$1])?!!t:"RegExp"==classof$7(e))},isRegExp=isRegexp,$TypeError$b=TypeError,notARegexp=function(e){if(isRegExp(e))throw $TypeError$b("The method doesn't accept regular expressions");return e},wellKnownSymbol$b=wellKnownSymbol$r,MATCH=wellKnownSymbol$b("match"),correctIsRegexpLogic=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[MATCH]=!1,"/./"[e](t)}catch(e){}}return!1},$$1n=_export,uncurryThis$h=functionUncurryThis,notARegExp$1=notARegexp,requireObjectCoercible$4=requireObjectCoercible$8,toString$a=toString$g,correctIsRegExpLogic$1=correctIsRegexpLogic,stringIndexOf=uncurryThis$h("".indexOf);$$1n({target:"String",proto:!0,forced:!correctIsRegExpLogic$1("includes")},{includes:function(e){return!!~stringIndexOf(toString$a(requireObjectCoercible$4(this)),toString$a(notARegExp$1(e)),arguments.length>1?arguments[1]:void 0)}});var entryVirtual$g=entryVirtual$n,includes$6=entryVirtual$g("String").includes,isPrototypeOf$l=objectIsPrototypeOf,arrayMethod=includes$7,stringMethod=includes$6,ArrayPrototype$e=Array.prototype,StringPrototype$3=String.prototype,includes$5=function(e){var t=e.includes;return e===ArrayPrototype$e||isPrototypeOf$l(ArrayPrototype$e,e)&&t===ArrayPrototype$e.includes?arrayMethod:"string"==typeof e||e===StringPrototype$3||isPrototypeOf$l(StringPrototype$3,e)&&t===StringPrototype$3.includes?stringMethod:t},parent$1J=includes$5,includes$4=parent$1J,parent$1I=includes$4,includes$3=parent$1I,parent$1H=includes$3,includes$2=parent$1H,includes$1=includes$2,includes3=includes$1,_includesInstanceProperty=getDefaultExportFromCjs$1(includes3),$$1m=_export,uncurryThis$g=functionUncurryThisClause,$indexOf=arrayIncludes.indexOf,arrayMethodIsStrict$5=arrayMethodIsStrict$7,nativeIndexOf=uncurryThis$g([].indexOf),NEGATIVE_ZERO$1=!!nativeIndexOf&&1/nativeIndexOf([1],1,-0)<0,FORCED$5=NEGATIVE_ZERO$1||!arrayMethodIsStrict$5("indexOf");$$1m({target:"Array",proto:!0,forced:FORCED$5},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return NEGATIVE_ZERO$1?nativeIndexOf(this,e,t)||0:$indexOf(this,e,t)}});var entryVirtual$f=entryVirtual$n,indexOf$6=entryVirtual$f("Array").indexOf,isPrototypeOf$k=objectIsPrototypeOf,method$f=indexOf$6,ArrayPrototype$d=Array.prototype,indexOf$5=function(e){var t=e.indexOf;return e===ArrayPrototype$d||isPrototypeOf$k(ArrayPrototype$d,e)&&t===ArrayPrototype$d.indexOf?method$f:t},parent$1G=indexOf$5,indexOf$4=parent$1G,parent$1F=indexOf$4,indexOf$3=parent$1F,parent$1E=indexOf$3,indexOf$2=parent$1E,indexOf$1=indexOf$2,_indexOfInstanceProperty$1=getDefaultExportFromCjs$1(indexOf$1),indexOf2=indexOf$1,_indexOfInstanceProperty=getDefaultExportFromCjs$1(indexOf2),$$1l=_export,$find=arrayIteration.find,FIND="find",SKIPS_HOLES=!0;FIND in[]&&Array(1)[FIND]((function(){SKIPS_HOLES=!1})),$$1l({target:"Array",proto:!0,forced:SKIPS_HOLES},{find:function(e){return $find(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$e=entryVirtual$n,find$7=entryVirtual$e("Array").find,isPrototypeOf$j=objectIsPrototypeOf,method$e=find$7,ArrayPrototype$c=Array.prototype,find$6=function(e){var t=e.find;return e===ArrayPrototype$c||isPrototypeOf$j(ArrayPrototype$c,e)&&t===ArrayPrototype$c.find?method$e:t},parent$1D=find$6,find$5=parent$1D,parent$1C=find$5,find$4=parent$1C,parent$1B=find$4,find$3=parent$1B,find$2=find$3,find$1=find$2,_findInstanceProperty=getDefaultExportFromCjs$1(find$1),$$1k=_export,isArray$8=isArray$d,isConstructor$1=isConstructor$4,isObject$9=isObject$m,toAbsoluteIndex$1=toAbsoluteIndex$4,lengthOfArrayLike$6=lengthOfArrayLike$c,toIndexedObject$1=toIndexedObject$c,createProperty$2=createProperty$6,wellKnownSymbol$a=wellKnownSymbol$r,arrayMethodHasSpeciesSupport$2=arrayMethodHasSpeciesSupport$5,nativeSlice=arraySlice$7,HAS_SPECIES_SUPPORT$2=arrayMethodHasSpeciesSupport$2("slice"),SPECIES$3=wellKnownSymbol$a("species"),$Array$1=Array,max$2=Math.max;$$1k({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$2},{slice:function(e,t){var r,n,a,i=toIndexedObject$1(this),s=lengthOfArrayLike$6(i),o=toAbsoluteIndex$1(e,s),l=toAbsoluteIndex$1(void 0===t?s:t,s);if(isArray$8(i)&&(r=i.constructor,(isConstructor$1(r)&&(r===$Array$1||isArray$8(r.prototype))||isObject$9(r)&&null===(r=r[SPECIES$3]))&&(r=void 0),r===$Array$1||void 0===r))return nativeSlice(i,o,l);for(n=new(void 0===r?$Array$1:r)(max$2(l-o,0)),a=0;o<l;o++,a++)o in i&&createProperty$2(n,a,i[o]);return n.length=a,n}});var entryVirtual$d=entryVirtual$n,slice$6=entryVirtual$d("Array").slice,isPrototypeOf$i=objectIsPrototypeOf,method$d=slice$6,ArrayPrototype$b=Array.prototype,slice$5=function(e){var t=e.slice;return e===ArrayPrototype$b||isPrototypeOf$i(ArrayPrototype$b,e)&&t===ArrayPrototype$b.slice?method$d:t},parent$1A=slice$5,slice$4=parent$1A,parent$1z=slice$4,slice$3=parent$1z,parent$1y=slice$3,slice$2=parent$1y,slice$1=slice$2,_sliceInstanceProperty$1=getDefaultExportFromCjs$1(slice$1),slice2=slice$1,_sliceInstanceProperty=getDefaultExportFromCjs$1(slice2),tryToString$4=tryToString$8,$TypeError$a=TypeError,deletePropertyOrThrow$2=function(e,t){if(!delete e[t])throw $TypeError$a("Cannot delete property "+tryToString$4(t)+" of "+tryToString$4(e))},$$1j=_export,toObject$4=toObject$d,toAbsoluteIndex=toAbsoluteIndex$4,toIntegerOrInfinity$3=toIntegerOrInfinity$7,lengthOfArrayLike$5=lengthOfArrayLike$c,setArrayLength=arraySetLength,doesNotExceedSafeInteger=doesNotExceedSafeInteger$3,arraySpeciesCreate=arraySpeciesCreate$3,createProperty$1=createProperty$6,deletePropertyOrThrow$1=deletePropertyOrThrow$2,arrayMethodHasSpeciesSupport$1=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$1=arrayMethodHasSpeciesSupport$1("splice"),max$1=Math.max,min$2=Math.min;$$1j({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$1},{splice:function(e,t){var r,n,a,i,s,o,l=toObject$4(this),c=lengthOfArrayLike$5(l),u=toAbsoluteIndex(e,c),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=c-u):(r=d-2,n=min$2(max$1(toIntegerOrInfinity$3(t),0),c-u)),doesNotExceedSafeInteger(c+r-n),a=arraySpeciesCreate(l,n),i=0;i<n;i++)(s=u+i)in l&&createProperty$1(a,i,l[s]);if(a.length=n,r<n){for(i=u;i<c-n;i++)o=i+r,(s=i+n)in l?l[o]=l[s]:deletePropertyOrThrow$1(l,o);for(i=c;i>c-n+r;i--)deletePropertyOrThrow$1(l,i-1)}else if(r>n)for(i=c-n;i>u;i--)o=i+r-1,(s=i+n-1)in l?l[o]=l[s]:deletePropertyOrThrow$1(l,o);for(i=0;i<r;i++)l[i+u]=arguments[i+2];return setArrayLength(l,c-n+r),a}});var entryVirtual$c=entryVirtual$n,splice$7=entryVirtual$c("Array").splice,isPrototypeOf$h=objectIsPrototypeOf,method$c=splice$7,ArrayPrototype$a=Array.prototype,splice$6=function(e){var t=e.splice;return e===ArrayPrototype$a||isPrototypeOf$h(ArrayPrototype$a,e)&&t===ArrayPrototype$a.splice?method$c:t},parent$1x=splice$6,splice$5=parent$1x,parent$1w=splice$5,splice$4=parent$1w,parent$1v=splice$4,splice$3=parent$1v,splice$2=splice$3,splice$1=splice$2,_spliceInstanceProperty=getDefaultExportFromCjs$1(splice$1),hasOwn$8=hasOwnProperty_1,ownKeys$2=ownKeys$5,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,definePropertyModule=objectDefineProperty,copyConstructorProperties$1=function(e,t,r){for(var n=ownKeys$2(t),a=definePropertyModule.f,i=getOwnPropertyDescriptorModule.f,s=0;s<n.length;s++){var o=n[s];hasOwn$8(e,o)||r&&hasOwn$8(r,o)||a(e,o,i(t,o))}},isObject$8=isObject$m,createNonEnumerableProperty$3=createNonEnumerableProperty$9,installErrorCause$1=function(e,t){isObject$8(t)&&"cause"in t&&createNonEnumerableProperty$3(e,"cause",t.cause)},uncurryThis$f=functionUncurryThis,$Error$1=Error,replace$4=uncurryThis$f("".replace),TEST=String($Error$1("zxcasd").stack),V8_OR_CHAKRA_STACK_ENTRY=/\n\s*at [^:]*:[^\n]*/,IS_V8_OR_CHAKRA_STACK=V8_OR_CHAKRA_STACK_ENTRY.test(TEST),errorStackClear=function(e,t){if(IS_V8_OR_CHAKRA_STACK&&"string"==typeof e&&!$Error$1.prepareStackTrace)for(;t--;)e=replace$4(e,V8_OR_CHAKRA_STACK_ENTRY,"");return e},fails$d=fails$A,createPropertyDescriptor$2=createPropertyDescriptor$8,errorStackInstallable=!fails$d((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",createPropertyDescriptor$2(1,7)),7!==e.stack)})),createNonEnumerableProperty$2=createNonEnumerableProperty$9,clearErrorStack=errorStackClear,ERROR_STACK_INSTALLABLE=errorStackInstallable,captureStackTrace=Error.captureStackTrace,errorStackInstall=function(e,t,r,n){ERROR_STACK_INSTALLABLE&&(captureStackTrace?captureStackTrace(e,t):createNonEnumerableProperty$2(e,"stack",clearErrorStack(r,n)))},wellKnownSymbol$9=wellKnownSymbol$r,Iterators$2=iterators,ITERATOR$7=wellKnownSymbol$9("iterator"),ArrayPrototype$9=Array.prototype,isArrayIteratorMethod$2=function(e){return void 0!==e&&(Iterators$2.Array===e||ArrayPrototype$9[ITERATOR$7]===e)},classof$6=classof$f,getMethod$1=getMethod$3,isNullOrUndefined$4=isNullOrUndefined$7,Iterators$1=iterators,wellKnownSymbol$8=wellKnownSymbol$r,ITERATOR$6=wellKnownSymbol$8("iterator"),getIteratorMethod$a=function(e){if(!isNullOrUndefined$4(e))return getMethod$1(e,ITERATOR$6)||getMethod$1(e,"@@iterator")||Iterators$1[classof$6(e)]},call$p=functionCall,aCallable$g=aCallable$l,anObject$9=anObject$i,tryToString$3=tryToString$8,getIteratorMethod$9=getIteratorMethod$a,$TypeError$9=TypeError,getIterator$3=function(e,t){var r=arguments.length<2?getIteratorMethod$9(e):t;if(aCallable$g(r))return anObject$9(call$p(r,e));throw $TypeError$9(tryToString$3(e)+" is not iterable")},call$o=functionCall,anObject$8=anObject$i,getMethod=getMethod$3,iteratorClose$4=function(e,t,r){var n,a;anObject$8(e);try{if(!(n=getMethod(e,"return"))){if("throw"===t)throw r;return r}n=call$o(n,e)}catch(e){a=!0,n=e}if("throw"===t)throw r;if(a)throw n;return anObject$8(n),r},bind$l=functionBindContext,call$n=functionCall,anObject$7=anObject$i,tryToString$2=tryToString$8,isArrayIteratorMethod$1=isArrayIteratorMethod$2,lengthOfArrayLike$4=lengthOfArrayLike$c,isPrototypeOf$g=objectIsPrototypeOf,getIterator$2=getIterator$3,getIteratorMethod$8=getIteratorMethod$a,iteratorClose$3=iteratorClose$4,$TypeError$8=TypeError,Result=function(e,t){this.stopped=e,this.result=t},ResultPrototype=Result.prototype,iterate$u=function(e,t,r){var n,a,i,s,o,l,c,u=r&&r.that,d=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_RECORD),h=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),y=bind$l(t,u),g=function(e){return n&&iteratorClose$3(n,"normal",e),new Result(!0,e)},v=function(e){return d?(anObject$7(e),p?y(e[0],e[1],g):y(e[0],e[1])):p?y(e,g):y(e)};if(f)n=e.iterator;else if(h)n=e;else{if(!(a=getIteratorMethod$8(e)))throw $TypeError$8(tryToString$2(e)+" is not iterable");if(isArrayIteratorMethod$1(a)){for(i=0,s=lengthOfArrayLike$4(e);s>i;i++)if((o=v(e[i]))&&isPrototypeOf$g(ResultPrototype,o))return o;return new Result(!1)}n=getIterator$2(e,a)}for(l=f?e.next:n.next;!(c=call$n(l,n)).done;){try{o=v(c.value)}catch(e){iteratorClose$3(n,"throw",e)}if("object"==typeof o&&o&&isPrototypeOf$g(ResultPrototype,o))return o}return new Result(!1)},toString$9=toString$g,normalizeStringArgument$1=function(e,t){return void 0===e?arguments.length<2?"":t:toString$9(e)},$$1i=_export,isPrototypeOf$f=objectIsPrototypeOf,getPrototypeOf2=objectGetPrototypeOf,setPrototypeOf=objectSetPrototypeOf,copyConstructorProperties=copyConstructorProperties$1,create$3=objectCreate,createNonEnumerableProperty$1=createNonEnumerableProperty$9,createPropertyDescriptor$1=createPropertyDescriptor$8,installErrorCause=installErrorCause$1,installErrorStack=errorStackInstall,iterate$t=iterate$u,normalizeStringArgument=normalizeStringArgument$1,wellKnownSymbol$7=wellKnownSymbol$r,TO_STRING_TAG=wellKnownSymbol$7("toStringTag"),$Error=Error,push$8=[].push,$AggregateError=function(e,t){var r,n=isPrototypeOf$f(AggregateErrorPrototype,this);setPrototypeOf?r=setPrototypeOf($Error(),n?getPrototypeOf2(this):AggregateErrorPrototype):(r=n?this:create$3(AggregateErrorPrototype),createNonEnumerableProperty$1(r,TO_STRING_TAG,"Error")),void 0!==t&&createNonEnumerableProperty$1(r,"message",normalizeStringArgument(t)),installErrorStack(r,$AggregateError,r.stack,1),arguments.length>2&&installErrorCause(r,arguments[2]);var a=[];return iterate$t(e,push$8,{that:a}),createNonEnumerableProperty$1(r,"errors",a),r};setPrototypeOf?setPrototypeOf($AggregateError,$Error):copyConstructorProperties($AggregateError,$Error,{name:!0});var AggregateErrorPrototype=$AggregateError.prototype=create$3($Error.prototype,{constructor:createPropertyDescriptor$1(1,$AggregateError),message:createPropertyDescriptor$1(1,""),name:createPropertyDescriptor$1(1,"AggregateError")});$$1i({global:!0,constructor:!0,arity:2},{AggregateError:$AggregateError});var $location,defer,channel,port,classof$5=classofRaw$2,engineIsNode="undefined"!=typeof process&&"process"==classof$5(process),getBuiltIn$7=getBuiltIn$j,defineBuiltInAccessor$3=defineBuiltInAccessor$5,wellKnownSymbol$6=wellKnownSymbol$r,DESCRIPTORS$6=descriptors,SPECIES$2=wellKnownSymbol$6("species"),setSpecies$2=function(e){var t=getBuiltIn$7(e);DESCRIPTORS$6&&t&&!t[SPECIES$2]&&defineBuiltInAccessor$3(t,SPECIES$2,{configurable:!0,get:function(){return this}})},isPrototypeOf$e=objectIsPrototypeOf,$TypeError$7=TypeError,anInstance$5=function(e,t){if(isPrototypeOf$e(t,e))return e;throw $TypeError$7("Incorrect invocation")},anObject$6=anObject$i,aConstructor$1=aConstructor$3,isNullOrUndefined$3=isNullOrUndefined$7,wellKnownSymbol$5=wellKnownSymbol$r,SPECIES$1=wellKnownSymbol$5("species"),speciesConstructor$2=function(e,t){var r,n=anObject$6(e).constructor;return void 0===n||isNullOrUndefined$3(r=anObject$6(n)[SPECIES$1])?t:aConstructor$1(r)},userAgent$5=engineUserAgent,engineIsIos=/(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$5),global$b=global$s,apply$2=functionApply,bind$k=functionBindContext,isCallable$9=isCallable$r,hasOwn$7=hasOwnProperty_1,fails$c=fails$A,html=html$2,arraySlice$3=arraySlice$7,createElement=documentCreateElement$1,validateArgumentsLength$3=validateArgumentsLength$5,IS_IOS$1=engineIsIos,IS_NODE$4=engineIsNode,set$c=global$b.setImmediate,clear=global$b.clearImmediate,process$3=global$b.process,Dispatch=global$b.Dispatch,Function$1=global$b.Function,MessageChannel=global$b.MessageChannel,String$1=global$b.String,counter=0,queue$2={},ONREADYSTATECHANGE="onreadystatechange";fails$c((function(){$location=global$b.location}));var run=function(e){if(hasOwn$7(queue$2,e)){var t=queue$2[e];delete queue$2[e],t()}},runner=function(e){return function(){run(e)}},eventListener=function(e){run(e.data)},globalPostMessageDefer=function(e){global$b.postMessage(String$1(e),$location.protocol+"//"+$location.host)};set$c&&clear||(set$c=function(e){validateArgumentsLength$3(arguments.length,1);var t=isCallable$9(e)?e:Function$1(e),r=arraySlice$3(arguments,1);return queue$2[++counter]=function(){apply$2(t,void 0,r)},defer(counter),counter},clear=function(e){delete queue$2[e]},IS_NODE$4?defer=function(e){process$3.nextTick(runner(e))}:Dispatch&&Dispatch.now?defer=function(e){Dispatch.now(runner(e))}:MessageChannel&&!IS_IOS$1?(port=(channel=new MessageChannel).port2,channel.port1.onmessage=eventListener,defer=bind$k(port.postMessage,port)):global$b.addEventListener&&isCallable$9(global$b.postMessage)&&!global$b.importScripts&&$location&&"file:"!==$location.protocol&&!fails$c(globalPostMessageDefer)?(defer=globalPostMessageDefer,global$b.addEventListener("message",eventListener,!1)):defer=ONREADYSTATECHANGE in createElement("script")?function(e){html.appendChild(createElement("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this),run(e)}}:function(e){setTimeout(runner(e),0)});var task$1={set:set$c,clear:clear},Queue$2=function(){this.head=null,this.tail=null};Queue$2.prototype={add:function(e){var t={item:e,next:null},r=this.tail;r?r.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var notify$1,toggle,node,promise$6,then,queue$1=Queue$2,userAgent$4=engineUserAgent,engineIsIosPebble=/ipad|iphone|ipod/i.test(userAgent$4)&&"undefined"!=typeof Pebble,userAgent$3=engineUserAgent,engineIsWebosWebkit=/web0s(?!.*chrome)/i.test(userAgent$3),global$a=global$s,bind$j=functionBindContext,getOwnPropertyDescriptor$2=objectGetOwnPropertyDescriptor.f,macrotask=task$1.set,Queue$1=queue$1,IS_IOS=engineIsIos,IS_IOS_PEBBLE=engineIsIosPebble,IS_WEBOS_WEBKIT=engineIsWebosWebkit,IS_NODE$3=engineIsNode,MutationObserver=global$a.MutationObserver||global$a.WebKitMutationObserver,document$2=global$a.document,process$2=global$a.process,Promise$1=global$a.Promise,queueMicrotaskDescriptor=getOwnPropertyDescriptor$2(global$a,"queueMicrotask"),microtask$1=queueMicrotaskDescriptor&&queueMicrotaskDescriptor.value;if(!microtask$1){var queue=new Queue$1,flush=function(){var e,t;for(IS_NODE$3&&(e=process$2.domain)&&e.exit();t=queue.get();)try{t()}catch(e){throw queue.head&¬ify$1(),e}e&&e.enter()};IS_IOS||IS_NODE$3||IS_WEBOS_WEBKIT||!MutationObserver||!document$2?!IS_IOS_PEBBLE&&Promise$1&&Promise$1.resolve?((promise$6=Promise$1.resolve(void 0)).constructor=Promise$1,then=bind$j(promise$6.then,promise$6),notify$1=function(){then(flush)}):IS_NODE$3?notify$1=function(){process$2.nextTick(flush)}:(macrotask=bind$j(macrotask,global$a),notify$1=function(){macrotask(flush)}):(toggle=!0,node=document$2.createTextNode(""),new MutationObserver(flush).observe(node,{characterData:!0}),notify$1=function(){node.data=toggle=!toggle}),microtask$1=function(e){queue.head||notify$1(),queue.add(e)}}var microtask_1=microtask$1,hostReportErrors$1=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}},perform$6=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},global$9=global$s,promiseNativeConstructor=global$9.Promise,engineIsDeno="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,IS_DENO$1=engineIsDeno,IS_NODE$2=engineIsNode,engineIsBrowser=!IS_DENO$1&&!IS_NODE$2&&"object"==typeof window&&"object"==typeof document,global$8=global$s,NativePromiseConstructor$5=promiseNativeConstructor,isCallable$8=isCallable$r,isForced=isForced_1,inspectSource=inspectSource$2,wellKnownSymbol$4=wellKnownSymbol$r,IS_BROWSER=engineIsBrowser,IS_DENO=engineIsDeno,V8_VERSION=engineV8Version,NativePromisePrototype$2=NativePromiseConstructor$5&&NativePromiseConstructor$5.prototype,SPECIES=wellKnownSymbol$4("species"),SUBCLASSING=!1,NATIVE_PROMISE_REJECTION_EVENT$1=isCallable$8(global$8.PromiseRejectionEvent),FORCED_PROMISE_CONSTRUCTOR$5=isForced("Promise",(function(){var e=inspectSource(NativePromiseConstructor$5),t=e!==String(NativePromiseConstructor$5);if(!t&&66===V8_VERSION)return!0;if(!NativePromisePrototype$2.catch||!NativePromisePrototype$2.finally)return!0;if(!V8_VERSION||V8_VERSION<51||!/native code/.test(e)){var r=new NativePromiseConstructor$5((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[SPECIES]=n,!(SUBCLASSING=r.then((function(){}))instanceof n))return!0}return!t&&(IS_BROWSER||IS_DENO)&&!NATIVE_PROMISE_REJECTION_EVENT$1})),promiseConstructorDetection={CONSTRUCTOR:FORCED_PROMISE_CONSTRUCTOR$5,REJECTION_EVENT:NATIVE_PROMISE_REJECTION_EVENT$1,SUBCLASSING:SUBCLASSING},newPromiseCapability$2={},aCallable$f=aCallable$l,$TypeError$6=TypeError,PromiseCapability=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw $TypeError$6("Bad Promise constructor");t=e,r=n})),this.resolve=aCallable$f(t),this.reject=aCallable$f(r)};newPromiseCapability$2.f=function(e){return new PromiseCapability(e)};var $$1h=_export,IS_NODE$1=engineIsNode,global$7=global$s,call$m=functionCall,defineBuiltIn$3=defineBuiltIn$8,setToStringTag$3=setToStringTag$9,setSpecies$1=setSpecies$2,aCallable$e=aCallable$l,isCallable$7=isCallable$r,isObject$7=isObject$m,anInstance$4=anInstance$5,speciesConstructor$1=speciesConstructor$2,task=task$1.set,microtask=microtask_1,hostReportErrors=hostReportErrors$1,perform$5=perform$6,Queue=queue$1,InternalStateModule$4=internalState,NativePromiseConstructor$4=promiseNativeConstructor,PromiseConstructorDetection=promiseConstructorDetection,newPromiseCapabilityModule$6=newPromiseCapability$2,PROMISE="Promise",FORCED_PROMISE_CONSTRUCTOR$4=PromiseConstructorDetection.CONSTRUCTOR,NATIVE_PROMISE_REJECTION_EVENT=PromiseConstructorDetection.REJECTION_EVENT;PromiseConstructorDetection.SUBCLASSING;var Internal,OwnPromiseCapability,PromiseWrapper,getInternalPromiseState=InternalStateModule$4.getterFor(PROMISE),setInternalState$4=InternalStateModule$4.set,NativePromisePrototype$1=NativePromiseConstructor$4&&NativePromiseConstructor$4.prototype,PromiseConstructor=NativePromiseConstructor$4,PromisePrototype=NativePromisePrototype$1,TypeError$3=global$7.TypeError,document$1=global$7.document,process$1=global$7.process,newPromiseCapability$1=newPromiseCapabilityModule$6.f,newGenericPromiseCapability=newPromiseCapability$1,DISPATCH_EVENT=!!(document$1&&document$1.createEvent&&global$7.dispatchEvent),UNHANDLED_REJECTION="unhandledrejection",REJECTION_HANDLED="rejectionhandled",PENDING=0,FULFILLED=1,REJECTED=2,HANDLED=1,UNHANDLED=2,isThenable=function(e){var t;return!(!isObject$7(e)||!isCallable$7(t=e.then))&&t},callReaction=function(e,t){var r,n,a,i=t.value,s=t.state==FULFILLED,o=s?e.ok:e.fail,l=e.resolve,c=e.reject,u=e.domain;try{o?(s||(t.rejection===UNHANDLED&&onHandleUnhandled(t),t.rejection=HANDLED),!0===o?r=i:(u&&u.enter(),r=o(i),u&&(u.exit(),a=!0)),r===e.promise?c(TypeError$3("Promise-chain cycle")):(n=isThenable(r))?call$m(n,r,l,c):l(r)):c(i)}catch(e){u&&!a&&u.exit(),c(e)}},notify=function(e,t){e.notified||(e.notified=!0,microtask((function(){for(var r,n=e.reactions;r=n.get();)callReaction(r,e);e.notified=!1,t&&!e.rejection&&onUnhandled(e)})))},dispatchEvent=function(e,t,r){var n,a;DISPATCH_EVENT?((n=document$1.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),global$7.dispatchEvent(n)):n={promise:t,reason:r},!NATIVE_PROMISE_REJECTION_EVENT&&(a=global$7["on"+e])?a(n):e===UNHANDLED_REJECTION&&hostReportErrors("Unhandled promise rejection",r)},onUnhandled=function(e){call$m(task,global$7,(function(){var t,r=e.facade,n=e.value;if(isUnhandled(e)&&(t=perform$5((function(){IS_NODE$1?process$1.emit("unhandledRejection",n,r):dispatchEvent(UNHANDLED_REJECTION,r,n)})),e.rejection=IS_NODE$1||isUnhandled(e)?UNHANDLED:HANDLED,t.error))throw t.value}))},isUnhandled=function(e){return e.rejection!==HANDLED&&!e.parent},onHandleUnhandled=function(e){call$m(task,global$7,(function(){var t=e.facade;IS_NODE$1?process$1.emit("rejectionHandled",t):dispatchEvent(REJECTION_HANDLED,t,e.value)}))},bind$i=function(e,t,r){return function(n){e(t,n,r)}},internalReject=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=REJECTED,notify(e,!0))},internalResolve=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw TypeError$3("Promise can't be resolved itself");var n=isThenable(t);n?microtask((function(){var r={done:!1};try{call$m(n,t,bind$i(internalResolve,r,e),bind$i(internalReject,r,e))}catch(t){internalReject(r,t,e)}})):(e.value=t,e.state=FULFILLED,notify(e,!1))}catch(t){internalReject({done:!1},t,e)}}};FORCED_PROMISE_CONSTRUCTOR$4&&(PromisePrototype=(PromiseConstructor=function(e){anInstance$4(this,PromisePrototype),aCallable$e(e),call$m(Internal,this);var t=getInternalPromiseState(this);try{e(bind$i(internalResolve,t),bind$i(internalReject,t))}catch(e){internalReject(t,e)}}).prototype,(Internal=function(e){setInternalState$4(this,{type:PROMISE,done:!1,notified:!1,parent:!1,reactions:new Queue,rejection:!1,state:PENDING,value:void 0})}).prototype=defineBuiltIn$3(PromisePrototype,"then",(function(e,t){var r=getInternalPromiseState(this),n=newPromiseCapability$1(speciesConstructor$1(this,PromiseConstructor));return r.parent=!0,n.ok=!isCallable$7(e)||e,n.fail=isCallable$7(t)&&t,n.domain=IS_NODE$1?process$1.domain:void 0,r.state==PENDING?r.reactions.add(n):microtask((function(){callReaction(n,r)})),n.promise})),OwnPromiseCapability=function(){var e=new Internal,t=getInternalPromiseState(e);this.promise=e,this.resolve=bind$i(internalResolve,t),this.reject=bind$i(internalReject,t)},newPromiseCapabilityModule$6.f=newPromiseCapability$1=function(e){return e===PromiseConstructor||e===PromiseWrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)}),$$1h({global:!0,constructor:!0,wrap:!0,forced:FORCED_PROMISE_CONSTRUCTOR$4},{Promise:PromiseConstructor}),setToStringTag$3(PromiseConstructor,PROMISE,!1,!0),setSpecies$1(PROMISE);var wellKnownSymbol$3=wellKnownSymbol$r,ITERATOR$5=wellKnownSymbol$3("iterator"),SAFE_CLOSING=!1;try{var called=0,iteratorWithReturn={next:function(){return{done:!!called++}},return:function(){SAFE_CLOSING=!0}};iteratorWithReturn[ITERATOR$5]=function(){return this},Array.from(iteratorWithReturn,(function(){throw 2}))}catch(e){}var checkCorrectnessOfIteration$2=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var n={};n[ITERATOR$5]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},NativePromiseConstructor$3=promiseNativeConstructor,checkCorrectnessOfIteration$1=checkCorrectnessOfIteration$2,FORCED_PROMISE_CONSTRUCTOR$3=promiseConstructorDetection.CONSTRUCTOR,promiseStaticsIncorrectIteration=FORCED_PROMISE_CONSTRUCTOR$3||!checkCorrectnessOfIteration$1((function(e){NativePromiseConstructor$3.all(e).then(void 0,(function(){}))})),$$1g=_export,call$l=functionCall,aCallable$d=aCallable$l,newPromiseCapabilityModule$5=newPromiseCapability$2,perform$4=perform$6,iterate$s=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION$3=promiseStaticsIncorrectIteration;$$1g({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$3},{all:function(e){var t=this,r=newPromiseCapabilityModule$5.f(t),n=r.resolve,a=r.reject,i=perform$4((function(){var r=aCallable$d(t.resolve),i=[],s=0,o=1;iterate$s(e,(function(e){var l=s++,c=!1;o++,call$l(r,t,e).then((function(e){c||(c=!0,i[l]=e,--o||n(i))}),a)})),--o||n(i)}));return i.error&&a(i.value),r.promise}});var $$1f=_export,FORCED_PROMISE_CONSTRUCTOR$2=promiseConstructorDetection.CONSTRUCTOR,NativePromiseConstructor$2=promiseNativeConstructor;promiseNativeConstructor&&promiseNativeConstructor.prototype,$$1f({target:"Promise",proto:!0,forced:FORCED_PROMISE_CONSTRUCTOR$2,real:!0},{catch:function(e){return this.then(void 0,e)}});var $$1e=_export,call$k=functionCall,aCallable$c=aCallable$l,newPromiseCapabilityModule$4=newPromiseCapability$2,perform$3=perform$6,iterate$r=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION$2=promiseStaticsIncorrectIteration;$$1e({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$2},{race:function(e){var t=this,r=newPromiseCapabilityModule$4.f(t),n=r.reject,a=perform$3((function(){var a=aCallable$c(t.resolve);iterate$r(e,(function(e){call$k(a,t,e).then(r.resolve,n)}))}));return a.error&&n(a.value),r.promise}});var $$1d=_export,call$j=functionCall,newPromiseCapabilityModule$3=newPromiseCapability$2,FORCED_PROMISE_CONSTRUCTOR$1=promiseConstructorDetection.CONSTRUCTOR;$$1d({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR$1},{reject:function(e){var t=newPromiseCapabilityModule$3.f(this);return call$j(t.reject,void 0,e),t.promise}});var anObject$5=anObject$i,isObject$6=isObject$m,newPromiseCapability=newPromiseCapability$2,promiseResolve$2=function(e,t){if(anObject$5(e),isObject$6(t)&&t.constructor===e)return t;var r=newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},$$1c=_export,getBuiltIn$6=getBuiltIn$j,IS_PURE$1=isPure,NativePromiseConstructor$1=promiseNativeConstructor,FORCED_PROMISE_CONSTRUCTOR=promiseConstructorDetection.CONSTRUCTOR,promiseResolve$1=promiseResolve$2,PromiseConstructorWrapper=getBuiltIn$6("Promise"),CHECK_WRAPPER=!FORCED_PROMISE_CONSTRUCTOR;$$1c({target:"Promise",stat:!0,forced:IS_PURE$1},{resolve:function(e){return promiseResolve$1(CHECK_WRAPPER&&this===PromiseConstructorWrapper?NativePromiseConstructor$1:this,e)}});var $$1b=_export,call$i=functionCall,aCallable$b=aCallable$l,newPromiseCapabilityModule$2=newPromiseCapability$2,perform$2=perform$6,iterate$q=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION$1=promiseStaticsIncorrectIteration;$$1b({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$1},{allSettled:function(e){var t=this,r=newPromiseCapabilityModule$2.f(t),n=r.resolve,a=r.reject,i=perform$2((function(){var r=aCallable$b(t.resolve),a=[],i=0,s=1;iterate$q(e,(function(e){var o=i++,l=!1;s++,call$i(r,t,e).then((function(e){l||(l=!0,a[o]={status:"fulfilled",value:e},--s||n(a))}),(function(e){l||(l=!0,a[o]={status:"rejected",reason:e},--s||n(a))}))})),--s||n(a)}));return i.error&&a(i.value),r.promise}});var $$1a=_export,call$h=functionCall,aCallable$a=aCallable$l,getBuiltIn$5=getBuiltIn$j,newPromiseCapabilityModule$1=newPromiseCapability$2,perform$1=perform$6,iterate$p=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION=promiseStaticsIncorrectIteration,PROMISE_ANY_ERROR="No one promise resolved";$$1a({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION},{any:function(e){var t=this,r=getBuiltIn$5("AggregateError"),n=newPromiseCapabilityModule$1.f(t),a=n.resolve,i=n.reject,s=perform$1((function(){var n=aCallable$a(t.resolve),s=[],o=0,l=1,c=!1;iterate$p(e,(function(e){var u=o++,d=!1;l++,call$h(n,t,e).then((function(e){d||c||(c=!0,a(e))}),(function(e){d||c||(d=!0,s[u]=e,--l||i(new r(s,PROMISE_ANY_ERROR)))}))})),--l||i(new r(s,PROMISE_ANY_ERROR))}));return s.error&&i(s.value),n.promise}});var $$19=_export,NativePromiseConstructor=promiseNativeConstructor,fails$b=fails$A,getBuiltIn$4=getBuiltIn$j,isCallable$6=isCallable$r,speciesConstructor=speciesConstructor$2,promiseResolve=promiseResolve$2,NativePromisePrototype=NativePromiseConstructor&&NativePromiseConstructor.prototype,NON_GENERIC=!!NativePromiseConstructor&&fails$b((function(){NativePromisePrototype.finally.call({then:function(){}},(function(){}))}));$$19({target:"Promise",proto:!0,real:!0,forced:NON_GENERIC},{finally:function(e){var t=speciesConstructor(this,getBuiltIn$4("Promise")),r=isCallable$6(e);return this.then(r?function(r){return promiseResolve(t,e()).then((function(){return r}))}:e,r?function(r){return promiseResolve(t,e()).then((function(){throw r}))}:e)}});var path$f=path$y,promise$5=path$f.Promise,parent$1u=promise$5,promise$4=parent$1u,parent$1t=promise$4,promise$3=parent$1t,$$18=_export,newPromiseCapabilityModule=newPromiseCapability$2,perform=perform$6;$$18({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=newPromiseCapabilityModule.f(this),r=perform(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var parent$1s=promise$3,promise$2=parent$1s,promise$1=promise$2,promise=promise$1,_Promise=getDefaultExportFromCjs$1(promise),whitespaces$4="\t\n\v\f\r \u2028\u2029\ufeff",uncurryThis$e=functionUncurryThis,requireObjectCoercible$3=requireObjectCoercible$8,toString$8=toString$g,whitespaces$3=whitespaces$4,replace$3=uncurryThis$e("".replace),ltrim=RegExp("^["+whitespaces$3+"]+"),rtrim=RegExp("(^|[^"+whitespaces$3+"])["+whitespaces$3+"]+$"),createMethod$2=function(e){return function(t){var r=toString$8(requireObjectCoercible$3(t));return 1&e&&(r=replace$3(r,ltrim,"")),2&e&&(r=replace$3(r,rtrim,"$1")),r}},stringTrim={start:createMethod$2(1),end:createMethod$2(2),trim:createMethod$2(3)},global$6=global$s,fails$a=fails$A,uncurryThis$d=functionUncurryThis,toString$7=toString$g,trim$8=stringTrim.trim,whitespaces$2=whitespaces$4,$parseInt$1=global$6.parseInt,Symbol$2=global$6.Symbol,ITERATOR$4=Symbol$2&&Symbol$2.iterator,hex=/^[+-]?0x/i,exec$2=uncurryThis$d(hex.exec),FORCED$4=8!==$parseInt$1(whitespaces$2+"08")||22!==$parseInt$1(whitespaces$2+"0x16")||ITERATOR$4&&!fails$a((function(){$parseInt$1(Object(ITERATOR$4))})),numberParseInt=FORCED$4?function(e,t){var r=trim$8(toString$7(e));return $parseInt$1(r,t>>>0||(exec$2(hex,r)?16:10))}:$parseInt$1,$$17=_export,$parseInt=numberParseInt;$$17({global:!0,forced:parseInt!=numberParseInt},{parseInt:numberParseInt});var path$e=path$y,_parseInt$6=path$e.parseInt,parent$1r=_parseInt$6,_parseInt$5=parent$1r,parent$1q=_parseInt$5,_parseInt$4=parent$1q,parent$1p=_parseInt$4,_parseInt$3=parent$1p,_parseInt$2=_parseInt$3,_parseInt=_parseInt$2,_parseInt$1=getDefaultExportFromCjs$1(_parseInt),$$16=_export,$map=arrayIteration.map,arrayMethodHasSpeciesSupport=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT=arrayMethodHasSpeciesSupport("map");$$16({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT},{map:function(e){return $map(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$b=entryVirtual$n,map$c=entryVirtual$b("Array").map,isPrototypeOf$d=objectIsPrototypeOf,method$b=map$c,ArrayPrototype$8=Array.prototype,map$b=function(e){var t=e.map;return e===ArrayPrototype$8||isPrototypeOf$d(ArrayPrototype$8,e)&&t===ArrayPrototype$8.map?method$b:t},parent$1o=map$b,map$a=parent$1o,parent$1n=map$a,map$9=parent$1n,parent$1m=map$9,map$8=parent$1m,map$7=map$8,map$6=map$7,_mapInstanceProperty=getDefaultExportFromCjs$1(map$6),$$15=_export,isArray$7=isArray$d;$$15({target:"Array",stat:!0},{isArray:isArray$7});var path$d=path$y,isArray$6=path$d.Array.isArray,parent$1l=isArray$6,isArray$5=parent$1l,parent$1k=isArray$5,isArray$4=parent$1k,parent$1j=isArray$4,isArray$3=parent$1j,isArray$2=isArray$3,_Array$isArray$1=getDefaultExportFromCjs$1(isArray$2),isArray$1=isArray$2,_Array$isArray=getDefaultExportFromCjs$1(isArray$1),filter2=filter$1,_filterInstanceProperty=getDefaultExportFromCjs$1(filter2),DESCRIPTORS$5=descriptors,uncurryThis$c=functionUncurryThis,call$g=functionCall,fails$9=fails$A,objectKeys=objectKeys$4,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,propertyIsEnumerableModule=objectPropertyIsEnumerable,toObject$3=toObject$d,IndexedObject$1=indexedObject,$assign=Object.assign,defineProperty$3=Object.defineProperty,concat2=uncurryThis$c([].concat),objectAssign=!$assign||fails$9((function(){if(DESCRIPTORS$5&&1!==$assign({b:1},$assign(defineProperty$3({},"a",{enumerable:!0,get:function(){defineProperty$3(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=$assign({},e)[r]||objectKeys($assign({},t)).join("")!=n}))?function(e,t){for(var r=toObject$3(e),n=arguments.length,a=1,i=getOwnPropertySymbolsModule.f,s=propertyIsEnumerableModule.f;n>a;)for(var o,l=IndexedObject$1(arguments[a++]),c=i?concat2(objectKeys(l),i(l)):objectKeys(l),u=c.length,d=0;u>d;)o=c[d++],DESCRIPTORS$5&&!call$g(s,l,o)||(r[o]=l[o]);return r}:$assign,$$14=_export,assign$7=objectAssign;$$14({target:"Object",stat:!0,arity:2,forced:Object.assign!==assign$7},{assign:assign$7});var path$c=path$y,assign$6=path$c.Object.assign,parent$1i=assign$6,assign$5=parent$1i,parent$1h=assign$5,assign$4=parent$1h,parent$1g=assign$4,assign$3=parent$1g,assign$2=assign$3,assign$1=assign$2,_Object$assign=getDefaultExportFromCjs$1(assign$1),getOwnPropertySymbols2=getOwnPropertySymbols$1,_Object$getOwnPropertySymbols=getDefaultExportFromCjs$1(getOwnPropertySymbols2),getOwnPropertyDescriptor$1=getOwnPropertyDescriptor$4,_Object$getOwnPropertyDescriptor=getDefaultExportFromCjs$1(getOwnPropertyDescriptor$1),getOwnPropertyDescriptors2=getOwnPropertyDescriptors$1,_Object$getOwnPropertyDescriptors=getDefaultExportFromCjs$1(getOwnPropertyDescriptors2),defineProperties4=defineProperties$1,_Object$defineProperties=getDefaultExportFromCjs$1(defineProperties4),defineProperty$2=defineProperty$7,_Object$defineProperty=getDefaultExportFromCjs$1(defineProperty$2),symbol=symbol$1,_Symbol=getDefaultExportFromCjs$1(symbol),iterator=iterator$1,_Symbol$iterator=getDefaultExportFromCjs$1(iterator),create$2=create$5,_Object$create=getDefaultExportFromCjs$1(create$2),bind$h=bind$n,_bindInstanceProperty=getDefaultExportFromCjs$1(bind$h),getIteratorMethod$7=getIteratorMethod$a,getIteratorMethod_1=getIteratorMethod$7,parent$1f=getIteratorMethod_1,getIteratorMethod$6=parent$1f,parent$1e=getIteratorMethod$6,getIteratorMethod$5=parent$1e,parent$1d=getIteratorMethod$5,getIteratorMethod$4=parent$1d,getIteratorMethod$3=getIteratorMethod$4,_getIteratorMethod$1=getDefaultExportFromCjs$1(getIteratorMethod$3),getIteratorMethod$2=getIteratorMethod$3,_getIteratorMethod=getDefaultExportFromCjs$1(getIteratorMethod$2),anObject$4=anObject$i,iteratorClose$2=iteratorClose$4,callWithSafeIterationClosing$1=function(e,t,r,n){try{return n?t(anObject$4(r)[0],r[1]):t(r)}catch(t){iteratorClose$2(e,"throw",t)}},bind$g=functionBindContext,call$f=functionCall,toObject$2=toObject$d,callWithSafeIterationClosing=callWithSafeIterationClosing$1,isArrayIteratorMethod=isArrayIteratorMethod$2,isConstructor3=isConstructor$4,lengthOfArrayLike$3=lengthOfArrayLike$c,createProperty=createProperty$6,getIterator$1=getIterator$3,getIteratorMethod$1=getIteratorMethod$a,$Array=Array,arrayFrom$1=function(e){var t=toObject$2(e),r=isConstructor3(this),n=arguments.length,a=n>1?arguments[1]:void 0,i=void 0!==a;i&&(a=bind$g(a,n>2?arguments[2]:void 0));var s,o,l,c,u,d,f=getIteratorMethod$1(t),h=0;if(!f||this===$Array&&isArrayIteratorMethod(f))for(s=lengthOfArrayLike$3(t),o=r?new this(s):$Array(s);s>h;h++)d=i?a(t[h],h):t[h],createProperty(o,h,d);else for(u=(c=getIterator$1(t,f)).next,o=r?new this:[];!(l=call$f(u,c)).done;h++)d=i?callWithSafeIterationClosing(c,a,[l.value,h],!0):l.value,createProperty(o,h,d);return o.length=h,o},$$13=_export,from$8=arrayFrom$1,checkCorrectnessOfIteration=checkCorrectnessOfIteration$2,INCORRECT_ITERATION=!checkCorrectnessOfIteration((function(e){Array.from(e)}));$$13({target:"Array",stat:!0,forced:INCORRECT_ITERATION},{from:from$8});var path$b=path$y,from$7=path$b.Array.from,parent$1c=from$7,from$6=parent$1c,parent$1b=from$6,from$5=parent$1b,parent$1a=from$5,from$4=parent$1a,from$3=from$4,_Array$from$1=getDefaultExportFromCjs$1(from$3),from$2=from$3,_Array$from=getDefaultExportFromCjs$1(from$2),toPrimitive=toPrimitive$1,_Symbol$toPrimitive=getDefaultExportFromCjs$1(toPrimitive);function ownKeys$1(e,t){var r=_Object$keys(e);if(_Object$getOwnPropertySymbols){var n=_Object$getOwnPropertySymbols(e);t&&(n=_filterInstanceProperty(n).call(n,(function(t){return _Object$getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2$1(e){for(var t=1;t<arguments.length;t++){var r,n,a=null!=arguments[t]?arguments[t]:{};t%2?_forEachInstanceProperty(r=ownKeys$1(Object(a),!0)).call(r,(function(t){_defineProperty$1(e,t,a[t])})):_Object$getOwnPropertyDescriptors?_Object$defineProperties(e,_Object$getOwnPropertyDescriptors(a)):_forEachInstanceProperty(n=ownKeys$1(Object(a))).call(n,(function(t){_Object$defineProperty(e,t,_Object$getOwnPropertyDescriptor(a,t))}))}return e}function _typeof(e){return(_typeof="function"==typeof _Symbol&&"symbol"==typeof _Symbol$iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof _Symbol&&e.constructor===_Symbol&&e!==_Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),_Object$defineProperty(e,_toPropertyKey$1(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),_Object$defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty$1(e,t,r){return(t=_toPropertyKey$1(t))in e?_Object$defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toConsumableArray$1(e){return _arrayWithoutHoles$1(e)||_iterableToArray$1(e)||_unsupportedIterableToArray$1(e)||_nonIterableSpread$1()}function _arrayWithoutHoles$1(e){if(_Array$isArray(e))return _arrayLikeToArray$1(e)}function _iterableToArray$1(e){if(void 0!==_Symbol&&null!=_getIteratorMethod(e)||null!=e["@@iterator"])return _Array$from(e)}function _unsupportedIterableToArray$1(e,t){var r;if(e){if("string"==typeof e)return _arrayLikeToArray$1(e,t);var n=_sliceInstanceProperty(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?_Array$from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray$1(e,t):void 0}}function _arrayLikeToArray$1(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _nonIterableSpread$1(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _toPrimitive$1(e,t){if("object"!==_typeof$1(e)||null===e)return e;var r=e[_Symbol$toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof$1(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey$1(e){var t=_toPrimitive$1(e,"string");return"symbol"===_typeof$1(t)?t:String(t)}var $$12=_export,$some=arrayIteration.some,arrayMethodIsStrict$4=arrayMethodIsStrict$7,STRICT_METHOD$3=arrayMethodIsStrict$4("some");$$12({target:"Array",proto:!0,forced:!STRICT_METHOD$3},{some:function(e){return $some(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$a=entryVirtual$n,some$6=entryVirtual$a("Array").some,isPrototypeOf$c=objectIsPrototypeOf,method$a=some$6,ArrayPrototype$7=Array.prototype,some$5=function(e){var t=e.some;return e===ArrayPrototype$7||isPrototypeOf$c(ArrayPrototype$7,e)&&t===ArrayPrototype$7.some?method$a:t},parent$19=some$5,some$4=parent$19,parent$18=some$4,some$3=parent$18,parent$17=some$3,some$2=parent$17,some$1=some$2,some2=some$1,_someInstanceProperty=getDefaultExportFromCjs$1(some2),toIntegerOrInfinity$2=toIntegerOrInfinity$7,toString$6=toString$g,requireObjectCoercible$2=requireObjectCoercible$8,$RangeError$1=RangeError,stringRepeat=function(e){var t=toString$6(requireObjectCoercible$2(this)),r="",n=toIntegerOrInfinity$2(e);if(n<0||n==1/0)throw $RangeError$1("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},uncurryThis$b=functionUncurryThis,toLength$1=toLength$3,toString$5=toString$g,$repeat=stringRepeat,requireObjectCoercible$1=requireObjectCoercible$8,repeat2=uncurryThis$b($repeat),stringSlice$3=uncurryThis$b("".slice),ceil=Math.ceil,createMethod$1=function(e){return function(t,r,n){var a,i,s=toString$5(requireObjectCoercible$1(t)),o=toLength$1(r),l=s.length,c=void 0===n?" ":toString$5(n);return o<=l||""==c?s:((i=repeat2(c,ceil((a=o-l)/c.length))).length>a&&(i=stringSlice$3(i,0,a)),e?s+i:i+s)}},stringPad={start:createMethod$1(!1),end:createMethod$1(!0)},userAgent$2=engineUserAgent,stringPadWebkitBug=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent$2),$$11=_export,$padStart=stringPad.start,WEBKIT_BUG=stringPadWebkitBug;$$11({target:"String",proto:!0,forced:WEBKIT_BUG},{padStart:function(e){return $padStart(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$9=entryVirtual$n,padStart$6=entryVirtual$9("String").padStart,isPrototypeOf$b=objectIsPrototypeOf,method$9=padStart$6,StringPrototype$2=String.prototype,padStart$5=function(e){var t=e.padStart;return"string"==typeof e||e===StringPrototype$2||isPrototypeOf$b(StringPrototype$2,e)&&t===StringPrototype$2.padStart?method$9:t},parent$16=padStart$5,padStart$4=parent$16,parent$15=padStart$4,padStart$3=parent$15,parent$14=padStart$3,padStart$2=parent$14,padStart$1=padStart$2,padStart2=padStart$1,_padStartInstanceProperty=getDefaultExportFromCjs$1(padStart2),path$a=path$y,setInterval$4=path$a.setInterval,parent$13=setInterval$4,setInterval$3=parent$13,parent$12=setInterval$3,setInterval$2=parent$12,setInterval$1=setInterval$2,setInterval=setInterval$1,_setInterval=getDefaultExportFromCjs$1(setInterval),$$10=_export,$every=arrayIteration.every,arrayMethodIsStrict$3=arrayMethodIsStrict$7,STRICT_METHOD$2=arrayMethodIsStrict$3("every");$$10({target:"Array",proto:!0,forced:!STRICT_METHOD$2},{every:function(e){return $every(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$8=entryVirtual$n,every$6=entryVirtual$8("Array").every,isPrototypeOf$a=objectIsPrototypeOf,method$8=every$6,ArrayPrototype$6=Array.prototype,every$5=function(e){var t=e.every;return e===ArrayPrototype$6||isPrototypeOf$a(ArrayPrototype$6,e)&&t===ArrayPrototype$6.every?method$8:t},parent$11=every$5,every$4=parent$11,parent$10=every$4,every$3=parent$10,parent$$=every$3,every$2=parent$$,every$1=every$2,every2=every$1,_everyInstanceProperty=getDefaultExportFromCjs$1(every2),global$5=global$s,fails$8=fails$A,uncurryThis$a=functionUncurryThis,toString$4=toString$g,trim$7=stringTrim.trim,whitespaces$1=whitespaces$4,charAt$2=uncurryThis$a("".charAt),$parseFloat$1=global$5.parseFloat,Symbol$1=global$5.Symbol,ITERATOR$3=Symbol$1&&Symbol$1.iterator,FORCED$3=1/$parseFloat$1(whitespaces$1+"-0")!=-1/0||ITERATOR$3&&!fails$8((function(){$parseFloat$1(Object(ITERATOR$3))})),numberParseFloat=FORCED$3?function(e){var t=trim$7(toString$4(e)),r=$parseFloat$1(t);return 0===r&&"-"==charAt$2(t,0)?-0:r}:$parseFloat$1,$$$=_export,$parseFloat=numberParseFloat;$$$({global:!0,forced:parseFloat!=numberParseFloat},{parseFloat:numberParseFloat});var path$9=path$y,_parseFloat$6=path$9.parseFloat,parent$_=_parseFloat$6,_parseFloat$5=parent$_,parent$Z=_parseFloat$5,_parseFloat$4=parent$Z,parent$Y=_parseFloat$4,_parseFloat$3=parent$Y,_parseFloat$2=_parseFloat$3,_parseFloat=_parseFloat$2,_parseFloat$1=getDefaultExportFromCjs$1(_parseFloat),PROPER_FUNCTION_NAME=functionName.PROPER,fails$7=fails$A,whitespaces=whitespaces$4,non="
",stringTrimForced=function(e){return fails$7((function(){return!!whitespaces[e]()||non[e]()!==non||PROPER_FUNCTION_NAME&&whitespaces[e].name!==e}))},$$_=_export,$trim=stringTrim.trim,forcedStringTrimMethod=stringTrimForced;$$_({target:"String",proto:!0,forced:forcedStringTrimMethod("trim")},{trim:function(){return $trim(this)}});var entryVirtual$7=entryVirtual$n,trim$6=entryVirtual$7("String").trim,isPrototypeOf$9=objectIsPrototypeOf,method$7=trim$6,StringPrototype$1=String.prototype,trim$5=function(e){var t=e.trim;return"string"==typeof e||e===StringPrototype$1||isPrototypeOf$9(StringPrototype$1,e)&&t===StringPrototype$1.trim?method$7:t},parent$X=trim$5,trim$4=parent$X,parent$W=trim$4,trim$3=parent$W,parent$V=trim$3,trim$2=parent$V,trim$1=trim$2,trim2=trim$1,_trimInstanceProperty=getDefaultExportFromCjs$1(trim2),arraySlice$2=arraySliceSimple,floor$3=Math.floor,mergeSort=function(e,t){var r=e.length,n=floor$3(r/2);return r<8?insertionSort(e,t):merge(e,mergeSort(arraySlice$2(e,0,n),t),mergeSort(arraySlice$2(e,n),t),t)},insertionSort=function(e,t){for(var r,n,a=e.length,i=1;i<a;){for(n=i,r=e[i];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==i++&&(e[n]=r)}return e},merge=function(e,t,r,n){for(var a=t.length,i=r.length,s=0,o=0;s<a||o<i;)e[s+o]=s<a&&o<i?n(t[s],r[o])<=0?t[s++]:r[o++]:s<a?t[s++]:r[o++];return e},arraySort$1=mergeSort,userAgent$1=engineUserAgent,firefox=userAgent$1.match(/firefox\/(\d+)/i),engineFfVersion=!!firefox&&+firefox[1],UA=engineUserAgent,engineIsIeOrEdge=/MSIE|Trident/.test(UA),userAgent=engineUserAgent,webkit=userAgent.match(/AppleWebKit\/(\d+)\./),engineWebkitVersion=!!webkit&&+webkit[1],$$Z=_export,uncurryThis$9=functionUncurryThis,aCallable$9=aCallable$l,toObject$1=toObject$d,lengthOfArrayLike$2=lengthOfArrayLike$c,deletePropertyOrThrow=deletePropertyOrThrow$2,toString$3=toString$g,fails$6=fails$A,internalSort=arraySort$1,arrayMethodIsStrict$2=arrayMethodIsStrict$7,FF=engineFfVersion,IE_OR_EDGE=engineIsIeOrEdge,V8=engineV8Version,WEBKIT=engineWebkitVersion,test$1=[],nativeSort=uncurryThis$9(test$1.sort),push$7=uncurryThis$9(test$1.push),FAILS_ON_UNDEFINED=fails$6((function(){test$1.sort(void 0)})),FAILS_ON_NULL=fails$6((function(){test$1.sort(null)})),STRICT_METHOD$1=arrayMethodIsStrict$2("sort"),STABLE_SORT=!fails$6((function(){if(V8)return V8<70;if(!(FF&&FF>3)){if(IE_OR_EDGE)return!0;if(WEBKIT)return WEBKIT<603;var e,t,r,n,a="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)test$1.push({k:t+n,v:r})}for(test$1.sort((function(e,t){return t.v-e.v})),n=0;n<test$1.length;n++)t=test$1[n].k.charAt(0),a.charAt(a.length-1)!==t&&(a+=t);return"DGBEFHACIJK"!==a}})),FORCED$2=FAILS_ON_UNDEFINED||!FAILS_ON_NULL||!STRICT_METHOD$1||!STABLE_SORT,getSortCompare=function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:toString$3(t)>toString$3(r)?1:-1}};$$Z({target:"Array",proto:!0,forced:FORCED$2},{sort:function(e){void 0!==e&&aCallable$9(e);var t=toObject$1(this);if(STABLE_SORT)return void 0===e?nativeSort(t):nativeSort(t,e);var r,n,a=[],i=lengthOfArrayLike$2(t);for(n=0;n<i;n++)n in t&&push$7(a,t[n]);for(internalSort(a,getSortCompare(e)),r=lengthOfArrayLike$2(a),n=0;n<r;)t[n]=a[n++];for(;n<i;)deletePropertyOrThrow(t,n++);return t}});var entryVirtual$6=entryVirtual$n,sort$6=entryVirtual$6("Array").sort,isPrototypeOf$8=objectIsPrototypeOf,method$6=sort$6,ArrayPrototype$5=Array.prototype,sort$5=function(e){var t=e.sort;return e===ArrayPrototype$5||isPrototypeOf$8(ArrayPrototype$5,e)&&t===ArrayPrototype$5.sort?method$6:t},parent$U=sort$5,sort$4=parent$U,parent$T=sort$4,sort$3=parent$T,parent$S=sort$3,sort$2=parent$S,sort$1=sort$2,sort2=sort$1,_sortInstanceProperty=getDefaultExportFromCjs$1(sort2),$$Y=_export,uncurryThis$8=functionUncurryThis,$Date=Date,thisTimeValue=uncurryThis$8($Date.prototype.getTime);$$Y({target:"Date",stat:!0},{now:function(){return thisTimeValue(new $Date)}});var _context,path$8=path$y,now$6=path$8.Date.now,parent$R=now$6,now$5=parent$R,parent$Q=now$5,now$4=parent$Q,parent$P=now$4,now$3=parent$P,now$2=now$3,now$1=now$2,_Date$now=getDefaultExportFromCjs$1(now$1),XG_DEBUG_OPEN="undefined"!=typeof window&&window.location&&_indexOfInstanceProperty(_context=window.location.href).call(_context,"xgplayerdebugger=1")>-1,STYLE={info:"color: #525252; background-color: #90ee90;",error:"color: #525252; background-color: red;",warn:"color: #525252; background-color: yellow; "},XGTAG="%c[xgplayer]",XG_DEBUG={config:{debug:XG_DEBUG_OPEN?3:0},logInfo:function(e){for(var t,r,n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];this.config.debug>=3&&(r=console).log.apply(r,_concatInstanceProperty(t=[XGTAG,STYLE.info,e]).call(t,a))},logWarn:function(e){for(var t,r,n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];this.config.debug>=1&&(r=console).warn.apply(r,_concatInstanceProperty(t=[XGTAG,STYLE.warn,e]).call(t,a))},logError:function(e){var t,r;if(!(this.config.debug<1)){for(var n=this.config.debug>=2?"trace":"error",a=arguments.length,i=new Array(a>1?a-1:0),s=1;s<a;s++)i[s-1]=arguments[s];(r=console)[n].apply(r,_concatInstanceProperty(t=[XGTAG,STYLE.error,e]).call(t,i))}}},XgplayerTimeRange=function(){function e(t){_classCallCheck(this,e),this.bufferedList=t}return _createClass(e,[{key:"start",value:function(e){return this.bufferedList[e].start}},{key:"end",value:function(e){return this.bufferedList[e].end}},{key:"length",get:function(){return this.bufferedList.length}}]),e}(),util={};function checkIsIn(e,t){for(var r=0,n=t.length;r<n;r++)if(_indexOfInstanceProperty(e).call(e,t[r])>-1)return!0;return!1}util.createDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=document.createElement(t);return i.className=a,i.innerHTML=r,_forEachInstanceProperty(e=_Object$keys(n)).call(e,(function(e){var r=e,a=n[e];"video"===t||"audio"===t||"live-video"===t?a&&i.setAttribute(r,a):i.setAttribute(r,a)})),i},util.createDomFromHtml=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{var n=document.createElement("div");n.innerHTML=e;var a=n.children;if(n=null,a.length>0){var i;if(a=a[0],r&&util.addClass(a,r),t)_forEachInstanceProperty(i=_Object$keys(t)).call(i,(function(e){a.setAttribute(e,t[e])}));return a}return null}catch(e){return XG_DEBUG.logError("util.createDomFromHtml",e),null}},util.hasClass=function(e,t){if(!e||!t)return!1;try{return _someInstanceProperty(Array.prototype).call(e.classList,(function(e){return e===t}))}catch(n){var r=e.className&&"object"===_typeof(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},util.addClass=function(e,t){if(e&&t)try{var r;_forEachInstanceProperty(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.add(t)}))}catch(r){util.hasClass(e,t)||(e.className&&"object"===_typeof(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},util.removeClass=function(e,t){if(e&&t)try{var r;_forEachInstanceProperty(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.remove(t)}))}catch(r){var n;if(util.hasClass(e,t))_forEachInstanceProperty(n=t.split(/\s+/g)).call(n,(function(t){var r=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===_typeof(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")}))}},util.toggleClass=function(e,t){var r;e&&_forEachInstanceProperty(r=t.split(/\s+/g)).call(r,(function(t){util.hasClass(e,t)?util.removeClass(e,t):util.addClass(e,t)}))},util.classNames=function(){for(var e=arguments,t=[],r=function(r){if("String"===util.typeOf(e[r]))t.push(e[r]);else if("Object"===util.typeOf(e[r])){var n;_mapInstanceProperty(n=_Object$keys(e[r])).call(n,(function(n){e[r][n]&&t.push(n)}))}},n=0;n<arguments.length;n++)r(n);return t.join(" ")},util.findDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,r=arguments.length>1?arguments[1]:void 0;try{e=t.querySelector(r)}catch(n){XG_DEBUG.logError("util.findDom",n),0===_indexOfInstanceProperty(r).call(r,"#")&&(e=t.getElementById(_sliceInstanceProperty(r).call(r,1)))}return e},util.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},util.padStart=function(e,t,r){for(var n=String(r),a=t>>0,i=Math.ceil(a/n.length),s=[],o=String(e);i--;)s.push(n);return s.join("").substring(0,a-o.length)+o},util.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=_padStartInstanceProperty(util).call(util,Math.floor(e/3600),2,0),r=_padStartInstanceProperty(util).call(util,Math.floor((e-3600*t)/60),2,0),n=_padStartInstanceProperty(util).call(util,Math.floor(e-3600*t-60*r),2,0);return("00"===t?[r,n]:[t,r,n]).join(":")},util.event=function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},util.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},util.deepCopy=function(e,t){var r;if("Object"===util.typeOf(t)&&"Object"===util.typeOf(e))return _forEachInstanceProperty(r=_Object$keys(t)).call(r,(function(r){if("Object"!==util.typeOf(t[r])||t[r]instanceof Node)if("Array"===util.typeOf(t[r])){var n;e[r]="Array"===util.typeOf(e[r])?_concatInstanceProperty(n=e[r]).call(n,t[r]):t[r]}else e[r]=t[r];else void 0===e[r]||void 0===e[r]?e[r]=t[r]:util.deepCopy(e[r],t[r])})),e},util.deepMerge=function(e,t){var r;return _mapInstanceProperty(r=_Object$keys(t)).call(r,(function(r){var n;"Array"===util.typeOf(t[r])&&"Array"===util.typeOf(e[r])?"Array"===util.typeOf(e[r])&&(n=e[r]).push.apply(n,_toConsumableArray$1(t[r])):util.typeOf(e[r])!==util.typeOf(t[r])||null===e[r]||"Object"!==util.typeOf(e[r])||t[r]instanceof window.Node?null!==t[r]&&(e[r]=t[r]):util.deepMerge(e[r],t[r])})),e},util.getBgImage=function(e){var t=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;if(!t||"none"===t)return"";var r=document.createElement("a");return r.href=t.replace(/url\("|"\)/g,""),r.href},util.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return _forEachInstanceProperty(Array.prototype).call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},util.setInterval=function(e,t,r,n){e._interval[t]||(e._interval[t]=_setInterval(_bindInstanceProperty(r).call(r,e),n))},util.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},util.setTimeout=function(e,t,r){e._timers||(e._timers=[]);var n=_setTimeout((function(){t(),util.clearTimeout(e,n)}),r);return e._timers.push(n),n},util.clearTimeout=function(e,t){var r=e._timers;if("Array"===util.typeOf(r)){for(var n=0;n<r.length;n++)if(r[n]===t){_spliceInstanceProperty(r).call(r,n,1),clearTimeout(t);break}}else clearTimeout(t)},util.clearAllTimers=function(e){var t=e._timers;"Array"===util.typeOf(t)&&(_mapInstanceProperty(t).call(t,(function(e){clearTimeout(e)})),e._timerIds=[])},util.createImgBtn=function(e,t,r,n){var a,i,s,o,l,c,u,d,f,h,p,y,g=util.createDom("xg-".concat(e),"",{},"xgplayer-".concat(e,"-img"));(g.style.backgroundImage='url("'.concat(t,'")'),r&&n)&&(_everyInstanceProperty(a=["px","rem","em","pt","dp","vw","vh","vm","%"]).call(a,(function(e){var t,a;return!(_indexOfInstanceProperty(r).call(r,e)>-1&&_indexOfInstanceProperty(n).call(n,e)>-1)||(u=_parseFloat$1(_trimInstanceProperty(t=_sliceInstanceProperty(r).call(r,0,_indexOfInstanceProperty(r).call(r,e))).call(t)),d=_parseFloat$1(_trimInstanceProperty(a=_sliceInstanceProperty(n).call(n,0,_indexOfInstanceProperty(n).call(n,e))).call(a)),f=e,!1)})),g.style.width=_concatInstanceProperty(i="".concat(u)).call(i,f),g.style.height=_concatInstanceProperty(s="".concat(d)).call(s,f),g.style.backgroundSize=_concatInstanceProperty(o=_concatInstanceProperty(l=_concatInstanceProperty(c="".concat(u)).call(c,f," ")).call(l,d)).call(o,f),g.style.margin="start"===e?_concatInstanceProperty(h=_concatInstanceProperty(p=_concatInstanceProperty(y="-".concat(d/2)).call(y,f," auto auto -")).call(p,u/2)).call(h,f):"auto 5px auto 5px");return g},util.Hex2RGBA=function(e,t){var r,n=[];if(/^\#[0-9A-F]{3}$/i.test(e)){var a="#";e.replace(/[0-9A-F]/gi,(function(e){a+=e+e})),e=a}return/^#[0-9A-F]{6}$/i.test(e)?(e.replace(/[0-9A-F]{2}/gi,(function(e){n.push(_parseInt$1(e,16))})),_concatInstanceProperty(r="rgba(".concat(n.join(","),", ")).call(r,t,")")):"rgba(255, 255, 255, 0.1)"},util.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},util.checkIsFunction=function(e){return e&&"function"==typeof e},util.checkIsObject=function(e){return null!==e&&"object"===_typeof(e)},util.hide=function(e){e.style.display="none"},util.show=function(e,t){e.style.display=t||"block"},util.isUndefined=function(e){if(null==e)return!0},util.isNotNull=function(e){return!(null==e)},util.setStyleFromCsstext=function(e,t){if(t)if("String"===util.typeOf(t)){var r=t.replace(/\s+/g,"").split(";");_mapInstanceProperty(r).call(r,(function(t){if(t){var r=t.split(":");r.length>1&&(e.style[r[0]]=r[1])}}))}else{var n;_mapInstanceProperty(n=_Object$keys(t)).call(n,(function(r){e.style[r]=t[r]}))}},util.filterStyleFromText=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height","top","left","bottom","right","position","z-index","padding","margin","transform"],n=e.style.cssText;if(!n)return{};var a=n.replace(/\s+/g,"").split(";"),i={},s={};return _mapInstanceProperty(a).call(a,(function(e){if(e){var t=e.split(":");t.length>1&&(checkIsIn(t[0],r)?i[t[0]]=t[1]:s[t[0]]=t[1])}})),e.setAttribute("style",""),_mapInstanceProperty(t=_Object$keys(s)).call(t,(function(t){e.style[t]=s[t]})),i},util.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var r=t.replace(/\s+/g,"").split(";"),n={};return _mapInstanceProperty(r).call(r,(function(e){if(e){var t=e.split(":");t.length>1&&(n[t[0]]=t[1])}})),n},util.preloadImg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(e){var n=new window.Image;n.onload=function(e){n=null,t&&t(e)},n.onerror=function(e){n=null,r&&r(e)},n.src=e}},util.stopPropagation=function(e){e&&e.stopPropagation()},util.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},util.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},util.checkTouchSupport=function(){return"ontouchstart"in window},util.getBuffered2=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=[],n=0;n<e.length;n++)r.push({start:e.start(n)<.5?0:e.start(n),end:e.end(n)});_sortInstanceProperty(r).call(r,(function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var a=[];if(t)for(var i=0;i<r.length;i++){var s=a.length;if(s){var o=a[s-1].end;r[i].start-o<t?r[i].end>o&&(a[s-1].end=r[i].end):a.push(r[i])}else a.push(r[i])}else a=r;return new XgplayerTimeRange(a)},util.getEventPos=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.touches&&e.touches.length>0&&(e=e.touches[0]),{x:e.x/t,y:e.y/t,clientX:e.clientX/t,clientY:e.clientY/t,offsetX:e.offsetX/t,offsetY:e.offsetY/t,pageX:e.pageX/t,pageY:e.pageY/t}},util.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},util.getHostFromUrl=function(e){if("String"!==util.typeOf(e))return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r},util.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},util.isMSE=function(e){return e.media&&(e=e.media),!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},util.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},util.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=_parseInt$1(e)}catch(t){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=_parseInt$1(window.performance.now())),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)}))},util.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},util.adjustTimeByDuration=function(e,t,r){return t&&e&&(e>t||r&&e<t)?t:e},util.createPositionBar=function(e,t){var r=util.createDom("xg-bar","",{"data-index":-1},e);return t.appendChild(r),r},util.getTransformStyle=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0,scale:1,rotate:0},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n={scale:"".concat(t.scale||1),translate:_concatInstanceProperty(e="".concat(t.x||0,"%, ")).call(e,t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")},a=_Object$keys(n);return _forEachInstanceProperty(a).call(a,(function(e){var t,a=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),i=_concatInstanceProperty(t="".concat(e,"(")).call(t,n[e],")");a.test(r)?(a.lastIndex=-1,r=r.replace(a,i)):r+="".concat(i," ")})),r},util.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},util.getIndexByTime=function(e,t){var r=t.length,n=-1;if(r<1)return n;if(e<=t[0].end||r<2)n=0;else if(e>t[r-1].end)n=r-1;else for(var a=1;a<r;a++)if(e>t[a-1].end&&e<=t[a].end){n=a;break}return n},util.getOffsetCurrentTime=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n=-1;if((n=r>=0&&r<t.length?r:util.getIndexByTime(e,t))<0)return-1;var a=t.length,i=t[n],s=i.start,o=i.end,l=i.cTime,c=i.offset;return e<s?l:e>=s&&e<=o?e-c:e>o&&n>=a-1?o:-1},util.getCurrentTimeByOffset=function(e,t){var r=-1;if(!t||t.length<0)return e;for(var n=0;n<t.length;n++)if(e<=t[n].duration){r=n;break}if(-1!==r){var a=t[r].start;return r-1<0?a+e:a+(e-t[r-1].duration)}return e};var URL_CHANGE="urlchange";function callHandler(e,t,r){for(var n,a=arguments.length,i=new Array(a>3?a-3:0),s=3;s<a;s++)i[s-3]=arguments[s];var o,l=t.call.apply(t,_concatInstanceProperty(n=[e]).call(n,i));r&&"function"==typeof r&&(l&&l.then?l.then((function(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];r.call.apply(r,_concatInstanceProperty(t=[e]).call(t,a))})):r.call.apply(r,_concatInstanceProperty(o=[e]).call(o,i)))}function hook(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{pre:null,next:null};return this.__hooks||(this.__hooks={}),!this.__hooks[e]&&(this.__hooks[e]=null),_bindInstanceProperty(r=function(){var r,a=arguments,i=this;if(n.pre)try{var s,o;(o=n.pre).call.apply(o,_concatInstanceProperty(s=[this]).call(s,_sliceInstanceProperty(Array.prototype).call(arguments)))}catch(t){var l,c;throw t.message=_concatInstanceProperty(l=_concatInstanceProperty(c="[pluginName: ".concat(this.pluginName,":")).call(c,e,":pre error] >> ")).call(l,t.message),t}if(this.__hooks&&this.__hooks[e])try{var u,d=runHooks(this,e,t);if(d)if(d.then)d.then((function(e){var r;!1!==e&&callHandler.apply(void 0,_concatInstanceProperty(r=[i,t,n.next]).call(r,_toConsumableArray$1(a)))})).catch((function(e){throw e}));else callHandler.apply(void 0,_concatInstanceProperty(u=[this,t,n.next]).call(u,_sliceInstanceProperty(Array.prototype).call(arguments)));else if(void 0===d){var f;callHandler.apply(void 0,_concatInstanceProperty(f=[this,t,n.next]).call(f,_sliceInstanceProperty(Array.prototype).call(arguments)))}}catch(t){var h,p;throw t.message=_concatInstanceProperty(h=_concatInstanceProperty(p="[pluginName: ".concat(this.pluginName,":")).call(p,e,"] >> ")).call(h,t.message),t}else callHandler.apply(void 0,_concatInstanceProperty(r=[this,t,n.next]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}).call(r,this)}function findHookIndex(e,t){var r=this.__hooks;if(!r||!_Array$isArray(r[e]))return-1;for(var n=r[e],a=0;a<n.length;a++)if(n[a]===t)return a;return-1}function useHooks(e,t){var r=this.__hooks;if(r)return r.hasOwnProperty(e)?(_Array$isArray(r[e])||(r[e]=[]),-1===findHookIndex.call(this,e,t)&&r[e].push(t),!0):(console.warn("has no supported hook which name [".concat(e,"]")),!1)}function removeHooks(e,t){var r=this.__hooks;if(r)if(_Array$isArray(r[e])){var n=r[e],a=findHookIndex.call(this,e,t);-1!==a&&_spliceInstanceProperty(n).call(n,a,1)}else r[e]&&(r[e]=null)}function hooksDescriptor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&_mapInstanceProperty(t).call(t,(function(t){e.__hooks[t]=null})),_Object$defineProperty(e,"hooks",{get:function(){var t;return e.__hooks&&_mapInstanceProperty(t=_Object$keys(e.__hooks)).call(t,(function(t){if(e.__hooks[t])return t}))}})}function delHooksDescriptor(e){e.__hooks=null}function runHooks(e,t,r){for(var n=arguments.length,a=new Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];if(e.__hooks&&_Array$isArray(e.__hooks[t])){var s,o=e.__hooks[t],l=-1;return function e(t,r,n){for(var a,i,s=arguments.length,c=new Array(s>3?s-3:0),u=3;u<s;u++)c[u-3]=arguments[u];if(l++,0===o.length||l===o.length)return n.call.apply(n,_concatInstanceProperty(i=[t,t]).call(i,c));var d,f=o[l],h=f.call.apply(f,_concatInstanceProperty(a=[t,t]).call(a,c));return h&&h.then?h.then((function(a){var i;return!1===a?null:e.apply(void 0,_concatInstanceProperty(i=[t,r,n]).call(i,c))})).catch((function(e){console.warn("[runHooks]".concat(r," reject"),e.message)})):!1!==h?e.apply(void 0,_concatInstanceProperty(d=[t,r,n]).call(d,c)):void 0}.apply(void 0,_concatInstanceProperty(s=[e,t,r]).call(s,a))}var c;return r.call.apply(r,_concatInstanceProperty(c=[e,e]).call(c,a))}function showErrorMsg(e,t){var r;XG_DEBUG.logError(_concatInstanceProperty(r="[".concat(e,"] event or callback cant be undefined or null when call ")).call(r,t))}var BasePlugin=function(){function e(t){_classCallCheck(this,e),util.checkIsFunction(this.beforeCreate)&&this.beforeCreate(t),hooksDescriptor(this),this.__args=t,this.__events={},this.__onceEvents={},this.config=t.config||{},this.player=null,this.playerConfig={},this.pluginName="",this.__init(t)}return _createClass(e,[{key:"beforeCreate",value:function(e){}},{key:"afterCreate",value:function(){}},{key:"beforePlayerInit",value:function(){}},{key:"onPluginsReady",value:function(){}},{key:"afterPlayerInit",value:function(){}},{key:"destroy",value:function(){}},{key:"__init",value:function(e){this.player=e.player,this.playerConfig=e.player&&e.player.config,this.pluginName=e.pluginName?e.pluginName.toLowerCase():this.constructor.pluginName.toLowerCase(),this.logger=e.player&&e.player.logger}},{key:"updateLang",value:function(e){e||(e=this.lang)}},{key:"lang",get:function(){return this.player.lang}},{key:"i18n",get:function(){return this.player.i18n}},{key:"i18nKeys",get:function(){return this.player.i18nKeys}},{key:"domEventType",get:function(){var e=util.checkTouchSupport()?"touch":"mouse";return!this.playerConfig||"touch"!==this.playerConfig.domEventType&&"mouse"!==this.playerConfig.domEventType||(e=this.playerConfig.domEventType),e}},{key:"on",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(this.__events[e]=t,this.player.on(e,t)):_Array$isArray(e)&&_forEachInstanceProperty(e).call(e,(function(e){r.__events[e]=t,r.player.on(e,t)})):showErrorMsg(this.pluginName,"plugin.on(event, callback)")}},{key:"once",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(this.__onceEvents[e]=t,this.player.once(e,t)):_Array$isArray(e)&&_forEachInstanceProperty(e).call(e,(function(n){r.__onceEvents[n]=t,r.player.once(e,t)})):showErrorMsg(this.pluginName,"plugin.once(event, callback)")}},{key:"off",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(delete this.__events[e],this.player.off(e,t)):_Array$isArray(e)&&_forEachInstanceProperty(e).call(e,(function(n){delete r.__events[e],r.player.off(n,t)})):showErrorMsg(this.pluginName,"plugin.off(event, callback)")}},{key:"offAll",value:function(){var e,t=this;_forEachInstanceProperty(e=["__events","__onceEvents"]).call(e,(function(e){var r;_forEachInstanceProperty(r=_Object$keys(t[e])).call(r,(function(r){t[e][r]&&t.off(r,t[e][r]),r&&delete t[e][r]}))})),this.__events={},this.__onceEvents={}}},{key:"emit",value:function(e){var t,r;if(this.player){for(var n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];(r=this.player).emit.apply(r,_concatInstanceProperty(t=[e]).call(t,a))}}},{key:"emitUserAction",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var n=_objectSpread2$1(_objectSpread2$1({},r),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,n)}}},{key:"hook",value:function(e,t){var r;return hook.call.apply(hook,_concatInstanceProperty(r=[this]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}},{key:"useHooks",value:function(e,t){for(var r,n=arguments.length,a=new Array(n>2?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i];return useHooks.call.apply(useHooks,_concatInstanceProperty(r=[this]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}},{key:"removeHooks",value:function(e,t){for(var r,n=arguments.length,a=new Array(n>2?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i];return removeHooks.call.apply(removeHooks,_concatInstanceProperty(r=[this]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}},{key:"registerPlugin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(this.player)return r&&(t.pluginName=r),this.player.registerPlugin({plugin:e,options:t})}},{key:"getPlugin",value:function(e){return this.player?this.player.getPlugin(e):null}},{key:"__destroy",value:function(){var e,t=this,r=this.player,n=this.pluginName;this.offAll(),util.clearAllTimers(this),util.checkIsFunction(this.destroy)&&this.destroy(),_mapInstanceProperty(e=["player","playerConfig","pluginName","logger","__args","__hooks"]).call(e,(function(e){t[e]=null})),r.unRegisterPlugin(n),delHooksDescriptor(this)}}],[{key:"defineGetterOrSetter",value:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&_Object$defineProperty(e,r,t[r])}},{key:"defineMethod",value:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&"function"==typeof t[r]&&_Object$defineProperty(e,r,{configurable:!0,value:t[r]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}(),fails$5=fails$A,wellKnownSymbol$2=wellKnownSymbol$r,DESCRIPTORS$4=descriptors,IS_PURE=isPure,ITERATOR$2=wellKnownSymbol$2("iterator"),urlConstructorDetection=!fails$5((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),IS_PURE&&!e.toJSON||!t.size&&(IS_PURE||!DESCRIPTORS$4)||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[ITERATOR$2]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),uncurryThis$7=functionUncurryThis,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexNonASCII=/[^\0-\u007E]/,regexSeparators=/[.\u3002\uFF0E\uFF61]/g,OVERFLOW_ERROR="Overflow: input needs wider integers to process",baseMinusTMin=base-tMin,$RangeError=RangeError,exec$1=uncurryThis$7(regexSeparators.exec),floor$2=Math.floor,fromCharCode=String.fromCharCode,charCodeAt=uncurryThis$7("".charCodeAt),join$2=uncurryThis$7([].join),push$6=uncurryThis$7([].push),replace$2=uncurryThis$7("".replace),split$2=uncurryThis$7("".split),toLowerCase$1=uncurryThis$7("".toLowerCase),ucs2decode=function(e){for(var t=[],r=0,n=e.length;r<n;){var a=charCodeAt(e,r++);if(a>=55296&&a<=56319&&r<n){var i=charCodeAt(e,r++);56320==(64512&i)?push$6(t,((1023&a)<<10)+(1023&i)+65536):(push$6(t,a),r--)}else push$6(t,a)}return t},digitToBasic=function(e){return e+22+75*(e<26)},adapt=function(e,t,r){var n=0;for(e=r?floor$2(e/damp):e>>1,e+=floor$2(e/t);e>baseMinusTMin*tMax>>1;)e=floor$2(e/baseMinusTMin),n+=base;return floor$2(n+(baseMinusTMin+1)*e/(e+skew))},encode=function(e){var t,r,n=[],a=(e=ucs2decode(e)).length,i=initialN,s=0,o=initialBias;for(t=0;t<e.length;t++)(r=e[t])<128&&push$6(n,fromCharCode(r));var l=n.length,c=l;for(l&&push$6(n,delimiter);c<a;){var u=maxInt;for(t=0;t<e.length;t++)(r=e[t])>=i&&r<u&&(u=r);var d=c+1;if(u-i>floor$2((maxInt-s)/d))throw $RangeError(OVERFLOW_ERROR);for(s+=(u-i)*d,i=u,t=0;t<e.length;t++){if((r=e[t])<i&&++s>maxInt)throw $RangeError(OVERFLOW_ERROR);if(r==i){for(var f=s,h=base;;){var p=h<=o?tMin:h>=o+tMax?tMax:h-o;if(f<p)break;var y=f-p,g=base-p;push$6(n,fromCharCode(digitToBasic(p+y%g))),f=floor$2(y/g),h+=base}push$6(n,fromCharCode(digitToBasic(f))),o=adapt(s,d,c==l),s=0,c++}}s++,i++}return join$2(n,"")},stringPunycodeToAscii=function(e){var t,r,n=[],a=split$2(replace$2(toLowerCase$1(e),regexSeparators,"."),".");for(t=0;t<a.length;t++)r=a[t],push$6(n,exec$1(regexNonASCII,r)?"xn--"+encode(r):r);return join$2(n,".")},defineBuiltIn$2=defineBuiltIn$8,defineBuiltIns$2=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:defineBuiltIn$2(e,n,t[n],r);return e},$$X=_export,global$4=global$s,call$e=functionCall,uncurryThis$6=functionUncurryThis,DESCRIPTORS$3=descriptors,USE_NATIVE_URL$2=urlConstructorDetection,defineBuiltIn$1=defineBuiltIn$8,defineBuiltInAccessor$2=defineBuiltInAccessor$5,defineBuiltIns$1=defineBuiltIns$2,setToStringTag$2=setToStringTag$9,createIteratorConstructor=iteratorCreateConstructor,InternalStateModule$3=internalState,anInstance$3=anInstance$5,isCallable$5=isCallable$r,hasOwn$6=hasOwnProperty_1,bind$f=functionBindContext,classof$4=classof$f,anObject$3=anObject$i,isObject$5=isObject$m,$toString$1=toString$g,create$1=objectCreate,createPropertyDescriptor=createPropertyDescriptor$8,getIterator=getIterator$3,getIteratorMethod=getIteratorMethod$a,validateArgumentsLength$2=validateArgumentsLength$5,wellKnownSymbol$1=wellKnownSymbol$r,arraySort=arraySort$1,ITERATOR$1=wellKnownSymbol$1("iterator"),URL_SEARCH_PARAMS="URLSearchParams",URL_SEARCH_PARAMS_ITERATOR=URL_SEARCH_PARAMS+"Iterator",setInternalState$3=InternalStateModule$3.set,getInternalParamsState=InternalStateModule$3.getterFor(URL_SEARCH_PARAMS),getInternalIteratorState=InternalStateModule$3.getterFor(URL_SEARCH_PARAMS_ITERATOR),getOwnPropertyDescriptor5=Object.getOwnPropertyDescriptor,safeGetBuiltIn=function(e){if(!DESCRIPTORS$3)return global$4[e];var t=getOwnPropertyDescriptor5(global$4,e);return t&&t.value},nativeFetch=safeGetBuiltIn("fetch"),NativeRequest=safeGetBuiltIn("Request"),Headers=safeGetBuiltIn("Headers"),RequestPrototype=NativeRequest&&NativeRequest.prototype,HeadersPrototype=Headers&&Headers.prototype,RegExp$1=global$4.RegExp,TypeError$2=global$4.TypeError,decodeURIComponent$1=global$4.decodeURIComponent,encodeURIComponent$1=global$4.encodeURIComponent,charAt$1=uncurryThis$6("".charAt),join$1=uncurryThis$6([].join),push$5=uncurryThis$6([].push),replace$1=uncurryThis$6("".replace),shift$1=uncurryThis$6([].shift),splice2=uncurryThis$6([].splice),split$1=uncurryThis$6("".split),stringSlice$2=uncurryThis$6("".slice),plus=/\+/g,sequences=Array(4),percentSequence=function(e){return sequences[e-1]||(sequences[e-1]=RegExp$1("((?:%[\\da-f]{2}){"+e+"})","gi"))},percentDecode=function(e){try{return decodeURIComponent$1(e)}catch(t){return e}},deserialize=function(e){var t=replace$1(e,plus," "),r=4;try{return decodeURIComponent$1(t)}catch(e){for(;r;)t=replace$1(t,percentSequence(r--),percentDecode);return t}},find2=/[!'()~]|%20/g,replacements={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},replacer=function(e){return replacements[e]},serialize=function(e){return replace$1(encodeURIComponent$1(e),find2,replacer)},URLSearchParamsIterator=createIteratorConstructor((function(e,t){setInternalState$3(this,{type:URL_SEARCH_PARAMS_ITERATOR,iterator:getIterator(getInternalParamsState(e).entries),kind:t})}),"Iterator",(function(){var e=getInternalIteratorState(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),URLSearchParamsState=function(e){this.entries=[],this.url=null,void 0!==e&&(isObject$5(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===charAt$1(e,0)?stringSlice$2(e,1):e:$toString$1(e)))};URLSearchParamsState.prototype={type:URL_SEARCH_PARAMS,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,a,i,s,o,l=getIteratorMethod(e);if(l)for(r=(t=getIterator(e,l)).next;!(n=call$e(r,t)).done;){if(i=(a=getIterator(anObject$3(n.value))).next,(s=call$e(i,a)).done||(o=call$e(i,a)).done||!call$e(i,a).done)throw TypeError$2("Expected sequence with length 2");push$5(this.entries,{key:$toString$1(s.value),value:$toString$1(o.value)})}else for(var c in e)hasOwn$6(e,c)&&push$5(this.entries,{key:c,value:$toString$1(e[c])})},parseQuery:function(e){if(e)for(var t,r,n=split$1(e,"&"),a=0;a<n.length;)(t=n[a++]).length&&(r=split$1(t,"="),push$5(this.entries,{key:deserialize(shift$1(r)),value:deserialize(join$1(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],push$5(r,serialize(e.key)+"="+serialize(e.value));return join$1(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var URLSearchParamsConstructor=function(){anInstance$3(this,URLSearchParamsPrototype);var e=setInternalState$3(this,new URLSearchParamsState(arguments.length>0?arguments[0]:void 0));DESCRIPTORS$3||(this.length=e.entries.length)},URLSearchParamsPrototype=URLSearchParamsConstructor.prototype;if(defineBuiltIns$1(URLSearchParamsPrototype,{append:function(e,t){validateArgumentsLength$2(arguments.length,2);var r=getInternalParamsState(this);push$5(r.entries,{key:$toString$1(e),value:$toString$1(t)}),DESCRIPTORS$3||this.length++,r.updateURL()},delete:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this),r=t.entries,n=$toString$1(e),a=0;a<r.length;)r[a].key===n?splice2(r,a,1):a++;DESCRIPTORS$3||(this.length=r.length),t.updateURL()},get:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=[],a=0;a<t.length;a++)t[a].key===r&&push$5(n,t[a].value);return n},has:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){validateArgumentsLength$2(arguments.length,1);for(var r,n=getInternalParamsState(this),a=n.entries,i=!1,s=$toString$1(e),o=$toString$1(t),l=0;l<a.length;l++)(r=a[l]).key===s&&(i?splice2(a,l--,1):(i=!0,r.value=o));i||push$5(a,{key:s,value:o}),DESCRIPTORS$3||(this.length=a.length),n.updateURL()},sort:function(){var e=getInternalParamsState(this);arraySort(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=getInternalParamsState(this).entries,n=bind$f(e,arguments.length>1?arguments[1]:void 0),a=0;a<r.length;)n((t=r[a++]).value,t.key,this)},keys:function(){return new URLSearchParamsIterator(this,"keys")},values:function(){return new URLSearchParamsIterator(this,"values")},entries:function(){return new URLSearchParamsIterator(this,"entries")}},{enumerable:!0}),defineBuiltIn$1(URLSearchParamsPrototype,ITERATOR$1,URLSearchParamsPrototype.entries,{name:"entries"}),defineBuiltIn$1(URLSearchParamsPrototype,"toString",(function(){return getInternalParamsState(this).serialize()}),{enumerable:!0}),DESCRIPTORS$3&&defineBuiltInAccessor$2(URLSearchParamsPrototype,"size",{get:function(){return getInternalParamsState(this).entries.length},configurable:!0,enumerable:!0}),setToStringTag$2(URLSearchParamsConstructor,URL_SEARCH_PARAMS),$$X({global:!0,constructor:!0,forced:!USE_NATIVE_URL$2},{URLSearchParams:URLSearchParamsConstructor}),!USE_NATIVE_URL$2&&isCallable$5(Headers)){var headersHas=uncurryThis$6(HeadersPrototype.has),headersSet=uncurryThis$6(HeadersPrototype.set),wrapRequestOptions=function(e){if(isObject$5(e)){var t,r=e.body;if(classof$4(r)===URL_SEARCH_PARAMS)return t=e.headers?new Headers(e.headers):new Headers,headersHas(t,"content-type")||headersSet(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),create$1(e,{body:createPropertyDescriptor(0,$toString$1(r)),headers:createPropertyDescriptor(0,t)})}return e};if(isCallable$5(nativeFetch)&&$$X({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return nativeFetch(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})}}),isCallable$5(NativeRequest)){var RequestConstructor=function(e){return anInstance$3(this,RequestPrototype),new NativeRequest(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})};RequestPrototype.constructor=RequestConstructor,RequestConstructor.prototype=RequestPrototype,$$X({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:RequestConstructor})}}var EOF,web_urlSearchParams_constructor={URLSearchParams:URLSearchParamsConstructor,getState:getInternalParamsState},$$W=_export,DESCRIPTORS$2=descriptors,USE_NATIVE_URL$1=urlConstructorDetection,global$3=global$s,bind$e=functionBindContext,uncurryThis$5=functionUncurryThis,defineBuiltIn=defineBuiltIn$8,defineBuiltInAccessor$1=defineBuiltInAccessor$5,anInstance$2=anInstance$5,hasOwn$5=hasOwnProperty_1,assign2=objectAssign,arrayFrom=arrayFrom$1,arraySlice$1=arraySliceSimple,codeAt=stringMultibyte.codeAt,toASCII=stringPunycodeToAscii,$toString=toString$g,setToStringTag$1=setToStringTag$9,validateArgumentsLength$1=validateArgumentsLength$5,URLSearchParamsModule=web_urlSearchParams_constructor,InternalStateModule$2=internalState,setInternalState$2=InternalStateModule$2.set,getInternalURLState=InternalStateModule$2.getterFor("URL"),URLSearchParams$1=URLSearchParamsModule.URLSearchParams,getInternalSearchParamsState=URLSearchParamsModule.getState,NativeURL=global$3.URL,TypeError$1=global$3.TypeError,parseInt$1=global$3.parseInt,floor$1=Math.floor,pow=Math.pow,charAt=uncurryThis$5("".charAt),exec=uncurryThis$5(/./.exec),join=uncurryThis$5([].join),numberToString=uncurryThis$5(1..toString),pop=uncurryThis$5([].pop),push$4=uncurryThis$5([].push),replace=uncurryThis$5("".replace),shift=uncurryThis$5([].shift),split=uncurryThis$5("".split),stringSlice$1=uncurryThis$5("".slice),toLowerCase=uncurryThis$5("".toLowerCase),unshift=uncurryThis$5([].unshift),INVALID_AUTHORITY="Invalid authority",INVALID_SCHEME="Invalid scheme",INVALID_HOST="Invalid host",INVALID_PORT="Invalid port",ALPHA=/[a-z]/i,ALPHANUMERIC=/[\d+-.a-z]/i,DIGIT=/\d/,HEX_START=/^0x/i,OCT=/^[0-7]+$/,DEC=/^\d+$/,HEX=/^[\da-f]+$/i,FORBIDDEN_HOST_CODE_POINT=/[\0\t\n\r #%/:<>?@[\\\]^|]/,FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT=/[\0\t\n\r #/:<>?@[\\\]^|]/,LEADING_C0_CONTROL_OR_SPACE=/^[\u0000-\u0020]+/,TRAILING_C0_CONTROL_OR_SPACE=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,TAB_AND_NEW_LINE=/[\t\n\r]/g,parseIPv4=function(e){var t,r,n,a,i,s,o,l=split(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(a=l[n]))return e;if(i=10,a.length>1&&"0"==charAt(a,0)&&(i=exec(HEX_START,a)?16:8,a=stringSlice$1(a,8==i?1:2)),""===a)s=0;else{if(!exec(10==i?DEC:8==i?OCT:HEX,a))return e;s=parseInt$1(a,i)}push$4(r,s)}for(n=0;n<t;n++)if(s=r[n],n==t-1){if(s>=pow(256,5-t))return null}else if(s>255)return null;for(o=pop(r),n=0;n<r.length;n++)o+=r[n]*pow(256,3-n);return o},parseIPv6=function(e){var t,r,n,a,i,s,o,l=[0,0,0,0,0,0,0,0],c=0,u=null,d=0,f=function(){return charAt(e,d)};if(":"==f()){if(":"!=charAt(e,1))return;d+=2,u=++c}for(;f();){if(8==c)return;if(":"!=f()){for(t=r=0;r<4&&exec(HEX,f());)t=16*t+parseInt$1(f(),16),d++,r++;if("."==f()){if(0==r)return;if(d-=r,c>6)return;for(n=0;f();){if(a=null,n>0){if(!("."==f()&&n<4))return;d++}if(!exec(DIGIT,f()))return;for(;exec(DIGIT,f());){if(i=parseInt$1(f(),10),null===a)a=i;else{if(0==a)return;a=10*a+i}if(a>255)return;d++}l[c]=256*l[c]+a,2!=++n&&4!=n||c++}if(4!=n)return;break}if(":"==f()){if(d++,!f())return}else if(f())return;l[c++]=t}else{if(null!==u)return;d++,u=++c}}if(null!==u)for(s=c-u,c=7;0!=c&&s>0;)o=l[c],l[c--]=l[u+s-1],l[u+--s]=o;else if(8!=c)return;return l},findLongestZeroSequence=function(e){for(var t=null,r=1,n=null,a=0,i=0;i<8;i++)0!==e[i]?(a>r&&(t=n,r=a),n=null,a=0):(null===n&&(n=i),++a);return a>r&&(t=n,r=a),t},serializeHost=function(e){var t,r,n,a;if("number"==typeof e){for(t=[],r=0;r<4;r++)unshift(t,e%256),e=floor$1(e/256);return join(t,".")}if("object"==typeof e){for(t="",n=findLongestZeroSequence(e),r=0;r<8;r++)a&&0===e[r]||(a&&(a=!1),n===r?(t+=r?":":"::",a=!0):(t+=numberToString(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},C0ControlPercentEncodeSet={},fragmentPercentEncodeSet=assign2({},C0ControlPercentEncodeSet,{" ":1,'"':1,"<":1,">":1,"`":1}),pathPercentEncodeSet=assign2({},fragmentPercentEncodeSet,{"#":1,"?":1,"{":1,"}":1}),userinfoPercentEncodeSet=assign2({},pathPercentEncodeSet,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),percentEncode=function(e,t){var r=codeAt(e,0);return r>32&&r<127&&!hasOwn$5(t,e)?e:encodeURIComponent(e)},specialSchemes={ftp:21,file:null,http:80,https:443,ws:80,wss:443},isWindowsDriveLetter=function(e,t){var r;return 2==e.length&&exec(ALPHA,charAt(e,0))&&(":"==(r=charAt(e,1))||!t&&"|"==r)},startsWithWindowsDriveLetter=function(e){var t;return e.length>1&&isWindowsDriveLetter(stringSlice$1(e,0,2))&&(2==e.length||"/"===(t=charAt(e,2))||"\\"===t||"?"===t||"#"===t)},isSingleDot=function(e){return"."===e||"%2e"===toLowerCase(e)},isDoubleDot=function(e){return".."===(e=toLowerCase(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},SCHEME_START={},SCHEME={},NO_SCHEME={},SPECIAL_RELATIVE_OR_AUTHORITY={},PATH_OR_AUTHORITY={},RELATIVE={},RELATIVE_SLASH={},SPECIAL_AUTHORITY_SLASHES={},SPECIAL_AUTHORITY_IGNORE_SLASHES={},AUTHORITY={},HOST={},HOSTNAME={},PORT={},FILE={},FILE_SLASH={},FILE_HOST={},PATH_START={},PATH={},CANNOT_BE_A_BASE_URL_PATH={},QUERY={},FRAGMENT={},URLState=function(e,t,r){var n,a,i,s=$toString(e);if(t){if(a=this.parse(s))throw TypeError$1(a);this.searchParams=null}else{if(void 0!==r&&(n=new URLState(r,!0)),a=this.parse(s,null,n))throw TypeError$1(a);(i=getInternalSearchParamsState(new URLSearchParams$1)).bindURL(this),this.searchParams=i}};URLState.prototype={type:"URL",parse:function(e,t,r){var n,a,i,s,o=this,l=t||SCHEME_START,c=0,u="",d=!1,f=!1,h=!1;for(e=$toString(e),t||(o.scheme="",o.username="",o.password="",o.host=null,o.port=null,o.path=[],o.query=null,o.fragment=null,o.cannotBeABaseURL=!1,e=replace(e,LEADING_C0_CONTROL_OR_SPACE,""),e=replace(e,TRAILING_C0_CONTROL_OR_SPACE,"$1")),e=replace(e,TAB_AND_NEW_LINE,""),n=arrayFrom(e);c<=n.length;){switch(a=n[c],l){case SCHEME_START:if(!a||!exec(ALPHA,a)){if(t)return INVALID_SCHEME;l=NO_SCHEME;continue}u+=toLowerCase(a),l=SCHEME;break;case SCHEME:if(a&&(exec(ALPHANUMERIC,a)||"+"==a||"-"==a||"."==a))u+=toLowerCase(a);else{if(":"!=a){if(t)return INVALID_SCHEME;u="",l=NO_SCHEME,c=0;continue}if(t&&(o.isSpecial()!=hasOwn$5(specialSchemes,u)||"file"==u&&(o.includesCredentials()||null!==o.port)||"file"==o.scheme&&!o.host))return;if(o.scheme=u,t)return void(o.isSpecial()&&specialSchemes[o.scheme]==o.port&&(o.port=null));u="","file"==o.scheme?l=FILE:o.isSpecial()&&r&&r.scheme==o.scheme?l=SPECIAL_RELATIVE_OR_AUTHORITY:o.isSpecial()?l=SPECIAL_AUTHORITY_SLASHES:"/"==n[c+1]?(l=PATH_OR_AUTHORITY,c++):(o.cannotBeABaseURL=!0,push$4(o.path,""),l=CANNOT_BE_A_BASE_URL_PATH)}break;case NO_SCHEME:if(!r||r.cannotBeABaseURL&&"#"!=a)return INVALID_SCHEME;if(r.cannotBeABaseURL&&"#"==a){o.scheme=r.scheme,o.path=arraySlice$1(r.path),o.query=r.query,o.fragment="",o.cannotBeABaseURL=!0,l=FRAGMENT;break}l="file"==r.scheme?FILE:RELATIVE;continue;case SPECIAL_RELATIVE_OR_AUTHORITY:if("/"!=a||"/"!=n[c+1]){l=RELATIVE;continue}l=SPECIAL_AUTHORITY_IGNORE_SLASHES,c++;break;case PATH_OR_AUTHORITY:if("/"==a){l=AUTHORITY;break}l=PATH;continue;case RELATIVE:if(o.scheme=r.scheme,a==EOF)o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.query=r.query;else if("/"==a||"\\"==a&&o.isSpecial())l=RELATIVE_SLASH;else if("?"==a)o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.query="",l=QUERY;else{if("#"!=a){o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.path.length--,l=PATH;continue}o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.query=r.query,o.fragment="",l=FRAGMENT}break;case RELATIVE_SLASH:if(!o.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,l=PATH;continue}l=AUTHORITY}else l=SPECIAL_AUTHORITY_IGNORE_SLASHES;break;case SPECIAL_AUTHORITY_SLASHES:if(l=SPECIAL_AUTHORITY_IGNORE_SLASHES,"/"!=a||"/"!=charAt(u,c+1))continue;c++;break;case SPECIAL_AUTHORITY_IGNORE_SLASHES:if("/"!=a&&"\\"!=a){l=AUTHORITY;continue}break;case AUTHORITY:if("@"==a){d&&(u="%40"+u),d=!0,i=arrayFrom(u);for(var p=0;p<i.length;p++){var y=i[p];if(":"!=y||h){var g=percentEncode(y,userinfoPercentEncodeSet);h?o.password+=g:o.username+=g}else h=!0}u=""}else if(a==EOF||"/"==a||"?"==a||"#"==a||"\\"==a&&o.isSpecial()){if(d&&""==u)return INVALID_AUTHORITY;c-=arrayFrom(u).length+1,u="",l=HOST}else u+=a;break;case HOST:case HOSTNAME:if(t&&"file"==o.scheme){l=FILE_HOST;continue}if(":"!=a||f){if(a==EOF||"/"==a||"?"==a||"#"==a||"\\"==a&&o.isSpecial()){if(o.isSpecial()&&""==u)return INVALID_HOST;if(t&&""==u&&(o.includesCredentials()||null!==o.port))return;if(s=o.parseHost(u))return s;if(u="",l=PATH_START,t)return;continue}"["==a?f=!0:"]"==a&&(f=!1),u+=a}else{if(""==u)return INVALID_HOST;if(s=o.parseHost(u))return s;if(u="",l=PORT,t==HOSTNAME)return}break;case PORT:if(!exec(DIGIT,a)){if(a==EOF||"/"==a||"?"==a||"#"==a||"\\"==a&&o.isSpecial()||t){if(""!=u){var v=parseInt$1(u,10);if(v>65535)return INVALID_PORT;o.port=o.isSpecial()&&v===specialSchemes[o.scheme]?null:v,u=""}if(t)return;l=PATH_START;continue}return INVALID_PORT}u+=a;break;case FILE:if(o.scheme="file","/"==a||"\\"==a)l=FILE_SLASH;else{if(!r||"file"!=r.scheme){l=PATH;continue}if(a==EOF)o.host=r.host,o.path=arraySlice$1(r.path),o.query=r.query;else if("?"==a)o.host=r.host,o.path=arraySlice$1(r.path),o.query="",l=QUERY;else{if("#"!=a){startsWithWindowsDriveLetter(join(arraySlice$1(n,c),""))||(o.host=r.host,o.path=arraySlice$1(r.path),o.shortenPath()),l=PATH;continue}o.host=r.host,o.path=arraySlice$1(r.path),o.query=r.query,o.fragment="",l=FRAGMENT}}break;case FILE_SLASH:if("/"==a||"\\"==a){l=FILE_HOST;break}r&&"file"==r.scheme&&!startsWithWindowsDriveLetter(join(arraySlice$1(n,c),""))&&(isWindowsDriveLetter(r.path[0],!0)?push$4(o.path,r.path[0]):o.host=r.host),l=PATH;continue;case FILE_HOST:if(a==EOF||"/"==a||"\\"==a||"?"==a||"#"==a){if(!t&&isWindowsDriveLetter(u))l=PATH;else if(""==u){if(o.host="",t)return;l=PATH_START}else{if(s=o.parseHost(u))return s;if("localhost"==o.host&&(o.host=""),t)return;u="",l=PATH_START}continue}u+=a;break;case PATH_START:if(o.isSpecial()){if(l=PATH,"/"!=a&&"\\"!=a)continue}else if(t||"?"!=a)if(t||"#"!=a){if(a!=EOF&&(l=PATH,"/"!=a))continue}else o.fragment="",l=FRAGMENT;else o.query="",l=QUERY;break;case PATH:if(a==EOF||"/"==a||"\\"==a&&o.isSpecial()||!t&&("?"==a||"#"==a)){if(isDoubleDot(u)?(o.shortenPath(),"/"==a||"\\"==a&&o.isSpecial()||push$4(o.path,"")):isSingleDot(u)?"/"==a||"\\"==a&&o.isSpecial()||push$4(o.path,""):("file"==o.scheme&&!o.path.length&&isWindowsDriveLetter(u)&&(o.host&&(o.host=""),u=charAt(u,0)+":"),push$4(o.path,u)),u="","file"==o.scheme&&(a==EOF||"?"==a||"#"==a))for(;o.path.length>1&&""===o.path[0];)shift(o.path);"?"==a?(o.query="",l=QUERY):"#"==a&&(o.fragment="",l=FRAGMENT)}else u+=percentEncode(a,pathPercentEncodeSet);break;case CANNOT_BE_A_BASE_URL_PATH:"?"==a?(o.query="",l=QUERY):"#"==a?(o.fragment="",l=FRAGMENT):a!=EOF&&(o.path[0]+=percentEncode(a,C0ControlPercentEncodeSet));break;case QUERY:t||"#"!=a?a!=EOF&&("'"==a&&o.isSpecial()?o.query+="%27":o.query+="#"==a?"%23":percentEncode(a,C0ControlPercentEncodeSet)):(o.fragment="",l=FRAGMENT);break;case FRAGMENT:a!=EOF&&(o.fragment+=percentEncode(a,fragmentPercentEncodeSet))}c++}},parseHost:function(e){var t,r,n;if("["==charAt(e,0)){if("]"!=charAt(e,e.length-1))return INVALID_HOST;if(!(t=parseIPv6(stringSlice$1(e,1,-1))))return INVALID_HOST;this.host=t}else if(this.isSpecial()){if(e=toASCII(e),exec(FORBIDDEN_HOST_CODE_POINT,e))return INVALID_HOST;if(null===(t=parseIPv4(e)))return INVALID_HOST;this.host=t}else{if(exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT,e))return INVALID_HOST;for(t="",r=arrayFrom(e),n=0;n<r.length;n++)t+=percentEncode(r[n],C0ControlPercentEncodeSet);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return hasOwn$5(specialSchemes,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&isWindowsDriveLetter(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,a=e.host,i=e.port,s=e.path,o=e.query,l=e.fragment,c=t+":";return null!==a?(c+="//",e.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=serializeHost(a),null!==i&&(c+=":"+i)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+join(s,"/"):"",null!==o&&(c+="?"+o),null!==l&&(c+="#"+l),c},setHref:function(e){var t=this.parse(e);if(t)throw TypeError$1(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new URLConstructor(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+serializeHost(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse($toString(e)+":",SCHEME_START)},getUsername:function(){return this.username},setUsername:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=percentEncode(t[r],userinfoPercentEncodeSet)}},getPassword:function(){return this.password},setPassword:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=percentEncode(t[r],userinfoPercentEncodeSet)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?serializeHost(e):serializeHost(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,HOST)},getHostname:function(){var e=this.host;return null===e?"":serializeHost(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,HOSTNAME)},getPort:function(){var e=this.port;return null===e?"":$toString(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=$toString(e))?this.port=null:this.parse(e,PORT))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+join(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,PATH_START))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=$toString(e))?this.query=null:("?"==charAt(e,0)&&(e=stringSlice$1(e,1)),this.query="",this.parse(e,QUERY)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=$toString(e))?("#"==charAt(e,0)&&(e=stringSlice$1(e,1)),this.fragment="",this.parse(e,FRAGMENT)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var URLConstructor=function(e){var t=anInstance$2(this,URLPrototype),r=validateArgumentsLength$1(arguments.length,1)>1?arguments[1]:void 0,n=setInternalState$2(t,new URLState(e,!1,r));DESCRIPTORS$2||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},URLPrototype=URLConstructor.prototype,accessorDescriptor=function(e,t){return{get:function(){return getInternalURLState(this)[e]()},set:t&&function(e){return getInternalURLState(this)[t](e)},configurable:!0,enumerable:!0}};if(DESCRIPTORS$2&&(defineBuiltInAccessor$1(URLPrototype,"href",accessorDescriptor("serialize","setHref")),defineBuiltInAccessor$1(URLPrototype,"origin",accessorDescriptor("getOrigin")),defineBuiltInAccessor$1(URLPrototype,"protocol",accessorDescriptor("getProtocol","setProtocol")),defineBuiltInAccessor$1(URLPrototype,"username",accessorDescriptor("getUsername","setUsername")),defineBuiltInAccessor$1(URLPrototype,"password",accessorDescriptor("getPassword","setPassword")),defineBuiltInAccessor$1(URLPrototype,"host",accessorDescriptor("getHost","setHost")),defineBuiltInAccessor$1(URLPrototype,"hostname",accessorDescriptor("getHostname","setHostname")),defineBuiltInAccessor$1(URLPrototype,"port",accessorDescriptor("getPort","setPort")),defineBuiltInAccessor$1(URLPrototype,"pathname",accessorDescriptor("getPathname","setPathname")),defineBuiltInAccessor$1(URLPrototype,"search",accessorDescriptor("getSearch","setSearch")),defineBuiltInAccessor$1(URLPrototype,"searchParams",accessorDescriptor("getSearchParams")),defineBuiltInAccessor$1(URLPrototype,"hash",accessorDescriptor("getHash","setHash"))),defineBuiltIn(URLPrototype,"toJSON",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),defineBuiltIn(URLPrototype,"toString",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),NativeURL){var nativeCreateObjectURL=NativeURL.createObjectURL,nativeRevokeObjectURL=NativeURL.revokeObjectURL;nativeCreateObjectURL&&defineBuiltIn(URLConstructor,"createObjectURL",bind$e(nativeCreateObjectURL,NativeURL)),nativeRevokeObjectURL&&defineBuiltIn(URLConstructor,"revokeObjectURL",bind$e(nativeRevokeObjectURL,NativeURL))}setToStringTag$1(URLConstructor,"URL"),$$W({global:!0,constructor:!0,forced:!USE_NATIVE_URL$1,sham:!DESCRIPTORS$2},{URL:URLConstructor});var $$V=_export,getBuiltIn$3=getBuiltIn$j,fails$4=fails$A,validateArgumentsLength=validateArgumentsLength$5,toString$2=toString$g,USE_NATIVE_URL=urlConstructorDetection,URL$1=getBuiltIn$3("URL"),THROWS_WITHOUT_ARGUMENTS=USE_NATIVE_URL&&fails$4((function(){URL$1.canParse()}));$$V({target:"URL",stat:!0,forced:!THROWS_WITHOUT_ARGUMENTS},{canParse:function(e){var t=validateArgumentsLength(arguments.length,1),r=toString$2(e),n=t<2||void 0===arguments[1]?void 0:toString$2(arguments[1]);try{return!!new URL$1(r,n)}catch(e){return!1}}});var path$7=path$y,url$5=path$7.URL,parent$O=url$5,url$4=parent$O,parent$N=url$4,url$3=parent$N,parent$M=url$3,url$2=parent$M,url$1=url$2,url=url$1,_URL=getDefaultExportFromCjs$1(url),path$6=path$y,apply$1=functionApply;path$6.JSON||(path$6.JSON={stringify:JSON.stringify});var stringify$5=function(e,t,r){return apply$1(path$6.JSON.stringify,null,arguments)},parent$L=stringify$5,stringify$4=parent$L,parent$K=stringify$4,stringify$3=parent$K,parent$J=stringify$3,stringify$2=parent$J,stringify$1=stringify$2,stringify2=stringify$1,_JSON$stringify=getDefaultExportFromCjs$1(stringify2),$$U=_export,uncurryThis$4=functionUncurryThisClause;objectGetOwnPropertyDescriptor.f;var toLength=toLength$3,toString$1=toString$g,notARegExp=notARegexp,requireObjectCoercible=requireObjectCoercible$8,correctIsRegExpLogic=correctIsRegexpLogic,nativeStartsWith=uncurryThis$4("".startsWith),stringSlice=uncurryThis$4("".slice),min$1=Math.min,CORRECT_IS_REGEXP_LOGIC=correctIsRegExpLogic("startsWith");$$U({target:"String",proto:!0,forced:!CORRECT_IS_REGEXP_LOGIC},{startsWith:function(e){var t=toString$1(requireObjectCoercible(this));notARegExp(e);var r=toLength(min$1(arguments.length>1?arguments[1]:void 0,t.length)),n=toString$1(e);return nativeStartsWith?nativeStartsWith(t,n,r):stringSlice(t,r,r+n.length)===n}});var entryVirtual$5=entryVirtual$n,startsWith$7=entryVirtual$5("String").startsWith,isPrototypeOf$7=objectIsPrototypeOf,method$5=startsWith$7,StringPrototype=String.prototype,startsWith$6=function(e){var t=e.startsWith;return"string"==typeof e||e===StringPrototype||isPrototypeOf$7(StringPrototype,e)&&t===StringPrototype.startsWith?method$5:t},parent$I=startsWith$6,startsWith$5=parent$I,parent$H=startsWith$5,startsWith$4=parent$H,parent$G=startsWith$4,startsWith$3=parent$G,startsWith$2=startsWith$3,startsWith$1=startsWith$2,_startsWithInstanceProperty=getDefaultExportFromCjs$1(startsWith$1),isObject$4=isObject$m,floor=Math.floor,isIntegralNumber$2=Number.isInteger||function(e){return!isObject$4(e)&&isFinite(e)&&floor(e)===e},$$T=_export,isIntegralNumber$1=isIntegralNumber$2;$$T({target:"Number",stat:!0},{isInteger:isIntegralNumber$1});var path$5=path$y,isInteger$5=path$5.Number.isInteger,parent$F=isInteger$5,isInteger$4=parent$F,parent$E=isInteger$4,isInteger$3=parent$E,parent$D=isInteger$3,isInteger$2=parent$D,isInteger$1=isInteger$2,isInteger2=isInteger$1,_Number$isInteger=getDefaultExportFromCjs$1(isInteger2);function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){var r;if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=_sliceInstanceProperty$1(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?_Array$from$1(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _createForOfIteratorHelper(e,t){var r=void 0!==_Symbol$1&&_getIteratorMethod$1(e)||e["@@iterator"];if(!r){if(_Array$isArray$1(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw i}}}}function _arrayWithoutHoles(e){if(_Array$isArray$1(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if(void 0!==_Symbol$1&&null!=_getIteratorMethod$1(e)||null!=e["@@iterator"])return _Array$from$1(e)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithHoles(e){if(_Array$isArray$1(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:void 0!==_Symbol$1&&_getIteratorMethod$1(e)||e["@@iterator"];if(null!=r){var n,a,i,s,o=[],l=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(_pushInstanceProperty(o).call(o,n.value),o.length!==t);l=!0);}catch(e){c=!0,a=e}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}var internalMetadata={exports:{}},fails$3=fails$A,arrayBufferNonExtensible=fails$3((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fails$2=fails$A,isObject$3=isObject$m,classof$3=classofRaw$2,ARRAY_BUFFER_NON_EXTENSIBLE=arrayBufferNonExtensible,$isExtensible=Object.isExtensible,FAILS_ON_PRIMITIVES=fails$2((function(){$isExtensible(1)})),objectIsExtensible=FAILS_ON_PRIMITIVES||ARRAY_BUFFER_NON_EXTENSIBLE?function(e){return!!isObject$3(e)&&((!ARRAY_BUFFER_NON_EXTENSIBLE||"ArrayBuffer"!=classof$3(e))&&(!$isExtensible||$isExtensible(e)))}:$isExtensible,fails$1=fails$A,freezing=!fails$1((function(){return Object.isExtensible(Object.preventExtensions({}))})),$$S=_export,uncurryThis$3=functionUncurryThis,hiddenKeys=hiddenKeys$6,isObject$2=isObject$m,hasOwn$4=hasOwnProperty_1,defineProperty$1=objectDefineProperty.f,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertyNamesExternalModule=objectGetOwnPropertyNamesExternal,isExtensible2=objectIsExtensible,uid=uid$4,FREEZING=freezing,REQUIRED=!1,METADATA=uid("meta"),id=0,setMetadata=function(e){defineProperty$1(e,METADATA,{value:{objectID:"O"+id++,weakData:{}}})},fastKey$1=function(e,t){if(!isObject$2(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!hasOwn$4(e,METADATA)){if(!isExtensible2(e))return"F";if(!t)return"E";setMetadata(e)}return e[METADATA].objectID},getWeakData=function(e,t){if(!hasOwn$4(e,METADATA)){if(!isExtensible2(e))return!0;if(!t)return!1;setMetadata(e)}return e[METADATA].weakData},onFreeze=function(e){return FREEZING&&REQUIRED&&isExtensible2(e)&&!hasOwn$4(e,METADATA)&&setMetadata(e),e},enable=function(){meta.enable=function(){},REQUIRED=!0;var e=getOwnPropertyNamesModule.f,t=uncurryThis$3([].splice),r={};r[METADATA]=1,e(r).length&&(getOwnPropertyNamesModule.f=function(r){for(var n=e(r),a=0,i=n.length;a<i;a++)if(n[a]===METADATA){t(n,a,1);break}return n},$$S({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:getOwnPropertyNamesExternalModule.f}))},meta=internalMetadata.exports={enable:enable,fastKey:fastKey$1,getWeakData:getWeakData,onFreeze:onFreeze};hiddenKeys[METADATA]=!0;var internalMetadataExports=internalMetadata.exports,$$R=_export,global$2=global$s,InternalMetadataModule=internalMetadataExports,fails=fails$A,createNonEnumerableProperty=createNonEnumerableProperty$9,iterate$o=iterate$u,anInstance$1=anInstance$5,isCallable$4=isCallable$r,isObject$1=isObject$m,setToStringTag=setToStringTag$9,defineProperty5=objectDefineProperty.f,forEach3=arrayIteration.forEach,DESCRIPTORS$1=descriptors,InternalStateModule$1=internalState,setInternalState$1=InternalStateModule$1.set,internalStateGetterFor$1=InternalStateModule$1.getterFor,collection$2=function(e,t,r){var n,a=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),s=a?"set":"add",o=global$2[e],l=o&&o.prototype,c={};if(DESCRIPTORS$1&&isCallable$4(o)&&(i||l.forEach&&!fails((function(){(new o).entries().next()})))){var u=(n=t((function(t,r){setInternalState$1(anInstance$1(t,u),{type:e,collection:new o}),null!=r&&iterate$o(r,t[s],{that:t,AS_ENTRIES:a})}))).prototype,d=internalStateGetterFor$1(e);forEach3(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in l)||i&&"clear"==e||createNonEnumerableProperty(u,e,(function(r,n){var a=d(this).collection;if(!t&&i&&!isObject$1(r))return"get"==e&&void 0;var s=a[e](0===r?0:r,n);return t?this:s}))})),i||defineProperty5(u,"size",{configurable:!0,get:function(){return d(this).collection.size}})}else n=r.getConstructor(t,e,a,s),InternalMetadataModule.enable();return setToStringTag(n,e,!1,!0),c[e]=n,$$R({global:!0,forced:!0},c),i||r.setStrong(n,e,a),n},create4=objectCreate,defineBuiltInAccessor=defineBuiltInAccessor$5,defineBuiltIns=defineBuiltIns$2,bind$d=functionBindContext,anInstance=anInstance$5,isNullOrUndefined$2=isNullOrUndefined$7,iterate$n=iterate$u,defineIterator=iteratorDefine,createIterResultObject=createIterResultObject$3,setSpecies=setSpecies$2,DESCRIPTORS=descriptors,fastKey=internalMetadataExports.fastKey,InternalStateModule=internalState,setInternalState=InternalStateModule.set,internalStateGetterFor=InternalStateModule.getterFor,collectionStrong$2={getConstructor:function(e,t,r,n){var a=e((function(e,a){anInstance(e,i),setInternalState(e,{type:t,index:create4(null),first:void 0,last:void 0,size:0}),DESCRIPTORS||(e.size=0),isNullOrUndefined$2(a)||iterate$n(a,e[n],{that:e,AS_ENTRIES:r})})),i=a.prototype,s=internalStateGetterFor(t),o=function(e,t,r){var n,a,i=s(e),o=l(e,t);return o?o.value=r:(i.last=o={index:a=fastKey(t,!0),key:t,value:r,previous:n=i.last,next:void 0,removed:!1},i.first||(i.first=o),n&&(n.next=o),DESCRIPTORS?i.size++:e.size++,"F"!==a&&(i.index[a]=o)),e},l=function(e,t){var r,n=s(e),a=fastKey(t);if("F"!==a)return n.index[a];for(r=n.first;r;r=r.next)if(r.key==t)return r};return defineBuiltIns(i,{clear:function(){for(var e=s(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,DESCRIPTORS?e.size=0:this.size=0},delete:function(e){var t=this,r=s(t),n=l(t,e);if(n){var a=n.next,i=n.previous;delete r.index[n.index],n.removed=!0,i&&(i.next=a),a&&(a.previous=i),r.first==n&&(r.first=a),r.last==n&&(r.last=i),DESCRIPTORS?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=s(this),n=bind$d(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!l(this,e)}}),defineBuiltIns(i,r?{get:function(e){var t=l(this,e);return t&&t.value},set:function(e,t){return o(this,0===e?0:e,t)}}:{add:function(e){return o(this,e=0===e?0:e,e)}}),DESCRIPTORS&&defineBuiltInAccessor(i,"size",{configurable:!0,get:function(){return s(this).size}}),a},setStrong:function(e,t,r){var n=t+" Iterator",a=internalStateGetterFor(t),i=internalStateGetterFor(n);defineIterator(e,t,(function(e,t){setInternalState(this,{type:n,target:e,state:a(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?createIterResultObject("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,createIterResultObject(void 0,!0))}),r?"entries":"values",!r,!0),setSpecies(t)}},collection$1=collection$2,collectionStrong$1=collectionStrong$2;collection$1("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong$1);var path$4=path$y,map$5=path$4.Map,parent$C=map$5,map$4=parent$C,parent$B=map$4,map$3=parent$B,bind$c=functionBindContext,call$d=functionCall,aCallable$8=aCallable$l,aConstructor=aConstructor$3,isNullOrUndefined$1=isNullOrUndefined$7,iterate$m=iterate$u,push$3=[].push,collectionFrom=function(e){var t,r,n,a,i=arguments.length,s=i>1?arguments[1]:void 0;return aConstructor(this),(t=void 0!==s)&&aCallable$8(s),isNullOrUndefined$1(e)?new this:(r=[],t?(n=0,a=bind$c(s,i>2?arguments[2]:void 0),iterate$m(e,(function(e){call$d(push$3,r,a(e,n++))}))):iterate$m(e,push$3,{that:r}),new this(r))},$$Q=_export,from$1=collectionFrom;$$Q({target:"Map",stat:!0,forced:!0},{from:from$1});var arraySlice=arraySlice$7,collectionOf=function(){return new this(arraySlice(arguments))},$$P=_export,of$1=collectionOf;$$P({target:"Map",stat:!0,forced:!0},{of:of$1});var tryToString$1=tryToString$8,aMap$e=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"get"in e&&"set"in e&&"delete"in e&&"entries"in e)return e;throw TypeError(tryToString$1(e)+" is not a map")},caller$2=function(e,t){return 1==t?function(t,r){return t[e](r)}:function(t,r,n){return t[e](r,n)}},getBuiltIn$2=getBuiltIn$j,caller$1=caller$2,Map$5=getBuiltIn$2("Map"),mapHelpers={Map:Map$5,set:caller$1("set",2),get:caller$1("get",1),has:caller$1("has",1),remove:caller$1("delete",1),proto:Map$5.prototype},$$O=_export,aMap$d=aMap$e,remove$3=mapHelpers.remove;$$O({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=aMap$d(this),r=!0,n=0,a=arguments.length;n<a;n++)e=remove$3(t,arguments[n]),r=r&&e;return!!r}});var $$N=_export,aMap$c=aMap$e,MapHelpers$4=mapHelpers,get$1=MapHelpers$4.get,has$6=MapHelpers$4.has,set$b=MapHelpers$4.set;$$N({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,a=aMap$c(this);return has$6(a,e)?(r=get$1(a,e),"update"in t&&(r=t.update(r,e,a),set$b(a,e,r)),r):(n=t.insert(e,a),set$b(a,e,n),n)}});var call$c=functionCall,iterateSimple$8=function(e,t,r){for(var n,a,i=r||e.next;!(n=call$c(i,e)).done;)if(void 0!==(a=t(n.value)))return a},iterateSimple$7=iterateSimple$8,mapIterate=function(e,t,r){return r?iterateSimple$7(e.entries(),(function(e){return t(e[1],e[0])})):e.forEach(t)},$$M=_export,bind$b=functionBindContext,aMap$b=aMap$e,iterate$l=mapIterate;$$M({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=aMap$b(this),r=bind$b(e,arguments.length>1?arguments[1]:void 0);return!1!==iterate$l(t,(function(e,n){if(!r(e,n,t))return!1}),!0)}});var $$L=_export,bind$a=functionBindContext,aMap$a=aMap$e,MapHelpers$3=mapHelpers,iterate$k=mapIterate,Map$4=MapHelpers$3.Map,set$a=MapHelpers$3.set;$$L({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=aMap$a(this),r=bind$a(e,arguments.length>1?arguments[1]:void 0),n=new Map$4;return iterate$k(t,(function(e,a){r(e,a,t)&&set$a(n,a,e)})),n}});var $$K=_export,bind$9=functionBindContext,aMap$9=aMap$e,iterate$j=mapIterate;$$K({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=aMap$9(this),r=bind$9(e,arguments.length>1?arguments[1]:void 0),n=iterate$j(t,(function(e,n){if(r(e,n,t))return{value:e}}),!0);return n&&n.value}});var $$J=_export,bind$8=functionBindContext,aMap$8=aMap$e,iterate$i=mapIterate;$$J({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=aMap$8(this),r=bind$8(e,arguments.length>1?arguments[1]:void 0),n=iterate$i(t,(function(e,n){if(r(e,n,t))return{key:n}}),!0);return n&&n.key}});var $$I=_export,call$b=functionCall,uncurryThis$2=functionUncurryThis,isCallable$3=isCallable$r,aCallable$7=aCallable$l,iterate$h=iterate$u,Map$3=mapHelpers.Map,push$2=uncurryThis$2([].push);$$I({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){var r=new(isCallable$3(this)?this:Map$3);aCallable$7(t);var n=aCallable$7(r.has),a=aCallable$7(r.get),i=aCallable$7(r.set);return iterate$h(e,(function(e){var s=t(e);call$b(n,r,s)?push$2(call$b(a,r,s),e):call$b(i,r,s,[e])})),r}});var sameValueZero$1=function(e,t){return e===t||e!=e&&t!=t},$$H=_export,sameValueZero=sameValueZero$1,aMap$7=aMap$e,iterate$g=mapIterate;$$H({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===iterate$g(aMap$7(this),(function(t){if(sameValueZero(t,e))return!0}),!0)}});var $$G=_export,call$a=functionCall,iterate$f=iterate$u,isCallable$2=isCallable$r,aCallable$6=aCallable$l,Map$2=mapHelpers.Map;$$G({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(isCallable$2(this)?this:Map$2);aCallable$6(t);var n=aCallable$6(r.set);return iterate$f(e,(function(e){call$a(n,r,t(e),e)})),r}});var $$F=_export,aMap$6=aMap$e,iterate$e=mapIterate;$$F({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=iterate$e(aMap$6(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var $$E=_export,bind$7=functionBindContext,aMap$5=aMap$e,MapHelpers$2=mapHelpers,iterate$d=mapIterate,Map$1=MapHelpers$2.Map,set$9=MapHelpers$2.set;$$E({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=aMap$5(this),r=bind$7(e,arguments.length>1?arguments[1]:void 0),n=new Map$1;return iterate$d(t,(function(e,a){set$9(n,r(e,a,t),e)})),n}});var $$D=_export,bind$6=functionBindContext,aMap$4=aMap$e,MapHelpers$1=mapHelpers,iterate$c=mapIterate,Map=MapHelpers$1.Map,set$8=MapHelpers$1.set;$$D({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=aMap$4(this),r=bind$6(e,arguments.length>1?arguments[1]:void 0),n=new Map;return iterate$c(t,(function(e,a){set$8(n,a,r(e,a,t))})),n}});var $$C=_export,aMap$3=aMap$e,iterate$b=iterate$u,set$7=mapHelpers.set;$$C({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=aMap$3(this),r=arguments.length,n=0;n<r;)iterate$b(arguments[n++],(function(e,r){set$7(t,e,r)}),{AS_ENTRIES:!0});return t}});var $$B=_export,aCallable$5=aCallable$l,aMap$2=aMap$e,iterate$a=mapIterate,$TypeError$5=TypeError;$$B({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=aMap$2(this),r=arguments.length<2,n=r?void 0:arguments[1];if(aCallable$5(e),iterate$a(t,(function(a,i){r?(r=!1,n=a):n=e(n,a,i,t)})),r)throw $TypeError$5("Reduce of empty map with no initial value");return n}});var $$A=_export,bind$5=functionBindContext,aMap$1=aMap$e,iterate$9=mapIterate;$$A({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=aMap$1(this),r=bind$5(e,arguments.length>1?arguments[1]:void 0);return!0===iterate$9(t,(function(e,n){if(r(e,n,t))return!0}),!0)}});var $$z=_export,aCallable$4=aCallable$l,aMap=aMap$e,MapHelpers=mapHelpers,$TypeError$4=TypeError,get2=MapHelpers.get,has$5=MapHelpers.has,set$6=MapHelpers.set;$$z({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=aMap(this),n=arguments.length;aCallable$4(t);var a=has$5(r,e);if(!a&&n<3)throw $TypeError$4("Updating absent value");var i=a?get2(r,e):aCallable$4(n>2?arguments[2]:void 0)(e,r);return set$6(r,e,t(i,e,r)),r}});var call$9=functionCall,aCallable$3=aCallable$l,isCallable$1=isCallable$r,anObject$2=anObject$i,$TypeError$3=TypeError,mapUpsert=function(e,t){var r,n=anObject$2(this),a=aCallable$3(n.get),i=aCallable$3(n.has),s=aCallable$3(n.set),o=arguments.length>2?arguments[2]:void 0;if(!isCallable$1(t)&&!isCallable$1(o))throw $TypeError$3("At least one callback required");return call$9(i,n,e)?(r=call$9(a,n,e),isCallable$1(t)&&(r=t(r),call$9(s,n,e,r))):isCallable$1(o)&&(r=o(),call$9(s,n,e,r)),r},$$y=_export,upsert$1=mapUpsert;$$y({target:"Map",proto:!0,real:!0,forced:!0},{upsert:upsert$1});var $$x=_export,upsert2=mapUpsert;$$x({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:upsert2});var parent$A=map$3,map$2=parent$A,map$1=map$2,_Map$1=getDefaultExportFromCjs$1(map$1);function _isNativeFunction(e){var t;return-1!==_indexOfInstanceProperty$1(t=Function.toString.call(e)).call(t,"[native code]")}function _construct(e,t,r){var n;_isNativeReflectConstruct()?_construct=_bindInstanceProperty$1(n=_Reflect$construct).call(n):_construct=function(e,t,r){var n=[null];_pushInstanceProperty(n).apply(n,t);var a=new(_bindInstanceProperty$1(Function).apply(e,n));return r&&_setPrototypeOf(a,r.prototype),a};return _construct.apply(null,arguments)}function _wrapNativeSuper(e){var t="function"==typeof _Map$1?new _Map$1:void 0;return _wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return r.prototype=_Object$create$1(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,e)},_wrapNativeSuper(e)}var global$1=global$s,globalIsFinite=global$1.isFinite,numberIsFinite$1=Number.isFinite||function(e){return"number"==typeof e&&globalIsFinite(e)},$$w=_export,numberIsFinite=numberIsFinite$1;$$w({target:"Number",stat:!0},{isFinite:numberIsFinite});var path$3=path$y,_isFinite$5=path$3.Number.isFinite,parent$z=_isFinite$5,_isFinite$4=parent$z,parent$y=_isFinite$4,_isFinite$3=parent$y,parent$x=_isFinite$3,_isFinite$2=parent$x,_isFinite$1=_isFinite$2,_isFinite=_isFinite$1,_Number$isFinite=getDefaultExportFromCjs$1(_isFinite),$$v=_export,isIntegralNumber=isIntegralNumber$2,abs=Math.abs;$$v({target:"Number",stat:!0},{isSafeInteger:function(e){return isIntegralNumber(e)&&abs(e)<=9007199254740991}});var path$2=path$y,isSafeInteger$6=path$2.Number.isSafeInteger,parent$w=isSafeInteger$6,isSafeInteger$5=parent$w,parent$v=isSafeInteger$5,isSafeInteger$4=parent$v,parent$u=isSafeInteger$4,isSafeInteger$3=parent$u,isSafeInteger$2=isSafeInteger$3,isSafeInteger$1=isSafeInteger$2,_Number$isSafeInteger=getDefaultExportFromCjs$1(isSafeInteger$1),$$u=_export;$$u({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var maxSafeInteger$5=9007199254740991,parent$t=maxSafeInteger$5,maxSafeInteger$4=parent$t,parent$s=maxSafeInteger$4,maxSafeInteger$3=parent$s,parent$r=maxSafeInteger$3,maxSafeInteger$2=parent$r,maxSafeInteger$1=maxSafeInteger$2,maxSafeInteger=maxSafeInteger$1,_Number$MAX_SAFE_INTEGER=getDefaultExportFromCjs$1(maxSafeInteger),aCallable$2=aCallable$l,toObject=toObject$d,IndexedObject=indexedObject,lengthOfArrayLike$1=lengthOfArrayLike$c,$TypeError$2=TypeError,createMethod=function(e){return function(t,r,n,a){aCallable$2(r);var i=toObject(t),s=IndexedObject(i),o=lengthOfArrayLike$1(i),l=e?o-1:0,c=e?-1:1;if(n<2)for(;;){if(l in s){a=s[l],l+=c;break}if(l+=c,e?l<0:o<=l)throw $TypeError$2("Reduce of empty array with no initial value")}for(;e?l>=0:o>l;l+=c)l in s&&(a=r(a,s[l],l,i));return a}},arrayReduce={left:createMethod(!1),right:createMethod(!0)},$$t=_export,$reduce=arrayReduce.left,arrayMethodIsStrict$1=arrayMethodIsStrict$7,CHROME_VERSION=engineV8Version,IS_NODE=engineIsNode,CHROME_BUG=!IS_NODE&&engineV8Version>79&&engineV8Version<83,FORCED$1=CHROME_BUG||!arrayMethodIsStrict$1("reduce");$$t({target:"Array",proto:!0,forced:FORCED$1},{reduce:function(e){var t=arguments.length;return $reduce(this,e,t,t>1?arguments[1]:void 0)}});var entryVirtual$4=entryVirtual$n,reduce$6=entryVirtual$4("Array").reduce,isPrototypeOf$6=objectIsPrototypeOf,method$4=reduce$6,ArrayPrototype$4=Array.prototype,reduce$5=function(e){var t=e.reduce;return e===ArrayPrototype$4||isPrototypeOf$6(ArrayPrototype$4,e)&&t===ArrayPrototype$4.reduce?method$4:t},parent$q=reduce$5,reduce$4=parent$q,parent$p=reduce$4,reduce$3=parent$p,parent$o=reduce$3,reduce$2=parent$o,reduce$1=reduce$2,reduce3=reduce$1,_reduceInstanceProperty=getDefaultExportFromCjs$1(reduce3),anObject$1=anObject$i,regexpFlags=function(){var e=anObject$1(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},call$8=functionCall,hasOwn$3=hasOwnProperty_1,isPrototypeOf$5=objectIsPrototypeOf,regExpFlags=regexpFlags,RegExpPrototype$1=RegExp.prototype,regexpGetFlags=function(e){var t=e.flags;return void 0!==t||"flags"in RegExpPrototype$1||hasOwn$3(e,"flags")||!isPrototypeOf$5(RegExpPrototype$1,e)?t:call$8(regExpFlags,e)},getRegExpFlags=regexpGetFlags,flags$6=getRegExpFlags,isPrototypeOf$4=objectIsPrototypeOf,flags$5=flags$6,RegExpPrototype=RegExp.prototype,flags_1=function(e){return e===RegExpPrototype||isPrototypeOf$4(RegExpPrototype,e)?flags$5(e):e.flags},parent$n=flags_1,flags$4=parent$n,parent$m=flags$4,flags$3=parent$m,parent$l=flags$3,flags$2=parent$l,flags$1=flags$2,flags=flags$1,_flagsInstanceProperty=getDefaultExportFromCjs$1(flags),apply=functionApply,toIndexedObject=toIndexedObject$c,toIntegerOrInfinity$1=toIntegerOrInfinity$7,lengthOfArrayLike=lengthOfArrayLike$c,arrayMethodIsStrict=arrayMethodIsStrict$7,min=Math.min,$lastIndexOf=[].lastIndexOf,NEGATIVE_ZERO=!!$lastIndexOf&&1/[1].lastIndexOf(1,-0)<0,STRICT_METHOD=arrayMethodIsStrict("lastIndexOf"),FORCED=NEGATIVE_ZERO||!STRICT_METHOD,arrayLastIndexOf=FORCED?function(e){if(NEGATIVE_ZERO)return apply($lastIndexOf,this,arguments)||0;var t=toIndexedObject(this),r=lengthOfArrayLike(t),n=r-1;for(arguments.length>1&&(n=min(n,toIntegerOrInfinity$1(arguments[1]))),n<0&&(n=r+n);n>=0;n--)if(n in t&&t[n]===e)return n||0;return-1}:$lastIndexOf,$$s=_export,lastIndexOf$7=arrayLastIndexOf;$$s({target:"Array",proto:!0,forced:arrayLastIndexOf!==[].lastIndexOf},{lastIndexOf:arrayLastIndexOf});var entryVirtual$3=entryVirtual$n,lastIndexOf$6=entryVirtual$3("Array").lastIndexOf,isPrototypeOf$3=objectIsPrototypeOf,method$3=lastIndexOf$6,ArrayPrototype$3=Array.prototype,lastIndexOf$5=function(e){var t=e.lastIndexOf;return e===ArrayPrototype$3||isPrototypeOf$3(ArrayPrototype$3,e)&&t===ArrayPrototype$3.lastIndexOf?method$3:t},parent$k=lastIndexOf$5,lastIndexOf$4=parent$k,parent$j=lastIndexOf$4,lastIndexOf$3=parent$j,parent$i=lastIndexOf$3,lastIndexOf$2=parent$i,lastIndexOf$1=lastIndexOf$2,lastIndexOf2=lastIndexOf$1,_lastIndexOfInstanceProperty=getDefaultExportFromCjs$1(lastIndexOf2),$$r=_export,uncurryThis$1=functionUncurryThis,isArray2=isArray$d,nativeReverse=uncurryThis$1([].reverse),test=[1,2];$$r({target:"Array",proto:!0,forced:String(test)===String(test.reverse())},{reverse:function(){return isArray2(this)&&(this.length=this.length),nativeReverse(this)}});var entryVirtual$2=entryVirtual$n,reverse$6=entryVirtual$2("Array").reverse,isPrototypeOf$2=objectIsPrototypeOf,method$2=reverse$6,ArrayPrototype$2=Array.prototype,reverse$5=function(e){var t=e.reverse;return e===ArrayPrototype$2||isPrototypeOf$2(ArrayPrototype$2,e)&&t===ArrayPrototype$2.reverse?method$2:t},parent$h=reverse$5,reverse$4=parent$h,parent$g=reverse$4,reverse$3=parent$g,parent$f=reverse$3,reverse$2=parent$f,reverse$1=reverse$2,reverse2=reverse$1,_reverseInstanceProperty=getDefaultExportFromCjs$1(reverse2),$$q=_export;$$q({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var epsilon$5=Math.pow(2,-52),parent$e=epsilon$5,epsilon$4=parent$e,parent$d=epsilon$4,epsilon$3=parent$d,parent$c=epsilon$3,epsilon$2=parent$c,epsilon$1=epsilon$2,epsilon=epsilon$1,_Number$EPSILON=getDefaultExportFromCjs$1(epsilon),map2=map$1,_Map=getDefaultExportFromCjs$1(map2),collection=collection$2,collectionStrong=collectionStrong$2;collection("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong);var path$1=path$y,set$5=path$1.Set,parent$b=set$5,set$4=parent$b,tryToString=tryToString$8,aSet$g=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"add"in e&&"delete"in e&&"keys"in e)return e;throw TypeError(tryToString(e)+" is not a set")},getBuiltIn$1=getBuiltIn$j,caller=caller$2,Set$5=getBuiltIn$1("Set"),SetPrototype=Set$5.prototype,setHelpers={Set:Set$5,add:caller("add",1),has:caller("has",1),remove:caller("delete",1),proto:SetPrototype},iterateSimple$6=iterateSimple$8,setIterate=function(e,t,r){return r?iterateSimple$6(e.keys(),t):e.forEach(t)},SetHelpers$5=setHelpers,iterate$8=setIterate,Set$4=SetHelpers$5.Set,add$6=SetHelpers$5.add,setClone=function(e){var t=new Set$4;return iterate$8(e,(function(e){add$6(t,e)})),t},setSize=function(e){return e.size},aCallable$1=aCallable$l,anObject=anObject$i,call$7=functionCall,toIntegerOrInfinity=toIntegerOrInfinity$7,$TypeError$1=TypeError,max=Math.max,SetRecord=function(e,t,r,n){this.set=e,this.size=t,this.has=r,this.keys=n};SetRecord.prototype={getIterator:function(){return anObject(call$7(this.keys,this.set))},includes:function(e){return call$7(this.has,this.set,e)}};var getSetRecord$7=function(e){anObject(e);var t=+e.size;if(t!=t)throw $TypeError$1("Invalid size");return new SetRecord(e,max(toIntegerOrInfinity(t),0),aCallable$1(e.has),aCallable$1(e.keys))},aSet$f=aSet$g,SetHelpers$4=setHelpers,clone$2=setClone,size$4=setSize,getSetRecord$6=getSetRecord$7,iterateSet$2=setIterate,iterateSimple$5=iterateSimple$8,has$4=SetHelpers$4.has,remove$2=SetHelpers$4.remove,setDifference=function(e){var t=aSet$f(this),r=getSetRecord$6(e),n=clone$2(t);return size$4(t)<=r.size?iterateSet$2(t,(function(e){r.includes(e)&&remove$2(n,e)})):iterateSimple$5(r.getIterator(),(function(e){has$4(t,e)&&remove$2(n,e)})),n},setMethodAcceptSetLike$7=function(){return!1},$$p=_export,difference2=setDifference,setMethodAcceptSetLike$6=setMethodAcceptSetLike$7;$$p({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$6()},{difference:difference2});var aSet$e=aSet$g,SetHelpers$3=setHelpers,size$3=setSize,getSetRecord$5=getSetRecord$7,iterateSet$1=setIterate,iterateSimple$4=iterateSimple$8,Set$3=SetHelpers$3.Set,add$5=SetHelpers$3.add,has$3=SetHelpers$3.has,setIntersection=function(e){var t=aSet$e(this),r=getSetRecord$5(e),n=new Set$3;return size$3(t)>r.size?iterateSimple$4(r.getIterator(),(function(e){has$3(t,e)&&add$5(n,e)})):iterateSet$1(t,(function(e){r.includes(e)&&add$5(n,e)})),n},$$o=_export,intersection$1=setIntersection,setMethodAcceptSetLike$5=setMethodAcceptSetLike$7,INCORRECT=!setMethodAcceptSetLike$5();$$o({target:"Set",proto:!0,real:!0,forced:INCORRECT},{intersection:intersection$1});var aSet$d=aSet$g,has$2=setHelpers.has,size$2=setSize,getSetRecord$4=getSetRecord$7,iterateSet=setIterate,iterateSimple$3=iterateSimple$8,iteratorClose$1=iteratorClose$4,setIsDisjointFrom=function(e){var t=aSet$d(this),r=getSetRecord$4(e);if(size$2(t)<=r.size)return!1!==iterateSet(t,(function(e){if(r.includes(e))return!1}),!0);var n=r.getIterator();return!1!==iterateSimple$3(n,(function(e){if(has$2(t,e))return iteratorClose$1(n,"normal",!1)}))},$$n=_export,isDisjointFrom2=setIsDisjointFrom,setMethodAcceptSetLike$4=setMethodAcceptSetLike$7;$$n({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$4()},{isDisjointFrom:isDisjointFrom2});var aSet$c=aSet$g,size$1=setSize,iterate$7=setIterate,getSetRecord$3=getSetRecord$7,setIsSubsetOf=function(e){var t=aSet$c(this),r=getSetRecord$3(e);return!(size$1(t)>r.size)&&!1!==iterate$7(t,(function(e){if(!r.includes(e))return!1}),!0)},$$m=_export,isSubsetOf2=setIsSubsetOf,setMethodAcceptSetLike$3=setMethodAcceptSetLike$7;$$m({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$3()},{isSubsetOf:isSubsetOf2});var aSet$b=aSet$g,has$1=setHelpers.has,size2=setSize,getSetRecord$2=getSetRecord$7,iterateSimple$2=iterateSimple$8,iteratorClose=iteratorClose$4,setIsSupersetOf=function(e){var t=aSet$b(this),r=getSetRecord$2(e);if(size2(t)<r.size)return!1;var n=r.getIterator();return!1!==iterateSimple$2(n,(function(e){if(!has$1(t,e))return iteratorClose(n,"normal",!1)}))},$$l=_export,isSupersetOf2=setIsSupersetOf,setMethodAcceptSetLike$2=setMethodAcceptSetLike$7;$$l({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$2()},{isSupersetOf:isSupersetOf2});var aSet$a=aSet$g,SetHelpers$2=setHelpers,clone$1=setClone,getSetRecord$1=getSetRecord$7,iterateSimple$1=iterateSimple$8,add$4=SetHelpers$2.add,has2=SetHelpers$2.has,remove$1=SetHelpers$2.remove,setSymmetricDifference=function(e){var t=aSet$a(this),r=getSetRecord$1(e).getIterator(),n=clone$1(t);return iterateSimple$1(r,(function(e){has2(t,e)?remove$1(n,e):add$4(n,e)})),n},$$k=_export,symmetricDifference2=setSymmetricDifference,setMethodAcceptSetLike$1=setMethodAcceptSetLike$7;$$k({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$1()},{symmetricDifference:symmetricDifference2});var aSet$9=aSet$g,add$3=setHelpers.add,clone=setClone,getSetRecord=getSetRecord$7,iterateSimple=iterateSimple$8,setUnion=function(e){var t=aSet$9(this),r=getSetRecord(e).getIterator(),n=clone(t);return iterateSimple(r,(function(e){add$3(n,e)})),n},$$j=_export,union2=setUnion,setMethodAcceptSetLike=setMethodAcceptSetLike$7;$$j({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike()},{union:union2});var parent$a=set$4,set$3=parent$a,$$i=_export,from3=collectionFrom;$$i({target:"Set",stat:!0,forced:!0},{from:from3});var $$h=_export,of2=collectionOf;$$h({target:"Set",stat:!0,forced:!0},{of:of2});var $$g=_export,aSet$8=aSet$g,add$2=setHelpers.add;$$g({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=aSet$8(this),t=0,r=arguments.length;t<r;t++)add$2(e,arguments[t]);return e}});var $$f=_export,aSet$7=aSet$g,remove=setHelpers.remove;$$f({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=aSet$7(this),r=!0,n=0,a=arguments.length;n<a;n++)e=remove(t,arguments[n]),r=r&&e;return!!r}});var $$e=_export,bind$4=functionBindContext,aSet$6=aSet$g,iterate$6=setIterate;$$e({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=aSet$6(this),r=bind$4(e,arguments.length>1?arguments[1]:void 0);return!1!==iterate$6(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var classof$2=classof$f,hasOwn$2=hasOwnProperty_1,isNullOrUndefined=isNullOrUndefined$7,wellKnownSymbol=wellKnownSymbol$r,Iterators=iterators,ITERATOR=wellKnownSymbol("iterator"),$Object=Object,isIterable$1=function(e){if(isNullOrUndefined(e))return!1;var t=$Object(e);return void 0!==t[ITERATOR]||"@@iterator"in t||hasOwn$2(Iterators,classof$2(t))},getBuiltIn=getBuiltIn$j,isCallable=isCallable$r,isIterable=isIterable$1,isObject=isObject$m,Set$2=getBuiltIn("Set"),isSetLike=function(e){return isObject(e)&&"number"==typeof e.size&&isCallable(e.has)&&isCallable(e.keys)},toSetLike$7=function(e){return isSetLike(e)?e:isIterable(e)?new Set$2(e):e},$$d=_export,call$6=functionCall,toSetLike$6=toSetLike$7,$difference=setDifference;$$d({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return call$6($difference,this,toSetLike$6(e))}});var $$c=_export,bind$3=functionBindContext,aSet$5=aSet$g,SetHelpers$1=setHelpers,iterate$5=setIterate,Set$1=SetHelpers$1.Set,add$1=SetHelpers$1.add;$$c({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=aSet$5(this),r=bind$3(e,arguments.length>1?arguments[1]:void 0),n=new Set$1;return iterate$5(t,(function(e){r(e,e,t)&&add$1(n,e)})),n}});var $$b=_export,bind$2=functionBindContext,aSet$4=aSet$g,iterate$4=setIterate;$$b({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=aSet$4(this),r=bind$2(e,arguments.length>1?arguments[1]:void 0),n=iterate$4(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return n&&n.value}});var $$a=_export,call$5=functionCall,toSetLike$5=toSetLike$7,$intersection=setIntersection;$$a({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return call$5($intersection,this,toSetLike$5(e))}});var $$9=_export,call$4=functionCall,toSetLike$4=toSetLike$7,$isDisjointFrom=setIsDisjointFrom;$$9({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return call$4($isDisjointFrom,this,toSetLike$4(e))}});var $$8=_export,call$3=functionCall,toSetLike$3=toSetLike$7,$isSubsetOf=setIsSubsetOf;$$8({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return call$3($isSubsetOf,this,toSetLike$3(e))}});var $$7=_export,call$2=functionCall,toSetLike$2=toSetLike$7,$isSupersetOf=setIsSupersetOf;$$7({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return call$2($isSupersetOf,this,toSetLike$2(e))}});var $$6=_export,uncurryThis=functionUncurryThis,aSet$3=aSet$g,iterate$3=setIterate,toString4=toString$g,arrayJoin=uncurryThis([].join),push$1=uncurryThis([].push);$$6({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=aSet$3(this),r=void 0===e?",":toString4(e),n=[];return iterate$3(t,(function(e){push$1(n,e)})),arrayJoin(n,r)}});var $$5=_export,bind$1=functionBindContext,aSet$2=aSet$g,SetHelpers=setHelpers,iterate$2=setIterate,Set=SetHelpers.Set,add=SetHelpers.add;$$5({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=aSet$2(this),r=bind$1(e,arguments.length>1?arguments[1]:void 0),n=new Set;return iterate$2(t,(function(e){add(n,r(e,e,t))})),n}});var $$4=_export,aCallable=aCallable$l,aSet$1=aSet$g,iterate$1=setIterate,$TypeError=TypeError;$$4({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=aSet$1(this),r=arguments.length<2,n=r?void 0:arguments[1];if(aCallable(e),iterate$1(t,(function(a){r?(r=!1,n=a):n=e(n,a,a,t)})),r)throw $TypeError("Reduce of empty set with no initial value");return n}});var $$3=_export,bind2=functionBindContext,aSet=aSet$g,iterate=setIterate;$$3({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=aSet(this),r=bind2(e,arguments.length>1?arguments[1]:void 0);return!0===iterate(t,(function(e){if(r(e,e,t))return!0}),!0)}});var $$2=_export,call$1=functionCall,toSetLike$1=toSetLike$7,$symmetricDifference=setSymmetricDifference;$$2({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return call$1($symmetricDifference,this,toSetLike$1(e))}});var $$1=_export,call=functionCall,toSetLike=toSetLike$7,$union=setUnion;$$1({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return call($union,this,toSetLike(e))}});var parent$9=set$3,set$2=parent$9,set$1=set$2,set2=set$1,_Set=getDefaultExportFromCjs$1(set2),$=_export,$entries=objectToArray.entries;$({target:"Object",stat:!0},{entries:function(e){return $entries(e)}});var _CmcdHeaderMap,path=path$y,entries$c=path.Object.entries,parent$8=entries$c,entries$b=parent$8,parent$7=entries$b,entries$a=parent$7,parent$6=entries$a,entries$9=parent$6,entries$8=entries$9,entries$7=entries$8,_Object$entries=getDefaultExportFromCjs$1(entries$7),entryVirtual$1=entryVirtual$n,entries$6=entryVirtual$1("Array").entries,parent$5=entries$6,entries$5=parent$5,classof$1=classof$f,hasOwn$1=hasOwnProperty_1,isPrototypeOf$1=objectIsPrototypeOf,method$1=entries$5,ArrayPrototype$1=Array.prototype,DOMIterables$1={DOMTokenList:!0,NodeList:!0},entries$4=function(e){var t=e.entries;return e===ArrayPrototype$1||isPrototypeOf$1(ArrayPrototype$1,e)&&t===ArrayPrototype$1.entries||hasOwn$1(DOMIterables$1,classof$1(e))?method$1:t},parent$4=entries$4,entries$3=parent$4,parent$3=entries$3,entries$2=parent$3,entries$1=entries$2,entries3=entries$1,_entriesInstanceProperty=getDefaultExportFromCjs$1(entries3),entryVirtual=entryVirtual$n,values$6=entryVirtual("Array").values,parent$2=values$6,values$5=parent$2,classof=classof$f,hasOwn2=hasOwnProperty_1,isPrototypeOf=objectIsPrototypeOf,method=values$5,ArrayPrototype=Array.prototype,DOMIterables={DOMTokenList:!0,NodeList:!0},values$4=function(e){var t=e.values;return e===ArrayPrototype||isPrototypeOf(ArrayPrototype,e)&&t===ArrayPrototype.values||hasOwn2(DOMIterables,classof(e))?method:t},parent$1=values$4,values$3=parent$1,parent=values$3,values$2=parent,values$1=values$2,values3=values$1,_valuesInstanceProperty=getDefaultExportFromCjs$1(values3),isFiniteNumber=_Number$isFinite||function(e){return"number"==typeof e&&isFinite(e)},isSafeInteger2=_Number$isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=MAX_SAFE_INTEGER},MAX_SAFE_INTEGER=_Number$MAX_SAFE_INTEGER||9007199254740991,ErrorTypes=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),ErrorDetails=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),Events=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),PlaylistContextType={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},PlaylistLevelType={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},EWMA=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;_classCallCheck$1(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=r,this.totalWeight_=n}return _createClass$1(e,[{key:"sample",value:function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}]),e}(),EwmaBandWidthEstimator=function(){function e(t,r,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;_classCallCheck$1(this,e),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new EWMA(t),this.fast_=new EWMA(r),this.defaultTTFB_=a,this.ttfb_=new EWMA(t)}return _createClass$1(e,[{key:"update",value:function(e,t){var r=this.slow_,n=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new EWMA(e,r.getEstimate(),r.getTotalWeight())),n.halfLife!==t&&(this.fast_=new EWMA(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new EWMA(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}]),e}();function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?_Object$defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _extends(){var e;return _extends=_Object$assign?_bindInstanceProperty(e=_Object$assign).call(e):function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}function ownKeys2(e,t){var r=_Object$keys(e);if(_Object$getOwnPropertySymbols){var n=_Object$getOwnPropertySymbols(e);t&&(n=_filterInstanceProperty(n).call(n,(function(t){return _Object$getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r,n,a=null!=arguments[t]?arguments[t]:{};t%2?_forEachInstanceProperty(r=ownKeys2(Object(a),!0)).call(r,(function(t){_defineProperty(e,t,a[t])})):_Object$getOwnPropertyDescriptors?_Object$defineProperties(e,_Object$getOwnPropertyDescriptors(a)):_forEachInstanceProperty(n=ownKeys2(Object(a))).call(n,(function(t){_Object$defineProperty(e,t,_Object$getOwnPropertyDescriptor(a,t))}))}return e}function _toPrimitive(e,t){if("object"!=_typeof$1(e)||!e)return e;var r=e[_Symbol$toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof$1(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof$1(t)?t:t+""}var Logger=_createClass$1((function e(t,r){var n,a,i,s,o;_classCallCheck$1(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var l="[".concat(t,"]:");this.trace=noop,this.debug=_bindInstanceProperty(n=r.debug).call(n,null,l),this.log=_bindInstanceProperty(a=r.log).call(a,null,l),this.warn=_bindInstanceProperty(i=r.warn).call(i,null,l),this.info=_bindInstanceProperty(s=r.info).call(s,null,l),this.error=_bindInstanceProperty(o=r.error).call(o,null,l)})),noop=function(){},fakeLogger={trace:noop,debug:noop,log:noop,warn:noop,info:noop,error:noop};function createLogger(){return _extends({},fakeLogger)}function consolePrintFn(e,t){var r,n=self.console[e];return n?_bindInstanceProperty(n).call(n,self.console,_concatInstanceProperty(r="".concat(t?"["+t+"] ":"","[")).call(r,e,"] >")):noop}function getLoggerFn(e,t,r){var n;return t[e]?_bindInstanceProperty(n=t[e]).call(n,t):consolePrintFn(e,r)}var exportedLogger=createLogger();function enableLogs(e,t,r){var n=createLogger();if("object"===("undefined"==typeof console?"undefined":_typeof$1(console))&&!0===e||"object"===_typeof$1(e)){var a=["debug","log","info","warn","error"];_forEachInstanceProperty(a).call(a,(function(t){n[t]=getLoggerFn(t,e,r)}));try{n.log('Debug logs enabled for "'.concat(t,'" in hls.js version ',"1.6.0-beta.2"))}catch(e){return createLogger()}_forEachInstanceProperty(a).call(a,(function(t){exportedLogger[t]=getLoggerFn(t,e)}))}else _extends(exportedLogger,n);return n}var logger=exportedLogger;function _getMediaSource2(){if("undefined"!=typeof self)return(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function isManagedMediaSource(e){return"undefined"!=typeof self&&e===self.ManagedMediaSource}function isCompatibleTrackChange(e,t){var r=_Object$keys(e),n=_Object$keys(t),a=r.length,i=n.length;return!a||!i||a===i&&!_someInstanceProperty(r).call(r,(function(e){return-1===_indexOfInstanceProperty(n).call(n,e)}))}var sampleEntryCodesISO={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function isCodecType(e,t){var r=sampleEntryCodesISO[t];return!!r&&!!r[_sliceInstanceProperty(e).call(e,0,4)]}function areCodecsMediaSourceSupported(e,t){var r,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!_someInstanceProperty(r=e.split(",")).call(r,(function(e){return!isCodecMediaSourceSupported(e,t,n)}))}function isCodecMediaSourceSupported(e,t){var r,n=_getMediaSource2(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);return null!=(r=null==n?void 0:n.isTypeSupported(mimeTypeForCodec(e,t)))&&r}function mimeTypeForCodec(e,t){var r;return _concatInstanceProperty(r="".concat(t,"/mp4;codecs=")).call(r,e)}function videoCodecPreferenceValue(e){if(e){var t=e.substring(0,4);return sampleEntryCodesISO.video[t]}return 2}function codecsSetSelectionPreferenceValue(e){var t;return _reduceInstanceProperty(t=e.split(",")).call(t,(function(e,t){var r=sampleEntryCodesISO.video[t];return r?(2*r+e)/(e?3:2):(sampleEntryCodesISO.audio[t]+e)/(e?2:1)}),0)}var CODEC_COMPATIBLE_NAMES={};function getCodecCompatibleNameLower(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(CODEC_COMPATIBLE_NAMES[e])return CODEC_COMPATIBLE_NAMES[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],n=0;n<r.length;n++){var a;if(isCodecMediaSourceSupported(r[n],"audio",t))return CODEC_COMPATIBLE_NAMES[e]=r[n],r[n];if("mp3"===r[n]&&null!=(a=_getMediaSource2(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}var AUDIO_CODEC_REGEXP=/flac|opus|mp4a\.40\.34/i;function getCodecCompatibleName(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(AUDIO_CODEC_REGEXP,(function(e){return getCodecCompatibleNameLower(e.toLowerCase(),t)}))}function pickMostCompleteCodecName(e,t){var r;if(e&&(e.length>4||-1!==_indexOfInstanceProperty(r=["ac-3","ec-3","alac","fLaC","Opus"]).call(r,e)))return e;if(t){var n=t.split(",");if(n.length>1){if(e)for(var a=n.length;a--;)if(n[a].substring(0,4)===e.substring(0,4))return n[a];return n[0]}}return t||e}function convertAVC1ToAVCOTI(e){for(var t=e.split(","),r=0;r<t.length;r++){var n=t[r].split(".");if(n.length>2){var a,i=n.shift()+".";i+=_parseInt$1(n.shift()).toString(16),i+=_sliceInstanceProperty(a="000"+_parseInt$1(n.shift()).toString(16)).call(a,-4),t[r]=i}}return t.join(",")}function fillInMissingAV01Params(e){if(_startsWithInstanceProperty(e).call(e,"av01.")){for(var t=e.split("."),r=["0","111","01","01","01","0"],n=t.length;n>4&&n<10;n++)t[n]=r[n-4];return t.join(".")}return e}function getM2TSSupportedAudioTypes(e){var t=_getMediaSource2(e)||{isTypeSupported:function(){return!1}};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}var SUPPORTED_INFO_DEFAULT={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},SUPPORTED_INFO_CACHE={};function requiresMediaCapabilitiesDecodingInfo(e,t,r,n,a,i){var s,o=e.audioCodec?e.audioGroups:null,l=null==i?void 0:i.audioCodec,c=null==i?void 0:i.channels,u=c?_parseInt$1(c):l?1/0:2,d=null;if(null!=o&&o.length)try{d=1===o.length&&o[0]?t.groups[o[0]].channels:_reduceInstanceProperty(o).call(o,(function(e,r){if(r){var n,a=t.groups[r];if(!a)throw new Error("Audio track group ".concat(r," not found"));_forEachInstanceProperty(n=_Object$keys(a.channels)).call(n,(function(t){e[t]=(e[t]||0)+a.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(n,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(a,8e6))||!!d&&isFiniteNumber(u)&&_someInstanceProperty(s=_Object$keys(d)).call(s,(function(e){return _parseInt$1(e)>u}))}function getMediaDecodingInfoPromise(e,t,r){var n=e.videoCodec,a=e.audioCodec;if(!n&&!a||!r)return _Promise.resolve(SUPPORTED_INFO_DEFAULT);var i,s=[];if(n){var o,l={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},c=e.videoRange;"SDR"!==c&&(l.transferFunction=c.toLowerCase()),s.push.apply(s,_mapInstanceProperty(o=n.split(",")).call(o,(function(e){return{type:"media-source",video:_objectSpread2(_objectSpread2({},l),{},{contentType:mimeTypeForCodec(fillInMissingAV01Params(e),"video")})}})))}a&&e.audioGroups&&_forEachInstanceProperty(i=e.audioGroups).call(i,(function(e){var r,n;e&&(null==(n=t.groups[e])||_forEachInstanceProperty(r=n.tracks).call(r,(function(t){if(t.groupId===e){var r,n=t.channels||"",i=_parseFloat$1(n);if(isFiniteNumber(i)&&i>2)s.push.apply(s,_mapInstanceProperty(r=a.split(",")).call(r,(function(e){return{type:"media-source",audio:{contentType:mimeTypeForCodec(e,"audio"),channels:""+i}}})))}})))}));return _Promise.all(_mapInstanceProperty(s).call(s,(function(e){var t=getMediaDecodingInfoKey(e);return SUPPORTED_INFO_CACHE[t]||(SUPPORTED_INFO_CACHE[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!_someInstanceProperty(e).call(e,(function(e){return!e.supported})),configurations:s,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}}))}function getMediaDecodingInfoKey(e){var t=e.audio,r=e.video,n=r||t;if(n){var a,i,s,o,l,c,u,d=n.contentType.split('"')[1];if(r)return _concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="r".concat(r.height,"x")).call(l,r.width,"f")).call(o,Math.ceil(r.framerate))).call(s,r.transferFunction||"sd","_")).call(i,d,"_")).call(a,Math.ceil(r.bitrate/1e5));if(t)return _concatInstanceProperty(c=_concatInstanceProperty(u="c".concat(t.channels)).call(u,t.spatialRendering?"s":"n","_")).call(c,d)}return""}var HdcpLevels=["NONE","TYPE-0","TYPE-1",null];function isHdcpLevel(e){return _indexOfInstanceProperty(HdcpLevels).call(HdcpLevels,e)>-1}var VideoRangeValues=["SDR","PQ","HLG"];function isVideoRange(e){return!!e&&_indexOfInstanceProperty(VideoRangeValues).call(VideoRangeValues,e)>-1}var HlsSkip={No:"",Yes:"YES",v2:"v2"};function getSkipValue(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,n=e.age;return t&&n<t/2?r?HlsSkip.v2:HlsSkip.Yes:HlsSkip.No}var HlsUrlParameters=function(){function e(t,r,n){_classCallCheck$1(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=r,this.skip=n}return _createClass$1(e,[{key:"addDirectives",value:function(e){var t=new _URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}]),e}(),Level=function(){function e(t){var r,n;_classCallCheck$1(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=_mapInstanceProperty(r=_filterInstanceProperty(n=[t.videoCodec,t.audioCodec]).call(n,(function(e){return!!e}))).call(r,(function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}return _createClass$1(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return hasGroup(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return hasGroup(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===_indexOfInstanceProperty(r).call(r,t)&&r.push(t)}else if("text"===e){var n=this._subtitleGroups;n||(n=this._subtitleGroups=[]),-1===_indexOfInstanceProperty(n).call(n,t)&&n.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}]),e}();function hasGroup(e,t){return!(!t||!e)&&-1!==_indexOfInstanceProperty(e).call(e,t)}function isHdrSupported(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}function getVideoSelectionOptions(e,t){var r=!1,n=[];if(e&&(r="SDR"!==e,n=[e]),t){var a="SDR"!==(n=t.allowedVideoRanges||_sliceInstanceProperty(VideoRangeValues).call(VideoRangeValues,0)).join("")&&!t.videoCodec;(r=void 0!==t.preferHDR?t.preferHDR:a&&isHdrSupported())||(n=["SDR"])}return{preferHDR:r,allowedVideoRanges:n}}function getStartCodecTier(e,t,r,n,a){for(var i=_Object$keys(e),s=null==n?void 0:n.channels,o=null==n?void 0:n.audioCodec,l=null==a?void 0:a.videoCodec,c=s&&2===_parseInt$1(s),u=!1,d=!1,f=1/0,h=1/0,p=1/0,y=1/0,g=0,v=[],m=getVideoSelectionOptions(t,a),E=m.preferHDR,$=m.allowedVideoRanges,S=function(){var t=e[i[T]];u||(u=t.channels[2]>0),f=Math.min(f,t.minHeight),h=Math.min(h,t.minFramerate),p=Math.min(p,t.minBitrate),_filterInstanceProperty($).call($,(function(e){return t.videoRanges[e]>0})).length>0&&(d=!0)},T=i.length;T--;)S();f=isFiniteNumber(f)?f:0,h=isFiniteNumber(h)?h:0;var I=Math.max(1080,f),_=Math.max(30,h);p=isFiniteNumber(p)?p:r,r=Math.max(p,r),d||(t=void 0);var P=i.length>1;return{codecSet:_reduceInstanceProperty(i).call(i,(function(t,n){var a=e[n];if(n===t)return t;if(v=d?_filterInstanceProperty($).call($,(function(e){return a.videoRanges[e]>0})):[],P){var i,f,h,p,m;if(a.minBitrate>r)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(i="min bitrate of ".concat(a.minBitrate," > current estimate of ")).call(i,r)),t;if(!a.hasDefaultAudio)return logStartCodecCandidateIgnored(n,"no renditions with default or auto-select sound found"),t;if(o&&_indexOfInstanceProperty(n).call(n,o.substring(0,4))%5!=0)return logStartCodecCandidateIgnored(n,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!c){if(!a.channels[s])return logStartCodecCandidateIgnored(n,_concatInstanceProperty(f="no renditions with ".concat(s," channel sound found (channels options: ")).call(f,_Object$keys(a.channels),")")),t}else if((!o||c)&&u&&0===a.channels[2])return logStartCodecCandidateIgnored(n,"no renditions with stereo sound found"),t;if(a.minHeight>I)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(h="min resolution of ".concat(a.minHeight," > maximum of ")).call(h,I)),t;if(a.minFramerate>_)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(p="min framerate of ".concat(a.minFramerate," > maximum of ")).call(p,_)),t;if(!_someInstanceProperty(v).call(v,(function(e){return a.videoRanges[e]>0})))return logStartCodecCandidateIgnored(n,"no variants with VIDEO-RANGE of ".concat(_JSON$stringify(v)," found")),t;if(l&&_indexOfInstanceProperty(n).call(n,l.substring(0,4))%5!=0)return logStartCodecCandidateIgnored(n,'video codec preference "'.concat(l,'" not found')),t;if(a.maxScore<g)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(m="max score of ".concat(a.maxScore," < selected max of ")).call(m,g)),t}return t&&(codecsSetSelectionPreferenceValue(n)>=codecsSetSelectionPreferenceValue(t)||a.fragmentError>e[t].fragmentError)?t:(y=a.minIndex,g=a.maxScore,n)}),void 0),videoRanges:v,preferHDR:E,minFramerate:h,minBitrate:p,minIndex:y}}function logStartCodecCandidateIgnored(e,t){var r;logger.log(_concatInstanceProperty(r='[abr] start candidates with "'.concat(e,'" ignored because ')).call(r,t))}function getAudioTracksByGroup(e){return _reduceInstanceProperty(e).call(e,(function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var n=t.channels||"2";return r.channels[n]=(r.channels[n]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function getCodecTiers(e,t,r,n){var a;return _reduceInstanceProperty(a=_sliceInstanceProperty(e).call(e,r,n+1)).call(a,(function(e,r,n){if(!r.codecSet)return e;var a=r.audioGroups,i=e[r.codecSet];i||(e[r.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),i.minBitrate=Math.min(i.minBitrate,r.bitrate);var s=Math.min(r.height,r.width);return i.minHeight=Math.min(i.minHeight,s),i.minFramerate=Math.min(i.minFramerate,r.frameRate),i.minIndex=Math.min(i.minIndex,n),i.maxScore=Math.max(i.maxScore,r.score),i.fragmentError+=r.fragmentError,i.videoRanges[r.videoRange]=(i.videoRanges[r.videoRange]||0)+1,a&&_forEachInstanceProperty(a).call(a,(function(e){var r;if(e){var n=t.groups[e];n&&(i.hasDefaultAudio=i.hasDefaultAudio||t.hasDefaultAudio?n.hasDefault:n.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,_forEachInstanceProperty(r=_Object$keys(n.channels)).call(r,(function(e){i.channels[e]=(i.channels[e]||0)+n.channels[e]})))}})),e}),{})}function getBasicSelectionOption(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function findMatchingOption(e,t,r){if("attrs"in e){var n=_indexOfInstanceProperty(t).call(t,e);if(-1!==n)return n}for(var a=0;a<t.length;a++){if(matchesOption(e,t[a],r))return a}return-1}function matchesOption(e,t,r){var n=e.groupId,a=e.name,i=e.lang,s=e.assocLang,o=e.characteristics,l=e.default,c=e.forced;return(void 0===n||t.groupId===n)&&(void 0===a||t.name===a)&&(void 0===i||languagesMatch(i,t.lang))&&(void 0===i||t.assocLang===s)&&(void 0===l||t.default===l)&&(void 0===c||t.forced===c)&&(void 0===o||characteristicsMatch(o,t.characteristics))&&(void 0===r||r(e,t))}function languagesMatch(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--";return e.length===t.length?e===t:_startsWithInstanceProperty(e).call(e,t)||_startsWithInstanceProperty(t).call(t,e)}function characteristicsMatch(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),n=t.split(",");return r.length===n.length&&!_someInstanceProperty(r).call(r,(function(e){return-1===_indexOfInstanceProperty(n).call(n,e)}))}function audioMatchPredicate(e,t){var r=e.audioCodec,n=e.channels;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==n&&n!==(t.channels||"2"))}function findClosestLevelWithAudioGroup(e,t,r,n,a){var i=t[n],s=_reduceInstanceProperty(t).call(t,(function(e,t,r){var n=t.uri;return(e[n]||(e[n]=[])).push(r),e}),{})[i.uri];s.length>1&&(n=Math.max.apply(Math,s));var o=i.videoRange,l=i.frameRate,c=i.codecSet.substring(0,4),u=searchDownAndUpList(t,n,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==c)return!1;var n=t.audioGroups,i=_filterInstanceProperty(r).call(r,(function(e){return!n||-1!==_indexOfInstanceProperty(n).call(n,e.groupId)}));return findMatchingOption(e,i,a)>-1}));return u>-1?u:searchDownAndUpList(t,n,(function(t){var n=t.audioGroups,i=_filterInstanceProperty(r).call(r,(function(e){return!n||-1!==_indexOfInstanceProperty(n).call(n,e.groupId)}));return findMatchingOption(e,i,a)>-1}))}function searchDownAndUpList(e,t,r){for(var n=t;n>-1;n--)if(r(e[n]))return n;for(var a=t+1;a<e.length;a++)if(r(e[a]))return a;return-1}function useAlternateAudio(e,t){var r;return!!e&&e!==(null==(r=t.levels[t.loadLevel])?void 0:r.uri)}var AbrController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"abr",e.logger)).hls=void 0,n.lastLevelLoadSec=0,n.lastLoadedFragLevel=-1,n.firstSelection=-1,n._nextAutoLevel=-1,n.nextAutoLevelKey="",n.audioTracksByGroup=null,n.codecTiers=null,n.timer=-1,n.fragCurrent=null,n.partCurrent=null,n.bitrateTestDelay=0,n.bwEstimator=void 0,n._abandonRulesCheck=function(){var e,t,r,a,i,s,o,l,c,u,d,f,h=_assertThisInitialized(n),p=h.fragCurrent,y=h.partCurrent,g=h.hls,v=g.autoLevelEnabled,m=g.media;if(p&&m){var E=performance.now(),$=y?y.stats:p.stats,S=y?y.duration:p.duration,T=E-$.loading.start,I=g.minAutoLevel;if($.aborted||$.loaded&&$.loaded===$.total||p.level<=I)return n.clearTimer(),void(n._nextAutoLevel=-1);if(v&&!m.paused&&m.playbackRate&&m.readyState){var _=g.mainForwardBufferInfo;if(null!==_){var P=n.bwEstimator.getEstimateTTFB(),b=Math.abs(m.playbackRate);if(!(T<=Math.max(P,S/(2*b)*1e3))){var A=_.len/b,R=$.loading.first?$.loading.first-$.loading.start:-1,k=$.loaded&&R>-1,C=n.getBwEstimate(),O=g.levels,L=O[p.level],D=Math.max($.loaded,Math.round(S*(p.bitrate||L.averageBitrate)/8)),w=k?T-R:T;w<1&&k&&(w=Math.min(T,8*$.loaded/C));var M=k?1e3*$.loaded/w:0,x=P/1e3,N=M?(D-$.loaded)/M:8*D/C+x;if(!(N<=A)){var F,U=M?8*M:C,B=!0===(null==(f=n.hls.latestLevelDetails)?void 0:f.live),j=n.hls.config.abrBandWidthUpFactor,G=Number.POSITIVE_INFINITY;for(F=p.level-1;F>I;F--){var H=O[F].maxBitrate,K=!O[F].details||B;if((G=n.getTimeToLoadFrag(x,U,S*H,K))<Math.min(A,S+x))break}if(!(G>=N||G>10*S)){k?n.bwEstimator.sample(T-Math.min(P,R),$.loaded):n.bwEstimator.sampleTTFB(T);var V=O[F].maxBitrate;n.getBwEstimate()*j>V&&n.resetEstimator(V);var W=n.findBestLevel(V,I,F,0,A,1,1);W>-1&&(F=W),n.warn(_concatInstanceProperty(e=_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l=_concatInstanceProperty(c=_concatInstanceProperty(u=_concatInstanceProperty(d="Fragment ".concat(p.sn)).call(d,y?" part "+y.index:""," of level ")).call(u,p.level," is loading too slowly;\n Fragment duration: ")).call(c,p.duration.toFixed(3),"\n Time to underbuffer: ")).call(l,A.toFixed(3)," s\n Estimated load time for current fragment: ")).call(o,N.toFixed(3)," s\n Estimated load time for down switch fragment: ")).call(s,G.toFixed(3)," s\n TTFB estimate: ")).call(i,0|R," ms\n Current BW estimate: ")).call(a,isFiniteNumber(C)?0|C:"Unknown"," bps\n New BW estimate: ")).call(r,0|n.getBwEstimate()," bps\n Switching to level ")).call(t,F," @ ")).call(e,0|V," bps")),g.nextLoadLevel=g.nextAutoLevel=F,n.clearTimer(),n.timer=_setInterval((function(){if(n.clearTimer(),n.fragCurrent===p&&n.hls.loadLevel===F&&F>0){var e,t,r=n.getStarvationDelay();if(n.warn(_concatInstanceProperty(e=_concatInstanceProperty(t="Aborting inflight request ".concat(F>0?"and switching down":"","\n Fragment duration: ")).call(t,p.duration.toFixed(3)," s\n Time to underbuffer: ")).call(e,r.toFixed(3)," s")),p.abortRequests(),n.fragCurrent=n.partCurrent=null,F>I){var a=n.findBestLevel(n.hls.levels[I].bitrate,I,F,0,r,1,1);-1===a&&(a=I),n.hls.nextLoadLevel=n.hls.nextAutoLevel=a,n.resetEstimator(n.hls.levels[a].bitrate)}}}),1e3*G),g.trigger(Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:p,part:y,stats:$})}}}}}}},n.hls=e,n.bwEstimator=n.initEstimator(),n.registerListeners(),n}return _createClass$1(r,[{key:"resetEstimator",value:function(e){e&&(this.log("setting initial bwe to ".concat(e)),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new EwmaBandWidthEstimator(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.FRAG_LOADING,this.onFragLoading,this),e.on(Events.FRAG_LOADED,this.onFragLoaded,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.FRAG_LOADING,this.onFragLoading,this),e.off(Events.FRAG_LOADED,this.onFragLoaded,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Events.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){var n;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(n=t.part)?n:null;this.clearTimer(),this.timer=_setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case ErrorDetails.BUFFER_ADD_CODEC_ERROR:case ErrorDetails.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case ErrorDetails.FRAG_LOAD_TIMEOUT:var r=t.frag,n=this.fragCurrent,a=this.partCurrent;if(r&&n&&r.sn===n.sn&&r.level===n.level){var i=performance.now(),s=a?a.stats:r.stats,o=i-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(c,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}}},{key:"getTimeToLoadFrag",value:function(e,t,r,n){return e+r/t+(n?this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var r=this.hls.config,n=t.stats.loading,a=n.end-n.start;isFiniteNumber(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,n=t.part,a=n?n.stats:r.stats;if(r.type===PlaylistLevelType.MAIN&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var i=n?n.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+a.loaded,l=(s.loaded?s.loaded.duration:0)+i;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var c={stats:a,frag:r,part:n,id:r.type};this.onFragBuffered(Events.FRAG_BUFFERED,c),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,n=t.part,a=null!=n&&n.stats.loaded?n.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var i=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(i,a.loaded),a.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==PlaylistLevelType.MAIN||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e,t=this.hls,r=t.maxAutoLevel,n=t.minAutoLevel,a=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,s=this.findBestLevel(a,n,r,0,i,1,1);if(s>-1)return s;var o=this.hls.firstLevel,l=Math.min(Math.max(o,n),r);return this.warn(_concatInstanceProperty(e="Could not find best starting auto level. Defaulting to first in playlist ".concat(o," clamped to ")).call(e,l)),l}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var n=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function(e){var t=this.hls,r=t.maxAutoLevel,n=t.minAutoLevel,a=Math.min(Math.max(e,n),r);this._nextAutoLevel!==a&&(this.nextAutoLevelKey="",this._nextAutoLevel=a)}},{key:"getAutoLevelKey",value:function(){var e;return _concatInstanceProperty(e="".concat(this.getBwEstimate(),"_")).call(e,this.getStarvationDelay().toFixed(2))}},{key:"getNextABRAutoLevel",value:function(){var e,t=this.fragCurrent,r=this.partCurrent,n=this.hls;if(n.levels.length<=1)return n.loadLevel;var a=n.maxAutoLevel,i=n.config,s=n.minAutoLevel,o=r?r.duration:t?t.duration:0,l=this.getBwEstimate(),c=this.getStarvationDelay(),u=i.abrBandWidthFactor,d=i.abrBandWidthUpFactor;if(c){var f=this.findBestLevel(l,s,a,c,0,u,d);if(f>=0)return f}var h=o?Math.min(o,i.maxStarvationDelay):i.maxStarvationDelay;if(!c){var p,y=this.bitrateTestDelay;if(y)h=(o?Math.min(o,i.maxLoadingDelay):i.maxLoadingDelay)-y,this.info(_concatInstanceProperty(p="bitrate test took ".concat(Math.round(1e3*y),"ms, set first fragment max fetchDuration to ")).call(p,Math.round(1e3*h)," ms")),u=d=1}var g=this.findBestLevel(l,s,a,c,h,u,d);if(this.info(_concatInstanceProperty(e="".concat(c?"rebuffering expected":"buffer is empty",", optimal quality level ")).call(e,g)),g>-1)return g;var v=n.levels[s],m=n.levels[n.loadLevel];return(null==v?void 0:v.bitrate)<(null==m?void 0:m.bitrate)?s:n.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/r}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,r,n,a,i,s){var o,l=this,c=n+a,u=this.lastLoadedFragLevel,d=-1===u?this.hls.firstLevel:u,f=this.fragCurrent,h=this.partCurrent,p=this.hls,y=p.levels,g=p.allAudioTracks,v=p.loadLevel,m=p.config;if(1===y.length)return 0;var E,$=y[d],S=!(null==(o=this.hls.latestLevelDetails)||!o.live),T=-1===v||-1===u,I="SDR",_=(null==$?void 0:$.frameRate)||0,P=m.audioPreference,b=m.videoPreference,A=this.audioTracksByGroup||(this.audioTracksByGroup=getAudioTracksByGroup(g)),R=-1;if(T){if(-1!==this.firstSelection)return this.firstSelection;var k=getStartCodecTier(this.codecTiers||(this.codecTiers=getCodecTiers(y,A,t,r)),I,e,P,b),C=k.codecSet,O=k.videoRanges,L=k.minFramerate,D=k.minBitrate,w=k.minIndex,M=k.preferHDR;R=w,E=C,I=M?O[O.length-1]:O[0],_=L,e=Math.max(e,D),this.log("picked start tier ".concat(_JSON$stringify(k)))}else E=null==$?void 0:$.codecSet,I=null==$?void 0:$.videoRange;for(var x=h?h.duration:f?f.duration:0,N=this.bwEstimator.getEstimateTTFB()/1e3,F=[],U=function(){var t=y[B],o=B>d;if(!t)return"continue";if(m.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var f=navigator.mediaCapabilities;"function"!=typeof(null==f?void 0:f.decodingInfo)||!requiresMediaCapabilitiesDecodingInfo(t,A,I,_,e,P)&&"hvc1"!==(null==(G=t.videoCodec)?void 0:G.substring(0,4))?t.supportedResult=SUPPORTED_INFO_DEFAULT:(t.supportedPromise=getMediaDecodingInfoPromise(t,A,f),t.supportedPromise.then((function(e){if(l.hls){t.supportedResult=e;var r,n,a=l.hls.levels,i=_indexOfInstanceProperty(a).call(a,t);if(e.error)l.warn(_concatInstanceProperty(r=_concatInstanceProperty(n='MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ')).call(n,i," ")).call(r,_JSON$stringify(e)));else if(!e.supported){var s;l.warn(_concatInstanceProperty(s="Unsupported MediaCapabilities decodingInfo result for level ".concat(i," ")).call(s,_JSON$stringify(e))),i>-1&&a.length>1&&(l.log("Removing unsupported level ".concat(i)),l.hls.removeLevel(i),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0))}}})))}if((E&&t.codecSet!==E||I&&t.videoRange!==I||o&&_>t.frameRate||!o&&_>0&&_<t.frameRate||t.supportedResult&&(null==(j=t.supportedResult.decodingInfoResults)||!j[0].smooth))&&(!T||B!==R))return F.push(B),"continue";var p,g=t.details,$=(h?null==g?void 0:g.partTarget:null==g?void 0:g.averagetargetduration)||x;p=o?s*e:i*e;var b=x&&n>=2*x&&0===a?t.averageBitrate:t.maxBitrate,k=l.getTimeToLoadFrag(N,p,b*$,void 0===g);if(p>=b&&(B===u||0===t.loadError&&0===t.fragmentError)&&(k<=N||!isFiniteNumber(k)||S&&!l.bitrateTestDelay||k<c)){var C=l.forcedAutoLevel;if(B!==v&&(-1===C||C!==v)){var O,L,D,w,M,U,H,K,V,W,Y,q,z,X,Q,J;if(F.length)l.trace(_concatInstanceProperty(q=_concatInstanceProperty(z=_concatInstanceProperty(X=_concatInstanceProperty(Q=_concatInstanceProperty(J="Skipped level(s) ".concat(F.join(",")," of ")).call(J,r,' max with CODECS and VIDEO-RANGE:"')).call(Q,y[F[0]].codecs,'" ')).call(X,y[F[0]].videoRange,'; not compatible with "')).call(z,E,'" ')).call(q,I));l.info(_concatInstanceProperty(O=_concatInstanceProperty(L=_concatInstanceProperty(D=_concatInstanceProperty(w=_concatInstanceProperty(M=_concatInstanceProperty(U=_concatInstanceProperty(H=_concatInstanceProperty(K=_concatInstanceProperty(V=_concatInstanceProperty(W=_concatInstanceProperty(Y="switch candidate:".concat(d,"->")).call(Y,B," adjustedbw(")).call(W,Math.round(p),")-bitrate=")).call(V,Math.round(p-b)," ttfb:")).call(K,N.toFixed(1)," avgDuration:")).call(H,$.toFixed(1)," maxFetchDuration:")).call(U,c.toFixed(1)," fetchDuration:")).call(M,k.toFixed(1)," firstSelection:")).call(w,T," codecSet:")).call(D,t.codecSet," videoRange:")).call(L,t.videoRange," hls.loadLevel:")).call(O,v))}return T&&(l.firstSelection=B),{v:B}}},B=r;B>=t;B--){var j,G,H=U();if("continue"!==H&&"object"===_typeof$1(H))return H.v}return-1}}]),r}(),BinarySearch={search:function(e,t){for(var r=0,n=e.length-1,a=null,i=null;r<=n;){var s=t(i=e[a=(r+n)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return i;n=a-1}}return null}};function findFragmentByPDT(e,t,r){if(null===t||!_Array$isArray(e)||!e.length||!isFiniteNumber(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<e.length;++n){var a=e[n];if(pdtWithinToleranceTest(t,r,a))return a}return null}function findFragmentByPTS(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.005,i=null;if(e){i=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7),i&&e.level!==i.level&&i.end<=e.end&&(i=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(i=t[0]);if(i&&((!e||e.level===i.level)&&0===fragmentWithinToleranceTest(r,n,i)||fragmentWithinFastStartSwitch(i,e,Math.min(a,n))))return i;var o=BinarySearch.search(t,_bindInstanceProperty(fragmentWithinToleranceTest).call(fragmentWithinToleranceTest,null,r,n));return!o||o===e&&i?i:o}function fragmentWithinFastStartSwitch(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var n,a=_reduceInstanceProperty(n=t.tagList).call(n,(function(e,t){return"INF"===t[0]&&(e+=_parseFloat$1(t[1])),e}),r);return e.start<=a}return!1}function fragmentWithinToleranceTest(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;if(r.start<=e&&r.start+r.duration>e)return 0;var n=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-n<=e?1:r.start-n>e&&r.start?-1:0}function pdtWithinToleranceTest(e,t,r){var n=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-n>e}function findFragWithCC(e,t){return BinarySearch.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function findNearestWithCC(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var n=r.start,a=r.end,i=e.fragments;if(!r.relurl){var s=e.fragmentHint;s&&(i=_concatInstanceProperty(i).call(i,s))}return BinarySearch.search(i,(function(e){return e.cc<t||e.end<=n?1:e.cc>t||e.start>=a?-1:0}))}return null}function isTimeoutError(e){switch(e.details){case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_TIMEOUT:case ErrorDetails.LEVEL_LOAD_TIMEOUT:case ErrorDetails.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function getRetryConfig(e,t){var r=isTimeoutError(t);return e.default["".concat(r?"timeout":"error","Retry")]}function getRetryDelay(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function getLoaderConfigWithoutReties(e){return _objectSpread2(_objectSpread2({},e),{errorRetry:null,timeoutRetry:null})}function shouldRetry(e,t,r,n){if(!e)return!1;var a=null==n?void 0:n.code,i=t<e.maxNumRetry&&(retryForHttpStatus(a)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,n,i):i}function retryForHttpStatus(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}var NetworkErrorAction={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ErrorActionFlags={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},ErrorController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"error-controller",e.logger)).hls=void 0,n.playlistError=0,n.penalizedRenditions={},n.hls=e,n.registerListeners(),n}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.ERROR,this.onError,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.ERROR,this.onError,this),e.off(Events.ERROR,this.onErrorOut,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===PlaylistLevelType.MAIN?e.level:this.hls.loadLevel}},{key:"onManifestLoading",value:function(){this.playlistError=0,this.penalizedRenditions={}}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var r;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case ErrorDetails.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=createDoNothingErrorAction());case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=NetworkErrorAction.SendAlternateToPenaltyBox);case ErrorDetails.LEVEL_EMPTY_ERROR:case ErrorDetails.LEVEL_PARSING_ERROR:var i,s,o=t.parent===PlaylistLevelType.MAIN?t.level:n.loadLevel;return void(t.details===ErrorDetails.LEVEL_EMPTY_ERROR&&null!=(i=t.context)&&null!=(s=i.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case ErrorDetails.LEVEL_LOAD_ERROR:case ErrorDetails.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case ErrorDetails.SUBTITLE_LOAD_ERROR:case ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=n.levels[n.loadLevel];if(l&&(a.type===PlaylistContextType.AUDIO_TRACK&&l.hasAudioGroup(a.groupId)||a.type===PlaylistContextType.SUBTITLE_TRACK&&l.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=NetworkErrorAction.SendAlternateToPenaltyBox,void(t.errorAction.flags=ErrorActionFlags.MoveAllAlternatesMatchingHost)}return;case ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=n.levels[n.loadLevel],u=null==c?void 0:c.attrs["HDCP-LEVEL"];return void(u?t.errorAction={action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t));case ErrorDetails.BUFFER_ADD_CODEC_ERROR:case ErrorDetails.REMUX_ALLOC_ERROR:case ErrorDetails.BUFFER_APPEND_ERROR:var d;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(d=t.level)?d:n.loadLevel);return;case ErrorDetails.INTERNAL_EXCEPTION:case ErrorDetails.BUFFER_APPENDING_ERROR:case ErrorDetails.BUFFER_FULL_ERROR:case ErrorDetails.LEVEL_SWITCH_ERROR:case ErrorDetails.BUFFER_STALLED_ERROR:case ErrorDetails.BUFFER_SEEK_OVER_HOLE:case ErrorDetails.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=createDoNothingErrorAction())}t.type===ErrorTypes.KEY_SYSTEM_ERROR&&this.keySystemError(t)}}},{key:"keySystemError",value:function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var r=getRetryConfig(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++;if(shouldRetry(r,n,isTimeoutError(e),e.response))return{action:NetworkErrorAction.RetryRequest,flags:ErrorActionFlags.None,retryConfig:r,retryCount:n};var a=this.getLevelSwitchAction(e,t);return r&&(a.retryConfig=r,a.retryCount=n),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t,r,n=this.hls,a=this.getVariantLevelIndex(e.frag),i=n.levels[a],s=n.config,o=s.fragLoadPolicy,l=s.keyLoadPolicy,c=getRetryConfig(_startsWithInstanceProperty(t=e.details).call(t,"key")?l:o,e),u=_reduceInstanceProperty(r=n.levels).call(r,(function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==ErrorDetails.FRAG_GAP&&i.fragmentError++,shouldRetry(c,u,isTimeoutError(e),e.response)))return{action:NetworkErrorAction.RetryRequest,flags:ErrorActionFlags.None,retryConfig:c,retryCount:u};var d=this.getLevelSwitchAction(e,a);return c&&(d.retryConfig=c,d.retryCount=u),d}},{key:"getLevelSwitchAction",value:function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var n=this.hls.levels[t];if(n){var a,i,s=e.details;n.loadError++,s===ErrorDetails.BUFFER_APPEND_ERROR&&n.fragmentError++;var o=-1,l=r.levels,c=r.loadLevel,u=r.minAutoLevel,d=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var f=null==(a=e.frag)?void 0:a.type,h=(f===PlaylistLevelType.AUDIO&&s===ErrorDetails.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===ErrorDetails.BUFFER_ADD_CODEC_ERROR||s===ErrorDetails.BUFFER_APPEND_ERROR))&&_someInstanceProperty(l).call(l,(function(e){var t=e.audioCodec;return n.audioCodec!==t})),p="video"===e.sourceBufferName&&(s===ErrorDetails.BUFFER_ADD_CODEC_ERROR||s===ErrorDetails.BUFFER_APPEND_ERROR)&&_someInstanceProperty(l).call(l,(function(e){var t=e.codecSet,r=e.audioCodec;return n.codecSet!==t&&n.audioCodec===r})),y=null!=(i=e.context)?i:{},g=y.type,v=y.groupId,m=function(){var t=(E+c)%l.length;if(t!==c&&t>=u&&t<=d&&0===l[t].loadError){var r=l[t];if(s===ErrorDetails.FRAG_GAP&&f===PlaylistLevelType.MAIN&&e.frag){var a=l[t].details;if(a){var i=findFragmentByPTS(e.frag,a.fragments,e.frag.start);if(null!=i&&i.gap)return"continue"}}else{if(g===PlaylistContextType.AUDIO_TRACK&&r.hasAudioGroup(v)||g===PlaylistContextType.SUBTITLE_TRACK&&r.hasSubtitleGroup(v))return"continue";if(f===PlaylistLevelType.AUDIO&&null!=($=n.audioGroups)&&_someInstanceProperty($).call($,(function(e){return r.hasAudioGroup(e)}))||f===PlaylistLevelType.SUBTITLE&&null!=(S=n.subtitleGroups)&&_someInstanceProperty(S).call(S,(function(e){return r.hasSubtitleGroup(e)}))||h&&n.audioCodec===r.audioCodec||!h&&n.audioCodec!==r.audioCodec||p&&n.codecSet===r.codecSet)return"continue"}return o=t,"break"}},E=l.length;E--;){var $,S,T=m();if("continue"!==T&&"break"===T)break}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.None,nextAutoLevel:o}}return{action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.MoveAllAlternatesMatchingHost}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case NetworkErrorAction.DoNothing:break;case NetworkErrorAction.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===ErrorDetails.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'.concat(t.sourceBufferName,'" sourceBuffer append error. Attempting to recover from media error.')),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,r=e.errorAction;if(r){var n=_flagsInstanceProperty(r),a=r.hdcpLevel,i=r.nextAutoLevel;switch(n){case ErrorActionFlags.None:this.switchLevel(e,i);break;case ErrorActionFlags.MoveAllAlternatesMatchingHDCP:a&&(t.maxHdcpLevel=HdcpLevels[_indexOfInstanceProperty(HdcpLevels).call(HdcpLevels,a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'))}r.resolved||this.switchLevel(e,i)}}},{key:"switchLevel",value:function(e,t){var r;void 0!==t&&e.errorAction&&(this.warn(_concatInstanceProperty(r="switching to level ".concat(t," after ")).call(r,e.details)),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}]),r}();function createDoNothingErrorAction(e){var t={action:NetworkErrorAction.DoNothing,flags:ErrorActionFlags.None};return e&&(t.resolved=!0),t}var FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},FragmentTracker=function(){function e(t){_classCallCheck$1(this,e),this.activePartLists=_Object$create(null),this.endListFragments=_Object$create(null),this.fragments=_Object$create(null),this.timeRanges=_Object$create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}return _createClass$1(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Events.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Events.FRAG_LOADED,this.onFragLoaded,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var r=this.activePartLists[t];if(r)for(var n=r.length;n--;){var a=r[n];if(!a)break;var i=a.end;if(a.start<=e&&null!==i&&e<=i)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,r){for(var n=this.fragments,a=_Object$keys(n),i=a.length;i--;){var s=n[a[i]];if((null==s?void 0:s.body.type)===t&&(!r||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null}},{key:"detectEvictedFragments",value:function(e,t,r,n,a){var i,s=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(null==n?void 0:n.fragment.sn)||-1;_forEachInstanceProperty(i=_Object$keys(this.fragments)).call(i,(function(n){var i,l=s.fragments[n];if(l&&!(o>=l.body.sn))if(l.buffered||l.loaded&&!a){var c=l.range[e];c&&(0!==c.time.length?_someInstanceProperty(i=c.time).call(i,(function(e){var r=!s.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&s.removeFragment(l.body),r})):s.removeFragment(l.body))}else l.body.type===r&&s.removeFragment(l.body)}))}},{key:"detectPartialFragments",value:function(e){var t,r=this,n=this.timeRanges;if(n&&"initSegment"!==e.frag.sn){var a=e.frag,i=getFragmentKey(a),s=this.fragments[i];if(!(!s||s.buffered&&a.gap)){var o=!a.relurl;if(_forEachInstanceProperty(t=_Object$keys(n)).call(t,(function(t){var i=a.elementaryStreams[t];if(i){var l=n[t],c=o||!0===i.partial;s.range[t]=r.getBufferedTimes(a,e.part,c,l)}})),s.loaded=null,_Object$keys(s.range).length)s.buffered=!0,(s.body.endList=a.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),isPartial(s)||this.removeParts(a.sn-1,a.type);else this.removeFragment(s.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=_filterInstanceProperty(r).call(r,(function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=getFragmentKey(e),n=this.fragments[r];!n&&t&&(n=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:_Object$create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}},{key:"getBufferedTimes",value:function(e,t,r,n){for(var a={time:[],partial:r},i=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||i,c=0;c<n.length;c++){var u=n.start(c)-this.bufferPadding,d=n.end(c)+this.bufferPadding;if(l>=u&&o<=d){a.time.push({startPTS:Math.max(i,n.start(c)),endPTS:Math.min(s,n.end(c))});break}if(i<d&&s>u){var f=Math.max(i,n.start(c)),h=Math.min(s,n.end(c));h>f&&(a.partial=!0,a.time.push({startPTS:f,endPTS:h}))}else if(s<=u)break}return a}},{key:"getPartialFragment",value:function(e){var t,r,n,a,i=null,s=0,o=this.bufferPadding,l=this.fragments;return _forEachInstanceProperty(t=_Object$keys(l)).call(t,(function(t){var c=l[t];c&&isPartial(c)&&(n=c.body.start-o,a=c.body.end+o,e>=n&&e<=a&&(r=Math.min(e-n,a-e),s<=r&&(i=c.body,s=r)))})),i}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||isPartial(t))}},{key:"getState",value:function(e){var t=getFragmentKey(e),r=this.fragments[t];return r?r.buffered?isPartial(r)?FragmentState.PARTIAL:FragmentState.OK:FragmentState.APPENDING:FragmentState.NOT_LOADED}},{key:"isTimeBuffered",value:function(e,t,r){for(var n,a,i=0;i<r.length;i++){if(n=r.start(i)-this.bufferPadding,a=r.end(i)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var r=t.frag,n=t.part?null:t,a=getFragmentKey(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:_Object$create(null)}}}},{key:"onBufferAppended",value:function(e,t){var r=t.frag,n=t.part,a=t.timeRanges,i=t.type;if("initSegment"!==r.sn){var s=r.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a;var l=a[i];this.detectEvictedFragments(i,l,s,n)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=getFragmentKey(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=_Object$keys(t);if(!e)return r.length>0;for(var n=r.length;n--;){var a=t[r[n]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,r,n,a){var i,s=this;n&&!this.hasGaps||_forEachInstanceProperty(i=_Object$keys(this.fragments)).call(i,(function(i){var o=s.fragments[i];if(o){var l=o.body;l.type!==r||n&&!l.gap||l.start<t&&l.end>e&&(o.buffered||a)&&s.removeFragment(l)}}))}},{key:"removeFragment",value:function(e){var t=getFragmentKey(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var n=e.sn;this.activePartLists[e.type]=_filterInstanceProperty(r).call(r,(function(e){return e.fragment.sn!==n}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e,t;this.fragments=_Object$create(null),this.endListFragments=_Object$create(null),this.activePartLists=_Object$create(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&_forEachInstanceProperty(r).call(r,(function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function isPartial(e){var t,r,n;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(n=e.range.audiovideo)?void 0:n.partial))}function getFragmentKey(e){var t,r;return _concatInstanceProperty(t=_concatInstanceProperty(r="".concat(e.type,"_")).call(r,e.level,"_")).call(t,e.sn)}var DecrypterAesMode={cbc:0,ctr:1},AESCrypto=function(){function e(t,r,n){_classCallCheck$1(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=r,this.aesMode=n}return _createClass$1(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case DecrypterAesMode.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case DecrypterAesMode.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode ".concat(this.aesMode))}}}]),e}();function sliceUint8(e,t,r){return _sliceInstanceProperty(Uint8Array.prototype)?_sliceInstanceProperty(e).call(e,t,r):new Uint8Array(_sliceInstanceProperty(Array.prototype).call(e,t,r))}function removePadding(e){var t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?sliceUint8(e,0,t-r):e}var AESDecryptor=function(){function e(){_classCallCheck$1(this,e),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()}return _createClass$1(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),n=0;n<4;n++)r[n]=t.getUint32(4*n);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,n=r[0],a=r[1],i=r[2],s=r[3],o=this.invSubMix,l=o[0],c=o[1],u=o[2],d=o[3],f=new Uint32Array(256),h=0,p=0,y=0;for(y=0;y<256;y++)f[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var g=p^p<<1^p<<2^p<<3^p<<4;g=g>>>8^255&g^99,e[h]=g,t[g]=h;var v=f[h],m=f[v],E=f[m],$=257*f[g]^16843008*g;n[h]=$<<24|$>>>8,a[h]=$<<16|$>>>16,i[h]=$<<8|$>>>24,s[h]=$,$=16843009*E^65537*m^257*v^16843008*h,l[g]=$<<24|$>>>8,c[g]=$<<16|$>>>16,u[g]=$<<8|$>>>24,d[g]=$,h?(h=v^f[f[f[E^v]]],p^=f[f[p]]):h=p=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n<t.length&&r;)r=t[n]===this.key[n],n++;if(!r){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var i,s,o,l,c=this.ksRows=4*(a+6+1),u=this.keySchedule=new Uint32Array(c),d=this.invKeySchedule=new Uint32Array(c),f=this.sBox,h=this.rcon,p=this.invSubMix,y=p[0],g=p[1],v=p[2],m=p[3];for(i=0;i<c;i++)i<a?o=u[i]=t[i]:(l=o,i%a==0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=h[i/a|0]<<24):a>6&&i%a==4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),u[i]=o=(u[i-a]^l)>>>0);for(s=0;s<c;s++)i=c-s,l=3&s?u[i]:u[i-4],d[s]=s<4||i<=4?l:y[f[l>>>24]]^g[f[l>>>16&255]]^v[f[l>>>8&255]]^m[f[255&l]],d[s]=d[s]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var n,a,i,s,o,l,c,u,d,f,h,p,y,g,v=this.keySize+6,m=this.invKeySchedule,E=this.invSBox,$=this.invSubMix,S=$[0],T=$[1],I=$[2],_=$[3],P=this.uint8ArrayToUint32Array_(r),b=P[0],A=P[1],R=P[2],k=P[3],C=new Int32Array(e),O=new Int32Array(C.length),L=this.networkToHostOrderSwap;t<C.length;){for(d=L(C[t]),f=L(C[t+1]),h=L(C[t+2]),p=L(C[t+3]),o=d^m[0],l=p^m[1],c=h^m[2],u=f^m[3],y=4,g=1;g<v;g++)n=S[o>>>24]^T[l>>16&255]^I[c>>8&255]^_[255&u]^m[y],a=S[l>>>24]^T[c>>16&255]^I[u>>8&255]^_[255&o]^m[y+1],i=S[c>>>24]^T[u>>16&255]^I[o>>8&255]^_[255&l]^m[y+2],s=S[u>>>24]^T[o>>16&255]^I[l>>8&255]^_[255&c]^m[y+3],o=n,l=a,c=i,u=s,y+=4;n=E[o>>>24]<<24^E[l>>16&255]<<16^E[c>>8&255]<<8^E[255&u]^m[y],a=E[l>>>24]<<24^E[c>>16&255]<<16^E[u>>8&255]<<8^E[255&o]^m[y+1],i=E[c>>>24]<<24^E[u>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^m[y+2],s=E[u>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&c]^m[y+3],O[t]=L(n^b),O[t+1]=L(s^A),O[t+2]=L(i^R),O[t+3]=L(a^k),b=d,A=f,R=h,k=p,t+=4}return O.buffer}}]),e}(),FastAESKey=function(){function e(t,r,n){_classCallCheck$1(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=r,this.aesMode=n}return _createClass$1(e,[{key:"expandKey",value:function(){var e=getSubtleAlgoName(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}]),e}();function getSubtleAlgoName(e){switch(e){case DecrypterAesMode.cbc:return"AES-CBC";case DecrypterAesMode.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode ".concat(e))}}function utf8ArrayToStr(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("undefined"!=typeof TextDecoder){var r=new TextDecoder("utf-8").decode(e);if(t){var n=_indexOfInstanceProperty(r).call(r,"\0");return-1!==n?r.substring(0,n):r}return r.replace(/\0/g,"")}for(var a,i,s,o=e.length,l="",c=0;c<o;){if(0===(a=e[c++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:i=e[c++],l+=String.fromCharCode((31&a)<<6|63&i);break;case 14:i=e[c++],s=e[c++],l+=String.fromCharCode((15&a)<<12|(63&i)<<6|(63&s)<<0)}}return l}var Hex={hexDump:function(e){for(var t="",r=0;r<e.length;r++){var n=e[r].toString(16);n.length<2&&(n="0"+n),t+=n}return t}};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var urlToolkit={exports:{}};!function(e,t){var r,n,a,i,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=_trimInstanceProperty(e).call(e),!(t=_trimInstanceProperty(t).call(t))){if(!r.alwaysNormalize)return e;var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=s.normalizePath(a.path),s.buildURLFromParts(a)}var i=s.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=s.normalizePath(i.path),s.buildURLFromParts(i)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=n.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var c={scheme:o.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(c.netLoc=o.netLoc,"/"!==i.path[0]))if(i.path){var u=o.path,d=u.substring(0,_lastIndexOfInstanceProperty(u).call(u,"/")+1)+i.path;c.path=s.normalizePath(d)}else c.path=o.path,i.params||(c.params=o.params,i.query||(c.query=o.query));return null===c.path&&(c.path=r.alwaysNormalize?s.normalizePath(i.path):i.path),s.buildURLFromParts(c)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){var t,r;for(e=_reverseInstanceProperty(t=e.split("")).call(t).join("").replace(a,"");e.length!==(e=e.replace(i,"")).length;);return _reverseInstanceProperty(r=e.split("")).call(r).join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},urlToolkit.exports=s}();var urlToolkitExports=urlToolkit.exports,LoadStats=_createClass$1((function e(){_classCallCheck$1(this,e),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}})),ElementaryStreamTypes={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},BaseSegment=function(){function e(t){_classCallCheck$1(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t}return _createClass$1(e,[{key:"setByteRange",value:function(e,t){var r,n=e.split("@",2);r=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:_parseInt$1(n[1]),this._byteRange=[r,_parseInt$1(n[0])+r]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){var e;null===this._streams&&(this._streams=(_defineProperty$2(e={},ElementaryStreamTypes.AUDIO,null),_defineProperty$2(e,ElementaryStreamTypes.VIDEO,null),_defineProperty$2(e,ElementaryStreamTypes.AUDIOVIDEO,null),e));return this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new LoadStats),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=urlToolkitExports.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[ElementaryStreamTypes.AUDIO]=null,e[ElementaryStreamTypes.VIDEO]=null,e[ElementaryStreamTypes.AUDIOVIDEO]=null}}]),e}();function isMediaFragment(e){return"initSegment"!==e.sn}var Fragment=function(e){_inherits(r,BaseSegment);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,n))._decryptdata=null,a._programDateTime=null,a._ref=null,a._bitrate=void 0,a.rawProgramDateTime=null,a.tagList=[],a.duration=0,a.sn=0,a.levelkeys=void 0,a.type=void 0,a.loader=null,a.keyLoader=null,a.level=-1,a.cc=0,a.startPTS=void 0,a.endPTS=void 0,a.startDTS=void 0,a.endDTS=void 0,a.start=0,a.playlistOffset=0,a.deltaPTS=void 0,a.maxStartPTS=void 0,a.minEndPTS=void 0,a.data=void 0,a.bitrateTest=!1,a.title=null,a.initSegment=null,a.endList=void 0,a.gap=void 0,a.urlId=0,a.type=e,a}return _createClass$1(r,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var t=this.byteRange[0],r=this.byteRange[1];if(isFiniteNumber(t)&&isFiniteNumber(r))return r-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=_Object$keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=isFiniteNumber(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=_Object$keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){isFiniteNumber(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return isMediaFragment(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,r,n,a){var i=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,a)):s[e]={startPTS:t,endPTS:r,startDTS:n,endDTS:a,partial:i}}}]),r}(),Part=function(e){_inherits(r,BaseSegment);var t=_createSuper(r);function r(e,n,a,i,s){var o;_classCallCheck$1(this,r),(o=t.call(this,a)).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=n,o.index=i;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return _createClass$1(r,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),r}(),UINT32_MAX$1=Math.pow(2,32)-1,push2=[].push,RemuxerTrackIdConfig={video:1,audio:2,id3:3,text:4};function bin2str(e){return String.fromCharCode.apply(null,e)}function readUint16(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function readUint32(e,t){var r=readSint32(e,t);return r<0?4294967296+r:r}function readUint64(e,t){var r=readUint32(e,t);return r*=Math.pow(2,32),r+=readUint32(e,t+4)}function readSint32(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function writeUint32(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function hasMoofData(e){for(var t=e.byteLength,r=0;r<t;){var n=readUint32(e,r);if(n>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=n>1?r+n:t}return!1}function findBox(e,t){var r=[];if(!t.length)return r;for(var n=e.byteLength,a=0;a<n;){var i=readUint32(e,a),s=i>1?a+i:n;if(bin2str(e.subarray(a+4,a+8))===t[0])if(1===t.length)r.push(e.subarray(a+8,s));else{var o=findBox(e.subarray(a+8,s),_sliceInstanceProperty(t).call(t,1));o.length&&push2.apply(r,o)}a=s}return r}function parseSegmentIndex(e){var t=[],r=e[0],n=8,a=readUint32(e,n);n+=4;var i=0,s=0;0===r?(i=readUint32(e,n),s=readUint32(e,n+4),n+=8):(i=readUint64(e,n),s=readUint64(e,n+8),n+=16),n+=2;var o=e.length+s,l=readUint16(e,n);n+=2;for(var c=0;c<l;c++){var u=n,d=readUint32(e,u);u+=4;var f=2147483647&d;if(1===(2147483648&d)>>>31)return logger.warn("SIDX has hierarchical references (not supported)"),null;var h=readUint32(e,u);u+=4,t.push({referenceSize:f,subsegmentDuration:h,info:{duration:h/a,start:o,end:o+f-1}}),o+=f,n=u+=4}return{earliestPresentationTime:i,timescale:a,version:r,referencesCount:l,references:t}}function parseInitSegment(e){for(var t=[],r=findBox(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],i=findBox(a,["tkhd"])[0];if(i){var s=i[0],o=readUint32(i,0===s?12:20),l=findBox(a,["mdia","mdhd"])[0];if(l){var c=readUint32(l,0===(s=l[0])?12:20),u=findBox(a,["mdia","hdlr"])[0];if(u){var d=bin2str(u.subarray(8,12)),f={soun:ElementaryStreamTypes.AUDIO,vide:ElementaryStreamTypes.VIDEO}[d];if(f){var h=parseStsd(findBox(a,["mdia","minf","stbl","stsd"])[0]);t[o]={timescale:c,type:f},t[f]=_objectSpread2({timescale:c,id:o},h)}}}}}var p=findBox(e,["moov","mvex","trex"]);return _forEachInstanceProperty(p).call(p,(function(e){var r=readUint32(e,4),n=t[r];n&&(n.default={duration:readUint32(e,12),flags:readUint32(e,20)})})),t}function parseStsd(e){var t=e.subarray(8),r=t.subarray(86),n=bin2str(t.subarray(4,8)),a=n,i="enca"===n||"encv"===n;if(i){var s=findBox(t,[n])[0],o=findBox(s.subarray("enca"===n?28:78),["sinf"]);_forEachInstanceProperty(o).call(o,(function(e){var t=findBox(e,["schm"])[0];if(t){var r=bin2str(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var n=findBox(e,["frma"])[0];n&&(a=bin2str(n))}}}))}switch(a){case"avc1":case"avc2":case"avc3":case"avc4":var l=findBox(r,["avcC"])[0];a+="."+toHex(l[1])+toHex(l[2])+toHex(l[3]);break;case"mp4a":var c=findBox(t,[n])[0],u=findBox(c.subarray(28),["esds"])[0];if(u&&u.length>7){var d=4;if(3!==u[d++])break;d=skipBERInteger(u,d),d+=2;var f=u[d++];if(128&f&&(d+=2),64&f&&(d+=u[d++]),4!==u[d++])break;d=skipBERInteger(u,d);var h=u[d++];if(64!==h)break;if(a+="."+toHex(h),d+=12,5!==u[d++])break;d=skipBERInteger(u,d);var p=u[d++],y=(248&p)>>3;31===y&&(y+=1+((7&p)<<3)+((224&u[d])>>5)),a+="."+y}break;case"hvc1":case"hev1":var g=findBox(r,["hvcC"])[0],v=g[1],m=["","A","B","C"][v>>6],E=31&v,$=readUint32(g,2),S=(32&v)>>5?"H":"L",T=g[12],I=g.subarray(6,12);a+="."+m+E,a+="."+$.toString(16).toUpperCase(),a+="."+S+T;for(var _="",P=I.length;P--;){var b=I[P];if(b||_)_="."+b.toString(16).toUpperCase()+_}a+=_;break;case"dvh1":case"dvhe":var A=findBox(r,["dvcC"])[0],R=A[2]>>1&127,k=A[2]<<5&32|A[3]>>3&31;a+="."+addLeadingZero(R)+"."+addLeadingZero(k);break;case"vp09":var C=findBox(r,["vpcC"])[0],O=C[4],L=C[5],D=C[6]>>4&15;a+="."+addLeadingZero(O)+"."+addLeadingZero(L)+"."+addLeadingZero(D);break;case"av01":var w=findBox(r,["av1C"])[0],M=w[1]>>>5,x=31&w[1],N=w[2]>>>7?"H":"M",F=(64&w[2])>>6,U=(32&w[2])>>5,B=2===M&&F?U?12:10:F?10:8,j=(16&w[2])>>4,G=(8&w[2])>>3,H=(4&w[2])>>2,K=3&w[2];a+="."+M+"."+addLeadingZero(x)+N+"."+addLeadingZero(B)+"."+j+"."+G+H+K+"."+addLeadingZero(1)+"."+addLeadingZero(1)+"."+addLeadingZero(1)+".0"}return{codec:a,encrypted:i}}function skipBERInteger(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function toHex(e){var t;return _sliceInstanceProperty(t="0"+e.toString(16).toUpperCase()).call(t,-2)}function addLeadingZero(e){return(e<10?"0":"")+e}function patchEncyptionData(e,t){if(!e||!t)return e;var r=t.keyId;if(r&&t.isCommonEncryption){var n=findBox(e,["moov","trak"]);_forEachInstanceProperty(n).call(n,(function(e){var t=findBox(e,["mdia","minf","stbl","stsd"])[0].subarray(8),n=findBox(t,["enca"]),a=n.length>0;a||(n=findBox(t,["encv"])),_forEachInstanceProperty(n).call(n,(function(e){var t=findBox(a?e.subarray(28):e.subarray(78),["sinf"]);_forEachInstanceProperty(t).call(t,(function(e){var t=parseSinf(e);if(t){var n,i,s=t.subarray(8,24);if(!_someInstanceProperty(s).call(s,(function(e){return 0!==e})))logger.log(_concatInstanceProperty(n=_concatInstanceProperty(i="[eme] Patching keyId in 'enc".concat(a?"a":"v",">sinf>>tenc' box: ")).call(i,Hex.hexDump(s)," -> ")).call(n,Hex.hexDump(r))),t.set(r,8)}}))}))}))}return e}function parseSinf(e){var t=findBox(e,["schm"])[0];if(t){var r=bin2str(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return findBox(e,["schi","tenc"])[0]}return null}function getStartDTS(e,t){var r;return _reduceInstanceProperty(r=findBox(t,["moof","traf"])).call(r,(function(t,r){var n,a=findBox(r,["tfdt"])[0],i=a[0],s=_reduceInstanceProperty(n=findBox(r,["tfhd"])).call(n,(function(t,r){var n=readUint32(r,4),s=e[n];if(s){var o=readUint32(a,4);if(1===i){if(o===UINT32_MAX$1)return logger.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=UINT32_MAX$1+1,o+=readUint32(a,8)}var l=o/(s.timescale||9e4);if(isFiniteNumber(l)&&(null===t||l<t))return l}return t}),null);return null!==s&&isFiniteNumber(s)&&(null===t||s<t)?s:t}),null)}function getDuration(e,t){for(var r=0,n=0,a=0,i=findBox(e,["moof","traf"]),s=0;s<i.length;s++){var o=i[s],l=findBox(o,["tfhd"])[0],c=t[readUint32(l,4)];if(c){var u=c.default,d=readUint32(l,0)|(null==u?void 0:_flagsInstanceProperty(u)),f=null==u?void 0:u.duration;8&d&&(f=readUint32(l,2&d?12:8));for(var h=c.timescale||9e4,p=findBox(o,["trun"]),y=0;y<p.length;y++){if(!(r=computeRawDurationFromSamples(p[y]))&&f)r=f*readUint32(p[y],4);c.type===ElementaryStreamTypes.VIDEO?n+=r/h:c.type===ElementaryStreamTypes.AUDIO&&(a+=r/h)}}}if(0===n&&0===a){for(var g=1/0,v=0,m=0,E=findBox(e,["sidx"]),$=0;$<E.length;$++){var S=parseSegmentIndex(E[$]);if(null!=S&&S.references){var T;g=Math.min(g,S.earliestPresentationTime/S.timescale);var I=_reduceInstanceProperty(T=S.references).call(T,(function(e,t){return e+t.info.duration||0}),0);m=(v=Math.max(v,I+S.earliestPresentationTime/S.timescale))-g}}if(m&&isFiniteNumber(m))return m}return n||a}function computeRawDurationFromSamples(e){var t=readUint32(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var n=0,a=readUint32(e,4),i=0;i<a;i++){if(256&t)n+=readUint32(e,r),r+=4;512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return n}function offsetStartDTS(e,t,r){var n;_forEachInstanceProperty(n=findBox(t,["moof","traf"])).call(n,(function(t){var n;_forEachInstanceProperty(n=findBox(t,["tfhd"])).call(n,(function(n){var a,i=readUint32(n,4),s=e[i];if(s){var o=s.timescale||9e4;_forEachInstanceProperty(a=findBox(t,["tfdt"])).call(a,(function(e){var t=e[0],n=r*o;if(n){var a=readUint32(e,4);if(0===t)a-=n,writeUint32(e,4,a=Math.max(a,0));else{a*=Math.pow(2,32),a+=readUint32(e,8),a-=n,a=Math.max(a,0);var i=Math.floor(a/(UINT32_MAX$1+1)),s=Math.floor(a%(UINT32_MAX$1+1));writeUint32(e,4,i),writeUint32(e,8,s)}}}))}}))}))}function segmentValidRange(e){var t={valid:null,remainder:null},r=findBox(e,["moof"]);if(r.length<2)return t.remainder=e,t;var n=r[r.length-1];return t.valid=sliceUint8(e,0,n.byteOffset-8),t.remainder=sliceUint8(e,n.byteOffset-8),t}function appendUint8Array(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function parseSamples(e,t){var r=[],n=t.samples,a=t.timescale,i=t.id,s=!1,o=findBox(n,["moof"]);return _mapInstanceProperty(o).call(o,(function(o){var l=o.byteOffset-8,c=findBox(o,["traf"]);_mapInstanceProperty(c).call(c,(function(o){var c,u,d=_mapInstanceProperty(c=findBox(o,["tfdt"])).call(c,(function(e){var t=e[0],r=readUint32(e,4);return 1===t&&(r*=Math.pow(2,32),r+=readUint32(e,8)),r/a}))[0];return void 0!==d&&(e=d),_mapInstanceProperty(u=findBox(o,["tfhd"])).call(u,(function(c){var u,d=readUint32(c,4),f=16777215&readUint32(c,0),h=0,p=0!=(16&f),y=0,g=0!=(32&f),v=8;d===i&&(0!=(1&f)&&(v+=8),0!=(2&f)&&(v+=4),0!=(8&f)&&(h=readUint32(c,v),v+=4),p&&(y=readUint32(c,v),v+=4),g&&(v+=4),"video"===t.type&&(s=isHEVC(t.codec)),_mapInstanceProperty(u=findBox(o,["trun"])).call(u,(function(i){var o=i[0],c=16777215&readUint32(i,0),u=0!=(1&c),d=0,f=0!=(4&c),p=0!=(256&c),g=0,v=0!=(512&c),m=0,E=0!=(1024&c),$=0!=(2048&c),S=0,T=readUint32(i,4),I=8;u&&(d=readUint32(i,I),I+=4),f&&(I+=4);for(var _=d+l,P=0;P<T;P++){if(p?(g=readUint32(i,I),I+=4):g=h,v?(m=readUint32(i,I),I+=4):m=y,E&&(I+=4),$&&(S=0===o?readUint32(i,I):readSint32(i,I),I+=4),t.type===ElementaryStreamTypes.VIDEO)for(var b=0;b<m;){var A=readUint32(n,_);if(isSEIMessage(s,n[_+=4]))parseSEIMessageFromNALu(n.subarray(_,_+A),s?2:1,e+S/a,r);_+=A,b+=A+4}e+=g/a}})))}))}))})),r}function isHEVC(e){if(!e)return!1;var t=_indexOfInstanceProperty(e).call(e,"."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}function isSEIMessage(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function parseSEIMessageFromNALu(e,t,r,n){var a=discardEPB(e),i=0;i+=t;for(var s=0,o=0,l=0;i<a.length;){s=0;do{if(i>=a.length)break;s+=l=a[i++]}while(255===l);o=0;do{if(i>=a.length)break;o+=l=a[i++]}while(255===l);var c=a.length-i,u=i;if(o<c)i+=o;else if(o>c){var d;logger.error(_concatInstanceProperty(d="Malformed SEI payload. ".concat(o," is too small, only ")).call(d,c," bytes left to parse."));break}if(4===s){if(181===a[u++]){var f=readUint16(a,u);if(u+=2,49===f){var h=readUint32(a,u);if(u+=4,1195456820===h){var p=a[u++];if(3===p){var y=a[u++],g=64&y,v=g?2+3*(31&y):0,m=new Uint8Array(v);if(g){m[0]=y;for(var E=1;E<v;E++)m[E]=a[u++]}n.push({type:p,payloadType:s,pts:r,bytes:m})}}}}}else if(5===s&&o>16){for(var $=[],S=0;S<16;S++){var T=a[u++].toString(16);$.push(1==T.length?"0"+T:T),3!==S&&5!==S&&7!==S&&9!==S||$.push("-")}for(var I=o-16,_=new Uint8Array(I),P=0;P<I;P++)_[P]=a[u++];n.push({payloadType:s,pts:r,uuid:$.join(""),userData:utf8ArrayToStr(_),userDataBytes:_})}}}function discardEPB(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(0===r.length)return e;var a=t-r.length,i=new Uint8Array(a),s=0;for(n=0;n<a;s++,n++)s===r[0]&&(s++,r.shift()),i[n]=e[s];return i}function parseEmsg(e){var t=e[0],r="",n="",a=0,i=0,s=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==bin2str(e.subarray(c,c+1));)r+=bin2str(e.subarray(c,c+1)),c+=1;for(r+=bin2str(e.subarray(c,c+1)),c+=1;"\0"!==bin2str(e.subarray(c,c+1));)n+=bin2str(e.subarray(c,c+1)),c+=1;n+=bin2str(e.subarray(c,c+1)),c+=1,a=readUint32(e,12),i=readUint32(e,16),o=readUint32(e,20),l=readUint32(e,24),c=28}else if(1===t){a=readUint32(e,c+=4);var u=readUint32(e,c+=4),d=readUint32(e,c+=4);for(c+=4,s=Math.pow(2,32)*u+d,isSafeInteger2(s)||(s=_Number$MAX_SAFE_INTEGER,logger.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=readUint32(e,c),l=readUint32(e,c+=4),c+=4;"\0"!==bin2str(e.subarray(c,c+1));)r+=bin2str(e.subarray(c,c+1)),c+=1;for(r+=bin2str(e.subarray(c,c+1)),c+=1;"\0"!==bin2str(e.subarray(c,c+1));)n+=bin2str(e.subarray(c,c+1)),c+=1;n+=bin2str(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:n,timeScale:a,presentationTime:s,presentationTimeDelta:i,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}function mp4Box(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var a=r.length,i=8,s=a;s--;)i+=r[s].byteLength;var o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=255&i,o.set(e,4),s=0,i=8;s<a;s++)o.set(r[s],i),i+=r[s].byteLength;return o}function mp4pssh(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var n,a;n=new Uint8Array,a=new Uint8Array;var i=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(i.buffer).setUint32(0,r.byteLength,!1),mp4Box([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,n,i,r||new Uint8Array)}function parseMultiPssh(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,n=0;n+32<r;){var a=parsePssh(new DataView(e,n));t.push(a),n+=a.size}return t}function parsePssh(e){var t=e.getUint32(0),r=e.byteOffset,n=e.byteLength;if(n<t)return{offset:r,size:n};if(1886614376!==e.getUint32(4))return{offset:r,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:r,size:t};var i=e.buffer,s=Hex.hexDump(new Uint8Array(i,r+12,16)),o=e.getUint32(28),l=null,c=null;if(0===a){if(t-32<o||o<22)return{offset:r,size:t};c=new Uint8Array(i,r+32,o)}else if(1===a){if(!o||n<r+32+16*o+16)return{offset:r,size:t};l=[];for(var u=0;u<o;u++)l.push(new Uint8Array(i,r+32+16*u,16))}return{version:a,systemId:s,kids:l,data:c,offset:r,size:t}}var CHUNK_SIZE=16,Decrypter=function(){function e(t){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).removePKCS7Padding,n=void 0===r||r;if(_classCallCheck$1(this,e),this.logEnabled=!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.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}return _createClass$1(e,[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?removePadding(r):r}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,r,n){var a=this;return this.useSoftware?new _Promise((function(i,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);a.softwareDecrypt(o,t,r,n);var l=a.flush();l?i(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,n)}},{key:"softwareDecrypt",value:function(e,t,r,n){var a=this.currentIV,i=this.currentResult,s=this.remainderData;if(n!==DecrypterAesMode.cbc||16!==t.byteLength)return logger.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=appendUint8Array(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;a&&(r=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new AESDecryptor),l.expandKey(t);var c=i;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=sliceUint8(o,-16).buffer,c||null}},{key:"webCryptoDecrypt",value:function(e,t,r,n){var a=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return _Promise.resolve(this.onWebCryptoError(e,t,r,n));this.key=t,this.fastAesKey=new FastAESKey(this.subtle,t,n)}return this.fastAesKey.expandKey().then((function(t){return a.subtle?(a.logOnce("WebCrypto AES decrypt"),new AESCrypto(a.subtle,new Uint8Array(r),n).decrypt(e.buffer,t)):_Promise.reject(new Error("web crypto not initialized"))})).catch((function(i){var s;return logger.warn(_concatInstanceProperty(s="[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(i.name,": ")).call(s,i.message)),a.onWebCryptoError(e,t,r,n)}))}},{key:"onWebCryptoError",value:function(e,t,r,n){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,n);var i=this.flush();if(i)return i.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,r=e.length-e.length%CHUNK_SIZE;return r!==e.length&&(t=sliceUint8(e,0,r),this.remainderData=sliceUint8(e,r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(logger.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),MIN_CHUNK_SIZE=Math.pow(2,17),FragmentLoader=function(){function e(t){_classCallCheck$1(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}return _createClass$1(e,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var r=this,n=e.url;if(!n)return _Promise.reject(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(n?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,i=a.fLoader,s=a.loader;return new _Promise((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){var c;if(_someInstanceProperty(c=e.tagList).call(c,(function(e){return"GAP"===e[0]})))return void l(createGapLoadError(e));e.gap=!1}var u=r.loader=i?new i(a):new s(a),d=createLoaderContext(e);e.loader=u;var f=getLoaderConfigWithoutReties(a.fragLoadPolicy.default),h={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:MIN_CHUNK_SIZE};e.stats=u.stats;var p={onSuccess:function(t,n,a,i){r.resetLoader(e,u);var s=t.data;a.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(_sliceInstanceProperty(s).call(s,0,16)),s=_sliceInstanceProperty(s).call(s,16)),o({frag:e,part:null,payload:s,networkDetails:i})},onError:function(t,a,i,s){var o;r.resetLoader(e,u),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_objectSpread2({url:n,data:void 0},t),error:new Error(_concatInstanceProperty(o="HTTP Error ".concat(t.code," ")).call(o,t.text)),networkDetails:i,stats:s}))},onAbort:function(t,n,a){r.resetLoader(e,u),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:a,stats:t}))},onTimeout:function(t,n,a){r.resetLoader(e,u),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after ".concat(h.timeout,"ms")),networkDetails:a,stats:t}))}};t&&(p.onProgress=function(r,n,a,i){return t({frag:e,part:null,payload:a,networkDetails:i})}),u.load(d,h,p)}))}},{key:"loadPart",value:function(e,t,r){var n=this;this.abort();var a=this.config,i=a.fLoader,s=a.loader;return new _Promise((function(o,l){if(n.loader&&n.loader.destroy(),e.gap||t.gap)l(createGapLoadError(e,t));else{var c=n.loader=i?new i(a):new s(a),u=createLoaderContext(e,t);e.loader=c;var d=getLoaderConfigWithoutReties(a.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:MIN_CHUNK_SIZE};t.stats=c.stats,c.load(u,f,{onSuccess:function(a,i,s,l){n.resetLoader(e,c),n.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:a.data,networkDetails:l};r(u),o(u)},onError:function(r,a,i,s){var o;n.resetLoader(e,c),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_objectSpread2({url:u.url,data:void 0},r),error:new Error(_concatInstanceProperty(o="HTTP Error ".concat(r.code," ")).call(o,r.text)),networkDetails:i,stats:s}))},onAbort:function(r,a,i){e.stats.aborted=t.stats.aborted,n.resetLoader(e,c),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:i,stats:r}))},onTimeout:function(r,a,i){n.resetLoader(e,c),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after ".concat(f.timeout,"ms")),networkDetails:i,stats:r}))}})}}))}},{key:"updateStatsFromPart",value:function(e,t){var r=e.stats,n=t.stats,a=n.total;if(r.loaded+=n.loaded,a){var i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/a),i),o=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,c=n.loading;l.start?l.first+=c.first-c.start:(l.start=c.start,l.first=c.first),l.end=c.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}]),e}();function createLoaderContext(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=t||e,n={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,i=r.byteRangeEndOffset;if(isFiniteNumber(a)&&isFiniteNumber(i)){var s,o=a,l=i;if("initSegment"===e.sn&&isMethodFullSegmentAesCbc(null==(s=e.decryptdata)?void 0:s.method)){var c=i-a;c%16&&(l=i+(16-c%16)),0!==a&&(n.resetIV=!0,o=a-16)}n.rangeStart=o,n.rangeEnd=l}return n}function createGapLoadError(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),n={type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(n.part=t),(t||e).stats.aborted=!0,new LoadError(n)}function isMethodFullSegmentAesCbc(e){return"AES-128"===e||"AES-256"===e}var LoadError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e.error.message)).data=void 0,n.data=e,n}return _createClass$1(r)}(),TaskLoop=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a,i;return _classCallCheck$1(this,r),(i=t.call(this,e,n))._boundTick=void 0,i._tickTimer=null,i._tickInterval=null,i._tickCallCount=0,i._boundTick=_bindInstanceProperty(a=i.tick).call(a,_assertThisInitialized(i)),i}return _createClass$1(r,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=_setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=_setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}]),r}(),ChunkMetadata=_createClass$1((function e(t,r,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];_classCallCheck$1(this,e),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=getNewPerformanceTiming(),this.buffering={audio:getNewPerformanceTiming(),video:getNewPerformanceTiming(),audiovideo:getNewPerformanceTiming()},this.level=t,this.sn=r,this.id=n,this.size=a,this.part=i,this.partial=s}));function getNewPerformanceTiming(){return{start:0,executeStart:0,executeEnd:0,end:0}}var noopBuffered={length:0,start:function(){return 0},end:function(){return 0}},BufferHelper=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"isBuffered",value:function(t,r){if(t)for(var n=e.getBuffered(t),a=n.length;a--;)if(r>=n.start(a)&&r<=n.end(a))return!0;return!1}},{key:"bufferInfo",value:function(t,r,n){if(t){var a=e.getBuffered(t);if(a.length){for(var i=[],s=0;s<a.length;s++)i.push({start:a.start(s),end:a.end(s)});return e.bufferedInfo(i,r,n)}}return{len:0,start:r,end:r,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){t=Math.max(0,t),_sortInstanceProperty(e).call(e,(function(e,t){return e.start-t.start||t.end-e.end}));var n=[];if(r)for(var a=0;a<e.length;a++){var i=n.length;if(i){var s=n[i-1].end;e[a].start-s<r?e[a].end>s&&(n[i-1].end=e[a].end):n.push(e[a])}else n.push(e[a])}else n=e;for(var o,l=0,c=t,u=t,d=0;d<n.length;d++){var f=n[d].start,h=n[d].end;if(t+r>=f&&t<h)c=f,l=(u=h)-t;else if(t+r<f){o=f;break}}return{len:l,start:c||0,end:u||0,nextStart:o}}},{key:"getBuffered",value:function(e){try{return e.buffered||noopBuffered}catch(e){return logger.log("failed to get media.buffered",e),noopBuffered}}}]),e}(),VARIABLE_REPLACEMENT_REGEX=/\{\$([a-zA-Z0-9-_]+)\}/g;function hasVariableReferences(e){return VARIABLE_REPLACEMENT_REGEX.test(e)}function substituteVariables(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(VARIABLE_REPLACEMENT_REGEX,(function(t){var n=t.substring(2,t.length-1),a=null==r?void 0:r[n];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(n,'"'))),t):a}))}return t}function addVariableDefinition(e,t,r){var n,a,i=e.variableList;if(i||(e.variableList=i={}),"QUERYPARAM"in t){n=t.QUERYPARAM;try{var s,o=new _URL(r).searchParams;if(!o.has(n))throw new Error(_concatInstanceProperty(s='"'.concat(n,'" does not match any query parameter in URI: "')).call(s,r,'"'));a=o.get(n)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(t.message)))}}else n=t.NAME,a=t.VALUE;n in i?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(n,'"'))):i[n]=a||""}function importVariableDefinition(e,t,r){var n=t.IMPORT;if(r&&n in r){var a=e.variableList;a||(e.variableList=a={}),a[n]=r[n]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(n,'"')))}var DECIMAL_RESOLUTION_REGEX=/^(\d+)x(\d+)$/,ATTR_LIST_REGEX=/(.+?)=(".*?"|.*?)(?:,|$)/g,AttrList=function(){function e(t,r){_classCallCheck$1(this,e),"string"==typeof t&&(t=e.parseAttrList(t,r)),_extends(this,t)}return _createClass$1(e,[{key:"clientAttrs",get:function(){var e;return _filterInstanceProperty(e=_Object$keys(this)).call(e,(function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=_parseInt$1(this[e],10);return t>_Number$MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t,r=_sliceInstanceProperty(t=this[e]||"0x").call(t,2);r=(1&r.length?"0":"")+r;for(var n=new Uint8Array(r.length/2),a=0;a<r.length/2;a++)n[a]=_parseInt$1(_sliceInstanceProperty(r).call(r,2*a,2*a+2),16);return n}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=_parseInt$1(this[e],16);return t>_Number$MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return _parseFloat$1(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?_parseFloat$1(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r,n=this[e];return _reduceInstanceProperty(r=n?n.split(/[ ,]+/):[]).call(r,(function(e,t){return e[t.toLowerCase()]=!0,e}),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=DECIMAL_RESOLUTION_REGEX.exec(this[e]);if(null!==t)return{width:_parseInt$1(t[1],10),height:_parseInt$1(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,n,a={};for(ATTR_LIST_REGEX.lastIndex=0;null!==(n=ATTR_LIST_REGEX.exec(e));){var i,s=_trimInstanceProperty(i=n[1]).call(i),o=n[2],l=0===_indexOfInstanceProperty(o).call(o,'"')&&_lastIndexOfInstanceProperty(o).call(o,'"')===o.length-1,c=!1;if(l)o=_sliceInstanceProperty(o).call(o,1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":c=!0}if(t&&(l||c))o=substituteVariables(t,o);else if(!c&&!l)switch(s){case"CLOSED-CAPTIONS":if("NONE"===o)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":logger.warn(_concatInstanceProperty(r="".concat(e,": attribute ")).call(r,s," is missing quotes"))}a[s]=o}return a}}]),e}(),CLASS_INTERSTITIAL="com.apple.hls.interstitial";function isDateRangeCueAttribute(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function isSCTE35Attribute(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var DateRange=function(){function e(t,r){var n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(_classCallCheck$1(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==r?void 0:r.tagAnchor)||null,this.tagOrder=null!=(n=null==r?void 0:r.tagOrder)?n:a,r){var i=r.attr;for(var s in i)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==i[s]){var o;logger.warn(_concatInstanceProperty(o='DATERANGE tag attribute: "'.concat(s,'" does not match for tags with ID: "')).call(o,t.ID,'"')),this._badValueForSameId=s;break}t=_extends(new AttrList({}),i,t)}if(this.attr=t,r?(this._startDate=r._startDate,this._cue=r._cue,this._endDate=r._endDate,this._dateAtEnd=r._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var l=(null==r?void 0:r.endDate)||new Date(this.attr["END-DATE"]);isFiniteNumber(l.getTime())&&(this._endDate=l)}}return _createClass$1(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e,t=this.tagAnchor;return null===t||null===t.programDateTime?(logger.warn(_concatInstanceProperty(e='Expected tagAnchor Fragment with PDT set for DateRange "'.concat(this.id,'": ')).call(e,t)),NaN):t.start+(this.startDate.getTime()-t.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(isFiniteNumber(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return this.class===CLASS_INTERSTITIAL}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&isFiniteNumber(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}]),e}(),DEFAULT_TARGET_DURATION=10,LevelDetails=function(){function e(t){_classCallCheck$1(this,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.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return _createClass$1(e,[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&isFiniteNumber(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||DEFAULT_TARGET_DURATION}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(_Date$now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}]),e}();function isFullSegmentEncryption(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function getAesModeFromFullSegmentMethod(e){switch(e){case"AES-128":case"AES-256":return DecrypterAesMode.cbc;case"AES-256-CTR":return DecrypterAesMode.ctr;default:throw new Error("invalid full segment method ".concat(e))}}function base64Decode(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function strToUtf8array(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function getKeyIdBytes(e){var t=strToUtf8array(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}function changeEndianness(e){var t=function(e,t,r){var n=e[t];e[t]=e[r],e[r]=n};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function convertDataUriToArrayBytes(e){var t=e.split(":"),r=null;if("data"===t[0]&&2===t.length){var n=t[1].split(";"),a=n[n.length-1].split(",");if(2===a.length){var i="base64"===a[0],s=a[1];i?(_spliceInstanceProperty(n).call(n,-1,1),r=base64Decode(s)):r=getKeyIdBytes(s)}}return r}var optionalSelf="undefined"!=typeof self?self:void 0,KeySystems={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},KeySystemFormats={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function keySystemFormatToKeySystemDomain(e){switch(e){case KeySystemFormats.FAIRPLAY:return KeySystems.FAIRPLAY;case KeySystemFormats.PLAYREADY:return KeySystems.PLAYREADY;case KeySystemFormats.WIDEVINE:return KeySystems.WIDEVINE;case KeySystemFormats.CLEARKEY:return KeySystems.CLEARKEY}}var KeySystemIds={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function keySystemIdToKeySystemDomain(e){return e===KeySystemIds.WIDEVINE?KeySystems.WIDEVINE:e===KeySystemIds.PLAYREADY?KeySystems.PLAYREADY:e===KeySystemIds.CENC||e===KeySystemIds.CLEARKEY?KeySystems.CLEARKEY:void 0}function keySystemDomainToKeySystemFormat(e){switch(e){case KeySystems.FAIRPLAY:return KeySystemFormats.FAIRPLAY;case KeySystems.PLAYREADY:return KeySystemFormats.PLAYREADY;case KeySystems.WIDEVINE:return KeySystemFormats.WIDEVINE;case KeySystems.CLEARKEY:return KeySystemFormats.CLEARKEY}}function getKeySystemsForConfig(e){var t,r=e.drmSystems,n=e.widevineLicenseUrl,a=r?_filterInstanceProperty(t=[KeySystems.FAIRPLAY,KeySystems.WIDEVINE,KeySystems.PLAYREADY,KeySystems.CLEARKEY]).call(t,(function(e){return!!r[e]})):[];return!a[KeySystems.WIDEVINE]&&n&&a.push(KeySystems.WIDEVINE),a}var _requestMediaKeySystemAccess=function(e){var t;return null!=optionalSelf&&null!=(e=optionalSelf.navigator)&&e.requestMediaKeySystemAccess?_bindInstanceProperty(t=self.navigator.requestMediaKeySystemAccess).call(t,self.navigator):null}();function getSupportedMediaKeySystemConfigurations(e,t,r,n){var a;switch(e){case KeySystems.FAIRPLAY:a=["cenc","sinf"];break;case KeySystems.WIDEVINE:case KeySystems.PLAYREADY:a=["cenc"];break;case KeySystems.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return createMediaKeySystemConfigurations(a,t,r,n)}function createMediaKeySystemConfigurations(e,t,r,n){return[{initDataTypes:e,persistentState:n.persistentState||"optional",distinctiveIdentifier:n.distinctiveIdentifier||"optional",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:_mapInstanceProperty(t).call(t,(function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null}})),videoCapabilities:_mapInstanceProperty(r).call(r,(function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}}))}]}function parsePlayReadyWRM(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,_Array$from(t)),n=r.substring(_indexOfInstanceProperty(r).call(r,"<"),r.length),a=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];if(a){var i=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(i){var s=base64Decode(i).subarray(0,16);return changeEndianness(s),s}}return null}var keyUriToKeyIdMap={},LevelKey=function(){function e(t,r,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;_classCallCheck$1(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=r,this.keyFormat=n,this.keyFormatVersions=a,this.iv=i,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!isFullSegmentEncryption(t)}return _createClass$1(e,[{key:"isSupported",value:function(){var e;if(this.method){if(isFullSegmentEncryption(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case KeySystemFormats.FAIRPLAY:case KeySystemFormats.WIDEVINE:case KeySystemFormats.PLAYREADY:case KeySystemFormats.CLEARKEY:return-1!==_indexOfInstanceProperty(e=["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"]).call(e,this.method)}}return!1}},{key:"getDecryptData",value:function(t){if(!this.encrypted||!this.uri)return null;if(isFullSegmentEncryption(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(logger.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue')),t=0);var r=createInitializationVector(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var n=convertDataUriToArrayBytes(this.uri);if(n)switch(this.keyFormat){case KeySystemFormats.WIDEVINE:this.pssh=n,n.length>=22&&(this.keyId=n.subarray(n.length-22,n.length-6));break;case KeySystemFormats.PLAYREADY:var a=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=mp4pssh(a,null,n),this.keyId=parsePlayReadyWRM(n);break;default:var i=n.subarray(0,16);if(16!==i.length){var s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i}if(!this.keyId||16!==this.keyId.byteLength){var o=keyUriToKeyIdMap[this.uri];if(!o){var l=_Object$keys(keyUriToKeyIdMap).length%_Number$MAX_SAFE_INTEGER;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),keyUriToKeyIdMap[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){keyUriToKeyIdMap={}}}]),e}();function createInitializationVector(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}var MASTER_PLAYLIST_REGEX=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,MASTER_PLAYLIST_MEDIA_REGEX=/#EXT-X-MEDIA:(.*)/g,IS_MEDIA_PLAYLIST=/^#EXT(?:INF|-X-TARGETDURATION):/m,LEVEL_PLAYLIST_REGEX_FAST=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),LEVEL_PLAYLIST_REGEX_SLOW=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),M3U8Parser=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"findGroup",value:function(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.id===t)return n}}},{key:"resolve",value:function(e,t){return urlToolkitExports.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return IS_MEDIA_PLAYLIST.test(e)}},{key:"parseMasterPlaylist",value:function(t,r){var n,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:hasVariableReferences(t)},i=[];for(MASTER_PLAYLIST_REGEX.lastIndex=0;null!=(n=MASTER_PLAYLIST_REGEX.exec(t));)if(n[1]){var s,o=new AttrList(n[1],a),l=substituteVariables(a,n[2]),c={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},u=o.decimalResolution("RESOLUTION");u&&(c.width=u.width,c.height=u.height),setCodecs(o.CODECS,c),null!=(s=c.unknownCodecs)&&s.length||i.push(c),a.levels.push(c)}else if(n[3]){var d=n[3],f=n[4];switch(d){case"SESSION-DATA":var h=new AttrList(f,a),p=h["DATA-ID"];p&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[p]=h);break;case"SESSION-KEY":var y=parseKey(f,r,a);y.encrypted&&y.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(y)):logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(f,'"'));break;case"DEFINE":addVariableDefinition(a,new AttrList(f,a),r);break;case"CONTENT-STEERING":var g=new AttrList(f,a);a.contentSteering={uri:e.resolve(g["SERVER-URI"],r),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=parseStartTimeOffset(f)}}var v=i.length>0&&i.length<a.levels.length;return a.levels=v?i:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,r,n){var a,i={},s=n.levels,o={AUDIO:_mapInstanceProperty(s).call(s,(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:_mapInstanceProperty(s).call(s,(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(MASTER_PLAYLIST_MEDIA_REGEX.lastIndex=0;null!==(a=MASTER_PLAYLIST_MEDIA_REGEX.exec(t));){var c=new AttrList(a[1],n),u=c.TYPE;if(u){var d=o[u],f=i[u]||[];i[u]=f;var h=c.LANGUAGE,p=c["ASSOC-LANGUAGE"],y=c.CHANNELS,g=c.CHARACTERISTICS,v=c["INSTREAM-ID"],m={attrs:c,bitrate:0,id:l++,groupId:c["GROUP-ID"]||"",name:c.NAME||h||"",type:u,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:h,url:c.URI?e.resolve(c.URI,r):""};if(p&&(m.assocLang=p),y&&(m.channels=y),g&&(m.characteristics=g),v&&(m.instreamId=v),null!=d&&d.length){var E=e.findGroup(d,m.groupId)||d[0];assignCodec(m,E,"audioCodec"),assignCodec(m,E,"textCodec")}f.push(m)}}return i}},{key:"parseLevelPlaylist",value:function(e,t,r,n,a,i){var s,o,l,c={url:t},u=new LevelDetails(t),d=u.fragments,f=[],h=null,p=0,y=0,g=0,v=0,m=0,E=null,$=new Fragment(n,c),S=-1,T=!1,I=null;for(LEVEL_PLAYLIST_REGEX_FAST.lastIndex=0,u.m3u8=e,u.hasVariableRefs=hasVariableReferences(e);null!==(s=LEVEL_PLAYLIST_REGEX_FAST.exec(e));){T&&(T=!1,($=new Fragment(n,c)).playlistOffset=g,$.start=g,$.sn=p,$.cc=v,m&&($.bitrate=m),$.level=r,h&&($.initSegment=h,h.rawProgramDateTime&&($.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),I&&($.setByteRange(I),I=null)));var _=s[1];if(_){var P;$.duration=_parseFloat$1(_);var b=_sliceInstanceProperty(P=" "+s[2]).call(P,1);$.title=b||null,$.tagList.push(b?["INF",_,b]:["INF",_])}else if(s[3]){if(isFiniteNumber($.duration)){var A;$.playlistOffset=g,$.start=g,l&&setFragLevelKeys($,l,u),$.sn=p,$.level=r,$.cc=v,d.push($);var R=_sliceInstanceProperty(A=" "+s[3]).call(A,1);$.relurl=substituteVariables(u,R),assignProgramDateTime($,E,f),E=$,g+=$.duration,p++,y=0,T=!0}}else{var k,C,O;if(!(s=s[0].match(LEVEL_PLAYLIST_REGEX_SLOW))){logger.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<s.length&&void 0===s[o];o++);var L=_sliceInstanceProperty(k=" "+s[o]).call(k,1),D=_sliceInstanceProperty(C=" "+s[o+1]).call(C,1),w=s[o+2]?_sliceInstanceProperty(O=" "+s[o+2]).call(O,1):null;switch(L){case"BYTERANGE":E?$.setByteRange(D,E):$.setByteRange(D);break;case"PROGRAM-DATE-TIME":$.rawProgramDateTime=D,$.tagList.push(["PROGRAM-DATE-TIME",D]),-1===S&&(S=d.length);break;case"PLAYLIST-TYPE":u.type=D.toUpperCase();break;case"MEDIA-SEQUENCE":p=u.startSN=_parseInt$1(D);break;case"SKIP":u.skippedSegments&&(u.playlistParsingError=new Error("#EXT-X-SKIP MUST NOT appear more than once in a Playlist"));var M=new AttrList(D,u),x=M.decimalInteger("SKIPPED-SEGMENTS");if(isFiniteNumber(x)){u.skippedSegments+=x;for(var N=x;N--;)d.push(null);p+=x}var F,U=M.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(U)u.recentlyRemovedDateranges=_concatInstanceProperty(F=u.recentlyRemovedDateranges||[]).call(F,U.split("\t"));break;case"TARGETDURATION":u.targetduration=Math.max(_parseInt$1(D),1);break;case"VERSION":u.version=_parseInt$1(D);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(D||w)&&$.tagList.push(w?[D,w]:[D]);break;case"DISCONTINUITY":v++,$.tagList.push(["DIS"]);break;case"GAP":$.gap=!0,$.tagList.push([L]);break;case"BITRATE":$.tagList.push([L,D]),m=1e3*_parseInt$1(D),isFiniteNumber(m)?$.bitrate=m:m=0;break;case"DATERANGE":var B=new AttrList(D,u),j=new DateRange(B,u.dateRanges[B.ID],u.dateRangeTagCount);u.dateRangeTagCount++,j.isValid||u.skippedSegments?u.dateRanges[j.id]=j:logger.warn('Ignoring invalid DATERANGE tag: "'.concat(D,'"')),$.tagList.push(["EXT-X-DATERANGE",D]);break;case"DEFINE":var G=new AttrList(D,u);"IMPORT"in G?importVariableDefinition(u,G,i):addVariableDefinition(u,G,t);break;case"DISCONTINUITY-SEQUENCE":u.startCC=v=_parseInt$1(D);break;case"KEY":var H=parseKey(D,t,u);if(H.isSupported()){if("NONE"===H.method){l=void 0;break}l||(l={}),l[H.keyFormat]&&(l=_extends({},l)),l[H.keyFormat]=H}else logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(D,'"'));break;case"START":u.startTimeOffset=parseStartTimeOffset(D);break;case"MAP":var K=new AttrList(D,u);if($.duration){var V=new Fragment(n,c);setInitSegment(V,K,r,l),h=V,$.initSegment=h,h.rawProgramDateTime&&!$.rawProgramDateTime&&($.rawProgramDateTime=h.rawProgramDateTime)}else{var W=$.byteRangeEndOffset;if(W){var Y,q=$.byteRangeStartOffset;I=_concatInstanceProperty(Y="".concat(W-q,"@")).call(Y,q)}else I=null;setInitSegment($,K,r,l),h=$,T=!0}h.cc=v;break;case"SERVER-CONTROL":var z=new AttrList(D);u.canBlockReload=z.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=z.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&z.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=z.optionalFloat("PART-HOLD-BACK",0),u.holdBack=z.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var X=new AttrList(D);u.partTarget=X.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=u.partList;Q||(Q=u.partList=[]);var J=y>0?Q[Q.length-1]:void 0,Z=y++,ee=new AttrList(D,u),te=new Part(ee,$,c,Z,J);Q.push(te),$.duration+=te.duration;break;case"PRELOAD-HINT":var re=new AttrList(D,u);u.preloadHint=re;break;case"RENDITION-REPORT":var ne=new AttrList(D,u);u.renditionReports=u.renditionReports||[],u.renditionReports.push(ne);break;default:logger.warn("line parsed but not handled: ".concat(s))}}}E&&!E.relurl?(d.pop(),g-=E.duration,u.partList&&(u.fragmentHint=E)):u.partList&&(assignProgramDateTime($,E,f),$.cc=v,u.fragmentHint=$,l&&setFragLevelKeys($,l,u));var ae=d.length,ie=d[0],se=d[ae-1];if((g+=u.skippedSegments*u.targetduration)>0&&ae&&se){u.averagetargetduration=g/ae;var oe=se.sn;u.endSN="initSegment"!==oe?oe:0,u.live||(se.endList=!0),ie&&!u.startCC&&(u.startCC=ie.cc),S>0&&(backfillProgramDateTimes(d,S),ie&&f.unshift(ie))}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(g+=u.fragmentHint.duration),u.totalduration=g,f.length&&u.dateRangeTagCount&&ie&&mapDateRanges(f,u),u.endCC=v,u}}]),e}();function mapDateRanges(e,t){for(var r=e.length,n=e[r-1],a=t.live?1/0:t.totalduration,i=_Object$keys(t.dateRanges),s=i.length;s--;){var o=t.dateRanges[i[s]],l=o.startDate.getTime();o.tagAnchor=n.ref;for(var c=r;c--;){var u=findFragmentWithStartDate(t,l,e,c,a);if(-1!==u){o.tagAnchor=t.fragments[u].ref;break}}}}function findFragmentWithStartDate(e,t,r,n,a){var i=r[n];if(i){var s,o=i.programDateTime;if(t>=o||0===n)if(t<=o+1e3*(((null==(s=r[n+1])?void 0:s.start)||a)-i.start)){var l=r[n].sn-e.startSN,c=e.fragments;if(c.length>r.length)for(var u=(r[n+1]||c[c.length-1]).sn-e.startSN;u>l;u--){var d=c[u].programDateTime;if(t>=d&&t<d+1e3*c[u].duration)return u}return l}}return-1}function parseKey(e,t,r){var n,a,i,s,o=new AttrList(e,r),l=null!=(i=o.METHOD)?i:"",c=o.URI,u=o.hexadecimalInteger("IV"),d=o.KEYFORMATVERSIONS,f=null!=(s=o.KEYFORMAT)?s:"identity";c&&o.IV&&!u&&logger.error("Invalid IV: ".concat(o.IV));var h=c?M3U8Parser.resolve(c,t):"",p=_filterInstanceProperty(n=_mapInstanceProperty(a=(d||"1").split("/")).call(a,Number)).call(n,_Number$isFinite);return new LevelKey(l,h,f,p,u)}function parseStartTimeOffset(e){var t=new AttrList(e).decimalFloatingPoint("TIME-OFFSET");return isFiniteNumber(t)?t:null}function setCodecs(e,t){var r,n,a=_filterInstanceProperty(r=(e||"").split(/[ ,]+/)).call(r,(function(e){return e}));_forEachInstanceProperty(n=["video","audio","text"]).call(n,(function(e){var r=_filterInstanceProperty(a).call(a,(function(t){return isCodecType(t,e)}));r.length&&(t["".concat(e,"Codec")]=r.join(","),a=_filterInstanceProperty(a).call(a,(function(e){return-1===_indexOfInstanceProperty(r).call(r,e)})))})),t.unknownCodecs=a}function assignCodec(e,t,r){var n=t[r];n&&(e[r]=n)}function backfillProgramDateTimes(e,t){for(var r=e[t],n=t;n--;){var a=e[n];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}function assignProgramDateTime(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function setInitSegment(e,t,r,n){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",n&&(e.levelkeys=n),e.initSegment=null}function setFragLevelKeys(e,t,r){var n;e.levelkeys=t;var a=r.encryptedFragments;a.length&&a[a.length-1].levelkeys===t||!_someInstanceProperty(n=_Object$keys(t)).call(n,(function(e){return t[e].isCommonEncryption}))||a.push(e)}function updateFromToPTS(e,t){var r=t.startPTS;if(isFiniteNumber(r)){var n,a=0;t.sn>e.sn?(a=r-e.start,n=e):(a=e.start-r,n=t),n.duration!==a&&n.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function updateFragPTSDTS(e,t,r,n,a,i){n-r<=0&&(logger.warn("Fragment should have a positive duration",t),n=r+t.duration,i=a+t.duration);var s=r,o=n,l=t.startPTS,c=t.endPTS;if(isFiniteNumber(l)){var u=Math.abs(l-r);isFiniteNumber(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,s=Math.max(r,l),r=Math.min(r,l),a=Math.min(a,t.startDTS),o=Math.min(n,c),n=Math.max(n,c),i=Math.max(i,t.endDTS)}var d=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(n-t.start),t.startPTS=r,t.maxStartPTS=s,t.startDTS=a,t.endPTS=n,t.minEndPTS=o,t.endDTS=i;var f,h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;var p=h-e.startSN,y=e.fragments;for(y[p]=t,f=p;f>0;f--)updateFromToPTS(y[f],y[f-1]);for(f=p;f<y.length-1;f++)updateFromToPTS(y[f],y[f+1]);return e.fragmentHint&&updateFromToPTS(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,d}function mergeDetails(e,t){for(var r,n=null,a=e.fragments,i=a.length-1;i>=0;i--){var s=a[i].initSegment;if(s){n=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var o,l=0;mapFragmentIntersection(e,t,(function(e,r){e.relurl&&(l=e.cc-r.cc),isFiniteNumber(e.startPTS)&&isFiniteNumber(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(o=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,n=e.initSegment)}));var c,u=t.fragmentHint?_concatInstanceProperty(r=t.fragments).call(r,t.fragmentHint):t.fragments;if(n&&_forEachInstanceProperty(u).call(u,(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=n)?void 0:t.relurl)||(e.initSegment=n)})),t.skippedSegments)if(t.deltaUpdateFailed=_someInstanceProperty(c=t.fragments).call(c,(function(e){return!e})),t.deltaUpdateFailed){logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=t.skippedSegments;d--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC||(t.startCC=t.fragments[0].cc)}else{var f;t.canSkipDateRanges&&(t.dateRanges=mergeDateRanges(e.dateRanges,t));var h=_filterInstanceProperty(f=e.fragments).call(f,(function(e){return e.rawProgramDateTime}));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var p=1;p<u.length;p++)null===u[p].programDateTime&&assignProgramDateTime(u[p],u[p-1],h);mapDateRanges(h,t)}var y=t.fragments;if(l){logger.warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<y.length;g++)y[g].cc+=l}t.skippedSegments&&(t.startCC=t.fragments[0].cc),mapPartIntersection(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),o?updateFragPTSDTS(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):adjustSliding(e,t),y.length&&(t.totalduration=t.edge-y[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var v=t.advancedDateTime;if(t.advanced&&v){var m=t.edge;t.driftStart||(t.driftStartTime=v,t.driftStart=m),t.driftEndTime=v,t.driftEnd=m}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function mergeDateRanges(e,t){var r=t.dateRanges,n=t.recentlyRemovedDateranges,a=_extends({},e);n&&_forEachInstanceProperty(n).call(n,(function(e){delete a[e]}));var i,s=_Object$keys(a).length;s&&_forEachInstanceProperty(i=_Object$keys(r)).call(i,(function(e){var t=a[e],n=new DateRange(r[e].attr,t);n.isValid?(a[e]=n,t||(n.tagOrder+=s)):logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(_JSON$stringify(r[e].attr),'"'))}));return a}function mapPartIntersection(e,t,r){if(e&&t)for(var n=0,a=0,i=e.length;a<=i;a++){var s=e[a],o=t[a+n];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):n--}}function mapFragmentIntersection(e,t,r){for(var n,a,i=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,o=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,l=t.startSN-e.startSN,c=t.fragmentHint?_concatInstanceProperty(n=t.fragments).call(n,t.fragmentHint):t.fragments,u=e.fragmentHint?_concatInstanceProperty(a=e.fragments).call(a,e.fragmentHint):e.fragments,d=s;d<=o;d++){var f=u[l+d],h=c[d];i&&!h&&f&&(h=t.fragments[d]=f),f&&h&&r(f,h)}}function adjustSliding(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,i=n>=0,s=0;if(i&&n<a.length)s=a[n].start;else if(i&&t.startSN===e.endSN+1)s=e.fragmentEnd;else if(i&&r)s=e.fragmentStart+n*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;s=e.fragmentStart}addSliding(t,s)}function addSliding(e,t){if(t){for(var r=e.fragments,n=e.skippedSegments;n<r.length;n++)r[n].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function computeReloadInterval(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*r>t){var a=1e3*n[n.length-1].duration;a<r&&(r=a)}}else r/=2;return Math.round(r)}function getFragmentWithSN(e,t,r){if(!e)return null;var n=e.fragments[t-e.startSN];return n||((n=e.fragmentHint)&&n.sn===t?n:t<e.startSN&&r&&r.sn===t?r:null)}function getPartWith(e,t,r){return e?findPart(e.partList,t,r):null}function findPart(e,t,r){if(e)for(var n=e.length;n--;){var a=e[n];if(a.index===r&&a.fragment.sn===t)return a}return null}function reassignFragmentLevelIndexes(e){_forEachInstanceProperty(e).call(e,(function(e,t){var r,n=null==(r=e.details)?void 0:r.fragments;n&&_forEachInstanceProperty(n).call(n,(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function findFirstFragWithCC(e,t){for(var r=0,n=e.length;r<n;r++){var a;if((null==(a=e[r])?void 0:a.cc)===t)return e[r]}return null}function shouldAlignOnDiscontinuities(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}function adjustFragmentStart(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function adjustSlidingStart(e,t){for(var r=t.fragments,n=0,a=r.length;n<a;n++)adjustFragmentStart(r[n],e);t.fragmentHint&&adjustFragmentStart(t.fragmentHint,e),t.alignedSliding=!0}function alignStream(e,t){e&&(alignDiscontinuities(t,e),!t.alignedSliding&&e&&alignMediaPlaylistByPDT(t,e),t.alignedSliding||!e||t.skippedSegments||adjustSliding(e,t,!1))}function alignDiscontinuities(e,t){if(shouldAlignOnDiscontinuities(t,e)){var r=Math.min(t.endCC,e.endCC),n=findFirstFragWithCC(t.fragments,r),a=findFirstFragWithCC(e.fragments,r);if(n&&a)logger.log("Aligning playlist at start of dicontinuity sequence ".concat(r)),adjustSlidingStart(n.start-a.start,e)}}function alignMediaPlaylistByPDT(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,n=t.fragments;if(r.length&&n.length){var a,i,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(a=findFirstFragWithCC(n,s),i=findFirstFragWithCC(r,s)),a&&i||(i=findFirstFragWithCC(r,(a=n[Math.floor(n.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=a.programDateTime,l=i.programDateTime;if(o&&l)adjustSlidingStart((l-o)/1e3-(i.start-a.start),e)}}}var TimeRanges={toString:function(e){for(var t="",r=e.length,n=0;n<r;n++){var a;t+=_concatInstanceProperty(a="[".concat(e.start(n).toFixed(3),"-")).call(a,e.end(n).toFixed(3),"]")}return t}},State={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},BaseStreamController=function(e){_inherits(r,TaskLoop);var t=_createSuper(r);function r(e,n,a,i,s){var o;return _classCallCheck$1(this,r),(o=t.call(this,i,e.logger)).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=State.STOPPED,o.playlistType=void 0,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.buffering=!0,o.loadingParts=!1,o.loopSn=void 0,o.onMediaSeeking=function(){var e,t=_assertThisInitialized(o),r=t.config,n=t.fragCurrent,a=t.media,i=t.mediaBuffer,s=t.state,l=a?a.currentTime:0,c=BufferHelper.bufferInfo(i||a,l,r.maxBufferHole);if(o.log(_concatInstanceProperty(e="media seeking to ".concat(isFiniteNumber(l)?l.toFixed(3):l,", state: ")).call(e,s)),o.state===State.ENDED)o.resetLoadingState();else if(n){var u=r.maxFragLookUpTolerance,d=n.start-u,f=n.start+n.duration+u;if(!c.len||f<c.start||d>c.end){var h=l>f;(l<d||h)&&(h&&n.loader&&(o.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),n.abortRequests(),o.resetLoadingState()),o.fragPrevious=null)}}if(a&&(o.fragmentTracker.removeFragmentsInRange(l,1/0,o.playlistType,!0),l>o.lastCurrentTime&&(o.lastCurrentTime=l),!o.loadingParts)){var p,y=Math.max(c.end,l),g=o.shouldLoadParts(o.getLevelDetails(),y);if(g)o.log(_concatInstanceProperty(p="LL-Part loading ON after seeking to ".concat(l.toFixed(2)," with buffer @")).call(p,y.toFixed(2))),o.loadingParts=g}o.hls.hasEnoughToStart||c.len||(o.log("setting startPosition to ".concat(l," because of seek before start")),o.nextLoadPosition=o.startPosition=l),o.tickImmediate()},o.onMediaEnded=function(){o.log("setting startPosition to 0 because media ended"),o.startPosition=o.lastCurrentTime=0,o.triggerEnded()},o.playlistType=s,o.hls=e,o.fragmentLoader=new FragmentLoader(e.config),o.keyLoader=a,o.fragmentTracker=n,o.config=e.config,o.decrypter=new Decrypter(e.config),o}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==State.STOPPED){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=State.STOPPED}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"_streamEnded",value:function(e,t){var r=void 0!==this.config.timelineOffset,n=e.nextStart,a=n&&(!r||n<t.edge);if(t.live||a||!e.end||!this.media)return!1;var i=t.partList;if(null!=i&&i.length){var s=i[i.length-1];return BufferHelper.isBuffered(this.media,s.start+s.duration/2)}var o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}},{key:"getLevelDetails",value:function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details}},{key:"onMediaAttached",value:function(e,t){var r=this.media=this.mediaBuffer=t.media;r.removeEventListener("seeking",this.onMediaSeeking),r.removeEventListener("ended",this.onMediaEnded),r.addEventListener("seeking",this.onMediaSeeking),r.addEventListener("ended",this.onMediaEnded);var n=this.config;this.levels&&n.autoStartLoad&&this.state===State.STOPPED&&this.startLoad(n.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,n=this.media;null!==n&&(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),n.removeEventListener("seeking",this.onMediaSeeking),n.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r?this.resetTransmuxer():(this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()))}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"triggerEnded",value:function(){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=State.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,_get(_getPrototypeOf(r.prototype),"onHandlerDestroyed",this).call(this)}},{key:"loadFragment",value:function(e,t,r){var n=this.hls.config;if(n.interstitialsController&&!1!==n.enableInterstitialPlayback&&e.type!==PlaylistLevelType.SUBTITLE){var a=this.hls.interstitialsManager,i=null==a?void 0:a.bufferingItem;if(i){var s=i.event;if(s){if(s.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return}else{var o;if(e.end<=i.start&&!1===(null==(o=t.details)?void 0:o.live))return;if(e.start>i.end&&i.nextEvent)return}}}this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}},{key:"_loadFragForPlayback",value:function(e,t,r){var n=this;this._doFragLoad(e,t,r,(function(e){var t,r,a,i=e.frag;if(n.fragContextChanged(i))return n.warn(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(a="".concat(i.type," sn: ")).call(a,i.sn)).call(r,e.part?" part: "+e.part.index:""," of ")).call(t,n.fragInfo(i,!1,e.part),") was dropped during download.")),void n.fragmentTracker.removeFragment(i);i.stats.chunkCount++,n._handleFragmentLoadProgress(e)})).then((function(e){if(e){var t=n.state,r=e.frag;if(n.fragContextChanged(r))(t===State.FRAG_LOADING||!n.fragCurrent&&t===State.PARSING)&&(n.fragmentTracker.removeFragment(r),n.state=State.IDLE);else{var a,i,s;if("payload"in e)n.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Loaded ".concat(r.type," sn: ")).call(s,r.sn," of ")).call(i,n.playlistLabel()," ")).call(a,r.level)),n.hls.trigger(Events.FRAG_LOADED,e);n._handleFragmentLoadComplete(e)}}})).catch((function(t){n.state!==State.STOPPED&&n.state!==State.ERROR&&(n.warn("Frag error: ".concat((null==t?void 0:t.message)||t)),n.resetFragmentLoading(e))}))}},{key:"clearTrackerIfNeeded",value:function(e){var t,r=this.fragmentTracker;if(r.getState(e)===FragmentState.APPENDING){var n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),i=Math.max(e.duration,a?a.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(i,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===FragmentState.PARTIAL&&r.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t){if(e-t){var r={startOffset:e,endOffset:t,type:arguments.length>2&&void 0!==arguments[2]?arguments[2]:null};this.hls.trigger(Events.BUFFER_FLUSHING,r)}}},{key:"_loadInitSegment",value:function(e,t){var r=this;this._doFragLoad(e,t).then((function(e){var t=null==e?void 0:e.frag;if(!t||r.fragContextChanged(t)||!r.levels)throw new Error("init load aborted");return e})).then((function(e){var t=r.hls,n=e.frag,a=e.payload,i=n.decryptdata;if(a&&a.byteLength>0&&null!=i&&i.key&&i.iv&&isFullSegmentEncryption(i.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(a),i.key.buffer,i.iv.buffer,getAesModeFromFullSegmentMethod(i.method)).catch((function(e){throw t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:n}),e})).then((function(a){var i=self.performance.now();return t.trigger(Events.FRAG_DECRYPTED,{frag:n,payload:a,stats:{tstart:s,tdecrypt:i}}),e.payload=a,r.completeInitSegmentLoad(e)}))}return r.completeInitSegmentLoad(e)})).catch((function(t){r.state!==State.STOPPED&&r.state!==State.ERROR&&(r.warn(t),r.resetFragmentLoading(e))}))}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==State.STOPPED&&(this.state=State.IDLE),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var r,n,a,i,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="Buffered ".concat(e.type," sn: ")).call(i,e.sn)).call(a,t?" part: "+t.index:""," of ")).call(n,this.fragInfo(e,!1,t)," > buffer:")).call(r,s?TimeRanges.toString(BufferHelper.getBuffered(s)):"(detached)",")")),isMediaFragment(e)){var o;if(e.type!==PlaylistLevelType.SUBTITLE){var l,c=e.elementaryStreams;if(!_someInstanceProperty(l=_Object$keys(c)).call(l,(function(e){return!!c[e]})))return void(this.state=State.IDLE)}var u=null==(o=this.levels)?void 0:o[e.level];null!=u&&u.fragmentError&&(this.log("Resetting level fragment error count of ".concat(u.fragmentError," on frag buffered")),u.fragmentError=0)}this.state=State.IDLE}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var r=e.frag,n=e.part,a=e.partsLoaded,i=!a||0===a.length||_someInstanceProperty(a).call(a,(function(e){return!e})),s=new ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!i);t.flush(s)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t){var r,n,a,i,s,o,l=this,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3?arguments[3]:void 0;this.fragCurrent=e;var d=null==t?void 0:t.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level".concat(d?"":" detail","s"));var f,h,p,y,g=null;!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(e,d.encryptedFragments):(this.log(_concatInstanceProperty(f=_concatInstanceProperty(h=_concatInstanceProperty(p=_concatInstanceProperty(y="Loading key for ".concat(e.sn," of [")).call(y,d.startSN,"-")).call(p,d.endSN,"], ")).call(h,this.playlistLabel()," ")).call(f,e.level)),this.state=State.KEY_LOADING,this.fragCurrent=e,g=this.keyLoader.load(e).then((function(e){if(!l.fragContextChanged(e.frag))return l.hls.trigger(Events.KEY_LOADED,e),l.state===State.KEY_LOADING&&(l.state=State.IDLE),e})),this.hls.trigger(Events.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(g=_Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var v=this.fragPrevious;if(isMediaFragment(e)&&(!v||e.sn!==v.sn)){var m,E,$=this.shouldLoadParts(t.details,e.end);if($!==this.loadingParts)this.log(_concatInstanceProperty(m=_concatInstanceProperty(E="LL-Part loading ".concat($?"ON":"OFF"," loading sn ")).call(E,null==v?void 0:v.sn,"->")).call(m,e.sn)),this.loadingParts=$}if(c=Math.max(e.start,c||0),this.loadingParts&&isMediaFragment(e)){var S=d.partList;if(S&&u){c>e.end&&d.fragmentHint&&(e=d.fragmentHint);var T=this.getNextPart(S,e,c);if(T>-1){var I,_,P,b,A,R,k,C,O,L,D=S[T];return e=this.fragCurrent=D.fragment,this.log(_concatInstanceProperty(I=_concatInstanceProperty(_=_concatInstanceProperty(P=_concatInstanceProperty(b=_concatInstanceProperty(A=_concatInstanceProperty(R=_concatInstanceProperty(k=_concatInstanceProperty(C=_concatInstanceProperty(O="Loading ".concat(e.type," sn: ")).call(O,e.sn," part: ")).call(C,D.index," (")).call(k,T,"/")).call(R,S.length-1,") of ")).call(A,this.fragInfo(e,!1,D),") cc: ")).call(b,e.cc," [")).call(P,d.startSN,"-")).call(_,d.endSN,"], target: ")).call(I,_parseFloat$1(c.toFixed(3)))),this.nextLoadPosition=D.start+D.duration,this.state=State.FRAG_LOADING,L=g?g.then((function(r){return!r||l.fragContextChanged(r.frag)?null:l.doFragPartsLoad(e,D,t,u)})).catch((function(e){return l.handleFragLoadError(e)})):this.doFragPartsLoad(e,D,t,u).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(Events.FRAG_LOADING,{frag:e,part:D,targetBufferTime:c}),null===this.fragCurrent?_Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):L}if(!e.url||this.loadedEndOfParts(S,c))return _Promise.resolve(null)}}if(isMediaFragment(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(c.toFixed(2))),this.loadingParts=!1;else if(!e.url)return _Promise.resolve(null);this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Loading ".concat(e.type," sn: ")).call(s,e.sn," of ")).call(i,this.fragInfo(e,!1),") cc: ")).call(a,e.cc," ")).call(n,d?"["+d.startSN+"-"+d.endSN+"]":"",", target: ")).call(r,_parseFloat$1(c.toFixed(3)))),isFiniteNumber(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=State.FRAG_LOADING;var w,M=this.config.progressive;return w=M&&g?g.then((function(t){return!t||l.fragContextChanged(null==t?void 0:t.frag)?null:l.fragmentLoader.load(e,u)})).catch((function(e){return l.handleFragLoadError(e)})):_Promise.all([this.fragmentLoader.load(e,M?u:void 0),g]).then((function(e){var t=_slicedToArray(e,1)[0];return!M&&t&&u&&u(t),t})).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(Events.FRAG_LOADING,{frag:e,targetBufferTime:c}),null===this.fragCurrent?_Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):w}},{key:"doFragPartsLoad",value:function(e,t,r,n){var a=this;return new _Promise((function(i,s){var o,l=[],c=null==(o=r.details)?void 0:o.partList;!function t(o){a.fragmentLoader.loadPart(e,o,n).then((function(n){l[o.index]=n;var s=n.part;a.hls.trigger(Events.FRAG_LOADED,n);var u=getPartWith(r.details,e.sn,o.index+1)||findPart(c,e.sn,o.index+1);if(!u)return i({frag:e,part:s,partsLoaded:l});t(u)})).catch(s)}(t)}))}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;e.data&&t.details===ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(Events.ERROR,t)}else this.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===State.PARSING){var r=t.frag,n=t.part,a=t.level,i=self.performance.now();r.stats.parsing.end=i,n&&(n.stats.parsing.end=i);var s,o=this.getLevelDetails(),l=o&&r.sn>o.endSN||this.shouldLoadParts(o,r.end);if(l!==this.loadingParts)this.log(_concatInstanceProperty(s="LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @")).call(s,r.end.toFixed(2))),this.loadingParts=l;this.updateLevelTiming(r,n,a,e.partial)}else this.fragCurrent||this.state===State.STOPPED||this.state===State.ERROR||(this.state=State.IDLE)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var r,n,a=e.partList[0];if(t>=a.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0))if((this.hls.hasEnoughToStart?(null==(n=this.media)?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t,r,n=this.levels,a=this.fragCurrent,i=e.level,s=e.sn,o=e.part;if(null==n||!n[i])return this.warn(_concatInstanceProperty(t=_concatInstanceProperty(r="Levels object was unset while buffering fragment ".concat(s," of ")).call(r,this.playlistLabel()," ")).call(t,i,". The current chunk will not be buffered.")),null;var l=n[i],c=l.details,u=o>-1?getPartWith(c,s,o):null,d=u?u.fragment:getFragmentWithSN(c,s,a);return d?(a&&a!==d&&(d.stats=a.stats),{frag:d,part:u,level:l}):null}},{key:"bufferFragmentData",value:function(e,t,r,n,a){var i;if(e&&this.state===State.PARSING){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=appendUint8Array(s,o)),null!=(i=l)&&i.length){var c={type:e.type,frag:t,part:r,chunkMeta:n,parent:t.type,data:l};if(this.hls.trigger(Events.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(BufferHelper.isBuffered(t,t.currentTime)){var r=t.currentTime,n=BufferHelper.bufferInfo(t,r,0),a=e.duration,i=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(e.start-i,n.end-i),r+i);e.start-s>i&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var r,n=this.getLoadPosition();if(!isFiniteNumber(n))return null;var a=this.lastCurrentTime>n||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,r,n){var a=BufferHelper.bufferInfo(e,t,n);if(0===a.len&&void 0!==a.nextStart){var i=this.fragmentTracker.getBufferedFrag(t,r);if(i&&(a.nextStart<=i.end||i.gap))return BufferHelper.bufferInfo(e,t,Math.max(a.nextStart,n))}return a}},{key:"getMaxBufferLength",value:function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)}},{key:"reduceMaxBufferLength",value:function(e,t){var r=this.config,n=Math.max(Math.min(e-t,r.maxBufferLength),t),a=Math.max(e-3*t,r.maxMaxBufferLength/2,n);return a>=n&&(r.maxMaxBufferLength=a,this.warn("Reduce max buffer length to ".concat(a,"s")),!0)}},{key:"getAppendedFrag",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:PlaylistLevelType.MAIN,n=null==(t=this.fragmentTracker)?void 0:t.getAppendedFrag(e,r);return n&&"fragment"in n?n.fragment:n}},{key:"getNextFragment",value:function(e,t){var r=t.fragments,n=r.length;if(!n)return null;var a=this.config,i=r[0].start,s=a.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l,c=a.initialLiveManifestSize;if(n<c)return this.warn(_concatInstanceProperty(l="Not enough fragments to start playback (have: ".concat(n,", need: ")).call(l,c,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<i){var u,d,f,h;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,r);var p=this.hls.startPosition,y=this.hls.liveSyncPosition,g=o?(-1!==p?p:y)||o.start:e;this.log(_concatInstanceProperty(u=_concatInstanceProperty(d=_concatInstanceProperty(f="Setting startPosition to ".concat(g," to match initial live edge. mainStart: ")).call(f,p," liveSyncPosition: ")).call(d,y," frag.start: ")).call(u,null==(h=o)?void 0:h.start)),this.startPosition=this.nextLoadPosition=g}}else e<=i&&(o=r[0]);if(!o){var v=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,v,t)}return this.mapToInitFragWhenRequired(o)}},{key:"isLoopLoading",value:function(e,t){var r=this.fragmentTracker.getState(e);return(r===FragmentState.OK||r===FragmentState.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}},{key:"getNextFragmentLoopLoading",value:function(e,t,r,n,a){var i=null;if(e.gap&&(i=this.getNextFragment(this.nextLoadPosition,t))&&!i.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,n,0);if(null!==s&&r.len+s.len>=a){var o,l=i.sn;if(this.loopSn!==l)this.log(_concatInstanceProperty(o='buffer full after gaps in "'.concat(n,'" playlist starting at sn: ')).call(o,l)),this.loopSn=l;return null}}return this.loopSn=void 0,i}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,r){for(var n=-1,a=!1,i=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(i=i&&!l.independent,n>-1&&r<l.start)break;var c=l.loaded;c?n=-1:(a||l.independent||i)&&l.fragment===t&&(n=s),a=c}return n}},{key:"loadedEndOfParts",value:function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded}},{key:"getInitialLiveFragment",value:function(e,t){var r=this.fragPrevious,n=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime)),n=findFragmentByPDT(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var a=r.sn+1;if(a>=e.startSN&&a<=e.endSN){var i=t[a-e.startSN];r.cc===i.cc&&(n=i,this.log("Live playlist, switching playlist, load frag with next SN: ".concat(n.sn)))}n||(n=findFragWithCC(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(n.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(n=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}},{key:"getFragmentAtPosition",value:function(e,t,r){var n,a,i=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,c=r.fragmentHint,u=i.maxFragLookUpTolerance,d=r.partList,f=!!(this.loadingParts&&null!=d&&d.length&&c);(f&&c&&!this.bitrateTest&&d[d.length-1].fragment.sn===c.sn&&(o=_concatInstanceProperty(o).call(o,c),l=c.sn),e<t)?n=findFragmentByPTS(s,o,e,e<this.lastCurrentTime||e>t-u||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:u):n=o[o.length-1];if(n){var h=n.sn-r.startSN,p=this.fragmentTracker.getState(n);if((p===FragmentState.OK||p===FragmentState.PARTIAL&&n.gap)&&(s=n),s&&n.sn===s.sn&&(!f||d[0].fragment.sn>n.sn||!r.live&&!f))if(s&&n.level===s.level){var y=o[h+1];n=n.sn<l&&this.fragmentTracker.getState(y)!==FragmentState.OK?y:null}}return n}},{key:"alignPlaylists",value:function(e,t,r){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,i=!t,s=e.alignedSliding&&isFiniteNumber(a);if(i||!s&&!a){var o,l,c;alignStream(r,e);var u=e.fragmentStart;return this.log(_concatInstanceProperty(o=_concatInstanceProperty(l=_concatInstanceProperty(c="Live playlist sliding: ".concat(u.toFixed(2)," start-sn: ")).call(c,t?t.startSN:"na","->")).call(l,e.startSN," fragments: ")).call(o,n)),u}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r){var n,a,i=null!==this.startTimeOffset,s=i?this.startTimeOffset:e.startTimeOffset;if(null!==s&&isFiniteNumber(s))r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(_concatInstanceProperty(n=_concatInstanceProperty(a="Setting startPosition to ".concat(r," for start time offset ")).call(a,s," found in ")).call(n,i?"multivariant":"media"," playlist")),this.startPosition=r;else e.live?(r=this.hls.liveSyncPosition||t,this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0);this.lastCurrentTime=r}this.nextLoadPosition=r}},{key:"getLoadPosition",value:function(){var e,t=this.media,r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}},{key:"handleFragLoadAborted",value:function(e,t){var r,n,a;this.transmuxer&&e.type===this.playlistType&&isMediaFragment(e)&&e.stats.aborted&&(this.warn(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="Fragment ".concat(e.sn)).call(a,t?" part "+t.index:""," of ")).call(n,this.playlistLabel()," ")).call(r,e.level," was aborted")),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===State.FRAG_LOADING_WAITING_RETRY)||(this.state=State.IDLE)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var n=t.frag;if(n&&n.type===e&&this.levels)if(this.fragContextChanged(n)){var a,i;this.warn(_concatInstanceProperty(a="Frag load error must match current frag to retry ".concat(n.url," > ")).call(a,null==(i=this.fragCurrent)?void 0:i.url))}else{var s=t.details===ErrorDetails.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(n,!0);var o=t.errorAction,l=o||{},c=l.action,u=_flagsInstanceProperty(l),d=l.retryCount,f=void 0===d?0:d,h=l.retryConfig,p=!!o&&!!h,y=p&&c===NetworkErrorAction.RetryRequest,g=p&&!o.resolved&&u===ErrorActionFlags.MoveAllAlternatesMatchingHost;if(!y&&g&&isMediaFragment(n)&&!n.endList)this.resetFragmentErrors(e),this.treatAsGap(n),o.resolved=!0;else if((y||g)&&f<h.maxNumRetry){var v,m,E,$,S,T;this.resetStartWhenNotLoaded(this.levelLastLoaded);var I=getRetryDelay(h,f);this.warn(_concatInstanceProperty(v=_concatInstanceProperty(m=_concatInstanceProperty(E=_concatInstanceProperty($=_concatInstanceProperty(S=_concatInstanceProperty(T="Fragment ".concat(n.sn," of ")).call(T,e," ")).call(S,n.level," errored with ")).call($,t.details,", retrying loading ")).call(E,f+1,"/")).call(m,h.maxNumRetry," in ")).call(v,I,"ms")),o.resolved=!0,this.retryDate=self.performance.now()+I,this.state=State.FRAG_LOADING_WAITING_RETRY}else if(h&&o){var _;if(this.resetFragmentErrors(e),!(f<h.maxNumRetry))return void this.warn(_concatInstanceProperty(_="".concat(t.details," reached or exceeded max retry (")).call(_,f,")"));s||c===NetworkErrorAction.RemoveAlternatePermanently||(o.resolved=!0)}else c===NetworkErrorAction.SendAlternateToPenaltyBox?this.state=State.WAITING_LEVEL:this.state=State.ERROR;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===State.PARSING||this.state===State.PARSED){var t=e.frag,r=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,r),a=n&&n.len>.5;a&&this.reduceMaxBufferLength(n.len,(null==t?void 0:t.duration)||10);var i=!a;return i&&this.warn("Buffer full error while media.currentTime is not buffered, flush ".concat(r," buffer")),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),i}return!1}},{key:"resetFragmentErrors",value:function(e){e===PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==State.STOPPED&&(this.state=State.IDLE)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var n=BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,r),this.state===State.ENDED&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==State.STOPPED&&(this.state=State.IDLE)}},{key:"resetStartWhenNotLoaded",value:function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){var t,r;this.warn(_concatInstanceProperty(t=_concatInstanceProperty(r="The loading context changed while buffering fragment ".concat(e.sn," of ")).call(r,this.playlistLabel()," ")).call(t,e.level,". This chunk will not be buffered.")),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,r,n){var a,i,s,o,l,c=this,u=r.details;if(u){if(!_reduceInstanceProperty(a=_Object$keys(e.elementaryStreams)).call(a,(function(t,a){var i=e.elementaryStreams[a];if(i){var s,o,l=i.endPTS-i.startPTS;if(l<=0)return c.warn(_concatInstanceProperty(s=_concatInstanceProperty(o="Could not parse fragment ".concat(e.sn," ")).call(o,a," duration reliably (")).call(s,l,")")),t||!1;var d=n?0:updateFragPTSDTS(u,e,i.startPTS,i.endPTS,i.startDTS,i.endDTS);return c.hls.trigger(Events.LEVEL_PTS_UPDATED,{details:u,level:r,drift:d,type:a,frag:e,start:i.startPTS,end:i.endPTS}),!0}return t}),!1)&&null===(null==(l=this.transmuxer)?void 0:l.error)){var d,f,h,p,y=new Error(_concatInstanceProperty(d=_concatInstanceProperty(f="Found no media in fragment ".concat(e.sn," of ")).call(f,this.playlistLabel()," ")).call(d,e.level," resetting transmuxer to fallback to playlist timing"));if(0===r.fragmentError&&this.treatAsGap(e,r),this.warn(y.message),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,error:y,frag:e,reason:_concatInstanceProperty(h=_concatInstanceProperty(p="Found no media in msn ".concat(e.sn," of ")).call(p,this.playlistLabel(),' "')).call(h,r.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=State.PARSED,this.log(_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Parsed ".concat(e.type," sn: ")).call(o,e.sn)).call(s,t?" part: "+t.index:""," of ")).call(i,this.fragInfo(e,!1,t),")")),this.hls.trigger(Events.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===PlaylistLevelType.MAIN?"level":"track"}},{key:"fragInfo",value:function(e){var t,r,n,a,i,s,o,l=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],c=arguments.length>2?arguments[2]:void 0;return _concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="".concat(this.playlistLabel()," ")).call(i,e.level," (")).call(a,c?"part":"frag",":[")).call(n,(null!=(s=l&&!c?e.startPTS:(c||e).start)?s:NaN).toFixed(3),"-")).call(r,(null!=(o=l&&!c?e.endPTS:(c||e).end)?o:NaN).toFixed(3),"]")).call(t,c&&"main"===e.type?"INDEPENDENT="+(c.independent?"YES":"NO"):"")}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t,r=this._state;r!==e&&(this._state=e,this.log(_concatInstanceProperty(t="".concat(r,"->")).call(t,e)))}}]),r}(),ChunkCache=function(){function e(){_classCallCheck$1(this,e),this.chunks=[],this.dataLength=0}return _createClass$1(e,[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:concatUint8Arrays(t,r),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}]),e}();function concatUint8Arrays(e,t){for(var r=new Uint8Array(t),n=0,a=0;a<e.length;a++){var i=e[a];r.set(i,n),n+=i.length}return r}var eventemitter3={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new a(n,i||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}_Object$create&&(n.prototype=_Object$create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(r?_sliceInstanceProperty(n).call(n,1):n);return _Object$getOwnPropertySymbols?_concatInstanceProperty(a).call(a,_Object$getOwnPropertySymbols(e)):a},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,i=n.length,s=new Array(i);a<i;a++)s[a]=n[a].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,a,i,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,c,u=this._events[o],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,a),!0;case 5:return u.fn.call(u.context,t,n,a,i),!0;case 6:return u.fn.call(u.context,t,n,a,i,s),!0}for(c=1,l=new Array(d-1);c<d;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var f,h=u.length;for(c=0;c<h;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),d){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,n);break;case 4:u[c].fn.call(u[c].context,t,n,a);break;default:if(!l)for(f=1,l=new Array(d-1);f<d;f++)l[f-1]=arguments[f];u[c].fn.apply(u[c].context,l)}}return!0},o.prototype.on=function(e,t,r){return i(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return i(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,a){var i=r?r+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var o=this._events[i];if(o.fn)o.fn!==t||a&&!o.once||n&&o.context!==n||s(this,i);else{for(var l=0,c=[],u=o.length;l<u;l++)(o[l].fn!==t||a&&!o[l].once||n&&o[l].context!==n)&&c.push(o[l]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(eventemitter3);var eventemitter3Exports=eventemitter3.exports,EventEmitter=getDefaultExportFromCjs(eventemitter3Exports),version="1.6.0-beta.2",workerStore={};function hasUMDWorker(){return"function"==typeof __HLS_WORKER_BUNDLE__}function injectWorker(){var e=workerStore[version];if(e)return e.clientCount++,e;var t=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(".concat(__HLS_WORKER_BUNDLE__.toString(),")(true);")],{type:"text/javascript"}),r=_URL.createObjectURL(t),n={worker:new self.Worker(r),objectURL:r,clientCount:1};return workerStore[version]=n,n}function loadWorker(e){var t=workerStore[e];if(t)return t.clientCount++,t;var r=new _URL(e,self.location.href).href,n={worker:new self.Worker(r),scriptURL:r,clientCount:1};return workerStore[e]=n,n}function removeWorkerFromStore(e){var t=workerStore[e||version];if(t&&1===t.clientCount--){var r=t.worker,n=t.objectURL;delete workerStore[e||version],n&&_URL.revokeObjectURL(n),r.terminate()}}function isId3Footer(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function isId3Header(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function readId3Size(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]}function getId3Data(e,t){for(var r=t,n=0;isId3Header(e,t);){n+=10,n+=readId3Size(e,t+6),isId3Footer(e,t+10)&&(n+=10),t+=n}if(n>0)return e.subarray(r,r+n)}function getAudioConfig(e,t,r,n){var a,i,s,o,l,c=t[r+2],u=c>>2&15;if(!(u>12)){var d=1+(c>>6&3),f=t[r+3]>>6&3|(1&c)<<2,h="mp4a.40."+d,p=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][u],y=u;5!==d&&29!==d||(y-=3);var g=[d<<3|(14&y)>>1,(1&y)<<7|f<<3];return logger.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="manifest codec:".concat(n,", parsed codec:")).call(l,h,", channels:")).call(o,f,", rate:")).call(s,p," (ADTS object type:")).call(i,d," sampling index:")).call(a,u,")")),{config:g,samplerate:p,channelCount:f,codec:h,parsedCodec:h,manifestCodec:n}}var v=new Error("invalid ADTS sampling index:".concat(u));e.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,error:v,reason:v.message})}function isHeaderPattern$1(e,t){return 255===e[t]&&240==(246&e[t+1])}function getHeaderLength(e,t){return 1&e[t+1]?7:9}function getFullFrameLength(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function canGetFrameLength(e,t){return t+5<e.length}function isHeader$1(e,t){return t+1<e.length&&isHeaderPattern$1(e,t)}function canParse$1(e,t){return canGetFrameLength(e,t)&&isHeaderPattern$1(e,t)&&getFullFrameLength(e,t)<=e.length-t}function probe$1(e,t){if(isHeader$1(e,t)){var r=getHeaderLength(e,t);if(t+r>=e.length)return!1;var n=getFullFrameLength(e,t);if(n<=r)return!1;var a=t+n;return a===e.length||isHeader$1(e,a)}return!1}function initTrackConfig(e,t,r,n,a){if(!e.samplerate){var i=getAudioConfig(t,r,n,a);if(!i)return;_extends(e,i)}}function getFrameDuration(e){return 9216e4/e}function parseFrameHeader(e,t){var r=getHeaderLength(e,t);if(t+r<=e.length){var n=getFullFrameLength(e,t)-r;if(n>0)return{headerLength:r,frameLength:n}}}function appendFrame$2(e,t,r,n,a){var i,s=n+a*getFrameDuration(e.samplerate),o=parseFrameHeader(t,r);if(o){var l=o.frameLength,c=o.headerLength,u=c+l,d=Math.max(0,r+u-t.length);d?(i=new Uint8Array(u-c)).set(t.subarray(r+c,t.length),0):i=t.subarray(r+c,r+u);var f={unit:i,pts:s};return d||e.samples.push(f),{sample:f,length:u,missing:d}}var h=t.length-r;return(i=new Uint8Array(h)).set(t.subarray(r,t.length),0),{sample:{unit:i,pts:s},length:h,missing:-1}}function canParseId3(e,t){return isId3Header(e,t)&&readId3Size(e,t+6)+10<=e.length-t}function decodeId3PrivFrame(e){if(!(e.size<2)){var t=utf8ArrayToStr(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}function decodeId3TextFrame(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=utf8ArrayToStr(e.data.subarray(t),!0);t+=r.length+1;var n=utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:n}}var a=utf8ArrayToStr(e.data.subarray(1));return{key:e.type,info:"",data:a}}}function decodeId3UrlFrame(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=utf8ArrayToStr(e.data.subarray(t),!0);t+=r.length+1;var n=utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:n}}var a=utf8ArrayToStr(e.data);return{key:e.type,info:"",data:a}}function toUint8(e){return view(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,Uint8Array)}function view(e,t,r,n){var a=unsafeGetArrayBuffer(e),i=1;"BYTES_PER_ELEMENT"in n&&(i=n.BYTES_PER_ELEMENT);var s=isArrayBufferView(e)?e.byteOffset:0,o=(s+e.byteLength)/i,l=(s+t)/i,c=Math.floor(Math.max(0,Math.min(l,o)));return new n(a,c,Math.floor(Math.min(c+Math.max(r,0),o))-c)}function unsafeGetArrayBuffer(e){return e instanceof ArrayBuffer?e:e.buffer}function isArrayBufferView(e){return e&&e.buffer instanceof ArrayBuffer&&void 0!==e.byteLength&&void 0!==e.byteOffset}function toArrayBuffer(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function base64encode(e){return btoa(String.fromCharCode.apply(String,_toConsumableArray(e)))}function roundToEven(e,t){if(e<0)return-roundToEven(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<_Number$EPSILON){var n=Math.floor(e*r);return(n%2==0?n:n+1)/r}return Math.round(e*r)/r}function urlToRelativePath(e,t){var r,n,a=new _URL(e),i=new _URL(t);if(a.origin!==i.origin)return e;for(var s=_sliceInstanceProperty(r=a.pathname.split("/")).call(r,1),o=_sliceInstanceProperty(n=i.pathname.split("/")).call(n,1,-1);s[0]===o[0];)s.shift(),o.shift();for(;o.length;)o.shift(),s.unshift("..");return s.join("/")}function uuid(){try{return crypto.randomUUID()}catch(n){try{var e=_URL.createObjectURL(new Blob),t=e.toString();return _URL.revokeObjectURL(e),_sliceInstanceProperty(t).call(t,_lastIndexOfInstanceProperty(t).call(t,"/")+1)}catch(e){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)}))}}}function decodeId3ImageFrame(e){var t,r,n={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var a=_indexOfInstanceProperty(t=e.data.subarray(1)).call(t,0);if(-1!==a){var i=utf8ArrayToStr(toUint8(e.data,1,a)),s=e.data[2+a],o=_indexOfInstanceProperty(r=e.data.subarray(3+a)).call(r,0);if(-1!==o){var l,c=utf8ArrayToStr(toUint8(e.data,3+a,o));return l="--\x3e"===i?utf8ArrayToStr(toUint8(e.data,4+a+o)):toArrayBuffer(e.data.subarray(4+a+o)),n.mimeType=i,n.pictureType=s,n.description=c,n.data=l,n}}}else console.log("Ignore frame with unrecognized character encoding")}function decodeId3Frame(e){return"PRIV"===e.type?decodeId3PrivFrame(e):"W"===e.type[0]?decodeId3UrlFrame(e):"APIC"===e.type?decodeId3ImageFrame(e):decodeId3TextFrame(e)}function getId3FrameData(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=readId3Size(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var HEADER_FOOTER_SIZE=10,FRAME_SIZE=10;function getId3Frames(e){for(var t=0,r=[];isId3Header(e,t);){var n=readId3Size(e,t+6);e[t+5]>>6&1&&(t+=HEADER_FOOTER_SIZE);for(var a=(t+=HEADER_FOOTER_SIZE)+n;t+FRAME_SIZE<a;){var i=getId3FrameData(e.subarray(t)),s=decodeId3Frame(i);s&&r.push(s),t+=i.size+HEADER_FOOTER_SIZE}isId3Footer(e,t)&&(t+=HEADER_FOOTER_SIZE)}return r}function isId3TimestampFrame(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function readId3Timestamp(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,r&&(n+=47721858.84),Math.round(n)}}function getId3Timestamp(e){for(var t=getId3Frames(e),r=0;r<t.length;r++){var n=t[r];if(isId3TimestampFrame(n))return readId3Timestamp(n)}}var MetadataSchema=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function dummyTrack(){return{type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",id:-1,pid:-1,inputTimeScale:arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,sequenceNumber:-1,samples:[],dropped:0}}var BaseAudioDemuxer=function(){function e(){_classCallCheck$1(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}return _createClass$1(e,[{key:"resetInitSegment",value:function(e,t,r,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,r){}},{key:"demux",value:function(e,t){this.cachedData&&(e=appendUint8Array(this.cachedData,e),this.cachedData=null);var r,n=getId3Data(e,0),a=n?n.length:0,i=this._audioTrack,s=this._id3Track,o=n?getId3Timestamp(n):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&isFiniteNumber(o))&&(this.basePTS=initPTSFn(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(e,a)){var c=this.appendFrame(i,e,a);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r=a+=c.length):a=l}else canParseId3(e,a)?(n=getId3Data(e,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),r=a+=n.length):a++;if(a===l&&r!==l){var u=sliceUint8(e,r);this.cachedData?this.cachedData=appendUint8Array(this.cachedData,u):this.cachedData=u}}return{audioTrack:i,videoTrack:dummyTrack(),id3Track:s,textTrack:dummyTrack()}}},{key:"demuxSampleAes",value:function(e,t,r){return _Promise.reject(new Error("[".concat(this,"] This demuxer does not support Sample-AES decryption")))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:dummyTrack(),id3Track:this._id3Track,textTrack:dummyTrack()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),initPTSFn=function(e,t,r){return isFiniteNumber(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},chromeVersion$1=null,BitratesMap=[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],SamplingRateMap=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot=[0,1,1,4];function appendFrame$1(e,t,r,n,a){if(!(r+24>t.length)){var i=parseHeader(t,r);if(i&&r+i.frameLength<=t.length){var s=n+a*(9e4*i.samplesPerFrame/i.sampleRate),o={unit:t.subarray(r,r+i.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=i.channelCount,e.samplerate=i.sampleRate,e.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function parseHeader(e,t){var r=e[t+1]>>3&3,n=e[t+1]>>1&3,a=e[t+2]>>4&15,i=e[t+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==i){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*BitratesMap[14*(3===r?3-n:3===n?3:4)+a-1],c=SamplingRateMap[3*(3===r?0:2===r?1:2)+i],u=3===o?1:2,d=SamplesCoefficients[r][n],f=BytesInSlot[n],h=8*d*f,p=Math.floor(d*l/c+s)*f;if(null===chromeVersion$1){var y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);chromeVersion$1=y?_parseInt$1(y[1]):0}return!!chromeVersion$1&&chromeVersion$1<=87&&2===n&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:u,frameLength:p,samplesPerFrame:h}}}function isHeaderPattern(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function isHeader(e,t){return t+1<e.length&&isHeaderPattern(e,t)}function _canParse(e,t){return isHeaderPattern(e,t)&&4<=e.length-t}function _probe(e,t){if(t+1<e.length&&isHeaderPattern(e,t)){var r=parseHeader(e,t),n=4;null!=r&&r.frameLength&&(n=r.frameLength);var a=t+n;return a===e.length||isHeader(e,a)}return!1}var AACDemuxer=function(e){_inherits(r,BaseAudioDemuxer);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this)).observer=void 0,a.config=void 0,a.observer=e,a.config=n,a}return _createClass$1(r,[{key:"resetInitSegment",value:function(e,t,n,a){_get(_getPrototypeOf(r.prototype),"resetInitSegment",this).call(this,e,t,n,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return canParse$1(e,t)}},{key:"appendFrame",value:function(e,t,r){initTrackConfig(e,this.observer,t,r,e.manifestCodec);var n=appendFrame$2(e,t,r,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}}],[{key:"probe",value:function(e,t){if(!e)return!1;var r=getId3Data(e,0),n=(null==r?void 0:r.length)||0;if(_probe(e,n))return!1;for(var a=e.length;n<a;n++)if(probe$1(e,n))return t.log("ADTS sync word found !"),!0;return!1}}]),r}(),getAudioBSID=function(e,t){var r=0,n=5;t+=n;for(var a=new Uint32Array(1),i=new Uint32Array(1),s=new Uint8Array(1);n>0;){s[0]=e[t];var o=Math.min(n,8),l=8-o;i[0]=4278190080>>>24+l<<l,a[0]=(s[0]&i[0])>>l,r=r?r<<o|a[0]:a[0],t+=1,n-=o}return r},AC3Demuxer=function(e){_inherits(r,BaseAudioDemuxer);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this)).observer=void 0,n.observer=e,n}return _createClass$1(r,[{key:"resetInitSegment",value:function(e,t,n,a){_get(_getPrototypeOf(r.prototype),"resetInitSegment",this).call(this,e,t,n,a),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,r){var n=_appendFrame(e,t,r,this.basePTS,this.frameIndex);if(-1!==n)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=getId3Data(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==getId3Timestamp(t)&&getAudioBSID(e,r)<16}}]),r}();function _appendFrame(e,t,r,n,a){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;var i=t[r+4]>>6;if(i>=3)return-1;var s=[48e3,44100,32e3][i],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+i];if(r+l>t.length)return-1;var c=t[r+6]>>5,u=0;2===c?u+=2:(1&c&&1!==c&&(u+=2),4&c&&(u+=2));var d=(t[r+6]<<8|t[r+7])>>12-u&1,f=[2,1,2,3,3,4,4,5][c]+d,h=t[r+5]>>3,p=7&t[r+5],y=new Uint8Array([i<<6|h<<1|p>>2,(3&p)<<6|c<<3|d<<2|o>>4,o<<4&224]),g=n+a*(1536/s*9e4),v=t.subarray(r,r+l);return e.config=y,e.channelCount=f,e.samplerate=s,e.samples.push({unit:v,pts:g}),l}var MP3Demuxer=function(e){_inherits(r,BaseAudioDemuxer);var t=_createSuper(r);function r(){return _classCallCheck$1(this,r),t.apply(this,arguments)}return _createClass$1(r,[{key:"resetInitSegment",value:function(e,t,n,a){_get(_getPrototypeOf(r.prototype),"resetInitSegment",this).call(this,e,t,n,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return _canParse(e,t)}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return appendFrame$1(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=getId3Data(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==getId3Timestamp(t)&&getAudioBSID(e,r)<=16)return!1;for(var n=e.length;r<n;r++)if(_probe(e,r))return logger.log("MPEG Audio sync word found !"),!0;return!1}}]),r}(),emsgSchemePattern=/\/emsg[-/]ID3/i,MP4Demuxer=function(){function e(t,r){_classCallCheck$1(this,e),this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=r}return _createClass$1(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,n){var a=this.videoTrack=dummyTrack("video",1),i=this.audioTrack=dummyTrack("audio",1),s=this.txtTrack=dummyTrack("text",1);if(this.id3Track=dummyTrack("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=parseInitSegment(e);if(o.video){var l=o.video,c=l.id,u=l.timescale,d=l.codec;a.id=c,a.timescale=s.timescale=u,a.codec=d}if(o.audio){var f=o.audio,h=f.id,p=f.timescale,y=f.codec;i.id=h,i.timescale=p,i.codec=y}s.id=RemuxerTrackIdConfig.text,a.sampleDuration=0,a.duration=i.duration=n}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var r=e,n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=appendUint8Array(this.remainderData,e));var i=segmentValidRange(r);this.remainderData=i.remainder,n.samples=i.valid||new Uint8Array}else n.samples=r;var s=this.extractID3Track(n,t);return a.samples=parseSamples(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(t,this.timeOffset);return r.samples=parseSamples(e,t),{videoTrack:t,audioTrack:dummyTrack(),id3Track:n,textTrack:dummyTrack()}}},{key:"extractID3Track",value:function(e,t){var r=this,n=this.id3Track;if(e.samples.length){var a=findBox(e.samples,["emsg"]);a&&_forEachInstanceProperty(a).call(a,(function(e){var a,i=parseEmsg(e);if(emsgSchemePattern.test(i.schemeIdUri)){var s=getEmsgStartTime(i,t),o=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;o<=.001&&(o=Number.POSITIVE_INFINITY);var l=i.payload;n.samples.push({data:l,len:l.byteLength,dts:s,pts:s,type:MetadataSchema.emsg,duration:o})}else if(r.config.enableEmsgKLVMetadata&&_startsWithInstanceProperty(a=i.schemeIdUri).call(a,"urn:misb:KLV:bin:1910.1")){var c=getEmsgStartTime(i,t);n.samples.push({data:i.payload,len:i.payload.byteLength,dts:c,pts:c,type:MetadataSchema.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return n}},{key:"demuxSampleAes",value:function(e,t,r){return _Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return hasMoofData(e)}}]),e}();function getEmsgStartTime(e,t){return isFiniteNumber(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var SampleAesDecrypter=function(){function e(t,r,n){_classCallCheck$1(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new Decrypter(r,{removePKCS7Padding:!1})}return _createClass$1(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,DecrypterAesMode.cbc)}},{key:"decryptAacSample",value:function(e,t,r){var n,a=this,i=e[t].unit;if(!(i.length<=16)){var s=i.subarray(16,i.length-i.length%16),o=_sliceInstanceProperty(n=s.buffer).call(n,s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(o).then((function(n){var s=new Uint8Array(n);i.set(s,16),a.decrypter.isSync()||a.decryptAacSamples(e,t+1,r)}))}}},{key:"decryptAacSamples",value:function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)r.set(e.subarray(a,a+16),n);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var r=new Uint8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)e.set(r.subarray(n,n+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,r,n,a){var i=this,s=discardEPB(a.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){a.data=i.getAvcDecryptedUnit(s,o),i.decrypter.isSync()||i.decryptAvcSamples(e,t,r+1,n)}))}},{key:"decryptAvcSamples",value:function(e,t,r,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void n();for(var a=e[t].units;!(r>=a.length);r++){var i=a[r];if(!(i.data.length<=48||1!==i.type&&5!==i.type||(this.decryptAvcSample(e,t,r,n,i),this.decrypter.isSync())))return}}}}]),e}(),BaseVideoParser=function(){function e(){_classCallCheck$1(this,e),this.VideoSample=null}return _createClass$1(e,[{key:"createVideoSample",value:function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,r,n=this.VideoSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(t=n)&&t.units){var a=n.units;r=a[a.length-1]}return r}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,n=r.length;if(!n)return void t.dropped++;var a=r[n-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,r){var n,a,i=t.byteLength,s=e.naluState||0,o=s,l=[],c=0,u=-1,d=0;for(-1===s&&(u=0,d=this.getNALuType(t,0),s=0,c=1);c<i;)if(n=t[c++],s)if(1!==s)if(n)if(1===n){if(a=c-s-1,u>=0){var f={data:t.subarray(u,a),type:d};l.push(f)}else{var h=this.getLastNalUnit(e.samples);h&&(o&&c<=4-o&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-o)),a>0&&(h.data=appendUint8Array(h.data,t.subarray(0,a)),h.state=0))}c<i?(u=c,d=this.getNALuType(t,c),s=0):s=-1}else s=0;else s=3;else s=n?0:2;else s=n?0:1;if(u>=0&&s>=0){var p={data:t.subarray(u,i),type:d,state:s};l.push(p)}if(0===l.length){var y=this.getLastNalUnit(e.samples);y&&(y.data=appendUint8Array(y.data,t))}return e.naluState=s,l}}]),e}(),ExpGolomb=function(){function e(t){_classCallCheck$1(this,e),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}return _createClass$1(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");n.set(e.subarray(r,r+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}]),e}(),AvcVideoParser=function(e){_inherits(r,BaseVideoParser);var t=_createSuper(r);function r(){return _classCallCheck$1(this,r),t.apply(this,arguments)}return _createClass$1(r,[{key:"parsePES",value:function(e,t,r,n){var a,i=this,s=this.parseNALu(e,r.data,n),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),_forEachInstanceProperty(s).call(s,(function(n){var s,c;switch(n.type){case 1:var u=!1;a=!0;var d,f=n.data;if(l&&f.length>4){var h=i.readSliceType(f);2!==h&&4!==h&&7!==h&&9!==h||(u=!0)}if(u)null!=(d=o)&&d.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null);o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=u;break;case 5:a=!0,null!=(s=o)&&s.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null),o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,parseSEIMessageFromNALu(n.data,1,r.pts,t.samples);break;case 7:var p,y;a=!0,l=!0;var g=n.data,v=i.readSPS(g);if(!e.sps||e.width!==v.width||e.height!==v.height||(null==(p=e.pixelRatio)?void 0:p[0])!==v.pixelRatio[0]||(null==(y=e.pixelRatio)?void 0:y[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[g];for(var m=g.subarray(1,4),E="avc1.",$=0;$<3;$++){var S=m[$].toString(16);S.length<2&&(S="0"+S),E+=S}e.codec=E}break;case 8:a=!0,e.pps=[n.data];break;case 9:a=!0,e.audFound=!0,null!=(c=o)&&c.frame&&(i.pushAccessUnit(o,e),o=null),o||(o=i.VideoSample=i.createVideoSample(!1,r.pts,r.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(n)})),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new ExpGolomb(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var r=8,n=8,a=0;a<e;a++)0!==n&&(n=(r+t.readEG()+256)%256),r=0===n?r:n}},{key:"readSPS",value:function(e){var t,r,n,a,i,s,o,l,c,u,d,f=new ExpGolomb(e),h=0,p=0,y=0,g=0,v=_bindInstanceProperty(t=f.readUByte).call(t,f),m=_bindInstanceProperty(r=f.readBits).call(r,f),E=_bindInstanceProperty(n=f.readUEG).call(n,f),$=_bindInstanceProperty(a=f.readBoolean).call(a,f),S=_bindInstanceProperty(i=f.skipBits).call(i,f),T=_bindInstanceProperty(s=f.skipEG).call(s,f),I=_bindInstanceProperty(o=f.skipUEG).call(o,f),_=_bindInstanceProperty(l=this.skipScalingList).call(l,this);v();var P=v();if(m(5),S(3),v(),I(),100===P||110===P||122===P||244===P||44===P||83===P||86===P||118===P||128===P){var b=E();if(3===b&&S(1),I(),I(),S(1),$())for(u=3!==b?8:12,d=0;d<u;d++)$()&&_(d<6?16:64,f)}I();var A=E();if(0===A)E();else if(1===A)for(S(1),T(),T(),c=E(),d=0;d<c;d++)T();I(),S(1);var R=E(),k=E(),C=m(1);0===C&&S(1),S(1),$()&&(h=E(),p=E(),y=E(),g=E());var O=[1,1];if($()&&$())switch(v()){case 1:O=[1,1];break;case 2:O=[12,11];break;case 3:O=[10,11];break;case 4:O=[16,11];break;case 5:O=[40,33];break;case 6:O=[24,11];break;case 7:O=[20,11];break;case 8:O=[32,11];break;case 9:O=[80,33];break;case 10:O=[18,11];break;case 11:O=[15,11];break;case 12:O=[64,33];break;case 13:O=[160,99];break;case 14:O=[4,3];break;case 15:O=[3,2];break;case 16:O=[2,1];break;case 255:O=[v()<<8|v(),v()<<8|v()]}return{width:Math.ceil(16*(R+1)-2*h-2*p),height:(2-C)*(k+1)*16-(C?2:4)*(y+g),pixelRatio:O}}}]),r}(),HevcVideoParser=function(e){_inherits(r,BaseVideoParser);var t=_createSuper(r);function r(){var e,n;_classCallCheck$1(this,r);for(var a=arguments.length,i=new Array(a),s=0;s<a;s++)i[s]=arguments[s];return(n=t.call.apply(t,_concatInstanceProperty(e=[this]).call(e,i))).initVPS=null,n}return _createClass$1(r,[{key:"parsePES",value:function(e,t,r,n){var a,i=this,s=this.parseNALu(e,r.data,n),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),_forEachInstanceProperty(s).call(s,(function(n){var s,c;switch(n.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=i.VideoSample=i.createVideoSample(!1,r.pts,r.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var u;if(a=!0,l)null!=(u=o)&&u.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null);o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(s=o)&&s.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null),o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,parseSEIMessageFromNALu(n.data,2,r.pts,t.samples);break;case 32:if(a=!0,!e.vps){var d=i.readVPS(n.data);e.params=_objectSpread2({},d),i.initVPS=n.data}e.vps=[n.data];break;case 33:if(a=!0,l=!0,"object"===_typeof$1(e.params)){if(void 0===e.vps||e.vps[0]===i.initVPS||void 0===e.sps||i.matchSPS(e.sps[0],n.data)||(i.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var f=i.readSPS(n.data);for(var h in e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],f.params)e.params[h]=f.params[h]}void 0!==e.vps&&e.vps[0]===i.initVPS&&e.sps.push(n.data)}o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0;break;case 34:if(a=!0,"object"===_typeof$1(e.params)){if(!e.pps){e.pps=[];var p=i.readPPS(n.data);for(var y in p)e.params[y]=p[y]}void 0!==e.vps&&e.vps[0]===i.initVPS&&e.pps.push(n.data)}break;case 35:a=!0,e.audFound=!0,null!=(c=o)&&c.frame&&(i.pushAccessUnit(o,e),o=null),o||(o=i.VideoSample=i.createVideoSample(!1,r.pts,r.dts));break;default:a=!1}o&&a&&o.units.push(n)})),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),r=0,n=0;n<e.byteLength;n++)n>=2&&3===e[n]&&0===e[n-1]&&0===e[n-2]||(t[r]=e[n],r++);return new Uint8Array(t.buffer,0,r)}},{key:"pushAccessUnit",value:function(e,t){_get(_getPrototypeOf(r.prototype),"pushAccessUnit",this).call(this,e,t),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new ExpGolomb(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t,r,n,a,i=new ExpGolomb(this.ebsp2rbsp(e));i.readUByte(),i.readUByte(),i.readBits(4);var s=i.readBits(3);i.readBoolean();for(var o=i.readBits(2),l=i.readBoolean(),c=i.readBits(5),u=i.readUByte(),d=i.readUByte(),f=i.readUByte(),h=i.readUByte(),p=i.readUByte(),y=i.readUByte(),g=i.readUByte(),v=i.readUByte(),m=i.readUByte(),E=i.readUByte(),$=i.readUByte(),S=[],T=[],I=0;I<s;I++)S.push(i.readBoolean()),T.push(i.readBoolean());if(s>0)for(var _=s;_<8;_++)i.readBits(2);for(var P=0;P<s;P++)S[P]&&(i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte()),T[P]&&i.readUByte();i.readUEG();var b=i.readUEG();3==b&&i.skipBits(1);var A=i.readUEG(),R=i.readUEG(),k=i.readBoolean(),C=0,O=0,L=0,D=0;k&&(C+=i.readUEG(),O+=i.readUEG(),L+=i.readUEG(),D+=i.readUEG());for(var w=i.readUEG(),M=i.readUEG(),x=i.readUEG(),N=i.readBoolean()?0:s;N<=s;N++)i.skipUEG(),i.skipUEG(),i.skipUEG();if((i.skipUEG(),i.skipUEG(),i.skipUEG(),i.skipUEG(),i.skipUEG(),i.skipUEG(),i.readBoolean())&&i.readBoolean())for(var F=0;F<4;F++)for(var U=0;U<(3===F?2:6);U++){if(i.readBoolean()){var B=Math.min(64,1<<4+(F<<1));F>1&&i.readEG();for(var j=0;j<B;j++)i.readEG()}else i.readUEG()}i.readBoolean(),i.readBoolean(),i.readBoolean()&&(i.readUByte(),i.skipUEG(),i.skipUEG(),i.readBoolean());for(var G=i.readUEG(),H=0,K=0;K<G;K++){var V=!1;if(0!==K&&(V=i.readBoolean()),V){K===G&&i.readUEG(),i.readBoolean(),i.readUEG();for(var W=0,Y=0;Y<=H;Y++){var q=i.readBoolean(),z=!1;q||(z=i.readBoolean()),(q||z)&&W++}H=W}else{var X=i.readUEG(),Q=i.readUEG();H=X+Q;for(var J=0;J<X;J++)i.readUEG(),i.readBoolean();for(var Z=0;Z<Q;Z++)i.readUEG(),i.readBoolean()}}if(i.readBoolean())for(var ee=i.readUEG(),te=0;te<ee;te++){for(var re=0;re<x+4;re++)i.readBits(1);i.readBits(1)}var ne=0,ae=1,ie=1,se=!0,oe=1,le=0;i.readBoolean(),i.readBoolean();var ce=!1;if(i.readBoolean()){if(i.readBoolean()){var ue=i.readUByte();ue>0&&ue<16?(ae=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ue-1],ie=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ue-1]):255===ue&&(ae=i.readBits(16),ie=i.readBits(16))}if(i.readBoolean()&&i.readBoolean(),i.readBoolean())i.readBits(3),i.readBoolean(),i.readBoolean()&&(i.readUByte(),i.readUByte(),i.readUByte());if(i.readBoolean()&&(i.readUEG(),i.readUEG()),i.readBoolean(),i.readBoolean(),i.readBoolean(),(ce=i.readBoolean())&&(C+=i.readUEG(),O+=i.readUEG(),L+=i.readUEG(),D+=i.readUEG()),i.readBoolean())if(oe=i.readBits(32),le=i.readBits(32),i.readBoolean()&&i.readUEG(),i.readBoolean()){var de=i.readBoolean(),fe=i.readBoolean(),he=!1;(de||fe)&&((he=i.readBoolean())&&(i.readUByte(),i.readBits(5),i.readBoolean(),i.readBits(5)),i.readBits(4),i.readBits(4),he&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(var pe=0;pe<=s;pe++){var ye=!1;(se=i.readBoolean())||i.readBoolean()?i.readEG():ye=i.readBoolean();var ge=ye?1:i.readUEG()+1;if(de)for(var ve=0;ve<ge;ve++)i.readUEG(),i.readUEG(),he&&(i.readUEG(),i.readUEG()),i.skipBits(1);if(fe)for(var me=0;me<ge;me++)i.readUEG(),i.readUEG(),he&&(i.readUEG(),i.readUEG()),i.skipBits(1)}}i.readBoolean()&&(i.readBoolean(),i.readBoolean(),i.readBoolean(),ne=i.readUEG())}var Ee=A,$e=R;if(k||ce){var Se=1,Te=1;1===b?Se=Te=2:2==b&&(Se=2),Ee=A-Se*O-Se*C,$e=R-Te*D-Te*L}for(var Ie=o?["A","B","C"][o]:"",_e=u<<24|d<<16|f<<8|h,Pe=0,be=0;be<32;be++)Pe=(Pe|(_e>>be&1)<<31-be)>>>0;var Ae=Pe.toString(16);1===c&&"2"===Ae&&(Ae="6");var Re=l?"H":"L";return{codecString:_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="hvc1.".concat(Ie)).call(a,c,".")).call(n,Ae,".")).call(r,Re)).call(t,$,".B0"),params:{general_tier_flag:l,general_profile_idc:c,general_profile_space:o,general_profile_compatibility_flags:[u,d,f,h],general_constraint_indicator_flags:[p,y,g,v,m,E],general_level_idc:$,bit_depth:w+8,bit_depth_luma_minus8:w,bit_depth_chroma_minus8:M,min_spatial_segmentation_idc:ne,chroma_format_idc:b,frame_rate:{fixed:se,fps:le/oe}},width:Ee,height:$e,pixelRatio:[ae,ie]}}},{key:"readPPS",value:function(e){var t=new ExpGolomb(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var r=t.readBoolean(),n=t.readBoolean(),a=1;return n&&r?a=0:n?a=3:r&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}]),r}(),PACKET_LENGTH=188,TSDemuxer=function(){function e(t,r,n,a){_classCallCheck$1(this,e),this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=r,this.typeSupported=n,this.logger=a,this.videoParser=null}return _createClass$1(e,[{key:"resetInitSegment",value:function(t,r,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=n}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,r){var n,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];a||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,c=this._txtTrack,u=s.pid,d=s.pesData,f=o.pid,h=l.pid,p=o.pesData,y=l.pesData,g=null,v=this.pmtParsed,m=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=appendUint8Array(this.remainderData,t)).length,this.remainderData=null),E<PACKET_LENGTH&&!i)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:c};var $=Math.max(0,e.syncOffset(t));(E-=(E-$)%PACKET_LENGTH)<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var S=0,T=$;T<E;T+=PACKET_LENGTH)if(71===t[T]){var I=!!(64&t[T+1]),_=parsePID(t,T),P=void 0;if((48&t[T+3])>>4>1){if((P=T+5+t[T+4])===T+PACKET_LENGTH)continue}else P=T+4;switch(_){case u:if(I){if(d&&(n=parsePES(d,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new AvcVideoParser;break;case"hevc":this.videoParser=new HevcVideoParser}null!==this.videoParser&&this.videoParser.parsePES(s,c,n,!1)}d={data:[],size:0}}d&&(d.data.push(t.subarray(P,T+PACKET_LENGTH)),d.size+=T+PACKET_LENGTH-P);break;case f:if(I){if(p&&(n=parsePES(p,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n)}p={data:[],size:0}}p&&(p.data.push(t.subarray(P,T+PACKET_LENGTH)),p.size+=T+PACKET_LENGTH-P);break;case h:I&&(y&&(n=parsePES(y,this.logger))&&this.parseID3PES(l,n),y={data:[],size:0}),y&&(y.data.push(t.subarray(P,T+PACKET_LENGTH)),y.size+=T+PACKET_LENGTH-P);break;case 0:I&&(P+=t[P]+1),m=this._pmtId=parsePAT(t,P);break;case m:I&&(P+=t[P]+1);var b,A,R=parsePMT(t,P,this.typeSupported,a,this.observer,this.logger);if((u=R.videoPid)>0&&(s.pid=u,s.segmentCodec=R.segmentVideoCodec),(f=R.audioPid)>0&&(o.pid=f,o.segmentCodec=R.segmentAudioCodec),(h=R.id3Pid)>0&&(l.pid=h),null!==g&&!v)this.logger.warn(_concatInstanceProperty(b=_concatInstanceProperty(A="MPEG-TS PMT found at ".concat(T," after unknown PID '")).call(A,g,"'. Backtracking to sync byte @")).call(b,$," to parse all TS packets.")),g=null,T=$-188;v=this.pmtParsed=!0;break;case 17:case 8191:break;default:g=_}}else S++;S>0&&emitParsingError(this.observer,new Error("Found ".concat(S," TS packet/s that do not start with 0x47")),void 0,this.logger),s.pesData=d,o.pesData=p,l.pesData=y;var k={audioTrack:o,videoTrack:s,id3Track:l,textTrack:c};return i&&this.extractRemainingSamples(k),k}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,r=e.audioTrack,n=e.videoTrack,a=e.id3Track,i=e.textTrack,s=n.pesData,o=r.pesData,l=a.pesData;if(s&&(t=parsePES(s,this.logger))){if(null===this.videoParser)switch(n.segmentCodec){case"avc":this.videoParser=new AvcVideoParser;break;case"hevc":this.videoParser=new HevcVideoParser}null!==this.videoParser&&(this.videoParser.parsePES(n,i,t,!0),n.pesData=null)}else n.pesData=s;if(o&&(t=parsePES(o,this.logger))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t);break;case"ac3":this.parseAC3PES(r,t)}r.pesData=null}else null!=o&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=parsePES(l,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=l}},{key:"demuxSampleAes",value:function(e,t,r){var n=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new SampleAesDecrypter(this.observer,this.config,t);return this.decrypt(n,a)}},{key:"decrypt",value:function(e,t){return new _Promise((function(r){var n=e.audioTrack,a=e.videoTrack;n.samples&&"aac"===n.segmentCodec?t.decryptAacSamples(n.samples,0,(function(){a.samples?t.decryptAvcSamples(a.samples,0,0,(function(){r(e)})):r(e)})):a.samples&&t.decryptAvcSamples(a.samples,0,0,(function(){r(e)}))}))}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var r,n,a,i=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,c=s.sample.unit.byteLength;if(-1===l)o=appendUint8Array(s.sample.unit,o);else{var u=c-l;s.sample.unit.set(o.subarray(0,l),u),e.samples.push(s.sample),i=s.missing}}for(r=i,n=o.length;r<n-1&&!isHeader$1(o,r);r++);if(r!==i){var d,f=r<n-1;if(d=f?"AAC PES did not start with ADTS header,offset:".concat(r):"No ADTS header found in AAC PES",emitParsingError(this.observer,new Error(d),f,this.logger),!f)return}if(initTrackConfig(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!s)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var h=getFrameDuration(e.samplerate);a=s.sample.pts+h}for(var p,y=0;r<n;){if(r+=(p=appendFrame$2(e,o,r,a,y)).length,p.missing){this.aacOverFlow=p;break}for(y++;r<n-1&&!isHeader$1(o,r);r++);}}},{key:"parseMPEGPES",value:function(e,t){var r=t.data,n=r.length,a=0,i=0,s=t.pts;if(void 0!==s)for(;i<n;)if(isHeader(r,i)){var o=appendFrame$1(e,r,i,s,a);if(!o)break;i+=o.length,a++}else i++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var r=t.data,n=t.pts;if(void 0!==n)for(var a,i=r.length,s=0,o=0;o<i&&(a=_appendFrame(e,r,o,n,s++))>0;)o+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var r=_extends({},t,{type:this._videoTrack?MetadataSchema.emsg:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,r){var n=e.syncOffset(t);return n>0&&r.warn("MPEG2-TS detected but first sync word found @ offset ".concat(n)),-1!==n}},{key:"syncOffset",value:function(e){for(var t=e.length,r=Math.min(5*PACKET_LENGTH,t-PACKET_LENGTH)+1,n=0;n<r;){for(var a=!1,i=-1,s=0,o=n;o<t;o+=PACKET_LENGTH){if(71!==e[o]||t-o!==PACKET_LENGTH&&71!==e[o+PACKET_LENGTH]){if(s)return-1;break}if(s++,-1===i&&0!==(i=o)&&(r=Math.min(i+99*PACKET_LENGTH,e.length-PACKET_LENGTH)+1),a||(a=0===parsePID(e,o)),a&&s>1&&(0===i&&s>2||o+PACKET_LENGTH>r))return i}n++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:RemuxerTrackIdConfig[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function parsePID(e,t){return((31&e[t+1])<<8)+e[t+2]}function parsePAT(e,t){return(31&e[t+10])<<8|e[t+11]}function parsePMT(e,t,r,n,a,i){var s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){var l=parsePID(e,t),c=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!n){logEncryptedSamplesFoundInUnencryptedStream("ADTS AAC",i);break}case 15:-1===s.audioPid&&(s.audioPid=l);break;case 21:-1===s.id3Pid&&(s.id3Pid=l);break;case 219:if(!n){logEncryptedSamplesFoundInUnencryptedStream("H.264",i);break}case 27:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="mp3"):i.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){logEncryptedSamplesFoundInUnencryptedStream("AC-3",i);break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="ac3"):i.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&c>0)for(var u=t+5,d=c;d>2;){if(106===e[u])!0!==r.ac3?i.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");var f=e[u+1]+2;u+=f,d-=f}break;case 194:case 135:return emitParsingError(a,new Error("Unsupported EC-3 in M2TS found"),void 0,i),s;case 36:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="hevc",i.log("HEVC in M2TS found"))}t+=c+5}return s}function emitParsingError(e,t,r,n){n.warn("parsing error: ".concat(t.message)),e.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function logEncryptedSamplesFoundInUnencryptedStream(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function parsePES(e,t){var r,n,a,i,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=appendUint8Array(l[0],l[1]),_spliceInstanceProperty(l).call(l,1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((n=(r[4]<<8)+r[5])&&n>e.size-6)return null;var c=r[7];192&c&&(i=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&c?i-(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>54e5&&(t.warn("".concat(Math.round((i-s)/9e4),"s delta between PTS and DTS, align them")),i=s):s=i);var u=(a=r[8])+9;if(e.size<=u)return null;e.size-=u;for(var d=new Uint8Array(e.size),f=0,h=l.length;f<h;f++){var p=(r=l[f]).byteLength;if(u){if(u>p){u-=p;continue}r=r.subarray(u),p-=u,u=0}d.set(r,o),o+=p}return n&&(n-=a+3),{data:d,pts:i,dts:s,len:n}}return null}var AAC=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)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])}}}]),e}(),UINT32_MAX=Math.pow(2,32)-1,MP4=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:n};var a=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]);e.STTS=e.STSC=e.STCO=i,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e){for(var t=8,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];for(var i=n.length,s=i;i--;)t+=n[i].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),i=0,t=8;i<s;i++)o.set(n[i],t),t+=n[i].byteLength;return o}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){r*=t;var n=Math.floor(r/(UINT32_MAX+1)),a=Math.floor(r%(UINT32_MAX+1));return e.box(e.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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,r))}},{key:"moov",value:function(t){for(var r,n,a=t.length,i=[];a--;)i[a]=e.trak(t[a]);return e.box.apply(null,_concatInstanceProperty(r=_concatInstanceProperty(n=[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)]).call(n,i)).call(r,e.mvex(t)))}},{key:"mvex",value:function(t){for(var r,n=t.length,a=[];n--;)a[n]=e.trex(t[n]);return e.box.apply(null,_concatInstanceProperty(r=[e.types.mvex]).call(r,a))}},{key:"mvhd",value:function(t,r){r*=t;var n=Math.floor(r/(UINT32_MAX+1)),a=Math.floor(r%(UINT32_MAX+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,i)}},{key:"sdtp",value:function(t){var r,n,a=t.samples||[],i=new Uint8Array(4+a.length);for(r=0;r<a.length;r++)n=_flagsInstanceProperty(a[r]),i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,i)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,n,a,i,s,o,l=[],c=[];for(i=0;i<t.sps.length;i++)o=(s=t.sps[i]).byteLength,l.push(o>>>8&255),l.push(255&o),l=_concatInstanceProperty(l).call(l,_sliceInstanceProperty(Array.prototype).call(s));for(i=0;i<t.pps.length;i++)o=(s=t.pps[i]).byteLength,c.push(o>>>8&255),c.push(255&o),c=_concatInstanceProperty(c).call(c,_sliceInstanceProperty(Array.prototype).call(s));var u=e.box(e.types.avcC,new Uint8Array(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=[1,l[3],l[4],l[5],255,224|t.sps.length]).call(a,l)).call(n,[t.pps.length])).call(r,c))),d=t.width,f=t.height,h=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.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,d>>8&255,255&d,f>>8&255,255&f,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]),u,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,p>>24,p>>16&255,p>>8&255,255&p])))}},{key:"esds",value:function(e){var t,r=e.config;return new Uint8Array(_concatInstanceProperty(t=[0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2]).call(t,_toConsumableArray(r),[6,1,2]))}},{key:"audioStsd",value:function(e){var t=e.samplerate;return 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,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):"avc"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.avc1(t)):e.box(e.types.stsd,e.STSD,e.hvc1(t))}},{key:"tkhd",value:function(t){var r=t.id,n=t.duration*t.timescale,a=t.width,i=t.height,s=Math.floor(n/(UINT32_MAX+1)),o=Math.floor(n%(UINT32_MAX+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,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,a>>8&255,255&a,0,0,i>>8&255,255&i,0,0]))}},{key:"traf",value:function(t,r){var n=e.sdtp(t),a=t.id,i=Math.floor(r/(UINT32_MAX+1)),s=Math.floor(r%(UINT32_MAX+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,n.length+16+20+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,r){var n,a,i,s,o,l,c=t.samples||[],u=c.length,d=12+16*u,f=new Uint8Array(d);for(r+=8+d,f.set(["video"===t.type?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n<u;n++)i=(a=c[n]).duration,s=a.size,o=_flagsInstanceProperty(a),l=a.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return e.box(e.types.trun,f)}},{key:"initSegment",value:function(t){e.types||e.init();var r=e.moov(t);return appendUint8Array(e.FTYP,r)}},{key:"hvc1",value:function(t){for(var r=t.params,n=[t.vps,t.sps,t.pps],a=new Uint8Array([1,r.general_profile_space<<6|(r.general_tier_flag?32:0)|r.general_profile_idc,r.general_profile_compatibility_flags[0],r.general_profile_compatibility_flags[1],r.general_profile_compatibility_flags[2],r.general_profile_compatibility_flags[3],r.general_constraint_indicator_flags[0],r.general_constraint_indicator_flags[1],r.general_constraint_indicator_flags[2],r.general_constraint_indicator_flags[3],r.general_constraint_indicator_flags[4],r.general_constraint_indicator_flags[5],r.general_level_idc,240|r.min_spatial_segmentation_idc>>8,255&r.min_spatial_segmentation_idc,252|r.parallelismType,252|r.chroma_format_idc,248|r.bit_depth_luma_minus8,248|r.bit_depth_chroma_minus8,0,_parseInt$1(r.frame_rate.fps),3|r.temporal_id_nested<<2|r.num_temporal_layers<<3|(r.frame_rate.fixed?64:0),n.length]),i=a.length,s=0;s<n.length;s+=1){i+=3;for(var o=0;o<n[s].length;o+=1)i+=2+n[s][o].length}var l=new Uint8Array(i);l.set(a,0),i=a.length;for(var c=n.length-1,u=0;u<n.length;u+=1){l.set(new Uint8Array([32+u|(u===c?128:0),0,n[u].length]),i),i+=3;for(var d=0;d<n[u].length;d+=1)l.set(new Uint8Array([n[u][d].length>>8,255&n[u][d].length]),i),i+=2,l.set(n[u][d],i),i+=n[u][d].length}var f=e.box(e.types.hvcC,l),h=t.width,p=t.height,y=t.pixelRatio[0],g=t.pixelRatio[1];return e.box(e.types.hvc1,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,h>>8&255,255&h,p>>8&255,255&p,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]),f,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([y>>24,y>>16&255,y>>8&255,255&y,g>>24,g>>16&255,g>>8&255,255&g])))}}]),e}();MP4.types=void 0,MP4.HDLR_TYPES=void 0,MP4.STTS=void 0,MP4.STSC=void 0,MP4.STCO=void 0,MP4.STSZ=void 0,MP4.VMHD=void 0,MP4.SMHD=void 0,MP4.STSD=void 0,MP4.FTYP=void 0,MP4.DINF=void 0;var MPEG_TS_CLOCK_FREQ_HZ=9e4;function toTimescaleFromBase(e,t){var r=e*t*(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1);return arguments.length>3&&void 0!==arguments[3]&&arguments[3]?Math.round(r):r}function toTimescaleFromScale(e,t){return toTimescaleFromBase(e,t,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}function toMsFromMpegTsClock(e){return toTimescaleFromBase(e,1e3,1/MPEG_TS_CLOCK_FREQ_HZ,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}function toMpegTsClockFromTimescale(e){return toTimescaleFromBase(e,MPEG_TS_CLOCK_FREQ_HZ,1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1))}var MAX_SILENT_FRAME_DURATION=1e4,AAC_SAMPLES_PER_FRAME=1024,MPEG_AUDIO_SAMPLE_PER_FRAME=1152,AC3_SAMPLES_PER_FRAME=1536,chromeVersion=null,safariWebkitVersion=null,MP4Remuxer=function(){function e(t,r,n,a){if(_classCallCheck$1(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=r,this.typeSupported=n,this.logger=a,this.ISGenerated=!1,null===chromeVersion){var i=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);chromeVersion=i?_parseInt$1(i[1]):0}if(null===safariWebkitVersion){var s=navigator.userAgent.match(/Safari\/(\d+)/i);safariWebkitVersion=s?_parseInt$1(s[1]):0}}return _createClass$1(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,r=e[0].pts,n=_reduceInstanceProperty(e).call(e,(function(e,n){var a=n.pts,i=a-e;return i<-4294967296&&(t=!0,i=(a=normalizePts(a,r))-e),i>0?e:a}),r);return t&&this.logger.debug("PTS rollover detected"),n}},{key:"remux",value:function(e,t,r,n,a,i,s,o){var l,c,u,d,f,h,p=a,y=a,g=e.pid>-1,v=t.pid>-1,m=t.samples.length,E=e.samples.length>0,$=s&&m>0||m>1;if((!g||E)&&(!v||$)||this.ISGenerated||s){if(this.ISGenerated){var S,T,I,_,P=this.videoTrackConfig;(P&&(t.width!==P.width||t.height!==P.height||(null==(S=t.pixelRatio)?void 0:S[0])!==(null==(T=P.pixelRatio)?void 0:T[0])||(null==(I=t.pixelRatio)?void 0:I[1])!==(null==(_=P.pixelRatio)?void 0:_[1]))||!P&&$||null===this.nextAudioPts&&E)&&this.resetInitSegment()}this.ISGenerated||(u=this.generateIS(e,t,a,i));var b,A=this.isVideoContiguous,R=-1;if($&&(R=findKeyframeIndex(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(h=!0,R>0){var k,C;this.logger.warn(_concatInstanceProperty(k="[mp4-remuxer]: Dropped ".concat(R," out of ")).call(k,m," video samples due to a missing keyframe"));var O=this.getVideoStartPts(t.samples);t.samples=_sliceInstanceProperty(C=t.samples).call(C,R),t.dropped+=R,b=y+=(t.samples[0].pts-O)/t.inputTimeScale}else-1===R&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(m," video samples")),h=!1);if(this.ISGenerated){if(E&&$){var L=this.getVideoStartPts(t.samples),D=(normalizePts(e.samples[0].pts,L)-L)/t.inputTimeScale;p+=Math.max(0,D),y+=Math.max(0,-D)}if(E){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,a,i)),c=this.remuxAudio(e,p,this.isAudioContiguous,i,v||$||o===PlaylistLevelType.AUDIO?y:void 0),$){var w=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,a,i)),l=this.remuxVideo(t,y,A,w)}}else $&&(l=this.remuxVideo(t,y,A,0));l&&(l.firstKeyFrame=R,l.independent=-1!==R,l.firstKeyFramePTS=b)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=flushTextTrackMetadataCueSamples(r,a,this._initPTS,this._initDTS)),n.samples.length&&(d=flushTextTrackUserdataCueSamples(n,a,this._initPTS))),{audio:c,video:l,initSegment:u,independent:h,text:d,id3:f}}},{key:"generateIS",value:function(e,t,r,n){var a,i,s,o=e.samples,l=t.samples,c=this.typeSupported,u={},d=this._initPTS,f=!d||n,h="audio/mp4";if(f&&(a=i=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":c.mpeg?(h="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}u.audio={id:"audio",container:h,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&c.mpeg?new Uint8Array(0):MP4.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(s=e.inputTimeScale,d&&s===d.timescale?f=!1:a=i=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,u.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:MP4.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(s=t.inputTimeScale,d&&s===d.timescale)f=!1;else{var p=this.getVideoStartPts(l),y=Math.round(s*r);i=Math.min(i,normalizePts(l[0].dts,p)-y),a=Math.min(a,p-y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(_Object$keys(u).length)return this.ISGenerated=!0,f?(this._initPTS={baseTime:a,timescale:s},this._initDTS={baseTime:i,timescale:s}):a=s=void 0,{tracks:u,initPTS:a,timescale:s}}},{key:"remuxVideo",value:function(e,t,r,n){var a,i,s=e.inputTimeScale,o=e.samples,l=[],c=o.length,u=this._initPTS,d=this.nextAvcDts,f=8,h=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,g=!1;if(!r||null===d){var v=t*s,m=o[0].pts-normalizePts(o[0].dts,o[0].pts);chromeVersion&&null!==d&&Math.abs(v-m-d)<15e3?r=!0:d=v-m}for(var E=u.baseTime*s/u.timescale,$=0;$<c;$++){var S=o[$];S.pts=normalizePts(S.pts-E,d),S.dts=normalizePts(S.dts-E,d),S.dts<o[$>0?$-1:$].dts&&(g=!0)}g&&_sortInstanceProperty(o).call(o,(function(e,t){var r=e.dts-t.dts,n=e.pts-t.pts;return r||n})),a=o[0].dts;var T=(i=o[o.length-1].dts)-a,I=T?Math.round(T/(c-1)):h||e.inputTimeScale/30;if(r){var _=a-d,P=_>I,b=_<-1;if(P||b){var A,R,k,C,O,L;if(P)this.logger.warn(_concatInstanceProperty(A=_concatInstanceProperty(R=_concatInstanceProperty(k="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(k,toMsFromMpegTsClock(_,!0)," ms (")).call(R,_,"dts) hole between fragments detected at ")).call(A,t.toFixed(3)));else this.logger.warn(_concatInstanceProperty(C=_concatInstanceProperty(O=_concatInstanceProperty(L="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(L,toMsFromMpegTsClock(-_,!0)," ms (")).call(O,_,"dts) overlapping between fragments detected at ")).call(C,t.toFixed(3)));if(!b||d>=o[0].pts||chromeVersion){var D,w;a=d;var M=o[0].pts-_;if(P)o[0].dts=a,o[0].pts=M;else for(var x=!0,N=0;N<o.length&&!(o[N].dts>M&&x);N++){var F=o[N].pts;if(o[N].dts-=_,o[N].pts-=_,N<o.length-1){var U=o[N+1].pts;x=U<=o[N].pts==U<=F}}this.logger.log(_concatInstanceProperty(D=_concatInstanceProperty(w="Video: Initial PTS/DTS adjusted: ".concat(toMsFromMpegTsClock(M,!0),"/")).call(w,toMsFromMpegTsClock(a,!0),", delta: ")).call(D,toMsFromMpegTsClock(_,!0)," ms"))}}}for(var B=0,j=0,G=a=Math.max(0,a),H=0;H<c;H++){for(var K=o[H],V=K.units,W=V.length,Y=0,q=0;q<W;q++)Y+=V[q].data.length;j+=Y,B+=W,K.length=Y,K.dts<G?(K.dts=G,G+=I/4|0||1):G=K.dts,p=Math.min(K.pts,p),y=Math.max(K.pts,y)}i=o[c-1].dts;var z,X=j+4*B+8;try{z=new Uint8Array(X)}catch(e){return void this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MUX_ERROR,details:ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:X,reason:"fail allocating video mdat ".concat(X)})}var Q=new DataView(z.buffer);Q.setUint32(0,X),z.set(MP4.types.mdat,4);for(var J=!1,Z=Number.POSITIVE_INFINITY,ee=Number.POSITIVE_INFINITY,te=Number.NEGATIVE_INFINITY,re=Number.NEGATIVE_INFINITY,ne=0;ne<c;ne++){for(var ae=o[ne],ie=ae.units,se=0,oe=0,le=ie.length;oe<le;oe++){var ce=ie[oe],ue=ce.data,de=ce.data.byteLength;Q.setUint32(f,de),f+=4,z.set(ue,f),f+=de,se+=4+de}var fe=void 0;if(ne<c-1)h=o[ne+1].dts-ae.dts,fe=o[ne+1].pts-ae.pts;else{var he=this.config,pe=ne>0?ae.dts-o[ne-1].dts:I;if(fe=ne>0?ae.pts-o[ne-1].pts:I,he.stretchShortVideoTrack&&null!==this.nextAudioPts){var ye,ge=Math.floor(he.maxBufferHole*s),ve=(n?p+n*s:this.nextAudioPts)-ae.pts;if(ve>ge)(h=ve-pe)<0?h=pe:J=!0,this.logger.log(_concatInstanceProperty(ye="[mp4-remuxer]: It is approximately ".concat(ve/90," ms to the next segment; using duration ")).call(ye,h/90," ms for the last video frame."));else h=pe}else h=pe}var me=Math.round(ae.pts-ae.dts);Z=Math.min(Z,h),te=Math.max(te,h),ee=Math.min(ee,fe),re=Math.max(re,fe),l.push(new Mp4Sample(ae.key,h,se,me))}if(l.length)if(chromeVersion){if(chromeVersion<70){var Ee=_flagsInstanceProperty(l[0]);Ee.dependsOn=2,Ee.isNonSync=0}}else if(safariWebkitVersion&&re-ee<te-Z&&I/te<.025&&0===l[0].cts){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var $e=a,Se=0,Te=l.length;Se<Te;Se++){var Ie=$e+l[Se].duration,_e=$e+l[Se].cts;if(Se<Te-1){var Pe=Ie+l[Se+1].cts;l[Se].duration=Pe-_e}else l[Se].duration=Se?l[Se-1].duration:I;l[Se].cts=0,$e=Ie}}h=J||!h?I:h,this.nextAvcDts=d=i+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;var be={data1:MP4.moof(e.sequenceNumber++,a,_extends({},e,{samples:l})),data2:z,startPTS:p/s,endPTS:(y+h)/s,startDTS:a/s,endDTS:d/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,be}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return MPEG_AUDIO_SAMPLE_PER_FRAME;case"ac3":return AC3_SAMPLES_PER_FRAME;default:return AAC_SAMPLES_PER_FRAME}}},{key:"remuxAudio",value:function(e,t,r,n,a){var i=e.inputTimeScale,s=i/(e.samplerate?e.samplerate:i),o=this.getSamplesPerFrame(e),l=o*s,c=this._initPTS,u="mp3"===e.segmentCodec&&this.typeSupported.mpeg,d=[],f=void 0!==a,h=e.samples,p=u?0:8,y=this.nextAudioPts||-1,g=t*i,v=c.baseTime*i/c.timescale;if(this.isAudioContiguous=r=r||h.length&&y>0&&(n&&Math.abs(g-y)<9e3||Math.abs(normalizePts(h[0].pts-v,g)-y)<20*l),_forEachInstanceProperty(h).call(h,(function(e){e.pts=normalizePts(e.pts-v,g)})),!r||y<0){if(!(h=_filterInstanceProperty(h).call(h,(function(e){return e.pts>=0}))).length)return;y=0===a?0:n&&!f?Math.max(0,g):h[0].pts}if("aac"===e.segmentCodec)for(var m=this.config.maxAudioFramesDrift,E=0,$=y;E<h.length;E++){var S,T=h[E],I=T.pts,_=I-$,P=Math.abs(1e3*_/i);if(_<=-m*l&&f){if(0===E)this.logger.warn(_concatInstanceProperty(S="Audio frame @ ".concat((I/i).toFixed(3),"s overlaps nextAudioPts by ")).call(S,Math.round(1e3*_/i)," ms.")),this.nextAudioPts=y=$=I}else if(_>=m*l&&P<MAX_SILENT_FRAME_DURATION&&f){var b,A,R=Math.round(_/l);($=I-R*l)<0&&(R--,$+=l),0===E&&(this.nextAudioPts=y=$),this.logger.warn(_concatInstanceProperty(b=_concatInstanceProperty(A="[mp4-remuxer]: Injecting ".concat(R," audio frame @ ")).call(A,($/i).toFixed(3),"s due to ")).call(b,Math.round(1e3*_/i)," ms gap."));for(var k=0;k<R;k++){var C=Math.max($,0),O=AAC.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);O||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),O=T.unit.subarray()),_spliceInstanceProperty(h).call(h,E,0,{unit:O,pts:C}),$+=l,E++}}T.pts=$,$+=l}for(var L,D=null,w=null,M=0,x=h.length;x--;)M+=h[x].unit.byteLength;for(var N=0,F=h.length;N<F;N++){var U=h[N],B=U.unit,j=U.pts;if(null!==w){d[N-1].duration=Math.round((j-w)/s)}else{if(r&&"aac"===e.segmentCodec&&(j=y),D=j,!(M>0))return;M+=p;try{L=new Uint8Array(M)}catch(e){return void this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MUX_ERROR,details:ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:M,reason:"fail allocating audio mdat ".concat(M)})}u||(new DataView(L.buffer).setUint32(0,M),L.set(MP4.types.mdat,4))}L.set(B,p);var G=B.byteLength;p+=G,d.push(new Mp4Sample(!0,o,G,0)),w=j}var H=d.length;if(H){var K=d[d.length-1];this.nextAudioPts=y=w+s*K.duration;var V=u?new Uint8Array(0):MP4.moof(e.sequenceNumber++,D/s,_extends({},e,{samples:d}));e.samples=[];var W=D/i,Y=y/i,q={data1:V,data2:L,startPTS:W,endPTS:Y,startDTS:W,endDTS:Y,type:"audio",hasAudio:!0,hasVideo:!1,nb:H};return this.isAudioContiguous=!0,q}}}]),e}();function normalizePts(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function findKeyframeIndex(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}function flushTextTrackMetadataCueSamples(e,t,r,n){var a=e.samples.length;if(a){for(var i=e.inputTimeScale,s=0;s<a;s++){var o=e.samples[s];o.pts=normalizePts(o.pts-r.baseTime*i/r.timescale,t*i)/i,o.dts=normalizePts(o.dts-n.baseTime*i/n.timescale,t*i)/i}var l=e.samples;return e.samples=[],{samples:l}}}function flushTextTrackUserdataCueSamples(e,t,r){var n,a=e.samples.length;if(a){for(var i=e.inputTimeScale,s=0;s<a;s++){var o=e.samples[s];o.pts=normalizePts(o.pts-r.baseTime*i/r.timescale,t*i)/i}_sortInstanceProperty(n=e.samples).call(n,(function(e,t){return e.pts-t.pts}));var l=e.samples;return e.samples=[],{samples:l}}}var now2,Mp4Sample=_createClass$1((function e(t,r,n,a){_classCallCheck$1(this,e),this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=r,this.size=n,this.cts=a,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}})),PassThroughRemuxer=function(){function e(t,r,n,a){_classCallCheck$1(this,e),this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=a}return _createClass$1(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.lastEndTime=null}},{key:"resetNextTimestamp",value:function(){this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,r,n){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(patchEncyptionData(e,n)),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var n=this.initData=parseInitSegment(e);n.audio&&(t=getParsedTrackCodec(n.audio,ElementaryStreamTypes.AUDIO)),n.video&&(r=getParsedTrackCodec(n.video,ElementaryStreamTypes.VIDEO));var a={};n.audio&&n.video?a.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:n.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?a.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a}},{key:"remux",value:function(e,t,r,n,a,i){var s,o,l=this.initPTS,c=this.lastEndTime,u={audio:void 0,video:void 0,text:n,id3:r,initSegment:void 0};isFiniteNumber(c)||(c=this.lastEndTime=a||0);var d=t.samples;if(null==d||!d.length)return u;var f={initPTS:void 0,timescale:1},h=this.initData;if(null!=(s=h)&&s.length||(this.generateInitSegment(d),h=this.initData),null==(o=h)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var p=getDuration(d,h),y=getStartDTS(h,d),g=null===y?a:y;if(isInvalidInitPts(l,g,a,p)||f.timescale!==l.timescale&&i){var v,m;if(f.initPTS=g-a,l&&1===l.timescale)this.logger.warn(_concatInstanceProperty(v=_concatInstanceProperty(m="Adjusting initPTS @".concat(a," from ")).call(m,l.baseTime/l.timescale," to ")).call(v,f.initPTS));this.initPTS=l={baseTime:f.initPTS,timescale:1}}var E=e?g-l.baseTime/l.timescale:c,$=E+p;offsetStartDTS(h,d,l.baseTime/l.timescale),p>0?this.lastEndTime=$:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var S=!!h.audio,T=!!h.video,I="";S&&(I+="audio"),T&&(I+="video");var _={data1:d,startPTS:E,startDTS:E,endPTS:$,endDTS:$,type:I,hasAudio:S,hasVideo:T,nb:1,dropped:0};return u.audio="audio"===_.type?_:void 0,u.video="audio"!==_.type?_:void 0,u.initSegment=f,u.id3=flushTextTrackMetadataCueSamples(r,a,l,l),n.samples.length&&(u.text=flushTextTrackUserdataCueSamples(n,a,l)),u}}]),e}();function isInvalidInitPts(e,t,r,n){if(null===e)return!0;var a=Math.max(n,1),i=t-e.baseTime/e.timescale;return Math.abs(i-r)>a}function getParsedTrackCodec(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===ElementaryStreamTypes.AUDIO){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return getCodecCompatibleName(r,!1)}return logger.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"}return logger.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1"}try{var _context261;now2=_bindInstanceProperty(_context261=self.performance.now).call(_context261,self.performance)}catch(e){now2=_Date$now}var muxConfig=[{demux:MP4Demuxer,remux:PassThroughRemuxer},{demux:TSDemuxer,remux:MP4Remuxer},{demux:AACDemuxer,remux:MP4Remuxer},{demux:MP3Demuxer,remux:MP4Remuxer}];_spliceInstanceProperty(muxConfig).call(muxConfig,2,0,{demux:AC3Demuxer,remux:MP4Remuxer});var Transmuxer=function(){function e(t,r,n,a,i,s){_classCallCheck$1(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=r,this.config=n,this.id=i,this.logger=s}return _createClass$1(e,[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,r,n){var a=this,i=r.transmuxing;i.executeStart=now2();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;n&&(this.currentTransmuxState=n);var c=n||o,u=c.contiguous,d=c.discontinuity,f=c.trackSwitch,h=c.accurateTimeOffset,p=c.timeOffset,y=c.initSegmentChange,g=l.audioCodec,v=l.videoCodec,m=l.defaultInitPts,E=l.duration,$=l.initSegmentData,S=getEncryptionType(s,t);if(S&&isFullSegmentEncryption(S.method)){var T=this.getDecrypter(),I=getAesModeFromFullSegmentMethod(S.method);if(!T.isSync())return this.asyncResult=!0,this.decryptionPromise=T.webCryptoDecrypt(s,S.key.buffer,S.iv.buffer,I).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var _=T.softwareDecrypt(s,S.key.buffer,S.iv.buffer,I);if(r.part>-1){var P=T.flush();_=P?P.buffer:P}if(!_)return i.executeEnd=now2(),emptyResult(r);s=new Uint8Array(_)}var b=this.needsProbing(d,f);if(b){var A=this.configureTransmuxer(s);if(A)return this.logger.warn("[transmuxer] ".concat(A.message)),this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,error:A,reason:A.message}),i.executeEnd=now2(),emptyResult(r)}(d||f||y||b)&&this.resetInitSegment($,g,v,E,t),(d||y||b)&&this.resetInitialTimestamp(m),u||this.resetContiguity();var R=this.transmux(s,S,p,h,r);this.asyncResult=isPromise(R);var k=this.currentTransmuxState;return k.contiguous=!0,k.discontinuity=!1,k.trackSwitch=!1,i.executeEnd=now2(),R}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=now2();var n=this.decrypter,a=this.currentTransmuxState,i=this.decryptionPromise;if(i)return this.asyncResult=!0,i.then((function(){return t.flush(e)}));var s=[],o=a.timeOffset;if(n){var l=n.flush();l&&s.push(this.push(l.buffer,null,e))}var c=this.demuxer,u=this.remuxer;if(!c||!u){r.executeEnd=now2();var d=[emptyResult(e)];return this.asyncResult?_Promise.resolve(d):d}var f=c.flush(o);return isPromise(f)?(this.asyncResult=!0,f.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,f,e),this.asyncResult?_Promise.resolve(s):s)}},{key:"flushRemux",value:function(e,t,r){var n,a,i,s,o=t.audioTrack,l=t.videoTrack,c=t.id3Track,u=t.textTrack,d=this.currentTransmuxState,f=d.accurateTimeOffset,h=d.timeOffset;this.logger.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="[transmuxer.ts]: Flushed ".concat(this.id," sn: ")).call(s,r.sn)).call(i,r.part>-1?" part: "+r.part:""," of ")).call(a,this.id===PlaylistLevelType.MAIN?"level":"track"," ")).call(n,r.level));var p=this.remuxer.remux(o,l,c,u,h,f,!0,this.id);e.push({remuxResult:p,chunkMeta:r}),r.transmuxing.executeEnd=now2()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,r,n,a){var i=this.demuxer,s=this.remuxer;i&&s&&(i.resetInitSegment(e,t,r,n),s.resetInitSegment(e,t,r,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,r,n,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,n,a):this.transmuxUnencrypted(e,r,n,a)}},{key:"transmuxUnencrypted",value:function(e,t,r,n){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),i=a.audioTrack,s=a.videoTrack,o=a.id3Track,l=a.textTrack;return{remuxResult:this.remuxer.remux(i,s,o,l,t,r,!1,this.id),chunkMeta:n}}},{key:"transmuxSampleAes",value:function(e,t,r,n,a){var i=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:i.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,n,!1,i.id),chunkMeta:a}}))}},{key:"configureTransmuxer",value:function(e){for(var t,r=this.config,n=this.observer,a=this.typeSupported,i=0,s=muxConfig.length;i<s;i++){var o;if(null!=(o=muxConfig[i].demux)&&o.probe(e,this.logger)){t=muxConfig[i];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,c=this.remuxer,u=t.remux,d=t.demux;c&&c instanceof u||(this.remuxer=new u(n,r,a,this.logger)),l&&l instanceof d||(this.demuxer=new d(n,r,a,this.logger),this.probe=d.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new Decrypter(this.config)),e}}]),e}();function getEncryptionType(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}var emptyResult=function(e){return{remuxResult:{},chunkMeta:e}};function isPromise(e){return"then"in e&&e.then instanceof Function}var TransmuxConfig=_createClass$1((function e(t,r,n,a,i){_classCallCheck$1(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=r,this.initSegmentData=n,this.duration=a,this.defaultInitPts=i||null})),TransmuxState=_createClass$1((function e(t,r,n,a,i,s){_classCallCheck$1(this,e),this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=r,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=i,this.initSegmentChange=s})),transmuxerInstanceCount=0,TransmuxerInterface=function(){function e(t,r,n,a){var i=this;_classCallCheck$1(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=transmuxerInstanceCount++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(e){var t=e.data,r=i.hls;if(r&&null!=t&&t.event&&t.instanceNo===i.instanceNo)switch(t.event){case"init":var n,a=null==(n=i.workerContext)?void 0:n.objectURL;a&&_URL.revokeObjectURL(a);break;case"transmuxComplete":i.handleTransmuxComplete(t.data);break;case"flush":i.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=i.frag,t.data.part=i.part,t.data.id=i.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){var t,r;if(i.hls){var n=new Error(_concatInstanceProperty(t=_concatInstanceProperty(r="".concat(e.message," (")).call(r,e.filename,":")).call(t,e.lineno,")"));i.hls.config.enableWorker=!1,i.hls.logger.warn('Error in "'.concat(i.id,'" Web Worker, fallback to inline')),i.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:n})}};var s=t.config;this.hls=t,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var o=function(e,t){(t=t||{}).frag=i.frag||void 0,e===Events.ERROR&&(t.parent=i.id,t.part=i.part,i.error=t.error),i.hls.trigger(e,t)};this.observer=new EventEmitter,this.observer.on(Events.FRAG_DECRYPTED,o),this.observer.on(Events.ERROR,o);var l=getM2TSSupportedAudioTypes(s.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var c=this.hls.logger;if(s.workerPath||hasUMDWorker()){try{var u;if(s.workerPath)c.log(_concatInstanceProperty(u="loading Web Worker ".concat(s.workerPath,' for "')).call(u,r,'"')),this.workerContext=loadWorker(s.workerPath);else c.log('injecting Web Worker for "'.concat(r,'"')),this.workerContext=injectWorker();var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:l,id:r,config:_JSON$stringify(s)})}catch(e){c.warn('Error setting up "'.concat(r,'" Web Worker, fallback to inline'),e),this.terminateWorker(),this.error=null,this.transmuxer=new Transmuxer(this.observer,l,s,"",r,t.logger)}return}}this.transmuxer=new Transmuxer(this.observer,l,s,"",r,t.logger)}return _createClass$1(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=transmuxerInstanceCount++;var t=this.hls.config,r=getM2TSSupportedAudioTypes(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:_JSON$stringify(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),removeWorkerFromStore(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,r,n,a,i,s,o,l,c){var u,d,f=this;l.transmuxing.start=self.performance.now();var h=this.instanceNo,p=this.transmuxer,y=i?i.start:a.start,g=a.decryptdata,v=this.frag,m=!(v&&a.cc===v.cc),E=!(v&&l.level===v.level),$=v?l.sn-v.sn:-1,S=this.part?l.part-this.part.index:-1,T=0===$&&l.id>1&&l.id===(null==v?void 0:v.stats.chunkCount),I=!E&&(1===$||0===$&&(1===S||T&&S<=0)),_=self.performance.now();(E||$||0===a.stats.parsing.start)&&(a.stats.parsing.start=_),!i||!S&&I||(i.stats.parsing.start=_);var P=!(v&&(null==(u=a.initSegment)?void 0:u.url)===(null==(d=v.initSegment)?void 0:d.url)),b=new TransmuxState(m,I,o,E,y,P);if(!I||m||P){var A,R,k,C,O,L,D,w,M,x,N;this.hls.logger.log(_concatInstanceProperty(A=_concatInstanceProperty(R=_concatInstanceProperty(k=_concatInstanceProperty(C=_concatInstanceProperty(O=_concatInstanceProperty(L=_concatInstanceProperty(D=_concatInstanceProperty(w=_concatInstanceProperty(M=_concatInstanceProperty(x=_concatInstanceProperty(N="[transmuxer-interface]: Starting new transmux session for ".concat(a.type," sn: ")).call(N,l.sn)).call(x,l.part>-1?" part: "+l.part:""," ")).call(M,this.id===PlaylistLevelType.MAIN?"level":"track",": ")).call(w,l.level," id: ")).call(D,l.id,"\n discontinuity: ")).call(L,m,"\n trackSwitch: ")).call(O,E,"\n contiguous: ")).call(C,I,"\n accurateTimeOffset: ")).call(k,o,"\n timeOffset: ")).call(R,y,"\n initSegmentChange: ")).call(A,P));var F=new TransmuxConfig(r,n,t,s,c);this.configureTransmuxer(F)}if(this.frag=a,this.part=i,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:e,decryptdata:g,chunkMeta:l,state:b},e instanceof ArrayBuffer?[e]:[]);else if(p){var U=p.push(e,g,l,b);isPromise(U)?U.then((function(e){f.handleTransmuxComplete(e)})).catch((function(e){f.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(U)}}},{key:"flush",value:function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,n=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(n){var a=n.flush(e);isPromise(a)?a.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}}},{key:"transmuxerError",value:function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}},{key:"handleFlushResult",value:function(e,t){var r=this;_forEachInstanceProperty(e).call(e,(function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}]),e}();function subtitleOptionsIdentical(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!mediaAttributesIdentical(e[r].attrs,t[r].attrs))return!1;return!0}function mediaAttributesIdentical(e,t,r){var n,a=e["STABLE-RENDITION-ID"];return a&&!r?a===t["STABLE-RENDITION-ID"]:!_someInstanceProperty(n=r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).call(n,(function(r){return e[r]!==t[r]}))}function subtitleTrackMatchesTextTrack(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var TICK_INTERVAL$2=100,AudioStreamController=function(e){_inherits(r,BaseStreamController);var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e,n,a,"audio-stream-controller",PlaylistLevelType.AUDIO)).mainAnchor=null,i.mainFragLoading=null,i.audioOnly=!1,i.bufferedTrack=null,i.switchingTrack=null,i.trackId=-1,i.waitingData=null,i.mainDetails=null,i.flushing=!1,i.bufferFlushed=!1,i.cachedTrackLoadedData=null,i.registerListeners(),i}return _createClass$1(r,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){_get(_getPrototypeOf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Events.BUFFER_RESET,this.onBufferReset,this),e.on(Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Events.FRAG_LOADING,this.onFragLoading,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(_get(_getPrototypeOf(r.prototype),"unregisterListeners",this).call(this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Events.BUFFER_RESET,this.onBufferReset,this),e.off(Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Events.FRAG_LOADING,this.onFragLoading,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,t){var r=t.frag,n=t.id,a=t.initPTS,i=t.timescale;if(n===PlaylistLevelType.MAIN){var s,o,l=r.cc,c=this.fragCurrent;if(this.initPTS[l]={baseTime:a,timescale:i},this.log(_concatInstanceProperty(s=_concatInstanceProperty(o="InitPTS for cc: ".concat(l," found from main: ")).call(o,a,"/")).call(s,i)),this.mainAnchor=r,this.state===State.WAITING_INIT_PTS){var u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==l)&&(this.nextLoadPosition=this.findSyncFrag(r).start),this.tick()}else!this.hls.hasEnoughToStart&&c&&c.cc!==l?(this.startFragRequested=!1,this.nextLoadPosition=this.findSyncFrag(r).start,c.abortRequests(),this.resetLoadingState()):this.state===State.IDLE&&this.tick()}}},{key:"findSyncFrag",value:function(e){var t=this.getLevelDetails(),r=e.cc;return findNearestWithCC(t,r,e)||t&&findFragWithCC(t.fragments,r)||e}},{key:"startLoad",value:function(e){if(!this.levels)return this.startPosition=e,void(this.state=State.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(TICK_INTERVAL$2),t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @".concat(t.toFixed(3))),e=t,this.state=State.IDLE):this.state=State.WAITING_TRACK,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case State.IDLE:this.doTickIdle();break;case State.WAITING_TRACK:var e=this.levels,t=this.trackId,n=null==e?void 0:e[t],a=null==n?void 0:n.details;if(a&&!this.waitForLive(n)){if(this.waitForCdnTuneIn(a))break;this.state=State.WAITING_INIT_PTS}break;case State.FRAG_LOADING_WAITING_RETRY:var i,s=performance.now(),o=this.retryDate;if(!o||s>=o||null!=(i=this.media)&&i.seeking){var l=this.levels,c=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==l?void 0:l[c])||null),this.state=State.IDLE}break;case State.WAITING_INIT_PTS:var u=this.waitingData;if(u){var d=u.frag,f=u.part,h=u.cache,p=u.complete,y=this.mainAnchor;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.state=State.FRAG_LOADING;var g={frag:d,part:f,payload:h.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(g),p&&_get(_getPrototypeOf(r.prototype),"_handleFragmentLoadComplete",this).call(this,g)}else if(y&&y.cc!==u.frag.cc){var v;this.log(_concatInstanceProperty(v="Waiting fragment cc (".concat(d.cc,") cancelled because video is at cc ")).call(v,y.cc)),this.nextLoadPosition=this.findSyncFrag(y).start,this.clearWaitingFragment()}}else this.state=State.IDLE}this.onTickEnd()}},{key:"clearWaitingFragment",value:function(){var e=this.waitingData;e&&(this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.state!==State.STOPPED&&(this.state=State.IDLE))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),_get(_getPrototypeOf(r.prototype),"resetLoadingState",this).call(this)}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,r=this.levels,n=this.media,a=this.trackId,i=t.config;if(this.buffering&&(n||!this.startFragRequested&&i.startFragPrefetch)&&null!=r&&r[a]){var s=r[a],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=State.WAITING_TRACK,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ElementaryStreamTypes.AUDIO,PlaylistLevelType.AUDIO));var c=this.getFwdBufferInfo(l,PlaylistLevelType.AUDIO);if(null!==c){var u=this.bufferedTrack,d=this.switchingTrack;if(!d&&this._streamEnded(c,o))return t.trigger(Events.BUFFER_EOS,{type:"audio"}),void(this.state=State.ENDED);var f=c.len,h=t.maxBufferLength,p=o.fragments,y=p[0].start,g=this.getLoadPosition(),v=this.flushing?g:c.end;if(d&&n){var m=g;u&&!mediaAttributesIdentical(d.attrs,u.attrs)&&(v=m),o.PTSKnown&&m<y&&(c.end>y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=y+.05)}if(!(f>=h&&!d&&v<p[p.length-1].start)){var E=this.getNextFragment(v,o);if(E&&this.isLoopLoading(E,v)&&(E=this.getNextFragmentLoopLoading(E,o,c,PlaylistLevelType.MAIN,h)),E){var $=null==(e=this.mainFragLoading)?void 0:e.frag;if(!this.audioOnly&&this.startFragRequested&&$&&isMediaFragment($)&&isMediaFragment(E)&&!E.endList&&(!o.live||!this.loadingParts&&v<this.hls.liveSyncPosition)){var S=$;if(E.start>S.end){var T=this.fragmentTracker.getFragAtPos(v,PlaylistLevelType.MAIN);T&&T.end>$.end&&(S=T,this.mainFragLoading={frag:T,targetBufferTime:null})}if(E.start>S.end)return}this.loadFragment(E,s,v)}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,t){this.bufferFlushed=this.flushing=!1,_get(_getPrototypeOf(r.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=_mapInstanceProperty(r).call(r,(function(e){return new Level(e)}))}},{key:"onAudioTrackSwitching",value:function(e,t){var r=!!t.url;this.trackId=t.id;var n=this.fragCurrent;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==State.STOPPED&&(this.setInterval(TICK_INTERVAL$2),this.state=State.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){_get(_getPrototypeOf(r.prototype),"onManifestLoading",this).call(this),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.hls.trigger(Events.AUDIO_TRACK_LOADED,r))}},{key:"onAudioTrackLoaded",value:function(e,t){var r,n,a,i,s,o,l=this.levels,c=t.details,u=t.id,d=this.mainDetails;if(!d||d.expired||c.endCC>d.endCC)return this.cachedTrackLoadedData=t,void(this.state!==State.STOPPED&&(this.state=State.WAITING_TRACK));if(l){this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="Audio track ".concat(u," loaded [")).call(i,c.startSN,",")).call(a,c.endSN,"]")).call(n,c.lastPartSn?_concatInstanceProperty(s="[part-".concat(c.lastPartSn,"-")).call(s,c.lastPartIndex,"]"):"",",duration:")).call(r,c.totalduration));var f=l[u],h=0;if(c.live||null!=(o=f.details)&&o.live){if(this.checkLiveUpdate(c),c.deltaUpdateFailed)return;var p;if(f.details)h=this.alignPlaylists(c,f.details,null==(p=this.levelLastLoaded)?void 0:p.details);c.alignedSliding||(alignDiscontinuities(c,d),c.alignedSliding||alignMediaPlaylistByPDT(c,d),h=c.fragmentStart)}f.details=c,this.levelLastLoaded=f,this.startFragRequested||this.setStartPosition(d,h),this.hls.trigger(Events.AUDIO_TRACK_UPDATED,{details:c,id:u,groupId:t.groupId}),this.state!==State.WAITING_TRACK||this.waitForCdnTuneIn(c)||(this.state=State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level ".concat(u))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,n=e.part,a=e.payload,i=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);var u,d,f=i.defaultAudioCodec||l.audioCodec||"mp4a.40.2",h=this.transmuxer;if(!h)h=this.transmuxer=new TransmuxerInterface(this.hls,PlaylistLevelType.AUDIO,_bindInstanceProperty(u=this._handleTransmuxComplete).call(u,this),_bindInstanceProperty(d=this._handleTransmuxerFlush).call(d,this));var p=this.initPTS[r.cc],y=null==(t=r.initSegment)?void 0:t.data;if(void 0!==p){var g=n?n.index:-1,v=-1!==g,m=new ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,g,v);h.push(a,y,f,"",r,n,c.totalduration,!1,m,p)}else{var E,$,S,T;this.log(_concatInstanceProperty(E=_concatInstanceProperty($=_concatInstanceProperty(S=_concatInstanceProperty(T="Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ")).call(T,r.sn," of [")).call(S,c.startSN," ,")).call($,c.endSN,"],track ")).call(E,s)),(this.waitingData=this.waitingData||{frag:r,part:n,cache:new ChunkCache,complete:!1}).cache.push(new Uint8Array(a)),this.state!==State.STOPPED&&(this.state=State.WAITING_INIT_PTS)}}else this.warn("Audio track is undefined on fragment load progress")}else{var I;this.warn(_concatInstanceProperty(I="Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ")).call(I,r.level," will not be buffered"))}}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:_get(_getPrototypeOf(r.prototype),"_handleFragmentLoadComplete",this).call(this,e)}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===PlaylistLevelType.MAIN&&isMediaFragment(t.frag)&&(this.mainFragLoading=t,this.state===State.IDLE&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,n=t.part;if(r.type===PlaylistLevelType.AUDIO)if(this.fragContextChanged(r)){var a,i,s,o;this.warn(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Fragment ".concat(r.sn)).call(o,n?" p: "+n.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(i,this.state,", audioSwitch: ")).call(a,this.switchingTrack?this.switchingTrack.name:"false"))}else{if(isMediaFragment(r)){this.fragPrevious=r;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(Events.AUDIO_TRACK_SWITCHED,_objectSpread2({},l)))}this.fragBufferedComplete(r,n),this.media&&this.tick()}else this.audioOnly||r.type!==PlaylistLevelType.MAIN||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,t){var n;if(t.fatal)this.state=State.ERROR;else switch(t.details){case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_PARSING_ERROR:case ErrorDetails.FRAG_DECRYPT_ERROR:case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(PlaylistLevelType.AUDIO,t);break;case ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case ErrorDetails.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==State.WAITING_TRACK||(null==(n=t.context)?void 0:n.type)!==PlaylistContextType.AUDIO_TRACK||(this.state=State.IDLE);break;case ErrorDetails.BUFFER_APPEND_ERROR:case ErrorDetails.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===ErrorDetails.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,_get(_getPrototypeOf(r.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case ErrorDetails.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==ElementaryStreamTypes.VIDEO&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==ElementaryStreamTypes.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===State.ENDED&&(this.state=State.IDLE);var n=this.mediaBuffer||this.media;n&&(this.afterBufferFlushed(n,r,PlaylistLevelType.AUDIO),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,r="audio",n=this.hls,a=e.remuxResult,i=e.chunkMeta,s=this.getCurrentContext(i);if(s){var o=s.frag,l=s.part,c=s.level,u=c.details,d=a.audio,f=a.text,h=a.id3,p=a.initSegment;if(!this.fragContextChanged(o)&&u){if(this.state=State.PARSING,this.switchingTrack&&d&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){var y=o.initSegment||o;this._bufferInitSegment(c,p.tracks,y,i),n.trigger(Events.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:r,tracks:p.tracks})}if(d){var g=d.startPTS,v=d.endPTS,m=d.startDTS,E=d.endDTS;l&&(l.elementaryStreams[ElementaryStreamTypes.AUDIO]={startPTS:g,endPTS:v,startDTS:m,endDTS:E}),o.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO,g,v,m,E),this.bufferFragmentData(d,o,l,i)}if(null!=h&&null!=(t=h.samples)&&t.length){var $=_extends({id:r,frag:o,details:u},h);n.trigger(Events.FRAG_PARSING_METADATA,$)}if(f){var S=_extends({id:r,frag:o,details:u},f);n.trigger(Events.FRAG_PARSING_USERDATA,S)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(i)}},{key:"_bufferInitSegment",value:function(e,t,r,n){var a,i;if(this.state===State.PARSING&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var s=t.audio;s.id="audio";var o=e.audioCodec;this.log(_concatInstanceProperty(a=_concatInstanceProperty(i="Init audio buffer, container:".concat(s.container,", codecs[level/parsed]=[")).call(i,o,"/")).call(a,s.codec,"]")),o&&1===o.split(",").length&&(s.levelCodec=o),this.hls.trigger(Events.BUFFER_CODECS,t);var l=s.initSegment;if(null!=l&&l.byteLength){var c={type:"audio",frag:r,part:null,chunkMeta:n,parent:r.type,data:l};this.hls.trigger(Events.BUFFER_APPENDING,c)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,t,n){var a,i=this.fragmentTracker.getState(e);if(this.switchingTrack||i===FragmentState.NOT_LOADED||i===FragmentState.PARTIAL)if(isMediaFragment(e))if(null!=(a=t.details)&&a.live&&!this.initPTS[e.cc]){var s,o;this.log(_concatInstanceProperty(s=_concatInstanceProperty(o="Waiting for video PTS in continuity counter ".concat(e.cc," of live stream before loading audio fragment ")).call(o,e.sn," of level ")).call(s,this.trackId)),this.state=State.WAITING_INIT_PTS;var l=this.mainDetails;l&&l.fragmentStart!==t.details.fragmentStart&&alignMediaPlaylistByPDT(t.details,l)}else _get(_getPrototypeOf(r.prototype),"loadFragment",this).call(this,e,t,n);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){var t=this.media,n=this.bufferedTrack,a=null==n?void 0:n.attrs,i=e.attrs;t&&a&&(a.CHANNELS!==i.CHANNELS||n.name!==e.name||n.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),_get(_getPrototypeOf(r.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Events.AUDIO_TRACK_SWITCHED,_objectSpread2({},e))}}]),r}(),BasePlaylistController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,n,e.logger)).hls=void 0,a.canLoad=!1,a.timer=-1,a.hls=e,a}return _createClass$1(r,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,r){var n=null==t?void 0:t.renditionReports;if(n){for(var a=-1,i=0;i<n.length;i++){var s=n[i],o=void 0;try{o=new _URL(s.URI,t.url).href}catch(e){this.warn("Could not construct new URL for Rendition Report: ".concat(e)),o=s.URI||""}if(o===e){a=i;break}o===e.substring(0,o.length)&&(a=i)}if(-1!==a){var l=n[a],c=_parseInt$1(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),u=_parseInt$1(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var d=Math.min(t.age-t.partTarget,t.targetduration);u>=0&&d>t.partTarget&&(u+=1)}var f=r&&getSkipValue(r);return new HlsUrlParameters(c,u>=0?u:void 0,f)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(e))}return e}},{key:"playlistLoaded",value:function(e,t,r){var n=t.details,a=t.stats,i=self.performance.now(),s=a.loading.first?Math.max(0,i-a.loading.first):0;n.advancedDateTime=_Date$now()-s;var o=this.hls.config.timelineOffset;if(o!==n.appliedTimelineOffset){var l,c=Math.max(o||0,0);n.appliedTimelineOffset=c,_forEachInstanceProperty(l=n.fragments).call(l,(function(e){e.start=e.playlistOffset+c}))}if(n.live||null!=r&&r.live){var u,d="levelInfo"in t?t.levelInfo:t.track;n.reloaded(r),r&&n.fragments.length>0&&mergeDetails(r,n),-1===n.requestScheduled&&(n.requestScheduled=a.loading.start);var f,h=this.hls.mainForwardBufferInfo,p=h?h.end-h.len:0,y=computeReloadInterval(n,1e3*(n.edge-p));if(n.requestScheduled+y<i?n.requestScheduled=i:n.requestScheduled+=y,this.log(_concatInstanceProperty(u="live playlist ".concat(e," ")).call(u,n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),!this.canLoad||!n.live)return;var g=void 0,v=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var m=this.hls.config.lowLatencyMode,E=n.lastPartSn,$=n.endSN,S=n.lastPartIndex,T=E===$;-1!==S?T?(g=$+1,v=m?0:S):(g=E,v=m?S+1:n.maxPartIndex):g=$+1;var I=n.age,_=I+n.ageHeader,P=Math.min(_-n.partTarget,1.5*n.targetduration);if(P>0){if(_>3*n.targetduration)this.log("Playlist last advanced ".concat(I.toFixed(2),"s ago. Omitting segment and part directives.")),g=void 0,v=void 0;else if(null!=r&&r.tuneInGoal&&_-n.partTarget>r.tuneInGoal){var b,A;this.warn(_concatInstanceProperty(b=_concatInstanceProperty(A="CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ")).call(A,P," with playlist age: ")).call(b,n.age)),P=0}else{var R,k,C,O,L=Math.floor(P/n.targetduration);if(g+=L,void 0!==v)v+=Math.round(P%n.targetduration/n.partTarget);this.log(_concatInstanceProperty(R=_concatInstanceProperty(k=_concatInstanceProperty(C=_concatInstanceProperty(O="CDN Tune-in age: ".concat(n.ageHeader,"s last advanced ")).call(O,I.toFixed(2),"s goal: ")).call(C,P," skip sn ")).call(k,L," to part ")).call(R,v))}n.tuneInGoal=P}if(f=this.getDeliveryDirectives(n,t.deliveryDirectives,g,v),m||!T)return n.requestScheduled=i,void this.loadingPlaylist(d,f)}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,t.deliveryDirectives,g,v));f&&void 0!==g&&n.canBlockReload&&(n.requestScheduled=a.loading.first+Math.max(y-2*s,y/2)),this.scheduleLoading(d,f,n)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,r){var n,a=this,i=r||e.details;if(i){var s=self.performance.now(),o=i.requestScheduled;if(s>=o)this.loadingPlaylist(e,t);else{var l=o-s;this.log(_concatInstanceProperty(n="reload live playlist ".concat(e.name||e.bitrate+"bps"," in ")).call(n,Math.round(l)," ms")),this.clearTimer(),this.timer=_setTimeout((function(){return a.loadingPlaylist(e,t)}),l)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,n){var a=getSkipValue(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,n=t.part,a=HlsSkip.No),new HlsUrlParameters(r,n,a)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,n=isTimeoutError(e),a=e.errorAction,i=a||{},s=i.action,o=i.retryCount,l=void 0===o?0:o,c=i.retryConfig,u=!!a&&!!c&&(s===NetworkErrorAction.RetryRequest||!a.resolved&&s===NetworkErrorAction.SendAlternateToPenaltyBox);if(u){var d;if(l>=c.maxNumRetry)return!1;if(n&&null!=(d=e.context)&&d.deliveryDirectives){var f,h;this.warn(_concatInstanceProperty(f=_concatInstanceProperty(h="Retrying playlist loading ".concat(l+1,"/")).call(h,c.maxNumRetry,' after "')).call(f,r,'" without delivery-directives')),this.loadPlaylist()}else{var p,y,g,v=getRetryDelay(c,l);this.clearTimer(),this.timer=_setTimeout((function(){return t.loadPlaylist()}),v),this.warn(_concatInstanceProperty(p=_concatInstanceProperty(y=_concatInstanceProperty(g="Retrying playlist loading ".concat(l+1,"/")).call(g,c.maxNumRetry,' after "')).call(y,r,'" in ')).call(p,v,"ms"))}e.levelRetry=!0,a.resolved=!0}return u}}]),r}(),AudioTrackController=function(e){_inherits(r,BasePlaylistController);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e,"audio-track-controller")).tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.registerListeners(),n}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Events.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,_get(_getPrototypeOf(r.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var r,n,a,i,s,o=t.id,l=t.groupId,c=t.details,u=this.tracksInGroup[o];if(u&&u.groupId===l){var d=u.details;u.details=t.details,this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Audio track ".concat(o,' "')).call(s,u.name,'" lang:')).call(i,u.lang," group:")).call(a,l," loaded [")).call(n,c.startSN,"-")).call(r,c.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,d)}else{var f,h;this.warn(_concatInstanceProperty(f=_concatInstanceProperty(h="Audio track with id:".concat(o," and group:")).call(h,l," not found in active group ")).call(f,null==u?void 0:u.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.audioGroups||null,n=this.groupIds,a=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&_someInstanceProperty(r).call(r,(function(e){return-1===(null==n?void 0:_indexOfInstanceProperty(n).call(n,e))}))){var i,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=_filterInstanceProperty(i=this.tracks).call(i,(function(e){return!r||-1!==_indexOfInstanceProperty(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!_someInstanceProperty(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),_forEachInstanceProperty(o).call(o,(function(e,t){e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.audioPreference;if(!a&&l){var c=findMatchingOption(l,o,audioMatchPredicate);if(c>-1)a=o[c];else{var u=findMatchingOption(l,this.tracks);a=this.tracks[u]}}var d=this.findTrackId(a);-1===d&&a&&(d=this.findTrackId(null));var f={audioTracks:o};this.log(_concatInstanceProperty(s="Updating audio tracks, ".concat(o.length," track(s) found in group(s): ")).call(s,null==r?void 0:r.join(","))),this.hls.trigger(Events.AUDIO_TRACKS_UPDATED,f);var h=this.trackId;if(-1!==d&&-1===h)this.setAudioTrack(d);else if(o.length&&-1===h){var p,y,g=new Error(_concatInstanceProperty(p="No audio track selected for current audio group-ID(s): ".concat(null==(y=this.groupIds)?void 0:y.join(",")," track count: ")).call(p,o.length));this.warn(g.message),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==PlaylistContextType.AUDIO_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===_indexOfInstanceProperty(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){var n=this.currentTrack;if(n&&matchesOption(e,n,audioMatchPredicate))return n;var a=findMatchingOption(e,this.tracksInGroup,audioMatchPredicate);if(a>-1){var i=this.tracksInGroup[a];return this.setAudioTrack(a),i}if(n){var s=t.loadLevel;-1===s&&(s=t.firstAutoLevel);var o=findClosestLevelWithAudioGroup(e,t.levels,r,s,audioMatchPredicate);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=findMatchingOption(e,r);if(l>-1)return r[l]}}}return null}},{key:"setAudioTrack",value:function(e){var t,r,n,a,i=this.tracksInGroup;if(e<0||e>=i.length)this.warn("Invalid audio track id: ".concat(e));else{this.selectDefaultTrack=!1;var s=this.currentTrack,o=i[e],l=o.details&&!o.details.live;if(!(e===this.trackId&&o===s&&l||(this.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="Switching to audio-track ".concat(e,' "')).call(a,o.name,'" lang:')).call(n,o.lang," group:")).call(r,o.groupId," channels:")).call(t,o.channels)),this.trackId=e,this.currentTrack=o,this.hls.trigger(Events.AUDIO_TRACK_SWITCHING,_objectSpread2({},o)),l))){var c=this.switchParams(o.url,null==s?void 0:s.details,o.details);this.loadPlaylist(c)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var n=t[r];if((!this.selectDefaultTrack||n.default)&&(!e||matchesOption(e,n,audioMatchPredicate)))return r}if(e){for(var a=e.name,i=e.lang,s=e.assocLang,o=e.characteristics,l=e.audioCodec,c=e.channels,u=0;u<t.length;u++){if(matchesOption({name:a,lang:i,assocLang:s,characteristics:o,audioCodec:l,channels:c},t[u],audioMatchPredicate))return u}for(var d=0;d<t.length;d++){var f=t[d];if(mediaAttributesIdentical(e.attrs,f.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(var h=0;h<t.length;h++){var p=t[h];if(mediaAttributesIdentical(e.attrs,p.attrs,["LANGUAGE"]))return h}}return-1}},{key:"loadPlaylist",value:function(e){_get(_getPrototypeOf(r.prototype),"loadPlaylist",this).call(this);var t=this.currentTrack;this.shouldLoadPlaylist(t)&&useAlternateAudio(t.url,this.hls)&&this.scheduleLoading(t,e)}},{key:"loadingPlaylist",value:function(e,t){var n,a,i,s,o,l;_get(_getPrototypeOf(r.prototype),"loadingPlaylist",this).call(this,e,t);var c=e.id,u=e.groupId,d=this.getUrlWithDirectives(e.url,t),f=e.details,h=null==f?void 0:f.age;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="Loading audio-track ".concat(c,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,u)).call(i,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,h&&f.live?" age "+h.toFixed(1)+(f.type&&" "+f.type||""):""," ")).call(n,d)),this.hls.trigger(Events.AUDIO_TRACK_LOADING,{url:d,id:c,groupId:u,deliveryDirectives:t||null,track:e})}}]),r}(),BufferOperationQueue=function(){function e(t){_classCallCheck$1(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t}return _createClass$1(e,[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,r){if(null!==this.queues&&null!==this.tracks){var n=this.queues[t];n.push(e),1!==n.length||r||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){var t=this;return new _Promise((function(r){var n={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(n,e)}))}},{key:"prependBlocker",value:function(e){var t=this;return new _Promise((function(r){if(t.queues){var n={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(n)}}))}},{key:"removeBlockers",value:function(){var e;null!==this.queues&&_forEachInstanceProperty(e=[this.queues.video,this.queues.audio,this.queues.audiovideo]).call(e,(function(e){var t,r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),_spliceInstanceProperty(e).call(e,0,1))}))}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){var n;if(r.onError(t),null===this.queues||null===this.tracks)return;var a=null==(n=this.tracks[e])?void 0:n.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e,t,r=this.queues,n=this.tracks;return null===r||null===n?"<destroyed>":_concatInstanceProperty(e=_concatInstanceProperty(t="\n".concat(this.list("video"),"\n")).call(t,this.list("audio"),"\n")).call(e,this.list("audiovideo"),"}")}},{key:"list",value:function(e){var t,r,n,a;return null!=(n=this.queues)&&n[e]||null!=(a=this.tracks)&&a[e]?_concatInstanceProperty(t=_concatInstanceProperty(r="".concat(e,": (")).call(r,this.listSbInfo(e),") ")).call(t,this.listOps(e)):""}},{key:"listSbInfo",value:function(e){var t,r,n,a=null==(n=this.tracks)?void 0:n[e],i=null==a?void 0:a.buffer;return i?_concatInstanceProperty(t=_concatInstanceProperty(r="SourceBuffer".concat(i.updating?" updating":"")).call(r,a.ended?" ended":"")).call(t,a.ending?" ending":""):"none"}},{key:"listOps",value:function(e){var t,r;return(null==(r=this.queues)?void 0:_mapInstanceProperty(t=r[e]).call(t,(function(e){return e.label})).join(", "))||""}}]),e}(),VIDEO_CODEC_PROFILE_REPLACE=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,TRACK_REMOVED_ERROR_NAME="HlsJsTrackRemovedError",HlsJsTrackRemovedError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e)).name=TRACK_REMOVED_ERROR_NAME,n}return _createClass$1(r)}(),BufferController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,"buffer-controller",e.logger)).hls=void 0,a.fragmentTracker=void 0,a.details=null,a._objectUrl=null,a.operationQueue=null,a.bufferCodecEventsTotal=0,a.media=null,a.mediaSource=null,a.lastMpegAudioChunk=null,a.blockedAudioAppend=null,a.lastVideoAppendEnd=0,a.appendSource=void 0,a.transferData=void 0,a.overrides=void 0,a.appendErrors={audio:0,video:0,audiovideo:0},a.tracks={},a.sourceBuffers=[[null,null],[null,null]],a._onEndStreaming=function(e){var t;a.hls&&"open"===(null==(t=a.mediaSource)?void 0:t.readyState)&&a.hls.pauseBuffering()},a._onStartStreaming=function(e){a.hls&&a.hls.resumeBuffering()},a._onMediaSourceOpen=function(e){var t=_assertThisInitialized(a),r=t.media,n=t.mediaSource;e&&a.log("Media source opened"),r&&n&&(r.removeEventListener("emptied",a._onMediaEmptied),a.updateDuration(),a.hls.trigger(Events.MEDIA_ATTACHED,{media:r,mediaSource:n}),n.removeEventListener("sourceopen",a._onMediaSourceOpen),null!==a.mediaSource&&a.checkPendingTracks())},a._onMediaSourceClose=function(){a.log("Media source closed")},a._onMediaSourceEnded=function(){a.log("Media source ended")},a._onMediaEmptied=function(){var e,t=_assertThisInitialized(a),r=t.mediaSrc,n=t._objectUrl;r!==n&&a.error(_concatInstanceProperty(e="Media element src was set while attaching MediaSource (".concat(n," > ")).call(e,r,")"))},a.hls=e,a.fragmentTracker=n,a.appendSource=isManagedMediaSource(_getMediaSource2(e.config.preferManagedMediaSource)),a.initTracks(),a.registerListeners(),a}return _createClass$1(r,[{key:"hasSourceTypes",value:function(){return _Object$keys(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.BUFFER_RESET,this.onBufferReset,this),e.on(Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Events.BUFFER_EOS,this.onBufferEos,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Events.FRAG_PARSED,this.onFragParsed,this),e.on(Events.FRAG_CHANGED,this.onFragChanged,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.BUFFER_RESET,this.onBufferReset,this),e.off(Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Events.BUFFER_EOS,this.onBufferEos,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Events.FRAG_PARSED,this.onFragParsed,this),e.off(Events.FRAG_CHANGED,this.onFragChanged,this),e.off(Events.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var n={};if(this.operationQueue){var a=this.isUpdating();a||this.operationQueue.removeBlockers();var i,s,o=this.isQueued();if(a||o)this.warn(_concatInstanceProperty(i=_concatInstanceProperty(s="Transfering MediaSource with".concat(o?" operations in queue":"")).call(s,a?" updating SourceBuffer(s)":""," ")).call(i,this.operationQueue));this.operationQueue.destroy()}var l,c=this.transferData;!this.sourceBufferCount&&c&&c.mediaSource===r?_extends(n,c.tracks):_forEachInstanceProperty(l=this.sourceBuffers).call(l,(function(t){var r=_slicedToArray(t,1)[0];r&&(n[r]=_extends({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null}));return{media:t,mediaSource:r,tracks:n}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var r,n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log("".concat(n," bufferCodec event(s) expected.")),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media,n=_getMediaSource2(this.appendSource);if(this.transferData=this.overrides=void 0,r&&n){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var i=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(i),a)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=_URL.createObjectURL(i);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&i instanceof o,removeSourceChildren(r),addSource(r,s),r.load()}catch(e){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r,n;this.log(_concatInstanceProperty(t="".concat((null==(r=this.transferData)?void 0:r.mediaSource)===e?"transferred":"created"," media source: ")).call(t,null==(n=e.constructor)?void 0:n.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this,t=this.media,r=this.transferData;if(r&&t){var n=this.tracks,a=r.tracks,i=a?_Object$keys(a):null,s=i?i.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(a&&i&&s){var l,c;if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(_concatInstanceProperty(l=_concatInstanceProperty(c="attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ")).call(c,_JSON$stringify(n,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ")).call(l,_JSON$stringify(a,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!isCompatibleTrackChange(a,n)){var u,d,f;r.mediaSource=null,r.tracks=void 0;var h,p=t.currentTime,y=this.details,g=Math.max(p,(null==y?void 0:y.fragments[0].start)||0);return g-p>1?void this.log(_concatInstanceProperty(h="attachTransferred: waiting for playback to reach new tracks start time ".concat(p," -> ")).call(h,g)):(this.warn(_concatInstanceProperty(u=_concatInstanceProperty(d=_concatInstanceProperty(f='attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(_Object$keys(a),'"->"')).call(f,_Object$keys(n),'") start time: ')).call(d,g," currentTime: ")).call(u,p)),this.onMediaDetaching(Events.MEDIA_DETACHING,{}),this.onMediaAttaching(Events.MEDIA_ATTACHING,r),void(t.currentTime=g))}this.transferData=void 0,_forEachInstanceProperty(i).call(i,(function(t){var r=t,n=a[r];if(n){var i=n.buffer;if(i){var s=e.fragmentTracker,o=n.id;if(s.hasFragments(o)||s.hasParts(o)){var l=BufferHelper.getBuffered(i);s.detectEvictedFragments(r,l,o,null,!0)}var c=sourceBufferNameToIndex(r),u=[r,i];e.sourceBuffers[c]=u,i.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,n)}}})),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var r=this,n=!!t.transferMedia;this.transferData=this.overrides=void 0;var a=this.media,i=this.mediaSource,s=this._objectUrl;if(i){if(this.log("media source ".concat(n?"transferring":"detaching")),n){var o;_forEachInstanceProperty(o=this.sourceBuffers).call(o,(function(e){var t=_slicedToArray(e,1)[0];t&&r.removeBuffer(t)})),this.resetQueue()}else{if(this.mediaSourceOpenOrEnded){var l="open"===i.readyState;try{for(var c=i.sourceBuffers,u=c.length;u--;)l&&c[u].abort(),i.removeSourceBuffer(c[u]);l&&i.endOfStream()}catch(e){this.warn("onMediaDetaching: ".concat(e.message," while calling endOfStream"))}}this.sourceBufferCount&&this.onBufferReset()}i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(i.removeEventListener("startstreaming",this._onStartStreaming),i.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}a&&(a.removeEventListener("emptied",this._onMediaEmptied),n||(s&&_URL.revokeObjectURL(s),this.mediaSrc===s?(a.removeAttribute("src"),this.appendSource&&removeSourceChildren(a),a.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(Events.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){var e,t=this;_forEachInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var r=_slicedToArray(e,1)[0];r&&t.resetBuffer(r)})),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var n;null!=(n=this.mediaSource)&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn("onBufferReset ".concat(e),t)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[sourceBufferNameToIndex(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new BufferOperationQueue(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r,n=this,a=this.tracks,i=_Object$keys(t);this.log(_concatInstanceProperty(r='BUFFER_CODECS: "'.concat(i,'" (current SB count ')).call(r,this.sourceBufferCount,")"));var s,o="audiovideo"in t&&(a.audio||a.video)||a.audiovideo&&("audio"in t||"video"in t),l=!o&&this.sourceBufferCount&&this.media&&_someInstanceProperty(i).call(i,(function(e){return!a[e]}));o||l?this.warn(_concatInstanceProperty(s='Unsupported transition between "'.concat(_Object$keys(a),'" and "')).call(s,i,'" SourceBuffers')):(_forEachInstanceProperty(i).call(i,(function(e){var r,i,s,o=t[e],l=o.id,c=o.codec,u=o.levelCodec,d=o.container,f=o.metadata,h=a[e],p=null==(r=n.transferData)||null==(i=r.tracks)?void 0:i[e],y=null!=p&&p.buffer?p:h,g=(null==y?void 0:y.pendingCodec)||(null==y?void 0:y.codec),v=null==y?void 0:y.levelCodec,m=!y||!!n.hls.config.assetPlayerId;h||(h=a[e]={buffer:void 0,listeners:[],codec:c,container:d,levelCodec:u,metadata:f,id:l});var E,$=pickMostCompleteCodecName(g,v),S=null==$?void 0:$.replace(VIDEO_CODEC_PROFILE_REPLACE,"$1"),T=pickMostCompleteCodecName(c,u),I=null==(s=T)?void 0:s.replace(VIDEO_CODEC_PROFILE_REPLACE,"$1");T&&(S!==I||m)&&("audio"===_sliceInstanceProperty(e).call(e,0,5)&&(T=getCodecCompatibleName(T,n.appendSource)),n.log(_concatInstanceProperty(E="switching codec ".concat(g," to ")).call(E,T)),T!==(h.pendingCodec||h.codec)&&(h.pendingCodec=T),h.container=d,n.appendChangeType(e,d,T))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e,t=this;return _reduceInstanceProperty(e=_Object$keys(this.tracks)).call(e,(function(e,r){var n=t.tracks[r];return e[r]={id:n.id,container:n.container,codec:n.codec,levelCodec:n.levelCodec},e}),{})}},{key:"appendChangeType",value:function(e,t,r){var n,a=this,i=_concatInstanceProperty(n="".concat(t,";codecs=")).call(n,r),s={label:"change-type=".concat(i),execute:function(){var n=a.tracks[e];if(n){var s,o=n.buffer;if(null!=o&&o.changeType)a.log(_concatInstanceProperty(s="changing ".concat(e," sourceBuffer type to ")).call(s,i)),o.changeType(i),n.codec=r,n.container=t}a.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.warn("Failed to change ".concat(e," SourceBuffer type"),t)}};this.append(s,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,r=this,n=e.start,a=n+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(n,PlaylistLevelType.MAIN))?void 0:t.gap))){var i={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>a||null!=t&&t.buffer&&BufferHelper.isBuffered(t.buffer,a)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(a,PlaylistLevelType.MAIN))?void 0:e.gap))&&(r.blockedAudioAppend=null,r.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(e){r.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:i,frag:e},this.append(i,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(e,t){var r=this,n=this.tracks,a=t.data,i=t.type,s=t.parent,o=t.frag,l=t.part,c=t.chunkMeta,u=c.buffering[i],d=o.sn,f=self.performance.now();u.start=f;var h=o.stats.buffering,p=l?l.stats.buffering:null;0===h.start&&(h.start=f),p&&0===p.start&&(p.start=f);var y=n.audio,g=!1;"audio"===i&&"audio/mpeg"===(null==y?void 0:y.container)&&(g=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var v=this.tracks.video,m=null==v?void 0:v.buffer;if(m&&"initSegment"!==d){var E=l||o,$=this.blockedAudioAppend;if("audio"!==i||"main"===s||this.blockedAudioAppend){if("video"===i){var S=E.end;if($){var T=$.frag.start;(S>T||S<this.lastVideoAppendEnd||BufferHelper.isBuffered(m,T))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var I=E.start+.05*E.duration,_=m.buffered,P=this.currentOp("video");_.length||P?!P&&!BufferHelper.isBuffered(m,I)&&this.lastVideoAppendEnd<I&&this.blockAudio(E):this.blockAudio(E)}}var b=(l||o).start,A={label:"append-".concat(i),execute:function(){if(u.executeStart=self.performance.now(),g){var e=r.tracks[i];if(e){var t=e.buffer;if(t){var n,s,o=b-t.timestampOffset;if(Math.abs(o)>=.1)r.log(_concatInstanceProperty(n=_concatInstanceProperty(s="Updating audio SourceBuffer timestampOffset to ".concat(b," (delta: ")).call(s,o,") sn: ")).call(n,d,")")),t.timestampOffset=b}}}r.appendExecutor(a,i)},onStart:function(){},onComplete:function(){var e,t=self.performance.now();u.executeEnd=u.end=t,0===h.first&&(h.first=t),p&&0===p.first&&(p.first=t);var n={};_forEachInstanceProperty(e=r.sourceBuffers).call(e,(function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1];r&&(n[r]=BufferHelper.getBuffered(a))})),r.appendErrors[i]=0,"audio"===i||"video"===i?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(Events.BUFFER_APPENDED,{type:i,frag:o,part:l,chunkMeta:c,parent:o.type,timeRanges:n})},onError:function(e){var t,n={type:ErrorTypes.MEDIA_ERROR,parent:o.type,details:ErrorDetails.BUFFER_APPEND_ERROR,sourceBufferName:i,frag:o,part:l,chunkMeta:c,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)n.details=ErrorDetails.BUFFER_FULL_ERROR;else if(e.code!==DOMException.INVALID_STATE_ERR||!r.mediaSourceOpenOrEnded||null!=(t=r.media)&&t.error)if(e.name===TRACK_REMOVED_ERROR_NAME)0===r.sourceBufferCount?n.errorAction=createDoNothingErrorAction(!0):++r.appendErrors[i];else{var a,s,u=++r.appendErrors[i];r.warn(_concatInstanceProperty(a=_concatInstanceProperty(s="Failed ".concat(u,"/")).call(s,r.hls.config.appendErrorMaxRetry,' times to append segment in "')).call(a,i,'" sourceBuffer')),u>=r.hls.config.appendErrorMaxRetry&&(n.fatal=!0)}else n.errorAction=createDoNothingErrorAction(!0);r.hls.trigger(Events.ERROR,n)}};this.append(A,i,this.isPending(this.tracks[i]))}},{key:"getFlushOp",value:function(e,t,r){var n,a,i=this;return this.log(_concatInstanceProperty(n=_concatInstanceProperty(a='queuing "'.concat(e,'" remove ')).call(a,t,"-")).call(n,r)),{label:"remove",execute:function(){i.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){i.hls.trigger(Events.BUFFER_FLUSHED,{type:e})},onError:function(n){var a,s;i.warn(_concatInstanceProperty(a=_concatInstanceProperty(s="Failed to remove ".concat(t,"-")).call(s,r,' from "')).call(a,e,'" SourceBuffer'),n)}}}},{key:"onBufferFlushing",value:function(e,t){var r,n=this,a=t.type,i=t.startOffset,s=t.endOffset;a?this.append(this.getFlushOp(a,i,s),a):_forEachInstanceProperty(r=this.sourceBuffers).call(r,(function(e){var t=_slicedToArray(e,1)[0];t&&n.append(n.getFlushOp(t,i,s),t)}))}},{key:"onFragParsed",value:function(e,t){var r=this,n=t.frag,a=t.part,i=[],s=a?a.elementaryStreams:n.elementaryStreams;s[ElementaryStreamTypes.AUDIOVIDEO]?i.push("audiovideo"):(s[ElementaryStreamTypes.AUDIO]&&i.push("audio"),s[ElementaryStreamTypes.VIDEO]&&i.push("video"));var o,l;0===i.length&&this.warn(_concatInstanceProperty(o=_concatInstanceProperty(l="Fragments must have at least one ElementaryStreamType set. type: ".concat(n.type," level: ")).call(l,n.level," sn: ")).call(o,n.sn));this.blockBuffers((function(){var e=self.performance.now();n.stats.buffering.end=e,a&&(a.stats.buffering.end=e);var t=a?a.stats:n.stats;r.hls.trigger(Events.FRAG_BUFFERED,{frag:n,part:a,stats:t,id:n.type})}),i)}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var e,t=this;return this.sourceBufferCount>0&&!_someInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var r,n,a=_slicedToArray(e,1)[0];return a&&(!(null!=(r=t.tracks[a])&&r.ended)||(null==(n=t.tracks[a])?void 0:n.ending))}))}},{key:"onBufferEos",value:function(e,t){var r,n,a,i=this;_forEachInstanceProperty(r=this.sourceBuffers).call(r,(function(e){var r=_slicedToArray(e,1)[0];if(r){var n=i.tracks[r];t.type&&t.type!==r||(n.ending=!0,n.ended||(n.ended=!0,i.log("".concat(r," buffer reached EOS"))))}}));var s=!1!==(null==(a=this.overrides)?void 0:a.endOfStream);this.sourceBufferCount>0&&!_someInstanceProperty(n=this.sourceBuffers).call(n,(function(e){var t,r=_slicedToArray(e,1)[0];return r&&!(null!=(t=i.tracks[r])&&t.ended)}))&&(this.log("Queueing EOS"),this.blockUntilOpen((function(){var e;if(_forEachInstanceProperty(e=i.sourceBuffers).call(e,(function(e){var t=_slicedToArray(e,1)[0];if(null!==t){var r=i.tracks[t];r&&(r.ending=!1)}})),s){var t=i.mediaSource;if(!t||"open"!==t.readyState)return void(t&&i.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(t.readyState)));i.log("Calling mediaSource.endOfStream()"),t.endOfStream()}i.hls.trigger(Events.BUFFERED_TO_END,void 0)})))}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.updateDuration())}},{key:"updateDuration",value:function(){var e=this,t=this.getDurationAndRange();t&&this.blockUntilOpen((function(){return e.updateMediaSource(t)}))}},{key:"onError",value:function(e,t){if(t.details===ErrorDetails.BUFFER_APPEND_ERROR&&t.frag){var r,n=null==(r=t.errorAction)?void 0:r.nextAutoLevel;isFiniteNumber(n)&&n!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.sourceBufferCount){var n=e.config,a=r.currentTime,i=t.levelTargetDuration,s=t.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(isFiniteNumber(s)&&s>=0){var o=Math.max(s,i),l=Math.floor(a/i)*i-o;this.flushBackBuffer(a,i,l)}if(isFiniteNumber(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){var c=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(c,i),d=Math.floor(a/i)*i+u;this.flushFrontBuffer(a,i,d)}}}},{key:"flushBackBuffer",value:function(e,t,r){var n,a=this;_forEachInstanceProperty(n=this.sourceBuffers).call(n,(function(n){var i=_slicedToArray(n,2),s=i[0],o=i[1];if(o){var l=BufferHelper.getBuffered(o);if(l.length>0&&r>l.start(0)){var c;a.hls.trigger(Events.BACK_BUFFER_REACHED,{bufferEnd:r});var u=a.tracks[s];if(null!=(c=a.details)&&c.live)a.hls.trigger(Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=u&&u.ended&&l.end(l.length-1)-e<2*t)return void a.log("Cannot flush ".concat(s," back buffer while SourceBuffer is in ended state"));a.hls.trigger(Events.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}},{key:"flushFrontBuffer",value:function(e,t,r){var n,a=this;_forEachInstanceProperty(n=this.sourceBuffers).call(n,(function(n){var i=_slicedToArray(n,2),s=i[0],o=i[1];if(o){var l=BufferHelper.getBuffered(o),c=l.length;if(c<2)return;var u=l.start(c-1),d=l.end(c-1),f=a.tracks[s];if(r>u||e>=u&&e<=d)return;if(null!=f&&f.ended&&e-d<2*t)return void a.log("Cannot flush ".concat(s," front buffer while SourceBuffer is in ended state"));a.hls.trigger(Events.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:s})}}))}},{key:"getDurationAndRange",value:function(){var e,t=this.details,r=this.mediaSource;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;var n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(r.duration=1/0,t.fragments.length&&t.live&&r.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,n)}}return{duration:1/0}}var i=null==(e=this.overrides)?void 0:e.duration;if(i)return{duration:i};var s=this.media.duration;return n>(isFiniteNumber(r.duration)?r.duration:0)&&n>s||!isFiniteNumber(s)?{duration:n}:null}},{key:"updateMediaSource",value:function(e){var t,r,n=e.duration,a=e.start,i=e.end,s=this.mediaSource;this.media&&s&&"open"===s.readyState&&(s.duration!==n&&(isFiniteNumber(n)&&this.log("Updating MediaSource duration to ".concat(n.toFixed(3))),s.duration=n),void 0!==a&&void 0!==i&&(this.log(_concatInstanceProperty(t=_concatInstanceProperty(r="MediaSource duration is set to ".concat(s.duration,". Setting seekable range to ")).call(r,a,"-")).call(t,i,".")),s.setLiveSeekableRange(a,i)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e,t,r=this.bufferCodecEventsTotal,n=this.pendingTrackCount,a=this.tracks;if(this.log(_concatInstanceProperty(e=_concatInstanceProperty(t="checkPendingTracks (pending: ".concat(n," codec events expected: ")).call(t,r,") ")).call(e,_JSON$stringify(a))),this.tracksReady){var i,s=null==(i=this.transferData)?void 0:i.tracks;s&&_Object$keys(s).length?this.attachTransferred():(this.createSourceBuffers(),this.bufferCreated())}}},{key:"bufferCreated",value:function(){var e=this;if(this.sourceBufferCount){var t,r,n={};_forEachInstanceProperty(t=this.sourceBuffers).call(t,(function(t){var r=_slicedToArray(t,2),a=r[0],i=r[1];if(a){var s=e.tracks[a];n[a]={buffer:i,container:s.container,codec:s.codec,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}})),this.hls.trigger(Events.BUFFER_CREATED,{tracks:n}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),_forEachInstanceProperty(r=this.sourceBuffers).call(r,(function(t){var r=_slicedToArray(t,1)[0];e.executeNext(r)}))}else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,r=this.mediaSource;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(var n in e){var a=n,i=e[a];if(this.isPending(i)){var s,o,l,c=this.getTrackCodec(i,a),u=_concatInstanceProperty(s="".concat(i.container,";codecs=")).call(s,c);i.codec=c,this.log(_concatInstanceProperty(o=_concatInstanceProperty(l="creating sourceBuffer(".concat(u,")")).call(l,this.currentOp(a)?" Queued":""," ")).call(o,_JSON$stringify(i)));try{var d=r.addSourceBuffer(u),f=sourceBufferNameToIndex(a),h=[a,d];t[f]=h,i.buffer=d}catch(e){this.error("error while trying to add sourceBuffer: ".concat(e.message)),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:u});break}this.trackSourceBuffer(a,i)}}}},{key:"getTrackCodec",value:function(e,t){var r=pickMostCompleteCodecName(e.codec,e.levelCodec);return r?"audio"===_sliceInstanceProperty(t).call(t,0,5)?getCodecCompatibleName(r,this.appendSource):r:""}},{key:"trackSourceBuffer",value:function(e,t){var r=this,n=t.buffer;if(n){var a=this.getTrackCodec(t,e);this.tracks[e]={buffer:n,codec:a,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id,listeners:[]},this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(function(e,t){var n=t.removedRanges;null!=n&&n.length&&r.hls.trigger(Events.BUFFER_FLUSHED,{type:e})}))}}},{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var r,n,a=new Error(_concatInstanceProperty(r="".concat(e," SourceBuffer error. MediaSource readyState: ")).call(r,null==(n=this.mediaSource)?void 0:n.readyState));this.error("".concat(a),t),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:a,fatal:!1});var i=this.currentOp(e);i&&i.onError(a)}},{key:"removeExecutor",value:function(e,t,r){var n=this.media,a=this.mediaSource,i=this.tracks[e],s=null==i?void 0:i.buffer;if(!n||!a||!s)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var o,l,c=isFiniteNumber(n.duration)?n.duration:1/0,u=isFiniteNumber(a.duration)?a.duration:1/0,d=Math.max(0,t),f=Math.min(r,c,u);f>d&&(!i.ending||i.ended)?(i.ended=!1,this.log(_concatInstanceProperty(o=_concatInstanceProperty(l="Removing [".concat(d,",")).call(l,f,"] from the ")).call(o,e," SourceBuffer")),s.remove(d,f)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var r=this.tracks[t],n=null==r?void 0:r.buffer;if(!n)throw new HlsJsTrackRemovedError("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));r.ending=!1,r.ended=!1,n.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()}},{key:"isUpdating",value:function(){var e;return _someInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return r&&n.updating}))}},{key:"isQueued",value:function(){var e,t=this;return _someInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var r=_slicedToArray(e,1)[0];return r&&!!t.currentOp(r)}))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.sourceBufferTypes;if(!r.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void _Promise.resolve().then(e);var n=this.operationQueue,a=_mapInstanceProperty(r).call(r,(function(e){return t.appendBlocker(e)}));r.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),_Promise.all(a).then((function(a){n===t.operationQueue&&(e(),t.stepOperationQueue(r))}))}},{key:"stepOperationQueue",value:function(e){var t=this;_forEachInstanceProperty(e).call(e,(function(e){var r,n=null==(r=t.tracks[e])?void 0:r.buffer;n&&!n.updating&&t.shiftAndExecuteNext(e)}))}},{key:"append",value:function(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){var e,t=this;return _reduceInstanceProperty(e=_Object$keys(this.tracks)).call(e,(function(e,r){return e+(t.isPending(t.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){var e;return _reduceInstanceProperty(e=this.sourceBuffers).call(e,(function(e,t){return e+(_slicedToArray(t,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){var e,t;return _filterInstanceProperty(e=_mapInstanceProperty(t=this.sourceBuffers).call(t,(function(e){return _slicedToArray(e,1)[0]}))).call(e,(function(e){return!!e}))}},{key:"addBufferListener",value:function(e,t,r){var n=this.tracks[e];if(n){var a=n.buffer;if(a){var i=_bindInstanceProperty(r).call(r,this,e);n.listeners.push({event:t,listener:i}),a.addEventListener(t,i)}}}},{key:"removeBufferListeners",value:function(e){var t,r=this.tracks[e];if(r){var n=r.buffer;n&&(_forEachInstanceProperty(t=r.listeners).call(t,(function(e){n.removeEventListener(e.event,e.listener)})),r.listeners.length=0)}}}]),r}();function removeSourceChildren(e){var t,r=e.querySelectorAll("source");_forEachInstanceProperty(t=_sliceInstanceProperty([]).call(r)).call(t,(function(t){e.removeChild(t)}))}function addSource(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}function sourceBufferNameToIndex(e){return"audio"===e?1:0}var CapLevelController=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return _createClass$1(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&isFiniteNumber(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t,r,n,a,i=this.hls,s=this.getMaxLevel(e.length-1);if(s!==this.autoLevelCapping)i.logger.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="Setting autoLevelCapping to ".concat(s,": ")).call(a,e[s].height,"p@")).call(n,e[s].bitrate," for media ")).call(r,this.mediaWidth,"x")).call(t,this.mediaHeight));i.autoLevelCapping=s,i.autoLevelEnabled&&i.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=i.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var r=this,n=this.hls.levels;if(!n.length)return-1;var a=_filterInstanceProperty(n).call(n,(function(e,n){return r.isLevelAllowed(e)&&n<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){var e;this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=_setInterval(_bindInstanceProperty(e=this.detectPlayerSize).call(e,this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){var t=this.restrictedLevels;return!_someInstanceProperty(t).call(t,(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(null==e||!e.length)return-1;for(var n,a,i=e.length-1,s=Math.max(t,r),o=0;o<e.length;o+=1){var l=e[o];if((l.width>=s||l.height>=s)&&(n=l,!(a=e[o+1])||n.width!==a.width||n.height!==a.height)){i=o;break}}return i}}]),e}(),CmObjectType={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},CmcdObjectType=CmObjectType,CmStreamingFormat={DASH:"d",HLS:"h",SMOOTH:"s",OTHER:"o"},CmcdStreamingFormat=CmStreamingFormat,CMCD_OBJECT="CMCD-Object",CMCD_REQUEST="CMCD-Request",CMCD_SESSION="CMCD-Session",CMCD_STATUS="CMCD-Status",CmcdHeaderField={OBJECT:CMCD_OBJECT,REQUEST:CMCD_REQUEST,SESSION:CMCD_SESSION,STATUS:CMCD_STATUS},CmcdHeaderMap=(_defineProperty$2(_CmcdHeaderMap={},CmcdHeaderField.OBJECT,["br","d","ot","tb"]),_defineProperty$2(_CmcdHeaderMap,CmcdHeaderField.REQUEST,["bl","dl","mtp","nor","nrr","su"]),_defineProperty$2(_CmcdHeaderMap,CmcdHeaderField.SESSION,["cid","pr","sf","sid","st","v"]),_defineProperty$2(_CmcdHeaderMap,CmcdHeaderField.STATUS,["bs","rtp"]),_CmcdHeaderMap),SfItem=_createClass$1((function e(t,r){_classCallCheck$1(this,e),_Array$isArray(t)&&(t=_mapInstanceProperty(t).call(t,(function(t){return t instanceof e?t:new e(t)}))),this.value=t,this.params=r})),DICT="Dict";function format(e){return _Array$isArray(e)?_JSON$stringify(e):e instanceof _Map?"Map{}":e instanceof _Set?"Set{}":"object"===_typeof$1(e)?_JSON$stringify(e):String(e)}function throwError(e,t,r,n){var a,i;return new Error(_concatInstanceProperty(a=_concatInstanceProperty(i="failed to ".concat(e,' "')).call(i,format(t),'" as ')).call(a,r),{cause:n})}function serializeError(e,t,r){return throwError("serialize",e,t,r)}var SfToken=_createClass$1((function e(t){_classCallCheck$1(this,e),this.description=t})),BARE_ITEM="Bare Item",BOOLEAN="Boolean";function serializeBoolean(e){if("boolean"!=typeof e)throw serializeError(e,BOOLEAN);return e?"?1":"?0"}var BYTES="Byte Sequence";function serializeByteSequence(e){if(!1===ArrayBuffer.isView(e))throw serializeError(e,BYTES);return":".concat(base64encode(e),":")}var INTEGER="Integer";function isInvalidInt(e){return e<-999999999999999||999999999999999<e}function serializeInteger(e){if(isInvalidInt(e))throw serializeError(e,INTEGER);return e.toString()}function serializeDate(e){return"@".concat(serializeInteger(e.getTime()/1e3))}var DECIMAL="Decimal";function serializeDecimal(e){var t=roundToEven(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw serializeError(e,DECIMAL);var r=t.toString();return _includesInstanceProperty(r).call(r,".")?r:"".concat(r,".0")}var STRING="String",STRING_REGEX=/[\x00-\x1f\x7f]+/;function serializeString(e){if(STRING_REGEX.test(e))throw serializeError(e,STRING);return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}function symbolToStr(e){var t;return e.description||_sliceInstanceProperty(t=e.toString()).call(t,7,-1)}var TOKEN="Token";function serializeToken(e){var t=symbolToStr(e);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw serializeError(t,TOKEN);return t}function serializeBareItem(e){switch(_typeof$1(e)){case"number":if(!isFiniteNumber(e))throw serializeError(e,BARE_ITEM);return _Number$isInteger(e)?serializeInteger(e):serializeDecimal(e);case"string":return serializeString(e);case"symbol":return serializeToken(e);case"boolean":return serializeBoolean(e);case"object":if(e instanceof Date)return serializeDate(e);if(e instanceof Uint8Array)return serializeByteSequence(e);if(e instanceof SfToken)return serializeToken(e);default:throw serializeError(e,BARE_ITEM)}}var KEY="Key";function serializeKey(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw serializeError(e,KEY);return e}function serializeParams(e){var t;return null==e?"":_mapInstanceProperty(t=_Object$entries(e)).call(t,(function(e){var t,r=_slicedToArray(e,2),n=r[0],a=r[1];return!0===a?";".concat(serializeKey(n)):_concatInstanceProperty(t=";".concat(serializeKey(n),"=")).call(t,serializeBareItem(a))})).join("")}function serializeItem(e){var t;return e instanceof SfItem?_concatInstanceProperty(t="".concat(serializeBareItem(e.value))).call(t,serializeParams(e.params)):serializeBareItem(e)}function serializeInnerList(e){var t,r;return _concatInstanceProperty(t="(".concat(_mapInstanceProperty(r=e.value).call(r,serializeItem).join(" "),")")).call(t,serializeParams(e.params))}function serializeDict(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!==_typeof$1(e))throw serializeError(e,DICT);var n=e instanceof _Map?_entriesInstanceProperty(e).call(e):_Object$entries(e),a=(null==r?void 0:r.whitespace)?" ":"";return _mapInstanceProperty(t=_Array$from(n)).call(t,(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];n instanceof SfItem==!1&&(n=new SfItem(n));var a=serializeKey(r);return!0===n.value?a+=serializeParams(n.params):(a+="=",_Array$isArray(n.value)?a+=serializeInnerList(n):a+=serializeItem(n)),a})).join(",".concat(a))}function encodeSfDict(e,t){return serializeDict(e,t)}function isTokenField(e){return"ot"===e||"sf"===e||"st"===e}function isValid(e){return"number"==typeof e?isFiniteNumber(e):null!=e&&""!==e&&!1!==e}var toRounded=function(e){return Math.round(e)},toUrlSafe=function(e,t){return(null==t?void 0:t.baseUrl)&&(e=urlToRelativePath(e,t.baseUrl)),encodeURIComponent(e)},toHundred=function(e){return 100*toRounded(e/100)},CmcdFormatters={br:toRounded,d:toRounded,bl:toHundred,dl:toHundred,mtp:toHundred,nor:toUrlSafe,rtp:toHundred,tb:toRounded};function processCmcd(e,t){var r,n={};if(null==e||"object"!==_typeof$1(e))return n;var a=_sortInstanceProperty(r=_Object$keys(e)).call(r),i=_extends({},CmcdFormatters,null==t?void 0:t.formatters),s=null==t?void 0:_filterInstanceProperty(t);return _forEachInstanceProperty(a).call(a,(function(r){if(!(null==s?void 0:s(r))){var a=e[r],o=i[r];o&&(a=o(a,t)),"v"===r&&1===a||"pr"==r&&1===a||isValid(a)&&(isTokenField(r)&&"string"==typeof a&&(a=new SfToken(a)),n[r]=a)}})),n}function encodeCmcd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?encodeSfDict(processCmcd(e,t),_extends({whitespace:!1},t)):""}function toCmcdHeaders(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a={};if(!e)return a;var i=_Object$entries(e),s=_concatInstanceProperty(t=_Object$entries(CmcdHeaderMap)).call(t,_Object$entries((null==n?void 0:n.customHeaderMap)||{})),o=_reduceInstanceProperty(i).call(i,(function(e,t){var r,n,a=_slicedToArray(t,2),i=a[0],o=a[1],l=(null===(r=_findInstanceProperty(s).call(s,(function(e){var t;return _includesInstanceProperty(t=e[1]).call(t,i)})))||void 0===r?void 0:r[0])||CmcdHeaderField.REQUEST;return null!==(n=e[l])&&void 0!==n||(e[l]={}),e[l][i]=o,e}),{});return _reduceInstanceProperty(r=_Object$entries(o)).call(r,(function(e,t){var r=_slicedToArray(t,2),a=r[0],i=r[1];return e[a]=encodeCmcd(i,n),e}),a)}function appendCmcdHeaders(e,t,r){return _extends(e,toCmcdHeaders(t,r))}var CMCD_PARAM="CMCD";function toCmcdQuery(e){if(!e)return"";var t=encodeCmcd(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return"".concat(CMCD_PARAM,"=").concat(encodeURIComponent(t))}var REGEX=/CMCD=[^&#]+/;function appendCmcdQuery(e,t,r){var n,a,i=toCmcdQuery(t,r);if(!i)return e;if(REGEX.test(e))return e.replace(REGEX,i);var s=_includesInstanceProperty(e).call(e,"?")?"&":"?";return _concatInstanceProperty(n=_concatInstanceProperty(a="".concat(e)).call(a,s)).call(n,i)}var CMCDController=function(){function e(t){var r=this;_classCallCheck$1(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,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(e){try{r.apply(e,{ot:CmcdObjectType.MANIFEST,su:!r.initialized})}catch(e){r.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var t=e.frag,n=e.part,a=r.hls.levels[t.level],i=r.getObjectType(t),s={d:1e3*(n||t).duration,ot:i};i!==CmcdObjectType.VIDEO&&i!==CmcdObjectType.AUDIO&&i!=CmcdObjectType.MUXED||(s.br=a.bitrate/1e3,s.tb=r.getTopBandwidth(i)/1e3,s.bl=r.getBufferLength(i));var o=n?r.getNextPart(n):r.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),r.apply(e,s)}catch(e){r.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var n=this.config=t.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||t.sessionId,this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.includeKeys=a.includeKeys,this.registerListeners())}return _createClass$1(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Events.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Events.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var r,n;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(n=t.tracks.video)?void 0:n.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:CmcdStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_extends(t,this.createData());var r=t.ot===CmcdObjectType.INIT||t.ot===CmcdObjectType.VIDEO||t.ot===CmcdObjectType.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var n,a=this.includeKeys;a&&(t=_reduceInstanceProperty(n=_Object$keys(t)).call(n,(function(e,r){return _includesInstanceProperty(a).call(a,r)&&(e[r]=t[r]),e}),{}));var i={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),appendCmcdHeaders(e.headers,t,i)):e.url=appendCmcdQuery(e.url,t,i)}},{key:"getNextFrag",value:function(e){var t,r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){var n=e.sn-r.startSN;return r.fragments[n+1]}}},{key:"getNextPart",value:function(e){var t,r,n=e.index,a=e.fragment,i=null==(t=this.hls.levels[a.level])||null==(r=t.details)?void 0:r.partList;if(i)for(var s=a.sn,o=i.length-1;o>=0;o--){var l=i[o];if(l.index===n&&l.fragment.sn===s)return i[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?CmcdObjectType.TIMED_TEXT:"initSegment"===e.sn?CmcdObjectType.INIT:"audio"===t?CmcdObjectType.AUDIO:"main"===t?this.hls.audioTracks.length?CmcdObjectType.VIDEO:CmcdObjectType.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,n=this.hls;if(e===CmcdObjectType.AUDIO)t=n.audioTracks;else{var a,i=n.maxAutoLevel,s=i>-1?i+1:n.levels.length;t=_sliceInstanceProperty(a=n.levels).call(a,0,s)}var o,l=_createForOfIteratorHelper(t);try{for(l.s();!(o=l.n()).done;){var c=o.value;c.bitrate>r&&(r=c.bitrate)}}catch(e){l.e(e)}finally{l.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===CmcdObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*BufferHelper.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(t){_classCallCheck$1(this,e),this.loader=void 0,this.loader=new r(t)}return _createClass$1(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,n){t(e),this.loader.load(e,r,n)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(t){_classCallCheck$1(this,e),this.loader=void 0,this.loader=new r(t)}return _createClass$1(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,n){t(e),this.loader.load(e,r,n)}}]),e}()}}]),e}(),PATHWAY_PENALTY_DURATION_MS=3e5,ContentSteeringController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"content-steering",e.logger)).hls=void 0,n.loader=null,n.uri=null,n.pathwayId=".",n._pathwayPriority=null,n.timeToLoad=300,n.reloadTimer=-1,n.updated=0,n.started=!1,n.enabled=!0,n.levels=null,n.audioTracks=null,n.subtitleTracks=null,n.penalizedPathways={},n.hls=e,n.registerListeners(),n}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.ERROR,this.onError,this))}},{key:"pathways",value:function(){var e;return _reduceInstanceProperty(e=this.levels||[]).call(e,(function(e,t){return-1===_indexOfInstanceProperty(e).call(e,t.pathwayId)&&e.push(t.pathwayId),e}),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=_filterInstanceProperty(t).call(t,(function(t){return t!==e})))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===NetworkErrorAction.SendAlternateToPenaltyBox&&_flagsInstanceProperty(r)===ErrorActionFlags.MoveAllAlternatesMatchingHost){var n,a,i,s,o,l=this.levels,c=this._pathwayPriority,u=this.pathwayId;if(t.context){var d=t.context,f=d.groupId,h=d.pathwayId,p=d.type;f&&l?u=this.getPathwayForGroupId(f,p,u):h&&(u=h)}if(u in this.penalizedPathways||(this.penalizedPathways[u]=performance.now()),!c&&l&&(c=this.pathways()),c&&c.length>1&&(this.updatePathwayPriority(c),r.resolved=this.pathwayId!==u),!r.resolved)this.warn(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Could not resolve ".concat(t.details,' ("')).call(o,t.error.message,'") with content-steering for Pathway: ')).call(s,u," levels: ")).call(i,l?l.length:l," priorities: ")).call(a,_JSON$stringify(c)," penalized: ")).call(n,_JSON$stringify(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t,r,n=this.getLevelsForPathway(this.pathwayId);if(0===n.length){var a,i=e[0].pathwayId;this.log(_concatInstanceProperty(a="No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "')).call(a,i,'"')),n=this.getLevelsForPathway(i),this.pathwayId=i}n.length!==e.length&&this.log(_concatInstanceProperty(t=_concatInstanceProperty(r="Found ".concat(n.length,"/")).call(r,e.length,' levels in Pathway "')).call(t,this.pathwayId,'"'));return n}},{key:"getLevelsForPathway",value:function(e){var t;return null===this.levels?[]:_filterInstanceProperty(t=this.levels).call(t,(function(t){return e===t.pathwayId}))}},{key:"updatePathwayPriority",value:function(e){var t,r;this._pathwayPriority=e;var n=this.penalizedPathways,a=performance.now();_forEachInstanceProperty(t=_Object$keys(n)).call(t,(function(e){a-n[e]>PATHWAY_PENALTY_DURATION_MS&&delete n[e]}));for(var i=0;i<e.length;i++){var s=e[i];if(!(s in n)){if(s===this.pathwayId)return;var o=this.hls.nextLoadLevel,l=this.hls.levels[o];if((r=this.getLevelsForPathway(s)).length>0){this.log('Setting Pathway to "'.concat(s,'"')),this.pathwayId=s,reassignFragmentLevelIndexes(r),this.hls.trigger(Events.LEVELS_UPDATED,{levels:r});var c=this.hls.levels[o];if(l&&c&&this.levels){var u;if(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate)this.log(_concatInstanceProperty(u="Unstable Pathways change from bitrate ".concat(l.bitrate," to ")).call(u,c.bitrate));this.hls.nextLoadLevel=o}break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var n,a=_concatInstanceProperty(n=this.getLevelsForPathway(r)).call(n,this.levels||[]),i=0;i<a.length;i++)if(t===PlaylistContextType.AUDIO_TRACK&&a[i].hasAudioGroup(e)||t===PlaylistContextType.SUBTITLE_TRACK&&a[i].hasSubtitleGroup(e))return a[i].pathwayId;return r}},{key:"clonePathways",value:function(e){var t=this,r=this.levels;if(r){var n={},a={};_forEachInstanceProperty(e).call(e,(function(e){var i,s=e.ID,o=e["BASE-ID"],l=e["URI-REPLACEMENT"];if(!_someInstanceProperty(r).call(r,(function(e){return e.pathwayId===s}))){var c=_mapInstanceProperty(i=t.getLevelsForPathway(o)).call(i,(function(e){var t,r,i=new AttrList(e.attrs);i["PATHWAY-ID"]=s;var o=i.AUDIO&&_concatInstanceProperty(t="".concat(i.AUDIO,"_clone_")).call(t,s),c=i.SUBTITLES&&_concatInstanceProperty(r="".concat(i.SUBTITLES,"_clone_")).call(r,s);o&&(n[i.AUDIO]=o,i.AUDIO=o),c&&(a[i.SUBTITLES]=c,i.SUBTITLES=c);var u=performUriReplacement(e.uri,i["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),d=new Level({attrs:i,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var f=1;f<e.audioGroups.length;f++){var h;d.addGroupId("audio",_concatInstanceProperty(h="".concat(e.audioGroups[f],"_clone_")).call(h,s))}if(e.subtitleGroups)for(var p=1;p<e.subtitleGroups.length;p++){var y;d.addGroupId("text",_concatInstanceProperty(y="".concat(e.subtitleGroups[p],"_clone_")).call(y,s))}return d}));r.push.apply(r,_toConsumableArray(c)),cloneRenditionGroups(t.audioTracks,n,l,s),cloneRenditionGroups(t.subtitleTracks,a,l,s)}}))}}},{key:"loadSteeringManifest",value:function(e){var t,r=this,n=this.hls.config,a=n.loader;this.loader&&this.loader.destroy(),this.loader=new a(n);try{t=new _URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: ".concat(e))}if("data:"!==t.protocol){var i=0|(this.hls.bandwidthEstimate||n.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+i)}var s={responseType:"json",url:t.href},o=n.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},c={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},u={onSuccess:function(e,n,a,i){r.log('Loaded steering manifest: "'.concat(t,'"'));var s=e.data;if(1===(null==s?void 0:s.VERSION)){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],l=s["PATHWAY-CLONES"],c=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new _URL(o,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(o))}r.scheduleRefresh(r.uri||a.url),l&&r.clonePathways(l);var u={steeringManifest:s,url:t.toString()};r.hls.trigger(Events.STEERING_MANIFEST_LOADED,u),c&&r.updatePathwayPriority(c)}else r.log("Steering VERSION ".concat(s.VERSION," not supported!"))},onError:function(e,t,n,a){var i,s;if(r.log(_concatInstanceProperty(i=_concatInstanceProperty(s="Error loading steering manifest: ".concat(e.code," ")).call(s,e.text," (")).call(i,t.url,")")),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest ".concat(t.url," no longer available"));var o=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,o);else{var l=r.loader;if("function"==typeof(null==l?void 0:l.getResponseHeader)){var c=l.getResponseHeader("Retry-After");c&&(o=1e3*_parseFloat$1(c))}r.log("Steering manifest ".concat(t.url," rate limited"))}},onTimeout:function(e,t,n){r.log("Timeout loading steering manifest (".concat(t.url,")")),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: ".concat(t)),this.loader.load(s,c,u)}},{key:"scheduleRefresh",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3*this.timeToLoad;this.clearTimeout(),this.reloadTimer=_setTimeout((function(){var r,n=null==(r=t.hls)?void 0:r.media;!n||n.ended?t.scheduleRefresh(e,1e3*t.timeToLoad):t.loadSteeringManifest(e)}),r)}}]),r}();function cloneRenditionGroups(e,t,r,n){var a;e&&_forEachInstanceProperty(a=_Object$keys(t)).call(a,(function(a){var i,s=_mapInstanceProperty(i=_filterInstanceProperty(e).call(e,(function(e){return e.groupId===a}))).call(i,(function(e){var i=_extends({},e);return i.details=void 0,i.attrs=new AttrList(i.attrs),i.url=i.attrs.URI=performUriReplacement(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),i.groupId=i.attrs["GROUP-ID"]=t[a],i.attrs["PATHWAY-ID"]=n,i}));e.push.apply(e,_toConsumableArray(s))}))}function performUriReplacement(e,t,r,n){var a,i=n.HOST,s=n.PARAMS,o=n[r];t&&(a=null==o?void 0:o[t])&&(e=a);var l,c,u=new _URL(e);(i&&!a&&(u.host=i),s)&&_forEachInstanceProperty(l=_sortInstanceProperty(c=_Object$keys(s)).call(c)).call(l,(function(e){e&&u.searchParams.set(e,s[e])}));return u.href}var EMEController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"eme",e.logger)).hls=void 0,n.config=void 0,n.media=null,n.keyFormatPromise=null,n.keySystemAccessPromises={},n._requestLicenseFailureCount=0,n.mediaKeySessions=[],n.keyIdToKeySessionPromise={},n.setMediaKeysQueue=r.CDMCleanupPromise?[r.CDMCleanupPromise]:[],n.onMediaEncrypted=function(e){var t,r=e.initDataType,a=e.initData,i=_concatInstanceProperty(t='"'.concat(e.type,'" event: init data type: "')).call(t,r,'"');if(n.debug(i),null!==a){var s,o;if("sinf"===r&&n.getLicenseServerUrl(KeySystems.FAIRPLAY)){var l=bin2str(new Uint8Array(a));try{var c=parseSinf(base64Decode(JSON.parse(l).sinf));if(!c)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=c.subarray(8,24),o=KeySystems.FAIRPLAY}catch(e){var u;return void n.warn(_concatInstanceProperty(u="".concat(i," Failed to parse sinf: ")).call(u,e))}}else if(n.getLicenseServerUrl(KeySystems.WIDEVINE)){var d=parseMultiPssh(a),f=_Object$keys(n.keySystemAccessPromises);f.length||(f=getKeySystemsForConfig(n.config));var h=_filterInstanceProperty(d).call(d,(function(e){var t=e.systemId?keySystemIdToKeySystemDomain(e.systemId):null;return!!t&&_indexOfInstanceProperty(f).call(f,t)>-1}))[0];if(!h){var p;if(0===d.length||_someInstanceProperty(d).call(d,(function(e){return!e.systemId})))n.warn("".concat(i," contains incomplete or invalid pssh data"));else n.log(_concatInstanceProperty(p="ignoring ".concat(i," for ")).call(p,_mapInstanceProperty(d).call(d,(function(e){return keySystemIdToKeySystemDomain(e.systemId)})).join(",")," pssh data in favor of playlist keys"));return}if(o=keySystemIdToKeySystemDomain(h.systemId),0===h.version&&h.data)if(o===KeySystems.WIDEVINE){var y=h.data.length-22;s=h.data.subarray(y,y+16)}else o===KeySystems.PLAYREADY&&(s=parsePlayReadyWRM(h.data))}if(o&&s){for(var g=Hex.hexDump(s),v=_assertThisInitialized(n),m=v.keyIdToKeySessionPromise,E=v.mediaKeySessions,$=m[g],S=function(){var e,t=E[T],i=t.decryptdata;if(!i.keyId)return"continue";var o=Hex.hexDump(i.keyId);return g===o||-1!==_indexOfInstanceProperty(e=i.uri.replace(/-/g,"")).call(e,g)?($=m[o],i.pssh||(delete m[o],i.pssh=new Uint8Array(a),i.keyId=s,($=m[g]=$.then((function(){return n.generateRequestWithPreferredKeySession(t,r,a,"encrypted-event-key-match")}))).catch((function(e){return n.handleError(e)}))),"break"):void 0},T=0;T<E.length;T++){var I=S();if("continue"!==I&&"break"===I)break}$||($=m[g]=n.getKeySystemSelectionPromise([o]).then((function(e){var t,i=e.keySystem,o=e.mediaKeys;n.throwIfDestroyed();var l=new LevelKey("ISO-23001-7",g,null!=(t=keySystemDomainToKeySystemFormat(i))?t:"");return l.pssh=new Uint8Array(a),l.keyId=s,n.attemptSetMediaKeys(i,o).then((function(){n.throwIfDestroyed();var e=n.createMediaKeySessionContext({decryptdata:l,keySystem:i,mediaKeys:o});return n.generateRequestWithPreferredKeySession(e,r,a,"encrypted-event-no-match")}))}))).catch((function(e){return n.handleError(e)}))}}},n.onWaitingForKey=function(e){n.log('"'.concat(e.type,'" event'))},n.hls=e,n.config=e.config,n.registerListeners(),n}return _createClass$1(r,[{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,r=t.drmSystems,n=t.widevineLicenseUrl,a=r[e];return a?a.licenseUrl:e===KeySystems.WIDEVINE&&n?n:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error('no license server URL configured for key-system "'.concat(e,'"'));return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'.concat(e,'"]'))}},{key:"attemptKeySystemAccess",value:function(e){var t,r,n=this,a=this.hls.levels,i=function(e,t,r){return!!e&&_indexOfInstanceProperty(r).call(r,e)===t},s=_filterInstanceProperty(t=_mapInstanceProperty(a).call(a,(function(e){return e.audioCodec}))).call(t,i),o=_filterInstanceProperty(r=_mapInstanceProperty(a).call(a,(function(e){return e.videoCodec}))).call(r,i);return s.length+o.length===0&&o.push("avc1.42e01e"),new _Promise((function(t,r){!function e(a){var i=a.shift();n.getMediaKeysPromise(i,s,o).then((function(e){return t({keySystem:i,mediaKeys:e})})).catch((function(t){a.length?e(a):r(t instanceof EMEKeyError?t:new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))}(e)}))}},{key:"requestMediaKeySystemAccess",value:function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var n="Configured requestMediaKeySystemAccess is not a function ".concat(r);return null===_requestMediaKeySystemAccess&&"http:"===self.location.protocol&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),_Promise.reject(new Error(n))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var n=this,a=getSupportedMediaKeySystemConfigurations(e,t,r,this.config.drmSystemOptions),i=this.keySystemAccessPromises[e],s=null==i?void 0:i.keySystemAccess;if(!s){var o;this.log(_concatInstanceProperty(o='Requesting encrypted media "'.concat(e,'" key-system access with config: ')).call(o,_JSON$stringify(a))),s=this.requestMediaKeySystemAccess(e,a);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){var r;n.log(_concatInstanceProperty(r='Failed to obtain access to key-system "'.concat(e,'": ')).call(r,t))})),s.then((function(t){n.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=n.fetchServerCertificate(e);return n.log('Create media-keys for "'.concat(e,'"')),l.mediaKeys=t.createMediaKeys().then((function(t){return n.log('Media-keys created for "'.concat(e,'"')),r.then((function(r){return r?n.setMediaKeysServerCertificate(t,e,r):t}))})),l.mediaKeys.catch((function(t){var r;n.error(_concatInstanceProperty(r='Failed to create media-keys for "'.concat(e,'"}: ')).call(r,t))})),l.mediaKeys}))}return s.then((function(){return i.mediaKeys}))}},{key:"createMediaKeySessionContext",value:function(e){var t,r=e.decryptdata,n=e.keySystem,a=e.mediaKeys;this.log(_concatInstanceProperty(t='Creating key-system session "'.concat(n,'" keyId: ')).call(t,Hex.hexDump(r.keyId||[])));var i=a.createSession(),s={decryptdata:r,keySystem:n,mediaKeys:a,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"getKeyIdString",value:function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return Hex.hexDump(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,n,a,i=e.mediaKeysSession;return this.log(_concatInstanceProperty(r=_concatInstanceProperty(n='Updating key-session "'.concat(i.sessionId,'" for keyID ')).call(n,Hex.hexDump((null==(a=e.decryptdata)?void 0:a.keyId)||[]),"\n } (data length: ")).call(r,t?t.byteLength:t,")")),i.update(t)}},{key:"selectKeySystemFormat",value:function(e){var t,r,n,a=_Object$keys(e.levelkeys||{});this.keyFormatPromise||(this.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n="Selecting key-system from fragment (sn: ".concat(e.sn," ")).call(n,e.type,": ")).call(r,e.level,") key formats ")).call(t,a.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(a));return this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new _Promise((function(r,n){var a,i=getKeySystemsForConfig(t.config),s=_filterInstanceProperty(a=_mapInstanceProperty(e).call(e,keySystemFormatToKeySystemDomain)).call(a,(function(e){return!!e&&-1!==_indexOfInstanceProperty(i).call(i,e)}));return t.getKeySystemSelectionPromise(s).then((function(e){var t=e.keySystem,a=keySystemDomainToKeySystemFormat(t);a?r(a):n(new Error('Unable to find format for key-system "'.concat(t,'"')))})).catch(n)}))}},{key:"loadKey",value:function(e){var t,r,n,a=this,i=e.keyInfo.decryptdata,s=this.getKeyIdString(i),o=_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n="(keyId: ".concat(s,' format: "')).call(n,i.keyFormat,'" method: ')).call(r,i.method," uri: ")).call(t,i.uri,")");this.log("Starting session for key ".concat(o));var l=this.keyIdToKeySessionPromise[s];l||(l=this.getKeySystemForKeyPromise(i).then((function(t){var r,n,s,l=t.keySystem,c=t.mediaKeys;return a.throwIfDestroyed(),a.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(s="Handle encrypted media sn: ".concat(e.frag.sn," ")).call(s,e.frag.type,": ")).call(n,e.frag.level," using key ")).call(r,o)),a.attemptSetMediaKeys(l,c).then((function(){return a.throwIfDestroyed(),a.createMediaKeySessionContext({keySystem:l,mediaKeys:c,decryptdata:i})}))})),(this.keyIdToKeySessionPromise[s]=l.then((function(e){var t=i.pssh?i.pssh.buffer:null;return a.generateRequestWithPreferredKeySession(e,"cenc",t,"playlist-key")}))).catch((function(e){return a.handleError(e)})));return l}},{key:"throwIfDestroyed",value:function(){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e){this.hls&&(this.error(e.message),e instanceof EMEKeyError?this.hls.trigger(Events.ERROR,e.data):this.hls.trigger(Events.ERROR,{type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}},{key:"getKeySystemForKeyPromise",value:function(e){var t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){var n=keySystemFormatToKeySystemDomain(e.keyFormat),a=n?[n]:getKeySystemsForConfig(this.config);return this.attemptKeySystemAccess(a)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=getKeySystemsForConfig(this.config)),0===e.length)throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(_JSON$stringify({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r,n=this,a=_sliceInstanceProperty(r=this.setMediaKeysQueue).call(r);this.log('Setting media-keys for "'.concat(e,'"'));var i=_Promise.all(a).then((function(){if(!n.media)throw new Error("Attempted to set mediaKeys without media element attached");return n.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(i),i.then((function(){var t;n.log('Media-keys set for "'.concat(e,'"')),a.push(i),n.setMediaKeysQueue=_filterInstanceProperty(t=n.setMediaKeysQueue).call(t,(function(e){return-1===_indexOfInstanceProperty(a).call(a,e)}))}))}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,r,n){var a,i,s,o,l,c=this,u=null==(o=this.config.drmSystems)||null==(l=o[e.keySystem])?void 0:l.generateRequest;if(u)try{var d=u.call(this.hls,t,r,e);if(!d)throw new Error("Invalid response from configured generateRequest filter");t=d.initDataType,r=d.initData?d.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(e){var f;if(this.warn(e.message),null!=(f=this.hls)&&f.config.debug)throw e}if(null===r)return this.log('Skipping key-session request for "'.concat(n,'" (no initData)')),_Promise.resolve(e);var h=this.getKeyIdString(e.decryptdata);this.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s='Generating key-session request for "'.concat(n,'": ')).call(s,h," (init data type: ")).call(i,t," length: ")).call(a,r?r.byteLength:null,")"));var p=new EventEmitter,y=e._onmessage=function(t){var r,n,a=e.mediaKeysSession;if(a){var i=t.messageType,s=t.message;c.log(_concatInstanceProperty(r=_concatInstanceProperty(n='"'.concat(i,'" message event for session "')).call(n,a.sessionId,'" message size: ')).call(r,s.byteLength)),"license-request"===i||"license-renewal"===i?c.renewLicense(e,s).catch((function(e){p.eventNames().length?p.emit("error",e):c.handleError(e)})):"license-release"===i?e.keySystem===KeySystems.FAIRPLAY&&(c.updateKeySession(e,strToUtf8array("acknowledged")),c.removeSession(e)):c.warn('unhandled media key message type "'.concat(i,'"'))}else p.emit("error",new Error("invalid state"))},g=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){c.onKeyStatusChange(e);var r,n=e.keyStatus;if(p.emit("keyStatus",n),"expired"===n)c.warn(_concatInstanceProperty(r="".concat(e.keySystem," expired for key ")).call(r,h)),c.renewKeySession(e)}else p.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",y),e.mediaKeysSession.addEventListener("keystatuseschange",g);var v=new _Promise((function(e,t){p.on("error",t),p.on("keyStatus",(function(r){_startsWithInstanceProperty(r).call(r,"usable")?e():"output-restricted"===r?t(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(r,'"'))):"expired"===r?t(new Error("key expired while generating request")):c.warn('unhandled key status change "'.concat(r,'"'))}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t,r;c.log(_concatInstanceProperty(t='Request generated for key-session "'.concat(null==(r=e.mediaKeysSession)?void 0:r.sessionId,'" keyId: ')).call(t,h))})).catch((function(e){throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: ".concat(e))})).then((function(){return v})).catch((function(t){throw p.removeAllListeners(),c.removeSession(e),t})).then((function(){return p.removeAllListeners(),e}))}},{key:"onKeyStatusChange",value:function(e){var t,r=this;_forEachInstanceProperty(t=e.mediaKeysSession.keyStatuses).call(t,(function(t,n){var a,i,s;r.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s='key status change "'.concat(t,'" for keyStatuses keyId: ')).call(s,Hex.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))," session keyId: ")).call(i,Hex.hexDump(new Uint8Array(e.decryptdata.keyId||[]))," uri: ")).call(a,e.decryptdata.uri)),e.keyStatus=t}))}},{key:"fetchServerCertificate",value:function(e){var t=this.config,r=new(0,t.loader)(t),n=this.getServerCertificateUrl(e);return n?(this.log('Fetching server certificate for "'.concat(e,'"')),new _Promise((function(a,i){var s={responseType:"arraybuffer",url:n},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(e,t,r,n){a(e.data)},onError:function(t,r,a,o){var l,c,u;i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:_objectSpread2({url:s.url,data:void 0},t)},_concatInstanceProperty(l=_concatInstanceProperty(c=_concatInstanceProperty(u='"'.concat(e,'" certificate request failed (')).call(u,n,"). Status: ")).call(c,t.code," (")).call(l,t.text,")")))},onTimeout:function(t,r,a){var o;i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:s.url,data:void 0}},_concatInstanceProperty(o='"'.concat(e,'" certificate request timed out (')).call(o,n,")")))},onAbort:function(e,t,r){i(new Error("aborted"))}};r.load(s,l,c)}))):_Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var n=this;return new _Promise((function(a,i){e.setServerCertificate(r).then((function(i){var s,o;n.log(_concatInstanceProperty(s=_concatInstanceProperty(o="setServerCertificate ".concat(i?"success":"not supported by CDM"," (")).call(o,null==r?void 0:r.byteLength,') on "')).call(s,t,'"')),a(e)})).catch((function(e){i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))}},{key:"renewLicense",value:function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then((function(t){return r.updateKeySession(e,new Uint8Array(t)).catch((function(e){throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!_includesInstanceProperty(r).call(r,"PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var n=(new DOMParser).parseFromString(r,"application/xml"),a=n.querySelectorAll("HttpHeader");if(a.length>0)for(var i,s=0,o=a.length;s<o;s++){var l,c,u=null==(l=(i=a[s]).querySelector("name"))?void 0:l.textContent,d=null==(c=i.querySelector("value"))?void 0:c.textContent;u&&d&&e.setRequestHeader(u,d)}var f=n.querySelector("Challenge"),h=null==f?void 0:f.textContent;if(!h)throw new Error("Cannot find <Challenge> in key message");return strToUtf8array(atob(h))}},{key:"setupLicenseXHR",value:function(e,t,r,n){var a=this,i=this.config.licenseXhrSetup;return i?_Promise.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return i.call(a.hls,e,t,r,n)})).catch((function(s){if(!r.decryptdata)throw s;return e.open("POST",t,!0),i.call(a.hls,e,t,r,n)})).then((function(r){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||n}})):(e.open("POST",t,!0),_Promise.resolve({xhr:e,licenseChallenge:n}))}},{key:"requestLicense",value:function(e,t){var r=this,n=this.config.keyLoadPolicy.default;return new _Promise((function(a,i){var s=r.getLicenseServerUrlOrThrow(e.keySystem);r.log("Sending license request to URL: ".concat(s));var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(4===o.readyState)if(200===o.status){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received ".concat(l instanceof ArrayBuffer?l.byteLength:l));var c=r.config.licenseResponseCallback;if(c)try{l=c.call(r.hls,o,s,e)}catch(e){r.error(e)}a(l)}else{var u=n.errorRetry,d=u?u.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>d||o.status>=400&&o.status<500){var f,h;i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},_concatInstanceProperty(f=_concatInstanceProperty(h="License Request XHR failed (".concat(s,"). Status: ")).call(h,o.status," (")).call(f,o.statusText,")")))}else{var p=d-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(p," attempts left")),r.requestLicense(e,t).then(a,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,t).then((function(t){var n=t.xhr,a=t.licenseChallenge;e.keySystem==KeySystems.PLAYREADY&&(a=r.unpackPlayReadyKeyMessage(n,a)),n.send(a)}))}))}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}}},{key:"onMediaDetached",value:function(){var e,t,n=this,a=this.media,i=this.mediaKeySessions;a&&(a.removeEventListener("encrypted",this.onMediaEncrypted),a.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},LevelKey.clearKeyUriToKeyIdMap();var s=i.length;r.CDMCleanupPromise=_Promise.all(_concatInstanceProperty(e=_mapInstanceProperty(i).call(i,(function(e){return n.removeSession(e)}))).call(e,null==a||null==(t=a.setMediaKeys(null))?void 0:t.catch((function(e){var t;n.log("Could not clear media keys: ".concat(e)),null==(t=n.hls)||t.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){s&&(n.log("finished closing key sessions and clearing media keys"),i.length=0)})).catch((function(e){var t;n.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=n.hls)||t.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close sessions and clear media keys: ".concat(e))})}))}},{key:"onManifestLoading",value:function(){this.keyFormatPromise=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var n=_reduceInstanceProperty(r).call(r,(function(e,t){return-1===_indexOfInstanceProperty(e).call(e,t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys ".concat(n.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(n)}}},{key:"removeSession",value:function(e){var t=this,r=e.mediaKeysSession,n=e.licenseXhr;if(r){var a;this.log("Remove licenses and keys and close session ".concat(r.sessionId)),e._onmessage&&(r.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var i,s=_indexOfInstanceProperty(a=this.mediaKeySessions).call(a,e);if(s>-1)_spliceInstanceProperty(i=this.mediaKeySessions).call(i,s,1);return r.remove().catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error("Could not remove session: ".concat(e))})})).then((function(){return r.close()})).catch((function(e){var r;t.log("Could not close session: ".concat(e)),null==(r=t.hls)||r.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),r}();EMEController.CDMCleanupPromise=void 0;var EMEKeyError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,n)).data=void 0,e.error||(e.error=new Error(n)),a.data=e,e.err=e.error,a}return _createClass$1(r)}(),FPSController=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}return _createClass$1(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var n,a=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=a,a&&"function"==typeof a.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=_setInterval(_bindInstanceProperty(n=this.checkFPSInterval).call(n,this),r.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,r){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,i=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*i/a,l=this.hls;if(l.trigger(Events.FPS_DROP,{currentDropped:i,currentDecoded:s,totalDroppedFrames:r}),o>0&&i>l.config.fpsDroppedMonitoringThreshold*s){var c=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=c)&&(c-=1,l.trigger(Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}]),e}();function sendAddTrackEvent(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function addCueToTrack(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: ".concat(t))}catch(r){logger.debug("[texttrack-utils]: ".concat(r));try{var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){logger.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(e))}}"disabled"===r&&(e.mode=r)}function clearCurrentCues(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(var n=e.cues.length;n--;)t&&e.cues[n].removeEventListener("enter",t),e.removeCue(e.cues[n]);"disabled"===r&&(e.mode=r)}function removeCuesInRange(e,t,r,n){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var i=getCuesInRange(e.cues,t,r),s=0;s<i.length;s++)n&&!n(i[s])||e.removeCue(i[s]);"disabled"===a&&(e.mode=a)}function getFirstCueIndexAfterTime(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var n=0,a=r;n<=a;){var i=Math.floor((a+n)/2);if(t<e[i].startTime)a=i-1;else{if(!(t>e[i].startTime&&n<r))return i;n=i+1}}return e[n].startTime-t<t-e[a].startTime?n:a}function getCuesInRange(e,t,r){var n=[],a=getFirstCueIndexAfterTime(e,t);if(a>-1)for(var i=a,s=e.length;i<s;i++){var o=e[i];if(o.startTime>=t&&o.endTime<=r)n.push(o);else if(o.startTime>r)return n}return n}function filterSubtitleTracks(e){for(var t=[],r=0;r<e.length;r++){var n=e[r];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||t.push(e[r])}return t}var SubtitleTrackController=function(e){_inherits(r,BasePlaylistController);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e,"subtitle-track-controller")).media=null,n.tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.queuedDefaultTrack=-1,n.useTextTrackPolling=!1,n.subtitlePollingInterval=-1,n._subtitleDisplay=!0,n.asyncPollTrackChange=function(){return n.pollTrackChange(0)},n.onTextTracksChanged=function(){if(n.useTextTrackPolling||self.clearInterval(n.subtitlePollingInterval),n.media&&n.hls.config.renderTextTracksNatively){for(var e=null,t=filterSubtitleTracks(n.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}var a=n.findTrackForTextTrack(e);n.subtitleTrack!==a&&n.setSubtitleTrack(a)}},n.registerListeners(),n}return _createClass$1(r,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,_get(_getPrototypeOf(r.prototype),"destroy",this).call(this)}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Events.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.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))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=_setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;if(r){var n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!n){var a=filterSubtitleTracks(r.textTracks);_forEachInstanceProperty(a).call(a,(function(e){clearCurrentCues(e)}))}}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,n,a,i,s,o=t.id,l=t.groupId,c=t.details,u=this.tracksInGroup[o];if(u&&u.groupId===l){var d=u.details;u.details=t.details,this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Subtitle track ".concat(o,' "')).call(s,u.name,'" lang:')).call(i,u.lang," group:")).call(a,l," loaded [")).call(n,c.startSN,"-")).call(r,c.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,d)}else{var f,h;this.warn(_concatInstanceProperty(f=_concatInstanceProperty(h="Subtitle track with id:".concat(o," and group:")).call(h,l," not found in active group ")).call(f,null==u?void 0:u.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.subtitleGroups||null,n=this.groupIds,a=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&_someInstanceProperty(r).call(r,(function(e){return-1===(null==n?void 0:_indexOfInstanceProperty(n).call(n,e))}))){var i,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=_filterInstanceProperty(i=this.tracks).call(i,(function(e){return!r||-1!==_indexOfInstanceProperty(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!_someInstanceProperty(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),_forEachInstanceProperty(o).call(o,(function(e,t){e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.subtitlePreference;if(!a&&l){this.selectDefaultTrack=!1;var c=findMatchingOption(l,o);if(c>-1)a=o[c];else{var u=findMatchingOption(l,this.tracks);a=this.tracks[u]}}var d=this.findTrackId(a);-1===d&&a&&(d=this.findTrackId(null));var f={subtitleTracks:o};this.log(_concatInstanceProperty(s="Updating subtitle tracks, ".concat(o.length,' track(s) found in "')).call(s,null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(Events.SUBTITLE_TRACKS_UPDATED,f),-1!==d&&-1===this.trackId&&this.setSubtitleTrack(d)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=this.selectDefaultTrack,n=0;n<t.length;n++){var a=t[n];if((!r||a.default)&&(r||e)&&(!e||matchesOption(a,e)))return n}if(e){for(var i=0;i<t.length;i++){var s=t[i];if(mediaAttributesIdentical(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(var o=0;o<t.length;o++){var l=t[o];if(mediaAttributesIdentical(e.attrs,l.attrs,["LANGUAGE"]))return o}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,r=0;r<t.length;r++){if(subtitleTrackMatchesTextTrack(t[r],e))return r}return-1}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==PlaylistContextType.SUBTITLE_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===_indexOfInstanceProperty(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var r=this.currentTrack;if(r&&matchesOption(e,r))return r;var n=findMatchingOption(e,this.tracksInGroup);if(n>-1){var a=this.tracksInGroup[n];return this.setSubtitleTrack(n),a}if(r)return null;var i=findMatchingOption(e,t);if(i>-1)return t[i]}}return null}},{key:"loadPlaylist",value:function(e){_get(_getPrototypeOf(r.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,t){var n,a,i,s,o,l;_get(_getPrototypeOf(r.prototype),"loadingPlaylist",this).call(this,e,t);var c=e.id,u=e.groupId,d=this.getUrlWithDirectives(e.url,t),f=e.details,h=null==f?void 0:f.age;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="Loading subtitle ".concat(c,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,u)).call(i,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,h&&f.live?" age "+h.toFixed(1)+(f.type&&" "+f.type||""):""," ")).call(n,d)),this.hls.trigger(Events.SUBTITLE_TRACK_LOADING,{url:d,id:c,groupId:u,deliveryDirectives:t||null,track:e})}},{key:"toggleTrackModes",value:function(){var e,t=this.media;if(t){var r,n,a=filterSubtitleTracks(t.textTracks),i=this.currentTrack;if(i)if(!(r=_filterInstanceProperty(a).call(a,(function(e){return subtitleTrackMatchesTextTrack(i,e)}))[0]))this.warn(_concatInstanceProperty(n='Unable to find subtitle TextTrack with name "'.concat(i.name,'" and language "')).call(n,i.lang,'"'));if(_forEachInstanceProperty(e=_sliceInstanceProperty([]).call(a)).call(e,(function(e){"disabled"!==e.mode&&e!==r&&(e.mode="disabled")})),r){var s=this.subtitleDisplay?"showing":"hidden";r.mode!==s&&(r.mode=s)}}}},{key:"setSubtitleTrack",value:function(e){var t,r,n=this.tracksInGroup;if(this.media)if(e<-1||e>=n.length||!isFiniteNumber(e))this.warn("Invalid subtitle track id: ".concat(e));else{this.selectDefaultTrack=!1;var a=this.currentTrack,i=n[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),i){var s=!!i.details&&!i.details.live;if(e!==this.trackId||i!==a||!s){this.log("Switching to subtitle-track ".concat(e)+(i?_concatInstanceProperty(t=_concatInstanceProperty(r=' "'.concat(i.name,'" lang:')).call(r,i.lang," group:")).call(t,i.groupId):""));var o=i.id,l=i.groupId,c=void 0===l?"":l,u=i.name,d=i.type,f=i.url;this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:c,name:u,type:d,url:f});var h=this.switchParams(i.url,null==a?void 0:a.details,i.details);this.loadPlaylist(h)}}else this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),r}();function hash(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var ALIGNED_END_THRESHOLD_SECONDS=.02,TimelineOccupancy=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function generateAssetIdentifier(e,t,r){var n,a;return _concatInstanceProperty(n=_concatInstanceProperty(a="".concat(e.identifier,"-")).call(a,r+1,"-")).call(n,hash(t))}var InterstitialEvent=function(){function e(t,r){_classCallCheck$1(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.base=r,this.dateRange=t,this.setDateRange(t)}return _createClass$1(e,[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=this.error=void 0}},{key:"isAssetPastPlayoutLimit",value:function(e){if(e>=this.assetList.length)return!0;var t=this.playoutLimit;return!(e<=0||isNaN(t))&&this.assetList[e].startOffset>t}},{key:"findAssetIndex",value:function(e){var t;return _indexOfInstanceProperty(t=this.assetList).call(t,e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return getSnapToFragmentTime(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=isFiniteNumber(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return getSnapToFragmentTime(e,t)}return e}},{key:"appendInPlace",get:function(){return!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||0!==this.startTime&&!this.snapOptions.out||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<ALIGNED_END_THRESHOLD_SECONDS))},set:function(e){this.appendInPlaceStarted||(this.appendInPlaceDisabled=!e)}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?TimelineOccupancy.Range:TimelineOccupancy.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"toString",value:function(){return eventToString(this)}}]),e}();function getSnapToFragmentTime(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<ALIGNED_END_THRESHOLD_SECONDS)?t.start:t.start+t.duration}function getInterstitialUrl(e,t,r){var n=new _URL(e,r);return"data:"!==n.protocol&&n.searchParams.set("_HLS_primary_id",t),n}function eventToString(e){var t,r,n;return _concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n='["'.concat(e.identifier,'" ')).call(n,e.cue.pre?"<pre>":e.cue.post?"<post>":"")).call(r,e.timelineStart.toFixed(2),"-")).call(t,e.resumeTime.toFixed(2),"]")}function eventAssetToString(e){var t,r,n=e.timelineStart,a=e.duration||0;return _concatInstanceProperty(t=_concatInstanceProperty(r='["'.concat(e.identifier,'" ')).call(r,n.toFixed(2),"-")).call(t,(n+a).toFixed(2),"]")}var HlsAssetPlayer=function(){function e(t,r,n,a){var i=this;_classCallCheck$1(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this.playoutOffset=0,this.checkPlayout=function(){var e=i.interstitial.playoutLimit;i.playoutOffset+i.currentTime>=e&&i.hls.trigger(Events.PLAYOUT_LIMIT_REACHED,{})};var s=this.hls=new t(r);this.interstitial=n,this.assetItem=a;var o=a.uri;try{o=getInterstitialUrl(o,s.sessionId).href}catch(e){}s.loadSource(o);var l=function(){i.hasDetails=!0};s.once(Events.LEVEL_LOADED,l),s.once(Events.AUDIO_TRACK_LOADED,l),s.once(Events.SUBTITLE_TRACK_LOADED,l),s.on(Events.MEDIA_ATTACHING,(function(e,t){var r=t.media;i.removeMediaListeners(),i.mediaAttached=r;var n,s,o=i.interstitial;o.playoutLimit&&(i.playoutOffset=(null==(s=o.assetList[_indexOfInstanceProperty(n=o.assetList).call(n,a)])?void 0:s.startOffset)||0,r.addEventListener("timeupdate",i.checkPlayout))}))}return _createClass$1(e,[{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){return this.hls.media}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return 0;var t=BufferHelper.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):0}},{key:"duration",get:function(){var e,t=null==(e=this.assetItem)?void 0:e.duration;return t||0}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"timelineOffset",get:function(){return this.hls.config.timelineOffset||0},set:function(e){var t=this.timelineOffset;if(e!==t){var r=e-t;if(Math.abs(r)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&e.removeEventListener("timeupdate",this.checkPlayout)}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){this.hls.attachMedia(e)}},{key:"detachMedia",value:function(){this.removeMediaListeners(),this.hls.detachMedia()}},{key:"resumeBuffering",value:function(){this.hls.resumeBuffering()}},{key:"pauseBuffering",value:function(){this.hls.pauseBuffering()}},{key:"transferMedia",value:function(){return this.hls.transferMedia()}},{key:"on",value:function(e,t,r){this.hls.on(e,t)}},{key:"once",value:function(e,t,r){this.hls.once(e,t)}},{key:"off",value:function(e,t,r){this.hls.off(e,t)}},{key:"toString",value:function(){var e,t;return _concatInstanceProperty(e=_concatInstanceProperty(t="HlsAssetPlayer: ".concat(eventAssetToString(this.assetItem)," ")).call(t,this.hls.sessionId," ")).call(e,this.interstitial.appendInPlace?"append-in-place":"")}}]),e}(),ABUTTING_THRESHOLD_SECONDS=.033,InterstitialsSchedule=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,"interstitials-sched",n)).onScheduleUpdate=void 0,a.eventMap={},a.events=null,a.items=null,a.durations={primary:0,playout:0,integrated:0},a.onScheduleUpdate=e,a}return _createClass$1(r,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){var e;(this.eventMap={},this.setDurations(0,0,0),this.events)&&_forEachInstanceProperty(e=this.events).call(e,(function(e){return e.reset()}));this.events=this.items=null}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);var n=this.items;if(n)for(n[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(a=n[r])&&a.event;){var a;r--}return r}},{key:"findItemIndexAtTime",value:function(e,t){var r=this.items;if(r)for(var n=0;n<r.length;n++){var a=r[n];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return n}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var r=this.items;if(r)for(var n=e;n<=t&&r[n];n++){var a=r[n].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return n}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var r=t.length;r--;){var n;if((null==(n=t[r].event)?void 0:n.identifier)===e)return r}return-1}},{key:"findAssetIndex",value:function(e,t){var r=e.assetList,n=r.length;if(n>1)for(var a=0;a<n;a++){var i=r[a];if(!i.error){var s=i.timelineStart;if(t===s||t>s&&t<s+(i.duration||0))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t,r=null==(e=this.items)||null==(t=e[this.length-1])?void 0:t.event;if(r){var n=r.assetList,a=n[n.length-1];if(a)return a.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e){var t=this,r=e.main.details,n=r.dateRanges,a=this.events,i=this.parseDateRanges(n,{url:r.url}),s=_Object$keys(n),o=a?_filterInstanceProperty(a).call(a,(function(e){return!_includesInstanceProperty(s).call(s,e.identifier)})):[];i.length&&_sortInstanceProperty(i).call(i,(function(e,t){var r=e.cue.pre,n=e.cue.post,a=t.cue.pre,i=t.cue.post;if(r&&!a)return-1;if(a&&!r)return 1;if(n&&!i)return 1;if(i&&!n)return-1;if(!(r||a||n||i)){var s=e.startTime,o=t.startTime;if(s!==o)return s-o}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=i,_forEachInstanceProperty(o).call(o,(function(e){t.removeEvent(e)})),this.updateSchedule(e,o)}},{key:"updateSchedule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.events||[];if(r.length||t.length||this.length<2){var n=this.items,a=this.parseSchedule(r,e),i=t.length||(null==n?void 0:n.length)!==a.length||_someInstanceProperty(a).call(a,(function(e,t){return Math.abs(e.playout.start-n[t].playout.start)>.005||Math.abs(e.playout.end-n[t].playout.end)>.005}));i&&(this.items=a,this.onScheduleUpdate(t,n))}}},{key:"parseDateRanges",value:function(e,t){for(var r=[],n=_Object$keys(e),a=0;a<n.length;a++){var i=n[a],s=e[i];if(s.isInterstitial){var o=this.eventMap[i];o?o.setDateRange(s):(o=new InterstitialEvent(s,t),this.eventMap[i]=o),r.push(o)}}return r}},{key:"parseSchedule",value:function(e,t){var r=[],n=t.main.details,a=n.live?1/0:n.edge,i=0;if((e=_filterInstanceProperty(e).call(e,(function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(_forEachInstanceProperty(e).call(e,(function(t,n){var l=t.cue.pre,c=t.cue.post,u=e[n-1]||null,d=t.appendInPlace,f=c?a:t.startOffset,h=t.duration,p=t.timelineOccupancy===TimelineOccupancy.Range?h:0,y=t.resumptionOffset,g=(null==u?void 0:u.startTime)===f,v=f+t.cumulativeDuration,m=d?v+h:f+y;if(l||!c&&f<=0){var E=o;o+=p,t.timelineStart=v;var $=i;i+=h,r.push({event:t,start:v,end:m,playout:{start:$,end:i},integrated:{start:E,end:o}})}else{if(!(f<=a))return;if(!g){var S=f-s;if(S>ABUTTING_THRESHOLD_SECONDS){var T=s,I=o;o+=S;var _=i;i+=S;var P={previousEvent:e[n-1]||null,nextEvent:t,start:T,end:T+S,playout:{start:_,end:i},integrated:{start:I,end:o}};r.push(P)}else S>0&&u&&(u.cumulativeDuration+=S,r[r.length-1].end=f)}c&&(m=v),t.timelineStart=v;var b=o;o+=p;var A=i;i+=h,r.push({event:t,start:v,end:m,playout:{start:A,end:i},integrated:{start:b,end:o}})}var R=t.resumeTime;s=c||R>a?a:R})),s<a){var l,c=s,u=o,d=a-s;o+=d;var f=i;i+=d,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:s,end:c+d,playout:{start:f,end:i},integrated:{start:u,end:o}})}this.setDurations(a,i,o)}else{r.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return r}},{key:"setDurations",value:function(e,t,r){this.durations={primary:e,playout:t,integrated:r}}},{key:"resolveOffsets",value:function(e,t){var r=this,n=t.main.details,a=n.live?1/0:n.edge,i=0,s=-1;_forEachInstanceProperty(e).call(e,(function(o,l){var c=o.cue.pre,u=o.cue.post,d=c?0:u?a:o.startTime;(r.updateAssetDurations(o),s===d?o.cumulativeDuration=i:(i=0,s=d),!u&&o.snapOptions.in&&(o.resumeAnchor=findFragmentByPTS(null,n.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(r.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));if(!o.appendInPlace)for(var f=l-1;l--;){e[f+1].startTime-e[f].resumeTime<ABUTTING_THRESHOLD_SECONDS&&(e[f].appendInPlace=!1)}var h=isFiniteNumber(o.resumeOffset)?o.resumeOffset:o.duration;i+=h}))}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var r,n,a,i,s=this,o=e.resumeTime,l=e.startTime+e.resumptionOffset;return Math.abs(o-l)>ALIGNED_END_THRESHOLD_SECONDS?(this.log(_concatInstanceProperty(n=_concatInstanceProperty(a='"'.concat(e.identifier,'" resumption ')).call(a,o," not aligned with estimated timeline end ")).call(n,l)),!1):t?!_someInstanceProperty(r=_Object$keys(t)).call(r,(function(r){var n,a,i,l=t[r].details,c=l.edge;if(o>c)return s.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i='"'.concat(e.identifier,'" resumption ')).call(i,o," past ")).call(a,r," playlist end ")).call(n,c)),!0;var u,d,f=findFragmentByPTS(null,l.fragments,o);if(!f)return s.log(_concatInstanceProperty(u=_concatInstanceProperty(d='"'.concat(e.identifier,'" resumption ')).call(d,o," does not align with any fragments in ")).call(u,r," playlist")),!0;var h,p,y,g,v,m,E="audio"===r?.175:0;return!(Math.abs(f.start-o)<ALIGNED_END_THRESHOLD_SECONDS||Math.abs(f.end-o)<ALIGNED_END_THRESHOLD_SECONDS+E)&&(s.log(_concatInstanceProperty(h=_concatInstanceProperty(p=_concatInstanceProperty(y=_concatInstanceProperty(g=_concatInstanceProperty(v=_concatInstanceProperty(m='"'.concat(e.identifier,'" resumption ')).call(m,o," not aligned with ")).call(v,r," fragment bounds (")).call(g,f.start,"-")).call(y,f.end," sn: ")).call(p,f.sn," cc: ")).call(h,f.cc,")")),!0)})):(this.log(_concatInstanceProperty(i='"'.concat(e.identifier,'" resumption ')).call(i,o," can not be aligned with media (none selected)")),!1)}},{key:"updateAssetDurations",value:function(e){var t,r=e.timelineStart,n=0,a=!1,i=!1;_forEachInstanceProperty(t=e.assetList).call(t,(function(e,t){var s=r+n;e.startOffset=n,e.timelineStart=s,a||(a=null===e.duration),i||(i=!!e.error);var o=e.error?0:e.duration||0;n+=o})),e.duration=a&&!i?Math.max(n,e.duration):n}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}]),r}();function segmentToString(e){var t,r;return _concatInstanceProperty(t=_concatInstanceProperty(r="[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ")).call(r,e.start.toFixed(2),"-")).call(t,e.end.toFixed(2),"]")}var AssetListLoader=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.hls=t}return _createClass$1(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,n=this,a=e.assetListUrl;try{r=getInterstitialUrl(a,this.hls.sessionId,e.baseUrl)}catch(t){var i=this.assignAssetListError(e,ErrorDetails.ASSET_LIST_LOAD_ERROR,t,a);return void this.hls.trigger(Events.ERROR,i)}if(t&&!e.cue.pre&&!e.cue.post&&"data:"!==r.protocol){var s=t-e.startTime;s>0&&r.searchParams.set("_HLS_start_offset",""+Math.round(1e3*s)/1e3)}var o=this.hls.config,l=new(0,o.loader)(o),c={responseType:"json",url:r.href},u=o.interstitialAssetListLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(t,r,a,i){var s=t.data,o=null==s?void 0:s.ASSETS;if(_Array$isArray(o))e.assetListResponse=s,n.hls.trigger(Events.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:i});else{var l=n.assignAssetListError(e,ErrorDetails.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),a.url,r,i);n.hls.trigger(Events.ERROR,l)}},onError:function(t,r,a,i){var s,o,l=n.assignAssetListError(e,ErrorDetails.ASSET_LIST_LOAD_ERROR,new Error(_concatInstanceProperty(s=_concatInstanceProperty(o="Error loading X-ASSET-LIST: HTTP status ".concat(t.code," ")).call(o,t.text," (")).call(s,r.url,")")),r.url,i,a);n.hls.trigger(Events.ERROR,l)},onTimeout:function(t,r,a){var i=n.assignAssetListError(e,ErrorDetails.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,a);n.hls.trigger(Events.ERROR,i)}};return l.load(c,d,f),this.hls.trigger(Events.ASSET_LIST_LOADING,{event:e}),l}},{key:"assignAssetListError",value:function(e,t,r,n,a,i){return e.error=r,{type:ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:r,networkDetails:i,stats:a}}}]),e}();function playWithCatch(e){null==e||e.play().catch()}var InterstitialsController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,"interstitials",e.logger)).HlsPlayerClass=void 0,a.hls=void 0,a.assetListLoader=void 0,a.mediaSelection=null,a.altSelection=null,a.media=null,a.detachedData=null,a.requiredTracks=null,a.manager=null,a.playerQueue=[],a.bufferedPos=-1,a.timelinePos=-1,a.schedule=void 0,a.playingItem=null,a.bufferingItem=null,a.waitingItem=null,a.playingAsset=null,a.bufferingAsset=null,a.shouldPlay=!1,a.onPlay=function(){a.shouldPlay=!0},a.onPause=function(){a.shouldPlay=!1},a.onSeeking=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled){var t=e-a.timelinePos;if(!(Math.abs(t)<1/7056e5)){var r=t<=-.01;a.timelinePos=e,a.bufferedPos=e,a.checkBuffer();var n=a.playingItem;if(n)if(r&&e<n.start||e>=n.end){var i,s=a.schedule.findItemIndexAtTime(a.timelinePos);if(!a.isInterstitial(n)&&null!=(i=a.media)&&i.paused&&(a.shouldPlay=!1),!r){var o=a.findItemIndex(n);if(s>o){var l=a.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void a.setSchedulePosition(l)}}a.setSchedulePosition(s)}else{var c=a.playingAsset;if(c){var u=c.timelineStart,d=c.duration||0;(r&&e<u||e>=u+d)&&a.setScheduleToAssetAtTime(e,c)}else if(a.playingLastItem&&a.isInterstitial(n)){var f=n.event.assetList[0];f&&(a.playingItem=null,a.setScheduleToAssetAtTime(e,f))}}}}},a.onTimeupdate=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled&&e>a.timelinePos){e>a.bufferedPos&&a.checkBuffer(),a.timelinePos=e;var t=a.playingItem;if(t&&!a.playingLastItem){if(e>=t.end){a.timelinePos=t.end;var r=a.findItemIndex(t);a.setSchedulePosition(r+1)}var n=a.playingAsset;if(n)e>=n.timelineStart+(n.duration||0)&&a.setScheduleToAssetAtTime(e,n)}}},a.onScheduleUpdate=function(e,t){var r,n,i,s=a.schedule,o=a.playingItem,l=s.events||[],c=s.items||[],u=s.durations,d=_mapInstanceProperty(e).call(e,(function(e){return e.identifier})),f=!(!l.length&&!d.length);f&&(!1===a.hls.config.interstitialAppendInPlace&&_forEachInstanceProperty(l).call(l,(function(e){return e.appendInPlace=!1})),a.log(_concatInstanceProperty(n=_concatInstanceProperty(i="INTERSTITIALS_UPDATED (".concat(l.length,"): ")).call(i,l,"\nSchedule: ")).call(n,_mapInstanceProperty(c).call(c,(function(e){return segmentToString(e)})))));d.length&&a.log("Removed events ".concat(d)),_forEachInstanceProperty(r=a.playerQueue).call(r,(function(e){if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(o){var n,i,s;if(Math.abs(r)>ALIGNED_END_THRESHOLD_SECONDS)a.warn(_concatInstanceProperty(n=_concatInstanceProperty(i=_concatInstanceProperty(s="".concat(o,' ("')).call(s,e.assetId,'" ')).call(i,e.timelineOffset,"->")).call(n,t,")"))}}})),o&&!o.event&&(a.playingItem=a.updateItem(o,a.timelinePos));var h=a.bufferingItem;if(h&&(h.event?a.updateItem(h)||(a.bufferingItem=null,a.clearInterstitial(h.event,null)):a.bufferingItem=a.updateItem(h,a.bufferedPos)),a.waitingItem=a.updateItem(a.waitingItem),_forEachInstanceProperty(e).call(e,(function(e){var t;_forEachInstanceProperty(t=e.assetList).call(t,(function(e){a.clearAssetPlayer(e.identifier,null)}))})),f||t){if(a.hls.trigger(Events.INTERSTITIALS_UPDATED,{events:_sliceInstanceProperty(l).call(l,0),schedule:_sliceInstanceProperty(c).call(c,0),durations:u,removedIds:d}),a.isInterstitial(o)&&_includesInstanceProperty(d).call(d,o.event.identifier))return a.warn('Interstitial "'.concat(o.event.identifier,'" removed while playing')),void a.primaryFallback(o.event);a.checkBuffer()}},a.hls=e,a.HlsPlayerClass=n,a.assetListLoader=new AssetListLoader(e),a.schedule=new InterstitialsSchedule(a.onScheduleUpdate,e.logger),a.registerListeners(),a}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Events.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Events.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(Events.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(Events.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Events.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(Events.MEDIA_ENDED,this.onMediaEnded,this),e.on(Events.ERROR,this.onError,this),e.on(Events.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Events.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Events.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(Events.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(Events.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Events.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(Events.MEDIA_ENDED,this.onMediaEnded,this),e.off(Events.ERROR,this.onError,this),e.off(Events.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;_forEachInstanceProperty(e=this.playerQueue).call(e,(function(e){return e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){var e;_forEachInstanceProperty(e=this.playerQueue).call(e,(function(e){return e.pauseBuffering()}))}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){e.removeEventListener("play",this.onPlay),e.removeEventListener("pause",this.onPause),e.removeEventListener("seeking",this.onSeeking),e.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media;this.removeMediaListeners(r),r.addEventListener("seeking",this.onSeeking),r.addEventListener("timeupdate",this.onTimeupdate),r.addEventListener("play",this.onPlay),r.addEventListener("pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var r=this.playingItem,n=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!n){this.clearScheduleState();var a=this.findItemIndex(r);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.playingItem=this.bufferingItem=this.waitingItem=this.playingAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,n=this.media;if(this.media=null,!r&&(n&&this.removeMediaListeners(n),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.playingAsset=null,this.bufferingAsset=null,this.bufferingItem=null,this.waitingItem=null,this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.manager){if(!this.hls||!this.schedule.events)return null;var e=this,t=function(){return e.bufferingItem||e.waitingItem},r=function(){return e.playingItem||e.waitingItem},n=function(t){return t?e.getAssetPlayer(t.identifier):t},a=function(t,r,a,i,o){if(t){var l=t[r].start,c=t.event;if(c){if("playout"===r||c.timelineOccupancy!==TimelineOccupancy.Point){var u=n(a);(null==u?void 0:u.interstitial)===c&&(l+=u.assetItem.startOffset+u[o])}}else l+=("bufferedPos"===i?s():e[i])-t.start;return l}return 0},i=function(t,r){if(0!==t&&"primary"!==r&&e.schedule.length){var n,a=e.schedule.findItemIndexAtTime(t),i=null==(n=e.schedule.items)?void 0:n[a];if(i)return t+(i[r].start-i.start)}return t},s=function(){var t=e.bufferedPos;return t===Number.MAX_VALUE?o("primary"):t},o=function(t){var r;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:e.schedule.durations[t]},l=function(t,i){var s,o,l,c=r();if(null==c||null==(o=c.event)||!o.restrictions.skip){e.log(_concatInstanceProperty(s="seek to ".concat(t,' "')).call(s,i,'"'));var u=r(),d=e.schedule.findItemIndexAtTime(t,i),f=null==(l=e.schedule.items)?void 0:l[d],h=null==u?void 0:u.event,p=null==h?void 0:h.appendInPlace,y=u&&e.itemsMatch(u,f);if(u&&(p||y)){var g=n(e.playingAsset),v=(null==g?void 0:g.media)||e.hls.media;if(v){var m=t-("primary"===i?v.currentTime:a(u,i,e.playingAsset,"timelinePos","currentTime")),E=v.currentTime+m;if(E>=0&&(!g||p||E<=g.duration))return void(v.currentTime=E)}}if(f){var $=t;if("primary"!==i){var S=t-f[i].start;$=f.start+S}var T=!e.isInterstitial(f);if(e.isInterstitial(u)||!T&&!f.event.appendInPlace){if(u){var I=e.findItemIndex(u);if(d>I){var _=e.schedule.findJumpRestrictedIndex(I+1,d);if(_>I)return void e.setSchedulePosition(_)}var P=0;if(T)e.timelinePos=$;else{var b,A=null==f||null==(b=f.event)?void 0:b.assetList;if(A)for(var R=t-(f[i]||f).start,k=A.length;k--;){var C=A[k];if(C.duration&&R>=C.startOffset&&R<C.startOffset+C.duration){P=k;break}}}e.setSchedulePosition(d,P)}}else{var O=e.hls.media;O&&(O.currentTime=$)}}}};this.manager={get events(){var t,r;return(null==(t=e.schedule)||null==(r=t.events)?void 0:_sliceInstanceProperty(r).call(r,0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:_sliceInstanceProperty(r).call(r,0))||[]},get playerQueue(){var t;return _sliceInstanceProperty(t=e.playerQueue).call(t,0)},get bufferingPlayer(){return e.getBufferingPlayer()},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return e.bufferingItem},get playingAsset(){return e.playingAsset},get playingItem(){return e.playingItem},get bufferingIndex(){var r=t();return e.findItemIndex(r)},get playingIndex(){var t=r();return e.findItemIndex(t)},get waitingIndex(){return e.findItemIndex(e.waitingItem)},primary:{get bufferedEnd(){return s()},get currentTime(){var t=e.timelinePos;return t>0?t:0},get duration(){return o("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0},seekTo:function(e){return l(e,"primary")}},playout:{get bufferedEnd(){return a(t(),"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return a(r(),"playout",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("playout")},get seekableStart(){var t;return i((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"playout")},seekTo:function(e){return l(e,"playout")}},integrated:{get bufferedEnd(){return a(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return a(r(),"integrated",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("integrated")},get seekableStart(){var t;return i((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")},seekTo:function(e){return l(e,"integrated")}},skip:function(){var t=r(),n=null==t?void 0:t.event;if(n&&!n.restrictions.skip){var a=e.findItemIndex(t);if(n.appendInPlace){var i=t.playout.start+t.event.duration;l(i+.001,"playout")}else e.advanceAfterAssetEnded(n,a,1/0)}}}}return this.manager}},{key:"playingLastItem",get:function(){var e,t=this.playingItem;if(!this.playbackStarted||!t)return!1;var r=null==(e=this.schedule)?void 0:e.items;return this.itemsMatch(t,r?r[r.length-1]:null)}},{key:"playbackStarted",get:function(){return null!==this.playingItem}},{key:"currentTime",get:function(){var e,t,r;if(null!==this.mediaSelection){var n=this.waitingItem||this.playingItem;if(!this.isInterstitial(n)||n.event.appendInPlace){var a=this.media;!a&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(a=this.primaryMedia);var i=null==(r=a)?void 0:r.currentTime;if(void 0!==i&&isFiniteNumber(i))return i}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var r=e.interstitial.appendInPlace,n=e.media;if(r&&n===this.primaryMedia){var a;if(!t||this.isInterstitial(t)&&!t.event.appendInPlace)return void(t&&n&&(this.detachedData={media:n}));var i=e.transferMedia();this.log(_concatInstanceProperty(a="transfer MediaSource from ".concat(e," ")).call(a,_JSON$stringify(i))),this.bufferingAsset=null,this.detachedData=i}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}},{key:"transferMediaTo",value:function(e,t){var r,n,a,i,s,o,l=null,c=this.hls,u=e!==c,d=u&&e.interstitial.appendInPlace,f=null==(i=this.detachedData)?void 0:i.mediaSource;if(c.media&&d)l=c.transferMedia(),this.detachedData=l,o="Primary";else if(f){var h=this.getBufferingPlayer();h&&(l=h.transferMedia()),o="".concat(h)}else o="<unknown>";this.log(_concatInstanceProperty(r=_concatInstanceProperty(n="transferring to ".concat(u?e:"Primary","\nMediaSource ")).call(n,_JSON$stringify(l)," from ")).call(r,o)),l||(f?(l=this.detachedData,this.log("using detachedData: MediaSource ".concat(_JSON$stringify(l)))):this.detachedData&&this.hls.media!==t||(this.hls.detachMedia(),this.detachedData={media:t}));var p=l&&"mediaSource"in l&&"closed"!==(null==(s=l.mediaSource)?void 0:s.readyState),y=p&&l?l:t;if(this.log(_concatInstanceProperty(a="".concat(p?"transfering MediaSource":"attaching media"," to ")).call(a,u?e:"Primary")),y===l){var g=u&&e.assetId===this.schedule.assetIdAtEnd;y.overrides={duration:this.schedule.duration,endOfStream:!u||g,cueRemoval:!1}}e.attachMedia(y)}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=e.events;if(t&&!this.playbackDisabled){-1===this.bufferedPos&&(this.bufferedPos=0);var r=this.timelinePos,n=this.waitingItem;if(-1===r){var a=this.hls.startPosition;if(this.timelinePos=a,t.length&&t[0].cue.pre){var i=e.findEventIndex(t[0].identifier);this.setSchedulePosition(i)}else if(a>=0||!this.primaryLive){var s=this.timelinePos=a>0?a:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(n&&!this.playingItem){var l=e.findItemIndex(n);this.setSchedulePosition(l)}}}},{key:"advanceAfterAssetEnded",value:function(e,t,r){var n=r+1;if(e.isAssetPastPlayoutLimit(n)||e.assetList[n].error){var a=this.schedule.items;if(a){var i=t+1;if(i>=a.length)return void this.setSchedulePosition(-1);this.setSchedulePosition(i)}}else this.setSchedulePosition(t,n)}},{key:"setScheduleToAssetAtTime",value:function(e,t){var r=this.schedule,n=t.parentIdentifier,a=r.getEvent(n);if(a){var i=r.findEventIndex(n),s=r.findAssetIndex(a,e);this.setSchedulePosition(i,s)}}},{key:"setSchedulePosition",value:function(e,t){var r,n=this,a=this.schedule.items;if(a&&!this.playbackDisabled){this.log(_concatInstanceProperty(r="setSchedulePosition ".concat(e,", ")).call(r,t));var i=e>=0?a[e]:null,s=this.primaryMedia,o=this.playingItem,l=this.playingLastItem;if(this.isInterstitial(o)){var c,u,d=o.event,f=this.playingAsset,h=null==f?void 0:f.identifier,p=h?this.getAssetPlayer(h):null;if(p&&h&&(!this.eventItemsMatch(o,i)||void 0!==t&&h!==(null==(c=d.assetList)?void 0:c[t].identifier))){var y,g;this.playingAsset=null;var v=d.findAssetIndex(f);this.log(_concatInstanceProperty(y=_concatInstanceProperty(g="INTERSTITIAL_ASSET_ENDED ".concat(v+1,"/")).call(g,d.assetList.length," ")).call(y,eventAssetToString(f))),this.hls.trigger(Events.INTERSTITIAL_ASSET_ENDED,{asset:f,assetListIndex:v,event:d,schedule:_sliceInstanceProperty(a).call(a,0),scheduleIndex:e,player:p}),this.retreiveMediaSource(h,i),p.media&&!this.detachedData&&p.detachMedia(),this.clearAssetPlayer(h,i)}if(!this.eventItemsMatch(o,i))if(this.playingItem=null,this.log(_concatInstanceProperty(u="INTERSTITIAL_ENDED ".concat(d," ")).call(u,segmentToString(o))),d.hasPlayed=!0,this.hls.trigger(Events.INTERSTITIAL_ENDED,{event:d,schedule:_sliceInstanceProperty(a).call(a,0),scheduleIndex:e}),this.clearInterstitial(d,i),d.cue.once){if(this.updateSchedule(),i){var m=this.schedule.findItemIndex(i);this.setSchedulePosition(m,t)}return}}var E=this.playerQueue;if(E.length&&_forEachInstanceProperty(E).call(E,(function(t){var r=t.interstitial,a=n.schedule.findEventIndex(r.identifier);(a<e||a>e+1)&&n.clearInterstitial(r,i)})),this.isInterstitial(i)){this.timelinePos=Math.min(Math.max(this.timelinePos,i.start),i.end);var $=i.event;void 0===t&&(t=this.schedule.findAssetIndex($,this.timelinePos));var S,T=this.waitingItem,I=this.preloadAssets($,t);if(I||this.setBufferingItem(i),!this.eventItemsMatch(i,o||T))this.waitingItem=i,this.log(_concatInstanceProperty(S="INTERSTITIAL_STARTED ".concat(segmentToString(i)," ")).call(S,$.appendInPlace?"append in place":"")),this.hls.trigger(Events.INTERSTITIAL_STARTED,{event:$,schedule:_sliceInstanceProperty(a).call(a,0),scheduleIndex:e});var _=$.assetList.length;if(0===_&&!$.assetListResponse)return void this.log("Waiting for ASSET-LIST to complete loading ".concat($));if($.assetListLoader&&($.assetListLoader.destroy(),$.assetListLoader=void 0),!s)return void this.log("Waiting for attachMedia to start Interstitial ".concat($));this.waitingItem=null,this.playingItem=i;var P,b,A=$.assetList[t];if(!A){var R=a[e+1],k=this.media;return R&&k&&!this.isInterstitial(R)&&k.currentTime<R.start&&(k.currentTime=this.timelinePos=R.start),void this.advanceAfterAssetEnded($,e,t||0)}if(I||(I=this.getAssetPlayer(A.identifier)),null===I||I.destroyed)this.warn(_concatInstanceProperty(P=_concatInstanceProperty(b="asset ".concat(t+1,"/")).call(b,_," player destroyed ")).call(P,$)),I=this.createAssetPlayer($,A,t);if(!this.eventItemsMatch(i,this.bufferingItem)&&$.appendInPlace&&this.isAssetBuffered(A))return;this.startAssetPlayer(I,t,a,e,s),this.shouldPlay&&playWithCatch(I.media)}else null!==i?(this.resumePrimary(i,e,o),this.shouldPlay&&playWithCatch(this.hls.media)):l&&this.isInterstitial(o)&&(this.playingItem=o,o.event.appendInPlace||this.attachPrimary(this.schedule.durations.primary,null))}}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e,t;return null==(e=this.mediaSelection)||null==(t=e.main)?void 0:t.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,r){var n;if(this.playingItem=e,this.playingAsset=null,this.waitingItem=null,this.bufferedToItem(e),this.log("resuming ".concat(segmentToString(e))),null==(n=this.detachedData)||!n.mediaSource){var a=this.timelinePos;(a<e.start||a>=e.end)&&(a=this.getPrimaryResumption(e,t),this.timelinePos=a),this.attachPrimary(a,e)}if(r){var i=this.schedule.items;i&&(this.log("resumed ".concat(segmentToString(e))),this.hls.trigger(Events.INTERSTITIALS_PRIMARY_RESUMED,{schedule:_sliceInstanceProperty(i).call(i,0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var r=e.start;if(this.primaryLive){var n=this.primaryDetails;if(0===t)return this.hls.startPosition;if(n&&(r<n.fragmentStart||r>n.edge))return this.hls.liveSyncPosition||-1}return r}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:BufferHelper.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,r){t?this.setBufferingItem(t):this.bufferingItem=null,this.bufferingAsset=null;var n=this.primaryMedia;if(n){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,n),r&&this.startLoadingPrimaryAt(e,r)),r||(this.timelinePos=e,this.startLoadingPrimaryAt(e,r))}}},{key:"startLoadingPrimaryAt",value:function(e,t){this.hls.loadingEnabled&&this.hls.startLoad(e,t)}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.schedule.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(Events.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],n=_objectSpread2(_objectSpread2({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n),!this.playingItem&&this.schedule.items&&this.checkStart()}}},{key:"onAudioTrackUpdated",value:function(e,t){var r=this.hls.audioTracks[t.id],n=this.mediaSelection;if(n){var a=_objectSpread2(_objectSpread2({},n),{},{audio:r});this.mediaSelection=a}else this.altSelection=_objectSpread2(_objectSpread2({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(n){var a=_objectSpread2(_objectSpread2({},n),{},{subtitles:r});this.mediaSelection=a}else this.altSelection=_objectSpread2(_objectSpread2({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r,n=getBasicSelectionOption(t);_forEachInstanceProperty(r=this.playerQueue).call(r,(function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(n)}))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r,n=getBasicSelectionOption(t);_forEachInstanceProperty(r=this.playerQueue).call(r,(function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(n)}))}},{key:"onBufferCodecs",value:function(e,t){var r=t.tracks;r&&(this.requiredTracks=r)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var r=this.playingItem;if(r&&r!==this.bufferingItem&&!this.isInterstitial(r)){var n=this.timelinePos;this.bufferedPos=n,this.setBufferingItem(r)}}},{key:"onBufferedToEnd",value:function(e){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var r=0;r<t.length;r++){var n=t[r];if(n.cue.post){var a,i=this.schedule.findEventIndex(n.identifier),s=null==(a=this.schedule.items)?void 0:a[i];this.isInterstitial(s)&&this.eventItemsMatch(s,this.bufferingItem)&&this.bufferedToItem(s,0);break}}this.bufferedPos=Number.MAX_VALUE}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var r=this.findItemIndex(t);this.setSchedulePosition(r+1)}}},{key:"updateItem",value:function(e,t){var r=this.schedule.items;return e&&r&&r[this.findItemIndex(e,t)]||null}},{key:"itemsMatch",value:function(e,t){var r,n;return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&(null==(r=e.nextEvent)?void 0:r.identifier)===(null==(n=t.nextEvent)?void 0:n.identifier))}},{key:"eventItemsMatch",value:function(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}},{key:"findItemIndex",value:function(e,t){return e?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(){var e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[])}},{key:"checkBuffer",value:function(){var e=this.schedule.items;if(e){var t=BufferHelper.bufferInfo(this.primaryMedia,this.timelinePos,0);this.updateBufferedPos(t.end,e,0===t.len)}}},{key:"updateBufferedPos",value:function(e,t,r){var n=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var i=this.playingItem,s=this.findItemIndex(i),o=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,c=this.findItemIndex(a),u=Math.min(c+1,t.length-1),d=t[u];if(-1===o&&a&&e>=a.end&&(o=u),u-s>1&&!1===(null==a||null==(l=a.event)?void 0:l.appendInPlace))return;if(this.bufferedPos=e,o>c&&o>s)this.bufferedToItem(d);else{var f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&d.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(d)&&this.preloadAssets(d.event,0)}}else r&&i&&a!==i&&o===s&&this.bufferedToItem(i)}}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,r=this.schedule,n=r.items,a=r.events;if(n&&a&&(!t||r.findItemIndex(t)!==r.findItemIndex(e))){var i,s,o=this.isInterstitial(e),l=this.getBufferingPlayer(),c=l?l.remaining:t?t.end-this.timelinePos:0;if(this.log("buffered to boundary ".concat(segmentToString(e))+(t?" (".concat(c.toFixed(2)," remaining)"):"")),this.bufferingItem=e,this.bufferedPos=e.start,!this.playbackDisabled)if(o)_forEachInstanceProperty(i=this.playerQueue).call(i,(function(e){return e.resumeBuffering()}));else this.hls.resumeBuffering(),_forEachInstanceProperty(s=this.playerQueue).call(s,(function(e){return e.pauseBuffering()}));this.hls.trigger(Events.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:_sliceInstanceProperty(a).call(a,0),schedule:_sliceInstanceProperty(n).call(n,0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}return t}},{key:"bufferedToItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;var n=this.detachedData;if(n)if(n.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}},{key:"bufferedToEvent",value:function(e,t){var r=e.event,n=0===r.assetList.length&&!r.assetListLoader,a=r.cue.once;if(n||!a){var i=this.preloadAssets(r,t);if(null!=i&&i.interstitial.appendInPlace){var s=r.assetList[t],o=this.primaryMedia;s&&o&&this.bufferAssetPlayer(i,o)}}}},{key:"preloadAssets",value:function(e,t){var r=e.assetList.length,n=0===r&&!e.assetListLoader,a=e.cue.once;if(n){var i,s;this.log(_concatInstanceProperty(i=_concatInstanceProperty(s="Load interstitial asset ".concat(t+1,"/")).call(s,r," ")).call(i,e));var o=e.timelineStart;e.appendInPlace&&this.flushFrontBuffer(o);var l=e.assetUrl;if(l)return this.createAsset(e,0,0,o,e.duration,l);var c=0;!this.playingItem&&this.primaryLive&&-1===(c=this.hls.startPosition)&&(c=this.hls.liveSyncPosition||0);var u=this.assetListLoader.loadAssetList(e,c);u&&(e.assetListLoader=u)}else if(!a&&r){for(var d=t;d<r;d++){var f=e.assetList[d],h=this.getAssetPlayerQueueIndex(f.identifier);-1!==h&&!this.playerQueue[h].destroyed||f.error||this.createAssetPlayer(e,f,d)}return this.getAssetPlayer(e.assetList[t].identifier)}return null}},{key:"flushFrontBuffer",value:function(e){var t=this,r=this.requiredTracks;if(r){var n=_Object$keys(r);_forEachInstanceProperty(n).call(n,(function(r){t.hls.trigger(Events.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r})}))}}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}},{key:"createAsset",value:function(e,t,r,n,a,i){var s={parentIdentifier:e.identifier,identifier:generateAssetIdentifier(e,i,t),duration:a,startOffset:r,timelineStart:n,uri:i};return this.createAssetPlayer(e,s,t)}},{key:"createAssetPlayer",value:function(e,t,r){var n=this;this.log("create HLSAssetPlayer for ".concat(eventAssetToString(t)));var a=this.hls,i=a.userConfig,s=i.videoPreference,o=a.levels[a.loadLevel]||a.levels[a.currentLevel];(s||o)&&(s=_extends({},s),o.videoCodec&&(s.videoCodec=o.videoCodec),o.videoRange&&(s.allowedVideoRanges=[o.videoRange]));var l=a.audioTracks[a.audioTrack],c=a.subtitleTracks[a.subtitleTrack],u=0;if(this.primaryLive){var d=this.timelinePos-t.timelineStart;if(d>1){var f=t.duration;f&&d<f&&(u=d)}}var h=_objectSpread2(_objectSpread2({},i),{},{autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:a.sessionId,assetPlayerId:t.identifier,abrEwmaDefaultEstimate:a.bandwidthEstimate,interstitialsController:void 0,startPosition:u,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:l||i.audioPreference,subtitlePreference:c||i.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(h.timelineOffset=t.timelineStart));var p=h.cmcd;null!=p&&p.sessionId&&p.contentId&&(h.cmcd=_extends({},p,{contentId:hash(t.uri)}));var y=new HlsAssetPlayer(this.HlsPlayerClass,h,e,t);this.playerQueue.push(y),e.assetList[r]=t;var g=t.identifier,v=function(a){if(a.live){var i=new Error("Interstitials MUST be VOD assets ".concat(e)),s={fatal:!0,type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,error:i};n.handleAssetItemError(s,e,n.schedule.findEventIndex(e.identifier),r,i.message)}else{var o,l,c=a.edge-a.fragmentStart,u=t.duration;if(null===u||c>u)n.log(_concatInstanceProperty(o=_concatInstanceProperty(l='Interstitial asset "'.concat(g,'" duration change ')).call(l,u," > ")).call(o,c)),t.duration=c,n.updateSchedule()}};y.on(Events.LEVEL_UPDATED,(function(e,t){var r=t.details;return v(r)})),y.on(Events.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return v(r)}));y.on(Events.BUFFER_CODECS,(function e(t,r){var a=n.getAssetPlayer(g);if(a&&r.tracks){a.off(Events.BUFFER_CODECS,e),a.tracks=r.tracks;var i=n.primaryMedia;n.bufferingAsset===a.assetItem&&i&&!a.media&&n.bufferAssetPlayer(a,i)}}));y.on(Events.BUFFERED_TO_END,(function r(a){var i,s=n.getAssetPlayer(g);if(n.log("buffered to end of asset ".concat(s)),s){s.off(Events.BUFFERED_TO_END,r);var o=n.schedule.findEventIndex(e.identifier),l=e.findAssetIndex(t),c=l+1,u=null==(i=n.schedule.items)?void 0:i[o];if(n.isInterstitial(u))if(-1===l||e.isAssetPastPlayoutLimit(c)||e.assetList[c].error){var d,f=null==(d=n.schedule.items)?void 0:d[o+1];f&&n.bufferedToItem(f)}else n.bufferedToItem(u,l+1)}}));var m=function(t){return function(){if(n.getAssetPlayer(g)){n.shouldPlay=!0;var r=n.schedule.findEventIndex(e.identifier);n.advanceAfterAssetEnded(e,r,t)}}};return y.once(Events.MEDIA_ENDED,m(r)),y.once(Events.PLAYOUT_LIMIT_REACHED,m(1/0)),y.on(Events.ERROR,(function(t,a){var i;n.handleAssetItemError(a,e,n.schedule.findEventIndex(e.identifier),r,_concatInstanceProperty(i="Asset player error ".concat(a.error," ")).call(i,e))})),y.on(Events.DESTROYING,(function(){if(n.getAssetPlayer(g)){var t=new Error("Asset player destroyed unexpectedly ".concat(g)),a={fatal:!0,type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};n.handleAssetItemError(a,e,n.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(Events.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:y}),y}},{key:"clearInterstitial",value:function(e,t){var r,n=this;_forEachInstanceProperty(r=e.assetList).call(r,(function(e){n.clearAssetPlayer(e.identifier,t)})),e.appendInPlaceStarted=!1}},{key:"clearAssetPlayer",value:function(e,t){if(null!==t){var r=this.getAssetPlayerQueueIndex(e);if(-1!==r){var n,a;this.log(_concatInstanceProperty(n='clearAssetPlayer "'.concat(e,'" toSegment: ')).call(n,t?segmentToString(t):t));var i=this.playerQueue[r];this.transferMediaFromPlayer(i,t),_spliceInstanceProperty(a=this.playerQueue).call(a,r,1),i.destroy()}}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,r,n,a){var i,s,o=e.interstitial,l=e.assetItem,c=e.assetId,u=o.assetList.length,d=this.playingAsset;(this.playingAsset=l,d&&d.identifier===c)||(d&&(this.clearAssetPlayer(d.identifier,r[n]),delete d.error),this.log(_concatInstanceProperty(i=_concatInstanceProperty(s="INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/")).call(s,u," ")).call(i,e)),this.hls.trigger(Events.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:o,schedule:_sliceInstanceProperty(r).call(r,0),scheduleIndex:n,player:e}));e.media||this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var r,n,a=e.interstitial,i=e.assetItem,s=e.assetId,o=this.schedule.findEventIndex(a.identifier),l=null==(r=this.schedule.items)?void 0:r[o];if(l){this.setBufferingItem(l),this.bufferingAsset=i;var c=this.getBufferingPlayer();if(c!==e){var u=(null==c?void 0:c.tracks)||(null==(n=this.detachedData)?void 0:n.tracks)||this.requiredTracks;if(a.appendInPlace&&i!==this.playingAsset){if(!e.tracks)return;if(u&&!isCompatibleTrackChange(u,e.tracks)){var d,f,h=new Error(_concatInstanceProperty(d=_concatInstanceProperty(f='Asset "'.concat(s,"\" SourceBuffer tracks ('")).call(f,_Object$keys(e.tracks),"') are not compatible with primary content tracks ('")).call(d,_Object$keys(u),"')")),p={fatal:!0,type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},y=a.findAssetIndex(i);return void this.handleAssetItemError(p,a,o,y,h.message)}}this.transferMediaTo(e,t)}}}},{key:"handleAssetItemError",value:function(e,t,r,n,a){var i;if(e.details!==ErrorDetails.BUFFER_STALLED_ERROR){var s=t.assetList[n]||null,o=null;if(s){var l=this.getAssetPlayerQueueIndex(s.identifier);o=this.playerQueue[l]||null}var c=this.schedule.items,u=_extends({},e,{fatal:!1,errorAction:createDoNothingErrorAction(!0),asset:s,assetListIndex:n,event:t,schedule:c,scheduleIndex:r,player:o});if(this.warn("Asset item error: ".concat(e.error)),this.hls.trigger(Events.INTERSTITIAL_ASSET_ERROR,u),e.fatal){var d=new Error(a);s&&(this.playingAsset!==s&&this.clearAssetPlayer(s.identifier,null),s.error=d),_someInstanceProperty(i=t.assetList).call(i,(function(e){return!e.error}))?t.appendInPlace&&(t.error=d):t.error=d,this.primaryFallback(t)}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,r=this.playingItem||this.waitingItem;if(this.updateSchedule(),r){var n,a,i,s;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s='Fallback to primary from event "'.concat(e.identifier,'" start: ')).call(s,t," pos: ")).call(i,this.timelinePos," playing: ")).call(a,r?segmentToString(r):"<none>"," error: ")).call(n,e.error)),e.appendInPlace&&(e.appendInPlace=!1,this.attachPrimary(t,null),this.flushFrontBuffer(t));var o=this.timelinePos;-1===o&&(o=this.hls.startPosition);var l=this.updateItem(r,o);if(!this.itemsMatch(r,l)){var c=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(c)}}else this.checkStart()}},{key:"onAssetListLoaded",value:function(e,t){var r,n=this,a=t.event,i=a.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(i)){var o=a.timelineStart,l=0;_forEachInstanceProperty(s).call(s,(function(e,t){var r=_parseFloat$1(e.DURATION);n.createAsset(a,t,l,o+l,r,e.URI),l+=r})),a.duration=l;var c=this.waitingItem,u=(null==c?void 0:c.event.identifier)===i;this.updateSchedule();var d=null==(r=this.bufferingItem)?void 0:r.event;if(u){var f,h=this.schedule.findEventIndex(i),p=null==(f=this.schedule.items)?void 0:f[h];p&&this.setBufferingItem(p),this.setSchedulePosition(h)}else if((null==d?void 0:d.identifier)===i&&d.appendInPlace){var y=a.assetList[0],g=this.getAssetPlayer(y.identifier),v=this.primaryMedia;y&&g&&v&&this.bufferAssetPlayer(g,v)}}}},{key:"onError",value:function(e,t){switch(t.details){case ErrorDetails.ASSET_LIST_PARSING_ERROR:case ErrorDetails.ASSET_LIST_LOAD_ERROR:case ErrorDetails.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r)}}}]),r}(),TICK_INTERVAL$1=500,SubtitleStreamController=function(e){_inherits(r,BaseStreamController);var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e,n,a,"subtitle-stream-controller",PlaylistLevelType.SUBTITLE)).currentTrackId=-1,i.tracksBuffered=[],i.mainDetails=null,i.registerListeners(),i}return _createClass$1(r,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){_get(_getPrototypeOf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){_get(_getPrototypeOf(r.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e){this.stopLoad(),this.state=State.IDLE,this.setInterval(TICK_INTERVAL$1),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"onManifestLoading",value:function(){_get(_getPrototypeOf(r.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,t){this.tracksBuffered=[],_get(_getPrototypeOf(r.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var r=t.frag,n=t.success;if(isMediaFragment(r)&&(this.fragPrevious=r),this.state=State.IDLE,n){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var i,s=r.start,o=0;o<a.length;o++)if(s>=a[o].start&&s<=a[o].end){i=a[o];break}var l=r.start+r.duration;i?i.end=l:(i={start:s,end:l},a.push(i)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,n=t.endOffset;if(0===r&&n!==Number.POSITIVE_INFINITY){var a,i=n-1;if(i<=0)return;t.endOffsetSubtitles=Math.max(0,i),_forEachInstanceProperty(a=this.tracksBuffered).call(a,(function(e){for(var t=0;t<e.length;)if(e[t].end<=i)e.shift();else{if(!(e[t].start<i))break;e[t].start=i,t++}})),this.fragmentTracker.removeFragmentsInRange(r,i,PlaylistLevelType.SUBTITLE)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===PlaylistLevelType.SUBTITLE&&(t.details===ErrorDetails.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==State.STOPPED&&(this.state=State.IDLE))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,n=t.subtitleTracks;this.levels&&subtitleOptionsIdentical(this.levels,n)?this.levels=_mapInstanceProperty(n).call(n,(function(e){return new Level(e)})):(this.tracksBuffered=[],this.levels=_mapInstanceProperty(n).call(n,(function(e){var t=new Level(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,PlaylistLevelType.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r;if(this.currentTrackId=t.id,null!=(r=this.levels)&&r.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==State.STOPPED&&this.setInterval(TICK_INTERVAL$1)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,n,a,i,s,o,l=this.currentTrackId,c=this.levels,u=t.details,d=t.id;if(c){var f=c[d];if(!(d>=c.length)&&f){this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="Subtitle track ".concat(d," loaded [")).call(i,u.startSN,",")).call(a,u.endSN,"]")).call(n,u.lastPartSn?_concatInstanceProperty(s="[part-".concat(u.lastPartSn,"-")).call(s,u.lastPartIndex,"]"):"",",duration:")).call(r,u.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;if(u.live||null!=(o=f.details)&&o.live){var h=this.mainDetails;if(u.deltaUpdateFailed||!h)return;var p,y=h.fragments[0];if(f.details)0===this.alignPlaylists(u,f.details,null==(p=this.levelLastLoaded)?void 0:p.details)&&y&&addSliding(u,y.start);else u.hasProgramDateTime&&h.hasProgramDateTime?(alignMediaPlaylistByPDT(u,h),u.fragmentStart):y&&addSliding(u,y.start)}if(f.details=u,this.levelLastLoaded=f,d===l)if(this.hls.trigger(Events.SUBTITLE_TRACK_UPDATED,{details:u,id:d,groupId:t.groupId}),this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===State.IDLE)findFragmentByPTS(null,u.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0)}}else this.warn("Subtitle tracks were reset while loading level ".concat(d))}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this,r=e.frag,n=e.payload,a=r.decryptdata,i=this.hls;if(!this.fragContextChanged(r)&&n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&isFullSegmentEncryption(a.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,getAesModeFromFullSegmentMethod(a.method)).catch((function(e){throw i.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();i.trigger(Events.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){var r;t.warn(_concatInstanceProperty(r="".concat(e.name,": ")).call(r,e.message)),t.state=State.IDLE}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===State.IDLE){var e=this.currentTrackId,t=this.levels,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;if(this.waitForLive(r))return;var n=this.config,a=this.getLoadPosition(),i=BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),s=i.end,o=i.len,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;var c=l.fragments,u=c.length,d=l.edge,f=null,h=this.fragPrevious;if(s<d){var p=n.maxFragLookUpTolerance,y=s>d-p?0:p;!(f=findFragmentByPTS(h,c,Math.max(c[0].start,s),y))&&h&&h.start<c[0].start&&(f=c[0])}else f=c[u-1];if(!f)return;if(isMediaFragment(f=this.mapToInitFragWhenRequired(f))){var g=c[f.sn-l.startSN-1];g&&g.cc===f.cc&&this.fragmentTracker.getState(g)===FragmentState.NOT_LOADED&&(f=g)}this.fragmentTracker.getState(f)===FragmentState.NOT_LOADED&&this.loadFragment(f,r,s)}}else this.state=State.IDLE}},{key:"loadFragment",value:function(e,t,n){isMediaFragment(e)?_get(_getPrototypeOf(r.prototype),"loadFragment",this).call(this,e,t,n):this._loadInitSegment(e,t)}},{key:"mediaBufferTimeRanges",get:function(){return new BufferableInstance(this.tracksBuffered[this.currentTrackId]||[])}}]),r}(),BufferableInstance=_createClass$1((function e(t){_classCallCheck$1(this,e),this.buffered=void 0;var r=function(e,r,n){var a,i;if((r>>>=0)>n-1)throw new DOMException(_concatInstanceProperty(a=_concatInstanceProperty(i="Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (")).call(i,r,") is greater than the maximum bound (")).call(a,n,")"));return t[r][e]};this.buffered={get length(){return t.length},end:function(e){return r("end",e,t.length)},start:function(e){return r("start",e,t.length)}}})),specialCea608CharsCodes={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},getCharForByte=function(e){return String.fromCharCode(specialCea608CharsCodes[e]||e)},NR_ROWS=15,NR_COLS=100,rowsLowCh1={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},rowsHighCh1={17:2,18:4,21:6,22:8,23:10,19:13,20:15},rowsLowCh2={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},rowsHighCh2={25:2,26:4,29:6,30:8,31:10,27:13,28:15},backgroundColors=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],CaptionsLogger=function(){function e(){_classCallCheck$1(this,e),this.time=null,this.verboseLevel=0}return _createClass$1(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r,n,a="function"==typeof t?t():t;logger.log(_concatInstanceProperty(r=_concatInstanceProperty(n="".concat(this.time," [")).call(n,e,"] ")).call(r,a))}}}]),e}(),numArrayToHexArray=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},PenState=function(){function e(){_classCallCheck$1(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return _createClass$1(e,[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var n=t[r];e.hasOwnProperty(n)&&(this[n]=e[n])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}]),e}(),StyledUnicodeChar=function(){function e(){_classCallCheck$1(this,e),this.uchar=" ",this.penState=new PenState}return _createClass$1(e,[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}]),e}(),Row=function(){function e(t){_classCallCheck$1(this,e),this.chars=[],this.pos=0,this.currPenState=new PenState,this.cueStartTime=null,this.logger=void 0;for(var r=0;r<NR_COLS;r++)this.chars.push(new StyledUnicodeChar);this.logger=t}return _createClass$1(e,[{key:"equals",value:function(e){for(var t=0;t<NR_COLS;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<NR_COLS;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<NR_COLS;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>NR_COLS&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=NR_COLS)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){var t=this;e>=144&&this.backSpace();var r=getCharForByte(e);this.pos>=NR_COLS?this.logger.log(0,(function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<NR_COLS;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,r=0;r<NR_COLS;r++){var n=this.chars[r].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}]),e}(),CaptionScreen=function(){function e(t){_classCallCheck$1(this,e),this.rows=[],this.currRow=NR_ROWS-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var r=0;r<NR_ROWS;r++)this.rows.push(new Row(t));this.logger=t}return _createClass$1(e,[{key:"reset",value:function(){for(var e=0;e<NR_ROWS;e++)this.rows[e].clear();this.currRow=NR_ROWS-1}},{key:"equals",value:function(e){for(var t=!0,r=0;r<NR_ROWS;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<NR_ROWS;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<NR_ROWS;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,(function(){return"pacData = "+_JSON$stringify(e)}));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<NR_ROWS;r++)this.rows[r].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var i=a.rows[n].cueStartTime,s=this.logger.time;if(null!==i&&null!==s&&i<s)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(a.rows[n+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var c=e.indent,u=Math.max(c-1,0);l.setCursor(e.indent),e.color=l.chars[u].penState.foreground}var d={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(d)}},{key:"setBkgData",value:function(e){this.logger.log(2,(function(){return"bkgData = "+_JSON$stringify(e)})),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){var e,t,r=this;if(null!==this.nrRollUpRows){this.logger.log(1,(function(){return r.getDisplayText()}));var n=this.currRow+1-this.nrRollUpRows,a=_spliceInstanceProperty(e=this.rows).call(e,n,1)[0];a.clear(),_spliceInstanceProperty(t=this.rows).call(t,this.currRow,0,a),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],r="",n=-1,a=0;a<NR_ROWS;a++){var i=this.rows[a].getTextString();i&&(n=a+1,e?t.push("Row "+n+": '"+i+"'"):t.push(_trimInstanceProperty(i).call(i)))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),Cea608Channel=function(){function e(t,r,n){_classCallCheck$1(this,e),this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new CaptionScreen(n),this.nonDisplayedMemory=new CaptionScreen(n),this.lastOutputScreen=new CaptionScreen(n),this.currRollUpRow=this.displayedMemory.rows[NR_ROWS-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}return _createClass$1(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[NR_ROWS-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return n+": "+t.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(function(){return"DISP: "+e.displayedMemory.getDisplayText()}))}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+_JSON$stringify(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}]),e}(),Cea608Parser=function(){function e(t,r,n){_classCallCheck$1(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory=createCmdHistory(),this.logger=void 0;var a=this.logger=new CaptionsLogger;this.channels=[null,new Cea608Channel(t,r,a),new Cea608Channel(t+1,n,a)]}return _createClass$1(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r=this;this.logger.time=e;for(var n=function(e){var n=127&t[e],a=127&t[e+1],i=!1,s=null;if(0===n&&0===a)return"continue";r.logger.log(3,(function(){return"["+numArrayToHexArray([t[e],t[e+1]])+"] -> ("+numArrayToHexArray([n,a])+")"}));var o=r.cmdHistory;if(n>=16&&n<=31){if(hasCmdRepeated(n,a,o))return setLastCmd(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+numArrayToHexArray([n,a])+") is dropped"})),"continue";setLastCmd(n,a,r.cmdHistory),(i=r.parseCmd(n,a))||(i=r.parseMidrow(n,a)),i||(i=r.parsePAC(n,a)),i||(i=r.parseBackgroundAttributes(n,a))}else setLastCmd(null,null,o);if(!i&&(s=r.parseChars(n,a))){var l=r.currentChannel;if(l&&l>0)r.channels[l].insertChars(s);else r.logger.log(2,"No channel found yet. TEXT-MODE?")}i||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+numArrayToHexArray([n,a])+" orig: "+numArrayToHexArray([t[e],t[e+1]])}))},a=0;a<t.length;a+=2)n(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var r=20===e||21===e||23===e?1:2,n=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.currentChannel=r,!0}},{key:"parseMidrow",value:function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(t),this.logger.log(3,(function(){return"MIDROW ("+numArrayToHexArray([e,t])+")"})),!0)}return!1}},{key:"parsePAC",value:function(e,t){var r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var n=e<=23?1:2;r=t>=64&&t<=95?1===n?rowsLowCh1[e]:rowsLowCh2[e]:1===n?rowsHighCh1[e]:rowsHighCh2[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,t)),this.currentChannel=n,!0)}},{key:"interpretPAC",value:function(e,t){var r,n={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,n.underline=1==(1&r),r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n}},{key:"parseChars",value:function(e,t){var r,n,a=null,i=null;(e>=25?(r=2,i=e-8):(r=1,i=e),i>=17&&i<=19)?(n=17===i?t+80:18===i?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+getCharForByte(n)+"' in channel "+r})),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,(function(){return"Char codes = "+numArrayToHexArray(a).join(",")})),a}},{key:"parseBackgroundAttributes",value:function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(r=Math.floor((t-32)/2),n.background=backgroundColors[r],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),!0}},{key:"reset",value:function(){for(var e=0;e<_Object$keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}setLastCmd(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}}}]),e}();function setLastCmd(e,t,r){r.a=e,r.b=t}function hasCmdRepeated(e,t,r){return r.a===e&&r.b===t}function createCmdHistory(){return{a:null,b:null}}var VTTCue=function(){if(null!=optionalSelf&&optionalSelf.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!_Array$isArray(e))return!1;var r=t.toLowerCase();return!!~_indexOfInstanceProperty(e).call(e,r)&&r}function n(e){return r(t,e)}function a(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var s in i)e[s]=i[s]}return e}function i(t,i,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var c="",u=!1,d=t,f=i,h=s,p=null,y="",g=!0,v="auto",m="start",E=50,$="middle",S=50,T="middle";_Object$defineProperty(o,"id",a({},l,{get:function(){return c},set:function(e){c=""+e}})),_Object$defineProperty(o,"pauseOnExit",a({},l,{get:function(){return u},set:function(e){u=!!e}})),_Object$defineProperty(o,"startTime",a({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"endTime",a({},l,{get:function(){return f},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");f=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"text",a({},l,{get:function(){return h},set:function(e){h=""+e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"region",a({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"vertical",a({},l,{get:function(){return y},set:function(t){var n=function(t){return r(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");y=n,this.hasBeenReset=!0}})),_Object$defineProperty(o,"snapToLines",a({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"line",a({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"lineAlign",a({},l,{get:function(){return m},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");m=t,this.hasBeenReset=!0}})),_Object$defineProperty(o,"position",a({},l,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"positionAlign",a({},l,{get:function(){return $},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");$=t,this.hasBeenReset=!0}})),_Object$defineProperty(o,"size",a({},l,{get:function(){return S},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"align",a({},l,{get:function(){return T},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");T=t,this.hasBeenReset=!0}})),o.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),StringDecoder=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}]),e}();function parseTimeStamp(e){function t(e,t,r,n){return 3600*(0|e)+60*(0|t)+(0|r)+_parseFloat$1(n||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?_parseFloat$1(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var Settings=function(){function e(){_classCallCheck$1(this,e),this.values=_Object$create(null)}return _createClass$1(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(_valuesInstanceProperty(this)[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?_valuesInstanceProperty(this)[e]:t[r]:this.has(e)?_valuesInstanceProperty(this)[e]:t}},{key:"has",value:function(e){return e in _valuesInstanceProperty(this)}},{key:"alt",value:function(e,t,r){for(var n=0;n<r.length;++n)if(t===r[n]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,_parseInt$1(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=_parseFloat$1(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function parseOptions(e,t,r,n){var a=n?e.split(n):[e];for(var i in a)if("string"==typeof a[i]){var s=a[i].split(r);if(2===s.length)t(s[0],s[1])}}var defaults=new VTTCue(0,0,""),center="middle"===defaults.align?"middle":"center";function parseCue(e,t,r){var n=e;function a(){var t=parseTimeStamp(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function i(){e=e.replace(/^\s+/,"")}if(i(),t.startTime=a(),i(),"--\x3e"!==_sliceInstanceProperty(e).call(e,0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=_sliceInstanceProperty(e).call(e,3),i(),t.endTime=a(),i(),function(e,t){var n=new Settings;parseOptions(e,(function(e,t){var a;switch(e){case"region":for(var i=r.length-1;i>=0;i--)if(r[i].id===t){n.set(e,r[i].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),n.integer(e,a[0]),n.percent(e,a[0])&&n.set("snapToLines",!1),n.alt(e,a[0],["auto"]),2===a.length&&n.alt("lineAlign",a[1],["start",center,"end"]);break;case"position":a=t.split(","),n.percent(e,a[0]),2===a.length&&n.alt("positionAlign",a[1],["start",center,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",center,"end","left","right"])}}),/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var a=n.get("line","auto");"auto"===a&&-1===defaults.line&&(a=-1),t.line=a,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",center);var i=n.get("position","auto");"auto"===i&&50===defaults.position&&(i="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=i}(e,t)}function fixLineBreaks(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var VTTParser=function(){function e(){_classCallCheck$1(this,e),this.state="INITIAL",this.buffer="",this.decoder=new StringDecoder,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return _createClass$1(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=fixLineBreaks(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var n=_sliceInstanceProperty(e).call(e,0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=_sliceInstanceProperty(e).call(e,r),n}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(n=r()).match(/^()?WEBVTT([ \t].*)?$/);if(null==a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var i=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(i?i=!1:n=r(),t.state){case"HEADER":/:/.test(n)?parseOptions(n,(function(e,t){}),/:/):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new VTTCue(0,0,""),t.state="CUE",-1===_indexOfInstanceProperty(n).call(n,"--\x3e")){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{parseCue(n,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==_indexOfInstanceProperty(n).call(n,"--\x3e");if(!n||s&&(i=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=n;continue;case"BADCUE":n||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}]),e}(),LINEBREAKS=/\r\n|\n\r|\n|\r/g,startsWith2=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return _sliceInstanceProperty(e).call(e,r,r+t.length)===t},cueString2millis=function(e){var t=_parseInt$1(_sliceInstanceProperty(e).call(e,-3)),r=_parseInt$1(_sliceInstanceProperty(e).call(e,-6,-4)),n=_parseInt$1(_sliceInstanceProperty(e).call(e,-9,-7)),a=e.length>9?_parseInt$1(e.substring(0,_indexOfInstanceProperty(e).call(e,":"))):0;if(!(isFiniteNumber(t)&&isFiniteNumber(r)&&isFiniteNumber(n)&&isFiniteNumber(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*n,t+=36e5*a};function generateCueId(e,t,r){return hash(e.toString())+hash(t.toString())+hash(r)}var calculateOffset=function(e,t,r){var n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!=(i=a)&&i.new;){var i;e.ccOffset+=n.start-a.start,n.new=!1,a=e[(n=a).prevCC]}e.presentationOffset=r};function parseWebVTT(e,t,r,n,a,i,s){var o,l,c=new VTTParser,u=_trimInstanceProperty(o=utf8ArrayToStr(new Uint8Array(e))).call(o).replace(LINEBREAKS,"\n").split("\n"),d=[],f=t?toMpegTsClockFromTimescale(t.baseTime,t.timescale):0,h="00:00.000",p=0,y=0,g=!0;c.oncue=function(e){var i,s=r[n],o=r.ccOffset,c=(p-f)/9e4;if(null!=s&&s.new&&(void 0!==y?o=r.ccOffset=s.start:calculateOffset(r,n,c)),c){if(!t)return void(l=new Error("Missing initPTS for VTT MPEGTS"));o=c-r.presentationOffset}var u=e.endTime-e.startTime,h=normalizePts(9e4*(e.startTime+o-y),9e4*a)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+u,0);var g=_trimInstanceProperty(i=e.text).call(i);e.text=decodeURIComponent(encodeURIComponent(g)),e.id||(e.id=generateCueId(e.startTime,e.endTime,g)),e.endTime>0&&d.push(e)},c.onparsingerror=function(e){l=e},c.onflush=function(){l?s(l):i(d)},_forEachInstanceProperty(u).call(u,(function(e){if(g){if(startsWith2(e,"X-TIMESTAMP-MAP=")){var t;g=!1,_forEachInstanceProperty(t=_sliceInstanceProperty(e).call(e,16).split(",")).call(t,(function(e){startsWith2(e,"LOCAL:")?h=_sliceInstanceProperty(e).call(e,6):startsWith2(e,"MPEGTS:")&&(p=_parseInt$1(_sliceInstanceProperty(e).call(e,7)))}));try{y=cueString2millis(h)/1e3}catch(e){l=e}return}""===e&&(g=!1)}c.parse(e+"\n")})),c.flush()}var IMSC1_CODEC="stpp.ttml.im1t",HMSF_REGEX=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,TIME_UNIT_REGEX=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,textAlignToLineAlign={left:"start",center:"center",right:"end",start:"start",end:"end"};function parseIMSC1(e,t,r,n){var a=findBox(new Uint8Array(e),["mdat"]);if(0!==a.length){var i=_mapInstanceProperty(a).call(a,(function(e){return utf8ArrayToStr(e)})),s=toTimescaleFromScale(t.baseTime,1,t.timescale);try{_forEachInstanceProperty(i).call(i,(function(e){return r(parseTTML(e,s))}))}catch(e){n(e)}}else n(new Error("Could not parse IMSC1 mdat"))}function parseTTML(e,t){var r,n,a=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!a)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=_reduceInstanceProperty(r=_Object$keys(i)).call(r,(function(e,t){return e[t]=a.getAttribute("ttp:".concat(t))||i[t],e}),{}),o="preserve"!==a.getAttribute("xml:space"),l=collectionToDictionary(getElementCollection(a,"styling","style")),c=collectionToDictionary(getElementCollection(a,"layout","region")),u=getElementCollection(a,"body","[begin]");return _filterInstanceProperty(n=_mapInstanceProperty([]).call(u,(function(e){var r=getTextContent(e,o);if(!r||!e.hasAttribute("begin"))return null;var n=parseTtmlTime(e.getAttribute("begin"),s),a=parseTtmlTime(e.getAttribute("dur"),s),i=parseTtmlTime(e.getAttribute("end"),s);if(null===n)throw timestampParsingError(e);if(null===i){if(null===a)throw timestampParsingError(e);i=n+a}var u=new VTTCue(n-t,i-t,r);u.id=generateCueId(u.startTime,u.endTime,u.text);var d=getTtmlStyles(c[e.getAttribute("region")],l[e.getAttribute("style")],l),f=d.textAlign;if(f){var h=textAlignToLineAlign[f];h&&(u.lineAlign=h),u.align=f}return _extends(u,d),u}))).call(n,(function(e){return null!==e}))}function getElementCollection(e,t,r){var n=e.getElementsByTagName(t)[0];return n?_sliceInstanceProperty([]).call(n.querySelectorAll(r)):[]}function collectionToDictionary(e){return _reduceInstanceProperty(e).call(e,(function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function getTextContent(e,t){var r;return _reduceInstanceProperty(r=_sliceInstanceProperty([]).call(e.childNodes)).call(r,(function(e,r,n){var a,i;return"br"===r.nodeName&&n?e+"\n":null!=(a=r.childNodes)&&a.length?getTextContent(r,t):t?e+_trimInstanceProperty(i=r.textContent).call(i).replace(/\s+/g," "):e+r.textContent}),"")}function getTtmlStyles(e,t,r){var n="http://www.w3.org/ns/ttml#styling",a=null,i=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(a=r[s]),_reduceInstanceProperty(i).call(i,(function(r,i){var s=getAttributeNS(t,n,i)||getAttributeNS(e,n,i)||getAttributeNS(a,n,i);return s&&(r[i]=s),r}),{})}function getAttributeNS(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function timestampParsingError(e){return new Error("Could not parse ttml timestamp ".concat(e))}function parseTtmlTime(e,t){if(!e)return null;var r=parseTimeStamp(e);return null===r&&(HMSF_REGEX.test(e)?r=parseHoursMinutesSecondsFrames(e,t):TIME_UNIT_REGEX.test(e)&&(r=parseTimeUnits(e,t))),r}function parseHoursMinutesSecondsFrames(e,t){var r=HMSF_REGEX.exec(e),n=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+n/t.frameRate}function parseTimeUnits(e,t){var r=TIME_UNIT_REGEX.exec(e),n=Number(r[1]);switch(r[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}var OutputFilter=function(){function e(t,r){_classCallCheck$1(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=r}return _createClass$1(e,[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}]),e}(),TimelineController=function(){function e(t){_classCallCheck$1(this,e),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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=newVTTCCs(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},t.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Events.FRAG_LOADING,this.onFragLoading,this),t.on(Events.FRAG_LOADED,this.onFragLoaded,this),t.on(Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}return _createClass$1(e,[{key:"destroy",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Events.FRAG_LOADING,this.onFragLoading,this),e.off(Events.FRAG_LOADED,this.onFragLoaded,this),e.off(Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new OutputFilter(this,"textTrack1"),t=new OutputFilter(this,"textTrack2"),r=new OutputFilter(this,"textTrack3"),n=new OutputFilter(this,"textTrack4");this.cea608Parser1=new Cea608Parser(1,e,t),this.cea608Parser2=new Cea608Parser(3,r,n)}},{key:"addCues",value:function(e,t,r,n,a){for(var i=!1,s=a.length;s--;){var o=a[s],l=intersection3(o[0],o[1],t,r);if(l>=0&&(o[0]=Math.min(o[0],t),o[1]=Math.max(o[1],r),i=!0,l/(r-t)>.5))return}if(i||a.push([t,r]),this.config.renderTextTracksNatively){var c=this.captionsTracks[e];this.Cues.newCue(c,t,r,n)}else{var u=this.Cues.newCue(null,t,r,n);this.hls.trigger(Events.CUES_PARSED,{type:"captions",cues:u,track:e})}}},{key:"onInitPtsFound",value:function(e,t){var r=this,n=t.frag,a=t.id,i=t.initPTS,s=t.timescale,o=this.unparsedVttFrags;a===PlaylistLevelType.MAIN&&(this.initPTS[n.cc]={baseTime:i,timescale:s}),o.length&&(this.unparsedVttFrags=[],_forEachInstanceProperty(o).call(o,(function(e){r.onFragLoaded(Events.FRAG_LOADED,e)})))}},{key:"getExistingTrack",value:function(e,t){var r=this.media;if(r)for(var n=0;n<r.textTracks.length;n++){var a=r.textTracks[n];if(canReuseVttTextTrack(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound",attrs:{}}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,n=this.media,a=t[e],i=a.label,s=a.languageCode,o=this.getExistingTrack(i,s);if(o)r[e]=o,clearCurrentCues(r[e]),sendAddTrackEvent(r[e],n);else{var l=this.createTextTrack("captions",i,s);l&&(l[e]=!0,r[e]=l)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}}},{key:"createTextTrack",value:function(e,t,r){var n=this.media;if(n)return n.addTextTrack(e,t,r)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var r,n=!!t.transferMedia;if(this.media=null,!n){var a=this.captionsTracks;_forEachInstanceProperty(r=_Object$keys(a)).call(r,(function(e){clearCurrentCues(a[e]),delete a[e]})),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=newVTTCCs(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)clearCurrentCues(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,n=t.subtitleTracks||[],a=_someInstanceProperty(n).call(n,(function(e){return e.textCodec===IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(subtitleOptionsIdentical(this.tracks,n))return void(this.tracks=n);if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){var i,s=this.media,o=s?filterSubtitleTracks(s.textTracks):null;if(_forEachInstanceProperty(i=this.tracks).call(i,(function(e,t){var n;if(o){for(var a=null,i=0;i<o.length;i++)if(o[i]&&canReuseVttTextTrack(o[i],e)){a=o[i],o[i]=null;break}a&&(n=a)}if(n)clearCurrentCues(n);else{var s=captionsOrSubtitlesFromCharacteristics(e);(n=r.createTextTrack(s,e.name,e.lang))&&(n.mode="disabled")}n&&r.textTracks.push(n)})),null!=o&&o.length){var l,c=_mapInstanceProperty(l=_filterInstanceProperty(o).call(o,(function(e){return null!==e}))).call(l,(function(e){return e.label}));c.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(c.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){var u,d=_mapInstanceProperty(u=this.tracks).call(u,(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}}},{key:"onManifestLoaded",value:function(e,t){var r,n=this;this.config.enableCEA708Captions&&t.captions&&_forEachInstanceProperty(r=t.captions).call(r,(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack".concat(t[1]),a=n.captionsProperties[r];a&&(a.label=e.name,e.lang&&(a.languageCode=e.lang),a.media=e)}}))}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===PlaylistLevelType.MAIN){var r,n,a=this.cea608Parser1,i=this.cea608Parser2,s=this.lastSn,o=t.frag,l=o.cc,c=o.sn,u=null!=(r=null==(n=t.part)?void 0:n.index)?r:-1;a&&i&&(c!==s+1||c===s&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(a.reset(),i.reset()),this.lastCc=l,this.lastSn=c,this.lastPartIndex=u}}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,n=t.payload;if(r.type===PlaylistLevelType.SUBTITLE)if(n.byteLength){var a=r.decryptdata,i="stats"in t;if(null==a||!a.encrypted||i){var s=this.tracks[r.level],o=this.vttCCs;o[r.cc]||(o[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),s&&s.textCodec===IMSC1_CODEC?this._parseIMSC1(r,n):this._parseVTTs(t)}}else this.hls.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var r=this,n=this.hls;parseIMSC1(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),n.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){n.logger.log("Failed to parse IMSC1: ".concat(t)),n.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}},{key:"_parseVTTs",value:function(e){var t,r=this,n=e.frag,a=e.payload,i=this.initPTS,s=this.unparsedVttFrags,o=i.length-1;if(i[n.cc]||-1!==o){var l=this.hls;parseWebVTT(null!=(t=n.initSegment)&&t.data?appendUint8Array(n.initSegment.data,new Uint8Array(a)).buffer:a,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,(function(e){r._appendCues(e,n.level),l.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})}),(function(t){var i="Missing initPTS for VTT MPEGTS"===t.message;i?s.push(e):r._fallbackToIMSC1(n,a),l.logger.log("Failed to parse VTT cue: ".concat(t)),i&&o>n.cc||l.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})}))}else s.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var r=this,n=this.tracks[e.level];n.textCodec||parseIMSC1(t,this.initPTS[e.cc],(function(){n.textCodec=IMSC1_CODEC,r._parseIMSC1(e,t)}),(function(){n.textCodec="wvtt"}))}},{key:"_appendCues",value:function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||"disabled"===n.mode)return;_forEachInstanceProperty(e).call(e,(function(e){return addCueToTrack(n,e)}))}else{var a=this.tracks[t];if(!a)return;var i=a.default?"default":"subtitles"+t;r.trigger(Events.CUES_PARSED,{type:"subtitles",cues:e,track:i})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===PlaylistLevelType.SUBTITLE&&this.onFragLoaded(Events.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var r=t.frag,n=t.samples;if(r.type!==PlaylistLevelType.MAIN||"NONE"!==this.closedCaptionsForLevel(r))for(var a=0;a<n.length;a++){var i=n[a].bytes;if(i){this.cea608Parser1||this.initCea608Parsers();var s=this.extractCea608Data(i);this.cea608Parser1.addData(n[a].pts,s[0]),this.cea608Parser2.addData(n[a].pts,s[1])}}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,n=t.endOffset,a=t.endOffsetSubtitles,i=t.type,s=this.media;if(s&&!(s.currentTime<n)){if(!i||"video"===i){var o,l=this.captionsTracks;_forEachInstanceProperty(o=_Object$keys(l)).call(o,(function(e){return removeCuesInRange(l[e],r,n)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==a){var c,u=this.textTracks;_forEachInstanceProperty(c=_Object$keys(u)).call(c,(function(e){return removeCuesInRange(u[e],r,a)}))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],r=31&e[0],n=2,a=0;a<r;a++){var i=e[n++],s=127&e[n++],o=127&e[n++];if(0!==s||0!==o)if(0!=(4&i)){var l=3&i;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}();function captionsOrSubtitlesFromCharacteristics(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function canReuseVttTextTrack(e,t){return!!e&&e.kind===captionsOrSubtitlesFromCharacteristics(t)&&subtitleTrackMatchesTextTrack(t,e)}function intersection3(e,t,r,n){return Math.min(t,n)-Math.max(e,r)}function newVTTCCs(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var WHITESPACE_CHAR=/\s/,Cues={newCue:function(e,t,r,n){for(var a,i,s,o,l,c=[],u=self.VTTCue||self.TextTrackCue,d=0;d<n.rows.length;d++)if(s=!0,o=0,l="",!(a=n.rows[d]).isEmpty()){for(var f,h=0;h<a.chars.length;h++)WHITESPACE_CHAR.test(a.chars[h].uchar)&&s?o++:(l+=a.chars[h].uchar,s=!1);a.cueStartTime=t,t===r&&(r+=1e-4),o>=16?o--:o++;var p=fixLineBreaks(_trimInstanceProperty(l).call(l)),y=generateCueId(t,r,p);null!=e&&null!=(f=e.cues)&&f.getCueById(y)||((i=new u(t,r,p)).id=y,i.line=d+1,i.align="left",i.position=10+Math.min(80,10*Math.floor(8*o/32)),c.push(i))}return e&&c.length&&(_sortInstanceProperty(c).call(c,(function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),_forEachInstanceProperty(c).call(c,(function(t){return addCueToTrack(e,t)}))),c}};function fetchSupported(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var BYTERANGE=/(\d+)-(\d+)\/(\d+)/,FetchLoader=function(){function e(t){_classCallCheck$1(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||getRequest,this.controller=new self.AbortController,this.stats=new LoadStats}return _createClass$1(e,[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,r){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var i=getRequestParameters(e,this.controller.signal),s=r.onProgress,o="arraybuffer"===e.responseType,l=o?"byteLength":"length",c=t.loadPolicy,u=c.maxTimeToFirstByteMs,d=c.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=u&&isFiniteNumber(u)?u:d,this.requestTimeout=_setTimeout((function(){n.abortInternal(),r.onTimeout(a,e,n.response)}),t.timeout),(isPromise(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(i){n.response=n.loader=i;var l=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(n.requestTimeout),t.timeout=d,n.requestTimeout=_setTimeout((function(){n.abortInternal(),r.onTimeout(a,e,n.response)}),d-(l-a.loading.start)),!i.ok){var c=i.status,u=i.statusText;throw new FetchError(u||"fetch, bad network response",c,i)}return a.loading.first=l,a.total=getContentLength(i.headers)||a.total,s&&isFiniteNumber(t.highWaterMark)?n.loadProgressively(i,a,e,t.highWaterMark,s):o?i.arrayBuffer():"json"===e.responseType?i.json():i.text()})).then((function(i){var o=n.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var c=i[l];c&&(a.loaded=a.total=c);var u={url:o.url,data:i,code:o.status};s&&!isFiniteNumber(t.highWaterMark)&&s(a,e,i,o),r.onSuccess(u,a,e,o)})).catch((function(t){if(self.clearTimeout(n.requestTimeout),!a.aborted){var i=t&&t.code||0,s=t?t.message:null;r.onError({code:i,text:s},e,t?t.details:null,a)}}))}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?_parseFloat$1(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4?arguments[4]:void 0,i=new ChunkCache,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return i.dataLength&&a(t,r,i.flush().buffer,e),_Promise.resolve(new ArrayBuffer(0));var l=s.value,c=l.length;return t.loaded+=c,c<n||i.dataLength?(i.push(l),i.dataLength>=n&&a(t,r,i.flush().buffer,e)):a(t,r,l.buffer,e),o()})).catch((function(){return _Promise.reject()}))}()}}]),e}();function getRequestParameters(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(_extends({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}function getByteRangeLength(e){var t=BYTERANGE.exec(e);if(t)return _parseInt$1(t[2])-_parseInt$1(t[1])+1}function getContentLength(e){var t=e.get("Content-Range");if(t){var r=getByteRangeLength(t);if(isFiniteNumber(r))return r}var n=e.get("Content-Length");if(n)return _parseInt$1(n)}function getRequest(e,t){return new self.Request(e.url,t)}var FetchError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e)).code=void 0,i.details=void 0,i.code=n,i.details=a,i}return _createClass$1(r)}(),AGE_HEADER_LINE_REGEX=/^age:\s*[\d.]+\s*$/im,XhrLoader=function(){function e(t){_classCallCheck$1(this,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=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new LoadStats,this.retryDelay=0}return _createClass$1(e,[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,r){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=t,this.callbacks=r,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this,t=this.config,r=this.context;if(t&&r){var n=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var i=this.xhrSetup;i?_Promise.resolve().then((function(){if(e.loader===n&&!e.stats.aborted)return i(n,r.url)})).catch((function(t){if(e.loader===n&&!e.stats.aborted)return n.open("GET",r.url,!0),i(n,r.url)})).then((function(){e.loader!==n||e.stats.aborted||e.openAndSendXhr(n,r,t)})).catch((function(t){e.callbacks.onError({code:n.status,text:t.message},r,n,a)})):this.openAndSendXhr(n,r,t)}}},{key:"openAndSendXhr",value:function(e,t,r){var n,a,i;e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,c=o.maxLoadTimeMs;if(s)for(var u in s)e.setRequestHeader(u,s[u]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=_bindInstanceProperty(n=this.readystatechange).call(n,this),e.onprogress=_bindInstanceProperty(a=this.loadprogress).call(a,this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&isFiniteNumber(l)?l:c,this.requestTimeout=_setTimeout(_bindInstanceProperty(i=this.loadtimeout).call(i,this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!r.aborted&&n>=2){var i;if(0===r.loading.first)if(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=_setTimeout(_bindInstanceProperty(i=this.loadtimeout).call(i,this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start));if(4===n){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var s=t.status,o="text"===t.responseType?t.responseText:null;if(s>=200&&s<300){var l=null!=o?o:t.response;if(null!=l){r.loading.end=Math.max(self.performance.now(),r.loading.first);var c="arraybuffer"===t.responseType?l.byteLength:l.length;if(r.loaded=r.total=c,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,e,l,t),!this.callbacks)return;var d={url:t.responseURL,data:l,code:s};return void this.callbacks.onSuccess(d,r,e,t)}}var f,h=a.loadPolicy.errorRetry;if(shouldRetry(h,r.retry,!1,{url:e.url,data:void 0,code:s}))this.retry(h);else logger.error(_concatInstanceProperty(f="".concat(s," while loading ")).call(f,e.url)),this.callbacks.onError({code:s,text:t.statusText},e,t,r)}}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(shouldRetry(e,this.stats.retry,!0))this.retry(e);else{var t;logger.warn("timeout while loading ".concat(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t,r,n,a,i,s=this.context,o=this.stats;this.retryDelay=getRetryDelay(e,o.retry),o.retry++,logger.warn(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="".concat(status?"HTTP Status "+status:"Timeout"," while loading ")).call(a,null==s?void 0:s.url,", retrying ")).call(n,o.retry,"/")).call(r,e.maxNumRetry," in ")).call(t,this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=_setTimeout(_bindInstanceProperty(i=this.loadInternal).call(i,this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&AGE_HEADER_LINE_REGEX.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?_parseFloat$1(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp("^".concat(e,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}]),e}(),defaultLoadPolicy={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},hlsDefaultConfig=_objectSpread2(_objectSpread2({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:XhrLoader,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:AbrController,bufferController:BufferController,capLevelController:CapLevelController,errorController:ErrorController,fpsController:FPSController,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:_requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,certLoadPolicy:{default:defaultLoadPolicy},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},timelineConfig()),{},{subtitleStreamController:SubtitleStreamController,subtitleTrackController:SubtitleTrackController,timelineController:TimelineController,audioStreamController:AudioStreamController,audioTrackController:AudioTrackController,emeController:EMEController,cmcdController:CMCDController,contentSteeringController:ContentSteeringController,interstitialsController:InterstitialsController});function timelineConfig(){return{cueHandler:Cues,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function mergeConfig(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=deepCpy(e),a=["manifest","level","frag"],i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return _forEachInstanceProperty(a).call(a,(function(e){var a,s,o="".concat("level"===e?"playlist":e,"LoadPolicy"),l=void 0===t[o],c=[];(_forEachInstanceProperty(i).call(i,(function(r){var a,i=_concatInstanceProperty(a="".concat(e,"Loading")).call(a,r),s=t[i];if(void 0!==s&&l){c.push(i);var u=n[o].default;switch(t[o]={default:u},r){case"TimeOut":u.maxLoadTimeMs=s,u.maxTimeToFirstByteMs=s;break;case"MaxRetry":u.errorRetry.maxNumRetry=s,u.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":u.errorRetry.retryDelayMs=s,u.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=s,u.timeoutRetry.maxRetryDelayMs=s}}})),c.length)&&r.warn(_concatInstanceProperty(a=_concatInstanceProperty(s='hls.js config: "'.concat(c.join('", "'),'" setting(s) are deprecated, use "')).call(s,o,'": ')).call(a,_JSON$stringify(t[o])))})),_objectSpread2(_objectSpread2({},n),t)}function deepCpy(e){var t;return e&&"object"===_typeof$1(e)?_Array$isArray(e)?_mapInstanceProperty(e).call(e,deepCpy):_reduceInstanceProperty(t=_Object$keys(e)).call(t,(function(t,r){return t[r]=deepCpy(e[r]),t}),{}):e}function enableStreamingMode(e,t){var r=e.loader;r!==FetchLoader&&r!==XhrLoader?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):fetchSupported()&&(e.loader=FetchLoader,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var MIN_CUE_DURATION=.25;function getCueClass(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function createCueWithDataFields(e,t,r,n,a){var i=new e(t,r,"");try{i.value=n,a&&(i.type=a)}catch(s){i=new e(t,r,_JSON$stringify(a?_objectSpread2({type:a},n):n))}return i}var MAX_CUE_ENDTIME=function(){var e=getCueClass();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function hexToArrayBuffer(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var ID3TrackController=function(){function e(t){var r=this;_classCallCheck$1(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){r.hls&&r.hls.trigger(Events.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()}return _createClass$1(e,[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Events.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Events.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"onMediaAttaching",value:function(e,t){var r;this.media=t.media,!1===(null==(r=t.overrides)?void 0:r.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e=this.hls.latestLevelDetails;e&&this.updateDateRangeCues(e)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&clearCurrentCues(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return sendAddTrackEvent(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media){var r=this.hls.config,n=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(n||a){var i=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=getCueClass();if(s)for(var o=0;o<i.length;o++){var l=i[o].type;if((l!==MetadataSchema.emsg||n)&&a){var c=getId3Frames(i[o].data);if(c){var u=i[o].pts,d=u+i[o].duration;d>MAX_CUE_ENDTIME&&(d=MAX_CUE_ENDTIME),d-u<=0&&(d=u+MIN_CUE_DURATION);for(var f=0;f<c.length;f++){var h=c[f];if(!isId3TimestampFrame(h)){this.updateId3CueEnds(u,l);var p=createCueWithDataFields(s,u,d,h,l);p&&this.id3Track.addCue(p)}}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var r,n=null==(r=this.id3Track)?void 0:r.cues;if(n)for(var a=n.length;a--;){var i=n[a];i.type===t&&i.startTime<e&&i.endTime===MAX_CUE_ENDTIME&&(i.endTime=e)}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,n=t.endOffset,a=t.type,i=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,c=o.enableID3MetadataCues;if(i&&(l||c))removeCuesInRange(i,r,n,"audio"===a?function(e){return e.type===MetadataSchema.audioId3&&c}:"video"===a?function(e){return e.type===MetadataSchema.emsg&&l}:function(e){return e.type===MetadataSchema.audioId3&&c||e.type===MetadataSchema.emsg&&l})}}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;this.updateDateRangeCues(r,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var r=this;if(this.media&&e.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var n,a=this.id3Track,i=e.dateRanges,s=_Object$keys(i),o=this.dateRangeCuesAppended;if(a&&t)if(null!=(n=a.cues)&&n.length)for(var l,c=_filterInstanceProperty(l=_Object$keys(o)).call(l,(function(e){return!_includesInstanceProperty(s).call(s,e)})),u=function(){var e,t=c[d],n=o[t].cues;delete o[t],_forEachInstanceProperty(e=_Object$keys(n)).call(e,(function(e){try{var t=n[e];t.removeEventListener("enter",r.onEventCueEnter),a.removeCue(t)}catch(e){}}))},d=c.length;d--;)u();else o=this.dateRangeCuesAppended={};var f=e.fragments[e.fragments.length-1];if(0!==s.length&&isFiniteNumber(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var h=getCueClass(),p=function(){var e=s[y],t=i[e],n=t.startTime,a=o[e],l=(null==a?void 0:a.cues)||{},c=(null==a?void 0:a.durationKnown)||!1,u=MAX_CUE_ENDTIME,d=t.duration;if(t.endDate&&null!==d)u=n+d,c=!0;else if(t.endOnNext&&!c){var f=_reduceInstanceProperty(s).call(s,(function(e,r){if(r!==t.id){var n=i[r];if(n.class===t.class&&n.startDate>t.startDate&&(!e||t.startDate<e.startDate))return n}return e}),null);f&&(u=f.startTime,c=!0)}for(var p=_Object$keys(t.attr),g=0;g<p.length;g++){var v=p[g];if(isDateRangeCueAttribute(v)){var m=l[v];if(m)c&&!a.durationKnown?m.endTime=u:Math.abs(m.startTime-n)>.01&&(m.startTime=n,m.endTime=u);else if(h){var E=t.attr[v];isSCTE35Attribute(v)&&(E=hexToArrayBuffer(E));var $=createCueWithDataFields(h,n,u,{key:v,data:E},MetadataSchema.dateRange);$&&($.id=e,r.id3Track.addCue($),l[v]=$,r.hls.config.interstitialsController&&("X-ASSET-LIST"!==v&&"X-ASSET-URL"!==v||$.addEventListener("enter",r.onEventCueEnter)))}}}o[e]={cues:l,dateRange:t,durationKnown:c}},y=0;y<s.length;y++)p()}}}}]),e}(),LatencyController=function(){function e(t){var r=this;_classCallCheck$1(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=r.media,t=r.hls.latestLevelDetails;if(e&&t){r.currentTime=e.currentTime;var n=r.computeLatency();if(null!==n){r._latency=n;var a=r.config,i=a.lowLatencyMode,s=a.maxLiveSyncPlaybackRate;if(i&&1!==s&&t.live){var o=r.targetLatency;if(null!==o){var l=n-o;if(l<Math.min(r.maxLatency,o+t.targetduration)&&l>.05&&r.forwardBufferLength>1){var c=Math.min(2,Math.max(1,s)),u=Math.round(2/(1+Math.exp(-.75*l-r.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()}return _createClass$1(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e,t=this.config;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;var r=null==(e=this.hls)?void 0:e.latestLevelDetails;return r?t.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,n=e.targetduration,a=this.config,i=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode,l=this.hls.userConfig,c=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===c)&&(c=void 0!==i?i:s*n);var u=n;return c+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,u)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var r=this.hls.latestLevelDetails;if(null===r)return null;var n=r.edge,a=e-t-this.edgeStalled,i=n-r.totalduration,s=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(i,a),s)}},{key:"drift",get:function(){var e=this.hls.latestLevelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.hls.latestLevelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){this.hls.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){this.hls.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Events.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var r;t.details===ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.hls.latestLevelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"estimateLiveEdge",value:function(){var e=this.hls.latestLevelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}]),e}(),LevelController=function(e){_inherits(r,BasePlaylistController);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,e,"level-controller"))._levels=[],a._firstLevel=-1,a._maxAutoLevel=-1,a._startLevel=void 0,a.currentLevel=null,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.steering=void 0,a.onParsedComplete=void 0,a.steering=n,a._registerListeners(),a}return _createClass$1(r,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Events.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Events.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),_get(_getPrototypeOf(r.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){var e=this._levels;_forEachInstanceProperty(e).call(e,(function(e){e.loadError=0,e.fragmentError=0})),_get(_getPrototypeOf(r.prototype),"stopLoad",this).call(this)}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var r,n=this,a=this.hls.config.preferManagedMediaSource,i=[],s={},o={},l=!1,c=!1,u=!1;_forEachInstanceProperty(r=t.levels).call(r,(function(e){var t,r,d,f,h,p,y,g=e.attrs,v=e.audioCodec,m=e.videoCodec;v&&(e.audioCodec=v=getCodecCompatibleName(v,a)||void 0),0===(null==(y=m)?void 0:_indexOfInstanceProperty(y).call(y,"avc1"))&&(m=e.videoCodec=convertAVC1ToAVCOTI(m));var E=e.width,$=e.height,S=e.unknownCodecs,T=S?S.length:0;if(S)for(var I=T;I--;){var _,P=S[I];if(n.isAudioSupported(P))e.audioCodec=v=v?_concatInstanceProperty(_="".concat(v,",")).call(_,P):P,T--,sampleEntryCodesISO.audio[v.substring(0,4)]=2;else if(n.isVideoSupported(P)){var b;e.videoCodec=m=m?_concatInstanceProperty(b="".concat(m,",")).call(b,P):P,T--,sampleEntryCodesISO.video[m.substring(0,4)]=2}}if(l||(l=!(!E||!$)),c||(c=!!m),u||(u=!!v),!(T||v&&!n.isAudioSupported(v)||m&&!n.isVideoSupported(m))){var A=g.CODECS,R=g["FRAME-RATE"],k=g["HDCP-LEVEL"],C=g["PATHWAY-ID"],O=g.RESOLUTION,L=g["VIDEO-RANGE"],D="".concat(C||".","-"),w=_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(d=_concatInstanceProperty(f=_concatInstanceProperty(h=_concatInstanceProperty(p="".concat(D)).call(p,e.bitrate,"-")).call(h,O,"-")).call(f,R,"-")).call(d,A,"-")).call(r,L,"-")).call(t,k);if(s[w])if(s[w].uri===e.url||e.attrs["PATHWAY-ID"])s[w].addGroupId("audio",g.AUDIO),s[w].addGroupId("text",g.SUBTITLES);else{var M=o[w]+=1;e.attrs["PATHWAY-ID"]=new Array(M+1).join(".");var x=new Level(e);s[w]=x,i.push(x)}else{var N=new Level(e);s[w]=N,o[w]=1,i.push(N)}}})),this.filterAndSortMediaOptions(i,t,l,c,u)}},{key:"isAudioSupported",value:function(e){return areCodecsMediaSourceSupported(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return areCodecsMediaSourceSupported(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,n,a){var i=this,s=[],o=[],l=e;if((r||n)&&a&&(l=_filterInstanceProperty(l).call(l,(function(e){var t=e.videoCodec,r=e.videoRange,n=e.width,a=e.height;return(!!t||!(!n||!a))&&isVideoRange(r)}))),0!==l.length){var c;if(t.audioTracks)assignTrackIdsByGroup(s=_filterInstanceProperty(c=t.audioTracks).call(c,(function(e){return!e.audioCodec||i.isAudioSupported(e.audioCodec)})));t.subtitles&&assignTrackIdsByGroup(o=t.subtitles);var u=_sliceInstanceProperty(l).call(l,0);_sortInstanceProperty(l).call(l,(function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return _indexOfInstanceProperty(VideoRangeValues).call(VideoRangeValues,e.videoRange)-_indexOfInstanceProperty(VideoRangeValues).call(VideoRangeValues,t.videoRange);if(e.videoCodec!==t.videoCodec){var n=videoCodecPreferenceValue(e.videoCodec),a=videoCodecPreferenceValue(t.videoCodec);if(n!==a)return a-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var i=codecsSetSelectionPreferenceValue(e.codecSet),s=codecsSetSelectionPreferenceValue(t.codecSet);if(i!==s)return s-i}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var d=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var f=0;f<u.length;f++)if(u[f].pathwayId===l[0].pathwayId){d=u[f];break}this._levels=l;for(var h=0;h<l.length;h++)if(l[h]===d){var p,y;this._firstLevel=h;var g=d.bitrate,v=this.hls.bandwidthEstimate;if(this.log(_concatInstanceProperty(p="manifest loaded, ".concat(l.length," level(s) found, first bitrate: ")).call(p,g)),void 0===(null==(y=this.hls.userConfig)?void 0:y.abrEwmaDefaultEstimate)){var m=Math.min(g,this.hls.config.abrEwmaDefaultEstimateMax);m>v&&v===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=m)}break}var E=a&&!n,$={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:n,altAudio:!E&&_someInstanceProperty(s).call(s,(function(e){return!!e.url}))};this.hls.trigger(Events.MANIFEST_PARSED,$)}else _Promise.resolve().then((function(){if(i.hls){t.levels.length&&i.warn("One or more CODECS in variant not supported: ".concat(_JSON$stringify(t.levels[0].attrs)));var e=new Error("no level with compatible codecs found in manifest");i.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}))}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t,r,n,a,i,s,o,l=this._levels;if(0!==l.length){if(e<0||e>=l.length){var c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,l.length-1)}var d=this.currentLevelIndex,f=this.currentLevel,h=f?f.attrs["PATHWAY-ID"]:void 0,p=l[e],y=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=p,d!==e||!f||h!==y){this.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Switching to level ".concat(e," (")).call(o,p.height?p.height+"p ":"")).call(s,p.videoRange?p.videoRange+" ":"")).call(i,p.codecSet?p.codecSet+" ":"","@")).call(a,p.bitrate,")")).call(n,y?" with Pathway "+y:""," from level ")).call(r,d)).call(t,h?" with Pathway "+h:""));var g={level:e,attrs:p.attrs,details:p.details,bitrate:p.bitrate,averageBitrate:p.averageBitrate,maxBitrate:p.maxBitrate,realBitrate:p.realBitrate,width:p.width,height:p.height,codecSet:p.codecSet,audioCodec:p.audioCodec,videoCodec:p.videoCodec,audioGroups:p.audioGroups,subtitleGroups:p.subtitleGroups,loaded:p.loaded,loadError:p.loadError,fragmentError:p.fragmentError,name:p.name,id:p.id,uri:p.uri,url:p.url,urlId:0,audioGroupIds:p.audioGroupIds,textGroupIds:p.textGroupIds};this.hls.trigger(Events.LEVEL_SWITCHING,g);var v=p.details;if(!v||v.live){var m=this.switchParams(p.uri,null==f?void 0:f.details,v);this.loadPlaylist(m)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t,r=this.steering.pathways(),n=_filterInstanceProperty(e).call(e,(function(e){return-1!==_indexOfInstanceProperty(r).call(r,e)}));if(e.length<1)return void this.warn(_concatInstanceProperty(t="pathwayPriority ".concat(e," should contain at least one pathway from list: ")).call(t,r));this.steering.pathwayPriority=n}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===PlaylistContextType.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===PlaylistLevelType.MAIN){var n,a=r.elementaryStreams;if(!_someInstanceProperty(n=_Object$keys(a)).call(n,(function(e){return!!a[e]})))return;var i=this._levels[r.level];null!=i&&i.loadError&&(this.log("Resetting level error count of ".concat(i.loadError," on frag buffered")),i.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var r,n,a=t.level,i=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index ".concat(a)),void(null!=(n=t.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(a,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(i.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){_get(_getPrototypeOf(r.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,t){var n,a,i,s;_get(_getPrototypeOf(r.prototype),"loadingPlaylist",this).call(this,e,t);var o=this.getUrlWithDirectives(e.uri,t),l=this.currentLevelIndex,c=e.attrs["PATHWAY-ID"],u=e.details,d=null==u?void 0:u.age;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Loading level index ".concat(l)).call(s,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(i,c?" Pathway "+c:"")).call(a,d&&u.live?" age "+d.toFixed(1)+(u.type&&" "+u.type||""):""," ")).call(n,o)),this.hls.trigger(Events.LEVEL_LOADING,{url:o,level:l,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t,r,n=this;if(1!==this._levels.length){var a=_filterInstanceProperty(t=this._levels).call(t,(function(t,r){if(r!==e)return!0;var a;(n.steering&&n.steering.removeLevel(t),t===n.currentLevel)&&(n.currentLevel=null,n.currentLevelIndex=-1,t.details&&_forEachInstanceProperty(a=t.details.fragments).call(a,(function(e){return e.level=-1})));return!1}));reassignFragmentLevelIndexes(a),this._levels=a,this.currentLevelIndex>-1&&null!=(r=this.currentLevel)&&r.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var i=a.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(Events.LEVELS_UPDATED,{levels:a})}}},{key:"onLevelsUpdated",value:function(e,t){var r=t.levels;this._levels=r}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(Events.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}]),r}();function assignTrackIdsByGroup(e){var t={};_forEachInstanceProperty(e).call(e,(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var STALL_MINIMUM_DURATION_MS=250,MAX_START_GAP_JUMP=2,SKIP_BUFFER_HOLE_STEP_SECONDS=.1,SKIP_BUFFER_RANGE_START=.05,GapController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n,a,i){var s;return _classCallCheck$1(this,r),(s=t.call(this,"gap-controller",i.logger)).config=void 0,s.media=null,s.fragmentTracker=void 0,s.hls=void 0,s.nudgeRetry=0,s.stallReported=!1,s.stalled=null,s.moved=!1,s.seeking=!1,s.ended=0,s.config=e,s.media=n,s.fragmentTracker=a,s.hls=i,s}return _createClass$1(r,[{key:"destroy",value:function(){this.media=null,this.hls=this.fragmentTracker=null}},{key:"poll",value:function(e,t,r,n){var a=this.config,i=this.media,s=this.stalled;if(null!==i){var o=i.currentTime,l=i.seeking,c=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,o===e)if(u||c)this.stalled=null;else{if(i.paused&&!l||i.ended||0===i.playbackRate||!BufferHelper.getBuffered(i).length)return!this.ended&&i.ended&&(this.ended=o||1,this.hls.trigger(Events.MEDIA_ENDED,{stalled:!1})),void(this.nudgeRetry=0);var d=BufferHelper.bufferInfo(i,o,0),f=d.nextStart||0;if(l){var h=d.len>MAX_START_GAP_JUMP,p=!f||t&&t.start<=o||f-o>MAX_START_GAP_JUMP&&!this.fragmentTracker.getPartialFragment(o);if(h||p)return;this.moved=!1}if(!this.moved&&null!==this.stalled){if(!(d.len>0)&&!f)return;var y=Math.max(f,d.start||0)-o,g=!(null==r||!r.live)?2*r.targetduration:MAX_START_GAP_JUMP,v=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=g||v))return void(i.paused||this._trySkipBufferHole(v))}var m=self.performance.now();if(null!==s){var E=m-s;if(!l&&E>=STALL_MINIMUM_DURATION_MS){if(n===State.ENDED&&(null==r||!r.live)&&Math.abs(o-((null==r?void 0:r.edge)||0))<1){if(E<1e3||this.ended)return;return this.ended=o||1,void this.hls.trigger(Events.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media)return}var $=BufferHelper.bufferInfo(i,o,a.maxBufferHole);this._tryFixBufferStall($,E)}else this.stalled=m}else if(e&&(this.ended=0),this.moved=!0,l||(this.nudgeRetry=0),null!==s){if(this.stallReported){var S,T=self.performance.now()-s;this.warn(_concatInstanceProperty(S="playback not stuck anymore @".concat(o,", after ")).call(S,Math.round(T),"ms")),this.stallReported=!1}this.stalled=null}}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,n=this.fragmentTracker,a=this.media;if(null!==a){var i=a.currentTime,s=n.getPartialFragment(i);if(s)if(this._trySkipBufferHole(s)||!this.media)return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-i<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(this.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}}},{key:"_reportStall",value:function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){var n;this.stallReported=!0;var a=new Error(_concatInstanceProperty(n="Playback stalling at @".concat(r.currentTime," due to low buffer (")).call(n,_JSON$stringify(e),")"));this.warn(a.message),t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len})}}},{key:"_trySkipBufferHole",value:function(e){var t=this.config,r=this.hls,n=this.media;if(null===n)return 0;var a=n.currentTime,i=BufferHelper.bufferInfo(n,a,0),s=a<i.start?i.start:i.nextStart;if(s){var o=i.len<=t.maxBufferHole,l=i.len>0&&i.len<1&&n.readyState<3,c=s-a;if(c>0&&(o||l)){var u;if(c>t.maxBufferHole){var d=this.fragmentTracker,f=!1;if(0===a){var h=d.getAppendedFrag(0,PlaylistLevelType.MAIN);h&&s<h.end&&(f=!0)}if(!f){var p=e||d.getAppendedFrag(a,PlaylistLevelType.MAIN);if(p){for(var y=!1,g=p.end;g<s;){var v=d.getPartialFragment(g);if(!v){y=!0;break}g+=v.duration}if(y)return 0}}}var m=Math.max(s+SKIP_BUFFER_RANGE_START,a+SKIP_BUFFER_HOLE_STEP_SECONDS);if(this.warn(_concatInstanceProperty(u="skipping hole, adjusting currentTime from ".concat(a," to ")).call(u,m)),this.moved=!0,this.stalled=null,n.currentTime=m,e&&!e.gap){var E,$=new Error(_concatInstanceProperty(E="fragment loaded with buffer holes, seeking from ".concat(a," to ")).call(E,m));r.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:$,reason:$.message,frag:e})}return m}}return 0}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,n=this.nudgeRetry;if(null!==r){var a=r.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){var i,s=a+(n+1)*e.nudgeOffset,o=new Error(_concatInstanceProperty(i="Nudging 'currentTime' from ".concat(a," to ")).call(i,s));this.warn(o.message),r.currentTime=s,t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l,c=new Error(_concatInstanceProperty(l="Playhead still not moving while enough data buffered @".concat(a," after ")).call(l,e.nudgeMaxRetry," nudges"));this.error(c.message),t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_STALLED_ERROR,error:c,fatal:!0})}}}}]),r}();function getSourceBuffer(){return self.SourceBuffer||self.WebKitSourceBuffer}function _isMSESupported(){if(!_getMediaSource2())return!1;var e=getSourceBuffer();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}function _isSupported(){var e,t;if(!_isMSESupported())return!1;var r=_getMediaSource2();return"function"==typeof(null==r?void 0:r.isTypeSupported)&&(_someInstanceProperty(e=["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"]).call(e,(function(e){return r.isTypeSupported(mimeTypeForCodec(e,"video"))}))||_someInstanceProperty(t=["mp4a.40.2","fLaC"]).call(t,(function(e){return r.isTypeSupported(mimeTypeForCodec(e,"audio"))})))}function changeTypeSupported(){var e,t=getSourceBuffer();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}var TICK_INTERVAL=100,StreamController=function(e){_inherits(r,BaseStreamController);var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e,n,a,"stream-controller",PlaylistLevelType.MAIN)).audioCodecSwap=!1,i.gapController=null,i.level=-1,i._forceStartLoad=!1,i._hasEnoughToStart=!1,i.altAudio=0,i.audioOnly=!1,i.fragPlaying=null,i.fragLastKbps=0,i.couldBacktrack=!1,i.backtrackFragment=null,i.audioCodecSwitch=!1,i.videoBuffer=null,i.onMediaPlaying=function(){var e=i.gapController;e&&(e.ended=0),i.tick()},i.onMediaSeeked=function(){var e=i.media,t=e?e.currentTime:null;isFiniteNumber(t)&&i.log("Media seeked to ".concat(t.toFixed(3)));var r=i.getMainFwdBufferInfo();null!==r&&0!==r.len?i.tick():i.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"))},i.registerListeners(),i}return _createClass$1(r,[{key:"registerListeners",value:function(){_get(_getPrototypeOf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){_get(_getPrototypeOf(r.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this)}},{key:"startLoad",value:function(e,t){if(this.levels){var r=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(TICK_INTERVAL),this.level=-1,!this.startFragRequested){var a=n.startLevel;-1===a&&(n.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=n.firstAutoLevel),n.nextLoadLevel=a,this.level=n.loadLevel,this._hasEnoughToStart=!1}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r),this.state=State.IDLE,this.nextLoadPosition=this.lastCurrentTime=e,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=State.STOPPED}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,_get(_getPrototypeOf(r.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case State.WAITING_LEVEL:var e=this.levels,t=this.level,r=null==e?void 0:e[t],n=null==r?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(n))break;this.state=State.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=State.IDLE;break}break;case State.FRAG_LOADING_WAITING_RETRY:var a,i=self.performance.now(),s=this.retryDate;if(!s||i>=s||null!=(a=this.media)&&a.seeking){var o=this.levels,l=this.level,c=null==o?void 0:o[l];this.resetStartWhenNotLoaded(c||null),this.state=State.IDLE}}this.state===State.IDLE&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){_get(_getPrototypeOf(r.prototype),"onTickEnd",this).call(this),this.checkBuffer(),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,n=this.media;if(null!==t&&(n||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[a]){var i=r[a],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return 2===this.altAudio&&(l.type="video"),this.hls.trigger(Events.BUFFER_EOS,l),void(this.state=State.ENDED)}if(this.buffering){var c;if(e.loadLevel!==a&&-1===e.manualLevel)this.log(_concatInstanceProperty(c="Adapting to level ".concat(a," from level ")).call(c,this.level));this.level=e.nextLoadLevel=a;var u=i.details;if(!u||this.state===State.WAITING_LEVEL||this.waitForLive(i))return this.level=a,this.state=State.WAITING_LEVEL,void(this.startFragRequested=!1);var d=s.len,f=this.getMaxBufferLength(i.maxBitrate);if(!(d>=f)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var h=this.backtrackFragment?this.backtrackFragment.start:s.end,p=this.getNextFragment(h,u);if(this.couldBacktrack&&!this.fragPrevious&&p&&isMediaFragment(p)&&this.fragmentTracker.getState(p)!==FragmentState.OK){var y,g=(null!=(y=this.backtrackFragment)?y:p).sn-u.startSN,v=u.fragments[g-1];v&&p.cc===v.cc&&(p=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,h)){if(!p.gap){var m=this.audioOnly&&!this.altAudio?ElementaryStreamTypes.AUDIO:ElementaryStreamTypes.VIDEO,E=(m===ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,m,PlaylistLevelType.MAIN)}p=this.getNextFragmentLoopLoading(p,u,s,PlaylistLevelType.MAIN,f)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,i,h))}}}}}}},{key:"loadFragment",value:function(e,t,n){var a=this.fragmentTracker.getState(e);if(a===FragmentState.NOT_LOADED||a===FragmentState.PARTIAL)if(isMediaFragment(e))if(this.bitrateTest){var i;this.log(_concatInstanceProperty(i="Fragment ".concat(e.sn," of level ")).call(i,e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)}else _get(_getPrototypeOf(r.prototype),"loadFragment",this).call(this,e,t,n);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,PlaylistLevelType.MAIN)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var i=this.getMainFwdBufferInfo();if(!i||i.len<2*a.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(t.currentTime+r);if(l){var c=this.followingBufferedFrag(l);if(c){this.abortCurrentFrag();var u=c.maxStartPTS?c.maxStartPTS:c.start,d=c.duration,f=Math.max(l.end,u+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(f,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case State.KEY_LOADING:case State.FRAG_LOADING:case State.FRAG_LOADING_WAITING_RETRY:case State.PARSING:case State.PARSED:this.state=State.IDLE}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,t){_get(_getPrototypeOf(r.prototype),"flushMainBuffer",this).call(this,e,t,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,t){_get(_getPrototypeOf(r.prototype),"onMediaAttached",this).call(this,e,t);var n=t.media;n.removeEventListener("playing",this.onMediaPlaying),n.removeEventListener("seeked",this.onMediaSeeked),n.addEventListener("playing",this.onMediaPlaying),n.addEventListener("seeked",this.onMediaSeeked),this.gapController=new GapController(this.config,n,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(e,t){var n=this.media;n&&(n.removeEventListener("playing",this.onMediaPlaying),n.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),_get(_getPrototypeOf(r.prototype),"onMediaDetaching",this).call(this,e,t),!!t.transferMedia||(this._hasEnoughToStart=!1)}},{key:"triggerEnded",value:function(){var e=this.gapController;if(e){var t;if(e.ended)return;e.ended=(null==(t=this.media)?void 0:t.currentTime)||1}this.hls.trigger(Events.MEDIA_ENDED,{stalled:!1})}},{key:"onManifestLoading",value:function(){_get(_getPrototypeOf(r.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(Events.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){var r,n=!1,a=!1;_forEachInstanceProperty(r=t.levels).call(r,(function(e){var t=e.audioCodec;t&&(n=n||-1!==_indexOfInstanceProperty(t).call(t,"mp4a.40.2"),a=a||-1!==_indexOfInstanceProperty(t).call(t,"mp4a.40.5"))})),this.audioCodecSwitch=n&&a&&!changeTypeSupported(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===State.IDLE){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=State.WAITING_LEVEL)}}},{key:"onLevelLoaded",value:function(e,t){var r,n,a,i,s,o,l,c,u=this.levels,d=this.startFragRequested,f=t.level,h=t.details,p=h.totalduration;if(u){this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Level ".concat(f," loaded [")).call(o,h.startSN,",")).call(s,h.endSN,"]")).call(i,h.lastPartSn?_concatInstanceProperty(l="[part-".concat(h.lastPartSn,"-")).call(l,h.lastPartIndex,"]"):"",", cc [")).call(a,h.startCC,", ")).call(n,h.endCC,"] duration:")).call(r,p));var y=t.levelInfo,g=this.fragCurrent;!g||this.state!==State.FRAG_LOADING&&this.state!==State.FRAG_LOADING_WAITING_RETRY||g.level!==t.level&&g.loader&&this.abortCurrentFrag();var v=0;if(h.live||null!=(c=y.details)&&c.live){var m;if(this.checkLiveUpdate(h),h.deltaUpdateFailed)return;v=this.alignPlaylists(h,y.details,null==(m=this.levelLastLoaded)?void 0:m.details)}if(y.details=h,this.levelLastLoaded=y,d||this.setStartPosition(h,v),this.hls.trigger(Events.LEVEL_UPDATED,{details:h,level:f}),this.state===State.WAITING_LEVEL){if(this.waitForCdnTuneIn(h))return;this.state=State.IDLE}d&&h.live&&this.synchronizeToLiveEdge(h),this.tick()}else this.warn("Levels were reset while loading level ".concat(f))}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,r=this.media;if(r){var n=this.hls.liveSyncPosition,a=r.currentTime,i=e.fragmentStart,s=e.edge,o=a>=i-t.maxFragLookUpTolerance&&a<=s;if(null!==n&&r.duration>n&&(a<n||!o)){var l,c,u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if(!o&&r.readyState<4||a<s-u)if(this._hasEnoughToStart||(this.nextLoadPosition=n),r.readyState)this.warn(_concatInstanceProperty(l=_concatInstanceProperty(c="Playback: ".concat(a.toFixed(3)," is located too far from the end of live sliding playlist: ")).call(c,s,", reset currentTime to : ")).call(l,n.toFixed(3))),r.currentTime=n}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r,n,a=e.frag,i=e.part,s=e.payload,o=this.levels;if(o){var l=o[a.level];if(l){var c,u=l.details;if(!u)return this.warn(_concatInstanceProperty(c="Dropping fragment ".concat(a.sn," of level ")).call(c,a.level," after level details were reset")),void this.fragmentTracker.removeFragment(a);var d=l.videoCodec,f=u.PTSKnown||!u.live,h=null==(n=a.initSegment)?void 0:n.data,p=this._getAudioCodec(l),y=this.transmuxer=this.transmuxer||new TransmuxerInterface(this.hls,PlaylistLevelType.MAIN,_bindInstanceProperty(t=this._handleTransmuxComplete).call(t,this),_bindInstanceProperty(r=this._handleTransmuxerFlush).call(r,this)),g=i?i.index:-1,v=-1!==g,m=new ChunkMetadata(a.level,a.sn,a.stats.chunkCount,s.byteLength,g,v),E=this.initPTS[a.cc];y.push(s,h,p,d,a,i,u.totalduration,f,m,E)}else this.warn("Level ".concat(a.level," not found on progress"))}else{var $;this.warn(_concatInstanceProperty($="Levels were reset while fragment load was in progress. Fragment ".concat(a.sn," of level ")).call($,a.level," will not be buffered"))}}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this.hls,n=2===this.altAudio;if(useAlternateAudio(t.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();n&&(r.trigger(Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(Events.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=useAlternateAudio(t.url,this.hls);if(r){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var r,n,a=t.tracks,i=!1;for(var s in a){var o=a[s];if("main"===o.id){if(n=s,r=o,"video"===s){var l=a[s];l&&(this.videoBuffer=l.buffer)}}else i=!0}i&&r?(this.log("Alternate track found, use ".concat(n,".buffered to schedule main fragment loading")),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,n=t.part,a=r.type===PlaylistLevelType.MAIN;if(a){var i,s,o;if(this.fragContextChanged(r))return this.warn(_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Fragment ".concat(r.sn)).call(o,n?" p: "+n.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(i,this.state)),void(this.state===State.PARSED&&(this.state=State.IDLE));var l=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),isMediaFragment(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}var c=this.media;c&&(!this._hasEnoughToStart&&c.buffered.length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=State.ERROR;else switch(t.details){case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_PARSING_ERROR:case ErrorDetails.FRAG_DECRYPT_ERROR:case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(PlaylistLevelType.MAIN,t);break;case ErrorDetails.LEVEL_LOAD_ERROR:case ErrorDetails.LEVEL_LOAD_TIMEOUT:case ErrorDetails.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==State.WAITING_LEVEL||(null==(r=t.context)?void 0:r.type)!==PlaylistContextType.LEVEL||(this.state=State.IDLE);break;case ErrorDetails.BUFFER_APPEND_ERROR:case ErrorDetails.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===ErrorDetails.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case ErrorDetails.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"checkBuffer",value:function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this._hasEnoughToStart||!BufferHelper.getBuffered(e).length){var r=this.state,n=r!==State.IDLE?this.fragCurrent:null,a=this.getLevelDetails();t.poll(this.lastCurrentTime,n,a,r)}this.lastCurrentTime=e.currentTime}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=State.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var n=(r===ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,r,PlaylistLevelType.MAIN),this.tick()}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0){var n;if(e.seeking)return void this.log(_concatInstanceProperty(n="could not seek to ".concat(r,", already seeking at ")).call(n,t));var a=this.getLevelDetails(),i=this.config.timelineOffset;i&&r&&(r+=(null==a?void 0:a.appliedTimelineOffset)||i);var s,o,l=BufferHelper.getBuffered(e),c=l.length?l.start(0):0,u=c-r,d=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(u>0&&(u<d||this.loadingParts&&u<2*((null==a?void 0:a.partTarget)||0))&&(this.log("adjusting start position by ".concat(u," to match buffer start")),r+=u,this.startPosition=r),t<r)this.log(_concatInstanceProperty(s=_concatInstanceProperty(o="seek to target start position ".concat(r," from current time ")).call(o,t," buffer start ")).call(s,c)),e.currentTime=r}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==_indexOfInstanceProperty(t).call(t,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(e){var n=r.hls,a=null==e?void 0:e.frag;if(a&&!r.fragContextChanged(a)){t.fragmentError=0,r.state=State.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var i=a.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),n.trigger(Events.FRAG_LOADED,e),a.bitrateTest=!1}}))}},{key:"_handleTransmuxComplete",value:function(e){var t,r=this.playlistType,n=this.hls,a=e.remuxResult,i=e.chunkMeta,s=this.getCurrentContext(i);if(s){var o=s.frag,l=s.part,c=s.level,u=a.video,d=a.text,f=a.id3,h=a.initSegment,p=c.details,y=this.altAudio?void 0:a.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=State.PARSING,h){if(null!=h&&h.tracks){var g=o.initSegment||o;this._bufferInitSegment(c,h.tracks,g,i),n.trigger(Events.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:h.tracks})}var v=h.initPTS,m=h.timescale;isFiniteNumber(v)&&(this.initPTS[o.cc]={baseTime:v,timescale:m},n.trigger(Events.INIT_PTS_FOUND,{frag:o,id:r,initPTS:v,timescale:m}))}if(u&&p){var E=p.fragments[o.sn-1-p.startSN],$=o.sn===p.startSN,S=!E||o.cc>E.cc;if(!1!==a.independent){var T=u.startPTS,I=u.endPTS,_=u.startDTS,P=u.endDTS;if(l)l.elementaryStreams[u.type]={startPTS:T,endPTS:I,startDTS:_,endDTS:P};else if(u.firstKeyFrame&&u.independent&&1===i.id&&!S&&(this.couldBacktrack=!0),u.dropped&&u.independent){var b=this.getMainFwdBufferInfo(),A=(b?b.end:this.getLoadPosition())+this.config.maxBufferHole,R=u.firstKeyFramePTS?u.firstKeyFramePTS:T;if(!$&&A<R-this.config.maxBufferHole&&!S)return void this.backtrack(o);S&&(o.gap=!0),o.setElementaryStreamInfo(u.type,o.start,I,o.start,P,!0)}else $&&T-(p.appliedTimelineOffset||0)>MAX_START_GAP_JUMP&&(o.gap=!0);o.setElementaryStreamInfo(u.type,T,I,_,P),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(u,o,l,i,$||S)}else{if(!$&&!S)return void this.backtrack(o);o.gap=!0}}if(y){var k=y.startPTS,C=y.endPTS,O=y.startDTS,L=y.endDTS;l&&(l.elementaryStreams[ElementaryStreamTypes.AUDIO]={startPTS:k,endPTS:C,startDTS:O,endDTS:L}),o.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO,k,C,O,L),this.bufferFragmentData(y,o,l,i)}if(p&&null!=f&&null!=(t=f.samples)&&t.length){var D={id:r,frag:o,details:p,samples:f.samples};n.trigger(Events.FRAG_PARSING_METADATA,D)}if(p&&d){var w={id:r,frag:o,details:p,samples:d.samples};n.trigger(Events.FRAG_PARSING_USERDATA,w)}}}else this.resetWhenMissingContext(i)}},{key:"_bufferInitSegment",value:function(e,t,r,n){var a=this;if(this.state===State.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var i,s,o=t.audio,l=t.video,c=t.audiovideo;if(o){var u,d,f,h=pickMostCompleteCodecName(o.codec,e.audioCodec);"mp4a"===h&&(h="mp4a.40.5");var p,y=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h=-1!==_indexOfInstanceProperty(h).call(h,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var g=o.metadata;g&&"channelCount"in g&&1!==(g.channelCount||1)&&-1===_indexOfInstanceProperty(y).call(y,"firefox")&&(h="mp4a.40.5")}if(h&&-1!==_indexOfInstanceProperty(h).call(h,"mp4a.40.5")&&-1!==_indexOfInstanceProperty(y).call(y,"android")&&"audio/mpeg"!==o.container&&(h="mp4a.40.2",this.log("Android: force audio codec to ".concat(h))),e.audioCodec&&e.audioCodec!==h)this.log(_concatInstanceProperty(p='Swapping manifest audio codec "'.concat(e.audioCodec,'" for "')).call(p,h,'"'));o.levelCodec=h,o.id="main",this.log(_concatInstanceProperty(u=_concatInstanceProperty(d=_concatInstanceProperty(f="Init audio buffer, container:".concat(o.container,", codecs[selected/level/parsed]=[")).call(f,h||"","/")).call(d,e.audioCodec||"","/")).call(u,o.codec,"]")),delete t.audiovideo}if(l){var v,m,E;l.levelCodec=e.videoCodec,l.id="main";var $=l.codec;if(4===(null==$?void 0:$.length))switch($){case"hvc1":case"hev1":l.codec="hvc1.1.6.L120.90";break;case"av01":l.codec="av01.0.04M.08";break;case"avc1":l.codec="avc1.42e01e"}this.log(_concatInstanceProperty(v=_concatInstanceProperty(m=_concatInstanceProperty(E="Init video buffer, container:".concat(l.container,", codecs[level/parsed]=[")).call(E,e.videoCodec||"","/")).call(m,$)).call(v,l.codec!==$?" parsed-corrected="+l.codec:"","}]")),delete t.audiovideo}if(c)this.log(_concatInstanceProperty(i=_concatInstanceProperty(s="Init audiovideo buffer, container:".concat(c.container,", codecs[level/parsed]=[")).call(s,e.codecs,"/")).call(i,c.codec,"]")),delete t.video,delete t.audio;var S=_Object$keys(t);if(S.length){if(this.hls.trigger(Events.BUFFER_CODECS,t),!this.hls)return;_forEachInstanceProperty(S).call(S,(function(e){var i=t[e].initSegment;null!=i&&i.byteLength&&a.hls.trigger(Events.BUFFER_APPENDING,{type:e,data:i,frag:r,part:null,chunkMeta:n,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,PlaylistLevelType.MAIN)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=State.IDLE}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(BufferHelper.isBuffered(e,r)?t=this.getAppendedFrag(r):BufferHelper.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var n=this.fragPlaying,a=t.level;n&&t.sn===n.sn&&n.level===a||(this.fragPlaying=t,this.hls.trigger(Events.FRAG_CHANGED,{frag:t}),n&&n.level===a||this.hls.trigger(Events.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return isFiniteNumber(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(isFiniteNumber(t)){var r=this.getLevelDetails(),n=this.currentFrag||(r?findFragmentByPTS(null,r.fragments,t):null);if(n){var a=n.programDateTime;if(null!==a){var i=a+1e3*(t-n.start);return new Date(i)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(),KeyLoader=function(){function e(t){_classCallCheck$1(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}return _createClass$1(e,[{key:"abort",value:function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var n;if(e&&e!==(null==(n=r.context)?void 0:n.frag.type))return;r.abort()}}}},{key:"detach",value:function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}},{key:"createKeyLoadError",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ErrorDetails.KEY_LOAD_ERROR,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;return new LoadError({type:ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:n})}},{key:"loadClear",value:function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,a=e.cc,i=function(){var e=t[s];if(a<=e.cc&&("initSegment"===n||"initSegment"===e.sn||n<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),"break"},s=0;s<t.length;s++){if("break"===i())break}}},{key:"load",value:function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var r,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var i=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return _Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,i))}var s=a.uri;if(!s)return _Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(s,'"'))));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return a.key=l.decryptdata.key,_Promise.resolve({frag:e,keyInfo:l});if(null!=(n=l)&&n.keyLoadPromise)switch(null==(o=l.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return l.keyLoadPromise.then((function(t){return a.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return _Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(a.method,'"'))))}}},{key:"loadKeyEME",value:function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(r);if(n)return(e.keyLoadPromise=n.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return _Promise.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,n=this.config,a=new(0,n.loader)(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new _Promise((function(i,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=n.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:function(e,t,n,a){var o=n.frag,l=n.keyInfo,c=n.url;if(!o.decryptdata||l!==r.keyUriToKeyInfo[c])return s(r.createKeyLoadError(o,ErrorDetails.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),a));l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,l.loader=null,i({frag:o,keyInfo:l})},onError:function(e,n,a,i){var l;r.resetLoader(n),s(r.createKeyLoadError(t,ErrorDetails.KEY_LOAD_ERROR,new Error(_concatInstanceProperty(l="HTTP Error ".concat(e.code," loading key ")).call(l,e.text)),a,_objectSpread2({url:o.url,data:void 0},e)))},onTimeout:function(e,n,a){r.resetLoader(n),s(r.createKeyLoadError(t,ErrorDetails.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(e,n,a){r.resetLoader(n),s(r.createKeyLoadError(t,ErrorDetails.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};a.load(o,c,u)}))}},{key:"resetLoader",value:function(e){var t=e.frag,r=e.keyInfo,n=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()}}]),e}();function mapContextToLevelType(e){switch(e.type){case PlaylistContextType.AUDIO_TRACK:return PlaylistLevelType.AUDIO;case PlaylistContextType.SUBTITLE_TRACK:return PlaylistLevelType.SUBTITLE;default:return PlaylistLevelType.MAIN}}function getResponseUrl(e,t){var r=e.url;return void 0!==r&&0!==_indexOfInstanceProperty(r).call(r,"data:")||(r=t.url),r}var PlaylistLoader=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.loaders=_Object$create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()}return _createClass$1(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,r=t.pLoader,n=t.loader,a=new(r||n)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var r=t.id,n=t.level,a=t.pathwayId,i=t.url,s=t.deliveryDirectives,o=t.levelInfo;this.load({id:r,level:n,pathwayId:a,responseType:"text",type:PlaylistContextType.LEVEL,url:i,deliveryDirectives:s,levelOrTrack:o})}},{key:"onAudioTrackLoading",value:function(e,t){var r=t.id,n=t.groupId,a=t.url,i=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:n,level:null,responseType:"text",type:PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:i,levelOrTrack:s})}},{key:"onSubtitleTrackLoading",value:function(e,t){var r=t.id,n=t.groupId,a=t.url,i=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:n,level:null,responseType:"text",type:PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:i,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[PlaylistContextType.LEVEL];if(r){var n,a=r.context;a&&!_someInstanceProperty(n=t.levels).call(n,(function(e){return e===a.levelOrTrack}))&&(r.abort(),delete this.loaders[PlaylistContextType.LEVEL])}}},{key:"load",value:function(e){var t,r,n,a=this,i=this.hls.config,s=this.getInternalLoader(e);if(s){var o=this.hls.logger,l=s.context;if(l&&l.levelOrTrack===e.levelOrTrack&&(l.url===e.url||l.deliveryDirectives&&!e.deliveryDirectives)){var c;if(l.url===e.url)o.log("[playlist-loader]: ignore ".concat(e.url," ongoing request"));else o.log(_concatInstanceProperty(c="[playlist-loader]: ignore ".concat(e.url," in favor of ")).call(c,l.url));return}o.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if((r=e.type===PlaylistContextType.MANIFEST?i.manifestLoadPolicy.default:_extends({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),isFiniteNumber(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===PlaylistContextType.LEVEL&&null!==e.level?n=this.hls.levels[e.level].details:e.type===PlaylistContextType.AUDIO_TRACK&&null!==e.id?n=this.hls.audioTracks[e.id].details:e.type===PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(n=this.hls.subtitleTracks[e.id].details),n)){var u=n.partTarget,d=n.targetduration;if(u&&d){var f=1e3*Math.max(3*u,.8*d);r=_extends({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var h=r.errorRetry||r.timeoutRetry||{},p={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},y={onSuccess:function(e,t,r,n){var i=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=e.data;0===_indexOfInstanceProperty(s).call(s,"#EXTM3U")?(t.parsing.start=performance.now(),M3U8Parser.isMediaPlaylist(s)||r.type!==PlaylistContextType.MANIFEST?a.handleTrackOrLevelPlaylist(e,t,r,n||null,i):a.handleMasterPlaylist(e,t,r,n)):a.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),n||null,t)},onError:function(e,t,r,n){a.handleNetworkError(t,r,!1,e,n)},onTimeout:function(e,t,r){a.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,p,y)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e,t=this.hls,r=t.config,n=r.autoStartLoad,a=r.startPosition,i=t.forceStartLoad;if(n||i)this.hls.logger.log(_concatInstanceProperty(e="".concat(n?"auto":"force"," startLoad with configured startPosition ")).call(e,a)),this.hls.startLoad(a)}}},{key:"handleMasterPlaylist",value:function(e,t,r,n){var a=this.hls,i=e.data,s=getResponseUrl(e,r),o=M3U8Parser.parseMasterPlaylist(i,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,n,t);else{var l=o.contentSteering,c=o.levels,u=o.sessionData,d=o.sessionKeys,f=o.startTimeOffset,h=o.variableList;this.variableList=h;var p=M3U8Parser.parseMasterPlaylistMedia(i,s,o),y=p.AUDIO,g=void 0===y?[]:y,v=p.SUBTITLES,m=p["CLOSED-CAPTIONS"];if(g.length)_someInstanceProperty(g).call(g,(function(e){return!e.url}))||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new AttrList({}),bitrate:0,url:""}));a.trigger(Events.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:v,captions:m,contentSteering:l,url:s,stats:t,networkDetails:n,sessionData:u,sessionKeys:d,startTimeOffset:f,variableList:h})}}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,r,n,a){var i=this.hls,s=r.id,o=r.level,l=r.type,c=getResponseUrl(e,r),u=isFiniteNumber(o)?o:isFiniteNumber(s)?s:0,d=mapContextToLevelType(r),f=M3U8Parser.parseLevelPlaylist(e.data,c,u,d,0,this.variableList);if(l===PlaylistContextType.MANIFEST){var h={attrs:new AttrList({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+computeReloadInterval(f,0),i.trigger(Events.MANIFEST_LOADED,{levels:[h],audioTracks:[],url:c,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=f,this.handlePlaylistLoaded(f,e,t,r,n,a)}},{key:"handleManifestParsingError",value:function(e,t,r,n,a){this.hls.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===PlaylistContextType.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:n,stats:a})}},{key:"handleNetworkError",value:function(e,t){var r,n,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=_concatInstanceProperty(r="A network ".concat(a?"timeout":"error"+(i?" (status "+i.code+")":"")," occurred while loading ")).call(r,e.type);if(e.type===PlaylistContextType.LEVEL)o+=_concatInstanceProperty(n=": ".concat(e.level," id: ")).call(n,e.id);else if(e.type===PlaylistContextType.AUDIO_TRACK||e.type===PlaylistContextType.SUBTITLE_TRACK){var l;o+=_concatInstanceProperty(l=" id: ".concat(e.id,' group-id: "')).call(l,e.groupId,'"')}var c=new Error(o);this.hls.logger.warn("[playlist-loader]: ".concat(o));var u=ErrorDetails.UNKNOWN,d=!1,f=this.getInternalLoader(e);switch(e.type){case PlaylistContextType.MANIFEST:u=a?ErrorDetails.MANIFEST_LOAD_TIMEOUT:ErrorDetails.MANIFEST_LOAD_ERROR,d=!0;break;case PlaylistContextType.LEVEL:u=a?ErrorDetails.LEVEL_LOAD_TIMEOUT:ErrorDetails.LEVEL_LOAD_ERROR,d=!1;break;case PlaylistContextType.AUDIO_TRACK:u=a?ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:ErrorDetails.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case PlaylistContextType.SUBTITLE_TRACK:u=a?ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:ErrorDetails.SUBTITLE_LOAD_ERROR,d=!1}f&&this.resetInternalLoader(e.type);var h={type:ErrorTypes.NETWORK_ERROR,details:u,fatal:d,url:e.url,loader:f,context:e,error:c,networkDetails:t,stats:s};if(i){var p=(null==t?void 0:t.url)||e.url;h.response=_objectSpread2({url:p,data:void 0},i)}this.hls.trigger(Events.ERROR,h)}},{key:"handlePlaylistLoaded",value:function(e,t,r,n,a,i){var s=this.hls,o=n.type,l=n.level,c=n.id,u=n.groupId,d=n.deliveryDirectives,f=getResponseUrl(t,n),h=mapContextToLevelType(n),p="number"==typeof n.level&&h===PlaylistLevelType.MAIN?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;if(y)s.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:y,reason:y.message,response:t,context:n,level:p,parent:h,networkDetails:a,stats:r});else switch(e.live&&i&&(i.getCacheAge&&(e.ageHeader=i.getCacheAge()||0),i.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case PlaylistContextType.MANIFEST:case PlaylistContextType.LEVEL:s.trigger(Events.LEVEL_LOADED,{details:e,levelInfo:n.levelOrTrack||s.levels[0],level:p||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:d,withoutMultiVariant:o===PlaylistContextType.MANIFEST});break;case PlaylistContextType.AUDIO_TRACK:s.trigger(Events.AUDIO_TRACK_LOADED,{details:e,track:n.levelOrTrack,id:c||0,groupId:u||"",stats:r,networkDetails:a,deliveryDirectives:d});break;case PlaylistContextType.SUBTITLE_TRACK:s.trigger(Events.SUBTITLE_TRACK_LOADED,{details:e,track:n.levelOrTrack,id:c||0,groupId:u||"",stats:r,networkDetails:a,deliveryDirectives:d})}}else{var g=e.playlistParsingError=new Error("No Segments found in Playlist");s.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:n,level:p,parent:h,networkDetails:a,stats:r})}}}]),e}(),Hls=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck$1(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new EventEmitter,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var r=this.logger=enableLogs(t.debug||!1,"Hls instance",t.assetPlayerId),n=this.config=mergeConfig(e.DefaultConfig,t,r);this.userConfig=t,n.progressive&&enableStreamingMode(n,r);var a=n.abrController,i=n.bufferController,s=n.capLevelController,o=n.errorController,l=n.fpsController,c=new o(this),u=this.abrController=new a(this),d=new FragmentTracker(this),f=n.interstitialsController,h=f?this.interstitialsController=new f(this,e):null,p=this.bufferController=new i(this,d),y=this.capLevelController=new s(this),g=new l(this),v=new PlaylistLoader(this),m=n.contentSteeringController,E=m?new m(this):null,$=this.levelController=new LevelController(this,E),S=new ID3TrackController(this),T=new KeyLoader(this.config),I=this.streamController=new StreamController(this,d,T);y.setStreamController(I),g.setStreamController(I);var _=[v,$,I];h&&_spliceInstanceProperty(_).call(_,1,0,h),E&&_spliceInstanceProperty(_).call(_,1,0,E),this.networkControllers=_;var P=[u,p,y,g,S,d];this.audioTrackController=this.createController(n.audioTrackController,_);var b=n.audioStreamController;b&&_.push(new b(this,d,T)),this.subtitleTrackController=this.createController(n.subtitleTrackController,_);var A=n.subtitleStreamController;A&&_.push(new A(this,d,T)),this.createController(n.timelineController,P),T.emeController=this.emeController=this.createController(n.emeController,P),this.cmcdController=this.createController(n.cmcdController,P),this.latencyController=this.createController(LatencyController,P),this.coreComponents=P,_.push(c);var R=c.onErrorOut;"function"==typeof R&&this.on(Events.ERROR,R,c),this.on(Events.MANIFEST_LOADED,v.onManifestLoaded,v)}return _createClass$1(e,[{key:"createController",value:function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null}},{key:"on",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.on(e,t,r)}},{key:"once",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.once(e,t,r)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,n=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,n)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,r){return this._emitter.emit(e,t,r)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===Events.ERROR;this.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){var e,t;this.logger.log("destroy"),this.trigger(Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,_forEachInstanceProperty(e=this.networkControllers).call(e,(function(e){return e.destroy()})),this.networkControllers.length=0,_forEachInstanceProperty(t=this.coreComponents).call(t,(function(e){return e.destroy()})),this.coreComponents.length=0;var r=this.config;r.xhrSetup=r.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument (".concat(e,")"));this.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in e,n=r?e.media:e,a=r?e:{media:n};this._media=n,this.trigger(Events.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(Events.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(Events.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,n=this._url=urlToolkitExports.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:".concat(n)),t&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Events.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=arguments.length>1?arguments[1]:void 0;this.logger.log("startLoad(".concat(e+(t?", <skip seek to start>":""),")")),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){var e;this.bufferingEnabled||(this.logger.log("resume buffering"),_forEachInstanceProperty(e=this.networkControllers).call(e,(function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){var e;this.bufferingEnabled&&(this.logger.log("pause buffering"),_forEachInstanceProperty(e=this.networkControllers).call(e,(function(e){e.pauseBuffering&&e.pauseBuffering()})))}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=uuid()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:".concat(e)),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:".concat(e)),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:".concat(e)),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:".concat(e)),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){isHdcpLevel(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,n=0;n<r;n++)if(e[n].maxBitrate>=t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,n)for(var a=e;a--;){var i=t[a].attrs["HDCP-LEVEL"];if(i&&i<=n)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e){return getMediaDecodingInfoPromise(e,getAudioTracksByGroup(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return version}},{key:"isMSESupported",value:function(){return _isMSESupported()}},{key:"isSupported",value:function(){return _isSupported()}},{key:"getMediaSource",value:function(){return _getMediaSource2()}},{key:"Events",get:function(){return Events}},{key:"MetadataSchema",get:function(){return MetadataSchema}},{key:"ErrorTypes",get:function(){return ErrorTypes}},{key:"ErrorDetails",get:function(){return ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:hlsDefaultConfig},set:function(t){e.defaultConfig=t}}]),e}();Hls.defaultConfig=void 0;var optionsMap={liveSyncDuration:{key:"targetLatency",val:10},liveMaxLatencyDuration:{key:"maxLatency",val:20},backBufferLength:{key:"bufferBehind",val:10},initialLiveManifestSize:{key:"minSegmentsStartPlay",val:3},preferManagedMediaSource:{key:"preferMMS",val:!1},lowLatencyMode:{key:"useLowLatency",val:!0}};function getHlsConfig(e,t){var r,n={};_forEachInstanceProperty(r=_Object$keys(optionsMap)).call(r,(function(t){var r=optionsMap[t];n[t]=e[r.key]||r.val}));var a="number"==typeof e.retryCount?e.retryCount:3,i="number"==typeof e.retryDelay?e.retryDelay:1e3,s=e.loadTimeout||1e4,o="number"==typeof e.manifestLoadTimeout?e.manifestLoadTimeout:1e4,l={maxNumRetry:a,retryDelayMs:i,maxRetryDelayMs:i,shouldRetry:function(e,t){return t<e.maxNumRetry}},c={maxNumRetry:a,retryDelayMs:i,maxRetryDelayMs:i,shouldRetry:function(e,t){return t<e.maxNumRetry}};return n.manifestLoadPolicy={default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:o,timeoutRetry:l,errorRetry:c}},n.playlistLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:s,timeoutRetry:l,errorRetry:c}},n.fragLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:s,timeoutRetry:l,errorRetry:c}},_objectSpread2$2(_objectSpread2$2({},n),e)}var MAX_HOLE=.1,XgHls=function(e){_inherits(r,BasePlugin);var t=_createSuper(r);function r(e){var n;_classCallCheck$1(this,r),(n=t.call(this,e))._tickInterval=500,n._onPlay=function(){n.hls.startLoad()},n.onUrlChange=function(e){/^blob/.test(e)||(n.playerConfig.url=e,n.register(e))},n._getBufferend=function(e){var t=e.buffered;return t&&t.length?t.end(t.length-1):0},n._tick=function(){clearTimeout(n._tickTimer);var e=n.player.media;if(e){n._tickTimer=_setTimeout(n._tick,n._tickInterval);var t=n._getBufferend(e);t<MAX_HOLE||!e.readyState||n.player.config.isLive&&4===e.readyState&&e.paused&&t-e.currentTime>n.config.disconnectTime&&n.hls.stopLoad()}},n.on=function(e,t){var r;null==(r=n.hls)||r.on(e,t)};var a=e.config||{};return n.config=a,n.player.handleSource=!1,n}return _createClass$1(r,[{key:"beforePlayerInit",value:function(){this.register(this.player.config.url)}},{key:"initEvt",value:function(){var e=this;this.hls.on(Hls.Events.SUBTITLE_FRAG_PROCESSED,(function(t,r){var n=r.frag;e.player.emit("core_event",{eventName:"core.subtitlesegments",list:n})})),this.hls.on(Hls.Events.MANIFEST_PARSED,(function(t,r){var n=r.levels;e.player.emit("core_event",{eventName:"core.subtitleplaylist",list:n})})),this.hls.on(Hls.Events.MANIFEST_LOADING,(function(t,r){var n=r.url;e.player.emit("core_event",{eventName:"core.loadstart",url:n})})),this.hls.on(Hls.Events.LEVEL_LOADING,(function(t,r){var n=r.url;e.player.emit("core_event",{eventName:"core.loadstart",url:n})})),this.hls.on(Hls.Events.FRAG_LOADING,(function(t,r){var n=r.frag;e.player.emit("core_event",{eventName:"core.loadstart",url:n.url})})),this.hls.on(Hls.Events.MANIFEST_LOADED,(function(t,r){var n=r.url;e.player.emit("core_event",{eventName:"core.loadcomplete",url:n})})),this.hls.on(Hls.Events.LEVEL_LOADED,(function(t,r){var n=r.details,a=r.stats;e.player.emit("core_event",_objectSpread2$2(_objectSpread2$2({eventName:"core.loadcomplete"},a),{},{url:null==n?void 0:n.url}))})),this.hls.on(Hls.Events.FRAG_LOADED,(function(t,r){var n=r.frag;e.player.emit("core_event",{eventName:"core.loadcomplete",url:n.url})})),this.hls.on(Hls.Events.FRAG_PARSING_USERDATA,(function(t,r){var n=r.samples;e.player.emit("core_event",{eventName:"core.sei",sei:n})})),this.hls.on(Hls.Events.MANIFEST_LOADED,(function(t,r){var n=r.levels,a=r.networkDetails;e.player.emit("core_event",{eventName:"core.hlsmanifestloaded",playlist:n}),e.player.emit("core_event",{eventName:"core.loadresponseheaders",headers:a.headers})})),this.hls.on(Hls.Events.LEVEL_LOADED,(function(t,r){var n,a=r.details,i={};_forEachInstanceProperty(n=_Object$keys(a.dateRanges)).call(n,(function(e){i[e]=a.dateRanges[e].attr["START-DATE"]})),e.player.emit("core_event",{eventName:"core.hlslevelloaded",playlist:_objectSpread2$2(_objectSpread2$2({},a),{},{segments:a.fragments,dateRanges:i})})})),this.hls.on(Hls.Events.ERROR,(function(t,r){var n=r.details,a=r.fatal,i=r.type,s=r.response,o=r.reason,l=r.error;if(a){var c,u;switch(i){case Hls.ErrorTypes.NETWORK_ERROR:c=2100,_includesInstanceProperty(n).call(n,"TimeOut")?c=2101:403===(null==s?void 0:s.code)?c=2103:404===(null==s?void 0:s.code)&&(c=2104),e.player.emit("error",{errorType:"network",errorCode:c,message:(null==l?void 0:l.message)||n,originError:r});break;case Hls.ErrorTypes.MEDIA_ERROR:u="media",n===Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?c=5104:n===Hls.ErrorDetails.FRAG_DECRYPT_ERROR?c=5105:n===Hls.ErrorDetails.FRAG_PARSING_ERROR?(c=1100,u="manifest"):n===Hls.ErrorDetails.FRAG_GAP?c=5104:n===Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR?c=5200:n===Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR?c=5104:n===Hls.ErrorDetails.BUFFER_APPEND_ERROR||n===Hls.ErrorDetails.BUFFER_APPENDING_ERROR?c=5201:n===Hls.ErrorDetails.BUFFER_STALLED_ERROR||n===Hls.ErrorDetails.BUFFER_FULL_ERROR?c=5203:(n===Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE||n===Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL)&&(c=5202),e.player.emit("error",{errorType:u||i,errorCode:c,message:(null==l?void 0:l.message)||n,originError:r});break;case Hls.ErrorTypes.MUX_ERROR:c=4100,e.player.emit("error",{errorType:"remux",errorCode:c,message:(null==l?void 0:l.message)||n,originError:r});break;case Hls.ErrorTypes.KEY_SYSTEM_ERROR:c=7111,n===Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS?c=7103:n===Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS?c=7101:n===Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION?c=7104:n===Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?c=7107:n===Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED?c=7108:n===Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED||n===Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?c=7110:n===Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?c=7104:n===Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR&&(c=7111),e.player.emit("error",{errorType:"drm",errorCode:c,message:(null==l?void 0:l.message)||o||n,originError:r});break;default:n===Hls.ErrorDetails.LEVEL_SWITCH_ERROR&&(c=2100,u="network"),e.player.emit("error",{errorType:u||"other",errorCode:c,message:(null==l?void 0:l.message)||o||n,originError:r})}try{e.hls.stopLoad(),e.player.pause()}catch(e){}}})),this.hls.on(Hls.Events.MEDIA_ATTACHED,(function(){e.player.emit("sourceopen")})),this.hls.on(Hls.Events.BUFFER_APPENDED,(function(){e.player.emit("bufferappend")}))}},{key:"afterCreate",value:function(){var e=this.player.media;this.player.on(URL_CHANGE,this.onUrlChange);try{BasePlugin.defineGetterOrSetter(this.player,{url:{get:function(){try{return e.src}catch(e){return null}},configurable:!0}})}catch(e){}}},{key:"register",value:function(e){var t=this.player;this.hls&&this.hls.destroy();var r=getHlsConfig(this.config,t.config);(this.hls=new Hls(r),this.initEvt(),t.config.preProcessUrl)&&(e=t.config.preProcessUrl(e).url);this.hls.loadSource(e);var n=this.player.media;this.hls.attachMedia(n),clearTimeout(this._tickTimer),this._tickTimer=_setTimeout(this._tick,this._tickInterval),n.removeEventListener("play",this._onPlay),n.addEventListener("play",this._onPlay)}},{key:"destroy",value:function(){clearTimeout(this._tickTimer),this.player.off(URL_CHANGE,this.onUrlChange),this.hls.destroy()}}],[{key:"pluginName",get:function(){return"hls"}}]),r}(),HlsPlugin=function(e){_inherits(r,XgHls);var t=_createSuper(r);function r(){return _classCallCheck$1(this,r),t.apply(this,arguments)}return _createClass$1(r,[{key:"beforePlayerInit",value:function(){_get(_getPrototypeOf(r.prototype),"beforePlayerInit",this).call(this),this._transEvent()}},{key:"_transEvent",value:function(){var e,t=this;_forEachInstanceProperty(e=_Object$values(Events)).call(e,(function(e){e!==Events.ERROR&&t._transCoreEvent(e)}))}},{key:"_transCoreEvent",value:function(e){var t,r=this;null===(t=this.hls)||void 0===t||t.on(e,(function(t){if(r.player){for(var n,a,i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];(n=r.player).emit.apply(n,_concatInstanceProperty(a=[e]).call(a,s))}}))}}]),r}(),DynamicModule=window.VePlayer.DynamicModule,__PLUGIN_NAME__=DynamicModule.PluginHlsJs;export{HlsPlugin,__PLUGIN_NAME__};
|
|
1
|
+
import{DynamicModule}from"@volcengine/veplayer";function _classCallCheck$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs$1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var defineProperty$e={exports:{}},check=function(e){return e&&e.Math==Math&&e},global$s=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||function(){return this}()||commonjsGlobal||Function("return this")(),fails$A=function(e){try{return!!e()}catch(e){return!0}},fails$z=fails$A,functionBindNative=!fails$z((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),NATIVE_BIND$4=functionBindNative,FunctionPrototype$3=Function.prototype,apply$7=FunctionPrototype$3.apply,call$A=FunctionPrototype$3.call,functionApply="object"==typeof Reflect&&Reflect.apply||(NATIVE_BIND$4?call$A.bind(apply$7):function(){return call$A.apply(apply$7,arguments)}),NATIVE_BIND$3=functionBindNative,FunctionPrototype$2=Function.prototype,call$z=FunctionPrototype$2.call,uncurryThisWithBind=NATIVE_BIND$3&&FunctionPrototype$2.bind.bind(call$z,call$z),functionUncurryThis=NATIVE_BIND$3?uncurryThisWithBind:function(e){return function(){return call$z.apply(e,arguments)}},uncurryThis$E=functionUncurryThis,toString$i=uncurryThis$E({}.toString),stringSlice$5=uncurryThis$E("".slice),classofRaw$2=function(e){return stringSlice$5(toString$i(e),8,-1)},classofRaw$1=classofRaw$2,uncurryThis$D=functionUncurryThis,functionUncurryThisClause=function(e){if("Function"===classofRaw$1(e))return uncurryThis$D(e)},documentAll$2="object"==typeof document&&document.all,IS_HTMLDDA=void 0===documentAll$2&&void 0!==documentAll$2,documentAll_1={all:documentAll$2,IS_HTMLDDA:IS_HTMLDDA},$documentAll$1=documentAll_1,documentAll$1=$documentAll$1.all,isCallable$r=$documentAll$1.IS_HTMLDDA?function(e){return"function"==typeof e||e===documentAll$1}:function(e){return"function"==typeof e},objectGetOwnPropertyDescriptor={},fails$y=fails$A,descriptors=!fails$y((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),NATIVE_BIND$2=functionBindNative,call$y=Function.prototype.call,functionCall=NATIVE_BIND$2?call$y.bind(call$y):function(){return call$y.apply(call$y,arguments)},objectPropertyIsEnumerable={},$propertyIsEnumerable$2={}.propertyIsEnumerable,getOwnPropertyDescriptor$b=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$b&&!$propertyIsEnumerable$2.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$b(this,e);return!!t&&t.enumerable}:$propertyIsEnumerable$2;var match,version$1,createPropertyDescriptor$8=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},uncurryThis$C=functionUncurryThis,fails$x=fails$A,classof$h=classofRaw$2,$Object$5=Object,split$3=uncurryThis$C("".split),indexedObject=fails$x((function(){return!$Object$5("z").propertyIsEnumerable(0)}))?function(e){return"String"==classof$h(e)?split$3(e,""):$Object$5(e)}:$Object$5,isNullOrUndefined$7=function(e){return null==e},isNullOrUndefined$6=isNullOrUndefined$7,$TypeError$m=TypeError,requireObjectCoercible$8=function(e){if(isNullOrUndefined$6(e))throw $TypeError$m("Can't call method on "+e);return e},IndexedObject$3=indexedObject,requireObjectCoercible$7=requireObjectCoercible$8,toIndexedObject$c=function(e){return IndexedObject$3(requireObjectCoercible$7(e))},isCallable$q=isCallable$r,$documentAll=documentAll_1,documentAll=$documentAll.all,isObject$m=$documentAll.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:isCallable$q(e)||e===documentAll}:function(e){return"object"==typeof e?null!==e:isCallable$q(e)},path$y={},path$x=path$y,global$r=global$s,isCallable$p=isCallable$r,aFunction=function(e){return isCallable$p(e)?e:void 0},getBuiltIn$j=function(e,t){return arguments.length<2?aFunction(path$x[e])||aFunction(global$r[e]):path$x[e]&&path$x[e][t]||global$r[e]&&global$r[e][t]},uncurryThis$B=functionUncurryThis,objectIsPrototypeOf=uncurryThis$B({}.isPrototypeOf),engineUserAgent="undefined"!=typeof navigator&&String(navigator.userAgent)||"",global$q=global$s,userAgent$6=engineUserAgent,process$4=global$q.process,Deno$1=global$q.Deno,versions=process$4&&process$4.versions||Deno$1&&Deno$1.version,v8=versions&&versions.v8;v8&&(version$1=(match=v8.split("."))[0]>0&&match[0]<4?1:+(match[0]+match[1])),!version$1&&userAgent$6&&(!(match=userAgent$6.match(/Edge\/(\d+)/))||match[1]>=74)&&(match=userAgent$6.match(/Chrome\/(\d+)/))&&(version$1=+match[1]);var engineV8Version=version$1,V8_VERSION$3=engineV8Version,fails$w=fails$A,global$p=global$s,$String$5=global$p.String,symbolConstructorDetection=!!Object.getOwnPropertySymbols&&!fails$w((function(){var e=Symbol();return!$String$5(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&V8_VERSION$3&&V8_VERSION$3<41})),NATIVE_SYMBOL$5=symbolConstructorDetection,useSymbolAsUid=NATIVE_SYMBOL$5&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,getBuiltIn$i=getBuiltIn$j,isCallable$o=isCallable$r,isPrototypeOf$s=objectIsPrototypeOf,USE_SYMBOL_AS_UID$1=useSymbolAsUid,$Object$4=Object,isSymbol$5=USE_SYMBOL_AS_UID$1?function(e){return"symbol"==typeof e}:function(e){var t=getBuiltIn$i("Symbol");return isCallable$o(t)&&isPrototypeOf$s(t.prototype,$Object$4(e))},$String$4=String,tryToString$8=function(e){try{return $String$4(e)}catch(e){return"Object"}},isCallable$n=isCallable$r,tryToString$7=tryToString$8,$TypeError$l=TypeError,aCallable$l=function(e){if(isCallable$n(e))return e;throw $TypeError$l(tryToString$7(e)+" is not a function")},aCallable$k=aCallable$l,isNullOrUndefined$5=isNullOrUndefined$7,getMethod$3=function(e,t){var r=e[t];return isNullOrUndefined$5(r)?void 0:aCallable$k(r)},call$x=functionCall,isCallable$m=isCallable$r,isObject$l=isObject$m,$TypeError$k=TypeError,ordinaryToPrimitive$1=function(e,t){var r,n;if("string"===t&&isCallable$m(r=e.toString)&&!isObject$l(n=call$x(r,e)))return n;if(isCallable$m(r=e.valueOf)&&!isObject$l(n=call$x(r,e)))return n;if("string"!==t&&isCallable$m(r=e.toString)&&!isObject$l(n=call$x(r,e)))return n;throw $TypeError$k("Can't convert object to primitive value")},shared$7={exports:{}},isPure=!0,global$o=global$s,defineProperty$d=Object.defineProperty,defineGlobalProperty$1=function(e,t){try{defineProperty$d(global$o,e,{value:t,configurable:!0,writable:!0})}catch(r){global$o[e]=t}return t},global$n=global$s,defineGlobalProperty=defineGlobalProperty$1,SHARED="__core-js_shared__",store$3=global$n[SHARED]||defineGlobalProperty(SHARED,{}),sharedStore=store$3,store$2=sharedStore;(shared$7.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"});var sharedExports=shared$7.exports,requireObjectCoercible$6=requireObjectCoercible$8,$Object$3=Object,toObject$d=function(e){return $Object$3(requireObjectCoercible$6(e))},uncurryThis$A=functionUncurryThis,toObject$c=toObject$d,hasOwnProperty=uncurryThis$A({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty(toObject$c(e),t)},uncurryThis$z=functionUncurryThis,id$1=0,postfix=Math.random(),toString$h=uncurryThis$z(1..toString),uid$4=function(e){return"Symbol("+(void 0===e?"":e)+")_"+toString$h(++id$1+postfix,36)},global$m=global$s,shared$6=sharedExports,hasOwn$n=hasOwnProperty_1,uid$3=uid$4,NATIVE_SYMBOL$4=symbolConstructorDetection,USE_SYMBOL_AS_UID=useSymbolAsUid,Symbol$5=global$m.Symbol,WellKnownSymbolsStore$2=shared$6("wks"),createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol$5.for||Symbol$5:Symbol$5&&Symbol$5.withoutSetter||uid$3,wellKnownSymbol$r=function(e){return hasOwn$n(WellKnownSymbolsStore$2,e)||(WellKnownSymbolsStore$2[e]=NATIVE_SYMBOL$4&&hasOwn$n(Symbol$5,e)?Symbol$5[e]:createWellKnownSymbol("Symbol."+e)),WellKnownSymbolsStore$2[e]},call$w=functionCall,isObject$k=isObject$m,isSymbol$4=isSymbol$5,getMethod$2=getMethod$3,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$q=wellKnownSymbol$r,$TypeError$j=TypeError,TO_PRIMITIVE=wellKnownSymbol$q("toPrimitive"),toPrimitive$7=function(e,t){if(!isObject$k(e)||isSymbol$4(e))return e;var r,n=getMethod$2(e,TO_PRIMITIVE);if(n){if(void 0===t&&(t="default"),r=call$w(n,e,t),!isObject$k(r)||isSymbol$4(r))return r;throw $TypeError$j("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive$6=toPrimitive$7,isSymbol$3=isSymbol$5,toPropertyKey$4=function(e){var t=toPrimitive$6(e,"string");return isSymbol$3(t)?t:t+""},global$l=global$s,isObject$j=isObject$m,document$3=global$l.document,EXISTS$1=isObject$j(document$3)&&isObject$j(document$3.createElement),documentCreateElement$1=function(e){return EXISTS$1?document$3.createElement(e):{}},DESCRIPTORS$l=descriptors,fails$v=fails$A,createElement$1=documentCreateElement$1,ie8DomDefine=!DESCRIPTORS$l&&!fails$v((function(){return 7!=Object.defineProperty(createElement$1("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$k=descriptors,call$v=functionCall,propertyIsEnumerableModule$2=objectPropertyIsEnumerable,createPropertyDescriptor$7=createPropertyDescriptor$8,toIndexedObject$b=toIndexedObject$c,toPropertyKey$3=toPropertyKey$4,hasOwn$m=hasOwnProperty_1,IE8_DOM_DEFINE$1=ie8DomDefine,$getOwnPropertyDescriptor$2=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$k?$getOwnPropertyDescriptor$2:function(e,t){if(e=toIndexedObject$b(e),t=toPropertyKey$3(t),IE8_DOM_DEFINE$1)try{return $getOwnPropertyDescriptor$2(e,t)}catch(e){}if(hasOwn$m(e,t))return createPropertyDescriptor$7(!call$v(propertyIsEnumerableModule$2.f,e,t),e[t])};var fails$u=fails$A,isCallable$l=isCallable$r,replacement=/#|\.prototype\./,isForced$2=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&(isCallable$l(t)?fails$u(t):!!t)},normalize=isForced$2.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$2.data={},NATIVE=isForced$2.NATIVE="N",POLYFILL=isForced$2.POLYFILL="P",isForced_1=isForced$2,uncurryThis$y=functionUncurryThisClause,aCallable$j=aCallable$l,NATIVE_BIND$1=functionBindNative,bind$w=functionUncurryThisClause(functionUncurryThisClause.bind),functionBindContext=function(e,t){return aCallable$j(e),void 0===t?e:NATIVE_BIND$1?bind$w(e,t):function(){return e.apply(t,arguments)}},objectDefineProperty={},DESCRIPTORS$j=descriptors,fails$t=fails$A,v8PrototypeDefineBug=DESCRIPTORS$j&&fails$t((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),isObject$i=isObject$m,$String$3=String,$TypeError$i=TypeError,anObject$i=function(e){if(isObject$i(e))return e;throw $TypeError$i($String$3(e)+" is not an object")},DESCRIPTORS$i=descriptors,IE8_DOM_DEFINE=ie8DomDefine,V8_PROTOTYPE_DEFINE_BUG$1=v8PrototypeDefineBug,anObject$h=anObject$i,toPropertyKey$2=toPropertyKey$4,$TypeError$h=TypeError,$defineProperty$1=Object.defineProperty,$getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor,ENUMERABLE="enumerable",CONFIGURABLE$1="configurable",WRITABLE="writable";objectDefineProperty.f=DESCRIPTORS$i?V8_PROTOTYPE_DEFINE_BUG$1?function(e,t,r){if(anObject$h(e),t=toPropertyKey$2(t),anObject$h(r),"function"==typeof e&&"prototype"===t&&"value"in r&&WRITABLE in r&&!r[WRITABLE]){var n=$getOwnPropertyDescriptor$1(e,t);n&&n[WRITABLE]&&(e[t]=r.value,r={configurable:CONFIGURABLE$1 in r?r[CONFIGURABLE$1]:n[CONFIGURABLE$1],enumerable:ENUMERABLE in r?r[ENUMERABLE]:n[ENUMERABLE],writable:!1})}return $defineProperty$1(e,t,r)}:$defineProperty$1:function(e,t,r){if(anObject$h(e),t=toPropertyKey$2(t),anObject$h(r),IE8_DOM_DEFINE)try{return $defineProperty$1(e,t,r)}catch(e){}if("get"in r||"set"in r)throw $TypeError$h("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var DESCRIPTORS$h=descriptors,definePropertyModule$4=objectDefineProperty,createPropertyDescriptor$6=createPropertyDescriptor$8,createNonEnumerableProperty$9=DESCRIPTORS$h?function(e,t,r){return definePropertyModule$4.f(e,t,createPropertyDescriptor$6(1,r))}:function(e,t,r){return e[t]=r,e},global$k=global$s,apply$6=functionApply,uncurryThis$x=functionUncurryThisClause,isCallable$k=isCallable$r,getOwnPropertyDescriptor$a=objectGetOwnPropertyDescriptor.f,isForced$1=isForced_1,path$w=path$y,bind$v=functionBindContext,createNonEnumerableProperty$8=createNonEnumerableProperty$9,hasOwn$l=hasOwnProperty_1,wrapConstructor=function(e){var t=function(r,n,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,a)}return apply$6(e,this,arguments)};return t.prototype=e.prototype,t},_export=function(e,t){var r,n,a,i,s,o,l,c,u,d=e.target,f=e.global,h=e.stat,p=e.proto,y=f?global$k:h?global$k[d]:(global$k[d]||{}).prototype,g=f?path$w:path$w[d]||createNonEnumerableProperty$8(path$w,d,{})[d],v=g.prototype;for(i in t)n=!(r=isForced$1(f?i:d+(h?".":"#")+i,e.forced))&&y&&hasOwn$l(y,i),o=g[i],n&&(l=e.dontCallGetSet?(u=getOwnPropertyDescriptor$a(y,i))&&u.value:y[i]),s=n&&l?l:t[i],n&&typeof o==typeof s||(c=e.bind&&n?bind$v(s,global$k):e.wrap&&n?wrapConstructor(s):p&&isCallable$k(s)?uncurryThis$x(s):s,(e.sham||s&&s.sham||o&&o.sham)&&createNonEnumerableProperty$8(c,"sham",!0),createNonEnumerableProperty$8(g,i,c),p&&(hasOwn$l(path$w,a=d+"Prototype")||createNonEnumerableProperty$8(path$w,a,{}),createNonEnumerableProperty$8(path$w[a],i,s),e.real&&v&&(r||!v[i])&&createNonEnumerableProperty$8(v,i,s)))},$$1O=_export,DESCRIPTORS$g=descriptors,defineProperty$c=objectDefineProperty.f;$$1O({target:"Object",stat:!0,forced:Object.defineProperty!==defineProperty$c,sham:!DESCRIPTORS$g},{defineProperty:defineProperty$c});var path$v=path$y,Object$4=path$v.Object,defineProperty$b=defineProperty$e.exports=function(e,t,r){return Object$4.defineProperty(e,t,r)};Object$4.defineProperty.sham&&(defineProperty$b.sham=!0);var definePropertyExports=defineProperty$e.exports,parent$2H=definePropertyExports,defineProperty$a=parent$2H,parent$2G=defineProperty$a,defineProperty$9=parent$2G,parent$2F=defineProperty$9,defineProperty$8=parent$2F,defineProperty$7=defineProperty$8,_Object$defineProperty$1=getDefaultExportFromCjs$1(defineProperty$7),classof$g=classofRaw$2,isArray$d=Array.isArray||function(e){return"Array"==classof$g(e)},ceil$1=Math.ceil,floor$4=Math.floor,mathTrunc=Math.trunc||function(e){var t=+e;return(t>0?floor$4:ceil$1)(t)},trunc2=mathTrunc,toIntegerOrInfinity$7=function(e){var t=+e;return t!=t||0===t?0:trunc2(t)},toIntegerOrInfinity$6=toIntegerOrInfinity$7,min$4=Math.min,toLength$3=function(e){return e>0?min$4(toIntegerOrInfinity$6(e),9007199254740991):0},toLength$2=toLength$3,lengthOfArrayLike$c=function(e){return toLength$2(e.length)},$TypeError$g=TypeError,MAX_SAFE_INTEGER$1=9007199254740991,doesNotExceedSafeInteger$3=function(e){if(e>MAX_SAFE_INTEGER$1)throw $TypeError$g("Maximum allowed index exceeded");return e},toPropertyKey$1=toPropertyKey$4,definePropertyModule$3=objectDefineProperty,createPropertyDescriptor$5=createPropertyDescriptor$8,createProperty$6=function(e,t,r){var n=toPropertyKey$1(t);n in e?definePropertyModule$3.f(e,n,createPropertyDescriptor$5(0,r)):e[n]=r},wellKnownSymbol$p=wellKnownSymbol$r,TO_STRING_TAG$4=wellKnownSymbol$p("toStringTag"),test$2={};test$2[TO_STRING_TAG$4]="z";var toStringTagSupport="[object z]"===String(test$2),TO_STRING_TAG_SUPPORT$2=toStringTagSupport,isCallable$j=isCallable$r,classofRaw=classofRaw$2,wellKnownSymbol$o=wellKnownSymbol$r,TO_STRING_TAG$3=wellKnownSymbol$o("toStringTag"),$Object$2=Object,CORRECT_ARGUMENTS="Arguments"==classofRaw(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},classof$f=TO_STRING_TAG_SUPPORT$2?classofRaw:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=$Object$2(e),TO_STRING_TAG$3))?r:CORRECT_ARGUMENTS?classofRaw(t):"Object"==(n=classofRaw(t))&&isCallable$j(t.callee)?"Arguments":n},uncurryThis$w=functionUncurryThis,isCallable$i=isCallable$r,store$1=sharedStore,functionToString=uncurryThis$w(Function.toString);isCallable$i(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var inspectSource$2=store$1.inspectSource,uncurryThis$v=functionUncurryThis,fails$s=fails$A,isCallable$h=isCallable$r,classof$e=classof$f,getBuiltIn$h=getBuiltIn$j,inspectSource$1=inspectSource$2,noop$1=function(){},empty=[],construct$6=getBuiltIn$h("Reflect","construct"),constructorRegExp=/^\s*(?:class|function)\b/,exec$4=uncurryThis$v(constructorRegExp.exec),INCORRECT_TO_STRING=!constructorRegExp.exec(noop$1),isConstructorModern=function(e){if(!isCallable$h(e))return!1;try{return construct$6(noop$1,empty,e),!0}catch(e){return!1}},isConstructorLegacy=function(e){if(!isCallable$h(e))return!1;switch(classof$e(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return INCORRECT_TO_STRING||!!exec$4(constructorRegExp,inspectSource$1(e))}catch(e){return!0}};isConstructorLegacy.sham=!0;var isConstructor$4=!construct$6||fails$s((function(){var e;return isConstructorModern(isConstructorModern.call)||!isConstructorModern(Object)||!isConstructorModern((function(){e=!0}))||e}))?isConstructorLegacy:isConstructorModern,isArray$c=isArray$d,isConstructor$3=isConstructor$4,isObject$h=isObject$m,wellKnownSymbol$n=wellKnownSymbol$r,SPECIES$5=wellKnownSymbol$n("species"),$Array$3=Array,arraySpeciesConstructor$1=function(e){var t;return isArray$c(e)&&(t=e.constructor,(isConstructor$3(t)&&(t===$Array$3||isArray$c(t.prototype))||isObject$h(t)&&null===(t=t[SPECIES$5]))&&(t=void 0)),void 0===t?$Array$3:t},arraySpeciesConstructor=arraySpeciesConstructor$1,arraySpeciesCreate$3=function(e,t){return new(arraySpeciesConstructor(e))(0===t?0:t)},fails$r=fails$A,wellKnownSymbol$m=wellKnownSymbol$r,V8_VERSION$2=engineV8Version,SPECIES$4=wellKnownSymbol$m("species"),arrayMethodHasSpeciesSupport$5=function(e){return V8_VERSION$2>=51||!fails$r((function(){var t=[];return(t.constructor={})[SPECIES$4]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},$$1N=_export,fails$q=fails$A,isArray$b=isArray$d,isObject$g=isObject$m,toObject$b=toObject$d,lengthOfArrayLike$b=lengthOfArrayLike$c,doesNotExceedSafeInteger$2=doesNotExceedSafeInteger$3,createProperty$5=createProperty$6,arraySpeciesCreate$2=arraySpeciesCreate$3,arrayMethodHasSpeciesSupport$4=arrayMethodHasSpeciesSupport$5,wellKnownSymbol$l=wellKnownSymbol$r,V8_VERSION$1=engineV8Version,IS_CONCAT_SPREADABLE=wellKnownSymbol$l("isConcatSpreadable"),IS_CONCAT_SPREADABLE_SUPPORT=V8_VERSION$1>=51||!fails$q((function(){var e=[];return e[IS_CONCAT_SPREADABLE]=!1,e.concat()[0]!==e})),isConcatSpreadable=function(e){if(!isObject$g(e))return!1;var t=e[IS_CONCAT_SPREADABLE];return void 0!==t?!!t:isArray$b(e)},FORCED$a=!IS_CONCAT_SPREADABLE_SUPPORT||!arrayMethodHasSpeciesSupport$4("concat");$$1N({target:"Array",proto:!0,arity:1,forced:FORCED$a},{concat:function(e){var t,r,n,a,i,s=toObject$b(this),o=arraySpeciesCreate$2(s,0),l=0;for(t=-1,n=arguments.length;t<n;t++)if(isConcatSpreadable(i=-1===t?s:arguments[t]))for(a=lengthOfArrayLike$b(i),doesNotExceedSafeInteger$2(l+a),r=0;r<a;r++,l++)r in i&&createProperty$5(o,l,i[r]);else doesNotExceedSafeInteger$2(l+1),createProperty$5(o,l++,i);return o.length=l,o}});var classof$d=classof$f,$String$2=String,toString$g=function(e){if("Symbol"===classof$d(e))throw TypeError("Cannot convert a Symbol value to a string");return $String$2(e)},objectDefineProperties={},toIntegerOrInfinity$5=toIntegerOrInfinity$7,max$4=Math.max,min$3=Math.min,toAbsoluteIndex$4=function(e,t){var r=toIntegerOrInfinity$5(e);return r<0?max$4(r+t,0):min$3(r,t)},toIndexedObject$a=toIndexedObject$c,toAbsoluteIndex$3=toAbsoluteIndex$4,lengthOfArrayLike$a=lengthOfArrayLike$c,createMethod$6=function(e){return function(t,r,n){var a,i=toIndexedObject$a(t),s=lengthOfArrayLike$a(i),o=toAbsoluteIndex$3(n,s);if(e&&r!=r){for(;s>o;)if((a=i[o++])!=a)return!0}else for(;s>o;o++)if((e||o in i)&&i[o]===r)return e||o||0;return!e&&-1}},arrayIncludes={includes:createMethod$6(!0),indexOf:createMethod$6(!1)},hiddenKeys$6={},uncurryThis$u=functionUncurryThis,hasOwn$k=hasOwnProperty_1,toIndexedObject$9=toIndexedObject$c,indexOf$7=arrayIncludes.indexOf,hiddenKeys$5=hiddenKeys$6,push$k=uncurryThis$u([].push),objectKeysInternal=function(e,t){var r,n=toIndexedObject$9(e),a=0,i=[];for(r in n)!hasOwn$k(hiddenKeys$5,r)&&hasOwn$k(n,r)&&push$k(i,r);for(;t.length>a;)hasOwn$k(n,r=t[a++])&&(~indexOf$7(i,r)||push$k(i,r));return i},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,objectKeys$4=Object.keys||function(e){return internalObjectKeys$1(e,enumBugKeys$2)},DESCRIPTORS$f=descriptors,V8_PROTOTYPE_DEFINE_BUG=v8PrototypeDefineBug,definePropertyModule$2=objectDefineProperty,anObject$g=anObject$i,toIndexedObject$8=toIndexedObject$c,objectKeys$3=objectKeys$4;objectDefineProperties.f=DESCRIPTORS$f&&!V8_PROTOTYPE_DEFINE_BUG?Object.defineProperties:function(e,t){anObject$g(e);for(var r,n=toIndexedObject$8(t),a=objectKeys$3(t),i=a.length,s=0;i>s;)definePropertyModule$2.f(e,r=a[s++],n[r]);return e};var activeXDocument,getBuiltIn$g=getBuiltIn$j,html$2=getBuiltIn$g("document","documentElement"),shared$5=sharedExports,uid$2=uid$4,keys$6=shared$5("keys"),sharedKey$4=function(e){return keys$6[e]||(keys$6[e]=uid$2(e))},anObject$f=anObject$i,definePropertiesModule$1=objectDefineProperties,enumBugKeys$1=enumBugKeys$3,hiddenKeys$4=hiddenKeys$6,html$1=html$2,documentCreateElement=documentCreateElement$1,sharedKey$3=sharedKey$4,GT=">",LT="<",PROTOTYPE$1="prototype",SCRIPT="script",IE_PROTO$1=sharedKey$3("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return LT+SCRIPT+GT+e+LT+"/"+SCRIPT+GT},NullProtoObjectViaActiveX=function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t},NullProtoObjectViaIFrame=function(){var e,t=documentCreateElement("iframe"),r="java"+SCRIPT+":";return t.style.display="none",html$1.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(scriptTag("document.F=Object")),e.close(),e.F},NullProtoObject=function(){try{activeXDocument=new ActiveXObject("htmlfile")}catch(e){}NullProtoObject="undefined"!=typeof document?document.domain&&activeXDocument?NullProtoObjectViaActiveX(activeXDocument):NullProtoObjectViaIFrame():NullProtoObjectViaActiveX(activeXDocument);for(var e=enumBugKeys$1.length;e--;)delete NullProtoObject[PROTOTYPE$1][enumBugKeys$1[e]];return NullProtoObject()};hiddenKeys$4[IE_PROTO$1]=!0;var objectCreate=Object.create||function(e,t){var r;return null!==e?(EmptyConstructor[PROTOTYPE$1]=anObject$f(e),r=new EmptyConstructor,EmptyConstructor[PROTOTYPE$1]=null,r[IE_PROTO$1]=e):r=NullProtoObject(),void 0===t?r:definePropertiesModule$1.f(r,t)},objectGetOwnPropertyNames={},internalObjectKeys=objectKeysInternal,enumBugKeys=enumBugKeys$3,hiddenKeys$3=enumBugKeys.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys(e,hiddenKeys$3)};var objectGetOwnPropertyNamesExternal={},toAbsoluteIndex$2=toAbsoluteIndex$4,lengthOfArrayLike$9=lengthOfArrayLike$c,createProperty$4=createProperty$6,$Array$2=Array,max$3=Math.max,arraySliceSimple=function(e,t,r){for(var n=lengthOfArrayLike$9(e),a=toAbsoluteIndex$2(t,n),i=toAbsoluteIndex$2(void 0===r?n:r,n),s=$Array$2(max$3(i-a,0)),o=0;a<i;a++,o++)createProperty$4(s,o,e[a]);return s.length=o,s},classof$c=classofRaw$2,toIndexedObject$7=toIndexedObject$c,$getOwnPropertyNames$1=objectGetOwnPropertyNames.f,arraySlice$8=arraySliceSimple,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return $getOwnPropertyNames$1(e)}catch(e){return arraySlice$8(windowNames)}};objectGetOwnPropertyNamesExternal.f=function(e){return windowNames&&"Window"==classof$c(e)?getWindowNames(e):$getOwnPropertyNames$1(toIndexedObject$7(e))};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var createNonEnumerableProperty$7=createNonEnumerableProperty$9,defineBuiltIn$8=function(e,t,r,n){return n&&n.enumerable?e[t]=r:createNonEnumerableProperty$7(e,t,r),e},defineProperty$6=objectDefineProperty,defineBuiltInAccessor$5=function(e,t,r){return defineProperty$6.f(e,t,r)},wellKnownSymbolWrapped={},wellKnownSymbol$k=wellKnownSymbol$r;wellKnownSymbolWrapped.f=wellKnownSymbol$k;var set$d,get$8,has$7,path$u=path$y,hasOwn$j=hasOwnProperty_1,wrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,defineProperty$5=objectDefineProperty.f,wellKnownSymbolDefine=function(e){var t=path$u.Symbol||(path$u.Symbol={});hasOwn$j(t,e)||defineProperty$5(t,e,{value:wrappedWellKnownSymbolModule$1.f(e)})},call$u=functionCall,getBuiltIn$f=getBuiltIn$j,wellKnownSymbol$j=wellKnownSymbol$r,defineBuiltIn$7=defineBuiltIn$8,symbolDefineToPrimitive=function(){var e=getBuiltIn$f("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=wellKnownSymbol$j("toPrimitive");t&&!t[n]&&defineBuiltIn$7(t,n,(function(e){return call$u(r,this)}),{arity:1})},TO_STRING_TAG_SUPPORT$1=toStringTagSupport,classof$b=classof$f,objectToString=TO_STRING_TAG_SUPPORT$1?{}.toString:function(){return"[object "+classof$b(this)+"]"},TO_STRING_TAG_SUPPORT=toStringTagSupport,defineProperty$4=objectDefineProperty.f,createNonEnumerableProperty$6=createNonEnumerableProperty$9,hasOwn$i=hasOwnProperty_1,toString$f=objectToString,wellKnownSymbol$i=wellKnownSymbol$r,TO_STRING_TAG$2=wellKnownSymbol$i("toStringTag"),setToStringTag$9=function(e,t,r,n){if(e){var a=r?e:e.prototype;hasOwn$i(a,TO_STRING_TAG$2)||defineProperty$4(a,TO_STRING_TAG$2,{configurable:!0,value:t}),n&&!TO_STRING_TAG_SUPPORT&&createNonEnumerableProperty$6(a,"toString",toString$f)}},global$j=global$s,isCallable$g=isCallable$r,WeakMap$1=global$j.WeakMap,weakMapBasicDetection=isCallable$g(WeakMap$1)&&/native code/.test(String(WeakMap$1)),NATIVE_WEAK_MAP=weakMapBasicDetection,global$i=global$s,isObject$f=isObject$m,createNonEnumerableProperty$5=createNonEnumerableProperty$9,hasOwn$h=hasOwnProperty_1,shared$4=sharedStore,sharedKey$2=sharedKey$4,hiddenKeys$2=hiddenKeys$6,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$5=global$i.TypeError,WeakMap=global$i.WeakMap,enforce=function(e){return has$7(e)?get$8(e):set$d(e,{})},getterFor=function(e){return function(t){var r;if(!isObject$f(t)||(r=get$8(t)).type!==e)throw TypeError$5("Incompatible receiver, "+e+" required");return r}};if(NATIVE_WEAK_MAP||shared$4.state){var store=shared$4.state||(shared$4.state=new WeakMap);store.get=store.get,store.has=store.has,store.set=store.set,set$d=function(e,t){if(store.has(e))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,store.set(e,t),t},get$8=function(e){return store.get(e)||{}},has$7=function(e){return store.has(e)}}else{var STATE=sharedKey$2("state");hiddenKeys$2[STATE]=!0,set$d=function(e,t){if(hasOwn$h(e,STATE))throw TypeError$5(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$5(e,STATE,t),t},get$8=function(e){return hasOwn$h(e,STATE)?e[STATE]:{}},has$7=function(e){return hasOwn$h(e,STATE)}}var internalState={set:set$d,get:get$8,has:has$7,enforce:enforce,getterFor:getterFor},bind$u=functionBindContext,uncurryThis$t=functionUncurryThis,IndexedObject$2=indexedObject,toObject$a=toObject$d,lengthOfArrayLike$8=lengthOfArrayLike$c,arraySpeciesCreate$1=arraySpeciesCreate$3,push$j=uncurryThis$t([].push),createMethod$5=function(e){var t=1==e,r=2==e,n=3==e,a=4==e,i=6==e,s=7==e,o=5==e||i;return function(l,c,u,d){for(var f,h,p=toObject$a(l),y=IndexedObject$2(p),g=bind$u(c,u),v=lengthOfArrayLike$8(y),m=0,E=d||arraySpeciesCreate$1,$=t?E(l,v):r||s?E(l,0):void 0;v>m;m++)if((o||m in y)&&(h=g(f=y[m],m,p),e))if(t)$[m]=h;else if(h)switch(e){case 3:return!0;case 5:return f;case 6:return m;case 2:push$j($,f)}else switch(e){case 4:return!1;case 7:push$j($,f)}return i?-1:n||a?a:$}},arrayIteration={forEach:createMethod$5(0),map:createMethod$5(1),filter:createMethod$5(2),some:createMethod$5(3),every:createMethod$5(4),find:createMethod$5(5),findIndex:createMethod$5(6),filterReject:createMethod$5(7)},$$1M=_export,global$h=global$s,call$t=functionCall,uncurryThis$s=functionUncurryThis,DESCRIPTORS$e=descriptors,NATIVE_SYMBOL$3=symbolConstructorDetection,fails$p=fails$A,hasOwn$g=hasOwnProperty_1,isPrototypeOf$r=objectIsPrototypeOf,anObject$e=anObject$i,toIndexedObject$6=toIndexedObject$c,toPropertyKey=toPropertyKey$4,$toString$2=toString$g,createPropertyDescriptor$4=createPropertyDescriptor$8,nativeObjectCreate=objectCreate,objectKeys$2=objectKeys$4,getOwnPropertyNamesModule$2=objectGetOwnPropertyNames,getOwnPropertyNamesExternal=objectGetOwnPropertyNamesExternal,getOwnPropertySymbolsModule$3=objectGetOwnPropertySymbols,getOwnPropertyDescriptorModule$3=objectGetOwnPropertyDescriptor,definePropertyModule$1=objectDefineProperty,definePropertiesModule=objectDefineProperties,propertyIsEnumerableModule$1=objectPropertyIsEnumerable,defineBuiltIn$6=defineBuiltIn$8,defineBuiltInAccessor$4=defineBuiltInAccessor$5,shared$3=sharedExports,sharedKey$1=sharedKey$4,hiddenKeys$1=hiddenKeys$6,uid$1=uid$4,wellKnownSymbol$h=wellKnownSymbol$r,wrappedWellKnownSymbolModule=wellKnownSymbolWrapped,defineWellKnownSymbol$l=wellKnownSymbolDefine,defineSymbolToPrimitive$1=symbolDefineToPrimitive,setToStringTag$8=setToStringTag$9,InternalStateModule$7=internalState,$forEach$1=arrayIteration.forEach,HIDDEN=sharedKey$1("hidden"),SYMBOL="Symbol",PROTOTYPE="prototype",setInternalState$7=InternalStateModule$7.set,getInternalState$2=InternalStateModule$7.getterFor(SYMBOL),ObjectPrototype$2=Object[PROTOTYPE],$Symbol=global$h.Symbol,SymbolPrototype=$Symbol&&$Symbol[PROTOTYPE],TypeError$4=global$h.TypeError,QObject=global$h.QObject,nativeGetOwnPropertyDescriptor$1=getOwnPropertyDescriptorModule$3.f,nativeDefineProperty=definePropertyModule$1.f,nativeGetOwnPropertyNames=getOwnPropertyNamesExternal.f,nativePropertyIsEnumerable=propertyIsEnumerableModule$1.f,push$i=uncurryThis$s([].push),AllSymbols=shared$3("symbols"),ObjectPrototypeSymbols=shared$3("op-symbols"),WellKnownSymbolsStore$1=shared$3("wks"),USE_SETTER=!QObject||!QObject[PROTOTYPE]||!QObject[PROTOTYPE].findChild,setSymbolDescriptor=DESCRIPTORS$e&&fails$p((function(){return 7!=nativeObjectCreate(nativeDefineProperty({},"a",{get:function(){return nativeDefineProperty(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=nativeGetOwnPropertyDescriptor$1(ObjectPrototype$2,t);n&&delete ObjectPrototype$2[t],nativeDefineProperty(e,t,r),n&&e!==ObjectPrototype$2&&nativeDefineProperty(ObjectPrototype$2,t,n)}:nativeDefineProperty,wrap=function(e,t){var r=AllSymbols[e]=nativeObjectCreate(SymbolPrototype);return setInternalState$7(r,{type:SYMBOL,tag:e,description:t}),DESCRIPTORS$e||(r.description=t),r},$defineProperty=function(e,t,r){e===ObjectPrototype$2&&$defineProperty(ObjectPrototypeSymbols,t,r),anObject$e(e);var n=toPropertyKey(t);return anObject$e(r),hasOwn$g(AllSymbols,n)?(r.enumerable?(hasOwn$g(e,HIDDEN)&&e[HIDDEN][n]&&(e[HIDDEN][n]=!1),r=nativeObjectCreate(r,{enumerable:createPropertyDescriptor$4(0,!1)})):(hasOwn$g(e,HIDDEN)||nativeDefineProperty(e,HIDDEN,createPropertyDescriptor$4(1,{})),e[HIDDEN][n]=!0),setSymbolDescriptor(e,n,r)):nativeDefineProperty(e,n,r)},$defineProperties=function(e,t){anObject$e(e);var r=toIndexedObject$6(t),n=objectKeys$2(r).concat($getOwnPropertySymbols(r));return $forEach$1(n,(function(t){DESCRIPTORS$e&&!call$t($propertyIsEnumerable$1,r,t)||$defineProperty(e,t,r[t])})),e},$create=function(e,t){return void 0===t?nativeObjectCreate(e):$defineProperties(nativeObjectCreate(e),t)},$propertyIsEnumerable$1=function(e){var t=toPropertyKey(e),r=call$t(nativePropertyIsEnumerable,this,t);return!(this===ObjectPrototype$2&&hasOwn$g(AllSymbols,t)&&!hasOwn$g(ObjectPrototypeSymbols,t))&&(!(r||!hasOwn$g(this,t)||!hasOwn$g(AllSymbols,t)||hasOwn$g(this,HIDDEN)&&this[HIDDEN][t])||r)},$getOwnPropertyDescriptor=function(e,t){var r=toIndexedObject$6(e),n=toPropertyKey(t);if(r!==ObjectPrototype$2||!hasOwn$g(AllSymbols,n)||hasOwn$g(ObjectPrototypeSymbols,n)){var a=nativeGetOwnPropertyDescriptor$1(r,n);return!a||!hasOwn$g(AllSymbols,n)||hasOwn$g(r,HIDDEN)&&r[HIDDEN][n]||(a.enumerable=!0),a}},$getOwnPropertyNames=function(e){var t=nativeGetOwnPropertyNames(toIndexedObject$6(e)),r=[];return $forEach$1(t,(function(e){hasOwn$g(AllSymbols,e)||hasOwn$g(hiddenKeys$1,e)||push$i(r,e)})),r},$getOwnPropertySymbols=function(e){var t=e===ObjectPrototype$2,r=nativeGetOwnPropertyNames(t?ObjectPrototypeSymbols:toIndexedObject$6(e)),n=[];return $forEach$1(r,(function(e){!hasOwn$g(AllSymbols,e)||t&&!hasOwn$g(ObjectPrototype$2,e)||push$i(n,AllSymbols[e])})),n};NATIVE_SYMBOL$3||(defineBuiltIn$6(SymbolPrototype=($Symbol=function(){if(isPrototypeOf$r(SymbolPrototype,this))throw TypeError$4("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?$toString$2(arguments[0]):void 0,t=uid$1(e),r=function(e){this===ObjectPrototype$2&&call$t(r,ObjectPrototypeSymbols,e),hasOwn$g(this,HIDDEN)&&hasOwn$g(this[HIDDEN],t)&&(this[HIDDEN][t]=!1),setSymbolDescriptor(this,t,createPropertyDescriptor$4(1,e))};return DESCRIPTORS$e&&USE_SETTER&&setSymbolDescriptor(ObjectPrototype$2,t,{configurable:!0,set:r}),wrap(t,e)})[PROTOTYPE],"toString",(function(){return getInternalState$2(this).tag})),defineBuiltIn$6($Symbol,"withoutSetter",(function(e){return wrap(uid$1(e),e)})),propertyIsEnumerableModule$1.f=$propertyIsEnumerable$1,definePropertyModule$1.f=$defineProperty,definePropertiesModule.f=$defineProperties,getOwnPropertyDescriptorModule$3.f=$getOwnPropertyDescriptor,getOwnPropertyNamesModule$2.f=getOwnPropertyNamesExternal.f=$getOwnPropertyNames,getOwnPropertySymbolsModule$3.f=$getOwnPropertySymbols,wrappedWellKnownSymbolModule.f=function(e){return wrap(wellKnownSymbol$h(e),e)},DESCRIPTORS$e&&defineBuiltInAccessor$4(SymbolPrototype,"description",{configurable:!0,get:function(){return getInternalState$2(this).description}})),$$1M({global:!0,constructor:!0,wrap:!0,forced:!NATIVE_SYMBOL$3,sham:!NATIVE_SYMBOL$3},{Symbol:$Symbol}),$forEach$1(objectKeys$2(WellKnownSymbolsStore$1),(function(e){defineWellKnownSymbol$l(e)})),$$1M({target:SYMBOL,stat:!0,forced:!NATIVE_SYMBOL$3},{useSetter:function(){USE_SETTER=!0},useSimple:function(){USE_SETTER=!1}}),$$1M({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3,sham:!DESCRIPTORS$e},{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor}),$$1M({target:"Object",stat:!0,forced:!NATIVE_SYMBOL$3},{getOwnPropertyNames:$getOwnPropertyNames}),defineSymbolToPrimitive$1(),setToStringTag$8($Symbol,SYMBOL),hiddenKeys$1[HIDDEN]=!0;var NATIVE_SYMBOL$2=symbolConstructorDetection,symbolRegistryDetection=NATIVE_SYMBOL$2&&!!Symbol.for&&!!Symbol.keyFor,$$1L=_export,getBuiltIn$e=getBuiltIn$j,hasOwn$f=hasOwnProperty_1,toString$e=toString$g,shared$2=sharedExports,NATIVE_SYMBOL_REGISTRY$1=symbolRegistryDetection,StringToSymbolRegistry=shared$2("string-to-symbol-registry"),SymbolToStringRegistry$1=shared$2("symbol-to-string-registry");$$1L({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY$1},{for:function(e){var t=toString$e(e);if(hasOwn$f(StringToSymbolRegistry,t))return StringToSymbolRegistry[t];var r=getBuiltIn$e("Symbol")(t);return StringToSymbolRegistry[t]=r,SymbolToStringRegistry$1[r]=t,r}});var $$1K=_export,hasOwn$e=hasOwnProperty_1,isSymbol$2=isSymbol$5,tryToString$6=tryToString$8,shared$1=sharedExports,NATIVE_SYMBOL_REGISTRY=symbolRegistryDetection,SymbolToStringRegistry=shared$1("symbol-to-string-registry");$$1K({target:"Symbol",stat:!0,forced:!NATIVE_SYMBOL_REGISTRY},{keyFor:function(e){if(!isSymbol$2(e))throw TypeError(tryToString$6(e)+" is not a symbol");if(hasOwn$e(SymbolToStringRegistry,e))return SymbolToStringRegistry[e]}});var uncurryThis$r=functionUncurryThis,arraySlice$7=uncurryThis$r([].slice),uncurryThis$q=functionUncurryThis,isArray$a=isArray$d,isCallable$f=isCallable$r,classof$a=classofRaw$2,toString$d=toString$g,push$h=uncurryThis$q([].push),getJsonReplacerFunction=function(e){if(isCallable$f(e))return e;if(isArray$a(e)){for(var t=e.length,r=[],n=0;n<t;n++){var a=e[n];"string"==typeof a?push$h(r,a):"number"!=typeof a&&"Number"!=classof$a(a)&&"String"!=classof$a(a)||push$h(r,toString$d(a))}var i=r.length,s=!0;return function(e,t){if(s)return s=!1,t;if(isArray$a(this))return t;for(var n=0;n<i;n++)if(r[n]===e)return t}}},$$1J=_export,getBuiltIn$d=getBuiltIn$j,apply$5=functionApply,call$s=functionCall,uncurryThis$p=functionUncurryThis,fails$o=fails$A,isCallable$e=isCallable$r,isSymbol$1=isSymbol$5,arraySlice$6=arraySlice$7,getReplacerFunction=getJsonReplacerFunction,NATIVE_SYMBOL$1=symbolConstructorDetection,$String$1=String,$stringify=getBuiltIn$d("JSON","stringify"),exec$3=uncurryThis$p(/./.exec),charAt$5=uncurryThis$p("".charAt),charCodeAt$2=uncurryThis$p("".charCodeAt),replace$5=uncurryThis$p("".replace),numberToString$1=uncurryThis$p(1..toString),tester=/[\uD800-\uDFFF]/g,low=/^[\uD800-\uDBFF]$/,hi=/^[\uDC00-\uDFFF]$/,WRONG_SYMBOLS_CONVERSION=!NATIVE_SYMBOL$1||fails$o((function(){var e=getBuiltIn$d("Symbol")();return"[null]"!=$stringify([e])||"{}"!=$stringify({a:e})||"{}"!=$stringify(Object(e))})),ILL_FORMED_UNICODE=fails$o((function(){return'"\\udf06\\ud834"'!==$stringify("\udf06\ud834")||'"\\udead"'!==$stringify("\udead")})),stringifyWithSymbolsFix=function(e,t){var r=arraySlice$6(arguments),n=getReplacerFunction(t);if(isCallable$e(n)||void 0!==e&&!isSymbol$1(e))return r[1]=function(e,t){if(isCallable$e(n)&&(t=call$s(n,this,$String$1(e),t)),!isSymbol$1(t))return t},apply$5($stringify,null,r)},fixIllFormed=function(e,t,r){var n=charAt$5(r,t-1),a=charAt$5(r,t+1);return exec$3(low,e)&&!exec$3(hi,a)||exec$3(hi,e)&&!exec$3(low,n)?"\\u"+numberToString$1(charCodeAt$2(e,0),16):e};$stringify&&$$1J({target:"JSON",stat:!0,arity:3,forced:WRONG_SYMBOLS_CONVERSION||ILL_FORMED_UNICODE},{stringify:function(e,t,r){var n=arraySlice$6(arguments),a=apply$5(WRONG_SYMBOLS_CONVERSION?stringifyWithSymbolsFix:$stringify,null,n);return ILL_FORMED_UNICODE&&"string"==typeof a?replace$5(a,tester,fixIllFormed):a}});var $$1I=_export,NATIVE_SYMBOL=symbolConstructorDetection,fails$n=fails$A,getOwnPropertySymbolsModule$2=objectGetOwnPropertySymbols,toObject$9=toObject$d,FORCED$9=!NATIVE_SYMBOL||fails$n((function(){getOwnPropertySymbolsModule$2.f(1)}));$$1I({target:"Object",stat:!0,forced:FORCED$9},{getOwnPropertySymbols:function(e){var t=getOwnPropertySymbolsModule$2.f;return t?t(toObject$9(e)):[]}});var defineWellKnownSymbol$k=wellKnownSymbolDefine;defineWellKnownSymbol$k("asyncIterator");var defineWellKnownSymbol$j=wellKnownSymbolDefine;defineWellKnownSymbol$j("hasInstance");var defineWellKnownSymbol$i=wellKnownSymbolDefine;defineWellKnownSymbol$i("isConcatSpreadable");var defineWellKnownSymbol$h=wellKnownSymbolDefine;defineWellKnownSymbol$h("iterator");var defineWellKnownSymbol$g=wellKnownSymbolDefine;defineWellKnownSymbol$g("match");var defineWellKnownSymbol$f=wellKnownSymbolDefine;defineWellKnownSymbol$f("matchAll");var defineWellKnownSymbol$e=wellKnownSymbolDefine;defineWellKnownSymbol$e("replace");var defineWellKnownSymbol$d=wellKnownSymbolDefine;defineWellKnownSymbol$d("search");var defineWellKnownSymbol$c=wellKnownSymbolDefine;defineWellKnownSymbol$c("species");var defineWellKnownSymbol$b=wellKnownSymbolDefine;defineWellKnownSymbol$b("split");var defineWellKnownSymbol$a=wellKnownSymbolDefine,defineSymbolToPrimitive=symbolDefineToPrimitive;defineWellKnownSymbol$a("toPrimitive"),defineSymbolToPrimitive();var getBuiltIn$c=getBuiltIn$j,defineWellKnownSymbol$9=wellKnownSymbolDefine,setToStringTag$7=setToStringTag$9;defineWellKnownSymbol$9("toStringTag"),setToStringTag$7(getBuiltIn$c("Symbol"),"Symbol");var defineWellKnownSymbol$8=wellKnownSymbolDefine;defineWellKnownSymbol$8("unscopables");var global$g=global$s,setToStringTag$6=setToStringTag$9;setToStringTag$6(global$g.JSON,"JSON",!0);var IteratorPrototype$1,PrototypeOfArrayIteratorPrototype,arrayIterator,path$t=path$y,symbol$5=path$t.Symbol,iterators={},DESCRIPTORS$d=descriptors,hasOwn$d=hasOwnProperty_1,FunctionPrototype$1=Function.prototype,getDescriptor=DESCRIPTORS$d&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$d(FunctionPrototype$1,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$d||DESCRIPTORS$d&&getDescriptor(FunctionPrototype$1,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},fails$m=fails$A,correctPrototypeGetter=!fails$m((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),hasOwn$c=hasOwnProperty_1,isCallable$d=isCallable$r,toObject$8=toObject$d,sharedKey=sharedKey$4,CORRECT_PROTOTYPE_GETTER$1=correctPrototypeGetter,IE_PROTO=sharedKey("IE_PROTO"),$Object$1=Object,ObjectPrototype$1=$Object$1.prototype,objectGetPrototypeOf=CORRECT_PROTOTYPE_GETTER$1?$Object$1.getPrototypeOf:function(e){var t=toObject$8(e);if(hasOwn$c(t,IE_PROTO))return t[IE_PROTO];var r=t.constructor;return isCallable$d(r)&&t instanceof r?r.prototype:t instanceof $Object$1?ObjectPrototype$1:null},fails$l=fails$A,isCallable$c=isCallable$r,isObject$e=isObject$m,create$c=objectCreate,getPrototypeOf$8=objectGetPrototypeOf,defineBuiltIn$5=defineBuiltIn$8,wellKnownSymbol$g=wellKnownSymbol$r,ITERATOR$9=wellKnownSymbol$g("iterator"),BUGGY_SAFARI_ITERATORS$1=!1;[].keys&&("next"in(arrayIterator=[].keys())?(PrototypeOfArrayIteratorPrototype=getPrototypeOf$8(getPrototypeOf$8(arrayIterator)))!==Object.prototype&&(IteratorPrototype$1=PrototypeOfArrayIteratorPrototype):BUGGY_SAFARI_ITERATORS$1=!0);var NEW_ITERATOR_PROTOTYPE=!isObject$e(IteratorPrototype$1)||fails$l((function(){var e={};return IteratorPrototype$1[ITERATOR$9].call(e)!==e}));isCallable$c((IteratorPrototype$1=NEW_ITERATOR_PROTOTYPE?{}:create$c(IteratorPrototype$1))[ITERATOR$9])||defineBuiltIn$5(IteratorPrototype$1,ITERATOR$9,(function(){return this}));var iteratorsCore={IteratorPrototype:IteratorPrototype$1,BUGGY_SAFARI_ITERATORS:BUGGY_SAFARI_ITERATORS$1},IteratorPrototype=iteratorsCore.IteratorPrototype,create$b=objectCreate,createPropertyDescriptor$3=createPropertyDescriptor$8,setToStringTag$5=setToStringTag$9,Iterators$6=iterators,returnThis$1=function(){return this},iteratorCreateConstructor=function(e,t,r,n){var a=t+" Iterator";return e.prototype=create$b(IteratorPrototype,{next:createPropertyDescriptor$3(+!n,r)}),setToStringTag$5(e,a,!1,!0),Iterators$6[a]=returnThis$1,e},uncurryThis$o=functionUncurryThis,aCallable$i=aCallable$l,functionUncurryThisAccessor=function(e,t,r){try{return uncurryThis$o(aCallable$i(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}},isCallable$b=isCallable$r,$String=String,$TypeError$f=TypeError,aPossiblePrototype$1=function(e){if("object"==typeof e||isCallable$b(e))return e;throw $TypeError$f("Can't set "+$String(e)+" as a prototype")},uncurryThisAccessor=functionUncurryThisAccessor,anObject$d=anObject$i,aPossiblePrototype=aPossiblePrototype$1,objectSetPrototypeOf=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=uncurryThisAccessor(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(e){}return function(r,n){return anObject$d(r),aPossiblePrototype(n),t?e(r,n):r.__proto__=n,r}}():void 0),$$1H=_export,call$r=functionCall,FunctionName=functionName,createIteratorConstructor$1=iteratorCreateConstructor,getPrototypeOf$7=objectGetPrototypeOf,setToStringTag$4=setToStringTag$9,defineBuiltIn$4=defineBuiltIn$8,wellKnownSymbol$f=wellKnownSymbol$r,Iterators$5=iterators,IteratorsCore=iteratorsCore,PROPER_FUNCTION_NAME$1=FunctionName.PROPER;FunctionName.CONFIGURABLE,IteratorsCore.IteratorPrototype;var BUGGY_SAFARI_ITERATORS=IteratorsCore.BUGGY_SAFARI_ITERATORS,ITERATOR$8=wellKnownSymbol$f("iterator"),KEYS="keys",VALUES="values",ENTRIES="entries",returnThis=function(){return this},iteratorDefine=function(e,t,r,n,a,i,s){createIteratorConstructor$1(r,t,n);var o,l,c,u=function(e){if(e===a&&y)return y;if(!BUGGY_SAFARI_ITERATORS&&e in h)return h[e];switch(e){case KEYS:case VALUES:case ENTRIES:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",f=!1,h=e.prototype,p=h[ITERATOR$8]||h["@@iterator"]||a&&h[a],y=!BUGGY_SAFARI_ITERATORS&&p||u(a),g="Array"==t&&h.entries||p;if(g&&(o=getPrototypeOf$7(g.call(new e)))!==Object.prototype&&o.next&&(setToStringTag$4(o,d,!0,!0),Iterators$5[d]=returnThis),PROPER_FUNCTION_NAME$1&&a==VALUES&&p&&p.name!==VALUES&&(f=!0,y=function(){return call$r(p,this)}),a)if(l={values:u(VALUES),keys:i?y:u(KEYS),entries:u(ENTRIES)},s)for(c in l)(BUGGY_SAFARI_ITERATORS||f||!(c in h))&&defineBuiltIn$4(h,c,l[c]);else $$1H({target:t,proto:!0,forced:BUGGY_SAFARI_ITERATORS||f},l);return s&&h[ITERATOR$8]!==y&&defineBuiltIn$4(h,ITERATOR$8,y,{name:a}),Iterators$5[t]=y,l},createIterResultObject$3=function(e,t){return{value:e,done:t}},toIndexedObject$5=toIndexedObject$c,Iterators$4=iterators,InternalStateModule$6=internalState;objectDefineProperty.f;var defineIterator$2=iteratorDefine,createIterResultObject$2=createIterResultObject$3,ARRAY_ITERATOR="Array Iterator",setInternalState$6=InternalStateModule$6.set,getInternalState$1=InternalStateModule$6.getterFor(ARRAY_ITERATOR);defineIterator$2(Array,"Array",(function(e,t){setInternalState$6(this,{type:ARRAY_ITERATOR,target:toIndexedObject$5(e),index:0,kind:t})}),(function(){var e=getInternalState$1(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,createIterResultObject$2(void 0,!0)):createIterResultObject$2("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values"),Iterators$4.Arguments=Iterators$4.Array;var domIterables={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},DOMIterables$3=domIterables,global$f=global$s,classof$9=classof$f,createNonEnumerableProperty$4=createNonEnumerableProperty$9,Iterators$3=iterators,wellKnownSymbol$e=wellKnownSymbol$r,TO_STRING_TAG$1=wellKnownSymbol$e("toStringTag");for(var COLLECTION_NAME in DOMIterables$3){var Collection=global$f[COLLECTION_NAME],CollectionPrototype=Collection&&Collection.prototype;CollectionPrototype&&classof$9(CollectionPrototype)!==TO_STRING_TAG$1&&createNonEnumerableProperty$4(CollectionPrototype,TO_STRING_TAG$1,COLLECTION_NAME),Iterators$3[COLLECTION_NAME]=Iterators$3.Array}var parent$2E=symbol$5,symbol$4=parent$2E,defineWellKnownSymbol$7=wellKnownSymbolDefine;defineWellKnownSymbol$7("dispose");var parent$2D=symbol$4,symbol$3=parent$2D,defineWellKnownSymbol$6=wellKnownSymbolDefine;defineWellKnownSymbol$6("asyncDispose");var $$1G=_export,getBuiltIn$b=getBuiltIn$j,uncurryThis$n=functionUncurryThis,Symbol$4=getBuiltIn$b("Symbol"),keyFor2=Symbol$4.keyFor,thisSymbolValue$1=uncurryThis$n(Symbol$4.prototype.valueOf);$$1G({target:"Symbol",stat:!0},{isRegistered:function(e){try{return void 0!==keyFor2(thisSymbolValue$1(e))}catch(e){return!1}}});for(var $$1F=_export,shared=sharedExports,getBuiltIn$a=getBuiltIn$j,uncurryThis$m=functionUncurryThis,isSymbol=isSymbol$5,wellKnownSymbol$d=wellKnownSymbol$r,Symbol$3=getBuiltIn$a("Symbol"),$isWellKnown=Symbol$3.isWellKnown,getOwnPropertyNames4=getBuiltIn$a("Object","getOwnPropertyNames"),thisSymbolValue=uncurryThis$m(Symbol$3.prototype.valueOf),WellKnownSymbolsStore=shared("wks"),i=0,symbolKeys=getOwnPropertyNames4(Symbol$3),symbolKeysLength=symbolKeys.length;i<symbolKeysLength;i++)try{var symbolKey=symbolKeys[i];isSymbol(Symbol$3[symbolKey])&&wellKnownSymbol$d(symbolKey)}catch(e){}$$1F({target:"Symbol",stat:!0,forced:!0},{isWellKnown:function(e){if($isWellKnown&&$isWellKnown(e))return!0;try{for(var t=thisSymbolValue(e),r=0,n=getOwnPropertyNames4(WellKnownSymbolsStore),a=n.length;r<a;r++)if(WellKnownSymbolsStore[n[r]]==t)return!0}catch(e){}return!1}});var defineWellKnownSymbol$5=wellKnownSymbolDefine;defineWellKnownSymbol$5("matcher");var defineWellKnownSymbol$4=wellKnownSymbolDefine;defineWellKnownSymbol$4("metadataKey");var defineWellKnownSymbol$3=wellKnownSymbolDefine;defineWellKnownSymbol$3("observable");var defineWellKnownSymbol$2=wellKnownSymbolDefine;defineWellKnownSymbol$2("metadata");var defineWellKnownSymbol$1=wellKnownSymbolDefine;defineWellKnownSymbol$1("patternMatch");var defineWellKnownSymbol=wellKnownSymbolDefine;defineWellKnownSymbol("replaceAll");var parent$2C=symbol$3,symbol$2=parent$2C,symbol$1=symbol$2,_Symbol$1=getDefaultExportFromCjs$1(symbol$1),uncurryThis$l=functionUncurryThis,toIntegerOrInfinity$4=toIntegerOrInfinity$7,toString$c=toString$g,requireObjectCoercible$5=requireObjectCoercible$8,charAt$4=uncurryThis$l("".charAt),charCodeAt$1=uncurryThis$l("".charCodeAt),stringSlice$4=uncurryThis$l("".slice),createMethod$4=function(e){return function(t,r){var n,a,i=toString$c(requireObjectCoercible$5(t)),s=toIntegerOrInfinity$4(r),o=i.length;return s<0||s>=o?e?"":void 0:(n=charCodeAt$1(i,s))<55296||n>56319||s+1===o||(a=charCodeAt$1(i,s+1))<56320||a>57343?e?charAt$4(i,s):n:e?stringSlice$4(i,s,s+2):a-56320+(n-55296<<10)+65536}},stringMultibyte={codeAt:createMethod$4(!1),charAt:createMethod$4(!0)},charAt$3=stringMultibyte.charAt,toString$b=toString$g,InternalStateModule$5=internalState,defineIterator$1=iteratorDefine,createIterResultObject$1=createIterResultObject$3,STRING_ITERATOR="String Iterator",setInternalState$5=InternalStateModule$5.set,getInternalState=InternalStateModule$5.getterFor(STRING_ITERATOR);defineIterator$1(String,"String",(function(e){setInternalState$5(this,{type:STRING_ITERATOR,string:toString$b(e),index:0})}),(function(){var e,t=getInternalState(this),r=t.string,n=t.index;return n>=r.length?createIterResultObject$1(void 0,!0):(e=charAt$3(r,n),t.index+=e.length,createIterResultObject$1(e,!1))}));var WrappedWellKnownSymbolModule$1=wellKnownSymbolWrapped,iterator$5=WrappedWellKnownSymbolModule$1.f("iterator"),parent$2B=iterator$5,iterator$4=parent$2B,parent$2A=iterator$4,iterator$3=parent$2A,parent$2z=iterator$3,iterator$2=parent$2z,iterator$1=iterator$2,_Symbol$iterator$1=getDefaultExportFromCjs$1(iterator$1);function _typeof$1(e){return(_typeof$1="function"==typeof _Symbol$1&&"symbol"==typeof _Symbol$iterator$1?function(e){return typeof e}:function(e){return e&&"function"==typeof _Symbol$1&&e.constructor===_Symbol$1&&e!==_Symbol$1.prototype?"symbol":typeof e})(e)}var WrappedWellKnownSymbolModule=wellKnownSymbolWrapped,toPrimitive$5=WrappedWellKnownSymbolModule.f("toPrimitive"),parent$2y=toPrimitive$5,toPrimitive$4=parent$2y,parent$2x=toPrimitive$4,toPrimitive$3=parent$2x,parent$2w=toPrimitive$3,toPrimitive$2=parent$2w,toPrimitive$1=toPrimitive$2,_Symbol$toPrimitive$1=getDefaultExportFromCjs$1(toPrimitive$1);function _toPrimitive$2(e,t){if("object"!==_typeof$1(e)||null===e)return e;var r=e[_Symbol$toPrimitive$1];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof$1(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey$2(e){var t=_toPrimitive$2(e,"string");return"symbol"===_typeof$1(t)?t:String(t)}function _defineProperties$1(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),_Object$defineProperty$1(e,_toPropertyKey$2(n.key),n)}}function _createClass$1(e,t,r){return t&&_defineProperties$1(e.prototype,t),r&&_defineProperties$1(e,r),_Object$defineProperty$1(e,"prototype",{writable:!1}),e}var hasOwn$b=hasOwnProperty_1,isDataDescriptor$1=function(e){return void 0!==e&&(hasOwn$b(e,"value")||hasOwn$b(e,"writable"))},$$1E=_export,call$q=functionCall,isObject$d=isObject$m,anObject$c=anObject$i,isDataDescriptor=isDataDescriptor$1,getOwnPropertyDescriptorModule$2=objectGetOwnPropertyDescriptor,getPrototypeOf$6=objectGetPrototypeOf;function get$7(e,t){var r,n,a=arguments.length<3?e:arguments[2];return anObject$c(e)===a?e[t]:(r=getOwnPropertyDescriptorModule$2.f(e,t))?isDataDescriptor(r)?r.value:void 0===r.get?void 0:call$q(r.get,a):isObject$d(n=getPrototypeOf$6(e))?get$7(n,t,a):void 0}$$1E({target:"Reflect",stat:!0},{get:get$7});var path$s=path$y,get$6=path$s.Reflect.get,parent$2v=get$6,get$5=parent$2v,parent$2u=get$5,get$4=parent$2u,parent$2t=get$4,get$3=parent$2t,get$2=get$3,_Reflect$get=getDefaultExportFromCjs$1(get$2),uncurryThis$k=functionUncurryThis,aCallable$h=aCallable$l,isObject$c=isObject$m,hasOwn$a=hasOwnProperty_1,arraySlice$5=arraySlice$7,NATIVE_BIND=functionBindNative,$Function=Function,concat$9=uncurryThis$k([].concat),join$3=uncurryThis$k([].join),factories={},construct$5=function(e,t,r){if(!hasOwn$a(factories,t)){for(var n=[],a=0;a<t;a++)n[a]="a["+a+"]";factories[t]=$Function("C,a","return new C("+join$3(n,",")+")")}return factories[t](e,r)},functionBind=NATIVE_BIND?$Function.bind:function(e){var t=aCallable$h(this),r=t.prototype,n=arraySlice$5(arguments,1),a=function(){var r=concat$9(n,arraySlice$5(arguments));return this instanceof a?construct$5(t,r.length,r):t.apply(e,r)};return isObject$c(r)&&(a.prototype=r),a},$$1D=_export,bind$t=functionBind;$$1D({target:"Function",proto:!0,forced:Function.bind!==bind$t},{bind:bind$t});var path$r=path$y,entryVirtual$n=function(e){return path$r[e+"Prototype"]},entryVirtual$m=entryVirtual$n,bind$s=entryVirtual$m("Function").bind,isPrototypeOf$q=objectIsPrototypeOf,method$k=bind$s,FunctionPrototype=Function.prototype,bind$r=function(e){var t=e.bind;return e===FunctionPrototype||isPrototypeOf$q(FunctionPrototype,e)&&t===FunctionPrototype.bind?method$k:t},parent$2s=bind$r,bind$q=parent$2s,parent$2r=bind$q,bind$p=parent$2r,parent$2q=bind$p,bind$o=parent$2q,bind$n=bind$o,_bindInstanceProperty$1=getDefaultExportFromCjs$1(bind$n),getOwnPropertyDescriptor$9={exports:{}},$$1C=_export,fails$k=fails$A,toIndexedObject$4=toIndexedObject$c,nativeGetOwnPropertyDescriptor=objectGetOwnPropertyDescriptor.f,DESCRIPTORS$c=descriptors,FORCED$8=!DESCRIPTORS$c||fails$k((function(){nativeGetOwnPropertyDescriptor(1)}));$$1C({target:"Object",stat:!0,forced:FORCED$8,sham:!DESCRIPTORS$c},{getOwnPropertyDescriptor:function(e,t){return nativeGetOwnPropertyDescriptor(toIndexedObject$4(e),t)}});var path$q=path$y,Object$3=path$q.Object,getOwnPropertyDescriptor$8=getOwnPropertyDescriptor$9.exports=function(e,t){return Object$3.getOwnPropertyDescriptor(e,t)};Object$3.getOwnPropertyDescriptor.sham&&(getOwnPropertyDescriptor$8.sham=!0);var getOwnPropertyDescriptorExports=getOwnPropertyDescriptor$9.exports,parent$2p=getOwnPropertyDescriptorExports,getOwnPropertyDescriptor$7=parent$2p,parent$2o=getOwnPropertyDescriptor$7,getOwnPropertyDescriptor$6=parent$2o,parent$2n=getOwnPropertyDescriptor$6,getOwnPropertyDescriptor$5=parent$2n,getOwnPropertyDescriptor$4=getOwnPropertyDescriptor$5,_Object$getOwnPropertyDescriptor$1=getDefaultExportFromCjs$1(getOwnPropertyDescriptor$4),$$1B=_export,setPrototypeOf$6=objectSetPrototypeOf;$$1B({target:"Object",stat:!0},{setPrototypeOf:setPrototypeOf$6});var path$p=path$y,setPrototypeOf$5=path$p.Object.setPrototypeOf,parent$2m=setPrototypeOf$5,setPrototypeOf$4=parent$2m,parent$2l=setPrototypeOf$4,setPrototypeOf$3=parent$2l,parent$2k=setPrototypeOf$3,setPrototypeOf$2=parent$2k,setPrototypeOf$1=setPrototypeOf$2,_Object$setPrototypeOf=getDefaultExportFromCjs$1(setPrototypeOf$1),$$1A=_export,fails$j=fails$A,toObject$7=toObject$d,nativeGetPrototypeOf=objectGetPrototypeOf,CORRECT_PROTOTYPE_GETTER=correctPrototypeGetter,FAILS_ON_PRIMITIVES$2=fails$j((function(){nativeGetPrototypeOf(1)}));$$1A({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$2,sham:!CORRECT_PROTOTYPE_GETTER},{getPrototypeOf:function(e){return nativeGetPrototypeOf(toObject$7(e))}});var path$o=path$y,getPrototypeOf$5=path$o.Object.getPrototypeOf,parent$2j=getPrototypeOf$5,getPrototypeOf$4=parent$2j,parent$2i=getPrototypeOf$4,getPrototypeOf$3=parent$2i,parent$2h=getPrototypeOf$3,getPrototypeOf$2=parent$2h,getPrototypeOf$1=getPrototypeOf$2,_Object$getPrototypeOf=getDefaultExportFromCjs$1(getPrototypeOf$1);function _getPrototypeOf(e){var t;return(_getPrototypeOf=_Object$setPrototypeOf?_bindInstanceProperty$1(t=_Object$getPrototypeOf).call(t):function(e){return e.__proto__||_Object$getPrototypeOf(e)})(e)}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(){var e;"undefined"!=typeof Reflect&&_Reflect$get?_get=_bindInstanceProperty$1(e=_Reflect$get).call(e):_get=function(e,t,r){var n=_superPropBase(e,t);if(n){var a=_Object$getOwnPropertyDescriptor$1(n,t);return a.get?a.get.call(arguments.length<3?e:r):a.value}};return _get.apply(this,arguments)}var $$1z=_export,DESCRIPTORS$b=descriptors,create$a=objectCreate;$$1z({target:"Object",stat:!0,sham:!DESCRIPTORS$b},{create:create$a});var path$n=path$y,Object$2=path$n.Object,create$9=function(e,t){return Object$2.create(e,t)},parent$2g=create$9,create$8=parent$2g,parent$2f=create$8,create$7=parent$2f,parent$2e=create$7,create$6=parent$2e,create$5=create$6,_Object$create$1=getDefaultExportFromCjs$1(create$5);function _setPrototypeOf(e,t){var r;return(_setPrototypeOf=_Object$setPrototypeOf?_bindInstanceProperty$1(r=_Object$setPrototypeOf).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=_Object$create$1(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),_Object$defineProperty$1(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}var isConstructor$2=isConstructor$4,tryToString$5=tryToString$8,$TypeError$e=TypeError,aConstructor$3=function(e){if(isConstructor$2(e))return e;throw $TypeError$e(tryToString$5(e)+" is not a constructor")},$$1y=_export,getBuiltIn$9=getBuiltIn$j,apply$4=functionApply,bind$m=functionBind,aConstructor$2=aConstructor$3,anObject$b=anObject$i,isObject$b=isObject$m,create$4=objectCreate,fails$i=fails$A,nativeConstruct=getBuiltIn$9("Reflect","construct"),ObjectPrototype=Object.prototype,push$g=[].push,NEW_TARGET_BUG=fails$i((function(){function e(){}return!(nativeConstruct((function(){}),[],e)instanceof e)})),ARGS_BUG=!fails$i((function(){nativeConstruct((function(){}))})),FORCED$7=NEW_TARGET_BUG||ARGS_BUG;$$1y({target:"Reflect",stat:!0,forced:FORCED$7,sham:FORCED$7},{construct:function(e,t){aConstructor$2(e),anObject$b(t);var r=arguments.length<3?e:aConstructor$2(arguments[2]);if(ARGS_BUG&&!NEW_TARGET_BUG)return nativeConstruct(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return apply$4(push$g,n,t),new(apply$4(bind$m,e,n))}var a=r.prototype,i=create$4(isObject$b(a)?a:ObjectPrototype),s=apply$4(e,i,t);return isObject$b(s)?s:i}});var path$m=path$y,construct$4=path$m.Reflect.construct,parent$2d=construct$4,construct$3=parent$2d,parent$2c=construct$3,construct$2=parent$2c,parent$2b=construct$2,construct$1=parent$2b,construct2=construct$1,_Reflect$construct=getDefaultExportFromCjs$1(construct2);function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!_Reflect$construct)return!1;if(_Reflect$construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(_Reflect$construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof$1(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var a=_getPrototypeOf(this).constructor;r=_Reflect$construct(n,arguments,a)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}var fails$h=fails$A,arrayMethodIsStrict$7=function(e,t){var r=[][e];return!!r&&fails$h((function(){r.call(null,t||function(){return 1},1)}))},$forEach=arrayIteration.forEach,arrayMethodIsStrict$6=arrayMethodIsStrict$7,STRICT_METHOD$4=arrayMethodIsStrict$6("forEach"),arrayForEach=STRICT_METHOD$4?[].forEach:function(e){return $forEach(this,e,arguments.length>1?arguments[1]:void 0)},$$1x=_export,forEach$8=arrayForEach;$$1x({target:"Array",proto:!0,forced:[].forEach!=arrayForEach},{forEach:arrayForEach});var entryVirtual$l=entryVirtual$n,forEach$7=entryVirtual$l("Array").forEach,parent$2a=forEach$7,forEach$6=parent$2a,classof$8=classof$f,hasOwn$9=hasOwnProperty_1,isPrototypeOf$p=objectIsPrototypeOf,method$j=forEach$6,ArrayPrototype$i=Array.prototype,DOMIterables$2={DOMTokenList:!0,NodeList:!0},forEach$5=function(e){var t=e.forEach;return e===ArrayPrototype$i||isPrototypeOf$p(ArrayPrototype$i,e)&&t===ArrayPrototype$i.forEach||hasOwn$9(DOMIterables$2,classof$8(e))?method$j:t},parent$29=forEach$5,forEach$4=parent$29,parent$28=forEach$4,forEach$3=parent$28,forEach$2=forEach$3,_forEachInstanceProperty$1=getDefaultExportFromCjs$1(forEach$2),forEach$1=forEach$2,_forEachInstanceProperty=getDefaultExportFromCjs$1(forEach$1),DESCRIPTORS$a=descriptors,uncurryThis$j=functionUncurryThis,objectKeys$1=objectKeys$4,toIndexedObject$3=toIndexedObject$c,$propertyIsEnumerable=objectPropertyIsEnumerable.f,propertyIsEnumerable3=uncurryThis$j($propertyIsEnumerable),push$f=uncurryThis$j([].push),createMethod$3=function(e){return function(t){for(var r,n=toIndexedObject$3(t),a=objectKeys$1(n),i=a.length,s=0,o=[];i>s;)r=a[s++],DESCRIPTORS$a&&!propertyIsEnumerable3(n,r)||push$f(o,e?[r,n[r]]:n[r]);return o}},objectToArray={entries:createMethod$3(!0),values:createMethod$3(!1)},$$1w=_export,$values=objectToArray.values;$$1w({target:"Object",stat:!0},{values:function(e){return $values(e)}});var path$l=path$y,values$c=path$l.Object.values,parent$27=values$c,values$b=parent$27,parent$26=values$b,values$a=parent$26,parent$25=values$a,values$9=parent$25,values$8=values$9,values$7=values$8,_Object$values=getDefaultExportFromCjs$1(values$7),entryVirtual$k=entryVirtual$n,concat$8=entryVirtual$k("Array").concat,isPrototypeOf$o=objectIsPrototypeOf,method$i=concat$8,ArrayPrototype$h=Array.prototype,concat$7=function(e){var t=e.concat;return e===ArrayPrototype$h||isPrototypeOf$o(ArrayPrototype$h,e)&&t===ArrayPrototype$h.concat?method$i:t},parent$24=concat$7,concat$6=parent$24,parent$23=concat$6,concat$5=parent$23,parent$22=concat$5,concat$4=parent$22,concat$3=concat$4,concat$2=concat$3,_concatInstanceProperty=getDefaultExportFromCjs$1(concat$2),$$1v=_export,toObject$6=toObject$d,nativeKeys=objectKeys$4,fails$g=fails$A,FAILS_ON_PRIMITIVES$1=fails$g((function(){nativeKeys(1)}));$$1v({target:"Object",stat:!0,forced:FAILS_ON_PRIMITIVES$1},{keys:function(e){return nativeKeys(toObject$6(e))}});var path$k=path$y,keys$5=path$k.Object.keys,parent$21=keys$5,keys$4=parent$21,parent$20=keys$4,keys$3=parent$20,parent$1$=keys$3,keys$2=parent$1$,keys$1=keys$2,_Object$keys$1=getDefaultExportFromCjs$1(keys$1),path$j=path$y,getOwnPropertySymbols$5=path$j.Object.getOwnPropertySymbols,parent$1_=getOwnPropertySymbols$5,getOwnPropertySymbols$4=parent$1_,parent$1Z=getOwnPropertySymbols$4,getOwnPropertySymbols$3=parent$1Z,parent$1Y=getOwnPropertySymbols$3,getOwnPropertySymbols$2=parent$1Y,getOwnPropertySymbols$1=getOwnPropertySymbols$2,_Object$getOwnPropertySymbols$1=getDefaultExportFromCjs$1(getOwnPropertySymbols$1),$$1u=_export,$filter=arrayIteration.filter,arrayMethodHasSpeciesSupport$3=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$3=arrayMethodHasSpeciesSupport$3("filter");$$1u({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$3},{filter:function(e){return $filter(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$j=entryVirtual$n,filter$6=entryVirtual$j("Array").filter,isPrototypeOf$n=objectIsPrototypeOf,method$h=filter$6,ArrayPrototype$g=Array.prototype,filter$5=function(e){var t=e.filter;return e===ArrayPrototype$g||isPrototypeOf$n(ArrayPrototype$g,e)&&t===ArrayPrototype$g.filter?method$h:t},parent$1X=filter$5,filter$4=parent$1X,parent$1W=filter$4,filter$3=parent$1W,parent$1V=filter$3,filter$2=parent$1V,filter$1=filter$2,_filterInstanceProperty$1=getDefaultExportFromCjs$1(filter$1),DESCRIPTORS$9=descriptors,isArray$9=isArray$d,$TypeError$d=TypeError,getOwnPropertyDescriptor$3=Object.getOwnPropertyDescriptor,SILENT_ON_NON_WRITABLE_LENGTH_SET=DESCRIPTORS$9&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),arraySetLength=SILENT_ON_NON_WRITABLE_LENGTH_SET?function(e,t){if(isArray$9(e)&&!getOwnPropertyDescriptor$3(e,"length").writable)throw $TypeError$d("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},$$1t=_export,toObject$5=toObject$d,lengthOfArrayLike$7=lengthOfArrayLike$c,setArrayLength$1=arraySetLength,doesNotExceedSafeInteger$1=doesNotExceedSafeInteger$3,fails$f=fails$A,INCORRECT_TO_LENGTH=fails$f((function(){return 4294967297!==[].push.call({length:4294967296},1)})),properErrorOnNonWritableLength=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}},FORCED$6=INCORRECT_TO_LENGTH||!properErrorOnNonWritableLength();$$1t({target:"Array",proto:!0,arity:1,forced:FORCED$6},{push:function(e){var t=toObject$5(this),r=lengthOfArrayLike$7(t),n=arguments.length;doesNotExceedSafeInteger$1(r+n);for(var a=0;a<n;a++)t[r]=arguments[a],r++;return setArrayLength$1(t,r),r}});var entryVirtual$i=entryVirtual$n,push$e=entryVirtual$i("Array").push,isPrototypeOf$m=objectIsPrototypeOf,method$g=push$e,ArrayPrototype$f=Array.prototype,push$d=function(e){var t=e.push;return e===ArrayPrototype$f||isPrototypeOf$m(ArrayPrototype$f,e)&&t===ArrayPrototype$f.push?method$g:t},parent$1U=push$d,push$c=parent$1U,parent$1T=push$c,push$b=parent$1T,parent$1S=push$b,push$a=parent$1S,push$9=push$a,_pushInstanceProperty=getDefaultExportFromCjs$1(push$9),getBuiltIn$8=getBuiltIn$j,uncurryThis$i=functionUncurryThis,getOwnPropertyNamesModule$1=objectGetOwnPropertyNames,getOwnPropertySymbolsModule$1=objectGetOwnPropertySymbols,anObject$a=anObject$i,concat$1=uncurryThis$i([].concat),ownKeys$5=getBuiltIn$8("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule$1.f(anObject$a(e)),r=getOwnPropertySymbolsModule$1.f;return r?concat$1(t,r(e)):t},$$1s=_export,DESCRIPTORS$8=descriptors,ownKeys$4=ownKeys$5,toIndexedObject$2=toIndexedObject$c,getOwnPropertyDescriptorModule$1=objectGetOwnPropertyDescriptor,createProperty$3=createProperty$6;$$1s({target:"Object",stat:!0,sham:!DESCRIPTORS$8},{getOwnPropertyDescriptors:function(e){for(var t,r,n=toIndexedObject$2(e),a=getOwnPropertyDescriptorModule$1.f,i=ownKeys$4(n),s={},o=0;i.length>o;)void 0!==(r=a(n,t=i[o++]))&&createProperty$3(s,t,r);return s}});var path$i=path$y,getOwnPropertyDescriptors$5=path$i.Object.getOwnPropertyDescriptors,parent$1R=getOwnPropertyDescriptors$5,getOwnPropertyDescriptors$4=parent$1R,parent$1Q=getOwnPropertyDescriptors$4,getOwnPropertyDescriptors$3=parent$1Q,parent$1P=getOwnPropertyDescriptors$3,getOwnPropertyDescriptors$2=parent$1P,getOwnPropertyDescriptors$1=getOwnPropertyDescriptors$2,_Object$getOwnPropertyDescriptors$1=getDefaultExportFromCjs$1(getOwnPropertyDescriptors$1),defineProperties$7={exports:{}},$$1r=_export,DESCRIPTORS$7=descriptors,defineProperties$6=objectDefineProperties.f;$$1r({target:"Object",stat:!0,forced:Object.defineProperties!==defineProperties$6,sham:!DESCRIPTORS$7},{defineProperties:defineProperties$6});var path$h=path$y,Object$1=path$h.Object,defineProperties$5=defineProperties$7.exports=function(e,t){return Object$1.defineProperties(e,t)};Object$1.defineProperties.sham&&(defineProperties$5.sham=!0);var definePropertiesExports=defineProperties$7.exports,parent$1O=definePropertiesExports,defineProperties$4=parent$1O,parent$1N=defineProperties$4,defineProperties$3=parent$1N,parent$1M=defineProperties$3,defineProperties$2=parent$1M,defineProperties$1=defineProperties$2,_Object$defineProperties$1=getDefaultExportFromCjs$1(defineProperties$1);function _defineProperty$2(e,t,r){return(t=_toPropertyKey$2(t))in e?_Object$defineProperty$1(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys$3(e,t){var r=_Object$keys$1(e);if(_Object$getOwnPropertySymbols$1){var n=_Object$getOwnPropertySymbols$1(e);t&&(n=_filterInstanceProperty$1(n).call(n,(function(t){return _Object$getOwnPropertyDescriptor$1(e,t).enumerable}))),_pushInstanceProperty(r).apply(r,n)}return r}function _objectSpread2$2(e){for(var t=1;t<arguments.length;t++){var r,n,a=null!=arguments[t]?arguments[t]:{};t%2?_forEachInstanceProperty$1(r=ownKeys$3(Object(a),!0)).call(r,(function(t){_defineProperty$2(e,t,a[t])})):_Object$getOwnPropertyDescriptors$1?_Object$defineProperties$1(e,_Object$getOwnPropertyDescriptors$1(a)):_forEachInstanceProperty$1(n=ownKeys$3(Object(a))).call(n,(function(t){_Object$defineProperty$1(e,t,_Object$getOwnPropertyDescriptor$1(a,t))}))}return e}var engineIsBun="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,$TypeError$c=TypeError,validateArgumentsLength$5=function(e,t){if(e<t)throw $TypeError$c("Not enough arguments");return e},global$e=global$s,apply$3=functionApply,isCallable$a=isCallable$r,ENGINE_IS_BUN=engineIsBun,USER_AGENT=engineUserAgent,arraySlice$4=arraySlice$7,validateArgumentsLength$4=validateArgumentsLength$5,Function$2=global$e.Function,WRAP=/MSIE .\./.test(USER_AGENT)||ENGINE_IS_BUN&&function(){var e=global$e.Bun.version.split(".");return e.length<3||0==e[0]&&(e[1]<3||3==e[1]&&0==e[2])}(),schedulersFix$2=function(e,t){var r=t?2:1;return WRAP?function(n,a){var i=validateArgumentsLength$4(arguments.length,1)>r,s=isCallable$a(n)?n:Function$2(n),o=i?arraySlice$4(arguments,r):[],l=i?function(){apply$3(s,this,o)}:s;return t?e(l,a):e(l)}:e},$$1q=_export,global$d=global$s,schedulersFix$1=schedulersFix$2,setInterval$5=schedulersFix$1(global$d.setInterval,!0);$$1q({global:!0,bind:!0,forced:global$d.setInterval!==setInterval$5},{setInterval:setInterval$5});var $$1p=_export,global$c=global$s,schedulersFix=schedulersFix$2,setTimeout$6=schedulersFix(global$c.setTimeout,!0);$$1p({global:!0,bind:!0,forced:global$c.setTimeout!==setTimeout$6},{setTimeout:setTimeout$6});var path$g=path$y,setTimeout$5=path$g.setTimeout,parent$1L=setTimeout$5,setTimeout$4=parent$1L,parent$1K=setTimeout$4,setTimeout$3=parent$1K,setTimeout$2=setTimeout$3,setTimeout$1=setTimeout$2,_setTimeout=getDefaultExportFromCjs$1(setTimeout$1),$$1o=_export,uncurryThis$h=functionUncurryThisClause,$indexOf=arrayIncludes.indexOf,arrayMethodIsStrict$5=arrayMethodIsStrict$7,nativeIndexOf=uncurryThis$h([].indexOf),NEGATIVE_ZERO$1=!!nativeIndexOf&&1/nativeIndexOf([1],1,-0)<0,FORCED$5=NEGATIVE_ZERO$1||!arrayMethodIsStrict$5("indexOf");$$1o({target:"Array",proto:!0,forced:FORCED$5},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return NEGATIVE_ZERO$1?nativeIndexOf(this,e,t)||0:$indexOf(this,e,t)}});var entryVirtual$h=entryVirtual$n,indexOf$6=entryVirtual$h("Array").indexOf,isPrototypeOf$l=objectIsPrototypeOf,method$f=indexOf$6,ArrayPrototype$e=Array.prototype,indexOf$5=function(e){var t=e.indexOf;return e===ArrayPrototype$e||isPrototypeOf$l(ArrayPrototype$e,e)&&t===ArrayPrototype$e.indexOf?method$f:t},parent$1J=indexOf$5,indexOf$4=parent$1J,parent$1I=indexOf$4,indexOf$3=parent$1I,parent$1H=indexOf$3,indexOf$2=parent$1H,indexOf$1=indexOf$2,_indexOfInstanceProperty$1=getDefaultExportFromCjs$1(indexOf$1),indexOf2=indexOf$1,_indexOfInstanceProperty=getDefaultExportFromCjs$1(indexOf2),$$1n=_export,$find=arrayIteration.find,FIND="find",SKIPS_HOLES=!0;FIND in[]&&Array(1)[FIND]((function(){SKIPS_HOLES=!1})),$$1n({target:"Array",proto:!0,forced:SKIPS_HOLES},{find:function(e){return $find(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$g=entryVirtual$n,find$7=entryVirtual$g("Array").find,isPrototypeOf$k=objectIsPrototypeOf,method$e=find$7,ArrayPrototype$d=Array.prototype,find$6=function(e){var t=e.find;return e===ArrayPrototype$d||isPrototypeOf$k(ArrayPrototype$d,e)&&t===ArrayPrototype$d.find?method$e:t},parent$1G=find$6,find$5=parent$1G,parent$1F=find$5,find$4=parent$1F,parent$1E=find$4,find$3=parent$1E,find$2=find$3,find$1=find$2,_findInstanceProperty=getDefaultExportFromCjs$1(find$1),keys3=keys$1,_Object$keys=getDefaultExportFromCjs$1(keys3),$$1m=_export,isArray$8=isArray$d,isConstructor$1=isConstructor$4,isObject$a=isObject$m,toAbsoluteIndex$1=toAbsoluteIndex$4,lengthOfArrayLike$6=lengthOfArrayLike$c,toIndexedObject$1=toIndexedObject$c,createProperty$2=createProperty$6,wellKnownSymbol$c=wellKnownSymbol$r,arrayMethodHasSpeciesSupport$2=arrayMethodHasSpeciesSupport$5,nativeSlice=arraySlice$7,HAS_SPECIES_SUPPORT$2=arrayMethodHasSpeciesSupport$2("slice"),SPECIES$3=wellKnownSymbol$c("species"),$Array$1=Array,max$2=Math.max;$$1m({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$2},{slice:function(e,t){var r,n,a,i=toIndexedObject$1(this),s=lengthOfArrayLike$6(i),o=toAbsoluteIndex$1(e,s),l=toAbsoluteIndex$1(void 0===t?s:t,s);if(isArray$8(i)&&(r=i.constructor,(isConstructor$1(r)&&(r===$Array$1||isArray$8(r.prototype))||isObject$a(r)&&null===(r=r[SPECIES$3]))&&(r=void 0),r===$Array$1||void 0===r))return nativeSlice(i,o,l);for(n=new(void 0===r?$Array$1:r)(max$2(l-o,0)),a=0;o<l;o++,a++)o in i&&createProperty$2(n,a,i[o]);return n.length=a,n}});var entryVirtual$f=entryVirtual$n,slice$6=entryVirtual$f("Array").slice,isPrototypeOf$j=objectIsPrototypeOf,method$d=slice$6,ArrayPrototype$c=Array.prototype,slice$5=function(e){var t=e.slice;return e===ArrayPrototype$c||isPrototypeOf$j(ArrayPrototype$c,e)&&t===ArrayPrototype$c.slice?method$d:t},parent$1D=slice$5,slice$4=parent$1D,parent$1C=slice$4,slice$3=parent$1C,parent$1B=slice$3,slice$2=parent$1B,slice$1=slice$2,_sliceInstanceProperty$1=getDefaultExportFromCjs$1(slice$1),slice2=slice$1,_sliceInstanceProperty=getDefaultExportFromCjs$1(slice2),tryToString$4=tryToString$8,$TypeError$b=TypeError,deletePropertyOrThrow$2=function(e,t){if(!delete e[t])throw $TypeError$b("Cannot delete property "+tryToString$4(t)+" of "+tryToString$4(e))},$$1l=_export,toObject$4=toObject$d,toAbsoluteIndex=toAbsoluteIndex$4,toIntegerOrInfinity$3=toIntegerOrInfinity$7,lengthOfArrayLike$5=lengthOfArrayLike$c,setArrayLength=arraySetLength,doesNotExceedSafeInteger=doesNotExceedSafeInteger$3,arraySpeciesCreate=arraySpeciesCreate$3,createProperty$1=createProperty$6,deletePropertyOrThrow$1=deletePropertyOrThrow$2,arrayMethodHasSpeciesSupport$1=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT$1=arrayMethodHasSpeciesSupport$1("splice"),max$1=Math.max,min$2=Math.min;$$1l({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT$1},{splice:function(e,t){var r,n,a,i,s,o,l=toObject$4(this),c=lengthOfArrayLike$5(l),u=toAbsoluteIndex(e,c),d=arguments.length;for(0===d?r=n=0:1===d?(r=0,n=c-u):(r=d-2,n=min$2(max$1(toIntegerOrInfinity$3(t),0),c-u)),doesNotExceedSafeInteger(c+r-n),a=arraySpeciesCreate(l,n),i=0;i<n;i++)(s=u+i)in l&&createProperty$1(a,i,l[s]);if(a.length=n,r<n){for(i=u;i<c-n;i++)o=i+r,(s=i+n)in l?l[o]=l[s]:deletePropertyOrThrow$1(l,o);for(i=c;i>c-n+r;i--)deletePropertyOrThrow$1(l,i-1)}else if(r>n)for(i=c-n;i>u;i--)o=i+r-1,(s=i+n-1)in l?l[o]=l[s]:deletePropertyOrThrow$1(l,o);for(i=0;i<r;i++)l[i+u]=arguments[i+2];return setArrayLength(l,c-n+r),a}});var entryVirtual$e=entryVirtual$n,splice$7=entryVirtual$e("Array").splice,isPrototypeOf$i=objectIsPrototypeOf,method$c=splice$7,ArrayPrototype$b=Array.prototype,splice$6=function(e){var t=e.splice;return e===ArrayPrototype$b||isPrototypeOf$i(ArrayPrototype$b,e)&&t===ArrayPrototype$b.splice?method$c:t},parent$1A=splice$6,splice$5=parent$1A,parent$1z=splice$5,splice$4=parent$1z,parent$1y=splice$4,splice$3=parent$1y,splice$2=splice$3,splice$1=splice$2,_spliceInstanceProperty=getDefaultExportFromCjs$1(splice$1),hasOwn$8=hasOwnProperty_1,ownKeys$2=ownKeys$5,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,definePropertyModule=objectDefineProperty,copyConstructorProperties$1=function(e,t,r){for(var n=ownKeys$2(t),a=definePropertyModule.f,i=getOwnPropertyDescriptorModule.f,s=0;s<n.length;s++){var o=n[s];hasOwn$8(e,o)||r&&hasOwn$8(r,o)||a(e,o,i(t,o))}},isObject$9=isObject$m,createNonEnumerableProperty$3=createNonEnumerableProperty$9,installErrorCause$1=function(e,t){isObject$9(t)&&"cause"in t&&createNonEnumerableProperty$3(e,"cause",t.cause)},uncurryThis$g=functionUncurryThis,$Error$1=Error,replace$4=uncurryThis$g("".replace),TEST=String($Error$1("zxcasd").stack),V8_OR_CHAKRA_STACK_ENTRY=/\n\s*at [^:]*:[^\n]*/,IS_V8_OR_CHAKRA_STACK=V8_OR_CHAKRA_STACK_ENTRY.test(TEST),errorStackClear=function(e,t){if(IS_V8_OR_CHAKRA_STACK&&"string"==typeof e&&!$Error$1.prepareStackTrace)for(;t--;)e=replace$4(e,V8_OR_CHAKRA_STACK_ENTRY,"");return e},fails$e=fails$A,createPropertyDescriptor$2=createPropertyDescriptor$8,errorStackInstallable=!fails$e((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",createPropertyDescriptor$2(1,7)),7!==e.stack)})),createNonEnumerableProperty$2=createNonEnumerableProperty$9,clearErrorStack=errorStackClear,ERROR_STACK_INSTALLABLE=errorStackInstallable,captureStackTrace=Error.captureStackTrace,errorStackInstall=function(e,t,r,n){ERROR_STACK_INSTALLABLE&&(captureStackTrace?captureStackTrace(e,t):createNonEnumerableProperty$2(e,"stack",clearErrorStack(r,n)))},wellKnownSymbol$b=wellKnownSymbol$r,Iterators$2=iterators,ITERATOR$7=wellKnownSymbol$b("iterator"),ArrayPrototype$a=Array.prototype,isArrayIteratorMethod$2=function(e){return void 0!==e&&(Iterators$2.Array===e||ArrayPrototype$a[ITERATOR$7]===e)},classof$7=classof$f,getMethod$1=getMethod$3,isNullOrUndefined$4=isNullOrUndefined$7,Iterators$1=iterators,wellKnownSymbol$a=wellKnownSymbol$r,ITERATOR$6=wellKnownSymbol$a("iterator"),getIteratorMethod$a=function(e){if(!isNullOrUndefined$4(e))return getMethod$1(e,ITERATOR$6)||getMethod$1(e,"@@iterator")||Iterators$1[classof$7(e)]},call$p=functionCall,aCallable$g=aCallable$l,anObject$9=anObject$i,tryToString$3=tryToString$8,getIteratorMethod$9=getIteratorMethod$a,$TypeError$a=TypeError,getIterator$3=function(e,t){var r=arguments.length<2?getIteratorMethod$9(e):t;if(aCallable$g(r))return anObject$9(call$p(r,e));throw $TypeError$a(tryToString$3(e)+" is not iterable")},call$o=functionCall,anObject$8=anObject$i,getMethod=getMethod$3,iteratorClose$4=function(e,t,r){var n,a;anObject$8(e);try{if(!(n=getMethod(e,"return"))){if("throw"===t)throw r;return r}n=call$o(n,e)}catch(e){a=!0,n=e}if("throw"===t)throw r;if(a)throw n;return anObject$8(n),r},bind$l=functionBindContext,call$n=functionCall,anObject$7=anObject$i,tryToString$2=tryToString$8,isArrayIteratorMethod$1=isArrayIteratorMethod$2,lengthOfArrayLike$4=lengthOfArrayLike$c,isPrototypeOf$h=objectIsPrototypeOf,getIterator$2=getIterator$3,getIteratorMethod$8=getIteratorMethod$a,iteratorClose$3=iteratorClose$4,$TypeError$9=TypeError,Result=function(e,t){this.stopped=e,this.result=t},ResultPrototype=Result.prototype,iterate$u=function(e,t,r){var n,a,i,s,o,l,c,u=r&&r.that,d=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_RECORD),h=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),y=bind$l(t,u),g=function(e){return n&&iteratorClose$3(n,"normal",e),new Result(!0,e)},v=function(e){return d?(anObject$7(e),p?y(e[0],e[1],g):y(e[0],e[1])):p?y(e,g):y(e)};if(f)n=e.iterator;else if(h)n=e;else{if(!(a=getIteratorMethod$8(e)))throw $TypeError$9(tryToString$2(e)+" is not iterable");if(isArrayIteratorMethod$1(a)){for(i=0,s=lengthOfArrayLike$4(e);s>i;i++)if((o=v(e[i]))&&isPrototypeOf$h(ResultPrototype,o))return o;return new Result(!1)}n=getIterator$2(e,a)}for(l=f?e.next:n.next;!(c=call$n(l,n)).done;){try{o=v(c.value)}catch(e){iteratorClose$3(n,"throw",e)}if("object"==typeof o&&o&&isPrototypeOf$h(ResultPrototype,o))return o}return new Result(!1)},toString$a=toString$g,normalizeStringArgument$1=function(e,t){return void 0===e?arguments.length<2?"":t:toString$a(e)},$$1k=_export,isPrototypeOf$g=objectIsPrototypeOf,getPrototypeOf2=objectGetPrototypeOf,setPrototypeOf=objectSetPrototypeOf,copyConstructorProperties=copyConstructorProperties$1,create$3=objectCreate,createNonEnumerableProperty$1=createNonEnumerableProperty$9,createPropertyDescriptor$1=createPropertyDescriptor$8,installErrorCause=installErrorCause$1,installErrorStack=errorStackInstall,iterate$t=iterate$u,normalizeStringArgument=normalizeStringArgument$1,wellKnownSymbol$9=wellKnownSymbol$r,TO_STRING_TAG=wellKnownSymbol$9("toStringTag"),$Error=Error,push$8=[].push,$AggregateError=function(e,t){var r,n=isPrototypeOf$g(AggregateErrorPrototype,this);setPrototypeOf?r=setPrototypeOf($Error(),n?getPrototypeOf2(this):AggregateErrorPrototype):(r=n?this:create$3(AggregateErrorPrototype),createNonEnumerableProperty$1(r,TO_STRING_TAG,"Error")),void 0!==t&&createNonEnumerableProperty$1(r,"message",normalizeStringArgument(t)),installErrorStack(r,$AggregateError,r.stack,1),arguments.length>2&&installErrorCause(r,arguments[2]);var a=[];return iterate$t(e,push$8,{that:a}),createNonEnumerableProperty$1(r,"errors",a),r};setPrototypeOf?setPrototypeOf($AggregateError,$Error):copyConstructorProperties($AggregateError,$Error,{name:!0});var AggregateErrorPrototype=$AggregateError.prototype=create$3($Error.prototype,{constructor:createPropertyDescriptor$1(1,$AggregateError),message:createPropertyDescriptor$1(1,""),name:createPropertyDescriptor$1(1,"AggregateError")});$$1k({global:!0,constructor:!0,arity:2},{AggregateError:$AggregateError});var $location,defer,channel,port,classof$6=classofRaw$2,engineIsNode="undefined"!=typeof process&&"process"==classof$6(process),getBuiltIn$7=getBuiltIn$j,defineBuiltInAccessor$3=defineBuiltInAccessor$5,wellKnownSymbol$8=wellKnownSymbol$r,DESCRIPTORS$6=descriptors,SPECIES$2=wellKnownSymbol$8("species"),setSpecies$2=function(e){var t=getBuiltIn$7(e);DESCRIPTORS$6&&t&&!t[SPECIES$2]&&defineBuiltInAccessor$3(t,SPECIES$2,{configurable:!0,get:function(){return this}})},isPrototypeOf$f=objectIsPrototypeOf,$TypeError$8=TypeError,anInstance$5=function(e,t){if(isPrototypeOf$f(t,e))return e;throw $TypeError$8("Incorrect invocation")},anObject$6=anObject$i,aConstructor$1=aConstructor$3,isNullOrUndefined$3=isNullOrUndefined$7,wellKnownSymbol$7=wellKnownSymbol$r,SPECIES$1=wellKnownSymbol$7("species"),speciesConstructor$2=function(e,t){var r,n=anObject$6(e).constructor;return void 0===n||isNullOrUndefined$3(r=anObject$6(n)[SPECIES$1])?t:aConstructor$1(r)},userAgent$5=engineUserAgent,engineIsIos=/(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$5),global$b=global$s,apply$2=functionApply,bind$k=functionBindContext,isCallable$9=isCallable$r,hasOwn$7=hasOwnProperty_1,fails$d=fails$A,html=html$2,arraySlice$3=arraySlice$7,createElement=documentCreateElement$1,validateArgumentsLength$3=validateArgumentsLength$5,IS_IOS$1=engineIsIos,IS_NODE$4=engineIsNode,set$c=global$b.setImmediate,clear=global$b.clearImmediate,process$3=global$b.process,Dispatch=global$b.Dispatch,Function$1=global$b.Function,MessageChannel=global$b.MessageChannel,String$1=global$b.String,counter=0,queue$2={},ONREADYSTATECHANGE="onreadystatechange";fails$d((function(){$location=global$b.location}));var run=function(e){if(hasOwn$7(queue$2,e)){var t=queue$2[e];delete queue$2[e],t()}},runner=function(e){return function(){run(e)}},eventListener=function(e){run(e.data)},globalPostMessageDefer=function(e){global$b.postMessage(String$1(e),$location.protocol+"//"+$location.host)};set$c&&clear||(set$c=function(e){validateArgumentsLength$3(arguments.length,1);var t=isCallable$9(e)?e:Function$1(e),r=arraySlice$3(arguments,1);return queue$2[++counter]=function(){apply$2(t,void 0,r)},defer(counter),counter},clear=function(e){delete queue$2[e]},IS_NODE$4?defer=function(e){process$3.nextTick(runner(e))}:Dispatch&&Dispatch.now?defer=function(e){Dispatch.now(runner(e))}:MessageChannel&&!IS_IOS$1?(port=(channel=new MessageChannel).port2,channel.port1.onmessage=eventListener,defer=bind$k(port.postMessage,port)):global$b.addEventListener&&isCallable$9(global$b.postMessage)&&!global$b.importScripts&&$location&&"file:"!==$location.protocol&&!fails$d(globalPostMessageDefer)?(defer=globalPostMessageDefer,global$b.addEventListener("message",eventListener,!1)):defer=ONREADYSTATECHANGE in createElement("script")?function(e){html.appendChild(createElement("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this),run(e)}}:function(e){setTimeout(runner(e),0)});var task$1={set:set$c,clear:clear},Queue$2=function(){this.head=null,this.tail=null};Queue$2.prototype={add:function(e){var t={item:e,next:null},r=this.tail;r?r.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var notify$1,toggle,node,promise$6,then,queue$1=Queue$2,userAgent$4=engineUserAgent,engineIsIosPebble=/ipad|iphone|ipod/i.test(userAgent$4)&&"undefined"!=typeof Pebble,userAgent$3=engineUserAgent,engineIsWebosWebkit=/web0s(?!.*chrome)/i.test(userAgent$3),global$a=global$s,bind$j=functionBindContext,getOwnPropertyDescriptor$2=objectGetOwnPropertyDescriptor.f,macrotask=task$1.set,Queue$1=queue$1,IS_IOS=engineIsIos,IS_IOS_PEBBLE=engineIsIosPebble,IS_WEBOS_WEBKIT=engineIsWebosWebkit,IS_NODE$3=engineIsNode,MutationObserver=global$a.MutationObserver||global$a.WebKitMutationObserver,document$2=global$a.document,process$2=global$a.process,Promise$1=global$a.Promise,queueMicrotaskDescriptor=getOwnPropertyDescriptor$2(global$a,"queueMicrotask"),microtask$1=queueMicrotaskDescriptor&&queueMicrotaskDescriptor.value;if(!microtask$1){var queue=new Queue$1,flush=function(){var e,t;for(IS_NODE$3&&(e=process$2.domain)&&e.exit();t=queue.get();)try{t()}catch(e){throw queue.head&¬ify$1(),e}e&&e.enter()};IS_IOS||IS_NODE$3||IS_WEBOS_WEBKIT||!MutationObserver||!document$2?!IS_IOS_PEBBLE&&Promise$1&&Promise$1.resolve?((promise$6=Promise$1.resolve(void 0)).constructor=Promise$1,then=bind$j(promise$6.then,promise$6),notify$1=function(){then(flush)}):IS_NODE$3?notify$1=function(){process$2.nextTick(flush)}:(macrotask=bind$j(macrotask,global$a),notify$1=function(){macrotask(flush)}):(toggle=!0,node=document$2.createTextNode(""),new MutationObserver(flush).observe(node,{characterData:!0}),notify$1=function(){node.data=toggle=!toggle}),microtask$1=function(e){queue.head||notify$1(),queue.add(e)}}var microtask_1=microtask$1,hostReportErrors$1=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}},perform$6=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},global$9=global$s,promiseNativeConstructor=global$9.Promise,engineIsDeno="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,IS_DENO$1=engineIsDeno,IS_NODE$2=engineIsNode,engineIsBrowser=!IS_DENO$1&&!IS_NODE$2&&"object"==typeof window&&"object"==typeof document,global$8=global$s,NativePromiseConstructor$5=promiseNativeConstructor,isCallable$8=isCallable$r,isForced=isForced_1,inspectSource=inspectSource$2,wellKnownSymbol$6=wellKnownSymbol$r,IS_BROWSER=engineIsBrowser,IS_DENO=engineIsDeno,V8_VERSION=engineV8Version,NativePromisePrototype$2=NativePromiseConstructor$5&&NativePromiseConstructor$5.prototype,SPECIES=wellKnownSymbol$6("species"),SUBCLASSING=!1,NATIVE_PROMISE_REJECTION_EVENT$1=isCallable$8(global$8.PromiseRejectionEvent),FORCED_PROMISE_CONSTRUCTOR$5=isForced("Promise",(function(){var e=inspectSource(NativePromiseConstructor$5),t=e!==String(NativePromiseConstructor$5);if(!t&&66===V8_VERSION)return!0;if(!NativePromisePrototype$2.catch||!NativePromisePrototype$2.finally)return!0;if(!V8_VERSION||V8_VERSION<51||!/native code/.test(e)){var r=new NativePromiseConstructor$5((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[SPECIES]=n,!(SUBCLASSING=r.then((function(){}))instanceof n))return!0}return!t&&(IS_BROWSER||IS_DENO)&&!NATIVE_PROMISE_REJECTION_EVENT$1})),promiseConstructorDetection={CONSTRUCTOR:FORCED_PROMISE_CONSTRUCTOR$5,REJECTION_EVENT:NATIVE_PROMISE_REJECTION_EVENT$1,SUBCLASSING:SUBCLASSING},newPromiseCapability$2={},aCallable$f=aCallable$l,$TypeError$7=TypeError,PromiseCapability=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw $TypeError$7("Bad Promise constructor");t=e,r=n})),this.resolve=aCallable$f(t),this.reject=aCallable$f(r)};newPromiseCapability$2.f=function(e){return new PromiseCapability(e)};var $$1j=_export,IS_NODE$1=engineIsNode,global$7=global$s,call$m=functionCall,defineBuiltIn$3=defineBuiltIn$8,setToStringTag$3=setToStringTag$9,setSpecies$1=setSpecies$2,aCallable$e=aCallable$l,isCallable$7=isCallable$r,isObject$8=isObject$m,anInstance$4=anInstance$5,speciesConstructor$1=speciesConstructor$2,task=task$1.set,microtask=microtask_1,hostReportErrors=hostReportErrors$1,perform$5=perform$6,Queue=queue$1,InternalStateModule$4=internalState,NativePromiseConstructor$4=promiseNativeConstructor,PromiseConstructorDetection=promiseConstructorDetection,newPromiseCapabilityModule$6=newPromiseCapability$2,PROMISE="Promise",FORCED_PROMISE_CONSTRUCTOR$4=PromiseConstructorDetection.CONSTRUCTOR,NATIVE_PROMISE_REJECTION_EVENT=PromiseConstructorDetection.REJECTION_EVENT;PromiseConstructorDetection.SUBCLASSING;var Internal,OwnPromiseCapability,PromiseWrapper,getInternalPromiseState=InternalStateModule$4.getterFor(PROMISE),setInternalState$4=InternalStateModule$4.set,NativePromisePrototype$1=NativePromiseConstructor$4&&NativePromiseConstructor$4.prototype,PromiseConstructor=NativePromiseConstructor$4,PromisePrototype=NativePromisePrototype$1,TypeError$3=global$7.TypeError,document$1=global$7.document,process$1=global$7.process,newPromiseCapability$1=newPromiseCapabilityModule$6.f,newGenericPromiseCapability=newPromiseCapability$1,DISPATCH_EVENT=!!(document$1&&document$1.createEvent&&global$7.dispatchEvent),UNHANDLED_REJECTION="unhandledrejection",REJECTION_HANDLED="rejectionhandled",PENDING=0,FULFILLED=1,REJECTED=2,HANDLED=1,UNHANDLED=2,isThenable=function(e){var t;return!(!isObject$8(e)||!isCallable$7(t=e.then))&&t},callReaction=function(e,t){var r,n,a,i=t.value,s=t.state==FULFILLED,o=s?e.ok:e.fail,l=e.resolve,c=e.reject,u=e.domain;try{o?(s||(t.rejection===UNHANDLED&&onHandleUnhandled(t),t.rejection=HANDLED),!0===o?r=i:(u&&u.enter(),r=o(i),u&&(u.exit(),a=!0)),r===e.promise?c(TypeError$3("Promise-chain cycle")):(n=isThenable(r))?call$m(n,r,l,c):l(r)):c(i)}catch(e){u&&!a&&u.exit(),c(e)}},notify=function(e,t){e.notified||(e.notified=!0,microtask((function(){for(var r,n=e.reactions;r=n.get();)callReaction(r,e);e.notified=!1,t&&!e.rejection&&onUnhandled(e)})))},dispatchEvent=function(e,t,r){var n,a;DISPATCH_EVENT?((n=document$1.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),global$7.dispatchEvent(n)):n={promise:t,reason:r},!NATIVE_PROMISE_REJECTION_EVENT&&(a=global$7["on"+e])?a(n):e===UNHANDLED_REJECTION&&hostReportErrors("Unhandled promise rejection",r)},onUnhandled=function(e){call$m(task,global$7,(function(){var t,r=e.facade,n=e.value;if(isUnhandled(e)&&(t=perform$5((function(){IS_NODE$1?process$1.emit("unhandledRejection",n,r):dispatchEvent(UNHANDLED_REJECTION,r,n)})),e.rejection=IS_NODE$1||isUnhandled(e)?UNHANDLED:HANDLED,t.error))throw t.value}))},isUnhandled=function(e){return e.rejection!==HANDLED&&!e.parent},onHandleUnhandled=function(e){call$m(task,global$7,(function(){var t=e.facade;IS_NODE$1?process$1.emit("rejectionHandled",t):dispatchEvent(REJECTION_HANDLED,t,e.value)}))},bind$i=function(e,t,r){return function(n){e(t,n,r)}},internalReject=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=REJECTED,notify(e,!0))},internalResolve=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw TypeError$3("Promise can't be resolved itself");var n=isThenable(t);n?microtask((function(){var r={done:!1};try{call$m(n,t,bind$i(internalResolve,r,e),bind$i(internalReject,r,e))}catch(t){internalReject(r,t,e)}})):(e.value=t,e.state=FULFILLED,notify(e,!1))}catch(t){internalReject({done:!1},t,e)}}};FORCED_PROMISE_CONSTRUCTOR$4&&(PromisePrototype=(PromiseConstructor=function(e){anInstance$4(this,PromisePrototype),aCallable$e(e),call$m(Internal,this);var t=getInternalPromiseState(this);try{e(bind$i(internalResolve,t),bind$i(internalReject,t))}catch(e){internalReject(t,e)}}).prototype,(Internal=function(e){setInternalState$4(this,{type:PROMISE,done:!1,notified:!1,parent:!1,reactions:new Queue,rejection:!1,state:PENDING,value:void 0})}).prototype=defineBuiltIn$3(PromisePrototype,"then",(function(e,t){var r=getInternalPromiseState(this),n=newPromiseCapability$1(speciesConstructor$1(this,PromiseConstructor));return r.parent=!0,n.ok=!isCallable$7(e)||e,n.fail=isCallable$7(t)&&t,n.domain=IS_NODE$1?process$1.domain:void 0,r.state==PENDING?r.reactions.add(n):microtask((function(){callReaction(n,r)})),n.promise})),OwnPromiseCapability=function(){var e=new Internal,t=getInternalPromiseState(e);this.promise=e,this.resolve=bind$i(internalResolve,t),this.reject=bind$i(internalReject,t)},newPromiseCapabilityModule$6.f=newPromiseCapability$1=function(e){return e===PromiseConstructor||e===PromiseWrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)}),$$1j({global:!0,constructor:!0,wrap:!0,forced:FORCED_PROMISE_CONSTRUCTOR$4},{Promise:PromiseConstructor}),setToStringTag$3(PromiseConstructor,PROMISE,!1,!0),setSpecies$1(PROMISE);var wellKnownSymbol$5=wellKnownSymbol$r,ITERATOR$5=wellKnownSymbol$5("iterator"),SAFE_CLOSING=!1;try{var called=0,iteratorWithReturn={next:function(){return{done:!!called++}},return:function(){SAFE_CLOSING=!0}};iteratorWithReturn[ITERATOR$5]=function(){return this},Array.from(iteratorWithReturn,(function(){throw 2}))}catch(e){}var checkCorrectnessOfIteration$2=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var n={};n[ITERATOR$5]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(e){}return r},NativePromiseConstructor$3=promiseNativeConstructor,checkCorrectnessOfIteration$1=checkCorrectnessOfIteration$2,FORCED_PROMISE_CONSTRUCTOR$3=promiseConstructorDetection.CONSTRUCTOR,promiseStaticsIncorrectIteration=FORCED_PROMISE_CONSTRUCTOR$3||!checkCorrectnessOfIteration$1((function(e){NativePromiseConstructor$3.all(e).then(void 0,(function(){}))})),$$1i=_export,call$l=functionCall,aCallable$d=aCallable$l,newPromiseCapabilityModule$5=newPromiseCapability$2,perform$4=perform$6,iterate$s=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION$3=promiseStaticsIncorrectIteration;$$1i({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$3},{all:function(e){var t=this,r=newPromiseCapabilityModule$5.f(t),n=r.resolve,a=r.reject,i=perform$4((function(){var r=aCallable$d(t.resolve),i=[],s=0,o=1;iterate$s(e,(function(e){var l=s++,c=!1;o++,call$l(r,t,e).then((function(e){c||(c=!0,i[l]=e,--o||n(i))}),a)})),--o||n(i)}));return i.error&&a(i.value),r.promise}});var $$1h=_export,FORCED_PROMISE_CONSTRUCTOR$2=promiseConstructorDetection.CONSTRUCTOR,NativePromiseConstructor$2=promiseNativeConstructor;promiseNativeConstructor&&promiseNativeConstructor.prototype,$$1h({target:"Promise",proto:!0,forced:FORCED_PROMISE_CONSTRUCTOR$2,real:!0},{catch:function(e){return this.then(void 0,e)}});var $$1g=_export,call$k=functionCall,aCallable$c=aCallable$l,newPromiseCapabilityModule$4=newPromiseCapability$2,perform$3=perform$6,iterate$r=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION$2=promiseStaticsIncorrectIteration;$$1g({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$2},{race:function(e){var t=this,r=newPromiseCapabilityModule$4.f(t),n=r.reject,a=perform$3((function(){var a=aCallable$c(t.resolve);iterate$r(e,(function(e){call$k(a,t,e).then(r.resolve,n)}))}));return a.error&&n(a.value),r.promise}});var $$1f=_export,call$j=functionCall,newPromiseCapabilityModule$3=newPromiseCapability$2,FORCED_PROMISE_CONSTRUCTOR$1=promiseConstructorDetection.CONSTRUCTOR;$$1f({target:"Promise",stat:!0,forced:FORCED_PROMISE_CONSTRUCTOR$1},{reject:function(e){var t=newPromiseCapabilityModule$3.f(this);return call$j(t.reject,void 0,e),t.promise}});var anObject$5=anObject$i,isObject$7=isObject$m,newPromiseCapability=newPromiseCapability$2,promiseResolve$2=function(e,t){if(anObject$5(e),isObject$7(t)&&t.constructor===e)return t;var r=newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},$$1e=_export,getBuiltIn$6=getBuiltIn$j,IS_PURE$1=isPure,NativePromiseConstructor$1=promiseNativeConstructor,FORCED_PROMISE_CONSTRUCTOR=promiseConstructorDetection.CONSTRUCTOR,promiseResolve$1=promiseResolve$2,PromiseConstructorWrapper=getBuiltIn$6("Promise"),CHECK_WRAPPER=!FORCED_PROMISE_CONSTRUCTOR;$$1e({target:"Promise",stat:!0,forced:IS_PURE$1},{resolve:function(e){return promiseResolve$1(CHECK_WRAPPER&&this===PromiseConstructorWrapper?NativePromiseConstructor$1:this,e)}});var $$1d=_export,call$i=functionCall,aCallable$b=aCallable$l,newPromiseCapabilityModule$2=newPromiseCapability$2,perform$2=perform$6,iterate$q=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION$1=promiseStaticsIncorrectIteration;$$1d({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION$1},{allSettled:function(e){var t=this,r=newPromiseCapabilityModule$2.f(t),n=r.resolve,a=r.reject,i=perform$2((function(){var r=aCallable$b(t.resolve),a=[],i=0,s=1;iterate$q(e,(function(e){var o=i++,l=!1;s++,call$i(r,t,e).then((function(e){l||(l=!0,a[o]={status:"fulfilled",value:e},--s||n(a))}),(function(e){l||(l=!0,a[o]={status:"rejected",reason:e},--s||n(a))}))})),--s||n(a)}));return i.error&&a(i.value),r.promise}});var $$1c=_export,call$h=functionCall,aCallable$a=aCallable$l,getBuiltIn$5=getBuiltIn$j,newPromiseCapabilityModule$1=newPromiseCapability$2,perform$1=perform$6,iterate$p=iterate$u,PROMISE_STATICS_INCORRECT_ITERATION=promiseStaticsIncorrectIteration,PROMISE_ANY_ERROR="No one promise resolved";$$1c({target:"Promise",stat:!0,forced:PROMISE_STATICS_INCORRECT_ITERATION},{any:function(e){var t=this,r=getBuiltIn$5("AggregateError"),n=newPromiseCapabilityModule$1.f(t),a=n.resolve,i=n.reject,s=perform$1((function(){var n=aCallable$a(t.resolve),s=[],o=0,l=1,c=!1;iterate$p(e,(function(e){var u=o++,d=!1;l++,call$h(n,t,e).then((function(e){d||c||(c=!0,a(e))}),(function(e){d||c||(d=!0,s[u]=e,--l||i(new r(s,PROMISE_ANY_ERROR)))}))})),--l||i(new r(s,PROMISE_ANY_ERROR))}));return s.error&&i(s.value),n.promise}});var $$1b=_export,NativePromiseConstructor=promiseNativeConstructor,fails$c=fails$A,getBuiltIn$4=getBuiltIn$j,isCallable$6=isCallable$r,speciesConstructor=speciesConstructor$2,promiseResolve=promiseResolve$2,NativePromisePrototype=NativePromiseConstructor&&NativePromiseConstructor.prototype,NON_GENERIC=!!NativePromiseConstructor&&fails$c((function(){NativePromisePrototype.finally.call({then:function(){}},(function(){}))}));$$1b({target:"Promise",proto:!0,real:!0,forced:NON_GENERIC},{finally:function(e){var t=speciesConstructor(this,getBuiltIn$4("Promise")),r=isCallable$6(e);return this.then(r?function(r){return promiseResolve(t,e()).then((function(){return r}))}:e,r?function(r){return promiseResolve(t,e()).then((function(){throw r}))}:e)}});var path$f=path$y,promise$5=path$f.Promise,parent$1x=promise$5,promise$4=parent$1x,parent$1w=promise$4,promise$3=parent$1w,$$1a=_export,newPromiseCapabilityModule=newPromiseCapability$2,perform=perform$6;$$1a({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=newPromiseCapabilityModule.f(this),r=perform(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var parent$1v=promise$3,promise$2=parent$1v,promise$1=promise$2,promise=promise$1,_Promise=getDefaultExportFromCjs$1(promise),whitespaces$4="\t\n\v\f\r \u2028\u2029\ufeff",uncurryThis$f=functionUncurryThis,requireObjectCoercible$4=requireObjectCoercible$8,toString$9=toString$g,whitespaces$3=whitespaces$4,replace$3=uncurryThis$f("".replace),ltrim=RegExp("^["+whitespaces$3+"]+"),rtrim=RegExp("(^|[^"+whitespaces$3+"])["+whitespaces$3+"]+$"),createMethod$2=function(e){return function(t){var r=toString$9(requireObjectCoercible$4(t));return 1&e&&(r=replace$3(r,ltrim,"")),2&e&&(r=replace$3(r,rtrim,"$1")),r}},stringTrim={start:createMethod$2(1),end:createMethod$2(2),trim:createMethod$2(3)},global$6=global$s,fails$b=fails$A,uncurryThis$e=functionUncurryThis,toString$8=toString$g,trim$8=stringTrim.trim,whitespaces$2=whitespaces$4,$parseInt$1=global$6.parseInt,Symbol$2=global$6.Symbol,ITERATOR$4=Symbol$2&&Symbol$2.iterator,hex=/^[+-]?0x/i,exec$2=uncurryThis$e(hex.exec),FORCED$4=8!==$parseInt$1(whitespaces$2+"08")||22!==$parseInt$1(whitespaces$2+"0x16")||ITERATOR$4&&!fails$b((function(){$parseInt$1(Object(ITERATOR$4))})),numberParseInt=FORCED$4?function(e,t){var r=trim$8(toString$8(e));return $parseInt$1(r,t>>>0||(exec$2(hex,r)?16:10))}:$parseInt$1,$$19=_export,$parseInt=numberParseInt;$$19({global:!0,forced:parseInt!=numberParseInt},{parseInt:numberParseInt});var path$e=path$y,_parseInt$6=path$e.parseInt,parent$1u=_parseInt$6,_parseInt$5=parent$1u,parent$1t=_parseInt$5,_parseInt$4=parent$1t,parent$1s=_parseInt$4,_parseInt$3=parent$1s,_parseInt$2=_parseInt$3,_parseInt=_parseInt$2,_parseInt$1=getDefaultExportFromCjs$1(_parseInt),$$18=_export,$map=arrayIteration.map,arrayMethodHasSpeciesSupport=arrayMethodHasSpeciesSupport$5,HAS_SPECIES_SUPPORT=arrayMethodHasSpeciesSupport("map");$$18({target:"Array",proto:!0,forced:!HAS_SPECIES_SUPPORT},{map:function(e){return $map(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$d=entryVirtual$n,map$c=entryVirtual$d("Array").map,isPrototypeOf$e=objectIsPrototypeOf,method$b=map$c,ArrayPrototype$9=Array.prototype,map$b=function(e){var t=e.map;return e===ArrayPrototype$9||isPrototypeOf$e(ArrayPrototype$9,e)&&t===ArrayPrototype$9.map?method$b:t},parent$1r=map$b,map$a=parent$1r,parent$1q=map$a,map$9=parent$1q,parent$1p=map$9,map$8=parent$1p,map$7=map$8,map$6=map$7,_mapInstanceProperty=getDefaultExportFromCjs$1(map$6),$$17=_export,isArray$7=isArray$d;$$17({target:"Array",stat:!0},{isArray:isArray$7});var path$d=path$y,isArray$6=path$d.Array.isArray,parent$1o=isArray$6,isArray$5=parent$1o,parent$1n=isArray$5,isArray$4=parent$1n,parent$1m=isArray$4,isArray$3=parent$1m,isArray$2=isArray$3,_Array$isArray$1=getDefaultExportFromCjs$1(isArray$2),isArray$1=isArray$2,_Array$isArray=getDefaultExportFromCjs$1(isArray$1),filter2=filter$1,_filterInstanceProperty=getDefaultExportFromCjs$1(filter2),DESCRIPTORS$5=descriptors,uncurryThis$d=functionUncurryThis,call$g=functionCall,fails$a=fails$A,objectKeys=objectKeys$4,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,propertyIsEnumerableModule=objectPropertyIsEnumerable,toObject$3=toObject$d,IndexedObject$1=indexedObject,$assign=Object.assign,defineProperty$3=Object.defineProperty,concat2=uncurryThis$d([].concat),objectAssign=!$assign||fails$a((function(){if(DESCRIPTORS$5&&1!==$assign({b:1},$assign(defineProperty$3({},"a",{enumerable:!0,get:function(){defineProperty$3(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=$assign({},e)[r]||objectKeys($assign({},t)).join("")!=n}))?function(e,t){for(var r=toObject$3(e),n=arguments.length,a=1,i=getOwnPropertySymbolsModule.f,s=propertyIsEnumerableModule.f;n>a;)for(var o,l=IndexedObject$1(arguments[a++]),c=i?concat2(objectKeys(l),i(l)):objectKeys(l),u=c.length,d=0;u>d;)o=c[d++],DESCRIPTORS$5&&!call$g(s,l,o)||(r[o]=l[o]);return r}:$assign,$$16=_export,assign$7=objectAssign;$$16({target:"Object",stat:!0,arity:2,forced:Object.assign!==assign$7},{assign:assign$7});var path$c=path$y,assign$6=path$c.Object.assign,parent$1l=assign$6,assign$5=parent$1l,parent$1k=assign$5,assign$4=parent$1k,parent$1j=assign$4,assign$3=parent$1j,assign$2=assign$3,assign$1=assign$2,_Object$assign=getDefaultExportFromCjs$1(assign$1),getOwnPropertySymbols2=getOwnPropertySymbols$1,_Object$getOwnPropertySymbols=getDefaultExportFromCjs$1(getOwnPropertySymbols2),getOwnPropertyDescriptor$1=getOwnPropertyDescriptor$4,_Object$getOwnPropertyDescriptor=getDefaultExportFromCjs$1(getOwnPropertyDescriptor$1),getOwnPropertyDescriptors2=getOwnPropertyDescriptors$1,_Object$getOwnPropertyDescriptors=getDefaultExportFromCjs$1(getOwnPropertyDescriptors2),defineProperties4=defineProperties$1,_Object$defineProperties=getDefaultExportFromCjs$1(defineProperties4),defineProperty$2=defineProperty$7,_Object$defineProperty=getDefaultExportFromCjs$1(defineProperty$2),symbol=symbol$1,_Symbol=getDefaultExportFromCjs$1(symbol),iterator=iterator$1,_Symbol$iterator=getDefaultExportFromCjs$1(iterator),create$2=create$5,_Object$create=getDefaultExportFromCjs$1(create$2),bind$h=bind$n,_bindInstanceProperty=getDefaultExportFromCjs$1(bind$h),getIteratorMethod$7=getIteratorMethod$a,getIteratorMethod_1=getIteratorMethod$7,parent$1i=getIteratorMethod_1,getIteratorMethod$6=parent$1i,parent$1h=getIteratorMethod$6,getIteratorMethod$5=parent$1h,parent$1g=getIteratorMethod$5,getIteratorMethod$4=parent$1g,getIteratorMethod$3=getIteratorMethod$4,_getIteratorMethod$1=getDefaultExportFromCjs$1(getIteratorMethod$3),getIteratorMethod$2=getIteratorMethod$3,_getIteratorMethod=getDefaultExportFromCjs$1(getIteratorMethod$2),anObject$4=anObject$i,iteratorClose$2=iteratorClose$4,callWithSafeIterationClosing$1=function(e,t,r,n){try{return n?t(anObject$4(r)[0],r[1]):t(r)}catch(t){iteratorClose$2(e,"throw",t)}},bind$g=functionBindContext,call$f=functionCall,toObject$2=toObject$d,callWithSafeIterationClosing=callWithSafeIterationClosing$1,isArrayIteratorMethod=isArrayIteratorMethod$2,isConstructor3=isConstructor$4,lengthOfArrayLike$3=lengthOfArrayLike$c,createProperty=createProperty$6,getIterator$1=getIterator$3,getIteratorMethod$1=getIteratorMethod$a,$Array=Array,arrayFrom$1=function(e){var t=toObject$2(e),r=isConstructor3(this),n=arguments.length,a=n>1?arguments[1]:void 0,i=void 0!==a;i&&(a=bind$g(a,n>2?arguments[2]:void 0));var s,o,l,c,u,d,f=getIteratorMethod$1(t),h=0;if(!f||this===$Array&&isArrayIteratorMethod(f))for(s=lengthOfArrayLike$3(t),o=r?new this(s):$Array(s);s>h;h++)d=i?a(t[h],h):t[h],createProperty(o,h,d);else for(u=(c=getIterator$1(t,f)).next,o=r?new this:[];!(l=call$f(u,c)).done;h++)d=i?callWithSafeIterationClosing(c,a,[l.value,h],!0):l.value,createProperty(o,h,d);return o.length=h,o},$$15=_export,from$8=arrayFrom$1,checkCorrectnessOfIteration=checkCorrectnessOfIteration$2,INCORRECT_ITERATION=!checkCorrectnessOfIteration((function(e){Array.from(e)}));$$15({target:"Array",stat:!0,forced:INCORRECT_ITERATION},{from:from$8});var path$b=path$y,from$7=path$b.Array.from,parent$1f=from$7,from$6=parent$1f,parent$1e=from$6,from$5=parent$1e,parent$1d=from$5,from$4=parent$1d,from$3=from$4,_Array$from$1=getDefaultExportFromCjs$1(from$3),from$2=from$3,_Array$from=getDefaultExportFromCjs$1(from$2),toPrimitive=toPrimitive$1,_Symbol$toPrimitive=getDefaultExportFromCjs$1(toPrimitive);function ownKeys$1(e,t){var r=_Object$keys(e);if(_Object$getOwnPropertySymbols){var n=_Object$getOwnPropertySymbols(e);t&&(n=_filterInstanceProperty(n).call(n,(function(t){return _Object$getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2$1(e){for(var t=1;t<arguments.length;t++){var r,n,a=null!=arguments[t]?arguments[t]:{};t%2?_forEachInstanceProperty(r=ownKeys$1(Object(a),!0)).call(r,(function(t){_defineProperty$1(e,t,a[t])})):_Object$getOwnPropertyDescriptors?_Object$defineProperties(e,_Object$getOwnPropertyDescriptors(a)):_forEachInstanceProperty(n=ownKeys$1(Object(a))).call(n,(function(t){_Object$defineProperty(e,t,_Object$getOwnPropertyDescriptor(a,t))}))}return e}function _typeof(e){return(_typeof="function"==typeof _Symbol&&"symbol"==typeof _Symbol$iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof _Symbol&&e.constructor===_Symbol&&e!==_Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),_Object$defineProperty(e,_toPropertyKey$1(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),_Object$defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty$1(e,t,r){return(t=_toPropertyKey$1(t))in e?_Object$defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toConsumableArray$1(e){return _arrayWithoutHoles$1(e)||_iterableToArray$1(e)||_unsupportedIterableToArray$1(e)||_nonIterableSpread$1()}function _arrayWithoutHoles$1(e){if(_Array$isArray(e))return _arrayLikeToArray$1(e)}function _iterableToArray$1(e){if(void 0!==_Symbol&&null!=_getIteratorMethod(e)||null!=e["@@iterator"])return _Array$from(e)}function _unsupportedIterableToArray$1(e,t){var r;if(e){if("string"==typeof e)return _arrayLikeToArray$1(e,t);var n=_sliceInstanceProperty(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?_Array$from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray$1(e,t):void 0}}function _arrayLikeToArray$1(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _nonIterableSpread$1(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _toPrimitive$1(e,t){if("object"!==_typeof$1(e)||null===e)return e;var r=e[_Symbol$toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof$1(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey$1(e){var t=_toPrimitive$1(e,"string");return"symbol"===_typeof$1(t)?t:String(t)}var $$14=_export,$some=arrayIteration.some,arrayMethodIsStrict$4=arrayMethodIsStrict$7,STRICT_METHOD$3=arrayMethodIsStrict$4("some");$$14({target:"Array",proto:!0,forced:!STRICT_METHOD$3},{some:function(e){return $some(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$c=entryVirtual$n,some$6=entryVirtual$c("Array").some,isPrototypeOf$d=objectIsPrototypeOf,method$a=some$6,ArrayPrototype$8=Array.prototype,some$5=function(e){var t=e.some;return e===ArrayPrototype$8||isPrototypeOf$d(ArrayPrototype$8,e)&&t===ArrayPrototype$8.some?method$a:t},parent$1c=some$5,some$4=parent$1c,parent$1b=some$4,some$3=parent$1b,parent$1a=some$3,some$2=parent$1a,some$1=some$2,some2=some$1,_someInstanceProperty=getDefaultExportFromCjs$1(some2),toIntegerOrInfinity$2=toIntegerOrInfinity$7,toString$7=toString$g,requireObjectCoercible$3=requireObjectCoercible$8,$RangeError$1=RangeError,stringRepeat=function(e){var t=toString$7(requireObjectCoercible$3(this)),r="",n=toIntegerOrInfinity$2(e);if(n<0||n==1/0)throw $RangeError$1("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},uncurryThis$c=functionUncurryThis,toLength$1=toLength$3,toString$6=toString$g,$repeat=stringRepeat,requireObjectCoercible$2=requireObjectCoercible$8,repeat2=uncurryThis$c($repeat),stringSlice$3=uncurryThis$c("".slice),ceil=Math.ceil,createMethod$1=function(e){return function(t,r,n){var a,i,s=toString$6(requireObjectCoercible$2(t)),o=toLength$1(r),l=s.length,c=void 0===n?" ":toString$6(n);return o<=l||""==c?s:((i=repeat2(c,ceil((a=o-l)/c.length))).length>a&&(i=stringSlice$3(i,0,a)),e?s+i:i+s)}},stringPad={start:createMethod$1(!1),end:createMethod$1(!0)},userAgent$2=engineUserAgent,stringPadWebkitBug=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent$2),$$13=_export,$padStart=stringPad.start,WEBKIT_BUG=stringPadWebkitBug;$$13({target:"String",proto:!0,forced:WEBKIT_BUG},{padStart:function(e){return $padStart(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$b=entryVirtual$n,padStart$6=entryVirtual$b("String").padStart,isPrototypeOf$c=objectIsPrototypeOf,method$9=padStart$6,StringPrototype$3=String.prototype,padStart$5=function(e){var t=e.padStart;return"string"==typeof e||e===StringPrototype$3||isPrototypeOf$c(StringPrototype$3,e)&&t===StringPrototype$3.padStart?method$9:t},parent$19=padStart$5,padStart$4=parent$19,parent$18=padStart$4,padStart$3=parent$18,parent$17=padStart$3,padStart$2=parent$17,padStart$1=padStart$2,padStart2=padStart$1,_padStartInstanceProperty=getDefaultExportFromCjs$1(padStart2),path$a=path$y,setInterval$4=path$a.setInterval,parent$16=setInterval$4,setInterval$3=parent$16,parent$15=setInterval$3,setInterval$2=parent$15,setInterval$1=setInterval$2,setInterval=setInterval$1,_setInterval=getDefaultExportFromCjs$1(setInterval),$$12=_export,$every=arrayIteration.every,arrayMethodIsStrict$3=arrayMethodIsStrict$7,STRICT_METHOD$2=arrayMethodIsStrict$3("every");$$12({target:"Array",proto:!0,forced:!STRICT_METHOD$2},{every:function(e){return $every(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$a=entryVirtual$n,every$6=entryVirtual$a("Array").every,isPrototypeOf$b=objectIsPrototypeOf,method$8=every$6,ArrayPrototype$7=Array.prototype,every$5=function(e){var t=e.every;return e===ArrayPrototype$7||isPrototypeOf$b(ArrayPrototype$7,e)&&t===ArrayPrototype$7.every?method$8:t},parent$14=every$5,every$4=parent$14,parent$13=every$4,every$3=parent$13,parent$12=every$3,every$2=parent$12,every$1=every$2,every2=every$1,_everyInstanceProperty=getDefaultExportFromCjs$1(every2),global$5=global$s,fails$9=fails$A,uncurryThis$b=functionUncurryThis,toString$5=toString$g,trim$7=stringTrim.trim,whitespaces$1=whitespaces$4,charAt$2=uncurryThis$b("".charAt),$parseFloat$1=global$5.parseFloat,Symbol$1=global$5.Symbol,ITERATOR$3=Symbol$1&&Symbol$1.iterator,FORCED$3=1/$parseFloat$1(whitespaces$1+"-0")!=-1/0||ITERATOR$3&&!fails$9((function(){$parseFloat$1(Object(ITERATOR$3))})),numberParseFloat=FORCED$3?function(e){var t=trim$7(toString$5(e)),r=$parseFloat$1(t);return 0===r&&"-"==charAt$2(t,0)?-0:r}:$parseFloat$1,$$11=_export,$parseFloat=numberParseFloat;$$11({global:!0,forced:parseFloat!=numberParseFloat},{parseFloat:numberParseFloat});var path$9=path$y,_parseFloat$6=path$9.parseFloat,parent$11=_parseFloat$6,_parseFloat$5=parent$11,parent$10=_parseFloat$5,_parseFloat$4=parent$10,parent$$=_parseFloat$4,_parseFloat$3=parent$$,_parseFloat$2=_parseFloat$3,_parseFloat=_parseFloat$2,_parseFloat$1=getDefaultExportFromCjs$1(_parseFloat),PROPER_FUNCTION_NAME=functionName.PROPER,fails$8=fails$A,whitespaces=whitespaces$4,non="
",stringTrimForced=function(e){return fails$8((function(){return!!whitespaces[e]()||non[e]()!==non||PROPER_FUNCTION_NAME&&whitespaces[e].name!==e}))},$$10=_export,$trim=stringTrim.trim,forcedStringTrimMethod=stringTrimForced;$$10({target:"String",proto:!0,forced:forcedStringTrimMethod("trim")},{trim:function(){return $trim(this)}});var entryVirtual$9=entryVirtual$n,trim$6=entryVirtual$9("String").trim,isPrototypeOf$a=objectIsPrototypeOf,method$7=trim$6,StringPrototype$2=String.prototype,trim$5=function(e){var t=e.trim;return"string"==typeof e||e===StringPrototype$2||isPrototypeOf$a(StringPrototype$2,e)&&t===StringPrototype$2.trim?method$7:t},parent$_=trim$5,trim$4=parent$_,parent$Z=trim$4,trim$3=parent$Z,parent$Y=trim$3,trim$2=parent$Y,trim$1=trim$2,trim2=trim$1,_trimInstanceProperty=getDefaultExportFromCjs$1(trim2),arraySlice$2=arraySliceSimple,floor$3=Math.floor,mergeSort=function(e,t){var r=e.length,n=floor$3(r/2);return r<8?insertionSort(e,t):merge(e,mergeSort(arraySlice$2(e,0,n),t),mergeSort(arraySlice$2(e,n),t),t)},insertionSort=function(e,t){for(var r,n,a=e.length,i=1;i<a;){for(n=i,r=e[i];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==i++&&(e[n]=r)}return e},merge=function(e,t,r,n){for(var a=t.length,i=r.length,s=0,o=0;s<a||o<i;)e[s+o]=s<a&&o<i?n(t[s],r[o])<=0?t[s++]:r[o++]:s<a?t[s++]:r[o++];return e},arraySort$1=mergeSort,userAgent$1=engineUserAgent,firefox=userAgent$1.match(/firefox\/(\d+)/i),engineFfVersion=!!firefox&&+firefox[1],UA=engineUserAgent,engineIsIeOrEdge=/MSIE|Trident/.test(UA),userAgent=engineUserAgent,webkit=userAgent.match(/AppleWebKit\/(\d+)\./),engineWebkitVersion=!!webkit&&+webkit[1],$$$=_export,uncurryThis$a=functionUncurryThis,aCallable$9=aCallable$l,toObject$1=toObject$d,lengthOfArrayLike$2=lengthOfArrayLike$c,deletePropertyOrThrow=deletePropertyOrThrow$2,toString$4=toString$g,fails$7=fails$A,internalSort=arraySort$1,arrayMethodIsStrict$2=arrayMethodIsStrict$7,FF=engineFfVersion,IE_OR_EDGE=engineIsIeOrEdge,V8=engineV8Version,WEBKIT=engineWebkitVersion,test$1=[],nativeSort=uncurryThis$a(test$1.sort),push$7=uncurryThis$a(test$1.push),FAILS_ON_UNDEFINED=fails$7((function(){test$1.sort(void 0)})),FAILS_ON_NULL=fails$7((function(){test$1.sort(null)})),STRICT_METHOD$1=arrayMethodIsStrict$2("sort"),STABLE_SORT=!fails$7((function(){if(V8)return V8<70;if(!(FF&&FF>3)){if(IE_OR_EDGE)return!0;if(WEBKIT)return WEBKIT<603;var e,t,r,n,a="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)test$1.push({k:t+n,v:r})}for(test$1.sort((function(e,t){return t.v-e.v})),n=0;n<test$1.length;n++)t=test$1[n].k.charAt(0),a.charAt(a.length-1)!==t&&(a+=t);return"DGBEFHACIJK"!==a}})),FORCED$2=FAILS_ON_UNDEFINED||!FAILS_ON_NULL||!STRICT_METHOD$1||!STABLE_SORT,getSortCompare=function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:toString$4(t)>toString$4(r)?1:-1}};$$$({target:"Array",proto:!0,forced:FORCED$2},{sort:function(e){void 0!==e&&aCallable$9(e);var t=toObject$1(this);if(STABLE_SORT)return void 0===e?nativeSort(t):nativeSort(t,e);var r,n,a=[],i=lengthOfArrayLike$2(t);for(n=0;n<i;n++)n in t&&push$7(a,t[n]);for(internalSort(a,getSortCompare(e)),r=lengthOfArrayLike$2(a),n=0;n<r;)t[n]=a[n++];for(;n<i;)deletePropertyOrThrow(t,n++);return t}});var entryVirtual$8=entryVirtual$n,sort$6=entryVirtual$8("Array").sort,isPrototypeOf$9=objectIsPrototypeOf,method$6=sort$6,ArrayPrototype$6=Array.prototype,sort$5=function(e){var t=e.sort;return e===ArrayPrototype$6||isPrototypeOf$9(ArrayPrototype$6,e)&&t===ArrayPrototype$6.sort?method$6:t},parent$X=sort$5,sort$4=parent$X,parent$W=sort$4,sort$3=parent$W,parent$V=sort$3,sort$2=parent$V,sort$1=sort$2,sort2=sort$1,_sortInstanceProperty=getDefaultExportFromCjs$1(sort2),$$_=_export,uncurryThis$9=functionUncurryThis,$Date=Date,thisTimeValue=uncurryThis$9($Date.prototype.getTime);$$_({target:"Date",stat:!0},{now:function(){return thisTimeValue(new $Date)}});var _context,path$8=path$y,now$6=path$8.Date.now,parent$U=now$6,now$5=parent$U,parent$T=now$5,now$4=parent$T,parent$S=now$4,now$3=parent$S,now$2=now$3,now$1=now$2,_Date$now=getDefaultExportFromCjs$1(now$1),XG_DEBUG_OPEN="undefined"!=typeof window&&window.location&&_indexOfInstanceProperty(_context=window.location.href).call(_context,"xgplayerdebugger=1")>-1,STYLE={info:"color: #525252; background-color: #90ee90;",error:"color: #525252; background-color: red;",warn:"color: #525252; background-color: yellow; "},XGTAG="%c[xgplayer]",XG_DEBUG={config:{debug:XG_DEBUG_OPEN?3:0},logInfo:function(e){for(var t,r,n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];this.config.debug>=3&&(r=console).log.apply(r,_concatInstanceProperty(t=[XGTAG,STYLE.info,e]).call(t,a))},logWarn:function(e){for(var t,r,n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];this.config.debug>=1&&(r=console).warn.apply(r,_concatInstanceProperty(t=[XGTAG,STYLE.warn,e]).call(t,a))},logError:function(e){var t,r;if(!(this.config.debug<1)){for(var n=this.config.debug>=2?"trace":"error",a=arguments.length,i=new Array(a>1?a-1:0),s=1;s<a;s++)i[s-1]=arguments[s];(r=console)[n].apply(r,_concatInstanceProperty(t=[XGTAG,STYLE.error,e]).call(t,i))}}},XgplayerTimeRange=function(){function e(t){_classCallCheck(this,e),this.bufferedList=t}return _createClass(e,[{key:"start",value:function(e){return this.bufferedList[e].start}},{key:"end",value:function(e){return this.bufferedList[e].end}},{key:"length",get:function(){return this.bufferedList.length}}]),e}(),util={};function checkIsIn(e,t){for(var r=0,n=t.length;r<n;r++)if(_indexOfInstanceProperty(e).call(e,t[r])>-1)return!0;return!1}util.createDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=document.createElement(t);return i.className=a,i.innerHTML=r,_forEachInstanceProperty(e=_Object$keys(n)).call(e,(function(e){var r=e,a=n[e];"video"===t||"audio"===t||"live-video"===t?a&&i.setAttribute(r,a):i.setAttribute(r,a)})),i},util.createDomFromHtml=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{var n=document.createElement("div");n.innerHTML=e;var a=n.children;if(n=null,a.length>0){var i;if(a=a[0],r&&util.addClass(a,r),t)_forEachInstanceProperty(i=_Object$keys(t)).call(i,(function(e){a.setAttribute(e,t[e])}));return a}return null}catch(e){return XG_DEBUG.logError("util.createDomFromHtml",e),null}},util.hasClass=function(e,t){if(!e||!t)return!1;try{return _someInstanceProperty(Array.prototype).call(e.classList,(function(e){return e===t}))}catch(n){var r=e.className&&"object"===_typeof(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},util.addClass=function(e,t){if(e&&t)try{var r;_forEachInstanceProperty(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.add(t)}))}catch(r){util.hasClass(e,t)||(e.className&&"object"===_typeof(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},util.removeClass=function(e,t){if(e&&t)try{var r;_forEachInstanceProperty(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.remove(t)}))}catch(r){var n;if(util.hasClass(e,t))_forEachInstanceProperty(n=t.split(/\s+/g)).call(n,(function(t){var r=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===_typeof(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")}))}},util.toggleClass=function(e,t){var r;e&&_forEachInstanceProperty(r=t.split(/\s+/g)).call(r,(function(t){util.hasClass(e,t)?util.removeClass(e,t):util.addClass(e,t)}))},util.classNames=function(){for(var e=arguments,t=[],r=function(r){if("String"===util.typeOf(e[r]))t.push(e[r]);else if("Object"===util.typeOf(e[r])){var n;_mapInstanceProperty(n=_Object$keys(e[r])).call(n,(function(n){e[r][n]&&t.push(n)}))}},n=0;n<arguments.length;n++)r(n);return t.join(" ")},util.findDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,r=arguments.length>1?arguments[1]:void 0;try{e=t.querySelector(r)}catch(n){XG_DEBUG.logError("util.findDom",n),0===_indexOfInstanceProperty(r).call(r,"#")&&(e=t.getElementById(_sliceInstanceProperty(r).call(r,1)))}return e},util.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},util.padStart=function(e,t,r){for(var n=String(r),a=t>>0,i=Math.ceil(a/n.length),s=[],o=String(e);i--;)s.push(n);return s.join("").substring(0,a-o.length)+o},util.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=_padStartInstanceProperty(util).call(util,Math.floor(e/3600),2,0),r=_padStartInstanceProperty(util).call(util,Math.floor((e-3600*t)/60),2,0),n=_padStartInstanceProperty(util).call(util,Math.floor(e-3600*t-60*r),2,0);return("00"===t?[r,n]:[t,r,n]).join(":")},util.event=function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},util.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},util.deepCopy=function(e,t){var r;if("Object"===util.typeOf(t)&&"Object"===util.typeOf(e))return _forEachInstanceProperty(r=_Object$keys(t)).call(r,(function(r){if("Object"!==util.typeOf(t[r])||t[r]instanceof Node)if("Array"===util.typeOf(t[r])){var n;e[r]="Array"===util.typeOf(e[r])?_concatInstanceProperty(n=e[r]).call(n,t[r]):t[r]}else e[r]=t[r];else void 0===e[r]||void 0===e[r]?e[r]=t[r]:util.deepCopy(e[r],t[r])})),e},util.deepMerge=function(e,t){var r;return _mapInstanceProperty(r=_Object$keys(t)).call(r,(function(r){var n;"Array"===util.typeOf(t[r])&&"Array"===util.typeOf(e[r])?"Array"===util.typeOf(e[r])&&(n=e[r]).push.apply(n,_toConsumableArray$1(t[r])):util.typeOf(e[r])!==util.typeOf(t[r])||null===e[r]||"Object"!==util.typeOf(e[r])||t[r]instanceof window.Node?null!==t[r]&&(e[r]=t[r]):util.deepMerge(e[r],t[r])})),e},util.getBgImage=function(e){var t=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;if(!t||"none"===t)return"";var r=document.createElement("a");return r.href=t.replace(/url\("|"\)/g,""),r.href},util.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return _forEachInstanceProperty(Array.prototype).call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},util.setInterval=function(e,t,r,n){e._interval[t]||(e._interval[t]=_setInterval(_bindInstanceProperty(r).call(r,e),n))},util.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},util.setTimeout=function(e,t,r){e._timers||(e._timers=[]);var n=_setTimeout((function(){t(),util.clearTimeout(e,n)}),r);return e._timers.push(n),n},util.clearTimeout=function(e,t){var r=e._timers;if("Array"===util.typeOf(r)){for(var n=0;n<r.length;n++)if(r[n]===t){_spliceInstanceProperty(r).call(r,n,1),clearTimeout(t);break}}else clearTimeout(t)},util.clearAllTimers=function(e){var t=e._timers;"Array"===util.typeOf(t)&&(_mapInstanceProperty(t).call(t,(function(e){clearTimeout(e)})),e._timerIds=[])},util.createImgBtn=function(e,t,r,n){var a,i,s,o,l,c,u,d,f,h,p,y,g=util.createDom("xg-".concat(e),"",{},"xgplayer-".concat(e,"-img"));(g.style.backgroundImage='url("'.concat(t,'")'),r&&n)&&(_everyInstanceProperty(a=["px","rem","em","pt","dp","vw","vh","vm","%"]).call(a,(function(e){var t,a;return!(_indexOfInstanceProperty(r).call(r,e)>-1&&_indexOfInstanceProperty(n).call(n,e)>-1)||(u=_parseFloat$1(_trimInstanceProperty(t=_sliceInstanceProperty(r).call(r,0,_indexOfInstanceProperty(r).call(r,e))).call(t)),d=_parseFloat$1(_trimInstanceProperty(a=_sliceInstanceProperty(n).call(n,0,_indexOfInstanceProperty(n).call(n,e))).call(a)),f=e,!1)})),g.style.width=_concatInstanceProperty(i="".concat(u)).call(i,f),g.style.height=_concatInstanceProperty(s="".concat(d)).call(s,f),g.style.backgroundSize=_concatInstanceProperty(o=_concatInstanceProperty(l=_concatInstanceProperty(c="".concat(u)).call(c,f," ")).call(l,d)).call(o,f),g.style.margin="start"===e?_concatInstanceProperty(h=_concatInstanceProperty(p=_concatInstanceProperty(y="-".concat(d/2)).call(y,f," auto auto -")).call(p,u/2)).call(h,f):"auto 5px auto 5px");return g},util.Hex2RGBA=function(e,t){var r,n=[];if(/^\#[0-9A-F]{3}$/i.test(e)){var a="#";e.replace(/[0-9A-F]/gi,(function(e){a+=e+e})),e=a}return/^#[0-9A-F]{6}$/i.test(e)?(e.replace(/[0-9A-F]{2}/gi,(function(e){n.push(_parseInt$1(e,16))})),_concatInstanceProperty(r="rgba(".concat(n.join(","),", ")).call(r,t,")")):"rgba(255, 255, 255, 0.1)"},util.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},util.checkIsFunction=function(e){return e&&"function"==typeof e},util.checkIsObject=function(e){return null!==e&&"object"===_typeof(e)},util.hide=function(e){e.style.display="none"},util.show=function(e,t){e.style.display=t||"block"},util.isUndefined=function(e){if(null==e)return!0},util.isNotNull=function(e){return!(null==e)},util.setStyleFromCsstext=function(e,t){if(t)if("String"===util.typeOf(t)){var r=t.replace(/\s+/g,"").split(";");_mapInstanceProperty(r).call(r,(function(t){if(t){var r=t.split(":");r.length>1&&(e.style[r[0]]=r[1])}}))}else{var n;_mapInstanceProperty(n=_Object$keys(t)).call(n,(function(r){e.style[r]=t[r]}))}},util.filterStyleFromText=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height","top","left","bottom","right","position","z-index","padding","margin","transform"],n=e.style.cssText;if(!n)return{};var a=n.replace(/\s+/g,"").split(";"),i={},s={};return _mapInstanceProperty(a).call(a,(function(e){if(e){var t=e.split(":");t.length>1&&(checkIsIn(t[0],r)?i[t[0]]=t[1]:s[t[0]]=t[1])}})),e.setAttribute("style",""),_mapInstanceProperty(t=_Object$keys(s)).call(t,(function(t){e.style[t]=s[t]})),i},util.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var r=t.replace(/\s+/g,"").split(";"),n={};return _mapInstanceProperty(r).call(r,(function(e){if(e){var t=e.split(":");t.length>1&&(n[t[0]]=t[1])}})),n},util.preloadImg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(e){var n=new window.Image;n.onload=function(e){n=null,t&&t(e)},n.onerror=function(e){n=null,r&&r(e)},n.src=e}},util.stopPropagation=function(e){e&&e.stopPropagation()},util.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},util.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},util.checkTouchSupport=function(){return"ontouchstart"in window},util.getBuffered2=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=[],n=0;n<e.length;n++)r.push({start:e.start(n)<.5?0:e.start(n),end:e.end(n)});_sortInstanceProperty(r).call(r,(function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var a=[];if(t)for(var i=0;i<r.length;i++){var s=a.length;if(s){var o=a[s-1].end;r[i].start-o<t?r[i].end>o&&(a[s-1].end=r[i].end):a.push(r[i])}else a.push(r[i])}else a=r;return new XgplayerTimeRange(a)},util.getEventPos=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.touches&&e.touches.length>0&&(e=e.touches[0]),{x:e.x/t,y:e.y/t,clientX:e.clientX/t,clientY:e.clientY/t,offsetX:e.offsetX/t,offsetY:e.offsetY/t,pageX:e.pageX/t,pageY:e.pageY/t}},util.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},util.getHostFromUrl=function(e){if("String"!==util.typeOf(e))return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r},util.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},util.isMSE=function(e){return e.media&&(e=e.media),!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},util.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},util.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=_parseInt$1(e)}catch(t){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=_parseInt$1(window.performance.now())),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)}))},util.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},util.adjustTimeByDuration=function(e,t,r){return t&&e&&(e>t||r&&e<t)?t:e},util.createPositionBar=function(e,t){var r=util.createDom("xg-bar","",{"data-index":-1},e);return t.appendChild(r),r},util.getTransformStyle=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0,scale:1,rotate:0},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n={scale:"".concat(t.scale||1),translate:_concatInstanceProperty(e="".concat(t.x||0,"%, ")).call(e,t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")},a=_Object$keys(n);return _forEachInstanceProperty(a).call(a,(function(e){var t,a=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),i=_concatInstanceProperty(t="".concat(e,"(")).call(t,n[e],")");a.test(r)?(a.lastIndex=-1,r=r.replace(a,i)):r+="".concat(i," ")})),r},util.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},util.getIndexByTime=function(e,t){var r=t.length,n=-1;if(r<1)return n;if(e<=t[0].end||r<2)n=0;else if(e>t[r-1].end)n=r-1;else for(var a=1;a<r;a++)if(e>t[a-1].end&&e<=t[a].end){n=a;break}return n},util.getOffsetCurrentTime=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n=-1;if((n=r>=0&&r<t.length?r:util.getIndexByTime(e,t))<0)return-1;var a=t.length,i=t[n],s=i.start,o=i.end,l=i.cTime,c=i.offset;return e<s?l:e>=s&&e<=o?e-c:e>o&&n>=a-1?o:-1},util.getCurrentTimeByOffset=function(e,t){var r=-1;if(!t||t.length<0)return e;for(var n=0;n<t.length;n++)if(e<=t[n].duration){r=n;break}if(-1!==r){var a=t[r].start;return r-1<0?a+e:a+(e-t[r-1].duration)}return e};var URL_CHANGE="urlchange";function callHandler(e,t,r){for(var n,a=arguments.length,i=new Array(a>3?a-3:0),s=3;s<a;s++)i[s-3]=arguments[s];var o,l=t.call.apply(t,_concatInstanceProperty(n=[e]).call(n,i));r&&"function"==typeof r&&(l&&l.then?l.then((function(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];r.call.apply(r,_concatInstanceProperty(t=[e]).call(t,a))})):r.call.apply(r,_concatInstanceProperty(o=[e]).call(o,i)))}function hook(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{pre:null,next:null};return this.__hooks||(this.__hooks={}),!this.__hooks[e]&&(this.__hooks[e]=null),_bindInstanceProperty(r=function(){var r,a=arguments,i=this;if(n.pre)try{var s,o;(o=n.pre).call.apply(o,_concatInstanceProperty(s=[this]).call(s,_sliceInstanceProperty(Array.prototype).call(arguments)))}catch(t){var l,c;throw t.message=_concatInstanceProperty(l=_concatInstanceProperty(c="[pluginName: ".concat(this.pluginName,":")).call(c,e,":pre error] >> ")).call(l,t.message),t}if(this.__hooks&&this.__hooks[e])try{var u,d=runHooks(this,e,t);if(d)if(d.then)d.then((function(e){var r;!1!==e&&callHandler.apply(void 0,_concatInstanceProperty(r=[i,t,n.next]).call(r,_toConsumableArray$1(a)))})).catch((function(e){throw e}));else callHandler.apply(void 0,_concatInstanceProperty(u=[this,t,n.next]).call(u,_sliceInstanceProperty(Array.prototype).call(arguments)));else if(void 0===d){var f;callHandler.apply(void 0,_concatInstanceProperty(f=[this,t,n.next]).call(f,_sliceInstanceProperty(Array.prototype).call(arguments)))}}catch(t){var h,p;throw t.message=_concatInstanceProperty(h=_concatInstanceProperty(p="[pluginName: ".concat(this.pluginName,":")).call(p,e,"] >> ")).call(h,t.message),t}else callHandler.apply(void 0,_concatInstanceProperty(r=[this,t,n.next]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}).call(r,this)}function findHookIndex(e,t){var r=this.__hooks;if(!r||!_Array$isArray(r[e]))return-1;for(var n=r[e],a=0;a<n.length;a++)if(n[a]===t)return a;return-1}function useHooks(e,t){var r=this.__hooks;if(r)return r.hasOwnProperty(e)?(_Array$isArray(r[e])||(r[e]=[]),-1===findHookIndex.call(this,e,t)&&r[e].push(t),!0):(console.warn("has no supported hook which name [".concat(e,"]")),!1)}function removeHooks(e,t){var r=this.__hooks;if(r)if(_Array$isArray(r[e])){var n=r[e],a=findHookIndex.call(this,e,t);-1!==a&&_spliceInstanceProperty(n).call(n,a,1)}else r[e]&&(r[e]=null)}function hooksDescriptor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&_mapInstanceProperty(t).call(t,(function(t){e.__hooks[t]=null})),_Object$defineProperty(e,"hooks",{get:function(){var t;return e.__hooks&&_mapInstanceProperty(t=_Object$keys(e.__hooks)).call(t,(function(t){if(e.__hooks[t])return t}))}})}function delHooksDescriptor(e){e.__hooks=null}function runHooks(e,t,r){for(var n=arguments.length,a=new Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];if(e.__hooks&&_Array$isArray(e.__hooks[t])){var s,o=e.__hooks[t],l=-1;return function e(t,r,n){for(var a,i,s=arguments.length,c=new Array(s>3?s-3:0),u=3;u<s;u++)c[u-3]=arguments[u];if(l++,0===o.length||l===o.length)return n.call.apply(n,_concatInstanceProperty(i=[t,t]).call(i,c));var d,f=o[l],h=f.call.apply(f,_concatInstanceProperty(a=[t,t]).call(a,c));return h&&h.then?h.then((function(a){var i;return!1===a?null:e.apply(void 0,_concatInstanceProperty(i=[t,r,n]).call(i,c))})).catch((function(e){console.warn("[runHooks]".concat(r," reject"),e.message)})):!1!==h?e.apply(void 0,_concatInstanceProperty(d=[t,r,n]).call(d,c)):void 0}.apply(void 0,_concatInstanceProperty(s=[e,t,r]).call(s,a))}var c;return r.call.apply(r,_concatInstanceProperty(c=[e,e]).call(c,a))}function showErrorMsg(e,t){var r;XG_DEBUG.logError(_concatInstanceProperty(r="[".concat(e,"] event or callback cant be undefined or null when call ")).call(r,t))}var BasePlugin=function(){function e(t){_classCallCheck(this,e),util.checkIsFunction(this.beforeCreate)&&this.beforeCreate(t),hooksDescriptor(this),this.__args=t,this.__events={},this.__onceEvents={},this.config=t.config||{},this.player=null,this.playerConfig={},this.pluginName="",this.__init(t)}return _createClass(e,[{key:"beforeCreate",value:function(e){}},{key:"afterCreate",value:function(){}},{key:"beforePlayerInit",value:function(){}},{key:"onPluginsReady",value:function(){}},{key:"afterPlayerInit",value:function(){}},{key:"destroy",value:function(){}},{key:"__init",value:function(e){this.player=e.player,this.playerConfig=e.player&&e.player.config,this.pluginName=e.pluginName?e.pluginName.toLowerCase():this.constructor.pluginName.toLowerCase(),this.logger=e.player&&e.player.logger}},{key:"updateLang",value:function(e){e||(e=this.lang)}},{key:"lang",get:function(){return this.player.lang}},{key:"i18n",get:function(){return this.player.i18n}},{key:"i18nKeys",get:function(){return this.player.i18nKeys}},{key:"domEventType",get:function(){var e=util.checkTouchSupport()?"touch":"mouse";return!this.playerConfig||"touch"!==this.playerConfig.domEventType&&"mouse"!==this.playerConfig.domEventType||(e=this.playerConfig.domEventType),e}},{key:"on",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(this.__events[e]=t,this.player.on(e,t)):_Array$isArray(e)&&_forEachInstanceProperty(e).call(e,(function(e){r.__events[e]=t,r.player.on(e,t)})):showErrorMsg(this.pluginName,"plugin.on(event, callback)")}},{key:"once",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(this.__onceEvents[e]=t,this.player.once(e,t)):_Array$isArray(e)&&_forEachInstanceProperty(e).call(e,(function(n){r.__onceEvents[n]=t,r.player.once(e,t)})):showErrorMsg(this.pluginName,"plugin.once(event, callback)")}},{key:"off",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(delete this.__events[e],this.player.off(e,t)):_Array$isArray(e)&&_forEachInstanceProperty(e).call(e,(function(n){delete r.__events[e],r.player.off(n,t)})):showErrorMsg(this.pluginName,"plugin.off(event, callback)")}},{key:"offAll",value:function(){var e,t=this;_forEachInstanceProperty(e=["__events","__onceEvents"]).call(e,(function(e){var r;_forEachInstanceProperty(r=_Object$keys(t[e])).call(r,(function(r){t[e][r]&&t.off(r,t[e][r]),r&&delete t[e][r]}))})),this.__events={},this.__onceEvents={}}},{key:"emit",value:function(e){var t,r;if(this.player){for(var n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];(r=this.player).emit.apply(r,_concatInstanceProperty(t=[e]).call(t,a))}}},{key:"emitUserAction",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var n=_objectSpread2$1(_objectSpread2$1({},r),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,n)}}},{key:"hook",value:function(e,t){var r;return hook.call.apply(hook,_concatInstanceProperty(r=[this]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}},{key:"useHooks",value:function(e,t){for(var r,n=arguments.length,a=new Array(n>2?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i];return useHooks.call.apply(useHooks,_concatInstanceProperty(r=[this]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}},{key:"removeHooks",value:function(e,t){for(var r,n=arguments.length,a=new Array(n>2?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i];return removeHooks.call.apply(removeHooks,_concatInstanceProperty(r=[this]).call(r,_sliceInstanceProperty(Array.prototype).call(arguments)))}},{key:"registerPlugin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(this.player)return r&&(t.pluginName=r),this.player.registerPlugin({plugin:e,options:t})}},{key:"getPlugin",value:function(e){return this.player?this.player.getPlugin(e):null}},{key:"__destroy",value:function(){var e,t=this,r=this.player,n=this.pluginName;this.offAll(),util.clearAllTimers(this),util.checkIsFunction(this.destroy)&&this.destroy(),_mapInstanceProperty(e=["player","playerConfig","pluginName","logger","__args","__hooks"]).call(e,(function(e){t[e]=null})),r.unRegisterPlugin(n),delHooksDescriptor(this)}}],[{key:"defineGetterOrSetter",value:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&_Object$defineProperty(e,r,t[r])}},{key:"defineMethod",value:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&"function"==typeof t[r]&&_Object$defineProperty(e,r,{configurable:!0,value:t[r]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}(),fails$6=fails$A,wellKnownSymbol$4=wellKnownSymbol$r,DESCRIPTORS$4=descriptors,IS_PURE=isPure,ITERATOR$2=wellKnownSymbol$4("iterator"),urlConstructorDetection=!fails$6((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),IS_PURE&&!e.toJSON||!t.size&&(IS_PURE||!DESCRIPTORS$4)||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[ITERATOR$2]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host})),uncurryThis$8=functionUncurryThis,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexNonASCII=/[^\0-\u007E]/,regexSeparators=/[.\u3002\uFF0E\uFF61]/g,OVERFLOW_ERROR="Overflow: input needs wider integers to process",baseMinusTMin=base-tMin,$RangeError=RangeError,exec$1=uncurryThis$8(regexSeparators.exec),floor$2=Math.floor,fromCharCode=String.fromCharCode,charCodeAt=uncurryThis$8("".charCodeAt),join$2=uncurryThis$8([].join),push$6=uncurryThis$8([].push),replace$2=uncurryThis$8("".replace),split$2=uncurryThis$8("".split),toLowerCase$1=uncurryThis$8("".toLowerCase),ucs2decode=function(e){for(var t=[],r=0,n=e.length;r<n;){var a=charCodeAt(e,r++);if(a>=55296&&a<=56319&&r<n){var i=charCodeAt(e,r++);56320==(64512&i)?push$6(t,((1023&a)<<10)+(1023&i)+65536):(push$6(t,a),r--)}else push$6(t,a)}return t},digitToBasic=function(e){return e+22+75*(e<26)},adapt=function(e,t,r){var n=0;for(e=r?floor$2(e/damp):e>>1,e+=floor$2(e/t);e>baseMinusTMin*tMax>>1;)e=floor$2(e/baseMinusTMin),n+=base;return floor$2(n+(baseMinusTMin+1)*e/(e+skew))},encode=function(e){var t,r,n=[],a=(e=ucs2decode(e)).length,i=initialN,s=0,o=initialBias;for(t=0;t<e.length;t++)(r=e[t])<128&&push$6(n,fromCharCode(r));var l=n.length,c=l;for(l&&push$6(n,delimiter);c<a;){var u=maxInt;for(t=0;t<e.length;t++)(r=e[t])>=i&&r<u&&(u=r);var d=c+1;if(u-i>floor$2((maxInt-s)/d))throw $RangeError(OVERFLOW_ERROR);for(s+=(u-i)*d,i=u,t=0;t<e.length;t++){if((r=e[t])<i&&++s>maxInt)throw $RangeError(OVERFLOW_ERROR);if(r==i){for(var f=s,h=base;;){var p=h<=o?tMin:h>=o+tMax?tMax:h-o;if(f<p)break;var y=f-p,g=base-p;push$6(n,fromCharCode(digitToBasic(p+y%g))),f=floor$2(y/g),h+=base}push$6(n,fromCharCode(digitToBasic(f))),o=adapt(s,d,c==l),s=0,c++}}s++,i++}return join$2(n,"")},stringPunycodeToAscii=function(e){var t,r,n=[],a=split$2(replace$2(toLowerCase$1(e),regexSeparators,"."),".");for(t=0;t<a.length;t++)r=a[t],push$6(n,exec$1(regexNonASCII,r)?"xn--"+encode(r):r);return join$2(n,".")},defineBuiltIn$2=defineBuiltIn$8,defineBuiltIns$2=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:defineBuiltIn$2(e,n,t[n],r);return e},$$Z=_export,global$4=global$s,call$e=functionCall,uncurryThis$7=functionUncurryThis,DESCRIPTORS$3=descriptors,USE_NATIVE_URL$2=urlConstructorDetection,defineBuiltIn$1=defineBuiltIn$8,defineBuiltInAccessor$2=defineBuiltInAccessor$5,defineBuiltIns$1=defineBuiltIns$2,setToStringTag$2=setToStringTag$9,createIteratorConstructor=iteratorCreateConstructor,InternalStateModule$3=internalState,anInstance$3=anInstance$5,isCallable$5=isCallable$r,hasOwn$6=hasOwnProperty_1,bind$f=functionBindContext,classof$5=classof$f,anObject$3=anObject$i,isObject$6=isObject$m,$toString$1=toString$g,create$1=objectCreate,createPropertyDescriptor=createPropertyDescriptor$8,getIterator=getIterator$3,getIteratorMethod=getIteratorMethod$a,validateArgumentsLength$2=validateArgumentsLength$5,wellKnownSymbol$3=wellKnownSymbol$r,arraySort=arraySort$1,ITERATOR$1=wellKnownSymbol$3("iterator"),URL_SEARCH_PARAMS="URLSearchParams",URL_SEARCH_PARAMS_ITERATOR=URL_SEARCH_PARAMS+"Iterator",setInternalState$3=InternalStateModule$3.set,getInternalParamsState=InternalStateModule$3.getterFor(URL_SEARCH_PARAMS),getInternalIteratorState=InternalStateModule$3.getterFor(URL_SEARCH_PARAMS_ITERATOR),getOwnPropertyDescriptor5=Object.getOwnPropertyDescriptor,safeGetBuiltIn=function(e){if(!DESCRIPTORS$3)return global$4[e];var t=getOwnPropertyDescriptor5(global$4,e);return t&&t.value},nativeFetch=safeGetBuiltIn("fetch"),NativeRequest=safeGetBuiltIn("Request"),Headers=safeGetBuiltIn("Headers"),RequestPrototype=NativeRequest&&NativeRequest.prototype,HeadersPrototype=Headers&&Headers.prototype,RegExp$1=global$4.RegExp,TypeError$2=global$4.TypeError,decodeURIComponent$1=global$4.decodeURIComponent,encodeURIComponent$1=global$4.encodeURIComponent,charAt$1=uncurryThis$7("".charAt),join$1=uncurryThis$7([].join),push$5=uncurryThis$7([].push),replace$1=uncurryThis$7("".replace),shift$1=uncurryThis$7([].shift),splice2=uncurryThis$7([].splice),split$1=uncurryThis$7("".split),stringSlice$2=uncurryThis$7("".slice),plus=/\+/g,sequences=Array(4),percentSequence=function(e){return sequences[e-1]||(sequences[e-1]=RegExp$1("((?:%[\\da-f]{2}){"+e+"})","gi"))},percentDecode=function(e){try{return decodeURIComponent$1(e)}catch(t){return e}},deserialize=function(e){var t=replace$1(e,plus," "),r=4;try{return decodeURIComponent$1(t)}catch(e){for(;r;)t=replace$1(t,percentSequence(r--),percentDecode);return t}},find2=/[!'()~]|%20/g,replacements={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},replacer=function(e){return replacements[e]},serialize=function(e){return replace$1(encodeURIComponent$1(e),find2,replacer)},URLSearchParamsIterator=createIteratorConstructor((function(e,t){setInternalState$3(this,{type:URL_SEARCH_PARAMS_ITERATOR,iterator:getIterator(getInternalParamsState(e).entries),kind:t})}),"Iterator",(function(){var e=getInternalIteratorState(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),URLSearchParamsState=function(e){this.entries=[],this.url=null,void 0!==e&&(isObject$6(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===charAt$1(e,0)?stringSlice$2(e,1):e:$toString$1(e)))};URLSearchParamsState.prototype={type:URL_SEARCH_PARAMS,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,a,i,s,o,l=getIteratorMethod(e);if(l)for(r=(t=getIterator(e,l)).next;!(n=call$e(r,t)).done;){if(i=(a=getIterator(anObject$3(n.value))).next,(s=call$e(i,a)).done||(o=call$e(i,a)).done||!call$e(i,a).done)throw TypeError$2("Expected sequence with length 2");push$5(this.entries,{key:$toString$1(s.value),value:$toString$1(o.value)})}else for(var c in e)hasOwn$6(e,c)&&push$5(this.entries,{key:c,value:$toString$1(e[c])})},parseQuery:function(e){if(e)for(var t,r,n=split$1(e,"&"),a=0;a<n.length;)(t=n[a++]).length&&(r=split$1(t,"="),push$5(this.entries,{key:deserialize(shift$1(r)),value:deserialize(join$1(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],push$5(r,serialize(e.key)+"="+serialize(e.value));return join$1(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var URLSearchParamsConstructor=function(){anInstance$3(this,URLSearchParamsPrototype);var e=setInternalState$3(this,new URLSearchParamsState(arguments.length>0?arguments[0]:void 0));DESCRIPTORS$3||(this.length=e.entries.length)},URLSearchParamsPrototype=URLSearchParamsConstructor.prototype;if(defineBuiltIns$1(URLSearchParamsPrototype,{append:function(e,t){validateArgumentsLength$2(arguments.length,2);var r=getInternalParamsState(this);push$5(r.entries,{key:$toString$1(e),value:$toString$1(t)}),DESCRIPTORS$3||this.length++,r.updateURL()},delete:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this),r=t.entries,n=$toString$1(e),a=0;a<r.length;)r[a].key===n?splice2(r,a,1):a++;DESCRIPTORS$3||(this.length=r.length),t.updateURL()},get:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=[],a=0;a<t.length;a++)t[a].key===r&&push$5(n,t[a].value);return n},has:function(e){validateArgumentsLength$2(arguments.length,1);for(var t=getInternalParamsState(this).entries,r=$toString$1(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){validateArgumentsLength$2(arguments.length,1);for(var r,n=getInternalParamsState(this),a=n.entries,i=!1,s=$toString$1(e),o=$toString$1(t),l=0;l<a.length;l++)(r=a[l]).key===s&&(i?splice2(a,l--,1):(i=!0,r.value=o));i||push$5(a,{key:s,value:o}),DESCRIPTORS$3||(this.length=a.length),n.updateURL()},sort:function(){var e=getInternalParamsState(this);arraySort(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=getInternalParamsState(this).entries,n=bind$f(e,arguments.length>1?arguments[1]:void 0),a=0;a<r.length;)n((t=r[a++]).value,t.key,this)},keys:function(){return new URLSearchParamsIterator(this,"keys")},values:function(){return new URLSearchParamsIterator(this,"values")},entries:function(){return new URLSearchParamsIterator(this,"entries")}},{enumerable:!0}),defineBuiltIn$1(URLSearchParamsPrototype,ITERATOR$1,URLSearchParamsPrototype.entries,{name:"entries"}),defineBuiltIn$1(URLSearchParamsPrototype,"toString",(function(){return getInternalParamsState(this).serialize()}),{enumerable:!0}),DESCRIPTORS$3&&defineBuiltInAccessor$2(URLSearchParamsPrototype,"size",{get:function(){return getInternalParamsState(this).entries.length},configurable:!0,enumerable:!0}),setToStringTag$2(URLSearchParamsConstructor,URL_SEARCH_PARAMS),$$Z({global:!0,constructor:!0,forced:!USE_NATIVE_URL$2},{URLSearchParams:URLSearchParamsConstructor}),!USE_NATIVE_URL$2&&isCallable$5(Headers)){var headersHas=uncurryThis$7(HeadersPrototype.has),headersSet=uncurryThis$7(HeadersPrototype.set),wrapRequestOptions=function(e){if(isObject$6(e)){var t,r=e.body;if(classof$5(r)===URL_SEARCH_PARAMS)return t=e.headers?new Headers(e.headers):new Headers,headersHas(t,"content-type")||headersSet(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),create$1(e,{body:createPropertyDescriptor(0,$toString$1(r)),headers:createPropertyDescriptor(0,t)})}return e};if(isCallable$5(nativeFetch)&&$$Z({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return nativeFetch(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})}}),isCallable$5(NativeRequest)){var RequestConstructor=function(e){return anInstance$3(this,RequestPrototype),new NativeRequest(e,arguments.length>1?wrapRequestOptions(arguments[1]):{})};RequestPrototype.constructor=RequestConstructor,RequestConstructor.prototype=RequestPrototype,$$Z({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:RequestConstructor})}}var EOF,web_urlSearchParams_constructor={URLSearchParams:URLSearchParamsConstructor,getState:getInternalParamsState},$$Y=_export,DESCRIPTORS$2=descriptors,USE_NATIVE_URL$1=urlConstructorDetection,global$3=global$s,bind$e=functionBindContext,uncurryThis$6=functionUncurryThis,defineBuiltIn=defineBuiltIn$8,defineBuiltInAccessor$1=defineBuiltInAccessor$5,anInstance$2=anInstance$5,hasOwn$5=hasOwnProperty_1,assign2=objectAssign,arrayFrom=arrayFrom$1,arraySlice$1=arraySliceSimple,codeAt=stringMultibyte.codeAt,toASCII=stringPunycodeToAscii,$toString=toString$g,setToStringTag$1=setToStringTag$9,validateArgumentsLength$1=validateArgumentsLength$5,URLSearchParamsModule=web_urlSearchParams_constructor,InternalStateModule$2=internalState,setInternalState$2=InternalStateModule$2.set,getInternalURLState=InternalStateModule$2.getterFor("URL"),URLSearchParams$1=URLSearchParamsModule.URLSearchParams,getInternalSearchParamsState=URLSearchParamsModule.getState,NativeURL=global$3.URL,TypeError$1=global$3.TypeError,parseInt$1=global$3.parseInt,floor$1=Math.floor,pow=Math.pow,charAt=uncurryThis$6("".charAt),exec=uncurryThis$6(/./.exec),join=uncurryThis$6([].join),numberToString=uncurryThis$6(1..toString),pop=uncurryThis$6([].pop),push$4=uncurryThis$6([].push),replace=uncurryThis$6("".replace),shift=uncurryThis$6([].shift),split=uncurryThis$6("".split),stringSlice$1=uncurryThis$6("".slice),toLowerCase=uncurryThis$6("".toLowerCase),unshift=uncurryThis$6([].unshift),INVALID_AUTHORITY="Invalid authority",INVALID_SCHEME="Invalid scheme",INVALID_HOST="Invalid host",INVALID_PORT="Invalid port",ALPHA=/[a-z]/i,ALPHANUMERIC=/[\d+-.a-z]/i,DIGIT=/\d/,HEX_START=/^0x/i,OCT=/^[0-7]+$/,DEC=/^\d+$/,HEX=/^[\da-f]+$/i,FORBIDDEN_HOST_CODE_POINT=/[\0\t\n\r #%/:<>?@[\\\]^|]/,FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT=/[\0\t\n\r #/:<>?@[\\\]^|]/,LEADING_C0_CONTROL_OR_SPACE=/^[\u0000-\u0020]+/,TRAILING_C0_CONTROL_OR_SPACE=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,TAB_AND_NEW_LINE=/[\t\n\r]/g,parseIPv4=function(e){var t,r,n,a,i,s,o,l=split(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(a=l[n]))return e;if(i=10,a.length>1&&"0"==charAt(a,0)&&(i=exec(HEX_START,a)?16:8,a=stringSlice$1(a,8==i?1:2)),""===a)s=0;else{if(!exec(10==i?DEC:8==i?OCT:HEX,a))return e;s=parseInt$1(a,i)}push$4(r,s)}for(n=0;n<t;n++)if(s=r[n],n==t-1){if(s>=pow(256,5-t))return null}else if(s>255)return null;for(o=pop(r),n=0;n<r.length;n++)o+=r[n]*pow(256,3-n);return o},parseIPv6=function(e){var t,r,n,a,i,s,o,l=[0,0,0,0,0,0,0,0],c=0,u=null,d=0,f=function(){return charAt(e,d)};if(":"==f()){if(":"!=charAt(e,1))return;d+=2,u=++c}for(;f();){if(8==c)return;if(":"!=f()){for(t=r=0;r<4&&exec(HEX,f());)t=16*t+parseInt$1(f(),16),d++,r++;if("."==f()){if(0==r)return;if(d-=r,c>6)return;for(n=0;f();){if(a=null,n>0){if(!("."==f()&&n<4))return;d++}if(!exec(DIGIT,f()))return;for(;exec(DIGIT,f());){if(i=parseInt$1(f(),10),null===a)a=i;else{if(0==a)return;a=10*a+i}if(a>255)return;d++}l[c]=256*l[c]+a,2!=++n&&4!=n||c++}if(4!=n)return;break}if(":"==f()){if(d++,!f())return}else if(f())return;l[c++]=t}else{if(null!==u)return;d++,u=++c}}if(null!==u)for(s=c-u,c=7;0!=c&&s>0;)o=l[c],l[c--]=l[u+s-1],l[u+--s]=o;else if(8!=c)return;return l},findLongestZeroSequence=function(e){for(var t=null,r=1,n=null,a=0,i=0;i<8;i++)0!==e[i]?(a>r&&(t=n,r=a),n=null,a=0):(null===n&&(n=i),++a);return a>r&&(t=n,r=a),t},serializeHost=function(e){var t,r,n,a;if("number"==typeof e){for(t=[],r=0;r<4;r++)unshift(t,e%256),e=floor$1(e/256);return join(t,".")}if("object"==typeof e){for(t="",n=findLongestZeroSequence(e),r=0;r<8;r++)a&&0===e[r]||(a&&(a=!1),n===r?(t+=r?":":"::",a=!0):(t+=numberToString(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},C0ControlPercentEncodeSet={},fragmentPercentEncodeSet=assign2({},C0ControlPercentEncodeSet,{" ":1,'"':1,"<":1,">":1,"`":1}),pathPercentEncodeSet=assign2({},fragmentPercentEncodeSet,{"#":1,"?":1,"{":1,"}":1}),userinfoPercentEncodeSet=assign2({},pathPercentEncodeSet,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),percentEncode=function(e,t){var r=codeAt(e,0);return r>32&&r<127&&!hasOwn$5(t,e)?e:encodeURIComponent(e)},specialSchemes={ftp:21,file:null,http:80,https:443,ws:80,wss:443},isWindowsDriveLetter=function(e,t){var r;return 2==e.length&&exec(ALPHA,charAt(e,0))&&(":"==(r=charAt(e,1))||!t&&"|"==r)},startsWithWindowsDriveLetter=function(e){var t;return e.length>1&&isWindowsDriveLetter(stringSlice$1(e,0,2))&&(2==e.length||"/"===(t=charAt(e,2))||"\\"===t||"?"===t||"#"===t)},isSingleDot=function(e){return"."===e||"%2e"===toLowerCase(e)},isDoubleDot=function(e){return".."===(e=toLowerCase(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},SCHEME_START={},SCHEME={},NO_SCHEME={},SPECIAL_RELATIVE_OR_AUTHORITY={},PATH_OR_AUTHORITY={},RELATIVE={},RELATIVE_SLASH={},SPECIAL_AUTHORITY_SLASHES={},SPECIAL_AUTHORITY_IGNORE_SLASHES={},AUTHORITY={},HOST={},HOSTNAME={},PORT={},FILE={},FILE_SLASH={},FILE_HOST={},PATH_START={},PATH={},CANNOT_BE_A_BASE_URL_PATH={},QUERY={},FRAGMENT={},URLState=function(e,t,r){var n,a,i,s=$toString(e);if(t){if(a=this.parse(s))throw TypeError$1(a);this.searchParams=null}else{if(void 0!==r&&(n=new URLState(r,!0)),a=this.parse(s,null,n))throw TypeError$1(a);(i=getInternalSearchParamsState(new URLSearchParams$1)).bindURL(this),this.searchParams=i}};URLState.prototype={type:"URL",parse:function(e,t,r){var n,a,i,s,o=this,l=t||SCHEME_START,c=0,u="",d=!1,f=!1,h=!1;for(e=$toString(e),t||(o.scheme="",o.username="",o.password="",o.host=null,o.port=null,o.path=[],o.query=null,o.fragment=null,o.cannotBeABaseURL=!1,e=replace(e,LEADING_C0_CONTROL_OR_SPACE,""),e=replace(e,TRAILING_C0_CONTROL_OR_SPACE,"$1")),e=replace(e,TAB_AND_NEW_LINE,""),n=arrayFrom(e);c<=n.length;){switch(a=n[c],l){case SCHEME_START:if(!a||!exec(ALPHA,a)){if(t)return INVALID_SCHEME;l=NO_SCHEME;continue}u+=toLowerCase(a),l=SCHEME;break;case SCHEME:if(a&&(exec(ALPHANUMERIC,a)||"+"==a||"-"==a||"."==a))u+=toLowerCase(a);else{if(":"!=a){if(t)return INVALID_SCHEME;u="",l=NO_SCHEME,c=0;continue}if(t&&(o.isSpecial()!=hasOwn$5(specialSchemes,u)||"file"==u&&(o.includesCredentials()||null!==o.port)||"file"==o.scheme&&!o.host))return;if(o.scheme=u,t)return void(o.isSpecial()&&specialSchemes[o.scheme]==o.port&&(o.port=null));u="","file"==o.scheme?l=FILE:o.isSpecial()&&r&&r.scheme==o.scheme?l=SPECIAL_RELATIVE_OR_AUTHORITY:o.isSpecial()?l=SPECIAL_AUTHORITY_SLASHES:"/"==n[c+1]?(l=PATH_OR_AUTHORITY,c++):(o.cannotBeABaseURL=!0,push$4(o.path,""),l=CANNOT_BE_A_BASE_URL_PATH)}break;case NO_SCHEME:if(!r||r.cannotBeABaseURL&&"#"!=a)return INVALID_SCHEME;if(r.cannotBeABaseURL&&"#"==a){o.scheme=r.scheme,o.path=arraySlice$1(r.path),o.query=r.query,o.fragment="",o.cannotBeABaseURL=!0,l=FRAGMENT;break}l="file"==r.scheme?FILE:RELATIVE;continue;case SPECIAL_RELATIVE_OR_AUTHORITY:if("/"!=a||"/"!=n[c+1]){l=RELATIVE;continue}l=SPECIAL_AUTHORITY_IGNORE_SLASHES,c++;break;case PATH_OR_AUTHORITY:if("/"==a){l=AUTHORITY;break}l=PATH;continue;case RELATIVE:if(o.scheme=r.scheme,a==EOF)o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.query=r.query;else if("/"==a||"\\"==a&&o.isSpecial())l=RELATIVE_SLASH;else if("?"==a)o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.query="",l=QUERY;else{if("#"!=a){o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.path.length--,l=PATH;continue}o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,o.path=arraySlice$1(r.path),o.query=r.query,o.fragment="",l=FRAGMENT}break;case RELATIVE_SLASH:if(!o.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){o.username=r.username,o.password=r.password,o.host=r.host,o.port=r.port,l=PATH;continue}l=AUTHORITY}else l=SPECIAL_AUTHORITY_IGNORE_SLASHES;break;case SPECIAL_AUTHORITY_SLASHES:if(l=SPECIAL_AUTHORITY_IGNORE_SLASHES,"/"!=a||"/"!=charAt(u,c+1))continue;c++;break;case SPECIAL_AUTHORITY_IGNORE_SLASHES:if("/"!=a&&"\\"!=a){l=AUTHORITY;continue}break;case AUTHORITY:if("@"==a){d&&(u="%40"+u),d=!0,i=arrayFrom(u);for(var p=0;p<i.length;p++){var y=i[p];if(":"!=y||h){var g=percentEncode(y,userinfoPercentEncodeSet);h?o.password+=g:o.username+=g}else h=!0}u=""}else if(a==EOF||"/"==a||"?"==a||"#"==a||"\\"==a&&o.isSpecial()){if(d&&""==u)return INVALID_AUTHORITY;c-=arrayFrom(u).length+1,u="",l=HOST}else u+=a;break;case HOST:case HOSTNAME:if(t&&"file"==o.scheme){l=FILE_HOST;continue}if(":"!=a||f){if(a==EOF||"/"==a||"?"==a||"#"==a||"\\"==a&&o.isSpecial()){if(o.isSpecial()&&""==u)return INVALID_HOST;if(t&&""==u&&(o.includesCredentials()||null!==o.port))return;if(s=o.parseHost(u))return s;if(u="",l=PATH_START,t)return;continue}"["==a?f=!0:"]"==a&&(f=!1),u+=a}else{if(""==u)return INVALID_HOST;if(s=o.parseHost(u))return s;if(u="",l=PORT,t==HOSTNAME)return}break;case PORT:if(!exec(DIGIT,a)){if(a==EOF||"/"==a||"?"==a||"#"==a||"\\"==a&&o.isSpecial()||t){if(""!=u){var v=parseInt$1(u,10);if(v>65535)return INVALID_PORT;o.port=o.isSpecial()&&v===specialSchemes[o.scheme]?null:v,u=""}if(t)return;l=PATH_START;continue}return INVALID_PORT}u+=a;break;case FILE:if(o.scheme="file","/"==a||"\\"==a)l=FILE_SLASH;else{if(!r||"file"!=r.scheme){l=PATH;continue}if(a==EOF)o.host=r.host,o.path=arraySlice$1(r.path),o.query=r.query;else if("?"==a)o.host=r.host,o.path=arraySlice$1(r.path),o.query="",l=QUERY;else{if("#"!=a){startsWithWindowsDriveLetter(join(arraySlice$1(n,c),""))||(o.host=r.host,o.path=arraySlice$1(r.path),o.shortenPath()),l=PATH;continue}o.host=r.host,o.path=arraySlice$1(r.path),o.query=r.query,o.fragment="",l=FRAGMENT}}break;case FILE_SLASH:if("/"==a||"\\"==a){l=FILE_HOST;break}r&&"file"==r.scheme&&!startsWithWindowsDriveLetter(join(arraySlice$1(n,c),""))&&(isWindowsDriveLetter(r.path[0],!0)?push$4(o.path,r.path[0]):o.host=r.host),l=PATH;continue;case FILE_HOST:if(a==EOF||"/"==a||"\\"==a||"?"==a||"#"==a){if(!t&&isWindowsDriveLetter(u))l=PATH;else if(""==u){if(o.host="",t)return;l=PATH_START}else{if(s=o.parseHost(u))return s;if("localhost"==o.host&&(o.host=""),t)return;u="",l=PATH_START}continue}u+=a;break;case PATH_START:if(o.isSpecial()){if(l=PATH,"/"!=a&&"\\"!=a)continue}else if(t||"?"!=a)if(t||"#"!=a){if(a!=EOF&&(l=PATH,"/"!=a))continue}else o.fragment="",l=FRAGMENT;else o.query="",l=QUERY;break;case PATH:if(a==EOF||"/"==a||"\\"==a&&o.isSpecial()||!t&&("?"==a||"#"==a)){if(isDoubleDot(u)?(o.shortenPath(),"/"==a||"\\"==a&&o.isSpecial()||push$4(o.path,"")):isSingleDot(u)?"/"==a||"\\"==a&&o.isSpecial()||push$4(o.path,""):("file"==o.scheme&&!o.path.length&&isWindowsDriveLetter(u)&&(o.host&&(o.host=""),u=charAt(u,0)+":"),push$4(o.path,u)),u="","file"==o.scheme&&(a==EOF||"?"==a||"#"==a))for(;o.path.length>1&&""===o.path[0];)shift(o.path);"?"==a?(o.query="",l=QUERY):"#"==a&&(o.fragment="",l=FRAGMENT)}else u+=percentEncode(a,pathPercentEncodeSet);break;case CANNOT_BE_A_BASE_URL_PATH:"?"==a?(o.query="",l=QUERY):"#"==a?(o.fragment="",l=FRAGMENT):a!=EOF&&(o.path[0]+=percentEncode(a,C0ControlPercentEncodeSet));break;case QUERY:t||"#"!=a?a!=EOF&&("'"==a&&o.isSpecial()?o.query+="%27":o.query+="#"==a?"%23":percentEncode(a,C0ControlPercentEncodeSet)):(o.fragment="",l=FRAGMENT);break;case FRAGMENT:a!=EOF&&(o.fragment+=percentEncode(a,fragmentPercentEncodeSet))}c++}},parseHost:function(e){var t,r,n;if("["==charAt(e,0)){if("]"!=charAt(e,e.length-1))return INVALID_HOST;if(!(t=parseIPv6(stringSlice$1(e,1,-1))))return INVALID_HOST;this.host=t}else if(this.isSpecial()){if(e=toASCII(e),exec(FORBIDDEN_HOST_CODE_POINT,e))return INVALID_HOST;if(null===(t=parseIPv4(e)))return INVALID_HOST;this.host=t}else{if(exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT,e))return INVALID_HOST;for(t="",r=arrayFrom(e),n=0;n<r.length;n++)t+=percentEncode(r[n],C0ControlPercentEncodeSet);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return hasOwn$5(specialSchemes,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&isWindowsDriveLetter(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,a=e.host,i=e.port,s=e.path,o=e.query,l=e.fragment,c=t+":";return null!==a?(c+="//",e.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=serializeHost(a),null!==i&&(c+=":"+i)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+join(s,"/"):"",null!==o&&(c+="?"+o),null!==l&&(c+="#"+l),c},setHref:function(e){var t=this.parse(e);if(t)throw TypeError$1(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new URLConstructor(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+serializeHost(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse($toString(e)+":",SCHEME_START)},getUsername:function(){return this.username},setUsername:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=percentEncode(t[r],userinfoPercentEncodeSet)}},getPassword:function(){return this.password},setPassword:function(e){var t=arrayFrom($toString(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=percentEncode(t[r],userinfoPercentEncodeSet)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?serializeHost(e):serializeHost(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,HOST)},getHostname:function(){var e=this.host;return null===e?"":serializeHost(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,HOSTNAME)},getPort:function(){var e=this.port;return null===e?"":$toString(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=$toString(e))?this.port=null:this.parse(e,PORT))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+join(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,PATH_START))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=$toString(e))?this.query=null:("?"==charAt(e,0)&&(e=stringSlice$1(e,1)),this.query="",this.parse(e,QUERY)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=$toString(e))?("#"==charAt(e,0)&&(e=stringSlice$1(e,1)),this.fragment="",this.parse(e,FRAGMENT)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var URLConstructor=function(e){var t=anInstance$2(this,URLPrototype),r=validateArgumentsLength$1(arguments.length,1)>1?arguments[1]:void 0,n=setInternalState$2(t,new URLState(e,!1,r));DESCRIPTORS$2||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},URLPrototype=URLConstructor.prototype,accessorDescriptor=function(e,t){return{get:function(){return getInternalURLState(this)[e]()},set:t&&function(e){return getInternalURLState(this)[t](e)},configurable:!0,enumerable:!0}};if(DESCRIPTORS$2&&(defineBuiltInAccessor$1(URLPrototype,"href",accessorDescriptor("serialize","setHref")),defineBuiltInAccessor$1(URLPrototype,"origin",accessorDescriptor("getOrigin")),defineBuiltInAccessor$1(URLPrototype,"protocol",accessorDescriptor("getProtocol","setProtocol")),defineBuiltInAccessor$1(URLPrototype,"username",accessorDescriptor("getUsername","setUsername")),defineBuiltInAccessor$1(URLPrototype,"password",accessorDescriptor("getPassword","setPassword")),defineBuiltInAccessor$1(URLPrototype,"host",accessorDescriptor("getHost","setHost")),defineBuiltInAccessor$1(URLPrototype,"hostname",accessorDescriptor("getHostname","setHostname")),defineBuiltInAccessor$1(URLPrototype,"port",accessorDescriptor("getPort","setPort")),defineBuiltInAccessor$1(URLPrototype,"pathname",accessorDescriptor("getPathname","setPathname")),defineBuiltInAccessor$1(URLPrototype,"search",accessorDescriptor("getSearch","setSearch")),defineBuiltInAccessor$1(URLPrototype,"searchParams",accessorDescriptor("getSearchParams")),defineBuiltInAccessor$1(URLPrototype,"hash",accessorDescriptor("getHash","setHash"))),defineBuiltIn(URLPrototype,"toJSON",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),defineBuiltIn(URLPrototype,"toString",(function(){return getInternalURLState(this).serialize()}),{enumerable:!0}),NativeURL){var nativeCreateObjectURL=NativeURL.createObjectURL,nativeRevokeObjectURL=NativeURL.revokeObjectURL;nativeCreateObjectURL&&defineBuiltIn(URLConstructor,"createObjectURL",bind$e(nativeCreateObjectURL,NativeURL)),nativeRevokeObjectURL&&defineBuiltIn(URLConstructor,"revokeObjectURL",bind$e(nativeRevokeObjectURL,NativeURL))}setToStringTag$1(URLConstructor,"URL"),$$Y({global:!0,constructor:!0,forced:!USE_NATIVE_URL$1,sham:!DESCRIPTORS$2},{URL:URLConstructor});var $$X=_export,getBuiltIn$3=getBuiltIn$j,fails$5=fails$A,validateArgumentsLength=validateArgumentsLength$5,toString$3=toString$g,USE_NATIVE_URL=urlConstructorDetection,URL$1=getBuiltIn$3("URL"),THROWS_WITHOUT_ARGUMENTS=USE_NATIVE_URL&&fails$5((function(){URL$1.canParse()}));$$X({target:"URL",stat:!0,forced:!THROWS_WITHOUT_ARGUMENTS},{canParse:function(e){var t=validateArgumentsLength(arguments.length,1),r=toString$3(e),n=t<2||void 0===arguments[1]?void 0:toString$3(arguments[1]);try{return!!new URL$1(r,n)}catch(e){return!1}}});var path$7=path$y,url$5=path$7.URL,parent$R=url$5,url$4=parent$R,parent$Q=url$4,url$3=parent$Q,parent$P=url$3,url$2=parent$P,url$1=url$2,url=url$1,_URL=getDefaultExportFromCjs$1(url),path$6=path$y,apply$1=functionApply;path$6.JSON||(path$6.JSON={stringify:JSON.stringify});var stringify$5=function(e,t,r){return apply$1(path$6.JSON.stringify,null,arguments)},parent$O=stringify$5,stringify$4=parent$O,parent$N=stringify$4,stringify$3=parent$N,parent$M=stringify$3,stringify$2=parent$M,stringify$1=stringify$2,stringify2=stringify$1,_JSON$stringify=getDefaultExportFromCjs$1(stringify2),isObject$5=isObject$m,classof$4=classofRaw$2,wellKnownSymbol$2=wellKnownSymbol$r,MATCH$1=wellKnownSymbol$2("match"),isRegexp=function(e){var t;return isObject$5(e)&&(void 0!==(t=e[MATCH$1])?!!t:"RegExp"==classof$4(e))},isRegExp=isRegexp,$TypeError$6=TypeError,notARegexp=function(e){if(isRegExp(e))throw $TypeError$6("The method doesn't accept regular expressions");return e},wellKnownSymbol$1=wellKnownSymbol$r,MATCH=wellKnownSymbol$1("match"),correctIsRegexpLogic=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[MATCH]=!1,"/./"[e](t)}catch(e){}}return!1},$$W=_export,uncurryThis$5=functionUncurryThisClause;objectGetOwnPropertyDescriptor.f;var toLength=toLength$3,toString$2=toString$g,notARegExp$1=notARegexp,requireObjectCoercible$1=requireObjectCoercible$8,correctIsRegExpLogic$1=correctIsRegexpLogic,nativeStartsWith=uncurryThis$5("".startsWith),stringSlice=uncurryThis$5("".slice),min$1=Math.min,CORRECT_IS_REGEXP_LOGIC=correctIsRegExpLogic$1("startsWith");$$W({target:"String",proto:!0,forced:!CORRECT_IS_REGEXP_LOGIC},{startsWith:function(e){var t=toString$2(requireObjectCoercible$1(this));notARegExp$1(e);var r=toLength(min$1(arguments.length>1?arguments[1]:void 0,t.length)),n=toString$2(e);return nativeStartsWith?nativeStartsWith(t,n,r):stringSlice(t,r,r+n.length)===n}});var entryVirtual$7=entryVirtual$n,startsWith$7=entryVirtual$7("String").startsWith,isPrototypeOf$8=objectIsPrototypeOf,method$5=startsWith$7,StringPrototype$1=String.prototype,startsWith$6=function(e){var t=e.startsWith;return"string"==typeof e||e===StringPrototype$1||isPrototypeOf$8(StringPrototype$1,e)&&t===StringPrototype$1.startsWith?method$5:t},parent$L=startsWith$6,startsWith$5=parent$L,parent$K=startsWith$5,startsWith$4=parent$K,parent$J=startsWith$4,startsWith$3=parent$J,startsWith$2=startsWith$3,startsWith$1=startsWith$2,_startsWithInstanceProperty=getDefaultExportFromCjs$1(startsWith$1),isObject$4=isObject$m,floor=Math.floor,isIntegralNumber$2=Number.isInteger||function(e){return!isObject$4(e)&&isFinite(e)&&floor(e)===e},$$V=_export,isIntegralNumber$1=isIntegralNumber$2;$$V({target:"Number",stat:!0},{isInteger:isIntegralNumber$1});var path$5=path$y,isInteger$5=path$5.Number.isInteger,parent$I=isInteger$5,isInteger$4=parent$I,parent$H=isInteger$4,isInteger$3=parent$H,parent$G=isInteger$3,isInteger$2=parent$G,isInteger$1=isInteger$2,isInteger2=isInteger$1,_Number$isInteger=getDefaultExportFromCjs$1(isInteger2),$$U=_export,$includes=arrayIncludes.includes,fails$4=fails$A,BROKEN_ON_SPARSE=fails$4((function(){return!Array(1).includes()}));$$U({target:"Array",proto:!0,forced:BROKEN_ON_SPARSE},{includes:function(e){return $includes(this,e,arguments.length>1?arguments[1]:void 0)}});var entryVirtual$6=entryVirtual$n,includes$7=entryVirtual$6("Array").includes,$$T=_export,uncurryThis$4=functionUncurryThis,notARegExp=notARegexp,requireObjectCoercible=requireObjectCoercible$8,toString$1=toString$g,correctIsRegExpLogic=correctIsRegexpLogic,stringIndexOf=uncurryThis$4("".indexOf);$$T({target:"String",proto:!0,forced:!correctIsRegExpLogic("includes")},{includes:function(e){return!!~stringIndexOf(toString$1(requireObjectCoercible(this)),toString$1(notARegExp(e)),arguments.length>1?arguments[1]:void 0)}});var entryVirtual$5=entryVirtual$n,includes$6=entryVirtual$5("String").includes,isPrototypeOf$7=objectIsPrototypeOf,arrayMethod=includes$7,stringMethod=includes$6,ArrayPrototype$5=Array.prototype,StringPrototype=String.prototype,includes$5=function(e){var t=e.includes;return e===ArrayPrototype$5||isPrototypeOf$7(ArrayPrototype$5,e)&&t===ArrayPrototype$5.includes?arrayMethod:"string"==typeof e||e===StringPrototype||isPrototypeOf$7(StringPrototype,e)&&t===StringPrototype.includes?stringMethod:t},parent$F=includes$5,includes$4=parent$F,parent$E=includes$4,includes$3=parent$E,parent$D=includes$3,includes$2=parent$D,includes$1=includes$2,includes3=includes$1,_includesInstanceProperty=getDefaultExportFromCjs$1(includes3);function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){var r;if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=_sliceInstanceProperty$1(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?_Array$from$1(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _createForOfIteratorHelper(e,t){var r=void 0!==_Symbol$1&&_getIteratorMethod$1(e)||e["@@iterator"];if(!r){if(_Array$isArray$1(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw i}}}}function _arrayWithoutHoles(e){if(_Array$isArray$1(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if(void 0!==_Symbol$1&&null!=_getIteratorMethod$1(e)||null!=e["@@iterator"])return _Array$from$1(e)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithHoles(e){if(_Array$isArray$1(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:void 0!==_Symbol$1&&_getIteratorMethod$1(e)||e["@@iterator"];if(null!=r){var n,a,i,s,o=[],l=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(_pushInstanceProperty(o).call(o,n.value),o.length!==t);l=!0);}catch(e){c=!0,a=e}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw a}}return o}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}var internalMetadata={exports:{}},fails$3=fails$A,arrayBufferNonExtensible=fails$3((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fails$2=fails$A,isObject$3=isObject$m,classof$3=classofRaw$2,ARRAY_BUFFER_NON_EXTENSIBLE=arrayBufferNonExtensible,$isExtensible=Object.isExtensible,FAILS_ON_PRIMITIVES=fails$2((function(){$isExtensible(1)})),objectIsExtensible=FAILS_ON_PRIMITIVES||ARRAY_BUFFER_NON_EXTENSIBLE?function(e){return!!isObject$3(e)&&((!ARRAY_BUFFER_NON_EXTENSIBLE||"ArrayBuffer"!=classof$3(e))&&(!$isExtensible||$isExtensible(e)))}:$isExtensible,fails$1=fails$A,freezing=!fails$1((function(){return Object.isExtensible(Object.preventExtensions({}))})),$$S=_export,uncurryThis$3=functionUncurryThis,hiddenKeys=hiddenKeys$6,isObject$2=isObject$m,hasOwn$4=hasOwnProperty_1,defineProperty$1=objectDefineProperty.f,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertyNamesExternalModule=objectGetOwnPropertyNamesExternal,isExtensible2=objectIsExtensible,uid=uid$4,FREEZING=freezing,REQUIRED=!1,METADATA=uid("meta"),id=0,setMetadata=function(e){defineProperty$1(e,METADATA,{value:{objectID:"O"+id++,weakData:{}}})},fastKey$1=function(e,t){if(!isObject$2(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!hasOwn$4(e,METADATA)){if(!isExtensible2(e))return"F";if(!t)return"E";setMetadata(e)}return e[METADATA].objectID},getWeakData=function(e,t){if(!hasOwn$4(e,METADATA)){if(!isExtensible2(e))return!0;if(!t)return!1;setMetadata(e)}return e[METADATA].weakData},onFreeze=function(e){return FREEZING&&REQUIRED&&isExtensible2(e)&&!hasOwn$4(e,METADATA)&&setMetadata(e),e},enable=function(){meta.enable=function(){},REQUIRED=!0;var e=getOwnPropertyNamesModule.f,t=uncurryThis$3([].splice),r={};r[METADATA]=1,e(r).length&&(getOwnPropertyNamesModule.f=function(r){for(var n=e(r),a=0,i=n.length;a<i;a++)if(n[a]===METADATA){t(n,a,1);break}return n},$$S({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:getOwnPropertyNamesExternalModule.f}))},meta=internalMetadata.exports={enable:enable,fastKey:fastKey$1,getWeakData:getWeakData,onFreeze:onFreeze};hiddenKeys[METADATA]=!0;var internalMetadataExports=internalMetadata.exports,$$R=_export,global$2=global$s,InternalMetadataModule=internalMetadataExports,fails=fails$A,createNonEnumerableProperty=createNonEnumerableProperty$9,iterate$o=iterate$u,anInstance$1=anInstance$5,isCallable$4=isCallable$r,isObject$1=isObject$m,setToStringTag=setToStringTag$9,defineProperty5=objectDefineProperty.f,forEach3=arrayIteration.forEach,DESCRIPTORS$1=descriptors,InternalStateModule$1=internalState,setInternalState$1=InternalStateModule$1.set,internalStateGetterFor$1=InternalStateModule$1.getterFor,collection$2=function(e,t,r){var n,a=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),s=a?"set":"add",o=global$2[e],l=o&&o.prototype,c={};if(DESCRIPTORS$1&&isCallable$4(o)&&(i||l.forEach&&!fails((function(){(new o).entries().next()})))){var u=(n=t((function(t,r){setInternalState$1(anInstance$1(t,u),{type:e,collection:new o}),null!=r&&iterate$o(r,t[s],{that:t,AS_ENTRIES:a})}))).prototype,d=internalStateGetterFor$1(e);forEach3(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in l)||i&&"clear"==e||createNonEnumerableProperty(u,e,(function(r,n){var a=d(this).collection;if(!t&&i&&!isObject$1(r))return"get"==e&&void 0;var s=a[e](0===r?0:r,n);return t?this:s}))})),i||defineProperty5(u,"size",{configurable:!0,get:function(){return d(this).collection.size}})}else n=r.getConstructor(t,e,a,s),InternalMetadataModule.enable();return setToStringTag(n,e,!1,!0),c[e]=n,$$R({global:!0,forced:!0},c),i||r.setStrong(n,e,a),n},create4=objectCreate,defineBuiltInAccessor=defineBuiltInAccessor$5,defineBuiltIns=defineBuiltIns$2,bind$d=functionBindContext,anInstance=anInstance$5,isNullOrUndefined$2=isNullOrUndefined$7,iterate$n=iterate$u,defineIterator=iteratorDefine,createIterResultObject=createIterResultObject$3,setSpecies=setSpecies$2,DESCRIPTORS=descriptors,fastKey=internalMetadataExports.fastKey,InternalStateModule=internalState,setInternalState=InternalStateModule.set,internalStateGetterFor=InternalStateModule.getterFor,collectionStrong$2={getConstructor:function(e,t,r,n){var a=e((function(e,a){anInstance(e,i),setInternalState(e,{type:t,index:create4(null),first:void 0,last:void 0,size:0}),DESCRIPTORS||(e.size=0),isNullOrUndefined$2(a)||iterate$n(a,e[n],{that:e,AS_ENTRIES:r})})),i=a.prototype,s=internalStateGetterFor(t),o=function(e,t,r){var n,a,i=s(e),o=l(e,t);return o?o.value=r:(i.last=o={index:a=fastKey(t,!0),key:t,value:r,previous:n=i.last,next:void 0,removed:!1},i.first||(i.first=o),n&&(n.next=o),DESCRIPTORS?i.size++:e.size++,"F"!==a&&(i.index[a]=o)),e},l=function(e,t){var r,n=s(e),a=fastKey(t);if("F"!==a)return n.index[a];for(r=n.first;r;r=r.next)if(r.key==t)return r};return defineBuiltIns(i,{clear:function(){for(var e=s(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,DESCRIPTORS?e.size=0:this.size=0},delete:function(e){var t=this,r=s(t),n=l(t,e);if(n){var a=n.next,i=n.previous;delete r.index[n.index],n.removed=!0,i&&(i.next=a),a&&(a.previous=i),r.first==n&&(r.first=a),r.last==n&&(r.last=i),DESCRIPTORS?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=s(this),n=bind$d(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!l(this,e)}}),defineBuiltIns(i,r?{get:function(e){var t=l(this,e);return t&&t.value},set:function(e,t){return o(this,0===e?0:e,t)}}:{add:function(e){return o(this,e=0===e?0:e,e)}}),DESCRIPTORS&&defineBuiltInAccessor(i,"size",{configurable:!0,get:function(){return s(this).size}}),a},setStrong:function(e,t,r){var n=t+" Iterator",a=internalStateGetterFor(t),i=internalStateGetterFor(n);defineIterator(e,t,(function(e,t){setInternalState(this,{type:n,target:e,state:a(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?createIterResultObject("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,createIterResultObject(void 0,!0))}),r?"entries":"values",!r,!0),setSpecies(t)}},collection$1=collection$2,collectionStrong$1=collectionStrong$2;collection$1("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong$1);var path$4=path$y,map$5=path$4.Map,parent$C=map$5,map$4=parent$C,parent$B=map$4,map$3=parent$B,bind$c=functionBindContext,call$d=functionCall,aCallable$8=aCallable$l,aConstructor=aConstructor$3,isNullOrUndefined$1=isNullOrUndefined$7,iterate$m=iterate$u,push$3=[].push,collectionFrom=function(e){var t,r,n,a,i=arguments.length,s=i>1?arguments[1]:void 0;return aConstructor(this),(t=void 0!==s)&&aCallable$8(s),isNullOrUndefined$1(e)?new this:(r=[],t?(n=0,a=bind$c(s,i>2?arguments[2]:void 0),iterate$m(e,(function(e){call$d(push$3,r,a(e,n++))}))):iterate$m(e,push$3,{that:r}),new this(r))},$$Q=_export,from$1=collectionFrom;$$Q({target:"Map",stat:!0,forced:!0},{from:from$1});var arraySlice=arraySlice$7,collectionOf=function(){return new this(arraySlice(arguments))},$$P=_export,of$1=collectionOf;$$P({target:"Map",stat:!0,forced:!0},{of:of$1});var tryToString$1=tryToString$8,aMap$e=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"get"in e&&"set"in e&&"delete"in e&&"entries"in e)return e;throw TypeError(tryToString$1(e)+" is not a map")},caller$2=function(e,t){return 1==t?function(t,r){return t[e](r)}:function(t,r,n){return t[e](r,n)}},getBuiltIn$2=getBuiltIn$j,caller$1=caller$2,Map$5=getBuiltIn$2("Map"),mapHelpers={Map:Map$5,set:caller$1("set",2),get:caller$1("get",1),has:caller$1("has",1),remove:caller$1("delete",1),proto:Map$5.prototype},$$O=_export,aMap$d=aMap$e,remove$3=mapHelpers.remove;$$O({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=aMap$d(this),r=!0,n=0,a=arguments.length;n<a;n++)e=remove$3(t,arguments[n]),r=r&&e;return!!r}});var $$N=_export,aMap$c=aMap$e,MapHelpers$4=mapHelpers,get$1=MapHelpers$4.get,has$6=MapHelpers$4.has,set$b=MapHelpers$4.set;$$N({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,n,a=aMap$c(this);return has$6(a,e)?(r=get$1(a,e),"update"in t&&(r=t.update(r,e,a),set$b(a,e,r)),r):(n=t.insert(e,a),set$b(a,e,n),n)}});var call$c=functionCall,iterateSimple$8=function(e,t,r){for(var n,a,i=r||e.next;!(n=call$c(i,e)).done;)if(void 0!==(a=t(n.value)))return a},iterateSimple$7=iterateSimple$8,mapIterate=function(e,t,r){return r?iterateSimple$7(e.entries(),(function(e){return t(e[1],e[0])})):e.forEach(t)},$$M=_export,bind$b=functionBindContext,aMap$b=aMap$e,iterate$l=mapIterate;$$M({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=aMap$b(this),r=bind$b(e,arguments.length>1?arguments[1]:void 0);return!1!==iterate$l(t,(function(e,n){if(!r(e,n,t))return!1}),!0)}});var $$L=_export,bind$a=functionBindContext,aMap$a=aMap$e,MapHelpers$3=mapHelpers,iterate$k=mapIterate,Map$4=MapHelpers$3.Map,set$a=MapHelpers$3.set;$$L({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=aMap$a(this),r=bind$a(e,arguments.length>1?arguments[1]:void 0),n=new Map$4;return iterate$k(t,(function(e,a){r(e,a,t)&&set$a(n,a,e)})),n}});var $$K=_export,bind$9=functionBindContext,aMap$9=aMap$e,iterate$j=mapIterate;$$K({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=aMap$9(this),r=bind$9(e,arguments.length>1?arguments[1]:void 0),n=iterate$j(t,(function(e,n){if(r(e,n,t))return{value:e}}),!0);return n&&n.value}});var $$J=_export,bind$8=functionBindContext,aMap$8=aMap$e,iterate$i=mapIterate;$$J({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=aMap$8(this),r=bind$8(e,arguments.length>1?arguments[1]:void 0),n=iterate$i(t,(function(e,n){if(r(e,n,t))return{key:n}}),!0);return n&&n.key}});var $$I=_export,call$b=functionCall,uncurryThis$2=functionUncurryThis,isCallable$3=isCallable$r,aCallable$7=aCallable$l,iterate$h=iterate$u,Map$3=mapHelpers.Map,push$2=uncurryThis$2([].push);$$I({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){var r=new(isCallable$3(this)?this:Map$3);aCallable$7(t);var n=aCallable$7(r.has),a=aCallable$7(r.get),i=aCallable$7(r.set);return iterate$h(e,(function(e){var s=t(e);call$b(n,r,s)?push$2(call$b(a,r,s),e):call$b(i,r,s,[e])})),r}});var sameValueZero$1=function(e,t){return e===t||e!=e&&t!=t},$$H=_export,sameValueZero=sameValueZero$1,aMap$7=aMap$e,iterate$g=mapIterate;$$H({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===iterate$g(aMap$7(this),(function(t){if(sameValueZero(t,e))return!0}),!0)}});var $$G=_export,call$a=functionCall,iterate$f=iterate$u,isCallable$2=isCallable$r,aCallable$6=aCallable$l,Map$2=mapHelpers.Map;$$G({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(isCallable$2(this)?this:Map$2);aCallable$6(t);var n=aCallable$6(r.set);return iterate$f(e,(function(e){call$a(n,r,t(e),e)})),r}});var $$F=_export,aMap$6=aMap$e,iterate$e=mapIterate;$$F({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=iterate$e(aMap$6(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var $$E=_export,bind$7=functionBindContext,aMap$5=aMap$e,MapHelpers$2=mapHelpers,iterate$d=mapIterate,Map$1=MapHelpers$2.Map,set$9=MapHelpers$2.set;$$E({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=aMap$5(this),r=bind$7(e,arguments.length>1?arguments[1]:void 0),n=new Map$1;return iterate$d(t,(function(e,a){set$9(n,r(e,a,t),e)})),n}});var $$D=_export,bind$6=functionBindContext,aMap$4=aMap$e,MapHelpers$1=mapHelpers,iterate$c=mapIterate,Map=MapHelpers$1.Map,set$8=MapHelpers$1.set;$$D({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=aMap$4(this),r=bind$6(e,arguments.length>1?arguments[1]:void 0),n=new Map;return iterate$c(t,(function(e,a){set$8(n,a,r(e,a,t))})),n}});var $$C=_export,aMap$3=aMap$e,iterate$b=iterate$u,set$7=mapHelpers.set;$$C({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=aMap$3(this),r=arguments.length,n=0;n<r;)iterate$b(arguments[n++],(function(e,r){set$7(t,e,r)}),{AS_ENTRIES:!0});return t}});var $$B=_export,aCallable$5=aCallable$l,aMap$2=aMap$e,iterate$a=mapIterate,$TypeError$5=TypeError;$$B({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=aMap$2(this),r=arguments.length<2,n=r?void 0:arguments[1];if(aCallable$5(e),iterate$a(t,(function(a,i){r?(r=!1,n=a):n=e(n,a,i,t)})),r)throw $TypeError$5("Reduce of empty map with no initial value");return n}});var $$A=_export,bind$5=functionBindContext,aMap$1=aMap$e,iterate$9=mapIterate;$$A({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=aMap$1(this),r=bind$5(e,arguments.length>1?arguments[1]:void 0);return!0===iterate$9(t,(function(e,n){if(r(e,n,t))return!0}),!0)}});var $$z=_export,aCallable$4=aCallable$l,aMap=aMap$e,MapHelpers=mapHelpers,$TypeError$4=TypeError,get2=MapHelpers.get,has$5=MapHelpers.has,set$6=MapHelpers.set;$$z({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=aMap(this),n=arguments.length;aCallable$4(t);var a=has$5(r,e);if(!a&&n<3)throw $TypeError$4("Updating absent value");var i=a?get2(r,e):aCallable$4(n>2?arguments[2]:void 0)(e,r);return set$6(r,e,t(i,e,r)),r}});var call$9=functionCall,aCallable$3=aCallable$l,isCallable$1=isCallable$r,anObject$2=anObject$i,$TypeError$3=TypeError,mapUpsert=function(e,t){var r,n=anObject$2(this),a=aCallable$3(n.get),i=aCallable$3(n.has),s=aCallable$3(n.set),o=arguments.length>2?arguments[2]:void 0;if(!isCallable$1(t)&&!isCallable$1(o))throw $TypeError$3("At least one callback required");return call$9(i,n,e)?(r=call$9(a,n,e),isCallable$1(t)&&(r=t(r),call$9(s,n,e,r))):isCallable$1(o)&&(r=o(),call$9(s,n,e,r)),r},$$y=_export,upsert$1=mapUpsert;$$y({target:"Map",proto:!0,real:!0,forced:!0},{upsert:upsert$1});var $$x=_export,upsert2=mapUpsert;$$x({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:upsert2});var parent$A=map$3,map$2=parent$A,map$1=map$2,_Map$1=getDefaultExportFromCjs$1(map$1);function _isNativeFunction(e){var t;return-1!==_indexOfInstanceProperty$1(t=Function.toString.call(e)).call(t,"[native code]")}function _construct(e,t,r){var n;_isNativeReflectConstruct()?_construct=_bindInstanceProperty$1(n=_Reflect$construct).call(n):_construct=function(e,t,r){var n=[null];_pushInstanceProperty(n).apply(n,t);var a=new(_bindInstanceProperty$1(Function).apply(e,n));return r&&_setPrototypeOf(a,r.prototype),a};return _construct.apply(null,arguments)}function _wrapNativeSuper(e){var t="function"==typeof _Map$1?new _Map$1:void 0;return _wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return r.prototype=_Object$create$1(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,e)},_wrapNativeSuper(e)}var global$1=global$s,globalIsFinite=global$1.isFinite,numberIsFinite$1=Number.isFinite||function(e){return"number"==typeof e&&globalIsFinite(e)},$$w=_export,numberIsFinite=numberIsFinite$1;$$w({target:"Number",stat:!0},{isFinite:numberIsFinite});var path$3=path$y,_isFinite$5=path$3.Number.isFinite,parent$z=_isFinite$5,_isFinite$4=parent$z,parent$y=_isFinite$4,_isFinite$3=parent$y,parent$x=_isFinite$3,_isFinite$2=parent$x,_isFinite$1=_isFinite$2,_isFinite=_isFinite$1,_Number$isFinite=getDefaultExportFromCjs$1(_isFinite),$$v=_export,isIntegralNumber=isIntegralNumber$2,abs=Math.abs;$$v({target:"Number",stat:!0},{isSafeInteger:function(e){return isIntegralNumber(e)&&abs(e)<=9007199254740991}});var path$2=path$y,isSafeInteger$6=path$2.Number.isSafeInteger,parent$w=isSafeInteger$6,isSafeInteger$5=parent$w,parent$v=isSafeInteger$5,isSafeInteger$4=parent$v,parent$u=isSafeInteger$4,isSafeInteger$3=parent$u,isSafeInteger$2=isSafeInteger$3,isSafeInteger$1=isSafeInteger$2,_Number$isSafeInteger=getDefaultExportFromCjs$1(isSafeInteger$1),$$u=_export;$$u({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var maxSafeInteger$5=9007199254740991,parent$t=maxSafeInteger$5,maxSafeInteger$4=parent$t,parent$s=maxSafeInteger$4,maxSafeInteger$3=parent$s,parent$r=maxSafeInteger$3,maxSafeInteger$2=parent$r,maxSafeInteger$1=maxSafeInteger$2,maxSafeInteger=maxSafeInteger$1,_Number$MAX_SAFE_INTEGER=getDefaultExportFromCjs$1(maxSafeInteger),aCallable$2=aCallable$l,toObject=toObject$d,IndexedObject=indexedObject,lengthOfArrayLike$1=lengthOfArrayLike$c,$TypeError$2=TypeError,createMethod=function(e){return function(t,r,n,a){aCallable$2(r);var i=toObject(t),s=IndexedObject(i),o=lengthOfArrayLike$1(i),l=e?o-1:0,c=e?-1:1;if(n<2)for(;;){if(l in s){a=s[l],l+=c;break}if(l+=c,e?l<0:o<=l)throw $TypeError$2("Reduce of empty array with no initial value")}for(;e?l>=0:o>l;l+=c)l in s&&(a=r(a,s[l],l,i));return a}},arrayReduce={left:createMethod(!1),right:createMethod(!0)},$$t=_export,$reduce=arrayReduce.left,arrayMethodIsStrict$1=arrayMethodIsStrict$7,CHROME_VERSION=engineV8Version,IS_NODE=engineIsNode,CHROME_BUG=!IS_NODE&&engineV8Version>79&&engineV8Version<83,FORCED$1=CHROME_BUG||!arrayMethodIsStrict$1("reduce");$$t({target:"Array",proto:!0,forced:FORCED$1},{reduce:function(e){var t=arguments.length;return $reduce(this,e,t,t>1?arguments[1]:void 0)}});var entryVirtual$4=entryVirtual$n,reduce$6=entryVirtual$4("Array").reduce,isPrototypeOf$6=objectIsPrototypeOf,method$4=reduce$6,ArrayPrototype$4=Array.prototype,reduce$5=function(e){var t=e.reduce;return e===ArrayPrototype$4||isPrototypeOf$6(ArrayPrototype$4,e)&&t===ArrayPrototype$4.reduce?method$4:t},parent$q=reduce$5,reduce$4=parent$q,parent$p=reduce$4,reduce$3=parent$p,parent$o=reduce$3,reduce$2=parent$o,reduce$1=reduce$2,reduce3=reduce$1,_reduceInstanceProperty=getDefaultExportFromCjs$1(reduce3),anObject$1=anObject$i,regexpFlags=function(){var e=anObject$1(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},call$8=functionCall,hasOwn$3=hasOwnProperty_1,isPrototypeOf$5=objectIsPrototypeOf,regExpFlags=regexpFlags,RegExpPrototype$1=RegExp.prototype,regexpGetFlags=function(e){var t=e.flags;return void 0!==t||"flags"in RegExpPrototype$1||hasOwn$3(e,"flags")||!isPrototypeOf$5(RegExpPrototype$1,e)?t:call$8(regExpFlags,e)},getRegExpFlags=regexpGetFlags,flags$6=getRegExpFlags,isPrototypeOf$4=objectIsPrototypeOf,flags$5=flags$6,RegExpPrototype=RegExp.prototype,flags_1=function(e){return e===RegExpPrototype||isPrototypeOf$4(RegExpPrototype,e)?flags$5(e):e.flags},parent$n=flags_1,flags$4=parent$n,parent$m=flags$4,flags$3=parent$m,parent$l=flags$3,flags$2=parent$l,flags$1=flags$2,flags=flags$1,_flagsInstanceProperty=getDefaultExportFromCjs$1(flags),apply=functionApply,toIndexedObject=toIndexedObject$c,toIntegerOrInfinity$1=toIntegerOrInfinity$7,lengthOfArrayLike=lengthOfArrayLike$c,arrayMethodIsStrict=arrayMethodIsStrict$7,min=Math.min,$lastIndexOf=[].lastIndexOf,NEGATIVE_ZERO=!!$lastIndexOf&&1/[1].lastIndexOf(1,-0)<0,STRICT_METHOD=arrayMethodIsStrict("lastIndexOf"),FORCED=NEGATIVE_ZERO||!STRICT_METHOD,arrayLastIndexOf=FORCED?function(e){if(NEGATIVE_ZERO)return apply($lastIndexOf,this,arguments)||0;var t=toIndexedObject(this),r=lengthOfArrayLike(t),n=r-1;for(arguments.length>1&&(n=min(n,toIntegerOrInfinity$1(arguments[1]))),n<0&&(n=r+n);n>=0;n--)if(n in t&&t[n]===e)return n||0;return-1}:$lastIndexOf,$$s=_export,lastIndexOf$7=arrayLastIndexOf;$$s({target:"Array",proto:!0,forced:arrayLastIndexOf!==[].lastIndexOf},{lastIndexOf:arrayLastIndexOf});var entryVirtual$3=entryVirtual$n,lastIndexOf$6=entryVirtual$3("Array").lastIndexOf,isPrototypeOf$3=objectIsPrototypeOf,method$3=lastIndexOf$6,ArrayPrototype$3=Array.prototype,lastIndexOf$5=function(e){var t=e.lastIndexOf;return e===ArrayPrototype$3||isPrototypeOf$3(ArrayPrototype$3,e)&&t===ArrayPrototype$3.lastIndexOf?method$3:t},parent$k=lastIndexOf$5,lastIndexOf$4=parent$k,parent$j=lastIndexOf$4,lastIndexOf$3=parent$j,parent$i=lastIndexOf$3,lastIndexOf$2=parent$i,lastIndexOf$1=lastIndexOf$2,lastIndexOf2=lastIndexOf$1,_lastIndexOfInstanceProperty=getDefaultExportFromCjs$1(lastIndexOf2),$$r=_export,uncurryThis$1=functionUncurryThis,isArray2=isArray$d,nativeReverse=uncurryThis$1([].reverse),test=[1,2];$$r({target:"Array",proto:!0,forced:String(test)===String(test.reverse())},{reverse:function(){return isArray2(this)&&(this.length=this.length),nativeReverse(this)}});var entryVirtual$2=entryVirtual$n,reverse$6=entryVirtual$2("Array").reverse,isPrototypeOf$2=objectIsPrototypeOf,method$2=reverse$6,ArrayPrototype$2=Array.prototype,reverse$5=function(e){var t=e.reverse;return e===ArrayPrototype$2||isPrototypeOf$2(ArrayPrototype$2,e)&&t===ArrayPrototype$2.reverse?method$2:t},parent$h=reverse$5,reverse$4=parent$h,parent$g=reverse$4,reverse$3=parent$g,parent$f=reverse$3,reverse$2=parent$f,reverse$1=reverse$2,reverse2=reverse$1,_reverseInstanceProperty=getDefaultExportFromCjs$1(reverse2),$$q=_export;$$q({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var epsilon$5=Math.pow(2,-52),parent$e=epsilon$5,epsilon$4=parent$e,parent$d=epsilon$4,epsilon$3=parent$d,parent$c=epsilon$3,epsilon$2=parent$c,epsilon$1=epsilon$2,epsilon=epsilon$1,_Number$EPSILON=getDefaultExportFromCjs$1(epsilon),map2=map$1,_Map=getDefaultExportFromCjs$1(map2),collection=collection$2,collectionStrong=collectionStrong$2;collection("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),collectionStrong);var path$1=path$y,set$5=path$1.Set,parent$b=set$5,set$4=parent$b,tryToString=tryToString$8,aSet$g=function(e){if("object"==typeof e&&"size"in e&&"has"in e&&"add"in e&&"delete"in e&&"keys"in e)return e;throw TypeError(tryToString(e)+" is not a set")},getBuiltIn$1=getBuiltIn$j,caller=caller$2,Set$5=getBuiltIn$1("Set"),SetPrototype=Set$5.prototype,setHelpers={Set:Set$5,add:caller("add",1),has:caller("has",1),remove:caller("delete",1),proto:SetPrototype},iterateSimple$6=iterateSimple$8,setIterate=function(e,t,r){return r?iterateSimple$6(e.keys(),t):e.forEach(t)},SetHelpers$5=setHelpers,iterate$8=setIterate,Set$4=SetHelpers$5.Set,add$6=SetHelpers$5.add,setClone=function(e){var t=new Set$4;return iterate$8(e,(function(e){add$6(t,e)})),t},setSize=function(e){return e.size},aCallable$1=aCallable$l,anObject=anObject$i,call$7=functionCall,toIntegerOrInfinity=toIntegerOrInfinity$7,$TypeError$1=TypeError,max=Math.max,SetRecord=function(e,t,r,n){this.set=e,this.size=t,this.has=r,this.keys=n};SetRecord.prototype={getIterator:function(){return anObject(call$7(this.keys,this.set))},includes:function(e){return call$7(this.has,this.set,e)}};var getSetRecord$7=function(e){anObject(e);var t=+e.size;if(t!=t)throw $TypeError$1("Invalid size");return new SetRecord(e,max(toIntegerOrInfinity(t),0),aCallable$1(e.has),aCallable$1(e.keys))},aSet$f=aSet$g,SetHelpers$4=setHelpers,clone$2=setClone,size$4=setSize,getSetRecord$6=getSetRecord$7,iterateSet$2=setIterate,iterateSimple$5=iterateSimple$8,has$4=SetHelpers$4.has,remove$2=SetHelpers$4.remove,setDifference=function(e){var t=aSet$f(this),r=getSetRecord$6(e),n=clone$2(t);return size$4(t)<=r.size?iterateSet$2(t,(function(e){r.includes(e)&&remove$2(n,e)})):iterateSimple$5(r.getIterator(),(function(e){has$4(t,e)&&remove$2(n,e)})),n},setMethodAcceptSetLike$7=function(){return!1},$$p=_export,difference2=setDifference,setMethodAcceptSetLike$6=setMethodAcceptSetLike$7;$$p({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$6()},{difference:difference2});var aSet$e=aSet$g,SetHelpers$3=setHelpers,size$3=setSize,getSetRecord$5=getSetRecord$7,iterateSet$1=setIterate,iterateSimple$4=iterateSimple$8,Set$3=SetHelpers$3.Set,add$5=SetHelpers$3.add,has$3=SetHelpers$3.has,setIntersection=function(e){var t=aSet$e(this),r=getSetRecord$5(e),n=new Set$3;return size$3(t)>r.size?iterateSimple$4(r.getIterator(),(function(e){has$3(t,e)&&add$5(n,e)})):iterateSet$1(t,(function(e){r.includes(e)&&add$5(n,e)})),n},$$o=_export,intersection$1=setIntersection,setMethodAcceptSetLike$5=setMethodAcceptSetLike$7,INCORRECT=!setMethodAcceptSetLike$5();$$o({target:"Set",proto:!0,real:!0,forced:INCORRECT},{intersection:intersection$1});var aSet$d=aSet$g,has$2=setHelpers.has,size$2=setSize,getSetRecord$4=getSetRecord$7,iterateSet=setIterate,iterateSimple$3=iterateSimple$8,iteratorClose$1=iteratorClose$4,setIsDisjointFrom=function(e){var t=aSet$d(this),r=getSetRecord$4(e);if(size$2(t)<=r.size)return!1!==iterateSet(t,(function(e){if(r.includes(e))return!1}),!0);var n=r.getIterator();return!1!==iterateSimple$3(n,(function(e){if(has$2(t,e))return iteratorClose$1(n,"normal",!1)}))},$$n=_export,isDisjointFrom2=setIsDisjointFrom,setMethodAcceptSetLike$4=setMethodAcceptSetLike$7;$$n({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$4()},{isDisjointFrom:isDisjointFrom2});var aSet$c=aSet$g,size$1=setSize,iterate$7=setIterate,getSetRecord$3=getSetRecord$7,setIsSubsetOf=function(e){var t=aSet$c(this),r=getSetRecord$3(e);return!(size$1(t)>r.size)&&!1!==iterate$7(t,(function(e){if(!r.includes(e))return!1}),!0)},$$m=_export,isSubsetOf2=setIsSubsetOf,setMethodAcceptSetLike$3=setMethodAcceptSetLike$7;$$m({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$3()},{isSubsetOf:isSubsetOf2});var aSet$b=aSet$g,has$1=setHelpers.has,size2=setSize,getSetRecord$2=getSetRecord$7,iterateSimple$2=iterateSimple$8,iteratorClose=iteratorClose$4,setIsSupersetOf=function(e){var t=aSet$b(this),r=getSetRecord$2(e);if(size2(t)<r.size)return!1;var n=r.getIterator();return!1!==iterateSimple$2(n,(function(e){if(!has$1(t,e))return iteratorClose(n,"normal",!1)}))},$$l=_export,isSupersetOf2=setIsSupersetOf,setMethodAcceptSetLike$2=setMethodAcceptSetLike$7;$$l({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$2()},{isSupersetOf:isSupersetOf2});var aSet$a=aSet$g,SetHelpers$2=setHelpers,clone$1=setClone,getSetRecord$1=getSetRecord$7,iterateSimple$1=iterateSimple$8,add$4=SetHelpers$2.add,has2=SetHelpers$2.has,remove$1=SetHelpers$2.remove,setSymmetricDifference=function(e){var t=aSet$a(this),r=getSetRecord$1(e).getIterator(),n=clone$1(t);return iterateSimple$1(r,(function(e){has2(t,e)?remove$1(n,e):add$4(n,e)})),n},$$k=_export,symmetricDifference2=setSymmetricDifference,setMethodAcceptSetLike$1=setMethodAcceptSetLike$7;$$k({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike$1()},{symmetricDifference:symmetricDifference2});var aSet$9=aSet$g,add$3=setHelpers.add,clone=setClone,getSetRecord=getSetRecord$7,iterateSimple=iterateSimple$8,setUnion=function(e){var t=aSet$9(this),r=getSetRecord(e).getIterator(),n=clone(t);return iterateSimple(r,(function(e){add$3(n,e)})),n},$$j=_export,union2=setUnion,setMethodAcceptSetLike=setMethodAcceptSetLike$7;$$j({target:"Set",proto:!0,real:!0,forced:!setMethodAcceptSetLike()},{union:union2});var parent$a=set$4,set$3=parent$a,$$i=_export,from3=collectionFrom;$$i({target:"Set",stat:!0,forced:!0},{from:from3});var $$h=_export,of2=collectionOf;$$h({target:"Set",stat:!0,forced:!0},{of:of2});var $$g=_export,aSet$8=aSet$g,add$2=setHelpers.add;$$g({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=aSet$8(this),t=0,r=arguments.length;t<r;t++)add$2(e,arguments[t]);return e}});var $$f=_export,aSet$7=aSet$g,remove=setHelpers.remove;$$f({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=aSet$7(this),r=!0,n=0,a=arguments.length;n<a;n++)e=remove(t,arguments[n]),r=r&&e;return!!r}});var $$e=_export,bind$4=functionBindContext,aSet$6=aSet$g,iterate$6=setIterate;$$e({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=aSet$6(this),r=bind$4(e,arguments.length>1?arguments[1]:void 0);return!1!==iterate$6(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var classof$2=classof$f,hasOwn$2=hasOwnProperty_1,isNullOrUndefined=isNullOrUndefined$7,wellKnownSymbol=wellKnownSymbol$r,Iterators=iterators,ITERATOR=wellKnownSymbol("iterator"),$Object=Object,isIterable$1=function(e){if(isNullOrUndefined(e))return!1;var t=$Object(e);return void 0!==t[ITERATOR]||"@@iterator"in t||hasOwn$2(Iterators,classof$2(t))},getBuiltIn=getBuiltIn$j,isCallable=isCallable$r,isIterable=isIterable$1,isObject=isObject$m,Set$2=getBuiltIn("Set"),isSetLike=function(e){return isObject(e)&&"number"==typeof e.size&&isCallable(e.has)&&isCallable(e.keys)},toSetLike$7=function(e){return isSetLike(e)?e:isIterable(e)?new Set$2(e):e},$$d=_export,call$6=functionCall,toSetLike$6=toSetLike$7,$difference=setDifference;$$d({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return call$6($difference,this,toSetLike$6(e))}});var $$c=_export,bind$3=functionBindContext,aSet$5=aSet$g,SetHelpers$1=setHelpers,iterate$5=setIterate,Set$1=SetHelpers$1.Set,add$1=SetHelpers$1.add;$$c({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=aSet$5(this),r=bind$3(e,arguments.length>1?arguments[1]:void 0),n=new Set$1;return iterate$5(t,(function(e){r(e,e,t)&&add$1(n,e)})),n}});var $$b=_export,bind$2=functionBindContext,aSet$4=aSet$g,iterate$4=setIterate;$$b({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=aSet$4(this),r=bind$2(e,arguments.length>1?arguments[1]:void 0),n=iterate$4(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return n&&n.value}});var $$a=_export,call$5=functionCall,toSetLike$5=toSetLike$7,$intersection=setIntersection;$$a({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return call$5($intersection,this,toSetLike$5(e))}});var $$9=_export,call$4=functionCall,toSetLike$4=toSetLike$7,$isDisjointFrom=setIsDisjointFrom;$$9({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return call$4($isDisjointFrom,this,toSetLike$4(e))}});var $$8=_export,call$3=functionCall,toSetLike$3=toSetLike$7,$isSubsetOf=setIsSubsetOf;$$8({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return call$3($isSubsetOf,this,toSetLike$3(e))}});var $$7=_export,call$2=functionCall,toSetLike$2=toSetLike$7,$isSupersetOf=setIsSupersetOf;$$7({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return call$2($isSupersetOf,this,toSetLike$2(e))}});var $$6=_export,uncurryThis=functionUncurryThis,aSet$3=aSet$g,iterate$3=setIterate,toString4=toString$g,arrayJoin=uncurryThis([].join),push$1=uncurryThis([].push);$$6({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=aSet$3(this),r=void 0===e?",":toString4(e),n=[];return iterate$3(t,(function(e){push$1(n,e)})),arrayJoin(n,r)}});var $$5=_export,bind$1=functionBindContext,aSet$2=aSet$g,SetHelpers=setHelpers,iterate$2=setIterate,Set=SetHelpers.Set,add=SetHelpers.add;$$5({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=aSet$2(this),r=bind$1(e,arguments.length>1?arguments[1]:void 0),n=new Set;return iterate$2(t,(function(e){add(n,r(e,e,t))})),n}});var $$4=_export,aCallable=aCallable$l,aSet$1=aSet$g,iterate$1=setIterate,$TypeError=TypeError;$$4({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=aSet$1(this),r=arguments.length<2,n=r?void 0:arguments[1];if(aCallable(e),iterate$1(t,(function(a){r?(r=!1,n=a):n=e(n,a,a,t)})),r)throw $TypeError("Reduce of empty set with no initial value");return n}});var $$3=_export,bind2=functionBindContext,aSet=aSet$g,iterate=setIterate;$$3({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=aSet(this),r=bind2(e,arguments.length>1?arguments[1]:void 0);return!0===iterate(t,(function(e){if(r(e,e,t))return!0}),!0)}});var $$2=_export,call$1=functionCall,toSetLike$1=toSetLike$7,$symmetricDifference=setSymmetricDifference;$$2({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return call$1($symmetricDifference,this,toSetLike$1(e))}});var $$1=_export,call=functionCall,toSetLike=toSetLike$7,$union=setUnion;$$1({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return call($union,this,toSetLike(e))}});var parent$9=set$3,set$2=parent$9,set$1=set$2,set2=set$1,_Set=getDefaultExportFromCjs$1(set2),$=_export,$entries=objectToArray.entries;$({target:"Object",stat:!0},{entries:function(e){return $entries(e)}});var _CmcdHeaderMap,path=path$y,entries$c=path.Object.entries,parent$8=entries$c,entries$b=parent$8,parent$7=entries$b,entries$a=parent$7,parent$6=entries$a,entries$9=parent$6,entries$8=entries$9,entries$7=entries$8,_Object$entries=getDefaultExportFromCjs$1(entries$7),entryVirtual$1=entryVirtual$n,entries$6=entryVirtual$1("Array").entries,parent$5=entries$6,entries$5=parent$5,classof$1=classof$f,hasOwn$1=hasOwnProperty_1,isPrototypeOf$1=objectIsPrototypeOf,method$1=entries$5,ArrayPrototype$1=Array.prototype,DOMIterables$1={DOMTokenList:!0,NodeList:!0},entries$4=function(e){var t=e.entries;return e===ArrayPrototype$1||isPrototypeOf$1(ArrayPrototype$1,e)&&t===ArrayPrototype$1.entries||hasOwn$1(DOMIterables$1,classof$1(e))?method$1:t},parent$4=entries$4,entries$3=parent$4,parent$3=entries$3,entries$2=parent$3,entries$1=entries$2,entries3=entries$1,_entriesInstanceProperty=getDefaultExportFromCjs$1(entries3),entryVirtual=entryVirtual$n,values$6=entryVirtual("Array").values,parent$2=values$6,values$5=parent$2,classof=classof$f,hasOwn2=hasOwnProperty_1,isPrototypeOf=objectIsPrototypeOf,method=values$5,ArrayPrototype=Array.prototype,DOMIterables={DOMTokenList:!0,NodeList:!0},values$4=function(e){var t=e.values;return e===ArrayPrototype||isPrototypeOf(ArrayPrototype,e)&&t===ArrayPrototype.values||hasOwn2(DOMIterables,classof(e))?method:t},parent$1=values$4,values$3=parent$1,parent=values$3,values$2=parent,values$1=values$2,values3=values$1,_valuesInstanceProperty=getDefaultExportFromCjs$1(values3),isFiniteNumber=_Number$isFinite||function(e){return"number"==typeof e&&isFinite(e)},isSafeInteger2=_Number$isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=MAX_SAFE_INTEGER},MAX_SAFE_INTEGER=_Number$MAX_SAFE_INTEGER||9007199254740991,ErrorTypes=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),ErrorDetails=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),Events=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),PlaylistContextType={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},PlaylistLevelType={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},EWMA=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;_classCallCheck$1(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=r,this.totalWeight_=n}return _createClass$1(e,[{key:"sample",value:function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}]),e}(),EwmaBandWidthEstimator=function(){function e(t,r,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;_classCallCheck$1(this,e),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new EWMA(t),this.fast_=new EWMA(r),this.defaultTTFB_=a,this.ttfb_=new EWMA(t)}return _createClass$1(e,[{key:"update",value:function(e,t){var r=this.slow_,n=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new EWMA(e,r.getEstimate(),r.getTotalWeight())),n.halfLife!==t&&(this.fast_=new EWMA(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new EWMA(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}]),e}();function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?_Object$defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _extends(){var e;return _extends=_Object$assign?_bindInstanceProperty(e=_Object$assign).call(e):function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}function ownKeys2(e,t){var r=_Object$keys(e);if(_Object$getOwnPropertySymbols){var n=_Object$getOwnPropertySymbols(e);t&&(n=_filterInstanceProperty(n).call(n,(function(t){return _Object$getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r,n,a=null!=arguments[t]?arguments[t]:{};t%2?_forEachInstanceProperty(r=ownKeys2(Object(a),!0)).call(r,(function(t){_defineProperty(e,t,a[t])})):_Object$getOwnPropertyDescriptors?_Object$defineProperties(e,_Object$getOwnPropertyDescriptors(a)):_forEachInstanceProperty(n=ownKeys2(Object(a))).call(n,(function(t){_Object$defineProperty(e,t,_Object$getOwnPropertyDescriptor(a,t))}))}return e}function _toPrimitive(e,t){if("object"!=_typeof$1(e)||!e)return e;var r=e[_Symbol$toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof$1(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof$1(t)?t:t+""}var Logger=_createClass$1((function e(t,r){var n,a,i,s,o;_classCallCheck$1(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var l="[".concat(t,"]:");this.trace=noop,this.debug=_bindInstanceProperty(n=r.debug).call(n,null,l),this.log=_bindInstanceProperty(a=r.log).call(a,null,l),this.warn=_bindInstanceProperty(i=r.warn).call(i,null,l),this.info=_bindInstanceProperty(s=r.info).call(s,null,l),this.error=_bindInstanceProperty(o=r.error).call(o,null,l)})),noop=function(){},fakeLogger={trace:noop,debug:noop,log:noop,warn:noop,info:noop,error:noop};function createLogger(){return _extends({},fakeLogger)}function consolePrintFn(e,t){var r,n=self.console[e];return n?_bindInstanceProperty(n).call(n,self.console,_concatInstanceProperty(r="".concat(t?"["+t+"] ":"","[")).call(r,e,"] >")):noop}function getLoggerFn(e,t,r){var n;return t[e]?_bindInstanceProperty(n=t[e]).call(n,t):consolePrintFn(e,r)}var exportedLogger=createLogger();function enableLogs(e,t,r){var n=createLogger();if("object"===("undefined"==typeof console?"undefined":_typeof$1(console))&&!0===e||"object"===_typeof$1(e)){var a=["debug","log","info","warn","error"];_forEachInstanceProperty(a).call(a,(function(t){n[t]=getLoggerFn(t,e,r)}));try{n.log('Debug logs enabled for "'.concat(t,'" in hls.js version ',"1.6.0-beta.2"))}catch(e){return createLogger()}_forEachInstanceProperty(a).call(a,(function(t){exportedLogger[t]=getLoggerFn(t,e)}))}else _extends(exportedLogger,n);return n}var logger=exportedLogger;function _getMediaSource2(){if("undefined"!=typeof self)return(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function isManagedMediaSource(e){return"undefined"!=typeof self&&e===self.ManagedMediaSource}function isCompatibleTrackChange(e,t){var r=_Object$keys(e),n=_Object$keys(t),a=r.length,i=n.length;return!a||!i||a===i&&!_someInstanceProperty(r).call(r,(function(e){return-1===_indexOfInstanceProperty(n).call(n,e)}))}var sampleEntryCodesISO={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function isCodecType(e,t){var r=sampleEntryCodesISO[t];return!!r&&!!r[_sliceInstanceProperty(e).call(e,0,4)]}function areCodecsMediaSourceSupported(e,t){var r,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!_someInstanceProperty(r=e.split(",")).call(r,(function(e){return!isCodecMediaSourceSupported(e,t,n)}))}function isCodecMediaSourceSupported(e,t){var r,n=_getMediaSource2(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);return null!=(r=null==n?void 0:n.isTypeSupported(mimeTypeForCodec(e,t)))&&r}function mimeTypeForCodec(e,t){var r;return _concatInstanceProperty(r="".concat(t,"/mp4;codecs=")).call(r,e)}function videoCodecPreferenceValue(e){if(e){var t=e.substring(0,4);return sampleEntryCodesISO.video[t]}return 2}function codecsSetSelectionPreferenceValue(e){var t;return _reduceInstanceProperty(t=e.split(",")).call(t,(function(e,t){var r=sampleEntryCodesISO.video[t];return r?(2*r+e)/(e?3:2):(sampleEntryCodesISO.audio[t]+e)/(e?2:1)}),0)}var CODEC_COMPATIBLE_NAMES={};function getCodecCompatibleNameLower(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(CODEC_COMPATIBLE_NAMES[e])return CODEC_COMPATIBLE_NAMES[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],n=0;n<r.length;n++){var a;if(isCodecMediaSourceSupported(r[n],"audio",t))return CODEC_COMPATIBLE_NAMES[e]=r[n],r[n];if("mp3"===r[n]&&null!=(a=_getMediaSource2(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}var AUDIO_CODEC_REGEXP=/flac|opus|mp4a\.40\.34/i;function getCodecCompatibleName(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(AUDIO_CODEC_REGEXP,(function(e){return getCodecCompatibleNameLower(e.toLowerCase(),t)}))}function pickMostCompleteCodecName(e,t){var r;if(e&&(e.length>4||-1!==_indexOfInstanceProperty(r=["ac-3","ec-3","alac","fLaC","Opus"]).call(r,e)))return e;if(t){var n=t.split(",");if(n.length>1){if(e)for(var a=n.length;a--;)if(n[a].substring(0,4)===e.substring(0,4))return n[a];return n[0]}}return t||e}function convertAVC1ToAVCOTI(e){for(var t=e.split(","),r=0;r<t.length;r++){var n=t[r].split(".");if(n.length>2){var a,i=n.shift()+".";i+=_parseInt$1(n.shift()).toString(16),i+=_sliceInstanceProperty(a="000"+_parseInt$1(n.shift()).toString(16)).call(a,-4),t[r]=i}}return t.join(",")}function fillInMissingAV01Params(e){if(_startsWithInstanceProperty(e).call(e,"av01.")){for(var t=e.split("."),r=["0","111","01","01","01","0"],n=t.length;n>4&&n<10;n++)t[n]=r[n-4];return t.join(".")}return e}function getM2TSSupportedAudioTypes(e){var t=_getMediaSource2(e)||{isTypeSupported:function(){return!1}};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}var SUPPORTED_INFO_DEFAULT={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},SUPPORTED_INFO_CACHE={};function requiresMediaCapabilitiesDecodingInfo(e,t,r,n,a,i){var s,o=e.audioCodec?e.audioGroups:null,l=null==i?void 0:i.audioCodec,c=null==i?void 0:i.channels,u=c?_parseInt$1(c):l?1/0:2,d=null;if(null!=o&&o.length)try{d=1===o.length&&o[0]?t.groups[o[0]].channels:_reduceInstanceProperty(o).call(o,(function(e,r){if(r){var n,a=t.groups[r];if(!a)throw new Error("Audio track group ".concat(r," not found"));_forEachInstanceProperty(n=_Object$keys(a.channels)).call(n,(function(t){e[t]=(e[t]||0)+a.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(n,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(a,8e6))||!!d&&isFiniteNumber(u)&&_someInstanceProperty(s=_Object$keys(d)).call(s,(function(e){return _parseInt$1(e)>u}))}function getMediaDecodingInfoPromise(e,t,r){var n=e.videoCodec,a=e.audioCodec;if(!n&&!a||!r)return _Promise.resolve(SUPPORTED_INFO_DEFAULT);var i,s=[];if(n){var o,l={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},c=e.videoRange;"SDR"!==c&&(l.transferFunction=c.toLowerCase()),s.push.apply(s,_mapInstanceProperty(o=n.split(",")).call(o,(function(e){return{type:"media-source",video:_objectSpread2(_objectSpread2({},l),{},{contentType:mimeTypeForCodec(fillInMissingAV01Params(e),"video")})}})))}a&&e.audioGroups&&_forEachInstanceProperty(i=e.audioGroups).call(i,(function(e){var r,n;e&&(null==(n=t.groups[e])||_forEachInstanceProperty(r=n.tracks).call(r,(function(t){if(t.groupId===e){var r,n=t.channels||"",i=_parseFloat$1(n);if(isFiniteNumber(i)&&i>2)s.push.apply(s,_mapInstanceProperty(r=a.split(",")).call(r,(function(e){return{type:"media-source",audio:{contentType:mimeTypeForCodec(e,"audio"),channels:""+i}}})))}})))}));return _Promise.all(_mapInstanceProperty(s).call(s,(function(e){var t=getMediaDecodingInfoKey(e);return SUPPORTED_INFO_CACHE[t]||(SUPPORTED_INFO_CACHE[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!_someInstanceProperty(e).call(e,(function(e){return!e.supported})),configurations:s,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}}))}function getMediaDecodingInfoKey(e){var t=e.audio,r=e.video,n=r||t;if(n){var a,i,s,o,l,c,u,d=n.contentType.split('"')[1];if(r)return _concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="r".concat(r.height,"x")).call(l,r.width,"f")).call(o,Math.ceil(r.framerate))).call(s,r.transferFunction||"sd","_")).call(i,d,"_")).call(a,Math.ceil(r.bitrate/1e5));if(t)return _concatInstanceProperty(c=_concatInstanceProperty(u="c".concat(t.channels)).call(u,t.spatialRendering?"s":"n","_")).call(c,d)}return""}var HdcpLevels=["NONE","TYPE-0","TYPE-1",null];function isHdcpLevel(e){return _indexOfInstanceProperty(HdcpLevels).call(HdcpLevels,e)>-1}var VideoRangeValues=["SDR","PQ","HLG"];function isVideoRange(e){return!!e&&_indexOfInstanceProperty(VideoRangeValues).call(VideoRangeValues,e)>-1}var HlsSkip={No:"",Yes:"YES",v2:"v2"};function getSkipValue(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,n=e.age;return t&&n<t/2?r?HlsSkip.v2:HlsSkip.Yes:HlsSkip.No}var HlsUrlParameters=function(){function e(t,r,n){_classCallCheck$1(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=r,this.skip=n}return _createClass$1(e,[{key:"addDirectives",value:function(e){var t=new _URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}]),e}(),Level=function(){function e(t){var r,n;_classCallCheck$1(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=_mapInstanceProperty(r=_filterInstanceProperty(n=[t.videoCodec,t.audioCodec]).call(n,(function(e){return!!e}))).call(r,(function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}return _createClass$1(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return hasGroup(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return hasGroup(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===_indexOfInstanceProperty(r).call(r,t)&&r.push(t)}else if("text"===e){var n=this._subtitleGroups;n||(n=this._subtitleGroups=[]),-1===_indexOfInstanceProperty(n).call(n,t)&&n.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}]),e}();function hasGroup(e,t){return!(!t||!e)&&-1!==_indexOfInstanceProperty(e).call(e,t)}function isHdrSupported(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}function getVideoSelectionOptions(e,t){var r=!1,n=[];if(e&&(r="SDR"!==e,n=[e]),t){var a="SDR"!==(n=t.allowedVideoRanges||_sliceInstanceProperty(VideoRangeValues).call(VideoRangeValues,0)).join("")&&!t.videoCodec;(r=void 0!==t.preferHDR?t.preferHDR:a&&isHdrSupported())||(n=["SDR"])}return{preferHDR:r,allowedVideoRanges:n}}function getStartCodecTier(e,t,r,n,a){for(var i=_Object$keys(e),s=null==n?void 0:n.channels,o=null==n?void 0:n.audioCodec,l=null==a?void 0:a.videoCodec,c=s&&2===_parseInt$1(s),u=!1,d=!1,f=1/0,h=1/0,p=1/0,y=1/0,g=0,v=[],m=getVideoSelectionOptions(t,a),E=m.preferHDR,$=m.allowedVideoRanges,S=function(){var t=e[i[T]];u||(u=t.channels[2]>0),f=Math.min(f,t.minHeight),h=Math.min(h,t.minFramerate),p=Math.min(p,t.minBitrate),_filterInstanceProperty($).call($,(function(e){return t.videoRanges[e]>0})).length>0&&(d=!0)},T=i.length;T--;)S();f=isFiniteNumber(f)?f:0,h=isFiniteNumber(h)?h:0;var I=Math.max(1080,f),_=Math.max(30,h);p=isFiniteNumber(p)?p:r,r=Math.max(p,r),d||(t=void 0);var P=i.length>1;return{codecSet:_reduceInstanceProperty(i).call(i,(function(t,n){var a=e[n];if(n===t)return t;if(v=d?_filterInstanceProperty($).call($,(function(e){return a.videoRanges[e]>0})):[],P){var i,f,h,p,m;if(a.minBitrate>r)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(i="min bitrate of ".concat(a.minBitrate," > current estimate of ")).call(i,r)),t;if(!a.hasDefaultAudio)return logStartCodecCandidateIgnored(n,"no renditions with default or auto-select sound found"),t;if(o&&_indexOfInstanceProperty(n).call(n,o.substring(0,4))%5!=0)return logStartCodecCandidateIgnored(n,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!c){if(!a.channels[s])return logStartCodecCandidateIgnored(n,_concatInstanceProperty(f="no renditions with ".concat(s," channel sound found (channels options: ")).call(f,_Object$keys(a.channels),")")),t}else if((!o||c)&&u&&0===a.channels[2])return logStartCodecCandidateIgnored(n,"no renditions with stereo sound found"),t;if(a.minHeight>I)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(h="min resolution of ".concat(a.minHeight," > maximum of ")).call(h,I)),t;if(a.minFramerate>_)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(p="min framerate of ".concat(a.minFramerate," > maximum of ")).call(p,_)),t;if(!_someInstanceProperty(v).call(v,(function(e){return a.videoRanges[e]>0})))return logStartCodecCandidateIgnored(n,"no variants with VIDEO-RANGE of ".concat(_JSON$stringify(v)," found")),t;if(l&&_indexOfInstanceProperty(n).call(n,l.substring(0,4))%5!=0)return logStartCodecCandidateIgnored(n,'video codec preference "'.concat(l,'" not found')),t;if(a.maxScore<g)return logStartCodecCandidateIgnored(n,_concatInstanceProperty(m="max score of ".concat(a.maxScore," < selected max of ")).call(m,g)),t}return t&&(codecsSetSelectionPreferenceValue(n)>=codecsSetSelectionPreferenceValue(t)||a.fragmentError>e[t].fragmentError)?t:(y=a.minIndex,g=a.maxScore,n)}),void 0),videoRanges:v,preferHDR:E,minFramerate:h,minBitrate:p,minIndex:y}}function logStartCodecCandidateIgnored(e,t){var r;logger.log(_concatInstanceProperty(r='[abr] start candidates with "'.concat(e,'" ignored because ')).call(r,t))}function getAudioTracksByGroup(e){return _reduceInstanceProperty(e).call(e,(function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var n=t.channels||"2";return r.channels[n]=(r.channels[n]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function getCodecTiers(e,t,r,n){var a;return _reduceInstanceProperty(a=_sliceInstanceProperty(e).call(e,r,n+1)).call(a,(function(e,r,n){if(!r.codecSet)return e;var a=r.audioGroups,i=e[r.codecSet];i||(e[r.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),i.minBitrate=Math.min(i.minBitrate,r.bitrate);var s=Math.min(r.height,r.width);return i.minHeight=Math.min(i.minHeight,s),i.minFramerate=Math.min(i.minFramerate,r.frameRate),i.minIndex=Math.min(i.minIndex,n),i.maxScore=Math.max(i.maxScore,r.score),i.fragmentError+=r.fragmentError,i.videoRanges[r.videoRange]=(i.videoRanges[r.videoRange]||0)+1,a&&_forEachInstanceProperty(a).call(a,(function(e){var r;if(e){var n=t.groups[e];n&&(i.hasDefaultAudio=i.hasDefaultAudio||t.hasDefaultAudio?n.hasDefault:n.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,_forEachInstanceProperty(r=_Object$keys(n.channels)).call(r,(function(e){i.channels[e]=(i.channels[e]||0)+n.channels[e]})))}})),e}),{})}function getBasicSelectionOption(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function findMatchingOption(e,t,r){if("attrs"in e){var n=_indexOfInstanceProperty(t).call(t,e);if(-1!==n)return n}for(var a=0;a<t.length;a++){if(matchesOption(e,t[a],r))return a}return-1}function matchesOption(e,t,r){var n=e.groupId,a=e.name,i=e.lang,s=e.assocLang,o=e.characteristics,l=e.default,c=e.forced;return(void 0===n||t.groupId===n)&&(void 0===a||t.name===a)&&(void 0===i||languagesMatch(i,t.lang))&&(void 0===i||t.assocLang===s)&&(void 0===l||t.default===l)&&(void 0===c||t.forced===c)&&(void 0===o||characteristicsMatch(o,t.characteristics))&&(void 0===r||r(e,t))}function languagesMatch(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--";return e.length===t.length?e===t:_startsWithInstanceProperty(e).call(e,t)||_startsWithInstanceProperty(t).call(t,e)}function characteristicsMatch(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),n=t.split(",");return r.length===n.length&&!_someInstanceProperty(r).call(r,(function(e){return-1===_indexOfInstanceProperty(n).call(n,e)}))}function audioMatchPredicate(e,t){var r=e.audioCodec,n=e.channels;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==n&&n!==(t.channels||"2"))}function findClosestLevelWithAudioGroup(e,t,r,n,a){var i=t[n],s=_reduceInstanceProperty(t).call(t,(function(e,t,r){var n=t.uri;return(e[n]||(e[n]=[])).push(r),e}),{})[i.uri];s.length>1&&(n=Math.max.apply(Math,s));var o=i.videoRange,l=i.frameRate,c=i.codecSet.substring(0,4),u=searchDownAndUpList(t,n,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==c)return!1;var n=t.audioGroups,i=_filterInstanceProperty(r).call(r,(function(e){return!n||-1!==_indexOfInstanceProperty(n).call(n,e.groupId)}));return findMatchingOption(e,i,a)>-1}));return u>-1?u:searchDownAndUpList(t,n,(function(t){var n=t.audioGroups,i=_filterInstanceProperty(r).call(r,(function(e){return!n||-1!==_indexOfInstanceProperty(n).call(n,e.groupId)}));return findMatchingOption(e,i,a)>-1}))}function searchDownAndUpList(e,t,r){for(var n=t;n>-1;n--)if(r(e[n]))return n;for(var a=t+1;a<e.length;a++)if(r(e[a]))return a;return-1}function useAlternateAudio(e,t){var r;return!!e&&e!==(null==(r=t.levels[t.loadLevel])?void 0:r.uri)}var AbrController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"abr",e.logger)).hls=void 0,n.lastLevelLoadSec=0,n.lastLoadedFragLevel=-1,n.firstSelection=-1,n._nextAutoLevel=-1,n.nextAutoLevelKey="",n.audioTracksByGroup=null,n.codecTiers=null,n.timer=-1,n.fragCurrent=null,n.partCurrent=null,n.bitrateTestDelay=0,n.bwEstimator=void 0,n._abandonRulesCheck=function(){var e,t,r,a,i,s,o,l,c,u,d,f,h=_assertThisInitialized(n),p=h.fragCurrent,y=h.partCurrent,g=h.hls,v=g.autoLevelEnabled,m=g.media;if(p&&m){var E=performance.now(),$=y?y.stats:p.stats,S=y?y.duration:p.duration,T=E-$.loading.start,I=g.minAutoLevel;if($.aborted||$.loaded&&$.loaded===$.total||p.level<=I)return n.clearTimer(),void(n._nextAutoLevel=-1);if(v&&!m.paused&&m.playbackRate&&m.readyState){var _=g.mainForwardBufferInfo;if(null!==_){var P=n.bwEstimator.getEstimateTTFB(),b=Math.abs(m.playbackRate);if(!(T<=Math.max(P,S/(2*b)*1e3))){var A=_.len/b,k=$.loading.first?$.loading.first-$.loading.start:-1,R=$.loaded&&k>-1,C=n.getBwEstimate(),O=g.levels,L=O[p.level],D=Math.max($.loaded,Math.round(S*(p.bitrate||L.averageBitrate)/8)),w=R?T-k:T;w<1&&R&&(w=Math.min(T,8*$.loaded/C));var M=R?1e3*$.loaded/w:0,x=P/1e3,N=M?(D-$.loaded)/M:8*D/C+x;if(!(N<=A)){var F,U=M?8*M:C,B=!0===(null==(f=n.hls.latestLevelDetails)?void 0:f.live),j=n.hls.config.abrBandWidthUpFactor,G=Number.POSITIVE_INFINITY;for(F=p.level-1;F>I;F--){var H=O[F].maxBitrate,K=!O[F].details||B;if((G=n.getTimeToLoadFrag(x,U,S*H,K))<Math.min(A,S+x))break}if(!(G>=N||G>10*S)){R?n.bwEstimator.sample(T-Math.min(P,k),$.loaded):n.bwEstimator.sampleTTFB(T);var V=O[F].maxBitrate;n.getBwEstimate()*j>V&&n.resetEstimator(V);var W=n.findBestLevel(V,I,F,0,A,1,1);W>-1&&(F=W),n.warn(_concatInstanceProperty(e=_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l=_concatInstanceProperty(c=_concatInstanceProperty(u=_concatInstanceProperty(d="Fragment ".concat(p.sn)).call(d,y?" part "+y.index:""," of level ")).call(u,p.level," is loading too slowly;\n Fragment duration: ")).call(c,p.duration.toFixed(3),"\n Time to underbuffer: ")).call(l,A.toFixed(3)," s\n Estimated load time for current fragment: ")).call(o,N.toFixed(3)," s\n Estimated load time for down switch fragment: ")).call(s,G.toFixed(3)," s\n TTFB estimate: ")).call(i,0|k," ms\n Current BW estimate: ")).call(a,isFiniteNumber(C)?0|C:"Unknown"," bps\n New BW estimate: ")).call(r,0|n.getBwEstimate()," bps\n Switching to level ")).call(t,F," @ ")).call(e,0|V," bps")),g.nextLoadLevel=g.nextAutoLevel=F,n.clearTimer(),n.timer=_setInterval((function(){if(n.clearTimer(),n.fragCurrent===p&&n.hls.loadLevel===F&&F>0){var e,t,r=n.getStarvationDelay();if(n.warn(_concatInstanceProperty(e=_concatInstanceProperty(t="Aborting inflight request ".concat(F>0?"and switching down":"","\n Fragment duration: ")).call(t,p.duration.toFixed(3)," s\n Time to underbuffer: ")).call(e,r.toFixed(3)," s")),p.abortRequests(),n.fragCurrent=n.partCurrent=null,F>I){var a=n.findBestLevel(n.hls.levels[I].bitrate,I,F,0,r,1,1);-1===a&&(a=I),n.hls.nextLoadLevel=n.hls.nextAutoLevel=a,n.resetEstimator(n.hls.levels[a].bitrate)}}}),1e3*G),g.trigger(Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:p,part:y,stats:$})}}}}}}},n.hls=e,n.bwEstimator=n.initEstimator(),n.registerListeners(),n}return _createClass$1(r,[{key:"resetEstimator",value:function(e){e&&(this.log("setting initial bwe to ".concat(e)),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new EwmaBandWidthEstimator(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.FRAG_LOADING,this.onFragLoading,this),e.on(Events.FRAG_LOADED,this.onFragLoaded,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.FRAG_LOADING,this.onFragLoading,this),e.off(Events.FRAG_LOADED,this.onFragLoaded,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Events.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){var n;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(n=t.part)?n:null;this.clearTimer(),this.timer=_setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case ErrorDetails.BUFFER_ADD_CODEC_ERROR:case ErrorDetails.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case ErrorDetails.FRAG_LOAD_TIMEOUT:var r=t.frag,n=this.fragCurrent,a=this.partCurrent;if(r&&n&&r.sn===n.sn&&r.level===n.level){var i=performance.now(),s=a?a.stats:r.stats,o=i-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(c,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}}},{key:"getTimeToLoadFrag",value:function(e,t,r,n){return e+r/t+(n?this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var r=this.hls.config,n=t.stats.loading,a=n.end-n.start;isFiniteNumber(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,n=t.part,a=n?n.stats:r.stats;if(r.type===PlaylistLevelType.MAIN&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var i=n?n.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+a.loaded,l=(s.loaded?s.loaded.duration:0)+i;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var c={stats:a,frag:r,part:n,id:r.type};this.onFragBuffered(Events.FRAG_BUFFERED,c),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,n=t.part,a=null!=n&&n.stats.loaded?n.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var i=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(i,a.loaded),a.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==PlaylistLevelType.MAIN||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e,t=this.hls,r=t.maxAutoLevel,n=t.minAutoLevel,a=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,s=this.findBestLevel(a,n,r,0,i,1,1);if(s>-1)return s;var o=this.hls.firstLevel,l=Math.min(Math.max(o,n),r);return this.warn(_concatInstanceProperty(e="Could not find best starting auto level. Defaulting to first in playlist ".concat(o," clamped to ")).call(e,l)),l}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var n=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function(e){var t=this.hls,r=t.maxAutoLevel,n=t.minAutoLevel,a=Math.min(Math.max(e,n),r);this._nextAutoLevel!==a&&(this.nextAutoLevelKey="",this._nextAutoLevel=a)}},{key:"getAutoLevelKey",value:function(){var e;return _concatInstanceProperty(e="".concat(this.getBwEstimate(),"_")).call(e,this.getStarvationDelay().toFixed(2))}},{key:"getNextABRAutoLevel",value:function(){var e,t=this.fragCurrent,r=this.partCurrent,n=this.hls;if(n.levels.length<=1)return n.loadLevel;var a=n.maxAutoLevel,i=n.config,s=n.minAutoLevel,o=r?r.duration:t?t.duration:0,l=this.getBwEstimate(),c=this.getStarvationDelay(),u=i.abrBandWidthFactor,d=i.abrBandWidthUpFactor;if(c){var f=this.findBestLevel(l,s,a,c,0,u,d);if(f>=0)return f}var h=o?Math.min(o,i.maxStarvationDelay):i.maxStarvationDelay;if(!c){var p,y=this.bitrateTestDelay;if(y)h=(o?Math.min(o,i.maxLoadingDelay):i.maxLoadingDelay)-y,this.info(_concatInstanceProperty(p="bitrate test took ".concat(Math.round(1e3*y),"ms, set first fragment max fetchDuration to ")).call(p,Math.round(1e3*h)," ms")),u=d=1}var g=this.findBestLevel(l,s,a,c,h,u,d);if(this.info(_concatInstanceProperty(e="".concat(c?"rebuffering expected":"buffer is empty",", optimal quality level ")).call(e,g)),g>-1)return g;var v=n.levels[s],m=n.levels[n.loadLevel];return(null==v?void 0:v.bitrate)<(null==m?void 0:m.bitrate)?s:n.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/r}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,r,n,a,i,s){var o,l=this,c=n+a,u=this.lastLoadedFragLevel,d=-1===u?this.hls.firstLevel:u,f=this.fragCurrent,h=this.partCurrent,p=this.hls,y=p.levels,g=p.allAudioTracks,v=p.loadLevel,m=p.config;if(1===y.length)return 0;var E,$=y[d],S=!(null==(o=this.hls.latestLevelDetails)||!o.live),T=-1===v||-1===u,I="SDR",_=(null==$?void 0:$.frameRate)||0,P=m.audioPreference,b=m.videoPreference,A=this.audioTracksByGroup||(this.audioTracksByGroup=getAudioTracksByGroup(g)),k=-1;if(T){if(-1!==this.firstSelection)return this.firstSelection;var R=getStartCodecTier(this.codecTiers||(this.codecTiers=getCodecTiers(y,A,t,r)),I,e,P,b),C=R.codecSet,O=R.videoRanges,L=R.minFramerate,D=R.minBitrate,w=R.minIndex,M=R.preferHDR;k=w,E=C,I=M?O[O.length-1]:O[0],_=L,e=Math.max(e,D),this.log("picked start tier ".concat(_JSON$stringify(R)))}else E=null==$?void 0:$.codecSet,I=null==$?void 0:$.videoRange;for(var x=h?h.duration:f?f.duration:0,N=this.bwEstimator.getEstimateTTFB()/1e3,F=[],U=function(){var t=y[B],o=B>d;if(!t)return"continue";if(m.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var f=navigator.mediaCapabilities;"function"!=typeof(null==f?void 0:f.decodingInfo)||!requiresMediaCapabilitiesDecodingInfo(t,A,I,_,e,P)&&"hvc1"!==(null==(G=t.videoCodec)?void 0:G.substring(0,4))?t.supportedResult=SUPPORTED_INFO_DEFAULT:(t.supportedPromise=getMediaDecodingInfoPromise(t,A,f),t.supportedPromise.then((function(e){if(l.hls){t.supportedResult=e;var r,n,a=l.hls.levels,i=_indexOfInstanceProperty(a).call(a,t);if(e.error)l.warn(_concatInstanceProperty(r=_concatInstanceProperty(n='MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ')).call(n,i," ")).call(r,_JSON$stringify(e)));else if(!e.supported){var s;l.warn(_concatInstanceProperty(s="Unsupported MediaCapabilities decodingInfo result for level ".concat(i," ")).call(s,_JSON$stringify(e))),i>-1&&a.length>1&&(l.log("Removing unsupported level ".concat(i)),l.hls.removeLevel(i),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0))}}})))}if((E&&t.codecSet!==E||I&&t.videoRange!==I||o&&_>t.frameRate||!o&&_>0&&_<t.frameRate||t.supportedResult&&(null==(j=t.supportedResult.decodingInfoResults)||!j[0].smooth))&&(!T||B!==k))return F.push(B),"continue";var p,g=t.details,$=(h?null==g?void 0:g.partTarget:null==g?void 0:g.averagetargetduration)||x;p=o?s*e:i*e;var b=x&&n>=2*x&&0===a?t.averageBitrate:t.maxBitrate,R=l.getTimeToLoadFrag(N,p,b*$,void 0===g);if(p>=b&&(B===u||0===t.loadError&&0===t.fragmentError)&&(R<=N||!isFiniteNumber(R)||S&&!l.bitrateTestDelay||R<c)){var C=l.forcedAutoLevel;if(B!==v&&(-1===C||C!==v)){var O,L,D,w,M,U,H,K,V,W,Y,q,z,X,Q,J;if(F.length)l.trace(_concatInstanceProperty(q=_concatInstanceProperty(z=_concatInstanceProperty(X=_concatInstanceProperty(Q=_concatInstanceProperty(J="Skipped level(s) ".concat(F.join(",")," of ")).call(J,r,' max with CODECS and VIDEO-RANGE:"')).call(Q,y[F[0]].codecs,'" ')).call(X,y[F[0]].videoRange,'; not compatible with "')).call(z,E,'" ')).call(q,I));l.info(_concatInstanceProperty(O=_concatInstanceProperty(L=_concatInstanceProperty(D=_concatInstanceProperty(w=_concatInstanceProperty(M=_concatInstanceProperty(U=_concatInstanceProperty(H=_concatInstanceProperty(K=_concatInstanceProperty(V=_concatInstanceProperty(W=_concatInstanceProperty(Y="switch candidate:".concat(d,"->")).call(Y,B," adjustedbw(")).call(W,Math.round(p),")-bitrate=")).call(V,Math.round(p-b)," ttfb:")).call(K,N.toFixed(1)," avgDuration:")).call(H,$.toFixed(1)," maxFetchDuration:")).call(U,c.toFixed(1)," fetchDuration:")).call(M,R.toFixed(1)," firstSelection:")).call(w,T," codecSet:")).call(D,t.codecSet," videoRange:")).call(L,t.videoRange," hls.loadLevel:")).call(O,v))}return T&&(l.firstSelection=B),{v:B}}},B=r;B>=t;B--){var j,G,H=U();if("continue"!==H&&"object"===_typeof$1(H))return H.v}return-1}}]),r}(),BinarySearch={search:function(e,t){for(var r=0,n=e.length-1,a=null,i=null;r<=n;){var s=t(i=e[a=(r+n)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return i;n=a-1}}return null}};function findFragmentByPDT(e,t,r){if(null===t||!_Array$isArray(e)||!e.length||!isFiniteNumber(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<e.length;++n){var a=e[n];if(pdtWithinToleranceTest(t,r,a))return a}return null}function findFragmentByPTS(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.005,i=null;if(e){i=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7),i&&e.level!==i.level&&i.end<=e.end&&(i=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(i=t[0]);if(i&&((!e||e.level===i.level)&&0===fragmentWithinToleranceTest(r,n,i)||fragmentWithinFastStartSwitch(i,e,Math.min(a,n))))return i;var o=BinarySearch.search(t,_bindInstanceProperty(fragmentWithinToleranceTest).call(fragmentWithinToleranceTest,null,r,n));return!o||o===e&&i?i:o}function fragmentWithinFastStartSwitch(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var n,a=_reduceInstanceProperty(n=t.tagList).call(n,(function(e,t){return"INF"===t[0]&&(e+=_parseFloat$1(t[1])),e}),r);return e.start<=a}return!1}function fragmentWithinToleranceTest(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;if(r.start<=e&&r.start+r.duration>e)return 0;var n=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-n<=e?1:r.start-n>e&&r.start?-1:0}function pdtWithinToleranceTest(e,t,r){var n=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-n>e}function findFragWithCC(e,t){return BinarySearch.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function findNearestWithCC(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var n=r.start,a=r.end,i=e.fragments;if(!r.relurl){var s=e.fragmentHint;s&&(i=_concatInstanceProperty(i).call(i,s))}return BinarySearch.search(i,(function(e){return e.cc<t||e.end<=n?1:e.cc>t||e.start>=a?-1:0}))}return null}function isTimeoutError(e){switch(e.details){case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_TIMEOUT:case ErrorDetails.LEVEL_LOAD_TIMEOUT:case ErrorDetails.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function getRetryConfig(e,t){var r=isTimeoutError(t);return e.default["".concat(r?"timeout":"error","Retry")]}function getRetryDelay(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function getLoaderConfigWithoutReties(e){return _objectSpread2(_objectSpread2({},e),{errorRetry:null,timeoutRetry:null})}function shouldRetry(e,t,r,n){if(!e)return!1;var a=null==n?void 0:n.code,i=t<e.maxNumRetry&&(retryForHttpStatus(a)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,n,i):i}function retryForHttpStatus(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}var NetworkErrorAction={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ErrorActionFlags={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},ErrorController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"error-controller",e.logger)).hls=void 0,n.playlistError=0,n.penalizedRenditions={},n.hls=e,n.registerListeners(),n}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.ERROR,this.onError,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.ERROR,this.onError,this),e.off(Events.ERROR,this.onErrorOut,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===PlaylistLevelType.MAIN?e.level:this.hls.loadLevel}},{key:"onManifestLoading",value:function(){this.playlistError=0,this.penalizedRenditions={}}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var r;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case ErrorDetails.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=createDoNothingErrorAction());case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=NetworkErrorAction.SendAlternateToPenaltyBox);case ErrorDetails.LEVEL_EMPTY_ERROR:case ErrorDetails.LEVEL_PARSING_ERROR:var i,s,o=t.parent===PlaylistLevelType.MAIN?t.level:n.loadLevel;return void(t.details===ErrorDetails.LEVEL_EMPTY_ERROR&&null!=(i=t.context)&&null!=(s=i.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case ErrorDetails.LEVEL_LOAD_ERROR:case ErrorDetails.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case ErrorDetails.SUBTITLE_LOAD_ERROR:case ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=n.levels[n.loadLevel];if(l&&(a.type===PlaylistContextType.AUDIO_TRACK&&l.hasAudioGroup(a.groupId)||a.type===PlaylistContextType.SUBTITLE_TRACK&&l.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=NetworkErrorAction.SendAlternateToPenaltyBox,void(t.errorAction.flags=ErrorActionFlags.MoveAllAlternatesMatchingHost)}return;case ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=n.levels[n.loadLevel],u=null==c?void 0:c.attrs["HDCP-LEVEL"];return void(u?t.errorAction={action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t));case ErrorDetails.BUFFER_ADD_CODEC_ERROR:case ErrorDetails.REMUX_ALLOC_ERROR:case ErrorDetails.BUFFER_APPEND_ERROR:var d;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(d=t.level)?d:n.loadLevel);return;case ErrorDetails.INTERNAL_EXCEPTION:case ErrorDetails.BUFFER_APPENDING_ERROR:case ErrorDetails.BUFFER_FULL_ERROR:case ErrorDetails.LEVEL_SWITCH_ERROR:case ErrorDetails.BUFFER_STALLED_ERROR:case ErrorDetails.BUFFER_SEEK_OVER_HOLE:case ErrorDetails.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=createDoNothingErrorAction())}t.type===ErrorTypes.KEY_SYSTEM_ERROR&&this.keySystemError(t)}}},{key:"keySystemError",value:function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var r=getRetryConfig(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++;if(shouldRetry(r,n,isTimeoutError(e),e.response))return{action:NetworkErrorAction.RetryRequest,flags:ErrorActionFlags.None,retryConfig:r,retryCount:n};var a=this.getLevelSwitchAction(e,t);return r&&(a.retryConfig=r,a.retryCount=n),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t,r,n=this.hls,a=this.getVariantLevelIndex(e.frag),i=n.levels[a],s=n.config,o=s.fragLoadPolicy,l=s.keyLoadPolicy,c=getRetryConfig(_startsWithInstanceProperty(t=e.details).call(t,"key")?l:o,e),u=_reduceInstanceProperty(r=n.levels).call(r,(function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==ErrorDetails.FRAG_GAP&&i.fragmentError++,shouldRetry(c,u,isTimeoutError(e),e.response)))return{action:NetworkErrorAction.RetryRequest,flags:ErrorActionFlags.None,retryConfig:c,retryCount:u};var d=this.getLevelSwitchAction(e,a);return c&&(d.retryConfig=c,d.retryCount=u),d}},{key:"getLevelSwitchAction",value:function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var n=this.hls.levels[t];if(n){var a,i,s=e.details;n.loadError++,s===ErrorDetails.BUFFER_APPEND_ERROR&&n.fragmentError++;var o=-1,l=r.levels,c=r.loadLevel,u=r.minAutoLevel,d=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var f=null==(a=e.frag)?void 0:a.type,h=(f===PlaylistLevelType.AUDIO&&s===ErrorDetails.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===ErrorDetails.BUFFER_ADD_CODEC_ERROR||s===ErrorDetails.BUFFER_APPEND_ERROR))&&_someInstanceProperty(l).call(l,(function(e){var t=e.audioCodec;return n.audioCodec!==t})),p="video"===e.sourceBufferName&&(s===ErrorDetails.BUFFER_ADD_CODEC_ERROR||s===ErrorDetails.BUFFER_APPEND_ERROR)&&_someInstanceProperty(l).call(l,(function(e){var t=e.codecSet,r=e.audioCodec;return n.codecSet!==t&&n.audioCodec===r})),y=null!=(i=e.context)?i:{},g=y.type,v=y.groupId,m=function(){var t=(E+c)%l.length;if(t!==c&&t>=u&&t<=d&&0===l[t].loadError){var r=l[t];if(s===ErrorDetails.FRAG_GAP&&f===PlaylistLevelType.MAIN&&e.frag){var a=l[t].details;if(a){var i=findFragmentByPTS(e.frag,a.fragments,e.frag.start);if(null!=i&&i.gap)return"continue"}}else{if(g===PlaylistContextType.AUDIO_TRACK&&r.hasAudioGroup(v)||g===PlaylistContextType.SUBTITLE_TRACK&&r.hasSubtitleGroup(v))return"continue";if(f===PlaylistLevelType.AUDIO&&null!=($=n.audioGroups)&&_someInstanceProperty($).call($,(function(e){return r.hasAudioGroup(e)}))||f===PlaylistLevelType.SUBTITLE&&null!=(S=n.subtitleGroups)&&_someInstanceProperty(S).call(S,(function(e){return r.hasSubtitleGroup(e)}))||h&&n.audioCodec===r.audioCodec||!h&&n.audioCodec!==r.audioCodec||p&&n.codecSet===r.codecSet)return"continue"}return o=t,"break"}},E=l.length;E--;){var $,S,T=m();if("continue"!==T&&"break"===T)break}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.None,nextAutoLevel:o}}return{action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.MoveAllAlternatesMatchingHost}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case NetworkErrorAction.DoNothing:break;case NetworkErrorAction.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===ErrorDetails.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'.concat(t.sourceBufferName,'" sourceBuffer append error. Attempting to recover from media error.')),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,r=e.errorAction;if(r){var n=_flagsInstanceProperty(r),a=r.hdcpLevel,i=r.nextAutoLevel;switch(n){case ErrorActionFlags.None:this.switchLevel(e,i);break;case ErrorActionFlags.MoveAllAlternatesMatchingHDCP:a&&(t.maxHdcpLevel=HdcpLevels[_indexOfInstanceProperty(HdcpLevels).call(HdcpLevels,a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'))}r.resolved||this.switchLevel(e,i)}}},{key:"switchLevel",value:function(e,t){var r;void 0!==t&&e.errorAction&&(this.warn(_concatInstanceProperty(r="switching to level ".concat(t," after ")).call(r,e.details)),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}]),r}();function createDoNothingErrorAction(e){var t={action:NetworkErrorAction.DoNothing,flags:ErrorActionFlags.None};return e&&(t.resolved=!0),t}var FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},FragmentTracker=function(){function e(t){_classCallCheck$1(this,e),this.activePartLists=_Object$create(null),this.endListFragments=_Object$create(null),this.fragments=_Object$create(null),this.timeRanges=_Object$create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}return _createClass$1(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Events.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Events.FRAG_LOADED,this.onFragLoaded,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var r=this.activePartLists[t];if(r)for(var n=r.length;n--;){var a=r[n];if(!a)break;var i=a.end;if(a.start<=e&&null!==i&&e<=i)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,r){for(var n=this.fragments,a=_Object$keys(n),i=a.length;i--;){var s=n[a[i]];if((null==s?void 0:s.body.type)===t&&(!r||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null}},{key:"detectEvictedFragments",value:function(e,t,r,n,a){var i,s=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(null==n?void 0:n.fragment.sn)||-1;_forEachInstanceProperty(i=_Object$keys(this.fragments)).call(i,(function(n){var i,l=s.fragments[n];if(l&&!(o>=l.body.sn))if(l.buffered||l.loaded&&!a){var c=l.range[e];c&&(0!==c.time.length?_someInstanceProperty(i=c.time).call(i,(function(e){var r=!s.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&s.removeFragment(l.body),r})):s.removeFragment(l.body))}else l.body.type===r&&s.removeFragment(l.body)}))}},{key:"detectPartialFragments",value:function(e){var t,r=this,n=this.timeRanges;if(n&&"initSegment"!==e.frag.sn){var a=e.frag,i=getFragmentKey(a),s=this.fragments[i];if(!(!s||s.buffered&&a.gap)){var o=!a.relurl;if(_forEachInstanceProperty(t=_Object$keys(n)).call(t,(function(t){var i=a.elementaryStreams[t];if(i){var l=n[t],c=o||!0===i.partial;s.range[t]=r.getBufferedTimes(a,e.part,c,l)}})),s.loaded=null,_Object$keys(s.range).length)s.buffered=!0,(s.body.endList=a.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),isPartial(s)||this.removeParts(a.sn-1,a.type);else this.removeFragment(s.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=_filterInstanceProperty(r).call(r,(function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=getFragmentKey(e),n=this.fragments[r];!n&&t&&(n=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:_Object$create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}},{key:"getBufferedTimes",value:function(e,t,r,n){for(var a={time:[],partial:r},i=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||i,c=0;c<n.length;c++){var u=n.start(c)-this.bufferPadding,d=n.end(c)+this.bufferPadding;if(l>=u&&o<=d){a.time.push({startPTS:Math.max(i,n.start(c)),endPTS:Math.min(s,n.end(c))});break}if(i<d&&s>u){var f=Math.max(i,n.start(c)),h=Math.min(s,n.end(c));h>f&&(a.partial=!0,a.time.push({startPTS:f,endPTS:h}))}else if(s<=u)break}return a}},{key:"getPartialFragment",value:function(e){var t,r,n,a,i=null,s=0,o=this.bufferPadding,l=this.fragments;return _forEachInstanceProperty(t=_Object$keys(l)).call(t,(function(t){var c=l[t];c&&isPartial(c)&&(n=c.body.start-o,a=c.body.end+o,e>=n&&e<=a&&(r=Math.min(e-n,a-e),s<=r&&(i=c.body,s=r)))})),i}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||isPartial(t))}},{key:"getState",value:function(e){var t=getFragmentKey(e),r=this.fragments[t];return r?r.buffered?isPartial(r)?FragmentState.PARTIAL:FragmentState.OK:FragmentState.APPENDING:FragmentState.NOT_LOADED}},{key:"isTimeBuffered",value:function(e,t,r){for(var n,a,i=0;i<r.length;i++){if(n=r.start(i)-this.bufferPadding,a=r.end(i)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var r=t.frag,n=t.part?null:t,a=getFragmentKey(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:_Object$create(null)}}}},{key:"onBufferAppended",value:function(e,t){var r=t.frag,n=t.part,a=t.timeRanges,i=t.type;if("initSegment"!==r.sn){var s=r.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a;var l=a[i];this.detectEvictedFragments(i,l,s,n)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=getFragmentKey(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=_Object$keys(t);if(!e)return r.length>0;for(var n=r.length;n--;){var a=t[r[n]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,r,n,a){var i,s=this;n&&!this.hasGaps||_forEachInstanceProperty(i=_Object$keys(this.fragments)).call(i,(function(i){var o=s.fragments[i];if(o){var l=o.body;l.type!==r||n&&!l.gap||l.start<t&&l.end>e&&(o.buffered||a)&&s.removeFragment(l)}}))}},{key:"removeFragment",value:function(e){var t=getFragmentKey(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var n=e.sn;this.activePartLists[e.type]=_filterInstanceProperty(r).call(r,(function(e){return e.fragment.sn!==n}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e,t;this.fragments=_Object$create(null),this.endListFragments=_Object$create(null),this.activePartLists=_Object$create(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&_forEachInstanceProperty(r).call(r,(function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function isPartial(e){var t,r,n;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(n=e.range.audiovideo)?void 0:n.partial))}function getFragmentKey(e){var t,r;return _concatInstanceProperty(t=_concatInstanceProperty(r="".concat(e.type,"_")).call(r,e.level,"_")).call(t,e.sn)}var DecrypterAesMode={cbc:0,ctr:1},AESCrypto=function(){function e(t,r,n){_classCallCheck$1(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=r,this.aesMode=n}return _createClass$1(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case DecrypterAesMode.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case DecrypterAesMode.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode ".concat(this.aesMode))}}}]),e}();function sliceUint8(e,t,r){return _sliceInstanceProperty(Uint8Array.prototype)?_sliceInstanceProperty(e).call(e,t,r):new Uint8Array(_sliceInstanceProperty(Array.prototype).call(e,t,r))}function removePadding(e){var t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?sliceUint8(e,0,t-r):e}var AESDecryptor=function(){function e(){_classCallCheck$1(this,e),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()}return _createClass$1(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),n=0;n<4;n++)r[n]=t.getUint32(4*n);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,n=r[0],a=r[1],i=r[2],s=r[3],o=this.invSubMix,l=o[0],c=o[1],u=o[2],d=o[3],f=new Uint32Array(256),h=0,p=0,y=0;for(y=0;y<256;y++)f[y]=y<128?y<<1:y<<1^283;for(y=0;y<256;y++){var g=p^p<<1^p<<2^p<<3^p<<4;g=g>>>8^255&g^99,e[h]=g,t[g]=h;var v=f[h],m=f[v],E=f[m],$=257*f[g]^16843008*g;n[h]=$<<24|$>>>8,a[h]=$<<16|$>>>16,i[h]=$<<8|$>>>24,s[h]=$,$=16843009*E^65537*m^257*v^16843008*h,l[g]=$<<24|$>>>8,c[g]=$<<16|$>>>16,u[g]=$<<8|$>>>24,d[g]=$,h?(h=v^f[f[f[E^v]]],p^=f[f[p]]):h=p=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n<t.length&&r;)r=t[n]===this.key[n],n++;if(!r){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var i,s,o,l,c=this.ksRows=4*(a+6+1),u=this.keySchedule=new Uint32Array(c),d=this.invKeySchedule=new Uint32Array(c),f=this.sBox,h=this.rcon,p=this.invSubMix,y=p[0],g=p[1],v=p[2],m=p[3];for(i=0;i<c;i++)i<a?o=u[i]=t[i]:(l=o,i%a==0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=h[i/a|0]<<24):a>6&&i%a==4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),u[i]=o=(u[i-a]^l)>>>0);for(s=0;s<c;s++)i=c-s,l=3&s?u[i]:u[i-4],d[s]=s<4||i<=4?l:y[f[l>>>24]]^g[f[l>>>16&255]]^v[f[l>>>8&255]]^m[f[255&l]],d[s]=d[s]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var n,a,i,s,o,l,c,u,d,f,h,p,y,g,v=this.keySize+6,m=this.invKeySchedule,E=this.invSBox,$=this.invSubMix,S=$[0],T=$[1],I=$[2],_=$[3],P=this.uint8ArrayToUint32Array_(r),b=P[0],A=P[1],k=P[2],R=P[3],C=new Int32Array(e),O=new Int32Array(C.length),L=this.networkToHostOrderSwap;t<C.length;){for(d=L(C[t]),f=L(C[t+1]),h=L(C[t+2]),p=L(C[t+3]),o=d^m[0],l=p^m[1],c=h^m[2],u=f^m[3],y=4,g=1;g<v;g++)n=S[o>>>24]^T[l>>16&255]^I[c>>8&255]^_[255&u]^m[y],a=S[l>>>24]^T[c>>16&255]^I[u>>8&255]^_[255&o]^m[y+1],i=S[c>>>24]^T[u>>16&255]^I[o>>8&255]^_[255&l]^m[y+2],s=S[u>>>24]^T[o>>16&255]^I[l>>8&255]^_[255&c]^m[y+3],o=n,l=a,c=i,u=s,y+=4;n=E[o>>>24]<<24^E[l>>16&255]<<16^E[c>>8&255]<<8^E[255&u]^m[y],a=E[l>>>24]<<24^E[c>>16&255]<<16^E[u>>8&255]<<8^E[255&o]^m[y+1],i=E[c>>>24]<<24^E[u>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^m[y+2],s=E[u>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&c]^m[y+3],O[t]=L(n^b),O[t+1]=L(s^A),O[t+2]=L(i^k),O[t+3]=L(a^R),b=d,A=f,k=h,R=p,t+=4}return O.buffer}}]),e}(),FastAESKey=function(){function e(t,r,n){_classCallCheck$1(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=r,this.aesMode=n}return _createClass$1(e,[{key:"expandKey",value:function(){var e=getSubtleAlgoName(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}]),e}();function getSubtleAlgoName(e){switch(e){case DecrypterAesMode.cbc:return"AES-CBC";case DecrypterAesMode.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode ".concat(e))}}function utf8ArrayToStr(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("undefined"!=typeof TextDecoder){var r=new TextDecoder("utf-8").decode(e);if(t){var n=_indexOfInstanceProperty(r).call(r,"\0");return-1!==n?r.substring(0,n):r}return r.replace(/\0/g,"")}for(var a,i,s,o=e.length,l="",c=0;c<o;){if(0===(a=e[c++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:i=e[c++],l+=String.fromCharCode((31&a)<<6|63&i);break;case 14:i=e[c++],s=e[c++],l+=String.fromCharCode((15&a)<<12|(63&i)<<6|(63&s)<<0)}}return l}var Hex={hexDump:function(e){for(var t="",r=0;r<e.length;r++){var n=e[r].toString(16);n.length<2&&(n="0"+n),t+=n}return t}};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var urlToolkit={exports:{}};!function(e,t){var r,n,a,i,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=_trimInstanceProperty(e).call(e),!(t=_trimInstanceProperty(t).call(t))){if(!r.alwaysNormalize)return e;var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=s.normalizePath(a.path),s.buildURLFromParts(a)}var i=s.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=s.normalizePath(i.path),s.buildURLFromParts(i)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=n.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var c={scheme:o.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(c.netLoc=o.netLoc,"/"!==i.path[0]))if(i.path){var u=o.path,d=u.substring(0,_lastIndexOfInstanceProperty(u).call(u,"/")+1)+i.path;c.path=s.normalizePath(d)}else c.path=o.path,i.params||(c.params=o.params,i.query||(c.query=o.query));return null===c.path&&(c.path=r.alwaysNormalize?s.normalizePath(i.path):i.path),s.buildURLFromParts(c)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){var t,r;for(e=_reverseInstanceProperty(t=e.split("")).call(t).join("").replace(a,"");e.length!==(e=e.replace(i,"")).length;);return _reverseInstanceProperty(r=e.split("")).call(r).join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},urlToolkit.exports=s}();var urlToolkitExports=urlToolkit.exports,LoadStats=_createClass$1((function e(){_classCallCheck$1(this,e),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}})),ElementaryStreamTypes={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},BaseSegment=function(){function e(t){_classCallCheck$1(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t}return _createClass$1(e,[{key:"setByteRange",value:function(e,t){var r,n=e.split("@",2);r=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:_parseInt$1(n[1]),this._byteRange=[r,_parseInt$1(n[0])+r]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){var e;null===this._streams&&(this._streams=(_defineProperty$2(e={},ElementaryStreamTypes.AUDIO,null),_defineProperty$2(e,ElementaryStreamTypes.VIDEO,null),_defineProperty$2(e,ElementaryStreamTypes.AUDIOVIDEO,null),e));return this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new LoadStats),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=urlToolkitExports.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[ElementaryStreamTypes.AUDIO]=null,e[ElementaryStreamTypes.VIDEO]=null,e[ElementaryStreamTypes.AUDIOVIDEO]=null}}]),e}();function isMediaFragment(e){return"initSegment"!==e.sn}var Fragment=function(e){_inherits(r,BaseSegment);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,n))._decryptdata=null,a._programDateTime=null,a._ref=null,a._bitrate=void 0,a.rawProgramDateTime=null,a.tagList=[],a.duration=0,a.sn=0,a.levelkeys=void 0,a.type=void 0,a.loader=null,a.keyLoader=null,a.level=-1,a.cc=0,a.startPTS=void 0,a.endPTS=void 0,a.startDTS=void 0,a.endDTS=void 0,a.start=0,a.playlistOffset=0,a.deltaPTS=void 0,a.maxStartPTS=void 0,a.minEndPTS=void 0,a.data=void 0,a.bitrateTest=!1,a.title=null,a.initSegment=null,a.endList=void 0,a.gap=void 0,a.urlId=0,a.type=e,a}return _createClass$1(r,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var t=this.byteRange[0],r=this.byteRange[1];if(isFiniteNumber(t)&&isFiniteNumber(r))return r-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=_Object$keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=isFiniteNumber(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=_Object$keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){isFiniteNumber(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return isMediaFragment(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,r,n,a){var i=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,a)):s[e]={startPTS:t,endPTS:r,startDTS:n,endDTS:a,partial:i}}}]),r}(),Part=function(e){_inherits(r,BaseSegment);var t=_createSuper(r);function r(e,n,a,i,s){var o;_classCallCheck$1(this,r),(o=t.call(this,a)).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=n,o.index=i;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return _createClass$1(r,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),r}(),UINT32_MAX$1=Math.pow(2,32)-1,push2=[].push,RemuxerTrackIdConfig={video:1,audio:2,id3:3,text:4};function bin2str(e){return String.fromCharCode.apply(null,e)}function readUint16(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function readUint32(e,t){var r=readSint32(e,t);return r<0?4294967296+r:r}function readUint64(e,t){var r=readUint32(e,t);return r*=Math.pow(2,32),r+=readUint32(e,t+4)}function readSint32(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function writeUint32(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function hasMoofData(e){for(var t=e.byteLength,r=0;r<t;){var n=readUint32(e,r);if(n>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=n>1?r+n:t}return!1}function findBox(e,t){var r=[];if(!t.length)return r;for(var n=e.byteLength,a=0;a<n;){var i=readUint32(e,a),s=i>1?a+i:n;if(bin2str(e.subarray(a+4,a+8))===t[0])if(1===t.length)r.push(e.subarray(a+8,s));else{var o=findBox(e.subarray(a+8,s),_sliceInstanceProperty(t).call(t,1));o.length&&push2.apply(r,o)}a=s}return r}function parseSegmentIndex(e){var t=[],r=e[0],n=8,a=readUint32(e,n);n+=4;var i=0,s=0;0===r?(i=readUint32(e,n),s=readUint32(e,n+4),n+=8):(i=readUint64(e,n),s=readUint64(e,n+8),n+=16),n+=2;var o=e.length+s,l=readUint16(e,n);n+=2;for(var c=0;c<l;c++){var u=n,d=readUint32(e,u);u+=4;var f=2147483647&d;if(1===(2147483648&d)>>>31)return logger.warn("SIDX has hierarchical references (not supported)"),null;var h=readUint32(e,u);u+=4,t.push({referenceSize:f,subsegmentDuration:h,info:{duration:h/a,start:o,end:o+f-1}}),o+=f,n=u+=4}return{earliestPresentationTime:i,timescale:a,version:r,referencesCount:l,references:t}}function parseInitSegment(e){for(var t=[],r=findBox(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],i=findBox(a,["tkhd"])[0];if(i){var s=i[0],o=readUint32(i,0===s?12:20),l=findBox(a,["mdia","mdhd"])[0];if(l){var c=readUint32(l,0===(s=l[0])?12:20),u=findBox(a,["mdia","hdlr"])[0];if(u){var d=bin2str(u.subarray(8,12)),f={soun:ElementaryStreamTypes.AUDIO,vide:ElementaryStreamTypes.VIDEO}[d];if(f){var h=parseStsd(findBox(a,["mdia","minf","stbl","stsd"])[0]);t[o]={timescale:c,type:f},t[f]=_objectSpread2({timescale:c,id:o},h)}}}}}var p=findBox(e,["moov","mvex","trex"]);return _forEachInstanceProperty(p).call(p,(function(e){var r=readUint32(e,4),n=t[r];n&&(n.default={duration:readUint32(e,12),flags:readUint32(e,20)})})),t}function parseStsd(e){var t=e.subarray(8),r=t.subarray(86),n=bin2str(t.subarray(4,8)),a=n,i="enca"===n||"encv"===n;if(i){var s=findBox(t,[n])[0],o=findBox(s.subarray("enca"===n?28:78),["sinf"]);_forEachInstanceProperty(o).call(o,(function(e){var t=findBox(e,["schm"])[0];if(t){var r=bin2str(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var n=findBox(e,["frma"])[0];n&&(a=bin2str(n))}}}))}switch(a){case"avc1":case"avc2":case"avc3":case"avc4":var l=findBox(r,["avcC"])[0];a+="."+toHex(l[1])+toHex(l[2])+toHex(l[3]);break;case"mp4a":var c=findBox(t,[n])[0],u=findBox(c.subarray(28),["esds"])[0];if(u&&u.length>7){var d=4;if(3!==u[d++])break;d=skipBERInteger(u,d),d+=2;var f=u[d++];if(128&f&&(d+=2),64&f&&(d+=u[d++]),4!==u[d++])break;d=skipBERInteger(u,d);var h=u[d++];if(64!==h)break;if(a+="."+toHex(h),d+=12,5!==u[d++])break;d=skipBERInteger(u,d);var p=u[d++],y=(248&p)>>3;31===y&&(y+=1+((7&p)<<3)+((224&u[d])>>5)),a+="."+y}break;case"hvc1":case"hev1":var g=findBox(r,["hvcC"])[0],v=g[1],m=["","A","B","C"][v>>6],E=31&v,$=readUint32(g,2),S=(32&v)>>5?"H":"L",T=g[12],I=g.subarray(6,12);a+="."+m+E,a+="."+$.toString(16).toUpperCase(),a+="."+S+T;for(var _="",P=I.length;P--;){var b=I[P];if(b||_)_="."+b.toString(16).toUpperCase()+_}a+=_;break;case"dvh1":case"dvhe":var A=findBox(r,["dvcC"])[0],k=A[2]>>1&127,R=A[2]<<5&32|A[3]>>3&31;a+="."+addLeadingZero(k)+"."+addLeadingZero(R);break;case"vp09":var C=findBox(r,["vpcC"])[0],O=C[4],L=C[5],D=C[6]>>4&15;a+="."+addLeadingZero(O)+"."+addLeadingZero(L)+"."+addLeadingZero(D);break;case"av01":var w=findBox(r,["av1C"])[0],M=w[1]>>>5,x=31&w[1],N=w[2]>>>7?"H":"M",F=(64&w[2])>>6,U=(32&w[2])>>5,B=2===M&&F?U?12:10:F?10:8,j=(16&w[2])>>4,G=(8&w[2])>>3,H=(4&w[2])>>2,K=3&w[2];a+="."+M+"."+addLeadingZero(x)+N+"."+addLeadingZero(B)+"."+j+"."+G+H+K+"."+addLeadingZero(1)+"."+addLeadingZero(1)+"."+addLeadingZero(1)+".0"}return{codec:a,encrypted:i}}function skipBERInteger(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function toHex(e){var t;return _sliceInstanceProperty(t="0"+e.toString(16).toUpperCase()).call(t,-2)}function addLeadingZero(e){return(e<10?"0":"")+e}function patchEncyptionData(e,t){if(!e||!t)return e;var r=t.keyId;if(r&&t.isCommonEncryption){var n=findBox(e,["moov","trak"]);_forEachInstanceProperty(n).call(n,(function(e){var t=findBox(e,["mdia","minf","stbl","stsd"])[0].subarray(8),n=findBox(t,["enca"]),a=n.length>0;a||(n=findBox(t,["encv"])),_forEachInstanceProperty(n).call(n,(function(e){var t=findBox(a?e.subarray(28):e.subarray(78),["sinf"]);_forEachInstanceProperty(t).call(t,(function(e){var t=parseSinf(e);if(t){var n,i,s=t.subarray(8,24);if(!_someInstanceProperty(s).call(s,(function(e){return 0!==e})))logger.log(_concatInstanceProperty(n=_concatInstanceProperty(i="[eme] Patching keyId in 'enc".concat(a?"a":"v",">sinf>>tenc' box: ")).call(i,Hex.hexDump(s)," -> ")).call(n,Hex.hexDump(r))),t.set(r,8)}}))}))}))}return e}function parseSinf(e){var t=findBox(e,["schm"])[0];if(t){var r=bin2str(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return findBox(e,["schi","tenc"])[0]}return null}function getStartDTS(e,t){var r;return _reduceInstanceProperty(r=findBox(t,["moof","traf"])).call(r,(function(t,r){var n,a=findBox(r,["tfdt"])[0],i=a[0],s=_reduceInstanceProperty(n=findBox(r,["tfhd"])).call(n,(function(t,r){var n=readUint32(r,4),s=e[n];if(s){var o=readUint32(a,4);if(1===i){if(o===UINT32_MAX$1)return logger.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=UINT32_MAX$1+1,o+=readUint32(a,8)}var l=o/(s.timescale||9e4);if(isFiniteNumber(l)&&(null===t||l<t))return l}return t}),null);return null!==s&&isFiniteNumber(s)&&(null===t||s<t)?s:t}),null)}function getDuration(e,t){for(var r=0,n=0,a=0,i=findBox(e,["moof","traf"]),s=0;s<i.length;s++){var o=i[s],l=findBox(o,["tfhd"])[0],c=t[readUint32(l,4)];if(c){var u=c.default,d=readUint32(l,0)|(null==u?void 0:_flagsInstanceProperty(u)),f=null==u?void 0:u.duration;8&d&&(f=readUint32(l,2&d?12:8));for(var h=c.timescale||9e4,p=findBox(o,["trun"]),y=0;y<p.length;y++){if(!(r=computeRawDurationFromSamples(p[y]))&&f)r=f*readUint32(p[y],4);c.type===ElementaryStreamTypes.VIDEO?n+=r/h:c.type===ElementaryStreamTypes.AUDIO&&(a+=r/h)}}}if(0===n&&0===a){for(var g=1/0,v=0,m=0,E=findBox(e,["sidx"]),$=0;$<E.length;$++){var S=parseSegmentIndex(E[$]);if(null!=S&&S.references){var T;g=Math.min(g,S.earliestPresentationTime/S.timescale);var I=_reduceInstanceProperty(T=S.references).call(T,(function(e,t){return e+t.info.duration||0}),0);m=(v=Math.max(v,I+S.earliestPresentationTime/S.timescale))-g}}if(m&&isFiniteNumber(m))return m}return n||a}function computeRawDurationFromSamples(e){var t=readUint32(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var n=0,a=readUint32(e,4),i=0;i<a;i++){if(256&t)n+=readUint32(e,r),r+=4;512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return n}function offsetStartDTS(e,t,r){var n;_forEachInstanceProperty(n=findBox(t,["moof","traf"])).call(n,(function(t){var n;_forEachInstanceProperty(n=findBox(t,["tfhd"])).call(n,(function(n){var a,i=readUint32(n,4),s=e[i];if(s){var o=s.timescale||9e4;_forEachInstanceProperty(a=findBox(t,["tfdt"])).call(a,(function(e){var t=e[0],n=r*o;if(n){var a=readUint32(e,4);if(0===t)a-=n,writeUint32(e,4,a=Math.max(a,0));else{a*=Math.pow(2,32),a+=readUint32(e,8),a-=n,a=Math.max(a,0);var i=Math.floor(a/(UINT32_MAX$1+1)),s=Math.floor(a%(UINT32_MAX$1+1));writeUint32(e,4,i),writeUint32(e,8,s)}}}))}}))}))}function segmentValidRange(e){var t={valid:null,remainder:null},r=findBox(e,["moof"]);if(r.length<2)return t.remainder=e,t;var n=r[r.length-1];return t.valid=sliceUint8(e,0,n.byteOffset-8),t.remainder=sliceUint8(e,n.byteOffset-8),t}function appendUint8Array(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function parseSamples(e,t){var r=[],n=t.samples,a=t.timescale,i=t.id,s=!1,o=findBox(n,["moof"]);return _mapInstanceProperty(o).call(o,(function(o){var l=o.byteOffset-8,c=findBox(o,["traf"]);_mapInstanceProperty(c).call(c,(function(o){var c,u,d=_mapInstanceProperty(c=findBox(o,["tfdt"])).call(c,(function(e){var t=e[0],r=readUint32(e,4);return 1===t&&(r*=Math.pow(2,32),r+=readUint32(e,8)),r/a}))[0];return void 0!==d&&(e=d),_mapInstanceProperty(u=findBox(o,["tfhd"])).call(u,(function(c){var u,d=readUint32(c,4),f=16777215&readUint32(c,0),h=0,p=0!=(16&f),y=0,g=0!=(32&f),v=8;d===i&&(0!=(1&f)&&(v+=8),0!=(2&f)&&(v+=4),0!=(8&f)&&(h=readUint32(c,v),v+=4),p&&(y=readUint32(c,v),v+=4),g&&(v+=4),"video"===t.type&&(s=isHEVC(t.codec)),_mapInstanceProperty(u=findBox(o,["trun"])).call(u,(function(i){var o=i[0],c=16777215&readUint32(i,0),u=0!=(1&c),d=0,f=0!=(4&c),p=0!=(256&c),g=0,v=0!=(512&c),m=0,E=0!=(1024&c),$=0!=(2048&c),S=0,T=readUint32(i,4),I=8;u&&(d=readUint32(i,I),I+=4),f&&(I+=4);for(var _=d+l,P=0;P<T;P++){if(p?(g=readUint32(i,I),I+=4):g=h,v?(m=readUint32(i,I),I+=4):m=y,E&&(I+=4),$&&(S=0===o?readUint32(i,I):readSint32(i,I),I+=4),t.type===ElementaryStreamTypes.VIDEO)for(var b=0;b<m;){var A=readUint32(n,_);if(isSEIMessage(s,n[_+=4]))parseSEIMessageFromNALu(n.subarray(_,_+A),s?2:1,e+S/a,r);_+=A,b+=A+4}e+=g/a}})))}))}))})),r}function isHEVC(e){if(!e)return!1;var t=_indexOfInstanceProperty(e).call(e,"."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}function isSEIMessage(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function parseSEIMessageFromNALu(e,t,r,n){var a=discardEPB(e),i=0;i+=t;for(var s=0,o=0,l=0;i<a.length;){s=0;do{if(i>=a.length)break;s+=l=a[i++]}while(255===l);o=0;do{if(i>=a.length)break;o+=l=a[i++]}while(255===l);var c=a.length-i,u=i;if(o<c)i+=o;else if(o>c){var d;logger.error(_concatInstanceProperty(d="Malformed SEI payload. ".concat(o," is too small, only ")).call(d,c," bytes left to parse."));break}if(4===s){if(181===a[u++]){var f=readUint16(a,u);if(u+=2,49===f){var h=readUint32(a,u);if(u+=4,1195456820===h){var p=a[u++];if(3===p){var y=a[u++],g=64&y,v=g?2+3*(31&y):0,m=new Uint8Array(v);if(g){m[0]=y;for(var E=1;E<v;E++)m[E]=a[u++]}n.push({type:p,payloadType:s,pts:r,bytes:m})}}}}}else if(5===s&&o>16){for(var $=[],S=0;S<16;S++){var T=a[u++].toString(16);$.push(1==T.length?"0"+T:T),3!==S&&5!==S&&7!==S&&9!==S||$.push("-")}for(var I=o-16,_=new Uint8Array(I),P=0;P<I;P++)_[P]=a[u++];n.push({payloadType:s,pts:r,uuid:$.join(""),userData:utf8ArrayToStr(_),userDataBytes:_})}}}function discardEPB(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(0===r.length)return e;var a=t-r.length,i=new Uint8Array(a),s=0;for(n=0;n<a;s++,n++)s===r[0]&&(s++,r.shift()),i[n]=e[s];return i}function parseEmsg(e){var t=e[0],r="",n="",a=0,i=0,s=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==bin2str(e.subarray(c,c+1));)r+=bin2str(e.subarray(c,c+1)),c+=1;for(r+=bin2str(e.subarray(c,c+1)),c+=1;"\0"!==bin2str(e.subarray(c,c+1));)n+=bin2str(e.subarray(c,c+1)),c+=1;n+=bin2str(e.subarray(c,c+1)),c+=1,a=readUint32(e,12),i=readUint32(e,16),o=readUint32(e,20),l=readUint32(e,24),c=28}else if(1===t){a=readUint32(e,c+=4);var u=readUint32(e,c+=4),d=readUint32(e,c+=4);for(c+=4,s=Math.pow(2,32)*u+d,isSafeInteger2(s)||(s=_Number$MAX_SAFE_INTEGER,logger.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=readUint32(e,c),l=readUint32(e,c+=4),c+=4;"\0"!==bin2str(e.subarray(c,c+1));)r+=bin2str(e.subarray(c,c+1)),c+=1;for(r+=bin2str(e.subarray(c,c+1)),c+=1;"\0"!==bin2str(e.subarray(c,c+1));)n+=bin2str(e.subarray(c,c+1)),c+=1;n+=bin2str(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:n,timeScale:a,presentationTime:s,presentationTimeDelta:i,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}function mp4Box(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var a=r.length,i=8,s=a;s--;)i+=r[s].byteLength;var o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=255&i,o.set(e,4),s=0,i=8;s<a;s++)o.set(r[s],i),i+=r[s].byteLength;return o}function mp4pssh(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var n,a;n=new Uint8Array,a=new Uint8Array;var i=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(i.buffer).setUint32(0,r.byteLength,!1),mp4Box([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,n,i,r||new Uint8Array)}function parseMultiPssh(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,n=0;n+32<r;){var a=parsePssh(new DataView(e,n));t.push(a),n+=a.size}return t}function parsePssh(e){var t=e.getUint32(0),r=e.byteOffset,n=e.byteLength;if(n<t)return{offset:r,size:n};if(1886614376!==e.getUint32(4))return{offset:r,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:r,size:t};var i=e.buffer,s=Hex.hexDump(new Uint8Array(i,r+12,16)),o=e.getUint32(28),l=null,c=null;if(0===a){if(t-32<o||o<22)return{offset:r,size:t};c=new Uint8Array(i,r+32,o)}else if(1===a){if(!o||n<r+32+16*o+16)return{offset:r,size:t};l=[];for(var u=0;u<o;u++)l.push(new Uint8Array(i,r+32+16*u,16))}return{version:a,systemId:s,kids:l,data:c,offset:r,size:t}}var CHUNK_SIZE=16,Decrypter=function(){function e(t){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).removePKCS7Padding,n=void 0===r||r;if(_classCallCheck$1(this,e),this.logEnabled=!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.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}return _createClass$1(e,[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?removePadding(r):r}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,r,n){var a=this;return this.useSoftware?new _Promise((function(i,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);a.softwareDecrypt(o,t,r,n);var l=a.flush();l?i(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,n)}},{key:"softwareDecrypt",value:function(e,t,r,n){var a=this.currentIV,i=this.currentResult,s=this.remainderData;if(n!==DecrypterAesMode.cbc||16!==t.byteLength)return logger.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=appendUint8Array(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;a&&(r=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new AESDecryptor),l.expandKey(t);var c=i;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=sliceUint8(o,-16).buffer,c||null}},{key:"webCryptoDecrypt",value:function(e,t,r,n){var a=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return _Promise.resolve(this.onWebCryptoError(e,t,r,n));this.key=t,this.fastAesKey=new FastAESKey(this.subtle,t,n)}return this.fastAesKey.expandKey().then((function(t){return a.subtle?(a.logOnce("WebCrypto AES decrypt"),new AESCrypto(a.subtle,new Uint8Array(r),n).decrypt(e.buffer,t)):_Promise.reject(new Error("web crypto not initialized"))})).catch((function(i){var s;return logger.warn(_concatInstanceProperty(s="[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(i.name,": ")).call(s,i.message)),a.onWebCryptoError(e,t,r,n)}))}},{key:"onWebCryptoError",value:function(e,t,r,n){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,n);var i=this.flush();if(i)return i.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,r=e.length-e.length%CHUNK_SIZE;return r!==e.length&&(t=sliceUint8(e,0,r),this.remainderData=sliceUint8(e,r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(logger.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),MIN_CHUNK_SIZE=Math.pow(2,17),FragmentLoader=function(){function e(t){_classCallCheck$1(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}return _createClass$1(e,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var r=this,n=e.url;if(!n)return _Promise.reject(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(n?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,i=a.fLoader,s=a.loader;return new _Promise((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){var c;if(_someInstanceProperty(c=e.tagList).call(c,(function(e){return"GAP"===e[0]})))return void l(createGapLoadError(e));e.gap=!1}var u=r.loader=i?new i(a):new s(a),d=createLoaderContext(e);e.loader=u;var f=getLoaderConfigWithoutReties(a.fragLoadPolicy.default),h={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:MIN_CHUNK_SIZE};e.stats=u.stats;var p={onSuccess:function(t,n,a,i){r.resetLoader(e,u);var s=t.data;a.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(_sliceInstanceProperty(s).call(s,0,16)),s=_sliceInstanceProperty(s).call(s,16)),o({frag:e,part:null,payload:s,networkDetails:i})},onError:function(t,a,i,s){var o;r.resetLoader(e,u),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_objectSpread2({url:n,data:void 0},t),error:new Error(_concatInstanceProperty(o="HTTP Error ".concat(t.code," ")).call(o,t.text)),networkDetails:i,stats:s}))},onAbort:function(t,n,a){r.resetLoader(e,u),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:a,stats:t}))},onTimeout:function(t,n,a){r.resetLoader(e,u),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after ".concat(h.timeout,"ms")),networkDetails:a,stats:t}))}};t&&(p.onProgress=function(r,n,a,i){return t({frag:e,part:null,payload:a,networkDetails:i})}),u.load(d,h,p)}))}},{key:"loadPart",value:function(e,t,r){var n=this;this.abort();var a=this.config,i=a.fLoader,s=a.loader;return new _Promise((function(o,l){if(n.loader&&n.loader.destroy(),e.gap||t.gap)l(createGapLoadError(e,t));else{var c=n.loader=i?new i(a):new s(a),u=createLoaderContext(e,t);e.loader=c;var d=getLoaderConfigWithoutReties(a.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:MIN_CHUNK_SIZE};t.stats=c.stats,c.load(u,f,{onSuccess:function(a,i,s,l){n.resetLoader(e,c),n.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:a.data,networkDetails:l};r(u),o(u)},onError:function(r,a,i,s){var o;n.resetLoader(e,c),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_objectSpread2({url:u.url,data:void 0},r),error:new Error(_concatInstanceProperty(o="HTTP Error ".concat(r.code," ")).call(o,r.text)),networkDetails:i,stats:s}))},onAbort:function(r,a,i){e.stats.aborted=t.stats.aborted,n.resetLoader(e,c),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:i,stats:r}))},onTimeout:function(r,a,i){n.resetLoader(e,c),l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after ".concat(f.timeout,"ms")),networkDetails:i,stats:r}))}})}}))}},{key:"updateStatsFromPart",value:function(e,t){var r=e.stats,n=t.stats,a=n.total;if(r.loaded+=n.loaded,a){var i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/a),i),o=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,c=n.loading;l.start?l.first+=c.first-c.start:(l.start=c.start,l.first=c.first),l.end=c.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}]),e}();function createLoaderContext(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=t||e,n={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,i=r.byteRangeEndOffset;if(isFiniteNumber(a)&&isFiniteNumber(i)){var s,o=a,l=i;if("initSegment"===e.sn&&isMethodFullSegmentAesCbc(null==(s=e.decryptdata)?void 0:s.method)){var c=i-a;c%16&&(l=i+(16-c%16)),0!==a&&(n.resetIV=!0,o=a-16)}n.rangeStart=o,n.rangeEnd=l}return n}function createGapLoadError(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),n={type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(n.part=t),(t||e).stats.aborted=!0,new LoadError(n)}function isMethodFullSegmentAesCbc(e){return"AES-128"===e||"AES-256"===e}var LoadError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e.error.message)).data=void 0,n.data=e,n}return _createClass$1(r)}(),TaskLoop=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a,i;return _classCallCheck$1(this,r),(i=t.call(this,e,n))._boundTick=void 0,i._tickTimer=null,i._tickInterval=null,i._tickCallCount=0,i._boundTick=_bindInstanceProperty(a=i.tick).call(a,_assertThisInitialized(i)),i}return _createClass$1(r,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=_setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=_setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}]),r}(),ChunkMetadata=_createClass$1((function e(t,r,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];_classCallCheck$1(this,e),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=getNewPerformanceTiming(),this.buffering={audio:getNewPerformanceTiming(),video:getNewPerformanceTiming(),audiovideo:getNewPerformanceTiming()},this.level=t,this.sn=r,this.id=n,this.size=a,this.part=i,this.partial=s}));function getNewPerformanceTiming(){return{start:0,executeStart:0,executeEnd:0,end:0}}var noopBuffered={length:0,start:function(){return 0},end:function(){return 0}},BufferHelper=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"isBuffered",value:function(t,r){if(t)for(var n=e.getBuffered(t),a=n.length;a--;)if(r>=n.start(a)&&r<=n.end(a))return!0;return!1}},{key:"bufferInfo",value:function(t,r,n){if(t){var a=e.getBuffered(t);if(a.length){for(var i=[],s=0;s<a.length;s++)i.push({start:a.start(s),end:a.end(s)});return e.bufferedInfo(i,r,n)}}return{len:0,start:r,end:r,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){t=Math.max(0,t),_sortInstanceProperty(e).call(e,(function(e,t){return e.start-t.start||t.end-e.end}));var n=[];if(r)for(var a=0;a<e.length;a++){var i=n.length;if(i){var s=n[i-1].end;e[a].start-s<r?e[a].end>s&&(n[i-1].end=e[a].end):n.push(e[a])}else n.push(e[a])}else n=e;for(var o,l=0,c=t,u=t,d=0;d<n.length;d++){var f=n[d].start,h=n[d].end;if(t+r>=f&&t<h)c=f,l=(u=h)-t;else if(t+r<f){o=f;break}}return{len:l,start:c||0,end:u||0,nextStart:o}}},{key:"getBuffered",value:function(e){try{return e.buffered||noopBuffered}catch(e){return logger.log("failed to get media.buffered",e),noopBuffered}}}]),e}(),VARIABLE_REPLACEMENT_REGEX=/\{\$([a-zA-Z0-9-_]+)\}/g;function hasVariableReferences(e){return VARIABLE_REPLACEMENT_REGEX.test(e)}function substituteVariables(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(VARIABLE_REPLACEMENT_REGEX,(function(t){var n=t.substring(2,t.length-1),a=null==r?void 0:r[n];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(n,'"'))),t):a}))}return t}function addVariableDefinition(e,t,r){var n,a,i=e.variableList;if(i||(e.variableList=i={}),"QUERYPARAM"in t){n=t.QUERYPARAM;try{var s,o=new _URL(r).searchParams;if(!o.has(n))throw new Error(_concatInstanceProperty(s='"'.concat(n,'" does not match any query parameter in URI: "')).call(s,r,'"'));a=o.get(n)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(t.message)))}}else n=t.NAME,a=t.VALUE;n in i?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(n,'"'))):i[n]=a||""}function importVariableDefinition(e,t,r){var n=t.IMPORT;if(r&&n in r){var a=e.variableList;a||(e.variableList=a={}),a[n]=r[n]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(n,'"')))}var DECIMAL_RESOLUTION_REGEX=/^(\d+)x(\d+)$/,ATTR_LIST_REGEX=/(.+?)=(".*?"|.*?)(?:,|$)/g,AttrList=function(){function e(t,r){_classCallCheck$1(this,e),"string"==typeof t&&(t=e.parseAttrList(t,r)),_extends(this,t)}return _createClass$1(e,[{key:"clientAttrs",get:function(){var e;return _filterInstanceProperty(e=_Object$keys(this)).call(e,(function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=_parseInt$1(this[e],10);return t>_Number$MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t,r=_sliceInstanceProperty(t=this[e]||"0x").call(t,2);r=(1&r.length?"0":"")+r;for(var n=new Uint8Array(r.length/2),a=0;a<r.length/2;a++)n[a]=_parseInt$1(_sliceInstanceProperty(r).call(r,2*a,2*a+2),16);return n}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=_parseInt$1(this[e],16);return t>_Number$MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return _parseFloat$1(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?_parseFloat$1(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r,n=this[e];return _reduceInstanceProperty(r=n?n.split(/[ ,]+/):[]).call(r,(function(e,t){return e[t.toLowerCase()]=!0,e}),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=DECIMAL_RESOLUTION_REGEX.exec(this[e]);if(null!==t)return{width:_parseInt$1(t[1],10),height:_parseInt$1(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,n,a={};for(ATTR_LIST_REGEX.lastIndex=0;null!==(n=ATTR_LIST_REGEX.exec(e));){var i,s=_trimInstanceProperty(i=n[1]).call(i),o=n[2],l=0===_indexOfInstanceProperty(o).call(o,'"')&&_lastIndexOfInstanceProperty(o).call(o,'"')===o.length-1,c=!1;if(l)o=_sliceInstanceProperty(o).call(o,1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":c=!0}if(t&&(l||c))o=substituteVariables(t,o);else if(!c&&!l)switch(s){case"CLOSED-CAPTIONS":if("NONE"===o)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":logger.warn(_concatInstanceProperty(r="".concat(e,": attribute ")).call(r,s," is missing quotes"))}a[s]=o}return a}}]),e}(),CLASS_INTERSTITIAL="com.apple.hls.interstitial";function isDateRangeCueAttribute(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function isSCTE35Attribute(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var DateRange=function(){function e(t,r){var n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(_classCallCheck$1(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==r?void 0:r.tagAnchor)||null,this.tagOrder=null!=(n=null==r?void 0:r.tagOrder)?n:a,r){var i=r.attr;for(var s in i)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==i[s]){var o;logger.warn(_concatInstanceProperty(o='DATERANGE tag attribute: "'.concat(s,'" does not match for tags with ID: "')).call(o,t.ID,'"')),this._badValueForSameId=s;break}t=_extends(new AttrList({}),i,t)}if(this.attr=t,r?(this._startDate=r._startDate,this._cue=r._cue,this._endDate=r._endDate,this._dateAtEnd=r._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var l=(null==r?void 0:r.endDate)||new Date(this.attr["END-DATE"]);isFiniteNumber(l.getTime())&&(this._endDate=l)}}return _createClass$1(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e,t=this.tagAnchor;return null===t||null===t.programDateTime?(logger.warn(_concatInstanceProperty(e='Expected tagAnchor Fragment with PDT set for DateRange "'.concat(this.id,'": ')).call(e,t)),NaN):t.start+(this.startDate.getTime()-t.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(isFiniteNumber(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return this.class===CLASS_INTERSTITIAL}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&isFiniteNumber(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}]),e}(),DEFAULT_TARGET_DURATION=10,LevelDetails=function(){function e(t){_classCallCheck$1(this,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.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return _createClass$1(e,[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&isFiniteNumber(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||DEFAULT_TARGET_DURATION}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(_Date$now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}]),e}();function isFullSegmentEncryption(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function getAesModeFromFullSegmentMethod(e){switch(e){case"AES-128":case"AES-256":return DecrypterAesMode.cbc;case"AES-256-CTR":return DecrypterAesMode.ctr;default:throw new Error("invalid full segment method ".concat(e))}}function base64Decode(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function strToUtf8array(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function getKeyIdBytes(e){var t=strToUtf8array(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}function changeEndianness(e){var t=function(e,t,r){var n=e[t];e[t]=e[r],e[r]=n};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function convertDataUriToArrayBytes(e){var t=e.split(":"),r=null;if("data"===t[0]&&2===t.length){var n=t[1].split(";"),a=n[n.length-1].split(",");if(2===a.length){var i="base64"===a[0],s=a[1];i?(_spliceInstanceProperty(n).call(n,-1,1),r=base64Decode(s)):r=getKeyIdBytes(s)}}return r}var optionalSelf="undefined"!=typeof self?self:void 0,KeySystems={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},KeySystemFormats={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function keySystemFormatToKeySystemDomain(e){switch(e){case KeySystemFormats.FAIRPLAY:return KeySystems.FAIRPLAY;case KeySystemFormats.PLAYREADY:return KeySystems.PLAYREADY;case KeySystemFormats.WIDEVINE:return KeySystems.WIDEVINE;case KeySystemFormats.CLEARKEY:return KeySystems.CLEARKEY}}var KeySystemIds={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function keySystemIdToKeySystemDomain(e){return e===KeySystemIds.WIDEVINE?KeySystems.WIDEVINE:e===KeySystemIds.PLAYREADY?KeySystems.PLAYREADY:e===KeySystemIds.CENC||e===KeySystemIds.CLEARKEY?KeySystems.CLEARKEY:void 0}function keySystemDomainToKeySystemFormat(e){switch(e){case KeySystems.FAIRPLAY:return KeySystemFormats.FAIRPLAY;case KeySystems.PLAYREADY:return KeySystemFormats.PLAYREADY;case KeySystems.WIDEVINE:return KeySystemFormats.WIDEVINE;case KeySystems.CLEARKEY:return KeySystemFormats.CLEARKEY}}function getKeySystemsForConfig(e){var t,r=e.drmSystems,n=e.widevineLicenseUrl,a=r?_filterInstanceProperty(t=[KeySystems.FAIRPLAY,KeySystems.WIDEVINE,KeySystems.PLAYREADY,KeySystems.CLEARKEY]).call(t,(function(e){return!!r[e]})):[];return!a[KeySystems.WIDEVINE]&&n&&a.push(KeySystems.WIDEVINE),a}var _requestMediaKeySystemAccess=function(e){var t;return null!=optionalSelf&&null!=(e=optionalSelf.navigator)&&e.requestMediaKeySystemAccess?_bindInstanceProperty(t=self.navigator.requestMediaKeySystemAccess).call(t,self.navigator):null}();function getSupportedMediaKeySystemConfigurations(e,t,r,n){var a;switch(e){case KeySystems.FAIRPLAY:a=["cenc","sinf"];break;case KeySystems.WIDEVINE:case KeySystems.PLAYREADY:a=["cenc"];break;case KeySystems.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return createMediaKeySystemConfigurations(a,t,r,n)}function createMediaKeySystemConfigurations(e,t,r,n){return[{initDataTypes:e,persistentState:n.persistentState||"optional",distinctiveIdentifier:n.distinctiveIdentifier||"optional",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:_mapInstanceProperty(t).call(t,(function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null}})),videoCapabilities:_mapInstanceProperty(r).call(r,(function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}}))}]}function parsePlayReadyWRM(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,_Array$from(t)),n=r.substring(_indexOfInstanceProperty(r).call(r,"<"),r.length),a=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];if(a){var i=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(i){var s=base64Decode(i).subarray(0,16);return changeEndianness(s),s}}return null}var keyUriToKeyIdMap={},LevelKey=function(){function e(t,r,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;_classCallCheck$1(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=r,this.keyFormat=n,this.keyFormatVersions=a,this.iv=i,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!isFullSegmentEncryption(t)}return _createClass$1(e,[{key:"isSupported",value:function(){var e;if(this.method){if(isFullSegmentEncryption(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case KeySystemFormats.FAIRPLAY:case KeySystemFormats.WIDEVINE:case KeySystemFormats.PLAYREADY:case KeySystemFormats.CLEARKEY:return-1!==_indexOfInstanceProperty(e=["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"]).call(e,this.method)}}return!1}},{key:"getDecryptData",value:function(t){if(!this.encrypted||!this.uri)return null;if(isFullSegmentEncryption(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(logger.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue')),t=0);var r=createInitializationVector(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var n=convertDataUriToArrayBytes(this.uri);if(n)switch(this.keyFormat){case KeySystemFormats.WIDEVINE:this.pssh=n,n.length>=22&&(this.keyId=n.subarray(n.length-22,n.length-6));break;case KeySystemFormats.PLAYREADY:var a=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=mp4pssh(a,null,n),this.keyId=parsePlayReadyWRM(n);break;default:var i=n.subarray(0,16);if(16!==i.length){var s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i}if(!this.keyId||16!==this.keyId.byteLength){var o=keyUriToKeyIdMap[this.uri];if(!o){var l=_Object$keys(keyUriToKeyIdMap).length%_Number$MAX_SAFE_INTEGER;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),keyUriToKeyIdMap[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){keyUriToKeyIdMap={}}}]),e}();function createInitializationVector(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}var MASTER_PLAYLIST_REGEX=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,MASTER_PLAYLIST_MEDIA_REGEX=/#EXT-X-MEDIA:(.*)/g,IS_MEDIA_PLAYLIST=/^#EXT(?:INF|-X-TARGETDURATION):/m,LEVEL_PLAYLIST_REGEX_FAST=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),LEVEL_PLAYLIST_REGEX_SLOW=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),M3U8Parser=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"findGroup",value:function(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.id===t)return n}}},{key:"resolve",value:function(e,t){return urlToolkitExports.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return IS_MEDIA_PLAYLIST.test(e)}},{key:"parseMasterPlaylist",value:function(t,r){var n,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:hasVariableReferences(t)},i=[];for(MASTER_PLAYLIST_REGEX.lastIndex=0;null!=(n=MASTER_PLAYLIST_REGEX.exec(t));)if(n[1]){var s,o=new AttrList(n[1],a),l=substituteVariables(a,n[2]),c={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},u=o.decimalResolution("RESOLUTION");u&&(c.width=u.width,c.height=u.height),setCodecs(o.CODECS,c),null!=(s=c.unknownCodecs)&&s.length||i.push(c),a.levels.push(c)}else if(n[3]){var d=n[3],f=n[4];switch(d){case"SESSION-DATA":var h=new AttrList(f,a),p=h["DATA-ID"];p&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[p]=h);break;case"SESSION-KEY":var y=parseKey(f,r,a);y.encrypted&&y.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(y)):logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(f,'"'));break;case"DEFINE":addVariableDefinition(a,new AttrList(f,a),r);break;case"CONTENT-STEERING":var g=new AttrList(f,a);a.contentSteering={uri:e.resolve(g["SERVER-URI"],r),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=parseStartTimeOffset(f)}}var v=i.length>0&&i.length<a.levels.length;return a.levels=v?i:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,r,n){var a,i={},s=n.levels,o={AUDIO:_mapInstanceProperty(s).call(s,(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:_mapInstanceProperty(s).call(s,(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(MASTER_PLAYLIST_MEDIA_REGEX.lastIndex=0;null!==(a=MASTER_PLAYLIST_MEDIA_REGEX.exec(t));){var c=new AttrList(a[1],n),u=c.TYPE;if(u){var d=o[u],f=i[u]||[];i[u]=f;var h=c.LANGUAGE,p=c["ASSOC-LANGUAGE"],y=c.CHANNELS,g=c.CHARACTERISTICS,v=c["INSTREAM-ID"],m={attrs:c,bitrate:0,id:l++,groupId:c["GROUP-ID"]||"",name:c.NAME||h||"",type:u,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:h,url:c.URI?e.resolve(c.URI,r):""};if(p&&(m.assocLang=p),y&&(m.channels=y),g&&(m.characteristics=g),v&&(m.instreamId=v),null!=d&&d.length){var E=e.findGroup(d,m.groupId)||d[0];assignCodec(m,E,"audioCodec"),assignCodec(m,E,"textCodec")}f.push(m)}}return i}},{key:"parseLevelPlaylist",value:function(e,t,r,n,a,i){var s,o,l,c={url:t},u=new LevelDetails(t),d=u.fragments,f=[],h=null,p=0,y=0,g=0,v=0,m=0,E=null,$=new Fragment(n,c),S=-1,T=!1,I=null;for(LEVEL_PLAYLIST_REGEX_FAST.lastIndex=0,u.m3u8=e,u.hasVariableRefs=hasVariableReferences(e);null!==(s=LEVEL_PLAYLIST_REGEX_FAST.exec(e));){T&&(T=!1,($=new Fragment(n,c)).playlistOffset=g,$.start=g,$.sn=p,$.cc=v,m&&($.bitrate=m),$.level=r,h&&($.initSegment=h,h.rawProgramDateTime&&($.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),I&&($.setByteRange(I),I=null)));var _=s[1];if(_){var P;$.duration=_parseFloat$1(_);var b=_sliceInstanceProperty(P=" "+s[2]).call(P,1);$.title=b||null,$.tagList.push(b?["INF",_,b]:["INF",_])}else if(s[3]){if(isFiniteNumber($.duration)){var A;$.playlistOffset=g,$.start=g,l&&setFragLevelKeys($,l,u),$.sn=p,$.level=r,$.cc=v,d.push($);var k=_sliceInstanceProperty(A=" "+s[3]).call(A,1);$.relurl=substituteVariables(u,k),assignProgramDateTime($,E,f),E=$,g+=$.duration,p++,y=0,T=!0}}else{var R,C,O;if(!(s=s[0].match(LEVEL_PLAYLIST_REGEX_SLOW))){logger.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<s.length&&void 0===s[o];o++);var L=_sliceInstanceProperty(R=" "+s[o]).call(R,1),D=_sliceInstanceProperty(C=" "+s[o+1]).call(C,1),w=s[o+2]?_sliceInstanceProperty(O=" "+s[o+2]).call(O,1):null;switch(L){case"BYTERANGE":E?$.setByteRange(D,E):$.setByteRange(D);break;case"PROGRAM-DATE-TIME":$.rawProgramDateTime=D,$.tagList.push(["PROGRAM-DATE-TIME",D]),-1===S&&(S=d.length);break;case"PLAYLIST-TYPE":u.type=D.toUpperCase();break;case"MEDIA-SEQUENCE":p=u.startSN=_parseInt$1(D);break;case"SKIP":u.skippedSegments&&(u.playlistParsingError=new Error("#EXT-X-SKIP MUST NOT appear more than once in a Playlist"));var M=new AttrList(D,u),x=M.decimalInteger("SKIPPED-SEGMENTS");if(isFiniteNumber(x)){u.skippedSegments+=x;for(var N=x;N--;)d.push(null);p+=x}var F,U=M.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(U)u.recentlyRemovedDateranges=_concatInstanceProperty(F=u.recentlyRemovedDateranges||[]).call(F,U.split("\t"));break;case"TARGETDURATION":u.targetduration=Math.max(_parseInt$1(D),1);break;case"VERSION":u.version=_parseInt$1(D);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(D||w)&&$.tagList.push(w?[D,w]:[D]);break;case"DISCONTINUITY":v++,$.tagList.push(["DIS"]);break;case"GAP":$.gap=!0,$.tagList.push([L]);break;case"BITRATE":$.tagList.push([L,D]),m=1e3*_parseInt$1(D),isFiniteNumber(m)?$.bitrate=m:m=0;break;case"DATERANGE":var B=new AttrList(D,u),j=new DateRange(B,u.dateRanges[B.ID],u.dateRangeTagCount);u.dateRangeTagCount++,j.isValid||u.skippedSegments?u.dateRanges[j.id]=j:logger.warn('Ignoring invalid DATERANGE tag: "'.concat(D,'"')),$.tagList.push(["EXT-X-DATERANGE",D]);break;case"DEFINE":var G=new AttrList(D,u);"IMPORT"in G?importVariableDefinition(u,G,i):addVariableDefinition(u,G,t);break;case"DISCONTINUITY-SEQUENCE":u.startCC=v=_parseInt$1(D);break;case"KEY":var H=parseKey(D,t,u);if(H.isSupported()){if("NONE"===H.method){l=void 0;break}l||(l={}),l[H.keyFormat]&&(l=_extends({},l)),l[H.keyFormat]=H}else logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(D,'"'));break;case"START":u.startTimeOffset=parseStartTimeOffset(D);break;case"MAP":var K=new AttrList(D,u);if($.duration){var V=new Fragment(n,c);setInitSegment(V,K,r,l),h=V,$.initSegment=h,h.rawProgramDateTime&&!$.rawProgramDateTime&&($.rawProgramDateTime=h.rawProgramDateTime)}else{var W=$.byteRangeEndOffset;if(W){var Y,q=$.byteRangeStartOffset;I=_concatInstanceProperty(Y="".concat(W-q,"@")).call(Y,q)}else I=null;setInitSegment($,K,r,l),h=$,T=!0}h.cc=v;break;case"SERVER-CONTROL":var z=new AttrList(D);u.canBlockReload=z.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=z.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&z.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=z.optionalFloat("PART-HOLD-BACK",0),u.holdBack=z.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var X=new AttrList(D);u.partTarget=X.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=u.partList;Q||(Q=u.partList=[]);var J=y>0?Q[Q.length-1]:void 0,Z=y++,ee=new AttrList(D,u),te=new Part(ee,$,c,Z,J);Q.push(te),$.duration+=te.duration;break;case"PRELOAD-HINT":var re=new AttrList(D,u);u.preloadHint=re;break;case"RENDITION-REPORT":var ne=new AttrList(D,u);u.renditionReports=u.renditionReports||[],u.renditionReports.push(ne);break;default:logger.warn("line parsed but not handled: ".concat(s))}}}E&&!E.relurl?(d.pop(),g-=E.duration,u.partList&&(u.fragmentHint=E)):u.partList&&(assignProgramDateTime($,E,f),$.cc=v,u.fragmentHint=$,l&&setFragLevelKeys($,l,u));var ae=d.length,ie=d[0],se=d[ae-1];if((g+=u.skippedSegments*u.targetduration)>0&&ae&&se){u.averagetargetduration=g/ae;var oe=se.sn;u.endSN="initSegment"!==oe?oe:0,u.live||(se.endList=!0),ie&&!u.startCC&&(u.startCC=ie.cc),S>0&&(backfillProgramDateTimes(d,S),ie&&f.unshift(ie))}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(g+=u.fragmentHint.duration),u.totalduration=g,f.length&&u.dateRangeTagCount&&ie&&mapDateRanges(f,u),u.endCC=v,u}}]),e}();function mapDateRanges(e,t){for(var r=e.length,n=e[r-1],a=t.live?1/0:t.totalduration,i=_Object$keys(t.dateRanges),s=i.length;s--;){var o=t.dateRanges[i[s]],l=o.startDate.getTime();o.tagAnchor=n.ref;for(var c=r;c--;){var u=findFragmentWithStartDate(t,l,e,c,a);if(-1!==u){o.tagAnchor=t.fragments[u].ref;break}}}}function findFragmentWithStartDate(e,t,r,n,a){var i=r[n];if(i){var s,o=i.programDateTime;if(t>=o||0===n)if(t<=o+1e3*(((null==(s=r[n+1])?void 0:s.start)||a)-i.start)){var l=r[n].sn-e.startSN,c=e.fragments;if(c.length>r.length)for(var u=(r[n+1]||c[c.length-1]).sn-e.startSN;u>l;u--){var d=c[u].programDateTime;if(t>=d&&t<d+1e3*c[u].duration)return u}return l}}return-1}function parseKey(e,t,r){var n,a,i,s,o=new AttrList(e,r),l=null!=(i=o.METHOD)?i:"",c=o.URI,u=o.hexadecimalInteger("IV"),d=o.KEYFORMATVERSIONS,f=null!=(s=o.KEYFORMAT)?s:"identity";c&&o.IV&&!u&&logger.error("Invalid IV: ".concat(o.IV));var h=c?M3U8Parser.resolve(c,t):"",p=_filterInstanceProperty(n=_mapInstanceProperty(a=(d||"1").split("/")).call(a,Number)).call(n,_Number$isFinite);return new LevelKey(l,h,f,p,u)}function parseStartTimeOffset(e){var t=new AttrList(e).decimalFloatingPoint("TIME-OFFSET");return isFiniteNumber(t)?t:null}function setCodecs(e,t){var r,n,a=_filterInstanceProperty(r=(e||"").split(/[ ,]+/)).call(r,(function(e){return e}));_forEachInstanceProperty(n=["video","audio","text"]).call(n,(function(e){var r=_filterInstanceProperty(a).call(a,(function(t){return isCodecType(t,e)}));r.length&&(t["".concat(e,"Codec")]=r.join(","),a=_filterInstanceProperty(a).call(a,(function(e){return-1===_indexOfInstanceProperty(r).call(r,e)})))})),t.unknownCodecs=a}function assignCodec(e,t,r){var n=t[r];n&&(e[r]=n)}function backfillProgramDateTimes(e,t){for(var r=e[t],n=t;n--;){var a=e[n];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}function assignProgramDateTime(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function setInitSegment(e,t,r,n){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",n&&(e.levelkeys=n),e.initSegment=null}function setFragLevelKeys(e,t,r){var n;e.levelkeys=t;var a=r.encryptedFragments;a.length&&a[a.length-1].levelkeys===t||!_someInstanceProperty(n=_Object$keys(t)).call(n,(function(e){return t[e].isCommonEncryption}))||a.push(e)}function updateFromToPTS(e,t){var r=t.startPTS;if(isFiniteNumber(r)){var n,a=0;t.sn>e.sn?(a=r-e.start,n=e):(a=e.start-r,n=t),n.duration!==a&&n.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function updateFragPTSDTS(e,t,r,n,a,i){n-r<=0&&(logger.warn("Fragment should have a positive duration",t),n=r+t.duration,i=a+t.duration);var s=r,o=n,l=t.startPTS,c=t.endPTS;if(isFiniteNumber(l)){var u=Math.abs(l-r);isFiniteNumber(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,s=Math.max(r,l),r=Math.min(r,l),a=Math.min(a,t.startDTS),o=Math.min(n,c),n=Math.max(n,c),i=Math.max(i,t.endDTS)}var d=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(n-t.start),t.startPTS=r,t.maxStartPTS=s,t.startDTS=a,t.endPTS=n,t.minEndPTS=o,t.endDTS=i;var f,h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;var p=h-e.startSN,y=e.fragments;for(y[p]=t,f=p;f>0;f--)updateFromToPTS(y[f],y[f-1]);for(f=p;f<y.length-1;f++)updateFromToPTS(y[f],y[f+1]);return e.fragmentHint&&updateFromToPTS(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,d}function mergeDetails(e,t){for(var r,n=null,a=e.fragments,i=a.length-1;i>=0;i--){var s=a[i].initSegment;if(s){n=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var o,l=0;mapFragmentIntersection(e,t,(function(e,r){e.relurl&&(l=e.cc-r.cc),isFiniteNumber(e.startPTS)&&isFiniteNumber(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(o=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,n=e.initSegment)}));var c,u=t.fragmentHint?_concatInstanceProperty(r=t.fragments).call(r,t.fragmentHint):t.fragments;if(n&&_forEachInstanceProperty(u).call(u,(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=n)?void 0:t.relurl)||(e.initSegment=n)})),t.skippedSegments)if(t.deltaUpdateFailed=_someInstanceProperty(c=t.fragments).call(c,(function(e){return!e})),t.deltaUpdateFailed){logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=t.skippedSegments;d--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC||(t.startCC=t.fragments[0].cc)}else{var f;t.canSkipDateRanges&&(t.dateRanges=mergeDateRanges(e.dateRanges,t));var h=_filterInstanceProperty(f=e.fragments).call(f,(function(e){return e.rawProgramDateTime}));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var p=1;p<u.length;p++)null===u[p].programDateTime&&assignProgramDateTime(u[p],u[p-1],h);mapDateRanges(h,t)}var y=t.fragments;if(l){logger.warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<y.length;g++)y[g].cc+=l}t.skippedSegments&&(t.startCC=t.fragments[0].cc),mapPartIntersection(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),o?updateFragPTSDTS(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):adjustSliding(e,t),y.length&&(t.totalduration=t.edge-y[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var v=t.advancedDateTime;if(t.advanced&&v){var m=t.edge;t.driftStart||(t.driftStartTime=v,t.driftStart=m),t.driftEndTime=v,t.driftEnd=m}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function mergeDateRanges(e,t){var r=t.dateRanges,n=t.recentlyRemovedDateranges,a=_extends({},e);n&&_forEachInstanceProperty(n).call(n,(function(e){delete a[e]}));var i,s=_Object$keys(a).length;s&&_forEachInstanceProperty(i=_Object$keys(r)).call(i,(function(e){var t=a[e],n=new DateRange(r[e].attr,t);n.isValid?(a[e]=n,t||(n.tagOrder+=s)):logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(_JSON$stringify(r[e].attr),'"'))}));return a}function mapPartIntersection(e,t,r){if(e&&t)for(var n=0,a=0,i=e.length;a<=i;a++){var s=e[a],o=t[a+n];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):n--}}function mapFragmentIntersection(e,t,r){for(var n,a,i=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,o=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,l=t.startSN-e.startSN,c=t.fragmentHint?_concatInstanceProperty(n=t.fragments).call(n,t.fragmentHint):t.fragments,u=e.fragmentHint?_concatInstanceProperty(a=e.fragments).call(a,e.fragmentHint):e.fragments,d=s;d<=o;d++){var f=u[l+d],h=c[d];i&&!h&&f&&(h=t.fragments[d]=f),f&&h&&r(f,h)}}function adjustSliding(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,i=n>=0,s=0;if(i&&n<a.length)s=a[n].start;else if(i&&t.startSN===e.endSN+1)s=e.fragmentEnd;else if(i&&r)s=e.fragmentStart+n*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;s=e.fragmentStart}addSliding(t,s)}function addSliding(e,t){if(t){for(var r=e.fragments,n=e.skippedSegments;n<r.length;n++)r[n].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function computeReloadInterval(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*r>t){var a=1e3*n[n.length-1].duration;a<r&&(r=a)}}else r/=2;return Math.round(r)}function getFragmentWithSN(e,t,r){if(!e)return null;var n=e.fragments[t-e.startSN];return n||((n=e.fragmentHint)&&n.sn===t?n:t<e.startSN&&r&&r.sn===t?r:null)}function getPartWith(e,t,r){return e?findPart(e.partList,t,r):null}function findPart(e,t,r){if(e)for(var n=e.length;n--;){var a=e[n];if(a.index===r&&a.fragment.sn===t)return a}return null}function reassignFragmentLevelIndexes(e){_forEachInstanceProperty(e).call(e,(function(e,t){var r,n=null==(r=e.details)?void 0:r.fragments;n&&_forEachInstanceProperty(n).call(n,(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function findFirstFragWithCC(e,t){for(var r=0,n=e.length;r<n;r++){var a;if((null==(a=e[r])?void 0:a.cc)===t)return e[r]}return null}function shouldAlignOnDiscontinuities(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}function adjustFragmentStart(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function adjustSlidingStart(e,t){for(var r=t.fragments,n=0,a=r.length;n<a;n++)adjustFragmentStart(r[n],e);t.fragmentHint&&adjustFragmentStart(t.fragmentHint,e),t.alignedSliding=!0}function alignStream(e,t){e&&(alignDiscontinuities(t,e),!t.alignedSliding&&e&&alignMediaPlaylistByPDT(t,e),t.alignedSliding||!e||t.skippedSegments||adjustSliding(e,t,!1))}function alignDiscontinuities(e,t){if(shouldAlignOnDiscontinuities(t,e)){var r=Math.min(t.endCC,e.endCC),n=findFirstFragWithCC(t.fragments,r),a=findFirstFragWithCC(e.fragments,r);if(n&&a)logger.log("Aligning playlist at start of dicontinuity sequence ".concat(r)),adjustSlidingStart(n.start-a.start,e)}}function alignMediaPlaylistByPDT(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,n=t.fragments;if(r.length&&n.length){var a,i,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(a=findFirstFragWithCC(n,s),i=findFirstFragWithCC(r,s)),a&&i||(i=findFirstFragWithCC(r,(a=n[Math.floor(n.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=a.programDateTime,l=i.programDateTime;if(o&&l)adjustSlidingStart((l-o)/1e3-(i.start-a.start),e)}}}var TimeRanges={toString:function(e){for(var t="",r=e.length,n=0;n<r;n++){var a;t+=_concatInstanceProperty(a="[".concat(e.start(n).toFixed(3),"-")).call(a,e.end(n).toFixed(3),"]")}return t}},State={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},BaseStreamController=function(e){_inherits(r,TaskLoop);var t=_createSuper(r);function r(e,n,a,i,s){var o;return _classCallCheck$1(this,r),(o=t.call(this,i,e.logger)).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=State.STOPPED,o.playlistType=void 0,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.buffering=!0,o.loadingParts=!1,o.loopSn=void 0,o.onMediaSeeking=function(){var e,t=_assertThisInitialized(o),r=t.config,n=t.fragCurrent,a=t.media,i=t.mediaBuffer,s=t.state,l=a?a.currentTime:0,c=BufferHelper.bufferInfo(i||a,l,r.maxBufferHole);if(o.log(_concatInstanceProperty(e="media seeking to ".concat(isFiniteNumber(l)?l.toFixed(3):l,", state: ")).call(e,s)),o.state===State.ENDED)o.resetLoadingState();else if(n){var u=r.maxFragLookUpTolerance,d=n.start-u,f=n.start+n.duration+u;if(!c.len||f<c.start||d>c.end){var h=l>f;(l<d||h)&&(h&&n.loader&&(o.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),n.abortRequests(),o.resetLoadingState()),o.fragPrevious=null)}}if(a&&(o.fragmentTracker.removeFragmentsInRange(l,1/0,o.playlistType,!0),l>o.lastCurrentTime&&(o.lastCurrentTime=l),!o.loadingParts)){var p,y=Math.max(c.end,l),g=o.shouldLoadParts(o.getLevelDetails(),y);if(g)o.log(_concatInstanceProperty(p="LL-Part loading ON after seeking to ".concat(l.toFixed(2)," with buffer @")).call(p,y.toFixed(2))),o.loadingParts=g}o.hls.hasEnoughToStart||c.len||(o.log("setting startPosition to ".concat(l," because of seek before start")),o.nextLoadPosition=o.startPosition=l),o.tickImmediate()},o.onMediaEnded=function(){o.log("setting startPosition to 0 because media ended"),o.startPosition=o.lastCurrentTime=0,o.triggerEnded()},o.playlistType=s,o.hls=e,o.fragmentLoader=new FragmentLoader(e.config),o.keyLoader=a,o.fragmentTracker=n,o.config=e.config,o.decrypter=new Decrypter(e.config),o}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==State.STOPPED){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=State.STOPPED}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"_streamEnded",value:function(e,t){var r=void 0!==this.config.timelineOffset,n=e.nextStart,a=n&&(!r||n<t.edge);if(t.live||a||!e.end||!this.media)return!1;var i=t.partList;if(null!=i&&i.length){var s=i[i.length-1];return BufferHelper.isBuffered(this.media,s.start+s.duration/2)}var o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}},{key:"getLevelDetails",value:function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details}},{key:"onMediaAttached",value:function(e,t){var r=this.media=this.mediaBuffer=t.media;r.removeEventListener("seeking",this.onMediaSeeking),r.removeEventListener("ended",this.onMediaEnded),r.addEventListener("seeking",this.onMediaSeeking),r.addEventListener("ended",this.onMediaEnded);var n=this.config;this.levels&&n.autoStartLoad&&this.state===State.STOPPED&&this.startLoad(n.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,n=this.media;null!==n&&(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),n.removeEventListener("seeking",this.onMediaSeeking),n.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r?this.resetTransmuxer():(this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()))}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"triggerEnded",value:function(){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=State.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,_get(_getPrototypeOf(r.prototype),"onHandlerDestroyed",this).call(this)}},{key:"loadFragment",value:function(e,t,r){var n=this.hls.config;if(n.interstitialsController&&!1!==n.enableInterstitialPlayback&&e.type!==PlaylistLevelType.SUBTITLE){var a=this.hls.interstitialsManager,i=null==a?void 0:a.bufferingItem;if(i){var s=i.event;if(s){if(s.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return}else{var o;if(e.end<=i.start&&!1===(null==(o=t.details)?void 0:o.live))return;if(e.start>i.end&&i.nextEvent)return}}}this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}},{key:"_loadFragForPlayback",value:function(e,t,r){var n=this;this._doFragLoad(e,t,r,(function(e){var t,r,a,i=e.frag;if(n.fragContextChanged(i))return n.warn(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(a="".concat(i.type," sn: ")).call(a,i.sn)).call(r,e.part?" part: "+e.part.index:""," of ")).call(t,n.fragInfo(i,!1,e.part),") was dropped during download.")),void n.fragmentTracker.removeFragment(i);i.stats.chunkCount++,n._handleFragmentLoadProgress(e)})).then((function(e){if(e){var t=n.state,r=e.frag;if(n.fragContextChanged(r))(t===State.FRAG_LOADING||!n.fragCurrent&&t===State.PARSING)&&(n.fragmentTracker.removeFragment(r),n.state=State.IDLE);else{var a,i,s;if("payload"in e)n.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Loaded ".concat(r.type," sn: ")).call(s,r.sn," of ")).call(i,n.playlistLabel()," ")).call(a,r.level)),n.hls.trigger(Events.FRAG_LOADED,e);n._handleFragmentLoadComplete(e)}}})).catch((function(t){n.state!==State.STOPPED&&n.state!==State.ERROR&&(n.warn("Frag error: ".concat((null==t?void 0:t.message)||t)),n.resetFragmentLoading(e))}))}},{key:"clearTrackerIfNeeded",value:function(e){var t,r=this.fragmentTracker;if(r.getState(e)===FragmentState.APPENDING){var n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),i=Math.max(e.duration,a?a.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(i,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===FragmentState.PARTIAL&&r.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t){if(e-t){var r={startOffset:e,endOffset:t,type:arguments.length>2&&void 0!==arguments[2]?arguments[2]:null};this.hls.trigger(Events.BUFFER_FLUSHING,r)}}},{key:"_loadInitSegment",value:function(e,t){var r=this;this._doFragLoad(e,t).then((function(e){var t=null==e?void 0:e.frag;if(!t||r.fragContextChanged(t)||!r.levels)throw new Error("init load aborted");return e})).then((function(e){var t=r.hls,n=e.frag,a=e.payload,i=n.decryptdata;if(a&&a.byteLength>0&&null!=i&&i.key&&i.iv&&isFullSegmentEncryption(i.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(a),i.key.buffer,i.iv.buffer,getAesModeFromFullSegmentMethod(i.method)).catch((function(e){throw t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:n}),e})).then((function(a){var i=self.performance.now();return t.trigger(Events.FRAG_DECRYPTED,{frag:n,payload:a,stats:{tstart:s,tdecrypt:i}}),e.payload=a,r.completeInitSegmentLoad(e)}))}return r.completeInitSegmentLoad(e)})).catch((function(t){r.state!==State.STOPPED&&r.state!==State.ERROR&&(r.warn(t),r.resetFragmentLoading(e))}))}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==State.STOPPED&&(this.state=State.IDLE),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var r,n,a,i,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="Buffered ".concat(e.type," sn: ")).call(i,e.sn)).call(a,t?" part: "+t.index:""," of ")).call(n,this.fragInfo(e,!1,t)," > buffer:")).call(r,s?TimeRanges.toString(BufferHelper.getBuffered(s)):"(detached)",")")),isMediaFragment(e)){var o;if(e.type!==PlaylistLevelType.SUBTITLE){var l,c=e.elementaryStreams;if(!_someInstanceProperty(l=_Object$keys(c)).call(l,(function(e){return!!c[e]})))return void(this.state=State.IDLE)}var u=null==(o=this.levels)?void 0:o[e.level];null!=u&&u.fragmentError&&(this.log("Resetting level fragment error count of ".concat(u.fragmentError," on frag buffered")),u.fragmentError=0)}this.state=State.IDLE}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var r=e.frag,n=e.part,a=e.partsLoaded,i=!a||0===a.length||_someInstanceProperty(a).call(a,(function(e){return!e})),s=new ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!i);t.flush(s)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t){var r,n,a,i,s,o,l=this,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3?arguments[3]:void 0;this.fragCurrent=e;var d=null==t?void 0:t.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level".concat(d?"":" detail","s"));var f,h,p,y,g=null;!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(e,d.encryptedFragments):(this.log(_concatInstanceProperty(f=_concatInstanceProperty(h=_concatInstanceProperty(p=_concatInstanceProperty(y="Loading key for ".concat(e.sn," of [")).call(y,d.startSN,"-")).call(p,d.endSN,"], ")).call(h,this.playlistLabel()," ")).call(f,e.level)),this.state=State.KEY_LOADING,this.fragCurrent=e,g=this.keyLoader.load(e).then((function(e){if(!l.fragContextChanged(e.frag))return l.hls.trigger(Events.KEY_LOADED,e),l.state===State.KEY_LOADING&&(l.state=State.IDLE),e})),this.hls.trigger(Events.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(g=_Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var v=this.fragPrevious;if(isMediaFragment(e)&&(!v||e.sn!==v.sn)){var m,E,$=this.shouldLoadParts(t.details,e.end);if($!==this.loadingParts)this.log(_concatInstanceProperty(m=_concatInstanceProperty(E="LL-Part loading ".concat($?"ON":"OFF"," loading sn ")).call(E,null==v?void 0:v.sn,"->")).call(m,e.sn)),this.loadingParts=$}if(c=Math.max(e.start,c||0),this.loadingParts&&isMediaFragment(e)){var S=d.partList;if(S&&u){c>e.end&&d.fragmentHint&&(e=d.fragmentHint);var T=this.getNextPart(S,e,c);if(T>-1){var I,_,P,b,A,k,R,C,O,L,D=S[T];return e=this.fragCurrent=D.fragment,this.log(_concatInstanceProperty(I=_concatInstanceProperty(_=_concatInstanceProperty(P=_concatInstanceProperty(b=_concatInstanceProperty(A=_concatInstanceProperty(k=_concatInstanceProperty(R=_concatInstanceProperty(C=_concatInstanceProperty(O="Loading ".concat(e.type," sn: ")).call(O,e.sn," part: ")).call(C,D.index," (")).call(R,T,"/")).call(k,S.length-1,") of ")).call(A,this.fragInfo(e,!1,D),") cc: ")).call(b,e.cc," [")).call(P,d.startSN,"-")).call(_,d.endSN,"], target: ")).call(I,_parseFloat$1(c.toFixed(3)))),this.nextLoadPosition=D.start+D.duration,this.state=State.FRAG_LOADING,L=g?g.then((function(r){return!r||l.fragContextChanged(r.frag)?null:l.doFragPartsLoad(e,D,t,u)})).catch((function(e){return l.handleFragLoadError(e)})):this.doFragPartsLoad(e,D,t,u).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(Events.FRAG_LOADING,{frag:e,part:D,targetBufferTime:c}),null===this.fragCurrent?_Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):L}if(!e.url||this.loadedEndOfParts(S,c))return _Promise.resolve(null)}}if(isMediaFragment(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(c.toFixed(2))),this.loadingParts=!1;else if(!e.url)return _Promise.resolve(null);this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Loading ".concat(e.type," sn: ")).call(s,e.sn," of ")).call(i,this.fragInfo(e,!1),") cc: ")).call(a,e.cc," ")).call(n,d?"["+d.startSN+"-"+d.endSN+"]":"",", target: ")).call(r,_parseFloat$1(c.toFixed(3)))),isFiniteNumber(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=State.FRAG_LOADING;var w,M=this.config.progressive;return w=M&&g?g.then((function(t){return!t||l.fragContextChanged(null==t?void 0:t.frag)?null:l.fragmentLoader.load(e,u)})).catch((function(e){return l.handleFragLoadError(e)})):_Promise.all([this.fragmentLoader.load(e,M?u:void 0),g]).then((function(e){var t=_slicedToArray(e,1)[0];return!M&&t&&u&&u(t),t})).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(Events.FRAG_LOADING,{frag:e,targetBufferTime:c}),null===this.fragCurrent?_Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):w}},{key:"doFragPartsLoad",value:function(e,t,r,n){var a=this;return new _Promise((function(i,s){var o,l=[],c=null==(o=r.details)?void 0:o.partList;!function t(o){a.fragmentLoader.loadPart(e,o,n).then((function(n){l[o.index]=n;var s=n.part;a.hls.trigger(Events.FRAG_LOADED,n);var u=getPartWith(r.details,e.sn,o.index+1)||findPart(c,e.sn,o.index+1);if(!u)return i({frag:e,part:s,partsLoaded:l});t(u)})).catch(s)}(t)}))}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;e.data&&t.details===ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(Events.ERROR,t)}else this.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===State.PARSING){var r=t.frag,n=t.part,a=t.level,i=self.performance.now();r.stats.parsing.end=i,n&&(n.stats.parsing.end=i);var s,o=this.getLevelDetails(),l=o&&r.sn>o.endSN||this.shouldLoadParts(o,r.end);if(l!==this.loadingParts)this.log(_concatInstanceProperty(s="LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @")).call(s,r.end.toFixed(2))),this.loadingParts=l;this.updateLevelTiming(r,n,a,e.partial)}else this.fragCurrent||this.state===State.STOPPED||this.state===State.ERROR||(this.state=State.IDLE)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var r,n,a=e.partList[0];if(t>=a.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0))if((this.hls.hasEnoughToStart?(null==(n=this.media)?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t,r,n=this.levels,a=this.fragCurrent,i=e.level,s=e.sn,o=e.part;if(null==n||!n[i])return this.warn(_concatInstanceProperty(t=_concatInstanceProperty(r="Levels object was unset while buffering fragment ".concat(s," of ")).call(r,this.playlistLabel()," ")).call(t,i,". The current chunk will not be buffered.")),null;var l=n[i],c=l.details,u=o>-1?getPartWith(c,s,o):null,d=u?u.fragment:getFragmentWithSN(c,s,a);return d?(a&&a!==d&&(d.stats=a.stats),{frag:d,part:u,level:l}):null}},{key:"bufferFragmentData",value:function(e,t,r,n,a){var i;if(e&&this.state===State.PARSING){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=appendUint8Array(s,o)),null!=(i=l)&&i.length){var c={type:e.type,frag:t,part:r,chunkMeta:n,parent:t.type,data:l};if(this.hls.trigger(Events.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(BufferHelper.isBuffered(t,t.currentTime)){var r=t.currentTime,n=BufferHelper.bufferInfo(t,r,0),a=e.duration,i=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(e.start-i,n.end-i),r+i);e.start-s>i&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var r,n=this.getLoadPosition();if(!isFiniteNumber(n))return null;var a=this.lastCurrentTime>n||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,r,n){var a=BufferHelper.bufferInfo(e,t,n);if(0===a.len&&void 0!==a.nextStart){var i=this.fragmentTracker.getBufferedFrag(t,r);if(i&&(a.nextStart<=i.end||i.gap))return BufferHelper.bufferInfo(e,t,Math.max(a.nextStart,n))}return a}},{key:"getMaxBufferLength",value:function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)}},{key:"reduceMaxBufferLength",value:function(e,t){var r=this.config,n=Math.max(Math.min(e-t,r.maxBufferLength),t),a=Math.max(e-3*t,r.maxMaxBufferLength/2,n);return a>=n&&(r.maxMaxBufferLength=a,this.warn("Reduce max buffer length to ".concat(a,"s")),!0)}},{key:"getAppendedFrag",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:PlaylistLevelType.MAIN,n=null==(t=this.fragmentTracker)?void 0:t.getAppendedFrag(e,r);return n&&"fragment"in n?n.fragment:n}},{key:"getNextFragment",value:function(e,t){var r=t.fragments,n=r.length;if(!n)return null;var a=this.config,i=r[0].start,s=a.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l,c=a.initialLiveManifestSize;if(n<c)return this.warn(_concatInstanceProperty(l="Not enough fragments to start playback (have: ".concat(n,", need: ")).call(l,c,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<i){var u,d,f,h;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,r);var p=this.hls.startPosition,y=this.hls.liveSyncPosition,g=o?(-1!==p?p:y)||o.start:e;this.log(_concatInstanceProperty(u=_concatInstanceProperty(d=_concatInstanceProperty(f="Setting startPosition to ".concat(g," to match initial live edge. mainStart: ")).call(f,p," liveSyncPosition: ")).call(d,y," frag.start: ")).call(u,null==(h=o)?void 0:h.start)),this.startPosition=this.nextLoadPosition=g}}else e<=i&&(o=r[0]);if(!o){var v=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,v,t)}return this.mapToInitFragWhenRequired(o)}},{key:"isLoopLoading",value:function(e,t){var r=this.fragmentTracker.getState(e);return(r===FragmentState.OK||r===FragmentState.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}},{key:"getNextFragmentLoopLoading",value:function(e,t,r,n,a){var i=null;if(e.gap&&(i=this.getNextFragment(this.nextLoadPosition,t))&&!i.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,n,0);if(null!==s&&r.len+s.len>=a){var o,l=i.sn;if(this.loopSn!==l)this.log(_concatInstanceProperty(o='buffer full after gaps in "'.concat(n,'" playlist starting at sn: ')).call(o,l)),this.loopSn=l;return null}}return this.loopSn=void 0,i}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,r){for(var n=-1,a=!1,i=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(i=i&&!l.independent,n>-1&&r<l.start)break;var c=l.loaded;c?n=-1:(a||l.independent||i)&&l.fragment===t&&(n=s),a=c}return n}},{key:"loadedEndOfParts",value:function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded}},{key:"getInitialLiveFragment",value:function(e,t){var r=this.fragPrevious,n=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime)),n=findFragmentByPDT(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var a=r.sn+1;if(a>=e.startSN&&a<=e.endSN){var i=t[a-e.startSN];r.cc===i.cc&&(n=i,this.log("Live playlist, switching playlist, load frag with next SN: ".concat(n.sn)))}n||(n=findFragWithCC(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(n.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(n=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}},{key:"getFragmentAtPosition",value:function(e,t,r){var n,a,i=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,c=r.fragmentHint,u=i.maxFragLookUpTolerance,d=r.partList,f=!!(this.loadingParts&&null!=d&&d.length&&c);(f&&c&&!this.bitrateTest&&d[d.length-1].fragment.sn===c.sn&&(o=_concatInstanceProperty(o).call(o,c),l=c.sn),e<t)?n=findFragmentByPTS(s,o,e,e<this.lastCurrentTime||e>t-u||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:u):n=o[o.length-1];if(n){var h=n.sn-r.startSN,p=this.fragmentTracker.getState(n);if((p===FragmentState.OK||p===FragmentState.PARTIAL&&n.gap)&&(s=n),s&&n.sn===s.sn&&(!f||d[0].fragment.sn>n.sn||!r.live&&!f))if(s&&n.level===s.level){var y=o[h+1];n=n.sn<l&&this.fragmentTracker.getState(y)!==FragmentState.OK?y:null}}return n}},{key:"alignPlaylists",value:function(e,t,r){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,i=!t,s=e.alignedSliding&&isFiniteNumber(a);if(i||!s&&!a){var o,l,c;alignStream(r,e);var u=e.fragmentStart;return this.log(_concatInstanceProperty(o=_concatInstanceProperty(l=_concatInstanceProperty(c="Live playlist sliding: ".concat(u.toFixed(2)," start-sn: ")).call(c,t?t.startSN:"na","->")).call(l,e.startSN," fragments: ")).call(o,n)),u}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r){var n,a,i=null!==this.startTimeOffset,s=i?this.startTimeOffset:e.startTimeOffset;if(null!==s&&isFiniteNumber(s))r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(_concatInstanceProperty(n=_concatInstanceProperty(a="Setting startPosition to ".concat(r," for start time offset ")).call(a,s," found in ")).call(n,i?"multivariant":"media"," playlist")),this.startPosition=r;else e.live?(r=this.hls.liveSyncPosition||t,this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0);this.lastCurrentTime=r}this.nextLoadPosition=r}},{key:"getLoadPosition",value:function(){var e,t=this.media,r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}},{key:"handleFragLoadAborted",value:function(e,t){var r,n,a;this.transmuxer&&e.type===this.playlistType&&isMediaFragment(e)&&e.stats.aborted&&(this.warn(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="Fragment ".concat(e.sn)).call(a,t?" part "+t.index:""," of ")).call(n,this.playlistLabel()," ")).call(r,e.level," was aborted")),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===State.FRAG_LOADING_WAITING_RETRY)||(this.state=State.IDLE)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var n=t.frag;if(n&&n.type===e&&this.levels)if(this.fragContextChanged(n)){var a,i;this.warn(_concatInstanceProperty(a="Frag load error must match current frag to retry ".concat(n.url," > ")).call(a,null==(i=this.fragCurrent)?void 0:i.url))}else{var s=t.details===ErrorDetails.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(n,!0);var o=t.errorAction,l=o||{},c=l.action,u=_flagsInstanceProperty(l),d=l.retryCount,f=void 0===d?0:d,h=l.retryConfig,p=!!o&&!!h,y=p&&c===NetworkErrorAction.RetryRequest,g=p&&!o.resolved&&u===ErrorActionFlags.MoveAllAlternatesMatchingHost;if(!y&&g&&isMediaFragment(n)&&!n.endList)this.resetFragmentErrors(e),this.treatAsGap(n),o.resolved=!0;else if((y||g)&&f<h.maxNumRetry){var v,m,E,$,S,T;this.resetStartWhenNotLoaded(this.levelLastLoaded);var I=getRetryDelay(h,f);this.warn(_concatInstanceProperty(v=_concatInstanceProperty(m=_concatInstanceProperty(E=_concatInstanceProperty($=_concatInstanceProperty(S=_concatInstanceProperty(T="Fragment ".concat(n.sn," of ")).call(T,e," ")).call(S,n.level," errored with ")).call($,t.details,", retrying loading ")).call(E,f+1,"/")).call(m,h.maxNumRetry," in ")).call(v,I,"ms")),o.resolved=!0,this.retryDate=self.performance.now()+I,this.state=State.FRAG_LOADING_WAITING_RETRY}else if(h&&o){var _;if(this.resetFragmentErrors(e),!(f<h.maxNumRetry))return void this.warn(_concatInstanceProperty(_="".concat(t.details," reached or exceeded max retry (")).call(_,f,")"));s||c===NetworkErrorAction.RemoveAlternatePermanently||(o.resolved=!0)}else c===NetworkErrorAction.SendAlternateToPenaltyBox?this.state=State.WAITING_LEVEL:this.state=State.ERROR;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===State.PARSING||this.state===State.PARSED){var t=e.frag,r=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,r),a=n&&n.len>.5;a&&this.reduceMaxBufferLength(n.len,(null==t?void 0:t.duration)||10);var i=!a;return i&&this.warn("Buffer full error while media.currentTime is not buffered, flush ".concat(r," buffer")),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),i}return!1}},{key:"resetFragmentErrors",value:function(e){e===PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==State.STOPPED&&(this.state=State.IDLE)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var n=BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,r),this.state===State.ENDED&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==State.STOPPED&&(this.state=State.IDLE)}},{key:"resetStartWhenNotLoaded",value:function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){var t,r;this.warn(_concatInstanceProperty(t=_concatInstanceProperty(r="The loading context changed while buffering fragment ".concat(e.sn," of ")).call(r,this.playlistLabel()," ")).call(t,e.level,". This chunk will not be buffered.")),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,r,n){var a,i,s,o,l,c=this,u=r.details;if(u){if(!_reduceInstanceProperty(a=_Object$keys(e.elementaryStreams)).call(a,(function(t,a){var i=e.elementaryStreams[a];if(i){var s,o,l=i.endPTS-i.startPTS;if(l<=0)return c.warn(_concatInstanceProperty(s=_concatInstanceProperty(o="Could not parse fragment ".concat(e.sn," ")).call(o,a," duration reliably (")).call(s,l,")")),t||!1;var d=n?0:updateFragPTSDTS(u,e,i.startPTS,i.endPTS,i.startDTS,i.endDTS);return c.hls.trigger(Events.LEVEL_PTS_UPDATED,{details:u,level:r,drift:d,type:a,frag:e,start:i.startPTS,end:i.endPTS}),!0}return t}),!1)&&null===(null==(l=this.transmuxer)?void 0:l.error)){var d,f,h,p,y=new Error(_concatInstanceProperty(d=_concatInstanceProperty(f="Found no media in fragment ".concat(e.sn," of ")).call(f,this.playlistLabel()," ")).call(d,e.level," resetting transmuxer to fallback to playlist timing"));if(0===r.fragmentError&&this.treatAsGap(e,r),this.warn(y.message),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,error:y,frag:e,reason:_concatInstanceProperty(h=_concatInstanceProperty(p="Found no media in msn ".concat(e.sn," of ")).call(p,this.playlistLabel(),' "')).call(h,r.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=State.PARSED,this.log(_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Parsed ".concat(e.type," sn: ")).call(o,e.sn)).call(s,t?" part: "+t.index:""," of ")).call(i,this.fragInfo(e,!1,t),")")),this.hls.trigger(Events.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===PlaylistLevelType.MAIN?"level":"track"}},{key:"fragInfo",value:function(e){var t,r,n,a,i,s,o,l=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],c=arguments.length>2?arguments[2]:void 0;return _concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="".concat(this.playlistLabel()," ")).call(i,e.level," (")).call(a,c?"part":"frag",":[")).call(n,(null!=(s=l&&!c?e.startPTS:(c||e).start)?s:NaN).toFixed(3),"-")).call(r,(null!=(o=l&&!c?e.endPTS:(c||e).end)?o:NaN).toFixed(3),"]")).call(t,c&&"main"===e.type?"INDEPENDENT="+(c.independent?"YES":"NO"):"")}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t,r=this._state;r!==e&&(this._state=e,this.log(_concatInstanceProperty(t="".concat(r,"->")).call(t,e)))}}]),r}(),ChunkCache=function(){function e(){_classCallCheck$1(this,e),this.chunks=[],this.dataLength=0}return _createClass$1(e,[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:concatUint8Arrays(t,r),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}]),e}();function concatUint8Arrays(e,t){for(var r=new Uint8Array(t),n=0,a=0;a<e.length;a++){var i=e[a];r.set(i,n),n+=i.length}return r}var eventemitter3={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new a(n,i||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}_Object$create&&(n.prototype=_Object$create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(r?_sliceInstanceProperty(n).call(n,1):n);return _Object$getOwnPropertySymbols?_concatInstanceProperty(a).call(a,_Object$getOwnPropertySymbols(e)):a},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,i=n.length,s=new Array(i);a<i;a++)s[a]=n[a].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,a,i,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,c,u=this._events[o],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,a),!0;case 5:return u.fn.call(u.context,t,n,a,i),!0;case 6:return u.fn.call(u.context,t,n,a,i,s),!0}for(c=1,l=new Array(d-1);c<d;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var f,h=u.length;for(c=0;c<h;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),d){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,n);break;case 4:u[c].fn.call(u[c].context,t,n,a);break;default:if(!l)for(f=1,l=new Array(d-1);f<d;f++)l[f-1]=arguments[f];u[c].fn.apply(u[c].context,l)}}return!0},o.prototype.on=function(e,t,r){return i(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return i(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,a){var i=r?r+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var o=this._events[i];if(o.fn)o.fn!==t||a&&!o.once||n&&o.context!==n||s(this,i);else{for(var l=0,c=[],u=o.length;l<u;l++)(o[l].fn!==t||a&&!o[l].once||n&&o[l].context!==n)&&c.push(o[l]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(eventemitter3);var eventemitter3Exports=eventemitter3.exports,EventEmitter=getDefaultExportFromCjs(eventemitter3Exports),version="1.6.0-beta.2",workerStore={};function hasUMDWorker(){return"function"==typeof __HLS_WORKER_BUNDLE__}function injectWorker(){var e=workerStore[version];if(e)return e.clientCount++,e;var t=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(".concat(__HLS_WORKER_BUNDLE__.toString(),")(true);")],{type:"text/javascript"}),r=_URL.createObjectURL(t),n={worker:new self.Worker(r),objectURL:r,clientCount:1};return workerStore[version]=n,n}function loadWorker(e){var t=workerStore[e];if(t)return t.clientCount++,t;var r=new _URL(e,self.location.href).href,n={worker:new self.Worker(r),scriptURL:r,clientCount:1};return workerStore[e]=n,n}function removeWorkerFromStore(e){var t=workerStore[e||version];if(t&&1===t.clientCount--){var r=t.worker,n=t.objectURL;delete workerStore[e||version],n&&_URL.revokeObjectURL(n),r.terminate()}}function isId3Footer(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function isId3Header(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function readId3Size(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]}function getId3Data(e,t){for(var r=t,n=0;isId3Header(e,t);){n+=10,n+=readId3Size(e,t+6),isId3Footer(e,t+10)&&(n+=10),t+=n}if(n>0)return e.subarray(r,r+n)}function getAudioConfig(e,t,r,n){var a,i,s,o,l,c=t[r+2],u=c>>2&15;if(!(u>12)){var d=1+(c>>6&3),f=t[r+3]>>6&3|(1&c)<<2,h="mp4a.40."+d,p=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][u],y=u;5!==d&&29!==d||(y-=3);var g=[d<<3|(14&y)>>1,(1&y)<<7|f<<3];return logger.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="manifest codec:".concat(n,", parsed codec:")).call(l,h,", channels:")).call(o,f,", rate:")).call(s,p," (ADTS object type:")).call(i,d," sampling index:")).call(a,u,")")),{config:g,samplerate:p,channelCount:f,codec:h,parsedCodec:h,manifestCodec:n}}var v=new Error("invalid ADTS sampling index:".concat(u));e.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,error:v,reason:v.message})}function isHeaderPattern$1(e,t){return 255===e[t]&&240==(246&e[t+1])}function getHeaderLength(e,t){return 1&e[t+1]?7:9}function getFullFrameLength(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function canGetFrameLength(e,t){return t+5<e.length}function isHeader$1(e,t){return t+1<e.length&&isHeaderPattern$1(e,t)}function canParse$1(e,t){return canGetFrameLength(e,t)&&isHeaderPattern$1(e,t)&&getFullFrameLength(e,t)<=e.length-t}function probe$1(e,t){if(isHeader$1(e,t)){var r=getHeaderLength(e,t);if(t+r>=e.length)return!1;var n=getFullFrameLength(e,t);if(n<=r)return!1;var a=t+n;return a===e.length||isHeader$1(e,a)}return!1}function initTrackConfig(e,t,r,n,a){if(!e.samplerate){var i=getAudioConfig(t,r,n,a);if(!i)return;_extends(e,i)}}function getFrameDuration(e){return 9216e4/e}function parseFrameHeader(e,t){var r=getHeaderLength(e,t);if(t+r<=e.length){var n=getFullFrameLength(e,t)-r;if(n>0)return{headerLength:r,frameLength:n}}}function appendFrame$2(e,t,r,n,a){var i,s=n+a*getFrameDuration(e.samplerate),o=parseFrameHeader(t,r);if(o){var l=o.frameLength,c=o.headerLength,u=c+l,d=Math.max(0,r+u-t.length);d?(i=new Uint8Array(u-c)).set(t.subarray(r+c,t.length),0):i=t.subarray(r+c,r+u);var f={unit:i,pts:s};return d||e.samples.push(f),{sample:f,length:u,missing:d}}var h=t.length-r;return(i=new Uint8Array(h)).set(t.subarray(r,t.length),0),{sample:{unit:i,pts:s},length:h,missing:-1}}function canParseId3(e,t){return isId3Header(e,t)&&readId3Size(e,t+6)+10<=e.length-t}function decodeId3PrivFrame(e){if(!(e.size<2)){var t=utf8ArrayToStr(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}function decodeId3TextFrame(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=utf8ArrayToStr(e.data.subarray(t),!0);t+=r.length+1;var n=utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:n}}var a=utf8ArrayToStr(e.data.subarray(1));return{key:e.type,info:"",data:a}}}function decodeId3UrlFrame(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=utf8ArrayToStr(e.data.subarray(t),!0);t+=r.length+1;var n=utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:n}}var a=utf8ArrayToStr(e.data);return{key:e.type,info:"",data:a}}function toUint8(e){return view(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,Uint8Array)}function view(e,t,r,n){var a=unsafeGetArrayBuffer(e),i=1;"BYTES_PER_ELEMENT"in n&&(i=n.BYTES_PER_ELEMENT);var s=isArrayBufferView(e)?e.byteOffset:0,o=(s+e.byteLength)/i,l=(s+t)/i,c=Math.floor(Math.max(0,Math.min(l,o)));return new n(a,c,Math.floor(Math.min(c+Math.max(r,0),o))-c)}function unsafeGetArrayBuffer(e){return e instanceof ArrayBuffer?e:e.buffer}function isArrayBufferView(e){return e&&e.buffer instanceof ArrayBuffer&&void 0!==e.byteLength&&void 0!==e.byteOffset}function toArrayBuffer(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function base64encode(e){return btoa(String.fromCharCode.apply(String,_toConsumableArray(e)))}function roundToEven(e,t){if(e<0)return-roundToEven(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<_Number$EPSILON){var n=Math.floor(e*r);return(n%2==0?n:n+1)/r}return Math.round(e*r)/r}function urlToRelativePath(e,t){var r,n,a=new _URL(e),i=new _URL(t);if(a.origin!==i.origin)return e;for(var s=_sliceInstanceProperty(r=a.pathname.split("/")).call(r,1),o=_sliceInstanceProperty(n=i.pathname.split("/")).call(n,1,-1);s[0]===o[0];)s.shift(),o.shift();for(;o.length;)o.shift(),s.unshift("..");return s.join("/")}function uuid(){try{return crypto.randomUUID()}catch(n){try{var e=_URL.createObjectURL(new Blob),t=e.toString();return _URL.revokeObjectURL(e),_sliceInstanceProperty(t).call(t,_lastIndexOfInstanceProperty(t).call(t,"/")+1)}catch(e){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)}))}}}function decodeId3ImageFrame(e){var t,r,n={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var a=_indexOfInstanceProperty(t=e.data.subarray(1)).call(t,0);if(-1!==a){var i=utf8ArrayToStr(toUint8(e.data,1,a)),s=e.data[2+a],o=_indexOfInstanceProperty(r=e.data.subarray(3+a)).call(r,0);if(-1!==o){var l,c=utf8ArrayToStr(toUint8(e.data,3+a,o));return l="--\x3e"===i?utf8ArrayToStr(toUint8(e.data,4+a+o)):toArrayBuffer(e.data.subarray(4+a+o)),n.mimeType=i,n.pictureType=s,n.description=c,n.data=l,n}}}else console.log("Ignore frame with unrecognized character encoding")}function decodeId3Frame(e){return"PRIV"===e.type?decodeId3PrivFrame(e):"W"===e.type[0]?decodeId3UrlFrame(e):"APIC"===e.type?decodeId3ImageFrame(e):decodeId3TextFrame(e)}function getId3FrameData(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=readId3Size(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var HEADER_FOOTER_SIZE=10,FRAME_SIZE=10;function getId3Frames(e){for(var t=0,r=[];isId3Header(e,t);){var n=readId3Size(e,t+6);e[t+5]>>6&1&&(t+=HEADER_FOOTER_SIZE);for(var a=(t+=HEADER_FOOTER_SIZE)+n;t+FRAME_SIZE<a;){var i=getId3FrameData(e.subarray(t)),s=decodeId3Frame(i);s&&r.push(s),t+=i.size+HEADER_FOOTER_SIZE}isId3Footer(e,t)&&(t+=HEADER_FOOTER_SIZE)}return r}function isId3TimestampFrame(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function readId3Timestamp(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,r&&(n+=47721858.84),Math.round(n)}}function getId3Timestamp(e){for(var t=getId3Frames(e),r=0;r<t.length;r++){var n=t[r];if(isId3TimestampFrame(n))return readId3Timestamp(n)}}var MetadataSchema=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function dummyTrack(){return{type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",id:-1,pid:-1,inputTimeScale:arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,sequenceNumber:-1,samples:[],dropped:0}}var BaseAudioDemuxer=function(){function e(){_classCallCheck$1(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}return _createClass$1(e,[{key:"resetInitSegment",value:function(e,t,r,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,r){}},{key:"demux",value:function(e,t){this.cachedData&&(e=appendUint8Array(this.cachedData,e),this.cachedData=null);var r,n=getId3Data(e,0),a=n?n.length:0,i=this._audioTrack,s=this._id3Track,o=n?getId3Timestamp(n):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&isFiniteNumber(o))&&(this.basePTS=initPTSFn(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(e,a)){var c=this.appendFrame(i,e,a);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r=a+=c.length):a=l}else canParseId3(e,a)?(n=getId3Data(e,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),r=a+=n.length):a++;if(a===l&&r!==l){var u=sliceUint8(e,r);this.cachedData?this.cachedData=appendUint8Array(this.cachedData,u):this.cachedData=u}}return{audioTrack:i,videoTrack:dummyTrack(),id3Track:s,textTrack:dummyTrack()}}},{key:"demuxSampleAes",value:function(e,t,r){return _Promise.reject(new Error("[".concat(this,"] This demuxer does not support Sample-AES decryption")))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:dummyTrack(),id3Track:this._id3Track,textTrack:dummyTrack()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),initPTSFn=function(e,t,r){return isFiniteNumber(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},chromeVersion$1=null,BitratesMap=[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],SamplingRateMap=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot=[0,1,1,4];function appendFrame$1(e,t,r,n,a){if(!(r+24>t.length)){var i=parseHeader(t,r);if(i&&r+i.frameLength<=t.length){var s=n+a*(9e4*i.samplesPerFrame/i.sampleRate),o={unit:t.subarray(r,r+i.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=i.channelCount,e.samplerate=i.sampleRate,e.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function parseHeader(e,t){var r=e[t+1]>>3&3,n=e[t+1]>>1&3,a=e[t+2]>>4&15,i=e[t+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==i){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*BitratesMap[14*(3===r?3-n:3===n?3:4)+a-1],c=SamplingRateMap[3*(3===r?0:2===r?1:2)+i],u=3===o?1:2,d=SamplesCoefficients[r][n],f=BytesInSlot[n],h=8*d*f,p=Math.floor(d*l/c+s)*f;if(null===chromeVersion$1){var y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);chromeVersion$1=y?_parseInt$1(y[1]):0}return!!chromeVersion$1&&chromeVersion$1<=87&&2===n&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:u,frameLength:p,samplesPerFrame:h}}}function isHeaderPattern(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function isHeader(e,t){return t+1<e.length&&isHeaderPattern(e,t)}function _canParse(e,t){return isHeaderPattern(e,t)&&4<=e.length-t}function _probe(e,t){if(t+1<e.length&&isHeaderPattern(e,t)){var r=parseHeader(e,t),n=4;null!=r&&r.frameLength&&(n=r.frameLength);var a=t+n;return a===e.length||isHeader(e,a)}return!1}var AACDemuxer=function(e){_inherits(r,BaseAudioDemuxer);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this)).observer=void 0,a.config=void 0,a.observer=e,a.config=n,a}return _createClass$1(r,[{key:"resetInitSegment",value:function(e,t,n,a){_get(_getPrototypeOf(r.prototype),"resetInitSegment",this).call(this,e,t,n,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return canParse$1(e,t)}},{key:"appendFrame",value:function(e,t,r){initTrackConfig(e,this.observer,t,r,e.manifestCodec);var n=appendFrame$2(e,t,r,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}}],[{key:"probe",value:function(e,t){if(!e)return!1;var r=getId3Data(e,0),n=(null==r?void 0:r.length)||0;if(_probe(e,n))return!1;for(var a=e.length;n<a;n++)if(probe$1(e,n))return t.log("ADTS sync word found !"),!0;return!1}}]),r}(),getAudioBSID=function(e,t){var r=0,n=5;t+=n;for(var a=new Uint32Array(1),i=new Uint32Array(1),s=new Uint8Array(1);n>0;){s[0]=e[t];var o=Math.min(n,8),l=8-o;i[0]=4278190080>>>24+l<<l,a[0]=(s[0]&i[0])>>l,r=r?r<<o|a[0]:a[0],t+=1,n-=o}return r},AC3Demuxer=function(e){_inherits(r,BaseAudioDemuxer);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this)).observer=void 0,n.observer=e,n}return _createClass$1(r,[{key:"resetInitSegment",value:function(e,t,n,a){_get(_getPrototypeOf(r.prototype),"resetInitSegment",this).call(this,e,t,n,a),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,r){var n=_appendFrame(e,t,r,this.basePTS,this.frameIndex);if(-1!==n)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=getId3Data(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==getId3Timestamp(t)&&getAudioBSID(e,r)<16}}]),r}();function _appendFrame(e,t,r,n,a){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;var i=t[r+4]>>6;if(i>=3)return-1;var s=[48e3,44100,32e3][i],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+i];if(r+l>t.length)return-1;var c=t[r+6]>>5,u=0;2===c?u+=2:(1&c&&1!==c&&(u+=2),4&c&&(u+=2));var d=(t[r+6]<<8|t[r+7])>>12-u&1,f=[2,1,2,3,3,4,4,5][c]+d,h=t[r+5]>>3,p=7&t[r+5],y=new Uint8Array([i<<6|h<<1|p>>2,(3&p)<<6|c<<3|d<<2|o>>4,o<<4&224]),g=n+a*(1536/s*9e4),v=t.subarray(r,r+l);return e.config=y,e.channelCount=f,e.samplerate=s,e.samples.push({unit:v,pts:g}),l}var MP3Demuxer=function(e){_inherits(r,BaseAudioDemuxer);var t=_createSuper(r);function r(){return _classCallCheck$1(this,r),t.apply(this,arguments)}return _createClass$1(r,[{key:"resetInitSegment",value:function(e,t,n,a){_get(_getPrototypeOf(r.prototype),"resetInitSegment",this).call(this,e,t,n,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return _canParse(e,t)}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return appendFrame$1(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=getId3Data(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==getId3Timestamp(t)&&getAudioBSID(e,r)<=16)return!1;for(var n=e.length;r<n;r++)if(_probe(e,r))return logger.log("MPEG Audio sync word found !"),!0;return!1}}]),r}(),emsgSchemePattern=/\/emsg[-/]ID3/i,MP4Demuxer=function(){function e(t,r){_classCallCheck$1(this,e),this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=r}return _createClass$1(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,n){var a=this.videoTrack=dummyTrack("video",1),i=this.audioTrack=dummyTrack("audio",1),s=this.txtTrack=dummyTrack("text",1);if(this.id3Track=dummyTrack("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=parseInitSegment(e);if(o.video){var l=o.video,c=l.id,u=l.timescale,d=l.codec;a.id=c,a.timescale=s.timescale=u,a.codec=d}if(o.audio){var f=o.audio,h=f.id,p=f.timescale,y=f.codec;i.id=h,i.timescale=p,i.codec=y}s.id=RemuxerTrackIdConfig.text,a.sampleDuration=0,a.duration=i.duration=n}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var r=e,n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=appendUint8Array(this.remainderData,e));var i=segmentValidRange(r);this.remainderData=i.remainder,n.samples=i.valid||new Uint8Array}else n.samples=r;var s=this.extractID3Track(n,t);return a.samples=parseSamples(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(t,this.timeOffset);return r.samples=parseSamples(e,t),{videoTrack:t,audioTrack:dummyTrack(),id3Track:n,textTrack:dummyTrack()}}},{key:"extractID3Track",value:function(e,t){var r=this,n=this.id3Track;if(e.samples.length){var a=findBox(e.samples,["emsg"]);a&&_forEachInstanceProperty(a).call(a,(function(e){var a,i=parseEmsg(e);if(emsgSchemePattern.test(i.schemeIdUri)){var s=getEmsgStartTime(i,t),o=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;o<=.001&&(o=Number.POSITIVE_INFINITY);var l=i.payload;n.samples.push({data:l,len:l.byteLength,dts:s,pts:s,type:MetadataSchema.emsg,duration:o})}else if(r.config.enableEmsgKLVMetadata&&_startsWithInstanceProperty(a=i.schemeIdUri).call(a,"urn:misb:KLV:bin:1910.1")){var c=getEmsgStartTime(i,t);n.samples.push({data:i.payload,len:i.payload.byteLength,dts:c,pts:c,type:MetadataSchema.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return n}},{key:"demuxSampleAes",value:function(e,t,r){return _Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return hasMoofData(e)}}]),e}();function getEmsgStartTime(e,t){return isFiniteNumber(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var SampleAesDecrypter=function(){function e(t,r,n){_classCallCheck$1(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new Decrypter(r,{removePKCS7Padding:!1})}return _createClass$1(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,DecrypterAesMode.cbc)}},{key:"decryptAacSample",value:function(e,t,r){var n,a=this,i=e[t].unit;if(!(i.length<=16)){var s=i.subarray(16,i.length-i.length%16),o=_sliceInstanceProperty(n=s.buffer).call(n,s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(o).then((function(n){var s=new Uint8Array(n);i.set(s,16),a.decrypter.isSync()||a.decryptAacSamples(e,t+1,r)}))}}},{key:"decryptAacSamples",value:function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)r.set(e.subarray(a,a+16),n);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var r=new Uint8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)e.set(r.subarray(n,n+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,r,n,a){var i=this,s=discardEPB(a.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){a.data=i.getAvcDecryptedUnit(s,o),i.decrypter.isSync()||i.decryptAvcSamples(e,t,r+1,n)}))}},{key:"decryptAvcSamples",value:function(e,t,r,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void n();for(var a=e[t].units;!(r>=a.length);r++){var i=a[r];if(!(i.data.length<=48||1!==i.type&&5!==i.type||(this.decryptAvcSample(e,t,r,n,i),this.decrypter.isSync())))return}}}}]),e}(),BaseVideoParser=function(){function e(){_classCallCheck$1(this,e),this.VideoSample=null}return _createClass$1(e,[{key:"createVideoSample",value:function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,r,n=this.VideoSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(t=n)&&t.units){var a=n.units;r=a[a.length-1]}return r}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,n=r.length;if(!n)return void t.dropped++;var a=r[n-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,r){var n,a,i=t.byteLength,s=e.naluState||0,o=s,l=[],c=0,u=-1,d=0;for(-1===s&&(u=0,d=this.getNALuType(t,0),s=0,c=1);c<i;)if(n=t[c++],s)if(1!==s)if(n)if(1===n){if(a=c-s-1,u>=0){var f={data:t.subarray(u,a),type:d};l.push(f)}else{var h=this.getLastNalUnit(e.samples);h&&(o&&c<=4-o&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-o)),a>0&&(h.data=appendUint8Array(h.data,t.subarray(0,a)),h.state=0))}c<i?(u=c,d=this.getNALuType(t,c),s=0):s=-1}else s=0;else s=3;else s=n?0:2;else s=n?0:1;if(u>=0&&s>=0){var p={data:t.subarray(u,i),type:d,state:s};l.push(p)}if(0===l.length){var y=this.getLastNalUnit(e.samples);y&&(y.data=appendUint8Array(y.data,t))}return e.naluState=s,l}}]),e}(),ExpGolomb=function(){function e(t){_classCallCheck$1(this,e),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}return _createClass$1(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");n.set(e.subarray(r,r+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}]),e}(),AvcVideoParser=function(e){_inherits(r,BaseVideoParser);var t=_createSuper(r);function r(){return _classCallCheck$1(this,r),t.apply(this,arguments)}return _createClass$1(r,[{key:"parsePES",value:function(e,t,r,n){var a,i=this,s=this.parseNALu(e,r.data,n),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),_forEachInstanceProperty(s).call(s,(function(n){var s,c;switch(n.type){case 1:var u=!1;a=!0;var d,f=n.data;if(l&&f.length>4){var h=i.readSliceType(f);2!==h&&4!==h&&7!==h&&9!==h||(u=!0)}if(u)null!=(d=o)&&d.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null);o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=u;break;case 5:a=!0,null!=(s=o)&&s.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null),o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,parseSEIMessageFromNALu(n.data,1,r.pts,t.samples);break;case 7:var p,y;a=!0,l=!0;var g=n.data,v=i.readSPS(g);if(!e.sps||e.width!==v.width||e.height!==v.height||(null==(p=e.pixelRatio)?void 0:p[0])!==v.pixelRatio[0]||(null==(y=e.pixelRatio)?void 0:y[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[g];for(var m=g.subarray(1,4),E="avc1.",$=0;$<3;$++){var S=m[$].toString(16);S.length<2&&(S="0"+S),E+=S}e.codec=E}break;case 8:a=!0,e.pps=[n.data];break;case 9:a=!0,e.audFound=!0,null!=(c=o)&&c.frame&&(i.pushAccessUnit(o,e),o=null),o||(o=i.VideoSample=i.createVideoSample(!1,r.pts,r.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(n)})),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new ExpGolomb(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var r=8,n=8,a=0;a<e;a++)0!==n&&(n=(r+t.readEG()+256)%256),r=0===n?r:n}},{key:"readSPS",value:function(e){var t,r,n,a,i,s,o,l,c,u,d,f=new ExpGolomb(e),h=0,p=0,y=0,g=0,v=_bindInstanceProperty(t=f.readUByte).call(t,f),m=_bindInstanceProperty(r=f.readBits).call(r,f),E=_bindInstanceProperty(n=f.readUEG).call(n,f),$=_bindInstanceProperty(a=f.readBoolean).call(a,f),S=_bindInstanceProperty(i=f.skipBits).call(i,f),T=_bindInstanceProperty(s=f.skipEG).call(s,f),I=_bindInstanceProperty(o=f.skipUEG).call(o,f),_=_bindInstanceProperty(l=this.skipScalingList).call(l,this);v();var P=v();if(m(5),S(3),v(),I(),100===P||110===P||122===P||244===P||44===P||83===P||86===P||118===P||128===P){var b=E();if(3===b&&S(1),I(),I(),S(1),$())for(u=3!==b?8:12,d=0;d<u;d++)$()&&_(d<6?16:64,f)}I();var A=E();if(0===A)E();else if(1===A)for(S(1),T(),T(),c=E(),d=0;d<c;d++)T();I(),S(1);var k=E(),R=E(),C=m(1);0===C&&S(1),S(1),$()&&(h=E(),p=E(),y=E(),g=E());var O=[1,1];if($()&&$())switch(v()){case 1:O=[1,1];break;case 2:O=[12,11];break;case 3:O=[10,11];break;case 4:O=[16,11];break;case 5:O=[40,33];break;case 6:O=[24,11];break;case 7:O=[20,11];break;case 8:O=[32,11];break;case 9:O=[80,33];break;case 10:O=[18,11];break;case 11:O=[15,11];break;case 12:O=[64,33];break;case 13:O=[160,99];break;case 14:O=[4,3];break;case 15:O=[3,2];break;case 16:O=[2,1];break;case 255:O=[v()<<8|v(),v()<<8|v()]}return{width:Math.ceil(16*(k+1)-2*h-2*p),height:(2-C)*(R+1)*16-(C?2:4)*(y+g),pixelRatio:O}}}]),r}(),HevcVideoParser=function(e){_inherits(r,BaseVideoParser);var t=_createSuper(r);function r(){var e,n;_classCallCheck$1(this,r);for(var a=arguments.length,i=new Array(a),s=0;s<a;s++)i[s]=arguments[s];return(n=t.call.apply(t,_concatInstanceProperty(e=[this]).call(e,i))).initVPS=null,n}return _createClass$1(r,[{key:"parsePES",value:function(e,t,r,n){var a,i=this,s=this.parseNALu(e,r.data,n),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),_forEachInstanceProperty(s).call(s,(function(n){var s,c;switch(n.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=i.VideoSample=i.createVideoSample(!1,r.pts,r.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var u;if(a=!0,l)null!=(u=o)&&u.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null);o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(s=o)&&s.frame&&!o.key&&(i.pushAccessUnit(o,e),o=i.VideoSample=null),o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,parseSEIMessageFromNALu(n.data,2,r.pts,t.samples);break;case 32:if(a=!0,!e.vps){var d=i.readVPS(n.data);e.params=_objectSpread2({},d),i.initVPS=n.data}e.vps=[n.data];break;case 33:if(a=!0,l=!0,"object"===_typeof$1(e.params)){if(void 0===e.vps||e.vps[0]===i.initVPS||void 0===e.sps||i.matchSPS(e.sps[0],n.data)||(i.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var f=i.readSPS(n.data);for(var h in e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],f.params)e.params[h]=f.params[h]}void 0!==e.vps&&e.vps[0]===i.initVPS&&e.sps.push(n.data)}o||(o=i.VideoSample=i.createVideoSample(!0,r.pts,r.dts)),o.key=!0;break;case 34:if(a=!0,"object"===_typeof$1(e.params)){if(!e.pps){e.pps=[];var p=i.readPPS(n.data);for(var y in p)e.params[y]=p[y]}void 0!==e.vps&&e.vps[0]===i.initVPS&&e.pps.push(n.data)}break;case 35:a=!0,e.audFound=!0,null!=(c=o)&&c.frame&&(i.pushAccessUnit(o,e),o=null),o||(o=i.VideoSample=i.createVideoSample(!1,r.pts,r.dts));break;default:a=!1}o&&a&&o.units.push(n)})),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),r=0,n=0;n<e.byteLength;n++)n>=2&&3===e[n]&&0===e[n-1]&&0===e[n-2]||(t[r]=e[n],r++);return new Uint8Array(t.buffer,0,r)}},{key:"pushAccessUnit",value:function(e,t){_get(_getPrototypeOf(r.prototype),"pushAccessUnit",this).call(this,e,t),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new ExpGolomb(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t,r,n,a,i=new ExpGolomb(this.ebsp2rbsp(e));i.readUByte(),i.readUByte(),i.readBits(4);var s=i.readBits(3);i.readBoolean();for(var o=i.readBits(2),l=i.readBoolean(),c=i.readBits(5),u=i.readUByte(),d=i.readUByte(),f=i.readUByte(),h=i.readUByte(),p=i.readUByte(),y=i.readUByte(),g=i.readUByte(),v=i.readUByte(),m=i.readUByte(),E=i.readUByte(),$=i.readUByte(),S=[],T=[],I=0;I<s;I++)S.push(i.readBoolean()),T.push(i.readBoolean());if(s>0)for(var _=s;_<8;_++)i.readBits(2);for(var P=0;P<s;P++)S[P]&&(i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte(),i.readUByte()),T[P]&&i.readUByte();i.readUEG();var b=i.readUEG();3==b&&i.skipBits(1);var A=i.readUEG(),k=i.readUEG(),R=i.readBoolean(),C=0,O=0,L=0,D=0;R&&(C+=i.readUEG(),O+=i.readUEG(),L+=i.readUEG(),D+=i.readUEG());for(var w=i.readUEG(),M=i.readUEG(),x=i.readUEG(),N=i.readBoolean()?0:s;N<=s;N++)i.skipUEG(),i.skipUEG(),i.skipUEG();if((i.skipUEG(),i.skipUEG(),i.skipUEG(),i.skipUEG(),i.skipUEG(),i.skipUEG(),i.readBoolean())&&i.readBoolean())for(var F=0;F<4;F++)for(var U=0;U<(3===F?2:6);U++){if(i.readBoolean()){var B=Math.min(64,1<<4+(F<<1));F>1&&i.readEG();for(var j=0;j<B;j++)i.readEG()}else i.readUEG()}i.readBoolean(),i.readBoolean(),i.readBoolean()&&(i.readUByte(),i.skipUEG(),i.skipUEG(),i.readBoolean());for(var G=i.readUEG(),H=0,K=0;K<G;K++){var V=!1;if(0!==K&&(V=i.readBoolean()),V){K===G&&i.readUEG(),i.readBoolean(),i.readUEG();for(var W=0,Y=0;Y<=H;Y++){var q=i.readBoolean(),z=!1;q||(z=i.readBoolean()),(q||z)&&W++}H=W}else{var X=i.readUEG(),Q=i.readUEG();H=X+Q;for(var J=0;J<X;J++)i.readUEG(),i.readBoolean();for(var Z=0;Z<Q;Z++)i.readUEG(),i.readBoolean()}}if(i.readBoolean())for(var ee=i.readUEG(),te=0;te<ee;te++){for(var re=0;re<x+4;re++)i.readBits(1);i.readBits(1)}var ne=0,ae=1,ie=1,se=!0,oe=1,le=0;i.readBoolean(),i.readBoolean();var ce=!1;if(i.readBoolean()){if(i.readBoolean()){var ue=i.readUByte();ue>0&&ue<16?(ae=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ue-1],ie=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ue-1]):255===ue&&(ae=i.readBits(16),ie=i.readBits(16))}if(i.readBoolean()&&i.readBoolean(),i.readBoolean())i.readBits(3),i.readBoolean(),i.readBoolean()&&(i.readUByte(),i.readUByte(),i.readUByte());if(i.readBoolean()&&(i.readUEG(),i.readUEG()),i.readBoolean(),i.readBoolean(),i.readBoolean(),(ce=i.readBoolean())&&(C+=i.readUEG(),O+=i.readUEG(),L+=i.readUEG(),D+=i.readUEG()),i.readBoolean())if(oe=i.readBits(32),le=i.readBits(32),i.readBoolean()&&i.readUEG(),i.readBoolean()){var de=i.readBoolean(),fe=i.readBoolean(),he=!1;(de||fe)&&((he=i.readBoolean())&&(i.readUByte(),i.readBits(5),i.readBoolean(),i.readBits(5)),i.readBits(4),i.readBits(4),he&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(var pe=0;pe<=s;pe++){var ye=!1;(se=i.readBoolean())||i.readBoolean()?i.readEG():ye=i.readBoolean();var ge=ye?1:i.readUEG()+1;if(de)for(var ve=0;ve<ge;ve++)i.readUEG(),i.readUEG(),he&&(i.readUEG(),i.readUEG()),i.skipBits(1);if(fe)for(var me=0;me<ge;me++)i.readUEG(),i.readUEG(),he&&(i.readUEG(),i.readUEG()),i.skipBits(1)}}i.readBoolean()&&(i.readBoolean(),i.readBoolean(),i.readBoolean(),ne=i.readUEG())}var Ee=A,$e=k;if(R||ce){var Se=1,Te=1;1===b?Se=Te=2:2==b&&(Se=2),Ee=A-Se*O-Se*C,$e=k-Te*D-Te*L}for(var Ie=o?["A","B","C"][o]:"",_e=u<<24|d<<16|f<<8|h,Pe=0,be=0;be<32;be++)Pe=(Pe|(_e>>be&1)<<31-be)>>>0;var Ae=Pe.toString(16);1===c&&"2"===Ae&&(Ae="6");var ke=l?"H":"L";return{codecString:_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="hvc1.".concat(Ie)).call(a,c,".")).call(n,Ae,".")).call(r,ke)).call(t,$,".B0"),params:{general_tier_flag:l,general_profile_idc:c,general_profile_space:o,general_profile_compatibility_flags:[u,d,f,h],general_constraint_indicator_flags:[p,y,g,v,m,E],general_level_idc:$,bit_depth:w+8,bit_depth_luma_minus8:w,bit_depth_chroma_minus8:M,min_spatial_segmentation_idc:ne,chroma_format_idc:b,frame_rate:{fixed:se,fps:le/oe}},width:Ee,height:$e,pixelRatio:[ae,ie]}}},{key:"readPPS",value:function(e){var t=new ExpGolomb(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var r=t.readBoolean(),n=t.readBoolean(),a=1;return n&&r?a=0:n?a=3:r&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}]),r}(),PACKET_LENGTH=188,TSDemuxer=function(){function e(t,r,n,a){_classCallCheck$1(this,e),this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=r,this.typeSupported=n,this.logger=a,this.videoParser=null}return _createClass$1(e,[{key:"resetInitSegment",value:function(t,r,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=n}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,r){var n,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];a||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,c=this._txtTrack,u=s.pid,d=s.pesData,f=o.pid,h=l.pid,p=o.pesData,y=l.pesData,g=null,v=this.pmtParsed,m=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=appendUint8Array(this.remainderData,t)).length,this.remainderData=null),E<PACKET_LENGTH&&!i)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:c};var $=Math.max(0,e.syncOffset(t));(E-=(E-$)%PACKET_LENGTH)<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var S=0,T=$;T<E;T+=PACKET_LENGTH)if(71===t[T]){var I=!!(64&t[T+1]),_=parsePID(t,T),P=void 0;if((48&t[T+3])>>4>1){if((P=T+5+t[T+4])===T+PACKET_LENGTH)continue}else P=T+4;switch(_){case u:if(I){if(d&&(n=parsePES(d,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new AvcVideoParser;break;case"hevc":this.videoParser=new HevcVideoParser}null!==this.videoParser&&this.videoParser.parsePES(s,c,n,!1)}d={data:[],size:0}}d&&(d.data.push(t.subarray(P,T+PACKET_LENGTH)),d.size+=T+PACKET_LENGTH-P);break;case f:if(I){if(p&&(n=parsePES(p,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n)}p={data:[],size:0}}p&&(p.data.push(t.subarray(P,T+PACKET_LENGTH)),p.size+=T+PACKET_LENGTH-P);break;case h:I&&(y&&(n=parsePES(y,this.logger))&&this.parseID3PES(l,n),y={data:[],size:0}),y&&(y.data.push(t.subarray(P,T+PACKET_LENGTH)),y.size+=T+PACKET_LENGTH-P);break;case 0:I&&(P+=t[P]+1),m=this._pmtId=parsePAT(t,P);break;case m:I&&(P+=t[P]+1);var b,A,k=parsePMT(t,P,this.typeSupported,a,this.observer,this.logger);if((u=k.videoPid)>0&&(s.pid=u,s.segmentCodec=k.segmentVideoCodec),(f=k.audioPid)>0&&(o.pid=f,o.segmentCodec=k.segmentAudioCodec),(h=k.id3Pid)>0&&(l.pid=h),null!==g&&!v)this.logger.warn(_concatInstanceProperty(b=_concatInstanceProperty(A="MPEG-TS PMT found at ".concat(T," after unknown PID '")).call(A,g,"'. Backtracking to sync byte @")).call(b,$," to parse all TS packets.")),g=null,T=$-188;v=this.pmtParsed=!0;break;case 17:case 8191:break;default:g=_}}else S++;S>0&&emitParsingError(this.observer,new Error("Found ".concat(S," TS packet/s that do not start with 0x47")),void 0,this.logger),s.pesData=d,o.pesData=p,l.pesData=y;var R={audioTrack:o,videoTrack:s,id3Track:l,textTrack:c};return i&&this.extractRemainingSamples(R),R}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,r=e.audioTrack,n=e.videoTrack,a=e.id3Track,i=e.textTrack,s=n.pesData,o=r.pesData,l=a.pesData;if(s&&(t=parsePES(s,this.logger))){if(null===this.videoParser)switch(n.segmentCodec){case"avc":this.videoParser=new AvcVideoParser;break;case"hevc":this.videoParser=new HevcVideoParser}null!==this.videoParser&&(this.videoParser.parsePES(n,i,t,!0),n.pesData=null)}else n.pesData=s;if(o&&(t=parsePES(o,this.logger))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t);break;case"ac3":this.parseAC3PES(r,t)}r.pesData=null}else null!=o&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=parsePES(l,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=l}},{key:"demuxSampleAes",value:function(e,t,r){var n=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new SampleAesDecrypter(this.observer,this.config,t);return this.decrypt(n,a)}},{key:"decrypt",value:function(e,t){return new _Promise((function(r){var n=e.audioTrack,a=e.videoTrack;n.samples&&"aac"===n.segmentCodec?t.decryptAacSamples(n.samples,0,(function(){a.samples?t.decryptAvcSamples(a.samples,0,0,(function(){r(e)})):r(e)})):a.samples&&t.decryptAvcSamples(a.samples,0,0,(function(){r(e)}))}))}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var r,n,a,i=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,c=s.sample.unit.byteLength;if(-1===l)o=appendUint8Array(s.sample.unit,o);else{var u=c-l;s.sample.unit.set(o.subarray(0,l),u),e.samples.push(s.sample),i=s.missing}}for(r=i,n=o.length;r<n-1&&!isHeader$1(o,r);r++);if(r!==i){var d,f=r<n-1;if(d=f?"AAC PES did not start with ADTS header,offset:".concat(r):"No ADTS header found in AAC PES",emitParsingError(this.observer,new Error(d),f,this.logger),!f)return}if(initTrackConfig(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!s)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var h=getFrameDuration(e.samplerate);a=s.sample.pts+h}for(var p,y=0;r<n;){if(r+=(p=appendFrame$2(e,o,r,a,y)).length,p.missing){this.aacOverFlow=p;break}for(y++;r<n-1&&!isHeader$1(o,r);r++);}}},{key:"parseMPEGPES",value:function(e,t){var r=t.data,n=r.length,a=0,i=0,s=t.pts;if(void 0!==s)for(;i<n;)if(isHeader(r,i)){var o=appendFrame$1(e,r,i,s,a);if(!o)break;i+=o.length,a++}else i++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var r=t.data,n=t.pts;if(void 0!==n)for(var a,i=r.length,s=0,o=0;o<i&&(a=_appendFrame(e,r,o,n,s++))>0;)o+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var r=_extends({},t,{type:this._videoTrack?MetadataSchema.emsg:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,r){var n=e.syncOffset(t);return n>0&&r.warn("MPEG2-TS detected but first sync word found @ offset ".concat(n)),-1!==n}},{key:"syncOffset",value:function(e){for(var t=e.length,r=Math.min(5*PACKET_LENGTH,t-PACKET_LENGTH)+1,n=0;n<r;){for(var a=!1,i=-1,s=0,o=n;o<t;o+=PACKET_LENGTH){if(71!==e[o]||t-o!==PACKET_LENGTH&&71!==e[o+PACKET_LENGTH]){if(s)return-1;break}if(s++,-1===i&&0!==(i=o)&&(r=Math.min(i+99*PACKET_LENGTH,e.length-PACKET_LENGTH)+1),a||(a=0===parsePID(e,o)),a&&s>1&&(0===i&&s>2||o+PACKET_LENGTH>r))return i}n++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:RemuxerTrackIdConfig[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function parsePID(e,t){return((31&e[t+1])<<8)+e[t+2]}function parsePAT(e,t){return(31&e[t+10])<<8|e[t+11]}function parsePMT(e,t,r,n,a,i){var s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){var l=parsePID(e,t),c=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!n){logEncryptedSamplesFoundInUnencryptedStream("ADTS AAC",i);break}case 15:-1===s.audioPid&&(s.audioPid=l);break;case 21:-1===s.id3Pid&&(s.id3Pid=l);break;case 219:if(!n){logEncryptedSamplesFoundInUnencryptedStream("H.264",i);break}case 27:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="mp3"):i.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){logEncryptedSamplesFoundInUnencryptedStream("AC-3",i);break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="ac3"):i.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&c>0)for(var u=t+5,d=c;d>2;){if(106===e[u])!0!==r.ac3?i.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");var f=e[u+1]+2;u+=f,d-=f}break;case 194:case 135:return emitParsingError(a,new Error("Unsupported EC-3 in M2TS found"),void 0,i),s;case 36:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="hevc",i.log("HEVC in M2TS found"))}t+=c+5}return s}function emitParsingError(e,t,r,n){n.warn("parsing error: ".concat(t.message)),e.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function logEncryptedSamplesFoundInUnencryptedStream(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function parsePES(e,t){var r,n,a,i,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=appendUint8Array(l[0],l[1]),_spliceInstanceProperty(l).call(l,1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((n=(r[4]<<8)+r[5])&&n>e.size-6)return null;var c=r[7];192&c&&(i=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&c?i-(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>54e5&&(t.warn("".concat(Math.round((i-s)/9e4),"s delta between PTS and DTS, align them")),i=s):s=i);var u=(a=r[8])+9;if(e.size<=u)return null;e.size-=u;for(var d=new Uint8Array(e.size),f=0,h=l.length;f<h;f++){var p=(r=l[f]).byteLength;if(u){if(u>p){u-=p;continue}r=r.subarray(u),p-=u,u=0}d.set(r,o),o+=p}return n&&(n-=a+3),{data:d,pts:i,dts:s,len:n}}return null}var AAC=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)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])}}}]),e}(),UINT32_MAX=Math.pow(2,32)-1,MP4=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:n};var a=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]);e.STTS=e.STSC=e.STCO=i,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e){for(var t=8,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];for(var i=n.length,s=i;i--;)t+=n[i].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),i=0,t=8;i<s;i++)o.set(n[i],t),t+=n[i].byteLength;return o}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){r*=t;var n=Math.floor(r/(UINT32_MAX+1)),a=Math.floor(r%(UINT32_MAX+1));return e.box(e.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,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,r))}},{key:"moov",value:function(t){for(var r,n,a=t.length,i=[];a--;)i[a]=e.trak(t[a]);return e.box.apply(null,_concatInstanceProperty(r=_concatInstanceProperty(n=[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)]).call(n,i)).call(r,e.mvex(t)))}},{key:"mvex",value:function(t){for(var r,n=t.length,a=[];n--;)a[n]=e.trex(t[n]);return e.box.apply(null,_concatInstanceProperty(r=[e.types.mvex]).call(r,a))}},{key:"mvhd",value:function(t,r){r*=t;var n=Math.floor(r/(UINT32_MAX+1)),a=Math.floor(r%(UINT32_MAX+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,i)}},{key:"sdtp",value:function(t){var r,n,a=t.samples||[],i=new Uint8Array(4+a.length);for(r=0;r<a.length;r++)n=_flagsInstanceProperty(a[r]),i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,i)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,n,a,i,s,o,l=[],c=[];for(i=0;i<t.sps.length;i++)o=(s=t.sps[i]).byteLength,l.push(o>>>8&255),l.push(255&o),l=_concatInstanceProperty(l).call(l,_sliceInstanceProperty(Array.prototype).call(s));for(i=0;i<t.pps.length;i++)o=(s=t.pps[i]).byteLength,c.push(o>>>8&255),c.push(255&o),c=_concatInstanceProperty(c).call(c,_sliceInstanceProperty(Array.prototype).call(s));var u=e.box(e.types.avcC,new Uint8Array(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=[1,l[3],l[4],l[5],255,224|t.sps.length]).call(a,l)).call(n,[t.pps.length])).call(r,c))),d=t.width,f=t.height,h=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.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,d>>8&255,255&d,f>>8&255,255&f,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]),u,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,p>>24,p>>16&255,p>>8&255,255&p])))}},{key:"esds",value:function(e){var t,r=e.config;return new Uint8Array(_concatInstanceProperty(t=[0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2]).call(t,_toConsumableArray(r),[6,1,2]))}},{key:"audioStsd",value:function(e){var t=e.samplerate;return 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,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):"avc"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.avc1(t)):e.box(e.types.stsd,e.STSD,e.hvc1(t))}},{key:"tkhd",value:function(t){var r=t.id,n=t.duration*t.timescale,a=t.width,i=t.height,s=Math.floor(n/(UINT32_MAX+1)),o=Math.floor(n%(UINT32_MAX+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,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,a>>8&255,255&a,0,0,i>>8&255,255&i,0,0]))}},{key:"traf",value:function(t,r){var n=e.sdtp(t),a=t.id,i=Math.floor(r/(UINT32_MAX+1)),s=Math.floor(r%(UINT32_MAX+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,n.length+16+20+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,r){var n,a,i,s,o,l,c=t.samples||[],u=c.length,d=12+16*u,f=new Uint8Array(d);for(r+=8+d,f.set(["video"===t.type?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n<u;n++)i=(a=c[n]).duration,s=a.size,o=_flagsInstanceProperty(a),l=a.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return e.box(e.types.trun,f)}},{key:"initSegment",value:function(t){e.types||e.init();var r=e.moov(t);return appendUint8Array(e.FTYP,r)}},{key:"hvc1",value:function(t){for(var r=t.params,n=[t.vps,t.sps,t.pps],a=new Uint8Array([1,r.general_profile_space<<6|(r.general_tier_flag?32:0)|r.general_profile_idc,r.general_profile_compatibility_flags[0],r.general_profile_compatibility_flags[1],r.general_profile_compatibility_flags[2],r.general_profile_compatibility_flags[3],r.general_constraint_indicator_flags[0],r.general_constraint_indicator_flags[1],r.general_constraint_indicator_flags[2],r.general_constraint_indicator_flags[3],r.general_constraint_indicator_flags[4],r.general_constraint_indicator_flags[5],r.general_level_idc,240|r.min_spatial_segmentation_idc>>8,255&r.min_spatial_segmentation_idc,252|r.parallelismType,252|r.chroma_format_idc,248|r.bit_depth_luma_minus8,248|r.bit_depth_chroma_minus8,0,_parseInt$1(r.frame_rate.fps),3|r.temporal_id_nested<<2|r.num_temporal_layers<<3|(r.frame_rate.fixed?64:0),n.length]),i=a.length,s=0;s<n.length;s+=1){i+=3;for(var o=0;o<n[s].length;o+=1)i+=2+n[s][o].length}var l=new Uint8Array(i);l.set(a,0),i=a.length;for(var c=n.length-1,u=0;u<n.length;u+=1){l.set(new Uint8Array([32+u|(u===c?128:0),0,n[u].length]),i),i+=3;for(var d=0;d<n[u].length;d+=1)l.set(new Uint8Array([n[u][d].length>>8,255&n[u][d].length]),i),i+=2,l.set(n[u][d],i),i+=n[u][d].length}var f=e.box(e.types.hvcC,l),h=t.width,p=t.height,y=t.pixelRatio[0],g=t.pixelRatio[1];return e.box(e.types.hvc1,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,h>>8&255,255&h,p>>8&255,255&p,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]),f,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([y>>24,y>>16&255,y>>8&255,255&y,g>>24,g>>16&255,g>>8&255,255&g])))}}]),e}();MP4.types=void 0,MP4.HDLR_TYPES=void 0,MP4.STTS=void 0,MP4.STSC=void 0,MP4.STCO=void 0,MP4.STSZ=void 0,MP4.VMHD=void 0,MP4.SMHD=void 0,MP4.STSD=void 0,MP4.FTYP=void 0,MP4.DINF=void 0;var MPEG_TS_CLOCK_FREQ_HZ=9e4;function toTimescaleFromBase(e,t){var r=e*t*(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1);return arguments.length>3&&void 0!==arguments[3]&&arguments[3]?Math.round(r):r}function toTimescaleFromScale(e,t){return toTimescaleFromBase(e,t,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}function toMsFromMpegTsClock(e){return toTimescaleFromBase(e,1e3,1/MPEG_TS_CLOCK_FREQ_HZ,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}function toMpegTsClockFromTimescale(e){return toTimescaleFromBase(e,MPEG_TS_CLOCK_FREQ_HZ,1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1))}var MAX_SILENT_FRAME_DURATION=1e4,AAC_SAMPLES_PER_FRAME=1024,MPEG_AUDIO_SAMPLE_PER_FRAME=1152,AC3_SAMPLES_PER_FRAME=1536,chromeVersion=null,safariWebkitVersion=null,MP4Remuxer=function(){function e(t,r,n,a){if(_classCallCheck$1(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=r,this.typeSupported=n,this.logger=a,this.ISGenerated=!1,null===chromeVersion){var i=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);chromeVersion=i?_parseInt$1(i[1]):0}if(null===safariWebkitVersion){var s=navigator.userAgent.match(/Safari\/(\d+)/i);safariWebkitVersion=s?_parseInt$1(s[1]):0}}return _createClass$1(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,r=e[0].pts,n=_reduceInstanceProperty(e).call(e,(function(e,n){var a=n.pts,i=a-e;return i<-4294967296&&(t=!0,i=(a=normalizePts(a,r))-e),i>0?e:a}),r);return t&&this.logger.debug("PTS rollover detected"),n}},{key:"remux",value:function(e,t,r,n,a,i,s,o){var l,c,u,d,f,h,p=a,y=a,g=e.pid>-1,v=t.pid>-1,m=t.samples.length,E=e.samples.length>0,$=s&&m>0||m>1;if((!g||E)&&(!v||$)||this.ISGenerated||s){if(this.ISGenerated){var S,T,I,_,P=this.videoTrackConfig;(P&&(t.width!==P.width||t.height!==P.height||(null==(S=t.pixelRatio)?void 0:S[0])!==(null==(T=P.pixelRatio)?void 0:T[0])||(null==(I=t.pixelRatio)?void 0:I[1])!==(null==(_=P.pixelRatio)?void 0:_[1]))||!P&&$||null===this.nextAudioPts&&E)&&this.resetInitSegment()}this.ISGenerated||(u=this.generateIS(e,t,a,i));var b,A=this.isVideoContiguous,k=-1;if($&&(k=findKeyframeIndex(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(h=!0,k>0){var R,C;this.logger.warn(_concatInstanceProperty(R="[mp4-remuxer]: Dropped ".concat(k," out of ")).call(R,m," video samples due to a missing keyframe"));var O=this.getVideoStartPts(t.samples);t.samples=_sliceInstanceProperty(C=t.samples).call(C,k),t.dropped+=k,b=y+=(t.samples[0].pts-O)/t.inputTimeScale}else-1===k&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(m," video samples")),h=!1);if(this.ISGenerated){if(E&&$){var L=this.getVideoStartPts(t.samples),D=(normalizePts(e.samples[0].pts,L)-L)/t.inputTimeScale;p+=Math.max(0,D),y+=Math.max(0,-D)}if(E){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,a,i)),c=this.remuxAudio(e,p,this.isAudioContiguous,i,v||$||o===PlaylistLevelType.AUDIO?y:void 0),$){var w=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,a,i)),l=this.remuxVideo(t,y,A,w)}}else $&&(l=this.remuxVideo(t,y,A,0));l&&(l.firstKeyFrame=k,l.independent=-1!==k,l.firstKeyFramePTS=b)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=flushTextTrackMetadataCueSamples(r,a,this._initPTS,this._initDTS)),n.samples.length&&(d=flushTextTrackUserdataCueSamples(n,a,this._initPTS))),{audio:c,video:l,initSegment:u,independent:h,text:d,id3:f}}},{key:"generateIS",value:function(e,t,r,n){var a,i,s,o=e.samples,l=t.samples,c=this.typeSupported,u={},d=this._initPTS,f=!d||n,h="audio/mp4";if(f&&(a=i=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":c.mpeg?(h="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}u.audio={id:"audio",container:h,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&c.mpeg?new Uint8Array(0):MP4.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(s=e.inputTimeScale,d&&s===d.timescale?f=!1:a=i=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,u.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:MP4.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(s=t.inputTimeScale,d&&s===d.timescale)f=!1;else{var p=this.getVideoStartPts(l),y=Math.round(s*r);i=Math.min(i,normalizePts(l[0].dts,p)-y),a=Math.min(a,p-y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(_Object$keys(u).length)return this.ISGenerated=!0,f?(this._initPTS={baseTime:a,timescale:s},this._initDTS={baseTime:i,timescale:s}):a=s=void 0,{tracks:u,initPTS:a,timescale:s}}},{key:"remuxVideo",value:function(e,t,r,n){var a,i,s=e.inputTimeScale,o=e.samples,l=[],c=o.length,u=this._initPTS,d=this.nextAvcDts,f=8,h=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,g=!1;if(!r||null===d){var v=t*s,m=o[0].pts-normalizePts(o[0].dts,o[0].pts);chromeVersion&&null!==d&&Math.abs(v-m-d)<15e3?r=!0:d=v-m}for(var E=u.baseTime*s/u.timescale,$=0;$<c;$++){var S=o[$];S.pts=normalizePts(S.pts-E,d),S.dts=normalizePts(S.dts-E,d),S.dts<o[$>0?$-1:$].dts&&(g=!0)}g&&_sortInstanceProperty(o).call(o,(function(e,t){var r=e.dts-t.dts,n=e.pts-t.pts;return r||n})),a=o[0].dts;var T=(i=o[o.length-1].dts)-a,I=T?Math.round(T/(c-1)):h||e.inputTimeScale/30;if(r){var _=a-d,P=_>I,b=_<-1;if(P||b){var A,k,R,C,O,L;if(P)this.logger.warn(_concatInstanceProperty(A=_concatInstanceProperty(k=_concatInstanceProperty(R="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(R,toMsFromMpegTsClock(_,!0)," ms (")).call(k,_,"dts) hole between fragments detected at ")).call(A,t.toFixed(3)));else this.logger.warn(_concatInstanceProperty(C=_concatInstanceProperty(O=_concatInstanceProperty(L="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(L,toMsFromMpegTsClock(-_,!0)," ms (")).call(O,_,"dts) overlapping between fragments detected at ")).call(C,t.toFixed(3)));if(!b||d>=o[0].pts||chromeVersion){var D,w;a=d;var M=o[0].pts-_;if(P)o[0].dts=a,o[0].pts=M;else for(var x=!0,N=0;N<o.length&&!(o[N].dts>M&&x);N++){var F=o[N].pts;if(o[N].dts-=_,o[N].pts-=_,N<o.length-1){var U=o[N+1].pts;x=U<=o[N].pts==U<=F}}this.logger.log(_concatInstanceProperty(D=_concatInstanceProperty(w="Video: Initial PTS/DTS adjusted: ".concat(toMsFromMpegTsClock(M,!0),"/")).call(w,toMsFromMpegTsClock(a,!0),", delta: ")).call(D,toMsFromMpegTsClock(_,!0)," ms"))}}}for(var B=0,j=0,G=a=Math.max(0,a),H=0;H<c;H++){for(var K=o[H],V=K.units,W=V.length,Y=0,q=0;q<W;q++)Y+=V[q].data.length;j+=Y,B+=W,K.length=Y,K.dts<G?(K.dts=G,G+=I/4|0||1):G=K.dts,p=Math.min(K.pts,p),y=Math.max(K.pts,y)}i=o[c-1].dts;var z,X=j+4*B+8;try{z=new Uint8Array(X)}catch(e){return void this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MUX_ERROR,details:ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:X,reason:"fail allocating video mdat ".concat(X)})}var Q=new DataView(z.buffer);Q.setUint32(0,X),z.set(MP4.types.mdat,4);for(var J=!1,Z=Number.POSITIVE_INFINITY,ee=Number.POSITIVE_INFINITY,te=Number.NEGATIVE_INFINITY,re=Number.NEGATIVE_INFINITY,ne=0;ne<c;ne++){for(var ae=o[ne],ie=ae.units,se=0,oe=0,le=ie.length;oe<le;oe++){var ce=ie[oe],ue=ce.data,de=ce.data.byteLength;Q.setUint32(f,de),f+=4,z.set(ue,f),f+=de,se+=4+de}var fe=void 0;if(ne<c-1)h=o[ne+1].dts-ae.dts,fe=o[ne+1].pts-ae.pts;else{var he=this.config,pe=ne>0?ae.dts-o[ne-1].dts:I;if(fe=ne>0?ae.pts-o[ne-1].pts:I,he.stretchShortVideoTrack&&null!==this.nextAudioPts){var ye,ge=Math.floor(he.maxBufferHole*s),ve=(n?p+n*s:this.nextAudioPts)-ae.pts;if(ve>ge)(h=ve-pe)<0?h=pe:J=!0,this.logger.log(_concatInstanceProperty(ye="[mp4-remuxer]: It is approximately ".concat(ve/90," ms to the next segment; using duration ")).call(ye,h/90," ms for the last video frame."));else h=pe}else h=pe}var me=Math.round(ae.pts-ae.dts);Z=Math.min(Z,h),te=Math.max(te,h),ee=Math.min(ee,fe),re=Math.max(re,fe),l.push(new Mp4Sample(ae.key,h,se,me))}if(l.length)if(chromeVersion){if(chromeVersion<70){var Ee=_flagsInstanceProperty(l[0]);Ee.dependsOn=2,Ee.isNonSync=0}}else if(safariWebkitVersion&&re-ee<te-Z&&I/te<.025&&0===l[0].cts){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var $e=a,Se=0,Te=l.length;Se<Te;Se++){var Ie=$e+l[Se].duration,_e=$e+l[Se].cts;if(Se<Te-1){var Pe=Ie+l[Se+1].cts;l[Se].duration=Pe-_e}else l[Se].duration=Se?l[Se-1].duration:I;l[Se].cts=0,$e=Ie}}h=J||!h?I:h,this.nextAvcDts=d=i+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;var be={data1:MP4.moof(e.sequenceNumber++,a,_extends({},e,{samples:l})),data2:z,startPTS:p/s,endPTS:(y+h)/s,startDTS:a/s,endDTS:d/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,be}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return MPEG_AUDIO_SAMPLE_PER_FRAME;case"ac3":return AC3_SAMPLES_PER_FRAME;default:return AAC_SAMPLES_PER_FRAME}}},{key:"remuxAudio",value:function(e,t,r,n,a){var i=e.inputTimeScale,s=i/(e.samplerate?e.samplerate:i),o=this.getSamplesPerFrame(e),l=o*s,c=this._initPTS,u="mp3"===e.segmentCodec&&this.typeSupported.mpeg,d=[],f=void 0!==a,h=e.samples,p=u?0:8,y=this.nextAudioPts||-1,g=t*i,v=c.baseTime*i/c.timescale;if(this.isAudioContiguous=r=r||h.length&&y>0&&(n&&Math.abs(g-y)<9e3||Math.abs(normalizePts(h[0].pts-v,g)-y)<20*l),_forEachInstanceProperty(h).call(h,(function(e){e.pts=normalizePts(e.pts-v,g)})),!r||y<0){if(!(h=_filterInstanceProperty(h).call(h,(function(e){return e.pts>=0}))).length)return;y=0===a?0:n&&!f?Math.max(0,g):h[0].pts}if("aac"===e.segmentCodec)for(var m=this.config.maxAudioFramesDrift,E=0,$=y;E<h.length;E++){var S,T=h[E],I=T.pts,_=I-$,P=Math.abs(1e3*_/i);if(_<=-m*l&&f){if(0===E)this.logger.warn(_concatInstanceProperty(S="Audio frame @ ".concat((I/i).toFixed(3),"s overlaps nextAudioPts by ")).call(S,Math.round(1e3*_/i)," ms.")),this.nextAudioPts=y=$=I}else if(_>=m*l&&P<MAX_SILENT_FRAME_DURATION&&f){var b,A,k=Math.round(_/l);($=I-k*l)<0&&(k--,$+=l),0===E&&(this.nextAudioPts=y=$),this.logger.warn(_concatInstanceProperty(b=_concatInstanceProperty(A="[mp4-remuxer]: Injecting ".concat(k," audio frame @ ")).call(A,($/i).toFixed(3),"s due to ")).call(b,Math.round(1e3*_/i)," ms gap."));for(var R=0;R<k;R++){var C=Math.max($,0),O=AAC.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);O||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),O=T.unit.subarray()),_spliceInstanceProperty(h).call(h,E,0,{unit:O,pts:C}),$+=l,E++}}T.pts=$,$+=l}for(var L,D=null,w=null,M=0,x=h.length;x--;)M+=h[x].unit.byteLength;for(var N=0,F=h.length;N<F;N++){var U=h[N],B=U.unit,j=U.pts;if(null!==w){d[N-1].duration=Math.round((j-w)/s)}else{if(r&&"aac"===e.segmentCodec&&(j=y),D=j,!(M>0))return;M+=p;try{L=new Uint8Array(M)}catch(e){return void this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MUX_ERROR,details:ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:M,reason:"fail allocating audio mdat ".concat(M)})}u||(new DataView(L.buffer).setUint32(0,M),L.set(MP4.types.mdat,4))}L.set(B,p);var G=B.byteLength;p+=G,d.push(new Mp4Sample(!0,o,G,0)),w=j}var H=d.length;if(H){var K=d[d.length-1];this.nextAudioPts=y=w+s*K.duration;var V=u?new Uint8Array(0):MP4.moof(e.sequenceNumber++,D/s,_extends({},e,{samples:d}));e.samples=[];var W=D/i,Y=y/i,q={data1:V,data2:L,startPTS:W,endPTS:Y,startDTS:W,endDTS:Y,type:"audio",hasAudio:!0,hasVideo:!1,nb:H};return this.isAudioContiguous=!0,q}}}]),e}();function normalizePts(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function findKeyframeIndex(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}function flushTextTrackMetadataCueSamples(e,t,r,n){var a=e.samples.length;if(a){for(var i=e.inputTimeScale,s=0;s<a;s++){var o=e.samples[s];o.pts=normalizePts(o.pts-r.baseTime*i/r.timescale,t*i)/i,o.dts=normalizePts(o.dts-n.baseTime*i/n.timescale,t*i)/i}var l=e.samples;return e.samples=[],{samples:l}}}function flushTextTrackUserdataCueSamples(e,t,r){var n,a=e.samples.length;if(a){for(var i=e.inputTimeScale,s=0;s<a;s++){var o=e.samples[s];o.pts=normalizePts(o.pts-r.baseTime*i/r.timescale,t*i)/i}_sortInstanceProperty(n=e.samples).call(n,(function(e,t){return e.pts-t.pts}));var l=e.samples;return e.samples=[],{samples:l}}}var now2,Mp4Sample=_createClass$1((function e(t,r,n,a){_classCallCheck$1(this,e),this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=r,this.size=n,this.cts=a,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}})),PassThroughRemuxer=function(){function e(t,r,n,a){_classCallCheck$1(this,e),this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=a}return _createClass$1(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.lastEndTime=null}},{key:"resetNextTimestamp",value:function(){this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,r,n){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(patchEncyptionData(e,n)),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var n=this.initData=parseInitSegment(e);n.audio&&(t=getParsedTrackCodec(n.audio,ElementaryStreamTypes.AUDIO)),n.video&&(r=getParsedTrackCodec(n.video,ElementaryStreamTypes.VIDEO));var a={};n.audio&&n.video?a.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:n.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?a.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a}},{key:"remux",value:function(e,t,r,n,a,i){var s,o,l=this.initPTS,c=this.lastEndTime,u={audio:void 0,video:void 0,text:n,id3:r,initSegment:void 0};isFiniteNumber(c)||(c=this.lastEndTime=a||0);var d=t.samples;if(null==d||!d.length)return u;var f={initPTS:void 0,timescale:1},h=this.initData;if(null!=(s=h)&&s.length||(this.generateInitSegment(d),h=this.initData),null==(o=h)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var p=getDuration(d,h),y=getStartDTS(h,d),g=null===y?a:y;if(isInvalidInitPts(l,g,a,p)||f.timescale!==l.timescale&&i){var v,m;if(f.initPTS=g-a,l&&1===l.timescale)this.logger.warn(_concatInstanceProperty(v=_concatInstanceProperty(m="Adjusting initPTS @".concat(a," from ")).call(m,l.baseTime/l.timescale," to ")).call(v,f.initPTS));this.initPTS=l={baseTime:f.initPTS,timescale:1}}var E=e?g-l.baseTime/l.timescale:c,$=E+p;offsetStartDTS(h,d,l.baseTime/l.timescale),p>0?this.lastEndTime=$:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var S=!!h.audio,T=!!h.video,I="";S&&(I+="audio"),T&&(I+="video");var _={data1:d,startPTS:E,startDTS:E,endPTS:$,endDTS:$,type:I,hasAudio:S,hasVideo:T,nb:1,dropped:0};return u.audio="audio"===_.type?_:void 0,u.video="audio"!==_.type?_:void 0,u.initSegment=f,u.id3=flushTextTrackMetadataCueSamples(r,a,l,l),n.samples.length&&(u.text=flushTextTrackUserdataCueSamples(n,a,l)),u}}]),e}();function isInvalidInitPts(e,t,r,n){if(null===e)return!0;var a=Math.max(n,1),i=t-e.baseTime/e.timescale;return Math.abs(i-r)>a}function getParsedTrackCodec(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===ElementaryStreamTypes.AUDIO){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return getCodecCompatibleName(r,!1)}return logger.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"}return logger.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1"}try{var _context261;now2=_bindInstanceProperty(_context261=self.performance.now).call(_context261,self.performance)}catch(e){now2=_Date$now}var muxConfig=[{demux:MP4Demuxer,remux:PassThroughRemuxer},{demux:TSDemuxer,remux:MP4Remuxer},{demux:AACDemuxer,remux:MP4Remuxer},{demux:MP3Demuxer,remux:MP4Remuxer}];_spliceInstanceProperty(muxConfig).call(muxConfig,2,0,{demux:AC3Demuxer,remux:MP4Remuxer});var Transmuxer=function(){function e(t,r,n,a,i,s){_classCallCheck$1(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=r,this.config=n,this.id=i,this.logger=s}return _createClass$1(e,[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,r,n){var a=this,i=r.transmuxing;i.executeStart=now2();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;n&&(this.currentTransmuxState=n);var c=n||o,u=c.contiguous,d=c.discontinuity,f=c.trackSwitch,h=c.accurateTimeOffset,p=c.timeOffset,y=c.initSegmentChange,g=l.audioCodec,v=l.videoCodec,m=l.defaultInitPts,E=l.duration,$=l.initSegmentData,S=getEncryptionType(s,t);if(S&&isFullSegmentEncryption(S.method)){var T=this.getDecrypter(),I=getAesModeFromFullSegmentMethod(S.method);if(!T.isSync())return this.asyncResult=!0,this.decryptionPromise=T.webCryptoDecrypt(s,S.key.buffer,S.iv.buffer,I).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var _=T.softwareDecrypt(s,S.key.buffer,S.iv.buffer,I);if(r.part>-1){var P=T.flush();_=P?P.buffer:P}if(!_)return i.executeEnd=now2(),emptyResult(r);s=new Uint8Array(_)}var b=this.needsProbing(d,f);if(b){var A=this.configureTransmuxer(s);if(A)return this.logger.warn("[transmuxer] ".concat(A.message)),this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,error:A,reason:A.message}),i.executeEnd=now2(),emptyResult(r)}(d||f||y||b)&&this.resetInitSegment($,g,v,E,t),(d||y||b)&&this.resetInitialTimestamp(m),u||this.resetContiguity();var k=this.transmux(s,S,p,h,r);this.asyncResult=isPromise(k);var R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.trackSwitch=!1,i.executeEnd=now2(),k}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=now2();var n=this.decrypter,a=this.currentTransmuxState,i=this.decryptionPromise;if(i)return this.asyncResult=!0,i.then((function(){return t.flush(e)}));var s=[],o=a.timeOffset;if(n){var l=n.flush();l&&s.push(this.push(l.buffer,null,e))}var c=this.demuxer,u=this.remuxer;if(!c||!u){r.executeEnd=now2();var d=[emptyResult(e)];return this.asyncResult?_Promise.resolve(d):d}var f=c.flush(o);return isPromise(f)?(this.asyncResult=!0,f.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,f,e),this.asyncResult?_Promise.resolve(s):s)}},{key:"flushRemux",value:function(e,t,r){var n,a,i,s,o=t.audioTrack,l=t.videoTrack,c=t.id3Track,u=t.textTrack,d=this.currentTransmuxState,f=d.accurateTimeOffset,h=d.timeOffset;this.logger.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="[transmuxer.ts]: Flushed ".concat(this.id," sn: ")).call(s,r.sn)).call(i,r.part>-1?" part: "+r.part:""," of ")).call(a,this.id===PlaylistLevelType.MAIN?"level":"track"," ")).call(n,r.level));var p=this.remuxer.remux(o,l,c,u,h,f,!0,this.id);e.push({remuxResult:p,chunkMeta:r}),r.transmuxing.executeEnd=now2()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,r,n,a){var i=this.demuxer,s=this.remuxer;i&&s&&(i.resetInitSegment(e,t,r,n),s.resetInitSegment(e,t,r,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,r,n,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,n,a):this.transmuxUnencrypted(e,r,n,a)}},{key:"transmuxUnencrypted",value:function(e,t,r,n){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),i=a.audioTrack,s=a.videoTrack,o=a.id3Track,l=a.textTrack;return{remuxResult:this.remuxer.remux(i,s,o,l,t,r,!1,this.id),chunkMeta:n}}},{key:"transmuxSampleAes",value:function(e,t,r,n,a){var i=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:i.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,n,!1,i.id),chunkMeta:a}}))}},{key:"configureTransmuxer",value:function(e){for(var t,r=this.config,n=this.observer,a=this.typeSupported,i=0,s=muxConfig.length;i<s;i++){var o;if(null!=(o=muxConfig[i].demux)&&o.probe(e,this.logger)){t=muxConfig[i];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,c=this.remuxer,u=t.remux,d=t.demux;c&&c instanceof u||(this.remuxer=new u(n,r,a,this.logger)),l&&l instanceof d||(this.demuxer=new d(n,r,a,this.logger),this.probe=d.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new Decrypter(this.config)),e}}]),e}();function getEncryptionType(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}var emptyResult=function(e){return{remuxResult:{},chunkMeta:e}};function isPromise(e){return"then"in e&&e.then instanceof Function}var TransmuxConfig=_createClass$1((function e(t,r,n,a,i){_classCallCheck$1(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=r,this.initSegmentData=n,this.duration=a,this.defaultInitPts=i||null})),TransmuxState=_createClass$1((function e(t,r,n,a,i,s){_classCallCheck$1(this,e),this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=r,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=i,this.initSegmentChange=s})),transmuxerInstanceCount=0,TransmuxerInterface=function(){function e(t,r,n,a){var i=this;_classCallCheck$1(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=transmuxerInstanceCount++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(e){var t=e.data,r=i.hls;if(r&&null!=t&&t.event&&t.instanceNo===i.instanceNo)switch(t.event){case"init":var n,a=null==(n=i.workerContext)?void 0:n.objectURL;a&&_URL.revokeObjectURL(a);break;case"transmuxComplete":i.handleTransmuxComplete(t.data);break;case"flush":i.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=i.frag,t.data.part=i.part,t.data.id=i.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){var t,r;if(i.hls){var n=new Error(_concatInstanceProperty(t=_concatInstanceProperty(r="".concat(e.message," (")).call(r,e.filename,":")).call(t,e.lineno,")"));i.hls.config.enableWorker=!1,i.hls.logger.warn('Error in "'.concat(i.id,'" Web Worker, fallback to inline')),i.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:n})}};var s=t.config;this.hls=t,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var o=function(e,t){(t=t||{}).frag=i.frag||void 0,e===Events.ERROR&&(t.parent=i.id,t.part=i.part,i.error=t.error),i.hls.trigger(e,t)};this.observer=new EventEmitter,this.observer.on(Events.FRAG_DECRYPTED,o),this.observer.on(Events.ERROR,o);var l=getM2TSSupportedAudioTypes(s.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var c=this.hls.logger;if(s.workerPath||hasUMDWorker()){try{var u;if(s.workerPath)c.log(_concatInstanceProperty(u="loading Web Worker ".concat(s.workerPath,' for "')).call(u,r,'"')),this.workerContext=loadWorker(s.workerPath);else c.log('injecting Web Worker for "'.concat(r,'"')),this.workerContext=injectWorker();var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:l,id:r,config:_JSON$stringify(s)})}catch(e){c.warn('Error setting up "'.concat(r,'" Web Worker, fallback to inline'),e),this.terminateWorker(),this.error=null,this.transmuxer=new Transmuxer(this.observer,l,s,"",r,t.logger)}return}}this.transmuxer=new Transmuxer(this.observer,l,s,"",r,t.logger)}return _createClass$1(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=transmuxerInstanceCount++;var t=this.hls.config,r=getM2TSSupportedAudioTypes(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:_JSON$stringify(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),removeWorkerFromStore(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,r,n,a,i,s,o,l,c){var u,d,f=this;l.transmuxing.start=self.performance.now();var h=this.instanceNo,p=this.transmuxer,y=i?i.start:a.start,g=a.decryptdata,v=this.frag,m=!(v&&a.cc===v.cc),E=!(v&&l.level===v.level),$=v?l.sn-v.sn:-1,S=this.part?l.part-this.part.index:-1,T=0===$&&l.id>1&&l.id===(null==v?void 0:v.stats.chunkCount),I=!E&&(1===$||0===$&&(1===S||T&&S<=0)),_=self.performance.now();(E||$||0===a.stats.parsing.start)&&(a.stats.parsing.start=_),!i||!S&&I||(i.stats.parsing.start=_);var P=!(v&&(null==(u=a.initSegment)?void 0:u.url)===(null==(d=v.initSegment)?void 0:d.url)),b=new TransmuxState(m,I,o,E,y,P);if(!I||m||P){var A,k,R,C,O,L,D,w,M,x,N;this.hls.logger.log(_concatInstanceProperty(A=_concatInstanceProperty(k=_concatInstanceProperty(R=_concatInstanceProperty(C=_concatInstanceProperty(O=_concatInstanceProperty(L=_concatInstanceProperty(D=_concatInstanceProperty(w=_concatInstanceProperty(M=_concatInstanceProperty(x=_concatInstanceProperty(N="[transmuxer-interface]: Starting new transmux session for ".concat(a.type," sn: ")).call(N,l.sn)).call(x,l.part>-1?" part: "+l.part:""," ")).call(M,this.id===PlaylistLevelType.MAIN?"level":"track",": ")).call(w,l.level," id: ")).call(D,l.id,"\n discontinuity: ")).call(L,m,"\n trackSwitch: ")).call(O,E,"\n contiguous: ")).call(C,I,"\n accurateTimeOffset: ")).call(R,o,"\n timeOffset: ")).call(k,y,"\n initSegmentChange: ")).call(A,P));var F=new TransmuxConfig(r,n,t,s,c);this.configureTransmuxer(F)}if(this.frag=a,this.part=i,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:e,decryptdata:g,chunkMeta:l,state:b},e instanceof ArrayBuffer?[e]:[]);else if(p){var U=p.push(e,g,l,b);isPromise(U)?U.then((function(e){f.handleTransmuxComplete(e)})).catch((function(e){f.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(U)}}},{key:"flush",value:function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,n=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(n){var a=n.flush(e);isPromise(a)?a.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}}},{key:"transmuxerError",value:function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}},{key:"handleFlushResult",value:function(e,t){var r=this;_forEachInstanceProperty(e).call(e,(function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}]),e}();function subtitleOptionsIdentical(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!mediaAttributesIdentical(e[r].attrs,t[r].attrs))return!1;return!0}function mediaAttributesIdentical(e,t,r){var n,a=e["STABLE-RENDITION-ID"];return a&&!r?a===t["STABLE-RENDITION-ID"]:!_someInstanceProperty(n=r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).call(n,(function(r){return e[r]!==t[r]}))}function subtitleTrackMatchesTextTrack(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var TICK_INTERVAL$2=100,AudioStreamController=function(e){_inherits(r,BaseStreamController);var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e,n,a,"audio-stream-controller",PlaylistLevelType.AUDIO)).mainAnchor=null,i.mainFragLoading=null,i.audioOnly=!1,i.bufferedTrack=null,i.switchingTrack=null,i.trackId=-1,i.waitingData=null,i.mainDetails=null,i.flushing=!1,i.bufferFlushed=!1,i.cachedTrackLoadedData=null,i.registerListeners(),i}return _createClass$1(r,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){_get(_getPrototypeOf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Events.BUFFER_RESET,this.onBufferReset,this),e.on(Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Events.FRAG_LOADING,this.onFragLoading,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(_get(_getPrototypeOf(r.prototype),"unregisterListeners",this).call(this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Events.BUFFER_RESET,this.onBufferReset,this),e.off(Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Events.FRAG_LOADING,this.onFragLoading,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,t){var r=t.frag,n=t.id,a=t.initPTS,i=t.timescale;if(n===PlaylistLevelType.MAIN){var s,o,l=r.cc,c=this.fragCurrent;if(this.initPTS[l]={baseTime:a,timescale:i},this.log(_concatInstanceProperty(s=_concatInstanceProperty(o="InitPTS for cc: ".concat(l," found from main: ")).call(o,a,"/")).call(s,i)),this.mainAnchor=r,this.state===State.WAITING_INIT_PTS){var u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==l)&&(this.nextLoadPosition=this.findSyncFrag(r).start),this.tick()}else!this.hls.hasEnoughToStart&&c&&c.cc!==l?(this.startFragRequested=!1,this.nextLoadPosition=this.findSyncFrag(r).start,c.abortRequests(),this.resetLoadingState()):this.state===State.IDLE&&this.tick()}}},{key:"findSyncFrag",value:function(e){var t=this.getLevelDetails(),r=e.cc;return findNearestWithCC(t,r,e)||t&&findFragWithCC(t.fragments,r)||e}},{key:"startLoad",value:function(e){if(!this.levels)return this.startPosition=e,void(this.state=State.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(TICK_INTERVAL$2),t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @".concat(t.toFixed(3))),e=t,this.state=State.IDLE):this.state=State.WAITING_TRACK,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case State.IDLE:this.doTickIdle();break;case State.WAITING_TRACK:var e=this.levels,t=this.trackId,n=null==e?void 0:e[t],a=null==n?void 0:n.details;if(a&&!this.waitForLive(n)){if(this.waitForCdnTuneIn(a))break;this.state=State.WAITING_INIT_PTS}break;case State.FRAG_LOADING_WAITING_RETRY:var i,s=performance.now(),o=this.retryDate;if(!o||s>=o||null!=(i=this.media)&&i.seeking){var l=this.levels,c=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==l?void 0:l[c])||null),this.state=State.IDLE}break;case State.WAITING_INIT_PTS:var u=this.waitingData;if(u){var d=u.frag,f=u.part,h=u.cache,p=u.complete,y=this.mainAnchor;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.state=State.FRAG_LOADING;var g={frag:d,part:f,payload:h.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(g),p&&_get(_getPrototypeOf(r.prototype),"_handleFragmentLoadComplete",this).call(this,g)}else if(y&&y.cc!==u.frag.cc){var v;this.log(_concatInstanceProperty(v="Waiting fragment cc (".concat(d.cc,") cancelled because video is at cc ")).call(v,y.cc)),this.nextLoadPosition=this.findSyncFrag(y).start,this.clearWaitingFragment()}}else this.state=State.IDLE}this.onTickEnd()}},{key:"clearWaitingFragment",value:function(){var e=this.waitingData;e&&(this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.state!==State.STOPPED&&(this.state=State.IDLE))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),_get(_getPrototypeOf(r.prototype),"resetLoadingState",this).call(this)}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,r=this.levels,n=this.media,a=this.trackId,i=t.config;if(this.buffering&&(n||!this.startFragRequested&&i.startFragPrefetch)&&null!=r&&r[a]){var s=r[a],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=State.WAITING_TRACK,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ElementaryStreamTypes.AUDIO,PlaylistLevelType.AUDIO));var c=this.getFwdBufferInfo(l,PlaylistLevelType.AUDIO);if(null!==c){var u=this.bufferedTrack,d=this.switchingTrack;if(!d&&this._streamEnded(c,o))return t.trigger(Events.BUFFER_EOS,{type:"audio"}),void(this.state=State.ENDED);var f=c.len,h=t.maxBufferLength,p=o.fragments,y=p[0].start,g=this.getLoadPosition(),v=this.flushing?g:c.end;if(d&&n){var m=g;u&&!mediaAttributesIdentical(d.attrs,u.attrs)&&(v=m),o.PTSKnown&&m<y&&(c.end>y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=y+.05)}if(!(f>=h&&!d&&v<p[p.length-1].start)){var E=this.getNextFragment(v,o);if(E&&this.isLoopLoading(E,v)&&(E=this.getNextFragmentLoopLoading(E,o,c,PlaylistLevelType.MAIN,h)),E){var $=null==(e=this.mainFragLoading)?void 0:e.frag;if(!this.audioOnly&&this.startFragRequested&&$&&isMediaFragment($)&&isMediaFragment(E)&&!E.endList&&(!o.live||!this.loadingParts&&v<this.hls.liveSyncPosition)){var S=$;if(E.start>S.end){var T=this.fragmentTracker.getFragAtPos(v,PlaylistLevelType.MAIN);T&&T.end>$.end&&(S=T,this.mainFragLoading={frag:T,targetBufferTime:null})}if(E.start>S.end)return}this.loadFragment(E,s,v)}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,t){this.bufferFlushed=this.flushing=!1,_get(_getPrototypeOf(r.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=_mapInstanceProperty(r).call(r,(function(e){return new Level(e)}))}},{key:"onAudioTrackSwitching",value:function(e,t){var r=!!t.url;this.trackId=t.id;var n=this.fragCurrent;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==State.STOPPED&&(this.setInterval(TICK_INTERVAL$2),this.state=State.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){_get(_getPrototypeOf(r.prototype),"onManifestLoading",this).call(this),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.hls.trigger(Events.AUDIO_TRACK_LOADED,r))}},{key:"onAudioTrackLoaded",value:function(e,t){var r,n,a,i,s,o,l=this.levels,c=t.details,u=t.id,d=this.mainDetails;if(!d||d.expired||c.endCC>d.endCC)return this.cachedTrackLoadedData=t,void(this.state!==State.STOPPED&&(this.state=State.WAITING_TRACK));if(l){this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="Audio track ".concat(u," loaded [")).call(i,c.startSN,",")).call(a,c.endSN,"]")).call(n,c.lastPartSn?_concatInstanceProperty(s="[part-".concat(c.lastPartSn,"-")).call(s,c.lastPartIndex,"]"):"",",duration:")).call(r,c.totalduration));var f=l[u],h=0;if(c.live||null!=(o=f.details)&&o.live){if(this.checkLiveUpdate(c),c.deltaUpdateFailed)return;var p;if(f.details)h=this.alignPlaylists(c,f.details,null==(p=this.levelLastLoaded)?void 0:p.details);c.alignedSliding||(alignDiscontinuities(c,d),c.alignedSliding||alignMediaPlaylistByPDT(c,d),h=c.fragmentStart)}f.details=c,this.levelLastLoaded=f,this.startFragRequested||this.setStartPosition(d,h),this.hls.trigger(Events.AUDIO_TRACK_UPDATED,{details:c,id:u,groupId:t.groupId}),this.state!==State.WAITING_TRACK||this.waitForCdnTuneIn(c)||(this.state=State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level ".concat(u))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,n=e.part,a=e.payload,i=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);var u,d,f=i.defaultAudioCodec||l.audioCodec||"mp4a.40.2",h=this.transmuxer;if(!h)h=this.transmuxer=new TransmuxerInterface(this.hls,PlaylistLevelType.AUDIO,_bindInstanceProperty(u=this._handleTransmuxComplete).call(u,this),_bindInstanceProperty(d=this._handleTransmuxerFlush).call(d,this));var p=this.initPTS[r.cc],y=null==(t=r.initSegment)?void 0:t.data;if(void 0!==p){var g=n?n.index:-1,v=-1!==g,m=new ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,g,v);h.push(a,y,f,"",r,n,c.totalduration,!1,m,p)}else{var E,$,S,T;this.log(_concatInstanceProperty(E=_concatInstanceProperty($=_concatInstanceProperty(S=_concatInstanceProperty(T="Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ")).call(T,r.sn," of [")).call(S,c.startSN," ,")).call($,c.endSN,"],track ")).call(E,s)),(this.waitingData=this.waitingData||{frag:r,part:n,cache:new ChunkCache,complete:!1}).cache.push(new Uint8Array(a)),this.state!==State.STOPPED&&(this.state=State.WAITING_INIT_PTS)}}else this.warn("Audio track is undefined on fragment load progress")}else{var I;this.warn(_concatInstanceProperty(I="Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ")).call(I,r.level," will not be buffered"))}}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:_get(_getPrototypeOf(r.prototype),"_handleFragmentLoadComplete",this).call(this,e)}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===PlaylistLevelType.MAIN&&isMediaFragment(t.frag)&&(this.mainFragLoading=t,this.state===State.IDLE&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,n=t.part;if(r.type===PlaylistLevelType.AUDIO)if(this.fragContextChanged(r)){var a,i,s,o;this.warn(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Fragment ".concat(r.sn)).call(o,n?" p: "+n.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(i,this.state,", audioSwitch: ")).call(a,this.switchingTrack?this.switchingTrack.name:"false"))}else{if(isMediaFragment(r)){this.fragPrevious=r;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(Events.AUDIO_TRACK_SWITCHED,_objectSpread2({},l)))}this.fragBufferedComplete(r,n),this.media&&this.tick()}else this.audioOnly||r.type!==PlaylistLevelType.MAIN||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,t){var n;if(t.fatal)this.state=State.ERROR;else switch(t.details){case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_PARSING_ERROR:case ErrorDetails.FRAG_DECRYPT_ERROR:case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(PlaylistLevelType.AUDIO,t);break;case ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case ErrorDetails.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==State.WAITING_TRACK||(null==(n=t.context)?void 0:n.type)!==PlaylistContextType.AUDIO_TRACK||(this.state=State.IDLE);break;case ErrorDetails.BUFFER_APPEND_ERROR:case ErrorDetails.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===ErrorDetails.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,_get(_getPrototypeOf(r.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case ErrorDetails.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==ElementaryStreamTypes.VIDEO&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==ElementaryStreamTypes.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===State.ENDED&&(this.state=State.IDLE);var n=this.mediaBuffer||this.media;n&&(this.afterBufferFlushed(n,r,PlaylistLevelType.AUDIO),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,r="audio",n=this.hls,a=e.remuxResult,i=e.chunkMeta,s=this.getCurrentContext(i);if(s){var o=s.frag,l=s.part,c=s.level,u=c.details,d=a.audio,f=a.text,h=a.id3,p=a.initSegment;if(!this.fragContextChanged(o)&&u){if(this.state=State.PARSING,this.switchingTrack&&d&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){var y=o.initSegment||o;this._bufferInitSegment(c,p.tracks,y,i),n.trigger(Events.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:r,tracks:p.tracks})}if(d){var g=d.startPTS,v=d.endPTS,m=d.startDTS,E=d.endDTS;l&&(l.elementaryStreams[ElementaryStreamTypes.AUDIO]={startPTS:g,endPTS:v,startDTS:m,endDTS:E}),o.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO,g,v,m,E),this.bufferFragmentData(d,o,l,i)}if(null!=h&&null!=(t=h.samples)&&t.length){var $=_extends({id:r,frag:o,details:u},h);n.trigger(Events.FRAG_PARSING_METADATA,$)}if(f){var S=_extends({id:r,frag:o,details:u},f);n.trigger(Events.FRAG_PARSING_USERDATA,S)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(i)}},{key:"_bufferInitSegment",value:function(e,t,r,n){var a,i;if(this.state===State.PARSING&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var s=t.audio;s.id="audio";var o=e.audioCodec;this.log(_concatInstanceProperty(a=_concatInstanceProperty(i="Init audio buffer, container:".concat(s.container,", codecs[level/parsed]=[")).call(i,o,"/")).call(a,s.codec,"]")),o&&1===o.split(",").length&&(s.levelCodec=o),this.hls.trigger(Events.BUFFER_CODECS,t);var l=s.initSegment;if(null!=l&&l.byteLength){var c={type:"audio",frag:r,part:null,chunkMeta:n,parent:r.type,data:l};this.hls.trigger(Events.BUFFER_APPENDING,c)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,t,n){var a,i=this.fragmentTracker.getState(e);if(this.switchingTrack||i===FragmentState.NOT_LOADED||i===FragmentState.PARTIAL)if(isMediaFragment(e))if(null!=(a=t.details)&&a.live&&!this.initPTS[e.cc]){var s,o;this.log(_concatInstanceProperty(s=_concatInstanceProperty(o="Waiting for video PTS in continuity counter ".concat(e.cc," of live stream before loading audio fragment ")).call(o,e.sn," of level ")).call(s,this.trackId)),this.state=State.WAITING_INIT_PTS;var l=this.mainDetails;l&&l.fragmentStart!==t.details.fragmentStart&&alignMediaPlaylistByPDT(t.details,l)}else _get(_getPrototypeOf(r.prototype),"loadFragment",this).call(this,e,t,n);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){var t=this.media,n=this.bufferedTrack,a=null==n?void 0:n.attrs,i=e.attrs;t&&a&&(a.CHANNELS!==i.CHANNELS||n.name!==e.name||n.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),_get(_getPrototypeOf(r.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Events.AUDIO_TRACK_SWITCHED,_objectSpread2({},e))}}]),r}(),BasePlaylistController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,n,e.logger)).hls=void 0,a.canLoad=!1,a.timer=-1,a.hls=e,a}return _createClass$1(r,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,r){var n=null==t?void 0:t.renditionReports;if(n){for(var a=-1,i=0;i<n.length;i++){var s=n[i],o=void 0;try{o=new _URL(s.URI,t.url).href}catch(e){this.warn("Could not construct new URL for Rendition Report: ".concat(e)),o=s.URI||""}if(o===e){a=i;break}o===e.substring(0,o.length)&&(a=i)}if(-1!==a){var l=n[a],c=_parseInt$1(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),u=_parseInt$1(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var d=Math.min(t.age-t.partTarget,t.targetduration);u>=0&&d>t.partTarget&&(u+=1)}var f=r&&getSkipValue(r);return new HlsUrlParameters(c,u>=0?u:void 0,f)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(e))}return e}},{key:"playlistLoaded",value:function(e,t,r){var n=t.details,a=t.stats,i=self.performance.now(),s=a.loading.first?Math.max(0,i-a.loading.first):0;n.advancedDateTime=_Date$now()-s;var o=this.hls.config.timelineOffset;if(o!==n.appliedTimelineOffset){var l,c=Math.max(o||0,0);n.appliedTimelineOffset=c,_forEachInstanceProperty(l=n.fragments).call(l,(function(e){e.start=e.playlistOffset+c}))}if(n.live||null!=r&&r.live){var u,d="levelInfo"in t?t.levelInfo:t.track;n.reloaded(r),r&&n.fragments.length>0&&mergeDetails(r,n),-1===n.requestScheduled&&(n.requestScheduled=a.loading.start);var f,h=this.hls.mainForwardBufferInfo,p=h?h.end-h.len:0,y=computeReloadInterval(n,1e3*(n.edge-p));if(n.requestScheduled+y<i?n.requestScheduled=i:n.requestScheduled+=y,this.log(_concatInstanceProperty(u="live playlist ".concat(e," ")).call(u,n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),!this.canLoad||!n.live)return;var g=void 0,v=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var m=this.hls.config.lowLatencyMode,E=n.lastPartSn,$=n.endSN,S=n.lastPartIndex,T=E===$;-1!==S?T?(g=$+1,v=m?0:S):(g=E,v=m?S+1:n.maxPartIndex):g=$+1;var I=n.age,_=I+n.ageHeader,P=Math.min(_-n.partTarget,1.5*n.targetduration);if(P>0){if(_>3*n.targetduration)this.log("Playlist last advanced ".concat(I.toFixed(2),"s ago. Omitting segment and part directives.")),g=void 0,v=void 0;else if(null!=r&&r.tuneInGoal&&_-n.partTarget>r.tuneInGoal){var b,A;this.warn(_concatInstanceProperty(b=_concatInstanceProperty(A="CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ")).call(A,P," with playlist age: ")).call(b,n.age)),P=0}else{var k,R,C,O,L=Math.floor(P/n.targetduration);if(g+=L,void 0!==v)v+=Math.round(P%n.targetduration/n.partTarget);this.log(_concatInstanceProperty(k=_concatInstanceProperty(R=_concatInstanceProperty(C=_concatInstanceProperty(O="CDN Tune-in age: ".concat(n.ageHeader,"s last advanced ")).call(O,I.toFixed(2),"s goal: ")).call(C,P," skip sn ")).call(R,L," to part ")).call(k,v))}n.tuneInGoal=P}if(f=this.getDeliveryDirectives(n,t.deliveryDirectives,g,v),m||!T)return n.requestScheduled=i,void this.loadingPlaylist(d,f)}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,t.deliveryDirectives,g,v));f&&void 0!==g&&n.canBlockReload&&(n.requestScheduled=a.loading.first+Math.max(y-2*s,y/2)),this.scheduleLoading(d,f,n)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,r){var n,a=this,i=r||e.details;if(i){var s=self.performance.now(),o=i.requestScheduled;if(s>=o)this.loadingPlaylist(e,t);else{var l=o-s;this.log(_concatInstanceProperty(n="reload live playlist ".concat(e.name||e.bitrate+"bps"," in ")).call(n,Math.round(l)," ms")),this.clearTimer(),this.timer=_setTimeout((function(){return a.loadingPlaylist(e,t)}),l)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,n){var a=getSkipValue(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,n=t.part,a=HlsSkip.No),new HlsUrlParameters(r,n,a)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,n=isTimeoutError(e),a=e.errorAction,i=a||{},s=i.action,o=i.retryCount,l=void 0===o?0:o,c=i.retryConfig,u=!!a&&!!c&&(s===NetworkErrorAction.RetryRequest||!a.resolved&&s===NetworkErrorAction.SendAlternateToPenaltyBox);if(u){var d;if(l>=c.maxNumRetry)return!1;if(n&&null!=(d=e.context)&&d.deliveryDirectives){var f,h;this.warn(_concatInstanceProperty(f=_concatInstanceProperty(h="Retrying playlist loading ".concat(l+1,"/")).call(h,c.maxNumRetry,' after "')).call(f,r,'" without delivery-directives')),this.loadPlaylist()}else{var p,y,g,v=getRetryDelay(c,l);this.clearTimer(),this.timer=_setTimeout((function(){return t.loadPlaylist()}),v),this.warn(_concatInstanceProperty(p=_concatInstanceProperty(y=_concatInstanceProperty(g="Retrying playlist loading ".concat(l+1,"/")).call(g,c.maxNumRetry,' after "')).call(y,r,'" in ')).call(p,v,"ms"))}e.levelRetry=!0,a.resolved=!0}return u}}]),r}(),AudioTrackController=function(e){_inherits(r,BasePlaylistController);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e,"audio-track-controller")).tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.registerListeners(),n}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Events.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,_get(_getPrototypeOf(r.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var r,n,a,i,s,o=t.id,l=t.groupId,c=t.details,u=this.tracksInGroup[o];if(u&&u.groupId===l){var d=u.details;u.details=t.details,this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Audio track ".concat(o,' "')).call(s,u.name,'" lang:')).call(i,u.lang," group:")).call(a,l," loaded [")).call(n,c.startSN,"-")).call(r,c.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,d)}else{var f,h;this.warn(_concatInstanceProperty(f=_concatInstanceProperty(h="Audio track with id:".concat(o," and group:")).call(h,l," not found in active group ")).call(f,null==u?void 0:u.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.audioGroups||null,n=this.groupIds,a=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&_someInstanceProperty(r).call(r,(function(e){return-1===(null==n?void 0:_indexOfInstanceProperty(n).call(n,e))}))){var i,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=_filterInstanceProperty(i=this.tracks).call(i,(function(e){return!r||-1!==_indexOfInstanceProperty(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!_someInstanceProperty(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),_forEachInstanceProperty(o).call(o,(function(e,t){e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.audioPreference;if(!a&&l){var c=findMatchingOption(l,o,audioMatchPredicate);if(c>-1)a=o[c];else{var u=findMatchingOption(l,this.tracks);a=this.tracks[u]}}var d=this.findTrackId(a);-1===d&&a&&(d=this.findTrackId(null));var f={audioTracks:o};this.log(_concatInstanceProperty(s="Updating audio tracks, ".concat(o.length," track(s) found in group(s): ")).call(s,null==r?void 0:r.join(","))),this.hls.trigger(Events.AUDIO_TRACKS_UPDATED,f);var h=this.trackId;if(-1!==d&&-1===h)this.setAudioTrack(d);else if(o.length&&-1===h){var p,y,g=new Error(_concatInstanceProperty(p="No audio track selected for current audio group-ID(s): ".concat(null==(y=this.groupIds)?void 0:y.join(",")," track count: ")).call(p,o.length));this.warn(g.message),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==PlaylistContextType.AUDIO_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===_indexOfInstanceProperty(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){var n=this.currentTrack;if(n&&matchesOption(e,n,audioMatchPredicate))return n;var a=findMatchingOption(e,this.tracksInGroup,audioMatchPredicate);if(a>-1){var i=this.tracksInGroup[a];return this.setAudioTrack(a),i}if(n){var s=t.loadLevel;-1===s&&(s=t.firstAutoLevel);var o=findClosestLevelWithAudioGroup(e,t.levels,r,s,audioMatchPredicate);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=findMatchingOption(e,r);if(l>-1)return r[l]}}}return null}},{key:"setAudioTrack",value:function(e){var t,r,n,a,i=this.tracksInGroup;if(e<0||e>=i.length)this.warn("Invalid audio track id: ".concat(e));else{this.selectDefaultTrack=!1;var s=this.currentTrack,o=i[e],l=o.details&&!o.details.live;if(!(e===this.trackId&&o===s&&l||(this.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="Switching to audio-track ".concat(e,' "')).call(a,o.name,'" lang:')).call(n,o.lang," group:")).call(r,o.groupId," channels:")).call(t,o.channels)),this.trackId=e,this.currentTrack=o,this.hls.trigger(Events.AUDIO_TRACK_SWITCHING,_objectSpread2({},o)),l))){var c=this.switchParams(o.url,null==s?void 0:s.details,o.details);this.loadPlaylist(c)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var n=t[r];if((!this.selectDefaultTrack||n.default)&&(!e||matchesOption(e,n,audioMatchPredicate)))return r}if(e){for(var a=e.name,i=e.lang,s=e.assocLang,o=e.characteristics,l=e.audioCodec,c=e.channels,u=0;u<t.length;u++){if(matchesOption({name:a,lang:i,assocLang:s,characteristics:o,audioCodec:l,channels:c},t[u],audioMatchPredicate))return u}for(var d=0;d<t.length;d++){var f=t[d];if(mediaAttributesIdentical(e.attrs,f.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(var h=0;h<t.length;h++){var p=t[h];if(mediaAttributesIdentical(e.attrs,p.attrs,["LANGUAGE"]))return h}}return-1}},{key:"loadPlaylist",value:function(e){_get(_getPrototypeOf(r.prototype),"loadPlaylist",this).call(this);var t=this.currentTrack;this.shouldLoadPlaylist(t)&&useAlternateAudio(t.url,this.hls)&&this.scheduleLoading(t,e)}},{key:"loadingPlaylist",value:function(e,t){var n,a,i,s,o,l;_get(_getPrototypeOf(r.prototype),"loadingPlaylist",this).call(this,e,t);var c=e.id,u=e.groupId,d=this.getUrlWithDirectives(e.url,t),f=e.details,h=null==f?void 0:f.age;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="Loading audio-track ".concat(c,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,u)).call(i,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,h&&f.live?" age "+h.toFixed(1)+(f.type&&" "+f.type||""):""," ")).call(n,d)),this.hls.trigger(Events.AUDIO_TRACK_LOADING,{url:d,id:c,groupId:u,deliveryDirectives:t||null,track:e})}}]),r}(),BufferOperationQueue=function(){function e(t){_classCallCheck$1(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t}return _createClass$1(e,[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,r){if(null!==this.queues&&null!==this.tracks){var n=this.queues[t];n.push(e),1!==n.length||r||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){var t=this;return new _Promise((function(r){var n={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(n,e)}))}},{key:"prependBlocker",value:function(e){var t=this;return new _Promise((function(r){if(t.queues){var n={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(n)}}))}},{key:"removeBlockers",value:function(){var e;null!==this.queues&&_forEachInstanceProperty(e=[this.queues.video,this.queues.audio,this.queues.audiovideo]).call(e,(function(e){var t,r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),_spliceInstanceProperty(e).call(e,0,1))}))}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){var n;if(r.onError(t),null===this.queues||null===this.tracks)return;var a=null==(n=this.tracks[e])?void 0:n.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e,t,r=this.queues,n=this.tracks;return null===r||null===n?"<destroyed>":_concatInstanceProperty(e=_concatInstanceProperty(t="\n".concat(this.list("video"),"\n")).call(t,this.list("audio"),"\n")).call(e,this.list("audiovideo"),"}")}},{key:"list",value:function(e){var t,r,n,a;return null!=(n=this.queues)&&n[e]||null!=(a=this.tracks)&&a[e]?_concatInstanceProperty(t=_concatInstanceProperty(r="".concat(e,": (")).call(r,this.listSbInfo(e),") ")).call(t,this.listOps(e)):""}},{key:"listSbInfo",value:function(e){var t,r,n,a=null==(n=this.tracks)?void 0:n[e],i=null==a?void 0:a.buffer;return i?_concatInstanceProperty(t=_concatInstanceProperty(r="SourceBuffer".concat(i.updating?" updating":"")).call(r,a.ended?" ended":"")).call(t,a.ending?" ending":""):"none"}},{key:"listOps",value:function(e){var t,r;return(null==(r=this.queues)?void 0:_mapInstanceProperty(t=r[e]).call(t,(function(e){return e.label})).join(", "))||""}}]),e}(),VIDEO_CODEC_PROFILE_REPLACE=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,TRACK_REMOVED_ERROR_NAME="HlsJsTrackRemovedError",HlsJsTrackRemovedError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e)).name=TRACK_REMOVED_ERROR_NAME,n}return _createClass$1(r)}(),BufferController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,"buffer-controller",e.logger)).hls=void 0,a.fragmentTracker=void 0,a.details=null,a._objectUrl=null,a.operationQueue=null,a.bufferCodecEventsTotal=0,a.media=null,a.mediaSource=null,a.lastMpegAudioChunk=null,a.blockedAudioAppend=null,a.lastVideoAppendEnd=0,a.appendSource=void 0,a.transferData=void 0,a.overrides=void 0,a.appendErrors={audio:0,video:0,audiovideo:0},a.tracks={},a.sourceBuffers=[[null,null],[null,null]],a._onEndStreaming=function(e){var t;a.hls&&"open"===(null==(t=a.mediaSource)?void 0:t.readyState)&&a.hls.pauseBuffering()},a._onStartStreaming=function(e){a.hls&&a.hls.resumeBuffering()},a._onMediaSourceOpen=function(e){var t=_assertThisInitialized(a),r=t.media,n=t.mediaSource;e&&a.log("Media source opened"),r&&n&&(r.removeEventListener("emptied",a._onMediaEmptied),a.updateDuration(),a.hls.trigger(Events.MEDIA_ATTACHED,{media:r,mediaSource:n}),n.removeEventListener("sourceopen",a._onMediaSourceOpen),null!==a.mediaSource&&a.checkPendingTracks())},a._onMediaSourceClose=function(){a.log("Media source closed")},a._onMediaSourceEnded=function(){a.log("Media source ended")},a._onMediaEmptied=function(){var e,t=_assertThisInitialized(a),r=t.mediaSrc,n=t._objectUrl;r!==n&&a.error(_concatInstanceProperty(e="Media element src was set while attaching MediaSource (".concat(n," > ")).call(e,r,")"))},a.hls=e,a.fragmentTracker=n,a.appendSource=isManagedMediaSource(_getMediaSource2(e.config.preferManagedMediaSource)),a.initTracks(),a.registerListeners(),a}return _createClass$1(r,[{key:"hasSourceTypes",value:function(){return _Object$keys(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.BUFFER_RESET,this.onBufferReset,this),e.on(Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Events.BUFFER_EOS,this.onBufferEos,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Events.FRAG_PARSED,this.onFragParsed,this),e.on(Events.FRAG_CHANGED,this.onFragChanged,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.BUFFER_RESET,this.onBufferReset,this),e.off(Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Events.BUFFER_EOS,this.onBufferEos,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Events.FRAG_PARSED,this.onFragParsed,this),e.off(Events.FRAG_CHANGED,this.onFragChanged,this),e.off(Events.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var n={};if(this.operationQueue){var a=this.isUpdating();a||this.operationQueue.removeBlockers();var i,s,o=this.isQueued();if(a||o)this.warn(_concatInstanceProperty(i=_concatInstanceProperty(s="Transfering MediaSource with".concat(o?" operations in queue":"")).call(s,a?" updating SourceBuffer(s)":""," ")).call(i,this.operationQueue));this.operationQueue.destroy()}var l,c=this.transferData;!this.sourceBufferCount&&c&&c.mediaSource===r?_extends(n,c.tracks):_forEachInstanceProperty(l=this.sourceBuffers).call(l,(function(t){var r=_slicedToArray(t,1)[0];r&&(n[r]=_extends({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null}));return{media:t,mediaSource:r,tracks:n}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var r,n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log("".concat(n," bufferCodec event(s) expected.")),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media,n=_getMediaSource2(this.appendSource);if(this.transferData=this.overrides=void 0,r&&n){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var i=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(i),a)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=_URL.createObjectURL(i);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&i instanceof o,removeSourceChildren(r),addSource(r,s),r.load()}catch(e){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r,n;this.log(_concatInstanceProperty(t="".concat((null==(r=this.transferData)?void 0:r.mediaSource)===e?"transferred":"created"," media source: ")).call(t,null==(n=e.constructor)?void 0:n.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this,t=this.media,r=this.transferData;if(r&&t){var n=this.tracks,a=r.tracks,i=a?_Object$keys(a):null,s=i?i.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(a&&i&&s){var l,c;if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(_concatInstanceProperty(l=_concatInstanceProperty(c="attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ")).call(c,_JSON$stringify(n,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ")).call(l,_JSON$stringify(a,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!isCompatibleTrackChange(a,n)){var u,d,f;r.mediaSource=null,r.tracks=void 0;var h,p=t.currentTime,y=this.details,g=Math.max(p,(null==y?void 0:y.fragments[0].start)||0);return g-p>1?void this.log(_concatInstanceProperty(h="attachTransferred: waiting for playback to reach new tracks start time ".concat(p," -> ")).call(h,g)):(this.warn(_concatInstanceProperty(u=_concatInstanceProperty(d=_concatInstanceProperty(f='attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(_Object$keys(a),'"->"')).call(f,_Object$keys(n),'") start time: ')).call(d,g," currentTime: ")).call(u,p)),this.onMediaDetaching(Events.MEDIA_DETACHING,{}),this.onMediaAttaching(Events.MEDIA_ATTACHING,r),void(t.currentTime=g))}this.transferData=void 0,_forEachInstanceProperty(i).call(i,(function(t){var r=t,n=a[r];if(n){var i=n.buffer;if(i){var s=e.fragmentTracker,o=n.id;if(s.hasFragments(o)||s.hasParts(o)){var l=BufferHelper.getBuffered(i);s.detectEvictedFragments(r,l,o,null,!0)}var c=sourceBufferNameToIndex(r),u=[r,i];e.sourceBuffers[c]=u,i.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,n)}}})),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var r=this,n=!!t.transferMedia;this.transferData=this.overrides=void 0;var a=this.media,i=this.mediaSource,s=this._objectUrl;if(i){if(this.log("media source ".concat(n?"transferring":"detaching")),n){var o;_forEachInstanceProperty(o=this.sourceBuffers).call(o,(function(e){var t=_slicedToArray(e,1)[0];t&&r.removeBuffer(t)})),this.resetQueue()}else{if(this.mediaSourceOpenOrEnded){var l="open"===i.readyState;try{for(var c=i.sourceBuffers,u=c.length;u--;)l&&c[u].abort(),i.removeSourceBuffer(c[u]);l&&i.endOfStream()}catch(e){this.warn("onMediaDetaching: ".concat(e.message," while calling endOfStream"))}}this.sourceBufferCount&&this.onBufferReset()}i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(i.removeEventListener("startstreaming",this._onStartStreaming),i.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}a&&(a.removeEventListener("emptied",this._onMediaEmptied),n||(s&&_URL.revokeObjectURL(s),this.mediaSrc===s?(a.removeAttribute("src"),this.appendSource&&removeSourceChildren(a),a.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(Events.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){var e,t=this;_forEachInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var r=_slicedToArray(e,1)[0];r&&t.resetBuffer(r)})),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var n;null!=(n=this.mediaSource)&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn("onBufferReset ".concat(e),t)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[sourceBufferNameToIndex(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new BufferOperationQueue(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r,n=this,a=this.tracks,i=_Object$keys(t);this.log(_concatInstanceProperty(r='BUFFER_CODECS: "'.concat(i,'" (current SB count ')).call(r,this.sourceBufferCount,")"));var s,o="audiovideo"in t&&(a.audio||a.video)||a.audiovideo&&("audio"in t||"video"in t),l=!o&&this.sourceBufferCount&&this.media&&_someInstanceProperty(i).call(i,(function(e){return!a[e]}));o||l?this.warn(_concatInstanceProperty(s='Unsupported transition between "'.concat(_Object$keys(a),'" and "')).call(s,i,'" SourceBuffers')):(_forEachInstanceProperty(i).call(i,(function(e){var r,i,s,o=t[e],l=o.id,c=o.codec,u=o.levelCodec,d=o.container,f=o.metadata,h=a[e],p=null==(r=n.transferData)||null==(i=r.tracks)?void 0:i[e],y=null!=p&&p.buffer?p:h,g=(null==y?void 0:y.pendingCodec)||(null==y?void 0:y.codec),v=null==y?void 0:y.levelCodec,m=!y||!!n.hls.config.assetPlayerId;h||(h=a[e]={buffer:void 0,listeners:[],codec:c,container:d,levelCodec:u,metadata:f,id:l});var E,$=pickMostCompleteCodecName(g,v),S=null==$?void 0:$.replace(VIDEO_CODEC_PROFILE_REPLACE,"$1"),T=pickMostCompleteCodecName(c,u),I=null==(s=T)?void 0:s.replace(VIDEO_CODEC_PROFILE_REPLACE,"$1");T&&(S!==I||m)&&("audio"===_sliceInstanceProperty(e).call(e,0,5)&&(T=getCodecCompatibleName(T,n.appendSource)),n.log(_concatInstanceProperty(E="switching codec ".concat(g," to ")).call(E,T)),T!==(h.pendingCodec||h.codec)&&(h.pendingCodec=T),h.container=d,n.appendChangeType(e,d,T))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e,t=this;return _reduceInstanceProperty(e=_Object$keys(this.tracks)).call(e,(function(e,r){var n=t.tracks[r];return e[r]={id:n.id,container:n.container,codec:n.codec,levelCodec:n.levelCodec},e}),{})}},{key:"appendChangeType",value:function(e,t,r){var n,a=this,i=_concatInstanceProperty(n="".concat(t,";codecs=")).call(n,r),s={label:"change-type=".concat(i),execute:function(){var n=a.tracks[e];if(n){var s,o=n.buffer;if(null!=o&&o.changeType)a.log(_concatInstanceProperty(s="changing ".concat(e," sourceBuffer type to ")).call(s,i)),o.changeType(i),n.codec=r,n.container=t}a.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.warn("Failed to change ".concat(e," SourceBuffer type"),t)}};this.append(s,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,r=this,n=e.start,a=n+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(n,PlaylistLevelType.MAIN))?void 0:t.gap))){var i={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>a||null!=t&&t.buffer&&BufferHelper.isBuffered(t.buffer,a)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(a,PlaylistLevelType.MAIN))?void 0:e.gap))&&(r.blockedAudioAppend=null,r.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(e){r.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:i,frag:e},this.append(i,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(e,t){var r=this,n=this.tracks,a=t.data,i=t.type,s=t.parent,o=t.frag,l=t.part,c=t.chunkMeta,u=c.buffering[i],d=o.sn,f=self.performance.now();u.start=f;var h=o.stats.buffering,p=l?l.stats.buffering:null;0===h.start&&(h.start=f),p&&0===p.start&&(p.start=f);var y=n.audio,g=!1;"audio"===i&&"audio/mpeg"===(null==y?void 0:y.container)&&(g=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var v=this.tracks.video,m=null==v?void 0:v.buffer;if(m&&"initSegment"!==d){var E=l||o,$=this.blockedAudioAppend;if("audio"!==i||"main"===s||this.blockedAudioAppend){if("video"===i){var S=E.end;if($){var T=$.frag.start;(S>T||S<this.lastVideoAppendEnd||BufferHelper.isBuffered(m,T))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var I=E.start+.05*E.duration,_=m.buffered,P=this.currentOp("video");_.length||P?!P&&!BufferHelper.isBuffered(m,I)&&this.lastVideoAppendEnd<I&&this.blockAudio(E):this.blockAudio(E)}}var b=(l||o).start,A={label:"append-".concat(i),execute:function(){if(u.executeStart=self.performance.now(),g){var e=r.tracks[i];if(e){var t=e.buffer;if(t){var n,s,o=b-t.timestampOffset;if(Math.abs(o)>=.1)r.log(_concatInstanceProperty(n=_concatInstanceProperty(s="Updating audio SourceBuffer timestampOffset to ".concat(b," (delta: ")).call(s,o,") sn: ")).call(n,d,")")),t.timestampOffset=b}}}r.appendExecutor(a,i)},onStart:function(){},onComplete:function(){var e,t=self.performance.now();u.executeEnd=u.end=t,0===h.first&&(h.first=t),p&&0===p.first&&(p.first=t);var n={};_forEachInstanceProperty(e=r.sourceBuffers).call(e,(function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1];r&&(n[r]=BufferHelper.getBuffered(a))})),r.appendErrors[i]=0,"audio"===i||"video"===i?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(Events.BUFFER_APPENDED,{type:i,frag:o,part:l,chunkMeta:c,parent:o.type,timeRanges:n})},onError:function(e){var t,n={type:ErrorTypes.MEDIA_ERROR,parent:o.type,details:ErrorDetails.BUFFER_APPEND_ERROR,sourceBufferName:i,frag:o,part:l,chunkMeta:c,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)n.details=ErrorDetails.BUFFER_FULL_ERROR;else if(e.code!==DOMException.INVALID_STATE_ERR||!r.mediaSourceOpenOrEnded||null!=(t=r.media)&&t.error)if(e.name===TRACK_REMOVED_ERROR_NAME)0===r.sourceBufferCount?n.errorAction=createDoNothingErrorAction(!0):++r.appendErrors[i];else{var a,s,u=++r.appendErrors[i];r.warn(_concatInstanceProperty(a=_concatInstanceProperty(s="Failed ".concat(u,"/")).call(s,r.hls.config.appendErrorMaxRetry,' times to append segment in "')).call(a,i,'" sourceBuffer')),u>=r.hls.config.appendErrorMaxRetry&&(n.fatal=!0)}else n.errorAction=createDoNothingErrorAction(!0);r.hls.trigger(Events.ERROR,n)}};this.append(A,i,this.isPending(this.tracks[i]))}},{key:"getFlushOp",value:function(e,t,r){var n,a,i=this;return this.log(_concatInstanceProperty(n=_concatInstanceProperty(a='queuing "'.concat(e,'" remove ')).call(a,t,"-")).call(n,r)),{label:"remove",execute:function(){i.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){i.hls.trigger(Events.BUFFER_FLUSHED,{type:e})},onError:function(n){var a,s;i.warn(_concatInstanceProperty(a=_concatInstanceProperty(s="Failed to remove ".concat(t,"-")).call(s,r,' from "')).call(a,e,'" SourceBuffer'),n)}}}},{key:"onBufferFlushing",value:function(e,t){var r,n=this,a=t.type,i=t.startOffset,s=t.endOffset;a?this.append(this.getFlushOp(a,i,s),a):_forEachInstanceProperty(r=this.sourceBuffers).call(r,(function(e){var t=_slicedToArray(e,1)[0];t&&n.append(n.getFlushOp(t,i,s),t)}))}},{key:"onFragParsed",value:function(e,t){var r=this,n=t.frag,a=t.part,i=[],s=a?a.elementaryStreams:n.elementaryStreams;s[ElementaryStreamTypes.AUDIOVIDEO]?i.push("audiovideo"):(s[ElementaryStreamTypes.AUDIO]&&i.push("audio"),s[ElementaryStreamTypes.VIDEO]&&i.push("video"));var o,l;0===i.length&&this.warn(_concatInstanceProperty(o=_concatInstanceProperty(l="Fragments must have at least one ElementaryStreamType set. type: ".concat(n.type," level: ")).call(l,n.level," sn: ")).call(o,n.sn));this.blockBuffers((function(){var e=self.performance.now();n.stats.buffering.end=e,a&&(a.stats.buffering.end=e);var t=a?a.stats:n.stats;r.hls.trigger(Events.FRAG_BUFFERED,{frag:n,part:a,stats:t,id:n.type})}),i)}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var e,t=this;return this.sourceBufferCount>0&&!_someInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var r,n,a=_slicedToArray(e,1)[0];return a&&(!(null!=(r=t.tracks[a])&&r.ended)||(null==(n=t.tracks[a])?void 0:n.ending))}))}},{key:"onBufferEos",value:function(e,t){var r,n,a,i=this;_forEachInstanceProperty(r=this.sourceBuffers).call(r,(function(e){var r=_slicedToArray(e,1)[0];if(r){var n=i.tracks[r];t.type&&t.type!==r||(n.ending=!0,n.ended||(n.ended=!0,i.log("".concat(r," buffer reached EOS"))))}}));var s=!1!==(null==(a=this.overrides)?void 0:a.endOfStream);this.sourceBufferCount>0&&!_someInstanceProperty(n=this.sourceBuffers).call(n,(function(e){var t,r=_slicedToArray(e,1)[0];return r&&!(null!=(t=i.tracks[r])&&t.ended)}))&&(this.log("Queueing EOS"),this.blockUntilOpen((function(){var e;if(_forEachInstanceProperty(e=i.sourceBuffers).call(e,(function(e){var t=_slicedToArray(e,1)[0];if(null!==t){var r=i.tracks[t];r&&(r.ending=!1)}})),s){var t=i.mediaSource;if(!t||"open"!==t.readyState)return void(t&&i.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(t.readyState)));i.log("Calling mediaSource.endOfStream()"),t.endOfStream()}i.hls.trigger(Events.BUFFERED_TO_END,void 0)})))}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.updateDuration())}},{key:"updateDuration",value:function(){var e=this,t=this.getDurationAndRange();t&&this.blockUntilOpen((function(){return e.updateMediaSource(t)}))}},{key:"onError",value:function(e,t){if(t.details===ErrorDetails.BUFFER_APPEND_ERROR&&t.frag){var r,n=null==(r=t.errorAction)?void 0:r.nextAutoLevel;isFiniteNumber(n)&&n!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.sourceBufferCount){var n=e.config,a=r.currentTime,i=t.levelTargetDuration,s=t.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(isFiniteNumber(s)&&s>=0){var o=Math.max(s,i),l=Math.floor(a/i)*i-o;this.flushBackBuffer(a,i,l)}if(isFiniteNumber(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){var c=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(c,i),d=Math.floor(a/i)*i+u;this.flushFrontBuffer(a,i,d)}}}},{key:"flushBackBuffer",value:function(e,t,r){var n,a=this;_forEachInstanceProperty(n=this.sourceBuffers).call(n,(function(n){var i=_slicedToArray(n,2),s=i[0],o=i[1];if(o){var l=BufferHelper.getBuffered(o);if(l.length>0&&r>l.start(0)){var c;a.hls.trigger(Events.BACK_BUFFER_REACHED,{bufferEnd:r});var u=a.tracks[s];if(null!=(c=a.details)&&c.live)a.hls.trigger(Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=u&&u.ended&&l.end(l.length-1)-e<2*t)return void a.log("Cannot flush ".concat(s," back buffer while SourceBuffer is in ended state"));a.hls.trigger(Events.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}},{key:"flushFrontBuffer",value:function(e,t,r){var n,a=this;_forEachInstanceProperty(n=this.sourceBuffers).call(n,(function(n){var i=_slicedToArray(n,2),s=i[0],o=i[1];if(o){var l=BufferHelper.getBuffered(o),c=l.length;if(c<2)return;var u=l.start(c-1),d=l.end(c-1),f=a.tracks[s];if(r>u||e>=u&&e<=d)return;if(null!=f&&f.ended&&e-d<2*t)return void a.log("Cannot flush ".concat(s," front buffer while SourceBuffer is in ended state"));a.hls.trigger(Events.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:s})}}))}},{key:"getDurationAndRange",value:function(){var e,t=this.details,r=this.mediaSource;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;var n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(r.duration=1/0,t.fragments.length&&t.live&&r.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,n)}}return{duration:1/0}}var i=null==(e=this.overrides)?void 0:e.duration;if(i)return{duration:i};var s=this.media.duration;return n>(isFiniteNumber(r.duration)?r.duration:0)&&n>s||!isFiniteNumber(s)?{duration:n}:null}},{key:"updateMediaSource",value:function(e){var t,r,n=e.duration,a=e.start,i=e.end,s=this.mediaSource;this.media&&s&&"open"===s.readyState&&(s.duration!==n&&(isFiniteNumber(n)&&this.log("Updating MediaSource duration to ".concat(n.toFixed(3))),s.duration=n),void 0!==a&&void 0!==i&&(this.log(_concatInstanceProperty(t=_concatInstanceProperty(r="MediaSource duration is set to ".concat(s.duration,". Setting seekable range to ")).call(r,a,"-")).call(t,i,".")),s.setLiveSeekableRange(a,i)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e,t,r=this.bufferCodecEventsTotal,n=this.pendingTrackCount,a=this.tracks;if(this.log(_concatInstanceProperty(e=_concatInstanceProperty(t="checkPendingTracks (pending: ".concat(n," codec events expected: ")).call(t,r,") ")).call(e,_JSON$stringify(a))),this.tracksReady){var i,s=null==(i=this.transferData)?void 0:i.tracks;s&&_Object$keys(s).length?this.attachTransferred():(this.createSourceBuffers(),this.bufferCreated())}}},{key:"bufferCreated",value:function(){var e=this;if(this.sourceBufferCount){var t,r,n={};_forEachInstanceProperty(t=this.sourceBuffers).call(t,(function(t){var r=_slicedToArray(t,2),a=r[0],i=r[1];if(a){var s=e.tracks[a];n[a]={buffer:i,container:s.container,codec:s.codec,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}})),this.hls.trigger(Events.BUFFER_CREATED,{tracks:n}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),_forEachInstanceProperty(r=this.sourceBuffers).call(r,(function(t){var r=_slicedToArray(t,1)[0];e.executeNext(r)}))}else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,r=this.mediaSource;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(var n in e){var a=n,i=e[a];if(this.isPending(i)){var s,o,l,c=this.getTrackCodec(i,a),u=_concatInstanceProperty(s="".concat(i.container,";codecs=")).call(s,c);i.codec=c,this.log(_concatInstanceProperty(o=_concatInstanceProperty(l="creating sourceBuffer(".concat(u,")")).call(l,this.currentOp(a)?" Queued":""," ")).call(o,_JSON$stringify(i)));try{var d=r.addSourceBuffer(u),f=sourceBufferNameToIndex(a),h=[a,d];t[f]=h,i.buffer=d}catch(e){this.error("error while trying to add sourceBuffer: ".concat(e.message)),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:u});break}this.trackSourceBuffer(a,i)}}}},{key:"getTrackCodec",value:function(e,t){var r=pickMostCompleteCodecName(e.codec,e.levelCodec);return r?"audio"===_sliceInstanceProperty(t).call(t,0,5)?getCodecCompatibleName(r,this.appendSource):r:""}},{key:"trackSourceBuffer",value:function(e,t){var r=this,n=t.buffer;if(n){var a=this.getTrackCodec(t,e);this.tracks[e]={buffer:n,codec:a,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id,listeners:[]},this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(function(e,t){var n=t.removedRanges;null!=n&&n.length&&r.hls.trigger(Events.BUFFER_FLUSHED,{type:e})}))}}},{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var r,n,a=new Error(_concatInstanceProperty(r="".concat(e," SourceBuffer error. MediaSource readyState: ")).call(r,null==(n=this.mediaSource)?void 0:n.readyState));this.error("".concat(a),t),this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:a,fatal:!1});var i=this.currentOp(e);i&&i.onError(a)}},{key:"removeExecutor",value:function(e,t,r){var n=this.media,a=this.mediaSource,i=this.tracks[e],s=null==i?void 0:i.buffer;if(!n||!a||!s)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var o,l,c=isFiniteNumber(n.duration)?n.duration:1/0,u=isFiniteNumber(a.duration)?a.duration:1/0,d=Math.max(0,t),f=Math.min(r,c,u);f>d&&(!i.ending||i.ended)?(i.ended=!1,this.log(_concatInstanceProperty(o=_concatInstanceProperty(l="Removing [".concat(d,",")).call(l,f,"] from the ")).call(o,e," SourceBuffer")),s.remove(d,f)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var r=this.tracks[t],n=null==r?void 0:r.buffer;if(!n)throw new HlsJsTrackRemovedError("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));r.ending=!1,r.ended=!1,n.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()}},{key:"isUpdating",value:function(){var e;return _someInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return r&&n.updating}))}},{key:"isQueued",value:function(){var e,t=this;return _someInstanceProperty(e=this.sourceBuffers).call(e,(function(e){var r=_slicedToArray(e,1)[0];return r&&!!t.currentOp(r)}))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.sourceBufferTypes;if(!r.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void _Promise.resolve().then(e);var n=this.operationQueue,a=_mapInstanceProperty(r).call(r,(function(e){return t.appendBlocker(e)}));r.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),_Promise.all(a).then((function(a){n===t.operationQueue&&(e(),t.stepOperationQueue(r))}))}},{key:"stepOperationQueue",value:function(e){var t=this;_forEachInstanceProperty(e).call(e,(function(e){var r,n=null==(r=t.tracks[e])?void 0:r.buffer;n&&!n.updating&&t.shiftAndExecuteNext(e)}))}},{key:"append",value:function(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){var e,t=this;return _reduceInstanceProperty(e=_Object$keys(this.tracks)).call(e,(function(e,r){return e+(t.isPending(t.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){var e;return _reduceInstanceProperty(e=this.sourceBuffers).call(e,(function(e,t){return e+(_slicedToArray(t,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){var e,t;return _filterInstanceProperty(e=_mapInstanceProperty(t=this.sourceBuffers).call(t,(function(e){return _slicedToArray(e,1)[0]}))).call(e,(function(e){return!!e}))}},{key:"addBufferListener",value:function(e,t,r){var n=this.tracks[e];if(n){var a=n.buffer;if(a){var i=_bindInstanceProperty(r).call(r,this,e);n.listeners.push({event:t,listener:i}),a.addEventListener(t,i)}}}},{key:"removeBufferListeners",value:function(e){var t,r=this.tracks[e];if(r){var n=r.buffer;n&&(_forEachInstanceProperty(t=r.listeners).call(t,(function(e){n.removeEventListener(e.event,e.listener)})),r.listeners.length=0)}}}]),r}();function removeSourceChildren(e){var t,r=e.querySelectorAll("source");_forEachInstanceProperty(t=_sliceInstanceProperty([]).call(r)).call(t,(function(t){e.removeChild(t)}))}function addSource(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}function sourceBufferNameToIndex(e){return"audio"===e?1:0}var CapLevelController=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return _createClass$1(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&isFiniteNumber(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t,r,n,a,i=this.hls,s=this.getMaxLevel(e.length-1);if(s!==this.autoLevelCapping)i.logger.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="Setting autoLevelCapping to ".concat(s,": ")).call(a,e[s].height,"p@")).call(n,e[s].bitrate," for media ")).call(r,this.mediaWidth,"x")).call(t,this.mediaHeight));i.autoLevelCapping=s,i.autoLevelEnabled&&i.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=i.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var r=this,n=this.hls.levels;if(!n.length)return-1;var a=_filterInstanceProperty(n).call(n,(function(e,n){return r.isLevelAllowed(e)&&n<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){var e;this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=_setInterval(_bindInstanceProperty(e=this.detectPlayerSize).call(e,this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){var t=this.restrictedLevels;return!_someInstanceProperty(t).call(t,(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(null==e||!e.length)return-1;for(var n,a,i=e.length-1,s=Math.max(t,r),o=0;o<e.length;o+=1){var l=e[o];if((l.width>=s||l.height>=s)&&(n=l,!(a=e[o+1])||n.width!==a.width||n.height!==a.height)){i=o;break}}return i}}]),e}(),CmObjectType={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},CmcdObjectType=CmObjectType,CmStreamingFormat={DASH:"d",HLS:"h",SMOOTH:"s",OTHER:"o"},CmcdStreamingFormat=CmStreamingFormat,CMCD_OBJECT="CMCD-Object",CMCD_REQUEST="CMCD-Request",CMCD_SESSION="CMCD-Session",CMCD_STATUS="CMCD-Status",CmcdHeaderField={OBJECT:CMCD_OBJECT,REQUEST:CMCD_REQUEST,SESSION:CMCD_SESSION,STATUS:CMCD_STATUS},CmcdHeaderMap=(_defineProperty$2(_CmcdHeaderMap={},CmcdHeaderField.OBJECT,["br","d","ot","tb"]),_defineProperty$2(_CmcdHeaderMap,CmcdHeaderField.REQUEST,["bl","dl","mtp","nor","nrr","su"]),_defineProperty$2(_CmcdHeaderMap,CmcdHeaderField.SESSION,["cid","pr","sf","sid","st","v"]),_defineProperty$2(_CmcdHeaderMap,CmcdHeaderField.STATUS,["bs","rtp"]),_CmcdHeaderMap),SfItem=_createClass$1((function e(t,r){_classCallCheck$1(this,e),_Array$isArray(t)&&(t=_mapInstanceProperty(t).call(t,(function(t){return t instanceof e?t:new e(t)}))),this.value=t,this.params=r})),DICT="Dict";function format(e){return _Array$isArray(e)?_JSON$stringify(e):e instanceof _Map?"Map{}":e instanceof _Set?"Set{}":"object"===_typeof$1(e)?_JSON$stringify(e):String(e)}function throwError(e,t,r,n){var a,i;return new Error(_concatInstanceProperty(a=_concatInstanceProperty(i="failed to ".concat(e,' "')).call(i,format(t),'" as ')).call(a,r),{cause:n})}function serializeError(e,t,r){return throwError("serialize",e,t,r)}var SfToken=_createClass$1((function e(t){_classCallCheck$1(this,e),this.description=t})),BARE_ITEM="Bare Item",BOOLEAN="Boolean";function serializeBoolean(e){if("boolean"!=typeof e)throw serializeError(e,BOOLEAN);return e?"?1":"?0"}var BYTES="Byte Sequence";function serializeByteSequence(e){if(!1===ArrayBuffer.isView(e))throw serializeError(e,BYTES);return":".concat(base64encode(e),":")}var INTEGER="Integer";function isInvalidInt(e){return e<-999999999999999||999999999999999<e}function serializeInteger(e){if(isInvalidInt(e))throw serializeError(e,INTEGER);return e.toString()}function serializeDate(e){return"@".concat(serializeInteger(e.getTime()/1e3))}var DECIMAL="Decimal";function serializeDecimal(e){var t=roundToEven(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw serializeError(e,DECIMAL);var r=t.toString();return _includesInstanceProperty(r).call(r,".")?r:"".concat(r,".0")}var STRING="String",STRING_REGEX=/[\x00-\x1f\x7f]+/;function serializeString(e){if(STRING_REGEX.test(e))throw serializeError(e,STRING);return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}function symbolToStr(e){var t;return e.description||_sliceInstanceProperty(t=e.toString()).call(t,7,-1)}var TOKEN="Token";function serializeToken(e){var t=symbolToStr(e);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw serializeError(t,TOKEN);return t}function serializeBareItem(e){switch(_typeof$1(e)){case"number":if(!isFiniteNumber(e))throw serializeError(e,BARE_ITEM);return _Number$isInteger(e)?serializeInteger(e):serializeDecimal(e);case"string":return serializeString(e);case"symbol":return serializeToken(e);case"boolean":return serializeBoolean(e);case"object":if(e instanceof Date)return serializeDate(e);if(e instanceof Uint8Array)return serializeByteSequence(e);if(e instanceof SfToken)return serializeToken(e);default:throw serializeError(e,BARE_ITEM)}}var KEY="Key";function serializeKey(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw serializeError(e,KEY);return e}function serializeParams(e){var t;return null==e?"":_mapInstanceProperty(t=_Object$entries(e)).call(t,(function(e){var t,r=_slicedToArray(e,2),n=r[0],a=r[1];return!0===a?";".concat(serializeKey(n)):_concatInstanceProperty(t=";".concat(serializeKey(n),"=")).call(t,serializeBareItem(a))})).join("")}function serializeItem(e){var t;return e instanceof SfItem?_concatInstanceProperty(t="".concat(serializeBareItem(e.value))).call(t,serializeParams(e.params)):serializeBareItem(e)}function serializeInnerList(e){var t,r;return _concatInstanceProperty(t="(".concat(_mapInstanceProperty(r=e.value).call(r,serializeItem).join(" "),")")).call(t,serializeParams(e.params))}function serializeDict(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!==_typeof$1(e))throw serializeError(e,DICT);var n=e instanceof _Map?_entriesInstanceProperty(e).call(e):_Object$entries(e),a=(null==r?void 0:r.whitespace)?" ":"";return _mapInstanceProperty(t=_Array$from(n)).call(t,(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];n instanceof SfItem==!1&&(n=new SfItem(n));var a=serializeKey(r);return!0===n.value?a+=serializeParams(n.params):(a+="=",_Array$isArray(n.value)?a+=serializeInnerList(n):a+=serializeItem(n)),a})).join(",".concat(a))}function encodeSfDict(e,t){return serializeDict(e,t)}function isTokenField(e){return"ot"===e||"sf"===e||"st"===e}function isValid(e){return"number"==typeof e?isFiniteNumber(e):null!=e&&""!==e&&!1!==e}var toRounded=function(e){return Math.round(e)},toUrlSafe=function(e,t){return(null==t?void 0:t.baseUrl)&&(e=urlToRelativePath(e,t.baseUrl)),encodeURIComponent(e)},toHundred=function(e){return 100*toRounded(e/100)},CmcdFormatters={br:toRounded,d:toRounded,bl:toHundred,dl:toHundred,mtp:toHundred,nor:toUrlSafe,rtp:toHundred,tb:toRounded};function processCmcd(e,t){var r,n={};if(null==e||"object"!==_typeof$1(e))return n;var a=_sortInstanceProperty(r=_Object$keys(e)).call(r),i=_extends({},CmcdFormatters,null==t?void 0:t.formatters),s=null==t?void 0:_filterInstanceProperty(t);return _forEachInstanceProperty(a).call(a,(function(r){if(!(null==s?void 0:s(r))){var a=e[r],o=i[r];o&&(a=o(a,t)),"v"===r&&1===a||"pr"==r&&1===a||isValid(a)&&(isTokenField(r)&&"string"==typeof a&&(a=new SfToken(a)),n[r]=a)}})),n}function encodeCmcd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?encodeSfDict(processCmcd(e,t),_extends({whitespace:!1},t)):""}function toCmcdHeaders(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a={};if(!e)return a;var i=_Object$entries(e),s=_concatInstanceProperty(t=_Object$entries(CmcdHeaderMap)).call(t,_Object$entries((null==n?void 0:n.customHeaderMap)||{})),o=_reduceInstanceProperty(i).call(i,(function(e,t){var r,n,a=_slicedToArray(t,2),i=a[0],o=a[1],l=(null===(r=_findInstanceProperty(s).call(s,(function(e){var t;return _includesInstanceProperty(t=e[1]).call(t,i)})))||void 0===r?void 0:r[0])||CmcdHeaderField.REQUEST;return null!==(n=e[l])&&void 0!==n||(e[l]={}),e[l][i]=o,e}),{});return _reduceInstanceProperty(r=_Object$entries(o)).call(r,(function(e,t){var r=_slicedToArray(t,2),a=r[0],i=r[1];return e[a]=encodeCmcd(i,n),e}),a)}function appendCmcdHeaders(e,t,r){return _extends(e,toCmcdHeaders(t,r))}var CMCD_PARAM="CMCD";function toCmcdQuery(e){if(!e)return"";var t=encodeCmcd(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return"".concat(CMCD_PARAM,"=").concat(encodeURIComponent(t))}var REGEX=/CMCD=[^&#]+/;function appendCmcdQuery(e,t,r){var n,a,i=toCmcdQuery(t,r);if(!i)return e;if(REGEX.test(e))return e.replace(REGEX,i);var s=_includesInstanceProperty(e).call(e,"?")?"&":"?";return _concatInstanceProperty(n=_concatInstanceProperty(a="".concat(e)).call(a,s)).call(n,i)}var CMCDController=function(){function e(t){var r=this;_classCallCheck$1(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,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(e){try{r.apply(e,{ot:CmcdObjectType.MANIFEST,su:!r.initialized})}catch(e){r.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var t=e.frag,n=e.part,a=r.hls.levels[t.level],i=r.getObjectType(t),s={d:1e3*(n||t).duration,ot:i};i!==CmcdObjectType.VIDEO&&i!==CmcdObjectType.AUDIO&&i!=CmcdObjectType.MUXED||(s.br=a.bitrate/1e3,s.tb=r.getTopBandwidth(i)/1e3,s.bl=r.getBufferLength(i));var o=n?r.getNextPart(n):r.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),r.apply(e,s)}catch(e){r.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var n=this.config=t.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||t.sessionId,this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.includeKeys=a.includeKeys,this.registerListeners())}return _createClass$1(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Events.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Events.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var r,n;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(n=t.tracks.video)?void 0:n.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:CmcdStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_extends(t,this.createData());var r=t.ot===CmcdObjectType.INIT||t.ot===CmcdObjectType.VIDEO||t.ot===CmcdObjectType.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var n,a=this.includeKeys;a&&(t=_reduceInstanceProperty(n=_Object$keys(t)).call(n,(function(e,r){return _includesInstanceProperty(a).call(a,r)&&(e[r]=t[r]),e}),{}));var i={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),appendCmcdHeaders(e.headers,t,i)):e.url=appendCmcdQuery(e.url,t,i)}},{key:"getNextFrag",value:function(e){var t,r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){var n=e.sn-r.startSN;return r.fragments[n+1]}}},{key:"getNextPart",value:function(e){var t,r,n=e.index,a=e.fragment,i=null==(t=this.hls.levels[a.level])||null==(r=t.details)?void 0:r.partList;if(i)for(var s=a.sn,o=i.length-1;o>=0;o--){var l=i[o];if(l.index===n&&l.fragment.sn===s)return i[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?CmcdObjectType.TIMED_TEXT:"initSegment"===e.sn?CmcdObjectType.INIT:"audio"===t?CmcdObjectType.AUDIO:"main"===t?this.hls.audioTracks.length?CmcdObjectType.VIDEO:CmcdObjectType.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,n=this.hls;if(e===CmcdObjectType.AUDIO)t=n.audioTracks;else{var a,i=n.maxAutoLevel,s=i>-1?i+1:n.levels.length;t=_sliceInstanceProperty(a=n.levels).call(a,0,s)}var o,l=_createForOfIteratorHelper(t);try{for(l.s();!(o=l.n()).done;){var c=o.value;c.bitrate>r&&(r=c.bitrate)}}catch(e){l.e(e)}finally{l.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===CmcdObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*BufferHelper.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(t){_classCallCheck$1(this,e),this.loader=void 0,this.loader=new r(t)}return _createClass$1(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,n){t(e),this.loader.load(e,r,n)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(t){_classCallCheck$1(this,e),this.loader=void 0,this.loader=new r(t)}return _createClass$1(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,n){t(e),this.loader.load(e,r,n)}}]),e}()}}]),e}(),PATHWAY_PENALTY_DURATION_MS=3e5,ContentSteeringController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"content-steering",e.logger)).hls=void 0,n.loader=null,n.uri=null,n.pathwayId=".",n._pathwayPriority=null,n.timeToLoad=300,n.reloadTimer=-1,n.updated=0,n.started=!1,n.enabled=!0,n.levels=null,n.audioTracks=null,n.subtitleTracks=null,n.penalizedPathways={},n.hls=e,n.registerListeners(),n}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.ERROR,this.onError,this))}},{key:"pathways",value:function(){var e;return _reduceInstanceProperty(e=this.levels||[]).call(e,(function(e,t){return-1===_indexOfInstanceProperty(e).call(e,t.pathwayId)&&e.push(t.pathwayId),e}),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=_filterInstanceProperty(t).call(t,(function(t){return t!==e})))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===NetworkErrorAction.SendAlternateToPenaltyBox&&_flagsInstanceProperty(r)===ErrorActionFlags.MoveAllAlternatesMatchingHost){var n,a,i,s,o,l=this.levels,c=this._pathwayPriority,u=this.pathwayId;if(t.context){var d=t.context,f=d.groupId,h=d.pathwayId,p=d.type;f&&l?u=this.getPathwayForGroupId(f,p,u):h&&(u=h)}if(u in this.penalizedPathways||(this.penalizedPathways[u]=performance.now()),!c&&l&&(c=this.pathways()),c&&c.length>1&&(this.updatePathwayPriority(c),r.resolved=this.pathwayId!==u),!r.resolved)this.warn(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Could not resolve ".concat(t.details,' ("')).call(o,t.error.message,'") with content-steering for Pathway: ')).call(s,u," levels: ")).call(i,l?l.length:l," priorities: ")).call(a,_JSON$stringify(c)," penalized: ")).call(n,_JSON$stringify(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t,r,n=this.getLevelsForPathway(this.pathwayId);if(0===n.length){var a,i=e[0].pathwayId;this.log(_concatInstanceProperty(a="No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "')).call(a,i,'"')),n=this.getLevelsForPathway(i),this.pathwayId=i}n.length!==e.length&&this.log(_concatInstanceProperty(t=_concatInstanceProperty(r="Found ".concat(n.length,"/")).call(r,e.length,' levels in Pathway "')).call(t,this.pathwayId,'"'));return n}},{key:"getLevelsForPathway",value:function(e){var t;return null===this.levels?[]:_filterInstanceProperty(t=this.levels).call(t,(function(t){return e===t.pathwayId}))}},{key:"updatePathwayPriority",value:function(e){var t,r;this._pathwayPriority=e;var n=this.penalizedPathways,a=performance.now();_forEachInstanceProperty(t=_Object$keys(n)).call(t,(function(e){a-n[e]>PATHWAY_PENALTY_DURATION_MS&&delete n[e]}));for(var i=0;i<e.length;i++){var s=e[i];if(!(s in n)){if(s===this.pathwayId)return;var o=this.hls.nextLoadLevel,l=this.hls.levels[o];if((r=this.getLevelsForPathway(s)).length>0){this.log('Setting Pathway to "'.concat(s,'"')),this.pathwayId=s,reassignFragmentLevelIndexes(r),this.hls.trigger(Events.LEVELS_UPDATED,{levels:r});var c=this.hls.levels[o];if(l&&c&&this.levels){var u;if(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate)this.log(_concatInstanceProperty(u="Unstable Pathways change from bitrate ".concat(l.bitrate," to ")).call(u,c.bitrate));this.hls.nextLoadLevel=o}break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var n,a=_concatInstanceProperty(n=this.getLevelsForPathway(r)).call(n,this.levels||[]),i=0;i<a.length;i++)if(t===PlaylistContextType.AUDIO_TRACK&&a[i].hasAudioGroup(e)||t===PlaylistContextType.SUBTITLE_TRACK&&a[i].hasSubtitleGroup(e))return a[i].pathwayId;return r}},{key:"clonePathways",value:function(e){var t=this,r=this.levels;if(r){var n={},a={};_forEachInstanceProperty(e).call(e,(function(e){var i,s=e.ID,o=e["BASE-ID"],l=e["URI-REPLACEMENT"];if(!_someInstanceProperty(r).call(r,(function(e){return e.pathwayId===s}))){var c=_mapInstanceProperty(i=t.getLevelsForPathway(o)).call(i,(function(e){var t,r,i=new AttrList(e.attrs);i["PATHWAY-ID"]=s;var o=i.AUDIO&&_concatInstanceProperty(t="".concat(i.AUDIO,"_clone_")).call(t,s),c=i.SUBTITLES&&_concatInstanceProperty(r="".concat(i.SUBTITLES,"_clone_")).call(r,s);o&&(n[i.AUDIO]=o,i.AUDIO=o),c&&(a[i.SUBTITLES]=c,i.SUBTITLES=c);var u=performUriReplacement(e.uri,i["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),d=new Level({attrs:i,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var f=1;f<e.audioGroups.length;f++){var h;d.addGroupId("audio",_concatInstanceProperty(h="".concat(e.audioGroups[f],"_clone_")).call(h,s))}if(e.subtitleGroups)for(var p=1;p<e.subtitleGroups.length;p++){var y;d.addGroupId("text",_concatInstanceProperty(y="".concat(e.subtitleGroups[p],"_clone_")).call(y,s))}return d}));r.push.apply(r,_toConsumableArray(c)),cloneRenditionGroups(t.audioTracks,n,l,s),cloneRenditionGroups(t.subtitleTracks,a,l,s)}}))}}},{key:"loadSteeringManifest",value:function(e){var t,r=this,n=this.hls.config,a=n.loader;this.loader&&this.loader.destroy(),this.loader=new a(n);try{t=new _URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: ".concat(e))}if("data:"!==t.protocol){var i=0|(this.hls.bandwidthEstimate||n.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+i)}var s={responseType:"json",url:t.href},o=n.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},c={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},u={onSuccess:function(e,n,a,i){r.log('Loaded steering manifest: "'.concat(t,'"'));var s=e.data;if(1===(null==s?void 0:s.VERSION)){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],l=s["PATHWAY-CLONES"],c=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new _URL(o,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(o))}r.scheduleRefresh(r.uri||a.url),l&&r.clonePathways(l);var u={steeringManifest:s,url:t.toString()};r.hls.trigger(Events.STEERING_MANIFEST_LOADED,u),c&&r.updatePathwayPriority(c)}else r.log("Steering VERSION ".concat(s.VERSION," not supported!"))},onError:function(e,t,n,a){var i,s;if(r.log(_concatInstanceProperty(i=_concatInstanceProperty(s="Error loading steering manifest: ".concat(e.code," ")).call(s,e.text," (")).call(i,t.url,")")),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest ".concat(t.url," no longer available"));var o=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,o);else{var l=r.loader;if("function"==typeof(null==l?void 0:l.getResponseHeader)){var c=l.getResponseHeader("Retry-After");c&&(o=1e3*_parseFloat$1(c))}r.log("Steering manifest ".concat(t.url," rate limited"))}},onTimeout:function(e,t,n){r.log("Timeout loading steering manifest (".concat(t.url,")")),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: ".concat(t)),this.loader.load(s,c,u)}},{key:"scheduleRefresh",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3*this.timeToLoad;this.clearTimeout(),this.reloadTimer=_setTimeout((function(){var r,n=null==(r=t.hls)?void 0:r.media;!n||n.ended?t.scheduleRefresh(e,1e3*t.timeToLoad):t.loadSteeringManifest(e)}),r)}}]),r}();function cloneRenditionGroups(e,t,r,n){var a;e&&_forEachInstanceProperty(a=_Object$keys(t)).call(a,(function(a){var i,s=_mapInstanceProperty(i=_filterInstanceProperty(e).call(e,(function(e){return e.groupId===a}))).call(i,(function(e){var i=_extends({},e);return i.details=void 0,i.attrs=new AttrList(i.attrs),i.url=i.attrs.URI=performUriReplacement(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),i.groupId=i.attrs["GROUP-ID"]=t[a],i.attrs["PATHWAY-ID"]=n,i}));e.push.apply(e,_toConsumableArray(s))}))}function performUriReplacement(e,t,r,n){var a,i=n.HOST,s=n.PARAMS,o=n[r];t&&(a=null==o?void 0:o[t])&&(e=a);var l,c,u=new _URL(e);(i&&!a&&(u.host=i),s)&&_forEachInstanceProperty(l=_sortInstanceProperty(c=_Object$keys(s)).call(c)).call(l,(function(e){e&&u.searchParams.set(e,s[e])}));return u.href}var EMEController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,"eme",e.logger)).hls=void 0,n.config=void 0,n.media=null,n.keyFormatPromise=null,n.keySystemAccessPromises={},n._requestLicenseFailureCount=0,n.mediaKeySessions=[],n.keyIdToKeySessionPromise={},n.setMediaKeysQueue=r.CDMCleanupPromise?[r.CDMCleanupPromise]:[],n.onMediaEncrypted=function(e){var t,r=e.initDataType,a=e.initData,i=_concatInstanceProperty(t='"'.concat(e.type,'" event: init data type: "')).call(t,r,'"');if(n.debug(i),null!==a){var s,o;if("sinf"===r&&n.getLicenseServerUrl(KeySystems.FAIRPLAY)){var l=bin2str(new Uint8Array(a));try{var c=parseSinf(base64Decode(JSON.parse(l).sinf));if(!c)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=c.subarray(8,24),o=KeySystems.FAIRPLAY}catch(e){var u;return void n.warn(_concatInstanceProperty(u="".concat(i," Failed to parse sinf: ")).call(u,e))}}else if(n.getLicenseServerUrl(KeySystems.WIDEVINE)){var d=parseMultiPssh(a),f=_Object$keys(n.keySystemAccessPromises);f.length||(f=getKeySystemsForConfig(n.config));var h=_filterInstanceProperty(d).call(d,(function(e){var t=e.systemId?keySystemIdToKeySystemDomain(e.systemId):null;return!!t&&_indexOfInstanceProperty(f).call(f,t)>-1}))[0];if(!h){var p;if(0===d.length||_someInstanceProperty(d).call(d,(function(e){return!e.systemId})))n.warn("".concat(i," contains incomplete or invalid pssh data"));else n.log(_concatInstanceProperty(p="ignoring ".concat(i," for ")).call(p,_mapInstanceProperty(d).call(d,(function(e){return keySystemIdToKeySystemDomain(e.systemId)})).join(",")," pssh data in favor of playlist keys"));return}if(o=keySystemIdToKeySystemDomain(h.systemId),0===h.version&&h.data)if(o===KeySystems.WIDEVINE){var y=h.data.length-22;s=h.data.subarray(y,y+16)}else o===KeySystems.PLAYREADY&&(s=parsePlayReadyWRM(h.data))}if(o&&s){for(var g=Hex.hexDump(s),v=_assertThisInitialized(n),m=v.keyIdToKeySessionPromise,E=v.mediaKeySessions,$=m[g],S=function(){var e,t=E[T],i=t.decryptdata;if(!i.keyId)return"continue";var o=Hex.hexDump(i.keyId);return g===o||-1!==_indexOfInstanceProperty(e=i.uri.replace(/-/g,"")).call(e,g)?($=m[o],i.pssh||(delete m[o],i.pssh=new Uint8Array(a),i.keyId=s,($=m[g]=$.then((function(){return n.generateRequestWithPreferredKeySession(t,r,a,"encrypted-event-key-match")}))).catch((function(e){return n.handleError(e)}))),"break"):void 0},T=0;T<E.length;T++){var I=S();if("continue"!==I&&"break"===I)break}$||($=m[g]=n.getKeySystemSelectionPromise([o]).then((function(e){var t,i=e.keySystem,o=e.mediaKeys;n.throwIfDestroyed();var l=new LevelKey("ISO-23001-7",g,null!=(t=keySystemDomainToKeySystemFormat(i))?t:"");return l.pssh=new Uint8Array(a),l.keyId=s,n.attemptSetMediaKeys(i,o).then((function(){n.throwIfDestroyed();var e=n.createMediaKeySessionContext({decryptdata:l,keySystem:i,mediaKeys:o});return n.generateRequestWithPreferredKeySession(e,r,a,"encrypted-event-no-match")}))}))).catch((function(e){return n.handleError(e)}))}}},n.onWaitingForKey=function(e){n.log('"'.concat(e.type,'" event'))},n.hls=e,n.config=e.config,n.registerListeners(),n}return _createClass$1(r,[{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,r=t.drmSystems,n=t.widevineLicenseUrl,a=r[e];return a?a.licenseUrl:e===KeySystems.WIDEVINE&&n?n:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error('no license server URL configured for key-system "'.concat(e,'"'));return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'.concat(e,'"]'))}},{key:"attemptKeySystemAccess",value:function(e){var t,r,n=this,a=this.hls.levels,i=function(e,t,r){return!!e&&_indexOfInstanceProperty(r).call(r,e)===t},s=_filterInstanceProperty(t=_mapInstanceProperty(a).call(a,(function(e){return e.audioCodec}))).call(t,i),o=_filterInstanceProperty(r=_mapInstanceProperty(a).call(a,(function(e){return e.videoCodec}))).call(r,i);return s.length+o.length===0&&o.push("avc1.42e01e"),new _Promise((function(t,r){!function e(a){var i=a.shift();n.getMediaKeysPromise(i,s,o).then((function(e){return t({keySystem:i,mediaKeys:e})})).catch((function(t){a.length?e(a):r(t instanceof EMEKeyError?t:new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))}(e)}))}},{key:"requestMediaKeySystemAccess",value:function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var n="Configured requestMediaKeySystemAccess is not a function ".concat(r);return null===_requestMediaKeySystemAccess&&"http:"===self.location.protocol&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),_Promise.reject(new Error(n))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var n=this,a=getSupportedMediaKeySystemConfigurations(e,t,r,this.config.drmSystemOptions),i=this.keySystemAccessPromises[e],s=null==i?void 0:i.keySystemAccess;if(!s){var o;this.log(_concatInstanceProperty(o='Requesting encrypted media "'.concat(e,'" key-system access with config: ')).call(o,_JSON$stringify(a))),s=this.requestMediaKeySystemAccess(e,a);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){var r;n.log(_concatInstanceProperty(r='Failed to obtain access to key-system "'.concat(e,'": ')).call(r,t))})),s.then((function(t){n.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=n.fetchServerCertificate(e);return n.log('Create media-keys for "'.concat(e,'"')),l.mediaKeys=t.createMediaKeys().then((function(t){return n.log('Media-keys created for "'.concat(e,'"')),r.then((function(r){return r?n.setMediaKeysServerCertificate(t,e,r):t}))})),l.mediaKeys.catch((function(t){var r;n.error(_concatInstanceProperty(r='Failed to create media-keys for "'.concat(e,'"}: ')).call(r,t))})),l.mediaKeys}))}return s.then((function(){return i.mediaKeys}))}},{key:"createMediaKeySessionContext",value:function(e){var t,r=e.decryptdata,n=e.keySystem,a=e.mediaKeys;this.log(_concatInstanceProperty(t='Creating key-system session "'.concat(n,'" keyId: ')).call(t,Hex.hexDump(r.keyId||[])));var i=a.createSession(),s={decryptdata:r,keySystem:n,mediaKeys:a,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"getKeyIdString",value:function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return Hex.hexDump(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,n,a,i=e.mediaKeysSession;return this.log(_concatInstanceProperty(r=_concatInstanceProperty(n='Updating key-session "'.concat(i.sessionId,'" for keyID ')).call(n,Hex.hexDump((null==(a=e.decryptdata)?void 0:a.keyId)||[]),"\n } (data length: ")).call(r,t?t.byteLength:t,")")),i.update(t)}},{key:"selectKeySystemFormat",value:function(e){var t,r,n,a=_Object$keys(e.levelkeys||{});this.keyFormatPromise||(this.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n="Selecting key-system from fragment (sn: ".concat(e.sn," ")).call(n,e.type,": ")).call(r,e.level,") key formats ")).call(t,a.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(a));return this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new _Promise((function(r,n){var a,i=getKeySystemsForConfig(t.config),s=_filterInstanceProperty(a=_mapInstanceProperty(e).call(e,keySystemFormatToKeySystemDomain)).call(a,(function(e){return!!e&&-1!==_indexOfInstanceProperty(i).call(i,e)}));return t.getKeySystemSelectionPromise(s).then((function(e){var t=e.keySystem,a=keySystemDomainToKeySystemFormat(t);a?r(a):n(new Error('Unable to find format for key-system "'.concat(t,'"')))})).catch(n)}))}},{key:"loadKey",value:function(e){var t,r,n,a=this,i=e.keyInfo.decryptdata,s=this.getKeyIdString(i),o=_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n="(keyId: ".concat(s,' format: "')).call(n,i.keyFormat,'" method: ')).call(r,i.method," uri: ")).call(t,i.uri,")");this.log("Starting session for key ".concat(o));var l=this.keyIdToKeySessionPromise[s];l||(l=this.getKeySystemForKeyPromise(i).then((function(t){var r,n,s,l=t.keySystem,c=t.mediaKeys;return a.throwIfDestroyed(),a.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(s="Handle encrypted media sn: ".concat(e.frag.sn," ")).call(s,e.frag.type,": ")).call(n,e.frag.level," using key ")).call(r,o)),a.attemptSetMediaKeys(l,c).then((function(){return a.throwIfDestroyed(),a.createMediaKeySessionContext({keySystem:l,mediaKeys:c,decryptdata:i})}))})),(this.keyIdToKeySessionPromise[s]=l.then((function(e){var t=i.pssh?i.pssh.buffer:null;return a.generateRequestWithPreferredKeySession(e,"cenc",t,"playlist-key")}))).catch((function(e){return a.handleError(e)})));return l}},{key:"throwIfDestroyed",value:function(){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e){this.hls&&(this.error(e.message),e instanceof EMEKeyError?this.hls.trigger(Events.ERROR,e.data):this.hls.trigger(Events.ERROR,{type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}},{key:"getKeySystemForKeyPromise",value:function(e){var t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){var n=keySystemFormatToKeySystemDomain(e.keyFormat),a=n?[n]:getKeySystemsForConfig(this.config);return this.attemptKeySystemAccess(a)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=getKeySystemsForConfig(this.config)),0===e.length)throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(_JSON$stringify({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r,n=this,a=_sliceInstanceProperty(r=this.setMediaKeysQueue).call(r);this.log('Setting media-keys for "'.concat(e,'"'));var i=_Promise.all(a).then((function(){if(!n.media)throw new Error("Attempted to set mediaKeys without media element attached");return n.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(i),i.then((function(){var t;n.log('Media-keys set for "'.concat(e,'"')),a.push(i),n.setMediaKeysQueue=_filterInstanceProperty(t=n.setMediaKeysQueue).call(t,(function(e){return-1===_indexOfInstanceProperty(a).call(a,e)}))}))}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,r,n){var a,i,s,o,l,c=this,u=null==(o=this.config.drmSystems)||null==(l=o[e.keySystem])?void 0:l.generateRequest;if(u)try{var d=u.call(this.hls,t,r,e);if(!d)throw new Error("Invalid response from configured generateRequest filter");t=d.initDataType,r=d.initData?d.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(e){var f;if(this.warn(e.message),null!=(f=this.hls)&&f.config.debug)throw e}if(null===r)return this.log('Skipping key-session request for "'.concat(n,'" (no initData)')),_Promise.resolve(e);var h=this.getKeyIdString(e.decryptdata);this.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s='Generating key-session request for "'.concat(n,'": ')).call(s,h," (init data type: ")).call(i,t," length: ")).call(a,r?r.byteLength:null,")"));var p=new EventEmitter,y=e._onmessage=function(t){var r,n,a=e.mediaKeysSession;if(a){var i=t.messageType,s=t.message;c.log(_concatInstanceProperty(r=_concatInstanceProperty(n='"'.concat(i,'" message event for session "')).call(n,a.sessionId,'" message size: ')).call(r,s.byteLength)),"license-request"===i||"license-renewal"===i?c.renewLicense(e,s).catch((function(e){p.eventNames().length?p.emit("error",e):c.handleError(e)})):"license-release"===i?e.keySystem===KeySystems.FAIRPLAY&&(c.updateKeySession(e,strToUtf8array("acknowledged")),c.removeSession(e)):c.warn('unhandled media key message type "'.concat(i,'"'))}else p.emit("error",new Error("invalid state"))},g=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){c.onKeyStatusChange(e);var r,n=e.keyStatus;if(p.emit("keyStatus",n),"expired"===n)c.warn(_concatInstanceProperty(r="".concat(e.keySystem," expired for key ")).call(r,h)),c.renewKeySession(e)}else p.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",y),e.mediaKeysSession.addEventListener("keystatuseschange",g);var v=new _Promise((function(e,t){p.on("error",t),p.on("keyStatus",(function(r){_startsWithInstanceProperty(r).call(r,"usable")?e():"output-restricted"===r?t(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(r,'"'))):"expired"===r?t(new Error("key expired while generating request")):c.warn('unhandled key status change "'.concat(r,'"'))}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t,r;c.log(_concatInstanceProperty(t='Request generated for key-session "'.concat(null==(r=e.mediaKeysSession)?void 0:r.sessionId,'" keyId: ')).call(t,h))})).catch((function(e){throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: ".concat(e))})).then((function(){return v})).catch((function(t){throw p.removeAllListeners(),c.removeSession(e),t})).then((function(){return p.removeAllListeners(),e}))}},{key:"onKeyStatusChange",value:function(e){var t,r=this;_forEachInstanceProperty(t=e.mediaKeysSession.keyStatuses).call(t,(function(t,n){var a,i,s;r.log(_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s='key status change "'.concat(t,'" for keyStatuses keyId: ')).call(s,Hex.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))," session keyId: ")).call(i,Hex.hexDump(new Uint8Array(e.decryptdata.keyId||[]))," uri: ")).call(a,e.decryptdata.uri)),e.keyStatus=t}))}},{key:"fetchServerCertificate",value:function(e){var t=this.config,r=new(0,t.loader)(t),n=this.getServerCertificateUrl(e);return n?(this.log('Fetching server certificate for "'.concat(e,'"')),new _Promise((function(a,i){var s={responseType:"arraybuffer",url:n},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(e,t,r,n){a(e.data)},onError:function(t,r,a,o){var l,c,u;i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:_objectSpread2({url:s.url,data:void 0},t)},_concatInstanceProperty(l=_concatInstanceProperty(c=_concatInstanceProperty(u='"'.concat(e,'" certificate request failed (')).call(u,n,"). Status: ")).call(c,t.code," (")).call(l,t.text,")")))},onTimeout:function(t,r,a){var o;i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:s.url,data:void 0}},_concatInstanceProperty(o='"'.concat(e,'" certificate request timed out (')).call(o,n,")")))},onAbort:function(e,t,r){i(new Error("aborted"))}};r.load(s,l,c)}))):_Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var n=this;return new _Promise((function(a,i){e.setServerCertificate(r).then((function(i){var s,o;n.log(_concatInstanceProperty(s=_concatInstanceProperty(o="setServerCertificate ".concat(i?"success":"not supported by CDM"," (")).call(o,null==r?void 0:r.byteLength,') on "')).call(s,t,'"')),a(e)})).catch((function(e){i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))}},{key:"renewLicense",value:function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then((function(t){return r.updateKeySession(e,new Uint8Array(t)).catch((function(e){throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!_includesInstanceProperty(r).call(r,"PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var n=(new DOMParser).parseFromString(r,"application/xml"),a=n.querySelectorAll("HttpHeader");if(a.length>0)for(var i,s=0,o=a.length;s<o;s++){var l,c,u=null==(l=(i=a[s]).querySelector("name"))?void 0:l.textContent,d=null==(c=i.querySelector("value"))?void 0:c.textContent;u&&d&&e.setRequestHeader(u,d)}var f=n.querySelector("Challenge"),h=null==f?void 0:f.textContent;if(!h)throw new Error("Cannot find <Challenge> in key message");return strToUtf8array(atob(h))}},{key:"setupLicenseXHR",value:function(e,t,r,n){var a=this,i=this.config.licenseXhrSetup;return i?_Promise.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return i.call(a.hls,e,t,r,n)})).catch((function(s){if(!r.decryptdata)throw s;return e.open("POST",t,!0),i.call(a.hls,e,t,r,n)})).then((function(r){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||n}})):(e.open("POST",t,!0),_Promise.resolve({xhr:e,licenseChallenge:n}))}},{key:"requestLicense",value:function(e,t){var r=this,n=this.config.keyLoadPolicy.default;return new _Promise((function(a,i){var s=r.getLicenseServerUrlOrThrow(e.keySystem);r.log("Sending license request to URL: ".concat(s));var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(4===o.readyState)if(200===o.status){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received ".concat(l instanceof ArrayBuffer?l.byteLength:l));var c=r.config.licenseResponseCallback;if(c)try{l=c.call(r.hls,o,s,e)}catch(e){r.error(e)}a(l)}else{var u=n.errorRetry,d=u?u.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>d||o.status>=400&&o.status<500){var f,h;i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},_concatInstanceProperty(f=_concatInstanceProperty(h="License Request XHR failed (".concat(s,"). Status: ")).call(h,o.status," (")).call(f,o.statusText,")")))}else{var p=d-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(p," attempts left")),r.requestLicense(e,t).then(a,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,t).then((function(t){var n=t.xhr,a=t.licenseChallenge;e.keySystem==KeySystems.PLAYREADY&&(a=r.unpackPlayReadyKeyMessage(n,a)),n.send(a)}))}))}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}}},{key:"onMediaDetached",value:function(){var e,t,n=this,a=this.media,i=this.mediaKeySessions;a&&(a.removeEventListener("encrypted",this.onMediaEncrypted),a.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},LevelKey.clearKeyUriToKeyIdMap();var s=i.length;r.CDMCleanupPromise=_Promise.all(_concatInstanceProperty(e=_mapInstanceProperty(i).call(i,(function(e){return n.removeSession(e)}))).call(e,null==a||null==(t=a.setMediaKeys(null))?void 0:t.catch((function(e){var t;n.log("Could not clear media keys: ".concat(e)),null==(t=n.hls)||t.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){s&&(n.log("finished closing key sessions and clearing media keys"),i.length=0)})).catch((function(e){var t;n.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=n.hls)||t.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close sessions and clear media keys: ".concat(e))})}))}},{key:"onManifestLoading",value:function(){this.keyFormatPromise=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var n=_reduceInstanceProperty(r).call(r,(function(e,t){return-1===_indexOfInstanceProperty(e).call(e,t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys ".concat(n.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(n)}}},{key:"removeSession",value:function(e){var t=this,r=e.mediaKeysSession,n=e.licenseXhr;if(r){var a;this.log("Remove licenses and keys and close session ".concat(r.sessionId)),e._onmessage&&(r.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var i,s=_indexOfInstanceProperty(a=this.mediaKeySessions).call(a,e);if(s>-1)_spliceInstanceProperty(i=this.mediaKeySessions).call(i,s,1);return r.remove().catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error("Could not remove session: ".concat(e))})})).then((function(){return r.close()})).catch((function(e){var r;t.log("Could not close session: ".concat(e)),null==(r=t.hls)||r.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),r}();EMEController.CDMCleanupPromise=void 0;var EMEKeyError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,n)).data=void 0,e.error||(e.error=new Error(n)),a.data=e,e.err=e.error,a}return _createClass$1(r)}(),FPSController=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}return _createClass$1(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var n,a=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=a,a&&"function"==typeof a.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=_setInterval(_bindInstanceProperty(n=this.checkFPSInterval).call(n,this),r.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,r){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,i=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*i/a,l=this.hls;if(l.trigger(Events.FPS_DROP,{currentDropped:i,currentDecoded:s,totalDroppedFrames:r}),o>0&&i>l.config.fpsDroppedMonitoringThreshold*s){var c=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=c)&&(c-=1,l.trigger(Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}]),e}();function sendAddTrackEvent(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function addCueToTrack(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: ".concat(t))}catch(r){logger.debug("[texttrack-utils]: ".concat(r));try{var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){logger.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(e))}}"disabled"===r&&(e.mode=r)}function clearCurrentCues(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(var n=e.cues.length;n--;)t&&e.cues[n].removeEventListener("enter",t),e.removeCue(e.cues[n]);"disabled"===r&&(e.mode=r)}function removeCuesInRange(e,t,r,n){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var i=getCuesInRange(e.cues,t,r),s=0;s<i.length;s++)n&&!n(i[s])||e.removeCue(i[s]);"disabled"===a&&(e.mode=a)}function getFirstCueIndexAfterTime(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var n=0,a=r;n<=a;){var i=Math.floor((a+n)/2);if(t<e[i].startTime)a=i-1;else{if(!(t>e[i].startTime&&n<r))return i;n=i+1}}return e[n].startTime-t<t-e[a].startTime?n:a}function getCuesInRange(e,t,r){var n=[],a=getFirstCueIndexAfterTime(e,t);if(a>-1)for(var i=a,s=e.length;i<s;i++){var o=e[i];if(o.startTime>=t&&o.endTime<=r)n.push(o);else if(o.startTime>r)return n}return n}function filterSubtitleTracks(e){for(var t=[],r=0;r<e.length;r++){var n=e[r];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||t.push(e[r])}return t}var SubtitleTrackController=function(e){_inherits(r,BasePlaylistController);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,e,"subtitle-track-controller")).media=null,n.tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.queuedDefaultTrack=-1,n.useTextTrackPolling=!1,n.subtitlePollingInterval=-1,n._subtitleDisplay=!0,n.asyncPollTrackChange=function(){return n.pollTrackChange(0)},n.onTextTracksChanged=function(){if(n.useTextTrackPolling||self.clearInterval(n.subtitlePollingInterval),n.media&&n.hls.config.renderTextTracksNatively){for(var e=null,t=filterSubtitleTracks(n.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}var a=n.findTrackForTextTrack(e);n.subtitleTrack!==a&&n.setSubtitleTrack(a)}},n.registerListeners(),n}return _createClass$1(r,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,_get(_getPrototypeOf(r.prototype),"destroy",this).call(this)}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Events.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.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))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=_setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;if(r){var n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!n){var a=filterSubtitleTracks(r.textTracks);_forEachInstanceProperty(a).call(a,(function(e){clearCurrentCues(e)}))}}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,n,a,i,s,o=t.id,l=t.groupId,c=t.details,u=this.tracksInGroup[o];if(u&&u.groupId===l){var d=u.details;u.details=t.details,this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Subtitle track ".concat(o,' "')).call(s,u.name,'" lang:')).call(i,u.lang," group:")).call(a,l," loaded [")).call(n,c.startSN,"-")).call(r,c.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,d)}else{var f,h;this.warn(_concatInstanceProperty(f=_concatInstanceProperty(h="Subtitle track with id:".concat(o," and group:")).call(h,l," not found in active group ")).call(f,null==u?void 0:u.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.subtitleGroups||null,n=this.groupIds,a=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&_someInstanceProperty(r).call(r,(function(e){return-1===(null==n?void 0:_indexOfInstanceProperty(n).call(n,e))}))){var i,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=_filterInstanceProperty(i=this.tracks).call(i,(function(e){return!r||-1!==_indexOfInstanceProperty(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!_someInstanceProperty(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),_forEachInstanceProperty(o).call(o,(function(e,t){e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.subtitlePreference;if(!a&&l){this.selectDefaultTrack=!1;var c=findMatchingOption(l,o);if(c>-1)a=o[c];else{var u=findMatchingOption(l,this.tracks);a=this.tracks[u]}}var d=this.findTrackId(a);-1===d&&a&&(d=this.findTrackId(null));var f={subtitleTracks:o};this.log(_concatInstanceProperty(s="Updating subtitle tracks, ".concat(o.length,' track(s) found in "')).call(s,null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(Events.SUBTITLE_TRACKS_UPDATED,f),-1!==d&&-1===this.trackId&&this.setSubtitleTrack(d)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=this.selectDefaultTrack,n=0;n<t.length;n++){var a=t[n];if((!r||a.default)&&(r||e)&&(!e||matchesOption(a,e)))return n}if(e){for(var i=0;i<t.length;i++){var s=t[i];if(mediaAttributesIdentical(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(var o=0;o<t.length;o++){var l=t[o];if(mediaAttributesIdentical(e.attrs,l.attrs,["LANGUAGE"]))return o}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,r=0;r<t.length;r++){if(subtitleTrackMatchesTextTrack(t[r],e))return r}return-1}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==PlaylistContextType.SUBTITLE_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===_indexOfInstanceProperty(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var r=this.currentTrack;if(r&&matchesOption(e,r))return r;var n=findMatchingOption(e,this.tracksInGroup);if(n>-1){var a=this.tracksInGroup[n];return this.setSubtitleTrack(n),a}if(r)return null;var i=findMatchingOption(e,t);if(i>-1)return t[i]}}return null}},{key:"loadPlaylist",value:function(e){_get(_getPrototypeOf(r.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,t){var n,a,i,s,o,l;_get(_getPrototypeOf(r.prototype),"loadingPlaylist",this).call(this,e,t);var c=e.id,u=e.groupId,d=this.getUrlWithDirectives(e.url,t),f=e.details,h=null==f?void 0:f.age;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o=_concatInstanceProperty(l="Loading subtitle ".concat(c,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,u)).call(i,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,h&&f.live?" age "+h.toFixed(1)+(f.type&&" "+f.type||""):""," ")).call(n,d)),this.hls.trigger(Events.SUBTITLE_TRACK_LOADING,{url:d,id:c,groupId:u,deliveryDirectives:t||null,track:e})}},{key:"toggleTrackModes",value:function(){var e,t=this.media;if(t){var r,n,a=filterSubtitleTracks(t.textTracks),i=this.currentTrack;if(i)if(!(r=_filterInstanceProperty(a).call(a,(function(e){return subtitleTrackMatchesTextTrack(i,e)}))[0]))this.warn(_concatInstanceProperty(n='Unable to find subtitle TextTrack with name "'.concat(i.name,'" and language "')).call(n,i.lang,'"'));if(_forEachInstanceProperty(e=_sliceInstanceProperty([]).call(a)).call(e,(function(e){"disabled"!==e.mode&&e!==r&&(e.mode="disabled")})),r){var s=this.subtitleDisplay?"showing":"hidden";r.mode!==s&&(r.mode=s)}}}},{key:"setSubtitleTrack",value:function(e){var t,r,n=this.tracksInGroup;if(this.media)if(e<-1||e>=n.length||!isFiniteNumber(e))this.warn("Invalid subtitle track id: ".concat(e));else{this.selectDefaultTrack=!1;var a=this.currentTrack,i=n[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),i){var s=!!i.details&&!i.details.live;if(e!==this.trackId||i!==a||!s){this.log("Switching to subtitle-track ".concat(e)+(i?_concatInstanceProperty(t=_concatInstanceProperty(r=' "'.concat(i.name,'" lang:')).call(r,i.lang," group:")).call(t,i.groupId):""));var o=i.id,l=i.groupId,c=void 0===l?"":l,u=i.name,d=i.type,f=i.url;this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:c,name:u,type:d,url:f});var h=this.switchParams(i.url,null==a?void 0:a.details,i.details);this.loadPlaylist(h)}}else this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),r}();function hash(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var ALIGNED_END_THRESHOLD_SECONDS=.02,TimelineOccupancy=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function generateAssetIdentifier(e,t,r){var n,a;return _concatInstanceProperty(n=_concatInstanceProperty(a="".concat(e.identifier,"-")).call(a,r+1,"-")).call(n,hash(t))}var InterstitialEvent=function(){function e(t,r){_classCallCheck$1(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.base=r,this.dateRange=t,this.setDateRange(t)}return _createClass$1(e,[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=this.error=void 0}},{key:"isAssetPastPlayoutLimit",value:function(e){if(e>=this.assetList.length)return!0;var t=this.playoutLimit;return!(e<=0||isNaN(t))&&this.assetList[e].startOffset>t}},{key:"findAssetIndex",value:function(e){var t;return _indexOfInstanceProperty(t=this.assetList).call(t,e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return getSnapToFragmentTime(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=isFiniteNumber(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return getSnapToFragmentTime(e,t)}return e}},{key:"appendInPlace",get:function(){return!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||0!==this.startTime&&!this.snapOptions.out||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<ALIGNED_END_THRESHOLD_SECONDS))},set:function(e){this.appendInPlaceStarted||(this.appendInPlaceDisabled=!e)}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?TimelineOccupancy.Range:TimelineOccupancy.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"toString",value:function(){return eventToString(this)}}]),e}();function getSnapToFragmentTime(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<ALIGNED_END_THRESHOLD_SECONDS)?t.start:t.start+t.duration}function getInterstitialUrl(e,t,r){var n=new _URL(e,r);return"data:"!==n.protocol&&n.searchParams.set("_HLS_primary_id",t),n}function eventToString(e){var t,r,n;return _concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n='["'.concat(e.identifier,'" ')).call(n,e.cue.pre?"<pre>":e.cue.post?"<post>":"")).call(r,e.timelineStart.toFixed(2),"-")).call(t,e.resumeTime.toFixed(2),"]")}function eventAssetToString(e){var t,r,n=e.timelineStart,a=e.duration||0;return _concatInstanceProperty(t=_concatInstanceProperty(r='["'.concat(e.identifier,'" ')).call(r,n.toFixed(2),"-")).call(t,(n+a).toFixed(2),"]")}var HlsAssetPlayer=function(){function e(t,r,n,a){var i=this;_classCallCheck$1(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this.playoutOffset=0,this.checkPlayout=function(){var e=i.interstitial.playoutLimit;i.playoutOffset+i.currentTime>=e&&i.hls.trigger(Events.PLAYOUT_LIMIT_REACHED,{})};var s=this.hls=new t(r);this.interstitial=n,this.assetItem=a;var o=a.uri;try{o=getInterstitialUrl(o,s.sessionId).href}catch(e){}s.loadSource(o);var l=function(){i.hasDetails=!0};s.once(Events.LEVEL_LOADED,l),s.once(Events.AUDIO_TRACK_LOADED,l),s.once(Events.SUBTITLE_TRACK_LOADED,l),s.on(Events.MEDIA_ATTACHING,(function(e,t){var r=t.media;i.removeMediaListeners(),i.mediaAttached=r;var n,s,o=i.interstitial;o.playoutLimit&&(i.playoutOffset=(null==(s=o.assetList[_indexOfInstanceProperty(n=o.assetList).call(n,a)])?void 0:s.startOffset)||0,r.addEventListener("timeupdate",i.checkPlayout))}))}return _createClass$1(e,[{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){return this.hls.media}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return 0;var t=BufferHelper.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):0}},{key:"duration",get:function(){var e,t=null==(e=this.assetItem)?void 0:e.duration;return t||0}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"timelineOffset",get:function(){return this.hls.config.timelineOffset||0},set:function(e){var t=this.timelineOffset;if(e!==t){var r=e-t;if(Math.abs(r)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&e.removeEventListener("timeupdate",this.checkPlayout)}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){this.hls.attachMedia(e)}},{key:"detachMedia",value:function(){this.removeMediaListeners(),this.hls.detachMedia()}},{key:"resumeBuffering",value:function(){this.hls.resumeBuffering()}},{key:"pauseBuffering",value:function(){this.hls.pauseBuffering()}},{key:"transferMedia",value:function(){return this.hls.transferMedia()}},{key:"on",value:function(e,t,r){this.hls.on(e,t)}},{key:"once",value:function(e,t,r){this.hls.once(e,t)}},{key:"off",value:function(e,t,r){this.hls.off(e,t)}},{key:"toString",value:function(){var e,t;return _concatInstanceProperty(e=_concatInstanceProperty(t="HlsAssetPlayer: ".concat(eventAssetToString(this.assetItem)," ")).call(t,this.hls.sessionId," ")).call(e,this.interstitial.appendInPlace?"append-in-place":"")}}]),e}(),ABUTTING_THRESHOLD_SECONDS=.033,InterstitialsSchedule=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,"interstitials-sched",n)).onScheduleUpdate=void 0,a.eventMap={},a.events=null,a.items=null,a.durations={primary:0,playout:0,integrated:0},a.onScheduleUpdate=e,a}return _createClass$1(r,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){var e;(this.eventMap={},this.setDurations(0,0,0),this.events)&&_forEachInstanceProperty(e=this.events).call(e,(function(e){return e.reset()}));this.events=this.items=null}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);var n=this.items;if(n)for(n[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(a=n[r])&&a.event;){var a;r--}return r}},{key:"findItemIndexAtTime",value:function(e,t){var r=this.items;if(r)for(var n=0;n<r.length;n++){var a=r[n];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return n}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var r=this.items;if(r)for(var n=e;n<=t&&r[n];n++){var a=r[n].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return n}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var r=t.length;r--;){var n;if((null==(n=t[r].event)?void 0:n.identifier)===e)return r}return-1}},{key:"findAssetIndex",value:function(e,t){var r=e.assetList,n=r.length;if(n>1)for(var a=0;a<n;a++){var i=r[a];if(!i.error){var s=i.timelineStart;if(t===s||t>s&&t<s+(i.duration||0))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t,r=null==(e=this.items)||null==(t=e[this.length-1])?void 0:t.event;if(r){var n=r.assetList,a=n[n.length-1];if(a)return a.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e){var t=this,r=e.main.details,n=r.dateRanges,a=this.events,i=this.parseDateRanges(n,{url:r.url}),s=_Object$keys(n),o=a?_filterInstanceProperty(a).call(a,(function(e){return!_includesInstanceProperty(s).call(s,e.identifier)})):[];i.length&&_sortInstanceProperty(i).call(i,(function(e,t){var r=e.cue.pre,n=e.cue.post,a=t.cue.pre,i=t.cue.post;if(r&&!a)return-1;if(a&&!r)return 1;if(n&&!i)return 1;if(i&&!n)return-1;if(!(r||a||n||i)){var s=e.startTime,o=t.startTime;if(s!==o)return s-o}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=i,_forEachInstanceProperty(o).call(o,(function(e){t.removeEvent(e)})),this.updateSchedule(e,o)}},{key:"updateSchedule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.events||[];if(r.length||t.length||this.length<2){var n=this.items,a=this.parseSchedule(r,e),i=t.length||(null==n?void 0:n.length)!==a.length||_someInstanceProperty(a).call(a,(function(e,t){return Math.abs(e.playout.start-n[t].playout.start)>.005||Math.abs(e.playout.end-n[t].playout.end)>.005}));i&&(this.items=a,this.onScheduleUpdate(t,n))}}},{key:"parseDateRanges",value:function(e,t){for(var r=[],n=_Object$keys(e),a=0;a<n.length;a++){var i=n[a],s=e[i];if(s.isInterstitial){var o=this.eventMap[i];o?o.setDateRange(s):(o=new InterstitialEvent(s,t),this.eventMap[i]=o),r.push(o)}}return r}},{key:"parseSchedule",value:function(e,t){var r=[],n=t.main.details,a=n.live?1/0:n.edge,i=0;if((e=_filterInstanceProperty(e).call(e,(function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(_forEachInstanceProperty(e).call(e,(function(t,n){var l=t.cue.pre,c=t.cue.post,u=e[n-1]||null,d=t.appendInPlace,f=c?a:t.startOffset,h=t.duration,p=t.timelineOccupancy===TimelineOccupancy.Range?h:0,y=t.resumptionOffset,g=(null==u?void 0:u.startTime)===f,v=f+t.cumulativeDuration,m=d?v+h:f+y;if(l||!c&&f<=0){var E=o;o+=p,t.timelineStart=v;var $=i;i+=h,r.push({event:t,start:v,end:m,playout:{start:$,end:i},integrated:{start:E,end:o}})}else{if(!(f<=a))return;if(!g){var S=f-s;if(S>ABUTTING_THRESHOLD_SECONDS){var T=s,I=o;o+=S;var _=i;i+=S;var P={previousEvent:e[n-1]||null,nextEvent:t,start:T,end:T+S,playout:{start:_,end:i},integrated:{start:I,end:o}};r.push(P)}else S>0&&u&&(u.cumulativeDuration+=S,r[r.length-1].end=f)}c&&(m=v),t.timelineStart=v;var b=o;o+=p;var A=i;i+=h,r.push({event:t,start:v,end:m,playout:{start:A,end:i},integrated:{start:b,end:o}})}var k=t.resumeTime;s=c||k>a?a:k})),s<a){var l,c=s,u=o,d=a-s;o+=d;var f=i;i+=d,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:s,end:c+d,playout:{start:f,end:i},integrated:{start:u,end:o}})}this.setDurations(a,i,o)}else{r.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return r}},{key:"setDurations",value:function(e,t,r){this.durations={primary:e,playout:t,integrated:r}}},{key:"resolveOffsets",value:function(e,t){var r=this,n=t.main.details,a=n.live?1/0:n.edge,i=0,s=-1;_forEachInstanceProperty(e).call(e,(function(o,l){var c=o.cue.pre,u=o.cue.post,d=c?0:u?a:o.startTime;(r.updateAssetDurations(o),s===d?o.cumulativeDuration=i:(i=0,s=d),!u&&o.snapOptions.in&&(o.resumeAnchor=findFragmentByPTS(null,n.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(r.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));if(!o.appendInPlace)for(var f=l-1;l--;){e[f+1].startTime-e[f].resumeTime<ABUTTING_THRESHOLD_SECONDS&&(e[f].appendInPlace=!1)}var h=isFiniteNumber(o.resumeOffset)?o.resumeOffset:o.duration;i+=h}))}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var r,n,a,i,s=this,o=e.resumeTime,l=e.startTime+e.resumptionOffset;return Math.abs(o-l)>ALIGNED_END_THRESHOLD_SECONDS?(this.log(_concatInstanceProperty(n=_concatInstanceProperty(a='"'.concat(e.identifier,'" resumption ')).call(a,o," not aligned with estimated timeline end ")).call(n,l)),!1):t?!_someInstanceProperty(r=_Object$keys(t)).call(r,(function(r){var n,a,i,l=t[r].details,c=l.edge;if(o>c)return s.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i='"'.concat(e.identifier,'" resumption ')).call(i,o," past ")).call(a,r," playlist end ")).call(n,c)),!0;var u,d,f=findFragmentByPTS(null,l.fragments,o);if(!f)return s.log(_concatInstanceProperty(u=_concatInstanceProperty(d='"'.concat(e.identifier,'" resumption ')).call(d,o," does not align with any fragments in ")).call(u,r," playlist")),!0;var h,p,y,g,v,m,E="audio"===r?.175:0;return!(Math.abs(f.start-o)<ALIGNED_END_THRESHOLD_SECONDS||Math.abs(f.end-o)<ALIGNED_END_THRESHOLD_SECONDS+E)&&(s.log(_concatInstanceProperty(h=_concatInstanceProperty(p=_concatInstanceProperty(y=_concatInstanceProperty(g=_concatInstanceProperty(v=_concatInstanceProperty(m='"'.concat(e.identifier,'" resumption ')).call(m,o," not aligned with ")).call(v,r," fragment bounds (")).call(g,f.start,"-")).call(y,f.end," sn: ")).call(p,f.sn," cc: ")).call(h,f.cc,")")),!0)})):(this.log(_concatInstanceProperty(i='"'.concat(e.identifier,'" resumption ')).call(i,o," can not be aligned with media (none selected)")),!1)}},{key:"updateAssetDurations",value:function(e){var t,r=e.timelineStart,n=0,a=!1,i=!1;_forEachInstanceProperty(t=e.assetList).call(t,(function(e,t){var s=r+n;e.startOffset=n,e.timelineStart=s,a||(a=null===e.duration),i||(i=!!e.error);var o=e.error?0:e.duration||0;n+=o})),e.duration=a&&!i?Math.max(n,e.duration):n}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}]),r}();function segmentToString(e){var t,r;return _concatInstanceProperty(t=_concatInstanceProperty(r="[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ")).call(r,e.start.toFixed(2),"-")).call(t,e.end.toFixed(2),"]")}var AssetListLoader=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.hls=t}return _createClass$1(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,n=this,a=e.assetListUrl;try{r=getInterstitialUrl(a,this.hls.sessionId,e.baseUrl)}catch(t){var i=this.assignAssetListError(e,ErrorDetails.ASSET_LIST_LOAD_ERROR,t,a);return void this.hls.trigger(Events.ERROR,i)}if(t&&!e.cue.pre&&!e.cue.post&&"data:"!==r.protocol){var s=t-e.startTime;s>0&&r.searchParams.set("_HLS_start_offset",""+Math.round(1e3*s)/1e3)}var o=this.hls.config,l=new(0,o.loader)(o),c={responseType:"json",url:r.href},u=o.interstitialAssetListLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(t,r,a,i){var s=t.data,o=null==s?void 0:s.ASSETS;if(_Array$isArray(o))e.assetListResponse=s,n.hls.trigger(Events.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:i});else{var l=n.assignAssetListError(e,ErrorDetails.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),a.url,r,i);n.hls.trigger(Events.ERROR,l)}},onError:function(t,r,a,i){var s,o,l=n.assignAssetListError(e,ErrorDetails.ASSET_LIST_LOAD_ERROR,new Error(_concatInstanceProperty(s=_concatInstanceProperty(o="Error loading X-ASSET-LIST: HTTP status ".concat(t.code," ")).call(o,t.text," (")).call(s,r.url,")")),r.url,i,a);n.hls.trigger(Events.ERROR,l)},onTimeout:function(t,r,a){var i=n.assignAssetListError(e,ErrorDetails.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,a);n.hls.trigger(Events.ERROR,i)}};return l.load(c,d,f),this.hls.trigger(Events.ASSET_LIST_LOADING,{event:e}),l}},{key:"assignAssetListError",value:function(e,t,r,n,a,i){return e.error=r,{type:ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:r,networkDetails:i,stats:a}}}]),e}();function playWithCatch(e){null==e||e.play().catch()}var InterstitialsController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,"interstitials",e.logger)).HlsPlayerClass=void 0,a.hls=void 0,a.assetListLoader=void 0,a.mediaSelection=null,a.altSelection=null,a.media=null,a.detachedData=null,a.requiredTracks=null,a.manager=null,a.playerQueue=[],a.bufferedPos=-1,a.timelinePos=-1,a.schedule=void 0,a.playingItem=null,a.bufferingItem=null,a.waitingItem=null,a.playingAsset=null,a.bufferingAsset=null,a.shouldPlay=!1,a.onPlay=function(){a.shouldPlay=!0},a.onPause=function(){a.shouldPlay=!1},a.onSeeking=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled){var t=e-a.timelinePos;if(!(Math.abs(t)<1/7056e5)){var r=t<=-.01;a.timelinePos=e,a.bufferedPos=e,a.checkBuffer();var n=a.playingItem;if(n)if(r&&e<n.start||e>=n.end){var i,s=a.schedule.findItemIndexAtTime(a.timelinePos);if(!a.isInterstitial(n)&&null!=(i=a.media)&&i.paused&&(a.shouldPlay=!1),!r){var o=a.findItemIndex(n);if(s>o){var l=a.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void a.setSchedulePosition(l)}}a.setSchedulePosition(s)}else{var c=a.playingAsset;if(c){var u=c.timelineStart,d=c.duration||0;(r&&e<u||e>=u+d)&&a.setScheduleToAssetAtTime(e,c)}else if(a.playingLastItem&&a.isInterstitial(n)){var f=n.event.assetList[0];f&&(a.playingItem=null,a.setScheduleToAssetAtTime(e,f))}}}}},a.onTimeupdate=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled&&e>a.timelinePos){e>a.bufferedPos&&a.checkBuffer(),a.timelinePos=e;var t=a.playingItem;if(t&&!a.playingLastItem){if(e>=t.end){a.timelinePos=t.end;var r=a.findItemIndex(t);a.setSchedulePosition(r+1)}var n=a.playingAsset;if(n)e>=n.timelineStart+(n.duration||0)&&a.setScheduleToAssetAtTime(e,n)}}},a.onScheduleUpdate=function(e,t){var r,n,i,s=a.schedule,o=a.playingItem,l=s.events||[],c=s.items||[],u=s.durations,d=_mapInstanceProperty(e).call(e,(function(e){return e.identifier})),f=!(!l.length&&!d.length);f&&(!1===a.hls.config.interstitialAppendInPlace&&_forEachInstanceProperty(l).call(l,(function(e){return e.appendInPlace=!1})),a.log(_concatInstanceProperty(n=_concatInstanceProperty(i="INTERSTITIALS_UPDATED (".concat(l.length,"): ")).call(i,l,"\nSchedule: ")).call(n,_mapInstanceProperty(c).call(c,(function(e){return segmentToString(e)})))));d.length&&a.log("Removed events ".concat(d)),_forEachInstanceProperty(r=a.playerQueue).call(r,(function(e){if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(o){var n,i,s;if(Math.abs(r)>ALIGNED_END_THRESHOLD_SECONDS)a.warn(_concatInstanceProperty(n=_concatInstanceProperty(i=_concatInstanceProperty(s="".concat(o,' ("')).call(s,e.assetId,'" ')).call(i,e.timelineOffset,"->")).call(n,t,")"))}}})),o&&!o.event&&(a.playingItem=a.updateItem(o,a.timelinePos));var h=a.bufferingItem;if(h&&(h.event?a.updateItem(h)||(a.bufferingItem=null,a.clearInterstitial(h.event,null)):a.bufferingItem=a.updateItem(h,a.bufferedPos)),a.waitingItem=a.updateItem(a.waitingItem),_forEachInstanceProperty(e).call(e,(function(e){var t;_forEachInstanceProperty(t=e.assetList).call(t,(function(e){a.clearAssetPlayer(e.identifier,null)}))})),f||t){if(a.hls.trigger(Events.INTERSTITIALS_UPDATED,{events:_sliceInstanceProperty(l).call(l,0),schedule:_sliceInstanceProperty(c).call(c,0),durations:u,removedIds:d}),a.isInterstitial(o)&&_includesInstanceProperty(d).call(d,o.event.identifier))return a.warn('Interstitial "'.concat(o.event.identifier,'" removed while playing')),void a.primaryFallback(o.event);a.checkBuffer()}},a.hls=e,a.HlsPlayerClass=n,a.assetListLoader=new AssetListLoader(e),a.schedule=new InterstitialsSchedule(a.onScheduleUpdate,e.logger),a.registerListeners(),a}return _createClass$1(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Events.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Events.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(Events.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(Events.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Events.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(Events.MEDIA_ENDED,this.onMediaEnded,this),e.on(Events.ERROR,this.onError,this),e.on(Events.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Events.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Events.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(Events.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(Events.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Events.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(Events.MEDIA_ENDED,this.onMediaEnded,this),e.off(Events.ERROR,this.onError,this),e.off(Events.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;_forEachInstanceProperty(e=this.playerQueue).call(e,(function(e){return e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){var e;_forEachInstanceProperty(e=this.playerQueue).call(e,(function(e){return e.pauseBuffering()}))}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){e.removeEventListener("play",this.onPlay),e.removeEventListener("pause",this.onPause),e.removeEventListener("seeking",this.onSeeking),e.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media;this.removeMediaListeners(r),r.addEventListener("seeking",this.onSeeking),r.addEventListener("timeupdate",this.onTimeupdate),r.addEventListener("play",this.onPlay),r.addEventListener("pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var r=this.playingItem,n=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!n){this.clearScheduleState();var a=this.findItemIndex(r);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.playingItem=this.bufferingItem=this.waitingItem=this.playingAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,n=this.media;if(this.media=null,!r&&(n&&this.removeMediaListeners(n),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.playingAsset=null,this.bufferingAsset=null,this.bufferingItem=null,this.waitingItem=null,this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.manager){if(!this.hls||!this.schedule.events)return null;var e=this,t=function(){return e.bufferingItem||e.waitingItem},r=function(){return e.playingItem||e.waitingItem},n=function(t){return t?e.getAssetPlayer(t.identifier):t},a=function(t,r,a,i,o){if(t){var l=t[r].start,c=t.event;if(c){if("playout"===r||c.timelineOccupancy!==TimelineOccupancy.Point){var u=n(a);(null==u?void 0:u.interstitial)===c&&(l+=u.assetItem.startOffset+u[o])}}else l+=("bufferedPos"===i?s():e[i])-t.start;return l}return 0},i=function(t,r){if(0!==t&&"primary"!==r&&e.schedule.length){var n,a=e.schedule.findItemIndexAtTime(t),i=null==(n=e.schedule.items)?void 0:n[a];if(i)return t+(i[r].start-i.start)}return t},s=function(){var t=e.bufferedPos;return t===Number.MAX_VALUE?o("primary"):t},o=function(t){var r;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:e.schedule.durations[t]},l=function(t,i){var s,o,l,c=r();if(null==c||null==(o=c.event)||!o.restrictions.skip){e.log(_concatInstanceProperty(s="seek to ".concat(t,' "')).call(s,i,'"'));var u=r(),d=e.schedule.findItemIndexAtTime(t,i),f=null==(l=e.schedule.items)?void 0:l[d],h=null==u?void 0:u.event,p=null==h?void 0:h.appendInPlace,y=u&&e.itemsMatch(u,f);if(u&&(p||y)){var g=n(e.playingAsset),v=(null==g?void 0:g.media)||e.hls.media;if(v){var m=t-("primary"===i?v.currentTime:a(u,i,e.playingAsset,"timelinePos","currentTime")),E=v.currentTime+m;if(E>=0&&(!g||p||E<=g.duration))return void(v.currentTime=E)}}if(f){var $=t;if("primary"!==i){var S=t-f[i].start;$=f.start+S}var T=!e.isInterstitial(f);if(e.isInterstitial(u)||!T&&!f.event.appendInPlace){if(u){var I=e.findItemIndex(u);if(d>I){var _=e.schedule.findJumpRestrictedIndex(I+1,d);if(_>I)return void e.setSchedulePosition(_)}var P=0;if(T)e.timelinePos=$;else{var b,A=null==f||null==(b=f.event)?void 0:b.assetList;if(A)for(var k=t-(f[i]||f).start,R=A.length;R--;){var C=A[R];if(C.duration&&k>=C.startOffset&&k<C.startOffset+C.duration){P=R;break}}}e.setSchedulePosition(d,P)}}else{var O=e.hls.media;O&&(O.currentTime=$)}}}};this.manager={get events(){var t,r;return(null==(t=e.schedule)||null==(r=t.events)?void 0:_sliceInstanceProperty(r).call(r,0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:_sliceInstanceProperty(r).call(r,0))||[]},get playerQueue(){var t;return _sliceInstanceProperty(t=e.playerQueue).call(t,0)},get bufferingPlayer(){return e.getBufferingPlayer()},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return e.bufferingItem},get playingAsset(){return e.playingAsset},get playingItem(){return e.playingItem},get bufferingIndex(){var r=t();return e.findItemIndex(r)},get playingIndex(){var t=r();return e.findItemIndex(t)},get waitingIndex(){return e.findItemIndex(e.waitingItem)},primary:{get bufferedEnd(){return s()},get currentTime(){var t=e.timelinePos;return t>0?t:0},get duration(){return o("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0},seekTo:function(e){return l(e,"primary")}},playout:{get bufferedEnd(){return a(t(),"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return a(r(),"playout",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("playout")},get seekableStart(){var t;return i((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"playout")},seekTo:function(e){return l(e,"playout")}},integrated:{get bufferedEnd(){return a(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return a(r(),"integrated",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("integrated")},get seekableStart(){var t;return i((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")},seekTo:function(e){return l(e,"integrated")}},skip:function(){var t=r(),n=null==t?void 0:t.event;if(n&&!n.restrictions.skip){var a=e.findItemIndex(t);if(n.appendInPlace){var i=t.playout.start+t.event.duration;l(i+.001,"playout")}else e.advanceAfterAssetEnded(n,a,1/0)}}}}return this.manager}},{key:"playingLastItem",get:function(){var e,t=this.playingItem;if(!this.playbackStarted||!t)return!1;var r=null==(e=this.schedule)?void 0:e.items;return this.itemsMatch(t,r?r[r.length-1]:null)}},{key:"playbackStarted",get:function(){return null!==this.playingItem}},{key:"currentTime",get:function(){var e,t,r;if(null!==this.mediaSelection){var n=this.waitingItem||this.playingItem;if(!this.isInterstitial(n)||n.event.appendInPlace){var a=this.media;!a&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(a=this.primaryMedia);var i=null==(r=a)?void 0:r.currentTime;if(void 0!==i&&isFiniteNumber(i))return i}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var r=e.interstitial.appendInPlace,n=e.media;if(r&&n===this.primaryMedia){var a;if(!t||this.isInterstitial(t)&&!t.event.appendInPlace)return void(t&&n&&(this.detachedData={media:n}));var i=e.transferMedia();this.log(_concatInstanceProperty(a="transfer MediaSource from ".concat(e," ")).call(a,_JSON$stringify(i))),this.bufferingAsset=null,this.detachedData=i}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}},{key:"transferMediaTo",value:function(e,t){var r,n,a,i,s,o,l=null,c=this.hls,u=e!==c,d=u&&e.interstitial.appendInPlace,f=null==(i=this.detachedData)?void 0:i.mediaSource;if(c.media&&d)l=c.transferMedia(),this.detachedData=l,o="Primary";else if(f){var h=this.getBufferingPlayer();h&&(l=h.transferMedia()),o="".concat(h)}else o="<unknown>";this.log(_concatInstanceProperty(r=_concatInstanceProperty(n="transferring to ".concat(u?e:"Primary","\nMediaSource ")).call(n,_JSON$stringify(l)," from ")).call(r,o)),l||(f?(l=this.detachedData,this.log("using detachedData: MediaSource ".concat(_JSON$stringify(l)))):this.detachedData&&this.hls.media!==t||(this.hls.detachMedia(),this.detachedData={media:t}));var p=l&&"mediaSource"in l&&"closed"!==(null==(s=l.mediaSource)?void 0:s.readyState),y=p&&l?l:t;if(this.log(_concatInstanceProperty(a="".concat(p?"transfering MediaSource":"attaching media"," to ")).call(a,u?e:"Primary")),y===l){var g=u&&e.assetId===this.schedule.assetIdAtEnd;y.overrides={duration:this.schedule.duration,endOfStream:!u||g,cueRemoval:!1}}e.attachMedia(y)}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=e.events;if(t&&!this.playbackDisabled){-1===this.bufferedPos&&(this.bufferedPos=0);var r=this.timelinePos,n=this.waitingItem;if(-1===r){var a=this.hls.startPosition;if(this.timelinePos=a,t.length&&t[0].cue.pre){var i=e.findEventIndex(t[0].identifier);this.setSchedulePosition(i)}else if(a>=0||!this.primaryLive){var s=this.timelinePos=a>0?a:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(n&&!this.playingItem){var l=e.findItemIndex(n);this.setSchedulePosition(l)}}}},{key:"advanceAfterAssetEnded",value:function(e,t,r){var n=r+1;if(e.isAssetPastPlayoutLimit(n)||e.assetList[n].error){var a=this.schedule.items;if(a){var i=t+1;if(i>=a.length)return void this.setSchedulePosition(-1);this.setSchedulePosition(i)}}else this.setSchedulePosition(t,n)}},{key:"setScheduleToAssetAtTime",value:function(e,t){var r=this.schedule,n=t.parentIdentifier,a=r.getEvent(n);if(a){var i=r.findEventIndex(n),s=r.findAssetIndex(a,e);this.setSchedulePosition(i,s)}}},{key:"setSchedulePosition",value:function(e,t){var r,n=this,a=this.schedule.items;if(a&&!this.playbackDisabled){this.log(_concatInstanceProperty(r="setSchedulePosition ".concat(e,", ")).call(r,t));var i=e>=0?a[e]:null,s=this.primaryMedia,o=this.playingItem,l=this.playingLastItem;if(this.isInterstitial(o)){var c,u,d=o.event,f=this.playingAsset,h=null==f?void 0:f.identifier,p=h?this.getAssetPlayer(h):null;if(p&&h&&(!this.eventItemsMatch(o,i)||void 0!==t&&h!==(null==(c=d.assetList)?void 0:c[t].identifier))){var y,g;this.playingAsset=null;var v=d.findAssetIndex(f);this.log(_concatInstanceProperty(y=_concatInstanceProperty(g="INTERSTITIAL_ASSET_ENDED ".concat(v+1,"/")).call(g,d.assetList.length," ")).call(y,eventAssetToString(f))),this.hls.trigger(Events.INTERSTITIAL_ASSET_ENDED,{asset:f,assetListIndex:v,event:d,schedule:_sliceInstanceProperty(a).call(a,0),scheduleIndex:e,player:p}),this.retreiveMediaSource(h,i),p.media&&!this.detachedData&&p.detachMedia(),this.clearAssetPlayer(h,i)}if(!this.eventItemsMatch(o,i))if(this.playingItem=null,this.log(_concatInstanceProperty(u="INTERSTITIAL_ENDED ".concat(d," ")).call(u,segmentToString(o))),d.hasPlayed=!0,this.hls.trigger(Events.INTERSTITIAL_ENDED,{event:d,schedule:_sliceInstanceProperty(a).call(a,0),scheduleIndex:e}),this.clearInterstitial(d,i),d.cue.once){if(this.updateSchedule(),i){var m=this.schedule.findItemIndex(i);this.setSchedulePosition(m,t)}return}}var E=this.playerQueue;if(E.length&&_forEachInstanceProperty(E).call(E,(function(t){var r=t.interstitial,a=n.schedule.findEventIndex(r.identifier);(a<e||a>e+1)&&n.clearInterstitial(r,i)})),this.isInterstitial(i)){this.timelinePos=Math.min(Math.max(this.timelinePos,i.start),i.end);var $=i.event;void 0===t&&(t=this.schedule.findAssetIndex($,this.timelinePos));var S,T=this.waitingItem,I=this.preloadAssets($,t);if(I||this.setBufferingItem(i),!this.eventItemsMatch(i,o||T))this.waitingItem=i,this.log(_concatInstanceProperty(S="INTERSTITIAL_STARTED ".concat(segmentToString(i)," ")).call(S,$.appendInPlace?"append in place":"")),this.hls.trigger(Events.INTERSTITIAL_STARTED,{event:$,schedule:_sliceInstanceProperty(a).call(a,0),scheduleIndex:e});var _=$.assetList.length;if(0===_&&!$.assetListResponse)return void this.log("Waiting for ASSET-LIST to complete loading ".concat($));if($.assetListLoader&&($.assetListLoader.destroy(),$.assetListLoader=void 0),!s)return void this.log("Waiting for attachMedia to start Interstitial ".concat($));this.waitingItem=null,this.playingItem=i;var P,b,A=$.assetList[t];if(!A){var k=a[e+1],R=this.media;return k&&R&&!this.isInterstitial(k)&&R.currentTime<k.start&&(R.currentTime=this.timelinePos=k.start),void this.advanceAfterAssetEnded($,e,t||0)}if(I||(I=this.getAssetPlayer(A.identifier)),null===I||I.destroyed)this.warn(_concatInstanceProperty(P=_concatInstanceProperty(b="asset ".concat(t+1,"/")).call(b,_," player destroyed ")).call(P,$)),I=this.createAssetPlayer($,A,t);if(!this.eventItemsMatch(i,this.bufferingItem)&&$.appendInPlace&&this.isAssetBuffered(A))return;this.startAssetPlayer(I,t,a,e,s),this.shouldPlay&&playWithCatch(I.media)}else null!==i?(this.resumePrimary(i,e,o),this.shouldPlay&&playWithCatch(this.hls.media)):l&&this.isInterstitial(o)&&(this.playingItem=o,o.event.appendInPlace||this.attachPrimary(this.schedule.durations.primary,null))}}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e,t;return null==(e=this.mediaSelection)||null==(t=e.main)?void 0:t.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,r){var n;if(this.playingItem=e,this.playingAsset=null,this.waitingItem=null,this.bufferedToItem(e),this.log("resuming ".concat(segmentToString(e))),null==(n=this.detachedData)||!n.mediaSource){var a=this.timelinePos;(a<e.start||a>=e.end)&&(a=this.getPrimaryResumption(e,t),this.timelinePos=a),this.attachPrimary(a,e)}if(r){var i=this.schedule.items;i&&(this.log("resumed ".concat(segmentToString(e))),this.hls.trigger(Events.INTERSTITIALS_PRIMARY_RESUMED,{schedule:_sliceInstanceProperty(i).call(i,0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var r=e.start;if(this.primaryLive){var n=this.primaryDetails;if(0===t)return this.hls.startPosition;if(n&&(r<n.fragmentStart||r>n.edge))return this.hls.liveSyncPosition||-1}return r}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:BufferHelper.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,r){t?this.setBufferingItem(t):this.bufferingItem=null,this.bufferingAsset=null;var n=this.primaryMedia;if(n){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,n),r&&this.startLoadingPrimaryAt(e,r)),r||(this.timelinePos=e,this.startLoadingPrimaryAt(e,r))}}},{key:"startLoadingPrimaryAt",value:function(e,t){this.hls.loadingEnabled&&this.hls.startLoad(e,t)}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.schedule.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(Events.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(Events.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],n=_objectSpread2(_objectSpread2({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n),!this.playingItem&&this.schedule.items&&this.checkStart()}}},{key:"onAudioTrackUpdated",value:function(e,t){var r=this.hls.audioTracks[t.id],n=this.mediaSelection;if(n){var a=_objectSpread2(_objectSpread2({},n),{},{audio:r});this.mediaSelection=a}else this.altSelection=_objectSpread2(_objectSpread2({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(n){var a=_objectSpread2(_objectSpread2({},n),{},{subtitles:r});this.mediaSelection=a}else this.altSelection=_objectSpread2(_objectSpread2({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r,n=getBasicSelectionOption(t);_forEachInstanceProperty(r=this.playerQueue).call(r,(function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(n)}))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r,n=getBasicSelectionOption(t);_forEachInstanceProperty(r=this.playerQueue).call(r,(function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(n)}))}},{key:"onBufferCodecs",value:function(e,t){var r=t.tracks;r&&(this.requiredTracks=r)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var r=this.playingItem;if(r&&r!==this.bufferingItem&&!this.isInterstitial(r)){var n=this.timelinePos;this.bufferedPos=n,this.setBufferingItem(r)}}},{key:"onBufferedToEnd",value:function(e){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var r=0;r<t.length;r++){var n=t[r];if(n.cue.post){var a,i=this.schedule.findEventIndex(n.identifier),s=null==(a=this.schedule.items)?void 0:a[i];this.isInterstitial(s)&&this.eventItemsMatch(s,this.bufferingItem)&&this.bufferedToItem(s,0);break}}this.bufferedPos=Number.MAX_VALUE}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var r=this.findItemIndex(t);this.setSchedulePosition(r+1)}}},{key:"updateItem",value:function(e,t){var r=this.schedule.items;return e&&r&&r[this.findItemIndex(e,t)]||null}},{key:"itemsMatch",value:function(e,t){var r,n;return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&(null==(r=e.nextEvent)?void 0:r.identifier)===(null==(n=t.nextEvent)?void 0:n.identifier))}},{key:"eventItemsMatch",value:function(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}},{key:"findItemIndex",value:function(e,t){return e?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(){var e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[])}},{key:"checkBuffer",value:function(){var e=this.schedule.items;if(e){var t=BufferHelper.bufferInfo(this.primaryMedia,this.timelinePos,0);this.updateBufferedPos(t.end,e,0===t.len)}}},{key:"updateBufferedPos",value:function(e,t,r){var n=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var i=this.playingItem,s=this.findItemIndex(i),o=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,c=this.findItemIndex(a),u=Math.min(c+1,t.length-1),d=t[u];if(-1===o&&a&&e>=a.end&&(o=u),u-s>1&&!1===(null==a||null==(l=a.event)?void 0:l.appendInPlace))return;if(this.bufferedPos=e,o>c&&o>s)this.bufferedToItem(d);else{var f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&d.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(d)&&this.preloadAssets(d.event,0)}}else r&&i&&a!==i&&o===s&&this.bufferedToItem(i)}}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,r=this.schedule,n=r.items,a=r.events;if(n&&a&&(!t||r.findItemIndex(t)!==r.findItemIndex(e))){var i,s,o=this.isInterstitial(e),l=this.getBufferingPlayer(),c=l?l.remaining:t?t.end-this.timelinePos:0;if(this.log("buffered to boundary ".concat(segmentToString(e))+(t?" (".concat(c.toFixed(2)," remaining)"):"")),this.bufferingItem=e,this.bufferedPos=e.start,!this.playbackDisabled)if(o)_forEachInstanceProperty(i=this.playerQueue).call(i,(function(e){return e.resumeBuffering()}));else this.hls.resumeBuffering(),_forEachInstanceProperty(s=this.playerQueue).call(s,(function(e){return e.pauseBuffering()}));this.hls.trigger(Events.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:_sliceInstanceProperty(a).call(a,0),schedule:_sliceInstanceProperty(n).call(n,0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}return t}},{key:"bufferedToItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;var n=this.detachedData;if(n)if(n.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}},{key:"bufferedToEvent",value:function(e,t){var r=e.event,n=0===r.assetList.length&&!r.assetListLoader,a=r.cue.once;if(n||!a){var i=this.preloadAssets(r,t);if(null!=i&&i.interstitial.appendInPlace){var s=r.assetList[t],o=this.primaryMedia;s&&o&&this.bufferAssetPlayer(i,o)}}}},{key:"preloadAssets",value:function(e,t){var r=e.assetList.length,n=0===r&&!e.assetListLoader,a=e.cue.once;if(n){var i,s;this.log(_concatInstanceProperty(i=_concatInstanceProperty(s="Load interstitial asset ".concat(t+1,"/")).call(s,r," ")).call(i,e));var o=e.timelineStart;e.appendInPlace&&this.flushFrontBuffer(o);var l=e.assetUrl;if(l)return this.createAsset(e,0,0,o,e.duration,l);var c=0;!this.playingItem&&this.primaryLive&&-1===(c=this.hls.startPosition)&&(c=this.hls.liveSyncPosition||0);var u=this.assetListLoader.loadAssetList(e,c);u&&(e.assetListLoader=u)}else if(!a&&r){for(var d=t;d<r;d++){var f=e.assetList[d],h=this.getAssetPlayerQueueIndex(f.identifier);-1!==h&&!this.playerQueue[h].destroyed||f.error||this.createAssetPlayer(e,f,d)}return this.getAssetPlayer(e.assetList[t].identifier)}return null}},{key:"flushFrontBuffer",value:function(e){var t=this,r=this.requiredTracks;if(r){var n=_Object$keys(r);_forEachInstanceProperty(n).call(n,(function(r){t.hls.trigger(Events.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r})}))}}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}},{key:"createAsset",value:function(e,t,r,n,a,i){var s={parentIdentifier:e.identifier,identifier:generateAssetIdentifier(e,i,t),duration:a,startOffset:r,timelineStart:n,uri:i};return this.createAssetPlayer(e,s,t)}},{key:"createAssetPlayer",value:function(e,t,r){var n=this;this.log("create HLSAssetPlayer for ".concat(eventAssetToString(t)));var a=this.hls,i=a.userConfig,s=i.videoPreference,o=a.levels[a.loadLevel]||a.levels[a.currentLevel];(s||o)&&(s=_extends({},s),o.videoCodec&&(s.videoCodec=o.videoCodec),o.videoRange&&(s.allowedVideoRanges=[o.videoRange]));var l=a.audioTracks[a.audioTrack],c=a.subtitleTracks[a.subtitleTrack],u=0;if(this.primaryLive){var d=this.timelinePos-t.timelineStart;if(d>1){var f=t.duration;f&&d<f&&(u=d)}}var h=_objectSpread2(_objectSpread2({},i),{},{autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:a.sessionId,assetPlayerId:t.identifier,abrEwmaDefaultEstimate:a.bandwidthEstimate,interstitialsController:void 0,startPosition:u,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:l||i.audioPreference,subtitlePreference:c||i.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(h.timelineOffset=t.timelineStart));var p=h.cmcd;null!=p&&p.sessionId&&p.contentId&&(h.cmcd=_extends({},p,{contentId:hash(t.uri)}));var y=new HlsAssetPlayer(this.HlsPlayerClass,h,e,t);this.playerQueue.push(y),e.assetList[r]=t;var g=t.identifier,v=function(a){if(a.live){var i=new Error("Interstitials MUST be VOD assets ".concat(e)),s={fatal:!0,type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,error:i};n.handleAssetItemError(s,e,n.schedule.findEventIndex(e.identifier),r,i.message)}else{var o,l,c=a.edge-a.fragmentStart,u=t.duration;if(null===u||c>u)n.log(_concatInstanceProperty(o=_concatInstanceProperty(l='Interstitial asset "'.concat(g,'" duration change ')).call(l,u," > ")).call(o,c)),t.duration=c,n.updateSchedule()}};y.on(Events.LEVEL_UPDATED,(function(e,t){var r=t.details;return v(r)})),y.on(Events.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return v(r)}));y.on(Events.BUFFER_CODECS,(function e(t,r){var a=n.getAssetPlayer(g);if(a&&r.tracks){a.off(Events.BUFFER_CODECS,e),a.tracks=r.tracks;var i=n.primaryMedia;n.bufferingAsset===a.assetItem&&i&&!a.media&&n.bufferAssetPlayer(a,i)}}));y.on(Events.BUFFERED_TO_END,(function r(a){var i,s=n.getAssetPlayer(g);if(n.log("buffered to end of asset ".concat(s)),s){s.off(Events.BUFFERED_TO_END,r);var o=n.schedule.findEventIndex(e.identifier),l=e.findAssetIndex(t),c=l+1,u=null==(i=n.schedule.items)?void 0:i[o];if(n.isInterstitial(u))if(-1===l||e.isAssetPastPlayoutLimit(c)||e.assetList[c].error){var d,f=null==(d=n.schedule.items)?void 0:d[o+1];f&&n.bufferedToItem(f)}else n.bufferedToItem(u,l+1)}}));var m=function(t){return function(){if(n.getAssetPlayer(g)){n.shouldPlay=!0;var r=n.schedule.findEventIndex(e.identifier);n.advanceAfterAssetEnded(e,r,t)}}};return y.once(Events.MEDIA_ENDED,m(r)),y.once(Events.PLAYOUT_LIMIT_REACHED,m(1/0)),y.on(Events.ERROR,(function(t,a){var i;n.handleAssetItemError(a,e,n.schedule.findEventIndex(e.identifier),r,_concatInstanceProperty(i="Asset player error ".concat(a.error," ")).call(i,e))})),y.on(Events.DESTROYING,(function(){if(n.getAssetPlayer(g)){var t=new Error("Asset player destroyed unexpectedly ".concat(g)),a={fatal:!0,type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};n.handleAssetItemError(a,e,n.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(Events.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:y}),y}},{key:"clearInterstitial",value:function(e,t){var r,n=this;_forEachInstanceProperty(r=e.assetList).call(r,(function(e){n.clearAssetPlayer(e.identifier,t)})),e.appendInPlaceStarted=!1}},{key:"clearAssetPlayer",value:function(e,t){if(null!==t){var r=this.getAssetPlayerQueueIndex(e);if(-1!==r){var n,a;this.log(_concatInstanceProperty(n='clearAssetPlayer "'.concat(e,'" toSegment: ')).call(n,t?segmentToString(t):t));var i=this.playerQueue[r];this.transferMediaFromPlayer(i,t),_spliceInstanceProperty(a=this.playerQueue).call(a,r,1),i.destroy()}}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,r,n,a){var i,s,o=e.interstitial,l=e.assetItem,c=e.assetId,u=o.assetList.length,d=this.playingAsset;(this.playingAsset=l,d&&d.identifier===c)||(d&&(this.clearAssetPlayer(d.identifier,r[n]),delete d.error),this.log(_concatInstanceProperty(i=_concatInstanceProperty(s="INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/")).call(s,u," ")).call(i,e)),this.hls.trigger(Events.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:o,schedule:_sliceInstanceProperty(r).call(r,0),scheduleIndex:n,player:e}));e.media||this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var r,n,a=e.interstitial,i=e.assetItem,s=e.assetId,o=this.schedule.findEventIndex(a.identifier),l=null==(r=this.schedule.items)?void 0:r[o];if(l){this.setBufferingItem(l),this.bufferingAsset=i;var c=this.getBufferingPlayer();if(c!==e){var u=(null==c?void 0:c.tracks)||(null==(n=this.detachedData)?void 0:n.tracks)||this.requiredTracks;if(a.appendInPlace&&i!==this.playingAsset){if(!e.tracks)return;if(u&&!isCompatibleTrackChange(u,e.tracks)){var d,f,h=new Error(_concatInstanceProperty(d=_concatInstanceProperty(f='Asset "'.concat(s,"\" SourceBuffer tracks ('")).call(f,_Object$keys(e.tracks),"') are not compatible with primary content tracks ('")).call(d,_Object$keys(u),"')")),p={fatal:!0,type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},y=a.findAssetIndex(i);return void this.handleAssetItemError(p,a,o,y,h.message)}}this.transferMediaTo(e,t)}}}},{key:"handleAssetItemError",value:function(e,t,r,n,a){var i;if(e.details!==ErrorDetails.BUFFER_STALLED_ERROR){var s=t.assetList[n]||null,o=null;if(s){var l=this.getAssetPlayerQueueIndex(s.identifier);o=this.playerQueue[l]||null}var c=this.schedule.items,u=_extends({},e,{fatal:!1,errorAction:createDoNothingErrorAction(!0),asset:s,assetListIndex:n,event:t,schedule:c,scheduleIndex:r,player:o});if(this.warn("Asset item error: ".concat(e.error)),this.hls.trigger(Events.INTERSTITIAL_ASSET_ERROR,u),e.fatal){var d=new Error(a);s&&(this.playingAsset!==s&&this.clearAssetPlayer(s.identifier,null),s.error=d),_someInstanceProperty(i=t.assetList).call(i,(function(e){return!e.error}))?t.appendInPlace&&(t.error=d):t.error=d,this.primaryFallback(t)}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,r=this.playingItem||this.waitingItem;if(this.updateSchedule(),r){var n,a,i,s;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s='Fallback to primary from event "'.concat(e.identifier,'" start: ')).call(s,t," pos: ")).call(i,this.timelinePos," playing: ")).call(a,r?segmentToString(r):"<none>"," error: ")).call(n,e.error)),e.appendInPlace&&(e.appendInPlace=!1,this.attachPrimary(t,null),this.flushFrontBuffer(t));var o=this.timelinePos;-1===o&&(o=this.hls.startPosition);var l=this.updateItem(r,o);if(!this.itemsMatch(r,l)){var c=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(c)}}else this.checkStart()}},{key:"onAssetListLoaded",value:function(e,t){var r,n=this,a=t.event,i=a.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(i)){var o=a.timelineStart,l=0;_forEachInstanceProperty(s).call(s,(function(e,t){var r=_parseFloat$1(e.DURATION);n.createAsset(a,t,l,o+l,r,e.URI),l+=r})),a.duration=l;var c=this.waitingItem,u=(null==c?void 0:c.event.identifier)===i;this.updateSchedule();var d=null==(r=this.bufferingItem)?void 0:r.event;if(u){var f,h=this.schedule.findEventIndex(i),p=null==(f=this.schedule.items)?void 0:f[h];p&&this.setBufferingItem(p),this.setSchedulePosition(h)}else if((null==d?void 0:d.identifier)===i&&d.appendInPlace){var y=a.assetList[0],g=this.getAssetPlayer(y.identifier),v=this.primaryMedia;y&&g&&v&&this.bufferAssetPlayer(g,v)}}}},{key:"onError",value:function(e,t){switch(t.details){case ErrorDetails.ASSET_LIST_PARSING_ERROR:case ErrorDetails.ASSET_LIST_LOAD_ERROR:case ErrorDetails.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r)}}}]),r}(),TICK_INTERVAL$1=500,SubtitleStreamController=function(e){_inherits(r,BaseStreamController);var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e,n,a,"subtitle-stream-controller",PlaylistLevelType.SUBTITLE)).currentTrackId=-1,i.tracksBuffered=[],i.mainDetails=null,i.registerListeners(),i}return _createClass$1(r,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){_get(_getPrototypeOf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){_get(_getPrototypeOf(r.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e){this.stopLoad(),this.state=State.IDLE,this.setInterval(TICK_INTERVAL$1),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"onManifestLoading",value:function(){_get(_getPrototypeOf(r.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,t){this.tracksBuffered=[],_get(_getPrototypeOf(r.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var r=t.frag,n=t.success;if(isMediaFragment(r)&&(this.fragPrevious=r),this.state=State.IDLE,n){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var i,s=r.start,o=0;o<a.length;o++)if(s>=a[o].start&&s<=a[o].end){i=a[o];break}var l=r.start+r.duration;i?i.end=l:(i={start:s,end:l},a.push(i)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,n=t.endOffset;if(0===r&&n!==Number.POSITIVE_INFINITY){var a,i=n-1;if(i<=0)return;t.endOffsetSubtitles=Math.max(0,i),_forEachInstanceProperty(a=this.tracksBuffered).call(a,(function(e){for(var t=0;t<e.length;)if(e[t].end<=i)e.shift();else{if(!(e[t].start<i))break;e[t].start=i,t++}})),this.fragmentTracker.removeFragmentsInRange(r,i,PlaylistLevelType.SUBTITLE)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===PlaylistLevelType.SUBTITLE&&(t.details===ErrorDetails.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==State.STOPPED&&(this.state=State.IDLE))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,n=t.subtitleTracks;this.levels&&subtitleOptionsIdentical(this.levels,n)?this.levels=_mapInstanceProperty(n).call(n,(function(e){return new Level(e)})):(this.tracksBuffered=[],this.levels=_mapInstanceProperty(n).call(n,(function(e){var t=new Level(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,PlaylistLevelType.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r;if(this.currentTrackId=t.id,null!=(r=this.levels)&&r.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==State.STOPPED&&this.setInterval(TICK_INTERVAL$1)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,n,a,i,s,o,l=this.currentTrackId,c=this.levels,u=t.details,d=t.id;if(c){var f=c[d];if(!(d>=c.length)&&f){this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i="Subtitle track ".concat(d," loaded [")).call(i,u.startSN,",")).call(a,u.endSN,"]")).call(n,u.lastPartSn?_concatInstanceProperty(s="[part-".concat(u.lastPartSn,"-")).call(s,u.lastPartIndex,"]"):"",",duration:")).call(r,u.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;if(u.live||null!=(o=f.details)&&o.live){var h=this.mainDetails;if(u.deltaUpdateFailed||!h)return;var p,y=h.fragments[0];if(f.details)0===this.alignPlaylists(u,f.details,null==(p=this.levelLastLoaded)?void 0:p.details)&&y&&addSliding(u,y.start);else u.hasProgramDateTime&&h.hasProgramDateTime?(alignMediaPlaylistByPDT(u,h),u.fragmentStart):y&&addSliding(u,y.start)}if(f.details=u,this.levelLastLoaded=f,d===l)if(this.hls.trigger(Events.SUBTITLE_TRACK_UPDATED,{details:u,id:d,groupId:t.groupId}),this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===State.IDLE)findFragmentByPTS(null,u.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0)}}else this.warn("Subtitle tracks were reset while loading level ".concat(d))}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this,r=e.frag,n=e.payload,a=r.decryptdata,i=this.hls;if(!this.fragContextChanged(r)&&n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&isFullSegmentEncryption(a.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,getAesModeFromFullSegmentMethod(a.method)).catch((function(e){throw i.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();i.trigger(Events.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){var r;t.warn(_concatInstanceProperty(r="".concat(e.name,": ")).call(r,e.message)),t.state=State.IDLE}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===State.IDLE){var e=this.currentTrackId,t=this.levels,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;if(this.waitForLive(r))return;var n=this.config,a=this.getLoadPosition(),i=BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),s=i.end,o=i.len,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;var c=l.fragments,u=c.length,d=l.edge,f=null,h=this.fragPrevious;if(s<d){var p=n.maxFragLookUpTolerance,y=s>d-p?0:p;!(f=findFragmentByPTS(h,c,Math.max(c[0].start,s),y))&&h&&h.start<c[0].start&&(f=c[0])}else f=c[u-1];if(!f)return;if(isMediaFragment(f=this.mapToInitFragWhenRequired(f))){var g=c[f.sn-l.startSN-1];g&&g.cc===f.cc&&this.fragmentTracker.getState(g)===FragmentState.NOT_LOADED&&(f=g)}this.fragmentTracker.getState(f)===FragmentState.NOT_LOADED&&this.loadFragment(f,r,s)}}else this.state=State.IDLE}},{key:"loadFragment",value:function(e,t,n){isMediaFragment(e)?_get(_getPrototypeOf(r.prototype),"loadFragment",this).call(this,e,t,n):this._loadInitSegment(e,t)}},{key:"mediaBufferTimeRanges",get:function(){return new BufferableInstance(this.tracksBuffered[this.currentTrackId]||[])}}]),r}(),BufferableInstance=_createClass$1((function e(t){_classCallCheck$1(this,e),this.buffered=void 0;var r=function(e,r,n){var a,i;if((r>>>=0)>n-1)throw new DOMException(_concatInstanceProperty(a=_concatInstanceProperty(i="Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (")).call(i,r,") is greater than the maximum bound (")).call(a,n,")"));return t[r][e]};this.buffered={get length(){return t.length},end:function(e){return r("end",e,t.length)},start:function(e){return r("start",e,t.length)}}})),specialCea608CharsCodes={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},getCharForByte=function(e){return String.fromCharCode(specialCea608CharsCodes[e]||e)},NR_ROWS=15,NR_COLS=100,rowsLowCh1={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},rowsHighCh1={17:2,18:4,21:6,22:8,23:10,19:13,20:15},rowsLowCh2={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},rowsHighCh2={25:2,26:4,29:6,30:8,31:10,27:13,28:15},backgroundColors=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],CaptionsLogger=function(){function e(){_classCallCheck$1(this,e),this.time=null,this.verboseLevel=0}return _createClass$1(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r,n,a="function"==typeof t?t():t;logger.log(_concatInstanceProperty(r=_concatInstanceProperty(n="".concat(this.time," [")).call(n,e,"] ")).call(r,a))}}}]),e}(),numArrayToHexArray=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},PenState=function(){function e(){_classCallCheck$1(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return _createClass$1(e,[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var n=t[r];e.hasOwnProperty(n)&&(this[n]=e[n])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}]),e}(),StyledUnicodeChar=function(){function e(){_classCallCheck$1(this,e),this.uchar=" ",this.penState=new PenState}return _createClass$1(e,[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}]),e}(),Row=function(){function e(t){_classCallCheck$1(this,e),this.chars=[],this.pos=0,this.currPenState=new PenState,this.cueStartTime=null,this.logger=void 0;for(var r=0;r<NR_COLS;r++)this.chars.push(new StyledUnicodeChar);this.logger=t}return _createClass$1(e,[{key:"equals",value:function(e){for(var t=0;t<NR_COLS;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<NR_COLS;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<NR_COLS;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>NR_COLS&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=NR_COLS)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){var t=this;e>=144&&this.backSpace();var r=getCharForByte(e);this.pos>=NR_COLS?this.logger.log(0,(function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<NR_COLS;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,r=0;r<NR_COLS;r++){var n=this.chars[r].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}]),e}(),CaptionScreen=function(){function e(t){_classCallCheck$1(this,e),this.rows=[],this.currRow=NR_ROWS-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var r=0;r<NR_ROWS;r++)this.rows.push(new Row(t));this.logger=t}return _createClass$1(e,[{key:"reset",value:function(){for(var e=0;e<NR_ROWS;e++)this.rows[e].clear();this.currRow=NR_ROWS-1}},{key:"equals",value:function(e){for(var t=!0,r=0;r<NR_ROWS;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<NR_ROWS;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<NR_ROWS;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,(function(){return"pacData = "+_JSON$stringify(e)}));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<NR_ROWS;r++)this.rows[r].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var i=a.rows[n].cueStartTime,s=this.logger.time;if(null!==i&&null!==s&&i<s)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(a.rows[n+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var c=e.indent,u=Math.max(c-1,0);l.setCursor(e.indent),e.color=l.chars[u].penState.foreground}var d={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(d)}},{key:"setBkgData",value:function(e){this.logger.log(2,(function(){return"bkgData = "+_JSON$stringify(e)})),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){var e,t,r=this;if(null!==this.nrRollUpRows){this.logger.log(1,(function(){return r.getDisplayText()}));var n=this.currRow+1-this.nrRollUpRows,a=_spliceInstanceProperty(e=this.rows).call(e,n,1)[0];a.clear(),_spliceInstanceProperty(t=this.rows).call(t,this.currRow,0,a),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],r="",n=-1,a=0;a<NR_ROWS;a++){var i=this.rows[a].getTextString();i&&(n=a+1,e?t.push("Row "+n+": '"+i+"'"):t.push(_trimInstanceProperty(i).call(i)))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),Cea608Channel=function(){function e(t,r,n){_classCallCheck$1(this,e),this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new CaptionScreen(n),this.nonDisplayedMemory=new CaptionScreen(n),this.lastOutputScreen=new CaptionScreen(n),this.currRollUpRow=this.displayedMemory.rows[NR_ROWS-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}return _createClass$1(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[NR_ROWS-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return n+": "+t.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(function(){return"DISP: "+e.displayedMemory.getDisplayText()}))}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+_JSON$stringify(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}]),e}(),Cea608Parser=function(){function e(t,r,n){_classCallCheck$1(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory=createCmdHistory(),this.logger=void 0;var a=this.logger=new CaptionsLogger;this.channels=[null,new Cea608Channel(t,r,a),new Cea608Channel(t+1,n,a)]}return _createClass$1(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r=this;this.logger.time=e;for(var n=function(e){var n=127&t[e],a=127&t[e+1],i=!1,s=null;if(0===n&&0===a)return"continue";r.logger.log(3,(function(){return"["+numArrayToHexArray([t[e],t[e+1]])+"] -> ("+numArrayToHexArray([n,a])+")"}));var o=r.cmdHistory;if(n>=16&&n<=31){if(hasCmdRepeated(n,a,o))return setLastCmd(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+numArrayToHexArray([n,a])+") is dropped"})),"continue";setLastCmd(n,a,r.cmdHistory),(i=r.parseCmd(n,a))||(i=r.parseMidrow(n,a)),i||(i=r.parsePAC(n,a)),i||(i=r.parseBackgroundAttributes(n,a))}else setLastCmd(null,null,o);if(!i&&(s=r.parseChars(n,a))){var l=r.currentChannel;if(l&&l>0)r.channels[l].insertChars(s);else r.logger.log(2,"No channel found yet. TEXT-MODE?")}i||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+numArrayToHexArray([n,a])+" orig: "+numArrayToHexArray([t[e],t[e+1]])}))},a=0;a<t.length;a+=2)n(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var r=20===e||21===e||23===e?1:2,n=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.currentChannel=r,!0}},{key:"parseMidrow",value:function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(t),this.logger.log(3,(function(){return"MIDROW ("+numArrayToHexArray([e,t])+")"})),!0)}return!1}},{key:"parsePAC",value:function(e,t){var r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var n=e<=23?1:2;r=t>=64&&t<=95?1===n?rowsLowCh1[e]:rowsLowCh2[e]:1===n?rowsHighCh1[e]:rowsHighCh2[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,t)),this.currentChannel=n,!0)}},{key:"interpretPAC",value:function(e,t){var r,n={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,n.underline=1==(1&r),r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n}},{key:"parseChars",value:function(e,t){var r,n,a=null,i=null;(e>=25?(r=2,i=e-8):(r=1,i=e),i>=17&&i<=19)?(n=17===i?t+80:18===i?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+getCharForByte(n)+"' in channel "+r})),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,(function(){return"Char codes = "+numArrayToHexArray(a).join(",")})),a}},{key:"parseBackgroundAttributes",value:function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(r=Math.floor((t-32)/2),n.background=backgroundColors[r],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),!0}},{key:"reset",value:function(){for(var e=0;e<_Object$keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}setLastCmd(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}}}]),e}();function setLastCmd(e,t,r){r.a=e,r.b=t}function hasCmdRepeated(e,t,r){return r.a===e&&r.b===t}function createCmdHistory(){return{a:null,b:null}}var VTTCue=function(){if(null!=optionalSelf&&optionalSelf.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!_Array$isArray(e))return!1;var r=t.toLowerCase();return!!~_indexOfInstanceProperty(e).call(e,r)&&r}function n(e){return r(t,e)}function a(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var s in i)e[s]=i[s]}return e}function i(t,i,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var c="",u=!1,d=t,f=i,h=s,p=null,y="",g=!0,v="auto",m="start",E=50,$="middle",S=50,T="middle";_Object$defineProperty(o,"id",a({},l,{get:function(){return c},set:function(e){c=""+e}})),_Object$defineProperty(o,"pauseOnExit",a({},l,{get:function(){return u},set:function(e){u=!!e}})),_Object$defineProperty(o,"startTime",a({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"endTime",a({},l,{get:function(){return f},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");f=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"text",a({},l,{get:function(){return h},set:function(e){h=""+e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"region",a({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"vertical",a({},l,{get:function(){return y},set:function(t){var n=function(t){return r(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");y=n,this.hasBeenReset=!0}})),_Object$defineProperty(o,"snapToLines",a({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"line",a({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"lineAlign",a({},l,{get:function(){return m},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");m=t,this.hasBeenReset=!0}})),_Object$defineProperty(o,"position",a({},l,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"positionAlign",a({},l,{get:function(){return $},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");$=t,this.hasBeenReset=!0}})),_Object$defineProperty(o,"size",a({},l,{get:function(){return S},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),_Object$defineProperty(o,"align",a({},l,{get:function(){return T},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");T=t,this.hasBeenReset=!0}})),o.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),StringDecoder=function(){function e(){_classCallCheck$1(this,e)}return _createClass$1(e,[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}]),e}();function parseTimeStamp(e){function t(e,t,r,n){return 3600*(0|e)+60*(0|t)+(0|r)+_parseFloat$1(n||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?_parseFloat$1(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var Settings=function(){function e(){_classCallCheck$1(this,e),this.values=_Object$create(null)}return _createClass$1(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(_valuesInstanceProperty(this)[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?_valuesInstanceProperty(this)[e]:t[r]:this.has(e)?_valuesInstanceProperty(this)[e]:t}},{key:"has",value:function(e){return e in _valuesInstanceProperty(this)}},{key:"alt",value:function(e,t,r){for(var n=0;n<r.length;++n)if(t===r[n]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,_parseInt$1(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=_parseFloat$1(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function parseOptions(e,t,r,n){var a=n?e.split(n):[e];for(var i in a)if("string"==typeof a[i]){var s=a[i].split(r);if(2===s.length)t(s[0],s[1])}}var defaults=new VTTCue(0,0,""),center="middle"===defaults.align?"middle":"center";function parseCue(e,t,r){var n=e;function a(){var t=parseTimeStamp(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function i(){e=e.replace(/^\s+/,"")}if(i(),t.startTime=a(),i(),"--\x3e"!==_sliceInstanceProperty(e).call(e,0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=_sliceInstanceProperty(e).call(e,3),i(),t.endTime=a(),i(),function(e,t){var n=new Settings;parseOptions(e,(function(e,t){var a;switch(e){case"region":for(var i=r.length-1;i>=0;i--)if(r[i].id===t){n.set(e,r[i].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),n.integer(e,a[0]),n.percent(e,a[0])&&n.set("snapToLines",!1),n.alt(e,a[0],["auto"]),2===a.length&&n.alt("lineAlign",a[1],["start",center,"end"]);break;case"position":a=t.split(","),n.percent(e,a[0]),2===a.length&&n.alt("positionAlign",a[1],["start",center,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",center,"end","left","right"])}}),/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var a=n.get("line","auto");"auto"===a&&-1===defaults.line&&(a=-1),t.line=a,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",center);var i=n.get("position","auto");"auto"===i&&50===defaults.position&&(i="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=i}(e,t)}function fixLineBreaks(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var VTTParser=function(){function e(){_classCallCheck$1(this,e),this.state="INITIAL",this.buffer="",this.decoder=new StringDecoder,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return _createClass$1(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=fixLineBreaks(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var n=_sliceInstanceProperty(e).call(e,0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=_sliceInstanceProperty(e).call(e,r),n}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(n=r()).match(/^()?WEBVTT([ \t].*)?$/);if(null==a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var i=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(i?i=!1:n=r(),t.state){case"HEADER":/:/.test(n)?parseOptions(n,(function(e,t){}),/:/):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new VTTCue(0,0,""),t.state="CUE",-1===_indexOfInstanceProperty(n).call(n,"--\x3e")){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{parseCue(n,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==_indexOfInstanceProperty(n).call(n,"--\x3e");if(!n||s&&(i=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=n;continue;case"BADCUE":n||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}]),e}(),LINEBREAKS=/\r\n|\n\r|\n|\r/g,startsWith2=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return _sliceInstanceProperty(e).call(e,r,r+t.length)===t},cueString2millis=function(e){var t=_parseInt$1(_sliceInstanceProperty(e).call(e,-3)),r=_parseInt$1(_sliceInstanceProperty(e).call(e,-6,-4)),n=_parseInt$1(_sliceInstanceProperty(e).call(e,-9,-7)),a=e.length>9?_parseInt$1(e.substring(0,_indexOfInstanceProperty(e).call(e,":"))):0;if(!(isFiniteNumber(t)&&isFiniteNumber(r)&&isFiniteNumber(n)&&isFiniteNumber(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*n,t+=36e5*a};function generateCueId(e,t,r){return hash(e.toString())+hash(t.toString())+hash(r)}var calculateOffset=function(e,t,r){var n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!=(i=a)&&i.new;){var i;e.ccOffset+=n.start-a.start,n.new=!1,a=e[(n=a).prevCC]}e.presentationOffset=r};function parseWebVTT(e,t,r,n,a,i,s){var o,l,c=new VTTParser,u=_trimInstanceProperty(o=utf8ArrayToStr(new Uint8Array(e))).call(o).replace(LINEBREAKS,"\n").split("\n"),d=[],f=t?toMpegTsClockFromTimescale(t.baseTime,t.timescale):0,h="00:00.000",p=0,y=0,g=!0;c.oncue=function(e){var i,s=r[n],o=r.ccOffset,c=(p-f)/9e4;if(null!=s&&s.new&&(void 0!==y?o=r.ccOffset=s.start:calculateOffset(r,n,c)),c){if(!t)return void(l=new Error("Missing initPTS for VTT MPEGTS"));o=c-r.presentationOffset}var u=e.endTime-e.startTime,h=normalizePts(9e4*(e.startTime+o-y),9e4*a)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+u,0);var g=_trimInstanceProperty(i=e.text).call(i);e.text=decodeURIComponent(encodeURIComponent(g)),e.id||(e.id=generateCueId(e.startTime,e.endTime,g)),e.endTime>0&&d.push(e)},c.onparsingerror=function(e){l=e},c.onflush=function(){l?s(l):i(d)},_forEachInstanceProperty(u).call(u,(function(e){if(g){if(startsWith2(e,"X-TIMESTAMP-MAP=")){var t;g=!1,_forEachInstanceProperty(t=_sliceInstanceProperty(e).call(e,16).split(",")).call(t,(function(e){startsWith2(e,"LOCAL:")?h=_sliceInstanceProperty(e).call(e,6):startsWith2(e,"MPEGTS:")&&(p=_parseInt$1(_sliceInstanceProperty(e).call(e,7)))}));try{y=cueString2millis(h)/1e3}catch(e){l=e}return}""===e&&(g=!1)}c.parse(e+"\n")})),c.flush()}var IMSC1_CODEC="stpp.ttml.im1t",HMSF_REGEX=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,TIME_UNIT_REGEX=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,textAlignToLineAlign={left:"start",center:"center",right:"end",start:"start",end:"end"};function parseIMSC1(e,t,r,n){var a=findBox(new Uint8Array(e),["mdat"]);if(0!==a.length){var i=_mapInstanceProperty(a).call(a,(function(e){return utf8ArrayToStr(e)})),s=toTimescaleFromScale(t.baseTime,1,t.timescale);try{_forEachInstanceProperty(i).call(i,(function(e){return r(parseTTML(e,s))}))}catch(e){n(e)}}else n(new Error("Could not parse IMSC1 mdat"))}function parseTTML(e,t){var r,n,a=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!a)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=_reduceInstanceProperty(r=_Object$keys(i)).call(r,(function(e,t){return e[t]=a.getAttribute("ttp:".concat(t))||i[t],e}),{}),o="preserve"!==a.getAttribute("xml:space"),l=collectionToDictionary(getElementCollection(a,"styling","style")),c=collectionToDictionary(getElementCollection(a,"layout","region")),u=getElementCollection(a,"body","[begin]");return _filterInstanceProperty(n=_mapInstanceProperty([]).call(u,(function(e){var r=getTextContent(e,o);if(!r||!e.hasAttribute("begin"))return null;var n=parseTtmlTime(e.getAttribute("begin"),s),a=parseTtmlTime(e.getAttribute("dur"),s),i=parseTtmlTime(e.getAttribute("end"),s);if(null===n)throw timestampParsingError(e);if(null===i){if(null===a)throw timestampParsingError(e);i=n+a}var u=new VTTCue(n-t,i-t,r);u.id=generateCueId(u.startTime,u.endTime,u.text);var d=getTtmlStyles(c[e.getAttribute("region")],l[e.getAttribute("style")],l),f=d.textAlign;if(f){var h=textAlignToLineAlign[f];h&&(u.lineAlign=h),u.align=f}return _extends(u,d),u}))).call(n,(function(e){return null!==e}))}function getElementCollection(e,t,r){var n=e.getElementsByTagName(t)[0];return n?_sliceInstanceProperty([]).call(n.querySelectorAll(r)):[]}function collectionToDictionary(e){return _reduceInstanceProperty(e).call(e,(function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function getTextContent(e,t){var r;return _reduceInstanceProperty(r=_sliceInstanceProperty([]).call(e.childNodes)).call(r,(function(e,r,n){var a,i;return"br"===r.nodeName&&n?e+"\n":null!=(a=r.childNodes)&&a.length?getTextContent(r,t):t?e+_trimInstanceProperty(i=r.textContent).call(i).replace(/\s+/g," "):e+r.textContent}),"")}function getTtmlStyles(e,t,r){var n="http://www.w3.org/ns/ttml#styling",a=null,i=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(a=r[s]),_reduceInstanceProperty(i).call(i,(function(r,i){var s=getAttributeNS(t,n,i)||getAttributeNS(e,n,i)||getAttributeNS(a,n,i);return s&&(r[i]=s),r}),{})}function getAttributeNS(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function timestampParsingError(e){return new Error("Could not parse ttml timestamp ".concat(e))}function parseTtmlTime(e,t){if(!e)return null;var r=parseTimeStamp(e);return null===r&&(HMSF_REGEX.test(e)?r=parseHoursMinutesSecondsFrames(e,t):TIME_UNIT_REGEX.test(e)&&(r=parseTimeUnits(e,t))),r}function parseHoursMinutesSecondsFrames(e,t){var r=HMSF_REGEX.exec(e),n=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+n/t.frameRate}function parseTimeUnits(e,t){var r=TIME_UNIT_REGEX.exec(e),n=Number(r[1]);switch(r[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}var OutputFilter=function(){function e(t,r){_classCallCheck$1(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=r}return _createClass$1(e,[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}]),e}(),TimelineController=function(){function e(t){_classCallCheck$1(this,e),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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=newVTTCCs(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},t.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Events.FRAG_LOADING,this.onFragLoading,this),t.on(Events.FRAG_LOADED,this.onFragLoaded,this),t.on(Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}return _createClass$1(e,[{key:"destroy",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Events.FRAG_LOADING,this.onFragLoading,this),e.off(Events.FRAG_LOADED,this.onFragLoaded,this),e.off(Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new OutputFilter(this,"textTrack1"),t=new OutputFilter(this,"textTrack2"),r=new OutputFilter(this,"textTrack3"),n=new OutputFilter(this,"textTrack4");this.cea608Parser1=new Cea608Parser(1,e,t),this.cea608Parser2=new Cea608Parser(3,r,n)}},{key:"addCues",value:function(e,t,r,n,a){for(var i=!1,s=a.length;s--;){var o=a[s],l=intersection3(o[0],o[1],t,r);if(l>=0&&(o[0]=Math.min(o[0],t),o[1]=Math.max(o[1],r),i=!0,l/(r-t)>.5))return}if(i||a.push([t,r]),this.config.renderTextTracksNatively){var c=this.captionsTracks[e];this.Cues.newCue(c,t,r,n)}else{var u=this.Cues.newCue(null,t,r,n);this.hls.trigger(Events.CUES_PARSED,{type:"captions",cues:u,track:e})}}},{key:"onInitPtsFound",value:function(e,t){var r=this,n=t.frag,a=t.id,i=t.initPTS,s=t.timescale,o=this.unparsedVttFrags;a===PlaylistLevelType.MAIN&&(this.initPTS[n.cc]={baseTime:i,timescale:s}),o.length&&(this.unparsedVttFrags=[],_forEachInstanceProperty(o).call(o,(function(e){r.onFragLoaded(Events.FRAG_LOADED,e)})))}},{key:"getExistingTrack",value:function(e,t){var r=this.media;if(r)for(var n=0;n<r.textTracks.length;n++){var a=r.textTracks[n];if(canReuseVttTextTrack(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound",attrs:{}}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,n=this.media,a=t[e],i=a.label,s=a.languageCode,o=this.getExistingTrack(i,s);if(o)r[e]=o,clearCurrentCues(r[e]),sendAddTrackEvent(r[e],n);else{var l=this.createTextTrack("captions",i,s);l&&(l[e]=!0,r[e]=l)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}}},{key:"createTextTrack",value:function(e,t,r){var n=this.media;if(n)return n.addTextTrack(e,t,r)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var r,n=!!t.transferMedia;if(this.media=null,!n){var a=this.captionsTracks;_forEachInstanceProperty(r=_Object$keys(a)).call(r,(function(e){clearCurrentCues(a[e]),delete a[e]})),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=newVTTCCs(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)clearCurrentCues(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,n=t.subtitleTracks||[],a=_someInstanceProperty(n).call(n,(function(e){return e.textCodec===IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(subtitleOptionsIdentical(this.tracks,n))return void(this.tracks=n);if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){var i,s=this.media,o=s?filterSubtitleTracks(s.textTracks):null;if(_forEachInstanceProperty(i=this.tracks).call(i,(function(e,t){var n;if(o){for(var a=null,i=0;i<o.length;i++)if(o[i]&&canReuseVttTextTrack(o[i],e)){a=o[i],o[i]=null;break}a&&(n=a)}if(n)clearCurrentCues(n);else{var s=captionsOrSubtitlesFromCharacteristics(e);(n=r.createTextTrack(s,e.name,e.lang))&&(n.mode="disabled")}n&&r.textTracks.push(n)})),null!=o&&o.length){var l,c=_mapInstanceProperty(l=_filterInstanceProperty(o).call(o,(function(e){return null!==e}))).call(l,(function(e){return e.label}));c.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(c.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){var u,d=_mapInstanceProperty(u=this.tracks).call(u,(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}}},{key:"onManifestLoaded",value:function(e,t){var r,n=this;this.config.enableCEA708Captions&&t.captions&&_forEachInstanceProperty(r=t.captions).call(r,(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack".concat(t[1]),a=n.captionsProperties[r];a&&(a.label=e.name,e.lang&&(a.languageCode=e.lang),a.media=e)}}))}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===PlaylistLevelType.MAIN){var r,n,a=this.cea608Parser1,i=this.cea608Parser2,s=this.lastSn,o=t.frag,l=o.cc,c=o.sn,u=null!=(r=null==(n=t.part)?void 0:n.index)?r:-1;a&&i&&(c!==s+1||c===s&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(a.reset(),i.reset()),this.lastCc=l,this.lastSn=c,this.lastPartIndex=u}}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,n=t.payload;if(r.type===PlaylistLevelType.SUBTITLE)if(n.byteLength){var a=r.decryptdata,i="stats"in t;if(null==a||!a.encrypted||i){var s=this.tracks[r.level],o=this.vttCCs;o[r.cc]||(o[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),s&&s.textCodec===IMSC1_CODEC?this._parseIMSC1(r,n):this._parseVTTs(t)}}else this.hls.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var r=this,n=this.hls;parseIMSC1(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),n.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){n.logger.log("Failed to parse IMSC1: ".concat(t)),n.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}},{key:"_parseVTTs",value:function(e){var t,r=this,n=e.frag,a=e.payload,i=this.initPTS,s=this.unparsedVttFrags,o=i.length-1;if(i[n.cc]||-1!==o){var l=this.hls;parseWebVTT(null!=(t=n.initSegment)&&t.data?appendUint8Array(n.initSegment.data,new Uint8Array(a)).buffer:a,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,(function(e){r._appendCues(e,n.level),l.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})}),(function(t){var i="Missing initPTS for VTT MPEGTS"===t.message;i?s.push(e):r._fallbackToIMSC1(n,a),l.logger.log("Failed to parse VTT cue: ".concat(t)),i&&o>n.cc||l.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})}))}else s.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var r=this,n=this.tracks[e.level];n.textCodec||parseIMSC1(t,this.initPTS[e.cc],(function(){n.textCodec=IMSC1_CODEC,r._parseIMSC1(e,t)}),(function(){n.textCodec="wvtt"}))}},{key:"_appendCues",value:function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||"disabled"===n.mode)return;_forEachInstanceProperty(e).call(e,(function(e){return addCueToTrack(n,e)}))}else{var a=this.tracks[t];if(!a)return;var i=a.default?"default":"subtitles"+t;r.trigger(Events.CUES_PARSED,{type:"subtitles",cues:e,track:i})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===PlaylistLevelType.SUBTITLE&&this.onFragLoaded(Events.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var r=t.frag,n=t.samples;if(r.type!==PlaylistLevelType.MAIN||"NONE"!==this.closedCaptionsForLevel(r))for(var a=0;a<n.length;a++){var i=n[a].bytes;if(i){this.cea608Parser1||this.initCea608Parsers();var s=this.extractCea608Data(i);this.cea608Parser1.addData(n[a].pts,s[0]),this.cea608Parser2.addData(n[a].pts,s[1])}}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,n=t.endOffset,a=t.endOffsetSubtitles,i=t.type,s=this.media;if(s&&!(s.currentTime<n)){if(!i||"video"===i){var o,l=this.captionsTracks;_forEachInstanceProperty(o=_Object$keys(l)).call(o,(function(e){return removeCuesInRange(l[e],r,n)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==a){var c,u=this.textTracks;_forEachInstanceProperty(c=_Object$keys(u)).call(c,(function(e){return removeCuesInRange(u[e],r,a)}))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],r=31&e[0],n=2,a=0;a<r;a++){var i=e[n++],s=127&e[n++],o=127&e[n++];if(0!==s||0!==o)if(0!=(4&i)){var l=3&i;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}();function captionsOrSubtitlesFromCharacteristics(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function canReuseVttTextTrack(e,t){return!!e&&e.kind===captionsOrSubtitlesFromCharacteristics(t)&&subtitleTrackMatchesTextTrack(t,e)}function intersection3(e,t,r,n){return Math.min(t,n)-Math.max(e,r)}function newVTTCCs(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var WHITESPACE_CHAR=/\s/,Cues={newCue:function(e,t,r,n){for(var a,i,s,o,l,c=[],u=self.VTTCue||self.TextTrackCue,d=0;d<n.rows.length;d++)if(s=!0,o=0,l="",!(a=n.rows[d]).isEmpty()){for(var f,h=0;h<a.chars.length;h++)WHITESPACE_CHAR.test(a.chars[h].uchar)&&s?o++:(l+=a.chars[h].uchar,s=!1);a.cueStartTime=t,t===r&&(r+=1e-4),o>=16?o--:o++;var p=fixLineBreaks(_trimInstanceProperty(l).call(l)),y=generateCueId(t,r,p);null!=e&&null!=(f=e.cues)&&f.getCueById(y)||((i=new u(t,r,p)).id=y,i.line=d+1,i.align="left",i.position=10+Math.min(80,10*Math.floor(8*o/32)),c.push(i))}return e&&c.length&&(_sortInstanceProperty(c).call(c,(function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),_forEachInstanceProperty(c).call(c,(function(t){return addCueToTrack(e,t)}))),c}};function fetchSupported(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var BYTERANGE=/(\d+)-(\d+)\/(\d+)/,FetchLoader=function(){function e(t){_classCallCheck$1(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||getRequest,this.controller=new self.AbortController,this.stats=new LoadStats}return _createClass$1(e,[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,r){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var i=getRequestParameters(e,this.controller.signal),s=r.onProgress,o="arraybuffer"===e.responseType,l=o?"byteLength":"length",c=t.loadPolicy,u=c.maxTimeToFirstByteMs,d=c.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=u&&isFiniteNumber(u)?u:d,this.requestTimeout=_setTimeout((function(){n.abortInternal(),r.onTimeout(a,e,n.response)}),t.timeout),(isPromise(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(i){n.response=n.loader=i;var l=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(n.requestTimeout),t.timeout=d,n.requestTimeout=_setTimeout((function(){n.abortInternal(),r.onTimeout(a,e,n.response)}),d-(l-a.loading.start)),!i.ok){var c=i.status,u=i.statusText;throw new FetchError(u||"fetch, bad network response",c,i)}return a.loading.first=l,a.total=getContentLength(i.headers)||a.total,s&&isFiniteNumber(t.highWaterMark)?n.loadProgressively(i,a,e,t.highWaterMark,s):o?i.arrayBuffer():"json"===e.responseType?i.json():i.text()})).then((function(i){var o=n.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var c=i[l];c&&(a.loaded=a.total=c);var u={url:o.url,data:i,code:o.status};s&&!isFiniteNumber(t.highWaterMark)&&s(a,e,i,o),r.onSuccess(u,a,e,o)})).catch((function(t){if(self.clearTimeout(n.requestTimeout),!a.aborted){var i=t&&t.code||0,s=t?t.message:null;r.onError({code:i,text:s},e,t?t.details:null,a)}}))}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?_parseFloat$1(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4?arguments[4]:void 0,i=new ChunkCache,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return i.dataLength&&a(t,r,i.flush().buffer,e),_Promise.resolve(new ArrayBuffer(0));var l=s.value,c=l.length;return t.loaded+=c,c<n||i.dataLength?(i.push(l),i.dataLength>=n&&a(t,r,i.flush().buffer,e)):a(t,r,l.buffer,e),o()})).catch((function(){return _Promise.reject()}))}()}}]),e}();function getRequestParameters(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(_extends({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}function getByteRangeLength(e){var t=BYTERANGE.exec(e);if(t)return _parseInt$1(t[2])-_parseInt$1(t[1])+1}function getContentLength(e){var t=e.get("Content-Range");if(t){var r=getByteRangeLength(t);if(isFiniteNumber(r))return r}var n=e.get("Content-Length");if(n)return _parseInt$1(n)}function getRequest(e,t){return new self.Request(e.url,t)}var FetchError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e)).code=void 0,i.details=void 0,i.code=n,i.details=a,i}return _createClass$1(r)}(),AGE_HEADER_LINE_REGEX=/^age:\s*[\d.]+\s*$/im,XhrLoader=function(){function e(t){_classCallCheck$1(this,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=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new LoadStats,this.retryDelay=0}return _createClass$1(e,[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,r){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=t,this.callbacks=r,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this,t=this.config,r=this.context;if(t&&r){var n=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var i=this.xhrSetup;i?_Promise.resolve().then((function(){if(e.loader===n&&!e.stats.aborted)return i(n,r.url)})).catch((function(t){if(e.loader===n&&!e.stats.aborted)return n.open("GET",r.url,!0),i(n,r.url)})).then((function(){e.loader!==n||e.stats.aborted||e.openAndSendXhr(n,r,t)})).catch((function(t){e.callbacks.onError({code:n.status,text:t.message},r,n,a)})):this.openAndSendXhr(n,r,t)}}},{key:"openAndSendXhr",value:function(e,t,r){var n,a,i;e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,c=o.maxLoadTimeMs;if(s)for(var u in s)e.setRequestHeader(u,s[u]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=_bindInstanceProperty(n=this.readystatechange).call(n,this),e.onprogress=_bindInstanceProperty(a=this.loadprogress).call(a,this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&isFiniteNumber(l)?l:c,this.requestTimeout=_setTimeout(_bindInstanceProperty(i=this.loadtimeout).call(i,this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!r.aborted&&n>=2){var i;if(0===r.loading.first)if(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=_setTimeout(_bindInstanceProperty(i=this.loadtimeout).call(i,this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start));if(4===n){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var s=t.status,o="text"===t.responseType?t.responseText:null;if(s>=200&&s<300){var l=null!=o?o:t.response;if(null!=l){r.loading.end=Math.max(self.performance.now(),r.loading.first);var c="arraybuffer"===t.responseType?l.byteLength:l.length;if(r.loaded=r.total=c,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,e,l,t),!this.callbacks)return;var d={url:t.responseURL,data:l,code:s};return void this.callbacks.onSuccess(d,r,e,t)}}var f,h=a.loadPolicy.errorRetry;if(shouldRetry(h,r.retry,!1,{url:e.url,data:void 0,code:s}))this.retry(h);else logger.error(_concatInstanceProperty(f="".concat(s," while loading ")).call(f,e.url)),this.callbacks.onError({code:s,text:t.statusText},e,t,r)}}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(shouldRetry(e,this.stats.retry,!0))this.retry(e);else{var t;logger.warn("timeout while loading ".concat(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t,r,n,a,i,s=this.context,o=this.stats;this.retryDelay=getRetryDelay(e,o.retry),o.retry++,logger.warn(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a="".concat(status?"HTTP Status "+status:"Timeout"," while loading ")).call(a,null==s?void 0:s.url,", retrying ")).call(n,o.retry,"/")).call(r,e.maxNumRetry," in ")).call(t,this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=_setTimeout(_bindInstanceProperty(i=this.loadInternal).call(i,this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&AGE_HEADER_LINE_REGEX.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?_parseFloat$1(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp("^".concat(e,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}]),e}(),defaultLoadPolicy={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},hlsDefaultConfig=_objectSpread2(_objectSpread2({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:XhrLoader,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:AbrController,bufferController:BufferController,capLevelController:CapLevelController,errorController:ErrorController,fpsController:FPSController,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:_requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,certLoadPolicy:{default:defaultLoadPolicy},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},timelineConfig()),{},{subtitleStreamController:SubtitleStreamController,subtitleTrackController:SubtitleTrackController,timelineController:TimelineController,audioStreamController:AudioStreamController,audioTrackController:AudioTrackController,emeController:EMEController,cmcdController:CMCDController,contentSteeringController:ContentSteeringController,interstitialsController:InterstitialsController});function timelineConfig(){return{cueHandler:Cues,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function mergeConfig(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=deepCpy(e),a=["manifest","level","frag"],i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return _forEachInstanceProperty(a).call(a,(function(e){var a,s,o="".concat("level"===e?"playlist":e,"LoadPolicy"),l=void 0===t[o],c=[];(_forEachInstanceProperty(i).call(i,(function(r){var a,i=_concatInstanceProperty(a="".concat(e,"Loading")).call(a,r),s=t[i];if(void 0!==s&&l){c.push(i);var u=n[o].default;switch(t[o]={default:u},r){case"TimeOut":u.maxLoadTimeMs=s,u.maxTimeToFirstByteMs=s;break;case"MaxRetry":u.errorRetry.maxNumRetry=s,u.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":u.errorRetry.retryDelayMs=s,u.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=s,u.timeoutRetry.maxRetryDelayMs=s}}})),c.length)&&r.warn(_concatInstanceProperty(a=_concatInstanceProperty(s='hls.js config: "'.concat(c.join('", "'),'" setting(s) are deprecated, use "')).call(s,o,'": ')).call(a,_JSON$stringify(t[o])))})),_objectSpread2(_objectSpread2({},n),t)}function deepCpy(e){var t;return e&&"object"===_typeof$1(e)?_Array$isArray(e)?_mapInstanceProperty(e).call(e,deepCpy):_reduceInstanceProperty(t=_Object$keys(e)).call(t,(function(t,r){return t[r]=deepCpy(e[r]),t}),{}):e}function enableStreamingMode(e,t){var r=e.loader;r!==FetchLoader&&r!==XhrLoader?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):fetchSupported()&&(e.loader=FetchLoader,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var MIN_CUE_DURATION=.25;function getCueClass(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function createCueWithDataFields(e,t,r,n,a){var i=new e(t,r,"");try{i.value=n,a&&(i.type=a)}catch(s){i=new e(t,r,_JSON$stringify(a?_objectSpread2({type:a},n):n))}return i}var MAX_CUE_ENDTIME=function(){var e=getCueClass();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function hexToArrayBuffer(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var ID3TrackController=function(){function e(t){var r=this;_classCallCheck$1(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){r.hls&&r.hls.trigger(Events.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()}return _createClass$1(e,[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Events.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Events.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"onMediaAttaching",value:function(e,t){var r;this.media=t.media,!1===(null==(r=t.overrides)?void 0:r.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e=this.hls.latestLevelDetails;e&&this.updateDateRangeCues(e)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&clearCurrentCues(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return sendAddTrackEvent(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media){var r=this.hls.config,n=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(n||a){var i=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=getCueClass();if(s)for(var o=0;o<i.length;o++){var l=i[o].type;if((l!==MetadataSchema.emsg||n)&&a){var c=getId3Frames(i[o].data);if(c){var u=i[o].pts,d=u+i[o].duration;d>MAX_CUE_ENDTIME&&(d=MAX_CUE_ENDTIME),d-u<=0&&(d=u+MIN_CUE_DURATION);for(var f=0;f<c.length;f++){var h=c[f];if(!isId3TimestampFrame(h)){this.updateId3CueEnds(u,l);var p=createCueWithDataFields(s,u,d,h,l);p&&this.id3Track.addCue(p)}}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var r,n=null==(r=this.id3Track)?void 0:r.cues;if(n)for(var a=n.length;a--;){var i=n[a];i.type===t&&i.startTime<e&&i.endTime===MAX_CUE_ENDTIME&&(i.endTime=e)}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,n=t.endOffset,a=t.type,i=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,c=o.enableID3MetadataCues;if(i&&(l||c))removeCuesInRange(i,r,n,"audio"===a?function(e){return e.type===MetadataSchema.audioId3&&c}:"video"===a?function(e){return e.type===MetadataSchema.emsg&&l}:function(e){return e.type===MetadataSchema.audioId3&&c||e.type===MetadataSchema.emsg&&l})}}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;this.updateDateRangeCues(r,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var r=this;if(this.media&&e.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var n,a=this.id3Track,i=e.dateRanges,s=_Object$keys(i),o=this.dateRangeCuesAppended;if(a&&t)if(null!=(n=a.cues)&&n.length)for(var l,c=_filterInstanceProperty(l=_Object$keys(o)).call(l,(function(e){return!_includesInstanceProperty(s).call(s,e)})),u=function(){var e,t=c[d],n=o[t].cues;delete o[t],_forEachInstanceProperty(e=_Object$keys(n)).call(e,(function(e){try{var t=n[e];t.removeEventListener("enter",r.onEventCueEnter),a.removeCue(t)}catch(e){}}))},d=c.length;d--;)u();else o=this.dateRangeCuesAppended={};var f=e.fragments[e.fragments.length-1];if(0!==s.length&&isFiniteNumber(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var h=getCueClass(),p=function(){var e=s[y],t=i[e],n=t.startTime,a=o[e],l=(null==a?void 0:a.cues)||{},c=(null==a?void 0:a.durationKnown)||!1,u=MAX_CUE_ENDTIME,d=t.duration;if(t.endDate&&null!==d)u=n+d,c=!0;else if(t.endOnNext&&!c){var f=_reduceInstanceProperty(s).call(s,(function(e,r){if(r!==t.id){var n=i[r];if(n.class===t.class&&n.startDate>t.startDate&&(!e||t.startDate<e.startDate))return n}return e}),null);f&&(u=f.startTime,c=!0)}for(var p=_Object$keys(t.attr),g=0;g<p.length;g++){var v=p[g];if(isDateRangeCueAttribute(v)){var m=l[v];if(m)c&&!a.durationKnown?m.endTime=u:Math.abs(m.startTime-n)>.01&&(m.startTime=n,m.endTime=u);else if(h){var E=t.attr[v];isSCTE35Attribute(v)&&(E=hexToArrayBuffer(E));var $=createCueWithDataFields(h,n,u,{key:v,data:E},MetadataSchema.dateRange);$&&($.id=e,r.id3Track.addCue($),l[v]=$,r.hls.config.interstitialsController&&("X-ASSET-LIST"!==v&&"X-ASSET-URL"!==v||$.addEventListener("enter",r.onEventCueEnter)))}}}o[e]={cues:l,dateRange:t,durationKnown:c}},y=0;y<s.length;y++)p()}}}}]),e}(),LatencyController=function(){function e(t){var r=this;_classCallCheck$1(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=r.media,t=r.hls.latestLevelDetails;if(e&&t){r.currentTime=e.currentTime;var n=r.computeLatency();if(null!==n){r._latency=n;var a=r.config,i=a.lowLatencyMode,s=a.maxLiveSyncPlaybackRate;if(i&&1!==s&&t.live){var o=r.targetLatency;if(null!==o){var l=n-o;if(l<Math.min(r.maxLatency,o+t.targetduration)&&l>.05&&r.forwardBufferLength>1){var c=Math.min(2,Math.max(1,s)),u=Math.round(2/(1+Math.exp(-.75*l-r.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()}return _createClass$1(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e,t=this.config;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;var r=null==(e=this.hls)?void 0:e.latestLevelDetails;return r?t.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,n=e.targetduration,a=this.config,i=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode,l=this.hls.userConfig,c=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===c)&&(c=void 0!==i?i:s*n);var u=n;return c+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,u)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var r=this.hls.latestLevelDetails;if(null===r)return null;var n=r.edge,a=e-t-this.edgeStalled,i=n-r.totalduration,s=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(i,a),s)}},{key:"drift",get:function(){var e=this.hls.latestLevelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.hls.latestLevelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){this.hls.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Events.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){this.hls.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Events.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var r;t.details===ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.hls.latestLevelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"estimateLiveEdge",value:function(){var e=this.hls.latestLevelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}]),e}(),LevelController=function(e){_inherits(r,BasePlaylistController);var t=_createSuper(r);function r(e,n){var a;return _classCallCheck$1(this,r),(a=t.call(this,e,"level-controller"))._levels=[],a._firstLevel=-1,a._maxAutoLevel=-1,a._startLevel=void 0,a.currentLevel=null,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.steering=void 0,a.onParsedComplete=void 0,a.steering=n,a._registerListeners(),a}return _createClass$1(r,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Events.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Events.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),_get(_getPrototypeOf(r.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){var e=this._levels;_forEachInstanceProperty(e).call(e,(function(e){e.loadError=0,e.fragmentError=0})),_get(_getPrototypeOf(r.prototype),"stopLoad",this).call(this)}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var r,n=this,a=this.hls.config.preferManagedMediaSource,i=[],s={},o={},l=!1,c=!1,u=!1;_forEachInstanceProperty(r=t.levels).call(r,(function(e){var t,r,d,f,h,p,y,g=e.attrs,v=e.audioCodec,m=e.videoCodec;v&&(e.audioCodec=v=getCodecCompatibleName(v,a)||void 0),0===(null==(y=m)?void 0:_indexOfInstanceProperty(y).call(y,"avc1"))&&(m=e.videoCodec=convertAVC1ToAVCOTI(m));var E=e.width,$=e.height,S=e.unknownCodecs,T=S?S.length:0;if(S)for(var I=T;I--;){var _,P=S[I];if(n.isAudioSupported(P))e.audioCodec=v=v?_concatInstanceProperty(_="".concat(v,",")).call(_,P):P,T--,sampleEntryCodesISO.audio[v.substring(0,4)]=2;else if(n.isVideoSupported(P)){var b;e.videoCodec=m=m?_concatInstanceProperty(b="".concat(m,",")).call(b,P):P,T--,sampleEntryCodesISO.video[m.substring(0,4)]=2}}if(l||(l=!(!E||!$)),c||(c=!!m),u||(u=!!v),!(T||v&&!n.isAudioSupported(v)||m&&!n.isVideoSupported(m))){var A=g.CODECS,k=g["FRAME-RATE"],R=g["HDCP-LEVEL"],C=g["PATHWAY-ID"],O=g.RESOLUTION,L=g["VIDEO-RANGE"],D="".concat(C||".","-"),w=_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(d=_concatInstanceProperty(f=_concatInstanceProperty(h=_concatInstanceProperty(p="".concat(D)).call(p,e.bitrate,"-")).call(h,O,"-")).call(f,k,"-")).call(d,A,"-")).call(r,L,"-")).call(t,R);if(s[w])if(s[w].uri===e.url||e.attrs["PATHWAY-ID"])s[w].addGroupId("audio",g.AUDIO),s[w].addGroupId("text",g.SUBTITLES);else{var M=o[w]+=1;e.attrs["PATHWAY-ID"]=new Array(M+1).join(".");var x=new Level(e);s[w]=x,i.push(x)}else{var N=new Level(e);s[w]=N,o[w]=1,i.push(N)}}})),this.filterAndSortMediaOptions(i,t,l,c,u)}},{key:"isAudioSupported",value:function(e){return areCodecsMediaSourceSupported(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return areCodecsMediaSourceSupported(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,n,a){var i=this,s=[],o=[],l=e;if((r||n)&&a&&(l=_filterInstanceProperty(l).call(l,(function(e){var t=e.videoCodec,r=e.videoRange,n=e.width,a=e.height;return(!!t||!(!n||!a))&&isVideoRange(r)}))),0!==l.length){var c;if(t.audioTracks)assignTrackIdsByGroup(s=_filterInstanceProperty(c=t.audioTracks).call(c,(function(e){return!e.audioCodec||i.isAudioSupported(e.audioCodec)})));t.subtitles&&assignTrackIdsByGroup(o=t.subtitles);var u=_sliceInstanceProperty(l).call(l,0);_sortInstanceProperty(l).call(l,(function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return _indexOfInstanceProperty(VideoRangeValues).call(VideoRangeValues,e.videoRange)-_indexOfInstanceProperty(VideoRangeValues).call(VideoRangeValues,t.videoRange);if(e.videoCodec!==t.videoCodec){var n=videoCodecPreferenceValue(e.videoCodec),a=videoCodecPreferenceValue(t.videoCodec);if(n!==a)return a-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var i=codecsSetSelectionPreferenceValue(e.codecSet),s=codecsSetSelectionPreferenceValue(t.codecSet);if(i!==s)return s-i}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var d=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var f=0;f<u.length;f++)if(u[f].pathwayId===l[0].pathwayId){d=u[f];break}this._levels=l;for(var h=0;h<l.length;h++)if(l[h]===d){var p,y;this._firstLevel=h;var g=d.bitrate,v=this.hls.bandwidthEstimate;if(this.log(_concatInstanceProperty(p="manifest loaded, ".concat(l.length," level(s) found, first bitrate: ")).call(p,g)),void 0===(null==(y=this.hls.userConfig)?void 0:y.abrEwmaDefaultEstimate)){var m=Math.min(g,this.hls.config.abrEwmaDefaultEstimateMax);m>v&&v===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=m)}break}var E=a&&!n,$={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:n,altAudio:!E&&_someInstanceProperty(s).call(s,(function(e){return!!e.url}))};this.hls.trigger(Events.MANIFEST_PARSED,$)}else _Promise.resolve().then((function(){if(i.hls){t.levels.length&&i.warn("One or more CODECS in variant not supported: ".concat(_JSON$stringify(t.levels[0].attrs)));var e=new Error("no level with compatible codecs found in manifest");i.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}))}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t,r,n,a,i,s,o,l=this._levels;if(0!==l.length){if(e<0||e>=l.length){var c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,l.length-1)}var d=this.currentLevelIndex,f=this.currentLevel,h=f?f.attrs["PATHWAY-ID"]:void 0,p=l[e],y=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=p,d!==e||!f||h!==y){this.log(_concatInstanceProperty(t=_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Switching to level ".concat(e," (")).call(o,p.height?p.height+"p ":"")).call(s,p.videoRange?p.videoRange+" ":"")).call(i,p.codecSet?p.codecSet+" ":"","@")).call(a,p.bitrate,")")).call(n,y?" with Pathway "+y:""," from level ")).call(r,d)).call(t,h?" with Pathway "+h:""));var g={level:e,attrs:p.attrs,details:p.details,bitrate:p.bitrate,averageBitrate:p.averageBitrate,maxBitrate:p.maxBitrate,realBitrate:p.realBitrate,width:p.width,height:p.height,codecSet:p.codecSet,audioCodec:p.audioCodec,videoCodec:p.videoCodec,audioGroups:p.audioGroups,subtitleGroups:p.subtitleGroups,loaded:p.loaded,loadError:p.loadError,fragmentError:p.fragmentError,name:p.name,id:p.id,uri:p.uri,url:p.url,urlId:0,audioGroupIds:p.audioGroupIds,textGroupIds:p.textGroupIds};this.hls.trigger(Events.LEVEL_SWITCHING,g);var v=p.details;if(!v||v.live){var m=this.switchParams(p.uri,null==f?void 0:f.details,v);this.loadPlaylist(m)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t,r=this.steering.pathways(),n=_filterInstanceProperty(e).call(e,(function(e){return-1!==_indexOfInstanceProperty(r).call(r,e)}));if(e.length<1)return void this.warn(_concatInstanceProperty(t="pathwayPriority ".concat(e," should contain at least one pathway from list: ")).call(t,r));this.steering.pathwayPriority=n}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===PlaylistContextType.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===PlaylistLevelType.MAIN){var n,a=r.elementaryStreams;if(!_someInstanceProperty(n=_Object$keys(a)).call(n,(function(e){return!!a[e]})))return;var i=this._levels[r.level];null!=i&&i.loadError&&(this.log("Resetting level error count of ".concat(i.loadError," on frag buffered")),i.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var r,n,a=t.level,i=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index ".concat(a)),void(null!=(n=t.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(a,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(i.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){_get(_getPrototypeOf(r.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,t){var n,a,i,s;_get(_getPrototypeOf(r.prototype),"loadingPlaylist",this).call(this,e,t);var o=this.getUrlWithDirectives(e.uri,t),l=this.currentLevelIndex,c=e.attrs["PATHWAY-ID"],u=e.details,d=null==u?void 0:u.age;this.log(_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s="Loading level index ".concat(l)).call(s,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(i,c?" Pathway "+c:"")).call(a,d&&u.live?" age "+d.toFixed(1)+(u.type&&" "+u.type||""):""," ")).call(n,o)),this.hls.trigger(Events.LEVEL_LOADING,{url:o,level:l,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t,r,n=this;if(1!==this._levels.length){var a=_filterInstanceProperty(t=this._levels).call(t,(function(t,r){if(r!==e)return!0;var a;(n.steering&&n.steering.removeLevel(t),t===n.currentLevel)&&(n.currentLevel=null,n.currentLevelIndex=-1,t.details&&_forEachInstanceProperty(a=t.details.fragments).call(a,(function(e){return e.level=-1})));return!1}));reassignFragmentLevelIndexes(a),this._levels=a,this.currentLevelIndex>-1&&null!=(r=this.currentLevel)&&r.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var i=a.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(Events.LEVELS_UPDATED,{levels:a})}}},{key:"onLevelsUpdated",value:function(e,t){var r=t.levels;this._levels=r}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(Events.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}]),r}();function assignTrackIdsByGroup(e){var t={};_forEachInstanceProperty(e).call(e,(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var STALL_MINIMUM_DURATION_MS=250,MAX_START_GAP_JUMP=2,SKIP_BUFFER_HOLE_STEP_SECONDS=.1,SKIP_BUFFER_RANGE_START=.05,GapController=function(e){_inherits(r,Logger);var t=_createSuper(r);function r(e,n,a,i){var s;return _classCallCheck$1(this,r),(s=t.call(this,"gap-controller",i.logger)).config=void 0,s.media=null,s.fragmentTracker=void 0,s.hls=void 0,s.nudgeRetry=0,s.stallReported=!1,s.stalled=null,s.moved=!1,s.seeking=!1,s.ended=0,s.config=e,s.media=n,s.fragmentTracker=a,s.hls=i,s}return _createClass$1(r,[{key:"destroy",value:function(){this.media=null,this.hls=this.fragmentTracker=null}},{key:"poll",value:function(e,t,r,n){var a=this.config,i=this.media,s=this.stalled;if(null!==i){var o=i.currentTime,l=i.seeking,c=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,o===e)if(u||c)this.stalled=null;else{if(i.paused&&!l||i.ended||0===i.playbackRate||!BufferHelper.getBuffered(i).length)return!this.ended&&i.ended&&(this.ended=o||1,this.hls.trigger(Events.MEDIA_ENDED,{stalled:!1})),void(this.nudgeRetry=0);var d=BufferHelper.bufferInfo(i,o,0),f=d.nextStart||0;if(l){var h=d.len>MAX_START_GAP_JUMP,p=!f||t&&t.start<=o||f-o>MAX_START_GAP_JUMP&&!this.fragmentTracker.getPartialFragment(o);if(h||p)return;this.moved=!1}if(!this.moved&&null!==this.stalled){if(!(d.len>0)&&!f)return;var y=Math.max(f,d.start||0)-o,g=!(null==r||!r.live)?2*r.targetduration:MAX_START_GAP_JUMP,v=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=g||v))return void(i.paused||this._trySkipBufferHole(v))}var m=self.performance.now();if(null!==s){var E=m-s;if(!l&&E>=STALL_MINIMUM_DURATION_MS){if(n===State.ENDED&&(null==r||!r.live)&&Math.abs(o-((null==r?void 0:r.edge)||0))<1){if(E<1e3||this.ended)return;return this.ended=o||1,void this.hls.trigger(Events.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media)return}var $=BufferHelper.bufferInfo(i,o,a.maxBufferHole);this._tryFixBufferStall($,E)}else this.stalled=m}else if(e&&(this.ended=0),this.moved=!0,l||(this.nudgeRetry=0),null!==s){if(this.stallReported){var S,T=self.performance.now()-s;this.warn(_concatInstanceProperty(S="playback not stuck anymore @".concat(o,", after ")).call(S,Math.round(T),"ms")),this.stallReported=!1}this.stalled=null}}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,n=this.fragmentTracker,a=this.media;if(null!==a){var i=a.currentTime,s=n.getPartialFragment(i);if(s)if(this._trySkipBufferHole(s)||!this.media)return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-i<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(this.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}}},{key:"_reportStall",value:function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){var n;this.stallReported=!0;var a=new Error(_concatInstanceProperty(n="Playback stalling at @".concat(r.currentTime," due to low buffer (")).call(n,_JSON$stringify(e),")"));this.warn(a.message),t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len})}}},{key:"_trySkipBufferHole",value:function(e){var t=this.config,r=this.hls,n=this.media;if(null===n)return 0;var a=n.currentTime,i=BufferHelper.bufferInfo(n,a,0),s=a<i.start?i.start:i.nextStart;if(s){var o=i.len<=t.maxBufferHole,l=i.len>0&&i.len<1&&n.readyState<3,c=s-a;if(c>0&&(o||l)){var u;if(c>t.maxBufferHole){var d=this.fragmentTracker,f=!1;if(0===a){var h=d.getAppendedFrag(0,PlaylistLevelType.MAIN);h&&s<h.end&&(f=!0)}if(!f){var p=e||d.getAppendedFrag(a,PlaylistLevelType.MAIN);if(p){for(var y=!1,g=p.end;g<s;){var v=d.getPartialFragment(g);if(!v){y=!0;break}g+=v.duration}if(y)return 0}}}var m=Math.max(s+SKIP_BUFFER_RANGE_START,a+SKIP_BUFFER_HOLE_STEP_SECONDS);if(this.warn(_concatInstanceProperty(u="skipping hole, adjusting currentTime from ".concat(a," to ")).call(u,m)),this.moved=!0,this.stalled=null,n.currentTime=m,e&&!e.gap){var E,$=new Error(_concatInstanceProperty(E="fragment loaded with buffer holes, seeking from ".concat(a," to ")).call(E,m));r.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:$,reason:$.message,frag:e})}return m}}return 0}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,n=this.nudgeRetry;if(null!==r){var a=r.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){var i,s=a+(n+1)*e.nudgeOffset,o=new Error(_concatInstanceProperty(i="Nudging 'currentTime' from ".concat(a," to ")).call(i,s));this.warn(o.message),r.currentTime=s,t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l,c=new Error(_concatInstanceProperty(l="Playhead still not moving while enough data buffered @".concat(a," after ")).call(l,e.nudgeMaxRetry," nudges"));this.error(c.message),t.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_STALLED_ERROR,error:c,fatal:!0})}}}}]),r}();function getSourceBuffer(){return self.SourceBuffer||self.WebKitSourceBuffer}function _isMSESupported(){if(!_getMediaSource2())return!1;var e=getSourceBuffer();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}function _isSupported(){var e,t;if(!_isMSESupported())return!1;var r=_getMediaSource2();return"function"==typeof(null==r?void 0:r.isTypeSupported)&&(_someInstanceProperty(e=["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"]).call(e,(function(e){return r.isTypeSupported(mimeTypeForCodec(e,"video"))}))||_someInstanceProperty(t=["mp4a.40.2","fLaC"]).call(t,(function(e){return r.isTypeSupported(mimeTypeForCodec(e,"audio"))})))}function changeTypeSupported(){var e,t=getSourceBuffer();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}var TICK_INTERVAL=100,StreamController=function(e){_inherits(r,BaseStreamController);var t=_createSuper(r);function r(e,n,a){var i;return _classCallCheck$1(this,r),(i=t.call(this,e,n,a,"stream-controller",PlaylistLevelType.MAIN)).audioCodecSwap=!1,i.gapController=null,i.level=-1,i._forceStartLoad=!1,i._hasEnoughToStart=!1,i.altAudio=0,i.audioOnly=!1,i.fragPlaying=null,i.fragLastKbps=0,i.couldBacktrack=!1,i.backtrackFragment=null,i.audioCodecSwitch=!1,i.videoBuffer=null,i.onMediaPlaying=function(){var e=i.gapController;e&&(e.ended=0),i.tick()},i.onMediaSeeked=function(){var e=i.media,t=e?e.currentTime:null;isFiniteNumber(t)&&i.log("Media seeked to ".concat(t.toFixed(3)));var r=i.getMainFwdBufferInfo();null!==r&&0!==r.len?i.tick():i.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"))},i.registerListeners(),i}return _createClass$1(r,[{key:"registerListeners",value:function(){_get(_getPrototypeOf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){_get(_getPrototypeOf(r.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),_get(_getPrototypeOf(r.prototype),"onHandlerDestroying",this).call(this)}},{key:"startLoad",value:function(e,t){if(this.levels){var r=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(TICK_INTERVAL),this.level=-1,!this.startFragRequested){var a=n.startLevel;-1===a&&(n.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=n.firstAutoLevel),n.nextLoadLevel=a,this.level=n.loadLevel,this._hasEnoughToStart=!1}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r),this.state=State.IDLE,this.nextLoadPosition=this.lastCurrentTime=e,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=State.STOPPED}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,_get(_getPrototypeOf(r.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case State.WAITING_LEVEL:var e=this.levels,t=this.level,r=null==e?void 0:e[t],n=null==r?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(n))break;this.state=State.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=State.IDLE;break}break;case State.FRAG_LOADING_WAITING_RETRY:var a,i=self.performance.now(),s=this.retryDate;if(!s||i>=s||null!=(a=this.media)&&a.seeking){var o=this.levels,l=this.level,c=null==o?void 0:o[l];this.resetStartWhenNotLoaded(c||null),this.state=State.IDLE}}this.state===State.IDLE&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){_get(_getPrototypeOf(r.prototype),"onTickEnd",this).call(this),this.checkBuffer(),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,n=this.media;if(null!==t&&(n||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[a]){var i=r[a],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return 2===this.altAudio&&(l.type="video"),this.hls.trigger(Events.BUFFER_EOS,l),void(this.state=State.ENDED)}if(this.buffering){var c;if(e.loadLevel!==a&&-1===e.manualLevel)this.log(_concatInstanceProperty(c="Adapting to level ".concat(a," from level ")).call(c,this.level));this.level=e.nextLoadLevel=a;var u=i.details;if(!u||this.state===State.WAITING_LEVEL||this.waitForLive(i))return this.level=a,this.state=State.WAITING_LEVEL,void(this.startFragRequested=!1);var d=s.len,f=this.getMaxBufferLength(i.maxBitrate);if(!(d>=f)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var h=this.backtrackFragment?this.backtrackFragment.start:s.end,p=this.getNextFragment(h,u);if(this.couldBacktrack&&!this.fragPrevious&&p&&isMediaFragment(p)&&this.fragmentTracker.getState(p)!==FragmentState.OK){var y,g=(null!=(y=this.backtrackFragment)?y:p).sn-u.startSN,v=u.fragments[g-1];v&&p.cc===v.cc&&(p=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,h)){if(!p.gap){var m=this.audioOnly&&!this.altAudio?ElementaryStreamTypes.AUDIO:ElementaryStreamTypes.VIDEO,E=(m===ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,m,PlaylistLevelType.MAIN)}p=this.getNextFragmentLoopLoading(p,u,s,PlaylistLevelType.MAIN,f)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,i,h))}}}}}}},{key:"loadFragment",value:function(e,t,n){var a=this.fragmentTracker.getState(e);if(a===FragmentState.NOT_LOADED||a===FragmentState.PARTIAL)if(isMediaFragment(e))if(this.bitrateTest){var i;this.log(_concatInstanceProperty(i="Fragment ".concat(e.sn," of level ")).call(i,e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)}else _get(_getPrototypeOf(r.prototype),"loadFragment",this).call(this,e,t,n);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,PlaylistLevelType.MAIN)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var i=this.getMainFwdBufferInfo();if(!i||i.len<2*a.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(t.currentTime+r);if(l){var c=this.followingBufferedFrag(l);if(c){this.abortCurrentFrag();var u=c.maxStartPTS?c.maxStartPTS:c.start,d=c.duration,f=Math.max(l.end,u+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(f,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case State.KEY_LOADING:case State.FRAG_LOADING:case State.FRAG_LOADING_WAITING_RETRY:case State.PARSING:case State.PARSED:this.state=State.IDLE}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,t){_get(_getPrototypeOf(r.prototype),"flushMainBuffer",this).call(this,e,t,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,t){_get(_getPrototypeOf(r.prototype),"onMediaAttached",this).call(this,e,t);var n=t.media;n.removeEventListener("playing",this.onMediaPlaying),n.removeEventListener("seeked",this.onMediaSeeked),n.addEventListener("playing",this.onMediaPlaying),n.addEventListener("seeked",this.onMediaSeeked),this.gapController=new GapController(this.config,n,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(e,t){var n=this.media;n&&(n.removeEventListener("playing",this.onMediaPlaying),n.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),_get(_getPrototypeOf(r.prototype),"onMediaDetaching",this).call(this,e,t),!!t.transferMedia||(this._hasEnoughToStart=!1)}},{key:"triggerEnded",value:function(){var e=this.gapController;if(e){var t;if(e.ended)return;e.ended=(null==(t=this.media)?void 0:t.currentTime)||1}this.hls.trigger(Events.MEDIA_ENDED,{stalled:!1})}},{key:"onManifestLoading",value:function(){_get(_getPrototypeOf(r.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(Events.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){var r,n=!1,a=!1;_forEachInstanceProperty(r=t.levels).call(r,(function(e){var t=e.audioCodec;t&&(n=n||-1!==_indexOfInstanceProperty(t).call(t,"mp4a.40.2"),a=a||-1!==_indexOfInstanceProperty(t).call(t,"mp4a.40.5"))})),this.audioCodecSwitch=n&&a&&!changeTypeSupported(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===State.IDLE){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=State.WAITING_LEVEL)}}},{key:"onLevelLoaded",value:function(e,t){var r,n,a,i,s,o,l,c,u=this.levels,d=this.startFragRequested,f=t.level,h=t.details,p=h.totalduration;if(u){this.log(_concatInstanceProperty(r=_concatInstanceProperty(n=_concatInstanceProperty(a=_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Level ".concat(f," loaded [")).call(o,h.startSN,",")).call(s,h.endSN,"]")).call(i,h.lastPartSn?_concatInstanceProperty(l="[part-".concat(h.lastPartSn,"-")).call(l,h.lastPartIndex,"]"):"",", cc [")).call(a,h.startCC,", ")).call(n,h.endCC,"] duration:")).call(r,p));var y=t.levelInfo,g=this.fragCurrent;!g||this.state!==State.FRAG_LOADING&&this.state!==State.FRAG_LOADING_WAITING_RETRY||g.level!==t.level&&g.loader&&this.abortCurrentFrag();var v=0;if(h.live||null!=(c=y.details)&&c.live){var m;if(this.checkLiveUpdate(h),h.deltaUpdateFailed)return;v=this.alignPlaylists(h,y.details,null==(m=this.levelLastLoaded)?void 0:m.details)}if(y.details=h,this.levelLastLoaded=y,d||this.setStartPosition(h,v),this.hls.trigger(Events.LEVEL_UPDATED,{details:h,level:f}),this.state===State.WAITING_LEVEL){if(this.waitForCdnTuneIn(h))return;this.state=State.IDLE}d&&h.live&&this.synchronizeToLiveEdge(h),this.tick()}else this.warn("Levels were reset while loading level ".concat(f))}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,r=this.media;if(r){var n=this.hls.liveSyncPosition,a=r.currentTime,i=e.fragmentStart,s=e.edge,o=a>=i-t.maxFragLookUpTolerance&&a<=s;if(null!==n&&r.duration>n&&(a<n||!o)){var l,c,u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if(!o&&r.readyState<4||a<s-u)if(this._hasEnoughToStart||(this.nextLoadPosition=n),r.readyState)this.warn(_concatInstanceProperty(l=_concatInstanceProperty(c="Playback: ".concat(a.toFixed(3)," is located too far from the end of live sliding playlist: ")).call(c,s,", reset currentTime to : ")).call(l,n.toFixed(3))),r.currentTime=n}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r,n,a=e.frag,i=e.part,s=e.payload,o=this.levels;if(o){var l=o[a.level];if(l){var c,u=l.details;if(!u)return this.warn(_concatInstanceProperty(c="Dropping fragment ".concat(a.sn," of level ")).call(c,a.level," after level details were reset")),void this.fragmentTracker.removeFragment(a);var d=l.videoCodec,f=u.PTSKnown||!u.live,h=null==(n=a.initSegment)?void 0:n.data,p=this._getAudioCodec(l),y=this.transmuxer=this.transmuxer||new TransmuxerInterface(this.hls,PlaylistLevelType.MAIN,_bindInstanceProperty(t=this._handleTransmuxComplete).call(t,this),_bindInstanceProperty(r=this._handleTransmuxerFlush).call(r,this)),g=i?i.index:-1,v=-1!==g,m=new ChunkMetadata(a.level,a.sn,a.stats.chunkCount,s.byteLength,g,v),E=this.initPTS[a.cc];y.push(s,h,p,d,a,i,u.totalduration,f,m,E)}else this.warn("Level ".concat(a.level," not found on progress"))}else{var $;this.warn(_concatInstanceProperty($="Levels were reset while fragment load was in progress. Fragment ".concat(a.sn," of level ")).call($,a.level," will not be buffered"))}}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this.hls,n=2===this.altAudio;if(useAlternateAudio(t.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();n&&(r.trigger(Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(Events.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=useAlternateAudio(t.url,this.hls);if(r){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var r,n,a=t.tracks,i=!1;for(var s in a){var o=a[s];if("main"===o.id){if(n=s,r=o,"video"===s){var l=a[s];l&&(this.videoBuffer=l.buffer)}}else i=!0}i&&r?(this.log("Alternate track found, use ".concat(n,".buffered to schedule main fragment loading")),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,n=t.part,a=r.type===PlaylistLevelType.MAIN;if(a){var i,s,o;if(this.fragContextChanged(r))return this.warn(_concatInstanceProperty(i=_concatInstanceProperty(s=_concatInstanceProperty(o="Fragment ".concat(r.sn)).call(o,n?" p: "+n.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(i,this.state)),void(this.state===State.PARSED&&(this.state=State.IDLE));var l=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),isMediaFragment(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}var c=this.media;c&&(!this._hasEnoughToStart&&c.buffered.length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=State.ERROR;else switch(t.details){case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_PARSING_ERROR:case ErrorDetails.FRAG_DECRYPT_ERROR:case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(PlaylistLevelType.MAIN,t);break;case ErrorDetails.LEVEL_LOAD_ERROR:case ErrorDetails.LEVEL_LOAD_TIMEOUT:case ErrorDetails.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==State.WAITING_LEVEL||(null==(r=t.context)?void 0:r.type)!==PlaylistContextType.LEVEL||(this.state=State.IDLE);break;case ErrorDetails.BUFFER_APPEND_ERROR:case ErrorDetails.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===ErrorDetails.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case ErrorDetails.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"checkBuffer",value:function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this._hasEnoughToStart||!BufferHelper.getBuffered(e).length){var r=this.state,n=r!==State.IDLE?this.fragCurrent:null,a=this.getLevelDetails();t.poll(this.lastCurrentTime,n,a,r)}this.lastCurrentTime=e.currentTime}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=State.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var n=(r===ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,r,PlaylistLevelType.MAIN),this.tick()}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0){var n;if(e.seeking)return void this.log(_concatInstanceProperty(n="could not seek to ".concat(r,", already seeking at ")).call(n,t));var a=this.getLevelDetails(),i=this.config.timelineOffset;i&&r&&(r+=(null==a?void 0:a.appliedTimelineOffset)||i);var s,o,l=BufferHelper.getBuffered(e),c=l.length?l.start(0):0,u=c-r,d=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(u>0&&(u<d||this.loadingParts&&u<2*((null==a?void 0:a.partTarget)||0))&&(this.log("adjusting start position by ".concat(u," to match buffer start")),r+=u,this.startPosition=r),t<r)this.log(_concatInstanceProperty(s=_concatInstanceProperty(o="seek to target start position ".concat(r," from current time ")).call(o,t," buffer start ")).call(s,c)),e.currentTime=r}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==_indexOfInstanceProperty(t).call(t,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(e){var n=r.hls,a=null==e?void 0:e.frag;if(a&&!r.fragContextChanged(a)){t.fragmentError=0,r.state=State.IDLE,r.startFragRequested=!1,r.bitrateTest=!1;var i=a.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),n.trigger(Events.FRAG_LOADED,e),a.bitrateTest=!1}}))}},{key:"_handleTransmuxComplete",value:function(e){var t,r=this.playlistType,n=this.hls,a=e.remuxResult,i=e.chunkMeta,s=this.getCurrentContext(i);if(s){var o=s.frag,l=s.part,c=s.level,u=a.video,d=a.text,f=a.id3,h=a.initSegment,p=c.details,y=this.altAudio?void 0:a.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=State.PARSING,h){if(null!=h&&h.tracks){var g=o.initSegment||o;this._bufferInitSegment(c,h.tracks,g,i),n.trigger(Events.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:h.tracks})}var v=h.initPTS,m=h.timescale;isFiniteNumber(v)&&(this.initPTS[o.cc]={baseTime:v,timescale:m},n.trigger(Events.INIT_PTS_FOUND,{frag:o,id:r,initPTS:v,timescale:m}))}if(u&&p){var E=p.fragments[o.sn-1-p.startSN],$=o.sn===p.startSN,S=!E||o.cc>E.cc;if(!1!==a.independent){var T=u.startPTS,I=u.endPTS,_=u.startDTS,P=u.endDTS;if(l)l.elementaryStreams[u.type]={startPTS:T,endPTS:I,startDTS:_,endDTS:P};else if(u.firstKeyFrame&&u.independent&&1===i.id&&!S&&(this.couldBacktrack=!0),u.dropped&&u.independent){var b=this.getMainFwdBufferInfo(),A=(b?b.end:this.getLoadPosition())+this.config.maxBufferHole,k=u.firstKeyFramePTS?u.firstKeyFramePTS:T;if(!$&&A<k-this.config.maxBufferHole&&!S)return void this.backtrack(o);S&&(o.gap=!0),o.setElementaryStreamInfo(u.type,o.start,I,o.start,P,!0)}else $&&T-(p.appliedTimelineOffset||0)>MAX_START_GAP_JUMP&&(o.gap=!0);o.setElementaryStreamInfo(u.type,T,I,_,P),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(u,o,l,i,$||S)}else{if(!$&&!S)return void this.backtrack(o);o.gap=!0}}if(y){var R=y.startPTS,C=y.endPTS,O=y.startDTS,L=y.endDTS;l&&(l.elementaryStreams[ElementaryStreamTypes.AUDIO]={startPTS:R,endPTS:C,startDTS:O,endDTS:L}),o.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO,R,C,O,L),this.bufferFragmentData(y,o,l,i)}if(p&&null!=f&&null!=(t=f.samples)&&t.length){var D={id:r,frag:o,details:p,samples:f.samples};n.trigger(Events.FRAG_PARSING_METADATA,D)}if(p&&d){var w={id:r,frag:o,details:p,samples:d.samples};n.trigger(Events.FRAG_PARSING_USERDATA,w)}}}else this.resetWhenMissingContext(i)}},{key:"_bufferInitSegment",value:function(e,t,r,n){var a=this;if(this.state===State.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var i,s,o=t.audio,l=t.video,c=t.audiovideo;if(o){var u,d,f,h=pickMostCompleteCodecName(o.codec,e.audioCodec);"mp4a"===h&&(h="mp4a.40.5");var p,y=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h=-1!==_indexOfInstanceProperty(h).call(h,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var g=o.metadata;g&&"channelCount"in g&&1!==(g.channelCount||1)&&-1===_indexOfInstanceProperty(y).call(y,"firefox")&&(h="mp4a.40.5")}if(h&&-1!==_indexOfInstanceProperty(h).call(h,"mp4a.40.5")&&-1!==_indexOfInstanceProperty(y).call(y,"android")&&"audio/mpeg"!==o.container&&(h="mp4a.40.2",this.log("Android: force audio codec to ".concat(h))),e.audioCodec&&e.audioCodec!==h)this.log(_concatInstanceProperty(p='Swapping manifest audio codec "'.concat(e.audioCodec,'" for "')).call(p,h,'"'));o.levelCodec=h,o.id="main",this.log(_concatInstanceProperty(u=_concatInstanceProperty(d=_concatInstanceProperty(f="Init audio buffer, container:".concat(o.container,", codecs[selected/level/parsed]=[")).call(f,h||"","/")).call(d,e.audioCodec||"","/")).call(u,o.codec,"]")),delete t.audiovideo}if(l){var v,m,E;l.levelCodec=e.videoCodec,l.id="main";var $=l.codec;if(4===(null==$?void 0:$.length))switch($){case"hvc1":case"hev1":l.codec="hvc1.1.6.L120.90";break;case"av01":l.codec="av01.0.04M.08";break;case"avc1":l.codec="avc1.42e01e"}this.log(_concatInstanceProperty(v=_concatInstanceProperty(m=_concatInstanceProperty(E="Init video buffer, container:".concat(l.container,", codecs[level/parsed]=[")).call(E,e.videoCodec||"","/")).call(m,$)).call(v,l.codec!==$?" parsed-corrected="+l.codec:"","}]")),delete t.audiovideo}if(c)this.log(_concatInstanceProperty(i=_concatInstanceProperty(s="Init audiovideo buffer, container:".concat(c.container,", codecs[level/parsed]=[")).call(s,e.codecs,"/")).call(i,c.codec,"]")),delete t.video,delete t.audio;var S=_Object$keys(t);if(S.length){if(this.hls.trigger(Events.BUFFER_CODECS,t),!this.hls)return;_forEachInstanceProperty(S).call(S,(function(e){var i=t[e].initSegment;null!=i&&i.byteLength&&a.hls.trigger(Events.BUFFER_APPENDING,{type:e,data:i,frag:r,part:null,chunkMeta:n,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,PlaylistLevelType.MAIN)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=State.IDLE}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(BufferHelper.isBuffered(e,r)?t=this.getAppendedFrag(r):BufferHelper.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var n=this.fragPlaying,a=t.level;n&&t.sn===n.sn&&n.level===a||(this.fragPlaying=t,this.hls.trigger(Events.FRAG_CHANGED,{frag:t}),n&&n.level===a||this.hls.trigger(Events.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return isFiniteNumber(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(isFiniteNumber(t)){var r=this.getLevelDetails(),n=this.currentFrag||(r?findFragmentByPTS(null,r.fragments,t):null);if(n){var a=n.programDateTime;if(null!==a){var i=a+1e3*(t-n.start);return new Date(i)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),r}(),KeyLoader=function(){function e(t){_classCallCheck$1(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}return _createClass$1(e,[{key:"abort",value:function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var n;if(e&&e!==(null==(n=r.context)?void 0:n.frag.type))return;r.abort()}}}},{key:"detach",value:function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}},{key:"createKeyLoadError",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ErrorDetails.KEY_LOAD_ERROR,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;return new LoadError({type:ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:n})}},{key:"loadClear",value:function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,a=e.cc,i=function(){var e=t[s];if(a<=e.cc&&("initSegment"===n||"initSegment"===e.sn||n<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),"break"},s=0;s<t.length;s++){if("break"===i())break}}},{key:"load",value:function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var r,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var i=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return _Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,i))}var s=a.uri;if(!s)return _Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(s,'"'))));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return a.key=l.decryptdata.key,_Promise.resolve({frag:e,keyInfo:l});if(null!=(n=l)&&n.keyLoadPromise)switch(null==(o=l.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return l.keyLoadPromise.then((function(t){return a.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return _Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(a.method,'"'))))}}},{key:"loadKeyEME",value:function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(r);if(n)return(e.keyLoadPromise=n.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return _Promise.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,n=this.config,a=new(0,n.loader)(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new _Promise((function(i,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=n.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:function(e,t,n,a){var o=n.frag,l=n.keyInfo,c=n.url;if(!o.decryptdata||l!==r.keyUriToKeyInfo[c])return s(r.createKeyLoadError(o,ErrorDetails.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),a));l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,l.loader=null,i({frag:o,keyInfo:l})},onError:function(e,n,a,i){var l;r.resetLoader(n),s(r.createKeyLoadError(t,ErrorDetails.KEY_LOAD_ERROR,new Error(_concatInstanceProperty(l="HTTP Error ".concat(e.code," loading key ")).call(l,e.text)),a,_objectSpread2({url:o.url,data:void 0},e)))},onTimeout:function(e,n,a){r.resetLoader(n),s(r.createKeyLoadError(t,ErrorDetails.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(e,n,a){r.resetLoader(n),s(r.createKeyLoadError(t,ErrorDetails.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};a.load(o,c,u)}))}},{key:"resetLoader",value:function(e){var t=e.frag,r=e.keyInfo,n=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()}}]),e}();function mapContextToLevelType(e){switch(e.type){case PlaylistContextType.AUDIO_TRACK:return PlaylistLevelType.AUDIO;case PlaylistContextType.SUBTITLE_TRACK:return PlaylistLevelType.SUBTITLE;default:return PlaylistLevelType.MAIN}}function getResponseUrl(e,t){var r=e.url;return void 0!==r&&0!==_indexOfInstanceProperty(r).call(r,"data:")||(r=t.url),r}var PlaylistLoader=function(){function e(t){_classCallCheck$1(this,e),this.hls=void 0,this.loaders=_Object$create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()}return _createClass$1(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,r=t.pLoader,n=t.loader,a=new(r||n)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var r=t.id,n=t.level,a=t.pathwayId,i=t.url,s=t.deliveryDirectives,o=t.levelInfo;this.load({id:r,level:n,pathwayId:a,responseType:"text",type:PlaylistContextType.LEVEL,url:i,deliveryDirectives:s,levelOrTrack:o})}},{key:"onAudioTrackLoading",value:function(e,t){var r=t.id,n=t.groupId,a=t.url,i=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:n,level:null,responseType:"text",type:PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:i,levelOrTrack:s})}},{key:"onSubtitleTrackLoading",value:function(e,t){var r=t.id,n=t.groupId,a=t.url,i=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:n,level:null,responseType:"text",type:PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:i,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[PlaylistContextType.LEVEL];if(r){var n,a=r.context;a&&!_someInstanceProperty(n=t.levels).call(n,(function(e){return e===a.levelOrTrack}))&&(r.abort(),delete this.loaders[PlaylistContextType.LEVEL])}}},{key:"load",value:function(e){var t,r,n,a=this,i=this.hls.config,s=this.getInternalLoader(e);if(s){var o=this.hls.logger,l=s.context;if(l&&l.levelOrTrack===e.levelOrTrack&&(l.url===e.url||l.deliveryDirectives&&!e.deliveryDirectives)){var c;if(l.url===e.url)o.log("[playlist-loader]: ignore ".concat(e.url," ongoing request"));else o.log(_concatInstanceProperty(c="[playlist-loader]: ignore ".concat(e.url," in favor of ")).call(c,l.url));return}o.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if((r=e.type===PlaylistContextType.MANIFEST?i.manifestLoadPolicy.default:_extends({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),isFiniteNumber(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===PlaylistContextType.LEVEL&&null!==e.level?n=this.hls.levels[e.level].details:e.type===PlaylistContextType.AUDIO_TRACK&&null!==e.id?n=this.hls.audioTracks[e.id].details:e.type===PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(n=this.hls.subtitleTracks[e.id].details),n)){var u=n.partTarget,d=n.targetduration;if(u&&d){var f=1e3*Math.max(3*u,.8*d);r=_extends({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var h=r.errorRetry||r.timeoutRetry||{},p={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},y={onSuccess:function(e,t,r,n){var i=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=e.data;0===_indexOfInstanceProperty(s).call(s,"#EXTM3U")?(t.parsing.start=performance.now(),M3U8Parser.isMediaPlaylist(s)||r.type!==PlaylistContextType.MANIFEST?a.handleTrackOrLevelPlaylist(e,t,r,n||null,i):a.handleMasterPlaylist(e,t,r,n)):a.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),n||null,t)},onError:function(e,t,r,n){a.handleNetworkError(t,r,!1,e,n)},onTimeout:function(e,t,r){a.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,p,y)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e,t=this.hls,r=t.config,n=r.autoStartLoad,a=r.startPosition,i=t.forceStartLoad;if(n||i)this.hls.logger.log(_concatInstanceProperty(e="".concat(n?"auto":"force"," startLoad with configured startPosition ")).call(e,a)),this.hls.startLoad(a)}}},{key:"handleMasterPlaylist",value:function(e,t,r,n){var a=this.hls,i=e.data,s=getResponseUrl(e,r),o=M3U8Parser.parseMasterPlaylist(i,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,n,t);else{var l=o.contentSteering,c=o.levels,u=o.sessionData,d=o.sessionKeys,f=o.startTimeOffset,h=o.variableList;this.variableList=h;var p=M3U8Parser.parseMasterPlaylistMedia(i,s,o),y=p.AUDIO,g=void 0===y?[]:y,v=p.SUBTITLES,m=p["CLOSED-CAPTIONS"];if(g.length)_someInstanceProperty(g).call(g,(function(e){return!e.url}))||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new AttrList({}),bitrate:0,url:""}));a.trigger(Events.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:v,captions:m,contentSteering:l,url:s,stats:t,networkDetails:n,sessionData:u,sessionKeys:d,startTimeOffset:f,variableList:h})}}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,r,n,a){var i=this.hls,s=r.id,o=r.level,l=r.type,c=getResponseUrl(e,r),u=isFiniteNumber(o)?o:isFiniteNumber(s)?s:0,d=mapContextToLevelType(r),f=M3U8Parser.parseLevelPlaylist(e.data,c,u,d,0,this.variableList);if(l===PlaylistContextType.MANIFEST){var h={attrs:new AttrList({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+computeReloadInterval(f,0),i.trigger(Events.MANIFEST_LOADED,{levels:[h],audioTracks:[],url:c,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=f,this.handlePlaylistLoaded(f,e,t,r,n,a)}},{key:"handleManifestParsingError",value:function(e,t,r,n,a){this.hls.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===PlaylistContextType.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:n,stats:a})}},{key:"handleNetworkError",value:function(e,t){var r,n,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=_concatInstanceProperty(r="A network ".concat(a?"timeout":"error"+(i?" (status "+i.code+")":"")," occurred while loading ")).call(r,e.type);if(e.type===PlaylistContextType.LEVEL)o+=_concatInstanceProperty(n=": ".concat(e.level," id: ")).call(n,e.id);else if(e.type===PlaylistContextType.AUDIO_TRACK||e.type===PlaylistContextType.SUBTITLE_TRACK){var l;o+=_concatInstanceProperty(l=" id: ".concat(e.id,' group-id: "')).call(l,e.groupId,'"')}var c=new Error(o);this.hls.logger.warn("[playlist-loader]: ".concat(o));var u=ErrorDetails.UNKNOWN,d=!1,f=this.getInternalLoader(e);switch(e.type){case PlaylistContextType.MANIFEST:u=a?ErrorDetails.MANIFEST_LOAD_TIMEOUT:ErrorDetails.MANIFEST_LOAD_ERROR,d=!0;break;case PlaylistContextType.LEVEL:u=a?ErrorDetails.LEVEL_LOAD_TIMEOUT:ErrorDetails.LEVEL_LOAD_ERROR,d=!1;break;case PlaylistContextType.AUDIO_TRACK:u=a?ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:ErrorDetails.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case PlaylistContextType.SUBTITLE_TRACK:u=a?ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:ErrorDetails.SUBTITLE_LOAD_ERROR,d=!1}f&&this.resetInternalLoader(e.type);var h={type:ErrorTypes.NETWORK_ERROR,details:u,fatal:d,url:e.url,loader:f,context:e,error:c,networkDetails:t,stats:s};if(i){var p=(null==t?void 0:t.url)||e.url;h.response=_objectSpread2({url:p,data:void 0},i)}this.hls.trigger(Events.ERROR,h)}},{key:"handlePlaylistLoaded",value:function(e,t,r,n,a,i){var s=this.hls,o=n.type,l=n.level,c=n.id,u=n.groupId,d=n.deliveryDirectives,f=getResponseUrl(t,n),h=mapContextToLevelType(n),p="number"==typeof n.level&&h===PlaylistLevelType.MAIN?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;if(y)s.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:y,reason:y.message,response:t,context:n,level:p,parent:h,networkDetails:a,stats:r});else switch(e.live&&i&&(i.getCacheAge&&(e.ageHeader=i.getCacheAge()||0),i.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case PlaylistContextType.MANIFEST:case PlaylistContextType.LEVEL:s.trigger(Events.LEVEL_LOADED,{details:e,levelInfo:n.levelOrTrack||s.levels[0],level:p||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:d,withoutMultiVariant:o===PlaylistContextType.MANIFEST});break;case PlaylistContextType.AUDIO_TRACK:s.trigger(Events.AUDIO_TRACK_LOADED,{details:e,track:n.levelOrTrack,id:c||0,groupId:u||"",stats:r,networkDetails:a,deliveryDirectives:d});break;case PlaylistContextType.SUBTITLE_TRACK:s.trigger(Events.SUBTITLE_TRACK_LOADED,{details:e,track:n.levelOrTrack,id:c||0,groupId:u||"",stats:r,networkDetails:a,deliveryDirectives:d})}}else{var g=e.playlistParsingError=new Error("No Segments found in Playlist");s.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:n,level:p,parent:h,networkDetails:a,stats:r})}}}]),e}(),Hls=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck$1(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new EventEmitter,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var r=this.logger=enableLogs(t.debug||!1,"Hls instance",t.assetPlayerId),n=this.config=mergeConfig(e.DefaultConfig,t,r);this.userConfig=t,n.progressive&&enableStreamingMode(n,r);var a=n.abrController,i=n.bufferController,s=n.capLevelController,o=n.errorController,l=n.fpsController,c=new o(this),u=this.abrController=new a(this),d=new FragmentTracker(this),f=n.interstitialsController,h=f?this.interstitialsController=new f(this,e):null,p=this.bufferController=new i(this,d),y=this.capLevelController=new s(this),g=new l(this),v=new PlaylistLoader(this),m=n.contentSteeringController,E=m?new m(this):null,$=this.levelController=new LevelController(this,E),S=new ID3TrackController(this),T=new KeyLoader(this.config),I=this.streamController=new StreamController(this,d,T);y.setStreamController(I),g.setStreamController(I);var _=[v,$,I];h&&_spliceInstanceProperty(_).call(_,1,0,h),E&&_spliceInstanceProperty(_).call(_,1,0,E),this.networkControllers=_;var P=[u,p,y,g,S,d];this.audioTrackController=this.createController(n.audioTrackController,_);var b=n.audioStreamController;b&&_.push(new b(this,d,T)),this.subtitleTrackController=this.createController(n.subtitleTrackController,_);var A=n.subtitleStreamController;A&&_.push(new A(this,d,T)),this.createController(n.timelineController,P),T.emeController=this.emeController=this.createController(n.emeController,P),this.cmcdController=this.createController(n.cmcdController,P),this.latencyController=this.createController(LatencyController,P),this.coreComponents=P,_.push(c);var k=c.onErrorOut;"function"==typeof k&&this.on(Events.ERROR,k,c),this.on(Events.MANIFEST_LOADED,v.onManifestLoaded,v)}return _createClass$1(e,[{key:"createController",value:function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null}},{key:"on",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.on(e,t,r)}},{key:"once",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.once(e,t,r)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,n=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,n)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,r){return this._emitter.emit(e,t,r)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===Events.ERROR;this.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){var e,t;this.logger.log("destroy"),this.trigger(Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,_forEachInstanceProperty(e=this.networkControllers).call(e,(function(e){return e.destroy()})),this.networkControllers.length=0,_forEachInstanceProperty(t=this.coreComponents).call(t,(function(e){return e.destroy()})),this.coreComponents.length=0;var r=this.config;r.xhrSetup=r.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument (".concat(e,")"));this.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in e,n=r?e.media:e,a=r?e:{media:n};this._media=n,this.trigger(Events.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(Events.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(Events.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,n=this._url=urlToolkitExports.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:".concat(n)),t&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Events.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=arguments.length>1?arguments[1]:void 0;this.logger.log("startLoad(".concat(e+(t?", <skip seek to start>":""),")")),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){var e;this.bufferingEnabled||(this.logger.log("resume buffering"),_forEachInstanceProperty(e=this.networkControllers).call(e,(function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){var e;this.bufferingEnabled&&(this.logger.log("pause buffering"),_forEachInstanceProperty(e=this.networkControllers).call(e,(function(e){e.pauseBuffering&&e.pauseBuffering()})))}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=uuid()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:".concat(e)),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:".concat(e)),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:".concat(e)),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:".concat(e)),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){isHdcpLevel(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,n=0;n<r;n++)if(e[n].maxBitrate>=t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,n)for(var a=e;a--;){var i=t[a].attrs["HDCP-LEVEL"];if(i&&i<=n)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e){return getMediaDecodingInfoPromise(e,getAudioTracksByGroup(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return version}},{key:"isMSESupported",value:function(){return _isMSESupported()}},{key:"isSupported",value:function(){return _isSupported()}},{key:"getMediaSource",value:function(){return _getMediaSource2()}},{key:"Events",get:function(){return Events}},{key:"MetadataSchema",get:function(){return MetadataSchema}},{key:"ErrorTypes",get:function(){return ErrorTypes}},{key:"ErrorDetails",get:function(){return ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:hlsDefaultConfig},set:function(t){e.defaultConfig=t}}]),e}();Hls.defaultConfig=void 0;var OPTIONS_MAP={liveSyncDuration:{key:"targetLatency",val:10},liveMaxLatencyDuration:{key:"maxLatency",val:20},backBufferLength:{key:"bufferBehind",val:10},initialLiveManifestSize:{key:"minSegmentsStartPlay",val:3},preferManagedMediaSource:[{key:"preferMMS",val:!1},{key:"preferMMSStreaming",val:!1}],lowLatencyMode:{key:"useLowLatency",val:!0},startPosition:{key:"startTime",val:0},interstitialLiveLookAhead:{key:"preloadTime",val:30}};function getHlsConfig(e){var t,r={};_forEachInstanceProperty(t=_Object$keys(OPTIONS_MAP)).call(t,(function(t){var n=OPTIONS_MAP[t];n instanceof Array?_forEachInstanceProperty(n).call(n,(function(e){r[t]=e.val})):r[t]=e[n.key]||n.val}));var n="number"==typeof e.retryCount?e.retryCount:3,a="number"==typeof e.retryDelay?e.retryDelay:1e3,i=e.loadTimeout||1e4,s="number"==typeof e.manifestLoadTimeout?e.manifestLoadTimeout:1e4,o={maxNumRetry:n,retryDelayMs:a,maxRetryDelayMs:a,shouldRetry:function(e,t){return t<e.maxNumRetry}},l={maxNumRetry:n,retryDelayMs:a,maxRetryDelayMs:a,shouldRetry:function(e,t){return t<e.maxNumRetry}};return r.manifestLoadPolicy={default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:s,timeoutRetry:o,errorRetry:l}},r.playlistLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:i,timeoutRetry:o,errorRetry:l}},r.fragLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:i,timeoutRetry:o,errorRetry:l}},_objectSpread2$2(_objectSpread2$2({},r),e)}function initHlsEvents(e,t){e.on(Hls.Events.SUBTITLE_FRAG_PROCESSED,(function(e,r){var n=r.frag;t.emit("core_event",{eventName:"core.subtitlesegments",list:n})})),e.on(Hls.Events.MANIFEST_PARSED,(function(e,r){var n=r.levels;t.emit("core_event",{eventName:"core.subtitleplaylist",list:n})})),e.on(Hls.Events.MANIFEST_LOADING,(function(e,r){var n=r.url;t.emit("core_event",{eventName:"core.loadstart",url:n})})),e.on(Hls.Events.LEVEL_LOADING,(function(e,r){var n=r.url;t.emit("core_event",{eventName:"core.loadstart",url:n})})),e.on(Hls.Events.FRAG_LOADING,(function(e,r){var n=r.frag;t.emit("core_event",{eventName:"core.loadstart",url:n.url})})),e.on(Hls.Events.MANIFEST_LOADED,(function(e,r){var n=r.url;t.emit("core_event",{eventName:"core.loadcomplete",url:n})})),e.on(Hls.Events.LEVEL_LOADED,(function(e,r){var n=r.details,a=r.stats;t.emit("core_event",_objectSpread2$2(_objectSpread2$2({eventName:"core.loadcomplete"},a),{},{url:null==n?void 0:n.url}))})),e.on(Hls.Events.FRAG_LOADED,(function(e,r){var n=r.frag;t.emit("core_event",{eventName:"core.loadcomplete",url:n.url})})),e.on(Hls.Events.FRAG_PARSING_USERDATA,(function(e,r){var n=r.samples;t.emit("core_event",{eventName:"core.sei",sei:n})})),e.on(Hls.Events.MANIFEST_LOADED,(function(e,r){var n=r.levels,a=r.networkDetails;t.emit("core_event",{eventName:"core.hlsmanifestloaded",playlist:n}),t.emit("core_event",{eventName:"core.loadresponseheaders",headers:a.headers})})),e.on(Hls.Events.LEVEL_LOADED,(function(e,r){var n,a=r.details,i={};_forEachInstanceProperty(n=_Object$keys(a.dateRanges)).call(n,(function(e){i[e]=a.dateRanges[e].attr["START-DATE"]})),t.emit("core_event",{eventName:"core.hlslevelloaded",playlist:_objectSpread2$2(_objectSpread2$2({},a),{},{segments:a.fragments,dateRanges:i})})})),e.on(Hls.Events.ERROR,(function(r,n){var a=n.details,i=n.fatal,s=n.type,o=n.response,l=n.reason,c=n.error;if(i){var u,d;switch(s){case Hls.ErrorTypes.NETWORK_ERROR:u=2100,_includesInstanceProperty(a).call(a,"TimeOut")?u=2101:403===(null==o?void 0:o.code)?u=2103:404===(null==o?void 0:o.code)&&(u=2104),t.emit("error",{errorType:"network",errorCode:u,message:(null==c?void 0:c.message)||a,originError:n});break;case Hls.ErrorTypes.MEDIA_ERROR:d="media",a===Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?u=5104:a===Hls.ErrorDetails.FRAG_DECRYPT_ERROR?u=5105:a===Hls.ErrorDetails.FRAG_PARSING_ERROR?(u=1100,d="manifest"):a===Hls.ErrorDetails.FRAG_GAP?u=5104:a===Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR?u=5200:a===Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR?u=5104:a===Hls.ErrorDetails.BUFFER_APPEND_ERROR||a===Hls.ErrorDetails.BUFFER_APPENDING_ERROR?u=5201:a===Hls.ErrorDetails.BUFFER_STALLED_ERROR||a===Hls.ErrorDetails.BUFFER_FULL_ERROR?u=5203:(a===Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE||a===Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL)&&(u=5202),t.emit("error",{errorType:d||s,errorCode:u,message:(null==c?void 0:c.message)||a,originError:n});break;case Hls.ErrorTypes.MUX_ERROR:u=4100,t.emit("error",{errorType:"remux",errorCode:u,message:(null==c?void 0:c.message)||a,originError:n});break;case Hls.ErrorTypes.KEY_SYSTEM_ERROR:u=7111,a===Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS?u=7103:a===Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS?u=7101:a===Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION?u=7104:a===Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?u=7107:a===Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED?u=7108:a===Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED||a===Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?u=7110:a===Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?u=7104:a===Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR&&(u=7111),t.emit("error",{errorType:"drm",errorCode:u,message:(null==c?void 0:c.message)||l||a,originError:n});break;default:a===Hls.ErrorDetails.LEVEL_SWITCH_ERROR&&(u=2100,d="network"),t.emit("error",{errorType:d||"other",errorCode:u,message:(null==c?void 0:c.message)||l||a,originError:n})}try{e.stopLoad(),t.pause()}catch(e){}}})),e.on(Hls.Events.MEDIA_ATTACHED,(function(){t.emit("sourceopen")})),e.on(Hls.Events.BUFFER_APPENDED,(function(){t.emit("bufferappend")})),e.on(Hls.Events.AUDIO_TRACKS_UPDATED,(function(e,r){var n=r.audioTracks;t.emit("core_event",{eventName:"core.audiotracksupdate",audioTracks:n})})),e.on(Hls.Events.AUDIO_TRACK_SWITCHING,(function(e,r){t.emit("core_event",_objectSpread2$2({eventName:"core.audiotrackswitching"},r))})),e.on(Hls.Events.AUDIO_TRACK_SWITCHED,(function(e,r){t.emit("core_event",_objectSpread2$2({eventName:"core.audiotrackswitched"},r))})),e.on(Hls.Events.SUBTITLE_TRACKS_UPDATED,(function(e,r){var n=r.subtitleTracks;t.emit("core_event",{eventName:"core.subtitletracksupdate",subtitleTracks:n})})),e.on(Hls.Events.SUBTITLE_TRACKS_CLEARED,(function(){t.emit("core_event",{eventName:"core.subtitletracksclear"})})),e.on(Hls.Events.SUBTITLE_TRACK_SWITCH,(function(e,r){t.emit("core_event",_objectSpread2$2({eventName:"core.subtitletrackswitch"},r))})),e.on(Hls.Events.SUBTITLE_TRACK_LOADING,(function(e,r){t.emit("core_event",_objectSpread2$2({eventName:"core.subtitletrackloading"},r))})),e.on(Hls.Events.SUBTITLE_TRACK_LOADED,(function(e,r){t.emit("core_event",_objectSpread2$2({eventName:"core.subtitletrackloaded"},r))}))}var TrackManager=function(){function e(t,r){_classCallCheck$1(this,e),this.hls=t,this.player=r}return _createClass$1(e,[{key:"getAudioTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.audioTracks||[]}catch(e){return console.error("Failed to get audio tracks:",e),[]}}},{key:"getCurrentAudioTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.audioTrack}catch(e){return console.error("Failed to get current audio track:",e),-1}}},{key:"switchAudioTrack",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;var t=this.getAudioTracks();if(0===t.length)return console.warn("No audio tracks available"),!1;if(!_someInstanceProperty(t).call(t,(function(t,r){return r===e})))return console.warn("Audio track with ID ".concat(e," not found")),!1;try{return this.hls.audioTrack=e,this.player.emit("core_event",{eventName:"core.audiotrackchange",trackId:e,trackInfo:t[e]||null}),!0}catch(e){return console.error("Failed to switch audio track:",e),!1}}},{key:"getSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.subtitleTracks||[]}catch(e){return console.error("Failed to get subtitle tracks:",e),[]}}},{key:"getAllSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.allSubtitleTracks||[]}catch(e){return console.error("Failed to get all subtitle tracks:",e),[]}}},{key:"getCurrentSubtitleTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.subtitleTrack}catch(e){return console.error("Failed to get current subtitle track:",e),-1}}},{key:"switchSubtitleTrack",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;var t=this.getSubtitleTracks();if(-1===e)try{return this.hls.subtitleTrack=-1,this.player.emit("core_event",{eventName:"core.subtitletrackchange",trackId:-1,trackInfo:null}),!0}catch(e){return console.error("Failed to disable subtitle track:",e),!1}if(0===t.length)return console.warn("No subtitle tracks available"),!1;if(!_someInstanceProperty(t).call(t,(function(t,r){return r===e})))return console.warn("Subtitle track with ID ".concat(e," not found")),!1;try{return this.hls.subtitleTrack=e,this.player.emit("core_event",{eventName:"core.subtitletrackchange",trackId:e,trackInfo:t[e]||null}),!0}catch(e){return console.error("Failed to switch subtitle track:",e),!1}}},{key:"getSubtitleDisplay",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),!1;try{return this.hls.subtitleDisplay}catch(e){return console.error("Failed to get subtitle display status:",e),!1}}},{key:"setSubtitleDisplay",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;try{return this.hls.subtitleDisplay=e,this.player.emit("core_event",{eventName:"core.subtitledisplaychange",enabled:e}),!0}catch(e){return console.error("Failed to set subtitle display:",e),!1}}}]),e}(),MAX_HOLE=.1,XgHls=function(e){_inherits(r,BasePlugin);var t=_createSuper(r);function r(e){var n;return _classCallCheck$1(this,r),(n=t.call(this,_objectSpread2$2(_objectSpread2$2({},e),{},{pluginName:r.pluginName})))._tickInterval=500,n._currentIndex=0,n._onPlay=function(){n.hls.startLoad()},n.onUrlChange=function(e){/^blob/.test(e)||(n.playerConfig.url=e,n.register(e))},n._getBufferend=function(e){var t=e.buffered;return t&&t.length?t.end(t.length-1):0},n._tick=function(){clearTimeout(n._tickTimer);var e=n.player.media;if(e){n._tickTimer=_setTimeout(n._tick,n._tickInterval);var t=n._getBufferend(e);t<MAX_HOLE||!e.readyState||n.player.config.isLive&&4===e.readyState&&e.paused&&t-e.currentTime>n.config.disconnectTime&&n.hls.stopLoad()}},n.on=function(e,t){var r;null==(r=n.hls)||r.on(e,t)},n.config=e.config||{},n.player.handleSource=!1,n}return _createClass$1(r,[{key:"beforePlayerInit",value:function(){this.register(this.player.config.url)}},{key:"initEvt",value:function(){initHlsEvents(this.hls,this.player)}},{key:"afterCreate",value:function(){var e=this.player.media;this.player.on(URL_CHANGE,this.onUrlChange);try{BasePlugin.defineGetterOrSetter(this.player,{url:{get:function(){try{return e.src}catch(e){return null}},configurable:!0}})}catch(e){}}},{key:"register",value:function(e){var t=this.player;this.hls&&this.hls.destroy();var r=getHlsConfig(this.config);(this.hls=new Hls(r),this._trackManager=new TrackManager(this.hls,this.player),this.initEvt(),t.config.preProcessUrl)&&(e=t.config.preProcessUrl(e).url);this.hls.loadSource(e);var n=this.player.media;this.hls.attachMedia(n),clearTimeout(this._tickTimer),this._tickTimer=_setTimeout(this._tick,this._tickInterval),n.removeEventListener("play",this._onPlay),n.addEventListener("play",this._onPlay)}},{key:"switchUrl",value:function(e,t){var r=t.startTime;(t.bitrate,t.seamless,this.hls.loadSource(e),void 0!==r)&&(this.player.media.currentTime=r)}},{key:"getAudioTracks",value:function(){return this._trackManager.getAudioTracks()}},{key:"getCurrentAudioTrack",value:function(){return this._trackManager.getCurrentAudioTrack()}},{key:"switchAudioTrack",value:function(e){return this._trackManager.switchAudioTrack(e)}},{key:"getSubtitleTracks",value:function(){return this._trackManager.getSubtitleTracks()}},{key:"getAllSubtitleTracks",value:function(){return this._trackManager.getAllSubtitleTracks()}},{key:"getCurrentSubtitleTrack",value:function(){return this._trackManager.getCurrentSubtitleTrack()}},{key:"switchSubtitleTrack",value:function(e){return this._trackManager.switchSubtitleTrack(e)}},{key:"getSubtitleDisplay",value:function(){return this._trackManager.getSubtitleDisplay()}},{key:"setSubtitleDisplay",value:function(e){return this._trackManager.setSubtitleDisplay(e)}},{key:"destroy",value:function(){var e;clearTimeout(this._tickTimer),this.player.off(URL_CHANGE,this.onUrlChange),null==(e=this.hls)||e.destroy()}}],[{key:"pluginName",get:function(){return"hls"}}]),r}(),HlsPlugin=function(e){_inherits(r,XgHls);var t=_createSuper(r);function r(){return _classCallCheck$1(this,r),t.apply(this,arguments)}return _createClass$1(r,[{key:"beforePlayerInit",value:function(){_get(_getPrototypeOf(r.prototype),"beforePlayerInit",this).call(this),this._transEvent()}},{key:"_transEvent",value:function(){var e,t=this;_forEachInstanceProperty(e=_Object$values(Events)).call(e,(function(e){e!==Events.ERROR&&t._transCoreEvent(e)}))}},{key:"_transCoreEvent",value:function(e){var t,r=this;null===(t=this.hls)||void 0===t||t.on(e,(function(t){if(r.player){for(var n,a,i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];(n=r.player).emit.apply(n,_concatInstanceProperty(a=[e]).call(a,s))}}))}}]),r}(),__PLUGIN_NAME__=DynamicModule.PluginHlsJs;export{HlsPlugin,__PLUGIN_NAME__};
|
|
2
2
|
//# sourceMappingURL=esm/veplayer.plugin.hlsjs.production.js.map
|