@byteplus/veplayer-plugin 2.11.0-rc.0 → 2.11.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 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).__VEPLAYER_PLUGIN_HLSJS__={})}(this,(function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n={exports:{}},a=function(e){return e&&e.Math==Math&&e},s=a("object"==typeof globalThis&&globalThis)||a("object"==typeof window&&window)||a("object"==typeof self&&self)||a("object"==typeof r&&r)||function(){return this}()||r||Function("return this")(),o=function(e){try{return!!e()}catch(t){return!0}},l=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),u=l,c=Function.prototype,h=c.apply,d=c.call,f="object"==typeof Reflect&&Reflect.apply||(u?d.bind(h):function(){return d.apply(h,arguments)}),v=l,g=Function.prototype,p=g.call,m=v&&g.bind.bind(p,p),y=v?m:function(e){return function(){return p.apply(e,arguments)}},E=y,k=E({}.toString),T=E("".slice),S=function(e){return T(k(e),8,-1)},A=S,L=y,b=function(e){if("Function"===A(e))return L(e)},R="object"==typeof document&&document.all,I={all:R,IS_HTMLDDA:void 0===R&&void 0!==R},D=I.all,_=I.IS_HTMLDDA?function(e){return"function"==typeof e||e===D}:function(e){return"function"==typeof e},w={},P=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=l,x=Function.prototype.call,M=C?x.bind(x):function(){return x.apply(x,arguments)},O={},F={}.propertyIsEnumerable,N=Object.getOwnPropertyDescriptor,U=N&&!F.call({1:2},1);O.f=U?function(e){var t=N(this,e);return!!t&&t.enumerable}:F;var B,G,K=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},H=o,V=S,j=Object,Y=y("".split),q=H((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==V(e)?Y(e,""):j(e)}:j,W=function(e){return null==e},z=W,X=TypeError,Q=function(e){if(z(e))throw X("Can't call method on "+e);return e},$=q,J=Q,Z=function(e){return $(J(e))},ee=_,te=I.all,re=I.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:ee(e)||e===te}:function(e){return"object"==typeof e?null!==e:ee(e)},ie={},ne=ie,ae=s,se=_,oe=function(e){return se(e)?e:void 0},le=function(e,t){return arguments.length<2?oe(ne[e])||oe(ae[e]):ne[e]&&ne[e][t]||ae[e]&&ae[e][t]},ue=y({}.isPrototypeOf),ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",he=s,de=ce,fe=he.process,ve=he.Deno,ge=fe&&fe.versions||ve&&ve.version,pe=ge&&ge.v8;pe&&(G=(B=pe.split("."))[0]>0&&B[0]<4?1:+(B[0]+B[1])),!G&&de&&(!(B=de.match(/Edge\/(\d+)/))||B[1]>=74)&&(B=de.match(/Chrome\/(\d+)/))&&(G=+B[1]);var me=G,ye=me,Ee=o,ke=s.String,Te=!!Object.getOwnPropertySymbols&&!Ee((function(){var e=Symbol();return!ke(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ye&&ye<41})),Se=Te&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ae=le,Le=_,be=ue,Re=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=Ae("Symbol");return Le(t)&&be(t.prototype,Re(e))},De=String,_e=function(e){try{return De(e)}catch(t){return"Object"}},we=_,Pe=_e,Ce=TypeError,xe=function(e){if(we(e))return e;throw Ce(Pe(e)+" is not a function")},Me=xe,Oe=W,Fe=function(e,t){var r=e[t];return Oe(r)?void 0:Me(r)},Ne=M,Ue=_,Be=re,Ge=TypeError,Ke={exports:{}},He=s,Ve=Object.defineProperty,je=function(e,t){try{Ve(He,e,{value:t,configurable:!0,writable:!0})}catch(r){He[e]=t}return t},Ye="__core-js_shared__",qe=s[Ye]||je(Ye,{}),We=qe;(Ke.exports=function(e,t){return We[e]||(We[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 ze=Ke.exports,Xe=Q,Qe=Object,$e=function(e){return Qe(Xe(e))},Je=$e,Ze=y({}.hasOwnProperty),et=Object.hasOwn||function(e,t){return Ze(Je(e),t)},tt=y,rt=0,it=Math.random(),nt=tt(1..toString),at=function(e){return"Symbol("+(void 0===e?"":e)+")_"+nt(++rt+it,36)},st=ze,ot=et,lt=at,ut=Te,ct=Se,ht=s.Symbol,dt=st("wks"),ft=ct?ht.for||ht:ht&&ht.withoutSetter||lt,vt=function(e){return ot(dt,e)||(dt[e]=ut&&ot(ht,e)?ht[e]:ft("Symbol."+e)),dt[e]},gt=M,pt=re,mt=Ie,yt=Fe,Et=function(e,t){var r,i;if("string"===t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;if(Ue(r=e.valueOf)&&!Be(i=Ne(r,e)))return i;if("string"!==t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;throw Ge("Can't convert object to primitive value")},kt=TypeError,Tt=vt("toPrimitive"),St=function(e,t){if(!pt(e)||mt(e))return e;var r,i=yt(e,Tt);if(i){if(void 0===t&&(t="default"),r=gt(i,e,t),!pt(r)||mt(r))return r;throw kt("Can't convert object to primitive value")}return void 0===t&&(t="number"),Et(e,t)},At=Ie,Lt=function(e){var t=St(e,"string");return At(t)?t:t+""},bt=re,Rt=s.document,It=bt(Rt)&&bt(Rt.createElement),Dt=function(e){return It?Rt.createElement(e):{}},_t=Dt,wt=!P&&!o((function(){return 7!=Object.defineProperty(_t("div"),"a",{get:function(){return 7}}).a})),Pt=P,Ct=M,xt=O,Mt=K,Ot=Z,Ft=Lt,Nt=et,Ut=wt,Bt=Object.getOwnPropertyDescriptor;w.f=Pt?Bt:function(e,t){if(e=Ot(e),t=Ft(t),Ut)try{return Bt(e,t)}catch(r){}if(Nt(e,t))return Mt(!Ct(xt.f,e,t),e[t])};var Gt=o,Kt=_,Ht=/#|\.prototype\./,Vt=function(e,t){var r=Yt[jt(e)];return r==Wt||r!=qt&&(Kt(t)?Gt(t):!!t)},jt=Vt.normalize=function(e){return String(e).replace(Ht,".").toLowerCase()},Yt=Vt.data={},qt=Vt.NATIVE="N",Wt=Vt.POLYFILL="P",zt=Vt,Xt=xe,Qt=l,$t=b(b.bind),Jt=function(e,t){return Xt(e),void 0===t?e:Qt?$t(e,t):function(){return e.apply(t,arguments)}},Zt={},er=P&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),tr=re,rr=String,ir=TypeError,nr=function(e){if(tr(e))return e;throw ir(rr(e)+" is not an object")},ar=P,sr=wt,or=er,lr=nr,ur=Lt,cr=TypeError,hr=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,fr="enumerable",vr="configurable",gr="writable";Zt.f=ar?or?function(e,t,r){if(lr(e),t=ur(t),lr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&gr in r&&!r[gr]){var i=dr(e,t);i&&i[gr]&&(e[t]=r.value,r={configurable:vr in r?r[vr]:i[vr],enumerable:fr in r?r[fr]:i[fr],writable:!1})}return hr(e,t,r)}:hr:function(e,t,r){if(lr(e),t=ur(t),lr(r),sr)try{return hr(e,t,r)}catch(i){}if("get"in r||"set"in r)throw cr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Zt,mr=K,yr=P?function(e,t,r){return pr.f(e,t,mr(1,r))}:function(e,t,r){return e[t]=r,e},Er=s,kr=f,Tr=b,Sr=_,Ar=w.f,Lr=zt,br=ie,Rr=Jt,Ir=yr,Dr=et,_r=function(e){var t=function(r,i,n){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,i)}return new e(r,i,n)}return kr(e,this,arguments)};return t.prototype=e.prototype,t},wr=function(e,t){var r,i,n,a,s,o,l,u,c,h=e.target,d=e.global,f=e.stat,v=e.proto,g=d?Er:f?Er[h]:(Er[h]||{}).prototype,p=d?br:br[h]||Ir(br,h,{})[h],m=p.prototype;for(a in t)i=!(r=Lr(d?a:h+(f?".":"#")+a,e.forced))&&g&&Dr(g,a),o=p[a],i&&(l=e.dontCallGetSet?(c=Ar(g,a))&&c.value:g[a]),s=i&&l?l:t[a],i&&typeof o==typeof s||(u=e.bind&&i?Rr(s,Er):e.wrap&&i?_r(s):v&&Sr(s)?Tr(s):s,(e.sham||s&&s.sham||o&&o.sham)&&Ir(u,"sham",!0),Ir(p,a,u),v&&(Dr(br,n=h+"Prototype")||Ir(br,n,{}),Ir(br[n],a,s),e.real&&m&&(r||!m[a])&&Ir(m,a,s)))},Pr=wr,Cr=P,xr=Zt.f;Pr({target:"Object",stat:!0,forced:Object.defineProperty!==xr,sham:!Cr},{defineProperty:xr});var Mr=ie.Object,Or=n.exports=function(e,t,r){return Mr.defineProperty(e,t,r)};Mr.defineProperty.sham&&(Or.sham=!0);var Fr=n.exports,Nr=i(Fr),Ur=S,Br=Array.isArray||function(e){return"Array"==Ur(e)},Gr=Math.ceil,Kr=Math.floor,Hr=Math.trunc||function(e){var t=+e;return(t>0?Kr:Gr)(t)},Vr=function(e){var t=+e;return t!=t||0===t?0:Hr(t)},jr=Vr,Yr=Math.min,qr=function(e){return e>0?Yr(jr(e),9007199254740991):0},Wr=qr,zr=function(e){return Wr(e.length)},Xr=TypeError,Qr=function(e){if(e>9007199254740991)throw Xr("Maximum allowed index exceeded");return e},$r=Lt,Jr=Zt,Zr=K,ei=function(e,t,r){var i=$r(t);i in e?Jr.f(e,i,Zr(0,r)):e[i]=r},ti={};ti[vt("toStringTag")]="z";var ri="[object z]"===String(ti),ii=ri,ni=_,ai=S,si=vt("toStringTag"),oi=Object,li="Arguments"==ai(function(){return arguments}()),ui=ii?ai:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=oi(e),si))?r:li?ai(t):"Object"==(i=ai(t))&&ni(t.callee)?"Arguments":i},ci=_,hi=qe,di=y(Function.toString);ci(hi.inspectSource)||(hi.inspectSource=function(e){return di(e)});var fi=hi.inspectSource,vi=y,gi=o,pi=_,mi=ui,yi=fi,Ei=function(){},ki=[],Ti=le("Reflect","construct"),Si=/^\s*(?:class|function)\b/,Ai=vi(Si.exec),Li=!Si.exec(Ei),bi=function(e){if(!pi(e))return!1;try{return Ti(Ei,ki,e),!0}catch(t){return!1}},Ri=function(e){if(!pi(e))return!1;switch(mi(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Li||!!Ai(Si,yi(e))}catch(t){return!0}};Ri.sham=!0;var Ii=!Ti||gi((function(){var e;return bi(bi.call)||!bi(Object)||!bi((function(){e=!0}))||e}))?Ri:bi,Di=Br,_i=Ii,wi=re,Pi=vt("species"),Ci=Array,xi=function(e){var t;return Di(e)&&(t=e.constructor,(_i(t)&&(t===Ci||Di(t.prototype))||wi(t)&&null===(t=t[Pi]))&&(t=void 0)),void 0===t?Ci:t},Mi=function(e,t){return new(xi(e))(0===t?0:t)},Oi=o,Fi=me,Ni=vt("species"),Ui=function(e){return Fi>=51||!Oi((function(){var t=[];return(t.constructor={})[Ni]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Bi=wr,Gi=o,Ki=Br,Hi=re,Vi=$e,ji=zr,Yi=Qr,qi=ei,Wi=Mi,zi=Ui,Xi=me,Qi=vt("isConcatSpreadable"),$i=Xi>=51||!Gi((function(){var e=[];return e[Qi]=!1,e.concat()[0]!==e})),Ji=function(e){if(!Hi(e))return!1;var t=e[Qi];return void 0!==t?!!t:Ki(e)};Bi({target:"Array",proto:!0,arity:1,forced:!$i||!zi("concat")},{concat:function(e){var t,r,i,n,a,s=Vi(this),o=Wi(s,0),l=0;for(t=-1,i=arguments.length;t<i;t++)if(Ji(a=-1===t?s:arguments[t]))for(n=ji(a),Yi(l+n),r=0;r<n;r++,l++)r in a&&qi(o,l,a[r]);else Yi(l+1),qi(o,l++,a);return o.length=l,o}});var Zi=ui,en=String,tn=function(e){if("Symbol"===Zi(e))throw TypeError("Cannot convert a Symbol value to a string");return en(e)},rn={},nn=Vr,an=Math.max,sn=Math.min,on=function(e,t){var r=nn(e);return r<0?an(r+t,0):sn(r,t)},ln=Z,un=on,cn=zr,hn=function(e){return function(t,r,i){var n,a=ln(t),s=cn(a),o=un(i,s);if(e&&r!=r){for(;s>o;)if((n=a[o++])!=n)return!0}else for(;s>o;o++)if((e||o in a)&&a[o]===r)return e||o||0;return!e&&-1}},dn={includes:hn(!0),indexOf:hn(!1)},fn={},vn=et,gn=Z,pn=dn.indexOf,mn=fn,yn=y([].push),En=function(e,t){var r,i=gn(e),n=0,a=[];for(r in i)!vn(mn,r)&&vn(i,r)&&yn(a,r);for(;t.length>n;)vn(i,r=t[n++])&&(~pn(a,r)||yn(a,r));return a},kn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Tn=En,Sn=kn,An=Object.keys||function(e){return Tn(e,Sn)},Ln=P,bn=er,Rn=Zt,In=nr,Dn=Z,_n=An;rn.f=Ln&&!bn?Object.defineProperties:function(e,t){In(e);for(var r,i=Dn(t),n=_n(t),a=n.length,s=0;a>s;)Rn.f(e,r=n[s++],i[r]);return e};var wn,Pn=le("document","documentElement"),Cn=at,xn=ze("keys"),Mn=function(e){return xn[e]||(xn[e]=Cn(e))},On=nr,Fn=rn,Nn=kn,Un=fn,Bn=Pn,Gn=Dt,Kn="prototype",Hn="script",Vn=Mn("IE_PROTO"),jn=function(){},Yn=function(e){return"<"+Hn+">"+e+"</"+Hn+">"},qn=function(e){e.write(Yn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Wn=function(){try{wn=new ActiveXObject("htmlfile")}catch(n){}var e,t,r;Wn="undefined"!=typeof document?document.domain&&wn?qn(wn):(t=Gn("iframe"),r="java"+Hn+":",t.style.display="none",Bn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Yn("document.F=Object")),e.close(),e.F):qn(wn);for(var i=Nn.length;i--;)delete Wn[Kn][Nn[i]];return Wn()};Un[Vn]=!0;var zn=Object.create||function(e,t){var r;return null!==e?(jn[Kn]=On(e),r=new jn,jn[Kn]=null,r[Vn]=e):r=Wn(),void 0===t?r:Fn.f(r,t)},Xn={},Qn=En,$n=kn.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Qn(e,$n)};var Jn={},Zn=on,ea=zr,ta=ei,ra=Array,ia=Math.max,na=function(e,t,r){for(var i=ea(e),n=Zn(t,i),a=Zn(void 0===r?i:r,i),s=ra(ia(a-n,0)),o=0;n<a;n++,o++)ta(s,o,e[n]);return s.length=o,s},aa=S,sa=Z,oa=Xn.f,la=na,ua="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Jn.f=function(e){return ua&&"Window"==aa(e)?function(e){try{return oa(e)}catch(t){return la(ua)}}(e):oa(sa(e))};var ca={};ca.f=Object.getOwnPropertySymbols;var ha=yr,da=function(e,t,r,i){return i&&i.enumerable?e[t]=r:ha(e,t,r),e},fa=Zt,va=function(e,t,r){return fa.f(e,t,r)},ga={},pa=vt;ga.f=pa;var ma,ya,Ea,ka=ie,Ta=et,Sa=ga,Aa=Zt.f,La=function(e){var t=ka.Symbol||(ka.Symbol={});Ta(t,e)||Aa(t,e,{value:Sa.f(e)})},ba=M,Ra=le,Ia=vt,Da=da,_a=function(){var e=Ra("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,i=Ia("toPrimitive");t&&!t[i]&&Da(t,i,(function(e){return ba(r,this)}),{arity:1})},wa=ui,Pa=ri?{}.toString:function(){return"[object "+wa(this)+"]"},Ca=ri,xa=Zt.f,Ma=yr,Oa=et,Fa=Pa,Na=vt("toStringTag"),Ua=function(e,t,r,i){if(e){var n=r?e:e.prototype;Oa(n,Na)||xa(n,Na,{configurable:!0,value:t}),i&&!Ca&&Ma(n,"toString",Fa)}},Ba=_,Ga=s.WeakMap,Ka=Ba(Ga)&&/native code/.test(String(Ga)),Ha=s,Va=re,ja=yr,Ya=et,qa=qe,Wa=Mn,za=fn,Xa="Object already initialized",Qa=Ha.TypeError,$a=Ha.WeakMap;if(Ka||qa.state){var Ja=qa.state||(qa.state=new $a);Ja.get=Ja.get,Ja.has=Ja.has,Ja.set=Ja.set,ma=function(e,t){if(Ja.has(e))throw Qa(Xa);return t.facade=e,Ja.set(e,t),t},ya=function(e){return Ja.get(e)||{}},Ea=function(e){return Ja.has(e)}}else{var Za=Wa("state");za[Za]=!0,ma=function(e,t){if(Ya(e,Za))throw Qa(Xa);return t.facade=e,ja(e,Za,t),t},ya=function(e){return Ya(e,Za)?e[Za]:{}},Ea=function(e){return Ya(e,Za)}}var es={set:ma,get:ya,has:Ea,enforce:function(e){return Ea(e)?ya(e):ma(e,{})},getterFor:function(e){return function(t){var r;if(!Va(t)||(r=ya(t)).type!==e)throw Qa("Incompatible receiver, "+e+" required");return r}}},ts=Jt,rs=q,is=$e,ns=zr,as=Mi,ss=y([].push),os=function(e){var t=1==e,r=2==e,i=3==e,n=4==e,a=6==e,s=7==e,o=5==e||a;return function(l,u,c,h){for(var d,f,v=is(l),g=rs(v),p=ts(u,c),m=ns(g),y=0,E=h||as,k=t?E(l,m):r||s?E(l,0):void 0;m>y;y++)if((o||y in g)&&(f=p(d=g[y],y,v),e))if(t)k[y]=f;else if(f)switch(e){case 3:return!0;case 5:return d;case 6:return y;case 2:ss(k,d)}else switch(e){case 4:return!1;case 7:ss(k,d)}return a?-1:i||n?n:k}},ls={forEach:os(0),map:os(1),filter:os(2),some:os(3),every:os(4),find:os(5),findIndex:os(6),filterReject:os(7)},us=wr,cs=s,hs=M,ds=y,fs=P,vs=Te,gs=o,ps=et,ms=ue,ys=nr,Es=Z,ks=Lt,Ts=tn,Ss=K,As=zn,Ls=An,bs=Xn,Rs=Jn,Is=ca,Ds=w,_s=Zt,ws=rn,Ps=O,Cs=da,xs=va,Ms=ze,Os=fn,Fs=at,Ns=vt,Us=ga,Bs=La,Gs=_a,Ks=Ua,Hs=es,Vs=ls.forEach,js=Mn("hidden"),Ys="Symbol",qs="prototype",Ws=Hs.set,zs=Hs.getterFor(Ys),Xs=Object[qs],Qs=cs.Symbol,$s=Qs&&Qs[qs],Js=cs.TypeError,Zs=cs.QObject,eo=Ds.f,to=_s.f,ro=Rs.f,io=Ps.f,no=ds([].push),ao=Ms("symbols"),so=Ms("op-symbols"),oo=Ms("wks"),lo=!Zs||!Zs[qs]||!Zs[qs].findChild,uo=fs&&gs((function(){return 7!=As(to({},"a",{get:function(){return to(this,"a",{value:7}).a}})).a}))?function(e,t,r){var i=eo(Xs,t);i&&delete Xs[t],to(e,t,r),i&&e!==Xs&&to(Xs,t,i)}:to,co=function(e,t){var r=ao[e]=As($s);return Ws(r,{type:Ys,tag:e,description:t}),fs||(r.description=t),r},ho=function(e,t,r){e===Xs&&ho(so,t,r),ys(e);var i=ks(t);return ys(r),ps(ao,i)?(r.enumerable?(ps(e,js)&&e[js][i]&&(e[js][i]=!1),r=As(r,{enumerable:Ss(0,!1)})):(ps(e,js)||to(e,js,Ss(1,{})),e[js][i]=!0),uo(e,i,r)):to(e,i,r)},fo=function(e,t){ys(e);var r=Es(t),i=Ls(r).concat(mo(r));return Vs(i,(function(t){fs&&!hs(vo,r,t)||ho(e,t,r[t])})),e},vo=function(e){var t=ks(e),r=hs(io,this,t);return!(this===Xs&&ps(ao,t)&&!ps(so,t))&&(!(r||!ps(this,t)||!ps(ao,t)||ps(this,js)&&this[js][t])||r)},go=function(e,t){var r=Es(e),i=ks(t);if(r!==Xs||!ps(ao,i)||ps(so,i)){var n=eo(r,i);return!n||!ps(ao,i)||ps(r,js)&&r[js][i]||(n.enumerable=!0),n}},po=function(e){var t=ro(Es(e)),r=[];return Vs(t,(function(e){ps(ao,e)||ps(Os,e)||no(r,e)})),r},mo=function(e){var t=e===Xs,r=ro(t?so:Es(e)),i=[];return Vs(r,(function(e){!ps(ao,e)||t&&!ps(Xs,e)||no(i,ao[e])})),i};vs||(Qs=function(){if(ms($s,this))throw Js("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Ts(arguments[0]):void 0,t=Fs(e),r=function(e){this===Xs&&hs(r,so,e),ps(this,js)&&ps(this[js],t)&&(this[js][t]=!1),uo(this,t,Ss(1,e))};return fs&&lo&&uo(Xs,t,{configurable:!0,set:r}),co(t,e)},Cs($s=Qs[qs],"toString",(function(){return zs(this).tag})),Cs(Qs,"withoutSetter",(function(e){return co(Fs(e),e)})),Ps.f=vo,_s.f=ho,ws.f=fo,Ds.f=go,bs.f=Rs.f=po,Is.f=mo,Us.f=function(e){return co(Ns(e),e)},fs&&xs($s,"description",{configurable:!0,get:function(){return zs(this).description}})),us({global:!0,constructor:!0,wrap:!0,forced:!vs,sham:!vs},{Symbol:Qs}),Vs(Ls(oo),(function(e){Bs(e)})),us({target:Ys,stat:!0,forced:!vs},{useSetter:function(){lo=!0},useSimple:function(){lo=!1}}),us({target:"Object",stat:!0,forced:!vs,sham:!fs},{create:function(e,t){return void 0===t?As(e):fo(As(e),t)},defineProperty:ho,defineProperties:fo,getOwnPropertyDescriptor:go}),us({target:"Object",stat:!0,forced:!vs},{getOwnPropertyNames:po}),Gs(),Ks(Qs,Ys),Os[js]=!0;var yo=Te&&!!Symbol.for&&!!Symbol.keyFor,Eo=wr,ko=le,To=et,So=tn,Ao=ze,Lo=yo,bo=Ao("string-to-symbol-registry"),Ro=Ao("symbol-to-string-registry");Eo({target:"Symbol",stat:!0,forced:!Lo},{for:function(e){var t=So(e);if(To(bo,t))return bo[t];var r=ko("Symbol")(t);return bo[t]=r,Ro[r]=t,r}});var Io=wr,Do=et,_o=Ie,wo=_e,Po=yo,Co=ze("symbol-to-string-registry");Io({target:"Symbol",stat:!0,forced:!Po},{keyFor:function(e){if(!_o(e))throw TypeError(wo(e)+" is not a symbol");if(Do(Co,e))return Co[e]}});var xo=y([].slice),Mo=Br,Oo=_,Fo=S,No=tn,Uo=y([].push),Bo=wr,Go=le,Ko=f,Ho=M,Vo=y,jo=o,Yo=_,qo=Ie,Wo=xo,zo=function(e){if(Oo(e))return e;if(Mo(e)){for(var t=e.length,r=[],i=0;i<t;i++){var n=e[i];"string"==typeof n?Uo(r,n):"number"!=typeof n&&"Number"!=Fo(n)&&"String"!=Fo(n)||Uo(r,No(n))}var a=r.length,s=!0;return function(e,t){if(s)return s=!1,t;if(Mo(this))return t;for(var i=0;i<a;i++)if(r[i]===e)return t}}},Xo=Te,Qo=String,$o=Go("JSON","stringify"),Jo=Vo(/./.exec),Zo=Vo("".charAt),el=Vo("".charCodeAt),tl=Vo("".replace),rl=Vo(1..toString),il=/[\uD800-\uDFFF]/g,nl=/^[\uD800-\uDBFF]$/,al=/^[\uDC00-\uDFFF]$/,sl=!Xo||jo((function(){var e=Go("Symbol")();return"[null]"!=$o([e])||"{}"!=$o({a:e})||"{}"!=$o(Object(e))})),ol=jo((function(){return'"\\udf06\\ud834"'!==$o("\udf06\ud834")||'"\\udead"'!==$o("\udead")})),ll=function(e,t){var r=Wo(arguments),i=zo(t);if(Yo(i)||void 0!==e&&!qo(e))return r[1]=function(e,t){if(Yo(i)&&(t=Ho(i,this,Qo(e),t)),!qo(t))return t},Ko($o,null,r)},ul=function(e,t,r){var i=Zo(r,t-1),n=Zo(r,t+1);return Jo(nl,e)&&!Jo(al,n)||Jo(al,e)&&!Jo(nl,i)?"\\u"+rl(el(e,0),16):e};$o&&Bo({target:"JSON",stat:!0,arity:3,forced:sl||ol},{stringify:function(e,t,r){var i=Wo(arguments),n=Ko(sl?ll:$o,null,i);return ol&&"string"==typeof n?tl(n,il,ul):n}});var cl=ca,hl=$e;wr({target:"Object",stat:!0,forced:!Te||o((function(){cl.f(1)}))},{getOwnPropertySymbols:function(e){var t=cl.f;return t?t(hl(e)):[]}}),La("asyncIterator"),La("hasInstance"),La("isConcatSpreadable"),La("iterator"),La("match"),La("matchAll"),La("replace"),La("search"),La("species"),La("split");var dl=_a;La("toPrimitive"),dl();var fl=le,vl=Ua;La("toStringTag"),vl(fl("Symbol"),"Symbol"),La("unscopables"),Ua(s.JSON,"JSON",!0);var gl,pl,ml,yl=ie.Symbol,El={},kl=P,Tl=et,Sl=Function.prototype,Al=kl&&Object.getOwnPropertyDescriptor,Ll=Tl(Sl,"name"),bl={EXISTS:Ll,PROPER:Ll&&"something"===function(){}.name,CONFIGURABLE:Ll&&(!kl||kl&&Al(Sl,"name").configurable)},Rl=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Il=et,Dl=_,_l=$e,wl=Rl,Pl=Mn("IE_PROTO"),Cl=Object,xl=Cl.prototype,Ml=wl?Cl.getPrototypeOf:function(e){var t=_l(e);if(Il(t,Pl))return t[Pl];var r=t.constructor;return Dl(r)&&t instanceof r?r.prototype:t instanceof Cl?xl:null},Ol=o,Fl=_,Nl=re,Ul=zn,Bl=Ml,Gl=da,Kl=vt("iterator"),Hl=!1;[].keys&&("next"in(ml=[].keys())?(pl=Bl(Bl(ml)))!==Object.prototype&&(gl=pl):Hl=!0);var Vl=!Nl(gl)||Ol((function(){var e={};return gl[Kl].call(e)!==e}));Fl((gl=Vl?{}:Ul(gl))[Kl])||Gl(gl,Kl,(function(){return this}));var jl={IteratorPrototype:gl,BUGGY_SAFARI_ITERATORS:Hl},Yl=jl.IteratorPrototype,ql=zn,Wl=K,zl=Ua,Xl=El,Ql=function(){return this},$l=function(e,t,r,i){var n=t+" Iterator";return e.prototype=ql(Yl,{next:Wl(+!i,r)}),zl(e,n,!1,!0),Xl[n]=Ql,e},Jl=y,Zl=xe,eu=_,tu=String,ru=TypeError,iu=function(e,t,r){try{return Jl(Zl(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},nu=nr,au=function(e){if("object"==typeof e||eu(e))return e;throw ru("Can't set "+tu(e)+" as a prototype")},su=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=iu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return nu(r),au(i),t?e(r,i):r.__proto__=i,r}}():void 0),ou=wr,lu=M,uu=bl,cu=$l,hu=Ml,du=Ua,fu=da,vu=El,gu=jl,pu=uu.PROPER,mu=gu.BUGGY_SAFARI_ITERATORS,yu=vt("iterator"),Eu="keys",ku="values",Tu="entries",Su=function(){return this},Au=function(e,t,r,i,n,a,s){cu(r,t,i);var o,l,u,c=function(e){if(e===n&&g)return g;if(!mu&&e in f)return f[e];switch(e){case Eu:case ku:case Tu:return function(){return new r(this,e)}}return function(){return new r(this)}},h=t+" Iterator",d=!1,f=e.prototype,v=f[yu]||f["@@iterator"]||n&&f[n],g=!mu&&v||c(n),p="Array"==t&&f.entries||v;if(p&&(o=hu(p.call(new e)))!==Object.prototype&&o.next&&(du(o,h,!0,!0),vu[h]=Su),pu&&n==ku&&v&&v.name!==ku&&(d=!0,g=function(){return lu(v,this)}),n)if(l={values:c(ku),keys:a?g:c(Eu),entries:c(Tu)},s)for(u in l)(mu||d||!(u in f))&&fu(f,u,l[u]);else ou({target:t,proto:!0,forced:mu||d},l);return s&&f[yu]!==g&&fu(f,yu,g,{name:n}),vu[t]=g,l},Lu=function(e,t){return{value:e,done:t}},bu=Z,Ru=El,Iu=es;Zt.f;var Du=Au,_u=Lu,wu="Array Iterator",Pu=Iu.set,Cu=Iu.getterFor(wu);Du(Array,"Array",(function(e,t){Pu(this,{type:wu,target:bu(e),index:0,kind:t})}),(function(){var e=Cu(this),t=e.target,r=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,_u(void 0,!0)):_u("keys"==r?i:"values"==r?t[i]:[i,t[i]],!1)}),"values"),Ru.Arguments=Ru.Array;var xu={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},Mu=s,Ou=ui,Fu=yr,Nu=El,Uu=vt("toStringTag");for(var Bu in xu){var Gu=Mu[Bu],Ku=Gu&&Gu.prototype;Ku&&Ou(Ku)!==Uu&&Fu(Ku,Uu,Bu),Nu[Bu]=Nu.Array}var Hu=yl;La("dispose");var Vu=Hu;La("asyncDispose");var ju=wr,Yu=y,qu=le("Symbol"),Wu=qu.keyFor,zu=Yu(qu.prototype.valueOf);ju({target:"Symbol",stat:!0},{isRegistered:function(e){try{return void 0!==Wu(zu(e))}catch(t){return!1}}});for(var Xu=wr,Qu=ze,$u=le,Ju=y,Zu=Ie,ec=vt,tc=$u("Symbol"),rc=tc.isWellKnown,ic=$u("Object","getOwnPropertyNames"),nc=Ju(tc.prototype.valueOf),ac=Qu("wks"),sc=0,oc=ic(tc),lc=oc.length;sc<lc;sc++)try{var uc=oc[sc];Zu(tc[uc])&&ec(uc)}catch(QV){}Xu({target:"Symbol",stat:!0,forced:!0},{isWellKnown:function(e){if(rc&&rc(e))return!0;try{for(var t=nc(e),r=0,i=ic(ac),n=i.length;r<n;r++)if(ac[i[r]]==t)return!0}catch(QV){}return!1}}),La("matcher"),La("metadataKey"),La("observable"),La("metadata"),La("patternMatch"),La("replaceAll");var cc=Vu,hc=i(cc),dc=y,fc=Vr,vc=tn,gc=Q,pc=dc("".charAt),mc=dc("".charCodeAt),yc=dc("".slice),Ec=function(e){return function(t,r){var i,n,a=vc(gc(t)),s=fc(r),o=a.length;return s<0||s>=o?e?"":void 0:(i=mc(a,s))<55296||i>56319||s+1===o||(n=mc(a,s+1))<56320||n>57343?e?pc(a,s):i:e?yc(a,s,s+2):n-56320+(i-55296<<10)+65536}},kc={codeAt:Ec(!1),charAt:Ec(!0)},Tc=kc.charAt,Sc=tn,Ac=es,Lc=Au,bc=Lu,Rc="String Iterator",Ic=Ac.set,Dc=Ac.getterFor(Rc);Lc(String,"String",(function(e){Ic(this,{type:Rc,string:Sc(e),index:0})}),(function(){var e,t=Dc(this),r=t.string,i=t.index;return i>=r.length?bc(void 0,!0):(e=Tc(r,i),t.index+=e.length,bc(e,!1))}));var _c=ga.f("iterator"),wc=i(_c);function Pc(e){return(Pc="function"==typeof hc&&"symbol"==typeof wc?function(e){return typeof e}:function(e){return e&&"function"==typeof hc&&e.constructor===hc&&e!==hc.prototype?"symbol":typeof e})(e)}var Cc=ga.f("toPrimitive"),xc=i(Cc);function Mc(e){var t=function(e,t){if("object"!==Pc(e)||null===e)return e;var r=e[xc];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Pc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Pc(t)?t:String(t)}function Oc(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Nr(e,Mc(i.key),i)}}function Fc(e,t,r){return t&&Oc(e.prototype,t),r&&Oc(e,r),Nr(e,"prototype",{writable:!1}),e}var Nc=et,Uc=M,Bc=re,Gc=nr,Kc=function(e){return void 0!==e&&(Nc(e,"value")||Nc(e,"writable"))},Hc=w,Vc=Ml;wr({target:"Reflect",stat:!0},{get:function e(t,r){var i,n,a=arguments.length<3?t:arguments[2];return Gc(t)===a?t[r]:(i=Hc.f(t,r))?Kc(i)?i.value:void 0===i.get?void 0:Uc(i.get,a):Bc(n=Vc(t))?e(n,r,a):void 0}});var jc=i(ie.Reflect.get),Yc=y,qc=xe,Wc=re,zc=et,Xc=xo,Qc=l,$c=Function,Jc=Yc([].concat),Zc=Yc([].join),eh={},th=Qc?$c.bind:function(e){var t=qc(this),r=t.prototype,i=Xc(arguments,1),n=function(){var r=Jc(i,Xc(arguments));return this instanceof n?function(e,t,r){if(!zc(eh,t)){for(var i=[],n=0;n<t;n++)i[n]="a["+n+"]";eh[t]=$c("C,a","return new C("+Zc(i,",")+")")}return eh[t](e,r)}(t,r.length,r):t.apply(e,r)};return Wc(r)&&(n.prototype=r),n},rh=th;wr({target:"Function",proto:!0,forced:Function.bind!==rh},{bind:rh});var ih=ie,nh=function(e){return ih[e+"Prototype"]},ah=nh("Function").bind,sh=ue,oh=ah,lh=Function.prototype,uh=function(e){var t=e.bind;return e===lh||sh(lh,e)&&t===lh.bind?oh:t},ch=i(uh),hh={exports:{}},dh=wr,fh=o,vh=Z,gh=w.f,ph=P;dh({target:"Object",stat:!0,forced:!ph||fh((function(){gh(1)})),sham:!ph},{getOwnPropertyDescriptor:function(e,t){return gh(vh(e),t)}});var mh=ie.Object,yh=hh.exports=function(e,t){return mh.getOwnPropertyDescriptor(e,t)};mh.getOwnPropertyDescriptor.sham&&(yh.sham=!0);var Eh=hh.exports,kh=i(Eh);wr({target:"Object",stat:!0},{setPrototypeOf:su});var Th=i(ie.Object.setPrototypeOf),Sh=$e,Ah=Ml,Lh=Rl;wr({target:"Object",stat:!0,forced:o((function(){Ah(1)})),sham:!Lh},{getPrototypeOf:function(e){return Ah(Sh(e))}});var bh=i(ie.Object.getPrototypeOf);function Rh(e){var t;return(Rh=Th?ch(t=bh).call(t):function(e){return e.__proto__||bh(e)})(e)}function Ih(){var e;"undefined"!=typeof Reflect&&jc?Ih=ch(e=jc).call(e):Ih=function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Rh(e)););return e}(e,t);if(i){var n=kh(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}};return Ih.apply(this,arguments)}wr({target:"Object",stat:!0,sham:!P},{create:zn});var Dh=ie.Object,_h=function(e,t){return Dh.create(e,t)},wh=i(_h);function Ph(e,t){var r;return(Ph=Th?ch(r=Th).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function Ch(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=wh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Nr(e,"prototype",{writable:!1}),t&&Ph(e,t)}var xh=Ii,Mh=_e,Oh=TypeError,Fh=function(e){if(xh(e))return e;throw Oh(Mh(e)+" is not a constructor")},Nh=wr,Uh=f,Bh=th,Gh=Fh,Kh=nr,Hh=re,Vh=zn,jh=o,Yh=le("Reflect","construct"),qh=Object.prototype,Wh=[].push,zh=jh((function(){function e(){}return!(Yh((function(){}),[],e)instanceof e)})),Xh=!jh((function(){Yh((function(){}))})),Qh=zh||Xh;Nh({target:"Reflect",stat:!0,forced:Qh,sham:Qh},{construct:function(e,t){Gh(e),Kh(t);var r=arguments.length<3?e:Gh(arguments[2]);if(Xh&&!zh)return Yh(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 i=[null];return Uh(Wh,i,t),new(Uh(Bh,e,i))}var n=r.prototype,a=Vh(Hh(n)?n:qh),s=Uh(e,a,t);return Hh(s)?s:a}});var $h=i(ie.Reflect.construct);function Jh(){if("undefined"==typeof Reflect||!$h)return!1;if($h.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call($h(Boolean,[],(function(){}))),!0}catch(e){return!1}}function Zh(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ed(e){var t=Jh();return function(){var r,i=Rh(e);if(t){var n=Rh(this).constructor;r=$h(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"===Pc(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Zh(e)}(this,r)}}var td=o,rd=function(e,t){var r=[][e];return!!r&&td((function(){r.call(null,t||function(){return 1},1)}))},id=ls.forEach,nd=rd("forEach")?[].forEach:function(e){return id(this,e,arguments.length>1?arguments[1]:void 0)};wr({target:"Array",proto:!0,forced:[].forEach!=nd},{forEach:nd});var ad=nh("Array").forEach,sd=ui,od=et,ld=ue,ud=ad,cd=Array.prototype,hd={DOMTokenList:!0,NodeList:!0},dd=function(e){var t=e.forEach;return e===cd||ld(cd,e)&&t===cd.forEach||od(hd,sd(e))?ud:t},fd=i(dd),vd=i(dd),gd=P,pd=y,md=An,yd=Z,Ed=pd(O.f),kd=pd([].push),Td=function(e){return function(t){for(var r,i=yd(t),n=md(i),a=n.length,s=0,o=[];a>s;)r=n[s++],gd&&!Ed(i,r)||kd(o,e?[r,i[r]]:i[r]);return o}},Sd={entries:Td(!0),values:Td(!1)},Ad=Sd.values;wr({target:"Object",stat:!0},{values:function(e){return Ad(e)}});var Ld=i(ie.Object.values),bd=nh("Array").concat,Rd=ue,Id=bd,Dd=Array.prototype,_d=i((function(e){var t=e.concat;return e===Dd||Rd(Dd,e)&&t===Dd.concat?Id:t})),wd=$e,Pd=An;wr({target:"Object",stat:!0,forced:o((function(){Pd(1)}))},{keys:function(e){return Pd(wd(e))}});var Cd=ie.Object.keys,xd=i(Cd),Md=ie.Object.getOwnPropertySymbols,Od=i(Md),Fd=ls.filter;wr({target:"Array",proto:!0,forced:!Ui("filter")},{filter:function(e){return Fd(this,e,arguments.length>1?arguments[1]:void 0)}});var Nd=nh("Array").filter,Ud=ue,Bd=Nd,Gd=Array.prototype,Kd=function(e){var t=e.filter;return e===Gd||Ud(Gd,e)&&t===Gd.filter?Bd:t},Hd=i(Kd),Vd=P,jd=Br,Yd=TypeError,qd=Object.getOwnPropertyDescriptor,Wd=Vd&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(QV){return QV instanceof TypeError}}()?function(e,t){if(jd(e)&&!qd(e,"length").writable)throw Yd("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},zd=$e,Xd=zr,Qd=Wd,$d=Qr;wr({target:"Array",proto:!0,arity:1,forced:o((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(QV){return QV instanceof TypeError}}()},{push:function(e){var t=zd(this),r=Xd(t),i=arguments.length;$d(r+i);for(var n=0;n<i;n++)t[r]=arguments[n],r++;return Qd(t,r),r}});var Jd=nh("Array").push,Zd=ue,ef=Jd,tf=Array.prototype,rf=i((function(e){var t=e.push;return e===tf||Zd(tf,e)&&t===tf.push?ef:t})),nf=le,af=Xn,sf=ca,of=nr,lf=y([].concat),uf=nf("Reflect","ownKeys")||function(e){var t=af.f(of(e)),r=sf.f;return r?lf(t,r(e)):t},cf=uf,hf=Z,df=w,ff=ei;wr({target:"Object",stat:!0,sham:!P},{getOwnPropertyDescriptors:function(e){for(var t,r,i=hf(e),n=df.f,a=cf(i),s={},o=0;a.length>o;)void 0!==(r=n(i,t=a[o++]))&&ff(s,t,r);return s}});var vf=ie.Object.getOwnPropertyDescriptors,gf=i(vf),pf={exports:{}},mf=wr,yf=P,Ef=rn.f;mf({target:"Object",stat:!0,forced:Object.defineProperties!==Ef,sham:!yf},{defineProperties:Ef});var kf=ie.Object,Tf=pf.exports=function(e,t){return kf.defineProperties(e,t)};kf.defineProperties.sham&&(Tf.sham=!0);var Sf=pf.exports,Af=i(Sf);function Lf(e,t,r){return(t=Mc(t))in e?Nr(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bf(e,t){var r=xd(e);if(Od){var i=Od(e);t&&(i=Hd(i).call(i,(function(t){return kh(e,t).enumerable}))),rf(r).apply(r,i)}return r}function Rf(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?fd(r=bf(Object(n),!0)).call(r,(function(t){Lf(e,t,n[t])})):gf?Af(e,gf(n)):fd(i=bf(Object(n))).call(i,(function(t){Nr(e,t,kh(n,t))}))}return e}var If,Df="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,_f=TypeError,wf=function(e,t){if(e<t)throw _f("Not enough arguments");return e},Pf=s,Cf=f,xf=_,Mf=Df,Of=ce,Ff=xo,Nf=wf,Uf=Pf.Function,Bf=/MSIE .\./.test(Of)||Mf&&((If=Pf.Bun.version.split(".")).length<3||0==If[0]&&(If[1]<3||3==If[1]&&0==If[2])),Gf=function(e,t){var r=t?2:1;return Bf?function(i,n){var a=Nf(arguments.length,1)>r,s=xf(i)?i:Uf(i),o=a?Ff(arguments,r):[],l=a?function(){Cf(s,this,o)}:s;return t?e(l,n):e(l)}:e},Kf=wr,Hf=s,Vf=Gf(Hf.setInterval,!0);Kf({global:!0,bind:!0,forced:Hf.setInterval!==Vf},{setInterval:Vf});var jf=wr,Yf=s,qf=Gf(Yf.setTimeout,!0);jf({global:!0,bind:!0,forced:Yf.setTimeout!==qf},{setTimeout:qf});var Wf=i(ie.setTimeout),zf=i(Cd),Xf=dn.includes;wr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return Xf(this,e,arguments.length>1?arguments[1]:void 0)}});var Qf=nh("Array").includes,$f=re,Jf=S,Zf=vt("match"),ev=function(e){var t;return $f(e)&&(void 0!==(t=e[Zf])?!!t:"RegExp"==Jf(e))},tv=TypeError,rv=function(e){if(ev(e))throw tv("The method doesn't accept regular expressions");return e},iv=vt("match"),nv=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[iv]=!1,"/./"[e](t)}catch(i){}}return!1},av=wr,sv=rv,ov=Q,lv=tn,uv=nv,cv=y("".indexOf);av({target:"String",proto:!0,forced:!uv("includes")},{includes:function(e){return!!~cv(lv(ov(this)),lv(sv(e)),arguments.length>1?arguments[1]:void 0)}});var hv=nh("String").includes,dv=ue,fv=Qf,vv=hv,gv=Array.prototype,pv=String.prototype,mv=i((function(e){var t=e.includes;return e===gv||dv(gv,e)&&t===gv.includes?fv:"string"==typeof e||e===pv||dv(pv,e)&&t===pv.includes?vv:t})),yv=wr,Ev=dn.indexOf,kv=rd,Tv=b([].indexOf),Sv=!!Tv&&1/Tv([1],1,-0)<0;yv({target:"Array",proto:!0,forced:Sv||!kv("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return Sv?Tv(this,e,t)||0:Ev(this,e,t)}});var Av=nh("Array").indexOf,Lv=ue,bv=Av,Rv=Array.prototype,Iv=function(e){var t=e.indexOf;return e===Rv||Lv(Rv,e)&&t===Rv.indexOf?bv:t},Dv=i(Iv),_v=i(Iv),wv=wr,Pv=ls.find,Cv="find",xv=!0;Cv in[]&&Array(1)[Cv]((function(){xv=!1})),wv({target:"Array",proto:!0,forced:xv},{find:function(e){return Pv(this,e,arguments.length>1?arguments[1]:void 0)}});var Mv=nh("Array").find,Ov=ue,Fv=Mv,Nv=Array.prototype,Uv=i((function(e){var t=e.find;return e===Nv||Ov(Nv,e)&&t===Nv.find?Fv:t})),Bv=wr,Gv=Br,Kv=Ii,Hv=re,Vv=on,jv=zr,Yv=Z,qv=ei,Wv=vt,zv=xo,Xv=Ui("slice"),Qv=Wv("species"),$v=Array,Jv=Math.max;Bv({target:"Array",proto:!0,forced:!Xv},{slice:function(e,t){var r,i,n,a=Yv(this),s=jv(a),o=Vv(e,s),l=Vv(void 0===t?s:t,s);if(Gv(a)&&(r=a.constructor,(Kv(r)&&(r===$v||Gv(r.prototype))||Hv(r)&&null===(r=r[Qv]))&&(r=void 0),r===$v||void 0===r))return zv(a,o,l);for(i=new(void 0===r?$v:r)(Jv(l-o,0)),n=0;o<l;o++,n++)o in a&&qv(i,n,a[o]);return i.length=n,i}});var Zv=nh("Array").slice,eg=ue,tg=Zv,rg=Array.prototype,ig=function(e){var t=e.slice;return e===rg||eg(rg,e)&&t===rg.slice?tg:t},ng=i(ig),ag=i(ig),sg=_e,og=TypeError,lg=function(e,t){if(!delete e[t])throw og("Cannot delete property "+sg(t)+" of "+sg(e))},ug=wr,cg=$e,hg=on,dg=Vr,fg=zr,vg=Wd,gg=Qr,pg=Mi,mg=ei,yg=lg,Eg=Ui("splice"),kg=Math.max,Tg=Math.min;ug({target:"Array",proto:!0,forced:!Eg},{splice:function(e,t){var r,i,n,a,s,o,l=cg(this),u=fg(l),c=hg(e,u),h=arguments.length;for(0===h?r=i=0:1===h?(r=0,i=u-c):(r=h-2,i=Tg(kg(dg(t),0),u-c)),gg(u+r-i),n=pg(l,i),a=0;a<i;a++)(s=c+a)in l&&mg(n,a,l[s]);if(n.length=i,r<i){for(a=c;a<u-i;a++)o=a+r,(s=a+i)in l?l[o]=l[s]:yg(l,o);for(a=u;a>u-i+r;a--)yg(l,a-1)}else if(r>i)for(a=u-i;a>c;a--)o=a+r-1,(s=a+i-1)in l?l[o]=l[s]:yg(l,o);for(a=0;a<r;a++)l[a+c]=arguments[a+2];return vg(l,u-i+r),n}});var Sg=nh("Array").splice,Ag=ue,Lg=Sg,bg=Array.prototype,Rg=i((function(e){var t=e.splice;return e===bg||Ag(bg,e)&&t===bg.splice?Lg:t})),Ig=et,Dg=uf,_g=w,wg=Zt,Pg=re,Cg=yr,xg=Error,Mg=y("".replace),Og=String(xg("zxcasd").stack),Fg=/\n\s*at [^:]*:[^\n]*/,Ng=Fg.test(Og),Ug=K,Bg=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Ug(1,7)),7!==e.stack)})),Gg=yr,Kg=function(e,t){if(Ng&&"string"==typeof e&&!xg.prepareStackTrace)for(;t--;)e=Mg(e,Fg,"");return e},Hg=Bg,Vg=Error.captureStackTrace,jg=El,Yg=vt("iterator"),qg=Array.prototype,Wg=function(e){return void 0!==e&&(jg.Array===e||qg[Yg]===e)},zg=ui,Xg=Fe,Qg=W,$g=El,Jg=vt("iterator"),Zg=function(e){if(!Qg(e))return Xg(e,Jg)||Xg(e,"@@iterator")||$g[zg(e)]},ep=M,tp=xe,rp=nr,ip=_e,np=Zg,ap=TypeError,sp=function(e,t){var r=arguments.length<2?np(e):t;if(tp(r))return rp(ep(r,e));throw ap(ip(e)+" is not iterable")},op=M,lp=nr,up=Fe,cp=function(e,t,r){var i,n;lp(e);try{if(!(i=up(e,"return"))){if("throw"===t)throw r;return r}i=op(i,e)}catch(QV){n=!0,i=QV}if("throw"===t)throw r;if(n)throw i;return lp(i),r},hp=Jt,dp=M,fp=nr,vp=_e,gp=Wg,pp=zr,mp=ue,yp=sp,Ep=Zg,kp=cp,Tp=TypeError,Sp=function(e,t){this.stopped=e,this.result=t},Ap=Sp.prototype,Lp=function(e,t,r){var i,n,a,s,o,l,u,c=r&&r.that,h=!(!r||!r.AS_ENTRIES),d=!(!r||!r.IS_RECORD),f=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),g=hp(t,c),p=function(e){return i&&kp(i,"normal",e),new Sp(!0,e)},m=function(e){return h?(fp(e),v?g(e[0],e[1],p):g(e[0],e[1])):v?g(e,p):g(e)};if(d)i=e.iterator;else if(f)i=e;else{if(!(n=Ep(e)))throw Tp(vp(e)+" is not iterable");if(gp(n)){for(a=0,s=pp(e);s>a;a++)if((o=m(e[a]))&&mp(Ap,o))return o;return new Sp(!1)}i=yp(e,n)}for(l=d?e.next:i.next;!(u=dp(l,i)).done;){try{o=m(u.value)}catch(QV){kp(i,"throw",QV)}if("object"==typeof o&&o&&mp(Ap,o))return o}return new Sp(!1)},bp=tn,Rp=wr,Ip=ue,Dp=Ml,_p=su,wp=function(e,t,r){for(var i=Dg(t),n=wg.f,a=_g.f,s=0;s<i.length;s++){var o=i[s];Ig(e,o)||r&&Ig(r,o)||n(e,o,a(t,o))}},Pp=zn,Cp=yr,xp=K,Mp=function(e,t){Pg(t)&&"cause"in t&&Cg(e,"cause",t.cause)},Op=function(e,t,r,i){Hg&&(Vg?Vg(e,t):Gg(e,"stack",Kg(r,i)))},Fp=Lp,Np=function(e,t){return void 0===e?arguments.length<2?"":t:bp(e)},Up=vt("toStringTag"),Bp=Error,Gp=[].push,Kp=function(e,t){var r,i=Ip(Hp,this);_p?r=_p(Bp(),i?Dp(this):Hp):(r=i?this:Pp(Hp),Cp(r,Up,"Error")),void 0!==t&&Cp(r,"message",Np(t)),Op(r,Kp,r.stack,1),arguments.length>2&&Mp(r,arguments[2]);var n=[];return Fp(e,Gp,{that:n}),Cp(r,"errors",n),r};_p?_p(Kp,Bp):wp(Kp,Bp,{name:!0});var Hp=Kp.prototype=Pp(Bp.prototype,{constructor:xp(1,Kp),message:xp(1,""),name:xp(1,"AggregateError")});Rp({global:!0,constructor:!0,arity:2},{AggregateError:Kp});var Vp,jp,Yp,qp,Wp="undefined"!=typeof process&&"process"==S(process),zp=le,Xp=va,Qp=P,$p=vt("species"),Jp=function(e){var t=zp(e);Qp&&t&&!t[$p]&&Xp(t,$p,{configurable:!0,get:function(){return this}})},Zp=ue,em=TypeError,tm=function(e,t){if(Zp(t,e))return e;throw em("Incorrect invocation")},rm=nr,im=Fh,nm=W,am=vt("species"),sm=function(e,t){var r,i=rm(e).constructor;return void 0===i||nm(r=rm(i)[am])?t:im(r)},om=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),lm=s,um=f,cm=Jt,hm=_,dm=et,fm=o,vm=Pn,gm=xo,pm=Dt,mm=wf,ym=om,Em=Wp,km=lm.setImmediate,Tm=lm.clearImmediate,Sm=lm.process,Am=lm.Dispatch,Lm=lm.Function,bm=lm.MessageChannel,Rm=lm.String,Im=0,Dm={},_m="onreadystatechange";fm((function(){Vp=lm.location}));var wm=function(e){if(dm(Dm,e)){var t=Dm[e];delete Dm[e],t()}},Pm=function(e){return function(){wm(e)}},Cm=function(e){wm(e.data)},xm=function(e){lm.postMessage(Rm(e),Vp.protocol+"//"+Vp.host)};km&&Tm||(km=function(e){mm(arguments.length,1);var t=hm(e)?e:Lm(e),r=gm(arguments,1);return Dm[++Im]=function(){um(t,void 0,r)},jp(Im),Im},Tm=function(e){delete Dm[e]},Em?jp=function(e){Sm.nextTick(Pm(e))}:Am&&Am.now?jp=function(e){Am.now(Pm(e))}:bm&&!ym?(qp=(Yp=new bm).port2,Yp.port1.onmessage=Cm,jp=cm(qp.postMessage,qp)):lm.addEventListener&&hm(lm.postMessage)&&!lm.importScripts&&Vp&&"file:"!==Vp.protocol&&!fm(xm)?(jp=xm,lm.addEventListener("message",Cm,!1)):jp=_m in pm("script")?function(e){vm.appendChild(pm("script"))[_m]=function(){vm.removeChild(this),wm(e)}}:function(e){setTimeout(Pm(e),0)});var Mm={set:km,clear:Tm},Om=function(){this.head=null,this.tail=null};Om.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 Fm,Nm,Um,Bm,Gm,Km=Om,Hm=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,Vm=/web0s(?!.*chrome)/i.test(ce),jm=s,Ym=Jt,qm=w.f,Wm=Mm.set,zm=Km,Xm=om,Qm=Hm,$m=Vm,Jm=Wp,Zm=jm.MutationObserver||jm.WebKitMutationObserver,ey=jm.document,ty=jm.process,ry=jm.Promise,iy=qm(jm,"queueMicrotask"),ny=iy&&iy.value;if(!ny){var ay=new zm,sy=function(){var e,t;for(Jm&&(e=ty.domain)&&e.exit();t=ay.get();)try{t()}catch(QV){throw ay.head&&Fm(),QV}e&&e.enter()};Xm||Jm||$m||!Zm||!ey?!Qm&&ry&&ry.resolve?((Bm=ry.resolve(void 0)).constructor=ry,Gm=Ym(Bm.then,Bm),Fm=function(){Gm(sy)}):Jm?Fm=function(){ty.nextTick(sy)}:(Wm=Ym(Wm,jm),Fm=function(){Wm(sy)}):(Nm=!0,Um=ey.createTextNode(""),new Zm(sy).observe(Um,{characterData:!0}),Fm=function(){Um.data=Nm=!Nm}),ny=function(e){ay.head||Fm(),ay.add(e)}}var oy=ny,ly=function(e){try{return{error:!1,value:e()}}catch(QV){return{error:!0,value:QV}}},uy=s.Promise,cy="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,hy=!cy&&!Wp&&"object"==typeof window&&"object"==typeof document,dy=s,fy=uy,vy=_,gy=zt,py=fi,my=vt,yy=hy,Ey=cy,ky=me,Ty=fy&&fy.prototype,Sy=my("species"),Ay=!1,Ly=vy(dy.PromiseRejectionEvent),by={CONSTRUCTOR:gy("Promise",(function(){var e=py(fy),t=e!==String(fy);if(!t&&66===ky)return!0;if(!Ty.catch||!Ty.finally)return!0;if(!ky||ky<51||!/native code/.test(e)){var r=new fy((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Sy]=i,!(Ay=r.then((function(){}))instanceof i))return!0}return!t&&(yy||Ey)&&!Ly})),REJECTION_EVENT:Ly,SUBCLASSING:Ay},Ry={},Iy=xe,Dy=TypeError,_y=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw Dy("Bad Promise constructor");t=e,r=i})),this.resolve=Iy(t),this.reject=Iy(r)};Ry.f=function(e){return new _y(e)};var wy,Py,Cy=wr,xy=Wp,My=s,Oy=M,Fy=da,Ny=Ua,Uy=Jp,By=xe,Gy=_,Ky=re,Hy=tm,Vy=sm,jy=Mm.set,Yy=oy,qy=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(QV){}},Wy=ly,zy=Km,Xy=es,Qy=uy,$y=by,Jy=Ry,Zy="Promise",eE=$y.CONSTRUCTOR,tE=$y.REJECTION_EVENT,rE=Xy.getterFor(Zy),iE=Xy.set,nE=Qy&&Qy.prototype,aE=Qy,sE=nE,oE=My.TypeError,lE=My.document,uE=My.process,cE=Jy.f,hE=cE,dE=!!(lE&&lE.createEvent&&My.dispatchEvent),fE="unhandledrejection",vE=function(e){var t;return!(!Ky(e)||!Gy(t=e.then))&&t},gE=function(e,t){var r,i,n,a=t.value,s=1==t.state,o=s?e.ok:e.fail,l=e.resolve,u=e.reject,c=e.domain;try{o?(s||(2===t.rejection&&kE(t),t.rejection=1),!0===o?r=a:(c&&c.enter(),r=o(a),c&&(c.exit(),n=!0)),r===e.promise?u(oE("Promise-chain cycle")):(i=vE(r))?Oy(i,r,l,u):l(r)):u(a)}catch(QV){c&&!n&&c.exit(),u(QV)}},pE=function(e,t){e.notified||(e.notified=!0,Yy((function(){for(var r,i=e.reactions;r=i.get();)gE(r,e);e.notified=!1,t&&!e.rejection&&yE(e)})))},mE=function(e,t,r){var i,n;dE?((i=lE.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),My.dispatchEvent(i)):i={promise:t,reason:r},!tE&&(n=My["on"+e])?n(i):e===fE&&qy("Unhandled promise rejection",r)},yE=function(e){Oy(jy,My,(function(){var t,r=e.facade,i=e.value;if(EE(e)&&(t=Wy((function(){xy?uE.emit("unhandledRejection",i,r):mE(fE,r,i)})),e.rejection=xy||EE(e)?2:1,t.error))throw t.value}))},EE=function(e){return 1!==e.rejection&&!e.parent},kE=function(e){Oy(jy,My,(function(){var t=e.facade;xy?uE.emit("rejectionHandled",t):mE("rejectionhandled",t,e.value)}))},TE=function(e,t,r){return function(i){e(t,i,r)}},SE=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,pE(e,!0))},AE=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw oE("Promise can't be resolved itself");var i=vE(t);i?Yy((function(){var r={done:!1};try{Oy(i,t,TE(AE,r,e),TE(SE,r,e))}catch(QV){SE(r,QV,e)}})):(e.value=t,e.state=1,pE(e,!1))}catch(QV){SE({done:!1},QV,e)}}};eE&&(sE=(aE=function(e){Hy(this,sE),By(e),Oy(wy,this);var t=rE(this);try{e(TE(AE,t),TE(SE,t))}catch(QV){SE(t,QV)}}).prototype,(wy=function(e){iE(this,{type:Zy,done:!1,notified:!1,parent:!1,reactions:new zy,rejection:!1,state:0,value:void 0})}).prototype=Fy(sE,"then",(function(e,t){var r=rE(this),i=cE(Vy(this,aE));return r.parent=!0,i.ok=!Gy(e)||e,i.fail=Gy(t)&&t,i.domain=xy?uE.domain:void 0,0==r.state?r.reactions.add(i):Yy((function(){gE(i,r)})),i.promise})),Py=function(){var e=new wy,t=rE(e);this.promise=e,this.resolve=TE(AE,t),this.reject=TE(SE,t)},Jy.f=cE=function(e){return e===aE||undefined===e?new Py(e):hE(e)}),Cy({global:!0,constructor:!0,wrap:!0,forced:eE},{Promise:aE}),Ny(aE,Zy,!1,!0),Uy(Zy);var LE=vt("iterator"),bE=!1;try{var RE=0,IE={next:function(){return{done:!!RE++}},return:function(){bE=!0}};IE[LE]=function(){return this},Array.from(IE,(function(){throw 2}))}catch(QV){}var DE=function(e,t){if(!t&&!bE)return!1;var r=!1;try{var i={};i[LE]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(QV){}return r},_E=uy,wE=by.CONSTRUCTOR||!DE((function(e){_E.all(e).then(void 0,(function(){}))})),PE=M,CE=xe,xE=Ry,ME=ly,OE=Lp;wr({target:"Promise",stat:!0,forced:wE},{all:function(e){var t=this,r=xE.f(t),i=r.resolve,n=r.reject,a=ME((function(){var r=CE(t.resolve),a=[],s=0,o=1;OE(e,(function(e){var l=s++,u=!1;o++,PE(r,t,e).then((function(e){u||(u=!0,a[l]=e,--o||i(a))}),n)})),--o||i(a)}));return a.error&&n(a.value),r.promise}});var FE=wr,NE=by.CONSTRUCTOR;uy&&uy.prototype,FE({target:"Promise",proto:!0,forced:NE,real:!0},{catch:function(e){return this.then(void 0,e)}});var UE=M,BE=xe,GE=Ry,KE=ly,HE=Lp;wr({target:"Promise",stat:!0,forced:wE},{race:function(e){var t=this,r=GE.f(t),i=r.reject,n=KE((function(){var n=BE(t.resolve);HE(e,(function(e){UE(n,t,e).then(r.resolve,i)}))}));return n.error&&i(n.value),r.promise}});var VE=M,jE=Ry;wr({target:"Promise",stat:!0,forced:by.CONSTRUCTOR},{reject:function(e){var t=jE.f(this);return VE(t.reject,void 0,e),t.promise}});var YE=nr,qE=re,WE=Ry,zE=function(e,t){if(YE(e),qE(t)&&t.constructor===e)return t;var r=WE.f(e);return(0,r.resolve)(t),r.promise},XE=wr,QE=uy,$E=by.CONSTRUCTOR,JE=zE,ZE=le("Promise"),ek=!$E;XE({target:"Promise",stat:!0,forced:true},{resolve:function(e){return JE(ek&&this===ZE?QE:this,e)}});var tk=M,rk=xe,ik=Ry,nk=ly,ak=Lp;wr({target:"Promise",stat:!0,forced:wE},{allSettled:function(e){var t=this,r=ik.f(t),i=r.resolve,n=r.reject,a=nk((function(){var r=rk(t.resolve),n=[],a=0,s=1;ak(e,(function(e){var o=a++,l=!1;s++,tk(r,t,e).then((function(e){l||(l=!0,n[o]={status:"fulfilled",value:e},--s||i(n))}),(function(e){l||(l=!0,n[o]={status:"rejected",reason:e},--s||i(n))}))})),--s||i(n)}));return a.error&&n(a.value),r.promise}});var sk=M,ok=xe,lk=le,uk=Ry,ck=ly,hk=Lp,dk="No one promise resolved";wr({target:"Promise",stat:!0,forced:wE},{any:function(e){var t=this,r=lk("AggregateError"),i=uk.f(t),n=i.resolve,a=i.reject,s=ck((function(){var i=ok(t.resolve),s=[],o=0,l=1,u=!1;hk(e,(function(e){var c=o++,h=!1;l++,sk(i,t,e).then((function(e){h||u||(u=!0,n(e))}),(function(e){h||u||(h=!0,s[c]=e,--l||a(new r(s,dk)))}))})),--l||a(new r(s,dk))}));return s.error&&a(s.value),i.promise}});var fk=wr,vk=uy,gk=o,pk=le,mk=_,yk=sm,Ek=zE,kk=vk&&vk.prototype;fk({target:"Promise",proto:!0,real:!0,forced:!!vk&&gk((function(){kk.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=yk(this,pk("Promise")),r=mk(e);return this.then(r?function(r){return Ek(t,e()).then((function(){return r}))}:e,r?function(r){return Ek(t,e()).then((function(){throw r}))}:e)}});var Tk=ie.Promise,Sk=Ry,Ak=ly;wr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Sk.f(this),r=Ak(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var Lk=i(Tk),bk="\t\n\v\f\r \u2028\u2029\ufeff",Rk=Q,Ik=tn,Dk=bk,_k=y("".replace),wk=RegExp("^["+Dk+"]+"),Pk=RegExp("(^|[^"+Dk+"])["+Dk+"]+$"),Ck=function(e){return function(t){var r=Ik(Rk(t));return 1&e&&(r=_k(r,wk,"")),2&e&&(r=_k(r,Pk,"$1")),r}},xk={start:Ck(1),end:Ck(2),trim:Ck(3)},Mk=s,Ok=o,Fk=y,Nk=tn,Uk=xk.trim,Bk=bk,Gk=Mk.parseInt,Kk=Mk.Symbol,Hk=Kk&&Kk.iterator,Vk=/^[+-]?0x/i,jk=Fk(Vk.exec),Yk=8!==Gk(Bk+"08")||22!==Gk(Bk+"0x16")||Hk&&!Ok((function(){Gk(Object(Hk))}))?function(e,t){var r=Uk(Nk(e));return Gk(r,t>>>0||(jk(Vk,r)?16:10))}:Gk;wr({global:!0,forced:parseInt!=Yk},{parseInt:Yk});var qk=i(ie.parseInt),Wk=ls.map;wr({target:"Array",proto:!0,forced:!Ui("map")},{map:function(e){return Wk(this,e,arguments.length>1?arguments[1]:void 0)}});var zk=nh("Array").map,Xk=ue,Qk=zk,$k=Array.prototype,Jk=i((function(e){var t=e.map;return e===$k||Xk($k,e)&&t===$k.map?Qk:t}));wr({target:"Array",stat:!0},{isArray:Br});var Zk=ie.Array.isArray,eT=i(Zk),tT=i(Zk),rT=i(Kd),iT=P,nT=y,aT=M,sT=o,oT=An,lT=ca,uT=O,cT=$e,hT=q,dT=Object.assign,fT=Object.defineProperty,vT=nT([].concat),gT=!dT||sT((function(){if(iT&&1!==dT({b:1},dT(fT({},"a",{enumerable:!0,get:function(){fT(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),i="abcdefghijklmnopqrst";return e[r]=7,i.split("").forEach((function(e){t[e]=e})),7!=dT({},e)[r]||oT(dT({},t)).join("")!=i}))?function(e,t){for(var r=cT(e),i=arguments.length,n=1,a=lT.f,s=uT.f;i>n;)for(var o,l=hT(arguments[n++]),u=a?vT(oT(l),a(l)):oT(l),c=u.length,h=0;c>h;)o=u[h++],iT&&!aT(s,l,o)||(r[o]=l[o]);return r}:dT,pT=gT;wr({target:"Object",stat:!0,arity:2,forced:Object.assign!==pT},{assign:pT});var mT=i(ie.Object.assign),yT=i(Md),ET=i(Eh),kT=i(vf),TT=i(Sf),ST=i(Fr),AT=i(cc),LT=i(_c),bT=i(_h),RT=i(uh),IT=Zg,DT=i(IT),_T=i(IT),wT=nr,PT=cp,CT=Jt,xT=M,MT=$e,OT=function(e,t,r,i){try{return i?t(wT(r)[0],r[1]):t(r)}catch(QV){PT(e,"throw",QV)}},FT=Wg,NT=Ii,UT=zr,BT=ei,GT=sp,KT=Zg,HT=Array,VT=function(e){var t=MT(e),r=NT(this),i=arguments.length,n=i>1?arguments[1]:void 0,a=void 0!==n;a&&(n=CT(n,i>2?arguments[2]:void 0));var s,o,l,u,c,h,d=KT(t),f=0;if(!d||this===HT&&FT(d))for(s=UT(t),o=r?new this(s):HT(s);s>f;f++)h=a?n(t[f],f):t[f],BT(o,f,h);else for(c=(u=GT(t,d)).next,o=r?new this:[];!(l=xT(c,u)).done;f++)h=a?OT(u,n,[l.value,f],!0):l.value,BT(o,f,h);return o.length=f,o},jT=VT;wr({target:"Array",stat:!0,forced:!DE((function(e){Array.from(e)}))},{from:jT});var YT=ie.Array.from,qT=i(YT),WT=i(YT),zT=i(Cc);function XT(e,t){var r=zf(e);if(yT){var i=yT(e);t&&(i=rT(i).call(i,(function(t){return ET(e,t).enumerable}))),r.push.apply(r,i)}return r}function QT(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=XT(Object(n),!0)).call(r,(function(t){tS(e,t,n[t])})):kT?TT(e,kT(n)):vd(i=XT(Object(n))).call(i,(function(t){ST(e,t,ET(n,t))}))}return e}function $T(e){return($T="function"==typeof AT&&"symbol"==typeof LT?function(e){return typeof e}:function(e){return e&&"function"==typeof AT&&e.constructor===AT&&e!==AT.prototype?"symbol":typeof e})(e)}function JT(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ZT(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),ST(e,nS(i.key),i)}}function eS(e,t,r){return t&&ZT(e.prototype,t),r&&ZT(e,r),ST(e,"prototype",{writable:!1}),e}function tS(e,t,r){return(t=nS(t))in e?ST(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function rS(e){return function(e){if(tT(e))return iS(e)}(e)||function(e){if(void 0!==AT&&null!=_T(e)||null!=e["@@iterator"])return WT(e)}(e)||function(e,t){var r;if(!e)return;if("string"==typeof e)return iS(e,t);var i=ag(r=Object.prototype.toString.call(e)).call(r,8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return WT(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return iS(e,t)}(e)||function(){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 iS(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function nS(e){var t=function(e,t){if("object"!==Pc(e)||null===e)return e;var r=e[zT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Pc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Pc(t)?t:String(t)}var aS=ls.some;wr({target:"Array",proto:!0,forced:!rd("some")},{some:function(e){return aS(this,e,arguments.length>1?arguments[1]:void 0)}});var sS=nh("Array").some,oS=ue,lS=sS,uS=Array.prototype,cS=i((function(e){var t=e.some;return e===uS||oS(uS,e)&&t===uS.some?lS:t})),hS=Vr,dS=tn,fS=Q,vS=RangeError,gS=y,pS=qr,mS=tn,yS=Q,ES=gS((function(e){var t=dS(fS(this)),r="",i=hS(e);if(i<0||i==1/0)throw vS("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r})),kS=gS("".slice),TS=Math.ceil,SS=function(e){return function(t,r,i){var n,a,s=mS(yS(t)),o=pS(r),l=s.length,u=void 0===i?" ":mS(i);return o<=l||""==u?s:((a=ES(u,TS((n=o-l)/u.length))).length>n&&(a=kS(a,0,n)),e?s+a:a+s)}},AS={start:SS(!1),end:SS(!0)},LS=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),bS=AS.start;wr({target:"String",proto:!0,forced:LS},{padStart:function(e){return bS(this,e,arguments.length>1?arguments[1]:void 0)}});var RS=nh("String").padStart,IS=ue,DS=RS,_S=String.prototype,wS=i((function(e){var t=e.padStart;return"string"==typeof e||e===_S||IS(_S,e)&&t===_S.padStart?DS:t})),PS=i(ie.setInterval),CS=ls.every;wr({target:"Array",proto:!0,forced:!rd("every")},{every:function(e){return CS(this,e,arguments.length>1?arguments[1]:void 0)}});var xS=nh("Array").every,MS=ue,OS=xS,FS=Array.prototype,NS=i((function(e){var t=e.every;return e===FS||MS(FS,e)&&t===FS.every?OS:t})),US=s,BS=o,GS=tn,KS=xk.trim,HS=bk,VS=y("".charAt),jS=US.parseFloat,YS=US.Symbol,qS=YS&&YS.iterator,WS=1/jS(HS+"-0")!=-1/0||qS&&!BS((function(){jS(Object(qS))}))?function(e){var t=KS(GS(e)),r=jS(t);return 0===r&&"-"==VS(t,0)?-0:r}:jS;wr({global:!0,forced:parseFloat!=WS},{parseFloat:WS});var zS=i(ie.parseFloat),XS=bl.PROPER,QS=o,$S=bk,JS=xk.trim;wr({target:"String",proto:!0,forced:function(e){return QS((function(){return!!$S[e]()||"
"!=="
"[e]()||XS&&$S[e].name!==e}))}("trim")},{trim:function(){return JS(this)}});var ZS=nh("String").trim,eA=ue,tA=ZS,rA=String.prototype,iA=i((function(e){var t=e.trim;return"string"==typeof e||e===rA||eA(rA,e)&&t===rA.trim?tA:t})),nA=na,aA=Math.floor,sA=function(e,t){var r=e.length,i=aA(r/2);return r<8?oA(e,t):lA(e,sA(nA(e,0,i),t),sA(nA(e,i),t),t)},oA=function(e,t){for(var r,i,n=e.length,a=1;a<n;){for(i=a,r=e[a];i&&t(e[i-1],r)>0;)e[i]=e[--i];i!==a++&&(e[i]=r)}return e},lA=function(e,t,r,i){for(var n=t.length,a=r.length,s=0,o=0;s<n||o<a;)e[s+o]=s<n&&o<a?i(t[s],r[o])<=0?t[s++]:r[o++]:s<n?t[s++]:r[o++];return e},uA=sA,cA=ce.match(/firefox\/(\d+)/i),hA=!!cA&&+cA[1],dA=/MSIE|Trident/.test(ce),fA=ce.match(/AppleWebKit\/(\d+)\./),vA=!!fA&&+fA[1],gA=wr,pA=y,mA=xe,yA=$e,EA=zr,kA=lg,TA=tn,SA=o,AA=uA,LA=rd,bA=hA,RA=dA,IA=me,DA=vA,_A=[],wA=pA(_A.sort),PA=pA(_A.push),CA=SA((function(){_A.sort(void 0)})),xA=SA((function(){_A.sort(null)})),MA=LA("sort"),OA=!SA((function(){if(IA)return IA<70;if(!(bA&&bA>3)){if(RA)return!0;if(DA)return DA<603;var e,t,r,i,n="";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(i=0;i<47;i++)_A.push({k:t+i,v:r})}for(_A.sort((function(e,t){return t.v-e.v})),i=0;i<_A.length;i++)t=_A[i].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));gA({target:"Array",proto:!0,forced:CA||!xA||!MA||!OA},{sort:function(e){void 0!==e&&mA(e);var t=yA(this);if(OA)return void 0===e?wA(t):wA(t,e);var r,i,n=[],a=EA(t);for(i=0;i<a;i++)i in t&&PA(n,t[i]);for(AA(n,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:TA(t)>TA(r)?1:-1}}(e)),r=EA(n),i=0;i<r;)t[i]=n[i++];for(;i<a;)kA(t,i++);return t}});var FA=nh("Array").sort,NA=ue,UA=FA,BA=Array.prototype,GA=i((function(e){var t=e.sort;return e===BA||NA(BA,e)&&t===BA.sort?UA:t})),KA=wr,HA=Date,VA=y(HA.prototype.getTime);KA({target:"Date",stat:!0},{now:function(){return VA(new HA)}});var jA,YA=i(ie.Date.now),qA="undefined"!=typeof window&&window.location&&_v(jA=window.location.href).call(jA,"xgplayerdebugger=1")>-1,WA="color: #525252; background-color: #90ee90;",zA="color: #525252; background-color: red;",XA="color: #525252; background-color: yellow; ",QA="%c[xgplayer]",$A={config:{debug:qA?3:0},logInfo:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=3&&(r=console).log.apply(r,_d(t=[QA,WA,e]).call(t,n))},logWarn:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=1&&(r=console).warn.apply(r,_d(t=[QA,XA,e]).call(t,n))},logError:function(e){var t,r;if(!(this.config.debug<1)){for(var i=this.config.debug>=2?"trace":"error",n=arguments.length,a=new Array(n>1?n-1:0),s=1;s<n;s++)a[s-1]=arguments[s];(r=console)[i].apply(r,_d(t=[QA,zA,e]).call(t,a))}}},JA=function(){function e(t){JT(this,e),this.bufferedList=t}return eS(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}(),ZA={};ZA.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]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=document.createElement(t);return a.className=n,a.innerHTML=r,vd(e=zf(i)).call(e,(function(e){var r=e,n=i[e];"video"===t||"audio"===t||"live-video"===t?n&&a.setAttribute(r,n):a.setAttribute(r,n)})),a},ZA.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 i=document.createElement("div");i.innerHTML=e;var n=i.children;if(i=null,n.length>0){var a;if(n=n[0],r&&ZA.addClass(n,r),t)vd(a=zf(t)).call(a,(function(e){n.setAttribute(e,t[e])}));return n}return null}catch(s){return $A.logError("util.createDomFromHtml",s),null}},ZA.hasClass=function(e,t){if(!e||!t)return!1;try{return cS(Array.prototype).call(e.classList,(function(e){return e===t}))}catch(i){var r=e.className&&"object"===$T(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},ZA.addClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.add(t)}))}catch(i){ZA.hasClass(e,t)||(e.className&&"object"===$T(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},ZA.removeClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.remove(t)}))}catch(n){var i;if(ZA.hasClass(e,t))vd(i=t.split(/\s+/g)).call(i,(function(t){var r=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===$T(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")}))}},ZA.toggleClass=function(e,t){var r;e&&vd(r=t.split(/\s+/g)).call(r,(function(t){ZA.hasClass(e,t)?ZA.removeClass(e,t):ZA.addClass(e,t)}))},ZA.classNames=function(){for(var e=arguments,t=[],r=function(r){if("String"===ZA.typeOf(e[r]))t.push(e[r]);else if("Object"===ZA.typeOf(e[r])){var i;Jk(i=zf(e[r])).call(i,(function(i){e[r][i]&&t.push(i)}))}},i=0;i<arguments.length;i++)r(i);return t.join(" ")},ZA.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(i){$A.logError("util.findDom",i),0===_v(r).call(r,"#")&&(e=t.getElementById(ag(r).call(r,1)))}return e},ZA.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},ZA.padStart=function(e,t,r){for(var i=String(r),n=t>>0,a=Math.ceil(n/i.length),s=[],o=String(e);a--;)s.push(i);return s.join("").substring(0,n-o.length)+o},ZA.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=wS(ZA).call(ZA,Math.floor(e/3600),2,0),r=wS(ZA).call(ZA,Math.floor((e-3600*t)/60),2,0),i=wS(ZA).call(ZA,Math.floor(e-3600*t-60*r),2,0);return("00"===t?[r,i]:[t,r,i]).join(":")},ZA.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},ZA.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},ZA.deepCopy=function(e,t){var r;if("Object"===ZA.typeOf(t)&&"Object"===ZA.typeOf(e))return vd(r=zf(t)).call(r,(function(r){if("Object"!==ZA.typeOf(t[r])||t[r]instanceof Node)if("Array"===ZA.typeOf(t[r])){var i;e[r]="Array"===ZA.typeOf(e[r])?_d(i=e[r]).call(i,t[r]):t[r]}else e[r]=t[r];else void 0===e[r]||void 0===e[r]?e[r]=t[r]:ZA.deepCopy(e[r],t[r])})),e},ZA.deepMerge=function(e,t){var r;return Jk(r=zf(t)).call(r,(function(r){var i;"Array"===ZA.typeOf(t[r])&&"Array"===ZA.typeOf(e[r])?"Array"===ZA.typeOf(e[r])&&(i=e[r]).push.apply(i,rS(t[r])):ZA.typeOf(e[r])!==ZA.typeOf(t[r])||null===e[r]||"Object"!==ZA.typeOf(e[r])||t[r]instanceof window.Node?null!==t[r]&&(e[r]=t[r]):ZA.deepMerge(e[r],t[r])})),e},ZA.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},ZA.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return vd(Array.prototype).call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},ZA.setInterval=function(e,t,r,i){e._interval[t]||(e._interval[t]=PS(RT(r).call(r,e),i))},ZA.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},ZA.setTimeout=function(e,t,r){e._timers||(e._timers=[]);var i=Wf((function(){t(),ZA.clearTimeout(e,i)}),r);return e._timers.push(i),i},ZA.clearTimeout=function(e,t){var r=e._timers;if("Array"===ZA.typeOf(r)){for(var i=0;i<r.length;i++)if(r[i]===t){Rg(r).call(r,i,1),clearTimeout(t);break}}else clearTimeout(t)},ZA.clearAllTimers=function(e){var t=e._timers;"Array"===ZA.typeOf(t)&&(Jk(t).call(t,(function(e){clearTimeout(e)})),e._timerIds=[])},ZA.createImgBtn=function(e,t,r,i){var n,a,s,o,l,u,c,h,d,f,v,g,p=ZA.createDom("xg-".concat(e),"",{},"xgplayer-".concat(e,"-img"));(p.style.backgroundImage='url("'.concat(t,'")'),r&&i)&&(NS(n=["px","rem","em","pt","dp","vw","vh","vm","%"]).call(n,(function(e){var t,n;return!(_v(r).call(r,e)>-1&&_v(i).call(i,e)>-1)||(c=zS(iA(t=ag(r).call(r,0,_v(r).call(r,e))).call(t)),h=zS(iA(n=ag(i).call(i,0,_v(i).call(i,e))).call(n)),d=e,!1)})),p.style.width=_d(a="".concat(c)).call(a,d),p.style.height=_d(s="".concat(h)).call(s,d),p.style.backgroundSize=_d(o=_d(l=_d(u="".concat(c)).call(u,d," ")).call(l,h)).call(o,d),p.style.margin="start"===e?_d(f=_d(v=_d(g="-".concat(h/2)).call(g,d," auto auto -")).call(v,c/2)).call(f,d):"auto 5px auto 5px");return p},ZA.Hex2RGBA=function(e,t){var r,i=[];if(/^\#[0-9A-F]{3}$/i.test(e)){var n="#";e.replace(/[0-9A-F]/gi,(function(e){n+=e+e})),e=n}return/^#[0-9A-F]{6}$/i.test(e)?(e.replace(/[0-9A-F]{2}/gi,(function(e){i.push(qk(e,16))})),_d(r="rgba(".concat(i.join(","),", ")).call(r,t,")")):"rgba(255, 255, 255, 0.1)"},ZA.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},ZA.checkIsFunction=function(e){return e&&"function"==typeof e},ZA.checkIsObject=function(e){return null!==e&&"object"===$T(e)},ZA.hide=function(e){e.style.display="none"},ZA.show=function(e,t){e.style.display=t||"block"},ZA.isUndefined=function(e){if(null==e)return!0},ZA.isNotNull=function(e){return!(null==e)},ZA.setStyleFromCsstext=function(e,t){if(t)if("String"===ZA.typeOf(t)){var r=t.replace(/\s+/g,"").split(";");Jk(r).call(r,(function(t){if(t){var r=t.split(":");r.length>1&&(e.style[r[0]]=r[1])}}))}else{var i;Jk(i=zf(t)).call(i,(function(r){e.style[r]=t[r]}))}},ZA.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"],i=e.style.cssText;if(!i)return{};var n=i.replace(/\s+/g,"").split(";"),a={},s={};return Jk(n).call(n,(function(e){if(e){var t=e.split(":");t.length>1&&(!function(e,t){for(var r=0,i=t.length;r<i;r++)if(_v(e).call(e,t[r])>-1)return!0;return!1}(t[0],r)?s[t[0]]=t[1]:a[t[0]]=t[1])}})),e.setAttribute("style",""),Jk(t=zf(s)).call(t,(function(t){e.style[t]=s[t]})),a},ZA.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var r=t.replace(/\s+/g,"").split(";"),i={};return Jk(r).call(r,(function(e){if(e){var t=e.split(":");t.length>1&&(i[t[0]]=t[1])}})),i},ZA.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 i=new window.Image;i.onload=function(e){i=null,t&&t(e)},i.onerror=function(e){i=null,r&&r(e)},i.src=e}},ZA.stopPropagation=function(e){e&&e.stopPropagation()},ZA.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},ZA.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},ZA.checkTouchSupport=function(){return"ontouchstart"in window},ZA.getBuffered2=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=[],i=0;i<e.length;i++)r.push({start:e.start(i)<.5?0:e.start(i),end:e.end(i)});GA(r).call(r,(function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var n=[];if(t)for(var a=0;a<r.length;a++){var s=n.length;if(s){var o=n[s-1].end;r[a].start-o<t?r[a].end>o&&(n[s-1].end=r[a].end):n.push(r[a])}else n.push(r[a])}else n=r;return new JA(n)},ZA.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}},ZA.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},ZA.getHostFromUrl=function(e){if("String"!==ZA.typeOf(e))return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r},ZA.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},ZA.isMSE=function(e){return e.media&&(e=e.media),!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},ZA.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},ZA.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=qk(e)}catch(r){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=qk(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)}))},ZA.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},ZA.adjustTimeByDuration=function(e,t,r){return t&&e&&(e>t||r&&e<t)?t:e},ZA.createPositionBar=function(e,t){var r=ZA.createDom("xg-bar","",{"data-index":-1},e);return t.appendChild(r),r},ZA.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]:"",i={scale:"".concat(t.scale||1),translate:_d(e="".concat(t.x||0,"%, ")).call(e,t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")},n=zf(i);return vd(n).call(n,(function(e){var t,n=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),a=_d(t="".concat(e,"(")).call(t,i[e],")");n.test(r)?(n.lastIndex=-1,r=r.replace(n,a)):r+="".concat(a," ")})),r},ZA.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},ZA.getIndexByTime=function(e,t){var r=t.length,i=-1;if(r<1)return i;if(e<=t[0].end||r<2)i=0;else if(e>t[r-1].end)i=r-1;else for(var n=1;n<r;n++)if(e>t[n-1].end&&e<=t[n].end){i=n;break}return i},ZA.getOffsetCurrentTime=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=-1;if((i=r>=0&&r<t.length?r:ZA.getIndexByTime(e,t))<0)return-1;var n=t.length,a=t[i],s=a.start,o=a.end,l=a.cTime,u=a.offset;return e<s?l:e>=s&&e<=o?e-u:e>o&&i>=n-1?o:-1},ZA.getCurrentTimeByOffset=function(e,t){var r=-1;if(!t||t.length<0)return e;for(var i=0;i<t.length;i++)if(e<=t[i].duration){r=i;break}if(-1!==r){var n=t[r].start;return r-1<0?n+e:n+(e-t[r-1].duration)}return e};var eL="urlchange";function tL(e,t,r){for(var i,n=arguments.length,a=new Array(n>3?n-3:0),s=3;s<n;s++)a[s-3]=arguments[s];var o,l=t.call.apply(t,_d(i=[e]).call(i,a));r&&"function"==typeof r&&(l&&l.then?l.then((function(){for(var t,i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];r.call.apply(r,_d(t=[e]).call(t,n))})):r.call.apply(r,_d(o=[e]).call(o,a)))}function rL(e,t){var r,i=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),RT(r=function(){var r,n=arguments,a=this;if(i.pre)try{var s,o;(o=i.pre).call.apply(o,_d(s=[this]).call(s,ag(Array.prototype).call(arguments)))}catch(g){var l,u;throw g.message=_d(l=_d(u="[pluginName: ".concat(this.pluginName,":")).call(u,e,":pre error] >> ")).call(l,g.message),g}if(this.__hooks&&this.__hooks[e])try{var c,h=function(e,t,r){for(var i=arguments.length,n=new Array(i>3?i-3:0),a=3;a<i;a++)n[a-3]=arguments[a];if(e.__hooks&&tT(e.__hooks[t])){var s,o=e.__hooks[t],l=-1,u=function e(t,r,i){for(var n,a,s=arguments.length,u=new Array(s>3?s-3:0),c=3;c<s;c++)u[c-3]=arguments[c];if(l++,0===o.length||l===o.length)return i.call.apply(i,_d(a=[t,t]).call(a,u));var h,d=o[l],f=d.call.apply(d,_d(n=[t,t]).call(n,u));return f&&f.then?f.then((function(n){var a;return!1===n?null:e.apply(void 0,_d(a=[t,r,i]).call(a,u))})).catch((function(e){console.warn("[runHooks]".concat(r," reject"),e.message)})):!1!==f?e.apply(void 0,_d(h=[t,r,i]).call(h,u)):void 0};return u.apply(void 0,_d(s=[e,t,r]).call(s,n))}var c;return r.call.apply(r,_d(c=[e,e]).call(c,n))}(this,e,t);if(h)if(h.then)h.then((function(e){var r;!1!==e&&tL.apply(void 0,_d(r=[a,t,i.next]).call(r,rS(n)))})).catch((function(e){throw e}));else tL.apply(void 0,_d(c=[this,t,i.next]).call(c,ag(Array.prototype).call(arguments)));else if(void 0===h){var d;tL.apply(void 0,_d(d=[this,t,i.next]).call(d,ag(Array.prototype).call(arguments)))}}catch(g){var f,v;throw g.message=_d(f=_d(v="[pluginName: ".concat(this.pluginName,":")).call(v,e,"] >> ")).call(f,g.message),g}else tL.apply(void 0,_d(r=[this,t,i.next]).call(r,ag(Array.prototype).call(arguments)))}).call(r,this)}function iL(e,t){var r=this.__hooks;if(!r||!tT(r[e]))return-1;for(var i=r[e],n=0;n<i.length;n++)if(i[n]===t)return n;return-1}function nL(e,t){var r=this.__hooks;if(r)return r.hasOwnProperty(e)?(tT(r[e])||(r[e]=[]),-1===iL.call(this,e,t)&&r[e].push(t),!0):(console.warn("has no supported hook which name [".concat(e,"]")),!1)}function aL(e,t){var r=this.__hooks;if(r)if(tT(r[e])){var i=r[e],n=iL.call(this,e,t);-1!==n&&Rg(i).call(i,n,1)}else r[e]&&(r[e]=null)}function sL(e,t){var r;$A.logError(_d(r="[".concat(e,"] event or callback cant be undefined or null when call ")).call(r,t))}var oL=function(){function e(t){JT(this,e),ZA.checkIsFunction(this.beforeCreate)&&this.beforeCreate(t),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&Jk(t).call(t,(function(t){e.__hooks[t]=null})),ST(e,"hooks",{get:function(){var t;return e.__hooks&&Jk(t=zf(e.__hooks)).call(t,(function(t){if(e.__hooks[t])return t}))}})}(this),this.__args=t,this.__events={},this.__onceEvents={},this.config=t.config||{},this.player=null,this.playerConfig={},this.pluginName="",this.__init(t)}return eS(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=ZA.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)):tT(e)&&vd(e).call(e,(function(e){r.__events[e]=t,r.player.on(e,t)})):sL(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)):tT(e)&&vd(e).call(e,(function(i){r.__onceEvents[i]=t,r.player.once(e,t)})):sL(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)):tT(e)&&vd(e).call(e,(function(i){delete r.__events[e],r.player.off(i,t)})):sL(this.pluginName,"plugin.off(event, callback)")}},{key:"offAll",value:function(){var e,t=this;vd(e=["__events","__onceEvents"]).call(e,(function(e){var r;vd(r=zf(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 i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];(r=this.player).emit.apply(r,_d(t=[e]).call(t,n))}}},{key:"emitUserAction",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var i=QT(QT({},r),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,i)}}},{key:"hook",value:function(e,t){var r;return rL.call.apply(rL,_d(r=[this]).call(r,ag(Array.prototype).call(arguments)))}},{key:"useHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return nL.call.apply(nL,_d(r=[this]).call(r,ag(Array.prototype).call(arguments)))}},{key:"removeHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return aL.call.apply(aL,_d(r=[this]).call(r,ag(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,i=this.pluginName;this.offAll(),ZA.clearAllTimers(this),ZA.checkIsFunction(this.destroy)&&this.destroy(),Jk(e=["player","playerConfig","pluginName","logger","__args","__hooks"]).call(e,(function(e){t[e]=null})),r.unRegisterPlugin(i),this.__hooks=null}}],[{key:"defineGetterOrSetter",value:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&ST(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]&&ST(e,r,{configurable:!0,value:t[r]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}(),lL=o,uL=vt("iterator"),cL=!lL((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,i){t.delete("b"),r+=i+e})),!e.toJSON||!t.size&&true||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[uL]||"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})),hL=y,dL=2147483647,fL=/[^\0-\u007E]/,vL=/[.\u3002\uFF0E\uFF61]/g,gL="Overflow: input needs wider integers to process",pL=RangeError,mL=hL(vL.exec),yL=Math.floor,EL=String.fromCharCode,kL=hL("".charCodeAt),TL=hL([].join),SL=hL([].push),AL=hL("".replace),LL=hL("".split),bL=hL("".toLowerCase),RL=function(e){return e+22+75*(e<26)},IL=function(e,t,r){var i=0;for(e=r?yL(e/700):e>>1,e+=yL(e/t);e>455;)e=yL(e/35),i+=36;return yL(i+36*e/(e+38))},DL=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var n=kL(e,r++);if(n>=55296&&n<=56319&&r<i){var a=kL(e,r++);56320==(64512&a)?SL(t,((1023&n)<<10)+(1023&a)+65536):(SL(t,n),r--)}else SL(t,n)}return t}(e);var r,i,n=e.length,a=128,s=0,o=72;for(r=0;r<e.length;r++)(i=e[r])<128&&SL(t,EL(i));var l=t.length,u=l;for(l&&SL(t,"-");u<n;){var c=dL;for(r=0;r<e.length;r++)(i=e[r])>=a&&i<c&&(c=i);var h=u+1;if(c-a>yL((dL-s)/h))throw pL(gL);for(s+=(c-a)*h,a=c,r=0;r<e.length;r++){if((i=e[r])<a&&++s>dL)throw pL(gL);if(i==a){for(var d=s,f=36;;){var v=f<=o?1:f>=o+26?26:f-o;if(d<v)break;var g=d-v,p=36-v;SL(t,EL(RL(v+g%p))),d=yL(g/p),f+=36}SL(t,EL(RL(d))),o=IL(s,h,u==l),s=0,u++}}s++,a++}return TL(t,"")},_L=da,wL=function(e,t,r){for(var i in t)r&&r.unsafe&&e[i]?e[i]=t[i]:_L(e,i,t[i],r);return e},PL=wr,CL=s,xL=M,ML=y,OL=P,FL=cL,NL=da,UL=va,BL=wL,GL=Ua,KL=$l,HL=es,VL=tm,jL=_,YL=et,qL=Jt,WL=ui,zL=nr,XL=re,QL=tn,$L=zn,JL=K,ZL=sp,eb=Zg,tb=wf,rb=uA,ib=vt("iterator"),nb="URLSearchParams",ab=nb+"Iterator",sb=HL.set,ob=HL.getterFor(nb),lb=HL.getterFor(ab),ub=Object.getOwnPropertyDescriptor,cb=function(e){if(!OL)return CL[e];var t=ub(CL,e);return t&&t.value},hb=cb("fetch"),db=cb("Request"),fb=cb("Headers"),vb=db&&db.prototype,gb=fb&&fb.prototype,pb=CL.RegExp,mb=CL.TypeError,yb=CL.decodeURIComponent,Eb=CL.encodeURIComponent,kb=ML("".charAt),Tb=ML([].join),Sb=ML([].push),Ab=ML("".replace),Lb=ML([].shift),bb=ML([].splice),Rb=ML("".split),Ib=ML("".slice),Db=/\+/g,_b=Array(4),wb=function(e){return _b[e-1]||(_b[e-1]=pb("((?:%[\\da-f]{2}){"+e+"})","gi"))},Pb=function(e){try{return yb(e)}catch(QV){return e}},Cb=function(e){var t=Ab(e,Db," "),r=4;try{return yb(t)}catch(QV){for(;r;)t=Ab(t,wb(r--),Pb);return t}},xb=/[!'()~]|%20/g,Mb={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Ob=function(e){return Mb[e]},Fb=function(e){return Ab(Eb(e),xb,Ob)},Nb=KL((function(e,t){sb(this,{type:ab,iterator:ZL(ob(e).entries),kind:t})}),"Iterator",(function(){var e=lb(this),t=e.kind,r=e.iterator.next(),i=r.value;return r.done||(r.value="keys"===t?i.key:"values"===t?i.value:[i.key,i.value]),r}),!0),Ub=function(e){this.entries=[],this.url=null,void 0!==e&&(XL(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===kb(e,0)?Ib(e,1):e:QL(e)))};Ub.prototype={type:nb,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,a,s,o,l=eb(e);if(l)for(r=(t=ZL(e,l)).next;!(i=xL(r,t)).done;){if(a=(n=ZL(zL(i.value))).next,(s=xL(a,n)).done||(o=xL(a,n)).done||!xL(a,n).done)throw mb("Expected sequence with length 2");Sb(this.entries,{key:QL(s.value),value:QL(o.value)})}else for(var u in e)YL(e,u)&&Sb(this.entries,{key:u,value:QL(e[u])})},parseQuery:function(e){if(e)for(var t,r,i=Rb(e,"&"),n=0;n<i.length;)(t=i[n++]).length&&(r=Rb(t,"="),Sb(this.entries,{key:Cb(Lb(r)),value:Cb(Tb(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],Sb(r,Fb(e.key)+"="+Fb(e.value));return Tb(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Bb=function(){VL(this,Gb);var e=sb(this,new Ub(arguments.length>0?arguments[0]:void 0));OL||(this.length=e.entries.length)},Gb=Bb.prototype;if(BL(Gb,{append:function(e,t){tb(arguments.length,2);var r=ob(this);Sb(r.entries,{key:QL(e),value:QL(t)}),OL||this.length++,r.updateURL()},delete:function(e){tb(arguments.length,1);for(var t=ob(this),r=t.entries,i=QL(e),n=0;n<r.length;)r[n].key===i?bb(r,n,1):n++;OL||(this.length=r.length),t.updateURL()},get:function(e){tb(arguments.length,1);for(var t=ob(this).entries,r=QL(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){tb(arguments.length,1);for(var t=ob(this).entries,r=QL(e),i=[],n=0;n<t.length;n++)t[n].key===r&&Sb(i,t[n].value);return i},has:function(e){tb(arguments.length,1);for(var t=ob(this).entries,r=QL(e),i=0;i<t.length;)if(t[i++].key===r)return!0;return!1},set:function(e,t){tb(arguments.length,1);for(var r,i=ob(this),n=i.entries,a=!1,s=QL(e),o=QL(t),l=0;l<n.length;l++)(r=n[l]).key===s&&(a?bb(n,l--,1):(a=!0,r.value=o));a||Sb(n,{key:s,value:o}),OL||(this.length=n.length),i.updateURL()},sort:function(){var e=ob(this);rb(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=ob(this).entries,i=qL(e,arguments.length>1?arguments[1]:void 0),n=0;n<r.length;)i((t=r[n++]).value,t.key,this)},keys:function(){return new Nb(this,"keys")},values:function(){return new Nb(this,"values")},entries:function(){return new Nb(this,"entries")}},{enumerable:!0}),NL(Gb,ib,Gb.entries,{name:"entries"}),NL(Gb,"toString",(function(){return ob(this).serialize()}),{enumerable:!0}),OL&&UL(Gb,"size",{get:function(){return ob(this).entries.length},configurable:!0,enumerable:!0}),GL(Bb,nb),PL({global:!0,constructor:!0,forced:!FL},{URLSearchParams:Bb}),!FL&&jL(fb)){var Kb=ML(gb.has),Hb=ML(gb.set),Vb=function(e){if(XL(e)){var t,r=e.body;if(WL(r)===nb)return t=e.headers?new fb(e.headers):new fb,Kb(t,"content-type")||Hb(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),$L(e,{body:JL(0,QL(r)),headers:JL(0,t)})}return e};if(jL(hb)&&PL({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return hb(e,arguments.length>1?Vb(arguments[1]):{})}}),jL(db)){var jb=function(e){return VL(this,vb),new db(e,arguments.length>1?Vb(arguments[1]):{})};vb.constructor=jb,jb.prototype=vb,PL({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:jb})}}var Yb,qb=wr,Wb=P,zb=cL,Xb=s,Qb=Jt,$b=y,Jb=da,Zb=va,eR=tm,tR=et,rR=gT,iR=VT,nR=na,aR=kc.codeAt,sR=function(e){var t,r,i=[],n=LL(AL(bL(e),vL,"."),".");for(t=0;t<n.length;t++)r=n[t],SL(i,mL(fL,r)?"xn--"+DL(r):r);return TL(i,".")},oR=tn,lR=Ua,uR=wf,cR={URLSearchParams:Bb,getState:ob},hR=es,dR=hR.set,fR=hR.getterFor("URL"),vR=cR.URLSearchParams,gR=cR.getState,pR=Xb.URL,mR=Xb.TypeError,yR=Xb.parseInt,ER=Math.floor,kR=Math.pow,TR=$b("".charAt),SR=$b(/./.exec),AR=$b([].join),LR=$b(1..toString),bR=$b([].pop),RR=$b([].push),IR=$b("".replace),DR=$b([].shift),_R=$b("".split),wR=$b("".slice),PR=$b("".toLowerCase),CR=$b([].unshift),xR="Invalid scheme",MR="Invalid host",OR="Invalid port",FR=/[a-z]/i,NR=/[\d+-.a-z]/i,UR=/\d/,BR=/^0x/i,GR=/^[0-7]+$/,KR=/^\d+$/,HR=/^[\da-f]+$/i,VR=/[\0\t\n\r #%/:<>?@[\\\]^|]/,jR=/[\0\t\n\r #/:<>?@[\\\]^|]/,YR=/^[\u0000-\u0020]+/,qR=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,WR=/[\t\n\r]/g,zR=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)CR(t,e%256),e=ER(e/256);return AR(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,n=0,a=0;a<8;a++)0!==e[a]?(n>r&&(t=i,r=n),i=null,n=0):(null===i&&(i=a),++n);return n>r&&(t=i,r=n),t}(e),r=0;r<8;r++)n&&0===e[r]||(n&&(n=!1),i===r?(t+=r?":":"::",n=!0):(t+=LR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},XR={},QR=rR({},XR,{" ":1,'"':1,"<":1,">":1,"`":1}),$R=rR({},QR,{"#":1,"?":1,"{":1,"}":1}),JR=rR({},$R,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ZR=function(e,t){var r=aR(e,0);return r>32&&r<127&&!tR(t,e)?e:encodeURIComponent(e)},eI={ftp:21,file:null,http:80,https:443,ws:80,wss:443},tI=function(e,t){var r;return 2==e.length&&SR(FR,TR(e,0))&&(":"==(r=TR(e,1))||!t&&"|"==r)},rI=function(e){var t;return e.length>1&&tI(wR(e,0,2))&&(2==e.length||"/"===(t=TR(e,2))||"\\"===t||"?"===t||"#"===t)},iI=function(e){return"."===e||"%2e"===PR(e)},nI={},aI={},sI={},oI={},lI={},uI={},cI={},hI={},dI={},fI={},vI={},gI={},pI={},mI={},yI={},EI={},kI={},TI={},SI={},AI={},LI={},bI=function(e,t,r){var i,n,a,s=oR(e);if(t){if(n=this.parse(s))throw mR(n);this.searchParams=null}else{if(void 0!==r&&(i=new bI(r,!0)),n=this.parse(s,null,i))throw mR(n);(a=gR(new vR)).bindURL(this),this.searchParams=a}};bI.prototype={type:"URL",parse:function(e,t,r){var i,n,a,s,o,l=this,u=t||nI,c=0,h="",d=!1,f=!1,v=!1;for(e=oR(e),t||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,e=IR(e,YR,""),e=IR(e,qR,"$1")),e=IR(e,WR,""),i=iR(e);c<=i.length;){switch(n=i[c],u){case nI:if(!n||!SR(FR,n)){if(t)return xR;u=sI;continue}h+=PR(n),u=aI;break;case aI:if(n&&(SR(NR,n)||"+"==n||"-"==n||"."==n))h+=PR(n);else{if(":"!=n){if(t)return xR;h="",u=sI,c=0;continue}if(t&&(l.isSpecial()!=tR(eI,h)||"file"==h&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=h,t)return void(l.isSpecial()&&eI[l.scheme]==l.port&&(l.port=null));h="","file"==l.scheme?u=mI:l.isSpecial()&&r&&r.scheme==l.scheme?u=oI:l.isSpecial()?u=hI:"/"==i[c+1]?(u=lI,c++):(l.cannotBeABaseURL=!0,RR(l.path,""),u=SI)}break;case sI:if(!r||r.cannotBeABaseURL&&"#"!=n)return xR;if(r.cannotBeABaseURL&&"#"==n){l.scheme=r.scheme,l.path=nR(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,u=LI;break}u="file"==r.scheme?mI:uI;continue;case oI:if("/"!=n||"/"!=i[c+1]){u=uI;continue}u=dI,c++;break;case lI:if("/"==n){u=fI;break}u=TI;continue;case uI:if(l.scheme=r.scheme,n==Yb)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=nR(r.path),l.query=r.query;else if("/"==n||"\\"==n&&l.isSpecial())u=cI;else if("?"==n)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=nR(r.path),l.query="",u=AI;else{if("#"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=nR(r.path),l.path.length--,u=TI;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=nR(r.path),l.query=r.query,l.fragment="",u=LI}break;case cI:if(!l.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,u=TI;continue}u=fI}else u=dI;break;case hI:if(u=dI,"/"!=n||"/"!=TR(h,c+1))continue;c++;break;case dI:if("/"!=n&&"\\"!=n){u=fI;continue}break;case fI:if("@"==n){d&&(h="%40"+h),d=!0,a=iR(h);for(var g=0;g<a.length;g++){var p=a[g];if(":"!=p||v){var m=ZR(p,JR);v?l.password+=m:l.username+=m}else v=!0}h=""}else if(n==Yb||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(d&&""==h)return"Invalid authority";c-=iR(h).length+1,h="",u=vI}else h+=n;break;case vI:case gI:if(t&&"file"==l.scheme){u=EI;continue}if(":"!=n||f){if(n==Yb||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(l.isSpecial()&&""==h)return MR;if(t&&""==h&&(l.includesCredentials()||null!==l.port))return;if(s=l.parseHost(h))return s;if(h="",u=kI,t)return;continue}"["==n?f=!0:"]"==n&&(f=!1),h+=n}else{if(""==h)return MR;if(s=l.parseHost(h))return s;if(h="",u=pI,t==gI)return}break;case pI:if(!SR(UR,n)){if(n==Yb||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()||t){if(""!=h){var y=yR(h,10);if(y>65535)return OR;l.port=l.isSpecial()&&y===eI[l.scheme]?null:y,h=""}if(t)return;u=kI;continue}return OR}h+=n;break;case mI:if(l.scheme="file","/"==n||"\\"==n)u=yI;else{if(!r||"file"!=r.scheme){u=TI;continue}if(n==Yb)l.host=r.host,l.path=nR(r.path),l.query=r.query;else if("?"==n)l.host=r.host,l.path=nR(r.path),l.query="",u=AI;else{if("#"!=n){rI(AR(nR(i,c),""))||(l.host=r.host,l.path=nR(r.path),l.shortenPath()),u=TI;continue}l.host=r.host,l.path=nR(r.path),l.query=r.query,l.fragment="",u=LI}}break;case yI:if("/"==n||"\\"==n){u=EI;break}r&&"file"==r.scheme&&!rI(AR(nR(i,c),""))&&(tI(r.path[0],!0)?RR(l.path,r.path[0]):l.host=r.host),u=TI;continue;case EI:if(n==Yb||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&tI(h))u=TI;else if(""==h){if(l.host="",t)return;u=kI}else{if(s=l.parseHost(h))return s;if("localhost"==l.host&&(l.host=""),t)return;h="",u=kI}continue}h+=n;break;case kI:if(l.isSpecial()){if(u=TI,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=Yb&&(u=TI,"/"!=n))continue}else l.fragment="",u=LI;else l.query="",u=AI;break;case TI:if(n==Yb||"/"==n||"\\"==n&&l.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(o=PR(o=h))||"%2e."===o||".%2e"===o||"%2e%2e"===o?(l.shortenPath(),"/"==n||"\\"==n&&l.isSpecial()||RR(l.path,"")):iI(h)?"/"==n||"\\"==n&&l.isSpecial()||RR(l.path,""):("file"==l.scheme&&!l.path.length&&tI(h)&&(l.host&&(l.host=""),h=TR(h,0)+":"),RR(l.path,h)),h="","file"==l.scheme&&(n==Yb||"?"==n||"#"==n))for(;l.path.length>1&&""===l.path[0];)DR(l.path);"?"==n?(l.query="",u=AI):"#"==n&&(l.fragment="",u=LI)}else h+=ZR(n,$R);break;case SI:"?"==n?(l.query="",u=AI):"#"==n?(l.fragment="",u=LI):n!=Yb&&(l.path[0]+=ZR(n,XR));break;case AI:t||"#"!=n?n!=Yb&&("'"==n&&l.isSpecial()?l.query+="%27":l.query+="#"==n?"%23":ZR(n,XR)):(l.fragment="",u=LI);break;case LI:n!=Yb&&(l.fragment+=ZR(n,QR))}c++}},parseHost:function(e){var t,r,i;if("["==TR(e,0)){if("]"!=TR(e,e.length-1))return MR;if(t=function(e){var t,r,i,n,a,s,o,l=[0,0,0,0,0,0,0,0],u=0,c=null,h=0,d=function(){return TR(e,h)};if(":"==d()){if(":"!=TR(e,1))return;h+=2,c=++u}for(;d();){if(8==u)return;if(":"!=d()){for(t=r=0;r<4&&SR(HR,d());)t=16*t+yR(d(),16),h++,r++;if("."==d()){if(0==r)return;if(h-=r,u>6)return;for(i=0;d();){if(n=null,i>0){if(!("."==d()&&i<4))return;h++}if(!SR(UR,d()))return;for(;SR(UR,d());){if(a=yR(d(),10),null===n)n=a;else{if(0==n)return;n=10*n+a}if(n>255)return;h++}l[u]=256*l[u]+n,2!=++i&&4!=i||u++}if(4!=i)return;break}if(":"==d()){if(h++,!d())return}else if(d())return;l[u++]=t}else{if(null!==c)return;h++,c=++u}}if(null!==c)for(s=u-c,u=7;0!=u&&s>0;)o=l[u],l[u--]=l[c+s-1],l[c+--s]=o;else if(8!=u)return;return l}(wR(e,1,-1)),!t)return MR;this.host=t}else if(this.isSpecial()){if(e=sR(e),SR(VR,e))return MR;if(t=function(e){var t,r,i,n,a,s,o,l=_R(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(r=[],i=0;i<t;i++){if(""==(n=l[i]))return e;if(a=10,n.length>1&&"0"==TR(n,0)&&(a=SR(BR,n)?16:8,n=wR(n,8==a?1:2)),""===n)s=0;else{if(!SR(10==a?KR:8==a?GR:HR,n))return e;s=yR(n,a)}RR(r,s)}for(i=0;i<t;i++)if(s=r[i],i==t-1){if(s>=kR(256,5-t))return null}else if(s>255)return null;for(o=bR(r),i=0;i<r.length;i++)o+=r[i]*kR(256,3-i);return o}(e),null===t)return MR;this.host=t}else{if(SR(jR,e))return MR;for(t="",r=iR(e),i=0;i<r.length;i++)t+=ZR(r[i],XR);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return tR(eI,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&tI(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,i=e.password,n=e.host,a=e.port,s=e.path,o=e.query,l=e.fragment,u=t+":";return null!==n?(u+="//",e.includesCredentials()&&(u+=r+(i?":"+i:"")+"@"),u+=zR(n),null!==a&&(u+=":"+a)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?s[0]:s.length?"/"+AR(s,"/"):"",null!==o&&(u+="?"+o),null!==l&&(u+="#"+l),u},setHref:function(e){var t=this.parse(e);if(t)throw mR(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new RI(e.path[0]).origin}catch(QV){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+zR(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(oR(e)+":",nI)},getUsername:function(){return this.username},setUsername:function(e){var t=iR(oR(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=ZR(t[r],JR)}},getPassword:function(){return this.password},setPassword:function(e){var t=iR(oR(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=ZR(t[r],JR)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?zR(e):zR(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,vI)},getHostname:function(){var e=this.host;return null===e?"":zR(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,gI)},getPort:function(){var e=this.port;return null===e?"":oR(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=oR(e))?this.port=null:this.parse(e,pI))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+AR(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,kI))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=oR(e))?this.query=null:("?"==TR(e,0)&&(e=wR(e,1)),this.query="",this.parse(e,AI)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=oR(e))?("#"==TR(e,0)&&(e=wR(e,1)),this.fragment="",this.parse(e,LI)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var RI=function(e){var t=eR(this,II),r=uR(arguments.length,1)>1?arguments[1]:void 0,i=dR(t,new bI(e,!1,r));Wb||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},II=RI.prototype,DI=function(e,t){return{get:function(){return fR(this)[e]()},set:t&&function(e){return fR(this)[t](e)},configurable:!0,enumerable:!0}};if(Wb&&(Zb(II,"href",DI("serialize","setHref")),Zb(II,"origin",DI("getOrigin")),Zb(II,"protocol",DI("getProtocol","setProtocol")),Zb(II,"username",DI("getUsername","setUsername")),Zb(II,"password",DI("getPassword","setPassword")),Zb(II,"host",DI("getHost","setHost")),Zb(II,"hostname",DI("getHostname","setHostname")),Zb(II,"port",DI("getPort","setPort")),Zb(II,"pathname",DI("getPathname","setPathname")),Zb(II,"search",DI("getSearch","setSearch")),Zb(II,"searchParams",DI("getSearchParams")),Zb(II,"hash",DI("getHash","setHash"))),Jb(II,"toJSON",(function(){return fR(this).serialize()}),{enumerable:!0}),Jb(II,"toString",(function(){return fR(this).serialize()}),{enumerable:!0}),pR){var _I=pR.createObjectURL,wI=pR.revokeObjectURL;_I&&Jb(RI,"createObjectURL",Qb(_I,pR)),wI&&Jb(RI,"revokeObjectURL",Qb(wI,pR))}lR(RI,"URL"),qb({global:!0,constructor:!0,forced:!zb,sham:!Wb},{URL:RI});var PI=wr,CI=o,xI=wf,MI=tn,OI=cL,FI=le("URL");PI({target:"URL",stat:!0,forced:!(OI&&CI((function(){FI.canParse()})))},{canParse:function(e){var t=xI(arguments.length,1),r=MI(e),i=t<2||void 0===arguments[1]?void 0:MI(arguments[1]);try{return!!new FI(r,i)}catch(QV){return!1}}});var NI=i(ie.URL),UI=ie,BI=f;UI.JSON||(UI.JSON={stringify:JSON.stringify});var GI=function(e,t,r){return BI(UI.JSON.stringify,null,arguments)},KI=i(GI),HI=wr,VI=b;w.f;var jI=qr,YI=tn,qI=rv,WI=Q,zI=nv,XI=VI("".startsWith),QI=VI("".slice),$I=Math.min;HI({target:"String",proto:!0,forced:!zI("startsWith")},{startsWith:function(e){var t=YI(WI(this));qI(e);var r=jI($I(arguments.length>1?arguments[1]:void 0,t.length)),i=YI(e);return XI?XI(t,i,r):QI(t,r,r+i.length)===i}});var JI=nh("String").startsWith,ZI=ue,eD=JI,tD=String.prototype,rD=i((function(e){var t=e.startsWith;return"string"==typeof e||e===tD||ZI(tD,e)&&t===tD.startsWith?eD:t})),iD=re,nD=Math.floor,aD=Number.isInteger||function(e){return!iD(e)&&isFinite(e)&&nD(e)===e};wr({target:"Number",stat:!0},{isInteger:aD});var sD=i(ie.Number.isInteger);function oD(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function lD(e,t){var r;if(e){if("string"==typeof e)return oD(e,t);var i=ng(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?qT(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?oD(e,t):void 0}}function uD(e){return function(e){if(eT(e))return oD(e)}(e)||function(e){if(void 0!==hc&&null!=DT(e)||null!=e["@@iterator"])return qT(e)}(e)||lD(e)||function(){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 cD(e,t){return function(e){if(eT(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==hc&&DT(e)||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(rf(o).call(o,i.value),o.length!==t);l=!0);}catch(c){u=!0,n=c}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return o}}(e,t)||lD(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var hD={exports:{}},dD=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fD=o,vD=re,gD=S,pD=dD,mD=Object.isExtensible,yD=fD((function(){mD(1)}))||pD?function(e){return!!vD(e)&&((!pD||"ArrayBuffer"!=gD(e))&&(!mD||mD(e)))}:mD,ED=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),kD=wr,TD=y,SD=fn,AD=re,LD=et,bD=Zt.f,RD=Xn,ID=Jn,DD=yD,_D=ED,wD=!1,PD=at("meta"),CD=0,xD=function(e){bD(e,PD,{value:{objectID:"O"+CD++,weakData:{}}})},MD=hD.exports={enable:function(){MD.enable=function(){},wD=!0;var e=RD.f,t=TD([].splice),r={};r[PD]=1,e(r).length&&(RD.f=function(r){for(var i=e(r),n=0,a=i.length;n<a;n++)if(i[n]===PD){t(i,n,1);break}return i},kD({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:ID.f}))},fastKey:function(e,t){if(!AD(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!LD(e,PD)){if(!DD(e))return"F";if(!t)return"E";xD(e)}return e[PD].objectID},getWeakData:function(e,t){if(!LD(e,PD)){if(!DD(e))return!0;if(!t)return!1;xD(e)}return e[PD].weakData},onFreeze:function(e){return _D&&wD&&DD(e)&&!LD(e,PD)&&xD(e),e}};SD[PD]=!0;var OD=hD.exports,FD=wr,ND=s,UD=OD,BD=o,GD=yr,KD=Lp,HD=tm,VD=_,jD=re,YD=Ua,qD=Zt.f,WD=ls.forEach,zD=P,XD=es.set,QD=es.getterFor,$D=function(e,t,r){var i,n=-1!==e.indexOf("Map"),a=-1!==e.indexOf("Weak"),s=n?"set":"add",o=ND[e],l=o&&o.prototype,u={};if(zD&&VD(o)&&(a||l.forEach&&!BD((function(){(new o).entries().next()})))){var c=(i=t((function(t,r){XD(HD(t,c),{type:e,collection:new o}),null!=r&&KD(r,t[s],{that:t,AS_ENTRIES:n})}))).prototype,h=QD(e);WD(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in l)||a&&"clear"==e||GD(c,e,(function(r,i){var n=h(this).collection;if(!t&&a&&!jD(r))return"get"==e&&void 0;var s=n[e](0===r?0:r,i);return t?this:s}))})),a||qD(c,"size",{configurable:!0,get:function(){return h(this).collection.size}})}else i=r.getConstructor(t,e,n,s),UD.enable();return YD(i,e,!1,!0),u[e]=i,FD({global:!0,forced:!0},u),a||r.setStrong(i,e,n),i},JD=zn,ZD=va,e_=wL,t_=Jt,r_=tm,i_=W,n_=Lp,a_=Au,s_=Lu,o_=Jp,l_=P,u_=OD.fastKey,c_=es.set,h_=es.getterFor,d_={getConstructor:function(e,t,r,i){var n=e((function(e,n){r_(e,a),c_(e,{type:t,index:JD(null),first:void 0,last:void 0,size:0}),l_||(e.size=0),i_(n)||n_(n,e[i],{that:e,AS_ENTRIES:r})})),a=n.prototype,s=h_(t),o=function(e,t,r){var i,n,a=s(e),o=l(e,t);return o?o.value=r:(a.last=o={index:n=u_(t,!0),key:t,value:r,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=o),i&&(i.next=o),l_?a.size++:e.size++,"F"!==n&&(a.index[n]=o)),e},l=function(e,t){var r,i=s(e),n=u_(t);if("F"!==n)return i.index[n];for(r=i.first;r;r=r.next)if(r.key==t)return r};return e_(a,{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,l_?e.size=0:this.size=0},delete:function(e){var t=this,r=s(t),i=l(t,e);if(i){var n=i.next,a=i.previous;delete r.index[i.index],i.removed=!0,a&&(a.next=n),n&&(n.previous=a),r.first==i&&(r.first=n),r.last==i&&(r.last=a),l_?r.size--:t.size--}return!!i},forEach:function(e){for(var t,r=s(this),i=t_(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(i(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!l(this,e)}}),e_(a,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)}}),l_&&ZD(a,"size",{configurable:!0,get:function(){return s(this).size}}),n},setStrong:function(e,t,r){var i=t+" Iterator",n=h_(t),a=h_(i);a_(e,t,(function(e,t){c_(this,{type:i,target:e,state:n(e),kind:t,last:void 0})}),(function(){for(var e=a(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)?s_("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,s_(void 0,!0))}),r?"entries":"values",!r,!0),o_(t)}};$D("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),d_);var f_=ie.Map,v_=Jt,g_=M,p_=xe,m_=Fh,y_=W,E_=Lp,k_=[].push,T_=function(e){var t,r,i,n,a=arguments.length,s=a>1?arguments[1]:void 0;return m_(this),(t=void 0!==s)&&p_(s),y_(e)?new this:(r=[],t?(i=0,n=v_(s,a>2?arguments[2]:void 0),E_(e,(function(e){g_(k_,r,n(e,i++))}))):E_(e,k_,{that:r}),new this(r))};wr({target:"Map",stat:!0,forced:!0},{from:T_});var S_=xo,A_=function(){return new this(S_(arguments))};wr({target:"Map",stat:!0,forced:!0},{of:A_});var L_=_e,b_=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(L_(e)+" is not a map")},R_=function(e,t){return 1==t?function(t,r){return t[e](r)}:function(t,r,i){return t[e](r,i)}},I_=R_,D_=le("Map"),__={Map:D_,set:I_("set",2),get:I_("get",1),has:I_("has",1),remove:I_("delete",1),proto:D_.prototype},w_=b_,P_=__.remove;wr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=w_(this),r=!0,i=0,n=arguments.length;i<n;i++)e=P_(t,arguments[i]),r=r&&e;return!!r}});var C_=b_,x_=__.get,M_=__.has,O_=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,i,n=C_(this);return M_(n,e)?(r=x_(n,e),"update"in t&&(r=t.update(r,e,n),O_(n,e,r)),r):(i=t.insert(e,n),O_(n,e,i),i)}});var F_=M,N_=function(e,t,r){for(var i,n,a=r||e.next;!(i=F_(a,e)).done;)if(void 0!==(n=t(i.value)))return n},U_=N_,B_=function(e,t,r){return r?U_(e.entries(),(function(e){return t(e[1],e[0])})):e.forEach(t)},G_=Jt,K_=b_,H_=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=K_(this),r=G_(e,arguments.length>1?arguments[1]:void 0);return!1!==H_(t,(function(e,i){if(!r(e,i,t))return!1}),!0)}});var V_=Jt,j_=b_,Y_=B_,q_=__.Map,W_=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=j_(this),r=V_(e,arguments.length>1?arguments[1]:void 0),i=new q_;return Y_(t,(function(e,n){r(e,n,t)&&W_(i,n,e)})),i}});var z_=Jt,X_=b_,Q_=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=X_(this),r=z_(e,arguments.length>1?arguments[1]:void 0),i=Q_(t,(function(e,i){if(r(e,i,t))return{value:e}}),!0);return i&&i.value}});var $_=Jt,J_=b_,Z_=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=J_(this),r=$_(e,arguments.length>1?arguments[1]:void 0),i=Z_(t,(function(e,i){if(r(e,i,t))return{key:i}}),!0);return i&&i.key}});var ew=wr,tw=M,rw=_,iw=xe,nw=Lp,aw=__.Map,sw=y([].push);ew({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){var r=new(rw(this)?this:aw);iw(t);var i=iw(r.has),n=iw(r.get),a=iw(r.set);return nw(e,(function(e){var s=t(e);tw(i,r,s)?sw(tw(n,r,s),e):tw(a,r,s,[e])})),r}});var ow=function(e,t){return e===t||e!=e&&t!=t},lw=b_,uw=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===uw(lw(this),(function(t){if(ow(t,e))return!0}),!0)}});var cw=M,hw=Lp,dw=_,fw=xe,vw=__.Map;wr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(dw(this)?this:vw);fw(t);var i=fw(r.set);return hw(e,(function(e){cw(i,r,t(e),e)})),r}});var gw=b_,pw=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=pw(gw(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var mw=Jt,yw=b_,Ew=B_,kw=__.Map,Tw=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=yw(this),r=mw(e,arguments.length>1?arguments[1]:void 0),i=new kw;return Ew(t,(function(e,n){Tw(i,r(e,n,t),e)})),i}});var Sw=Jt,Aw=b_,Lw=B_,bw=__.Map,Rw=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=Aw(this),r=Sw(e,arguments.length>1?arguments[1]:void 0),i=new bw;return Lw(t,(function(e,n){Rw(i,n,r(e,n,t))})),i}});var Iw=b_,Dw=Lp,_w=__.set;wr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=Iw(this),r=arguments.length,i=0;i<r;)Dw(arguments[i++],(function(e,r){_w(t,e,r)}),{AS_ENTRIES:!0});return t}});var ww=xe,Pw=b_,Cw=B_,xw=TypeError;wr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Pw(this),r=arguments.length<2,i=r?void 0:arguments[1];if(ww(e),Cw(t,(function(n,a){r?(r=!1,i=n):i=e(i,n,a,t)})),r)throw xw("Reduce of empty map with no initial value");return i}});var Mw=Jt,Ow=b_,Fw=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=Ow(this),r=Mw(e,arguments.length>1?arguments[1]:void 0);return!0===Fw(t,(function(e,i){if(r(e,i,t))return!0}),!0)}});var Nw=xe,Uw=b_,Bw=TypeError,Gw=__.get,Kw=__.has,Hw=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=Uw(this),i=arguments.length;Nw(t);var n=Kw(r,e);if(!n&&i<3)throw Bw("Updating absent value");var a=n?Gw(r,e):Nw(i>2?arguments[2]:void 0)(e,r);return Hw(r,e,t(a,e,r)),r}});var Vw=M,jw=xe,Yw=_,qw=nr,Ww=TypeError,zw=function(e,t){var r,i=qw(this),n=jw(i.get),a=jw(i.has),s=jw(i.set),o=arguments.length>2?arguments[2]:void 0;if(!Yw(t)&&!Yw(o))throw Ww("At least one callback required");return Vw(a,i,e)?(r=Vw(n,i,e),Yw(t)&&(r=t(r),Vw(s,i,e,r))):Yw(o)&&(r=o(),Vw(s,i,e,r)),r};wr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:zw}),wr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:zw});var Xw=f_,Qw=i(Xw);function $w(e,t,r){var i;Jh()?$w=ch(i=$h).call(i):$w=function(e,t,r){var i=[null];rf(i).apply(i,t);var n=new(ch(Function).apply(e,i));return r&&Ph(n,r.prototype),n};return $w.apply(null,arguments)}function Jw(e){var t="function"==typeof Qw?new Qw:void 0;return Jw=function(e){if(null===e||(r=e,-1===Dv(i=Function.toString.call(r)).call(i,"[native code]")))return e;var r,i;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,n)}function n(){return $w(e,arguments,Rh(this).constructor)}return n.prototype=wh(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ph(n,e)},Jw(e)}var Zw=s.isFinite;wr({target:"Number",stat:!0},{isFinite:Number.isFinite||function(e){return"number"==typeof e&&Zw(e)}});var eP=i(ie.Number.isFinite),tP=wr,rP=aD,iP=Math.abs;tP({target:"Number",stat:!0},{isSafeInteger:function(e){return rP(e)&&iP(e)<=9007199254740991}});var nP=i(ie.Number.isSafeInteger);wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var aP=i(9007199254740991),sP=xe,oP=$e,lP=q,uP=zr,cP=TypeError,hP=function(e){return function(t,r,i,n){sP(r);var a=oP(t),s=lP(a),o=uP(a),l=e?o-1:0,u=e?-1:1;if(i<2)for(;;){if(l in s){n=s[l],l+=u;break}if(l+=u,e?l<0:o<=l)throw cP("Reduce of empty array with no initial value")}for(;e?l>=0:o>l;l+=u)l in s&&(n=r(n,s[l],l,a));return n}},dP={left:hP(!1),right:hP(!0)}.left;wr({target:"Array",proto:!0,forced:!Wp&&me>79&&me<83||!rd("reduce")},{reduce:function(e){var t=arguments.length;return dP(this,e,t,t>1?arguments[1]:void 0)}});var fP=nh("Array").reduce,vP=ue,gP=fP,pP=Array.prototype,mP=i((function(e){var t=e.reduce;return e===pP||vP(pP,e)&&t===pP.reduce?gP:t})),yP=nr,EP=M,kP=et,TP=ue,SP=function(){var e=yP(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},AP=RegExp.prototype,LP=ue,bP=function(e){var t=e.flags;return void 0!==t||"flags"in AP||kP(e,"flags")||!TP(AP,e)?t:EP(SP,e)},RP=RegExp.prototype,IP=i((function(e){return e===RP||LP(RP,e)?bP(e):e.flags})),DP=f,_P=Z,wP=Vr,PP=zr,CP=rd,xP=Math.min,MP=[].lastIndexOf,OP=!!MP&&1/[1].lastIndexOf(1,-0)<0,FP=CP("lastIndexOf"),NP=OP||!FP?function(e){if(OP)return DP(MP,this,arguments)||0;var t=_P(this),r=PP(t),i=r-1;for(arguments.length>1&&(i=xP(i,wP(arguments[1]))),i<0&&(i=r+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:MP;wr({target:"Array",proto:!0,forced:NP!==[].lastIndexOf},{lastIndexOf:NP});var UP=nh("Array").lastIndexOf,BP=ue,GP=UP,KP=Array.prototype,HP=i((function(e){var t=e.lastIndexOf;return e===KP||BP(KP,e)&&t===KP.lastIndexOf?GP:t})),VP=wr,jP=Br,YP=y([].reverse),qP=[1,2];VP({target:"Array",proto:!0,forced:String(qP)===String(qP.reverse())},{reverse:function(){return jP(this)&&(this.length=this.length),YP(this)}});var WP=nh("Array").reverse,zP=ue,XP=WP,QP=Array.prototype,$P=i((function(e){var t=e.reverse;return e===QP||zP(QP,e)&&t===QP.reverse?XP:t}));wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var JP=i(Math.pow(2,-52)),ZP=i(Xw);$D("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),d_);var eC=ie.Set,tC=_e,rC=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(tC(e)+" is not a set")},iC=R_,nC=le("Set"),aC=nC.prototype,sC={Set:nC,add:iC("add",1),has:iC("has",1),remove:iC("delete",1),proto:aC},oC=N_,lC=function(e,t,r){return r?oC(e.keys(),t):e.forEach(t)},uC=lC,cC=sC.Set,hC=sC.add,dC=function(e){var t=new cC;return uC(e,(function(e){hC(t,e)})),t},fC=function(e){return e.size},vC=xe,gC=nr,pC=M,mC=Vr,yC=TypeError,EC=Math.max,kC=function(e,t,r,i){this.set=e,this.size=t,this.has=r,this.keys=i};kC.prototype={getIterator:function(){return gC(pC(this.keys,this.set))},includes:function(e){return pC(this.has,this.set,e)}};var TC=function(e){gC(e);var t=+e.size;if(t!=t)throw yC("Invalid size");return new kC(e,EC(mC(t),0),vC(e.has),vC(e.keys))},SC=rC,AC=dC,LC=fC,bC=TC,RC=lC,IC=N_,DC=sC.has,_C=sC.remove,wC=function(e){var t=SC(this),r=bC(e),i=AC(t);return LC(t)<=r.size?RC(t,(function(e){r.includes(e)&&_C(i,e)})):IC(r.getIterator(),(function(e){DC(t,e)&&_C(i,e)})),i},PC=function(){return!1},CC=wC;wr({target:"Set",proto:!0,real:!0,forced:!PC()},{difference:CC});var xC=rC,MC=fC,OC=TC,FC=lC,NC=N_,UC=sC.Set,BC=sC.add,GC=sC.has,KC=function(e){var t=xC(this),r=OC(e),i=new UC;return MC(t)>r.size?NC(r.getIterator(),(function(e){GC(t,e)&&BC(i,e)})):FC(t,(function(e){r.includes(e)&&BC(i,e)})),i},HC=KC;wr({target:"Set",proto:!0,real:!0,forced:!PC()},{intersection:HC});var VC=rC,jC=sC.has,YC=fC,qC=TC,WC=lC,zC=N_,XC=cp,QC=function(e){var t=VC(this),r=qC(e);if(YC(t)<=r.size)return!1!==WC(t,(function(e){if(r.includes(e))return!1}),!0);var i=r.getIterator();return!1!==zC(i,(function(e){if(jC(t,e))return XC(i,"normal",!1)}))},$C=QC;wr({target:"Set",proto:!0,real:!0,forced:!PC()},{isDisjointFrom:$C});var JC=rC,ZC=fC,ex=lC,tx=TC,rx=function(e){var t=JC(this),r=tx(e);return!(ZC(t)>r.size)&&!1!==ex(t,(function(e){if(!r.includes(e))return!1}),!0)},ix=rx;wr({target:"Set",proto:!0,real:!0,forced:!PC()},{isSubsetOf:ix});var nx=rC,ax=sC.has,sx=fC,ox=TC,lx=N_,ux=cp,cx=function(e){var t=nx(this),r=ox(e);if(sx(t)<r.size)return!1;var i=r.getIterator();return!1!==lx(i,(function(e){if(!ax(t,e))return ux(i,"normal",!1)}))},hx=cx;wr({target:"Set",proto:!0,real:!0,forced:!PC()},{isSupersetOf:hx});var dx=rC,fx=dC,vx=TC,gx=N_,px=sC.add,mx=sC.has,yx=sC.remove,Ex=function(e){var t=dx(this),r=vx(e).getIterator(),i=fx(t);return gx(r,(function(e){mx(t,e)?yx(i,e):px(i,e)})),i},kx=Ex;wr({target:"Set",proto:!0,real:!0,forced:!PC()},{symmetricDifference:kx});var Tx=rC,Sx=sC.add,Ax=dC,Lx=TC,bx=N_,Rx=function(e){var t=Tx(this),r=Lx(e).getIterator(),i=Ax(t);return bx(r,(function(e){Sx(i,e)})),i},Ix=Rx;wr({target:"Set",proto:!0,real:!0,forced:!PC()},{union:Ix});var Dx=eC;wr({target:"Set",stat:!0,forced:!0},{from:T_}),wr({target:"Set",stat:!0,forced:!0},{of:A_});var _x=rC,wx=sC.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=_x(this),t=0,r=arguments.length;t<r;t++)wx(e,arguments[t]);return e}});var Px=rC,Cx=sC.remove;wr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=Px(this),r=!0,i=0,n=arguments.length;i<n;i++)e=Cx(t,arguments[i]),r=r&&e;return!!r}});var xx=Jt,Mx=rC,Ox=lC;wr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=Mx(this),r=xx(e,arguments.length>1?arguments[1]:void 0);return!1!==Ox(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var Fx=ui,Nx=et,Ux=W,Bx=El,Gx=vt("iterator"),Kx=Object,Hx=_,Vx=function(e){if(Ux(e))return!1;var t=Kx(e);return void 0!==t[Gx]||"@@iterator"in t||Nx(Bx,Fx(t))},jx=re,Yx=le("Set"),qx=function(e){return function(e){return jx(e)&&"number"==typeof e.size&&Hx(e.has)&&Hx(e.keys)}(e)?e:Vx(e)?new Yx(e):e},Wx=M,zx=qx,Xx=wC;wr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return Wx(Xx,this,zx(e))}});var Qx=Jt,$x=rC,Jx=lC,Zx=sC.Set,eM=sC.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=$x(this),r=Qx(e,arguments.length>1?arguments[1]:void 0),i=new Zx;return Jx(t,(function(e){r(e,e,t)&&eM(i,e)})),i}});var tM=Jt,rM=rC,iM=lC;wr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=rM(this),r=tM(e,arguments.length>1?arguments[1]:void 0),i=iM(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return i&&i.value}});var nM=M,aM=qx,sM=KC;wr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return nM(sM,this,aM(e))}});var oM=M,lM=qx,uM=QC;wr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return oM(uM,this,lM(e))}});var cM=M,hM=qx,dM=rx;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return cM(dM,this,hM(e))}});var fM=M,vM=qx,gM=cx;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return fM(gM,this,vM(e))}});var pM=wr,mM=y,yM=rC,EM=lC,kM=tn,TM=mM([].join),SM=mM([].push);pM({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=yM(this),r=void 0===e?",":kM(e),i=[];return EM(t,(function(e){SM(i,e)})),TM(i,r)}});var AM=Jt,LM=rC,bM=lC,RM=sC.Set,IM=sC.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=LM(this),r=AM(e,arguments.length>1?arguments[1]:void 0),i=new RM;return bM(t,(function(e){IM(i,r(e,e,t))})),i}});var DM=xe,_M=rC,wM=lC,PM=TypeError;wr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=_M(this),r=arguments.length<2,i=r?void 0:arguments[1];if(DM(e),wM(t,(function(n){r?(r=!1,i=n):i=e(i,n,n,t)})),r)throw PM("Reduce of empty set with no initial value");return i}});var CM=Jt,xM=rC,MM=lC;wr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=xM(this),r=CM(e,arguments.length>1?arguments[1]:void 0);return!0===MM(t,(function(e){if(r(e,e,t))return!0}),!0)}});var OM=M,FM=qx,NM=Ex;wr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return OM(NM,this,FM(e))}});var UM=M,BM=qx,GM=Rx;wr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return UM(GM,this,BM(e))}});var KM=i(Dx),HM=Sd.entries;wr({target:"Object",stat:!0},{entries:function(e){return HM(e)}});var VM,jM=i(ie.Object.entries),YM=nh("Array").entries,qM=ui,WM=et,zM=ue,XM=YM,QM=Array.prototype,$M={DOMTokenList:!0,NodeList:!0},JM=i((function(e){var t=e.entries;return e===QM||zM(QM,e)&&t===QM.entries||WM($M,qM(e))?XM:t})),ZM=nh("Array").values,eO=ui,tO=et,rO=ue,iO=ZM,nO=Array.prototype,aO={DOMTokenList:!0,NodeList:!0},sO=i((function(e){var t=e.values;return e===nO||rO(nO,e)&&t===nO.values||tO(aO,eO(e))?iO:t})),oO=eP||function(e){return"number"==typeof e&&isFinite(e)},lO=nP||function(e){return"number"==typeof e&&Math.abs(e)<=uO},uO=aP||9007199254740991,cO=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}({}),hO=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}({}),dO=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}({}),fO="manifest",vO="level",gO="audioTrack",pO="subtitleTrack",mO="main",yO="audio",EO="subtitle",kO=function(){function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=r,this.alpha_=r?Math.exp(Math.log(.5)/r):0,this.estimate_=i,this.totalWeight_=n}return Fc(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}(),TO=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;t(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 kO(r),this.fast_=new kO(i),this.defaultTTFB_=a,this.ttfb_=new kO(r)}return Fc(e,[{key:"update",value:function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new kO(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new kO(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new kO(e,n.getEstimate(),n.getTotalWeight()))}},{key:"sample",value:function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}},{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 SO(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Pc(e)||!e)return e;var r=e[zT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=Pc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Pc(t)?t:t+""}(t))in e?ST(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function AO(){var e;return AO=mT?RT(e=mT).call(e):function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},AO.apply(null,arguments)}function LO(e,t){var r=zf(e);if(yT){var i=yT(e);t&&(i=rT(i).call(i,(function(t){return ET(e,t).enumerable}))),r.push.apply(r,i)}return r}function bO(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=LO(Object(n),!0)).call(r,(function(t){SO(e,t,n[t])})):kT?TT(e,kT(n)):vd(i=LO(Object(n))).call(i,(function(t){ST(e,t,ET(n,t))}))}return e}var RO=Fc((function e(r,i){var n,a,s,o,l;t(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 u="[".concat(r,"]:");this.trace=IO,this.debug=RT(n=i.debug).call(n,null,u),this.log=RT(a=i.log).call(a,null,u),this.warn=RT(s=i.warn).call(s,null,u),this.info=RT(o=i.info).call(o,null,u),this.error=RT(l=i.error).call(l,null,u)})),IO=function(){},DO={trace:IO,debug:IO,log:IO,warn:IO,info:IO,error:IO};function _O(){return AO({},DO)}function wO(e,t,r){var i;return t[e]?RT(i=t[e]).call(i,t):function(e,t){var r,i=self.console[e];return i?RT(i).call(i,self.console,_d(r="".concat(t?"["+t+"] ":"","[")).call(r,e,"] >")):IO}(e,r)}var PO=_O();var CO=PO;function xO(){if("undefined"!=typeof self)return(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function MO(e,t){var r=zf(e),i=zf(t),n=r.length,a=i.length;return!n||!a||n===a&&!cS(r).call(r,(function(e){return-1===_v(i).call(i,e)}))}var OO={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 FO(e,t){var r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!cS(r=e.split(",")).call(r,(function(e){return!NO(e,t,i)}))}function NO(e,t){var r,i=xO(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);return null!=(r=null==i?void 0:i.isTypeSupported(UO(e,t)))&&r}function UO(e,t){var r;return _d(r="".concat(t,"/mp4;codecs=")).call(r,e)}function BO(e){if(e){var t=e.substring(0,4);return OO.video[t]}return 2}function GO(e){var t;return mP(t=e.split(",")).call(t,(function(e,t){var r=OO.video[t];return r?(2*r+e)/(e?3:2):(OO.audio[t]+e)/(e?2:1)}),0)}var KO={};var HO=/flac|opus|mp4a\.40\.34/i;function VO(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(HO,(function(e){return function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(KO[e])return KO[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],i=0;i<r.length;i++){var n;if(NO(r[i],"audio",t))return KO[e]=r[i],r[i];if("mp3"===r[i]&&null!=(n=xO(t))&&n.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)}))}function jO(e,t){var r;if(e&&(e.length>4||-1!==_v(r=["ac-3","ec-3","alac","fLaC","Opus"]).call(r,e)))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function YO(e){if(rD(e).call(e,"av01.")){for(var t=e.split("."),r=["0","111","01","01","01","0"],i=t.length;i>4&&i<10;i++)t[i]=r[i-4];return t.join(".")}return e}function qO(e){var t=xO(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 WO={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},zO={};function XO(e,t,r){var i=e.videoCodec,n=e.audioCodec;if(!i&&!n||!r)return Lk.resolve(WO);var a,s=[];if(i){var o,l={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},u=e.videoRange;"SDR"!==u&&(l.transferFunction=u.toLowerCase()),s.push.apply(s,Jk(o=i.split(",")).call(o,(function(e){return{type:"media-source",video:bO(bO({},l),{},{contentType:UO(YO(e),"video")})}})))}n&&e.audioGroups&&vd(a=e.audioGroups).call(a,(function(e){var r,i;e&&(null==(i=t.groups[e])||vd(r=i.tracks).call(r,(function(t){if(t.groupId===e){var r,i=t.channels||"",a=zS(i);if(oO(a)&&a>2)s.push.apply(s,Jk(r=n.split(",")).call(r,(function(e){return{type:"media-source",audio:{contentType:UO(e,"audio"),channels:""+a}}})))}})))}));return Lk.all(Jk(s).call(s,(function(e){var t=function(e){var t=e.audio,r=e.video,i=r||t;if(i){var n,a,s,o,l,u,c,h=i.contentType.split('"')[1];if(r)return _d(n=_d(a=_d(s=_d(o=_d(l="r".concat(r.height,"x")).call(l,r.width,"f")).call(o,Math.ceil(r.framerate))).call(s,r.transferFunction||"sd","_")).call(a,h,"_")).call(n,Math.ceil(r.bitrate/1e5));if(t)return _d(u=_d(c="c".concat(t.channels)).call(c,t.spatialRendering?"s":"n","_")).call(u,h)}return""}(e);return zO[t]||(zO[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!cS(e).call(e,(function(e){return!e.supported})),configurations:s,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}}))}var QO=["NONE","TYPE-0","TYPE-1",null];var $O=["SDR","PQ","HLG"];var JO="",ZO="YES",eF="v2";function tF(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?eF:ZO:JO}var rF=function(){function e(r,i,n){t(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=r,this.part=i,this.skip=n}return Fc(e,[{key:"addDirectives",value:function(e){var t=new NI(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}(),iF=function(){function e(r){var i,n;t(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=[r.url],this._attrs=[r.attrs],this.bitrate=r.bitrate,r.details&&(this.details=r.details),this.id=r.id||0,this.name=r.name,this.width=r.width||0,this.height=r.height||0,this.frameRate=r.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=r.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=r.audioCodec,this.videoCodec=r.videoCodec,this.codecSet=Jk(i=rT(n=[r.videoCodec,r.audioCodec]).call(n,(function(e){return!!e}))).call(i,(function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",r.attrs.AUDIO),this.addGroupId("text",r.attrs.SUBTITLES)}return Fc(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 nF(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return nF(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===_v(r).call(r,t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===_v(i).call(i,t)&&i.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 nF(e,t){return!(!t||!e)&&-1!==_v(e).call(e,t)}function aF(e,t){var r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){var n="SDR"!==(i=t.allowedVideoRanges||ag($O).call($O,0)).join("")&&!t.videoCodec;(r=void 0!==t.preferHDR?t.preferHDR:n&&function(){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}())||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}function sF(e,t){var r;CO.log(_d(r='[abr] start candidates with "'.concat(e,'" ignored because ')).call(r,t))}function oF(e){return mP(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 i=t.channels||"2";return r.channels[i]=(r.channels[i]||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 lF(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function uF(e,t,r){if("attrs"in e){var i=_v(t).call(t,e);if(-1!==i)return i}for(var n=0;n<t.length;n++){if(cF(e,t[n],r))return n}return-1}function cF(e,t,r){var i=e.groupId,n=e.name,a=e.lang,s=e.assocLang,o=e.characteristics,l=e.default,u=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===a||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--";if(e.length===t.length)return e===t;return rD(e).call(e,t)||rD(t).call(t,e)}(a,t.lang))&&(void 0===a||t.assocLang===s)&&(void 0===l||t.default===l)&&(void 0===u||t.forced===u)&&(void 0===o||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),i=t.split(",");return r.length===i.length&&!cS(r).call(r,(function(e){return-1===_v(i).call(i,e)}))}(o,t.characteristics))&&(void 0===r||r(e,t))}function hF(e,t){var r=e.audioCodec,i=e.channels;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function dF(e,t,r){for(var i=t;i>-1;i--)if(r(e[i]))return i;for(var n=t+1;n<e.length;n++)if(r(e[n]))return n;return-1}function fF(e,t){var r;return!!e&&e!==(null==(r=t.levels[t.loadLevel])?void 0:r.uri)}var vF=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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,i,a,s,o,l,u,c,h,d,f=Zh(n),v=f.fragCurrent,g=f.partCurrent,p=f.hls,m=p.autoLevelEnabled,y=p.media;if(v&&y){var E=performance.now(),k=g?g.stats:v.stats,T=g?g.duration:v.duration,S=E-k.loading.start,A=p.minAutoLevel;if(k.aborted||k.loaded&&k.loaded===k.total||v.level<=A)return n.clearTimer(),void(n._nextAutoLevel=-1);if(m&&!y.paused&&y.playbackRate&&y.readyState){var L=p.mainForwardBufferInfo;if(null!==L){var b=n.bwEstimator.getEstimateTTFB(),R=Math.abs(y.playbackRate);if(!(S<=Math.max(b,T/(2*R)*1e3))){var I=L.len/R,D=k.loading.first?k.loading.first-k.loading.start:-1,_=k.loaded&&D>-1,w=n.getBwEstimate(),P=p.levels,C=P[v.level],x=Math.max(k.loaded,Math.round(T*(v.bitrate||C.averageBitrate)/8)),M=_?S-D:S;M<1&&_&&(M=Math.min(S,8*k.loaded/w));var O=_?1e3*k.loaded/M:0,F=b/1e3,N=O?(x-k.loaded)/O:8*x/w+F;if(!(N<=I)){var U,B=O?8*O:w,G=!0===(null==(d=n.hls.latestLevelDetails)?void 0:d.live),K=n.hls.config.abrBandWidthUpFactor,H=Number.POSITIVE_INFINITY;for(U=v.level-1;U>A;U--){var V=P[U].maxBitrate,j=!P[U].details||G;if((H=n.getTimeToLoadFrag(F,B,T*V,j))<Math.min(I,T+F))break}if(!(H>=N||H>10*T)){_?n.bwEstimator.sample(S-Math.min(b,D),k.loaded):n.bwEstimator.sampleTTFB(S);var Y=P[U].maxBitrate;n.getBwEstimate()*K>Y&&n.resetEstimator(Y);var q=n.findBestLevel(Y,A,U,0,I,1,1);q>-1&&(U=q),n.warn(_d(e=_d(t=_d(r=_d(i=_d(a=_d(s=_d(o=_d(l=_d(u=_d(c=_d(h="Fragment ".concat(v.sn)).call(h,g?" part "+g.index:""," of level ")).call(c,v.level," is loading too slowly;\n Fragment duration: ")).call(u,v.duration.toFixed(3),"\n Time to underbuffer: ")).call(l,I.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,H.toFixed(3)," s\n TTFB estimate: ")).call(a,0|D," ms\n Current BW estimate: ")).call(i,oO(w)?0|w:"Unknown"," bps\n New BW estimate: ")).call(r,0|n.getBwEstimate()," bps\n Switching to level ")).call(t,U," @ ")).call(e,0|Y," bps")),p.nextLoadLevel=p.nextAutoLevel=U,n.clearTimer(),n.timer=PS((function(){if(n.clearTimer(),n.fragCurrent===v&&n.hls.loadLevel===U&&U>0){var e,t,r=n.getStarvationDelay();if(n.warn(_d(e=_d(t="Aborting inflight request ".concat(U>0?"and switching down":"","\n Fragment duration: ")).call(t,v.duration.toFixed(3)," s\n Time to underbuffer: ")).call(e,r.toFixed(3)," s")),v.abortRequests(),n.fragCurrent=n.partCurrent=null,U>A){var i=n.findBestLevel(n.hls.levels[A].bitrate,A,U,0,r,1,1);-1===i&&(i=A),n.hls.nextLoadLevel=n.hls.nextAutoLevel=i,n.resetEstimator(n.hls.levels[i].bitrate)}}}),1e3*H),p.trigger(dO.FRAG_LOAD_EMERGENCY_ABORTED,{frag:v,part:g,stats:k})}}}}}}},n.hls=e,n.bwEstimator=n.initEstimator(),n.registerListeners(),n}return Fc(i,[{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 TO(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.FRAG_LOADING,this.onFragLoading,this),e.on(dO.FRAG_LOADED,this.onFragLoaded,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.FRAG_LOADING,this.onFragLoading,this),e.off(dO.FRAG_LOADED,this.onFragLoaded,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(dO.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 i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=PS(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case hO.BUFFER_ADD_CODEC_ERROR:case hO.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case hO.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,n=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var a=performance.now(),s=n?n.stats:r.stats,o=a-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}}},{key:"getTimeToLoadFrag",value:function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var r=this.hls.config,i=t.stats.loading,n=i.end-i.start;oO(n)&&(this.lastLevelLoadSec=n/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,i=t.part,n=i?i.stats:r.stats;if(r.type===mO&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,l=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(dO.FRAG_BUFFERED,u),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==mO||"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,i=t.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,s=this.findBestLevel(n,i,r,0,a,1,1);if(s>-1)return s;var o=this.hls.firstLevel,l=Math.min(Math.max(o,i),r);return this.warn(_d(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 i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=Math.min(Math.max(e,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}},{key:"getAutoLevelKey",value:function(){var e;return _d(e="".concat(this.getBwEstimate(),"_")).call(e,this.getStarvationDelay().toFixed(2))}},{key:"getNextABRAutoLevel",value:function(){var e,t=this.fragCurrent,r=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,s=i.minAutoLevel,o=r?r.duration:t?t.duration:0,l=this.getBwEstimate(),u=this.getStarvationDelay(),c=a.abrBandWidthFactor,h=a.abrBandWidthUpFactor;if(u){var d=this.findBestLevel(l,s,n,u,0,c,h);if(d>=0)return d}var f=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var v,g=this.bitrateTestDelay;if(g)f=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-g,this.info(_d(v="bitrate test took ".concat(Math.round(1e3*g),"ms, set first fragment max fetchDuration to ")).call(v,Math.round(1e3*f)," ms")),c=h=1}var p=this.findBestLevel(l,s,n,u,f,c,h);if(this.info(_d(e="".concat(u?"rebuffering expected":"buffer is empty",", optimal quality level ")).call(e,p)),p>-1)return p;var m=i.levels[s],y=i.levels[i.loadLevel];return(null==m?void 0:m.bitrate)<(null==y?void 0:y.bitrate)?s:i.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,i=e.mainForwardBufferInfo;return(i?i.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,i,n,a,s){var o,l=this,u=i+n,c=this.lastLoadedFragLevel,h=-1===c?this.hls.firstLevel:c,d=this.fragCurrent,f=this.partCurrent,v=this.hls,g=v.levels,p=v.allAudioTracks,m=v.loadLevel,y=v.config;if(1===g.length)return 0;var E,k=g[h],T=!(null==(o=this.hls.latestLevelDetails)||!o.live),S=-1===m||-1===c,A="SDR",L=(null==k?void 0:k.frameRate)||0,b=y.audioPreference,R=y.videoPreference,I=this.audioTracksByGroup||(this.audioTracksByGroup=oF(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var _=this.codecTiers||(this.codecTiers=function(e,t,r,i){var n;return mP(n=ag(e).call(e,r,i+1)).call(n,(function(e,r,i){if(!r.codecSet)return e;var n=r.audioGroups,a=e[r.codecSet];a||(e[r.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,r.bitrate);var s=Math.min(r.height,r.width);return a.minHeight=Math.min(a.minHeight,s),a.minFramerate=Math.min(a.minFramerate,r.frameRate),a.minIndex=Math.min(a.minIndex,i),a.maxScore=Math.max(a.maxScore,r.score),a.fragmentError+=r.fragmentError,a.videoRanges[r.videoRange]=(a.videoRanges[r.videoRange]||0)+1,n&&vd(n).call(n,(function(e){var r;if(e){var i=t.groups[e];i&&(a.hasDefaultAudio=a.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,vd(r=zf(i.channels)).call(r,(function(e){a.channels[e]=(a.channels[e]||0)+i.channels[e]})))}})),e}),{})}(g,I,t,r)),w=function(e,t,r,i,n){for(var a=zf(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==n?void 0:n.videoCodec,u=s&&2===qk(s),c=!1,h=!1,d=1/0,f=1/0,v=1/0,g=1/0,p=0,m=[],y=aF(t,n),E=y.preferHDR,k=y.allowedVideoRanges,T=function(){var t=e[a[S]];c||(c=t.channels[2]>0),d=Math.min(d,t.minHeight),f=Math.min(f,t.minFramerate),v=Math.min(v,t.minBitrate),rT(k).call(k,(function(e){return t.videoRanges[e]>0})).length>0&&(h=!0)},S=a.length;S--;)T();d=oO(d)?d:0,f=oO(f)?f:0;var A=Math.max(1080,d),L=Math.max(30,f);v=oO(v)?v:r,r=Math.max(v,r),h||(t=void 0);var b=a.length>1;return{codecSet:mP(a).call(a,(function(t,i){var n=e[i];if(i===t)return t;if(m=h?rT(k).call(k,(function(e){return n.videoRanges[e]>0})):[],b){var a,d,f,v,y;if(n.minBitrate>r)return sF(i,_d(a="min bitrate of ".concat(n.minBitrate," > current estimate of ")).call(a,r)),t;if(!n.hasDefaultAudio)return sF(i,"no renditions with default or auto-select sound found"),t;if(o&&_v(i).call(i,o.substring(0,4))%5!=0)return sF(i,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!u){if(!n.channels[s])return sF(i,_d(d="no renditions with ".concat(s," channel sound found (channels options: ")).call(d,zf(n.channels),")")),t}else if((!o||u)&&c&&0===n.channels[2])return sF(i,"no renditions with stereo sound found"),t;if(n.minHeight>A)return sF(i,_d(f="min resolution of ".concat(n.minHeight," > maximum of ")).call(f,A)),t;if(n.minFramerate>L)return sF(i,_d(v="min framerate of ".concat(n.minFramerate," > maximum of ")).call(v,L)),t;if(!cS(m).call(m,(function(e){return n.videoRanges[e]>0})))return sF(i,"no variants with VIDEO-RANGE of ".concat(KI(m)," found")),t;if(l&&_v(i).call(i,l.substring(0,4))%5!=0)return sF(i,'video codec preference "'.concat(l,'" not found')),t;if(n.maxScore<p)return sF(i,_d(y="max score of ".concat(n.maxScore," < selected max of ")).call(y,p)),t}return t&&(GO(i)>=GO(t)||n.fragmentError>e[t].fragmentError)?t:(g=n.minIndex,p=n.maxScore,i)}),void 0),videoRanges:m,preferHDR:E,minFramerate:f,minBitrate:v,minIndex:g}}(_,A,e,b,R),P=w.codecSet,C=w.videoRanges,x=w.minFramerate,M=w.minBitrate,O=w.minIndex,F=w.preferHDR;D=O,E=P,A=F?C[C.length-1]:C[0],L=x,e=Math.max(e,M),this.log("picked start tier ".concat(KI(w)))}else E=null==k?void 0:k.codecSet,A=null==k?void 0:k.videoRange;for(var N=f?f.duration:d?d.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,B=[],G=function(){var t=g[K],o=K>h;if(!t)return"continue";if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var d=navigator.mediaCapabilities;"function"!=typeof(null==d?void 0:d.decodingInfo)||!function(e,t,r,i,n,a){var s,o=e.audioCodec?e.audioGroups:null,l=null==a?void 0:a.audioCodec,u=null==a?void 0:a.channels,c=u?qk(u):l?1/0:2,h=null;if(null!=o&&o.length)try{h=1===o.length&&o[0]?t.groups[o[0]].channels:mP(o).call(o,(function(e,r){if(r){var i,n=t.groups[r];if(!n)throw new Error("Audio track group ".concat(r," not found"));vd(i=zf(n.channels)).call(i,(function(t){e[t]=(e[t]||0)+n.channels[t]}))}return e}),{2:0})}catch(QV){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(n,8e6))||!!h&&oO(c)&&cS(s=zf(h)).call(s,(function(e){return qk(e)>c}))}(t,I,A,L,e,b)&&"hvc1"!==(null==(V=t.videoCodec)?void 0:V.substring(0,4))?t.supportedResult=WO:(t.supportedPromise=XO(t,I,d),t.supportedPromise.then((function(e){if(l.hls){t.supportedResult=e;var r,i,n=l.hls.levels,a=_v(n).call(n,t);if(e.error)l.warn(_d(r=_d(i='MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ')).call(i,a," ")).call(r,KI(e)));else if(!e.supported){var s;l.warn(_d(s="Unsupported MediaCapabilities decodingInfo result for level ".concat(a," ")).call(s,KI(e))),a>-1&&n.length>1&&(l.log("Removing unsupported level ".concat(a)),l.hls.removeLevel(a),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0))}}})))}if((E&&t.codecSet!==E||A&&t.videoRange!==A||o&&L>t.frameRate||!o&&L>0&&L<t.frameRate||t.supportedResult&&(null==(H=t.supportedResult.decodingInfoResults)||!H[0].smooth))&&(!S||K!==D))return B.push(K),"continue";var v,p=t.details,k=(f?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;v=o?s*e:a*e;var R=N&&i>=2*N&&0===n?t.averageBitrate:t.maxBitrate,_=l.getTimeToLoadFrag(U,v,R*k,void 0===p);if(v>=R&&(K===c||0===t.loadError&&0===t.fragmentError)&&(_<=U||!oO(_)||T&&!l.bitrateTestDelay||_<u)){var w=l.forcedAutoLevel;if(K!==m&&(-1===w||w!==m)){var P,C,x,M,O,F,G,j,Y,q,W,z,X,Q,$,J;if(B.length)l.trace(_d(z=_d(X=_d(Q=_d($=_d(J="Skipped level(s) ".concat(B.join(",")," of ")).call(J,r,' max with CODECS and VIDEO-RANGE:"')).call($,g[B[0]].codecs,'" ')).call(Q,g[B[0]].videoRange,'; not compatible with "')).call(X,E,'" ')).call(z,A));l.info(_d(P=_d(C=_d(x=_d(M=_d(O=_d(F=_d(G=_d(j=_d(Y=_d(q=_d(W="switch candidate:".concat(h,"->")).call(W,K," adjustedbw(")).call(q,Math.round(v),")-bitrate=")).call(Y,Math.round(v-R)," ttfb:")).call(j,U.toFixed(1)," avgDuration:")).call(G,k.toFixed(1)," maxFetchDuration:")).call(F,u.toFixed(1)," fetchDuration:")).call(O,_.toFixed(1)," firstSelection:")).call(M,S," codecSet:")).call(x,t.codecSet," videoRange:")).call(C,t.videoRange," hls.loadLevel:")).call(P,m))}return S&&(l.firstSelection=K),{v:K}}},K=r;K>=t;K--){var H,V,j=G();if("continue"!==j&&"object"===Pc(j))return j.v}return-1}}]),i}(RO),gF=function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function pF(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.005,a=null;if(e){a=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7),a&&e.level!==a.level&&a.end<=e.end&&(a=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===mF(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i,n=mP(i=t.tagList).call(i,(function(e,t){return"INF"===t[0]&&(e+=zS(t[1])),e}),r);return e.start<=n}return!1}(a,e,Math.min(n,i))))return a;var o=gF(t,RT(mF).call(mF,null,r,i));return!o||o===e&&a?a:o}function mF(){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 i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function yF(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function EF(e,t){return gF(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function kF(e){switch(e.details){case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_TIMEOUT:case hO.LEVEL_LOAD_TIMEOUT:case hO.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function TF(e,t){var r=kF(t);return e.default["".concat(r?"timeout":"error","Retry")]}function SF(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function AF(e){return bO(bO({},e),{errorRetry:null,timeoutRetry:null})}function LF(e,t,r,i){if(!e)return!1;var n=null==i?void 0:i.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,a):a}var bF=0,RF=2,IF=3,DF=5,_F=0,wF=1,PF=2,CF=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"error-controller",e.logger)).hls=void 0,n.playlistError=0,n.penalizedRenditions={},n.hls=e,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.ERROR,this.onError,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.ERROR,this.onError,this),e.off(dO.ERROR,this.onErrorOut,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.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)===mO?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 i=this.hls,n=t.context;switch(t.details){case hO.FRAG_LOAD_ERROR:case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_ERROR:case hO.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case hO.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=xF());case hO.FRAG_GAP:case hO.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=RF);case hO.LEVEL_EMPTY_ERROR:case hO.LEVEL_PARSING_ERROR:var a,s,o=t.parent===mO?t.level:i.loadLevel;return void(t.details===hO.LEVEL_EMPTY_ERROR&&null!=(a=t.context)&&null!=(s=a.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case hO.LEVEL_LOAD_ERROR:case hO.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case hO.AUDIO_TRACK_LOAD_ERROR:case hO.AUDIO_TRACK_LOAD_TIMEOUT:case hO.SUBTITLE_LOAD_ERROR:case hO.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var l=i.levels[i.loadLevel];if(l&&(n.type===gO&&l.hasAudioGroup(n.groupId)||n.type===pO&&l.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=RF,void(t.errorAction.flags=wF)}return;case hO.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var u=i.levels[i.loadLevel],c=null==u?void 0:u.attrs["HDCP-LEVEL"];return void(c?t.errorAction={action:RF,flags:PF,hdcpLevel:c}:this.keySystemError(t));case hO.BUFFER_ADD_CODEC_ERROR:case hO.REMUX_ALLOC_ERROR:case hO.BUFFER_APPEND_ERROR:var h;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(h=t.level)?h:i.loadLevel);return;case hO.INTERNAL_EXCEPTION:case hO.BUFFER_APPENDING_ERROR:case hO.BUFFER_FULL_ERROR:case hO.LEVEL_SWITCH_ERROR:case hO.BUFFER_STALLED_ERROR:case hO.BUFFER_SEEK_OVER_HOLE:case hO.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=xF())}t.type===cO.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=TF(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(LF(r,i,kF(e),e.response))return{action:DF,flags:_F,retryConfig:r,retryCount:i};var n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n}},{key:"getFragRetryOrSwitchAction",value:function(e){var t,r,i=this.hls,n=this.getVariantLevelIndex(e.frag),a=i.levels[n],s=i.config,o=s.fragLoadPolicy,l=s.keyLoadPolicy,u=TF(rD(t=e.details).call(t,"key")?l:o,e),c=mP(r=i.levels).call(r,(function(e,t){return e+t.fragmentError}),0);if(a&&(e.details!==hO.FRAG_GAP&&a.fragmentError++,LF(u,c,kF(e),e.response)))return{action:DF,flags:_F,retryConfig:u,retryCount:c};var h=this.getLevelSwitchAction(e,n);return u&&(h.retryConfig=u,h.retryCount=c),h}},{key:"getLevelSwitchAction",value:function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var n,a,s=e.details;i.loadError++,s===hO.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,l=r.levels,u=r.loadLevel,c=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var d=null==(n=e.frag)?void 0:n.type,f=(d===yO&&s===hO.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===hO.BUFFER_ADD_CODEC_ERROR||s===hO.BUFFER_APPEND_ERROR))&&cS(l).call(l,(function(e){var t=e.audioCodec;return i.audioCodec!==t})),v="video"===e.sourceBufferName&&(s===hO.BUFFER_ADD_CODEC_ERROR||s===hO.BUFFER_APPEND_ERROR)&&cS(l).call(l,(function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(a=e.context)?a:{},p=g.type,m=g.groupId,y=function(){var t=(E+u)%l.length;if(t!==u&&t>=c&&t<=h&&0===l[t].loadError){var r=l[t];if(s===hO.FRAG_GAP&&d===mO&&e.frag){var n=l[t].details;if(n){var a=pF(e.frag,n.fragments,e.frag.start);if(null!=a&&a.gap)return"continue"}}else{if(p===gO&&r.hasAudioGroup(m)||p===pO&&r.hasSubtitleGroup(m))return"continue";if(d===yO&&null!=(k=i.audioGroups)&&cS(k).call(k,(function(e){return r.hasAudioGroup(e)}))||d===EO&&null!=(T=i.subtitleGroups)&&cS(T).call(T,(function(e){return r.hasSubtitleGroup(e)}))||f&&i.audioCodec===r.audioCodec||!f&&i.audioCodec!==r.audioCodec||v&&i.codecSet===r.codecSet)return"continue"}return o=t,"break"}},E=l.length;E--;){var k,T,S=y();if("continue"!==S&&"break"===S)break}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:RF,flags:_F,nextAutoLevel:o}}return{action:RF,flags:wF}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case bF:break;case RF:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===hO.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 i=IP(r),n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case _F:this.switchLevel(e,a);break;case PF:n&&(t.maxHdcpLevel=QO[_v(QO).call(QO,n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'))}r.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){var r;void 0!==t&&e.errorAction&&(this.warn(_d(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)}}]),i}(RO);function xF(e){var t={action:bF,flags:_F};return e&&(t.resolved=!0),t}var MF="NOT_LOADED",OF="APPENDING",FF="PARTIAL",NF="OK",UF=function(){function e(r){t(this,e),this.activePartLists=bT(null),this.endListFragments=bT(null),this.fragments=bT(null),this.timeRanges=bT(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=r,this._registerListeners()}return Fc(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(dO.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(dO.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 i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=e&&null!==a&&e<=a)return n}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 i=this.fragments,n=zf(i),a=n.length;a--;){var s=i[n[a]];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,i,n){var a,s=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(null==i?void 0:i.fragment.sn)||-1;vd(a=zf(this.fragments)).call(a,(function(i){var a,l=s.fragments[i];if(l&&!(o>=l.body.sn))if(l.buffered||l.loaded&&!n){var u=l.range[e];u&&(0!==u.time.length?cS(a=u.time).call(a,(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,i=this.timeRanges;if(i&&"initSegment"!==e.frag.sn){var n=e.frag,a=GF(n),s=this.fragments[a];if(!(!s||s.buffered&&n.gap)){var o=!n.relurl;if(vd(t=zf(i)).call(t,(function(t){var a=n.elementaryStreams[t];if(a){var l=i[t],u=o||!0===a.partial;s.range[t]=r.getBufferedTimes(n,e.part,u,l)}})),s.loaded=null,zf(s.range).length)s.buffered=!0,(s.body.endList=n.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),BF(s)||this.removeParts(n.sn-1,n.type);else this.removeFragment(s.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=rT(r).call(r,(function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=GF(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:bT(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}},{key:"getBufferedTimes",value:function(e,t,r,i){for(var n={time:[],partial:r},a=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<i.length;u++){var c=i.start(u)-this.bufferPadding,h=i.end(u)+this.bufferPadding;if(l>=c&&o<=h){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(a<h&&s>c){var d=Math.max(a,i.start(u)),f=Math.min(s,i.end(u));f>d&&(n.partial=!0,n.time.push({startPTS:d,endPTS:f}))}else if(s<=c)break}return n}},{key:"getPartialFragment",value:function(e){var t,r,i,n,a=null,s=0,o=this.bufferPadding,l=this.fragments;return vd(t=zf(l)).call(t,(function(t){var u=l[t];u&&BF(u)&&(i=u.body.start-o,n=u.body.end+o,e>=i&&e<=n&&(r=Math.min(e-i,n-e),s<=r&&(a=u.body,s=r)))})),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||BF(t))}},{key:"getState",value:function(e){var t=GF(e),r=this.fragments[t];return r?r.buffered?BF(r)?FF:NF:OF:MF}},{key:"isTimeBuffered",value:function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)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,i=t.part?null:t,n=GF(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:bT(null)}}}},{key:"onBufferAppended",value:function(e,t){var r=t.frag,i=t.part,n=t.timeRanges,a=t.type;if("initSegment"!==r.sn){var s=r.type;if(i){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(i)}this.timeRanges=n;var l=n[a];this.detectEvictedFragments(a,l,s,i)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=GF(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=zf(t);if(!e)return r.length>0;for(var i=r.length;i--;){var n=t[r[i]];if((null==n?void 0:n.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,i,n){var a,s=this;i&&!this.hasGaps||vd(a=zf(this.fragments)).call(a,(function(a){var o=s.fragments[a];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&s.removeFragment(l)}}))}},{key:"removeFragment",value:function(e){var t=GF(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=rT(r).call(r,(function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e,t;this.fragments=bT(null),this.endListFragments=bT(null),this.activePartLists=bT(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&vd(r).call(r,(function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function BF(e){var t,r,i;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==(i=e.range.audiovideo)?void 0:i.partial))}function GF(e){var t,r;return _d(t=_d(r="".concat(e.type,"_")).call(r,e.level,"_")).call(t,e.sn)}var KF=0,HF=1,VF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=r,this.aesIV=i,this.aesMode=n}return Fc(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case KF:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case HF: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 jF(e,t,r){return ag(Uint8Array.prototype)?ag(e).call(e,t,r):new Uint8Array(ag(Array.prototype).call(e,t,r))}var YF=function(){function e(){t(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 Fc(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],h=o[3],d=new Uint32Array(256),f=0,v=0,g=0;for(g=0;g<256;g++)d[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=v^v<<1^v<<2^v<<3^v<<4;p=p>>>8^255&p^99,e[f]=p,t[p]=f;var m=d[f],y=d[m],E=d[y],k=257*d[p]^16843008*p;i[f]=k<<24|k>>>8,n[f]=k<<16|k>>>16,a[f]=k<<8|k>>>24,s[f]=k,k=16843009*E^65537*y^257*m^16843008*f,l[p]=k<<24|k>>>8,u[p]=k<<16|k>>>16,c[p]=k<<8|k>>>24,h[p]=k,f?(f=m^d[d[d[E^m]]],v^=d[d[v]]):f=v=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,l,u=this.ksRows=4*(n+6+1),c=this.keySchedule=new Uint32Array(u),h=this.invKeySchedule=new Uint32Array(u),d=this.sBox,f=this.rcon,v=this.invSubMix,g=v[0],p=v[1],m=v[2],y=v[3];for(a=0;a<u;a++)a<n?o=c[a]=t[a]:(l=o,a%n==0?(l=d[(l=l<<8|l>>>24)>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l],l^=f[a/n|0]<<24):n>6&&a%n==4&&(l=d[l>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l]),c[a]=o=(c[a-n]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],h[s]=s<4||a<=4?l:g[d[l>>>24]]^p[d[l>>>16&255]]^m[d[l>>>8&255]]^y[d[255&l]],h[s]=h[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 i,n,a,s,o,l,u,c,h,d,f,v,g,p,m=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,k=this.invSubMix,T=k[0],S=k[1],A=k[2],L=k[3],b=this.uint8ArrayToUint32Array_(r),R=b[0],I=b[1],D=b[2],_=b[3],w=new Int32Array(e),P=new Int32Array(w.length),C=this.networkToHostOrderSwap;t<w.length;){for(h=C(w[t]),d=C(w[t+1]),f=C(w[t+2]),v=C(w[t+3]),o=h^y[0],l=v^y[1],u=f^y[2],c=d^y[3],g=4,p=1;p<m;p++)i=T[o>>>24]^S[l>>16&255]^A[u>>8&255]^L[255&c]^y[g],n=T[l>>>24]^S[u>>16&255]^A[c>>8&255]^L[255&o]^y[g+1],a=T[u>>>24]^S[c>>16&255]^A[o>>8&255]^L[255&l]^y[g+2],s=T[c>>>24]^S[o>>16&255]^A[l>>8&255]^L[255&u]^y[g+3],o=i,l=n,u=a,c=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&c]^y[g],n=E[l>>>24]<<24^E[u>>16&255]<<16^E[c>>8&255]<<8^E[255&o]^y[g+1],a=E[u>>>24]<<24^E[c>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[c>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],P[t]=C(i^R),P[t+1]=C(s^I),P[t+2]=C(a^D),P[t+3]=C(n^_),R=h,I=d,D=f,_=v,t+=4}return P.buffer}}]),e}(),qF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=r,this.key=i,this.aesMode=n}return Fc(e,[{key:"expandKey",value:function(){var e=function(e){switch(e){case KF:return"AES-CBC";case HF:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode ".concat(e))}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}]),e}();function WF(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 i=_v(r).call(r,"\0");return-1!==i?r.substring(0,i):r}return r.replace(/\0/g,"")}for(var n,a,s,o=e.length,l="",u=0;u<o;){if(0===(n=e[u++])&&t)return l;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:a=e[u++],l+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[u++],s=e[u++],l+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&s)<<0)}}return l}var zF={hexDump:function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}};function XF(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var QF,$F,JF,ZF,eN,tN={exports:{}};QF=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,$F=/^(?=([^\/?#]*))\1([^]*)$/,JF=/(?:\/|^)\.(?=\/)/g,ZF=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,tN.exports=eN={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=iA(e).call(e),!(t=iA(t).call(t))){if(!r.alwaysNormalize)return e;var i=eN.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=eN.normalizePath(i.path),eN.buildURLFromParts(i)}var n=eN.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=eN.normalizePath(n.path),eN.buildURLFromParts(n)):t;var a=eN.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var s=$F.exec(a.path);a.netLoc=s[1],a.path=s[2]}a.netLoc&&!a.path&&(a.path="/");var o={scheme:a.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(o.netLoc=a.netLoc,"/"!==n.path[0]))if(n.path){var l=a.path,u=l.substring(0,HP(l).call(l,"/")+1)+n.path;o.path=eN.normalizePath(u)}else o.path=a.path,n.params||(o.params=a.params,n.query||(o.query=a.query));return null===o.path&&(o.path=r.alwaysNormalize?eN.normalizePath(n.path):n.path),eN.buildURLFromParts(o)},parseURL:function(e){var t=QF.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=$P(t=e.split("")).call(t).join("").replace(JF,"");e.length!==(e=e.replace(ZF,"")).length;);return $P(r=e.split("")).call(r).join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var rN=tN.exports,iN=Fc((function e(){t(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}})),nN="audio",aN="video",sN="audiovideo",oN=function(){function e(r){t(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof r&&(r={url:r}),this.base=r}return Fc(e,[{key:"setByteRange",value:function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:qk(i[1]),this._byteRange=[r,qk(i[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=(Lf(e={},nN,null),Lf(e,aN,null),Lf(e,sN,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 iN),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=rN.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[nN]=null,e[aN]=null,e[sN]=null}}]),e}();function lN(e){return"initSegment"!==e.sn}var uN=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 Fc(i,[{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(oO(t)&&oO(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=zf(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=oO(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=zf(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){oO(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return lN(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,i,n){var a=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,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}}}]),i}(oN),cN=function(e){Ch(i,e);var r=ed(i);function i(e,n,a,s,o){var l;t(this,i),(l=r.call(this,a)).fragOffset=0,l.duration=0,l.gap=!1,l.independent=!1,l.relurl=void 0,l.fragment=void 0,l.index=void 0,l.duration=e.decimalFloatingPoint("DURATION"),l.gap=e.bool("GAP"),l.independent=e.bool("INDEPENDENT"),l.relurl=e.enumeratedString("URI"),l.fragment=n,l.index=s;var u=e.enumeratedString("BYTERANGE");return u&&l.setByteRange(u,o),o&&(l.fragOffset=o.fragOffset+o.duration),l}return Fc(i,[{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)}}]),i}(oN),hN=Math.pow(2,32)-1,dN=[].push,fN={video:1,audio:2,id3:3,text:4};function vN(e){return String.fromCharCode.apply(null,e)}function gN(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function pN(e,t){var r=yN(e,t);return r<0?4294967296+r:r}function mN(e,t){var r=pN(e,t);return r*=Math.pow(2,32),r+=pN(e,t+4)}function yN(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function EN(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 kN(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=pN(e,n),s=a>1?n+a:i;if(vN(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=kN(e.subarray(n+8,s),ag(t).call(t,1));o.length&&dN.apply(r,o)}n=s}return r}function TN(e){var t=[],r=e[0],i=8,n=pN(e,i);i+=4;var a=0,s=0;0===r?(a=pN(e,i),s=pN(e,i+4),i+=8):(a=mN(e,i),s=mN(e,i+8),i+=16),i+=2;var o=e.length+s,l=gN(e,i);i+=2;for(var u=0;u<l;u++){var c=i,h=pN(e,c);c+=4;var d=2147483647&h;if(1===(2147483648&h)>>>31)return CO.warn("SIDX has hierarchical references (not supported)"),null;var f=pN(e,c);c+=4,t.push({referenceSize:d,subsegmentDuration:f,info:{duration:f/n,start:o,end:o+d-1}}),o+=d,i=c+=4}return{earliestPresentationTime:a,timescale:n,version:r,referencesCount:l,references:t}}function SN(e){for(var t=[],r=kN(e,["moov","trak"]),i=0;i<r.length;i++){var n=r[i],a=kN(n,["tkhd"])[0];if(a){var s=a[0],o=pN(a,0===s?12:20),l=kN(n,["mdia","mdhd"])[0];if(l){var u=pN(l,0===(s=l[0])?12:20),c=kN(n,["mdia","hdlr"])[0];if(c){var h=vN(c.subarray(8,12)),d={soun:nN,vide:aN}[h];if(d){var f=AN(kN(n,["mdia","minf","stbl","stsd"])[0]);t[o]={timescale:u,type:d},t[d]=bO({timescale:u,id:o},f)}}}}}var v=kN(e,["moov","mvex","trex"]);return vd(v).call(v,(function(e){var r=pN(e,4),i=t[r];i&&(i.default={duration:pN(e,12),flags:pN(e,20)})})),t}function AN(e){var t=e.subarray(8),r=t.subarray(86),i=vN(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=kN(t,[i])[0],o=kN(s.subarray("enca"===i?28:78),["sinf"]);vd(o).call(o,(function(e){var t=kN(e,["schm"])[0];if(t){var r=vN(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=kN(e,["frma"])[0];i&&(n=vN(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var l=kN(r,["avcC"])[0];n+="."+bN(l[1])+bN(l[2])+bN(l[3]);break;case"mp4a":var u=kN(t,[i])[0],c=kN(u.subarray(28),["esds"])[0];if(c&&c.length>7){var h=4;if(3!==c[h++])break;h=LN(c,h),h+=2;var d=c[h++];if(128&d&&(h+=2),64&d&&(h+=c[h++]),4!==c[h++])break;h=LN(c,h);var f=c[h++];if(64!==f)break;if(n+="."+bN(f),h+=12,5!==c[h++])break;h=LN(c,h);var v=c[h++],g=(248&v)>>3;31===g&&(g+=1+((7&v)<<3)+((224&c[h])>>5)),n+="."+g}break;case"hvc1":case"hev1":var p=kN(r,["hvcC"])[0],m=p[1],y=["","A","B","C"][m>>6],E=31&m,k=pN(p,2),T=(32&m)>>5?"H":"L",S=p[12],A=p.subarray(6,12);n+="."+y+E,n+="."+k.toString(16).toUpperCase(),n+="."+T+S;for(var L="",b=A.length;b--;){var R=A[b];if(R||L)L="."+R.toString(16).toUpperCase()+L}n+=L;break;case"dvh1":case"dvhe":var I=kN(r,["dvcC"])[0],D=I[2]>>1&127,_=I[2]<<5&32|I[3]>>3&31;n+="."+RN(D)+"."+RN(_);break;case"vp09":var w=kN(r,["vpcC"])[0],P=w[4],C=w[5],x=w[6]>>4&15;n+="."+RN(P)+"."+RN(C)+"."+RN(x);break;case"av01":var M=kN(r,["av1C"])[0],O=M[1]>>>5,F=31&M[1],N=M[2]>>>7?"H":"M",U=(64&M[2])>>6,B=(32&M[2])>>5,G=2===O&&U?B?12:10:U?10:8,K=(16&M[2])>>4,H=(8&M[2])>>3,V=(4&M[2])>>2,j=3&M[2];n+="."+O+"."+RN(F)+N+"."+RN(G)+"."+K+"."+H+V+j+"."+RN(1)+"."+RN(1)+"."+RN(1)+".0"}return{codec:n,encrypted:a}}function LN(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function bN(e){var t;return ag(t="0"+e.toString(16).toUpperCase()).call(t,-2)}function RN(e){return(e<10?"0":"")+e}function IN(e){var t=kN(e,["schm"])[0];if(t){var r=vN(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return kN(e,["schi","tenc"])[0]}return null}function DN(e){var t=pN(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=pN(e,4),a=0;a<n;a++){if(256&t)i+=pN(e,r),r+=4;512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return i}function _N(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function wN(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1,o=kN(i,["moof"]);return Jk(o).call(o,(function(o){var l=o.byteOffset-8,u=kN(o,["traf"]);Jk(u).call(u,(function(o){var u,c,h=Jk(u=kN(o,["tfdt"])).call(u,(function(e){var t=e[0],r=pN(e,4);return 1===t&&(r*=Math.pow(2,32),r+=pN(e,8)),r/n}))[0];return void 0!==h&&(e=h),Jk(c=kN(o,["tfhd"])).call(c,(function(u){var c,h=pN(u,4),d=16777215&pN(u,0),f=0,v=0!=(16&d),g=0,p=0!=(32&d),m=8;h===a&&(0!=(1&d)&&(m+=8),0!=(2&d)&&(m+=4),0!=(8&d)&&(f=pN(u,m),m+=4),v&&(g=pN(u,m),m+=4),p&&(m+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=_v(e).call(e,"."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),Jk(c=kN(o,["trun"])).call(c,(function(a){var o=a[0],u=16777215&pN(a,0),c=0!=(1&u),h=0,d=0!=(4&u),v=0!=(256&u),p=0,m=0!=(512&u),y=0,E=0!=(1024&u),k=0!=(2048&u),T=0,S=pN(a,4),A=8;c&&(h=pN(a,A),A+=4),d&&(A+=4);for(var L=h+l,b=0;b<S;b++){if(v?(p=pN(a,A),A+=4):p=f,m?(y=pN(a,A),A+=4):y=g,E&&(A+=4),k&&(T=0===o?pN(a,A):yN(a,A),A+=4),t.type===aN)for(var R=0;R<y;){var I=pN(i,L);if(PN(s,i[L+=4]))CN(i.subarray(L,L+I),s?2:1,e+T/n,r);L+=I,R+=I+4}e+=p/n}})))}))}))})),r}function PN(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function CN(e,t,r,i){var n=xN(e),a=0;a+=t;for(var s=0,o=0,l=0;a<n.length;){s=0;do{if(a>=n.length)break;s+=l=n[a++]}while(255===l);o=0;do{if(a>=n.length)break;o+=l=n[a++]}while(255===l);var u=n.length-a,c=a;if(o<u)a+=o;else if(o>u){var h;CO.error(_d(h="Malformed SEI payload. ".concat(o," is too small, only ")).call(h,u," bytes left to parse."));break}if(4===s){if(181===n[c++]){var d=gN(n,c);if(c+=2,49===d){var f=pN(n,c);if(c+=4,1195456820===f){var v=n[c++];if(3===v){var g=n[c++],p=64&g,m=p?2+3*(31&g):0,y=new Uint8Array(m);if(p){y[0]=g;for(var E=1;E<m;E++)y[E]=n[c++]}i.push({type:v,payloadType:s,pts:r,bytes:y})}}}}}else if(5===s&&o>16){for(var k=[],T=0;T<16;T++){var S=n[c++].toString(16);k.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||k.push("-")}for(var A=o-16,L=new Uint8Array(A),b=0;b<A;b++)L[b]=n[c++];i.push({payloadType:s,pts:r,uuid:k.join(""),userData:WF(L),userDataBytes:L})}}}function xN(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}function MN(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var i,n;i=new Uint8Array,n=new Uint8Array;var a=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=r.length,a=8,s=n;s--;)a+=r[s].byteLength;var o=new Uint8Array(a);for(o[0]=a>>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),s=0,a=8;s<n;s++)o.set(r[s],a),a+=r[s].byteLength;return o}([112,115,115,104],new Uint8Array([0,0,0,0]),e,n,i,a,r||new Uint8Array)}function ON(e){var t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};var n=e.getUint32(8)>>>24;if(0!==n&&1!==n)return{offset:r,size:t};var a=e.buffer,s=zF.hexDump(new Uint8Array(a,r+12,16)),o=e.getUint32(28),l=null,u=null;if(0===n){if(t-32<o||o<22)return{offset:r,size:t};u=new Uint8Array(a,r+32,o)}else if(1===n){if(!o||i<r+32+16*o+16)return{offset:r,size:t};l=[];for(var c=0;c<o;c++)l.push(new Uint8Array(a,r+32+16*c,16))}return{version:n,systemId:s,kids:l,data:u,offset:r,size:t}}var FN=function(){function e(r){var i=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).removePKCS7Padding,n=void 0===i||i;if(t(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=r.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(s){}this.useSoftware=!this.subtle}return Fc(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,i,n,a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=a).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?jF(r,0,i-n):r):a}},{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,i){var n=this;return this.useSoftware?new Lk((function(a,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);n.softwareDecrypt(o,t,r,i);var l=n.flush();l?a(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}},{key:"softwareDecrypt",value:function(e,t,r,i){var n=this.currentIV,a=this.currentResult,s=this.remainderData;if(i!==KF||16!==t.byteLength)return CO.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=_N(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;n&&(r=n);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new YF),l.expandKey(t);var u=a;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=jF(o,-16).buffer,u||null}},{key:"webCryptoDecrypt",value:function(e,t,r,i){var n=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Lk.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new qF(this.subtle,t,i)}return this.fastAesKey.expandKey().then((function(t){return n.subtle?(n.logOnce("WebCrypto AES decrypt"),new VF(n.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):Lk.reject(new Error("web crypto not initialized"))})).catch((function(a){var s;return CO.warn(_d(s="[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(a.name,": ")).call(s,a.message)),n.onWebCryptoError(e,t,r,i)}))}},{key:"onWebCryptoError",value:function(e,t,r,i){var n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=jF(e,0,r),this.remainderData=jF(e,r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(CO.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),NN=Math.pow(2,17),UN=function(){function e(r){t(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=r}return Fc(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,i=e.url;if(!i)return Lk.reject(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new Lk((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){var u;if(cS(u=e.tagList).call(u,(function(e){return"GAP"===e[0]})))return void l(GN(e));e.gap=!1}var c=r.loader=a?new a(n):new s(n),h=BN(e);e.loader=c;var d=AF(n.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:NN};e.stats=c.stats;var v={onSuccess:function(t,i,n,a){r.resetLoader(e,c);var s=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(ag(s).call(s,0,16)),s=ag(s).call(s,16)),o({frag:e,part:null,payload:s,networkDetails:a})},onError:function(t,n,a,s){var o;r.resetLoader(e,c),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:bO({url:i,data:void 0},t),error:new Error(_d(o="HTTP Error ".concat(t.code," ")).call(o,t.text)),networkDetails:a,stats:s}))},onAbort:function(t,i,n){r.resetLoader(e,c),l(new KN({type:cO.NETWORK_ERROR,details:hO.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:function(t,i,n){r.resetLoader(e,c),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after ".concat(f.timeout,"ms")),networkDetails:n,stats:t}))}};t&&(v.onProgress=function(r,i,n,a){return t({frag:e,part:null,payload:n,networkDetails:a})}),c.load(h,f,v)}))}},{key:"loadPart",value:function(e,t,r){var i=this;this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new Lk((function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(GN(e,t));else{var u=i.loader=a?new a(n):new s(n),c=BN(e,t);e.loader=u;var h=AF(n.fragLoadPolicy.default),d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:NN};t.stats=u.stats,u.load(c,d,{onSuccess:function(n,a,s,l){i.resetLoader(e,u),i.updateStatsFromPart(e,t);var c={frag:e,part:t,payload:n.data,networkDetails:l};r(c),o(c)},onError:function(r,n,a,s){var o;i.resetLoader(e,u),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:bO({url:c.url,data:void 0},r),error:new Error(_d(o="HTTP Error ".concat(r.code," ")).call(o,r.text)),networkDetails:a,stats:s}))},onAbort:function(r,n,a){e.stats.aborted=t.stats.aborted,i.resetLoader(e,u),l(new KN({type:cO.NETWORK_ERROR,details:hO.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,n,a){i.resetLoader(e,u),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after ".concat(d.timeout,"ms")),networkDetails:a,stats:r}))}})}}))}},{key:"updateStatsFromPart",value:function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}]),e}();function BN(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=r||e,n={frag:e,part:r,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},a=i.byteRangeStartOffset,s=i.byteRangeEndOffset;if(oO(a)&&oO(s)){var o,l=a,u=s;if("initSegment"===e.sn&&("AES-128"===(t=null==(o=e.decryptdata)?void 0:o.method)||"AES-256"===t)){var c=s-a;c%16&&(u=s+(16-c%16)),0!==a&&(n.resetIV=!0,l=a-16)}n.rangeStart=l,n.rangeEnd=u}return n}function GN(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),i={type:cO.MEDIA_ERROR,details:hO.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new KN(i)}var KN=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e.error.message)).data=void 0,n.data=e,n}return Fc(i)}(Jw(Error)),HN=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(s=r.call(this,e,n))._boundTick=void 0,s._tickTimer=null,s._tickInterval=null,s._tickCallCount=0,s._boundTick=RT(a=s.tick).call(a,Zh(s)),s}return Fc(i,[{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=PS(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=Wf(this._boundTick,0)}},{key:"doTick",value:function(){}}]),i}(RO),VN=Fc((function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];t(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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=r,this.sn=i,this.id=n,this.size=a,this.part=s,this.partial=o}));var jN={length:0,start:function(){return 0},end:function(){return 0}},YN=function(){function e(){t(this,e)}return Fc(e,null,[{key:"isBuffered",value:function(t,r){if(t)for(var i=e.getBuffered(t),n=i.length;n--;)if(r>=i.start(n)&&r<=i.end(n))return!0;return!1}},{key:"bufferInfo",value:function(t,r,i){if(t){var n=e.getBuffered(t);if(n.length){for(var a=[],s=0;s<n.length;s++)a.push({start:n.start(s),end:n.end(s)});return e.bufferedInfo(a,r,i)}}return{len:0,start:r,end:r,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){t=Math.max(0,t),GA(e).call(e,(function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,c=t,h=0;h<i.length;h++){var d=i[h].start,f=i[h].end;if(t+r>=d&&t<f)u=d,l=(c=f)-t;else if(t+r<d){o=d;break}}return{len:l,start:u||0,end:c||0,nextStart:o}}},{key:"getBuffered",value:function(e){try{return e.buffered||jN}catch(t){return CO.log("failed to get media.buffered",t),jN}}}]),e}(),qN=/\{\$([a-zA-Z0-9-_]+)\}/g;function WN(e){return qN.test(e)}function zN(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(qN,(function(t){var i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(i,'"'))),t):n}))}return t}function XN(e,t,r){var i,n,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{var s,o=new NI(r).searchParams;if(!o.has(i))throw new Error(_d(s='"'.concat(i,'" does not match any query parameter in URI: "')).call(s,r,'"'));n=o.get(i)}catch(QV){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(QV.message)))}}else i=t.NAME,n=t.VALUE;i in a?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(i,'"'))):a[i]=n||""}function QN(e,t,r){var i=t.IMPORT;if(r&&i in r){var n=e.variableList;n||(e.variableList=n={}),n[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(i,'"')))}var $N=/^(\d+)x(\d+)$/,JN=/(.+?)=(".*?"|.*?)(?:,|$)/g,ZN=function(){function e(r,i){t(this,e),"string"==typeof r&&(r=e.parseAttrList(r,i)),AO(this,r)}return Fc(e,[{key:"clientAttrs",get:function(){var e;return rT(e=zf(this)).call(e,(function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=qk(this[e],10);return t>aP?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t,r=ag(t=this[e]||"0x").call(t,2);r=(1&r.length?"0":"")+r;for(var i=new Uint8Array(r.length/2),n=0;n<r.length/2;n++)i[n]=qk(ag(r).call(r,2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=qk(this[e],16);return t>aP?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return zS(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?zS(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r,i=this[e];return mP(r=i?i.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=$N.exec(this[e]);if(null!==t)return{width:qk(t[1],10),height:qk(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,i,n={};for(JN.lastIndex=0;null!==(i=JN.exec(e));){var a,s=iA(a=i[1]).call(a),o=i[2],l=0===_v(o).call(o,'"')&&HP(o).call(o,'"')===o.length-1,u=!1;if(l)o=ag(o).call(o,1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":u=!0}if(t&&(l||u))o=zN(t,o);else if(!u&&!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":CO.warn(_d(r="".concat(e,": attribute ")).call(r,s," is missing quotes"))}n[s]=o}return n}}]),e}();function eU(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var tU=function(){function e(r,i){var n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t(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==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(n=null==i?void 0:i.tagOrder)?n:a,i){var s=i.attr;for(var o in s)if(Object.prototype.hasOwnProperty.call(r,o)&&r[o]!==s[o]){var l;CO.warn(_d(l='DATERANGE tag attribute: "'.concat(o,'" does not match for tags with ID: "')).call(l,r.ID,'"')),this._badValueForSameId=o;break}r=AO(new ZN({}),s,r)}if(this.attr=r,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(r["START-DATE"]),"END-DATE"in this.attr){var u=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);oO(u.getTime())&&(this._endDate=u)}}return Fc(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?(CO.warn(_d(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(oO(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"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&oO(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}(),rU=function(){function e(r){t(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=r}return Fc(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&&oO(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{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(YA()-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 iU(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function nU(e){switch(e){case"AES-128":case"AES-256":return KF;case"AES-256-CTR":return HF;default:throw new Error("invalid full segment method ".concat(e))}}function aU(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function sU(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function oU(e){var t,r,i=e.split(":"),n=null;if("data"===i[0]&&2===i.length){var a=i[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(Rg(a).call(a,-1,1),n=aU(l)):(t=sU(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),n=r)}}return n}var lU="undefined"!=typeof self?self:void 0,uU="org.w3.clearkey",cU="com.apple.fps",hU="com.microsoft.playready",dU="com.widevine.alpha",fU="org.w3.clearkey",vU="com.apple.streamingkeydelivery",gU="com.microsoft.playready",pU="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function mU(e){switch(e){case vU:return cU;case gU:return hU;case pU:return dU;case fU:return uU}}var yU="1077efecc0b24d02ace33c1e52e2fb4b",EU="e2719d58a985b3c9781ab030af78d30e",kU="9a04f07998404286ab92e65be0885f95",TU="edef8ba979d64acea3c827dcd51d21ed";function SU(e){return e===TU?dU:e===kU?hU:e===yU||e===EU?uU:void 0}function AU(e){switch(e){case cU:return vU;case hU:return gU;case dU:return pU;case uU:return fU}}function LU(e){var t,r=e.drmSystems,i=e.widevineLicenseUrl,n=r?rT(t=[cU,dU,hU,uU]).call(t,(function(e){return!!r[e]})):[];return!n[dU]&&i&&n.push(dU),n}var bU,RU,IU=null!=lU&&null!=(bU=lU.navigator)&&bU.requestMediaKeySystemAccess?RT(RU=self.navigator.requestMediaKeySystemAccess).call(RU,self.navigator):null;function DU(e,t,r,i){var n;switch(e){case cU:n=["cenc","sinf"];break;case dU:case hU:n=["cenc"];break;case uU:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return function(e,t,r,i){var n={initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:Jk(t).call(t,(function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:Jk(r).call(r,(function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))};return[n]}(n,t,r,i)}function _U(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,WT(t)),i=r.substring(_v(r).call(r,"<"),r.length),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){var a=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(a){var s=aU(a).subarray(0,16);return function(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(s),s}}return null}var wU={},PU=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;t(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=r,this.uri=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=s,this.encrypted=!!r&&"NONE"!==r,this.isCommonEncryption=this.encrypted&&!iU(r)}return Fc(e,[{key:"isSupported",value:function(){var e;if(this.method){if(iU(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case vU:case pU:case gU:case fU:return-1!==_v(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(iU(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(CO.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue')),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var i=oU(this.uri);if(i)switch(this.keyFormat){case pU:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case gU:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=MN(n,0,i),this.keyId=_U(i);break;default:var a=i.subarray(0,16);if(16!==a.length){var s=new Uint8Array(16);s.set(a,16-a.length),a=s}this.keyId=a}if(!this.keyId||16!==this.keyId.byteLength){var o=wU[this.uri];if(!o){var l=zf(wU).length%aP;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),wU[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){wU={}}}]),e}();var CU=/#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,xU=/#EXT-X-MEDIA:(.*)/g,MU=/^#EXT(?:INF|-X-TARGETDURATION):/m,OU=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),FU=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("|")),NU=function(){function e(){t(this,e)}return Fc(e,null,[{key:"findGroup",value:function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}}},{key:"resolve",value:function(e,t){return rN.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return MU.test(e)}},{key:"parseMasterPlaylist",value:function(t,r){var i,n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:WN(t)},a=[];for(CU.lastIndex=0;null!=(i=CU.exec(t));)if(i[1]){var s,o=new ZN(i[1],n),l=zN(n,i[2]),u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),HU(o.CODECS,u),null!=(s=u.unknownCodecs)&&s.length||a.push(u),n.levels.push(u)}else if(i[3]){var h=i[3],d=i[4];switch(h){case"SESSION-DATA":var f=new ZN(d,n),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var g=GU(d,r,n);g.encrypted&&g.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(g)):CO.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(d,'"'));break;case"DEFINE":XN(n,new ZN(d,n),r);break;case"CONTENT-STEERING":var p=new ZN(d,n);n.contentSteering={uri:e.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=KU(d)}}var m=a.length>0&&a.length<n.levels.length;return n.levels=m?a:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n}},{key:"parseMasterPlaylistMedia",value:function(t,r,i){var n,a={},s=i.levels,o={AUDIO:Jk(s).call(s,(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:Jk(s).call(s,(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(xU.lastIndex=0;null!==(n=xU.exec(t));){var u=new ZN(n[1],i),c=u.TYPE;if(c){var h=o[c],d=a[c]||[];a[c]=d;var f=u.LANGUAGE,v=u["ASSOC-LANGUAGE"],g=u.CHANNELS,p=u.CHARACTERISTICS,m=u["INSTREAM-ID"],y={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||f||"",type:c,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:f,url:u.URI?e.resolve(u.URI,r):""};if(v&&(y.assocLang=v),g&&(y.channels=g),p&&(y.characteristics=p),m&&(y.instreamId=m),null!=h&&h.length){var E=e.findGroup(h,y.groupId)||h[0];VU(y,E,"audioCodec"),VU(y,E,"textCodec")}d.push(y)}}return a}},{key:"parseLevelPlaylist",value:function(e,t,r,i,n,a){var s,o,l,u={url:t},c=new rU(t),h=c.fragments,d=[],f=null,v=0,g=0,p=0,m=0,y=0,E=null,k=new uN(i,u),T=-1,S=!1,A=null;for(OU.lastIndex=0,c.m3u8=e,c.hasVariableRefs=WN(e);null!==(s=OU.exec(e));){S&&(S=!1,(k=new uN(i,u)).playlistOffset=p,k.start=p,k.sn=v,k.cc=m,y&&(k.bitrate=y),k.level=r,f&&(k.initSegment=f,f.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null),A&&(k.setByteRange(A),A=null)));var L=s[1];if(L){var b;k.duration=zS(L);var R=ag(b=" "+s[2]).call(b,1);k.title=R||null,k.tagList.push(R?["INF",L,R]:["INF",L])}else if(s[3]){if(oO(k.duration)){var I;k.playlistOffset=p,k.start=p,l&&qU(k,l,c),k.sn=v,k.level=r,k.cc=m,h.push(k);var D=ag(I=" "+s[3]).call(I,1);k.relurl=zN(c,D),jU(k,E,d),E=k,p+=k.duration,v++,g=0,S=!0}}else{var _,w,P;if(!(s=s[0].match(FU))){CO.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<s.length&&void 0===s[o];o++);var C=ag(_=" "+s[o]).call(_,1),x=ag(w=" "+s[o+1]).call(w,1),M=s[o+2]?ag(P=" "+s[o+2]).call(P,1):null;switch(C){case"BYTERANGE":E?k.setByteRange(x,E):k.setByteRange(x);break;case"PROGRAM-DATE-TIME":k.rawProgramDateTime=x,k.tagList.push(["PROGRAM-DATE-TIME",x]),-1===T&&(T=h.length);break;case"PLAYLIST-TYPE":c.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":v=c.startSN=qk(x);break;case"SKIP":c.skippedSegments&&(c.playlistParsingError=new Error("#EXT-X-SKIP MUST NOT appear more than once in a Playlist"));var O=new ZN(x,c),F=O.decimalInteger("SKIPPED-SEGMENTS");if(oO(F)){c.skippedSegments+=F;for(var N=F;N--;)h.push(null);v+=F}var U,B=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(B)c.recentlyRemovedDateranges=_d(U=c.recentlyRemovedDateranges||[]).call(U,B.split("\t"));break;case"TARGETDURATION":c.targetduration=Math.max(qk(x),1);break;case"VERSION":c.version=qk(x);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"#":(x||M)&&k.tagList.push(M?[x,M]:[x]);break;case"DISCONTINUITY":m++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([C]);break;case"BITRATE":k.tagList.push([C,x]),y=1e3*qk(x),oO(y)?k.bitrate=y:y=0;break;case"DATERANGE":var G=new ZN(x,c),K=new tU(G,c.dateRanges[G.ID],c.dateRangeTagCount);c.dateRangeTagCount++,K.isValid||c.skippedSegments?c.dateRanges[K.id]=K:CO.warn('Ignoring invalid DATERANGE tag: "'.concat(x,'"')),k.tagList.push(["EXT-X-DATERANGE",x]);break;case"DEFINE":var H=new ZN(x,c);"IMPORT"in H?QN(c,H,a):XN(c,H,t);break;case"DISCONTINUITY-SEQUENCE":c.startCC=m=qk(x);break;case"KEY":var V=GU(x,t,c);if(V.isSupported()){if("NONE"===V.method){l=void 0;break}l||(l={}),l[V.keyFormat]&&(l=AO({},l)),l[V.keyFormat]=V}else CO.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(x,'"'));break;case"START":c.startTimeOffset=KU(x);break;case"MAP":var j=new ZN(x,c);if(k.duration){var Y=new uN(i,u);YU(Y,j,r,l),f=Y,k.initSegment=f,f.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime)}else{var q=k.byteRangeEndOffset;if(q){var W,z=k.byteRangeStartOffset;A=_d(W="".concat(q-z,"@")).call(W,z)}else A=null;YU(k,j,r,l),f=k,S=!0}f.cc=m;break;case"SERVER-CONTROL":var X=new ZN(x);c.canBlockReload=X.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=X.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&X.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),c.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Q=new ZN(x);c.partTarget=Q.decimalFloatingPoint("PART-TARGET");break;case"PART":var $=c.partList;$||($=c.partList=[]);var J=g>0?$[$.length-1]:void 0,Z=g++,ee=new ZN(x,c),te=new cN(ee,k,u,Z,J);$.push(te),k.duration+=te.duration;break;case"PRELOAD-HINT":var re=new ZN(x,c);c.preloadHint=re;break;case"RENDITION-REPORT":var ie=new ZN(x,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(ie);break;default:CO.warn("line parsed but not handled: ".concat(s))}}}E&&!E.relurl?(h.pop(),p-=E.duration,c.partList&&(c.fragmentHint=E)):c.partList&&(jU(k,E,d),k.cc=m,c.fragmentHint=k,l&&qU(k,l,c));var ne=h.length,ae=h[0],se=h[ne-1];if((p+=c.skippedSegments*c.targetduration)>0&&ne&&se){c.averagetargetduration=p/ne;var oe=se.sn;c.endSN="initSegment"!==oe?oe:0,c.live||(se.endList=!0),ae&&!c.startCC&&(c.startCC=ae.cc),T>0&&(!function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,T),ae&&d.unshift(ae))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(p+=c.fragmentHint.duration),c.totalduration=p,d.length&&c.dateRangeTagCount&&ae&&UU(d,c),c.endCC=m,c}}]),e}();function UU(e,t){for(var r=e.length,i=e[r-1],n=t.live?1/0:t.totalduration,a=zf(t.dateRanges),s=a.length;s--;){var o=t.dateRanges[a[s]],l=o.startDate.getTime();o.tagAnchor=i.ref;for(var u=r;u--;){var c=BU(t,l,e,u,n);if(-1!==c){o.tagAnchor=t.fragments[c].ref;break}}}}function BU(e,t,r,i,n){var a=r[i];if(a){var s,o=a.programDateTime;if(t>=o||0===i)if(t<=o+1e3*(((null==(s=r[i+1])?void 0:s.start)||n)-a.start)){var l=r[i].sn-e.startSN,u=e.fragments;if(u.length>r.length)for(var c=(r[i+1]||u[u.length-1]).sn-e.startSN;c>l;c--){var h=u[c].programDateTime;if(t>=h&&t<h+1e3*u[c].duration)return c}return l}}return-1}function GU(e,t,r){var i,n,a,s,o=new ZN(e,r),l=null!=(a=o.METHOD)?a:"",u=o.URI,c=o.hexadecimalInteger("IV"),h=o.KEYFORMATVERSIONS,d=null!=(s=o.KEYFORMAT)?s:"identity";u&&o.IV&&!c&&CO.error("Invalid IV: ".concat(o.IV));var f=u?NU.resolve(u,t):"",v=rT(i=Jk(n=(h||"1").split("/")).call(n,Number)).call(i,eP);return new PU(l,f,d,v,c)}function KU(e){var t=new ZN(e).decimalFloatingPoint("TIME-OFFSET");return oO(t)?t:null}function HU(e,t){var r,i,n=rT(r=(e||"").split(/[ ,]+/)).call(r,(function(e){return e}));vd(i=["video","audio","text"]).call(i,(function(e){var r=rT(n).call(n,(function(t){return function(e,t){var r=OO[t];return!!r&&!!r[ag(e).call(e,0,4)]}(t,e)}));r.length&&(t["".concat(e,"Codec")]=r.join(","),n=rT(n).call(n,(function(e){return-1===_v(r).call(r,e)})))})),t.unknownCodecs=n}function VU(e,t,r){var i=t[r];i&&(e[r]=i)}function jU(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function YU(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function qU(e,t,r){var i;e.levelkeys=t;var n=r.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!cS(i=zf(t)).call(i,(function(e){return t[e].isCommonEncryption}))||n.push(e)}function WU(e,t){var r=t.startPTS;if(oO(r)){var i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}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 zU(e,t,r,i,n,a){i-r<=0&&(CO.warn("Fragment should have a positive duration",t),i=r+t.duration,a=n+t.duration);var s=r,o=i,l=t.startPTS,u=t.endPTS;if(oO(l)){var c=Math.abs(l-r);oO(t.deltaPTS)?t.deltaPTS=Math.max(c,t.deltaPTS):t.deltaPTS=c,s=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),o=Math.min(i,u),i=Math.max(i,u),a=Math.max(a,t.endDTS)}var h=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=s,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=a;var d,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,g=e.fragments;for(g[v]=t,d=v;d>0;d--)WU(g[d],g[d-1]);for(d=v;d<g.length-1;d++)WU(g[d],g[d+1]);return e.fragmentHint&&WU(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function XU(e,t){for(var r,i=null,n=e.fragments,a=n.length-1;a>=0;a--){var s=n[a].initSegment;if(s){i=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var o,l=0;!function(e,t,r){for(var i,n,a=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,o=(e.fragmentHint?1:0)+(a?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,l=t.startSN-e.startSN,u=t.fragmentHint?_d(i=t.fragments).call(i,t.fragmentHint):t.fragments,c=e.fragmentHint?_d(n=e.fragments).call(n,e.fragmentHint):e.fragments,h=s;h<=o;h++){var d=c[l+h],f=u[h];a&&!f&&d&&(f=t.fragments[h]=d),d&&f&&r(d,f)}}(e,t,(function(e,r){e.relurl&&(l=e.cc-r.cc),oO(e.startPTS)&&oO(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,i=e.initSegment)}));var u,c=t.fragmentHint?_d(r=t.fragments).call(r,t.fragmentHint):t.fragments;if(i&&vd(c).call(c,(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)})),t.skippedSegments)if(t.deltaUpdateFailed=cS(u=t.fragments).call(u,(function(e){return!e})),t.deltaUpdateFailed){CO.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=t.skippedSegments;h--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC||(t.startCC=t.fragments[0].cc)}else{var d;t.canSkipDateRanges&&(t.dateRanges=function(e,t){var r=t.dateRanges,i=t.recentlyRemovedDateranges,n=AO({},e);i&&vd(i).call(i,(function(e){delete n[e]}));var a,s=zf(n).length;s&&vd(a=zf(r)).call(a,(function(e){var t=n[e],i=new tU(r[e].attr,t);i.isValid?(n[e]=i,t||(i.tagOrder+=s)):CO.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(KI(r[e].attr),'"'))}));return n}(e.dateRanges,t));var f=rT(d=e.fragments).call(d,(function(e){return e.rawProgramDateTime}));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var v=1;v<c.length;v++)null===c[v].programDateTime&&jU(c[v],c[v-1],f);UU(f,t)}var g=t.fragments;if(l){CO.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<g.length;p++)g[p].cc+=l}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),o?zU(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):QU(e,t),g.length&&(t.totalduration=t.edge-g[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var y=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=y),t.driftEndTime=m,t.driftEnd=y}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function QU(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,a=i>=0,s=0;if(a&&i<n.length)s=n[i].start;else if(a&&t.startSN===e.endSN+1)s=e.fragmentEnd;else if(a&&r)s=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;s=e.fragmentStart}$U(t,s)}function $U(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function JU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function ZU(e,t,r){return e?eB(e.partList,t,r):null}function eB(e,t,r){if(e)for(var i=e.length;i--;){var n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function tB(e){vd(e).call(e,(function(e,t){var r,i=null==(r=e.details)?void 0:r.fragments;i&&vd(i).call(i,(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function rB(e,t){for(var r=0,i=e.length;r<i;r++){var n;if((null==(n=e[r])?void 0:n.cc)===t)return e[r]}return null}function iB(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function nB(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)iB(r[i],e);t.fragmentHint&&iB(t.fragmentHint,e),t.alignedSliding=!0}function aB(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var r=Math.min(t.endCC,e.endCC),i=rB(t.fragments,r),n=rB(e.fragments,r);if(i&&n)CO.log("Aligning playlist at start of dicontinuity sequence ".concat(r)),nB(i.start-n.start,e)}}function sB(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n,a,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(n=rB(i,s),a=rB(r,s)),n&&a||(a=rB(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,l=a.programDateTime;if(o&&l)nB((l-o)/1e3-(a.start-n.start),e)}}}var oB=function(e){for(var t="",r=e.length,i=0;i<r;i++){var n;t+=_d(n="[".concat(e.start(i).toFixed(3),"-")).call(n,e.end(i).toFixed(3),"]")}return t},lB="STOPPED",uB="IDLE",cB="KEY_LOADING",hB="FRAG_LOADING",dB="FRAG_LOADING_WAITING_RETRY",fB="WAITING_TRACK",vB="PARSING",gB="PARSED",pB="ENDED",mB="ERROR",yB="WAITING_INIT_PTS",EB="WAITING_LEVEL",kB=function(e){Ch(i,e);var r=ed(i);function i(e,n,a,s,o){var l;return t(this,i),(l=r.call(this,s,e.logger)).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=lB,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var e,t=Zh(l),r=t.config,i=t.fragCurrent,n=t.media,a=t.mediaBuffer,s=t.state,o=n?n.currentTime:0,u=YN.bufferInfo(a||n,o,r.maxBufferHole);if(l.log(_d(e="media seeking to ".concat(oO(o)?o.toFixed(3):o,", state: ")).call(e,s)),l.state===pB)l.resetLoadingState();else if(i){var c=r.maxFragLookUpTolerance,h=i.start-c,d=i.start+i.duration+c;if(!u.len||d<u.start||h>u.end){var f=o>d;(o<h||f)&&(f&&i.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(n&&(l.fragmentTracker.removeFragmentsInRange(o,1/0,l.playlistType,!0),o>l.lastCurrentTime&&(l.lastCurrentTime=o),!l.loadingParts)){var v,g=Math.max(u.end,o),p=l.shouldLoadParts(l.getLevelDetails(),g);if(p)l.log(_d(v="LL-Part loading ON after seeking to ".concat(o.toFixed(2)," with buffer @")).call(v,g.toFixed(2))),l.loadingParts=p}l.hls.hasEnoughToStart||u.len||(l.log("setting startPosition to ".concat(o," because of seek before start")),l.nextLoadPosition=l.startPosition=o),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0,l.triggerEnded()},l.playlistType=o,l.hls=e,l.fragmentLoader=new UN(e.config),l.keyLoader=a,l.fragmentTracker=n,l.config=e.config,l.decrypter=new FN(e.config),l}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.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!==lB){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=lB}}},{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,i=e.nextStart,n=i&&(!r||i<t.edge);if(t.live||n||!e.end||!this.media)return!1;var a=t.partList;if(null!=a&&a.length){var s=a[a.length-1];return YN.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 i=this.config;this.levels&&i.autoStartLoad&&this.state===lB&&this.startLoad(i.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;null!==i&&(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),i.removeEventListener("seeking",this.onMediaSeeking),i.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),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=lB,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,Ih(Rh(i.prototype),"onHandlerDestroyed",this).call(this)}},{key:"loadFragment",value:function(e,t,r){var i=this.hls.config;if(i.interstitialsController&&!1!==i.enableInterstitialPlayback&&e.type!==EO){var n=this.hls.interstitialsManager,a=null==n?void 0:n.bufferingItem;if(a){var s=a.event;if(s){if(s.appendInPlace||Math.abs(e.start-a.start)>1||0===a.start)return}else{var o;if(e.end<=a.start&&!1===(null==(o=t.details)?void 0:o.live))return;if(e.start>a.end&&a.nextEvent)return}}}this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}},{key:"_loadFragForPlayback",value:function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(e){var t,r,n,a=e.frag;if(i.fragContextChanged(a))return i.warn(_d(t=_d(r=_d(n="".concat(a.type," sn: ")).call(n,a.sn)).call(r,e.part?" part: "+e.part.index:""," of ")).call(t,i.fragInfo(a,!1,e.part),") was dropped during download.")),void i.fragmentTracker.removeFragment(a);a.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){var t=i.state,r=e.frag;if(i.fragContextChanged(r))(t===hB||!i.fragCurrent&&t===vB)&&(i.fragmentTracker.removeFragment(r),i.state=uB);else{var n,a,s;if("payload"in e)i.log(_d(n=_d(a=_d(s="Loaded ".concat(r.type," sn: ")).call(s,r.sn," of ")).call(a,i.playlistLabel()," ")).call(n,r.level)),i.hls.trigger(dO.FRAG_LOADED,e);i._handleFragmentLoadComplete(e)}}})).catch((function(t){i.state!==lB&&i.state!==mB&&(i.warn("Frag error: ".concat((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))}))}},{key:"clearTrackerIfNeeded",value:function(e){var t,r=this.fragmentTracker;if(r.getState(e)===OF){var i=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=Math.max(e.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(a,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)===FF&&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(dO.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,i=e.frag,n=e.payload,a=i.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&iU(a.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,nU(a.method)).catch((function(e){throw t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(n){var a=self.performance.now();return t.trigger(dO.FRAG_DECRYPTED,{frag:i,payload:n,stats:{tstart:s,tdecrypt:a}}),e.payload=n,r.completeInitSegmentLoad(e)}))}return r.completeInitSegmentLoad(e)})).catch((function(t){r.state!==lB&&r.state!==mB&&(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!==lB&&(this.state=uB),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,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(_d(r=_d(i=_d(n=_d(a="Buffered ".concat(e.type," sn: ")).call(a,e.sn)).call(n,t?" part: "+t.index:""," of ")).call(i,this.fragInfo(e,!1,t)," > buffer:")).call(r,s?oB(YN.getBuffered(s)):"(detached)",")")),lN(e)){var o;if(e.type!==EO){var l,u=e.elementaryStreams;if(!cS(l=zf(u)).call(l,(function(e){return!!u[e]})))return void(this.state=uB)}var c=null==(o=this.levels)?void 0:o[e.level];null!=c&&c.fragmentError&&(this.log("Resetting level fragment error count of ".concat(c.fragmentError," on frag buffered")),c.fragmentError=0)}this.state=uB}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||cS(n).call(n,(function(e){return!e})),s=new VN(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t){var r,i,n,a,s,o,l=this,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,c=arguments.length>3?arguments[3]:void 0;this.fragCurrent=e;var h=null==t?void 0:t.details;if(!this.levels||!h)throw new Error("frag load aborted, missing level".concat(h?"":" detail","s"));var d,f,v,g,p=null;!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&h.encryptedFragments.length&&this.keyLoader.loadClear(e,h.encryptedFragments):(this.log(_d(d=_d(f=_d(v=_d(g="Loading key for ".concat(e.sn," of [")).call(g,h.startSN,"-")).call(v,h.endSN,"], ")).call(f,this.playlistLabel()," ")).call(d,e.level)),this.state=cB,this.fragCurrent=e,p=this.keyLoader.load(e).then((function(e){if(!l.fragContextChanged(e.frag))return l.hls.trigger(dO.KEY_LOADED,e),l.state===cB&&(l.state=uB),e})),this.hls.trigger(dO.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(p=Lk.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var m=this.fragPrevious;if(lN(e)&&(!m||e.sn!==m.sn)){var y,E,k=this.shouldLoadParts(t.details,e.end);if(k!==this.loadingParts)this.log(_d(y=_d(E="LL-Part loading ".concat(k?"ON":"OFF"," loading sn ")).call(E,null==m?void 0:m.sn,"->")).call(y,e.sn)),this.loadingParts=k}if(u=Math.max(e.start,u||0),this.loadingParts&&lN(e)){var T=h.partList;if(T&&c){u>e.end&&h.fragmentHint&&(e=h.fragmentHint);var S=this.getNextPart(T,e,u);if(S>-1){var A,L,b,R,I,D,_,w,P,C,x=T[S];return e=this.fragCurrent=x.fragment,this.log(_d(A=_d(L=_d(b=_d(R=_d(I=_d(D=_d(_=_d(w=_d(P="Loading ".concat(e.type," sn: ")).call(P,e.sn," part: ")).call(w,x.index," (")).call(_,S,"/")).call(D,T.length-1,") of ")).call(I,this.fragInfo(e,!1,x),") cc: ")).call(R,e.cc," [")).call(b,h.startSN,"-")).call(L,h.endSN,"], target: ")).call(A,zS(u.toFixed(3)))),this.nextLoadPosition=x.start+x.duration,this.state=hB,C=p?p.then((function(r){return!r||l.fragContextChanged(r.frag)?null:l.doFragPartsLoad(e,x,t,c)})).catch((function(e){return l.handleFragLoadError(e)})):this.doFragPartsLoad(e,x,t,c).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(dO.FRAG_LOADING,{frag:e,part:x,targetBufferTime:u}),null===this.fragCurrent?Lk.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):C}if(!e.url||this.loadedEndOfParts(T,u))return Lk.resolve(null)}}if(lN(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(u.toFixed(2))),this.loadingParts=!1;else if(!e.url)return Lk.resolve(null);this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Loading ".concat(e.type," sn: ")).call(s,e.sn," of ")).call(a,this.fragInfo(e,!1),") cc: ")).call(n,e.cc," ")).call(i,h?"["+h.startSN+"-"+h.endSN+"]":"",", target: ")).call(r,zS(u.toFixed(3)))),oO(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=hB;var M,O=this.config.progressive;return M=O&&p?p.then((function(t){return!t||l.fragContextChanged(null==t?void 0:t.frag)?null:l.fragmentLoader.load(e,c)})).catch((function(e){return l.handleFragLoadError(e)})):Lk.all([this.fragmentLoader.load(e,O?c:void 0),p]).then((function(e){var t=cD(e,1)[0];return!O&&t&&c&&c(t),t})).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(dO.FRAG_LOADING,{frag:e,targetBufferTime:u}),null===this.fragCurrent?Lk.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):M}},{key:"doFragPartsLoad",value:function(e,t,r,i){var n=this;return new Lk((function(a,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function t(o){n.fragmentLoader.loadPart(e,o,i).then((function(i){l[o.index]=i;var s=i.part;n.hls.trigger(dO.FRAG_LOADED,i);var c=ZU(r.details,e.sn,o.index+1)||eB(u,e.sn,o.index+1);if(!c)return a({frag:e,part:s,partsLoaded:l});t(c)})).catch(s)}(t)}))}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;e.data&&t.details===hO.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(dO.ERROR,t)}else this.hls.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===vB){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a);var s,o=this.getLevelDetails(),l=o&&r.sn>o.endSN||this.shouldLoadParts(o,r.end);if(l!==this.loadingParts)this.log(_d(s="LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @")).call(s,r.end.toFixed(2))),this.loadingParts=l;this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===lB||this.state===mB||(this.state=uB)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var r,i,n=e.partList[0];if(t>=n.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0))if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t,r,i=this.levels,n=this.fragCurrent,a=e.level,s=e.sn,o=e.part;if(null==i||!i[a])return this.warn(_d(t=_d(r="Levels object was unset while buffering fragment ".concat(s," of ")).call(r,this.playlistLabel()," ")).call(t,a,". The current chunk will not be buffered.")),null;var l=i[a],u=l.details,c=o>-1?ZU(u,s,o):null,h=c?c.fragment:function(e,t,r){if(!e)return null;var i=e.fragments[t-e.startSN];return i||((i=e.fragmentHint)&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}(u,s,n);return h?(n&&n!==h&&(h.stats=n.stats),{frag:h,part:c,level:l}):null}},{key:"bufferFragmentData",value:function(e,t,r,i,n){var a;if(e&&this.state===vB){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=_N(s,o)),null!=(a=l)&&a.length){var u={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};if(this.hls.trigger(dO.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(YN.isBuffered(t,t.currentTime)){var r=t.currentTime,i=YN.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),s=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-s>a&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var r,i=this.getLoadPosition();if(!oO(i))return null;var n=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,n)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,r,i){var n=YN.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&(n.nextStart<=a.end||a.gap))return YN.bufferInfo(e,t,Math.max(n.nextStart,i))}return n}},{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,i=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn("Reduce max buffer length to ".concat(n,"s")),!0)}},{key:"getAppendedFrag",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:mO,i=null==(t=this.fragmentTracker)?void 0:t.getAppendedFrag(e,r);return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n=this.config,a=r[0].start,s=n.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l,u=n.initialLiveManifestSize;if(i<u)return this.warn(_d(l="Not enough fragments to start playback (have: ".concat(i,", need: ")).call(l,u,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a){var c,h,d,f;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,r);var v=this.hls.startPosition,g=this.hls.liveSyncPosition,p=o?(-1!==v?v:g)||o.start:e;this.log(_d(c=_d(h=_d(d="Setting startPosition to ".concat(p," to match initial live edge. mainStart: ")).call(d,v," liveSyncPosition: ")).call(h,g," frag.start: ")).call(c,null==(f=o)?void 0:f.start)),this.startPosition=this.nextLoadPosition=p}}else e<=a&&(o=r[0]);if(!o){var m=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,m,t)}return this.mapToInitFragWhenRequired(o)}},{key:"isLoopLoading",value:function(e,t){var r=this.fragmentTracker.getState(e);return(r===NF||r===FF&&!!e.gap)&&this.nextLoadPosition>t}},{key:"getNextFragmentLoopLoading",value:function(e,t,r,i,n){var a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t))&&!a.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==s&&r.len+s.len>=n){var o,l=a.sn;if(this.loopSn!==l)this.log(_d(o='buffer full after gaps in "'.concat(i,'" playlist starting at sn: ')).call(o,l)),this.loopSn=l;return null}}return this.loopSn=void 0,a}},{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 i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(n||l.independent||a)&&l.fragment===t&&(i=s),n=u}return i}},{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,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime)),i=function(e,t,r){if(null===t||!tT(e)||!e.length||!oO(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 i=0;i<e.length;++i){var n=e[i];if(yF(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: ".concat(i.sn)))}i||(i=EF(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}},{key:"getFragmentAtPosition",value:function(e,t,r){var i,n,a=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=a.maxFragLookUpTolerance,h=r.partList,d=!!(this.loadingParts&&null!=h&&h.length&&u);(d&&u&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=_d(o).call(o,u),l=u.sn),e<t)?i=pF(s,o,e,e<this.lastCurrentTime||e>t-c||null!=(n=this.media)&&n.paused||!this.startFragRequested?0:c):i=o[o.length-1];if(i){var f=i.sn-r.startSN,v=this.fragmentTracker.getState(i);if((v===NF||v===FF&&i.gap)&&(s=i),s&&i.sn===s.sn&&(!d||h[0].fragment.sn>i.sn||!r.live&&!d))if(s&&i.level===s.level){var g=o[f+1];i=i.sn<l&&this.fragmentTracker.getState(g)!==NF?g:null}}return i}},{key:"alignPlaylists",value:function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var n=e.fragmentStart,a=!t,s=e.alignedSliding&&oO(n);if(a||!s&&!n){var o,l,u;!function(e,t){e&&(aB(t,e),!t.alignedSliding&&e&&sB(t,e),t.alignedSliding||!e||t.skippedSegments||QU(e,t,!1))}(r,e);var c=e.fragmentStart;return this.log(_d(o=_d(l=_d(u="Live playlist sliding: ".concat(c.toFixed(2)," start-sn: ")).call(u,t?t.startSN:"na","->")).call(l,e.startSN," fragments: ")).call(o,i)),c}return n}},{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 i,n,a=null!==this.startTimeOffset,s=a?this.startTimeOffset:e.startTimeOffset;if(null!==s&&oO(s))r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(_d(i=_d(n="Setting startPosition to ".concat(r," for start time offset ")).call(n,s," found in ")).call(i,a?"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,i,n;this.transmuxer&&e.type===this.playlistType&&lN(e)&&e.stats.aborted&&(this.warn(_d(r=_d(i=_d(n="Fragment ".concat(e.sn)).call(n,t?" part "+t.index:""," of ")).call(i,this.playlistLabel()," ")).call(r,e.level," was aborted")),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===dB)||(this.state=uB)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var n,a;this.warn(_d(n="Frag load error must match current frag to retry ".concat(i.url," > ")).call(n,null==(a=this.fragCurrent)?void 0:a.url))}else{var s=t.details===hO.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);var o=t.errorAction,l=o||{},u=l.action,c=IP(l),h=l.retryCount,d=void 0===h?0:h,f=l.retryConfig,v=!!o&&!!f,g=v&&u===DF,p=v&&!o.resolved&&c===wF;if(!g&&p&&lN(i)&&!i.endList)this.resetFragmentErrors(e),this.treatAsGap(i),o.resolved=!0;else if((g||p)&&d<f.maxNumRetry){var m,y,E,k,T,S;this.resetStartWhenNotLoaded(this.levelLastLoaded);var A=SF(f,d);this.warn(_d(m=_d(y=_d(E=_d(k=_d(T=_d(S="Fragment ".concat(i.sn," of ")).call(S,e," ")).call(T,i.level," errored with ")).call(k,t.details,", retrying loading ")).call(E,d+1,"/")).call(y,f.maxNumRetry," in ")).call(m,A,"ms")),o.resolved=!0,this.retryDate=self.performance.now()+A,this.state=dB}else if(f&&o){var L;if(this.resetFragmentErrors(e),!(d<f.maxNumRetry))return void this.warn(_d(L="".concat(t.details," reached or exceeded max retry (")).call(L,d,")"));s||u===IF||(o.resolved=!0)}else this.state=u===RF?EB:mB;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===vB||this.state===gB){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var a=!n;return a&&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(),a}return!1}},{key:"resetFragmentErrors",value:function(e){e===yO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==lB&&(this.state=uB)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var i=YN.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===pB&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==lB&&(this.state=uB)}},{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(_d(t=_d(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,i){var n,a,s,o,l,u=this,c=r.details;if(c){if(!mP(n=zf(e.elementaryStreams)).call(n,(function(t,n){var a=e.elementaryStreams[n];if(a){var s,o,l=a.endPTS-a.startPTS;if(l<=0)return u.warn(_d(s=_d(o="Could not parse fragment ".concat(e.sn," ")).call(o,n," duration reliably (")).call(s,l,")")),t||!1;var h=i?0:zU(c,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return u.hls.trigger(dO.LEVEL_PTS_UPDATED,{details:c,level:r,drift:h,type:n,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t}),!1)&&null===(null==(l=this.transmuxer)?void 0:l.error)){var h,d,f,v,g=new Error(_d(h=_d(d="Found no media in fragment ".concat(e.sn," of ")).call(d,this.playlistLabel()," ")).call(h,e.level," resetting transmuxer to fallback to playlist timing"));if(0===r.fragmentError&&this.treatAsGap(e,r),this.warn(g.message),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!1,error:g,frag:e,reason:_d(f=_d(v="Found no media in msn ".concat(e.sn," of ")).call(v,this.playlistLabel(),' "')).call(f,r.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=gB,this.log(_d(a=_d(s=_d(o="Parsed ".concat(e.type," sn: ")).call(o,e.sn)).call(s,t?" part: "+t.index:""," of ")).call(a,this.fragInfo(e,!1,t),")")),this.hls.trigger(dO.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===mO?"level":"track"}},{key:"fragInfo",value:function(e){var t,r,i,n,a,s,o,l=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],u=arguments.length>2?arguments[2]:void 0;return _d(t=_d(r=_d(i=_d(n=_d(a="".concat(this.playlistLabel()," ")).call(a,e.level," (")).call(n,u?"part":"frag",":[")).call(i,(null!=(s=l&&!u?e.startPTS:(u||e).start)?s:NaN).toFixed(3),"-")).call(r,(null!=(o=l&&!u?e.endPTS:(u||e).end)?o:NaN).toFixed(3),"]")).call(t,u&&"main"===e.type?"INDEPENDENT="+(u.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(_d(t="".concat(r,"->")).call(t,e)))}}]),i}(HN),TB=function(){function e(){t(this,e),this.chunks=[],this.dataLength=0}return Fc(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]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}]),e}();var SB={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||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 i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}bT&&(i.prototype=bT(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?ag(i).call(i,1):i);return yT?_d(n).call(n,yT(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,a),!0;case 6:return c.fn.call(c.context,t,i,n,a,s),!0}for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),h){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,i);break;case 4:c[u].fn.call(c[u].context,t,i,n);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var l=0,u=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}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 i,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}(SB);var AB=XF(SB.exports),LB="1.6.0-beta.2",bB={};function RB(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 IB(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 DB(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 _B(e,t){for(var r=t,i=0;IB(e,t);){i+=10,i+=DB(e,t+6),RB(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function wB(e,t){return 255===e[t]&&240==(246&e[t+1])}function PB(e,t){return 1&e[t+1]?7:9}function CB(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function xB(e,t){return t+1<e.length&&wB(e,t)}function MB(e,t){if(xB(e,t)){var r=PB(e,t);if(t+r>=e.length)return!1;var i=CB(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||xB(e,n)}return!1}function OB(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i){var n,a,s,o,l,u=t[r+2],c=u>>2&15;if(!(c>12)){var h=1+(u>>6&3),d=t[r+3]>>6&3|(1&u)<<2,f="mp4a.40."+h,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][c],g=c;5!==h&&29!==h||(g-=3);var p=[h<<3|(14&g)>>1,(1&g)<<7|d<<3];return CO.log(_d(n=_d(a=_d(s=_d(o=_d(l="manifest codec:".concat(i,", parsed codec:")).call(l,f,", channels:")).call(o,d,", rate:")).call(s,v," (ADTS object type:")).call(a,h," sampling index:")).call(n,c,")")),{config:p,samplerate:v,channelCount:d,codec:f,parsedCodec:f,manifestCodec:i}}var m=new Error("invalid ADTS sampling index:".concat(c));e.emit(dO.ERROR,dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!0,error:m,reason:m.message})}(t,r,i,n);if(!a)return;AO(e,a)}}function FB(e){return 9216e4/e}function NB(e,t,r,i,n){var a,s=i+n*FB(e.samplerate),o=function(e,t){var r=PB(e,t);if(t+r<=e.length){var i=CB(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var l=o.frameLength,u=o.headerLength,c=u+l,h=Math.max(0,r+c-t.length);h?(a=new Uint8Array(c-u)).set(t.subarray(r+u,t.length),0):a=t.subarray(r+u,r+c);var d={unit:a,pts:s};return h||e.samples.push(d),{sample:d,length:c,missing:h}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}function UB(e,t){return IB(e,t)&&DB(e,t+6)+10<=e.length-t}function BB(e){return function(e,t,r,i){var n=(s=e,s instanceof ArrayBuffer?s:s.buffer),a=1;var s;"BYTES_PER_ELEMENT"in i&&(a=i.BYTES_PER_ELEMENT);var o=(d=e,d&&d.buffer instanceof ArrayBuffer&&void 0!==d.byteLength&&void 0!==d.byteOffset?e.byteOffset:0),l=(o+e.byteLength)/a,u=(o+t)/a,c=Math.floor(Math.max(0,Math.min(u,l))),h=Math.floor(Math.min(c+Math.max(r,0),l));var d;return new i(n,c,h-c)}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,Uint8Array)}function GB(e,t){if(e<0)return-GB(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<JP){var i=Math.floor(e*r);return(i%2==0?i:i+1)/r}return Math.round(e*r)/r}function KB(e){var t,r,i={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var n=_v(t=e.data.subarray(1)).call(t,0);if(-1!==n){var a=WF(BB(e.data,1,n)),s=e.data[2+n],o=_v(r=e.data.subarray(3+n)).call(r,0);if(-1!==o){var l,u,c=WF(BB(e.data,3+n,o));return l="--\x3e"===a?WF(BB(e.data,4+n+o)):(u=e.data.subarray(4+n+o))instanceof ArrayBuffer?u:0==u.byteOffset&&u.byteLength==u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer,i.mimeType=a,i.pictureType=s,i.description=c,i.data=l,i}}}else console.log("Ignore frame with unrecognized character encoding")}function HB(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=WF(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=WF(e.data.subarray(t),!0);t+=r.length+1;var i=WF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=WF(e.data);return{key:e.type,info:"",data:n}}(e):"APIC"===e.type?KB(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=WF(e.data.subarray(t),!0);t+=r.length+1;var i=WF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=WF(e.data.subarray(1));return{key:e.type,info:"",data:n}}}(e)}function VB(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=DB(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var jB=10,YB=10;function qB(e){for(var t=0,r=[];IB(e,t);){var i=DB(e,t+6);e[t+5]>>6&1&&(t+=jB);for(var n=(t+=jB)+i;t+YB<n;){var a=VB(e.subarray(t)),s=HB(a);s&&r.push(s),t+=a.size+jB}RB(e,t)&&(t+=jB)}return r}function WB(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function zB(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function XB(e){for(var t=qB(e),r=0;r<t.length;r++){var i=t[r];if(WB(i))return zB(i)}}var QB=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 $B(){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 JB=function(){function e(){t(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 Fc(e,[{key:"resetInitSegment",value:function(e,t,r,i){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=_N(this.cachedData,e),this.cachedData=null);var r,i=_B(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?XB(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&oO(o))&&(this.basePTS=ZB(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:QB.audioId3,duration:Number.POSITIVE_INFINITY});n<l;){if(this.canParse(e,n)){var u=this.appendFrame(a,e,n);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r=n+=u.length):n=l}else UB(e,n)?(i=_B(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:QB.audioId3,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===l&&r!==l){var c=jF(e,r);this.cachedData?this.cachedData=_N(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:$B(),id3Track:s,textTrack:$B()}}},{key:"demuxSampleAes",value:function(e,t,r){return Lk.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:$B(),id3Track:this._id3Track,textTrack:$B()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),ZB=function(e,t,r){return oO(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},eG=null,tG=[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],rG=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],iG=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],nG=[0,1,1,4];function aG(e,t,r,i,n){if(!(r+24>t.length)){var a=sG(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function sG(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*tG[14*(3===r?3-i:3===i?3:4)+n-1],u=rG[3*(3===r?0:2===r?1:2)+a],c=3===o?1:2,h=iG[r][i],d=nG[i],f=8*h*d,v=Math.floor(h*l/u+s)*d;if(null===eG){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);eG=g?qk(g[1]):0}return!!eG&&eG<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:c,frameLength:v,samplesPerFrame:f}}}function oG(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function lG(e,t){return t+1<e.length&&oG(e,t)}function uG(e,t){if(t+1<e.length&&oG(e,t)){var r=sG(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||lG(e,n)}return!1}var cG=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this)).observer=void 0,a.config=void 0,a.observer=e,a.config=n,a}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&wB(e,t)&&CB(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){OB(e,this.observer,t,r,e.manifestCodec);var i=NB(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}}],[{key:"probe",value:function(e,t){if(!e)return!1;var r=_B(e,0),i=(null==r?void 0:r.length)||0;if(uG(e,i))return!1;for(var n=e.length;i<n;i++)if(MB(e,i))return t.log("ADTS sync word found !"),!0;return!1}}]),i}(JB),hG=function(e,t){var r=0,i=5;t+=i;for(var n=new Uint32Array(1),a=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),l=8-o;a[0]=4278190080>>>24+l<<l,n[0]=(s[0]&a[0])>>l,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r},dG=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this)).observer=void 0,n.observer=e,n}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,r){var i=fG(e,t,r,this.basePTS,this.frameIndex);if(-1!==i)return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=_B(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==XB(t)&&hG(e,r)<16}}]),i}(JB);function fG(e,t,r,i,n){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;var a=t[r+4]>>6;if(a>=3)return-1;var s=[48e3,44100,32e3][a],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+a];if(r+l>t.length)return-1;var u=t[r+6]>>5,c=0;2===u?c+=2:(1&u&&1!==u&&(c+=2),4&u&&(c+=2));var h=(t[r+6]<<8|t[r+7])>>12-c&1,d=[2,1,2,3,3,4,4,5][u]+h,f=t[r+5]>>3,v=7&t[r+5],g=new Uint8Array([a<<6|f<<1|v>>2,(3&v)<<6|u<<3|h<<2|o>>4,o<<4&224]),p=i+n*(1536/s*9e4),m=t.subarray(r,r+l);return e.config=g,e.channelCount=d,e.samplerate=s,e.samples.push({unit:m,pts:p}),l}var vG=function(e){Ch(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return oG(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return aG(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=_B(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==XB(t)&&hG(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(uG(e,r))return CO.log("MPEG Audio sync word found !"),!0;return!1}}]),i}(JB),gG=/\/emsg[-/]ID3/i,pG=function(){function e(r,i){t(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=i}return Fc(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,i){var n=this.videoTrack=$B("video",1),a=this.audioTrack=$B("audio",1),s=this.txtTrack=$B("text",1);if(this.id3Track=$B("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=SN(e);if(o.video){var l=o.video,u=l.id,c=l.timescale,h=l.codec;n.id=u,n.timescale=s.timescale=c,n.codec=h}if(o.audio){var d=o.audio,f=d.id,v=d.timescale,g=d.codec;a.id=f,a.timescale=v,a.codec=g}s.id=fN.text,n.sampleDuration=0,n.duration=a.duration=i}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=_N(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=kN(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=jF(e,0,i.byteOffset-8),t.remainder=jF(e,i.byteOffset-8),t}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return n.samples=wN(t,i),{videoTrack:i,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 i=this.extractID3Track(t,this.timeOffset);return r.samples=wN(e,t),{videoTrack:t,audioTrack:$B(),id3Track:i,textTrack:$B()}}},{key:"extractID3Track",value:function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var n=kN(e.samples,["emsg"]);n&&vd(n).call(n,(function(e){var n,a=function(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==vN(e.subarray(u,u+1));)r+=vN(e.subarray(u,u+1)),u+=1;for(r+=vN(e.subarray(u,u+1)),u+=1;"\0"!==vN(e.subarray(u,u+1));)i+=vN(e.subarray(u,u+1)),u+=1;i+=vN(e.subarray(u,u+1)),u+=1,n=pN(e,12),a=pN(e,16),o=pN(e,20),l=pN(e,24),u=28}else if(1===t){n=pN(e,u+=4);var c=pN(e,u+=4),h=pN(e,u+=4);for(u+=4,s=Math.pow(2,32)*c+h,lO(s)||(s=aP,CO.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=pN(e,u),l=pN(e,u+=4),u+=4;"\0"!==vN(e.subarray(u,u+1));)r+=vN(e.subarray(u,u+1)),u+=1;for(r+=vN(e.subarray(u,u+1)),u+=1;"\0"!==vN(e.subarray(u,u+1));)i+=vN(e.subarray(u,u+1)),u+=1;i+=vN(e.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(u,e.byteLength)}}(e);if(gG.test(a.schemeIdUri)){var s=mG(a,t),o=4294967295===a.eventDuration?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;o<=.001&&(o=Number.POSITIVE_INFINITY);var l=a.payload;i.samples.push({data:l,len:l.byteLength,dts:s,pts:s,type:QB.emsg,duration:o})}else if(r.config.enableEmsgKLVMetadata&&rD(n=a.schemeIdUri).call(n,"urn:misb:KLV:bin:1910.1")){var u=mG(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:u,pts:u,type:QB.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return i}},{key:"demuxSampleAes",value:function(e,t,r){return Lk.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 function(e){for(var t=e.byteLength,r=0;r<t;){var i=pN(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}}]),e}();function mG(e,t){return oO(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var yG=function(){function e(r,i,n){t(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new FN(i,{removePKCS7Padding:!1})}return Fc(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,KF)}},{key:"decryptAacSample",value:function(e,t,r){var i,n=this,a=e[t].unit;if(!(a.length<=16)){var s=a.subarray(16,a.length-a.length%16),o=ag(i=s.buffer).call(i,s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(o).then((function(i){var s=new Uint8Array(i);a.set(s,16),n.decrypter.isSync()||n.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),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e}},{key:"decryptAvcSample",value:function(e,t,r,i,n){var a=this,s=xN(n.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){n.data=a.getAvcDecryptedUnit(s,o),a.decrypter.isSync()||a.decryptAvcSamples(e,t,r+1,i)}))}},{key:"decryptAvcSamples",value:function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,r,i,a),this.decrypter.isSync())))return}}}}]),e}(),EG=function(){function e(){t(this,e),this.VideoSample=null}return Fc(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,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var n=i.units;r=n[n.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,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,r){var i,n,a=t.byteLength,s=e.naluState||0,o=s,l=[],u=0,c=-1,h=0;for(-1===s&&(c=0,h=this.getNALuType(t,0),s=0,u=1);u<a;)if(i=t[u++],s)if(1!==s)if(i)if(1===i){if(n=u-s-1,c>=0){var d={data:t.subarray(c,n),type:h};l.push(d)}else{var f=this.getLastNalUnit(e.samples);f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),n>0&&(f.data=_N(f.data,t.subarray(0,n)),f.state=0))}u<a?(c=u,h=this.getNALuType(t,u),s=0):s=-1}else s=0;else s=3;else s=i?0:2;else s=i?0:1;if(c>=0&&s>=0){var v={data:t.subarray(c,a),type:h,state:s};l.push(v)}if(0===l.length){var g=this.getLastNalUnit(e.samples);g&&(g.data=_N(g.data,t))}return e.naluState=s,l}}]),e}(),kG=function(){function e(r){t(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=r,this.bytesAvailable=r.byteLength,this.word=0,this.bitsAvailable=0}return Fc(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}},{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&&CO.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}(),TG=function(e){Ch(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),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)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 1:var c=!1;n=!0;var h,d=i.data;if(l&&d.length>4){var f=a.readSliceType(d);2!==f&&4!==f&&7!==f&&9!==f||(c=!0)}if(c)null!=(h=o)&&h.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=c;break;case 5:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:n=!0,CN(i.data,1,r.pts,t.samples);break;case 7:var v,g;n=!0,l=!0;var p=i.data,m=a.readSPS(p);if(!e.sps||e.width!==m.width||e.height!==m.height||(null==(v=e.pixelRatio)?void 0:v[0])!==m.pixelRatio[0]||(null==(g=e.pixelRatio)?void 0:g[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[p];for(var y=p.subarray(1,4),E="avc1.",k=0;k<3;k++){var T=y[k].toString(16);T.length<2&&(T="0"+T),E+=T}e.codec=E}break;case 8:n=!0,e.pps=[i.data];break;case 9:n=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(a.pushAccessUnit(o,e),o=null),o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts));break;case 12:n=!0;break;default:n=!1}o&&n&&o.units.push(i)})),i&&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 kG(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var r=8,i=8,n=0;n<e;n++)0!==i&&(i=(r+t.readEG()+256)%256),r=0===i?r:i}},{key:"readSPS",value:function(e){var t,r,i,n,a,s,o,l,u,c,h,d=new kG(e),f=0,v=0,g=0,p=0,m=RT(t=d.readUByte).call(t,d),y=RT(r=d.readBits).call(r,d),E=RT(i=d.readUEG).call(i,d),k=RT(n=d.readBoolean).call(n,d),T=RT(a=d.skipBits).call(a,d),S=RT(s=d.skipEG).call(s,d),A=RT(o=d.skipUEG).call(o,d),L=RT(l=this.skipScalingList).call(l,this);m();var b=m();if(y(5),T(3),m(),A(),100===b||110===b||122===b||244===b||44===b||83===b||86===b||118===b||128===b){var R=E();if(3===R&&T(1),A(),A(),T(1),k())for(c=3!==R?8:12,h=0;h<c;h++)k()&&L(h<6?16:64,d)}A();var I=E();if(0===I)E();else if(1===I)for(T(1),S(),S(),u=E(),h=0;h<u;h++)S();A(),T(1);var D=E(),_=E(),w=y(1);0===w&&T(1),T(1),k()&&(f=E(),v=E(),g=E(),p=E());var P=[1,1];if(k()&&k())switch(m()){case 1:P=[1,1];break;case 2:P=[12,11];break;case 3:P=[10,11];break;case 4:P=[16,11];break;case 5:P=[40,33];break;case 6:P=[24,11];break;case 7:P=[20,11];break;case 8:P=[32,11];break;case 9:P=[80,33];break;case 10:P=[18,11];break;case 11:P=[15,11];break;case 12:P=[64,33];break;case 13:P=[160,99];break;case 14:P=[4,3];break;case 15:P=[3,2];break;case 16:P=[2,1];break;case 255:P=[m()<<8|m(),m()<<8|m()]}return{width:Math.ceil(16*(D+1)-2*f-2*v),height:(2-w)*(_+1)*16-(w?2:4)*(g+p),pixelRatio:P}}}]),i}(EG),SG=function(e){Ch(i,e);var r=ed(i);function i(){var e,n;t(this,i);for(var a=arguments.length,s=new Array(a),o=0;o<a;o++)s[o]=arguments[o];return(n=r.call.apply(r,_d(e=[this]).call(e,s))).initVPS=null,n}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),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)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts)),o.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var c;if(n=!0,l)null!=(c=o)&&c.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 39:n=!0,CN(i.data,2,r.pts,t.samples);break;case 32:if(n=!0,!e.vps){var h=a.readVPS(i.data);e.params=bO({},h),a.initVPS=i.data}e.vps=[i.data];break;case 33:if(n=!0,l=!0,"object"===Pc(e.params)){if(void 0===e.vps||e.vps[0]===a.initVPS||void 0===e.sps||a.matchSPS(e.sps[0],i.data)||(a.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=a.readSPS(i.data);for(var f in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],d.params)e.params[f]=d.params[f]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.sps.push(i.data)}o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0;break;case 34:if(n=!0,"object"===Pc(e.params)){if(!e.pps){e.pps=[];var v=a.readPPS(i.data);for(var g in v)e.params[g]=v[g]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.pps.push(i.data)}break;case 35:n=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(a.pushAccessUnit(o,e),o=null),o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts));break;default:n=!1}o&&n&&o.units.push(i)})),i&&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,i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}},{key:"pushAccessUnit",value:function(e,t){Ih(Rh(i.prototype),"pushAccessUnit",this).call(this,e,t),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new kG(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,i,n,a=new kG(this.ebsp2rbsp(e));a.readUByte(),a.readUByte(),a.readBits(4);var s=a.readBits(3);a.readBoolean();for(var o=a.readBits(2),l=a.readBoolean(),u=a.readBits(5),c=a.readUByte(),h=a.readUByte(),d=a.readUByte(),f=a.readUByte(),v=a.readUByte(),g=a.readUByte(),p=a.readUByte(),m=a.readUByte(),y=a.readUByte(),E=a.readUByte(),k=a.readUByte(),T=[],S=[],A=0;A<s;A++)T.push(a.readBoolean()),S.push(a.readBoolean());if(s>0)for(var L=s;L<8;L++)a.readBits(2);for(var b=0;b<s;b++)T[b]&&(a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte()),S[b]&&a.readUByte();a.readUEG();var R=a.readUEG();3==R&&a.skipBits(1);var I=a.readUEG(),D=a.readUEG(),_=a.readBoolean(),w=0,P=0,C=0,x=0;_&&(w+=a.readUEG(),P+=a.readUEG(),C+=a.readUEG(),x+=a.readUEG());for(var M=a.readUEG(),O=a.readUEG(),F=a.readUEG(),N=a.readBoolean()?0:s;N<=s;N++)a.skipUEG(),a.skipUEG(),a.skipUEG();if((a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.readBoolean())&&a.readBoolean())for(var U=0;U<4;U++)for(var B=0;B<(3===U?2:6);B++){if(a.readBoolean()){var G=Math.min(64,1<<4+(U<<1));U>1&&a.readEG();for(var K=0;K<G;K++)a.readEG()}else a.readUEG()}a.readBoolean(),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.skipUEG(),a.skipUEG(),a.readBoolean());for(var H=a.readUEG(),V=0,j=0;j<H;j++){var Y=!1;if(0!==j&&(Y=a.readBoolean()),Y){j===H&&a.readUEG(),a.readBoolean(),a.readUEG();for(var q=0,W=0;W<=V;W++){var z=a.readBoolean(),X=!1;z||(X=a.readBoolean()),(z||X)&&q++}V=q}else{var Q=a.readUEG(),$=a.readUEG();V=Q+$;for(var J=0;J<Q;J++)a.readUEG(),a.readBoolean();for(var Z=0;Z<$;Z++)a.readUEG(),a.readBoolean()}}if(a.readBoolean())for(var ee=a.readUEG(),te=0;te<ee;te++){for(var re=0;re<F+4;re++)a.readBits(1);a.readBits(1)}var ie=0,ne=1,ae=1,se=!0,oe=1,le=0;a.readBoolean(),a.readBoolean();var ue=!1;if(a.readBoolean()){if(a.readBoolean()){var ce=a.readUByte();ce>0&&ce<16?(ne=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ce-1],ae=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ce-1]):255===ce&&(ne=a.readBits(16),ae=a.readBits(16))}if(a.readBoolean()&&a.readBoolean(),a.readBoolean())a.readBits(3),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.readUByte(),a.readUByte());if(a.readBoolean()&&(a.readUEG(),a.readUEG()),a.readBoolean(),a.readBoolean(),a.readBoolean(),(ue=a.readBoolean())&&(w+=a.readUEG(),P+=a.readUEG(),C+=a.readUEG(),x+=a.readUEG()),a.readBoolean())if(oe=a.readBits(32),le=a.readBits(32),a.readBoolean()&&a.readUEG(),a.readBoolean()){var he=a.readBoolean(),de=a.readBoolean(),fe=!1;(he||de)&&((fe=a.readBoolean())&&(a.readUByte(),a.readBits(5),a.readBoolean(),a.readBits(5)),a.readBits(4),a.readBits(4),fe&&a.readBits(4),a.readBits(5),a.readBits(5),a.readBits(5));for(var ve=0;ve<=s;ve++){var ge=!1;(se=a.readBoolean())||a.readBoolean()?a.readEG():ge=a.readBoolean();var pe=ge?1:a.readUEG()+1;if(he)for(var me=0;me<pe;me++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1);if(de)for(var ye=0;ye<pe;ye++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1)}}a.readBoolean()&&(a.readBoolean(),a.readBoolean(),a.readBoolean(),ie=a.readUEG())}var Ee=I,ke=D;if(_||ue){var Te=1,Se=1;1===R?Te=Se=2:2==R&&(Te=2),Ee=I-Te*P-Te*w,ke=D-Se*x-Se*C}for(var Ae=o?["A","B","C"][o]:"",Le=c<<24|h<<16|d<<8|f,be=0,Re=0;Re<32;Re++)be=(be|(Le>>Re&1)<<31-Re)>>>0;var Ie=be.toString(16);1===u&&"2"===Ie&&(Ie="6");var De=l?"H":"L";return{codecString:_d(t=_d(r=_d(i=_d(n="hvc1.".concat(Ae)).call(n,u,".")).call(i,Ie,".")).call(r,De)).call(t,k,".B0"),params:{general_tier_flag:l,general_profile_idc:u,general_profile_space:o,general_profile_compatibility_flags:[c,h,d,f],general_constraint_indicator_flags:[v,g,p,m,y,E],general_level_idc:k,bit_depth:M+8,bit_depth_luma_minus8:M,bit_depth_chroma_minus8:O,min_spatial_segmentation_idc:ie,chroma_format_idc:R,frame_rate:{fixed:se,fps:le/oe}},width:Ee,height:ke,pixelRatio:[ne,ae]}}},{key:"readPPS",value:function(e){var t=new kG(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(),i=t.readBoolean(),n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}]),i}(EG),AG=188,LG=function(){function e(r,i,n,a){t(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=r,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return Fc(e,[{key:"resetInitSegment",value:function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=e.createTrack("audio",n),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=i}},{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 i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];n||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,c=s.pid,h=s.pesData,d=o.pid,f=l.pid,v=o.pesData,g=l.pesData,p=null,m=this.pmtParsed,y=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=_N(this.remainderData,t)).length,this.remainderData=null),E<AG&&!a)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var k=Math.max(0,e.syncOffset(t));(E-=(E-k)%AG)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var T=0,S=k;S<E;S+=AG)if(71===t[S]){var A=!!(64&t[S+1]),L=bG(t,S),b=void 0;if((48&t[S+3])>>4>1){if((b=S+5+t[S+4])===S+AG)continue}else b=S+4;switch(L){case c:if(A){if(h&&(i=wG(h,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new TG;break;case"hevc":this.videoParser=new SG}null!==this.videoParser&&this.videoParser.parsePES(s,u,i,!1)}h={data:[],size:0}}h&&(h.data.push(t.subarray(b,S+AG)),h.size+=S+AG-b);break;case d:if(A){if(v&&(i=wG(v,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,i);break;case"mp3":this.parseMPEGPES(o,i);break;case"ac3":this.parseAC3PES(o,i)}v={data:[],size:0}}v&&(v.data.push(t.subarray(b,S+AG)),v.size+=S+AG-b);break;case f:A&&(g&&(i=wG(g,this.logger))&&this.parseID3PES(l,i),g={data:[],size:0}),g&&(g.data.push(t.subarray(b,S+AG)),g.size+=S+AG-b);break;case 0:A&&(b+=t[b]+1),y=this._pmtId=RG(t,b);break;case y:A&&(b+=t[b]+1);var R,I,D=IG(t,b,this.typeSupported,n,this.observer,this.logger);if((c=D.videoPid)>0&&(s.pid=c,s.segmentCodec=D.segmentVideoCodec),(d=D.audioPid)>0&&(o.pid=d,o.segmentCodec=D.segmentAudioCodec),(f=D.id3Pid)>0&&(l.pid=f),null!==p&&!m)this.logger.warn(_d(R=_d(I="MPEG-TS PMT found at ".concat(S," after unknown PID '")).call(I,p,"'. Backtracking to sync byte @")).call(R,k," to parse all TS packets.")),p=null,S=k-188;m=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=L}}else T++;T>0&&DG(this.observer,new Error("Found ".concat(T," TS packet/s that do not start with 0x47")),void 0,this.logger),s.pesData=h,o.pesData=v,l.pesData=g;var _={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(_),_}},{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,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(t=wG(s,this.logger))){if(null===this.videoParser)switch(i.segmentCodec){case"avc":this.videoParser=new TG;break;case"hevc":this.videoParser=new SG}null!==this.videoParser&&(this.videoParser.parsePES(i,a,t,!0),i.pesData=null)}else i.pesData=s;if(o&&(t=wG(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=wG(l,this.logger))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=l}},{key:"demuxSampleAes",value:function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new yG(this.observer,this.config,t);return this.decrypt(i,n)}},{key:"decrypt",value:function(e,t){return new Lk((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.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,i,n,a=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=_N(s.sample.unit,o);else{var c=u-l;s.sample.unit.set(o.subarray(0,l),c),e.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r<i-1&&!xB(o,r);r++);if(r!==a){var h,d=r<i-1;if(h=d?"AAC PES did not start with ADTS header,offset:".concat(r):"No ADTS header found in AAC PES",DG(this.observer,new Error(h),d,this.logger),!d)return}if(OB(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)n=t.pts;else{if(!s)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var f=FB(e.samplerate);n=s.sample.pts+f}for(var v,g=0;r<i;){if(r+=(v=NB(e,o,r,n,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!xB(o,r);r++);}}},{key:"parseMPEGPES",value:function(e,t){var r=t.data,i=r.length,n=0,a=0,s=t.pts;if(void 0!==s)for(;a<i;)if(lG(r,a)){var o=aG(e,r,a,s,n);if(!o)break;a+=o.length,n++}else a++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var r=t.data,i=t.pts;if(void 0!==i)for(var n,a=r.length,s=0,o=0;o<a&&(n=fG(e,r,o,i,s++))>0;)o+=n;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var r=AO({},t,{type:this._videoTrack?QB.emsg:QB.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 i=e.syncOffset(t);return i>0&&r.warn("MPEG2-TS detected but first sync word found @ offset ".concat(i)),-1!==i}},{key:"syncOffset",value:function(e){for(var t=e.length,r=Math.min(940,t-AG)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=AG){if(71!==e[o]||t-o!==AG&&71!==e[o+AG]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-AG)+1),n||(n=0===bG(e,o)),n&&s>1&&(0===a&&s>2||o+AG>r))return a}i++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:fN[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function bG(e,t){return((31&e[t+1])<<8)+e[t+2]}function RG(e,t){return(31&e[t+10])<<8|e[t+11]}function IG(e,t,r,i,n,a){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=bG(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){_G("ADTS AAC",a);break}case 15:-1===s.audioPid&&(s.audioPid=l);break;case 21:-1===s.id3Pid&&(s.id3Pid=l);break;case 219:if(!i){_G("H.264",a);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"):a.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){_G("AC-3",a);break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="ac3"):a.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&u>0)for(var c=t+5,h=u;h>2;){if(106===e[c])!0!==r.ac3?a.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");var d=e[c+1]+2;c+=d,h-=d}break;case 194:case 135:return DG(n,new Error("Unsupported EC-3 in M2TS found"),void 0,a),s;case 36:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="hevc",a.log("HEVC in M2TS found"))}t+=u+5}return s}function DG(e,t,r,i){i.warn("parsing error: ".concat(t.message)),e.emit(dO.ERROR,dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function _G(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function wG(e,t){var r,i,n,a,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=_N(l[0],l[1]),Rg(l).call(l,1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;var u=r[7];192&u&&(a=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?a-(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((a-s)/9e4),"s delta between PTS and DTS, align them")),a=s):s=a);var c=(n=r[8])+9;if(e.size<=c)return null;e.size-=c;for(var h=new Uint8Array(e.size),d=0,f=l.length;d<f;d++){var v=(r=l[d]).byteLength;if(c){if(c>v){c-=v;continue}r=r.subarray(c),v-=c,c=0}h.set(r,o),o+=v}return i&&(i-=n+3),{data:h,pts:a,dts:s,len:i}}return null}var PG=function(){function e(){t(this,e)}return Fc(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}(),CG=Math.pow(2,32)-1,xG=function(){function e(){t(this,e)}return Fc(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]),i=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:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,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,n))}},{key:"box",value:function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].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),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].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 i=Math.floor(r/(CG+1)),n=Math.floor(r%(CG+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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))}},{key:"moov",value:function(t){for(var r,i,n=t.length,a=[];n--;)a[n]=e.trak(t[n]);return e.box.apply(null,_d(r=_d(i=[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)]).call(i,a)).call(r,e.mvex(t)))}},{key:"mvex",value:function(t){for(var r,i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,_d(r=[e.types.mvex]).call(r,n))}},{key:"mvhd",value:function(t,r){r*=t;var i=Math.floor(r/(CG+1)),n=Math.floor(r%(CG+1)),a=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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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,a)}},{key:"sdtp",value:function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=IP(n[r]),a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)}},{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,i,n,a,s,o,l=[],u=[];for(a=0;a<t.sps.length;a++)o=(s=t.sps[a]).byteLength,l.push(o>>>8&255),l.push(255&o),l=_d(l).call(l,ag(Array.prototype).call(s));for(a=0;a<t.pps.length;a++)o=(s=t.pps[a]).byteLength,u.push(o>>>8&255),u.push(255&o),u=_d(u).call(u,ag(Array.prototype).call(s));var c=e.box(e.types.avcC,new Uint8Array(_d(r=_d(i=_d(n=[1,l[3],l[4],l[5],255,224|t.sps.length]).call(n,l)).call(i,[t.pps.length])).call(r,u))),h=t.width,d=t.height,f=t.pixelRatio[0],v=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,h>>8&255,255&h,d>>8&255,255&d,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]),c,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([f>>24,f>>16&255,f>>8&255,255&f,v>>24,v>>16&255,v>>8&255,255&v])))}},{key:"esds",value:function(e){var t,r=e.config;return new Uint8Array(_d(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,uD(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,i=t.duration*t.timescale,n=t.width,a=t.height,s=Math.floor(i/(CG+1)),o=Math.floor(i%(CG+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,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))}},{key:"traf",value:function(t,r){var i=e.sdtp(t),n=t.id,a=Math.floor(r/(CG+1)),s=Math.floor(r%(CG+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)}},{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 i,n,a,s,o,l,u=t.samples||[],c=u.length,h=12+16*c,d=new Uint8Array(h);for(r+=8+h,d.set(["video"===t.type?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<c;i++)a=(n=u[i]).duration,s=n.size,o=IP(n),l=n.cts,d.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,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*i);return e.box(e.types.trun,d)}},{key:"initSegment",value:function(t){e.types||e.init();var r=e.moov(t);return _N(e.FTYP,r)}},{key:"hvc1",value:function(t){for(var r=t.params,i=[t.vps,t.sps,t.pps],n=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,qk(r.frame_rate.fps),3|r.temporal_id_nested<<2|r.num_temporal_layers<<3|(r.frame_rate.fixed?64:0),i.length]),a=n.length,s=0;s<i.length;s+=1){a+=3;for(var o=0;o<i[s].length;o+=1)a+=2+i[s][o].length}var l=new Uint8Array(a);l.set(n,0),a=n.length;for(var u=i.length-1,c=0;c<i.length;c+=1){l.set(new Uint8Array([32+c|(c===u?128:0),0,i[c].length]),a),a+=3;for(var h=0;h<i[c].length;h+=1)l.set(new Uint8Array([i[c][h].length>>8,255&i[c][h].length]),a),a+=2,l.set(i[c][h],a),a+=i[c][h].length}var d=e.box(e.types.hvcC,l),f=t.width,v=t.height,g=t.pixelRatio[0],p=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,f>>8&255,255&f,v>>8&255,255&v,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,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([g>>24,g>>16&255,g>>8&255,255&g,p>>24,p>>16&255,p>>8&255,255&p])))}}]),e}();xG.types=void 0,xG.HDLR_TYPES=void 0,xG.STTS=void 0,xG.STSC=void 0,xG.STCO=void 0,xG.STSZ=void 0,xG.VMHD=void 0,xG.SMHD=void 0,xG.STSD=void 0,xG.FTYP=void 0,xG.DINF=void 0;var MG=9e4;function OG(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 FG(e){return OG(e,1e3,1/MG,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}var NG=null,UG=null,BG=function(){function e(r,i,n,a){if(t(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=r,this.config=i,this.typeSupported=n,this.logger=a,this.ISGenerated=!1,null===NG){var s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);NG=s?qk(s[1]):0}if(null===UG){var o=navigator.userAgent.match(/Safari\/(\d+)/i);UG=o?qk(o[1]):0}}return Fc(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,i=mP(e).call(e,(function(e,i){var n=i.pts,a=n-e;return a<-4294967296&&(t=!0,a=(n=GG(n,r))-e),a>0?e:n}),r);return t&&this.logger.debug("PTS rollover detected"),i}},{key:"remux",value:function(e,t,r,i,n,a,s,o){var l,u,c,h,d,f,v=n,g=n,p=e.pid>-1,m=t.pid>-1,y=t.samples.length,E=e.samples.length>0,k=s&&y>0||y>1;if((!p||E)&&(!m||k)||this.ISGenerated||s){if(this.ISGenerated){var T,S,A,L,b=this.videoTrackConfig;(b&&(t.width!==b.width||t.height!==b.height||(null==(T=t.pixelRatio)?void 0:T[0])!==(null==(S=b.pixelRatio)?void 0:S[0])||(null==(A=t.pixelRatio)?void 0:A[1])!==(null==(L=b.pixelRatio)?void 0:L[1]))||!b&&k||null===this.nextAudioPts&&E)&&this.resetInitSegment()}this.ISGenerated||(c=this.generateIS(e,t,n,a));var R,I=this.isVideoContiguous,D=-1;if(k&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!I&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,D>0){var _,w;this.logger.warn(_d(_="[mp4-remuxer]: Dropped ".concat(D," out of ")).call(_,y," video samples due to a missing keyframe"));var P=this.getVideoStartPts(t.samples);t.samples=ag(w=t.samples).call(w,D),t.dropped+=D,R=g+=(t.samples[0].pts-P)/t.inputTimeScale}else-1===D&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(y," video samples")),f=!1);if(this.ISGenerated){if(E&&k){var C=this.getVideoStartPts(t.samples),x=(GG(e.samples[0].pts,C)-C)/t.inputTimeScale;v+=Math.max(0,x),g+=Math.max(0,-x)}if(E){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,v,this.isAudioContiguous,a,m||k||o===yO?g:void 0),k){var M=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),l=this.remuxVideo(t,g,I,M)}}else k&&(l=this.remuxVideo(t,g,I,0));l&&(l.firstKeyFrame=D,l.independent=-1!==D,l.firstKeyFramePTS=R)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(d=KG(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=HG(i,n,this._initPTS))),{audio:u,video:l,initSegment:c,independent:f,text:h,id3:d}}},{key:"generateIS",value:function(e,t,r,i){var n,a,s,o=e.samples,l=t.samples,u=this.typeSupported,c={},h=this._initPTS,d=!h||i,f="audio/mp4";if(d&&(n=a=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(f="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}c.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&u.mpeg?new Uint8Array(0):xG.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(s=e.inputTimeScale,h&&s===h.timescale?d=!1:n=a=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:xG.initSegment([t]),metadata:{width:t.width,height:t.height}},d)if(s=t.inputTimeScale,h&&s===h.timescale)d=!1;else{var v=this.getVideoStartPts(l),g=Math.round(s*r);a=Math.min(a,GG(l[0].dts,v)-g),n=Math.min(n,v-g)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(zf(c).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:c,initPTS:n,timescale:s}}},{key:"remuxVideo",value:function(e,t,r,i){var n,a,s=e.inputTimeScale,o=e.samples,l=[],u=o.length,c=this._initPTS,h=this.nextAvcDts,d=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,p=!1;if(!r||null===h){var m=t*s,y=o[0].pts-GG(o[0].dts,o[0].pts);NG&&null!==h&&Math.abs(m-y-h)<15e3?r=!0:h=m-y}for(var E=c.baseTime*s/c.timescale,k=0;k<u;k++){var T=o[k];T.pts=GG(T.pts-E,h),T.dts=GG(T.dts-E,h),T.dts<o[k>0?k-1:k].dts&&(p=!0)}p&&GA(o).call(o,(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=o[0].dts;var S=(a=o[o.length-1].dts)-n,A=S?Math.round(S/(u-1)):f||e.inputTimeScale/30;if(r){var L=n-h,b=L>A,R=L<-1;if(b||R){var I,D,_,w,P,C;if(b)this.logger.warn(_d(I=_d(D=_d(_="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(_,FG(L,!0)," ms (")).call(D,L,"dts) hole between fragments detected at ")).call(I,t.toFixed(3)));else this.logger.warn(_d(w=_d(P=_d(C="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(C,FG(-L,!0)," ms (")).call(P,L,"dts) overlapping between fragments detected at ")).call(w,t.toFixed(3)));if(!R||h>=o[0].pts||NG){var x,M;n=h;var O=o[0].pts-L;if(b)o[0].dts=n,o[0].pts=O;else for(var F=!0,N=0;N<o.length&&!(o[N].dts>O&&F);N++){var U=o[N].pts;if(o[N].dts-=L,o[N].pts-=L,N<o.length-1){var B=o[N+1].pts;F=B<=o[N].pts==B<=U}}this.logger.log(_d(x=_d(M="Video: Initial PTS/DTS adjusted: ".concat(FG(O,!0),"/")).call(M,FG(n,!0),", delta: ")).call(x,FG(L,!0)," ms"))}}}for(var G=0,K=0,H=n=Math.max(0,n),V=0;V<u;V++){for(var j=o[V],Y=j.units,q=Y.length,W=0,z=0;z<q;z++)W+=Y[z].data.length;K+=W,G+=q,j.length=W,j.dts<H?(j.dts=H,H+=A/4|0||1):H=j.dts,v=Math.min(j.pts,v),g=Math.max(j.pts,g)}a=o[u-1].dts;var X,Q=K+4*G+8;try{X=new Uint8Array(Q)}catch(Ie){return void this.observer.emit(dO.ERROR,dO.ERROR,{type:cO.MUX_ERROR,details:hO.REMUX_ALLOC_ERROR,fatal:!1,error:Ie,bytes:Q,reason:"fail allocating video mdat ".concat(Q)})}var $=new DataView(X.buffer);$.setUint32(0,Q),X.set(xG.types.mdat,4);for(var J=!1,Z=Number.POSITIVE_INFINITY,ee=Number.POSITIVE_INFINITY,te=Number.NEGATIVE_INFINITY,re=Number.NEGATIVE_INFINITY,ie=0;ie<u;ie++){for(var ne=o[ie],ae=ne.units,se=0,oe=0,le=ae.length;oe<le;oe++){var ue=ae[oe],ce=ue.data,he=ue.data.byteLength;$.setUint32(d,he),d+=4,X.set(ce,d),d+=he,se+=4+he}var de=void 0;if(ie<u-1)f=o[ie+1].dts-ne.dts,de=o[ie+1].pts-ne.pts;else{var fe=this.config,ve=ie>0?ne.dts-o[ie-1].dts:A;if(de=ie>0?ne.pts-o[ie-1].pts:A,fe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ge,pe=Math.floor(fe.maxBufferHole*s),me=(i?v+i*s:this.nextAudioPts)-ne.pts;if(me>pe)(f=me-ve)<0?f=ve:J=!0,this.logger.log(_d(ge="[mp4-remuxer]: It is approximately ".concat(me/90," ms to the next segment; using duration ")).call(ge,f/90," ms for the last video frame."));else f=ve}else f=ve}var ye=Math.round(ne.pts-ne.dts);Z=Math.min(Z,f),te=Math.max(te,f),ee=Math.min(ee,de),re=Math.max(re,de),l.push(new jG(ne.key,f,se,ye))}if(l.length)if(NG){if(NG<70){var Ee=IP(l[0]);Ee.dependsOn=2,Ee.isNonSync=0}}else if(UG&&re-ee<te-Z&&A/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 ke=n,Te=0,Se=l.length;Te<Se;Te++){var Ae=ke+l[Te].duration,Le=ke+l[Te].cts;if(Te<Se-1){var be=Ae+l[Te+1].cts;l[Te].duration=be-Le}else l[Te].duration=Te?l[Te-1].duration:A;l[Te].cts=0,ke=Ae}}f=J||!f?A:f,this.nextAvcDts=h=a+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;var Re={data1:xG.moof(e.sequenceNumber++,n,AO({},e,{samples:l})),data2:X,startPTS:v/s,endPTS:(g+f)/s,startDTS:n/s,endDTS:h/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Re}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,r,i,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.getSamplesPerFrame(e),l=o*s,u=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],d=void 0!==n,f=e.samples,v=c?0:8,g=this.nextAudioPts||-1,p=t*a,m=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||f.length&&g>0&&(i&&Math.abs(p-g)<9e3||Math.abs(GG(f[0].pts-m,p)-g)<20*l),vd(f).call(f,(function(e){e.pts=GG(e.pts-m,p)})),!r||g<0){if(!(f=rT(f).call(f,(function(e){return e.pts>=0}))).length)return;g=0===n?0:i&&!d?Math.max(0,p):f[0].pts}if("aac"===e.segmentCodec)for(var y=this.config.maxAudioFramesDrift,E=0,k=g;E<f.length;E++){var T,S=f[E],A=S.pts,L=A-k,b=Math.abs(1e3*L/a);if(L<=-y*l&&d){if(0===E)this.logger.warn(_d(T="Audio frame @ ".concat((A/a).toFixed(3),"s overlaps nextAudioPts by ")).call(T,Math.round(1e3*L/a)," ms.")),this.nextAudioPts=g=k=A}else if(L>=y*l&&b<1e4&&d){var R,I,D=Math.round(L/l);(k=A-D*l)<0&&(D--,k+=l),0===E&&(this.nextAudioPts=g=k),this.logger.warn(_d(R=_d(I="[mp4-remuxer]: Injecting ".concat(D," audio frame @ ")).call(I,(k/a).toFixed(3),"s due to ")).call(R,Math.round(1e3*L/a)," ms gap."));for(var _=0;_<D;_++){var w=Math.max(k,0),P=PG.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);P||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=S.unit.subarray()),Rg(f).call(f,E,0,{unit:P,pts:w}),k+=l,E++}}S.pts=k,k+=l}for(var C,x=null,M=null,O=0,F=f.length;F--;)O+=f[F].unit.byteLength;for(var N=0,U=f.length;N<U;N++){var B=f[N],G=B.unit,K=B.pts;if(null!==M){h[N-1].duration=Math.round((K-M)/s)}else{if(r&&"aac"===e.segmentCodec&&(K=g),x=K,!(O>0))return;O+=v;try{C=new Uint8Array(O)}catch(X){return void this.observer.emit(dO.ERROR,dO.ERROR,{type:cO.MUX_ERROR,details:hO.REMUX_ALLOC_ERROR,fatal:!1,error:X,bytes:O,reason:"fail allocating audio mdat ".concat(O)})}c||(new DataView(C.buffer).setUint32(0,O),C.set(xG.types.mdat,4))}C.set(G,v);var H=G.byteLength;v+=H,h.push(new jG(!0,o,H,0)),M=K}var V=h.length;if(V){var j=h[h.length-1];this.nextAudioPts=g=M+s*j.duration;var Y=c?new Uint8Array(0):xG.moof(e.sequenceNumber++,x/s,AO({},e,{samples:h}));e.samples=[];var q=x/a,W=g/a,z={data1:Y,data2:C,startPTS:q,endPTS:W,startDTS:q,endDTS:W,type:"audio",hasAudio:!0,hasVideo:!1,nb:V};return this.isAudioContiguous=!0,z}}}]),e}();function GG(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 KG(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=GG(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=GG(o.dts-i.baseTime*a/i.timescale,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function HG(e,t,r){var i,n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=GG(o.pts-r.baseTime*a/r.timescale,t*a)/a}GA(i=e.samples).call(i,(function(e,t){return e.pts-t.pts}));var l=e.samples;return e.samples=[],{samples:l}}}var VG,jG=Fc((function e(r,i,n,a){t(this,e),this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=n,this.cts=a,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:r?2:1,isNonSync:r?0:1}})),YG=function(){function e(r,i,n,a){t(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 Fc(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,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(!e||!t)return e;var r=t.keyId;if(r&&t.isCommonEncryption){var i=kN(e,["moov","trak"]);vd(i).call(i,(function(e){var t=kN(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=kN(t,["enca"]),n=i.length>0;n||(i=kN(t,["encv"])),vd(i).call(i,(function(e){var t=kN(n?e.subarray(28):e.subarray(78),["sinf"]);vd(t).call(t,(function(e){var t=IN(e);if(t){var i,a,s=t.subarray(8,24);cS(s).call(s,(function(e){return 0!==e}))||(CO.log(_d(i=_d(a="[eme] Patching keyId in 'enc".concat(n?"a":"v",">sinf>>tenc' box: ")).call(a,zF.hexDump(s)," -> ")).call(i,zF.hexDump(r))),t.set(r,8))}}))}))}))}return e}(e,i)),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 i=this.initData=SN(e);i.audio&&(t=qG(i.audio,nN)),i.video&&(r=qG(i.video,aN));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.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=n}},{key:"remux",value:function(e,t,r,i,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};oO(u)||(u=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return c;var d={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,n=0,a=kN(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],l=kN(o,["tfhd"])[0],u=t[pN(l,4)];if(u){var c=u.default,h=pN(l,0)|(null==c?void 0:IP(c)),d=null==c?void 0:c.duration;8&h&&(d=pN(l,2&h?12:8));for(var f=u.timescale||9e4,v=kN(o,["trun"]),g=0;g<v.length;g++)!(r=DN(v[g]))&&d&&(r=d*pN(v[g],4)),u.type===aN?i+=r/f:u.type===nN&&(n+=r/f)}}if(0===i&&0===n){for(var p=1/0,m=0,y=0,E=kN(e,["sidx"]),k=0;k<E.length;k++){var T=TN(E[k]);if(null!=T&&T.references){var S;p=Math.min(p,T.earliestPresentationTime/T.timescale);var A=mP(S=T.references).call(S,(function(e,t){return e+t.info.duration||0}),0);y=(m=Math.max(m,A+T.earliestPresentationTime/T.timescale))-p}}if(y&&oO(y))return y}return i||n}(h,f),g=function(e,t){var r;return mP(r=kN(t,["moof","traf"])).call(r,(function(t,r){var i,n=kN(r,["tfdt"])[0],a=n[0],s=mP(i=kN(r,["tfhd"])).call(i,(function(t,r){var i=pN(r,4),s=e[i];if(s){var o=pN(n,4);if(1===a){if(o===hN)return CO.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=hN+1,o+=pN(n,8)}var l=o/(s.timescale||9e4);if(oO(l)&&(null===t||l<t))return l}return t}),null);return null!==s&&oO(s)&&(null===t||s<t)?s:t}),null)}(f,h),p=null===g?n:g;if(function(e,t,r,i){if(null===e)return!0;var n=Math.max(i,1),a=t-e.baseTime/e.timescale;return Math.abs(a-r)>n}(l,p,n,v)||d.timescale!==l.timescale&&a){var m,y;if(d.initPTS=p-n,l&&1===l.timescale)this.logger.warn(_d(m=_d(y="Adjusting initPTS @".concat(n," from ")).call(y,l.baseTime/l.timescale," to ")).call(m,d.initPTS));this.initPTS=l={baseTime:d.initPTS,timescale:1}}var E=e?p-l.baseTime/l.timescale:u,k=E+v;!function(e,t,r){var i;vd(i=kN(t,["moof","traf"])).call(i,(function(t){var i;vd(i=kN(t,["tfhd"])).call(i,(function(i){var n,a=pN(i,4),s=e[a];if(s){var o=s.timescale||9e4;vd(n=kN(t,["tfdt"])).call(n,(function(e){var t=e[0],i=r*o;if(i){var n=pN(e,4);if(0===t)n-=i,EN(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=pN(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(hN+1)),s=Math.floor(n%(hN+1));EN(e,4,a),EN(e,8,s)}}}))}}))}))}(f,h,l.baseTime/l.timescale),v>0?this.lastEndTime=k:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!f.audio,S=!!f.video,A="";T&&(A+="audio"),S&&(A+="video");var L={data1:h,startPTS:E,startDTS:E,endPTS:k,endDTS:k,type:A,hasAudio:T,hasVideo:S,nb:1,dropped:0};return c.audio="audio"===L.type?L:void 0,c.video="audio"!==L.type?L:void 0,c.initSegment=d,c.id3=KG(r,n,l,l),i.samples.length&&(c.text=HG(i,n,l)),c}}]),e}();function qG(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===nN){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return VO(r,!1)}return CO.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"}return CO.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1"}try{var WG;VG=RT(WG=self.performance.now).call(WG,self.performance)}catch($V){VG=YA}var zG=[{demux:pG,remux:YG},{demux:LG,remux:BG},{demux:cG,remux:BG},{demux:vG,remux:BG}];Rg(zG).call(zG,2,0,{demux:dG,remux:BG});var XG=function(){function e(r,i,n,a,s,o){t(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=r,this.typeSupported=i,this.config=n,this.id=s,this.logger=o}return Fc(e,[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,r,i){var n=this,a=r.transmuxing;a.executeStart=VG();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,c=u.contiguous,h=u.discontinuity,d=u.trackSwitch,f=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,p=l.audioCodec,m=l.videoCodec,y=l.defaultInitPts,E=l.duration,k=l.initSegmentData,T=function(e,t){var r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(s,t);if(T&&iU(T.method)){var S=this.getDecrypter(),A=nU(T.method);if(!S.isSync())return this.asyncResult=!0,this.decryptionPromise=S.webCryptoDecrypt(s,T.key.buffer,T.iv.buffer,A).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var L=S.softwareDecrypt(s,T.key.buffer,T.iv.buffer,A);if(r.part>-1){var b=S.flush();L=b?b.buffer:b}if(!L)return a.executeEnd=VG(),QG(r);s=new Uint8Array(L)}var R=this.needsProbing(h,d);if(R){var I=this.configureTransmuxer(s);if(I)return this.logger.warn("[transmuxer] ".concat(I.message)),this.observer.emit(dO.ERROR,dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),a.executeEnd=VG(),QG(r)}(h||d||g||R)&&this.resetInitSegment(k,p,m,E,t),(h||g||R)&&this.resetInitialTimestamp(y),c||this.resetContiguity();var D=this.transmux(s,T,v,f,r);this.asyncResult=$G(D);var _=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,a.executeEnd=VG(),D}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=VG();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then((function(){return t.flush(e)}));var s=[],o=n.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l.buffer,null,e))}var u=this.demuxer,c=this.remuxer;if(!u||!c){r.executeEnd=VG();var h=[QG(e)];return this.asyncResult?Lk.resolve(h):h}var d=u.flush(o);return $G(d)?(this.asyncResult=!0,d.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,d,e),this.asyncResult?Lk.resolve(s):s)}},{key:"flushRemux",value:function(e,t,r){var i,n,a,s,o=t.audioTrack,l=t.videoTrack,u=t.id3Track,c=t.textTrack,h=this.currentTransmuxState,d=h.accurateTimeOffset,f=h.timeOffset;this.logger.log(_d(i=_d(n=_d(a=_d(s="[transmuxer.ts]: Flushed ".concat(this.id," sn: ")).call(s,r.sn)).call(a,r.part>-1?" part: "+r.part:""," of ")).call(n,this.id===mO?"level":"track"," ")).call(i,r.level));var v=this.remuxer.remux(o,l,u,c,f,d,!0,this.id);e.push({remuxResult:v,chunkMeta:r}),r.transmuxing.executeEnd=VG()}},{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,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,n))}},{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,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)}},{key:"transmuxUnencrypted",value:function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,r,!1,this.id),chunkMeta:i}}},{key:"transmuxSampleAes",value:function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))}},{key:"configureTransmuxer",value:function(e){for(var t,r=this.config,i=this.observer,n=this.typeSupported,a=0,s=zG.length;a<s;a++){var o;if(null!=(o=zG[a].demux)&&o.probe(e,this.logger)){t=zG[a];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,u=this.remuxer,c=t.remux,h=t.demux;u&&u instanceof c||(this.remuxer=new c(i,r,n,this.logger)),l&&l instanceof h||(this.demuxer=new h(i,r,n,this.logger),this.probe=h.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 FN(this.config)),e}}]),e}();var QG=function(e){return{remuxResult:{},chunkMeta:e}};function $G(e){return"then"in e&&e.then instanceof Function}var JG=Fc((function e(r,i,n,a,s){t(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=s||null})),ZG=Fc((function e(r,i,n,a,s,o){t(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=r,this.contiguous=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=s,this.initSegmentChange=o})),eK=0,tK=function(){function e(r,i,n,a){var s=this;t(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=eK++,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=s.hls;if(r&&null!=t&&t.event&&t.instanceNo===s.instanceNo)switch(t.event){case"init":var i,n=null==(i=s.workerContext)?void 0:i.objectURL;n&&NI.revokeObjectURL(n);break;case"transmuxComplete":s.handleTransmuxComplete(t.data);break;case"flush":s.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=s.frag,t.data.part=s.part,t.data.id=s.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){var t,r;if(s.hls){var i=new Error(_d(t=_d(r="".concat(e.message," (")).call(r,e.filename,":")).call(t,e.lineno,")"));s.hls.config.enableWorker=!1,s.hls.logger.warn('Error in "'.concat(s.id,'" Web Worker, fallback to inline')),s.hls.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})}};var o=r.config;this.hls=r,this.id=i,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var l=function(e,t){(t=t||{}).frag=s.frag||void 0,e===dO.ERROR&&(t.parent=s.id,t.part=s.part,s.error=t.error),s.hls.trigger(e,t)};this.observer=new AB,this.observer.on(dO.FRAG_DECRYPTED,l),this.observer.on(dO.ERROR,l);var u=qO(o.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var c=this.hls.logger;if(o.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{var h;if(o.workerPath)c.log(_d(h="loading Web Worker ".concat(o.workerPath,' for "')).call(h,i,'"')),this.workerContext=function(e){var t=bB[e];if(t)return t.clientCount++,t;var r=new NI(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return bB[e]=i,i}(o.workerPath);else c.log('injecting Web Worker for "'.concat(i,'"')),this.workerContext=function(){var e=bB[LB];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=NI.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return bB[LB]=i,i}();var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:i,config:KI(o)})}catch($V){c.warn('Error setting up "'.concat(i,'" Web Worker, fallback to inline'),$V),this.terminateWorker(),this.error=null,this.transmuxer=new XG(this.observer,u,o,"",i,r.logger)}return}}this.transmuxer=new XG(this.observer,u,o,"",i,r.logger)}return Fc(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=eK++;var t=this.hls.config,r=qO(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:KI(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),function(e){var t=bB[e||LB];if(t&&1==t.clientCount--){var r=t.worker,i=t.objectURL;delete bB[e||LB],i&&NI.revokeObjectURL(i),r.terminate()}}(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,i,n,a,s,o,l,u){var c,h,d=this;l.transmuxing.start=self.performance.now();var f=this.instanceNo,v=this.transmuxer,g=a?a.start:n.start,p=n.decryptdata,m=this.frag,y=!(m&&n.cc===m.cc),E=!(m&&l.level===m.level),k=m?l.sn-m.sn:-1,T=this.part?l.part-this.part.index:-1,S=0===k&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),A=!E&&(1===k||0===k&&(1===T||S&&T<=0)),L=self.performance.now();(E||k||0===n.stats.parsing.start)&&(n.stats.parsing.start=L),!a||!T&&A||(a.stats.parsing.start=L);var b=!(m&&(null==(c=n.initSegment)?void 0:c.url)===(null==(h=m.initSegment)?void 0:h.url)),R=new ZG(y,A,o,E,g,b);if(!A||y||b){var I,D,_,w,P,C,x,M,O,F,N;this.hls.logger.log(_d(I=_d(D=_d(_=_d(w=_d(P=_d(C=_d(x=_d(M=_d(O=_d(F=_d(N="[transmuxer-interface]: Starting new transmux session for ".concat(n.type," sn: ")).call(N,l.sn)).call(F,l.part>-1?" part: "+l.part:""," ")).call(O,this.id===mO?"level":"track",": ")).call(M,l.level," id: ")).call(x,l.id,"\n discontinuity: ")).call(C,y,"\n trackSwitch: ")).call(P,E,"\n contiguous: ")).call(w,A,"\n accurateTimeOffset: ")).call(_,o,"\n timeOffset: ")).call(D,g,"\n initSegmentChange: ")).call(I,b));var U=new JG(r,i,t,s,u);this.configureTransmuxer(U)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:R},e instanceof ArrayBuffer?[e]:[]);else if(v){var B=v.push(e,p,l,R);$G(B)?B.then((function(e){d.handleTransmuxComplete(e)})).catch((function(e){d.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(B)}}},{key:"flush",value:function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(i){var n=i.flush(e);$G(n)?n.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(n,e)}}},{key:"transmuxerError",value:function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.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;vd(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 rK(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!iK(e[r].attrs,t[r].attrs))return!1;return!0}function iK(e,t,r){var i,n=e["STABLE-RENDITION-ID"];return n&&!r?n===t["STABLE-RENDITION-ID"]:!cS(i=r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).call(i,(function(r){return e[r]!==t[r]}))}function nK(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var aK=function(e){Ch(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"audio-stream-controller",yO)).mainAnchor=null,s.mainFragLoading=null,s.audioOnly=!1,s.bufferedTrack=null,s.switchingTrack=null,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.flushing=!1,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.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(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(dO.BUFFER_RESET,this.onBufferReset,this),e.on(dO.BUFFER_CREATED,this.onBufferCreated,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(dO.FRAG_LOADING,this.onFragLoading,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(Ih(Rh(i.prototype),"unregisterListeners",this).call(this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(dO.BUFFER_RESET,this.onBufferReset,this),e.off(dO.BUFFER_CREATED,this.onBufferCreated,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(dO.FRAG_LOADING,this.onFragLoading,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,t){var r=t.frag,i=t.id,n=t.initPTS,a=t.timescale;if(i===mO){var s,o,l=r.cc,u=this.fragCurrent;if(this.initPTS[l]={baseTime:n,timescale:a},this.log(_d(s=_d(o="InitPTS for cc: ".concat(l," found from main: ")).call(o,n,"/")).call(s,a)),this.mainAnchor=r,this.state===yB){var c=this.waitingData;(!c&&!this.loadingParts||c&&c.frag.cc!==l)&&(this.nextLoadPosition=this.findSyncFrag(r).start),this.tick()}else!this.hls.hasEnoughToStart&&u&&u.cc!==l?(this.startFragRequested=!1,this.nextLoadPosition=this.findSyncFrag(r).start,u.abortRequests(),this.resetLoadingState()):this.state===uB&&this.tick()}}},{key:"findSyncFrag",value:function(e){var t=this.getLevelDetails(),r=e.cc;return function(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var i=r.start,n=r.end,a=e.fragments;if(!r.relurl){var s=e.fragmentHint;s&&(a=_d(a).call(a,s))}return gF(a,(function(e){return e.cc<t||e.end<=i?1:e.cc>t||e.start>=n?-1:0}))}return null}(t,r,e)||t&&EF(t.fragments,r)||e}},{key:"startLoad",value:function(e){if(!this.levels)return this.startPosition=e,void(this.state=lB);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @".concat(t.toFixed(3))),e=t,this.state=uB):this.state=fB,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case uB:this.doTickIdle();break;case fB:var e=this.levels,t=this.trackId,r=null==e?void 0:e[t],n=null==r?void 0:r.details;if(n&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(n))break;this.state=yB}break;case dB:var a,s=performance.now(),o=this.retryDate;if(!o||s>=o||null!=(a=this.media)&&a.seeking){var l=this.levels,u=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==l?void 0:l[u])||null),this.state=uB}break;case yB:var c=this.waitingData;if(c){var h=c.frag,d=c.part,f=c.cache,v=c.complete,g=this.mainAnchor;if(void 0!==this.initPTS[h.cc]){this.waitingData=null,this.state=hB;var p={frag:h,part:d,payload:f.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(p),v&&Ih(Rh(i.prototype),"_handleFragmentLoadComplete",this).call(this,p)}else if(g&&g.cc!==c.frag.cc){var m;this.log(_d(m="Waiting fragment cc (".concat(h.cc,") cancelled because video is at cc ")).call(m,g.cc)),this.nextLoadPosition=this.findSyncFrag(g).start,this.clearWaitingFragment()}}else this.state=uB}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!==lB&&(this.state=uB))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),Ih(Rh(i.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,i=this.media,n=this.trackId,a=t.config;if(this.buffering&&(i||!this.startFragRequested&&a.startFragPrefetch)&&null!=r&&r[n]){var s=r[n],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=fB,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,nN,yO));var u=this.getFwdBufferInfo(l,yO);if(null!==u){var c=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(u,o))return t.trigger(dO.BUFFER_EOS,{type:"audio"}),void(this.state=pB);var d=u.len,f=t.maxBufferLength,v=o.fragments,g=v[0].start,p=this.getLoadPosition(),m=this.flushing?p:u.end;if(h&&i){var y=p;c&&!iK(h.attrs,c.attrs)&&(m=y),o.PTSKnown&&y<g&&(u.end>g||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=g+.05)}if(!(d>=f&&!h&&m<v[v.length-1].start)){var E=this.getNextFragment(m,o);if(E&&this.isLoopLoading(E,m)&&(E=this.getNextFragmentLoopLoading(E,o,u,mO,f)),E){var k=null==(e=this.mainFragLoading)?void 0:e.frag;if(!this.audioOnly&&this.startFragRequested&&k&&lN(k)&&lN(E)&&!E.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)){var T=k;if(E.start>T.end){var S=this.fragmentTracker.getFragAtPos(m,mO);S&&S.end>k.end&&(T=S,this.mainFragLoading={frag:S,targetBufferTime:null})}if(E.start>T.end)return}this.loadFragment(E,s,m)}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,t){this.bufferFlushed=this.flushing=!1,Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=Jk(r).call(r,(function(e){return new iF(e)}))}},{key:"onAudioTrackSwitching",value:function(e,t){var r=!!t.url;this.trackId=t.id;var i=this.fragCurrent;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==lB&&(this.setInterval(100),this.state=uB,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){Ih(Rh(i.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(dO.AUDIO_TRACK_LOADED,r))}},{key:"onAudioTrackLoaded",value:function(e,t){var r,i,n,a,s,o,l=this.levels,u=t.details,c=t.id,h=this.mainDetails;if(!h||h.expired||u.endCC>h.endCC)return this.cachedTrackLoadedData=t,void(this.state!==lB&&(this.state=fB));if(l){this.log(_d(r=_d(i=_d(n=_d(a="Audio track ".concat(c," loaded [")).call(a,u.startSN,",")).call(n,u.endSN,"]")).call(i,u.lastPartSn?_d(s="[part-".concat(u.lastPartSn,"-")).call(s,u.lastPartIndex,"]"):"",",duration:")).call(r,u.totalduration));var d=l[c],f=0;if(u.live||null!=(o=d.details)&&o.live){if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;var v;if(d.details)f=this.alignPlaylists(u,d.details,null==(v=this.levelLastLoaded)?void 0:v.details);u.alignedSliding||(aB(u,h),u.alignedSliding||sB(u,h),f=u.fragmentStart)}d.details=u,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(h,f),this.hls.trigger(dO.AUDIO_TRACK_UPDATED,{details:u,id:c,groupId:t.groupId}),this.state!==fB||this.waitForCdnTuneIn(u)||(this.state=uB),this.tick()}else this.warn("Audio tracks were reset while loading level ".concat(c))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var u=l.details;if(!u)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);var c,h,d=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",f=this.transmuxer;if(!f)f=this.transmuxer=new tK(this.hls,yO,RT(c=this._handleTransmuxComplete).call(c,this),RT(h=this._handleTransmuxerFlush).call(h,this));var v=this.initPTS[r.cc],g=null==(t=r.initSegment)?void 0:t.data;if(void 0!==v){var p=i?i.index:-1,m=-1!==p,y=new VN(r.level,r.sn,r.stats.chunkCount,n.byteLength,p,m);f.push(n,g,d,"",r,i,u.totalduration,!1,y,v)}else{var E,k,T,S;this.log(_d(E=_d(k=_d(T=_d(S="Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ")).call(S,r.sn," of [")).call(T,u.startSN," ,")).call(k,u.endSN,"],track ")).call(E,s)),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new TB,complete:!1}).cache.push(new Uint8Array(n)),this.state!==lB&&(this.state=yB)}}else this.warn("Audio track is undefined on fragment load progress")}else{var A;this.warn(_d(A="Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ")).call(A,r.level," will not be buffered"))}}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:Ih(Rh(i.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===mO&&lN(t.frag)&&(this.mainFragLoading=t,this.state===uB&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part;if(r.type===yO)if(this.fragContextChanged(r)){var n,a,s,o;this.warn(_d(n=_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state,", audioSwitch: ")).call(n,this.switchingTrack?this.switchingTrack.name:"false"))}else{if(lN(r)){this.fragPrevious=r;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(dO.AUDIO_TRACK_SWITCHED,bO({},l)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==mO||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=mB;else switch(t.details){case hO.FRAG_GAP:case hO.FRAG_PARSING_ERROR:case hO.FRAG_DECRYPT_ERROR:case hO.FRAG_LOAD_ERROR:case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_ERROR:case hO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(yO,t);break;case hO.AUDIO_TRACK_LOAD_ERROR:case hO.AUDIO_TRACK_LOAD_TIMEOUT:case hO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==fB||(null==(r=t.context)?void 0:r.type)!==gO||(this.state=uB);break;case hO.BUFFER_APPEND_ERROR:case hO.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===hO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case hO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==aN&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==aN){this.flushing=!1,this.bufferFlushed=!0,this.state===pB&&(this.state=uB);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,r,yO),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,r="audio",i=this.hls,n=e.remuxResult,a=e.chunkMeta,s=this.getCurrentContext(a);if(s){var o=s.frag,l=s.part,u=s.level,c=u.details,h=n.audio,d=n.text,f=n.id3,v=n.initSegment;if(!this.fragContextChanged(o)&&c){if(this.state=vB,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=v&&v.tracks){var g=o.initSegment||o;this._bufferInitSegment(u,v.tracks,g,a),i.trigger(dO.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:v.tracks})}if(h){var p=h.startPTS,m=h.endPTS,y=h.startDTS,E=h.endDTS;l&&(l.elementaryStreams[nN]={startPTS:p,endPTS:m,startDTS:y,endDTS:E}),o.setElementaryStreamInfo(nN,p,m,y,E),this.bufferFragmentData(h,o,l,a)}if(null!=f&&null!=(t=f.samples)&&t.length){var k=AO({id:r,frag:o,details:c},f);i.trigger(dO.FRAG_PARSING_METADATA,k)}if(d){var T=AO({id:r,frag:o,details:c},d);i.trigger(dO.FRAG_PARSING_USERDATA,T)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(a)}},{key:"_bufferInitSegment",value:function(e,t,r,i){var n,a;if(this.state===vB&&(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(_d(n=_d(a="Init audio buffer, container:".concat(s.container,", codecs[level/parsed]=[")).call(a,o,"/")).call(n,s.codec,"]")),o&&1===o.split(",").length&&(s.levelCodec=o),this.hls.trigger(dO.BUFFER_CODECS,t);var l=s.initSegment;if(null!=l&&l.byteLength){var u={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:l};this.hls.trigger(dO.BUFFER_APPENDING,u)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,t,r){var n,a=this.fragmentTracker.getState(e);if(this.switchingTrack||a===MF||a===FF)if(lN(e))if(null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]){var s,o;this.log(_d(s=_d(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=yB;var l=this.mainDetails;l&&l.fragmentStart!==t.details.fragmentStart&&sB(t.details,l)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){var t=this.media,r=this.bufferedTrack,n=null==r?void 0:r.attrs,a=e.attrs;t&&n&&(n.CHANNELS!==a.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),Ih(Rh(i.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(dO.AUDIO_TRACK_SWITCHED,bO({},e))}}]),i}(kB),sK=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n,e.logger)).hls=void 0,a.canLoad=!1,a.timer=-1,a.hls=e,a}return Fc(i,[{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 i=null==t?void 0:t.renditionReports;if(i){for(var n=-1,a=0;a<i.length;a++){var s=i[a],o=void 0;try{o=new NI(s.URI,t.url).href}catch(QV){this.warn("Could not construct new URL for Rendition Report: ".concat(QV)),o=s.URI||""}if(o===e){n=a;break}o===e.substring(0,o.length)&&(n=a)}if(-1!==n){var l=i[n],u=qk(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),c=qk(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&h>t.partTarget&&(c+=1)}var d=r&&tF(r);return new rF(u,c>=0?c:void 0,d)}}}},{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(QV){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(QV))}return e}},{key:"playlistLoaded",value:function(e,t,r){var i=t.details,n=t.stats,a=self.performance.now(),s=n.loading.first?Math.max(0,a-n.loading.first):0;i.advancedDateTime=YA()-s;var o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){var l,u=Math.max(o||0,0);i.appliedTimelineOffset=u,vd(l=i.fragments).call(l,(function(e){e.start=e.playlistOffset+u}))}if(i.live||null!=r&&r.live){var c,h="levelInfo"in t?t.levelInfo:t.track;i.reloaded(r),r&&i.fragments.length>0&&XU(r,i),-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);var d,f=this.hls.mainForwardBufferInfo,v=f?f.end-f.len:0,g=JU(i,1e3*(i.edge-v));if(i.requestScheduled+g<a?i.requestScheduled=a:i.requestScheduled+=g,this.log(_d(c="live playlist ".concat(e," ")).call(c,i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;var p=void 0,m=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var y=this.hls.config.lowLatencyMode,E=i.lastPartSn,k=i.endSN,T=i.lastPartIndex,S=E===k;-1!==T?S?(p=k+1,m=y?0:T):(p=E,m=y?T+1:i.maxPartIndex):p=k+1;var A=i.age,L=A+i.ageHeader,b=Math.min(L-i.partTarget,1.5*i.targetduration);if(b>0){if(L>3*i.targetduration)this.log("Playlist last advanced ".concat(A.toFixed(2),"s ago. Omitting segment and part directives.")),p=void 0,m=void 0;else if(null!=r&&r.tuneInGoal&&L-i.partTarget>r.tuneInGoal){var R,I;this.warn(_d(R=_d(I="CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ")).call(I,b," with playlist age: ")).call(R,i.age)),b=0}else{var D,_,w,P,C=Math.floor(b/i.targetduration);if(p+=C,void 0!==m)m+=Math.round(b%i.targetduration/i.partTarget);this.log(_d(D=_d(_=_d(w=_d(P="CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ")).call(P,A.toFixed(2),"s goal: ")).call(w,b," skip sn ")).call(_,C," to part ")).call(D,m))}i.tuneInGoal=b}if(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m),y||!S)return i.requestScheduled=a,void this.loadingPlaylist(h,d)}else(i.canBlockReload||i.canSkipUntil)&&(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m));d&&void 0!==p&&i.canBlockReload&&(i.requestScheduled=n.loading.first+Math.max(g-2*s,g/2)),this.scheduleLoading(h,d,i)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,r){var i,n=this,a=r||e.details;if(a){var s=self.performance.now(),o=a.requestScheduled;if(s>=o)this.loadingPlaylist(e,t);else{var l=o-s;this.log(_d(i="reload live playlist ".concat(e.name||e.bitrate+"bps"," in ")).call(i,Math.round(l)," ms")),this.clearTimer(),this.timer=Wf((function(){return n.loadingPlaylist(e,t)}),l)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,i){var n=tF(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=JO),new rF(r,i,n)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,i=kF(e),n=e.errorAction,a=n||{},s=a.action,o=a.retryCount,l=void 0===o?0:o,u=a.retryConfig,c=!!n&&!!u&&(s===DF||!n.resolved&&s===RF);if(c){var h;if(l>=u.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives){var d,f;this.warn(_d(d=_d(f="Retrying playlist loading ".concat(l+1,"/")).call(f,u.maxNumRetry,' after "')).call(d,r,'" without delivery-directives')),this.loadPlaylist()}else{var v,g,p,m=SF(u,l);this.clearTimer(),this.timer=Wf((function(){return t.loadPlaylist()}),m),this.warn(_d(v=_d(g=_d(p="Retrying playlist loading ".concat(l+1,"/")).call(p,u.maxNumRetry,' after "')).call(g,r,'" in ')).call(v,m,"ms"))}e.levelRetry=!0,n.resolved=!0}return c}}]),i}(RO),oK=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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 Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVEL_LOADING,this.onLevelLoading,this),e.off(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(dO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,Ih(Rh(i.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,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Audio track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Audio track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.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,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&cS(r).call(r,(function(e){return-1===(null==i?void 0:_v(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=rT(a=this.tracks).call(a,(function(e){return!r||-1!==_v(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!cS(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.audioPreference;if(!n&&l){var u=uF(l,o,hF);if(u>-1)n=o[u];else{var c=uF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={audioTracks:o};this.log(_d(s="Updating audio tracks, ".concat(o.length," track(s) found in group(s): ")).call(s,null==r?void 0:r.join(","))),this.hls.trigger(dO.AUDIO_TRACKS_UPDATED,d);var f=this.trackId;if(-1!==h&&-1===f)this.setAudioTrack(h);else if(o.length&&-1===f){var v,g,p=new Error(_d(v="No audio track selected for current audio group-ID(s): ".concat(null==(g=this.groupIds)?void 0:g.join(",")," track count: ")).call(v,o.length));this.warn(p.message),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:p})}}}}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==gO||t.context.id!==this.trackId||this.groupIds&&-1===_v(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 i=this.currentTrack;if(i&&cF(e,i,hF))return i;var n=uF(e,this.tracksInGroup,hF);if(n>-1){var a=this.tracksInGroup[n];return this.setAudioTrack(n),a}if(i){var s=t.loadLevel;-1===s&&(s=t.firstAutoLevel);var o=function(e,t,r,i,n){var a=t[i],s=mP(t).call(t,(function(e,t,r){var i=t.uri;return(e[i]||(e[i]=[])).push(r),e}),{})[a.uri];s.length>1&&(i=Math.max.apply(Math,s));var o=a.videoRange,l=a.frameRate,u=a.codecSet.substring(0,4),c=dF(t,i,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var i=t.audioGroups,a=rT(r).call(r,(function(e){return!i||-1!==_v(i).call(i,e.groupId)}));return uF(e,a,n)>-1}));return c>-1?c:dF(t,i,(function(t){var i=t.audioGroups,a=rT(r).call(r,(function(e){return!i||-1!==_v(i).call(i,e.groupId)}));return uF(e,a,n)>-1}))}(e,t.levels,r,s,hF);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=uF(e,r);if(l>-1)return r[l]}}}return null}},{key:"setAudioTrack",value:function(e){var t,r,i,n,a=this.tracksInGroup;if(e<0||e>=a.length)this.warn("Invalid audio track id: ".concat(e));else{this.selectDefaultTrack=!1;var s=this.currentTrack,o=a[e],l=o.details&&!o.details.live;if(!(e===this.trackId&&o===s&&l||(this.log(_d(t=_d(r=_d(i=_d(n="Switching to audio-track ".concat(e,' "')).call(n,o.name,'" lang:')).call(i,o.lang," group:")).call(r,o.groupId," channels:")).call(t,o.channels)),this.trackId=e,this.currentTrack=o,this.hls.trigger(dO.AUDIO_TRACK_SWITCHING,bO({},o)),l))){var u=this.switchParams(o.url,null==s?void 0:s.details,o.details);this.loadPlaylist(u)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||cF(e,i,hF)))return r}if(e){for(var n=e.name,a=e.lang,s=e.assocLang,o=e.characteristics,l=e.audioCodec,u=e.channels,c=0;c<t.length;c++){if(cF({name:n,lang:a,assocLang:s,characteristics:o,audioCodec:l,channels:u},t[c],hF))return c}for(var h=0;h<t.length;h++){var d=t[h];if(iK(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var f=0;f<t.length;f++){var v=t[f];if(iK(e.attrs,v.attrs,["LANGUAGE"]))return f}}return-1}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this);var t=this.currentTrack;this.shouldLoadPlaylist(t)&&fF(t.url,this.hls)&&this.scheduleLoading(t,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading audio-track ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(dO.AUDIO_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}}]),i}(sK),lK=function(){function e(r){t(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=r}return Fc(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 i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){var t=this;return new Lk((function(r){var i={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(i,e)}))}},{key:"prependBlocker",value:function(e){var t=this;return new Lk((function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}}))}},{key:"removeBlockers",value:function(){var e;null!==this.queues&&vd(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(),Rg(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(QV){var i;if(r.onError(QV),null===this.queues||null===this.tracks)return;var n=null==(i=this.tracks[e])?void 0:i.buffer;null!=n&&n.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,i=this.tracks;return null===r||null===i?"<destroyed>":_d(e=_d(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,i,n;return null!=(i=this.queues)&&i[e]||null!=(n=this.tracks)&&n[e]?_d(t=_d(r="".concat(e,": (")).call(r,this.listSbInfo(e),") ")).call(t,this.listOps(e)):""}},{key:"listSbInfo",value:function(e){var t,r,i,n=null==(i=this.tracks)?void 0:i[e],a=null==n?void 0:n.buffer;return a?_d(t=_d(r="SourceBuffer".concat(a.updating?" updating":"")).call(r,n.ended?" ended":"")).call(t,n.ending?" ending":""):"none"}},{key:"listOps",value:function(e){var t,r;return(null==(r=this.queues)?void 0:Jk(t=r[e]).call(t,(function(e){return e.label})).join(", "))||""}}]),e}(),uK=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,cK="HlsJsTrackRemovedError",hK=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e)).name=cK,n}return Fc(i)}(Jw(Error)),dK=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(a=r.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=Zh(a),r=t.media,i=t.mediaSource;e&&a.log("Media source opened"),r&&i&&(r.removeEventListener("emptied",a._onMediaEmptied),a.updateDuration(),a.hls.trigger(dO.MEDIA_ATTACHED,{media:r,mediaSource:i}),i.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=Zh(a),r=t.mediaSrc,i=t._objectUrl;r!==i&&a.error(_d(e="Media element src was set while attaching MediaSource (".concat(i," > ")).call(e,r,")"))},a.hls=e,a.fragmentTracker=n,a.appendSource=(s=xO(e.config.preferManagedMediaSource),"undefined"!=typeof self&&s===self.ManagedMediaSource),a.initTracks(),a.registerListeners(),a}return Fc(i,[{key:"hasSourceTypes",value:function(){return zf(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(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.BUFFER_RESET,this.onBufferReset,this),e.on(dO.BUFFER_APPENDING,this.onBufferAppending,this),e.on(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(dO.BUFFER_EOS,this.onBufferEos,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(dO.FRAG_PARSED,this.onFragParsed,this),e.on(dO.FRAG_CHANGED,this.onFragChanged,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.BUFFER_RESET,this.onBufferReset,this),e.off(dO.BUFFER_APPENDING,this.onBufferAppending,this),e.off(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(dO.BUFFER_EOS,this.onBufferEos,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(dO.FRAG_PARSED,this.onFragParsed,this),e.off(dO.FRAG_CHANGED,this.onFragChanged,this),e.off(dO.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a,s,o=this.isQueued();if(n||o)this.warn(_d(a=_d(s="Transfering MediaSource with".concat(o?" operations in queue":"")).call(s,n?" updating SourceBuffer(s)":""," ")).call(a,this.operationQueue));this.operationQueue.destroy()}var l,u=this.transferData;!this.sourceBufferCount&&u&&u.mediaSource===r?AO(i,u.tracks):vd(l=this.sourceBuffers).call(l,(function(t){var r=cD(t,1)[0];r&&(i[r]=AO({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null}));return{media:t,mediaSource:r,tracks:i}}},{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,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log("".concat(i," bufferCodec event(s) expected.")),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media,i=xO(this.appendSource);if(this.transferData=this.overrides=void 0,r&&i){var n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var a=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(a),n)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=NI.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,fK(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(QV){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r,i;this.log(_d(t="".concat((null==(r=this.transferData)?void 0:r.mediaSource)===e?"transferred":"created"," media source: ")).call(t,null==(i=e.constructor)?void 0:i.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 i=this.tracks,n=r.tracks,a=n?zf(n):null,s=a?a.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(n&&a&&s){var l,u;if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(_d(l=_d(u="attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ")).call(u,KI(i,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ")).call(l,KI(n,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!MO(n,i)){var c,h,d;r.mediaSource=null,r.tracks=void 0;var f,v=t.currentTime,g=this.details,p=Math.max(v,(null==g?void 0:g.fragments[0].start)||0);return p-v>1?void this.log(_d(f="attachTransferred: waiting for playback to reach new tracks start time ".concat(v," -> ")).call(f,p)):(this.warn(_d(c=_d(h=_d(d='attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(zf(n),'"->"')).call(d,zf(i),'") start time: ')).call(h,p," currentTime: ")).call(c,v)),this.onMediaDetaching(dO.MEDIA_DETACHING,{}),this.onMediaAttaching(dO.MEDIA_ATTACHING,r),void(t.currentTime=p))}this.transferData=void 0,vd(a).call(a,(function(t){var r=t,i=n[r];if(i){var a=i.buffer;if(a){var s=e.fragmentTracker,o=i.id;if(s.hasFragments(o)||s.hasParts(o)){var l=YN.getBuffered(a);s.detectEvictedFragments(r,l,o,null,!0)}var u=vK(r),c=[r,a];e.sourceBuffers[u]=c,a.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,i)}}})),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,i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,s=this._objectUrl;if(a){if(this.log("media source ".concat(i?"transferring":"detaching")),i){var o;vd(o=this.sourceBuffers).call(o,(function(e){var t=cD(e,1)[0];t&&r.removeBuffer(t)})),this.resetQueue()}else{if(this.mediaSourceOpenOrEnded){var l="open"===a.readyState;try{for(var u=a.sourceBuffers,c=u.length;c--;)l&&u[c].abort(),a.removeSourceBuffer(u[c]);l&&a.endOfStream()}catch($V){this.warn("onMediaDetaching: ".concat($V.message," while calling endOfStream"))}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(s&&NI.revokeObjectURL(s),this.mediaSrc===s?(n.removeAttribute("src"),this.appendSource&&fK(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(dO.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){var e,t=this;vd(e=this.sourceBuffers).call(e,(function(e){var r=cD(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 i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch($V){this.warn("onBufferReset ".concat(e),$V)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[vK(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 lK(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r,i=this,n=this.tracks,a=zf(t);this.log(_d(r='BUFFER_CODECS: "'.concat(a,'" (current SB count ')).call(r,this.sourceBufferCount,")"));var s,o="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),l=!o&&this.sourceBufferCount&&this.media&&cS(a).call(a,(function(e){return!n[e]}));o||l?this.warn(_d(s='Unsupported transition between "'.concat(zf(n),'" and "')).call(s,a,'" SourceBuffers')):(vd(a).call(a,(function(e){var r,a,s,o=t[e],l=o.id,u=o.codec,c=o.levelCodec,h=o.container,d=o.metadata,f=n[e],v=null==(r=i.transferData)||null==(a=r.tracks)?void 0:a[e],g=null!=v&&v.buffer?v:f,p=(null==g?void 0:g.pendingCodec)||(null==g?void 0:g.codec),m=null==g?void 0:g.levelCodec,y=!g||!!i.hls.config.assetPlayerId;f||(f=n[e]={buffer:void 0,listeners:[],codec:u,container:h,levelCodec:c,metadata:d,id:l});var E,k=jO(p,m),T=null==k?void 0:k.replace(uK,"$1"),S=jO(u,c),A=null==(s=S)?void 0:s.replace(uK,"$1");S&&(T!==A||y)&&("audio"===ag(e).call(e,0,5)&&(S=VO(S,i.appendSource)),i.log(_d(E="switching codec ".concat(p," to ")).call(E,S)),S!==(f.pendingCodec||f.codec)&&(f.pendingCodec=S),f.container=h,i.appendChangeType(e,h,S))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e,t=this;return mP(e=zf(this.tracks)).call(e,(function(e,r){var i=t.tracks[r];return e[r]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e}),{})}},{key:"appendChangeType",value:function(e,t,r){var i,n=this,a=_d(i="".concat(t,";codecs=")).call(i,r),s={label:"change-type=".concat(a),execute:function(){var i=n.tracks[e];if(i){var s,o=i.buffer;if(null!=o&&o.changeType)n.log(_d(s="changing ".concat(e," sourceBuffer type to ")).call(s,a)),o.changeType(a),i.codec=r,i.container=t}n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){n.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,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,mO))?void 0:t.gap))){var a={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>n||null!=t&&t.buffer&&YN.isBuffered(t.buffer,n)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(n,mO))?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:a,frag:e},this.append(a,"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,i=this.tracks,n=t.data,a=t.type,s=t.parent,o=t.frag,l=t.part,u=t.chunkMeta,c=u.buffering[a],h=o.sn,d=self.performance.now();c.start=d;var f=o.stats.buffering,v=l?l.stats.buffering:null;0===f.start&&(f.start=d),v&&0===v.start&&(v.start=d);var g=i.audio,p=!1;"audio"===a&&"audio/mpeg"===(null==g?void 0:g.container)&&(p=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var m=this.tracks.video,y=null==m?void 0:m.buffer;if(y&&"initSegment"!==h){var E=l||o,k=this.blockedAudioAppend;if("audio"!==a||"main"===s||this.blockedAudioAppend){if("video"===a){var T=E.end;if(k){var S=k.frag.start;(T>S||T<this.lastVideoAppendEnd||YN.isBuffered(y,S))&&this.unblockAudio()}this.lastVideoAppendEnd=T}}else{var A=E.start+.05*E.duration,L=y.buffered,b=this.currentOp("video");L.length||b?!b&&!YN.isBuffered(y,A)&&this.lastVideoAppendEnd<A&&this.blockAudio(E):this.blockAudio(E)}}var R=(l||o).start,I={label:"append-".concat(a),execute:function(){if(c.executeStart=self.performance.now(),p){var e=r.tracks[a];if(e){var t=e.buffer;if(t){var i,s,o=R-t.timestampOffset;if(Math.abs(o)>=.1)r.log(_d(i=_d(s="Updating audio SourceBuffer timestampOffset to ".concat(R," (delta: ")).call(s,o,") sn: ")).call(i,h,")")),t.timestampOffset=R}}}r.appendExecutor(n,a)},onStart:function(){},onComplete:function(){var e,t=self.performance.now();c.executeEnd=c.end=t,0===f.first&&(f.first=t),v&&0===v.first&&(v.first=t);var i={};vd(e=r.sourceBuffers).call(e,(function(e){var t=cD(e,2),r=t[0],n=t[1];r&&(i[r]=YN.getBuffered(n))})),r.appendErrors[a]=0,"audio"===a||"video"===a?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(dO.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:i})},onError:function(e){var t,i={type:cO.MEDIA_ERROR,parent:o.type,details:hO.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:l,chunkMeta:u,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)i.details=hO.BUFFER_FULL_ERROR;else if(e.code!==DOMException.INVALID_STATE_ERR||!r.mediaSourceOpenOrEnded||null!=(t=r.media)&&t.error)if(e.name===cK)0===r.sourceBufferCount?i.errorAction=xF(!0):++r.appendErrors[a];else{var n,s,c=++r.appendErrors[a];r.warn(_d(n=_d(s="Failed ".concat(c,"/")).call(s,r.hls.config.appendErrorMaxRetry,' times to append segment in "')).call(n,a,'" sourceBuffer')),c>=r.hls.config.appendErrorMaxRetry&&(i.fatal=!0)}else i.errorAction=xF(!0);r.hls.trigger(dO.ERROR,i)}};this.append(I,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,r){var i,n,a=this;return this.log(_d(i=_d(n='queuing "'.concat(e,'" remove ')).call(n,t,"-")).call(i,r)),{label:"remove",execute:function(){a.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){a.hls.trigger(dO.BUFFER_FLUSHED,{type:e})},onError:function(i){var n,s;a.warn(_d(n=_d(s="Failed to remove ".concat(t,"-")).call(s,r,' from "')).call(n,e,'" SourceBuffer'),i)}}}},{key:"onBufferFlushing",value:function(e,t){var r,i=this,n=t.type,a=t.startOffset,s=t.endOffset;n?this.append(this.getFlushOp(n,a,s),n):vd(r=this.sourceBuffers).call(r,(function(e){var t=cD(e,1)[0];t&&i.append(i.getFlushOp(t,a,s),t)}))}},{key:"onFragParsed",value:function(e,t){var r=this,i=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[sN]?a.push("audiovideo"):(s[nN]&&a.push("audio"),s[aN]&&a.push("video"));var o,l;0===a.length&&this.warn(_d(o=_d(l="Fragments must have at least one ElementaryStreamType set. type: ".concat(i.type," level: ")).call(l,i.level," sn: ")).call(o,i.sn));this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;r.hls.trigger(dO.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})}),a)}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var e,t=this;return this.sourceBufferCount>0&&!cS(e=this.sourceBuffers).call(e,(function(e){var r,i,n=cD(e,1)[0];return n&&(!(null!=(r=t.tracks[n])&&r.ended)||(null==(i=t.tracks[n])?void 0:i.ending))}))}},{key:"onBufferEos",value:function(e,t){var r,i,n,a=this;vd(r=this.sourceBuffers).call(r,(function(e){var r=cD(e,1)[0];if(r){var i=a.tracks[r];t.type&&t.type!==r||(i.ending=!0,i.ended||(i.ended=!0,a.log("".concat(r," buffer reached EOS"))))}}));var s=!1!==(null==(n=this.overrides)?void 0:n.endOfStream);this.sourceBufferCount>0&&!cS(i=this.sourceBuffers).call(i,(function(e){var t,r=cD(e,1)[0];return r&&!(null!=(t=a.tracks[r])&&t.ended)}))&&(this.log("Queueing EOS"),this.blockUntilOpen((function(){var e;if(vd(e=a.sourceBuffers).call(e,(function(e){var t=cD(e,1)[0];if(null!==t){var r=a.tracks[t];r&&(r.ending=!1)}})),s){var t=a.mediaSource;if(!t||"open"!==t.readyState)return void(t&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(t.readyState)));a.log("Calling mediaSource.endOfStream()"),t.endOfStream()}a.hls.trigger(dO.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===hO.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;oO(i)&&i!==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 i=e.config,n=r.currentTime,a=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(oO(s)&&s>=0){var o=Math.max(s,a),l=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,l)}if(oO(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var u=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),c=Math.max(u,a),h=Math.floor(n/a)*a+c;this.flushFrontBuffer(n,a,h)}}}},{key:"flushBackBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=cD(i,2),s=a[0],o=a[1];if(o){var l=YN.getBuffered(o);if(l.length>0&&r>l.start(0)){var u;n.hls.trigger(dO.BACK_BUFFER_REACHED,{bufferEnd:r});var c=n.tracks[s];if(null!=(u=n.details)&&u.live)n.hls.trigger(dO.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=c&&c.ended&&l.end(l.length-1)-e<2*t)return void n.log("Cannot flush ".concat(s," back buffer while SourceBuffer is in ended state"));n.hls.trigger(dO.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}},{key:"flushFrontBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=cD(i,2),s=a[0],o=a[1];if(o){var l=YN.getBuffered(o),u=l.length;if(u<2)return;var c=l.start(u-1),h=l.end(u-1),d=n.tracks[s];if(r>c||e>=c&&e<=h)return;if(null!=d&&d.ended&&e-h<2*t)return void n.log("Cannot flush ".concat(s," front buffer while SourceBuffer is in ended state"));n.hls.trigger(dO.BUFFER_FLUSHING,{startOffset:c,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 i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(r.duration=1/0,t.fragments.length&&t.live&&r.setLiveSeekableRange){var n=Math.max(0,t.fragmentStart);return{duration:1/0,start:n,end:Math.max(n,i)}}return{duration:1/0}}var a=null==(e=this.overrides)?void 0:e.duration;if(a)return{duration:a};var s=this.media.duration;return i>(oO(r.duration)?r.duration:0)&&i>s||!oO(s)?{duration:i}:null}},{key:"updateMediaSource",value:function(e){var t,r,i=e.duration,n=e.start,a=e.end,s=this.mediaSource;this.media&&s&&"open"===s.readyState&&(s.duration!==i&&(oO(i)&&this.log("Updating MediaSource duration to ".concat(i.toFixed(3))),s.duration=i),void 0!==n&&void 0!==a&&(this.log(_d(t=_d(r="MediaSource duration is set to ".concat(s.duration,". Setting seekable range to ")).call(r,n,"-")).call(t,a,".")),s.setLiveSeekableRange(n,a)))}},{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,i=this.pendingTrackCount,n=this.tracks;if(this.log(_d(e=_d(t="checkPendingTracks (pending: ".concat(i," codec events expected: ")).call(t,r,") ")).call(e,KI(n))),this.tracksReady){var a,s=null==(a=this.transferData)?void 0:a.tracks;s&&zf(s).length?this.attachTransferred():(this.createSourceBuffers(),this.bufferCreated())}}},{key:"bufferCreated",value:function(){var e=this;if(this.sourceBufferCount){var t,r,i={};vd(t=this.sourceBuffers).call(t,(function(t){var r=cD(t,2),n=r[0],a=r[1];if(n){var s=e.tracks[n];i[n]={buffer:a,container:s.container,codec:s.codec,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}})),this.hls.trigger(dO.BUFFER_CREATED,{tracks:i}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),vd(r=this.sourceBuffers).call(r,(function(t){var r=cD(t,1)[0];e.executeNext(r)}))}else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.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 i in e){var n=i,a=e[n];if(this.isPending(a)){var s,o,l,u=this.getTrackCodec(a,n),c=_d(s="".concat(a.container,";codecs=")).call(s,u);a.codec=u,this.log(_d(o=_d(l="creating sourceBuffer(".concat(c,")")).call(l,this.currentOp(n)?" Queued":""," ")).call(o,KI(a)));try{var h=r.addSourceBuffer(c),d=vK(n),f=[n,h];t[d]=f,a.buffer=h}catch(QV){this.error("error while trying to add sourceBuffer: ".concat(QV.message)),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:QV,sourceBufferName:n,mimeType:c});break}this.trackSourceBuffer(n,a)}}}},{key:"getTrackCodec",value:function(e,t){var r=jO(e.codec,e.levelCodec);return r?"audio"===ag(t).call(t,0,5)?VO(r,this.appendSource):r:""}},{key:"trackSourceBuffer",value:function(e,t){var r=this,i=t.buffer;if(i){var n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,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 i=t.removedRanges;null!=i&&i.length&&r.hls.trigger(dO.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,i,n=new Error(_d(r="".concat(e," SourceBuffer error. MediaSource readyState: ")).call(r,null==(i=this.mediaSource)?void 0:i.readyState));this.error("".concat(n),t),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"removeExecutor",value:function(e,t,r){var i=this.media,n=this.mediaSource,a=this.tracks[e],s=null==a?void 0:a.buffer;if(!i||!n||!s)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var o,l,u=oO(i.duration)?i.duration:1/0,c=oO(n.duration)?n.duration:1/0,h=Math.max(0,t),d=Math.min(r,u,c);d>h&&(!a.ending||a.ended)?(a.ended=!1,this.log(_d(o=_d(l="Removing [".concat(h,",")).call(l,d,"] from the ")).call(o,e," SourceBuffer")),s.remove(h,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new hK("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));r.ending=!1,r.ended=!1,i.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()}},{key:"isUpdating",value:function(){var e;return cS(e=this.sourceBuffers).call(e,(function(e){var t=cD(e,2),r=t[0],i=t[1];return r&&i.updating}))}},{key:"isQueued",value:function(){var e,t=this;return cS(e=this.sourceBuffers).call(e,(function(e){var r=cD(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 Lk.resolve().then(e);var i=this.operationQueue,n=Jk(r).call(r,(function(e){return t.appendBlocker(e)}));r.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Lk.all(n).then((function(n){i===t.operationQueue&&(e(),t.stepOperationQueue(r))}))}},{key:"stepOperationQueue",value:function(e){var t=this;vd(e).call(e,(function(e){var r,i=null==(r=t.tracks[e])?void 0:r.buffer;i&&!i.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 mP(e=zf(this.tracks)).call(e,(function(e,r){return e+(t.isPending(t.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){var e;return mP(e=this.sourceBuffers).call(e,(function(e,t){return e+(cD(t,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){var e,t;return rT(e=Jk(t=this.sourceBuffers).call(t,(function(e){return cD(e,1)[0]}))).call(e,(function(e){return!!e}))}},{key:"addBufferListener",value:function(e,t,r){var i=this.tracks[e];if(i){var n=i.buffer;if(n){var a=RT(r).call(r,this,e);i.listeners.push({event:t,listener:a}),n.addEventListener(t,a)}}}},{key:"removeBufferListeners",value:function(e){var t,r=this.tracks[e];if(r){var i=r.buffer;i&&(vd(t=r.listeners).call(t,(function(e){i.removeEventListener(e.event,e.listener)})),r.listeners.length=0)}}}]),i}(RO);function fK(e){var t,r=e.querySelectorAll("source");vd(t=ag([]).call(r)).call(t,(function(t){e.removeChild(t)}))}function vK(e){return"audio"===e?1:0}var gK=function(){function e(r){t(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=r,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return Fc(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(dO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(dO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(dO.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&&oO(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,i,n,a=this.hls,s=this.getMaxLevel(e.length-1);if(s!==this.autoLevelCapping)a.logger.log(_d(t=_d(r=_d(i=_d(n="Setting autoLevelCapping to ".concat(s,": ")).call(n,e[s].height,"p@")).call(i,e[s].bitrate," for media ")).call(r,this.mediaWidth,"x")).call(t,this.mediaHeight));a.autoLevelCapping=s,a.autoLevelEnabled&&a.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=a.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=rT(i).call(i,(function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){var e;this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=PS(RT(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(t){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){var t=this.restrictedLevels;return!cS(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 i,n,a=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)&&(i=l,!(n=e[o+1])||i.width!==n.width||i.height!==n.height)){a=o;break}}return a}}]),e}(),pK={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},mK={DASH:"d",HLS:"h",SMOOTH:"s",OTHER:"o"},yK={OBJECT:"CMCD-Object",REQUEST:"CMCD-Request",SESSION:"CMCD-Session",STATUS:"CMCD-Status"},EK=(Lf(VM={},yK.OBJECT,["br","d","ot","tb"]),Lf(VM,yK.REQUEST,["bl","dl","mtp","nor","nrr","su"]),Lf(VM,yK.SESSION,["cid","pr","sf","sid","st","v"]),Lf(VM,yK.STATUS,["bs","rtp"]),VM),kK=Fc((function e(r,i){t(this,e),tT(r)&&(r=Jk(r).call(r,(function(t){return t instanceof e?t:new e(t)}))),this.value=r,this.params=i})),TK="Dict";function SK(e,t,r,i){var n,a,s;return new Error(_d(n=_d(a="failed to ".concat(e,' "')).call(a,(s=t,tT(s)?KI(s):s instanceof ZP?"Map{}":s instanceof KM?"Set{}":"object"===Pc(s)?KI(s):String(s)),'" as ')).call(n,r),{cause:i})}function AK(e,t,r){return SK("serialize",e,t,r)}var LK=Fc((function e(r){t(this,e),this.description=r})),bK="Bare Item",RK="Boolean";var IK="Byte Sequence";function DK(e){if(!1===ArrayBuffer.isView(e))throw AK(e,IK);return":".concat((t=e,btoa(String.fromCharCode.apply(String,uD(t)))),":");var t}var _K="Integer";function wK(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw AK(e,_K);return e.toString()}var PK="Decimal";function CK(e){var t=GB(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw AK(e,PK);var r=t.toString();return mv(r).call(r,".")?r:"".concat(r,".0")}var xK="String",MK=/[\x00-\x1f\x7f]+/;var OK="Token";function FK(e){var t,r,i=(t=e).description||ag(r=t.toString()).call(r,7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw AK(i,OK);return i}function NK(e){switch(Pc(e)){case"number":if(!oO(e))throw AK(e,bK);return sD(e)?wK(e):CK(e);case"string":return function(e){if(MK.test(e))throw AK(e,xK);return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(e);case"symbol":return FK(e);case"boolean":return function(e){if("boolean"!=typeof e)throw AK(e,RK);return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return"@".concat(wK(e.getTime()/1e3))}(e);if(e instanceof Uint8Array)return DK(e);if(e instanceof LK)return FK(e);default:throw AK(e,bK)}}var UK="Key";function BK(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw AK(e,UK);return e}function GK(e){var t;return null==e?"":Jk(t=jM(e)).call(t,(function(e){var t,r=cD(e,2),i=r[0],n=r[1];return!0===n?";".concat(BK(i)):_d(t=";".concat(BK(i),"=")).call(t,NK(n))})).join("")}function KK(e){var t;return e instanceof kK?_d(t="".concat(NK(e.value))).call(t,GK(e.params)):NK(e)}function HK(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!==Pc(e))throw AK(e,TK);var i=e instanceof ZP?JM(e).call(e):jM(e),n=(null==r?void 0:r.whitespace)?" ":"";return Jk(t=WT(i)).call(t,(function(e){var t=cD(e,2),r=t[0],i=t[1];i instanceof kK==!1&&(i=new kK(i));var n,a,s,o=BK(r);return!0===i.value?o+=GK(i.params):(o+="=",tT(i.value)?o+=_d(a="(".concat(Jk(s=(n=i).value).call(s,KK).join(" "),")")).call(a,GK(n.params)):o+=KK(i)),o})).join(",".concat(n))}var VK=function(e){return Math.round(e)},jK=function(e){return 100*VK(e/100)},YK={br:VK,d:VK,bl:jK,dl:jK,mtp:jK,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=function(e,t){var r,i,n=new NI(e),a=new NI(t);if(n.origin!==a.origin)return e;for(var s=ag(r=n.pathname.split("/")).call(r,1),o=ag(i=a.pathname.split("/")).call(i,1,-1);s[0]===o[0];)s.shift(),o.shift();for(;o.length;)o.shift(),s.unshift("..");return s.join("/")}(e,t.baseUrl)),encodeURIComponent(e)},rtp:jK,tb:VK};function qK(e,t){var r,i={};if(null==e||"object"!==Pc(e))return i;var n=GA(r=zf(e)).call(r),a=AO({},YK,null==t?void 0:t.formatters),s=null==t?void 0:rT(t);return vd(n).call(n,(function(r){if(!(null==s?void 0:s(r))){var n=e[r],o=a[r];o&&(n=o(n,t)),"v"===r&&1===n||"pr"==r&&1===n||function(e){return"number"==typeof e?oO(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return"ot"===e||"sf"===e||"st"===e}(r)&&"string"==typeof n&&(n=new LK(n)),i[r]=n)}})),i}function WK(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?function(e,t){return HK(e,t)}(qK(e,t),AO({whitespace:!1},t)):""}function zK(e,t,r){return AO(e,function(e){var t,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={};if(!e)return n;var a=jM(e),s=_d(t=jM(EK)).call(t,jM((null==i?void 0:i.customHeaderMap)||{})),o=mP(a).call(a,(function(e,t){var r,i,n=cD(t,2),a=n[0],o=n[1],l=(null===(r=Uv(s).call(s,(function(e){var t;return mv(t=e[1]).call(t,a)})))||void 0===r?void 0:r[0])||yK.REQUEST;return null!==(i=e[l])&&void 0!==i||(e[l]={}),e[l][a]=o,e}),{});return mP(r=jM(o)).call(r,(function(e,t){var r=cD(t,2),n=r[0],a=r[1];return e[n]=WK(a,i),e}),n)}(t,r))}var XK="CMCD";var QK=/CMCD=[^&#]+/;function $K(e,t,r){var i,n,a=function(e){if(!e)return"";var t=WK(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return"".concat(XK,"=").concat(encodeURIComponent(t))}(t,r);if(!a)return e;if(QK.test(e))return e.replace(QK,a);var s=mv(e).call(e,"?")?"&":"?";return _d(i=_d(n="".concat(e)).call(n,s)).call(i,a)}var JK=function(){function e(r){var i=this;t(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(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(e){try{i.apply(e,{ot:pK.MANIFEST,su:!i.initialized})}catch(QV){i.hls.logger.warn("Could not generate manifest CMCD data.",QV)}},this.applyFragmentData=function(e){try{var t=e.frag,r=e.part,n=i.hls.levels[t.level],a=i.getObjectType(t),s={d:1e3*(r||t).duration,ot:a};a!==pK.VIDEO&&a!==pK.AUDIO&&a!=pK.MUXED||(s.br=n.bitrate/1e3,s.tb=i.getTopBandwidth(a)/1e3,s.bl=i.getBufferLength(a));var o=r?i.getNextPart(r):i.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),i.apply(e,s)}catch(QV){i.hls.logger.warn("Could not generate segment CMCD data.",QV)}},this.hls=r;var n=this.config=r.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||r.sessionId,this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.includeKeys=a.includeKeys,this.registerListeners())}return Fc(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHED,this.onMediaDetached,this),e.on(dO.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHED,this.onMediaDetached,this),e.off(dO.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,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:mK.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]:{};AO(t,this.createData());var r=t.ot===pK.INIT||t.ot===pK.VIDEO||t.ot===pK.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var i,n=this.includeKeys;n&&(t=mP(i=zf(t)).call(i,(function(e,r){return mv(n).call(n,r)&&(e[r]=t[r]),e}),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),zK(e.headers,t,a)):e.url=$K(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){var i=e.sn-r.startSN;return r.fragments[i+1]}}},{key:"getNextPart",value:function(e){var t,r,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(r=t.details)?void 0:r.partList;if(a)for(var s=n.sn,o=a.length-1;o>=0;o--){var l=a[o];if(l.index===i&&l.fragment.sn===s)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?pK.TIMED_TEXT:"initSegment"===e.sn?pK.INIT:"audio"===t?pK.AUDIO:"main"===t?this.hls.audioTracks.length?pK.VIDEO:pK.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,i=this.hls;if(e===pK.AUDIO)t=i.audioTracks;else{var n,a=i.maxAutoLevel,s=a>-1?a+1:i.levels.length;t=ag(n=i.levels).call(n,0,s)}var o,l=function(e,t){var r=void 0!==hc&&DT(e)||e["@@iterator"];if(!r){if(eT(e)||(r=lD(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}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 a,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,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(t);try{for(l.s();!(o=l.n()).done;){var u=o.value;u.bitrate>r&&(r=u.bitrate)}}catch($V){l.e($V)}finally{l.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===pK.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*YN.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,r=this.applyPlaylistData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(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,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,r=this.applyFragmentData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(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,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}}]),e}(),ZK=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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 Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.ERROR,this.onError,this))}},{key:"pathways",value:function(){var e;return mP(e=this.levels||[]).call(e,(function(e,t){return-1===_v(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=rT(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)===RF&&IP(r)===wF){var i,n,a,s,o,l=this.levels,u=this._pathwayPriority,c=this.pathwayId;if(t.context){var h=t.context,d=h.groupId,f=h.pathwayId,v=h.type;d&&l?c=this.getPathwayForGroupId(d,v,c):f&&(c=f)}if(c in this.penalizedPathways||(this.penalizedPathways[c]=performance.now()),!u&&l&&(u=this.pathways()),u&&u.length>1&&(this.updatePathwayPriority(u),r.resolved=this.pathwayId!==c),!r.resolved)this.warn(_d(i=_d(n=_d(a=_d(s=_d(o="Could not resolve ".concat(t.details,' ("')).call(o,t.error.message,'") with content-steering for Pathway: ')).call(s,c," levels: ")).call(a,l?l.length:l," priorities: ")).call(n,KI(u)," penalized: ")).call(i,KI(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t,r,i=this.getLevelsForPathway(this.pathwayId);if(0===i.length){var n,a=e[0].pathwayId;this.log(_d(n="No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "')).call(n,a,'"')),i=this.getLevelsForPathway(a),this.pathwayId=a}i.length!==e.length&&this.log(_d(t=_d(r="Found ".concat(i.length,"/")).call(r,e.length,' levels in Pathway "')).call(t,this.pathwayId,'"'));return i}},{key:"getLevelsForPathway",value:function(e){var t;return null===this.levels?[]:rT(t=this.levels).call(t,(function(t){return e===t.pathwayId}))}},{key:"updatePathwayPriority",value:function(e){var t,r;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();vd(t=zf(i)).call(t,(function(e){n-i[e]>3e5&&delete i[e]}));for(var a=0;a<e.length;a++){var s=e[a];if(!(s in i)){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,tB(r),this.hls.trigger(dO.LEVELS_UPDATED,{levels:r});var u=this.hls.levels[o];if(l&&u&&this.levels){var c;if(u.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==l.bitrate)this.log(_d(c="Unstable Pathways change from bitrate ".concat(l.bitrate," to ")).call(c,u.bitrate));this.hls.nextLoadLevel=o}break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var i,n=_d(i=this.getLevelsForPathway(r)).call(i,this.levels||[]),a=0;a<n.length;a++)if(t===gO&&n[a].hasAudioGroup(e)||t===pO&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return r}},{key:"clonePathways",value:function(e){var t=this,r=this.levels;if(r){var i={},n={};vd(e).call(e,(function(e){var a,s=e.ID,o=e["BASE-ID"],l=e["URI-REPLACEMENT"];if(!cS(r).call(r,(function(e){return e.pathwayId===s}))){var u=Jk(a=t.getLevelsForPathway(o)).call(a,(function(e){var t,r,a=new ZN(e.attrs);a["PATHWAY-ID"]=s;var o=a.AUDIO&&_d(t="".concat(a.AUDIO,"_clone_")).call(t,s),u=a.SUBTITLES&&_d(r="".concat(a.SUBTITLES,"_clone_")).call(r,s);o&&(i[a.AUDIO]=o,a.AUDIO=o),u&&(n[a.SUBTITLES]=u,a.SUBTITLES=u);var c=tH(e.uri,a["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),h=new iF({attrs:a,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:c,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++){var f;h.addGroupId("audio",_d(f="".concat(e.audioGroups[d],"_clone_")).call(f,s))}if(e.subtitleGroups)for(var v=1;v<e.subtitleGroups.length;v++){var g;h.addGroupId("text",_d(g="".concat(e.subtitleGroups[v],"_clone_")).call(g,s))}return h}));r.push.apply(r,uD(u)),eH(t.audioTracks,i,l,s),eH(t.subtitleTracks,n,l,s)}}))}}},{key:"loadSteeringManifest",value:function(e){var t,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new NI(e)}catch(QV){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: ".concat(e))}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var s={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},c={onSuccess:function(e,i,n,a){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"],u=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new NI(o,t).href}catch(QV){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(o))}r.scheduleRefresh(r.uri||n.url),l&&r.clonePathways(l);var c={steeringManifest:s,url:t.toString()};r.hls.trigger(dO.STEERING_MANIFEST_LOADED,c),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION ".concat(s.VERSION," not supported!"))},onError:function(e,t,i,n){var a,s;if(r.log(_d(a=_d(s="Error loading steering manifest: ".concat(e.code," ")).call(s,e.text," (")).call(a,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 u=l.getResponseHeader("Retry-After");u&&(o=1e3*zS(u))}r.log("Steering manifest ".concat(t.url," rate limited"))}},onTimeout:function(e,t,i){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,u,c)}},{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=Wf((function(){var r,i=null==(r=t.hls)?void 0:r.media;!i||i.ended?t.scheduleRefresh(e,1e3*t.timeToLoad):t.loadSteeringManifest(e)}),r)}}]),i}(RO);function eH(e,t,r,i){var n;e&&vd(n=zf(t)).call(n,(function(n){var a,s=Jk(a=rT(e).call(e,(function(e){return e.groupId===n}))).call(a,(function(e){var a=AO({},e);return a.details=void 0,a.attrs=new ZN(a.attrs),a.url=a.attrs.URI=tH(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=t[n],a.attrs["PATHWAY-ID"]=i,a}));e.push.apply(e,uD(s))}))}function tH(e,t,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];t&&(n=null==o?void 0:o[t])&&(e=n);var l,u,c=new NI(e);(a&&!n&&(c.host=a),s)&&vd(l=GA(u=zf(s)).call(u)).call(l,(function(e){e&&c.searchParams.set(e,s[e])}));return c.href}var rH=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],n.onMediaEncrypted=function(e){var t,r=e.initDataType,i=e.initData,a=_d(t='"'.concat(e.type,'" event: init data type: "')).call(t,r,'"');if(n.debug(a),null!==i){var s,o;if("sinf"===r&&n.getLicenseServerUrl(cU)){var l=vN(new Uint8Array(i));try{var u=IN(aU(JSON.parse(l).sinf));if(!u)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=u.subarray(8,24),o=cU}catch(QV){var c;return void n.warn(_d(c="".concat(a," Failed to parse sinf: ")).call(c,QV))}}else if(n.getLicenseServerUrl(dU)){var h=function(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,i=0;i+32<r;){var n=ON(new DataView(e,i));t.push(n),i+=n.size}return t}(i),d=zf(n.keySystemAccessPromises);d.length||(d=LU(n.config));var f=rT(h).call(h,(function(e){var t=e.systemId?SU(e.systemId):null;return!!t&&_v(d).call(d,t)>-1}))[0];if(!f){var v;if(0===h.length||cS(h).call(h,(function(e){return!e.systemId})))n.warn("".concat(a," contains incomplete or invalid pssh data"));else n.log(_d(v="ignoring ".concat(a," for ")).call(v,Jk(h).call(h,(function(e){return SU(e.systemId)})).join(",")," pssh data in favor of playlist keys"));return}if(o=SU(f.systemId),0===f.version&&f.data)if(o===dU){var g=f.data.length-22;s=f.data.subarray(g,g+16)}else o===hU&&(s=_U(f.data))}if(o&&s){for(var p=zF.hexDump(s),m=Zh(n),y=m.keyIdToKeySessionPromise,E=m.mediaKeySessions,k=y[p],T=function(){var e,t=E[S],a=t.decryptdata;if(!a.keyId)return"continue";var o=zF.hexDump(a.keyId);return p===o||-1!==_v(e=a.uri.replace(/-/g,"")).call(e,p)?(k=y[o],a.pssh||(delete y[o],a.pssh=new Uint8Array(i),a.keyId=s,(k=y[p]=k.then((function(){return n.generateRequestWithPreferredKeySession(t,r,i,"encrypted-event-key-match")}))).catch((function(e){return n.handleError(e)}))),"break"):void 0},S=0;S<E.length;S++){var A=T();if("continue"!==A&&"break"===A)break}k||(k=y[p]=n.getKeySystemSelectionPromise([o]).then((function(e){var t,a=e.keySystem,o=e.mediaKeys;n.throwIfDestroyed();var l=new PU("ISO-23001-7",p,null!=(t=AU(a))?t:"");return l.pssh=new Uint8Array(i),l.keyId=s,n.attemptSetMediaKeys(a,o).then((function(){n.throwIfDestroyed();var e=n.createMediaKeySessionContext({decryptdata:l,keySystem:a,mediaKeys:o});return n.generateRequestWithPreferredKeySession(e,r,i,"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 Fc(i,[{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(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(dO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(dO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,r=t.drmSystems,i=t.widevineLicenseUrl,n=r[e];return n?n.licenseUrl:e===dU&&i?i: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,i=this,n=this.hls.levels,a=function(e,t,r){return!!e&&_v(r).call(r,e)===t},s=rT(t=Jk(n).call(n,(function(e){return e.audioCodec}))).call(t,a),o=rT(r=Jk(n).call(n,(function(e){return e.videoCodec}))).call(r,a);return s.length+o.length===0&&o.push("avc1.42e01e"),new Lk((function(t,r){!function e(n){var a=n.shift();i.getMediaKeysPromise(a,s,o).then((function(e){return t({keySystem:a,mediaKeys:e})})).catch((function(t){n.length?e(n):r(t instanceof iH?t:new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.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 i="Configured requestMediaKeySystemAccess is not a function ".concat(r);return null===IU&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),Lk.reject(new Error(i))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var i=this,n=DU(e,t,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e],s=null==a?void 0:a.keySystemAccess;if(!s){var o;this.log(_d(o='Requesting encrypted media "'.concat(e,'" key-system access with config: ')).call(o,KI(n))),s=this.requestMediaKeySystemAccess(e,n);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){var r;i.log(_d(r='Failed to obtain access to key-system "'.concat(e,'": ')).call(r,t))})),s.then((function(t){i.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=i.fetchServerCertificate(e);return i.log('Create media-keys for "'.concat(e,'"')),l.mediaKeys=t.createMediaKeys().then((function(t){return i.log('Media-keys created for "'.concat(e,'"')),r.then((function(r){return r?i.setMediaKeysServerCertificate(t,e,r):t}))})),l.mediaKeys.catch((function(t){var r;i.error(_d(r='Failed to create media-keys for "'.concat(e,'"}: ')).call(r,t))})),l.mediaKeys}))}return s.then((function(){return a.mediaKeys}))}},{key:"createMediaKeySessionContext",value:function(e){var t,r=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log(_d(t='Creating key-system session "'.concat(i,'" keyId: ')).call(t,zF.hexDump(r.keyId||[])));var a=n.createSession(),s={decryptdata:r,keySystem:i,mediaKeys:n,mediaKeysSession:a,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),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=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 zF.hexDump(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,i,n,a=e.mediaKeysSession;return this.log(_d(r=_d(i='Updating key-session "'.concat(a.sessionId,'" for keyID ')).call(i,zF.hexDump((null==(n=e.decryptdata)?void 0:n.keyId)||[]),"\n } (data length: ")).call(r,t?t.byteLength:t,")")),a.update(t)}},{key:"selectKeySystemFormat",value:function(e){var t,r,i,n=zf(e.levelkeys||{});this.keyFormatPromise||(this.log(_d(t=_d(r=_d(i="Selecting key-system from fragment (sn: ".concat(e.sn," ")).call(i,e.type,": ")).call(r,e.level,") key formats ")).call(t,n.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(n));return this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new Lk((function(r,i){var n,a=LU(t.config),s=rT(n=Jk(e).call(e,mU)).call(n,(function(e){return!!e&&-1!==_v(a).call(a,e)}));return t.getKeySystemSelectionPromise(s).then((function(e){var t=e.keySystem,n=AU(t);n?r(n):i(new Error('Unable to find format for key-system "'.concat(t,'"')))})).catch(i)}))}},{key:"loadKey",value:function(e){var t,r,i,n=this,a=e.keyInfo.decryptdata,s=this.getKeyIdString(a),o=_d(t=_d(r=_d(i="(keyId: ".concat(s,' format: "')).call(i,a.keyFormat,'" method: ')).call(r,a.method," uri: ")).call(t,a.uri,")");this.log("Starting session for key ".concat(o));var l=this.keyIdToKeySessionPromise[s];l||(l=this.getKeySystemForKeyPromise(a).then((function(t){var r,i,s,l=t.keySystem,u=t.mediaKeys;return n.throwIfDestroyed(),n.log(_d(r=_d(i=_d(s="Handle encrypted media sn: ".concat(e.frag.sn," ")).call(s,e.frag.type,": ")).call(i,e.frag.level," using key ")).call(r,o)),n.attemptSetMediaKeys(l,u).then((function(){return n.throwIfDestroyed(),n.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:a})}))})),(this.keyIdToKeySessionPromise[s]=l.then((function(e){var t=a.pssh?a.pssh.buffer:null;return n.generateRequestWithPreferredKeySession(e,"cenc",t,"playlist-key")}))).catch((function(e){return n.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 iH?this.hls.trigger(dO.ERROR,e.data):this.hls.trigger(dO.ERROR,{type:cO.KEY_SYSTEM_ERROR,details:hO.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 i=mU(e.keyFormat),n=i?[i]:LU(this.config);return this.attemptKeySystemAccess(n)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=LU(this.config)),0===e.length)throw new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(KI({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r,i=this,n=ag(r=this.setMediaKeysQueue).call(r);this.log('Setting media-keys for "'.concat(e,'"'));var a=Lk.all(n).then((function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(a),a.then((function(){var t;i.log('Media-keys set for "'.concat(e,'"')),n.push(a),i.setMediaKeysQueue=rT(t=i.setMediaKeysQueue).call(t,(function(e){return-1===_v(n).call(n,e)}))}))}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,r,i){var n,a,s,o,l,u=this,c=null==(o=this.config.drmSystems)||null==(l=o[e.keySystem])?void 0:l.generateRequest;if(c)try{var h=c.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=h.initData?h.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(QV){var d;if(this.warn(QV.message),null!=(d=this.hls)&&d.config.debug)throw QV}if(null===r)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),Lk.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log(_d(n=_d(a=_d(s='Generating key-session request for "'.concat(i,'": ')).call(s,f," (init data type: ")).call(a,t," length: ")).call(n,r?r.byteLength:null,")"));var v=new AB,g=e._onmessage=function(t){var r,i,n=e.mediaKeysSession;if(n){var a=t.messageType,s=t.message;u.log(_d(r=_d(i='"'.concat(a,'" message event for session "')).call(i,n.sessionId,'" message size: ')).call(r,s.byteLength)),"license-request"===a||"license-renewal"===a?u.renewLicense(e,s).catch((function(e){v.eventNames().length?v.emit("error",e):u.handleError(e)})):"license-release"===a?e.keySystem===cU&&(u.updateKeySession(e,sU("acknowledged")),u.removeSession(e)):u.warn('unhandled media key message type "'.concat(a,'"'))}else v.emit("error",new Error("invalid state"))},p=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){u.onKeyStatusChange(e);var r,i=e.keyStatus;if(v.emit("keyStatus",i),"expired"===i)u.warn(_d(r="".concat(e.keySystem," expired for key ")).call(r,f)),u.renewKeySession(e)}else v.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",g),e.mediaKeysSession.addEventListener("keystatuseschange",p);var m=new Lk((function(e,t){v.on("error",t),v.on("keyStatus",(function(r){rD(r).call(r,"usable")?e():"output-restricted"===r?t(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(r,'"'))):"expired"===r?t(new Error("key expired while generating request")):u.warn('unhandled key status change "'.concat(r,'"'))}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t,r;u.log(_d(t='Request generated for key-session "'.concat(null==(r=e.mediaKeysSession)?void 0:r.sessionId,'" keyId: ')).call(t,f))})).catch((function(e){throw new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: ".concat(e))})).then((function(){return m})).catch((function(t){throw v.removeAllListeners(),u.removeSession(e),t})).then((function(){return v.removeAllListeners(),e}))}},{key:"onKeyStatusChange",value:function(e){var t,r=this;vd(t=e.mediaKeysSession.keyStatuses).call(t,(function(t,i){var n,a,s;r.log(_d(n=_d(a=_d(s='key status change "'.concat(t,'" for keyStatuses keyId: ')).call(s,zF.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))," session keyId: ")).call(a,zF.hexDump(new Uint8Array(e.decryptdata.keyId||[]))," uri: ")).call(n,e.decryptdata.uri)),e.keyStatus=t}))}},{key:"fetchServerCertificate",value:function(e){var t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching server certificate for "'.concat(e,'"')),new Lk((function(n,a){var s={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:function(e,t,r,i){n(e.data)},onError:function(t,r,n,o){var l,u,c;a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:bO({url:s.url,data:void 0},t)},_d(l=_d(u=_d(c='"'.concat(e,'" certificate request failed (')).call(c,i,"). Status: ")).call(u,t.code," (")).call(l,t.text,")")))},onTimeout:function(t,r,n){var o;a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:s.url,data:void 0}},_d(o='"'.concat(e,'" certificate request timed out (')).call(o,i,")")))},onAbort:function(e,t,r){a(new Error("aborted"))}};r.load(s,l,u)}))):Lk.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var i=this;return new Lk((function(n,a){e.setServerCertificate(r).then((function(a){var s,o;i.log(_d(s=_d(o="setServerCertificate ".concat(a?"success":"not supported by CDM"," (")).call(o,null==r?void 0:r.byteLength,') on "')).call(s,t,'"')),n(e)})).catch((function(e){a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.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 iH({type:cO.KEY_SYSTEM_ERROR,details:hO.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(!mv(r).call(r,"PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var i=(new DOMParser).parseFromString(r,"application/xml"),n=i.querySelectorAll("HttpHeader");if(n.length>0)for(var a,s=0,o=n.length;s<o;s++){var l,u,c=null==(l=(a=n[s]).querySelector("name"))?void 0:l.textContent,h=null==(u=a.querySelector("value"))?void 0:u.textContent;c&&h&&e.setRequestHeader(c,h)}var d=i.querySelector("Challenge"),f=null==d?void 0:d.textContent;if(!f)throw new Error("Cannot find <Challenge> in key message");return sU(atob(f))}},{key:"setupLicenseXHR",value:function(e,t,r,i){var n=this,a=this.config.licenseXhrSetup;return a?Lk.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return a.call(n.hls,e,t,r,i)})).catch((function(s){if(!r.decryptdata)throw s;return e.open("POST",t,!0),a.call(n.hls,e,t,r,i)})).then((function(r){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||i}})):(e.open("POST",t,!0),Lk.resolve({xhr:e,licenseChallenge:i}))}},{key:"requestLicense",value:function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new Lk((function(n,a){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 a(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 u=r.config.licenseResponseCallback;if(u)try{l=u.call(r.hls,o,s,e)}catch(QV){r.error(QV)}n(l)}else{var c=i.errorRetry,h=c?c.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>h||o.status>=400&&o.status<500){var d,f;a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},_d(d=_d(f="License Request XHR failed (".concat(s,"). Status: ")).call(f,o.status," (")).call(d,o.statusText,")")))}else{var v=h-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(v," attempts left")),r.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,t).then((function(t){var i=t.xhr,n=t.licenseChallenge;e.keySystem==hU&&(n=r.unpackPlayReadyKeyMessage(i,n)),i.send(n)}))}))}},{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,r=this,n=this.media,a=this.mediaKeySessions;n&&(n.removeEventListener("encrypted",this.onMediaEncrypted),n.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},PU.clearKeyUriToKeyIdMap();var s=a.length;i.CDMCleanupPromise=Lk.all(_d(e=Jk(a).call(a,(function(e){return r.removeSession(e)}))).call(e,null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch((function(e){var t;r.log("Could not clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){s&&(r.log("finished closing key sessions and clearing media keys"),a.length=0)})).catch((function(e){var t;r.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.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 i=mP(r).call(r,(function(e,t){return-1===_v(e).call(e,t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys ".concat(i.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){var n;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),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a,s=_v(n=this.mediaKeySessions).call(n,e);if(s>-1)Rg(a=this.mediaKeySessions).call(a,s,1);return r.remove().catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.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(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),i}(RO);rH.CDMCleanupPromise=void 0;var iH=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n)).data=void 0,e.error||(e.error=new Error(n)),a.data=e,e.err=e.error,a}return Fc(i)}(Jw(Error)),nH=function(){function e(r){t(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=r,this.registerListeners()}return Fc(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(dO.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 i,n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=PS(RT(i=this.checkFPSInterval).call(i,this),r.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(dO.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(dO.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,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 aH(e,t){var r;try{r=new Event("addtrack")}catch($V){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function sH(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($V){CO.debug("[texttrack-utils]: ".concat($V));try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(n){CO.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(n))}}"disabled"===r&&(e.mode=r)}function oH(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(var i=e.cues.length;i--;)t&&e.cues[i].removeEventListener("enter",t),e.removeCue(e.cues[i]);"disabled"===r&&(e.mode=r)}function lH(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;var i=0,n=r;for(;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}function uH(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}var cH=function(e){Ch(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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=uH(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 i=n.findTrackForTextTrack(e);n.subtitleTrack!==i&&n.setSubtitleTrack(i)}},n.registerListeners(),n}return Fc(i,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,Ih(Rh(i.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(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVEL_LOADING,this.onLevelLoading,this),e.off(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(dO.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=PS(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;if(r){var i=!!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,!i){var n=uH(r.textTracks);vd(n).call(n,(function(e){oH(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,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Subtitle track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Subtitle track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.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,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&cS(r).call(r,(function(e){return-1===(null==i?void 0:_v(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=rT(a=this.tracks).call(a,(function(e){return!r||-1!==_v(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!cS(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.subtitlePreference;if(!n&&l){this.selectDefaultTrack=!1;var u=uF(l,o);if(u>-1)n=o[u];else{var c=uF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={subtitleTracks:o};this.log(_d(s="Updating subtitle tracks, ".concat(o.length,' track(s) found in "')).call(s,null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(dO.SUBTITLE_TRACKS_UPDATED,d),-1!==h&&-1===this.trackId&&this.setSubtitleTrack(h)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=this.selectDefaultTrack,i=0;i<t.length;i++){var n=t[i];if((!r||n.default)&&(r||e)&&(!e||cF(n,e)))return i}if(e){for(var a=0;a<t.length;a++){var s=t[a];if(iK(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return a}for(var o=0;o<t.length;o++){var l=t[o];if(iK(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(nK(t[r],e))return r}return-1}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==pO||t.context.id!==this.trackId||this.groupIds&&-1===_v(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&&cF(e,r))return r;var i=uF(e,this.tracksInGroup);if(i>-1){var n=this.tracksInGroup[i];return this.setSubtitleTrack(i),n}if(r)return null;var a=uF(e,t);if(a>-1)return t[a]}}return null}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading subtitle ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(dO.SUBTITLE_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}},{key:"toggleTrackModes",value:function(){var e,t=this.media;if(t){var r,i,n=uH(t.textTracks),a=this.currentTrack;if(a)if(!(r=rT(n).call(n,(function(e){return nK(a,e)}))[0]))this.warn(_d(i='Unable to find subtitle TextTrack with name "'.concat(a.name,'" and language "')).call(i,a.lang,'"'));if(vd(e=ag([]).call(n)).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,i=this.tracksInGroup;if(this.media)if(e<-1||e>=i.length||!oO(e))this.warn("Invalid subtitle track id: ".concat(e));else{this.selectDefaultTrack=!1;var n=this.currentTrack,a=i[e]||null;if(this.trackId=e,this.currentTrack=a,this.toggleTrackModes(),a){var s=!!a.details&&!a.details.live;if(e!==this.trackId||a!==n||!s){this.log("Switching to subtitle-track ".concat(e)+(a?_d(t=_d(r=' "'.concat(a.name,'" lang:')).call(r,a.lang," group:")).call(t,a.groupId):""));var o=a.id,l=a.groupId,u=void 0===l?"":l,c=a.name,h=a.type,d=a.url;this.hls.trigger(dO.SUBTITLE_TRACK_SWITCH,{id:o,groupId:u,name:c,type:h,url:d});var f=this.switchParams(a.url,null==n?void 0:n.details,a.details);this.loadPlaylist(f)}}else this.hls.trigger(dO.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),i}(sK);function hH(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var dH=.02,fH=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function vH(e,t,r){var i,n;return _d(i=_d(n="".concat(e.identifier,"-")).call(n,r+1,"-")).call(i,hH(t))}var gH=function(){function e(r,i){t(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=i,this.dateRange=r,this.setDateRange(r)}return Fc(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 _v(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 pH(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=oO(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 pH(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)<dH))},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"]?fH.Range:fH.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 _d(t=_d(r=_d(i='["'.concat((e=this).identifier,'" ')).call(i,e.cue.pre?"<pre>":e.cue.post?"<post>":"")).call(r,e.timelineStart.toFixed(2),"-")).call(t,e.resumeTime.toFixed(2),"]");var e,t,r,i}}]),e}();function pH(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<dH)?t.start:t.start+t.duration}function mH(e,t,r){var i=new NI(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function yH(e){var t,r,i=e.timelineStart,n=e.duration||0;return _d(t=_d(r='["'.concat(e.identifier,'" ')).call(r,i.toFixed(2),"-")).call(t,(i+n).toFixed(2),"]")}var EH=function(){function e(r,i,n,a){var s=this;t(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=s.interstitial.playoutLimit;s.playoutOffset+s.currentTime>=e&&s.hls.trigger(dO.PLAYOUT_LIMIT_REACHED,{})};var o=this.hls=new r(i);this.interstitial=n,this.assetItem=a;var l=a.uri;try{l=mH(l,o.sessionId).href}catch(QV){}o.loadSource(l);var u=function(){s.hasDetails=!0};o.once(dO.LEVEL_LOADED,u),o.once(dO.AUDIO_TRACK_LOADED,u),o.once(dO.SUBTITLE_TRACK_LOADED,u),o.on(dO.MEDIA_ATTACHING,(function(e,t){var r=t.media;s.removeMediaListeners(),s.mediaAttached=r;var i,n,o=s.interstitial;o.playoutLimit&&(s.playoutOffset=(null==(n=o.assetList[_v(i=o.assetList).call(i,a)])?void 0:n.startOffset)||0,r.addEventListener("timeupdate",s.checkPlayout))}))}return Fc(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=YN.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 _d(e=_d(t="HlsAssetPlayer: ".concat(yH(this.assetItem)," ")).call(t,this.hls.sessionId," ")).call(e,this.interstitial.appendInPlace?"append-in-place":"")}}]),e}(),kH=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 Fc(i,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){var e;(this.eventMap={},this.setDurations(0,0,0),this.events)&&vd(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 i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(n=i[r])&&n.event;){var n;r--}return r}},{key:"findItemIndexAtTime",value:function(e,t){var r=this.items;if(r)for(var i=0;i<r.length;i++){var n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return i}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var r=this.items;if(r)for(var i=e;i<=t&&r[i];i++){var n=r[i].event;if(null!=n&&n.restrictions.jump&&!n.appendInPlace)return i}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var r=t.length;r--;){var i;if((null==(i=t[r].event)?void 0:i.identifier)===e)return r}return-1}},{key:"findAssetIndex",value:function(e,t){var r=e.assetList,i=r.length;if(i>1)for(var n=0;n<i;n++){var a=r[n];if(!a.error){var s=a.timelineStart;if(t===s||t>s&&t<s+(a.duration||0))return n}}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 i=r.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e){var t=this,r=e.main.details,i=r.dateRanges,n=this.events,a=this.parseDateRanges(i,{url:r.url}),s=zf(i),o=n?rT(n).call(n,(function(e){return!mv(s).call(s,e.identifier)})):[];a.length&&GA(a).call(a,(function(e,t){var r=e.cue.pre,i=e.cue.post,n=t.cue.pre,a=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!a)return 1;if(a&&!i)return-1;if(!(r||n||i||a)){var s=e.startTime,o=t.startTime;if(s!==o)return s-o}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=a,vd(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 i=this.items,n=this.parseSchedule(r,e);(t.length||(null==i?void 0:i.length)!==n.length||cS(n).call(n,(function(e,t){return Math.abs(e.playout.start-i[t].playout.start)>.005||Math.abs(e.playout.end-i[t].playout.end)>.005})))&&(this.items=n,this.onScheduleUpdate(t,i))}}},{key:"parseDateRanges",value:function(e,t){for(var r=[],i=zf(e),n=0;n<i.length;n++){var a=i[n],s=e[a];if(s.isInterstitial){var o=this.eventMap[a];o?o.setDateRange(s):(o=new gH(s,t),this.eventMap[a]=o),r.push(o)}}return r}},{key:"parseSchedule",value:function(e,t){var r=[],i=t.main.details,n=i.live?1/0:i.edge,a=0;if((e=rT(e).call(e,(function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(vd(e).call(e,(function(t,i){var l=t.cue.pre,u=t.cue.post,c=e[i-1]||null,h=t.appendInPlace,d=u?n:t.startOffset,f=t.duration,v=t.timelineOccupancy===fH.Range?f:0,g=t.resumptionOffset,p=(null==c?void 0:c.startTime)===d,m=d+t.cumulativeDuration,y=h?m+f:d+g;if(l||!u&&d<=0){var E=o;o+=v,t.timelineStart=m;var k=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:k,end:a},integrated:{start:E,end:o}})}else{if(!(d<=n))return;if(!p){var T=d-s;if(T>.033){var S=s,A=o;o+=T;var L=a;a+=T;var b={previousEvent:e[i-1]||null,nextEvent:t,start:S,end:S+T,playout:{start:L,end:a},integrated:{start:A,end:o}};r.push(b)}else T>0&&c&&(c.cumulativeDuration+=T,r[r.length-1].end=d)}u&&(y=m),t.timelineStart=m;var R=o;o+=v;var I=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:I,end:a},integrated:{start:R,end:o}})}var D=t.resumeTime;s=u||D>n?n:D})),s<n){var l,u=s,c=o,h=n-s;o+=h;var d=a;a+=h,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:s,end:u+h,playout:{start:d,end:a},integrated:{start:c,end:o}})}this.setDurations(n,a,o)}else{r.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n)}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,i=t.main.details,n=i.live?1/0:i.edge,a=0,s=-1;vd(e).call(e,(function(o,l){var u=o.cue.pre,c=o.cue.post,h=u?0:c?n:o.startTime;(r.updateAssetDurations(o),s===h?o.cumulativeDuration=a:(a=0,s=h),!c&&o.snapOptions.in&&(o.resumeAnchor=pF(null,i.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 d=l-1;l--;){e[d+1].startTime-e[d].resumeTime<.033&&(e[d].appendInPlace=!1)}var f=oO(o.resumeOffset)?o.resumeOffset:o.duration;a+=f}))}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var r,i,n,a,s=this,o=e.resumeTime,l=e.startTime+e.resumptionOffset;return Math.abs(o-l)>dH?(this.log(_d(i=_d(n='"'.concat(e.identifier,'" resumption ')).call(n,o," not aligned with estimated timeline end ")).call(i,l)),!1):t?!cS(r=zf(t)).call(r,(function(r){var i,n,a,l=t[r].details,u=l.edge;if(o>u)return s.log(_d(i=_d(n=_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," past ")).call(n,r," playlist end ")).call(i,u)),!0;var c,h,d=pF(null,l.fragments,o);if(!d)return s.log(_d(c=_d(h='"'.concat(e.identifier,'" resumption ')).call(h,o," does not align with any fragments in ")).call(c,r," playlist")),!0;var f,v,g,p,m,y,E="audio"===r?.175:0;return!(Math.abs(d.start-o)<dH||Math.abs(d.end-o)<dH+E)&&(s.log(_d(f=_d(v=_d(g=_d(p=_d(m=_d(y='"'.concat(e.identifier,'" resumption ')).call(y,o," not aligned with ")).call(m,r," fragment bounds (")).call(p,d.start,"-")).call(g,d.end," sn: ")).call(v,d.sn," cc: ")).call(f,d.cc,")")),!0)})):(this.log(_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," can not be aligned with media (none selected)")),!1)}},{key:"updateAssetDurations",value:function(e){var t,r=e.timelineStart,i=0,n=!1,a=!1;vd(t=e.assetList).call(t,(function(e,t){var s=r+i;e.startOffset=i,e.timelineStart=s,n||(n=null===e.duration),a||(a=!!e.error);var o=e.error?0:e.duration||0;i+=o})),e.duration=n&&!a?Math.max(i,e.duration):i}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}]),i}(RO);function TH(e){var t,r;return _d(t=_d(r="[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ")).call(r,e.start.toFixed(2),"-")).call(t,e.end.toFixed(2),"]")}var SH=function(){function e(r){t(this,e),this.hls=void 0,this.hls=r}return Fc(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,i=this,n=e.assetListUrl;try{r=mH(n,this.hls.sessionId,e.baseUrl)}catch(QV){var a=this.assignAssetListError(e,hO.ASSET_LIST_LOAD_ERROR,QV,n);return void this.hls.trigger(dO.ERROR,a)}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),u={responseType:"json",url:r.href},c=o.interstitialAssetListLoadPolicy.default,h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:function(t,r,n,a){var s=t.data,o=null==s?void 0:s.ASSETS;if(tT(o))e.assetListResponse=s,i.hls.trigger(dO.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:a});else{var l=i.assignAssetListError(e,hO.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,r,a);i.hls.trigger(dO.ERROR,l)}},onError:function(t,r,n,a){var s,o,l=i.assignAssetListError(e,hO.ASSET_LIST_LOAD_ERROR,new Error(_d(s=_d(o="Error loading X-ASSET-LIST: HTTP status ".concat(t.code," ")).call(o,t.text," (")).call(s,r.url,")")),r.url,a,n);i.hls.trigger(dO.ERROR,l)},onTimeout:function(t,r,n){var a=i.assignAssetListError(e,hO.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,n);i.hls.trigger(dO.ERROR,a)}};return l.load(u,h,d),this.hls.trigger(dO.ASSET_LIST_LOADING,{event:e}),l}},{key:"assignAssetListError",value:function(e,t,r,i,n,a){return e.error=r,{type:cO.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:a,stats:n}}}]),e}();function AH(e){null==e||e.play().catch()}var LH=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 i=a.playingItem;if(i)if(r&&e<i.start||e>=i.end){var n,s=a.schedule.findItemIndexAtTime(a.timelinePos);if(!a.isInterstitial(i)&&null!=(n=a.media)&&n.paused&&(a.shouldPlay=!1),!r){var o=a.findItemIndex(i);if(s>o){var l=a.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void a.setSchedulePosition(l)}}a.setSchedulePosition(s)}else{var u=a.playingAsset;if(u){var c=u.timelineStart,h=u.duration||0;(r&&e<c||e>=c+h)&&a.setScheduleToAssetAtTime(e,u)}else if(a.playingLastItem&&a.isInterstitial(i)){var d=i.event.assetList[0];d&&(a.playingItem=null,a.setScheduleToAssetAtTime(e,d))}}}}},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 i=a.playingAsset;if(i)e>=i.timelineStart+(i.duration||0)&&a.setScheduleToAssetAtTime(e,i)}}},a.onScheduleUpdate=function(e,t){var r,i,n,s=a.schedule,o=a.playingItem,l=s.events||[],u=s.items||[],c=s.durations,h=Jk(e).call(e,(function(e){return e.identifier})),d=!(!l.length&&!h.length);d&&(!1===a.hls.config.interstitialAppendInPlace&&vd(l).call(l,(function(e){return e.appendInPlace=!1})),a.log(_d(i=_d(n="INTERSTITIALS_UPDATED (".concat(l.length,"): ")).call(n,l,"\nSchedule: ")).call(i,Jk(u).call(u,(function(e){return TH(e)})))));h.length&&a.log("Removed events ".concat(h)),vd(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 i,n,s;if(Math.abs(r)>dH)a.warn(_d(i=_d(n=_d(s="".concat(o,' ("')).call(s,e.assetId,'" ')).call(n,e.timelineOffset,"->")).call(i,t,")"))}}})),o&&!o.event&&(a.playingItem=a.updateItem(o,a.timelinePos));var f=a.bufferingItem;if(f&&(f.event?a.updateItem(f)||(a.bufferingItem=null,a.clearInterstitial(f.event,null)):a.bufferingItem=a.updateItem(f,a.bufferedPos)),a.waitingItem=a.updateItem(a.waitingItem),vd(e).call(e,(function(e){var t;vd(t=e.assetList).call(t,(function(e){a.clearAssetPlayer(e.identifier,null)}))})),d||t){if(a.hls.trigger(dO.INTERSTITIALS_UPDATED,{events:ag(l).call(l,0),schedule:ag(u).call(u,0),durations:c,removedIds:h}),a.isInterstitial(o)&&mv(h).call(h,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 SH(e),a.schedule=new kH(a.onScheduleUpdate,e.logger),a.registerListeners(),a}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(dO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(dO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(dO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(dO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(dO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(dO.MEDIA_ENDED,this.onMediaEnded,this),e.on(dO.ERROR,this.onError,this),e.on(dO.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(dO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(dO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(dO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(dO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(dO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(dO.MEDIA_ENDED,this.onMediaEnded,this),e.off(dO.ERROR,this.onError,this),e.off(dO.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;vd(e=this.playerQueue).call(e,(function(e){return e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){var e;vd(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,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();var n=this.findItemIndex(r);this.setSchedulePosition(n)}}},{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,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){var n=this.getBufferingPlayer();n&&(this.playingAsset=null,this.bufferingAsset=null,this.bufferingItem=null,this.waitingItem=null,this.detachedData=null,n.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},i=function(t){return t?e.getAssetPlayer(t.identifier):t},n=function(t,r,n,a,o){if(t){var l=t[r].start,u=t.event;if(u){if("playout"===r||u.timelineOccupancy!==fH.Point){var c=i(n);(null==c?void 0:c.interstitial)===u&&(l+=c.assetItem.startOffset+c[o])}}else l+=("bufferedPos"===a?s():e[a])-t.start;return l}return 0},a=function(t,r){if(0!==t&&"primary"!==r&&e.schedule.length){var i,n=e.schedule.findItemIndexAtTime(t),a=null==(i=e.schedule.items)?void 0:i[n];if(a)return t+(a[r].start-a.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,a){var s,o,l,u=r();if(null==u||null==(o=u.event)||!o.restrictions.skip){e.log(_d(s="seek to ".concat(t,' "')).call(s,a,'"'));var c=r(),h=e.schedule.findItemIndexAtTime(t,a),d=null==(l=e.schedule.items)?void 0:l[h],f=null==c?void 0:c.event,v=null==f?void 0:f.appendInPlace,g=c&&e.itemsMatch(c,d);if(c&&(v||g)){var p=i(e.playingAsset),m=(null==p?void 0:p.media)||e.hls.media;if(m){var y=t-("primary"===a?m.currentTime:n(c,a,e.playingAsset,"timelinePos","currentTime")),E=m.currentTime+y;if(E>=0&&(!p||v||E<=p.duration))return void(m.currentTime=E)}}if(d){var k=t;if("primary"!==a){var T=t-d[a].start;k=d.start+T}var S=!e.isInterstitial(d);if(e.isInterstitial(c)||!S&&!d.event.appendInPlace){if(c){var A=e.findItemIndex(c);if(h>A){var L=e.schedule.findJumpRestrictedIndex(A+1,h);if(L>A)return void e.setSchedulePosition(L)}var b=0;if(S)e.timelinePos=k;else{var R,I=null==d||null==(R=d.event)?void 0:R.assetList;if(I)for(var D=t-(d[a]||d).start,_=I.length;_--;){var w=I[_];if(w.duration&&D>=w.startOffset&&D<w.startOffset+w.duration){b=_;break}}}e.setSchedulePosition(h,b)}}else{var P=e.hls.media;P&&(P.currentTime=k)}}}};this.manager={get events(){var t,r;return(null==(t=e.schedule)||null==(r=t.events)?void 0:ag(r).call(r,0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:ag(r).call(r,0))||[]},get playerQueue(){var t;return ag(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 n(t(),"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"playout",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("playout")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"playout")},seekTo:function(e){return l(e,"playout")}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"integrated",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("integrated")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")},seekTo:function(e){return l(e,"integrated")}},skip:function(){var t=r(),i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;l(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,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 i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(n=this.primaryMedia);var a=null==(r=n)?void 0:r.currentTime;if(void 0!==a&&oO(a))return a}}}},{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,i=e.media;if(r&&i===this.primaryMedia){var n;if(!t||this.isInterstitial(t)&&!t.event.appendInPlace)return void(t&&i&&(this.detachedData={media:i}));var a=e.transferMedia();this.log(_d(n="transfer MediaSource from ".concat(e," ")).call(n,KI(a))),this.bufferingAsset=null,this.detachedData=a}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}},{key:"transferMediaTo",value:function(e,t){var r,i,n,a,s,o,l=null,u=this.hls,c=e!==u,h=c&&e.interstitial.appendInPlace,d=null==(a=this.detachedData)?void 0:a.mediaSource;if(u.media&&h)l=u.transferMedia(),this.detachedData=l,o="Primary";else if(d){var f=this.getBufferingPlayer();f&&(l=f.transferMedia()),o="".concat(f)}else o="<unknown>";this.log(_d(r=_d(i="transferring to ".concat(c?e:"Primary","\nMediaSource ")).call(i,KI(l)," from ")).call(r,o)),l||(d?(l=this.detachedData,this.log("using detachedData: MediaSource ".concat(KI(l)))):this.detachedData&&this.hls.media!==t||(this.hls.detachMedia(),this.detachedData={media:t}));var v=l&&"mediaSource"in l&&"closed"!==(null==(s=l.mediaSource)?void 0:s.readyState),g=v&&l?l:t;if(this.log(_d(n="".concat(v?"transfering MediaSource":"attaching media"," to ")).call(n,c?e:"Primary")),g===l){var p=c&&e.assetId===this.schedule.assetIdAtEnd;g.overrides={duration:this.schedule.duration,endOfStream:!c||p,cueRemoval:!1}}e.attachMedia(g)}},{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,i=this.waitingItem;if(-1===r){var n=this.hls.startPosition;if(this.timelinePos=n,t.length&&t[0].cue.pre){var a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(n>=0||!this.primaryLive){var s=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(i&&!this.playingItem){var l=e.findItemIndex(i);this.setSchedulePosition(l)}}}},{key:"advanceAfterAssetEnded",value:function(e,t,r){var i=r+1;if(e.isAssetPastPlayoutLimit(i)||e.assetList[i].error){var n=this.schedule.items;if(n){var a=t+1;if(a>=n.length)return void this.setSchedulePosition(-1);this.setSchedulePosition(a)}}else this.setSchedulePosition(t,i)}},{key:"setScheduleToAssetAtTime",value:function(e,t){var r=this.schedule,i=t.parentIdentifier,n=r.getEvent(i);if(n){var a=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.setSchedulePosition(a,s)}}},{key:"setSchedulePosition",value:function(e,t){var r,i=this,n=this.schedule.items;if(n&&!this.playbackDisabled){this.log(_d(r="setSchedulePosition ".concat(e,", ")).call(r,t));var a=e>=0?n[e]:null,s=this.primaryMedia,o=this.playingItem,l=this.playingLastItem;if(this.isInterstitial(o)){var u,c,h=o.event,d=this.playingAsset,f=null==d?void 0:d.identifier,v=f?this.getAssetPlayer(f):null;if(v&&f&&(!this.eventItemsMatch(o,a)||void 0!==t&&f!==(null==(u=h.assetList)?void 0:u[t].identifier))){var g,p;this.playingAsset=null;var m=h.findAssetIndex(d);this.log(_d(g=_d(p="INTERSTITIAL_ASSET_ENDED ".concat(m+1,"/")).call(p,h.assetList.length," ")).call(g,yH(d))),this.hls.trigger(dO.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:m,event:h,schedule:ag(n).call(n,0),scheduleIndex:e,player:v}),this.retreiveMediaSource(f,a),v.media&&!this.detachedData&&v.detachMedia(),this.clearAssetPlayer(f,a)}if(!this.eventItemsMatch(o,a))if(this.playingItem=null,this.log(_d(c="INTERSTITIAL_ENDED ".concat(h," ")).call(c,TH(o))),h.hasPlayed=!0,this.hls.trigger(dO.INTERSTITIAL_ENDED,{event:h,schedule:ag(n).call(n,0),scheduleIndex:e}),this.clearInterstitial(h,a),h.cue.once){if(this.updateSchedule(),a){var y=this.schedule.findItemIndex(a);this.setSchedulePosition(y,t)}return}}var E=this.playerQueue;if(E.length&&vd(E).call(E,(function(t){var r=t.interstitial,n=i.schedule.findEventIndex(r.identifier);(n<e||n>e+1)&&i.clearInterstitial(r,a)})),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);var k=a.event;void 0===t&&(t=this.schedule.findAssetIndex(k,this.timelinePos));var T,S=this.waitingItem,A=this.preloadAssets(k,t);if(A||this.setBufferingItem(a),!this.eventItemsMatch(a,o||S))this.waitingItem=a,this.log(_d(T="INTERSTITIAL_STARTED ".concat(TH(a)," ")).call(T,k.appendInPlace?"append in place":"")),this.hls.trigger(dO.INTERSTITIAL_STARTED,{event:k,schedule:ag(n).call(n,0),scheduleIndex:e});var L=k.assetList.length;if(0===L&&!k.assetListResponse)return void this.log("Waiting for ASSET-LIST to complete loading ".concat(k));if(k.assetListLoader&&(k.assetListLoader.destroy(),k.assetListLoader=void 0),!s)return void this.log("Waiting for attachMedia to start Interstitial ".concat(k));this.waitingItem=null,this.playingItem=a;var b,R,I=k.assetList[t];if(!I){var D=n[e+1],_=this.media;return D&&_&&!this.isInterstitial(D)&&_.currentTime<D.start&&(_.currentTime=this.timelinePos=D.start),void this.advanceAfterAssetEnded(k,e,t||0)}if(A||(A=this.getAssetPlayer(I.identifier)),null===A||A.destroyed)this.warn(_d(b=_d(R="asset ".concat(t+1,"/")).call(R,L," player destroyed ")).call(b,k)),A=this.createAssetPlayer(k,I,t);if(!this.eventItemsMatch(a,this.bufferingItem)&&k.appendInPlace&&this.isAssetBuffered(I))return;this.startAssetPlayer(A,t,n,e,s),this.shouldPlay&&AH(A.media)}else null!==a?(this.resumePrimary(a,e,o),this.shouldPlay&&AH(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 i;if(this.playingItem=e,this.playingAsset=null,this.waitingItem=null,this.bufferedToItem(e),this.log("resuming ".concat(TH(e))),null==(i=this.detachedData)||!i.mediaSource){var n=this.timelinePos;(n<e.start||n>=e.end)&&(n=this.getPrimaryResumption(e,t),this.timelinePos=n),this.attachPrimary(n,e)}if(r){var a=this.schedule.items;a&&(this.log("resumed ".concat(TH(e))),this.hls.trigger(dO.INTERSTITIALS_PRIMARY_RESUMED,{schedule:ag(a).call(a,0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var r=e.start;if(this.primaryLive){var i=this.primaryDetails;if(0===t)return this.hls.startPosition;if(i&&(r<i.fragmentStart||r>i.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:YN.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 i=this.primaryMedia;if(i){var n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,i),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(dO.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(dO.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],i=bO(bO({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i),!this.playingItem&&this.schedule.items&&this.checkStart()}}},{key:"onAudioTrackUpdated",value:function(e,t){var r=this.hls.audioTracks[t.id],i=this.mediaSelection;if(i){var n=bO(bO({},i),{},{audio:r});this.mediaSelection=n}else this.altSelection=bO(bO({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(i){var n=bO(bO({},i),{},{subtitles:r});this.mediaSelection=n}else this.altSelection=bO(bO({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r,i=lF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(i)}))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r,i=lF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(i)}))}},{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 i=this.timelinePos;this.bufferedPos=i,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 i=t[r];if(i.cue.post){var n,a=this.schedule.findEventIndex(i.identifier),s=null==(n=this.schedule.items)?void 0:n[a];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,i;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==(i=t.nextEvent)?void 0:i.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=YN.bufferInfo(this.primaryMedia,this.timelinePos,0);this.updateBufferedPos(t.end,e,0===t.len)}}},{key:"updateBufferedPos",value:function(e,t,r){var i=this.schedule,n=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],n))this.bufferedPos=e;else{var a=this.playingItem,s=this.findItemIndex(a),o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,u=this.findItemIndex(n),c=Math.min(u+1,t.length-1),h=t[c];if(-1===o&&n&&e>=n.end&&(o=c),c-s>1&&!1===(null==n||null==(l=n.event)?void 0:l.appendInPlace))return;if(this.bufferedPos=e,o>u&&o>s)this.bufferedToItem(h);else{var d=this.primaryDetails;this.primaryLive&&d&&e>d.edge-d.targetduration&&h.start<d.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else r&&a&&n!==a&&o===s&&this.bufferedToItem(a)}}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,r=this.schedule,i=r.items,n=r.events;if(i&&n&&(!t||r.findItemIndex(t)!==r.findItemIndex(e))){var a,s,o=this.isInterstitial(e),l=this.getBufferingPlayer(),u=l?l.remaining:t?t.end-this.timelinePos:0;if(this.log("buffered to boundary ".concat(TH(e))+(t?" (".concat(u.toFixed(2)," remaining)"):"")),this.bufferingItem=e,this.bufferedPos=e.start,!this.playbackDisabled)if(o)vd(a=this.playerQueue).call(a,(function(e){return e.resumeBuffering()}));else this.hls.resumeBuffering(),vd(s=this.playerQueue).call(s,(function(e){return e.pauseBuffering()}));this.hls.trigger(dO.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:ag(n).call(n,0),schedule:ag(i).call(i,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 i=this.detachedData;if(i)if(i.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,i=0===r.assetList.length&&!r.assetListLoader,n=r.cue.once;if(i||!n){var a=this.preloadAssets(r,t);if(null!=a&&a.interstitial.appendInPlace){var s=r.assetList[t],o=this.primaryMedia;s&&o&&this.bufferAssetPlayer(a,o)}}}},{key:"preloadAssets",value:function(e,t){var r=e.assetList.length,i=0===r&&!e.assetListLoader,n=e.cue.once;if(i){var a,s;this.log(_d(a=_d(s="Load interstitial asset ".concat(t+1,"/")).call(s,r," ")).call(a,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 u=0;!this.playingItem&&this.primaryLive&&-1===(u=this.hls.startPosition)&&(u=this.hls.liveSyncPosition||0);var c=this.assetListLoader.loadAssetList(e,u);c&&(e.assetListLoader=c)}else if(!n&&r){for(var h=t;h<r;h++){var d=e.assetList[h],f=this.getAssetPlayerQueueIndex(d.identifier);-1!==f&&!this.playerQueue[f].destroyed||d.error||this.createAssetPlayer(e,d,h)}return this.getAssetPlayer(e.assetList[t].identifier)}return null}},{key:"flushFrontBuffer",value:function(e){var t=this,r=this.requiredTracks;if(r){var i=zf(r);vd(i).call(i,(function(r){t.hls.trigger(dO.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,i,n,a){var s={parentIdentifier:e.identifier,identifier:vH(e,a,t),duration:n,startOffset:r,timelineStart:i,uri:a};return this.createAssetPlayer(e,s,t)}},{key:"createAssetPlayer",value:function(e,t,r){var i=this;this.log("create HLSAssetPlayer for ".concat(yH(t)));var n=this.hls,a=n.userConfig,s=a.videoPreference,o=n.levels[n.loadLevel]||n.levels[n.currentLevel];(s||o)&&(s=AO({},s),o.videoCodec&&(s.videoCodec=o.videoCodec),o.videoRange&&(s.allowedVideoRanges=[o.videoRange]));var l=n.audioTracks[n.audioTrack],u=n.subtitleTracks[n.subtitleTrack],c=0;if(this.primaryLive){var h=this.timelinePos-t.timelineStart;if(h>1){var d=t.duration;d&&h<d&&(c=h)}}var f=bO(bO({},a),{},{autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:t.identifier,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:l||a.audioPreference,subtitlePreference:u||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(f.timelineOffset=t.timelineStart));var v=f.cmcd;null!=v&&v.sessionId&&v.contentId&&(f.cmcd=AO({},v,{contentId:hH(t.uri)}));var g=new EH(this.HlsPlayerClass,f,e,t);this.playerQueue.push(g),e.assetList[r]=t;var p=t.identifier,m=function(n){if(n.live){var a=new Error("Interstitials MUST be VOD assets ".concat(e)),s={fatal:!0,type:cO.OTHER_ERROR,details:hO.INTERSTITIAL_ASSET_ITEM_ERROR,error:a};i.handleAssetItemError(s,e,i.schedule.findEventIndex(e.identifier),r,a.message)}else{var o,l,u=n.edge-n.fragmentStart,c=t.duration;if(null===c||u>c)i.log(_d(o=_d(l='Interstitial asset "'.concat(p,'" duration change ')).call(l,c," > ")).call(o,u)),t.duration=u,i.updateSchedule()}};g.on(dO.LEVEL_UPDATED,(function(e,t){var r=t.details;return m(r)})),g.on(dO.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return m(r)}));g.on(dO.BUFFER_CODECS,(function e(t,r){var n=i.getAssetPlayer(p);if(n&&r.tracks){n.off(dO.BUFFER_CODECS,e),n.tracks=r.tracks;var a=i.primaryMedia;i.bufferingAsset===n.assetItem&&a&&!n.media&&i.bufferAssetPlayer(n,a)}}));g.on(dO.BUFFERED_TO_END,(function r(n){var a,s=i.getAssetPlayer(p);if(i.log("buffered to end of asset ".concat(s)),s){s.off(dO.BUFFERED_TO_END,r);var o=i.schedule.findEventIndex(e.identifier),l=e.findAssetIndex(t),u=l+1,c=null==(a=i.schedule.items)?void 0:a[o];if(i.isInterstitial(c))if(-1===l||e.isAssetPastPlayoutLimit(u)||e.assetList[u].error){var h,d=null==(h=i.schedule.items)?void 0:h[o+1];d&&i.bufferedToItem(d)}else i.bufferedToItem(c,l+1)}}));var y=function(t){return function(){if(i.getAssetPlayer(p)){i.shouldPlay=!0;var r=i.schedule.findEventIndex(e.identifier);i.advanceAfterAssetEnded(e,r,t)}}};return g.once(dO.MEDIA_ENDED,y(r)),g.once(dO.PLAYOUT_LIMIT_REACHED,y(1/0)),g.on(dO.ERROR,(function(t,n){var a;i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,_d(a="Asset player error ".concat(n.error," ")).call(a,e))})),g.on(dO.DESTROYING,(function(){if(i.getAssetPlayer(p)){var t=new Error("Asset player destroyed unexpectedly ".concat(p)),n={fatal:!0,type:cO.OTHER_ERROR,details:hO.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(dO.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:g}),g}},{key:"clearInterstitial",value:function(e,t){var r,i=this;vd(r=e.assetList).call(r,(function(e){i.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 i,n;this.log(_d(i='clearAssetPlayer "'.concat(e,'" toSegment: ')).call(i,t?TH(t):t));var a=this.playerQueue[r];this.transferMediaFromPlayer(a,t),Rg(n=this.playerQueue).call(n,r,1),a.destroy()}}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,r,i,n){var a,s,o=e.interstitial,l=e.assetItem,u=e.assetId,c=o.assetList.length,h=this.playingAsset;(this.playingAsset=l,h&&h.identifier===u)||(h&&(this.clearAssetPlayer(h.identifier,r[i]),delete h.error),this.log(_d(a=_d(s="INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/")).call(s,c," ")).call(a,e)),this.hls.trigger(dO.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:o,schedule:ag(r).call(r,0),scheduleIndex:i,player:e}));e.media||this.bufferAssetPlayer(e,n)}},{key:"bufferAssetPlayer",value:function(e,t){var r,i,n=e.interstitial,a=e.assetItem,s=e.assetId,o=this.schedule.findEventIndex(n.identifier),l=null==(r=this.schedule.items)?void 0:r[o];if(l){this.setBufferingItem(l),this.bufferingAsset=a;var u=this.getBufferingPlayer();if(u!==e){var c=(null==u?void 0:u.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(n.appendInPlace&&a!==this.playingAsset){if(!e.tracks)return;if(c&&!MO(c,e.tracks)){var h,d,f=new Error(_d(h=_d(d='Asset "'.concat(s,"\" SourceBuffer tracks ('")).call(d,zf(e.tracks),"') are not compatible with primary content tracks ('")).call(h,zf(c),"')")),v={fatal:!0,type:cO.OTHER_ERROR,details:hO.INTERSTITIAL_ASSET_ITEM_ERROR,error:f},g=n.findAssetIndex(a);return void this.handleAssetItemError(v,n,o,g,f.message)}}this.transferMediaTo(e,t)}}}},{key:"handleAssetItemError",value:function(e,t,r,i,n){var a;if(e.details!==hO.BUFFER_STALLED_ERROR){var s=t.assetList[i]||null,o=null;if(s){var l=this.getAssetPlayerQueueIndex(s.identifier);o=this.playerQueue[l]||null}var u=this.schedule.items,c=AO({},e,{fatal:!1,errorAction:xF(!0),asset:s,assetListIndex:i,event:t,schedule:u,scheduleIndex:r,player:o});if(this.warn("Asset item error: ".concat(e.error)),this.hls.trigger(dO.INTERSTITIAL_ASSET_ERROR,c),e.fatal){var h=new Error(n);s&&(this.playingAsset!==s&&this.clearAssetPlayer(s.identifier,null),s.error=h),cS(a=t.assetList).call(a,(function(e){return!e.error}))?t.appendInPlace&&(t.error=h):t.error=h,this.primaryFallback(t)}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,r=this.playingItem||this.waitingItem;if(this.updateSchedule(),r){var i,n,a,s;this.log(_d(i=_d(n=_d(a=_d(s='Fallback to primary from event "'.concat(e.identifier,'" start: ')).call(s,t," pos: ")).call(a,this.timelinePos," playing: ")).call(n,r?TH(r):"<none>"," error: ")).call(i,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 u=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(u)}}else this.checkStart()}},{key:"onAssetListLoaded",value:function(e,t){var r,i=this,n=t.event,a=n.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(a)){var o=n.timelineStart,l=0;vd(s).call(s,(function(e,t){var r=zS(e.DURATION);i.createAsset(n,t,l,o+l,r,e.URI),l+=r})),n.duration=l;var u=this.waitingItem,c=(null==u?void 0:u.event.identifier)===a;this.updateSchedule();var h=null==(r=this.bufferingItem)?void 0:r.event;if(c){var d,f=this.schedule.findEventIndex(a),v=null==(d=this.schedule.items)?void 0:d[f];v&&this.setBufferingItem(v),this.setSchedulePosition(f)}else if((null==h?void 0:h.identifier)===a&&h.appendInPlace){var g=n.assetList[0],p=this.getAssetPlayer(g.identifier),m=this.primaryMedia;g&&p&&m&&this.bufferAssetPlayer(p,m)}}}},{key:"onError",value:function(e,t){switch(t.details){case hO.ASSET_LIST_PARSING_ERROR:case hO.ASSET_LIST_LOAD_ERROR:case hO.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r)}}}]),i}(RO),bH=function(e){Ch(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"subtitle-stream-controller",EO)).currentTrackId=-1,s.tracksBuffered=[],s.mainDetails=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(dO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(dO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e){this.stopLoad(),this.state=uB,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,t){this.tracksBuffered=[],Ih(Rh(i.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,i=t.success;if(lN(r)&&(this.fragPrevious=r),this.state=uB,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var a,s=r.start,o=0;o<n.length;o++)if(s>=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n,a=i-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),vd(n=this.tracksBuffered).call(n,(function(e){for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}})),this.fragmentTracker.removeFragmentsInRange(r,a,EO)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===EO&&(t.details===hO.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==lB&&(this.state=uB))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks;this.levels&&rK(this.levels,i)?this.levels=Jk(i).call(i,(function(e){return new iF(e)})):(this.tracksBuffered=[],this.levels=Jk(i).call(i,(function(e){var t=new iF(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,EO),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 i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==lB&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,i,n,a,s,o,l=this.currentTrackId,u=this.levels,c=t.details,h=t.id;if(u){var d=u[h];if(!(h>=u.length)&&d){this.log(_d(r=_d(i=_d(n=_d(a="Subtitle track ".concat(h," loaded [")).call(a,c.startSN,",")).call(n,c.endSN,"]")).call(i,c.lastPartSn?_d(s="[part-".concat(c.lastPartSn,"-")).call(s,c.lastPartIndex,"]"):"",",duration:")).call(r,c.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;if(c.live||null!=(o=d.details)&&o.live){var f=this.mainDetails;if(c.deltaUpdateFailed||!f)return;var v,g=f.fragments[0];if(d.details)0===this.alignPlaylists(c,d.details,null==(v=this.levelLastLoaded)?void 0:v.details)&&g&&$U(c,g.start);else c.hasProgramDateTime&&f.hasProgramDateTime?(sB(c,f),c.fragmentStart):g&&$U(c,g.start)}if(d.details=c,this.levelLastLoaded=d,h===l)if(this.hls.trigger(dO.SUBTITLE_TRACK_UPDATED,{details:c,id:h,groupId:t.groupId}),this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===uB)pF(null,c.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0)}}else this.warn("Subtitle tracks were reset while loading level ".concat(h))}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this,r=e.frag,i=e.payload,n=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&iU(n.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,nU(n.method)).catch((function(e){throw a.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();a.trigger(dO.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){var r;t.warn(_d(r="".concat(e.name,": ")).call(r,e.message)),t.state=uB}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===uB){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 i=this.config,n=this.getLoadPosition(),a=YN.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),s=a.end,o=a.len,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;var u=l.fragments,c=u.length,h=l.edge,d=null,f=this.fragPrevious;if(s<h){var v=i.maxFragLookUpTolerance,g=s>h-v?0:v;!(d=pF(f,u,Math.max(u[0].start,s),g))&&f&&f.start<u[0].start&&(d=u[0])}else d=u[c-1];if(!d)return;if(lN(d=this.mapToInitFragWhenRequired(d))){var p=u[d.sn-l.startSN-1];p&&p.cc===d.cc&&this.fragmentTracker.getState(p)===MF&&(d=p)}this.fragmentTracker.getState(d)===MF&&this.loadFragment(d,r,s)}}else this.state=uB}},{key:"loadFragment",value:function(e,t,r){lN(e)?Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r):this._loadInitSegment(e,t)}},{key:"mediaBufferTimeRanges",get:function(){return new RH(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(kB),RH=Fc((function e(r){t(this,e),this.buffered=void 0;var i=function(e,t,i){var n,a;if((t>>>=0)>i-1)throw new DOMException(_d(n=_d(a="Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (")).call(a,t,") is greater than the maximum bound (")).call(n,i,")"));return r[t][e]};this.buffered={get length(){return r.length},end:function(e){return i("end",e,r.length)},start:function(e){return i("start",e,r.length)}}})),IH={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},DH=function(e){return String.fromCharCode(IH[e]||e)},_H=15,wH=100,PH={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},CH={17:2,18:4,21:6,22:8,23:10,19:13,20:15},xH={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},MH={25:2,26:4,29:6,30:8,31:10,27:13,28:15},OH=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],FH=function(){function e(){t(this,e),this.time=null,this.verboseLevel=0}return Fc(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r,i,n="function"==typeof t?t():t;CO.log(_d(r=_d(i="".concat(this.time," [")).call(i,e,"] ")).call(r,n))}}}]),e}(),NH=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},UH=function(){function e(){t(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return Fc(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 i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}},{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}(),BH=function(){function e(){t(this,e),this.uchar=" ",this.penState=new UH}return Fc(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}(),GH=function(){function e(r){t(this,e),this.chars=[],this.pos=0,this.currPenState=new UH,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<wH;i++)this.chars.push(new BH);this.logger=r}return Fc(e,[{key:"equals",value:function(e){for(var t=0;t<wH;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<wH;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<wH;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>wH&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=wH)}},{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=DH(e);this.pos>=wH?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<wH;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<wH;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}]),e}(),KH=function(){function e(r){t(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<_H;i++)this.rows.push(new GH(r));this.logger=r}return Fc(e,[{key:"reset",value:function(){for(var e=0;e<_H;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,r=0;r<_H;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<_H;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<_H;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 = "+KI(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<_H;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){var a=n.rows[i].cueStartTime,s=this.logger.time;if(null!==a&&null!==s&&a<s)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(n.rows[i+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var u=e.indent,c=Math.max(u-1,0);l.setCursor(e.indent),e.color=l.chars[c].penState.foreground}var h={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(h)}},{key:"setBkgData",value:function(e){this.logger.log(2,(function(){return"bkgData = "+KI(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 i=this.currRow+1-this.nrRollUpRows,n=Rg(e=this.rows).call(e,i,1)[0];n.clear(),Rg(t=this.rows).call(t,this.currRow,0,n),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="",i=-1,n=0;n<_H;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(iA(a).call(a)))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),HH=function(){function e(r,i,n){t(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=r,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new KH(n),this.nonDisplayedMemory=new KH(n),this.lastOutputScreen=new KH(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}return Fc(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[14],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 i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return i+": "+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: "+KI(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}(),VH=function(){function e(r,i,n){t(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new FH;this.channels=[null,new HH(r,i,a),new HH(r+1,n,a)]}return Fc(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 i=function(e){var i=127&t[e],n=127&t[e+1],a=!1,s=null;if(0===i&&0===n)return"continue";r.logger.log(3,(function(){return"["+NH([t[e],t[e+1]])+"] -> ("+NH([i,n])+")"}));var o=r.cmdHistory;if(i>=16&&i<=31){if(function(e,t,r){return r.a===e&&r.b===t}(i,n,o))return jH(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+NH([i,n])+") is dropped"})),"continue";jH(i,n,r.cmdHistory),(a=r.parseCmd(i,n))||(a=r.parseMidrow(i,n)),a||(a=r.parsePAC(i,n)),a||(a=r.parseBackgroundAttributes(i,n))}else jH(null,null,o);if(!a&&(s=r.parseChars(i,n))){var l=r.currentChannel;if(l&&l>0)r.channels[l].insertChars(s);else r.logger.log(2,"No channel found yet. TEXT-MODE?")}a||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+NH([i,n])+" orig: "+NH([t[e],t[e+1]])}))},n=0;n<t.length;n+=2)i(n)}},{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,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.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 i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,(function(){return"MIDROW ("+NH([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 i=e<=23?1:2;r=t>=64&&t<=95?1===i?PH[e]:xH[e]:1===i?CH[e]:MH[e];var n=this.channels[i];return!!n&&(n.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}},{key:"interpretPAC",value:function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}},{key:"parseChars",value:function(e,t){var r,i,n=null,a=null;(e>=25?(r=2,a=e-8):(r=1,a=e),a>=17&&a<=19)?(i=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+DH(i)+"' in channel "+r})),n=[i]):e>=32&&e<=127&&(n=0===t?[e]:[e,t]);return n&&this.logger.log(3,(function(){return"Char codes = "+NH(n).join(",")})),n}},{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 i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=OH[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(i),!0}},{key:"reset",value:function(){for(var e=0;e<zf(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}jH(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 jH(e,t,r){r.a=e,r.b=t}var YH=function(){if(null!=lU&&lU.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(!tT(e))return!1;var r=t.toLowerCase();return!!~_v(e).call(e,r)&&r}function i(e){return r(t,e)}function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,h=t,d=a,f=s,v=null,g="",p=!0,m="auto",y="start",E=50,k="middle",T=50,S="middle";ST(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),ST(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),ST(o,"startTime",n({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),ST(o,"endTime",n({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");d=e,this.hasBeenReset=!0}})),ST(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),ST(o,"region",n({},l,{get:function(){return v},set:function(e){v=e,this.hasBeenReset=!0}})),ST(o,"vertical",n({},l,{get:function(){return g},set:function(t){var i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),ST(o,"snapToLines",n({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),ST(o,"line",n({},l,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),ST(o,"lineAlign",n({},l,{get:function(){return y},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),ST(o,"position",n({},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}})),ST(o,"positionAlign",n({},l,{get:function(){return k},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");k=t,this.hasBeenReset=!0}})),ST(o,"size",n({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),ST(o,"align",n({},l,{get:function(){return S},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),qH=function(){function e(){t(this,e)}return Fc(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 WH(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+zS(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?zS(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var zH=function(){function e(){t(this,e),this.values=bT(null)}return Fc(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(sO(this)[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?sO(this)[e]:t[r]:this.has(e)?sO(this)[e]:t}},{key:"has",value:function(e){return e in sO(this)}},{key:"alt",value:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,qk(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=zS(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function XH(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);if(2===s.length)t(s[0],s[1])}}var QH=new YH(0,0,""),$H="middle"===QH.align?"middle":"center";function JH(e,t,r){var i=e;function n(){var t=WH(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=n(),a(),"--\x3e"!==ag(e).call(e,0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=ag(e).call(e,3),a(),t.endTime=n(),a(),function(e,t){var i=new zH;XH(e,(function(e,t){var n;switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){i.set(e,r[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",$H,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",$H,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",$H,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===QH.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",$H);var a=i.get("position","auto");"auto"===a&&50===QH.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function ZH(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var eV=function(){function e(){t(this,e),this.state="INITIAL",this.buffer="",this.decoder=new qH,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return Fc(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=ZH(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=ag(e).call(e,0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=ag(e).call(e,r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var n=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(null==n||!n[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var a=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:i=r(),t.state){case"HEADER":/:/.test(i)?XH(i,(function(e,t){}),/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new YH(0,0,""),t.state="CUE",-1===_v(i).call(i,"--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{JH(i,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==_v(i).call(i,"--\x3e");if(!i||s&&(a=!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+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch(o){"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}(),tV=/\r\n|\n\r|\n|\r/g,rV=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return ag(e).call(e,r,r+t.length)===t};function iV(e,t,r){return hH(e.toString())+hH(t.toString())+hH(r)}function nV(e,t,r,i,n,a,s){var o,l,u=new eV,c=iA(o=WF(new Uint8Array(e))).call(o).replace(tV,"\n").split("\n"),h=[],d=t?function(e){return OG(e,MG,1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1))}(t.baseTime,t.timescale):0,f="00:00.000",v=0,g=0,p=!0;u.oncue=function(e){var a,s=r[i],o=r.ccOffset,u=(v-d)/9e4;if(null!=s&&s.new&&(void 0!==g?o=r.ccOffset=s.start:function(e,t,r){var i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(a=n)&&a.new;){var a;e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC]}e.presentationOffset=r}(r,i,u)),u){if(!t)return void(l=new Error("Missing initPTS for VTT MPEGTS"));o=u-r.presentationOffset}var c=e.endTime-e.startTime,f=GG(9e4*(e.startTime+o-g),9e4*n)/9e4;e.startTime=Math.max(f,0),e.endTime=Math.max(f+c,0);var p=iA(a=e.text).call(a);e.text=decodeURIComponent(encodeURIComponent(p)),e.id||(e.id=iV(e.startTime,e.endTime,p)),e.endTime>0&&h.push(e)},u.onparsingerror=function(e){l=e},u.onflush=function(){l?s(l):a(h)},vd(c).call(c,(function(e){if(p){if(rV(e,"X-TIMESTAMP-MAP=")){var t;p=!1,vd(t=ag(e).call(e,16).split(",")).call(t,(function(e){rV(e,"LOCAL:")?f=ag(e).call(e,6):rV(e,"MPEGTS:")&&(v=qk(ag(e).call(e,7)))}));try{g=function(e){var t=qk(ag(e).call(e,-3)),r=qk(ag(e).call(e,-6,-4)),i=qk(ag(e).call(e,-9,-7)),n=e.length>9?qk(e.substring(0,_v(e).call(e,":"))):0;if(!(oO(t)&&oO(r)&&oO(i)&&oO(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*i,t+36e5*n}(f)/1e3}catch(QV){l=QV}return}""===e&&(p=!1)}u.parse(e+"\n")})),u.flush()}var aV="stpp.ttml.im1t",sV=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,oV=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,lV={left:"start",center:"center",right:"end",start:"start",end:"end"};function uV(e,t,r,i){var n=kN(new Uint8Array(e),["mdat"]);if(0!==n.length){var a=Jk(n).call(n,(function(e){return WF(e)})),s=function(e,t){return OG(e,t,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}(t.baseTime,1,t.timescale);try{vd(a).call(a,(function(e){return r(function(e,t){var r,i,n=(new DOMParser).parseFromString(e,"text/xml"),a=n.getElementsByTagName("tt")[0];if(!a)throw new Error("Invalid ttml");var s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},o=mP(r=zf(s)).call(r,(function(e,t){return e[t]=a.getAttribute("ttp:".concat(t))||s[t],e}),{}),l="preserve"!==a.getAttribute("xml:space"),u=hV(cV(a,"styling","style")),c=hV(cV(a,"layout","region")),h=cV(a,"body","[begin]");return rT(i=Jk([]).call(h,(function(e){var r=dV(e,l);if(!r||!e.hasAttribute("begin"))return null;var i=gV(e.getAttribute("begin"),o),n=gV(e.getAttribute("dur"),o),a=gV(e.getAttribute("end"),o);if(null===i)throw vV(e);if(null===a){if(null===n)throw vV(e);a=i+n}var s=new YH(i-t,a-t,r);s.id=iV(s.startTime,s.endTime,s.text);var h=function(e,t,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;s&&r.hasOwnProperty(s)&&(n=r[s]);return mP(a).call(a,(function(r,a){var s=fV(t,i,a)||fV(e,i,a)||fV(n,i,a);return s&&(r[a]=s),r}),{})}(c[e.getAttribute("region")],u[e.getAttribute("style")],u),d=h.textAlign;if(d){var f=lV[d];f&&(s.lineAlign=f),s.align=d}return AO(s,h),s}))).call(i,(function(e){return null!==e}))}(e,s))}))}catch(QV){i(QV)}}else i(new Error("Could not parse IMSC1 mdat"))}function cV(e,t,r){var i=e.getElementsByTagName(t)[0];return i?ag([]).call(i.querySelectorAll(r)):[]}function hV(e){return mP(e).call(e,(function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function dV(e,t){var r;return mP(r=ag([]).call(e.childNodes)).call(r,(function(e,r,i){var n,a;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?dV(r,t):t?e+iA(a=r.textContent).call(a).replace(/\s+/g," "):e+r.textContent}),"")}function fV(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function vV(e){return new Error("Could not parse ttml timestamp ".concat(e))}function gV(e,t){if(!e)return null;var r=WH(e);return null===r&&(sV.test(e)?r=function(e,t){var r=sV.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):oV.test(e)&&(r=function(e,t){var r=oV.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}var pV=function(){function e(r,i){t(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=r,this.trackName=i}return Fc(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}(),mV=function(){function e(r){t(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={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=r,this.config=r.config,this.Cues=r.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}},r.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),r.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(dO.FRAG_LOADING,this.onFragLoading,this),r.on(dO.FRAG_LOADED,this.onFragLoaded,this),r.on(dO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),r.on(dO.FRAG_DECRYPTED,this.onFragDecrypted,this),r.on(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(dO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),r.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this)}return Fc(e,[{key:"destroy",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(dO.FRAG_LOADING,this.onFragLoading,this),e.off(dO.FRAG_LOADED,this.onFragLoaded,this),e.off(dO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(dO.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(dO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(dO.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 pV(this,"textTrack1"),t=new pV(this,"textTrack2"),r=new pV(this,"textTrack3"),i=new pV(this,"textTrack4");this.cea608Parser1=new VH(1,e,t),this.cea608Parser2=new VH(3,r,i)}},{key:"addCues",value:function(e,t,r,i,n){for(var a,s,o,l,u=!1,c=n.length;c--;){var h=n[c],d=(a=h[0],s=h[1],o=t,l=r,Math.min(s,l)-Math.max(a,o));if(d>=0&&(h[0]=Math.min(h[0],t),h[1]=Math.max(h[1],r),u=!0,d/(r-t)>.5))return}if(u||n.push([t,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[e];this.Cues.newCue(f,t,r,i)}else{var v=this.Cues.newCue(null,t,r,i);this.hls.trigger(dO.CUES_PARSED,{type:"captions",cues:v,track:e})}}},{key:"onInitPtsFound",value:function(e,t){var r=this,i=t.frag,n=t.id,a=t.initPTS,s=t.timescale,o=this.unparsedVttFrags;n===mO&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],vd(o).call(o,(function(e){r.onFragLoaded(dO.FRAG_LOADED,e)})))}},{key:"getExistingTrack",value:function(e,t){var r=this.media;if(r)for(var i=0;i<r.textTracks.length;i++){var n=r.textTracks[i];if(EV(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound",attrs:{}}))return n}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,i=this.media,n=t[e],a=n.label,s=n.languageCode,o=this.getExistingTrack(a,s);if(o)r[e]=o,oH(r[e]),aH(r[e],i);else{var l=this.createTextTrack("captions",a,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(dO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}}},{key:"createTextTrack",value:function(e,t,r){var i=this.media;if(i)return i.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,i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;vd(r=zf(n)).call(r,(function(e){oH(n[e]),delete n[e]})),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)oH(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks||[],n=cS(i).call(i,(function(e){return e.textCodec===aV}));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(rK(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a,s=this.media,o=s?uH(s.textTracks):null;if(vd(a=this.tracks).call(a,(function(e,t){var i;if(o){for(var n=null,a=0;a<o.length;a++)if(o[a]&&EV(o[a],e)){n=o[a],o[a]=null;break}n&&(i=n)}if(i)oH(i);else{var s=yV(e);(i=r.createTextTrack(s,e.name,e.lang))&&(i.mode="disabled")}i&&r.textTracks.push(i)})),null!=o&&o.length){var l,u=Jk(l=rT(o).call(o,(function(e){return null!==e}))).call(l,(function(e){return e.label}));u.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(u.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){var c,h=Jk(c=this.tracks).call(c,(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(dO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:h})}}}},{key:"onManifestLoaded",value:function(e,t){var r,i=this;this.config.enableCEA708Captions&&t.captions&&vd(r=t.captions).call(r,(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack".concat(t[1]),n=i.captionsProperties[r];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.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===mO){var r,i,n=this.cea608Parser1,a=this.cea608Parser2,s=this.lastSn,o=t.frag,l=o.cc,u=o.sn,c=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;n&&a&&(u!==s+1||u===s&&c!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=u,this.lastPartIndex=c}}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,i=t.payload;if(r.type===EO)if(i.byteLength){var n=r.decryptdata,a="stats"in t;if(null==n||!n.encrypted||a){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===aV?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var r=this,i=this.hls;uV(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){i.logger.log("Failed to parse IMSC1: ".concat(t)),i.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}},{key:"_parseVTTs",value:function(e){var t,r=this,i=e.frag,n=e.payload,a=this.initPTS,s=this.unparsedVttFrags,o=a.length-1;if(a[i.cc]||-1!==o){var l=this.hls;nV(null!=(t=i.initSegment)&&t.data?_N(i.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(function(e){r._appendCues(e,i.level),l.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(function(t){var a="Missing initPTS for VTT MPEGTS"===t.message;a?s.push(e):r._fallbackToIMSC1(i,n),l.logger.log("Failed to parse VTT cue: ".concat(t)),a&&o>i.cc||l.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})}))}else s.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||uV(t,this.initPTS[e.cc],(function(){i.textCodec=aV,r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))}},{key:"_appendCues",value:function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;vd(e).call(e,(function(e){return sH(i,e)}))}else{var n=this.tracks[t];if(!n)return;var a=n.default?"default":"subtitles"+t;r.trigger(dO.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===EO&&this.onFragLoaded(dO.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,i=t.samples;if(r.type!==mO||"NONE"!==this.closedCaptionsForLevel(r))for(var n=0;n<i.length;n++){var a=i[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();var s=this.extractCea608Data(a);this.cea608Parser1.addData(i[n].pts,s[0]),this.cea608Parser2.addData(i[n].pts,s[1])}}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.endOffsetSubtitles,a=t.type,s=this.media;if(s&&!(s.currentTime<i)){if(!a||"video"===a){var o,l=this.captionsTracks;vd(o=zf(l)).call(o,(function(e){return lH(l[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u,c=this.textTracks;vd(u=zf(c)).call(u,(function(e){return lH(c[e],r,n)}))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],r=31&e[0],i=2,n=0;n<r;n++){var a=e[i++],s=127&e[i++],o=127&e[i++];if(0!==s||0!==o)if(0!=(4&a)){var l=3&a;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}();function yV(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function EV(e,t){return!!e&&e.kind===yV(t)&&nK(t,e)}var kV=/\s/,TV={newCue:function(e,t,r,i){for(var n,a,s,o,l,u=[],c=self.VTTCue||self.TextTrackCue,h=0;h<i.rows.length;h++)if(s=!0,o=0,l="",!(n=i.rows[h]).isEmpty()){for(var d,f=0;f<n.chars.length;f++)kV.test(n.chars[f].uchar)&&s?o++:(l+=n.chars[f].uchar,s=!1);n.cueStartTime=t,t===r&&(r+=1e-4),o>=16?o--:o++;var v=ZH(iA(l).call(l)),g=iV(t,r,v);null!=e&&null!=(d=e.cues)&&d.getCueById(g)||((a=new c(t,r,v)).id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return e&&u.length&&(GA(u).call(u,(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})),vd(u).call(u,(function(t){return sH(e,t)}))),u}};var SV=/(\d+)-(\d+)\/(\d+)/,AV=function(){function e(r){t(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=r.fetchSetup||LV,this.controller=new self.AbortController,this.stats=new iN}return Fc(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 i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(AO({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s=r.onProgress,o="arraybuffer"===e.responseType,l=o?"byteLength":"length",u=t.loadPolicy,c=u.maxTimeToFirstByteMs,h=u.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=c&&oO(c)?c:h,this.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),($G(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(a){i.response=i.loader=a;var l=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=h,i.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),h-(l-n.loading.start)),!a.ok){var u=a.status,c=a.statusText;throw new bV(c||"fetch, bad network response",u,a)}return n.loading.first=l,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=SV.exec(e);if(t)return qk(t[2])-qk(t[1])+1}(t);if(oO(r))return r}var i=e.get("Content-Length");if(i)return qk(i)}(a.headers)||n.total,s&&oO(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,s):o?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var c={url:o.url,data:a,code:o.status};s&&!oO(t.highWaterMark)&&s(n,e,a,o),r.onSuccess(c,n,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;r.onError({code:a,text:s},e,t?t.details:null,n)}}))}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?zS(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 i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4?arguments[4]:void 0,a=new TB,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(t,r,a.flush().buffer,e),Lk.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return t.loaded+=u,u<i||a.dataLength?(a.push(l),a.dataLength>=i&&n(t,r,a.flush().buffer,e)):n(t,r,l.buffer,e),o()})).catch((function(){return Lk.reject()}))}()}}]),e}();function LV(e,t){return new self.Request(e.url,t)}var bV=function(e){Ch(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e)).code=void 0,s.details=void 0,s.code=n,s.details=a,s}return Fc(i)}(Jw(Error)),RV=/^age:\s*[\d.]+\s*$/im,IV=function(){function e(r){t(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=r&&r.xhrSetup||null,this.stats=new iN,this.retryDelay=0}return Fc(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 i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Lk.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return a(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){e.callbacks.onError({code:i.status,text:t.message},r,i,n)})):this.openAndSendXhr(i,r,t)}}},{key:"openAndSendXhr",value:function(e,t,r){var i,n,a;e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,u=o.maxLoadTimeMs;if(s)for(var c in s)e.setRequestHeader(c,s[c]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=RT(i=this.readystatechange).call(i,this),e.onprogress=RT(n=this.loadprogress).call(n,this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&oO(l)?l:u,this.requestTimeout=Wf(RT(a=this.loadtimeout).call(a,this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,n=this.config;if(!r.aborted&&i>=2){var a;if(0===r.loading.first)if(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=Wf(RT(a=this.loadtimeout).call(a,this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start));if(4===i){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 u="arraybuffer"===t.responseType?l.byteLength:l.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;var h={url:t.responseURL,data:l,code:s};return void this.callbacks.onSuccess(h,r,e,t)}}var d,f=n.loadPolicy.errorRetry;if(LF(f,r.retry,!1,{url:e.url,data:void 0,code:s}))this.retry(f);else CO.error(_d(d="".concat(s," while loading ")).call(d,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(LF(e,this.stats.retry,!0))this.retry(e);else{var t;CO.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,i,n,a,s=this.context,o=this.stats;this.retryDelay=SF(e,o.retry),o.retry++,CO.warn(_d(t=_d(r=_d(i=_d(n="".concat(status?"HTTP Status "+status:"Timeout"," while loading ")).call(n,null==s?void 0:s.url,", retrying ")).call(i,o.retry,"/")).call(r,e.maxNumRetry," in ")).call(t,this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=Wf(RT(a=this.loadInternal).call(a,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&&RV.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?zS(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}(),DV=bO(bO({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:IV,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:vF,bufferController:dK,capLevelController:gK,errorController:CF,fpsController:nH,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:IU,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:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},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},{cueHandler:TV,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:bH,subtitleTrackController:cH,timelineController:mV,audioStreamController:aK,audioTrackController:oK,emeController:rH,cmcdController:JK,contentSteeringController:ZK,interstitialsController:LH});function _V(e){var t;return e&&"object"===Pc(e)?tT(e)?Jk(e).call(e,_V):mP(t=zf(e)).call(t,(function(t,r){return t[r]=_V(e[r]),t}),{}):e}function wV(e,t){var r=e.loader;r!==AV&&r!==IV?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=AV,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}function PV(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function CV(e,t,r,i,n){var a=new e(t,r,"");try{a.value=i,n&&(a.type=n)}catch(s){a=new e(t,r,KI(n?bO({type:n},i):i))}return a}var xV=function(){var e=PV();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();var MV=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){i.hls&&i.hls.trigger(dO.EVENT_CUE_ENTER,{})},this.hls=r,this._registerListeners()}return Fc(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(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(dO.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(dO.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&&oH(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 aH(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=PV();if(s)for(var o=0;o<a.length;o++){var l=a[o].type;if((l!==QB.emsg||i)&&n){var u=qB(a[o].data);if(u){var c=a[o].pts,h=c+a[o].duration;h>xV&&(h=xV),h-c<=0&&(h=c+.25);for(var d=0;d<u.length;d++){var f=u[d];if(!WB(f)){this.updateId3CueEnds(c,l);var v=CV(s,c,h,f,l);v&&this.id3Track.addCue(v)}}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.type===t&&a.startTime<e&&a.endTime===xV&&(a.endTime=e)}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,a=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(l||u))lH(a,r,i,"audio"===n?function(e){return e.type===QB.audioId3&&u}:"video"===n?function(e){return e.type===QB.emsg&&l}:function(e){return e.type===QB.audioId3&&u||e.type===QB.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 i,n=this.id3Track,a=e.dateRanges,s=zf(a),o=this.dateRangeCuesAppended;if(n&&t)if(null!=(i=n.cues)&&i.length)for(var l,u=rT(l=zf(o)).call(l,(function(e){return!mv(s).call(s,e)})),c=function(){var e,t=u[h],i=o[t].cues;delete o[t],vd(e=zf(i)).call(e,(function(e){try{var t=i[e];t.removeEventListener("enter",r.onEventCueEnter),n.removeCue(t)}catch(a){}}))},h=u.length;h--;)c();else o=this.dateRangeCuesAppended={};var d=e.fragments[e.fragments.length-1];if(0!==s.length&&oO(null==d?void 0:d.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=PV(),v=function(){var e=s[g],t=a[e],i=t.startTime,n=o[e],l=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,c=xV,h=t.duration;if(t.endDate&&null!==h)c=i+h,u=!0;else if(t.endOnNext&&!u){var d=mP(s).call(s,(function(e,r){if(r!==t.id){var i=a[r];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate<e.startDate))return i}return e}),null);d&&(c=d.startTime,u=!0)}for(var v,p,m=zf(t.attr),y=0;y<m.length;y++){var E=m[y];if("ID"!==(p=E)&&"CLASS"!==p&&"CUE"!==p&&"START-DATE"!==p&&"DURATION"!==p&&"END-DATE"!==p&&"END-ON-NEXT"!==p){var k=l[E];if(k)u&&!n.durationKnown?k.endTime=c:Math.abs(k.startTime-i)>.01&&(k.startTime=i,k.endTime=c);else if(f){var T=t.attr[E];eU(E)&&(v=T,T=Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=CV(f,i,c,{key:E,data:T},QB.dateRange);S&&(S.id=e,r.id3Track.addCue(S),l[E]=S,r.hls.config.interstitialsController&&("X-ASSET-LIST"!==E&&"X-ASSET-URL"!==E||S.addEventListener("enter",r.onEventCueEnter)))}}}o[e]={cues:l,dateRange:t,durationKnown:u}},g=0;g<s.length;g++)v()}}}}]),e}(),OV=function(){function e(r){var i=this;t(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=i.media,t=i.hls.latestLevelDetails;if(e&&t){i.currentTime=e.currentTime;var r=i.computeLatency();if(null!==r){i._latency=r;var n=i.config,a=n.lowLatencyMode,s=n.maxLiveSyncPlaybackRate;if(a&&1!==s&&t.live){var o=i.targetLatency;if(null!==o){var l=r-o;if(l<Math.min(i.maxLatency,o+t.targetduration)&&l>.05&&i.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),c=Math.round(2/(1+Math.exp(-.75*l-i.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=r,this.config=r.config,this.registerListeners()}return Fc(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,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var c=i;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)},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 i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),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(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){this.hls.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(dO.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===hO.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}(),FV=function(e){Ch(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 Fc(i,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(dO.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(dO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){var e=this._levels;vd(e).call(e,(function(e){e.loadError=0,e.fragmentError=0})),Ih(Rh(i.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,i=this,n=this.hls.config.preferManagedMediaSource,a=[],s={},o={},l=!1,u=!1,c=!1;vd(r=t.levels).call(r,(function(e){var t,r,h,d,f,v,g,p=e.attrs,m=e.audioCodec,y=e.videoCodec;m&&(e.audioCodec=m=VO(m,n)||void 0),0===(null==(g=y)?void 0:_v(g).call(g,"avc1"))&&(y=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var n,a=i.shift()+".";a+=qk(i.shift()).toString(16),a+=ag(n="000"+qk(i.shift()).toString(16)).call(n,-4),t[r]=a}}return t.join(",")}(y));var E=e.width,k=e.height,T=e.unknownCodecs,S=T?T.length:0;if(T)for(var A=S;A--;){var L,b=T[A];if(i.isAudioSupported(b))e.audioCodec=m=m?_d(L="".concat(m,",")).call(L,b):b,S--,OO.audio[m.substring(0,4)]=2;else if(i.isVideoSupported(b)){var R;e.videoCodec=y=y?_d(R="".concat(y,",")).call(R,b):b,S--,OO.video[y.substring(0,4)]=2}}if(l||(l=!(!E||!k)),u||(u=!!y),c||(c=!!m),!(S||m&&!i.isAudioSupported(m)||y&&!i.isVideoSupported(y))){var I=p.CODECS,D=p["FRAME-RATE"],_=p["HDCP-LEVEL"],w=p["PATHWAY-ID"],P=p.RESOLUTION,C=p["VIDEO-RANGE"],x="".concat(w||".","-"),M=_d(t=_d(r=_d(h=_d(d=_d(f=_d(v="".concat(x)).call(v,e.bitrate,"-")).call(f,P,"-")).call(d,D,"-")).call(h,I,"-")).call(r,C,"-")).call(t,_);if(s[M])if(s[M].uri===e.url||e.attrs["PATHWAY-ID"])s[M].addGroupId("audio",p.AUDIO),s[M].addGroupId("text",p.SUBTITLES);else{var O=o[M]+=1;e.attrs["PATHWAY-ID"]=new Array(O+1).join(".");var F=new iF(e);s[M]=F,a.push(F)}else{var N=new iF(e);s[M]=N,o[M]=1,a.push(N)}}})),this.filterAndSortMediaOptions(a,t,l,u,c)}},{key:"isAudioSupported",value:function(e){return FO(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return FO(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,i,n){var a=this,s=[],o=[],l=e;if((r||i)&&n&&(l=rT(l).call(l,(function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&(!!(t=i)&&_v($O).call($O,t)>-1)}))),0!==l.length){var u;if(t.audioTracks)NV(s=rT(u=t.audioTracks).call(u,(function(e){return!e.audioCodec||a.isAudioSupported(e.audioCodec)})));t.subtitles&&NV(o=t.subtitles);var c=ag(l).call(l,0);GA(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 _v($O).call($O,e.videoRange)-_v($O).call($O,t.videoRange);if(e.videoCodec!==t.videoCodec){var i=BO(e.videoCodec),n=BO(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=GO(e.codecSet),s=GO(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==c.length)for(var d=0;d<c.length;d++)if(c[d].pathwayId===l[0].pathwayId){h=c[d];break}this._levels=l;for(var f=0;f<l.length;f++)if(l[f]===h){var v,g;this._firstLevel=f;var p=h.bitrate,m=this.hls.bandwidthEstimate;if(this.log(_d(v="manifest loaded, ".concat(l.length," level(s) found, first bitrate: ")).call(v,p)),void 0===(null==(g=this.hls.userConfig)?void 0:g.abrEwmaDefaultEstimate)){var y=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);y>m&&m===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=y)}break}var E=n&&!i,k={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!E&&cS(s).call(s,(function(e){return!!e.url}))};this.hls.trigger(dO.MANIFEST_PARSED,k)}else Lk.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: ".concat(KI(t.levels[0].attrs)));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.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,i,n,a,s,o,l=this._levels;if(0!==l.length){if(e<0||e>=l.length){var u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,l.length-1)}var h=this.currentLevelIndex,d=this.currentLevel,f=d?d.attrs["PATHWAY-ID"]:void 0,v=l[e],g=v.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=v,h!==e||!d||f!==g){this.log(_d(t=_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Switching to level ".concat(e," (")).call(o,v.height?v.height+"p ":"")).call(s,v.videoRange?v.videoRange+" ":"")).call(a,v.codecSet?v.codecSet+" ":"","@")).call(n,v.bitrate,")")).call(i,g?" with Pathway "+g:""," from level ")).call(r,h)).call(t,f?" with Pathway "+f:""));var p={level:e,attrs:v.attrs,details:v.details,bitrate:v.bitrate,averageBitrate:v.averageBitrate,maxBitrate:v.maxBitrate,realBitrate:v.realBitrate,width:v.width,height:v.height,codecSet:v.codecSet,audioCodec:v.audioCodec,videoCodec:v.videoCodec,audioGroups:v.audioGroups,subtitleGroups:v.subtitleGroups,loaded:v.loaded,loadError:v.loadError,fragmentError:v.fragmentError,name:v.name,id:v.id,uri:v.uri,url:v.url,urlId:0,audioGroupIds:v.audioGroupIds,textGroupIds:v.textGroupIds};this.hls.trigger(dO.LEVEL_SWITCHING,p);var m=v.details;if(!m||m.live){var y=this.switchParams(v.uri,null==d?void 0:d.details,m);this.loadPlaylist(y)}}}}},{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(),i=rT(e).call(e,(function(e){return-1!==_v(r).call(r,e)}));if(e.length<1)return void this.warn(_d(t="pathwayPriority ".concat(e," should contain at least one pathway from list: ")).call(t,r));this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===vO&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===mO){var i,n=r.elementaryStreams;if(!cS(i=zf(n)).call(i,(function(e){return!!n[e]})))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of ".concat(a.loadError," on frag buffered")),a.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n=t.level,a=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index ".concat(n)),void(null!=(i=t.deliveryDirectives)&&i.skip&&(a.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(n,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var o=this.getUrlWithDirectives(e.uri,t),l=this.currentLevelIndex,u=e.attrs["PATHWAY-ID"],c=e.details,h=null==c?void 0:c.age;this.log(_d(r=_d(n=_d(a=_d(s="Loading level index ".concat(l)).call(s,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,u?" Pathway "+u:"")).call(n,h&&c.live?" age "+h.toFixed(1)+(c.type&&" "+c.type||""):""," ")).call(r,o)),this.hls.trigger(dO.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,i=this;if(1!==this._levels.length){var n=rT(t=this._levels).call(t,(function(t,r){if(r!==e)return!0;var n;(i.steering&&i.steering.removeLevel(t),t===i.currentLevel)&&(i.currentLevel=null,i.currentLevelIndex=-1,t.details&&vd(n=t.details.fragments).call(n,(function(e){return e.level=-1})));return!1}));tB(n),this._levels=n,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 a=n.length-1;this._firstLevel=Math.min(this._firstLevel,a),this._startLevel&&(this._startLevel=Math.min(this._startLevel,a)),this.hls.trigger(dO.LEVELS_UPDATED,{levels:n})}}},{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,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(dO.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}]),i}(sK);function NV(e){var t={};vd(e).call(e,(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var UV=function(e){Ch(i,e);var r=ed(i);function i(e,n,a,s){var o;return t(this,i),(o=r.call(this,"gap-controller",s.logger)).config=void 0,o.media=null,o.fragmentTracker=void 0,o.hls=void 0,o.nudgeRetry=0,o.stallReported=!1,o.stalled=null,o.moved=!1,o.seeking=!1,o.ended=0,o.config=e,o.media=n,o.fragmentTracker=a,o.hls=s,o}return Fc(i,[{key:"destroy",value:function(){this.media=null,this.hls=this.fragmentTracker=null}},{key:"poll",value:function(e,t,r,i){var n=this.config,a=this.media,s=this.stalled;if(null!==a){var o=a.currentTime,l=a.seeking,u=this.seeking&&!l,c=!this.seeking&&l;if(this.seeking=l,o===e)if(c||u)this.stalled=null;else{if(a.paused&&!l||a.ended||0===a.playbackRate||!YN.getBuffered(a).length)return!this.ended&&a.ended&&(this.ended=o||1,this.hls.trigger(dO.MEDIA_ENDED,{stalled:!1})),void(this.nudgeRetry=0);var h=YN.bufferInfo(a,o,0),d=h.nextStart||0;if(l){var f=h.len>2,v=!d||t&&t.start<=o||d-o>2&&!this.fragmentTracker.getPartialFragment(o);if(f||v)return;this.moved=!1}if(!this.moved&&null!==this.stalled){if(!(h.len>0)&&!d)return;var g=Math.max(d,h.start||0)-o,p=!(null==r||!r.live)?2*r.targetduration:2,m=this.fragmentTracker.getPartialFragment(o);if(g>0&&(g<=p||m))return void(a.paused||this._trySkipBufferHole(m))}var y=self.performance.now();if(null!==s){var E=y-s;if(!l&&E>=250){if(i===pB&&(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(dO.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(h),!this.media)return}var k=YN.bufferInfo(a,o,n.maxBufferHole);this._tryFixBufferStall(k,E)}else this.stalled=y}else if(e&&(this.ended=0),this.moved=!0,l||(this.nudgeRetry=0),null!==s){if(this.stallReported){var T,S=self.performance.now()-s;this.warn(_d(T="playback not stuck anymore @".concat(o,", after ")).call(T,Math.round(S),"ms")),this.stallReported=!1}this.stalled=null}}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s)if(this._trySkipBufferHole(s)||!this.media)return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<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 i;this.stallReported=!0;var n=new Error(_d(i="Playback stalling at @".concat(r.currentTime," due to low buffer (")).call(i,KI(e),")"));this.warn(n.message),t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}},{key:"_trySkipBufferHole",value:function(e){var t=this.config,r=this.hls,i=this.media;if(null===i)return 0;var n=i.currentTime,a=YN.bufferInfo(i,n,0),s=n<a.start?a.start:a.nextStart;if(s){var o=a.len<=t.maxBufferHole,l=a.len>0&&a.len<1&&i.readyState<3,u=s-n;if(u>0&&(o||l)){var c;if(u>t.maxBufferHole){var h=this.fragmentTracker,d=!1;if(0===n){var f=h.getAppendedFrag(0,mO);f&&s<f.end&&(d=!0)}if(!d){var v=e||h.getAppendedFrag(n,mO);if(v){for(var g=!1,p=v.end;p<s;){var m=h.getPartialFragment(p);if(!m){g=!0;break}p+=m.duration}if(g)return 0}}}var y=Math.max(s+.05,n+.1);if(this.warn(_d(c="skipping hole, adjusting currentTime from ".concat(n," to ")).call(c,y)),this.moved=!0,this.stalled=null,i.currentTime=y,e&&!e.gap){var E,k=new Error(_d(E="fragment loaded with buffer holes, seeking from ".concat(n," to ")).call(E,y));r.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:k,reason:k.message,frag:e})}return y}}return 0}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var n=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var a,s=n+(i+1)*e.nudgeOffset,o=new Error(_d(a="Nudging 'currentTime' from ".concat(n," to ")).call(a,s));this.warn(o.message),r.currentTime=s,t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l,u=new Error(_d(l="Playhead still not moving while enough data buffered @".concat(n," after ")).call(l,e.nudgeMaxRetry," nudges"));this.error(u.message),t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_STALLED_ERROR,error:u,fatal:!0})}}}}]),i}(RO);function BV(){return self.SourceBuffer||self.WebKitSourceBuffer}function GV(){if(!xO())return!1;var e=BV();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var KV=function(e){Ch(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"stream-controller",mO)).audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s._hasEnoughToStart=!1,s.altAudio=0,s.audioOnly=!1,s.fragPlaying=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s.onMediaPlaying=function(){var e=s.gapController;e&&(e.ended=0),s.tick()},s.onMediaSeeked=function(){var e=s.media,t=e?e.currentTime:null;oO(t)&&s.log("Media seeked to ".concat(t.toFixed(3)));var r=s.getMainFwdBufferInfo();null!==r&&0!==r.len?s.tick():s.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"))},s.registerListeners(),s}return Fc(i,[{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(dO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(dO.BUFFER_CREATED,this.onBufferCreated,this),e.on(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(dO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(dO.BUFFER_CREATED,this.onBufferCreated,this),e.off(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this)}},{key:"startLoad",value:function(e,t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var n=i.startLevel;-1===n&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.firstAutoLevel),i.nextLoadLevel=n,this.level=i.loadLevel,this._hasEnoughToStart=!1}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r),this.state=uB,this.nextLoadPosition=this.lastCurrentTime=e,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=lB}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,Ih(Rh(i.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case EB:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=uB;break}if(this.hls.nextLoadLevel!==this.level){this.state=uB;break}break;case dB:var n,a=self.performance.now(),s=this.retryDate;if(!s||a>=s||null!=(n=this.media)&&n.seeking){var o=this.levels,l=this.level,u=null==o?void 0:o[l];this.resetStartWhenNotLoaded(u||null),this.state=uB}}this.state===uB&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){Ih(Rh(i.prototype),"onTickEnd",this).call(this),this.checkBuffer(),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[n]){var a=r[n],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(dO.BUFFER_EOS,l),void(this.state=pB)}if(this.buffering){var u;if(e.loadLevel!==n&&-1===e.manualLevel)this.log(_d(u="Adapting to level ".concat(n," from level ")).call(u,this.level));this.level=e.nextLoadLevel=n;var c=a.details;if(!c||this.state===EB||this.waitForLive(a))return this.level=n,this.state=EB,void(this.startFragRequested=!1);var h=s.len,d=this.getMaxBufferLength(a.maxBitrate);if(!(h>=d)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:s.end,v=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&v&&lN(v)&&this.fragmentTracker.getState(v)!==NF){var g,p=(null!=(g=this.backtrackFragment)?g:v).sn-c.startSN,m=c.fragments[p-1];m&&v.cc===m.cc&&(v=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,f)){if(!v.gap){var y=this.audioOnly&&!this.altAudio?nN:aN,E=(y===aN?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,y,mO)}v=this.getNextFragmentLoopLoading(v,c,s,mO,d)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,a,f))}}}}}}},{key:"loadFragment",value:function(e,t,r){var n=this.fragmentTracker.getState(e);if(n===MF||n===FF)if(lN(e))if(this.bitrateTest){var a;this.log(_d(a="Fragment ".concat(e.sn," of level ")).call(a,e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,mO)}},{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,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.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 u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var c=u.maxStartPTS?u.maxStartPTS:u.start,h=u.duration,d=Math.max(l.end,c+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(d,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 cB:case hB:case dB:case vB:case gB:this.state=uB}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,t){Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,e,t,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,t){Ih(Rh(i.prototype),"onMediaAttached",this).call(this,e,t);var r=t.media;r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked),r.addEventListener("playing",this.onMediaPlaying),r.addEventListener("seeked",this.onMediaSeeked),this.gapController=new UV(this.config,r,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;r&&(r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),Ih(Rh(i.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(dO.MEDIA_ENDED,{stalled:!1})}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(dO.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,i,n,a=!1,s=!1;vd(r=t.levels).call(r,(function(e){var t=e.audioCodec;t&&(a=a||-1!==_v(t).call(t,"mp4a.40.2"),s=s||-1!==_v(t).call(t,"mp4a.40.5"))})),this.audioCodecSwitch=a&&s&&!("function"==typeof(null==(n=BV())||null==(i=n.prototype)?void 0:i.changeType)),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===uB){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=EB)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n,a,s,o,l,u,c=this.levels,h=this.startFragRequested,d=t.level,f=t.details,v=f.totalduration;if(c){this.log(_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Level ".concat(d," loaded [")).call(o,f.startSN,",")).call(s,f.endSN,"]")).call(a,f.lastPartSn?_d(l="[part-".concat(f.lastPartSn,"-")).call(l,f.lastPartIndex,"]"):"",", cc [")).call(n,f.startCC,", ")).call(i,f.endCC,"] duration:")).call(r,v));var g=t.levelInfo,p=this.fragCurrent;!p||this.state!==hB&&this.state!==dB||p.level!==t.level&&p.loader&&this.abortCurrentFrag();var m=0;if(f.live||null!=(u=g.details)&&u.live){var y;if(this.checkLiveUpdate(f),f.deltaUpdateFailed)return;m=this.alignPlaylists(f,g.details,null==(y=this.levelLastLoaded)?void 0:y.details)}if(g.details=f,this.levelLastLoaded=g,h||this.setStartPosition(f,m),this.hls.trigger(dO.LEVEL_UPDATED,{details:f,level:d}),this.state===EB){if(this.waitForCdnTuneIn(f))return;this.state=uB}h&&f.live&&this.synchronizeToLiveEdge(f),this.tick()}else this.warn("Levels were reset while loading level ".concat(d))}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragmentStart,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var l,u,c=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if(!o&&r.readyState<4||n<s-c)if(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState)this.warn(_d(l=_d(u="Playback: ".concat(n.toFixed(3)," is located too far from the end of live sliding playlist: ")).call(u,s,", reset currentTime to : ")).call(l,i.toFixed(3))),r.currentTime=i}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r,i,n=e.frag,a=e.part,s=e.payload,o=this.levels;if(o){var l=o[n.level];if(l){var u,c=l.details;if(!c)return this.warn(_d(u="Dropping fragment ".concat(n.sn," of level ")).call(u,n.level," after level details were reset")),void this.fragmentTracker.removeFragment(n);var h=l.videoCodec,d=c.PTSKnown||!c.live,f=null==(i=n.initSegment)?void 0:i.data,v=this._getAudioCodec(l),g=this.transmuxer=this.transmuxer||new tK(this.hls,mO,RT(t=this._handleTransmuxComplete).call(t,this),RT(r=this._handleTransmuxerFlush).call(r,this)),p=a?a.index:-1,m=-1!==p,y=new VN(n.level,n.sn,n.stats.chunkCount,s.byteLength,p,m),E=this.initPTS[n.cc];g.push(s,f,v,h,n,a,c.totalduration,d,y,E)}else this.warn("Level ".concat(n.level," not found on progress"))}else{var k;this.warn(_d(k="Levels were reset while fragment load was in progress. Fragment ".concat(n.sn," of level ")).call(k,n.level," will not be buffered"))}}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this.hls,i=2===this.altAudio;if(fF(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 n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();i&&(r.trigger(dO.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(dO.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=fF(t.url,this.hls);if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use ".concat(i,".buffered to schedule main fragment loading")),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part,n=r.type===mO;if(n){var a,s,o;if(this.fragContextChanged(r))return this.warn(_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state)),void(this.state===gB&&(this.state=uB));var l=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),lN(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}var u=this.media;u&&(!this._hasEnoughToStart&&u.buffered.length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=mB;else switch(t.details){case hO.FRAG_GAP:case hO.FRAG_PARSING_ERROR:case hO.FRAG_DECRYPT_ERROR:case hO.FRAG_LOAD_ERROR:case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_ERROR:case hO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(mO,t);break;case hO.LEVEL_LOAD_ERROR:case hO.LEVEL_LOAD_TIMEOUT:case hO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==EB||(null==(r=t.context)?void 0:r.type)!==vO||(this.state=uB);break;case hO.BUFFER_APPEND_ERROR:case hO.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===hO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case hO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"checkBuffer",value:function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this._hasEnoughToStart||!YN.getBuffered(e).length){var r=this.state,i=r!==uB?this.fragCurrent:null,n=this.getLevelDetails();t.poll(this.lastCurrentTime,i,n,r)}this.lastCurrentTime=e.currentTime}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=uB,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==nN||this.audioOnly&&!this.altAudio){var i=(r===aN?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,mO),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 i;if(e.seeking)return void this.log(_d(i="could not seek to ".concat(r,", already seeking at ")).call(i,t));var n=this.getLevelDetails(),a=this.config.timelineOffset;a&&r&&(r+=(null==n?void 0:n.appliedTimelineOffset)||a);var s,o,l=YN.getBuffered(e),u=l.length?l.start(0):0,c=u-r,h=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(c>0&&(c<h||this.loadingParts&&c<2*((null==n?void 0:n.partTarget)||0))&&(this.log("adjusting start position by ".concat(c," to match buffer start")),r+=c,this.startPosition=r),t<r)this.log(_d(s=_d(o="seek to target start position ".concat(r," from current time ")).call(o,t," buffer start ")).call(s,u)),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!==_v(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 i=r.hls,n=null==e?void 0:e.frag;if(n&&!r.fragContextChanged(n)){t.fragmentError=0,r.state=uB,r.startFragRequested=!1,r.bitrateTest=!1;var a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(dO.FRAG_LOADED,e),n.bitrateTest=!1}}))}},{key:"_handleTransmuxComplete",value:function(e){var t,r=this.playlistType,i=this.hls,n=e.remuxResult,a=e.chunkMeta,s=this.getCurrentContext(a);if(s){var o=s.frag,l=s.part,u=s.level,c=n.video,h=n.text,d=n.id3,f=n.initSegment,v=u.details,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=vB,f){if(null!=f&&f.tracks){var p=o.initSegment||o;this._bufferInitSegment(u,f.tracks,p,a),i.trigger(dO.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:f.tracks})}var m=f.initPTS,y=f.timescale;oO(m)&&(this.initPTS[o.cc]={baseTime:m,timescale:y},i.trigger(dO.INIT_PTS_FOUND,{frag:o,id:r,initPTS:m,timescale:y}))}if(c&&v){var E=v.fragments[o.sn-1-v.startSN],k=o.sn===v.startSN,T=!E||o.cc>E.cc;if(!1!==n.independent){var S=c.startPTS,A=c.endPTS,L=c.startDTS,b=c.endDTS;if(l)l.elementaryStreams[c.type]={startPTS:S,endPTS:A,startDTS:L,endDTS:b};else if(c.firstKeyFrame&&c.independent&&1===a.id&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){var R=this.getMainFwdBufferInfo(),I=(R?R.end:this.getLoadPosition())+this.config.maxBufferHole,D=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!k&&I<D-this.config.maxBufferHole&&!T)return void this.backtrack(o);T&&(o.gap=!0),o.setElementaryStreamInfo(c.type,o.start,A,o.start,b,!0)}else k&&S-(v.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(c.type,S,A,L,b),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,l,a,k||T)}else{if(!k&&!T)return void this.backtrack(o);o.gap=!0}}if(g){var _=g.startPTS,w=g.endPTS,P=g.startDTS,C=g.endDTS;l&&(l.elementaryStreams[nN]={startPTS:_,endPTS:w,startDTS:P,endDTS:C}),o.setElementaryStreamInfo(nN,_,w,P,C),this.bufferFragmentData(g,o,l,a)}if(v&&null!=d&&null!=(t=d.samples)&&t.length){var x={id:r,frag:o,details:v,samples:d.samples};i.trigger(dO.FRAG_PARSING_METADATA,x)}if(v&&h){var M={id:r,frag:o,details:v,samples:h.samples};i.trigger(dO.FRAG_PARSING_USERDATA,M)}}}else this.resetWhenMissingContext(a)}},{key:"_bufferInitSegment",value:function(e,t,r,i){var n=this;if(this.state===vB){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a,s,o=t.audio,l=t.video,u=t.audiovideo;if(o){var c,h,d,f=jO(o.codec,e.audioCodec);"mp4a"===f&&(f="mp4a.40.5");var v,g=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){f&&(f=-1!==_v(f).call(f,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var p=o.metadata;p&&"channelCount"in p&&1!==(p.channelCount||1)&&-1===_v(g).call(g,"firefox")&&(f="mp4a.40.5")}if(f&&-1!==_v(f).call(f,"mp4a.40.5")&&-1!==_v(g).call(g,"android")&&"audio/mpeg"!==o.container&&(f="mp4a.40.2",this.log("Android: force audio codec to ".concat(f))),e.audioCodec&&e.audioCodec!==f)this.log(_d(v='Swapping manifest audio codec "'.concat(e.audioCodec,'" for "')).call(v,f,'"'));o.levelCodec=f,o.id="main",this.log(_d(c=_d(h=_d(d="Init audio buffer, container:".concat(o.container,", codecs[selected/level/parsed]=[")).call(d,f||"","/")).call(h,e.audioCodec||"","/")).call(c,o.codec,"]")),delete t.audiovideo}if(l){var m,y,E;l.levelCodec=e.videoCodec,l.id="main";var k=l.codec;if(4===(null==k?void 0:k.length))switch(k){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(_d(m=_d(y=_d(E="Init video buffer, container:".concat(l.container,", codecs[level/parsed]=[")).call(E,e.videoCodec||"","/")).call(y,k)).call(m,l.codec!==k?" parsed-corrected="+l.codec:"","}]")),delete t.audiovideo}if(u)this.log(_d(a=_d(s="Init audiovideo buffer, container:".concat(u.container,", codecs[level/parsed]=[")).call(s,e.codecs,"/")).call(a,u.codec,"]")),delete t.video,delete t.audio;var T=zf(t);if(T.length){if(this.hls.trigger(dO.BUFFER_CODECS,t),!this.hls)return;vd(T).call(T,(function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(dO.BUFFER_APPENDING,{type:e,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,mO)}},{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=uB}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(YN.isBuffered(e,r)?t=this.getAppendedFrag(r):YN.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n||(this.fragPlaying=t,this.hls.trigger(dO.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(dO.LEVEL_SWITCHED,{level:n}))}}}},{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 oO(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(oO(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?pF(null,r.fragments,t):null);if(i){var n=i.programDateTime;if(null!==n){var a=n+1e3*(t-i.start);return new Date(a)}}}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}}]),i}(kB),HV=function(){function e(r){t(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=r}return Fc(e,[{key:"abort",value:function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.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]:hO.KEY_LOAD_ERROR,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;return new KN({type:cO.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}},{key:"loadClear",value:function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(){var e=t[s];if(n<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),"break"},s=0;s<t.length;s++){if("break"===a())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,i;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return Lk.reject(this.createKeyLoadError(e,hO.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return Lk.reject(this.createKeyLoadError(e,hO.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(s,'"'))));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return n.key=l.decryptdata.key,Lk.resolve({frag:e,keyInfo:l});if(null!=(i=l)&&i.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 n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.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 Lk.reject(this.createKeyLoadError(e,hO.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(n.method,'"'))))}}},{key:"loadKeyEME",value:function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Lk.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Lk((function(a,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(e,t,i,n){var o=i.frag,l=i.keyInfo,u=i.url;if(!o.decryptdata||l!==r.keyUriToKeyInfo[u])return s(r.createKeyLoadError(o,hO.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,l.loader=null,a({frag:o,keyInfo:l})},onError:function(e,i,n,a){var l;r.resetLoader(i),s(r.createKeyLoadError(t,hO.KEY_LOAD_ERROR,new Error(_d(l="HTTP Error ".concat(e.code," loading key ")).call(l,e.text)),n,bO({url:o.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,hO.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,hO.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(o,u,c)}))}},{key:"resetLoader",value:function(e){var t=e.frag,r=e.keyInfo,i=e.url,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()}}]),e}();function VV(e){switch(e.type){case gO:return yO;case pO:return EO;default:return mO}}function jV(e,t){var r=e.url;return void 0!==r&&0!==_v(r).call(r,"data:")||(r=t.url),r}var YV=function(){function e(r){t(this,e),this.hls=void 0,this.loaders=bT(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=r,this.registerListeners()}return Fc(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(dO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.LEVEL_LOADING,this.onLevelLoading,this),e.off(dO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(dO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n}},{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:fO,url:r,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var r=t.id,i=t.level,n=t.pathwayId,a=t.url,s=t.deliveryDirectives,o=t.levelInfo;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:vO,url:a,deliveryDirectives:s,levelOrTrack:o})}},{key:"onAudioTrackLoading",value:function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:gO,url:n,deliveryDirectives:a,levelOrTrack:s})}},{key:"onSubtitleTrackLoading",value:function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:pO,url:n,deliveryDirectives:a,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[vO];if(r){var i,n=r.context;n&&!cS(i=t.levels).call(i,(function(e){return e===n.levelOrTrack}))&&(r.abort(),delete this.loaders[vO])}}},{key:"load",value:function(e){var t,r,i,n=this,a=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 u;if(l.url===e.url)o.log("[playlist-loader]: ignore ".concat(e.url," ongoing request"));else o.log(_d(u="[playlist-loader]: ignore ".concat(e.url," in favor of ")).call(u,l.url));return}o.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if((r=e.type===fO?a.manifestLoadPolicy.default:AO({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),oO(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===vO&&null!==e.level?i=this.hls.levels[e.level].details:e.type===gO&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===pO&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var c=i.partTarget,h=i.targetduration;if(c&&h){var d=1e3*Math.max(3*c,.8*h);r=AO({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var f=r.errorRetry||r.timeoutRetry||{},v={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},g={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===_v(s).call(s,"#EXTM3U")?(t.parsing.start=performance.now(),NU.isMediaPlaylist(s)||r.type!==fO?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,v,g)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e,t=this.hls,r=t.config,i=r.autoStartLoad,n=r.startPosition,a=t.forceStartLoad;if(i||a)this.hls.logger.log(_d(e="".concat(i?"auto":"force"," startLoad with configured startPosition ")).call(e,n)),this.hls.startLoad(n)}}},{key:"handleMasterPlaylist",value:function(e,t,r,i){var n=this.hls,a=e.data,s=jV(e,r),o=NU.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var l=o.contentSteering,u=o.levels,c=o.sessionData,h=o.sessionKeys,d=o.startTimeOffset,f=o.variableList;this.variableList=f;var v=NU.parseMasterPlaylistMedia(a,s,o),g=v.AUDIO,p=void 0===g?[]:g,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];if(p.length)cS(p).call(p,(function(e){return!e.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ZN({}),bitrate:0,url:""}));n.trigger(dO.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:m,captions:y,contentSteering:l,url:s,stats:t,networkDetails:i,sessionData:c,sessionKeys:h,startTimeOffset:d,variableList:f})}}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,r,i,n){var a=this.hls,s=r.id,o=r.level,l=r.type,u=jV(e,r),c=oO(o)?o:oO(s)?s:0,h=VV(r),d=NU.parseLevelPlaylist(e.data,u,c,h,0,this.variableList);if(l===fO){var f={attrs:new ZN({}),bitrate:0,details:d,name:"",url:u};d.requestScheduled=t.loading.start+JU(d,0),a.trigger(dO.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:u,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=d,this.handlePlaylistLoaded(d,e,t,r,i,n)}},{key:"handleManifestParsingError",value:function(e,t,r,i,n){this.hls.trigger(dO.ERROR,{type:cO.NETWORK_ERROR,details:hO.MANIFEST_PARSING_ERROR,fatal:t.type===fO,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}},{key:"handleNetworkError",value:function(e,t){var r,i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=_d(r="A network ".concat(n?"timeout":"error"+(a?" (status "+a.code+")":"")," occurred while loading ")).call(r,e.type);if(e.type===vO)o+=_d(i=": ".concat(e.level," id: ")).call(i,e.id);else if(e.type===gO||e.type===pO){var l;o+=_d(l=" id: ".concat(e.id,' group-id: "')).call(l,e.groupId,'"')}var u=new Error(o);this.hls.logger.warn("[playlist-loader]: ".concat(o));var c=hO.UNKNOWN,h=!1,d=this.getInternalLoader(e);switch(e.type){case fO:c=n?hO.MANIFEST_LOAD_TIMEOUT:hO.MANIFEST_LOAD_ERROR,h=!0;break;case vO:c=n?hO.LEVEL_LOAD_TIMEOUT:hO.LEVEL_LOAD_ERROR,h=!1;break;case gO:c=n?hO.AUDIO_TRACK_LOAD_TIMEOUT:hO.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case pO:c=n?hO.SUBTITLE_TRACK_LOAD_TIMEOUT:hO.SUBTITLE_LOAD_ERROR,h=!1}d&&this.resetInternalLoader(e.type);var f={type:cO.NETWORK_ERROR,details:c,fatal:h,url:e.url,loader:d,context:e,error:u,networkDetails:t,stats:s};if(a){var v=(null==t?void 0:t.url)||e.url;f.response=bO({url:v,data:void 0},a)}this.hls.trigger(dO.ERROR,f)}},{key:"handlePlaylistLoaded",value:function(e,t,r,i,n,a){var s=this.hls,o=i.type,l=i.level,u=i.id,c=i.groupId,h=i.deliveryDirectives,d=jV(t,i),f=VV(i),v="number"==typeof i.level&&f===mO?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var g=e.playlistParsingError;if(g)s.trigger(dO.ERROR,{type:cO.NETWORK_ERROR,details:hO.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:g,reason:g.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case fO:case vO:s.trigger(dO.LEVEL_LOADED,{details:e,levelInfo:i.levelOrTrack||s.levels[0],level:v||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===fO});break;case gO:s.trigger(dO.AUDIO_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case pO:s.trigger(dO.SUBTITLE_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h})}}else{var p=e.playlistParsingError=new Error("No Segments found in Playlist");s.trigger(dO.ERROR,{type:cO.NETWORK_ERROR,details:hO.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:p,reason:p.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r})}}}]),e}(),qV=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(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 AB,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 i=this.logger=function(e,t,r){var i=_O();if("object"===("undefined"==typeof console?"undefined":Pc(console))&&!0===e||"object"===Pc(e)){var n=["debug","log","info","warn","error"];vd(n).call(n,(function(t){i[t]=wO(t,e,r)}));try{i.log('Debug logs enabled for "'.concat(t,'" in hls.js version ',"1.6.0-beta.2"))}catch(a){return _O()}vd(n).call(n,(function(t){PO[t]=wO(t,e)}))}else AO(PO,i);return i}(r.debug||!1,"Hls instance",r.assetPlayerId),n=this.config=function(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 i=_V(e),n=["manifest","level","frag"],a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return vd(n).call(n,(function(e){var n,s,o="".concat("level"===e?"playlist":e,"LoadPolicy"),l=void 0===t[o],u=[];vd(a).call(a,(function(r){var n,a=_d(n="".concat(e,"Loading")).call(n,r),s=t[a];if(void 0!==s&&l){u.push(a);var c=i[o].default;switch(t[o]={default:c},r){case"TimeOut":c.maxLoadTimeMs=s,c.maxTimeToFirstByteMs=s;break;case"MaxRetry":c.errorRetry.maxNumRetry=s,c.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":c.errorRetry.retryDelayMs=s,c.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":c.errorRetry.maxRetryDelayMs=s,c.timeoutRetry.maxRetryDelayMs=s}}})),u.length&&r.warn(_d(n=_d(s='hls.js config: "'.concat(u.join('", "'),'" setting(s) are deprecated, use "')).call(s,o,'": ')).call(n,KI(t[o])))})),bO(bO({},i),t)}(e.DefaultConfig,r,i);this.userConfig=r,n.progressive&&wV(n,i);var a=n.abrController,s=n.bufferController,o=n.capLevelController,l=n.errorController,u=n.fpsController,c=new l(this),h=this.abrController=new a(this),d=new UF(this),f=n.interstitialsController,v=f?this.interstitialsController=new f(this,e):null,g=this.bufferController=new s(this,d),p=this.capLevelController=new o(this),m=new u(this),y=new YV(this),E=n.contentSteeringController,k=E?new E(this):null,T=this.levelController=new FV(this,k),S=new MV(this),A=new HV(this.config),L=this.streamController=new KV(this,d,A);p.setStreamController(L),m.setStreamController(L);var b=[y,T,L];v&&Rg(b).call(b,1,0,v),k&&Rg(b).call(b,1,0,k),this.networkControllers=b;var R=[h,g,p,m,S,d];this.audioTrackController=this.createController(n.audioTrackController,b);var I=n.audioStreamController;I&&b.push(new I(this,d,A)),this.subtitleTrackController=this.createController(n.subtitleTrackController,b);var D=n.subtitleStreamController;D&&b.push(new D(this,d,A)),this.createController(n.timelineController,R),A.emeController=this.emeController=this.createController(n.emeController,R),this.cmcdController=this.createController(n.cmcdController,R),this.latencyController=this.createController(OV,R),this.coreComponents=R,b.push(c);var _=c.onErrorOut;"function"==typeof _&&this.on(dO.ERROR,_,c),this.on(dO.MANIFEST_LOADED,y.onManifestLoaded,y)}return Fc(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,i=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,i)}},{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(QV){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+QV.message+'". Here is a stacktrace:',QV),!this.triggeringException){this.triggeringException=!0;var r=e===dO.ERROR;this.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.INTERNAL_EXCEPTION,fatal:r,event:e,error:QV}),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(dO.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,vd(e=this.networkControllers).call(e,(function(e){return e.destroy()})),this.networkControllers.length=0,vd(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(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.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,i=r?e.media:e,n=r?e:{media:i};this._media=i,this.trigger(dO.MEDIA_ATTACHING,n)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(dO.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(dO.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=rN.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:".concat(i)),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(dO.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"),vd(e=this.networkControllers).call(e,(function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){var e;this.bufferingEnabled&&(this.logger.log("pause buffering"),vd(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=function(){try{return crypto.randomUUID()}catch(QV){try{var e=NI.createObjectURL(new Blob),t=e.toString();return NI.revokeObjectURL(e),ag(t).call(t,HP(t).call(t,"/")+1)}catch(i){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)}))}}}()),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){(function(e){return _v(QO).call(QO,e)>-1})(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,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}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 XO(e,oF(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return LB}},{key:"isMSESupported",value:function(){return GV()}},{key:"isSupported",value:function(){return function(){var e,t;if(!GV())return!1;var r=xO();return"function"==typeof(null==r?void 0:r.isTypeSupported)&&(cS(e=["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"]).call(e,(function(e){return r.isTypeSupported(UO(e,"video"))}))||cS(t=["mp4a.40.2","fLaC"]).call(t,(function(e){return r.isTypeSupported(UO(e,"audio"))})))}()}},{key:"getMediaSource",value:function(){return xO()}},{key:"Events",get:function(){return dO}},{key:"MetadataSchema",get:function(){return QB}},{key:"ErrorTypes",get:function(){return cO}},{key:"ErrorDetails",get:function(){return hO}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:DV},set:function(t){e.defaultConfig=t}}]),e}();qV.defaultConfig=void 0;var WV={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}};var zV=function(e){Ch(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"beforePlayerInit",value:function(){Ih(Rh(i.prototype),"beforePlayerInit",this).call(this),this._transEvent()}},{key:"_transEvent",value:function(){var e,t=this;vd(e=Ld(dO)).call(e,(function(e){e!==dO.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 i,n,a=arguments.length,s=new Array(a>1?a-1:0),o=1;o<a;o++)s[o-1]=arguments[o];(i=r.player).emit.apply(i,_d(n=[e]).call(n,s))}}))}}]),i}(function(e){Ch(i,e);var r=ed(i);function i(e){var n;t(this,i),(n=r.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=Wf(n._tick,n._tickInterval);var t=n._getBufferend(e);t<.1||!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 Fc(i,[{key:"beforePlayerInit",value:function(){this.register(this.player.config.url)}},{key:"initEvt",value:function(){var e=this;this.hls.on(qV.Events.SUBTITLE_FRAG_PROCESSED,(function(t,r){var i=r.frag;e.player.emit("core_event",{eventName:"core.subtitlesegments",list:i})})),this.hls.on(qV.Events.MANIFEST_PARSED,(function(t,r){var i=r.levels;e.player.emit("core_event",{eventName:"core.subtitleplaylist",list:i})})),this.hls.on(qV.Events.MANIFEST_LOADING,(function(t,r){var i=r.url;e.player.emit("core_event",{eventName:"core.loadstart",url:i})})),this.hls.on(qV.Events.LEVEL_LOADING,(function(t,r){var i=r.url;e.player.emit("core_event",{eventName:"core.loadstart",url:i})})),this.hls.on(qV.Events.FRAG_LOADING,(function(t,r){var i=r.frag;e.player.emit("core_event",{eventName:"core.loadstart",url:i.url})})),this.hls.on(qV.Events.MANIFEST_LOADED,(function(t,r){var i=r.url;e.player.emit("core_event",{eventName:"core.loadcomplete",url:i})})),this.hls.on(qV.Events.LEVEL_LOADED,(function(t,r){var i=r.details,n=r.stats;e.player.emit("core_event",Rf(Rf({eventName:"core.loadcomplete"},n),{},{url:null==i?void 0:i.url}))})),this.hls.on(qV.Events.FRAG_LOADED,(function(t,r){var i=r.frag;e.player.emit("core_event",{eventName:"core.loadcomplete",url:i.url})})),this.hls.on(qV.Events.FRAG_PARSING_USERDATA,(function(t,r){var i=r.samples;e.player.emit("core_event",{eventName:"core.sei",sei:i})})),this.hls.on(qV.Events.MANIFEST_LOADED,(function(t,r){var i=r.levels,n=r.networkDetails;e.player.emit("core_event",{eventName:"core.hlsmanifestloaded",playlist:i}),e.player.emit("core_event",{eventName:"core.loadresponseheaders",headers:n.headers})})),this.hls.on(qV.Events.LEVEL_LOADED,(function(t,r){var i,n=r.details,a={};vd(i=zf(n.dateRanges)).call(i,(function(e){a[e]=n.dateRanges[e].attr["START-DATE"]})),e.player.emit("core_event",{eventName:"core.hlslevelloaded",playlist:Rf(Rf({},n),{},{segments:n.fragments,dateRanges:a})})})),this.hls.on(qV.Events.ERROR,(function(t,r){var i=r.details,n=r.fatal,a=r.type,s=r.response,o=r.reason,l=r.error;if(n){var u,c;switch(a){case qV.ErrorTypes.NETWORK_ERROR:u=2100,mv(i).call(i,"TimeOut")?u=2101:403===(null==s?void 0:s.code)?u=2103:404===(null==s?void 0:s.code)&&(u=2104),e.player.emit("error",{errorType:"network",errorCode:u,message:(null==l?void 0:l.message)||i,originError:r});break;case qV.ErrorTypes.MEDIA_ERROR:c="media",i===qV.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?u=5104:i===qV.ErrorDetails.FRAG_DECRYPT_ERROR?u=5105:i===qV.ErrorDetails.FRAG_PARSING_ERROR?(u=1100,c="manifest"):i===qV.ErrorDetails.FRAG_GAP?u=5104:i===qV.ErrorDetails.BUFFER_ADD_CODEC_ERROR?u=5200:i===qV.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR?u=5104:i===qV.ErrorDetails.BUFFER_APPEND_ERROR||i===qV.ErrorDetails.BUFFER_APPENDING_ERROR?u=5201:i===qV.ErrorDetails.BUFFER_STALLED_ERROR||i===qV.ErrorDetails.BUFFER_FULL_ERROR?u=5203:(i===qV.ErrorDetails.BUFFER_SEEK_OVER_HOLE||i===qV.ErrorDetails.BUFFER_NUDGE_ON_STALL)&&(u=5202),e.player.emit("error",{errorType:c||a,errorCode:u,message:(null==l?void 0:l.message)||i,originError:r});break;case qV.ErrorTypes.MUX_ERROR:u=4100,e.player.emit("error",{errorType:"remux",errorCode:u,message:(null==l?void 0:l.message)||i,originError:r});break;case qV.ErrorTypes.KEY_SYSTEM_ERROR:u=7111,i===qV.ErrorDetails.KEY_SYSTEM_NO_KEYS?u=7103:i===qV.ErrorDetails.KEY_SYSTEM_NO_ACCESS?u=7101:i===qV.ErrorDetails.KEY_SYSTEM_NO_SESSION?u=7104:i===qV.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?u=7107:i===qV.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED?u=7108:i===qV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED||i===qV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?u=7110:i===qV.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?u=7104:i===qV.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR&&(u=7111),e.player.emit("error",{errorType:"drm",errorCode:u,message:(null==l?void 0:l.message)||o||i,originError:r});break;default:i===qV.ErrorDetails.LEVEL_SWITCH_ERROR&&(u=2100,c="network"),e.player.emit("error",{errorType:c||"other",errorCode:u,message:(null==l?void 0:l.message)||o||i,originError:r})}try{e.hls.stopLoad(),e.player.pause()}catch(h){}}})),this.hls.on(qV.Events.MEDIA_ATTACHED,(function(){e.player.emit("sourceopen")})),this.hls.on(qV.Events.BUFFER_APPENDED,(function(){e.player.emit("bufferappend")}))}},{key:"afterCreate",value:function(){var e=this.player.media;this.player.on(eL,this.onUrlChange);try{oL.defineGetterOrSetter(this.player,{url:{get:function(){try{return e.src}catch(QV){return null}},configurable:!0}})}catch(t){}}},{key:"register",value:function(e){var t=this.player;this.hls&&this.hls.destroy();var r=function(e,t){var r,i={};vd(r=zf(WV)).call(r,(function(t){var r=WV[t];i[t]=e[r.key]||r.val}));var n="number"==typeof e.retryCount?e.retryCount:3,a="number"==typeof e.retryDelay?e.retryDelay:1e3,s=e.loadTimeout||1e4,o="number"==typeof e.manifestLoadTimeout?e.manifestLoadTimeout:1e4,l={maxNumRetry:n,retryDelayMs:a,maxRetryDelayMs:a,shouldRetry:function(e,t){return t<e.maxNumRetry}},u={maxNumRetry:n,retryDelayMs:a,maxRetryDelayMs:a,shouldRetry:function(e,t){return t<e.maxNumRetry}};return i.manifestLoadPolicy={default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:o,timeoutRetry:l,errorRetry:u}},i.playlistLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:s,timeoutRetry:l,errorRetry:u}},i.fragLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:s,timeoutRetry:l,errorRetry:u}},Rf(Rf({},i),e)}(this.config,t.config);(this.hls=new qV(r),this.initEvt(),t.config.preProcessUrl)&&(e=t.config.preProcessUrl(e).url);this.hls.loadSource(e);var i=this.player.media;this.hls.attachMedia(i),clearTimeout(this._tickTimer),this._tickTimer=Wf(this._tick,this._tickInterval),i.removeEventListener("play",this._onPlay),i.addEventListener("play",this._onPlay)}},{key:"destroy",value:function(){clearTimeout(this._tickTimer),this.player.off(eL,this.onUrlChange),this.hls.destroy()}}],[{key:"pluginName",get:function(){return"hls"}}]),i}(oL)),XV=window.VePlayer.DynamicModule;VePlayer.registerPlugin(XV.PluginHlsJs,{HlsPlugin:zV}),e.HlsPlugin=zV}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).__VEPLAYER_PLUGIN_HLSJS__={})}(this,(function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n={exports:{}},a=function(e){return e&&e.Math==Math&&e},s=a("object"==typeof globalThis&&globalThis)||a("object"==typeof window&&window)||a("object"==typeof self&&self)||a("object"==typeof r&&r)||function(){return this}()||r||Function("return this")(),o=function(e){try{return!!e()}catch(t){return!0}},l=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),u=l,c=Function.prototype,h=c.apply,d=c.call,f="object"==typeof Reflect&&Reflect.apply||(u?d.bind(h):function(){return d.apply(h,arguments)}),v=l,g=Function.prototype,p=g.call,m=v&&g.bind.bind(p,p),y=v?m:function(e){return function(){return p.apply(e,arguments)}},E=y,k=E({}.toString),T=E("".slice),S=function(e){return T(k(e),8,-1)},A=S,L=y,b=function(e){if("Function"===A(e))return L(e)},R="object"==typeof document&&document.all,I={all:R,IS_HTMLDDA:void 0===R&&void 0!==R},D=I.all,_=I.IS_HTMLDDA?function(e){return"function"==typeof e||e===D}:function(e){return"function"==typeof e},w={},C=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),P=l,x=Function.prototype.call,M=P?x.bind(x):function(){return x.apply(x,arguments)},O={},F={}.propertyIsEnumerable,N=Object.getOwnPropertyDescriptor,U=N&&!F.call({1:2},1);O.f=U?function(e){var t=N(this,e);return!!t&&t.enumerable}:F;var B,G,K=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},H=o,V=S,j=Object,Y=y("".split),q=H((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==V(e)?Y(e,""):j(e)}:j,W=function(e){return null==e},z=W,X=TypeError,Q=function(e){if(z(e))throw X("Can't call method on "+e);return e},$=q,J=Q,Z=function(e){return $(J(e))},ee=_,te=I.all,re=I.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:ee(e)||e===te}:function(e){return"object"==typeof e?null!==e:ee(e)},ie={},ne=ie,ae=s,se=_,oe=function(e){return se(e)?e:void 0},le=function(e,t){return arguments.length<2?oe(ne[e])||oe(ae[e]):ne[e]&&ne[e][t]||ae[e]&&ae[e][t]},ue=y({}.isPrototypeOf),ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",he=s,de=ce,fe=he.process,ve=he.Deno,ge=fe&&fe.versions||ve&&ve.version,pe=ge&&ge.v8;pe&&(G=(B=pe.split("."))[0]>0&&B[0]<4?1:+(B[0]+B[1])),!G&&de&&(!(B=de.match(/Edge\/(\d+)/))||B[1]>=74)&&(B=de.match(/Chrome\/(\d+)/))&&(G=+B[1]);var me=G,ye=me,Ee=o,ke=s.String,Te=!!Object.getOwnPropertySymbols&&!Ee((function(){var e=Symbol();return!ke(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ye&&ye<41})),Se=Te&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ae=le,Le=_,be=ue,Re=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=Ae("Symbol");return Le(t)&&be(t.prototype,Re(e))},De=String,_e=function(e){try{return De(e)}catch(t){return"Object"}},we=_,Ce=_e,Pe=TypeError,xe=function(e){if(we(e))return e;throw Pe(Ce(e)+" is not a function")},Me=xe,Oe=W,Fe=function(e,t){var r=e[t];return Oe(r)?void 0:Me(r)},Ne=M,Ue=_,Be=re,Ge=TypeError,Ke={exports:{}},He=s,Ve=Object.defineProperty,je=function(e,t){try{Ve(He,e,{value:t,configurable:!0,writable:!0})}catch(r){He[e]=t}return t},Ye="__core-js_shared__",qe=s[Ye]||je(Ye,{}),We=qe;(Ke.exports=function(e,t){return We[e]||(We[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 ze=Ke.exports,Xe=Q,Qe=Object,$e=function(e){return Qe(Xe(e))},Je=$e,Ze=y({}.hasOwnProperty),et=Object.hasOwn||function(e,t){return Ze(Je(e),t)},tt=y,rt=0,it=Math.random(),nt=tt(1..toString),at=function(e){return"Symbol("+(void 0===e?"":e)+")_"+nt(++rt+it,36)},st=ze,ot=et,lt=at,ut=Te,ct=Se,ht=s.Symbol,dt=st("wks"),ft=ct?ht.for||ht:ht&&ht.withoutSetter||lt,vt=function(e){return ot(dt,e)||(dt[e]=ut&&ot(ht,e)?ht[e]:ft("Symbol."+e)),dt[e]},gt=M,pt=re,mt=Ie,yt=Fe,Et=function(e,t){var r,i;if("string"===t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;if(Ue(r=e.valueOf)&&!Be(i=Ne(r,e)))return i;if("string"!==t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;throw Ge("Can't convert object to primitive value")},kt=TypeError,Tt=vt("toPrimitive"),St=function(e,t){if(!pt(e)||mt(e))return e;var r,i=yt(e,Tt);if(i){if(void 0===t&&(t="default"),r=gt(i,e,t),!pt(r)||mt(r))return r;throw kt("Can't convert object to primitive value")}return void 0===t&&(t="number"),Et(e,t)},At=Ie,Lt=function(e){var t=St(e,"string");return At(t)?t:t+""},bt=re,Rt=s.document,It=bt(Rt)&&bt(Rt.createElement),Dt=function(e){return It?Rt.createElement(e):{}},_t=Dt,wt=!C&&!o((function(){return 7!=Object.defineProperty(_t("div"),"a",{get:function(){return 7}}).a})),Ct=C,Pt=M,xt=O,Mt=K,Ot=Z,Ft=Lt,Nt=et,Ut=wt,Bt=Object.getOwnPropertyDescriptor;w.f=Ct?Bt:function(e,t){if(e=Ot(e),t=Ft(t),Ut)try{return Bt(e,t)}catch(r){}if(Nt(e,t))return Mt(!Pt(xt.f,e,t),e[t])};var Gt=o,Kt=_,Ht=/#|\.prototype\./,Vt=function(e,t){var r=Yt[jt(e)];return r==Wt||r!=qt&&(Kt(t)?Gt(t):!!t)},jt=Vt.normalize=function(e){return String(e).replace(Ht,".").toLowerCase()},Yt=Vt.data={},qt=Vt.NATIVE="N",Wt=Vt.POLYFILL="P",zt=Vt,Xt=xe,Qt=l,$t=b(b.bind),Jt=function(e,t){return Xt(e),void 0===t?e:Qt?$t(e,t):function(){return e.apply(t,arguments)}},Zt={},er=C&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),tr=re,rr=String,ir=TypeError,nr=function(e){if(tr(e))return e;throw ir(rr(e)+" is not an object")},ar=C,sr=wt,or=er,lr=nr,ur=Lt,cr=TypeError,hr=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,fr="enumerable",vr="configurable",gr="writable";Zt.f=ar?or?function(e,t,r){if(lr(e),t=ur(t),lr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&gr in r&&!r[gr]){var i=dr(e,t);i&&i[gr]&&(e[t]=r.value,r={configurable:vr in r?r[vr]:i[vr],enumerable:fr in r?r[fr]:i[fr],writable:!1})}return hr(e,t,r)}:hr:function(e,t,r){if(lr(e),t=ur(t),lr(r),sr)try{return hr(e,t,r)}catch(i){}if("get"in r||"set"in r)throw cr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Zt,mr=K,yr=C?function(e,t,r){return pr.f(e,t,mr(1,r))}:function(e,t,r){return e[t]=r,e},Er=s,kr=f,Tr=b,Sr=_,Ar=w.f,Lr=zt,br=ie,Rr=Jt,Ir=yr,Dr=et,_r=function(e){var t=function(r,i,n){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,i)}return new e(r,i,n)}return kr(e,this,arguments)};return t.prototype=e.prototype,t},wr=function(e,t){var r,i,n,a,s,o,l,u,c,h=e.target,d=e.global,f=e.stat,v=e.proto,g=d?Er:f?Er[h]:(Er[h]||{}).prototype,p=d?br:br[h]||Ir(br,h,{})[h],m=p.prototype;for(a in t)i=!(r=Lr(d?a:h+(f?".":"#")+a,e.forced))&&g&&Dr(g,a),o=p[a],i&&(l=e.dontCallGetSet?(c=Ar(g,a))&&c.value:g[a]),s=i&&l?l:t[a],i&&typeof o==typeof s||(u=e.bind&&i?Rr(s,Er):e.wrap&&i?_r(s):v&&Sr(s)?Tr(s):s,(e.sham||s&&s.sham||o&&o.sham)&&Ir(u,"sham",!0),Ir(p,a,u),v&&(Dr(br,n=h+"Prototype")||Ir(br,n,{}),Ir(br[n],a,s),e.real&&m&&(r||!m[a])&&Ir(m,a,s)))},Cr=wr,Pr=C,xr=Zt.f;Cr({target:"Object",stat:!0,forced:Object.defineProperty!==xr,sham:!Pr},{defineProperty:xr});var Mr=ie.Object,Or=n.exports=function(e,t,r){return Mr.defineProperty(e,t,r)};Mr.defineProperty.sham&&(Or.sham=!0);var Fr=n.exports,Nr=i(Fr),Ur=S,Br=Array.isArray||function(e){return"Array"==Ur(e)},Gr=Math.ceil,Kr=Math.floor,Hr=Math.trunc||function(e){var t=+e;return(t>0?Kr:Gr)(t)},Vr=function(e){var t=+e;return t!=t||0===t?0:Hr(t)},jr=Vr,Yr=Math.min,qr=function(e){return e>0?Yr(jr(e),9007199254740991):0},Wr=qr,zr=function(e){return Wr(e.length)},Xr=TypeError,Qr=function(e){if(e>9007199254740991)throw Xr("Maximum allowed index exceeded");return e},$r=Lt,Jr=Zt,Zr=K,ei=function(e,t,r){var i=$r(t);i in e?Jr.f(e,i,Zr(0,r)):e[i]=r},ti={};ti[vt("toStringTag")]="z";var ri="[object z]"===String(ti),ii=ri,ni=_,ai=S,si=vt("toStringTag"),oi=Object,li="Arguments"==ai(function(){return arguments}()),ui=ii?ai:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=oi(e),si))?r:li?ai(t):"Object"==(i=ai(t))&&ni(t.callee)?"Arguments":i},ci=_,hi=qe,di=y(Function.toString);ci(hi.inspectSource)||(hi.inspectSource=function(e){return di(e)});var fi=hi.inspectSource,vi=y,gi=o,pi=_,mi=ui,yi=fi,Ei=function(){},ki=[],Ti=le("Reflect","construct"),Si=/^\s*(?:class|function)\b/,Ai=vi(Si.exec),Li=!Si.exec(Ei),bi=function(e){if(!pi(e))return!1;try{return Ti(Ei,ki,e),!0}catch(t){return!1}},Ri=function(e){if(!pi(e))return!1;switch(mi(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Li||!!Ai(Si,yi(e))}catch(t){return!0}};Ri.sham=!0;var Ii=!Ti||gi((function(){var e;return bi(bi.call)||!bi(Object)||!bi((function(){e=!0}))||e}))?Ri:bi,Di=Br,_i=Ii,wi=re,Ci=vt("species"),Pi=Array,xi=function(e){var t;return Di(e)&&(t=e.constructor,(_i(t)&&(t===Pi||Di(t.prototype))||wi(t)&&null===(t=t[Ci]))&&(t=void 0)),void 0===t?Pi:t},Mi=function(e,t){return new(xi(e))(0===t?0:t)},Oi=o,Fi=me,Ni=vt("species"),Ui=function(e){return Fi>=51||!Oi((function(){var t=[];return(t.constructor={})[Ni]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Bi=wr,Gi=o,Ki=Br,Hi=re,Vi=$e,ji=zr,Yi=Qr,qi=ei,Wi=Mi,zi=Ui,Xi=me,Qi=vt("isConcatSpreadable"),$i=Xi>=51||!Gi((function(){var e=[];return e[Qi]=!1,e.concat()[0]!==e})),Ji=function(e){if(!Hi(e))return!1;var t=e[Qi];return void 0!==t?!!t:Ki(e)};Bi({target:"Array",proto:!0,arity:1,forced:!$i||!zi("concat")},{concat:function(e){var t,r,i,n,a,s=Vi(this),o=Wi(s,0),l=0;for(t=-1,i=arguments.length;t<i;t++)if(Ji(a=-1===t?s:arguments[t]))for(n=ji(a),Yi(l+n),r=0;r<n;r++,l++)r in a&&qi(o,l,a[r]);else Yi(l+1),qi(o,l++,a);return o.length=l,o}});var Zi=ui,en=String,tn=function(e){if("Symbol"===Zi(e))throw TypeError("Cannot convert a Symbol value to a string");return en(e)},rn={},nn=Vr,an=Math.max,sn=Math.min,on=function(e,t){var r=nn(e);return r<0?an(r+t,0):sn(r,t)},ln=Z,un=on,cn=zr,hn=function(e){return function(t,r,i){var n,a=ln(t),s=cn(a),o=un(i,s);if(e&&r!=r){for(;s>o;)if((n=a[o++])!=n)return!0}else for(;s>o;o++)if((e||o in a)&&a[o]===r)return e||o||0;return!e&&-1}},dn={includes:hn(!0),indexOf:hn(!1)},fn={},vn=et,gn=Z,pn=dn.indexOf,mn=fn,yn=y([].push),En=function(e,t){var r,i=gn(e),n=0,a=[];for(r in i)!vn(mn,r)&&vn(i,r)&&yn(a,r);for(;t.length>n;)vn(i,r=t[n++])&&(~pn(a,r)||yn(a,r));return a},kn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Tn=En,Sn=kn,An=Object.keys||function(e){return Tn(e,Sn)},Ln=C,bn=er,Rn=Zt,In=nr,Dn=Z,_n=An;rn.f=Ln&&!bn?Object.defineProperties:function(e,t){In(e);for(var r,i=Dn(t),n=_n(t),a=n.length,s=0;a>s;)Rn.f(e,r=n[s++],i[r]);return e};var wn,Cn=le("document","documentElement"),Pn=at,xn=ze("keys"),Mn=function(e){return xn[e]||(xn[e]=Pn(e))},On=nr,Fn=rn,Nn=kn,Un=fn,Bn=Cn,Gn=Dt,Kn="prototype",Hn="script",Vn=Mn("IE_PROTO"),jn=function(){},Yn=function(e){return"<"+Hn+">"+e+"</"+Hn+">"},qn=function(e){e.write(Yn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Wn=function(){try{wn=new ActiveXObject("htmlfile")}catch(n){}var e,t,r;Wn="undefined"!=typeof document?document.domain&&wn?qn(wn):(t=Gn("iframe"),r="java"+Hn+":",t.style.display="none",Bn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Yn("document.F=Object")),e.close(),e.F):qn(wn);for(var i=Nn.length;i--;)delete Wn[Kn][Nn[i]];return Wn()};Un[Vn]=!0;var zn=Object.create||function(e,t){var r;return null!==e?(jn[Kn]=On(e),r=new jn,jn[Kn]=null,r[Vn]=e):r=Wn(),void 0===t?r:Fn.f(r,t)},Xn={},Qn=En,$n=kn.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Qn(e,$n)};var Jn={},Zn=on,ea=zr,ta=ei,ra=Array,ia=Math.max,na=function(e,t,r){for(var i=ea(e),n=Zn(t,i),a=Zn(void 0===r?i:r,i),s=ra(ia(a-n,0)),o=0;n<a;n++,o++)ta(s,o,e[n]);return s.length=o,s},aa=S,sa=Z,oa=Xn.f,la=na,ua="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Jn.f=function(e){return ua&&"Window"==aa(e)?function(e){try{return oa(e)}catch(t){return la(ua)}}(e):oa(sa(e))};var ca={};ca.f=Object.getOwnPropertySymbols;var ha=yr,da=function(e,t,r,i){return i&&i.enumerable?e[t]=r:ha(e,t,r),e},fa=Zt,va=function(e,t,r){return fa.f(e,t,r)},ga={},pa=vt;ga.f=pa;var ma,ya,Ea,ka=ie,Ta=et,Sa=ga,Aa=Zt.f,La=function(e){var t=ka.Symbol||(ka.Symbol={});Ta(t,e)||Aa(t,e,{value:Sa.f(e)})},ba=M,Ra=le,Ia=vt,Da=da,_a=function(){var e=Ra("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,i=Ia("toPrimitive");t&&!t[i]&&Da(t,i,(function(e){return ba(r,this)}),{arity:1})},wa=ui,Ca=ri?{}.toString:function(){return"[object "+wa(this)+"]"},Pa=ri,xa=Zt.f,Ma=yr,Oa=et,Fa=Ca,Na=vt("toStringTag"),Ua=function(e,t,r,i){if(e){var n=r?e:e.prototype;Oa(n,Na)||xa(n,Na,{configurable:!0,value:t}),i&&!Pa&&Ma(n,"toString",Fa)}},Ba=_,Ga=s.WeakMap,Ka=Ba(Ga)&&/native code/.test(String(Ga)),Ha=s,Va=re,ja=yr,Ya=et,qa=qe,Wa=Mn,za=fn,Xa="Object already initialized",Qa=Ha.TypeError,$a=Ha.WeakMap;if(Ka||qa.state){var Ja=qa.state||(qa.state=new $a);Ja.get=Ja.get,Ja.has=Ja.has,Ja.set=Ja.set,ma=function(e,t){if(Ja.has(e))throw Qa(Xa);return t.facade=e,Ja.set(e,t),t},ya=function(e){return Ja.get(e)||{}},Ea=function(e){return Ja.has(e)}}else{var Za=Wa("state");za[Za]=!0,ma=function(e,t){if(Ya(e,Za))throw Qa(Xa);return t.facade=e,ja(e,Za,t),t},ya=function(e){return Ya(e,Za)?e[Za]:{}},Ea=function(e){return Ya(e,Za)}}var es={set:ma,get:ya,has:Ea,enforce:function(e){return Ea(e)?ya(e):ma(e,{})},getterFor:function(e){return function(t){var r;if(!Va(t)||(r=ya(t)).type!==e)throw Qa("Incompatible receiver, "+e+" required");return r}}},ts=Jt,rs=q,is=$e,ns=zr,as=Mi,ss=y([].push),os=function(e){var t=1==e,r=2==e,i=3==e,n=4==e,a=6==e,s=7==e,o=5==e||a;return function(l,u,c,h){for(var d,f,v=is(l),g=rs(v),p=ts(u,c),m=ns(g),y=0,E=h||as,k=t?E(l,m):r||s?E(l,0):void 0;m>y;y++)if((o||y in g)&&(f=p(d=g[y],y,v),e))if(t)k[y]=f;else if(f)switch(e){case 3:return!0;case 5:return d;case 6:return y;case 2:ss(k,d)}else switch(e){case 4:return!1;case 7:ss(k,d)}return a?-1:i||n?n:k}},ls={forEach:os(0),map:os(1),filter:os(2),some:os(3),every:os(4),find:os(5),findIndex:os(6),filterReject:os(7)},us=wr,cs=s,hs=M,ds=y,fs=C,vs=Te,gs=o,ps=et,ms=ue,ys=nr,Es=Z,ks=Lt,Ts=tn,Ss=K,As=zn,Ls=An,bs=Xn,Rs=Jn,Is=ca,Ds=w,_s=Zt,ws=rn,Cs=O,Ps=da,xs=va,Ms=ze,Os=fn,Fs=at,Ns=vt,Us=ga,Bs=La,Gs=_a,Ks=Ua,Hs=es,Vs=ls.forEach,js=Mn("hidden"),Ys="Symbol",qs="prototype",Ws=Hs.set,zs=Hs.getterFor(Ys),Xs=Object[qs],Qs=cs.Symbol,$s=Qs&&Qs[qs],Js=cs.TypeError,Zs=cs.QObject,eo=Ds.f,to=_s.f,ro=Rs.f,io=Cs.f,no=ds([].push),ao=Ms("symbols"),so=Ms("op-symbols"),oo=Ms("wks"),lo=!Zs||!Zs[qs]||!Zs[qs].findChild,uo=fs&&gs((function(){return 7!=As(to({},"a",{get:function(){return to(this,"a",{value:7}).a}})).a}))?function(e,t,r){var i=eo(Xs,t);i&&delete Xs[t],to(e,t,r),i&&e!==Xs&&to(Xs,t,i)}:to,co=function(e,t){var r=ao[e]=As($s);return Ws(r,{type:Ys,tag:e,description:t}),fs||(r.description=t),r},ho=function(e,t,r){e===Xs&&ho(so,t,r),ys(e);var i=ks(t);return ys(r),ps(ao,i)?(r.enumerable?(ps(e,js)&&e[js][i]&&(e[js][i]=!1),r=As(r,{enumerable:Ss(0,!1)})):(ps(e,js)||to(e,js,Ss(1,{})),e[js][i]=!0),uo(e,i,r)):to(e,i,r)},fo=function(e,t){ys(e);var r=Es(t),i=Ls(r).concat(mo(r));return Vs(i,(function(t){fs&&!hs(vo,r,t)||ho(e,t,r[t])})),e},vo=function(e){var t=ks(e),r=hs(io,this,t);return!(this===Xs&&ps(ao,t)&&!ps(so,t))&&(!(r||!ps(this,t)||!ps(ao,t)||ps(this,js)&&this[js][t])||r)},go=function(e,t){var r=Es(e),i=ks(t);if(r!==Xs||!ps(ao,i)||ps(so,i)){var n=eo(r,i);return!n||!ps(ao,i)||ps(r,js)&&r[js][i]||(n.enumerable=!0),n}},po=function(e){var t=ro(Es(e)),r=[];return Vs(t,(function(e){ps(ao,e)||ps(Os,e)||no(r,e)})),r},mo=function(e){var t=e===Xs,r=ro(t?so:Es(e)),i=[];return Vs(r,(function(e){!ps(ao,e)||t&&!ps(Xs,e)||no(i,ao[e])})),i};vs||(Qs=function(){if(ms($s,this))throw Js("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Ts(arguments[0]):void 0,t=Fs(e),r=function(e){this===Xs&&hs(r,so,e),ps(this,js)&&ps(this[js],t)&&(this[js][t]=!1),uo(this,t,Ss(1,e))};return fs&&lo&&uo(Xs,t,{configurable:!0,set:r}),co(t,e)},Ps($s=Qs[qs],"toString",(function(){return zs(this).tag})),Ps(Qs,"withoutSetter",(function(e){return co(Fs(e),e)})),Cs.f=vo,_s.f=ho,ws.f=fo,Ds.f=go,bs.f=Rs.f=po,Is.f=mo,Us.f=function(e){return co(Ns(e),e)},fs&&xs($s,"description",{configurable:!0,get:function(){return zs(this).description}})),us({global:!0,constructor:!0,wrap:!0,forced:!vs,sham:!vs},{Symbol:Qs}),Vs(Ls(oo),(function(e){Bs(e)})),us({target:Ys,stat:!0,forced:!vs},{useSetter:function(){lo=!0},useSimple:function(){lo=!1}}),us({target:"Object",stat:!0,forced:!vs,sham:!fs},{create:function(e,t){return void 0===t?As(e):fo(As(e),t)},defineProperty:ho,defineProperties:fo,getOwnPropertyDescriptor:go}),us({target:"Object",stat:!0,forced:!vs},{getOwnPropertyNames:po}),Gs(),Ks(Qs,Ys),Os[js]=!0;var yo=Te&&!!Symbol.for&&!!Symbol.keyFor,Eo=wr,ko=le,To=et,So=tn,Ao=ze,Lo=yo,bo=Ao("string-to-symbol-registry"),Ro=Ao("symbol-to-string-registry");Eo({target:"Symbol",stat:!0,forced:!Lo},{for:function(e){var t=So(e);if(To(bo,t))return bo[t];var r=ko("Symbol")(t);return bo[t]=r,Ro[r]=t,r}});var Io=wr,Do=et,_o=Ie,wo=_e,Co=yo,Po=ze("symbol-to-string-registry");Io({target:"Symbol",stat:!0,forced:!Co},{keyFor:function(e){if(!_o(e))throw TypeError(wo(e)+" is not a symbol");if(Do(Po,e))return Po[e]}});var xo=y([].slice),Mo=Br,Oo=_,Fo=S,No=tn,Uo=y([].push),Bo=wr,Go=le,Ko=f,Ho=M,Vo=y,jo=o,Yo=_,qo=Ie,Wo=xo,zo=function(e){if(Oo(e))return e;if(Mo(e)){for(var t=e.length,r=[],i=0;i<t;i++){var n=e[i];"string"==typeof n?Uo(r,n):"number"!=typeof n&&"Number"!=Fo(n)&&"String"!=Fo(n)||Uo(r,No(n))}var a=r.length,s=!0;return function(e,t){if(s)return s=!1,t;if(Mo(this))return t;for(var i=0;i<a;i++)if(r[i]===e)return t}}},Xo=Te,Qo=String,$o=Go("JSON","stringify"),Jo=Vo(/./.exec),Zo=Vo("".charAt),el=Vo("".charCodeAt),tl=Vo("".replace),rl=Vo(1..toString),il=/[\uD800-\uDFFF]/g,nl=/^[\uD800-\uDBFF]$/,al=/^[\uDC00-\uDFFF]$/,sl=!Xo||jo((function(){var e=Go("Symbol")();return"[null]"!=$o([e])||"{}"!=$o({a:e})||"{}"!=$o(Object(e))})),ol=jo((function(){return'"\\udf06\\ud834"'!==$o("\udf06\ud834")||'"\\udead"'!==$o("\udead")})),ll=function(e,t){var r=Wo(arguments),i=zo(t);if(Yo(i)||void 0!==e&&!qo(e))return r[1]=function(e,t){if(Yo(i)&&(t=Ho(i,this,Qo(e),t)),!qo(t))return t},Ko($o,null,r)},ul=function(e,t,r){var i=Zo(r,t-1),n=Zo(r,t+1);return Jo(nl,e)&&!Jo(al,n)||Jo(al,e)&&!Jo(nl,i)?"\\u"+rl(el(e,0),16):e};$o&&Bo({target:"JSON",stat:!0,arity:3,forced:sl||ol},{stringify:function(e,t,r){var i=Wo(arguments),n=Ko(sl?ll:$o,null,i);return ol&&"string"==typeof n?tl(n,il,ul):n}});var cl=ca,hl=$e;wr({target:"Object",stat:!0,forced:!Te||o((function(){cl.f(1)}))},{getOwnPropertySymbols:function(e){var t=cl.f;return t?t(hl(e)):[]}}),La("asyncIterator"),La("hasInstance"),La("isConcatSpreadable"),La("iterator"),La("match"),La("matchAll"),La("replace"),La("search"),La("species"),La("split");var dl=_a;La("toPrimitive"),dl();var fl=le,vl=Ua;La("toStringTag"),vl(fl("Symbol"),"Symbol"),La("unscopables"),Ua(s.JSON,"JSON",!0);var gl,pl,ml,yl=ie.Symbol,El={},kl=C,Tl=et,Sl=Function.prototype,Al=kl&&Object.getOwnPropertyDescriptor,Ll=Tl(Sl,"name"),bl={EXISTS:Ll,PROPER:Ll&&"something"===function(){}.name,CONFIGURABLE:Ll&&(!kl||kl&&Al(Sl,"name").configurable)},Rl=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Il=et,Dl=_,_l=$e,wl=Rl,Cl=Mn("IE_PROTO"),Pl=Object,xl=Pl.prototype,Ml=wl?Pl.getPrototypeOf:function(e){var t=_l(e);if(Il(t,Cl))return t[Cl];var r=t.constructor;return Dl(r)&&t instanceof r?r.prototype:t instanceof Pl?xl:null},Ol=o,Fl=_,Nl=re,Ul=zn,Bl=Ml,Gl=da,Kl=vt("iterator"),Hl=!1;[].keys&&("next"in(ml=[].keys())?(pl=Bl(Bl(ml)))!==Object.prototype&&(gl=pl):Hl=!0);var Vl=!Nl(gl)||Ol((function(){var e={};return gl[Kl].call(e)!==e}));Fl((gl=Vl?{}:Ul(gl))[Kl])||Gl(gl,Kl,(function(){return this}));var jl={IteratorPrototype:gl,BUGGY_SAFARI_ITERATORS:Hl},Yl=jl.IteratorPrototype,ql=zn,Wl=K,zl=Ua,Xl=El,Ql=function(){return this},$l=function(e,t,r,i){var n=t+" Iterator";return e.prototype=ql(Yl,{next:Wl(+!i,r)}),zl(e,n,!1,!0),Xl[n]=Ql,e},Jl=y,Zl=xe,eu=_,tu=String,ru=TypeError,iu=function(e,t,r){try{return Jl(Zl(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},nu=nr,au=function(e){if("object"==typeof e||eu(e))return e;throw ru("Can't set "+tu(e)+" as a prototype")},su=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=iu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return nu(r),au(i),t?e(r,i):r.__proto__=i,r}}():void 0),ou=wr,lu=M,uu=bl,cu=$l,hu=Ml,du=Ua,fu=da,vu=El,gu=jl,pu=uu.PROPER,mu=gu.BUGGY_SAFARI_ITERATORS,yu=vt("iterator"),Eu="keys",ku="values",Tu="entries",Su=function(){return this},Au=function(e,t,r,i,n,a,s){cu(r,t,i);var o,l,u,c=function(e){if(e===n&&g)return g;if(!mu&&e in f)return f[e];switch(e){case Eu:case ku:case Tu:return function(){return new r(this,e)}}return function(){return new r(this)}},h=t+" Iterator",d=!1,f=e.prototype,v=f[yu]||f["@@iterator"]||n&&f[n],g=!mu&&v||c(n),p="Array"==t&&f.entries||v;if(p&&(o=hu(p.call(new e)))!==Object.prototype&&o.next&&(du(o,h,!0,!0),vu[h]=Su),pu&&n==ku&&v&&v.name!==ku&&(d=!0,g=function(){return lu(v,this)}),n)if(l={values:c(ku),keys:a?g:c(Eu),entries:c(Tu)},s)for(u in l)(mu||d||!(u in f))&&fu(f,u,l[u]);else ou({target:t,proto:!0,forced:mu||d},l);return s&&f[yu]!==g&&fu(f,yu,g,{name:n}),vu[t]=g,l},Lu=function(e,t){return{value:e,done:t}},bu=Z,Ru=El,Iu=es;Zt.f;var Du=Au,_u=Lu,wu="Array Iterator",Cu=Iu.set,Pu=Iu.getterFor(wu);Du(Array,"Array",(function(e,t){Cu(this,{type:wu,target:bu(e),index:0,kind:t})}),(function(){var e=Pu(this),t=e.target,r=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,_u(void 0,!0)):_u("keys"==r?i:"values"==r?t[i]:[i,t[i]],!1)}),"values"),Ru.Arguments=Ru.Array;var xu={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},Mu=s,Ou=ui,Fu=yr,Nu=El,Uu=vt("toStringTag");for(var Bu in xu){var Gu=Mu[Bu],Ku=Gu&&Gu.prototype;Ku&&Ou(Ku)!==Uu&&Fu(Ku,Uu,Bu),Nu[Bu]=Nu.Array}var Hu=yl;La("dispose");var Vu=Hu;La("asyncDispose");var ju=wr,Yu=y,qu=le("Symbol"),Wu=qu.keyFor,zu=Yu(qu.prototype.valueOf);ju({target:"Symbol",stat:!0},{isRegistered:function(e){try{return void 0!==Wu(zu(e))}catch(t){return!1}}});for(var Xu=wr,Qu=ze,$u=le,Ju=y,Zu=Ie,ec=vt,tc=$u("Symbol"),rc=tc.isWellKnown,ic=$u("Object","getOwnPropertyNames"),nc=Ju(tc.prototype.valueOf),ac=Qu("wks"),sc=0,oc=ic(tc),lc=oc.length;sc<lc;sc++)try{var uc=oc[sc];Zu(tc[uc])&&ec(uc)}catch($V){}Xu({target:"Symbol",stat:!0,forced:!0},{isWellKnown:function(e){if(rc&&rc(e))return!0;try{for(var t=nc(e),r=0,i=ic(ac),n=i.length;r<n;r++)if(ac[i[r]]==t)return!0}catch($V){}return!1}}),La("matcher"),La("metadataKey"),La("observable"),La("metadata"),La("patternMatch"),La("replaceAll");var cc=Vu,hc=i(cc),dc=y,fc=Vr,vc=tn,gc=Q,pc=dc("".charAt),mc=dc("".charCodeAt),yc=dc("".slice),Ec=function(e){return function(t,r){var i,n,a=vc(gc(t)),s=fc(r),o=a.length;return s<0||s>=o?e?"":void 0:(i=mc(a,s))<55296||i>56319||s+1===o||(n=mc(a,s+1))<56320||n>57343?e?pc(a,s):i:e?yc(a,s,s+2):n-56320+(i-55296<<10)+65536}},kc={codeAt:Ec(!1),charAt:Ec(!0)},Tc=kc.charAt,Sc=tn,Ac=es,Lc=Au,bc=Lu,Rc="String Iterator",Ic=Ac.set,Dc=Ac.getterFor(Rc);Lc(String,"String",(function(e){Ic(this,{type:Rc,string:Sc(e),index:0})}),(function(){var e,t=Dc(this),r=t.string,i=t.index;return i>=r.length?bc(void 0,!0):(e=Tc(r,i),t.index+=e.length,bc(e,!1))}));var _c=ga.f("iterator"),wc=i(_c);function Cc(e){return(Cc="function"==typeof hc&&"symbol"==typeof wc?function(e){return typeof e}:function(e){return e&&"function"==typeof hc&&e.constructor===hc&&e!==hc.prototype?"symbol":typeof e})(e)}var Pc=ga.f("toPrimitive"),xc=i(Pc);function Mc(e){var t=function(e,t){if("object"!==Cc(e)||null===e)return e;var r=e[xc];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Cc(t)?t:String(t)}function Oc(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Nr(e,Mc(i.key),i)}}function Fc(e,t,r){return t&&Oc(e.prototype,t),r&&Oc(e,r),Nr(e,"prototype",{writable:!1}),e}var Nc=et,Uc=M,Bc=re,Gc=nr,Kc=function(e){return void 0!==e&&(Nc(e,"value")||Nc(e,"writable"))},Hc=w,Vc=Ml;wr({target:"Reflect",stat:!0},{get:function e(t,r){var i,n,a=arguments.length<3?t:arguments[2];return Gc(t)===a?t[r]:(i=Hc.f(t,r))?Kc(i)?i.value:void 0===i.get?void 0:Uc(i.get,a):Bc(n=Vc(t))?e(n,r,a):void 0}});var jc=i(ie.Reflect.get),Yc=y,qc=xe,Wc=re,zc=et,Xc=xo,Qc=l,$c=Function,Jc=Yc([].concat),Zc=Yc([].join),eh={},th=Qc?$c.bind:function(e){var t=qc(this),r=t.prototype,i=Xc(arguments,1),n=function(){var r=Jc(i,Xc(arguments));return this instanceof n?function(e,t,r){if(!zc(eh,t)){for(var i=[],n=0;n<t;n++)i[n]="a["+n+"]";eh[t]=$c("C,a","return new C("+Zc(i,",")+")")}return eh[t](e,r)}(t,r.length,r):t.apply(e,r)};return Wc(r)&&(n.prototype=r),n},rh=th;wr({target:"Function",proto:!0,forced:Function.bind!==rh},{bind:rh});var ih=ie,nh=function(e){return ih[e+"Prototype"]},ah=nh("Function").bind,sh=ue,oh=ah,lh=Function.prototype,uh=function(e){var t=e.bind;return e===lh||sh(lh,e)&&t===lh.bind?oh:t},ch=i(uh),hh={exports:{}},dh=wr,fh=o,vh=Z,gh=w.f,ph=C;dh({target:"Object",stat:!0,forced:!ph||fh((function(){gh(1)})),sham:!ph},{getOwnPropertyDescriptor:function(e,t){return gh(vh(e),t)}});var mh=ie.Object,yh=hh.exports=function(e,t){return mh.getOwnPropertyDescriptor(e,t)};mh.getOwnPropertyDescriptor.sham&&(yh.sham=!0);var Eh=hh.exports,kh=i(Eh);wr({target:"Object",stat:!0},{setPrototypeOf:su});var Th=i(ie.Object.setPrototypeOf),Sh=$e,Ah=Ml,Lh=Rl;wr({target:"Object",stat:!0,forced:o((function(){Ah(1)})),sham:!Lh},{getPrototypeOf:function(e){return Ah(Sh(e))}});var bh=i(ie.Object.getPrototypeOf);function Rh(e){var t;return(Rh=Th?ch(t=bh).call(t):function(e){return e.__proto__||bh(e)})(e)}function Ih(){var e;"undefined"!=typeof Reflect&&jc?Ih=ch(e=jc).call(e):Ih=function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Rh(e)););return e}(e,t);if(i){var n=kh(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}};return Ih.apply(this,arguments)}wr({target:"Object",stat:!0,sham:!C},{create:zn});var Dh=ie.Object,_h=function(e,t){return Dh.create(e,t)},wh=i(_h);function Ch(e,t){var r;return(Ch=Th?ch(r=Th).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function Ph(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=wh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Nr(e,"prototype",{writable:!1}),t&&Ch(e,t)}var xh=Ii,Mh=_e,Oh=TypeError,Fh=function(e){if(xh(e))return e;throw Oh(Mh(e)+" is not a constructor")},Nh=wr,Uh=f,Bh=th,Gh=Fh,Kh=nr,Hh=re,Vh=zn,jh=o,Yh=le("Reflect","construct"),qh=Object.prototype,Wh=[].push,zh=jh((function(){function e(){}return!(Yh((function(){}),[],e)instanceof e)})),Xh=!jh((function(){Yh((function(){}))})),Qh=zh||Xh;Nh({target:"Reflect",stat:!0,forced:Qh,sham:Qh},{construct:function(e,t){Gh(e),Kh(t);var r=arguments.length<3?e:Gh(arguments[2]);if(Xh&&!zh)return Yh(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 i=[null];return Uh(Wh,i,t),new(Uh(Bh,e,i))}var n=r.prototype,a=Vh(Hh(n)?n:qh),s=Uh(e,a,t);return Hh(s)?s:a}});var $h=i(ie.Reflect.construct);function Jh(){if("undefined"==typeof Reflect||!$h)return!1;if($h.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call($h(Boolean,[],(function(){}))),!0}catch(e){return!1}}function Zh(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ed(e){var t=Jh();return function(){var r,i=Rh(e);if(t){var n=Rh(this).constructor;r=$h(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"===Cc(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Zh(e)}(this,r)}}var td=o,rd=function(e,t){var r=[][e];return!!r&&td((function(){r.call(null,t||function(){return 1},1)}))},id=ls.forEach,nd=rd("forEach")?[].forEach:function(e){return id(this,e,arguments.length>1?arguments[1]:void 0)};wr({target:"Array",proto:!0,forced:[].forEach!=nd},{forEach:nd});var ad=nh("Array").forEach,sd=ui,od=et,ld=ue,ud=ad,cd=Array.prototype,hd={DOMTokenList:!0,NodeList:!0},dd=function(e){var t=e.forEach;return e===cd||ld(cd,e)&&t===cd.forEach||od(hd,sd(e))?ud:t},fd=i(dd),vd=i(dd),gd=C,pd=y,md=An,yd=Z,Ed=pd(O.f),kd=pd([].push),Td=function(e){return function(t){for(var r,i=yd(t),n=md(i),a=n.length,s=0,o=[];a>s;)r=n[s++],gd&&!Ed(i,r)||kd(o,e?[r,i[r]]:i[r]);return o}},Sd={entries:Td(!0),values:Td(!1)},Ad=Sd.values;wr({target:"Object",stat:!0},{values:function(e){return Ad(e)}});var Ld=i(ie.Object.values),bd=nh("Array").concat,Rd=ue,Id=bd,Dd=Array.prototype,_d=i((function(e){var t=e.concat;return e===Dd||Rd(Dd,e)&&t===Dd.concat?Id:t})),wd=$e,Cd=An;wr({target:"Object",stat:!0,forced:o((function(){Cd(1)}))},{keys:function(e){return Cd(wd(e))}});var Pd=ie.Object.keys,xd=i(Pd),Md=ie.Object.getOwnPropertySymbols,Od=i(Md),Fd=ls.filter;wr({target:"Array",proto:!0,forced:!Ui("filter")},{filter:function(e){return Fd(this,e,arguments.length>1?arguments[1]:void 0)}});var Nd=nh("Array").filter,Ud=ue,Bd=Nd,Gd=Array.prototype,Kd=function(e){var t=e.filter;return e===Gd||Ud(Gd,e)&&t===Gd.filter?Bd:t},Hd=i(Kd),Vd=C,jd=Br,Yd=TypeError,qd=Object.getOwnPropertyDescriptor,Wd=Vd&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch($V){return $V instanceof TypeError}}()?function(e,t){if(jd(e)&&!qd(e,"length").writable)throw Yd("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},zd=$e,Xd=zr,Qd=Wd,$d=Qr;wr({target:"Array",proto:!0,arity:1,forced:o((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch($V){return $V instanceof TypeError}}()},{push:function(e){var t=zd(this),r=Xd(t),i=arguments.length;$d(r+i);for(var n=0;n<i;n++)t[r]=arguments[n],r++;return Qd(t,r),r}});var Jd=nh("Array").push,Zd=ue,ef=Jd,tf=Array.prototype,rf=i((function(e){var t=e.push;return e===tf||Zd(tf,e)&&t===tf.push?ef:t})),nf=le,af=Xn,sf=ca,of=nr,lf=y([].concat),uf=nf("Reflect","ownKeys")||function(e){var t=af.f(of(e)),r=sf.f;return r?lf(t,r(e)):t},cf=uf,hf=Z,df=w,ff=ei;wr({target:"Object",stat:!0,sham:!C},{getOwnPropertyDescriptors:function(e){for(var t,r,i=hf(e),n=df.f,a=cf(i),s={},o=0;a.length>o;)void 0!==(r=n(i,t=a[o++]))&&ff(s,t,r);return s}});var vf=ie.Object.getOwnPropertyDescriptors,gf=i(vf),pf={exports:{}},mf=wr,yf=C,Ef=rn.f;mf({target:"Object",stat:!0,forced:Object.defineProperties!==Ef,sham:!yf},{defineProperties:Ef});var kf=ie.Object,Tf=pf.exports=function(e,t){return kf.defineProperties(e,t)};kf.defineProperties.sham&&(Tf.sham=!0);var Sf=pf.exports,Af=i(Sf);function Lf(e,t,r){return(t=Mc(t))in e?Nr(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bf(e,t){var r=xd(e);if(Od){var i=Od(e);t&&(i=Hd(i).call(i,(function(t){return kh(e,t).enumerable}))),rf(r).apply(r,i)}return r}function Rf(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?fd(r=bf(Object(n),!0)).call(r,(function(t){Lf(e,t,n[t])})):gf?Af(e,gf(n)):fd(i=bf(Object(n))).call(i,(function(t){Nr(e,t,kh(n,t))}))}return e}var If,Df="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,_f=TypeError,wf=function(e,t){if(e<t)throw _f("Not enough arguments");return e},Cf=s,Pf=f,xf=_,Mf=Df,Of=ce,Ff=xo,Nf=wf,Uf=Cf.Function,Bf=/MSIE .\./.test(Of)||Mf&&((If=Cf.Bun.version.split(".")).length<3||0==If[0]&&(If[1]<3||3==If[1]&&0==If[2])),Gf=function(e,t){var r=t?2:1;return Bf?function(i,n){var a=Nf(arguments.length,1)>r,s=xf(i)?i:Uf(i),o=a?Ff(arguments,r):[],l=a?function(){Pf(s,this,o)}:s;return t?e(l,n):e(l)}:e},Kf=wr,Hf=s,Vf=Gf(Hf.setInterval,!0);Kf({global:!0,bind:!0,forced:Hf.setInterval!==Vf},{setInterval:Vf});var jf=wr,Yf=s,qf=Gf(Yf.setTimeout,!0);jf({global:!0,bind:!0,forced:Yf.setTimeout!==qf},{setTimeout:qf});var Wf=i(ie.setTimeout),zf=wr,Xf=dn.indexOf,Qf=rd,$f=b([].indexOf),Jf=!!$f&&1/$f([1],1,-0)<0;zf({target:"Array",proto:!0,forced:Jf||!Qf("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return Jf?$f(this,e,t)||0:Xf(this,e,t)}});var Zf=nh("Array").indexOf,ev=ue,tv=Zf,rv=Array.prototype,iv=function(e){var t=e.indexOf;return e===rv||ev(rv,e)&&t===rv.indexOf?tv:t},nv=i(iv),av=i(iv),sv=wr,ov=ls.find,lv="find",uv=!0;lv in[]&&Array(1)[lv]((function(){uv=!1})),sv({target:"Array",proto:!0,forced:uv},{find:function(e){return ov(this,e,arguments.length>1?arguments[1]:void 0)}});var cv=nh("Array").find,hv=ue,dv=cv,fv=Array.prototype,vv=i((function(e){var t=e.find;return e===fv||hv(fv,e)&&t===fv.find?dv:t})),gv=i(Pd),pv=wr,mv=Br,yv=Ii,Ev=re,kv=on,Tv=zr,Sv=Z,Av=ei,Lv=vt,bv=xo,Rv=Ui("slice"),Iv=Lv("species"),Dv=Array,_v=Math.max;pv({target:"Array",proto:!0,forced:!Rv},{slice:function(e,t){var r,i,n,a=Sv(this),s=Tv(a),o=kv(e,s),l=kv(void 0===t?s:t,s);if(mv(a)&&(r=a.constructor,(yv(r)&&(r===Dv||mv(r.prototype))||Ev(r)&&null===(r=r[Iv]))&&(r=void 0),r===Dv||void 0===r))return bv(a,o,l);for(i=new(void 0===r?Dv:r)(_v(l-o,0)),n=0;o<l;o++,n++)o in a&&Av(i,n,a[o]);return i.length=n,i}});var wv=nh("Array").slice,Cv=ue,Pv=wv,xv=Array.prototype,Mv=function(e){var t=e.slice;return e===xv||Cv(xv,e)&&t===xv.slice?Pv:t},Ov=i(Mv),Fv=i(Mv),Nv=_e,Uv=TypeError,Bv=function(e,t){if(!delete e[t])throw Uv("Cannot delete property "+Nv(t)+" of "+Nv(e))},Gv=wr,Kv=$e,Hv=on,Vv=Vr,jv=zr,Yv=Wd,qv=Qr,Wv=Mi,zv=ei,Xv=Bv,Qv=Ui("splice"),$v=Math.max,Jv=Math.min;Gv({target:"Array",proto:!0,forced:!Qv},{splice:function(e,t){var r,i,n,a,s,o,l=Kv(this),u=jv(l),c=Hv(e,u),h=arguments.length;for(0===h?r=i=0:1===h?(r=0,i=u-c):(r=h-2,i=Jv($v(Vv(t),0),u-c)),qv(u+r-i),n=Wv(l,i),a=0;a<i;a++)(s=c+a)in l&&zv(n,a,l[s]);if(n.length=i,r<i){for(a=c;a<u-i;a++)o=a+r,(s=a+i)in l?l[o]=l[s]:Xv(l,o);for(a=u;a>u-i+r;a--)Xv(l,a-1)}else if(r>i)for(a=u-i;a>c;a--)o=a+r-1,(s=a+i-1)in l?l[o]=l[s]:Xv(l,o);for(a=0;a<r;a++)l[a+c]=arguments[a+2];return Yv(l,u-i+r),n}});var Zv=nh("Array").splice,eg=ue,tg=Zv,rg=Array.prototype,ig=i((function(e){var t=e.splice;return e===rg||eg(rg,e)&&t===rg.splice?tg:t})),ng=et,ag=uf,sg=w,og=Zt,lg=re,ug=yr,cg=Error,hg=y("".replace),dg=String(cg("zxcasd").stack),fg=/\n\s*at [^:]*:[^\n]*/,vg=fg.test(dg),gg=K,pg=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",gg(1,7)),7!==e.stack)})),mg=yr,yg=function(e,t){if(vg&&"string"==typeof e&&!cg.prepareStackTrace)for(;t--;)e=hg(e,fg,"");return e},Eg=pg,kg=Error.captureStackTrace,Tg=El,Sg=vt("iterator"),Ag=Array.prototype,Lg=function(e){return void 0!==e&&(Tg.Array===e||Ag[Sg]===e)},bg=ui,Rg=Fe,Ig=W,Dg=El,_g=vt("iterator"),wg=function(e){if(!Ig(e))return Rg(e,_g)||Rg(e,"@@iterator")||Dg[bg(e)]},Cg=M,Pg=xe,xg=nr,Mg=_e,Og=wg,Fg=TypeError,Ng=function(e,t){var r=arguments.length<2?Og(e):t;if(Pg(r))return xg(Cg(r,e));throw Fg(Mg(e)+" is not iterable")},Ug=M,Bg=nr,Gg=Fe,Kg=function(e,t,r){var i,n;Bg(e);try{if(!(i=Gg(e,"return"))){if("throw"===t)throw r;return r}i=Ug(i,e)}catch($V){n=!0,i=$V}if("throw"===t)throw r;if(n)throw i;return Bg(i),r},Hg=Jt,Vg=M,jg=nr,Yg=_e,qg=Lg,Wg=zr,zg=ue,Xg=Ng,Qg=wg,$g=Kg,Jg=TypeError,Zg=function(e,t){this.stopped=e,this.result=t},ep=Zg.prototype,tp=function(e,t,r){var i,n,a,s,o,l,u,c=r&&r.that,h=!(!r||!r.AS_ENTRIES),d=!(!r||!r.IS_RECORD),f=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),g=Hg(t,c),p=function(e){return i&&$g(i,"normal",e),new Zg(!0,e)},m=function(e){return h?(jg(e),v?g(e[0],e[1],p):g(e[0],e[1])):v?g(e,p):g(e)};if(d)i=e.iterator;else if(f)i=e;else{if(!(n=Qg(e)))throw Jg(Yg(e)+" is not iterable");if(qg(n)){for(a=0,s=Wg(e);s>a;a++)if((o=m(e[a]))&&zg(ep,o))return o;return new Zg(!1)}i=Xg(e,n)}for(l=d?e.next:i.next;!(u=Vg(l,i)).done;){try{o=m(u.value)}catch($V){$g(i,"throw",$V)}if("object"==typeof o&&o&&zg(ep,o))return o}return new Zg(!1)},rp=tn,ip=wr,np=ue,ap=Ml,sp=su,op=function(e,t,r){for(var i=ag(t),n=og.f,a=sg.f,s=0;s<i.length;s++){var o=i[s];ng(e,o)||r&&ng(r,o)||n(e,o,a(t,o))}},lp=zn,up=yr,cp=K,hp=function(e,t){lg(t)&&"cause"in t&&ug(e,"cause",t.cause)},dp=function(e,t,r,i){Eg&&(kg?kg(e,t):mg(e,"stack",yg(r,i)))},fp=tp,vp=function(e,t){return void 0===e?arguments.length<2?"":t:rp(e)},gp=vt("toStringTag"),pp=Error,mp=[].push,yp=function(e,t){var r,i=np(Ep,this);sp?r=sp(pp(),i?ap(this):Ep):(r=i?this:lp(Ep),up(r,gp,"Error")),void 0!==t&&up(r,"message",vp(t)),dp(r,yp,r.stack,1),arguments.length>2&&hp(r,arguments[2]);var n=[];return fp(e,mp,{that:n}),up(r,"errors",n),r};sp?sp(yp,pp):op(yp,pp,{name:!0});var Ep=yp.prototype=lp(pp.prototype,{constructor:cp(1,yp),message:cp(1,""),name:cp(1,"AggregateError")});ip({global:!0,constructor:!0,arity:2},{AggregateError:yp});var kp,Tp,Sp,Ap,Lp="undefined"!=typeof process&&"process"==S(process),bp=le,Rp=va,Ip=C,Dp=vt("species"),_p=function(e){var t=bp(e);Ip&&t&&!t[Dp]&&Rp(t,Dp,{configurable:!0,get:function(){return this}})},wp=ue,Cp=TypeError,Pp=function(e,t){if(wp(t,e))return e;throw Cp("Incorrect invocation")},xp=nr,Mp=Fh,Op=W,Fp=vt("species"),Np=function(e,t){var r,i=xp(e).constructor;return void 0===i||Op(r=xp(i)[Fp])?t:Mp(r)},Up=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),Bp=s,Gp=f,Kp=Jt,Hp=_,Vp=et,jp=o,Yp=Cn,qp=xo,Wp=Dt,zp=wf,Xp=Up,Qp=Lp,$p=Bp.setImmediate,Jp=Bp.clearImmediate,Zp=Bp.process,em=Bp.Dispatch,tm=Bp.Function,rm=Bp.MessageChannel,im=Bp.String,nm=0,am={},sm="onreadystatechange";jp((function(){kp=Bp.location}));var om=function(e){if(Vp(am,e)){var t=am[e];delete am[e],t()}},lm=function(e){return function(){om(e)}},um=function(e){om(e.data)},cm=function(e){Bp.postMessage(im(e),kp.protocol+"//"+kp.host)};$p&&Jp||($p=function(e){zp(arguments.length,1);var t=Hp(e)?e:tm(e),r=qp(arguments,1);return am[++nm]=function(){Gp(t,void 0,r)},Tp(nm),nm},Jp=function(e){delete am[e]},Qp?Tp=function(e){Zp.nextTick(lm(e))}:em&&em.now?Tp=function(e){em.now(lm(e))}:rm&&!Xp?(Ap=(Sp=new rm).port2,Sp.port1.onmessage=um,Tp=Kp(Ap.postMessage,Ap)):Bp.addEventListener&&Hp(Bp.postMessage)&&!Bp.importScripts&&kp&&"file:"!==kp.protocol&&!jp(cm)?(Tp=cm,Bp.addEventListener("message",um,!1)):Tp=sm in Wp("script")?function(e){Yp.appendChild(Wp("script"))[sm]=function(){Yp.removeChild(this),om(e)}}:function(e){setTimeout(lm(e),0)});var hm={set:$p,clear:Jp},dm=function(){this.head=null,this.tail=null};dm.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 fm,vm,gm,pm,mm,ym=dm,Em=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,km=/web0s(?!.*chrome)/i.test(ce),Tm=s,Sm=Jt,Am=w.f,Lm=hm.set,bm=ym,Rm=Up,Im=Em,Dm=km,_m=Lp,wm=Tm.MutationObserver||Tm.WebKitMutationObserver,Cm=Tm.document,Pm=Tm.process,xm=Tm.Promise,Mm=Am(Tm,"queueMicrotask"),Om=Mm&&Mm.value;if(!Om){var Fm=new bm,Nm=function(){var e,t;for(_m&&(e=Pm.domain)&&e.exit();t=Fm.get();)try{t()}catch($V){throw Fm.head&&fm(),$V}e&&e.enter()};Rm||_m||Dm||!wm||!Cm?!Im&&xm&&xm.resolve?((pm=xm.resolve(void 0)).constructor=xm,mm=Sm(pm.then,pm),fm=function(){mm(Nm)}):_m?fm=function(){Pm.nextTick(Nm)}:(Lm=Sm(Lm,Tm),fm=function(){Lm(Nm)}):(vm=!0,gm=Cm.createTextNode(""),new wm(Nm).observe(gm,{characterData:!0}),fm=function(){gm.data=vm=!vm}),Om=function(e){Fm.head||fm(),Fm.add(e)}}var Um=Om,Bm=function(e){try{return{error:!1,value:e()}}catch($V){return{error:!0,value:$V}}},Gm=s.Promise,Km="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Hm=!Km&&!Lp&&"object"==typeof window&&"object"==typeof document,Vm=s,jm=Gm,Ym=_,qm=zt,Wm=fi,zm=vt,Xm=Hm,Qm=Km,$m=me,Jm=jm&&jm.prototype,Zm=zm("species"),ey=!1,ty=Ym(Vm.PromiseRejectionEvent),ry={CONSTRUCTOR:qm("Promise",(function(){var e=Wm(jm),t=e!==String(jm);if(!t&&66===$m)return!0;if(!Jm.catch||!Jm.finally)return!0;if(!$m||$m<51||!/native code/.test(e)){var r=new jm((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Zm]=i,!(ey=r.then((function(){}))instanceof i))return!0}return!t&&(Xm||Qm)&&!ty})),REJECTION_EVENT:ty,SUBCLASSING:ey},iy={},ny=xe,ay=TypeError,sy=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw ay("Bad Promise constructor");t=e,r=i})),this.resolve=ny(t),this.reject=ny(r)};iy.f=function(e){return new sy(e)};var oy,ly,uy=wr,cy=Lp,hy=s,dy=M,fy=da,vy=Ua,gy=_p,py=xe,my=_,yy=re,Ey=Pp,ky=Np,Ty=hm.set,Sy=Um,Ay=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch($V){}},Ly=Bm,by=ym,Ry=es,Iy=Gm,Dy=ry,_y=iy,wy="Promise",Cy=Dy.CONSTRUCTOR,Py=Dy.REJECTION_EVENT,xy=Ry.getterFor(wy),My=Ry.set,Oy=Iy&&Iy.prototype,Fy=Iy,Ny=Oy,Uy=hy.TypeError,By=hy.document,Gy=hy.process,Ky=_y.f,Hy=Ky,Vy=!!(By&&By.createEvent&&hy.dispatchEvent),jy="unhandledrejection",Yy=function(e){var t;return!(!yy(e)||!my(t=e.then))&&t},qy=function(e,t){var r,i,n,a=t.value,s=1==t.state,o=s?e.ok:e.fail,l=e.resolve,u=e.reject,c=e.domain;try{o?(s||(2===t.rejection&&$y(t),t.rejection=1),!0===o?r=a:(c&&c.enter(),r=o(a),c&&(c.exit(),n=!0)),r===e.promise?u(Uy("Promise-chain cycle")):(i=Yy(r))?dy(i,r,l,u):l(r)):u(a)}catch($V){c&&!n&&c.exit(),u($V)}},Wy=function(e,t){e.notified||(e.notified=!0,Sy((function(){for(var r,i=e.reactions;r=i.get();)qy(r,e);e.notified=!1,t&&!e.rejection&&Xy(e)})))},zy=function(e,t,r){var i,n;Vy?((i=By.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),hy.dispatchEvent(i)):i={promise:t,reason:r},!Py&&(n=hy["on"+e])?n(i):e===jy&&Ay("Unhandled promise rejection",r)},Xy=function(e){dy(Ty,hy,(function(){var t,r=e.facade,i=e.value;if(Qy(e)&&(t=Ly((function(){cy?Gy.emit("unhandledRejection",i,r):zy(jy,r,i)})),e.rejection=cy||Qy(e)?2:1,t.error))throw t.value}))},Qy=function(e){return 1!==e.rejection&&!e.parent},$y=function(e){dy(Ty,hy,(function(){var t=e.facade;cy?Gy.emit("rejectionHandled",t):zy("rejectionhandled",t,e.value)}))},Jy=function(e,t,r){return function(i){e(t,i,r)}},Zy=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Wy(e,!0))},eE=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Uy("Promise can't be resolved itself");var i=Yy(t);i?Sy((function(){var r={done:!1};try{dy(i,t,Jy(eE,r,e),Jy(Zy,r,e))}catch($V){Zy(r,$V,e)}})):(e.value=t,e.state=1,Wy(e,!1))}catch($V){Zy({done:!1},$V,e)}}};Cy&&(Ny=(Fy=function(e){Ey(this,Ny),py(e),dy(oy,this);var t=xy(this);try{e(Jy(eE,t),Jy(Zy,t))}catch($V){Zy(t,$V)}}).prototype,(oy=function(e){My(this,{type:wy,done:!1,notified:!1,parent:!1,reactions:new by,rejection:!1,state:0,value:void 0})}).prototype=fy(Ny,"then",(function(e,t){var r=xy(this),i=Ky(ky(this,Fy));return r.parent=!0,i.ok=!my(e)||e,i.fail=my(t)&&t,i.domain=cy?Gy.domain:void 0,0==r.state?r.reactions.add(i):Sy((function(){qy(i,r)})),i.promise})),ly=function(){var e=new oy,t=xy(e);this.promise=e,this.resolve=Jy(eE,t),this.reject=Jy(Zy,t)},_y.f=Ky=function(e){return e===Fy||undefined===e?new ly(e):Hy(e)}),uy({global:!0,constructor:!0,wrap:!0,forced:Cy},{Promise:Fy}),vy(Fy,wy,!1,!0),gy(wy);var tE=vt("iterator"),rE=!1;try{var iE=0,nE={next:function(){return{done:!!iE++}},return:function(){rE=!0}};nE[tE]=function(){return this},Array.from(nE,(function(){throw 2}))}catch($V){}var aE=function(e,t){if(!t&&!rE)return!1;var r=!1;try{var i={};i[tE]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch($V){}return r},sE=Gm,oE=ry.CONSTRUCTOR||!aE((function(e){sE.all(e).then(void 0,(function(){}))})),lE=M,uE=xe,cE=iy,hE=Bm,dE=tp;wr({target:"Promise",stat:!0,forced:oE},{all:function(e){var t=this,r=cE.f(t),i=r.resolve,n=r.reject,a=hE((function(){var r=uE(t.resolve),a=[],s=0,o=1;dE(e,(function(e){var l=s++,u=!1;o++,lE(r,t,e).then((function(e){u||(u=!0,a[l]=e,--o||i(a))}),n)})),--o||i(a)}));return a.error&&n(a.value),r.promise}});var fE=wr,vE=ry.CONSTRUCTOR;Gm&&Gm.prototype,fE({target:"Promise",proto:!0,forced:vE,real:!0},{catch:function(e){return this.then(void 0,e)}});var gE=M,pE=xe,mE=iy,yE=Bm,EE=tp;wr({target:"Promise",stat:!0,forced:oE},{race:function(e){var t=this,r=mE.f(t),i=r.reject,n=yE((function(){var n=pE(t.resolve);EE(e,(function(e){gE(n,t,e).then(r.resolve,i)}))}));return n.error&&i(n.value),r.promise}});var kE=M,TE=iy;wr({target:"Promise",stat:!0,forced:ry.CONSTRUCTOR},{reject:function(e){var t=TE.f(this);return kE(t.reject,void 0,e),t.promise}});var SE=nr,AE=re,LE=iy,bE=function(e,t){if(SE(e),AE(t)&&t.constructor===e)return t;var r=LE.f(e);return(0,r.resolve)(t),r.promise},RE=wr,IE=Gm,DE=ry.CONSTRUCTOR,_E=bE,wE=le("Promise"),CE=!DE;RE({target:"Promise",stat:!0,forced:true},{resolve:function(e){return _E(CE&&this===wE?IE:this,e)}});var PE=M,xE=xe,ME=iy,OE=Bm,FE=tp;wr({target:"Promise",stat:!0,forced:oE},{allSettled:function(e){var t=this,r=ME.f(t),i=r.resolve,n=r.reject,a=OE((function(){var r=xE(t.resolve),n=[],a=0,s=1;FE(e,(function(e){var o=a++,l=!1;s++,PE(r,t,e).then((function(e){l||(l=!0,n[o]={status:"fulfilled",value:e},--s||i(n))}),(function(e){l||(l=!0,n[o]={status:"rejected",reason:e},--s||i(n))}))})),--s||i(n)}));return a.error&&n(a.value),r.promise}});var NE=M,UE=xe,BE=le,GE=iy,KE=Bm,HE=tp,VE="No one promise resolved";wr({target:"Promise",stat:!0,forced:oE},{any:function(e){var t=this,r=BE("AggregateError"),i=GE.f(t),n=i.resolve,a=i.reject,s=KE((function(){var i=UE(t.resolve),s=[],o=0,l=1,u=!1;HE(e,(function(e){var c=o++,h=!1;l++,NE(i,t,e).then((function(e){h||u||(u=!0,n(e))}),(function(e){h||u||(h=!0,s[c]=e,--l||a(new r(s,VE)))}))})),--l||a(new r(s,VE))}));return s.error&&a(s.value),i.promise}});var jE=wr,YE=Gm,qE=o,WE=le,zE=_,XE=Np,QE=bE,$E=YE&&YE.prototype;jE({target:"Promise",proto:!0,real:!0,forced:!!YE&&qE((function(){$E.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=XE(this,WE("Promise")),r=zE(e);return this.then(r?function(r){return QE(t,e()).then((function(){return r}))}:e,r?function(r){return QE(t,e()).then((function(){throw r}))}:e)}});var JE=ie.Promise,ZE=iy,ek=Bm;wr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=ZE.f(this),r=ek(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var tk=i(JE),rk="\t\n\v\f\r \u2028\u2029\ufeff",ik=Q,nk=tn,ak=rk,sk=y("".replace),ok=RegExp("^["+ak+"]+"),lk=RegExp("(^|[^"+ak+"])["+ak+"]+$"),uk=function(e){return function(t){var r=nk(ik(t));return 1&e&&(r=sk(r,ok,"")),2&e&&(r=sk(r,lk,"$1")),r}},ck={start:uk(1),end:uk(2),trim:uk(3)},hk=s,dk=o,fk=y,vk=tn,gk=ck.trim,pk=rk,mk=hk.parseInt,yk=hk.Symbol,Ek=yk&&yk.iterator,kk=/^[+-]?0x/i,Tk=fk(kk.exec),Sk=8!==mk(pk+"08")||22!==mk(pk+"0x16")||Ek&&!dk((function(){mk(Object(Ek))}))?function(e,t){var r=gk(vk(e));return mk(r,t>>>0||(Tk(kk,r)?16:10))}:mk;wr({global:!0,forced:parseInt!=Sk},{parseInt:Sk});var Ak=i(ie.parseInt),Lk=ls.map;wr({target:"Array",proto:!0,forced:!Ui("map")},{map:function(e){return Lk(this,e,arguments.length>1?arguments[1]:void 0)}});var bk=nh("Array").map,Rk=ue,Ik=bk,Dk=Array.prototype,_k=i((function(e){var t=e.map;return e===Dk||Rk(Dk,e)&&t===Dk.map?Ik:t}));wr({target:"Array",stat:!0},{isArray:Br});var wk=ie.Array.isArray,Ck=i(wk),Pk=i(wk),xk=i(Kd),Mk=C,Ok=y,Fk=M,Nk=o,Uk=An,Bk=ca,Gk=O,Kk=$e,Hk=q,Vk=Object.assign,jk=Object.defineProperty,Yk=Ok([].concat),qk=!Vk||Nk((function(){if(Mk&&1!==Vk({b:1},Vk(jk({},"a",{enumerable:!0,get:function(){jk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),i="abcdefghijklmnopqrst";return e[r]=7,i.split("").forEach((function(e){t[e]=e})),7!=Vk({},e)[r]||Uk(Vk({},t)).join("")!=i}))?function(e,t){for(var r=Kk(e),i=arguments.length,n=1,a=Bk.f,s=Gk.f;i>n;)for(var o,l=Hk(arguments[n++]),u=a?Yk(Uk(l),a(l)):Uk(l),c=u.length,h=0;c>h;)o=u[h++],Mk&&!Fk(s,l,o)||(r[o]=l[o]);return r}:Vk,Wk=qk;wr({target:"Object",stat:!0,arity:2,forced:Object.assign!==Wk},{assign:Wk});var zk=i(ie.Object.assign),Xk=i(Md),Qk=i(Eh),$k=i(vf),Jk=i(Sf),Zk=i(Fr),eT=i(cc),tT=i(_c),rT=i(_h),iT=i(uh),nT=wg,aT=i(nT),sT=i(nT),oT=nr,lT=Kg,uT=Jt,cT=M,hT=$e,dT=function(e,t,r,i){try{return i?t(oT(r)[0],r[1]):t(r)}catch($V){lT(e,"throw",$V)}},fT=Lg,vT=Ii,gT=zr,pT=ei,mT=Ng,yT=wg,ET=Array,kT=function(e){var t=hT(e),r=vT(this),i=arguments.length,n=i>1?arguments[1]:void 0,a=void 0!==n;a&&(n=uT(n,i>2?arguments[2]:void 0));var s,o,l,u,c,h,d=yT(t),f=0;if(!d||this===ET&&fT(d))for(s=gT(t),o=r?new this(s):ET(s);s>f;f++)h=a?n(t[f],f):t[f],pT(o,f,h);else for(c=(u=mT(t,d)).next,o=r?new this:[];!(l=cT(c,u)).done;f++)h=a?dT(u,n,[l.value,f],!0):l.value,pT(o,f,h);return o.length=f,o},TT=kT;wr({target:"Array",stat:!0,forced:!aE((function(e){Array.from(e)}))},{from:TT});var ST=ie.Array.from,AT=i(ST),LT=i(ST),bT=i(Pc);function RT(e,t){var r=gv(e);if(Xk){var i=Xk(e);t&&(i=xk(i).call(i,(function(t){return Qk(e,t).enumerable}))),r.push.apply(r,i)}return r}function IT(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=RT(Object(n),!0)).call(r,(function(t){PT(e,t,n[t])})):$k?Jk(e,$k(n)):vd(i=RT(Object(n))).call(i,(function(t){Zk(e,t,Qk(n,t))}))}return e}function DT(e){return(DT="function"==typeof eT&&"symbol"==typeof tT?function(e){return typeof e}:function(e){return e&&"function"==typeof eT&&e.constructor===eT&&e!==eT.prototype?"symbol":typeof e})(e)}function _T(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wT(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Zk(e,OT(i.key),i)}}function CT(e,t,r){return t&&wT(e.prototype,t),r&&wT(e,r),Zk(e,"prototype",{writable:!1}),e}function PT(e,t,r){return(t=OT(t))in e?Zk(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xT(e){return function(e){if(Pk(e))return MT(e)}(e)||function(e){if(void 0!==eT&&null!=sT(e)||null!=e["@@iterator"])return LT(e)}(e)||function(e,t){var r;if(!e)return;if("string"==typeof e)return MT(e,t);var i=Fv(r=Object.prototype.toString.call(e)).call(r,8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return LT(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return MT(e,t)}(e)||function(){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 MT(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function OT(e){var t=function(e,t){if("object"!==Cc(e)||null===e)return e;var r=e[bT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Cc(t)?t:String(t)}var FT=ls.some;wr({target:"Array",proto:!0,forced:!rd("some")},{some:function(e){return FT(this,e,arguments.length>1?arguments[1]:void 0)}});var NT=nh("Array").some,UT=ue,BT=NT,GT=Array.prototype,KT=i((function(e){var t=e.some;return e===GT||UT(GT,e)&&t===GT.some?BT:t})),HT=Vr,VT=tn,jT=Q,YT=RangeError,qT=y,WT=qr,zT=tn,XT=Q,QT=qT((function(e){var t=VT(jT(this)),r="",i=HT(e);if(i<0||i==1/0)throw YT("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r})),$T=qT("".slice),JT=Math.ceil,ZT=function(e){return function(t,r,i){var n,a,s=zT(XT(t)),o=WT(r),l=s.length,u=void 0===i?" ":zT(i);return o<=l||""==u?s:((a=QT(u,JT((n=o-l)/u.length))).length>n&&(a=$T(a,0,n)),e?s+a:a+s)}},eS={start:ZT(!1),end:ZT(!0)},tS=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),rS=eS.start;wr({target:"String",proto:!0,forced:tS},{padStart:function(e){return rS(this,e,arguments.length>1?arguments[1]:void 0)}});var iS=nh("String").padStart,nS=ue,aS=iS,sS=String.prototype,oS=i((function(e){var t=e.padStart;return"string"==typeof e||e===sS||nS(sS,e)&&t===sS.padStart?aS:t})),lS=i(ie.setInterval),uS=ls.every;wr({target:"Array",proto:!0,forced:!rd("every")},{every:function(e){return uS(this,e,arguments.length>1?arguments[1]:void 0)}});var cS=nh("Array").every,hS=ue,dS=cS,fS=Array.prototype,vS=i((function(e){var t=e.every;return e===fS||hS(fS,e)&&t===fS.every?dS:t})),gS=s,pS=o,mS=tn,yS=ck.trim,ES=rk,kS=y("".charAt),TS=gS.parseFloat,SS=gS.Symbol,AS=SS&&SS.iterator,LS=1/TS(ES+"-0")!=-1/0||AS&&!pS((function(){TS(Object(AS))}))?function(e){var t=yS(mS(e)),r=TS(t);return 0===r&&"-"==kS(t,0)?-0:r}:TS;wr({global:!0,forced:parseFloat!=LS},{parseFloat:LS});var bS=i(ie.parseFloat),RS=bl.PROPER,IS=o,DS=rk,_S=ck.trim;wr({target:"String",proto:!0,forced:function(e){return IS((function(){return!!DS[e]()||"
"!=="
"[e]()||RS&&DS[e].name!==e}))}("trim")},{trim:function(){return _S(this)}});var wS=nh("String").trim,CS=ue,PS=wS,xS=String.prototype,MS=i((function(e){var t=e.trim;return"string"==typeof e||e===xS||CS(xS,e)&&t===xS.trim?PS:t})),OS=na,FS=Math.floor,NS=function(e,t){var r=e.length,i=FS(r/2);return r<8?US(e,t):BS(e,NS(OS(e,0,i),t),NS(OS(e,i),t),t)},US=function(e,t){for(var r,i,n=e.length,a=1;a<n;){for(i=a,r=e[a];i&&t(e[i-1],r)>0;)e[i]=e[--i];i!==a++&&(e[i]=r)}return e},BS=function(e,t,r,i){for(var n=t.length,a=r.length,s=0,o=0;s<n||o<a;)e[s+o]=s<n&&o<a?i(t[s],r[o])<=0?t[s++]:r[o++]:s<n?t[s++]:r[o++];return e},GS=NS,KS=ce.match(/firefox\/(\d+)/i),HS=!!KS&&+KS[1],VS=/MSIE|Trident/.test(ce),jS=ce.match(/AppleWebKit\/(\d+)\./),YS=!!jS&&+jS[1],qS=wr,WS=y,zS=xe,XS=$e,QS=zr,$S=Bv,JS=tn,ZS=o,eA=GS,tA=rd,rA=HS,iA=VS,nA=me,aA=YS,sA=[],oA=WS(sA.sort),lA=WS(sA.push),uA=ZS((function(){sA.sort(void 0)})),cA=ZS((function(){sA.sort(null)})),hA=tA("sort"),dA=!ZS((function(){if(nA)return nA<70;if(!(rA&&rA>3)){if(iA)return!0;if(aA)return aA<603;var e,t,r,i,n="";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(i=0;i<47;i++)sA.push({k:t+i,v:r})}for(sA.sort((function(e,t){return t.v-e.v})),i=0;i<sA.length;i++)t=sA[i].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));qS({target:"Array",proto:!0,forced:uA||!cA||!hA||!dA},{sort:function(e){void 0!==e&&zS(e);var t=XS(this);if(dA)return void 0===e?oA(t):oA(t,e);var r,i,n=[],a=QS(t);for(i=0;i<a;i++)i in t&&lA(n,t[i]);for(eA(n,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:JS(t)>JS(r)?1:-1}}(e)),r=QS(n),i=0;i<r;)t[i]=n[i++];for(;i<a;)$S(t,i++);return t}});var fA=nh("Array").sort,vA=ue,gA=fA,pA=Array.prototype,mA=i((function(e){var t=e.sort;return e===pA||vA(pA,e)&&t===pA.sort?gA:t})),yA=wr,EA=Date,kA=y(EA.prototype.getTime);yA({target:"Date",stat:!0},{now:function(){return kA(new EA)}});var TA,SA=i(ie.Date.now),AA="undefined"!=typeof window&&window.location&&av(TA=window.location.href).call(TA,"xgplayerdebugger=1")>-1,LA="color: #525252; background-color: #90ee90;",bA="color: #525252; background-color: red;",RA="color: #525252; background-color: yellow; ",IA="%c[xgplayer]",DA={config:{debug:AA?3:0},logInfo:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=3&&(r=console).log.apply(r,_d(t=[IA,LA,e]).call(t,n))},logWarn:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=1&&(r=console).warn.apply(r,_d(t=[IA,RA,e]).call(t,n))},logError:function(e){var t,r;if(!(this.config.debug<1)){for(var i=this.config.debug>=2?"trace":"error",n=arguments.length,a=new Array(n>1?n-1:0),s=1;s<n;s++)a[s-1]=arguments[s];(r=console)[i].apply(r,_d(t=[IA,bA,e]).call(t,a))}}},_A=function(){function e(t){_T(this,e),this.bufferedList=t}return CT(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}(),wA={};wA.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]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=document.createElement(t);return a.className=n,a.innerHTML=r,vd(e=gv(i)).call(e,(function(e){var r=e,n=i[e];"video"===t||"audio"===t||"live-video"===t?n&&a.setAttribute(r,n):a.setAttribute(r,n)})),a},wA.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 i=document.createElement("div");i.innerHTML=e;var n=i.children;if(i=null,n.length>0){var a;if(n=n[0],r&&wA.addClass(n,r),t)vd(a=gv(t)).call(a,(function(e){n.setAttribute(e,t[e])}));return n}return null}catch(s){return DA.logError("util.createDomFromHtml",s),null}},wA.hasClass=function(e,t){if(!e||!t)return!1;try{return KT(Array.prototype).call(e.classList,(function(e){return e===t}))}catch(i){var r=e.className&&"object"===DT(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},wA.addClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.add(t)}))}catch(i){wA.hasClass(e,t)||(e.className&&"object"===DT(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},wA.removeClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.remove(t)}))}catch(n){var i;if(wA.hasClass(e,t))vd(i=t.split(/\s+/g)).call(i,(function(t){var r=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===DT(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")}))}},wA.toggleClass=function(e,t){var r;e&&vd(r=t.split(/\s+/g)).call(r,(function(t){wA.hasClass(e,t)?wA.removeClass(e,t):wA.addClass(e,t)}))},wA.classNames=function(){for(var e=arguments,t=[],r=function(r){if("String"===wA.typeOf(e[r]))t.push(e[r]);else if("Object"===wA.typeOf(e[r])){var i;_k(i=gv(e[r])).call(i,(function(i){e[r][i]&&t.push(i)}))}},i=0;i<arguments.length;i++)r(i);return t.join(" ")},wA.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(i){DA.logError("util.findDom",i),0===av(r).call(r,"#")&&(e=t.getElementById(Fv(r).call(r,1)))}return e},wA.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},wA.padStart=function(e,t,r){for(var i=String(r),n=t>>0,a=Math.ceil(n/i.length),s=[],o=String(e);a--;)s.push(i);return s.join("").substring(0,n-o.length)+o},wA.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=oS(wA).call(wA,Math.floor(e/3600),2,0),r=oS(wA).call(wA,Math.floor((e-3600*t)/60),2,0),i=oS(wA).call(wA,Math.floor(e-3600*t-60*r),2,0);return("00"===t?[r,i]:[t,r,i]).join(":")},wA.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},wA.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},wA.deepCopy=function(e,t){var r;if("Object"===wA.typeOf(t)&&"Object"===wA.typeOf(e))return vd(r=gv(t)).call(r,(function(r){if("Object"!==wA.typeOf(t[r])||t[r]instanceof Node)if("Array"===wA.typeOf(t[r])){var i;e[r]="Array"===wA.typeOf(e[r])?_d(i=e[r]).call(i,t[r]):t[r]}else e[r]=t[r];else void 0===e[r]||void 0===e[r]?e[r]=t[r]:wA.deepCopy(e[r],t[r])})),e},wA.deepMerge=function(e,t){var r;return _k(r=gv(t)).call(r,(function(r){var i;"Array"===wA.typeOf(t[r])&&"Array"===wA.typeOf(e[r])?"Array"===wA.typeOf(e[r])&&(i=e[r]).push.apply(i,xT(t[r])):wA.typeOf(e[r])!==wA.typeOf(t[r])||null===e[r]||"Object"!==wA.typeOf(e[r])||t[r]instanceof window.Node?null!==t[r]&&(e[r]=t[r]):wA.deepMerge(e[r],t[r])})),e},wA.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},wA.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return vd(Array.prototype).call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},wA.setInterval=function(e,t,r,i){e._interval[t]||(e._interval[t]=lS(iT(r).call(r,e),i))},wA.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},wA.setTimeout=function(e,t,r){e._timers||(e._timers=[]);var i=Wf((function(){t(),wA.clearTimeout(e,i)}),r);return e._timers.push(i),i},wA.clearTimeout=function(e,t){var r=e._timers;if("Array"===wA.typeOf(r)){for(var i=0;i<r.length;i++)if(r[i]===t){ig(r).call(r,i,1),clearTimeout(t);break}}else clearTimeout(t)},wA.clearAllTimers=function(e){var t=e._timers;"Array"===wA.typeOf(t)&&(_k(t).call(t,(function(e){clearTimeout(e)})),e._timerIds=[])},wA.createImgBtn=function(e,t,r,i){var n,a,s,o,l,u,c,h,d,f,v,g,p=wA.createDom("xg-".concat(e),"",{},"xgplayer-".concat(e,"-img"));(p.style.backgroundImage='url("'.concat(t,'")'),r&&i)&&(vS(n=["px","rem","em","pt","dp","vw","vh","vm","%"]).call(n,(function(e){var t,n;return!(av(r).call(r,e)>-1&&av(i).call(i,e)>-1)||(c=bS(MS(t=Fv(r).call(r,0,av(r).call(r,e))).call(t)),h=bS(MS(n=Fv(i).call(i,0,av(i).call(i,e))).call(n)),d=e,!1)})),p.style.width=_d(a="".concat(c)).call(a,d),p.style.height=_d(s="".concat(h)).call(s,d),p.style.backgroundSize=_d(o=_d(l=_d(u="".concat(c)).call(u,d," ")).call(l,h)).call(o,d),p.style.margin="start"===e?_d(f=_d(v=_d(g="-".concat(h/2)).call(g,d," auto auto -")).call(v,c/2)).call(f,d):"auto 5px auto 5px");return p},wA.Hex2RGBA=function(e,t){var r,i=[];if(/^\#[0-9A-F]{3}$/i.test(e)){var n="#";e.replace(/[0-9A-F]/gi,(function(e){n+=e+e})),e=n}return/^#[0-9A-F]{6}$/i.test(e)?(e.replace(/[0-9A-F]{2}/gi,(function(e){i.push(Ak(e,16))})),_d(r="rgba(".concat(i.join(","),", ")).call(r,t,")")):"rgba(255, 255, 255, 0.1)"},wA.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},wA.checkIsFunction=function(e){return e&&"function"==typeof e},wA.checkIsObject=function(e){return null!==e&&"object"===DT(e)},wA.hide=function(e){e.style.display="none"},wA.show=function(e,t){e.style.display=t||"block"},wA.isUndefined=function(e){if(null==e)return!0},wA.isNotNull=function(e){return!(null==e)},wA.setStyleFromCsstext=function(e,t){if(t)if("String"===wA.typeOf(t)){var r=t.replace(/\s+/g,"").split(";");_k(r).call(r,(function(t){if(t){var r=t.split(":");r.length>1&&(e.style[r[0]]=r[1])}}))}else{var i;_k(i=gv(t)).call(i,(function(r){e.style[r]=t[r]}))}},wA.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"],i=e.style.cssText;if(!i)return{};var n=i.replace(/\s+/g,"").split(";"),a={},s={};return _k(n).call(n,(function(e){if(e){var t=e.split(":");t.length>1&&(!function(e,t){for(var r=0,i=t.length;r<i;r++)if(av(e).call(e,t[r])>-1)return!0;return!1}(t[0],r)?s[t[0]]=t[1]:a[t[0]]=t[1])}})),e.setAttribute("style",""),_k(t=gv(s)).call(t,(function(t){e.style[t]=s[t]})),a},wA.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var r=t.replace(/\s+/g,"").split(";"),i={};return _k(r).call(r,(function(e){if(e){var t=e.split(":");t.length>1&&(i[t[0]]=t[1])}})),i},wA.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 i=new window.Image;i.onload=function(e){i=null,t&&t(e)},i.onerror=function(e){i=null,r&&r(e)},i.src=e}},wA.stopPropagation=function(e){e&&e.stopPropagation()},wA.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},wA.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},wA.checkTouchSupport=function(){return"ontouchstart"in window},wA.getBuffered2=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=[],i=0;i<e.length;i++)r.push({start:e.start(i)<.5?0:e.start(i),end:e.end(i)});mA(r).call(r,(function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var n=[];if(t)for(var a=0;a<r.length;a++){var s=n.length;if(s){var o=n[s-1].end;r[a].start-o<t?r[a].end>o&&(n[s-1].end=r[a].end):n.push(r[a])}else n.push(r[a])}else n=r;return new _A(n)},wA.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}},wA.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},wA.getHostFromUrl=function(e){if("String"!==wA.typeOf(e))return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r},wA.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},wA.isMSE=function(e){return e.media&&(e=e.media),!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},wA.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},wA.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=Ak(e)}catch(r){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=Ak(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)}))},wA.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},wA.adjustTimeByDuration=function(e,t,r){return t&&e&&(e>t||r&&e<t)?t:e},wA.createPositionBar=function(e,t){var r=wA.createDom("xg-bar","",{"data-index":-1},e);return t.appendChild(r),r},wA.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]:"",i={scale:"".concat(t.scale||1),translate:_d(e="".concat(t.x||0,"%, ")).call(e,t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")},n=gv(i);return vd(n).call(n,(function(e){var t,n=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),a=_d(t="".concat(e,"(")).call(t,i[e],")");n.test(r)?(n.lastIndex=-1,r=r.replace(n,a)):r+="".concat(a," ")})),r},wA.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},wA.getIndexByTime=function(e,t){var r=t.length,i=-1;if(r<1)return i;if(e<=t[0].end||r<2)i=0;else if(e>t[r-1].end)i=r-1;else for(var n=1;n<r;n++)if(e>t[n-1].end&&e<=t[n].end){i=n;break}return i},wA.getOffsetCurrentTime=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=-1;if((i=r>=0&&r<t.length?r:wA.getIndexByTime(e,t))<0)return-1;var n=t.length,a=t[i],s=a.start,o=a.end,l=a.cTime,u=a.offset;return e<s?l:e>=s&&e<=o?e-u:e>o&&i>=n-1?o:-1},wA.getCurrentTimeByOffset=function(e,t){var r=-1;if(!t||t.length<0)return e;for(var i=0;i<t.length;i++)if(e<=t[i].duration){r=i;break}if(-1!==r){var n=t[r].start;return r-1<0?n+e:n+(e-t[r-1].duration)}return e};var CA="urlchange";function PA(e,t,r){for(var i,n=arguments.length,a=new Array(n>3?n-3:0),s=3;s<n;s++)a[s-3]=arguments[s];var o,l=t.call.apply(t,_d(i=[e]).call(i,a));r&&"function"==typeof r&&(l&&l.then?l.then((function(){for(var t,i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];r.call.apply(r,_d(t=[e]).call(t,n))})):r.call.apply(r,_d(o=[e]).call(o,a)))}function xA(e,t){var r,i=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),iT(r=function(){var r,n=arguments,a=this;if(i.pre)try{var s,o;(o=i.pre).call.apply(o,_d(s=[this]).call(s,Fv(Array.prototype).call(arguments)))}catch(g){var l,u;throw g.message=_d(l=_d(u="[pluginName: ".concat(this.pluginName,":")).call(u,e,":pre error] >> ")).call(l,g.message),g}if(this.__hooks&&this.__hooks[e])try{var c,h=function(e,t,r){for(var i=arguments.length,n=new Array(i>3?i-3:0),a=3;a<i;a++)n[a-3]=arguments[a];if(e.__hooks&&Pk(e.__hooks[t])){var s,o=e.__hooks[t],l=-1,u=function e(t,r,i){for(var n,a,s=arguments.length,u=new Array(s>3?s-3:0),c=3;c<s;c++)u[c-3]=arguments[c];if(l++,0===o.length||l===o.length)return i.call.apply(i,_d(a=[t,t]).call(a,u));var h,d=o[l],f=d.call.apply(d,_d(n=[t,t]).call(n,u));return f&&f.then?f.then((function(n){var a;return!1===n?null:e.apply(void 0,_d(a=[t,r,i]).call(a,u))})).catch((function(e){console.warn("[runHooks]".concat(r," reject"),e.message)})):!1!==f?e.apply(void 0,_d(h=[t,r,i]).call(h,u)):void 0};return u.apply(void 0,_d(s=[e,t,r]).call(s,n))}var c;return r.call.apply(r,_d(c=[e,e]).call(c,n))}(this,e,t);if(h)if(h.then)h.then((function(e){var r;!1!==e&&PA.apply(void 0,_d(r=[a,t,i.next]).call(r,xT(n)))})).catch((function(e){throw e}));else PA.apply(void 0,_d(c=[this,t,i.next]).call(c,Fv(Array.prototype).call(arguments)));else if(void 0===h){var d;PA.apply(void 0,_d(d=[this,t,i.next]).call(d,Fv(Array.prototype).call(arguments)))}}catch(g){var f,v;throw g.message=_d(f=_d(v="[pluginName: ".concat(this.pluginName,":")).call(v,e,"] >> ")).call(f,g.message),g}else PA.apply(void 0,_d(r=[this,t,i.next]).call(r,Fv(Array.prototype).call(arguments)))}).call(r,this)}function MA(e,t){var r=this.__hooks;if(!r||!Pk(r[e]))return-1;for(var i=r[e],n=0;n<i.length;n++)if(i[n]===t)return n;return-1}function OA(e,t){var r=this.__hooks;if(r)return r.hasOwnProperty(e)?(Pk(r[e])||(r[e]=[]),-1===MA.call(this,e,t)&&r[e].push(t),!0):(console.warn("has no supported hook which name [".concat(e,"]")),!1)}function FA(e,t){var r=this.__hooks;if(r)if(Pk(r[e])){var i=r[e],n=MA.call(this,e,t);-1!==n&&ig(i).call(i,n,1)}else r[e]&&(r[e]=null)}function NA(e,t){var r;DA.logError(_d(r="[".concat(e,"] event or callback cant be undefined or null when call ")).call(r,t))}var UA=function(){function e(t){_T(this,e),wA.checkIsFunction(this.beforeCreate)&&this.beforeCreate(t),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&_k(t).call(t,(function(t){e.__hooks[t]=null})),Zk(e,"hooks",{get:function(){var t;return e.__hooks&&_k(t=gv(e.__hooks)).call(t,(function(t){if(e.__hooks[t])return t}))}})}(this),this.__args=t,this.__events={},this.__onceEvents={},this.config=t.config||{},this.player=null,this.playerConfig={},this.pluginName="",this.__init(t)}return CT(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=wA.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)):Pk(e)&&vd(e).call(e,(function(e){r.__events[e]=t,r.player.on(e,t)})):NA(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)):Pk(e)&&vd(e).call(e,(function(i){r.__onceEvents[i]=t,r.player.once(e,t)})):NA(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)):Pk(e)&&vd(e).call(e,(function(i){delete r.__events[e],r.player.off(i,t)})):NA(this.pluginName,"plugin.off(event, callback)")}},{key:"offAll",value:function(){var e,t=this;vd(e=["__events","__onceEvents"]).call(e,(function(e){var r;vd(r=gv(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 i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];(r=this.player).emit.apply(r,_d(t=[e]).call(t,n))}}},{key:"emitUserAction",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var i=IT(IT({},r),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,i)}}},{key:"hook",value:function(e,t){var r;return xA.call.apply(xA,_d(r=[this]).call(r,Fv(Array.prototype).call(arguments)))}},{key:"useHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return OA.call.apply(OA,_d(r=[this]).call(r,Fv(Array.prototype).call(arguments)))}},{key:"removeHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return FA.call.apply(FA,_d(r=[this]).call(r,Fv(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,i=this.pluginName;this.offAll(),wA.clearAllTimers(this),wA.checkIsFunction(this.destroy)&&this.destroy(),_k(e=["player","playerConfig","pluginName","logger","__args","__hooks"]).call(e,(function(e){t[e]=null})),r.unRegisterPlugin(i),this.__hooks=null}}],[{key:"defineGetterOrSetter",value:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&Zk(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]&&Zk(e,r,{configurable:!0,value:t[r]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}(),BA=o,GA=vt("iterator"),KA=!BA((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,i){t.delete("b"),r+=i+e})),!e.toJSON||!t.size&&true||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[GA]||"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})),HA=y,VA=2147483647,jA=/[^\0-\u007E]/,YA=/[.\u3002\uFF0E\uFF61]/g,qA="Overflow: input needs wider integers to process",WA=RangeError,zA=HA(YA.exec),XA=Math.floor,QA=String.fromCharCode,$A=HA("".charCodeAt),JA=HA([].join),ZA=HA([].push),eL=HA("".replace),tL=HA("".split),rL=HA("".toLowerCase),iL=function(e){return e+22+75*(e<26)},nL=function(e,t,r){var i=0;for(e=r?XA(e/700):e>>1,e+=XA(e/t);e>455;)e=XA(e/35),i+=36;return XA(i+36*e/(e+38))},aL=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var n=$A(e,r++);if(n>=55296&&n<=56319&&r<i){var a=$A(e,r++);56320==(64512&a)?ZA(t,((1023&n)<<10)+(1023&a)+65536):(ZA(t,n),r--)}else ZA(t,n)}return t}(e);var r,i,n=e.length,a=128,s=0,o=72;for(r=0;r<e.length;r++)(i=e[r])<128&&ZA(t,QA(i));var l=t.length,u=l;for(l&&ZA(t,"-");u<n;){var c=VA;for(r=0;r<e.length;r++)(i=e[r])>=a&&i<c&&(c=i);var h=u+1;if(c-a>XA((VA-s)/h))throw WA(qA);for(s+=(c-a)*h,a=c,r=0;r<e.length;r++){if((i=e[r])<a&&++s>VA)throw WA(qA);if(i==a){for(var d=s,f=36;;){var v=f<=o?1:f>=o+26?26:f-o;if(d<v)break;var g=d-v,p=36-v;ZA(t,QA(iL(v+g%p))),d=XA(g/p),f+=36}ZA(t,QA(iL(d))),o=nL(s,h,u==l),s=0,u++}}s++,a++}return JA(t,"")},sL=da,oL=function(e,t,r){for(var i in t)r&&r.unsafe&&e[i]?e[i]=t[i]:sL(e,i,t[i],r);return e},lL=wr,uL=s,cL=M,hL=y,dL=C,fL=KA,vL=da,gL=va,pL=oL,mL=Ua,yL=$l,EL=es,kL=Pp,TL=_,SL=et,AL=Jt,LL=ui,bL=nr,RL=re,IL=tn,DL=zn,_L=K,wL=Ng,CL=wg,PL=wf,xL=GS,ML=vt("iterator"),OL="URLSearchParams",FL=OL+"Iterator",NL=EL.set,UL=EL.getterFor(OL),BL=EL.getterFor(FL),GL=Object.getOwnPropertyDescriptor,KL=function(e){if(!dL)return uL[e];var t=GL(uL,e);return t&&t.value},HL=KL("fetch"),VL=KL("Request"),jL=KL("Headers"),YL=VL&&VL.prototype,qL=jL&&jL.prototype,WL=uL.RegExp,zL=uL.TypeError,XL=uL.decodeURIComponent,QL=uL.encodeURIComponent,$L=hL("".charAt),JL=hL([].join),ZL=hL([].push),eb=hL("".replace),tb=hL([].shift),rb=hL([].splice),ib=hL("".split),nb=hL("".slice),ab=/\+/g,sb=Array(4),ob=function(e){return sb[e-1]||(sb[e-1]=WL("((?:%[\\da-f]{2}){"+e+"})","gi"))},lb=function(e){try{return XL(e)}catch($V){return e}},ub=function(e){var t=eb(e,ab," "),r=4;try{return XL(t)}catch($V){for(;r;)t=eb(t,ob(r--),lb);return t}},cb=/[!'()~]|%20/g,hb={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},db=function(e){return hb[e]},fb=function(e){return eb(QL(e),cb,db)},vb=yL((function(e,t){NL(this,{type:FL,iterator:wL(UL(e).entries),kind:t})}),"Iterator",(function(){var e=BL(this),t=e.kind,r=e.iterator.next(),i=r.value;return r.done||(r.value="keys"===t?i.key:"values"===t?i.value:[i.key,i.value]),r}),!0),gb=function(e){this.entries=[],this.url=null,void 0!==e&&(RL(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===$L(e,0)?nb(e,1):e:IL(e)))};gb.prototype={type:OL,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,a,s,o,l=CL(e);if(l)for(r=(t=wL(e,l)).next;!(i=cL(r,t)).done;){if(a=(n=wL(bL(i.value))).next,(s=cL(a,n)).done||(o=cL(a,n)).done||!cL(a,n).done)throw zL("Expected sequence with length 2");ZL(this.entries,{key:IL(s.value),value:IL(o.value)})}else for(var u in e)SL(e,u)&&ZL(this.entries,{key:u,value:IL(e[u])})},parseQuery:function(e){if(e)for(var t,r,i=ib(e,"&"),n=0;n<i.length;)(t=i[n++]).length&&(r=ib(t,"="),ZL(this.entries,{key:ub(tb(r)),value:ub(JL(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],ZL(r,fb(e.key)+"="+fb(e.value));return JL(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var pb=function(){kL(this,mb);var e=NL(this,new gb(arguments.length>0?arguments[0]:void 0));dL||(this.length=e.entries.length)},mb=pb.prototype;if(pL(mb,{append:function(e,t){PL(arguments.length,2);var r=UL(this);ZL(r.entries,{key:IL(e),value:IL(t)}),dL||this.length++,r.updateURL()},delete:function(e){PL(arguments.length,1);for(var t=UL(this),r=t.entries,i=IL(e),n=0;n<r.length;)r[n].key===i?rb(r,n,1):n++;dL||(this.length=r.length),t.updateURL()},get:function(e){PL(arguments.length,1);for(var t=UL(this).entries,r=IL(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){PL(arguments.length,1);for(var t=UL(this).entries,r=IL(e),i=[],n=0;n<t.length;n++)t[n].key===r&&ZL(i,t[n].value);return i},has:function(e){PL(arguments.length,1);for(var t=UL(this).entries,r=IL(e),i=0;i<t.length;)if(t[i++].key===r)return!0;return!1},set:function(e,t){PL(arguments.length,1);for(var r,i=UL(this),n=i.entries,a=!1,s=IL(e),o=IL(t),l=0;l<n.length;l++)(r=n[l]).key===s&&(a?rb(n,l--,1):(a=!0,r.value=o));a||ZL(n,{key:s,value:o}),dL||(this.length=n.length),i.updateURL()},sort:function(){var e=UL(this);xL(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=UL(this).entries,i=AL(e,arguments.length>1?arguments[1]:void 0),n=0;n<r.length;)i((t=r[n++]).value,t.key,this)},keys:function(){return new vb(this,"keys")},values:function(){return new vb(this,"values")},entries:function(){return new vb(this,"entries")}},{enumerable:!0}),vL(mb,ML,mb.entries,{name:"entries"}),vL(mb,"toString",(function(){return UL(this).serialize()}),{enumerable:!0}),dL&&gL(mb,"size",{get:function(){return UL(this).entries.length},configurable:!0,enumerable:!0}),mL(pb,OL),lL({global:!0,constructor:!0,forced:!fL},{URLSearchParams:pb}),!fL&&TL(jL)){var yb=hL(qL.has),Eb=hL(qL.set),kb=function(e){if(RL(e)){var t,r=e.body;if(LL(r)===OL)return t=e.headers?new jL(e.headers):new jL,yb(t,"content-type")||Eb(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),DL(e,{body:_L(0,IL(r)),headers:_L(0,t)})}return e};if(TL(HL)&&lL({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return HL(e,arguments.length>1?kb(arguments[1]):{})}}),TL(VL)){var Tb=function(e){return kL(this,YL),new VL(e,arguments.length>1?kb(arguments[1]):{})};YL.constructor=Tb,Tb.prototype=YL,lL({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Tb})}}var Sb,Ab=wr,Lb=C,bb=KA,Rb=s,Ib=Jt,Db=y,_b=da,wb=va,Cb=Pp,Pb=et,xb=qk,Mb=kT,Ob=na,Fb=kc.codeAt,Nb=function(e){var t,r,i=[],n=tL(eL(rL(e),YA,"."),".");for(t=0;t<n.length;t++)r=n[t],ZA(i,zA(jA,r)?"xn--"+aL(r):r);return JA(i,".")},Ub=tn,Bb=Ua,Gb=wf,Kb={URLSearchParams:pb,getState:UL},Hb=es,Vb=Hb.set,jb=Hb.getterFor("URL"),Yb=Kb.URLSearchParams,qb=Kb.getState,Wb=Rb.URL,zb=Rb.TypeError,Xb=Rb.parseInt,Qb=Math.floor,$b=Math.pow,Jb=Db("".charAt),Zb=Db(/./.exec),eR=Db([].join),tR=Db(1..toString),rR=Db([].pop),iR=Db([].push),nR=Db("".replace),aR=Db([].shift),sR=Db("".split),oR=Db("".slice),lR=Db("".toLowerCase),uR=Db([].unshift),cR="Invalid scheme",hR="Invalid host",dR="Invalid port",fR=/[a-z]/i,vR=/[\d+-.a-z]/i,gR=/\d/,pR=/^0x/i,mR=/^[0-7]+$/,yR=/^\d+$/,ER=/^[\da-f]+$/i,kR=/[\0\t\n\r #%/:<>?@[\\\]^|]/,TR=/[\0\t\n\r #/:<>?@[\\\]^|]/,SR=/^[\u0000-\u0020]+/,AR=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,LR=/[\t\n\r]/g,bR=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)uR(t,e%256),e=Qb(e/256);return eR(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,n=0,a=0;a<8;a++)0!==e[a]?(n>r&&(t=i,r=n),i=null,n=0):(null===i&&(i=a),++n);return n>r&&(t=i,r=n),t}(e),r=0;r<8;r++)n&&0===e[r]||(n&&(n=!1),i===r?(t+=r?":":"::",n=!0):(t+=tR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},RR={},IR=xb({},RR,{" ":1,'"':1,"<":1,">":1,"`":1}),DR=xb({},IR,{"#":1,"?":1,"{":1,"}":1}),_R=xb({},DR,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),wR=function(e,t){var r=Fb(e,0);return r>32&&r<127&&!Pb(t,e)?e:encodeURIComponent(e)},CR={ftp:21,file:null,http:80,https:443,ws:80,wss:443},PR=function(e,t){var r;return 2==e.length&&Zb(fR,Jb(e,0))&&(":"==(r=Jb(e,1))||!t&&"|"==r)},xR=function(e){var t;return e.length>1&&PR(oR(e,0,2))&&(2==e.length||"/"===(t=Jb(e,2))||"\\"===t||"?"===t||"#"===t)},MR=function(e){return"."===e||"%2e"===lR(e)},OR={},FR={},NR={},UR={},BR={},GR={},KR={},HR={},VR={},jR={},YR={},qR={},WR={},zR={},XR={},QR={},$R={},JR={},ZR={},eI={},tI={},rI=function(e,t,r){var i,n,a,s=Ub(e);if(t){if(n=this.parse(s))throw zb(n);this.searchParams=null}else{if(void 0!==r&&(i=new rI(r,!0)),n=this.parse(s,null,i))throw zb(n);(a=qb(new Yb)).bindURL(this),this.searchParams=a}};rI.prototype={type:"URL",parse:function(e,t,r){var i,n,a,s,o,l=this,u=t||OR,c=0,h="",d=!1,f=!1,v=!1;for(e=Ub(e),t||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,e=nR(e,SR,""),e=nR(e,AR,"$1")),e=nR(e,LR,""),i=Mb(e);c<=i.length;){switch(n=i[c],u){case OR:if(!n||!Zb(fR,n)){if(t)return cR;u=NR;continue}h+=lR(n),u=FR;break;case FR:if(n&&(Zb(vR,n)||"+"==n||"-"==n||"."==n))h+=lR(n);else{if(":"!=n){if(t)return cR;h="",u=NR,c=0;continue}if(t&&(l.isSpecial()!=Pb(CR,h)||"file"==h&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=h,t)return void(l.isSpecial()&&CR[l.scheme]==l.port&&(l.port=null));h="","file"==l.scheme?u=zR:l.isSpecial()&&r&&r.scheme==l.scheme?u=UR:l.isSpecial()?u=HR:"/"==i[c+1]?(u=BR,c++):(l.cannotBeABaseURL=!0,iR(l.path,""),u=ZR)}break;case NR:if(!r||r.cannotBeABaseURL&&"#"!=n)return cR;if(r.cannotBeABaseURL&&"#"==n){l.scheme=r.scheme,l.path=Ob(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,u=tI;break}u="file"==r.scheme?zR:GR;continue;case UR:if("/"!=n||"/"!=i[c+1]){u=GR;continue}u=VR,c++;break;case BR:if("/"==n){u=jR;break}u=JR;continue;case GR:if(l.scheme=r.scheme,n==Sb)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Ob(r.path),l.query=r.query;else if("/"==n||"\\"==n&&l.isSpecial())u=KR;else if("?"==n)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Ob(r.path),l.query="",u=eI;else{if("#"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Ob(r.path),l.path.length--,u=JR;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Ob(r.path),l.query=r.query,l.fragment="",u=tI}break;case KR:if(!l.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,u=JR;continue}u=jR}else u=VR;break;case HR:if(u=VR,"/"!=n||"/"!=Jb(h,c+1))continue;c++;break;case VR:if("/"!=n&&"\\"!=n){u=jR;continue}break;case jR:if("@"==n){d&&(h="%40"+h),d=!0,a=Mb(h);for(var g=0;g<a.length;g++){var p=a[g];if(":"!=p||v){var m=wR(p,_R);v?l.password+=m:l.username+=m}else v=!0}h=""}else if(n==Sb||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(d&&""==h)return"Invalid authority";c-=Mb(h).length+1,h="",u=YR}else h+=n;break;case YR:case qR:if(t&&"file"==l.scheme){u=QR;continue}if(":"!=n||f){if(n==Sb||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(l.isSpecial()&&""==h)return hR;if(t&&""==h&&(l.includesCredentials()||null!==l.port))return;if(s=l.parseHost(h))return s;if(h="",u=$R,t)return;continue}"["==n?f=!0:"]"==n&&(f=!1),h+=n}else{if(""==h)return hR;if(s=l.parseHost(h))return s;if(h="",u=WR,t==qR)return}break;case WR:if(!Zb(gR,n)){if(n==Sb||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()||t){if(""!=h){var y=Xb(h,10);if(y>65535)return dR;l.port=l.isSpecial()&&y===CR[l.scheme]?null:y,h=""}if(t)return;u=$R;continue}return dR}h+=n;break;case zR:if(l.scheme="file","/"==n||"\\"==n)u=XR;else{if(!r||"file"!=r.scheme){u=JR;continue}if(n==Sb)l.host=r.host,l.path=Ob(r.path),l.query=r.query;else if("?"==n)l.host=r.host,l.path=Ob(r.path),l.query="",u=eI;else{if("#"!=n){xR(eR(Ob(i,c),""))||(l.host=r.host,l.path=Ob(r.path),l.shortenPath()),u=JR;continue}l.host=r.host,l.path=Ob(r.path),l.query=r.query,l.fragment="",u=tI}}break;case XR:if("/"==n||"\\"==n){u=QR;break}r&&"file"==r.scheme&&!xR(eR(Ob(i,c),""))&&(PR(r.path[0],!0)?iR(l.path,r.path[0]):l.host=r.host),u=JR;continue;case QR:if(n==Sb||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&PR(h))u=JR;else if(""==h){if(l.host="",t)return;u=$R}else{if(s=l.parseHost(h))return s;if("localhost"==l.host&&(l.host=""),t)return;h="",u=$R}continue}h+=n;break;case $R:if(l.isSpecial()){if(u=JR,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=Sb&&(u=JR,"/"!=n))continue}else l.fragment="",u=tI;else l.query="",u=eI;break;case JR:if(n==Sb||"/"==n||"\\"==n&&l.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(o=lR(o=h))||"%2e."===o||".%2e"===o||"%2e%2e"===o?(l.shortenPath(),"/"==n||"\\"==n&&l.isSpecial()||iR(l.path,"")):MR(h)?"/"==n||"\\"==n&&l.isSpecial()||iR(l.path,""):("file"==l.scheme&&!l.path.length&&PR(h)&&(l.host&&(l.host=""),h=Jb(h,0)+":"),iR(l.path,h)),h="","file"==l.scheme&&(n==Sb||"?"==n||"#"==n))for(;l.path.length>1&&""===l.path[0];)aR(l.path);"?"==n?(l.query="",u=eI):"#"==n&&(l.fragment="",u=tI)}else h+=wR(n,DR);break;case ZR:"?"==n?(l.query="",u=eI):"#"==n?(l.fragment="",u=tI):n!=Sb&&(l.path[0]+=wR(n,RR));break;case eI:t||"#"!=n?n!=Sb&&("'"==n&&l.isSpecial()?l.query+="%27":l.query+="#"==n?"%23":wR(n,RR)):(l.fragment="",u=tI);break;case tI:n!=Sb&&(l.fragment+=wR(n,IR))}c++}},parseHost:function(e){var t,r,i;if("["==Jb(e,0)){if("]"!=Jb(e,e.length-1))return hR;if(t=function(e){var t,r,i,n,a,s,o,l=[0,0,0,0,0,0,0,0],u=0,c=null,h=0,d=function(){return Jb(e,h)};if(":"==d()){if(":"!=Jb(e,1))return;h+=2,c=++u}for(;d();){if(8==u)return;if(":"!=d()){for(t=r=0;r<4&&Zb(ER,d());)t=16*t+Xb(d(),16),h++,r++;if("."==d()){if(0==r)return;if(h-=r,u>6)return;for(i=0;d();){if(n=null,i>0){if(!("."==d()&&i<4))return;h++}if(!Zb(gR,d()))return;for(;Zb(gR,d());){if(a=Xb(d(),10),null===n)n=a;else{if(0==n)return;n=10*n+a}if(n>255)return;h++}l[u]=256*l[u]+n,2!=++i&&4!=i||u++}if(4!=i)return;break}if(":"==d()){if(h++,!d())return}else if(d())return;l[u++]=t}else{if(null!==c)return;h++,c=++u}}if(null!==c)for(s=u-c,u=7;0!=u&&s>0;)o=l[u],l[u--]=l[c+s-1],l[c+--s]=o;else if(8!=u)return;return l}(oR(e,1,-1)),!t)return hR;this.host=t}else if(this.isSpecial()){if(e=Nb(e),Zb(kR,e))return hR;if(t=function(e){var t,r,i,n,a,s,o,l=sR(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(r=[],i=0;i<t;i++){if(""==(n=l[i]))return e;if(a=10,n.length>1&&"0"==Jb(n,0)&&(a=Zb(pR,n)?16:8,n=oR(n,8==a?1:2)),""===n)s=0;else{if(!Zb(10==a?yR:8==a?mR:ER,n))return e;s=Xb(n,a)}iR(r,s)}for(i=0;i<t;i++)if(s=r[i],i==t-1){if(s>=$b(256,5-t))return null}else if(s>255)return null;for(o=rR(r),i=0;i<r.length;i++)o+=r[i]*$b(256,3-i);return o}(e),null===t)return hR;this.host=t}else{if(Zb(TR,e))return hR;for(t="",r=Mb(e),i=0;i<r.length;i++)t+=wR(r[i],RR);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return Pb(CR,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&PR(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,i=e.password,n=e.host,a=e.port,s=e.path,o=e.query,l=e.fragment,u=t+":";return null!==n?(u+="//",e.includesCredentials()&&(u+=r+(i?":"+i:"")+"@"),u+=bR(n),null!==a&&(u+=":"+a)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?s[0]:s.length?"/"+eR(s,"/"):"",null!==o&&(u+="?"+o),null!==l&&(u+="#"+l),u},setHref:function(e){var t=this.parse(e);if(t)throw zb(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new iI(e.path[0]).origin}catch($V){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+bR(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Ub(e)+":",OR)},getUsername:function(){return this.username},setUsername:function(e){var t=Mb(Ub(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=wR(t[r],_R)}},getPassword:function(){return this.password},setPassword:function(e){var t=Mb(Ub(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=wR(t[r],_R)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?bR(e):bR(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,YR)},getHostname:function(){var e=this.host;return null===e?"":bR(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,qR)},getPort:function(){var e=this.port;return null===e?"":Ub(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=Ub(e))?this.port=null:this.parse(e,WR))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+eR(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,$R))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=Ub(e))?this.query=null:("?"==Jb(e,0)&&(e=oR(e,1)),this.query="",this.parse(e,eI)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=Ub(e))?("#"==Jb(e,0)&&(e=oR(e,1)),this.fragment="",this.parse(e,tI)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var iI=function(e){var t=Cb(this,nI),r=Gb(arguments.length,1)>1?arguments[1]:void 0,i=Vb(t,new rI(e,!1,r));Lb||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},nI=iI.prototype,aI=function(e,t){return{get:function(){return jb(this)[e]()},set:t&&function(e){return jb(this)[t](e)},configurable:!0,enumerable:!0}};if(Lb&&(wb(nI,"href",aI("serialize","setHref")),wb(nI,"origin",aI("getOrigin")),wb(nI,"protocol",aI("getProtocol","setProtocol")),wb(nI,"username",aI("getUsername","setUsername")),wb(nI,"password",aI("getPassword","setPassword")),wb(nI,"host",aI("getHost","setHost")),wb(nI,"hostname",aI("getHostname","setHostname")),wb(nI,"port",aI("getPort","setPort")),wb(nI,"pathname",aI("getPathname","setPathname")),wb(nI,"search",aI("getSearch","setSearch")),wb(nI,"searchParams",aI("getSearchParams")),wb(nI,"hash",aI("getHash","setHash"))),_b(nI,"toJSON",(function(){return jb(this).serialize()}),{enumerable:!0}),_b(nI,"toString",(function(){return jb(this).serialize()}),{enumerable:!0}),Wb){var sI=Wb.createObjectURL,oI=Wb.revokeObjectURL;sI&&_b(iI,"createObjectURL",Ib(sI,Wb)),oI&&_b(iI,"revokeObjectURL",Ib(oI,Wb))}Bb(iI,"URL"),Ab({global:!0,constructor:!0,forced:!bb,sham:!Lb},{URL:iI});var lI=wr,uI=o,cI=wf,hI=tn,dI=KA,fI=le("URL");lI({target:"URL",stat:!0,forced:!(dI&&uI((function(){fI.canParse()})))},{canParse:function(e){var t=cI(arguments.length,1),r=hI(e),i=t<2||void 0===arguments[1]?void 0:hI(arguments[1]);try{return!!new fI(r,i)}catch($V){return!1}}});var vI=i(ie.URL),gI=ie,pI=f;gI.JSON||(gI.JSON={stringify:JSON.stringify});var mI=function(e,t,r){return pI(gI.JSON.stringify,null,arguments)},yI=i(mI),EI=re,kI=S,TI=vt("match"),SI=function(e){var t;return EI(e)&&(void 0!==(t=e[TI])?!!t:"RegExp"==kI(e))},AI=TypeError,LI=function(e){if(SI(e))throw AI("The method doesn't accept regular expressions");return e},bI=vt("match"),RI=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[bI]=!1,"/./"[e](t)}catch(i){}}return!1},II=wr,DI=b;w.f;var _I=qr,wI=tn,CI=LI,PI=Q,xI=RI,MI=DI("".startsWith),OI=DI("".slice),FI=Math.min;II({target:"String",proto:!0,forced:!xI("startsWith")},{startsWith:function(e){var t=wI(PI(this));CI(e);var r=_I(FI(arguments.length>1?arguments[1]:void 0,t.length)),i=wI(e);return MI?MI(t,i,r):OI(t,r,r+i.length)===i}});var NI=nh("String").startsWith,UI=ue,BI=NI,GI=String.prototype,KI=i((function(e){var t=e.startsWith;return"string"==typeof e||e===GI||UI(GI,e)&&t===GI.startsWith?BI:t})),HI=re,VI=Math.floor,jI=Number.isInteger||function(e){return!HI(e)&&isFinite(e)&&VI(e)===e};wr({target:"Number",stat:!0},{isInteger:jI});var YI=i(ie.Number.isInteger),qI=dn.includes;wr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return qI(this,e,arguments.length>1?arguments[1]:void 0)}});var WI=nh("Array").includes,zI=wr,XI=LI,QI=Q,$I=tn,JI=RI,ZI=y("".indexOf);zI({target:"String",proto:!0,forced:!JI("includes")},{includes:function(e){return!!~ZI($I(QI(this)),$I(XI(e)),arguments.length>1?arguments[1]:void 0)}});var eD=nh("String").includes,tD=ue,rD=WI,iD=eD,nD=Array.prototype,aD=String.prototype,sD=i((function(e){var t=e.includes;return e===nD||tD(nD,e)&&t===nD.includes?rD:"string"==typeof e||e===aD||tD(aD,e)&&t===aD.includes?iD:t}));function oD(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function lD(e,t){var r;if(e){if("string"==typeof e)return oD(e,t);var i=Ov(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?AT(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?oD(e,t):void 0}}function uD(e){return function(e){if(Ck(e))return oD(e)}(e)||function(e){if(void 0!==hc&&null!=aT(e)||null!=e["@@iterator"])return AT(e)}(e)||lD(e)||function(){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 cD(e,t){return function(e){if(Ck(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==hc&&aT(e)||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(rf(o).call(o,i.value),o.length!==t);l=!0);}catch(c){u=!0,n=c}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return o}}(e,t)||lD(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var hD={exports:{}},dD=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),fD=o,vD=re,gD=S,pD=dD,mD=Object.isExtensible,yD=fD((function(){mD(1)}))||pD?function(e){return!!vD(e)&&((!pD||"ArrayBuffer"!=gD(e))&&(!mD||mD(e)))}:mD,ED=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),kD=wr,TD=y,SD=fn,AD=re,LD=et,bD=Zt.f,RD=Xn,ID=Jn,DD=yD,_D=ED,wD=!1,CD=at("meta"),PD=0,xD=function(e){bD(e,CD,{value:{objectID:"O"+PD++,weakData:{}}})},MD=hD.exports={enable:function(){MD.enable=function(){},wD=!0;var e=RD.f,t=TD([].splice),r={};r[CD]=1,e(r).length&&(RD.f=function(r){for(var i=e(r),n=0,a=i.length;n<a;n++)if(i[n]===CD){t(i,n,1);break}return i},kD({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:ID.f}))},fastKey:function(e,t){if(!AD(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!LD(e,CD)){if(!DD(e))return"F";if(!t)return"E";xD(e)}return e[CD].objectID},getWeakData:function(e,t){if(!LD(e,CD)){if(!DD(e))return!0;if(!t)return!1;xD(e)}return e[CD].weakData},onFreeze:function(e){return _D&&wD&&DD(e)&&!LD(e,CD)&&xD(e),e}};SD[CD]=!0;var OD=hD.exports,FD=wr,ND=s,UD=OD,BD=o,GD=yr,KD=tp,HD=Pp,VD=_,jD=re,YD=Ua,qD=Zt.f,WD=ls.forEach,zD=C,XD=es.set,QD=es.getterFor,$D=function(e,t,r){var i,n=-1!==e.indexOf("Map"),a=-1!==e.indexOf("Weak"),s=n?"set":"add",o=ND[e],l=o&&o.prototype,u={};if(zD&&VD(o)&&(a||l.forEach&&!BD((function(){(new o).entries().next()})))){var c=(i=t((function(t,r){XD(HD(t,c),{type:e,collection:new o}),null!=r&&KD(r,t[s],{that:t,AS_ENTRIES:n})}))).prototype,h=QD(e);WD(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in l)||a&&"clear"==e||GD(c,e,(function(r,i){var n=h(this).collection;if(!t&&a&&!jD(r))return"get"==e&&void 0;var s=n[e](0===r?0:r,i);return t?this:s}))})),a||qD(c,"size",{configurable:!0,get:function(){return h(this).collection.size}})}else i=r.getConstructor(t,e,n,s),UD.enable();return YD(i,e,!1,!0),u[e]=i,FD({global:!0,forced:!0},u),a||r.setStrong(i,e,n),i},JD=zn,ZD=va,e_=oL,t_=Jt,r_=Pp,i_=W,n_=tp,a_=Au,s_=Lu,o_=_p,l_=C,u_=OD.fastKey,c_=es.set,h_=es.getterFor,d_={getConstructor:function(e,t,r,i){var n=e((function(e,n){r_(e,a),c_(e,{type:t,index:JD(null),first:void 0,last:void 0,size:0}),l_||(e.size=0),i_(n)||n_(n,e[i],{that:e,AS_ENTRIES:r})})),a=n.prototype,s=h_(t),o=function(e,t,r){var i,n,a=s(e),o=l(e,t);return o?o.value=r:(a.last=o={index:n=u_(t,!0),key:t,value:r,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=o),i&&(i.next=o),l_?a.size++:e.size++,"F"!==n&&(a.index[n]=o)),e},l=function(e,t){var r,i=s(e),n=u_(t);if("F"!==n)return i.index[n];for(r=i.first;r;r=r.next)if(r.key==t)return r};return e_(a,{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,l_?e.size=0:this.size=0},delete:function(e){var t=this,r=s(t),i=l(t,e);if(i){var n=i.next,a=i.previous;delete r.index[i.index],i.removed=!0,a&&(a.next=n),n&&(n.previous=a),r.first==i&&(r.first=n),r.last==i&&(r.last=a),l_?r.size--:t.size--}return!!i},forEach:function(e){for(var t,r=s(this),i=t_(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(i(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!l(this,e)}}),e_(a,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)}}),l_&&ZD(a,"size",{configurable:!0,get:function(){return s(this).size}}),n},setStrong:function(e,t,r){var i=t+" Iterator",n=h_(t),a=h_(i);a_(e,t,(function(e,t){c_(this,{type:i,target:e,state:n(e),kind:t,last:void 0})}),(function(){for(var e=a(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)?s_("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,s_(void 0,!0))}),r?"entries":"values",!r,!0),o_(t)}};$D("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),d_);var f_=ie.Map,v_=Jt,g_=M,p_=xe,m_=Fh,y_=W,E_=tp,k_=[].push,T_=function(e){var t,r,i,n,a=arguments.length,s=a>1?arguments[1]:void 0;return m_(this),(t=void 0!==s)&&p_(s),y_(e)?new this:(r=[],t?(i=0,n=v_(s,a>2?arguments[2]:void 0),E_(e,(function(e){g_(k_,r,n(e,i++))}))):E_(e,k_,{that:r}),new this(r))};wr({target:"Map",stat:!0,forced:!0},{from:T_});var S_=xo,A_=function(){return new this(S_(arguments))};wr({target:"Map",stat:!0,forced:!0},{of:A_});var L_=_e,b_=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(L_(e)+" is not a map")},R_=function(e,t){return 1==t?function(t,r){return t[e](r)}:function(t,r,i){return t[e](r,i)}},I_=R_,D_=le("Map"),__={Map:D_,set:I_("set",2),get:I_("get",1),has:I_("has",1),remove:I_("delete",1),proto:D_.prototype},w_=b_,C_=__.remove;wr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=w_(this),r=!0,i=0,n=arguments.length;i<n;i++)e=C_(t,arguments[i]),r=r&&e;return!!r}});var P_=b_,x_=__.get,M_=__.has,O_=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,i,n=P_(this);return M_(n,e)?(r=x_(n,e),"update"in t&&(r=t.update(r,e,n),O_(n,e,r)),r):(i=t.insert(e,n),O_(n,e,i),i)}});var F_=M,N_=function(e,t,r){for(var i,n,a=r||e.next;!(i=F_(a,e)).done;)if(void 0!==(n=t(i.value)))return n},U_=N_,B_=function(e,t,r){return r?U_(e.entries(),(function(e){return t(e[1],e[0])})):e.forEach(t)},G_=Jt,K_=b_,H_=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=K_(this),r=G_(e,arguments.length>1?arguments[1]:void 0);return!1!==H_(t,(function(e,i){if(!r(e,i,t))return!1}),!0)}});var V_=Jt,j_=b_,Y_=B_,q_=__.Map,W_=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=j_(this),r=V_(e,arguments.length>1?arguments[1]:void 0),i=new q_;return Y_(t,(function(e,n){r(e,n,t)&&W_(i,n,e)})),i}});var z_=Jt,X_=b_,Q_=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=X_(this),r=z_(e,arguments.length>1?arguments[1]:void 0),i=Q_(t,(function(e,i){if(r(e,i,t))return{value:e}}),!0);return i&&i.value}});var $_=Jt,J_=b_,Z_=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=J_(this),r=$_(e,arguments.length>1?arguments[1]:void 0),i=Z_(t,(function(e,i){if(r(e,i,t))return{key:i}}),!0);return i&&i.key}});var ew=wr,tw=M,rw=_,iw=xe,nw=tp,aw=__.Map,sw=y([].push);ew({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){var r=new(rw(this)?this:aw);iw(t);var i=iw(r.has),n=iw(r.get),a=iw(r.set);return nw(e,(function(e){var s=t(e);tw(i,r,s)?sw(tw(n,r,s),e):tw(a,r,s,[e])})),r}});var ow=function(e,t){return e===t||e!=e&&t!=t},lw=b_,uw=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===uw(lw(this),(function(t){if(ow(t,e))return!0}),!0)}});var cw=M,hw=tp,dw=_,fw=xe,vw=__.Map;wr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(dw(this)?this:vw);fw(t);var i=fw(r.set);return hw(e,(function(e){cw(i,r,t(e),e)})),r}});var gw=b_,pw=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=pw(gw(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var mw=Jt,yw=b_,Ew=B_,kw=__.Map,Tw=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=yw(this),r=mw(e,arguments.length>1?arguments[1]:void 0),i=new kw;return Ew(t,(function(e,n){Tw(i,r(e,n,t),e)})),i}});var Sw=Jt,Aw=b_,Lw=B_,bw=__.Map,Rw=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=Aw(this),r=Sw(e,arguments.length>1?arguments[1]:void 0),i=new bw;return Lw(t,(function(e,n){Rw(i,n,r(e,n,t))})),i}});var Iw=b_,Dw=tp,_w=__.set;wr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=Iw(this),r=arguments.length,i=0;i<r;)Dw(arguments[i++],(function(e,r){_w(t,e,r)}),{AS_ENTRIES:!0});return t}});var ww=xe,Cw=b_,Pw=B_,xw=TypeError;wr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Cw(this),r=arguments.length<2,i=r?void 0:arguments[1];if(ww(e),Pw(t,(function(n,a){r?(r=!1,i=n):i=e(i,n,a,t)})),r)throw xw("Reduce of empty map with no initial value");return i}});var Mw=Jt,Ow=b_,Fw=B_;wr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=Ow(this),r=Mw(e,arguments.length>1?arguments[1]:void 0);return!0===Fw(t,(function(e,i){if(r(e,i,t))return!0}),!0)}});var Nw=xe,Uw=b_,Bw=TypeError,Gw=__.get,Kw=__.has,Hw=__.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=Uw(this),i=arguments.length;Nw(t);var n=Kw(r,e);if(!n&&i<3)throw Bw("Updating absent value");var a=n?Gw(r,e):Nw(i>2?arguments[2]:void 0)(e,r);return Hw(r,e,t(a,e,r)),r}});var Vw=M,jw=xe,Yw=_,qw=nr,Ww=TypeError,zw=function(e,t){var r,i=qw(this),n=jw(i.get),a=jw(i.has),s=jw(i.set),o=arguments.length>2?arguments[2]:void 0;if(!Yw(t)&&!Yw(o))throw Ww("At least one callback required");return Vw(a,i,e)?(r=Vw(n,i,e),Yw(t)&&(r=t(r),Vw(s,i,e,r))):Yw(o)&&(r=o(),Vw(s,i,e,r)),r};wr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:zw}),wr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:zw});var Xw=f_,Qw=i(Xw);function $w(e,t,r){var i;Jh()?$w=ch(i=$h).call(i):$w=function(e,t,r){var i=[null];rf(i).apply(i,t);var n=new(ch(Function).apply(e,i));return r&&Ch(n,r.prototype),n};return $w.apply(null,arguments)}function Jw(e){var t="function"==typeof Qw?new Qw:void 0;return Jw=function(e){if(null===e||(r=e,-1===nv(i=Function.toString.call(r)).call(i,"[native code]")))return e;var r,i;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,n)}function n(){return $w(e,arguments,Rh(this).constructor)}return n.prototype=wh(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ch(n,e)},Jw(e)}var Zw=s.isFinite;wr({target:"Number",stat:!0},{isFinite:Number.isFinite||function(e){return"number"==typeof e&&Zw(e)}});var eC=i(ie.Number.isFinite),tC=wr,rC=jI,iC=Math.abs;tC({target:"Number",stat:!0},{isSafeInteger:function(e){return rC(e)&&iC(e)<=9007199254740991}});var nC=i(ie.Number.isSafeInteger);wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var aC=i(9007199254740991),sC=xe,oC=$e,lC=q,uC=zr,cC=TypeError,hC=function(e){return function(t,r,i,n){sC(r);var a=oC(t),s=lC(a),o=uC(a),l=e?o-1:0,u=e?-1:1;if(i<2)for(;;){if(l in s){n=s[l],l+=u;break}if(l+=u,e?l<0:o<=l)throw cC("Reduce of empty array with no initial value")}for(;e?l>=0:o>l;l+=u)l in s&&(n=r(n,s[l],l,a));return n}},dC={left:hC(!1),right:hC(!0)}.left;wr({target:"Array",proto:!0,forced:!Lp&&me>79&&me<83||!rd("reduce")},{reduce:function(e){var t=arguments.length;return dC(this,e,t,t>1?arguments[1]:void 0)}});var fC=nh("Array").reduce,vC=ue,gC=fC,pC=Array.prototype,mC=i((function(e){var t=e.reduce;return e===pC||vC(pC,e)&&t===pC.reduce?gC:t})),yC=nr,EC=M,kC=et,TC=ue,SC=function(){var e=yC(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},AC=RegExp.prototype,LC=ue,bC=function(e){var t=e.flags;return void 0!==t||"flags"in AC||kC(e,"flags")||!TC(AC,e)?t:EC(SC,e)},RC=RegExp.prototype,IC=i((function(e){return e===RC||LC(RC,e)?bC(e):e.flags})),DC=f,_C=Z,wC=Vr,CC=zr,PC=rd,xC=Math.min,MC=[].lastIndexOf,OC=!!MC&&1/[1].lastIndexOf(1,-0)<0,FC=PC("lastIndexOf"),NC=OC||!FC?function(e){if(OC)return DC(MC,this,arguments)||0;var t=_C(this),r=CC(t),i=r-1;for(arguments.length>1&&(i=xC(i,wC(arguments[1]))),i<0&&(i=r+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:MC;wr({target:"Array",proto:!0,forced:NC!==[].lastIndexOf},{lastIndexOf:NC});var UC=nh("Array").lastIndexOf,BC=ue,GC=UC,KC=Array.prototype,HC=i((function(e){var t=e.lastIndexOf;return e===KC||BC(KC,e)&&t===KC.lastIndexOf?GC:t})),VC=wr,jC=Br,YC=y([].reverse),qC=[1,2];VC({target:"Array",proto:!0,forced:String(qC)===String(qC.reverse())},{reverse:function(){return jC(this)&&(this.length=this.length),YC(this)}});var WC=nh("Array").reverse,zC=ue,XC=WC,QC=Array.prototype,$C=i((function(e){var t=e.reverse;return e===QC||zC(QC,e)&&t===QC.reverse?XC:t}));wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var JC=i(Math.pow(2,-52)),ZC=i(Xw);$D("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),d_);var eP=ie.Set,tP=_e,rP=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(tP(e)+" is not a set")},iP=R_,nP=le("Set"),aP=nP.prototype,sP={Set:nP,add:iP("add",1),has:iP("has",1),remove:iP("delete",1),proto:aP},oP=N_,lP=function(e,t,r){return r?oP(e.keys(),t):e.forEach(t)},uP=lP,cP=sP.Set,hP=sP.add,dP=function(e){var t=new cP;return uP(e,(function(e){hP(t,e)})),t},fP=function(e){return e.size},vP=xe,gP=nr,pP=M,mP=Vr,yP=TypeError,EP=Math.max,kP=function(e,t,r,i){this.set=e,this.size=t,this.has=r,this.keys=i};kP.prototype={getIterator:function(){return gP(pP(this.keys,this.set))},includes:function(e){return pP(this.has,this.set,e)}};var TP=function(e){gP(e);var t=+e.size;if(t!=t)throw yP("Invalid size");return new kP(e,EP(mP(t),0),vP(e.has),vP(e.keys))},SP=rP,AP=dP,LP=fP,bP=TP,RP=lP,IP=N_,DP=sP.has,_P=sP.remove,wP=function(e){var t=SP(this),r=bP(e),i=AP(t);return LP(t)<=r.size?RP(t,(function(e){r.includes(e)&&_P(i,e)})):IP(r.getIterator(),(function(e){DP(t,e)&&_P(i,e)})),i},CP=function(){return!1},PP=wP;wr({target:"Set",proto:!0,real:!0,forced:!CP()},{difference:PP});var xP=rP,MP=fP,OP=TP,FP=lP,NP=N_,UP=sP.Set,BP=sP.add,GP=sP.has,KP=function(e){var t=xP(this),r=OP(e),i=new UP;return MP(t)>r.size?NP(r.getIterator(),(function(e){GP(t,e)&&BP(i,e)})):FP(t,(function(e){r.includes(e)&&BP(i,e)})),i},HP=KP;wr({target:"Set",proto:!0,real:!0,forced:!CP()},{intersection:HP});var VP=rP,jP=sP.has,YP=fP,qP=TP,WP=lP,zP=N_,XP=Kg,QP=function(e){var t=VP(this),r=qP(e);if(YP(t)<=r.size)return!1!==WP(t,(function(e){if(r.includes(e))return!1}),!0);var i=r.getIterator();return!1!==zP(i,(function(e){if(jP(t,e))return XP(i,"normal",!1)}))},$P=QP;wr({target:"Set",proto:!0,real:!0,forced:!CP()},{isDisjointFrom:$P});var JP=rP,ZP=fP,ex=lP,tx=TP,rx=function(e){var t=JP(this),r=tx(e);return!(ZP(t)>r.size)&&!1!==ex(t,(function(e){if(!r.includes(e))return!1}),!0)},ix=rx;wr({target:"Set",proto:!0,real:!0,forced:!CP()},{isSubsetOf:ix});var nx=rP,ax=sP.has,sx=fP,ox=TP,lx=N_,ux=Kg,cx=function(e){var t=nx(this),r=ox(e);if(sx(t)<r.size)return!1;var i=r.getIterator();return!1!==lx(i,(function(e){if(!ax(t,e))return ux(i,"normal",!1)}))},hx=cx;wr({target:"Set",proto:!0,real:!0,forced:!CP()},{isSupersetOf:hx});var dx=rP,fx=dP,vx=TP,gx=N_,px=sP.add,mx=sP.has,yx=sP.remove,Ex=function(e){var t=dx(this),r=vx(e).getIterator(),i=fx(t);return gx(r,(function(e){mx(t,e)?yx(i,e):px(i,e)})),i},kx=Ex;wr({target:"Set",proto:!0,real:!0,forced:!CP()},{symmetricDifference:kx});var Tx=rP,Sx=sP.add,Ax=dP,Lx=TP,bx=N_,Rx=function(e){var t=Tx(this),r=Lx(e).getIterator(),i=Ax(t);return bx(r,(function(e){Sx(i,e)})),i},Ix=Rx;wr({target:"Set",proto:!0,real:!0,forced:!CP()},{union:Ix});var Dx=eP;wr({target:"Set",stat:!0,forced:!0},{from:T_}),wr({target:"Set",stat:!0,forced:!0},{of:A_});var _x=rP,wx=sP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=_x(this),t=0,r=arguments.length;t<r;t++)wx(e,arguments[t]);return e}});var Cx=rP,Px=sP.remove;wr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=Cx(this),r=!0,i=0,n=arguments.length;i<n;i++)e=Px(t,arguments[i]),r=r&&e;return!!r}});var xx=Jt,Mx=rP,Ox=lP;wr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=Mx(this),r=xx(e,arguments.length>1?arguments[1]:void 0);return!1!==Ox(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var Fx=ui,Nx=et,Ux=W,Bx=El,Gx=vt("iterator"),Kx=Object,Hx=_,Vx=function(e){if(Ux(e))return!1;var t=Kx(e);return void 0!==t[Gx]||"@@iterator"in t||Nx(Bx,Fx(t))},jx=re,Yx=le("Set"),qx=function(e){return function(e){return jx(e)&&"number"==typeof e.size&&Hx(e.has)&&Hx(e.keys)}(e)?e:Vx(e)?new Yx(e):e},Wx=M,zx=qx,Xx=wP;wr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return Wx(Xx,this,zx(e))}});var Qx=Jt,$x=rP,Jx=lP,Zx=sP.Set,eM=sP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=$x(this),r=Qx(e,arguments.length>1?arguments[1]:void 0),i=new Zx;return Jx(t,(function(e){r(e,e,t)&&eM(i,e)})),i}});var tM=Jt,rM=rP,iM=lP;wr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=rM(this),r=tM(e,arguments.length>1?arguments[1]:void 0),i=iM(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return i&&i.value}});var nM=M,aM=qx,sM=KP;wr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return nM(sM,this,aM(e))}});var oM=M,lM=qx,uM=QP;wr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return oM(uM,this,lM(e))}});var cM=M,hM=qx,dM=rx;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return cM(dM,this,hM(e))}});var fM=M,vM=qx,gM=cx;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return fM(gM,this,vM(e))}});var pM=wr,mM=y,yM=rP,EM=lP,kM=tn,TM=mM([].join),SM=mM([].push);pM({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=yM(this),r=void 0===e?",":kM(e),i=[];return EM(t,(function(e){SM(i,e)})),TM(i,r)}});var AM=Jt,LM=rP,bM=lP,RM=sP.Set,IM=sP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=LM(this),r=AM(e,arguments.length>1?arguments[1]:void 0),i=new RM;return bM(t,(function(e){IM(i,r(e,e,t))})),i}});var DM=xe,_M=rP,wM=lP,CM=TypeError;wr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=_M(this),r=arguments.length<2,i=r?void 0:arguments[1];if(DM(e),wM(t,(function(n){r?(r=!1,i=n):i=e(i,n,n,t)})),r)throw CM("Reduce of empty set with no initial value");return i}});var PM=Jt,xM=rP,MM=lP;wr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=xM(this),r=PM(e,arguments.length>1?arguments[1]:void 0);return!0===MM(t,(function(e){if(r(e,e,t))return!0}),!0)}});var OM=M,FM=qx,NM=Ex;wr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return OM(NM,this,FM(e))}});var UM=M,BM=qx,GM=Rx;wr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return UM(GM,this,BM(e))}});var KM=i(Dx),HM=Sd.entries;wr({target:"Object",stat:!0},{entries:function(e){return HM(e)}});var VM,jM=i(ie.Object.entries),YM=nh("Array").entries,qM=ui,WM=et,zM=ue,XM=YM,QM=Array.prototype,$M={DOMTokenList:!0,NodeList:!0},JM=i((function(e){var t=e.entries;return e===QM||zM(QM,e)&&t===QM.entries||WM($M,qM(e))?XM:t})),ZM=nh("Array").values,eO=ui,tO=et,rO=ue,iO=ZM,nO=Array.prototype,aO={DOMTokenList:!0,NodeList:!0},sO=i((function(e){var t=e.values;return e===nO||rO(nO,e)&&t===nO.values||tO(aO,eO(e))?iO:t})),oO=eC||function(e){return"number"==typeof e&&isFinite(e)},lO=nC||function(e){return"number"==typeof e&&Math.abs(e)<=uO},uO=aC||9007199254740991,cO=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}({}),hO=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}({}),dO=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}({}),fO="manifest",vO="level",gO="audioTrack",pO="subtitleTrack",mO="main",yO="audio",EO="subtitle",kO=function(){function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=r,this.alpha_=r?Math.exp(Math.log(.5)/r):0,this.estimate_=i,this.totalWeight_=n}return Fc(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}(),TO=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;t(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 kO(r),this.fast_=new kO(i),this.defaultTTFB_=a,this.ttfb_=new kO(r)}return Fc(e,[{key:"update",value:function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new kO(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new kO(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new kO(e,n.getEstimate(),n.getTotalWeight()))}},{key:"sample",value:function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}},{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 SO(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Cc(e)||!e)return e;var r=e[bT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Cc(t)?t:t+""}(t))in e?Zk(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function AO(){var e;return AO=zk?iT(e=zk).call(e):function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},AO.apply(null,arguments)}function LO(e,t){var r=gv(e);if(Xk){var i=Xk(e);t&&(i=xk(i).call(i,(function(t){return Qk(e,t).enumerable}))),r.push.apply(r,i)}return r}function bO(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=LO(Object(n),!0)).call(r,(function(t){SO(e,t,n[t])})):$k?Jk(e,$k(n)):vd(i=LO(Object(n))).call(i,(function(t){Zk(e,t,Qk(n,t))}))}return e}var RO=Fc((function e(r,i){var n,a,s,o,l;t(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 u="[".concat(r,"]:");this.trace=IO,this.debug=iT(n=i.debug).call(n,null,u),this.log=iT(a=i.log).call(a,null,u),this.warn=iT(s=i.warn).call(s,null,u),this.info=iT(o=i.info).call(o,null,u),this.error=iT(l=i.error).call(l,null,u)})),IO=function(){},DO={trace:IO,debug:IO,log:IO,warn:IO,info:IO,error:IO};function _O(){return AO({},DO)}function wO(e,t,r){var i;return t[e]?iT(i=t[e]).call(i,t):function(e,t){var r,i=self.console[e];return i?iT(i).call(i,self.console,_d(r="".concat(t?"["+t+"] ":"","[")).call(r,e,"] >")):IO}(e,r)}var CO=_O();var PO=CO;function xO(){if("undefined"!=typeof self)return(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function MO(e,t){var r=gv(e),i=gv(t),n=r.length,a=i.length;return!n||!a||n===a&&!KT(r).call(r,(function(e){return-1===av(i).call(i,e)}))}var OO={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 FO(e,t){var r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!KT(r=e.split(",")).call(r,(function(e){return!NO(e,t,i)}))}function NO(e,t){var r,i=xO(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);return null!=(r=null==i?void 0:i.isTypeSupported(UO(e,t)))&&r}function UO(e,t){var r;return _d(r="".concat(t,"/mp4;codecs=")).call(r,e)}function BO(e){if(e){var t=e.substring(0,4);return OO.video[t]}return 2}function GO(e){var t;return mC(t=e.split(",")).call(t,(function(e,t){var r=OO.video[t];return r?(2*r+e)/(e?3:2):(OO.audio[t]+e)/(e?2:1)}),0)}var KO={};var HO=/flac|opus|mp4a\.40\.34/i;function VO(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(HO,(function(e){return function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(KO[e])return KO[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],i=0;i<r.length;i++){var n;if(NO(r[i],"audio",t))return KO[e]=r[i],r[i];if("mp3"===r[i]&&null!=(n=xO(t))&&n.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)}))}function jO(e,t){var r;if(e&&(e.length>4||-1!==av(r=["ac-3","ec-3","alac","fLaC","Opus"]).call(r,e)))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function YO(e){if(KI(e).call(e,"av01.")){for(var t=e.split("."),r=["0","111","01","01","01","0"],i=t.length;i>4&&i<10;i++)t[i]=r[i-4];return t.join(".")}return e}function qO(e){var t=xO(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 WO={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},zO={};function XO(e,t,r){var i=e.videoCodec,n=e.audioCodec;if(!i&&!n||!r)return tk.resolve(WO);var a,s=[];if(i){var o,l={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},u=e.videoRange;"SDR"!==u&&(l.transferFunction=u.toLowerCase()),s.push.apply(s,_k(o=i.split(",")).call(o,(function(e){return{type:"media-source",video:bO(bO({},l),{},{contentType:UO(YO(e),"video")})}})))}n&&e.audioGroups&&vd(a=e.audioGroups).call(a,(function(e){var r,i;e&&(null==(i=t.groups[e])||vd(r=i.tracks).call(r,(function(t){if(t.groupId===e){var r,i=t.channels||"",a=bS(i);if(oO(a)&&a>2)s.push.apply(s,_k(r=n.split(",")).call(r,(function(e){return{type:"media-source",audio:{contentType:UO(e,"audio"),channels:""+a}}})))}})))}));return tk.all(_k(s).call(s,(function(e){var t=function(e){var t=e.audio,r=e.video,i=r||t;if(i){var n,a,s,o,l,u,c,h=i.contentType.split('"')[1];if(r)return _d(n=_d(a=_d(s=_d(o=_d(l="r".concat(r.height,"x")).call(l,r.width,"f")).call(o,Math.ceil(r.framerate))).call(s,r.transferFunction||"sd","_")).call(a,h,"_")).call(n,Math.ceil(r.bitrate/1e5));if(t)return _d(u=_d(c="c".concat(t.channels)).call(c,t.spatialRendering?"s":"n","_")).call(u,h)}return""}(e);return zO[t]||(zO[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!KT(e).call(e,(function(e){return!e.supported})),configurations:s,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}}))}var QO=["NONE","TYPE-0","TYPE-1",null];var $O=["SDR","PQ","HLG"];var JO="",ZO="YES",eF="v2";function tF(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?eF:ZO:JO}var rF=function(){function e(r,i,n){t(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=r,this.part=i,this.skip=n}return Fc(e,[{key:"addDirectives",value:function(e){var t=new vI(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}(),iF=function(){function e(r){var i,n;t(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=[r.url],this._attrs=[r.attrs],this.bitrate=r.bitrate,r.details&&(this.details=r.details),this.id=r.id||0,this.name=r.name,this.width=r.width||0,this.height=r.height||0,this.frameRate=r.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=r.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=r.audioCodec,this.videoCodec=r.videoCodec,this.codecSet=_k(i=xk(n=[r.videoCodec,r.audioCodec]).call(n,(function(e){return!!e}))).call(i,(function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",r.attrs.AUDIO),this.addGroupId("text",r.attrs.SUBTITLES)}return Fc(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 nF(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return nF(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===av(r).call(r,t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===av(i).call(i,t)&&i.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 nF(e,t){return!(!t||!e)&&-1!==av(e).call(e,t)}function aF(e,t){var r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){var n="SDR"!==(i=t.allowedVideoRanges||Fv($O).call($O,0)).join("")&&!t.videoCodec;(r=void 0!==t.preferHDR?t.preferHDR:n&&function(){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}())||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}function sF(e,t){var r;PO.log(_d(r='[abr] start candidates with "'.concat(e,'" ignored because ')).call(r,t))}function oF(e){return mC(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 i=t.channels||"2";return r.channels[i]=(r.channels[i]||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 lF(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function uF(e,t,r){if("attrs"in e){var i=av(t).call(t,e);if(-1!==i)return i}for(var n=0;n<t.length;n++){if(cF(e,t[n],r))return n}return-1}function cF(e,t,r){var i=e.groupId,n=e.name,a=e.lang,s=e.assocLang,o=e.characteristics,l=e.default,u=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===a||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--";if(e.length===t.length)return e===t;return KI(e).call(e,t)||KI(t).call(t,e)}(a,t.lang))&&(void 0===a||t.assocLang===s)&&(void 0===l||t.default===l)&&(void 0===u||t.forced===u)&&(void 0===o||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),i=t.split(",");return r.length===i.length&&!KT(r).call(r,(function(e){return-1===av(i).call(i,e)}))}(o,t.characteristics))&&(void 0===r||r(e,t))}function hF(e,t){var r=e.audioCodec,i=e.channels;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function dF(e,t,r){for(var i=t;i>-1;i--)if(r(e[i]))return i;for(var n=t+1;n<e.length;n++)if(r(e[n]))return n;return-1}function fF(e,t){var r;return!!e&&e!==(null==(r=t.levels[t.loadLevel])?void 0:r.uri)}var vF=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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,i,a,s,o,l,u,c,h,d,f=Zh(n),v=f.fragCurrent,g=f.partCurrent,p=f.hls,m=p.autoLevelEnabled,y=p.media;if(v&&y){var E=performance.now(),k=g?g.stats:v.stats,T=g?g.duration:v.duration,S=E-k.loading.start,A=p.minAutoLevel;if(k.aborted||k.loaded&&k.loaded===k.total||v.level<=A)return n.clearTimer(),void(n._nextAutoLevel=-1);if(m&&!y.paused&&y.playbackRate&&y.readyState){var L=p.mainForwardBufferInfo;if(null!==L){var b=n.bwEstimator.getEstimateTTFB(),R=Math.abs(y.playbackRate);if(!(S<=Math.max(b,T/(2*R)*1e3))){var I=L.len/R,D=k.loading.first?k.loading.first-k.loading.start:-1,_=k.loaded&&D>-1,w=n.getBwEstimate(),C=p.levels,P=C[v.level],x=Math.max(k.loaded,Math.round(T*(v.bitrate||P.averageBitrate)/8)),M=_?S-D:S;M<1&&_&&(M=Math.min(S,8*k.loaded/w));var O=_?1e3*k.loaded/M:0,F=b/1e3,N=O?(x-k.loaded)/O:8*x/w+F;if(!(N<=I)){var U,B=O?8*O:w,G=!0===(null==(d=n.hls.latestLevelDetails)?void 0:d.live),K=n.hls.config.abrBandWidthUpFactor,H=Number.POSITIVE_INFINITY;for(U=v.level-1;U>A;U--){var V=C[U].maxBitrate,j=!C[U].details||G;if((H=n.getTimeToLoadFrag(F,B,T*V,j))<Math.min(I,T+F))break}if(!(H>=N||H>10*T)){_?n.bwEstimator.sample(S-Math.min(b,D),k.loaded):n.bwEstimator.sampleTTFB(S);var Y=C[U].maxBitrate;n.getBwEstimate()*K>Y&&n.resetEstimator(Y);var q=n.findBestLevel(Y,A,U,0,I,1,1);q>-1&&(U=q),n.warn(_d(e=_d(t=_d(r=_d(i=_d(a=_d(s=_d(o=_d(l=_d(u=_d(c=_d(h="Fragment ".concat(v.sn)).call(h,g?" part "+g.index:""," of level ")).call(c,v.level," is loading too slowly;\n Fragment duration: ")).call(u,v.duration.toFixed(3),"\n Time to underbuffer: ")).call(l,I.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,H.toFixed(3)," s\n TTFB estimate: ")).call(a,0|D," ms\n Current BW estimate: ")).call(i,oO(w)?0|w:"Unknown"," bps\n New BW estimate: ")).call(r,0|n.getBwEstimate()," bps\n Switching to level ")).call(t,U," @ ")).call(e,0|Y," bps")),p.nextLoadLevel=p.nextAutoLevel=U,n.clearTimer(),n.timer=lS((function(){if(n.clearTimer(),n.fragCurrent===v&&n.hls.loadLevel===U&&U>0){var e,t,r=n.getStarvationDelay();if(n.warn(_d(e=_d(t="Aborting inflight request ".concat(U>0?"and switching down":"","\n Fragment duration: ")).call(t,v.duration.toFixed(3)," s\n Time to underbuffer: ")).call(e,r.toFixed(3)," s")),v.abortRequests(),n.fragCurrent=n.partCurrent=null,U>A){var i=n.findBestLevel(n.hls.levels[A].bitrate,A,U,0,r,1,1);-1===i&&(i=A),n.hls.nextLoadLevel=n.hls.nextAutoLevel=i,n.resetEstimator(n.hls.levels[i].bitrate)}}}),1e3*H),p.trigger(dO.FRAG_LOAD_EMERGENCY_ABORTED,{frag:v,part:g,stats:k})}}}}}}},n.hls=e,n.bwEstimator=n.initEstimator(),n.registerListeners(),n}return Fc(i,[{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 TO(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.FRAG_LOADING,this.onFragLoading,this),e.on(dO.FRAG_LOADED,this.onFragLoaded,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.FRAG_LOADING,this.onFragLoading,this),e.off(dO.FRAG_LOADED,this.onFragLoaded,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(dO.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 i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=lS(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case hO.BUFFER_ADD_CODEC_ERROR:case hO.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case hO.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,n=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var a=performance.now(),s=n?n.stats:r.stats,o=a-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}}},{key:"getTimeToLoadFrag",value:function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var r=this.hls.config,i=t.stats.loading,n=i.end-i.start;oO(n)&&(this.lastLevelLoadSec=n/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,i=t.part,n=i?i.stats:r.stats;if(r.type===mO&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,l=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(dO.FRAG_BUFFERED,u),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==mO||"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,i=t.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,s=this.findBestLevel(n,i,r,0,a,1,1);if(s>-1)return s;var o=this.hls.firstLevel,l=Math.min(Math.max(o,i),r);return this.warn(_d(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 i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=Math.min(Math.max(e,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}},{key:"getAutoLevelKey",value:function(){var e;return _d(e="".concat(this.getBwEstimate(),"_")).call(e,this.getStarvationDelay().toFixed(2))}},{key:"getNextABRAutoLevel",value:function(){var e,t=this.fragCurrent,r=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,s=i.minAutoLevel,o=r?r.duration:t?t.duration:0,l=this.getBwEstimate(),u=this.getStarvationDelay(),c=a.abrBandWidthFactor,h=a.abrBandWidthUpFactor;if(u){var d=this.findBestLevel(l,s,n,u,0,c,h);if(d>=0)return d}var f=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var v,g=this.bitrateTestDelay;if(g)f=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-g,this.info(_d(v="bitrate test took ".concat(Math.round(1e3*g),"ms, set first fragment max fetchDuration to ")).call(v,Math.round(1e3*f)," ms")),c=h=1}var p=this.findBestLevel(l,s,n,u,f,c,h);if(this.info(_d(e="".concat(u?"rebuffering expected":"buffer is empty",", optimal quality level ")).call(e,p)),p>-1)return p;var m=i.levels[s],y=i.levels[i.loadLevel];return(null==m?void 0:m.bitrate)<(null==y?void 0:y.bitrate)?s:i.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,i=e.mainForwardBufferInfo;return(i?i.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,i,n,a,s){var o,l=this,u=i+n,c=this.lastLoadedFragLevel,h=-1===c?this.hls.firstLevel:c,d=this.fragCurrent,f=this.partCurrent,v=this.hls,g=v.levels,p=v.allAudioTracks,m=v.loadLevel,y=v.config;if(1===g.length)return 0;var E,k=g[h],T=!(null==(o=this.hls.latestLevelDetails)||!o.live),S=-1===m||-1===c,A="SDR",L=(null==k?void 0:k.frameRate)||0,b=y.audioPreference,R=y.videoPreference,I=this.audioTracksByGroup||(this.audioTracksByGroup=oF(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var _=this.codecTiers||(this.codecTiers=function(e,t,r,i){var n;return mC(n=Fv(e).call(e,r,i+1)).call(n,(function(e,r,i){if(!r.codecSet)return e;var n=r.audioGroups,a=e[r.codecSet];a||(e[r.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,r.bitrate);var s=Math.min(r.height,r.width);return a.minHeight=Math.min(a.minHeight,s),a.minFramerate=Math.min(a.minFramerate,r.frameRate),a.minIndex=Math.min(a.minIndex,i),a.maxScore=Math.max(a.maxScore,r.score),a.fragmentError+=r.fragmentError,a.videoRanges[r.videoRange]=(a.videoRanges[r.videoRange]||0)+1,n&&vd(n).call(n,(function(e){var r;if(e){var i=t.groups[e];i&&(a.hasDefaultAudio=a.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,vd(r=gv(i.channels)).call(r,(function(e){a.channels[e]=(a.channels[e]||0)+i.channels[e]})))}})),e}),{})}(g,I,t,r)),w=function(e,t,r,i,n){for(var a=gv(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==n?void 0:n.videoCodec,u=s&&2===Ak(s),c=!1,h=!1,d=1/0,f=1/0,v=1/0,g=1/0,p=0,m=[],y=aF(t,n),E=y.preferHDR,k=y.allowedVideoRanges,T=function(){var t=e[a[S]];c||(c=t.channels[2]>0),d=Math.min(d,t.minHeight),f=Math.min(f,t.minFramerate),v=Math.min(v,t.minBitrate),xk(k).call(k,(function(e){return t.videoRanges[e]>0})).length>0&&(h=!0)},S=a.length;S--;)T();d=oO(d)?d:0,f=oO(f)?f:0;var A=Math.max(1080,d),L=Math.max(30,f);v=oO(v)?v:r,r=Math.max(v,r),h||(t=void 0);var b=a.length>1;return{codecSet:mC(a).call(a,(function(t,i){var n=e[i];if(i===t)return t;if(m=h?xk(k).call(k,(function(e){return n.videoRanges[e]>0})):[],b){var a,d,f,v,y;if(n.minBitrate>r)return sF(i,_d(a="min bitrate of ".concat(n.minBitrate," > current estimate of ")).call(a,r)),t;if(!n.hasDefaultAudio)return sF(i,"no renditions with default or auto-select sound found"),t;if(o&&av(i).call(i,o.substring(0,4))%5!=0)return sF(i,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!u){if(!n.channels[s])return sF(i,_d(d="no renditions with ".concat(s," channel sound found (channels options: ")).call(d,gv(n.channels),")")),t}else if((!o||u)&&c&&0===n.channels[2])return sF(i,"no renditions with stereo sound found"),t;if(n.minHeight>A)return sF(i,_d(f="min resolution of ".concat(n.minHeight," > maximum of ")).call(f,A)),t;if(n.minFramerate>L)return sF(i,_d(v="min framerate of ".concat(n.minFramerate," > maximum of ")).call(v,L)),t;if(!KT(m).call(m,(function(e){return n.videoRanges[e]>0})))return sF(i,"no variants with VIDEO-RANGE of ".concat(yI(m)," found")),t;if(l&&av(i).call(i,l.substring(0,4))%5!=0)return sF(i,'video codec preference "'.concat(l,'" not found')),t;if(n.maxScore<p)return sF(i,_d(y="max score of ".concat(n.maxScore," < selected max of ")).call(y,p)),t}return t&&(GO(i)>=GO(t)||n.fragmentError>e[t].fragmentError)?t:(g=n.minIndex,p=n.maxScore,i)}),void 0),videoRanges:m,preferHDR:E,minFramerate:f,minBitrate:v,minIndex:g}}(_,A,e,b,R),C=w.codecSet,P=w.videoRanges,x=w.minFramerate,M=w.minBitrate,O=w.minIndex,F=w.preferHDR;D=O,E=C,A=F?P[P.length-1]:P[0],L=x,e=Math.max(e,M),this.log("picked start tier ".concat(yI(w)))}else E=null==k?void 0:k.codecSet,A=null==k?void 0:k.videoRange;for(var N=f?f.duration:d?d.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,B=[],G=function(){var t=g[K],o=K>h;if(!t)return"continue";if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var d=navigator.mediaCapabilities;"function"!=typeof(null==d?void 0:d.decodingInfo)||!function(e,t,r,i,n,a){var s,o=e.audioCodec?e.audioGroups:null,l=null==a?void 0:a.audioCodec,u=null==a?void 0:a.channels,c=u?Ak(u):l?1/0:2,h=null;if(null!=o&&o.length)try{h=1===o.length&&o[0]?t.groups[o[0]].channels:mC(o).call(o,(function(e,r){if(r){var i,n=t.groups[r];if(!n)throw new Error("Audio track group ".concat(r," not found"));vd(i=gv(n.channels)).call(i,(function(t){e[t]=(e[t]||0)+n.channels[t]}))}return e}),{2:0})}catch($V){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(n,8e6))||!!h&&oO(c)&&KT(s=gv(h)).call(s,(function(e){return Ak(e)>c}))}(t,I,A,L,e,b)&&"hvc1"!==(null==(V=t.videoCodec)?void 0:V.substring(0,4))?t.supportedResult=WO:(t.supportedPromise=XO(t,I,d),t.supportedPromise.then((function(e){if(l.hls){t.supportedResult=e;var r,i,n=l.hls.levels,a=av(n).call(n,t);if(e.error)l.warn(_d(r=_d(i='MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ')).call(i,a," ")).call(r,yI(e)));else if(!e.supported){var s;l.warn(_d(s="Unsupported MediaCapabilities decodingInfo result for level ".concat(a," ")).call(s,yI(e))),a>-1&&n.length>1&&(l.log("Removing unsupported level ".concat(a)),l.hls.removeLevel(a),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0))}}})))}if((E&&t.codecSet!==E||A&&t.videoRange!==A||o&&L>t.frameRate||!o&&L>0&&L<t.frameRate||t.supportedResult&&(null==(H=t.supportedResult.decodingInfoResults)||!H[0].smooth))&&(!S||K!==D))return B.push(K),"continue";var v,p=t.details,k=(f?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;v=o?s*e:a*e;var R=N&&i>=2*N&&0===n?t.averageBitrate:t.maxBitrate,_=l.getTimeToLoadFrag(U,v,R*k,void 0===p);if(v>=R&&(K===c||0===t.loadError&&0===t.fragmentError)&&(_<=U||!oO(_)||T&&!l.bitrateTestDelay||_<u)){var w=l.forcedAutoLevel;if(K!==m&&(-1===w||w!==m)){var C,P,x,M,O,F,G,j,Y,q,W,z,X,Q,$,J;if(B.length)l.trace(_d(z=_d(X=_d(Q=_d($=_d(J="Skipped level(s) ".concat(B.join(",")," of ")).call(J,r,' max with CODECS and VIDEO-RANGE:"')).call($,g[B[0]].codecs,'" ')).call(Q,g[B[0]].videoRange,'; not compatible with "')).call(X,E,'" ')).call(z,A));l.info(_d(C=_d(P=_d(x=_d(M=_d(O=_d(F=_d(G=_d(j=_d(Y=_d(q=_d(W="switch candidate:".concat(h,"->")).call(W,K," adjustedbw(")).call(q,Math.round(v),")-bitrate=")).call(Y,Math.round(v-R)," ttfb:")).call(j,U.toFixed(1)," avgDuration:")).call(G,k.toFixed(1)," maxFetchDuration:")).call(F,u.toFixed(1)," fetchDuration:")).call(O,_.toFixed(1)," firstSelection:")).call(M,S," codecSet:")).call(x,t.codecSet," videoRange:")).call(P,t.videoRange," hls.loadLevel:")).call(C,m))}return S&&(l.firstSelection=K),{v:K}}},K=r;K>=t;K--){var H,V,j=G();if("continue"!==j&&"object"===Cc(j))return j.v}return-1}}]),i}(RO),gF=function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function pF(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.005,a=null;if(e){a=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7),a&&e.level!==a.level&&a.end<=e.end&&(a=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===mF(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i,n=mC(i=t.tagList).call(i,(function(e,t){return"INF"===t[0]&&(e+=bS(t[1])),e}),r);return e.start<=n}return!1}(a,e,Math.min(n,i))))return a;var o=gF(t,iT(mF).call(mF,null,r,i));return!o||o===e&&a?a:o}function mF(){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 i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function yF(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function EF(e,t){return gF(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function kF(e){switch(e.details){case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_TIMEOUT:case hO.LEVEL_LOAD_TIMEOUT:case hO.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function TF(e,t){var r=kF(t);return e.default["".concat(r?"timeout":"error","Retry")]}function SF(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function AF(e){return bO(bO({},e),{errorRetry:null,timeoutRetry:null})}function LF(e,t,r,i){if(!e)return!1;var n=null==i?void 0:i.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,a):a}var bF=0,RF=2,IF=3,DF=5,_F=0,wF=1,CF=2,PF=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"error-controller",e.logger)).hls=void 0,n.playlistError=0,n.penalizedRenditions={},n.hls=e,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.ERROR,this.onError,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.ERROR,this.onError,this),e.off(dO.ERROR,this.onErrorOut,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.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)===mO?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 i=this.hls,n=t.context;switch(t.details){case hO.FRAG_LOAD_ERROR:case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_ERROR:case hO.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case hO.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=xF());case hO.FRAG_GAP:case hO.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=RF);case hO.LEVEL_EMPTY_ERROR:case hO.LEVEL_PARSING_ERROR:var a,s,o=t.parent===mO?t.level:i.loadLevel;return void(t.details===hO.LEVEL_EMPTY_ERROR&&null!=(a=t.context)&&null!=(s=a.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case hO.LEVEL_LOAD_ERROR:case hO.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case hO.AUDIO_TRACK_LOAD_ERROR:case hO.AUDIO_TRACK_LOAD_TIMEOUT:case hO.SUBTITLE_LOAD_ERROR:case hO.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var l=i.levels[i.loadLevel];if(l&&(n.type===gO&&l.hasAudioGroup(n.groupId)||n.type===pO&&l.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=RF,void(t.errorAction.flags=wF)}return;case hO.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var u=i.levels[i.loadLevel],c=null==u?void 0:u.attrs["HDCP-LEVEL"];return void(c?t.errorAction={action:RF,flags:CF,hdcpLevel:c}:this.keySystemError(t));case hO.BUFFER_ADD_CODEC_ERROR:case hO.REMUX_ALLOC_ERROR:case hO.BUFFER_APPEND_ERROR:var h;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(h=t.level)?h:i.loadLevel);return;case hO.INTERNAL_EXCEPTION:case hO.BUFFER_APPENDING_ERROR:case hO.BUFFER_FULL_ERROR:case hO.LEVEL_SWITCH_ERROR:case hO.BUFFER_STALLED_ERROR:case hO.BUFFER_SEEK_OVER_HOLE:case hO.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=xF())}t.type===cO.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=TF(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(LF(r,i,kF(e),e.response))return{action:DF,flags:_F,retryConfig:r,retryCount:i};var n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n}},{key:"getFragRetryOrSwitchAction",value:function(e){var t,r,i=this.hls,n=this.getVariantLevelIndex(e.frag),a=i.levels[n],s=i.config,o=s.fragLoadPolicy,l=s.keyLoadPolicy,u=TF(KI(t=e.details).call(t,"key")?l:o,e),c=mC(r=i.levels).call(r,(function(e,t){return e+t.fragmentError}),0);if(a&&(e.details!==hO.FRAG_GAP&&a.fragmentError++,LF(u,c,kF(e),e.response)))return{action:DF,flags:_F,retryConfig:u,retryCount:c};var h=this.getLevelSwitchAction(e,n);return u&&(h.retryConfig=u,h.retryCount=c),h}},{key:"getLevelSwitchAction",value:function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var n,a,s=e.details;i.loadError++,s===hO.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,l=r.levels,u=r.loadLevel,c=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var d=null==(n=e.frag)?void 0:n.type,f=(d===yO&&s===hO.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===hO.BUFFER_ADD_CODEC_ERROR||s===hO.BUFFER_APPEND_ERROR))&&KT(l).call(l,(function(e){var t=e.audioCodec;return i.audioCodec!==t})),v="video"===e.sourceBufferName&&(s===hO.BUFFER_ADD_CODEC_ERROR||s===hO.BUFFER_APPEND_ERROR)&&KT(l).call(l,(function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(a=e.context)?a:{},p=g.type,m=g.groupId,y=function(){var t=(E+u)%l.length;if(t!==u&&t>=c&&t<=h&&0===l[t].loadError){var r=l[t];if(s===hO.FRAG_GAP&&d===mO&&e.frag){var n=l[t].details;if(n){var a=pF(e.frag,n.fragments,e.frag.start);if(null!=a&&a.gap)return"continue"}}else{if(p===gO&&r.hasAudioGroup(m)||p===pO&&r.hasSubtitleGroup(m))return"continue";if(d===yO&&null!=(k=i.audioGroups)&&KT(k).call(k,(function(e){return r.hasAudioGroup(e)}))||d===EO&&null!=(T=i.subtitleGroups)&&KT(T).call(T,(function(e){return r.hasSubtitleGroup(e)}))||f&&i.audioCodec===r.audioCodec||!f&&i.audioCodec!==r.audioCodec||v&&i.codecSet===r.codecSet)return"continue"}return o=t,"break"}},E=l.length;E--;){var k,T,S=y();if("continue"!==S&&"break"===S)break}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:RF,flags:_F,nextAutoLevel:o}}return{action:RF,flags:wF}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case bF:break;case RF:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===hO.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 i=IC(r),n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case _F:this.switchLevel(e,a);break;case CF:n&&(t.maxHdcpLevel=QO[av(QO).call(QO,n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'))}r.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){var r;void 0!==t&&e.errorAction&&(this.warn(_d(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)}}]),i}(RO);function xF(e){var t={action:bF,flags:_F};return e&&(t.resolved=!0),t}var MF="NOT_LOADED",OF="APPENDING",FF="PARTIAL",NF="OK",UF=function(){function e(r){t(this,e),this.activePartLists=rT(null),this.endListFragments=rT(null),this.fragments=rT(null),this.timeRanges=rT(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=r,this._registerListeners()}return Fc(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(dO.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(dO.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 i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=e&&null!==a&&e<=a)return n}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 i=this.fragments,n=gv(i),a=n.length;a--;){var s=i[n[a]];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,i,n){var a,s=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(null==i?void 0:i.fragment.sn)||-1;vd(a=gv(this.fragments)).call(a,(function(i){var a,l=s.fragments[i];if(l&&!(o>=l.body.sn))if(l.buffered||l.loaded&&!n){var u=l.range[e];u&&(0!==u.time.length?KT(a=u.time).call(a,(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,i=this.timeRanges;if(i&&"initSegment"!==e.frag.sn){var n=e.frag,a=GF(n),s=this.fragments[a];if(!(!s||s.buffered&&n.gap)){var o=!n.relurl;if(vd(t=gv(i)).call(t,(function(t){var a=n.elementaryStreams[t];if(a){var l=i[t],u=o||!0===a.partial;s.range[t]=r.getBufferedTimes(n,e.part,u,l)}})),s.loaded=null,gv(s.range).length)s.buffered=!0,(s.body.endList=n.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),BF(s)||this.removeParts(n.sn-1,n.type);else this.removeFragment(s.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=xk(r).call(r,(function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=GF(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:rT(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}},{key:"getBufferedTimes",value:function(e,t,r,i){for(var n={time:[],partial:r},a=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<i.length;u++){var c=i.start(u)-this.bufferPadding,h=i.end(u)+this.bufferPadding;if(l>=c&&o<=h){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(a<h&&s>c){var d=Math.max(a,i.start(u)),f=Math.min(s,i.end(u));f>d&&(n.partial=!0,n.time.push({startPTS:d,endPTS:f}))}else if(s<=c)break}return n}},{key:"getPartialFragment",value:function(e){var t,r,i,n,a=null,s=0,o=this.bufferPadding,l=this.fragments;return vd(t=gv(l)).call(t,(function(t){var u=l[t];u&&BF(u)&&(i=u.body.start-o,n=u.body.end+o,e>=i&&e<=n&&(r=Math.min(e-i,n-e),s<=r&&(a=u.body,s=r)))})),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||BF(t))}},{key:"getState",value:function(e){var t=GF(e),r=this.fragments[t];return r?r.buffered?BF(r)?FF:NF:OF:MF}},{key:"isTimeBuffered",value:function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)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,i=t.part?null:t,n=GF(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:rT(null)}}}},{key:"onBufferAppended",value:function(e,t){var r=t.frag,i=t.part,n=t.timeRanges,a=t.type;if("initSegment"!==r.sn){var s=r.type;if(i){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(i)}this.timeRanges=n;var l=n[a];this.detectEvictedFragments(a,l,s,i)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=GF(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=gv(t);if(!e)return r.length>0;for(var i=r.length;i--;){var n=t[r[i]];if((null==n?void 0:n.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,i,n){var a,s=this;i&&!this.hasGaps||vd(a=gv(this.fragments)).call(a,(function(a){var o=s.fragments[a];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&s.removeFragment(l)}}))}},{key:"removeFragment",value:function(e){var t=GF(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=xk(r).call(r,(function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e,t;this.fragments=rT(null),this.endListFragments=rT(null),this.activePartLists=rT(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&vd(r).call(r,(function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function BF(e){var t,r,i;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==(i=e.range.audiovideo)?void 0:i.partial))}function GF(e){var t,r;return _d(t=_d(r="".concat(e.type,"_")).call(r,e.level,"_")).call(t,e.sn)}var KF=0,HF=1,VF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=r,this.aesIV=i,this.aesMode=n}return Fc(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case KF:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case HF: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 jF(e,t,r){return Fv(Uint8Array.prototype)?Fv(e).call(e,t,r):new Uint8Array(Fv(Array.prototype).call(e,t,r))}var YF=function(){function e(){t(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 Fc(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],h=o[3],d=new Uint32Array(256),f=0,v=0,g=0;for(g=0;g<256;g++)d[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=v^v<<1^v<<2^v<<3^v<<4;p=p>>>8^255&p^99,e[f]=p,t[p]=f;var m=d[f],y=d[m],E=d[y],k=257*d[p]^16843008*p;i[f]=k<<24|k>>>8,n[f]=k<<16|k>>>16,a[f]=k<<8|k>>>24,s[f]=k,k=16843009*E^65537*y^257*m^16843008*f,l[p]=k<<24|k>>>8,u[p]=k<<16|k>>>16,c[p]=k<<8|k>>>24,h[p]=k,f?(f=m^d[d[d[E^m]]],v^=d[d[v]]):f=v=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,l,u=this.ksRows=4*(n+6+1),c=this.keySchedule=new Uint32Array(u),h=this.invKeySchedule=new Uint32Array(u),d=this.sBox,f=this.rcon,v=this.invSubMix,g=v[0],p=v[1],m=v[2],y=v[3];for(a=0;a<u;a++)a<n?o=c[a]=t[a]:(l=o,a%n==0?(l=d[(l=l<<8|l>>>24)>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l],l^=f[a/n|0]<<24):n>6&&a%n==4&&(l=d[l>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l]),c[a]=o=(c[a-n]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],h[s]=s<4||a<=4?l:g[d[l>>>24]]^p[d[l>>>16&255]]^m[d[l>>>8&255]]^y[d[255&l]],h[s]=h[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 i,n,a,s,o,l,u,c,h,d,f,v,g,p,m=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,k=this.invSubMix,T=k[0],S=k[1],A=k[2],L=k[3],b=this.uint8ArrayToUint32Array_(r),R=b[0],I=b[1],D=b[2],_=b[3],w=new Int32Array(e),C=new Int32Array(w.length),P=this.networkToHostOrderSwap;t<w.length;){for(h=P(w[t]),d=P(w[t+1]),f=P(w[t+2]),v=P(w[t+3]),o=h^y[0],l=v^y[1],u=f^y[2],c=d^y[3],g=4,p=1;p<m;p++)i=T[o>>>24]^S[l>>16&255]^A[u>>8&255]^L[255&c]^y[g],n=T[l>>>24]^S[u>>16&255]^A[c>>8&255]^L[255&o]^y[g+1],a=T[u>>>24]^S[c>>16&255]^A[o>>8&255]^L[255&l]^y[g+2],s=T[c>>>24]^S[o>>16&255]^A[l>>8&255]^L[255&u]^y[g+3],o=i,l=n,u=a,c=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&c]^y[g],n=E[l>>>24]<<24^E[u>>16&255]<<16^E[c>>8&255]<<8^E[255&o]^y[g+1],a=E[u>>>24]<<24^E[c>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[c>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],C[t]=P(i^R),C[t+1]=P(s^I),C[t+2]=P(a^D),C[t+3]=P(n^_),R=h,I=d,D=f,_=v,t+=4}return C.buffer}}]),e}(),qF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=r,this.key=i,this.aesMode=n}return Fc(e,[{key:"expandKey",value:function(){var e=function(e){switch(e){case KF:return"AES-CBC";case HF:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode ".concat(e))}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}]),e}();function WF(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 i=av(r).call(r,"\0");return-1!==i?r.substring(0,i):r}return r.replace(/\0/g,"")}for(var n,a,s,o=e.length,l="",u=0;u<o;){if(0===(n=e[u++])&&t)return l;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:a=e[u++],l+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[u++],s=e[u++],l+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&s)<<0)}}return l}var zF={hexDump:function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}};function XF(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var QF,$F,JF,ZF,eN,tN={exports:{}};QF=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,$F=/^(?=([^\/?#]*))\1([^]*)$/,JF=/(?:\/|^)\.(?=\/)/g,ZF=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,tN.exports=eN={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=MS(e).call(e),!(t=MS(t).call(t))){if(!r.alwaysNormalize)return e;var i=eN.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=eN.normalizePath(i.path),eN.buildURLFromParts(i)}var n=eN.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=eN.normalizePath(n.path),eN.buildURLFromParts(n)):t;var a=eN.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var s=$F.exec(a.path);a.netLoc=s[1],a.path=s[2]}a.netLoc&&!a.path&&(a.path="/");var o={scheme:a.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(o.netLoc=a.netLoc,"/"!==n.path[0]))if(n.path){var l=a.path,u=l.substring(0,HC(l).call(l,"/")+1)+n.path;o.path=eN.normalizePath(u)}else o.path=a.path,n.params||(o.params=a.params,n.query||(o.query=a.query));return null===o.path&&(o.path=r.alwaysNormalize?eN.normalizePath(n.path):n.path),eN.buildURLFromParts(o)},parseURL:function(e){var t=QF.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=$C(t=e.split("")).call(t).join("").replace(JF,"");e.length!==(e=e.replace(ZF,"")).length;);return $C(r=e.split("")).call(r).join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var rN=tN.exports,iN=Fc((function e(){t(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}})),nN="audio",aN="video",sN="audiovideo",oN=function(){function e(r){t(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof r&&(r={url:r}),this.base=r}return Fc(e,[{key:"setByteRange",value:function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:Ak(i[1]),this._byteRange=[r,Ak(i[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=(Lf(e={},nN,null),Lf(e,aN,null),Lf(e,sN,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 iN),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=rN.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[nN]=null,e[aN]=null,e[sN]=null}}]),e}();function lN(e){return"initSegment"!==e.sn}var uN=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 Fc(i,[{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(oO(t)&&oO(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=gv(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=oO(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=gv(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){oO(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return lN(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,i,n){var a=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,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}}}]),i}(oN),cN=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s,o){var l;t(this,i),(l=r.call(this,a)).fragOffset=0,l.duration=0,l.gap=!1,l.independent=!1,l.relurl=void 0,l.fragment=void 0,l.index=void 0,l.duration=e.decimalFloatingPoint("DURATION"),l.gap=e.bool("GAP"),l.independent=e.bool("INDEPENDENT"),l.relurl=e.enumeratedString("URI"),l.fragment=n,l.index=s;var u=e.enumeratedString("BYTERANGE");return u&&l.setByteRange(u,o),o&&(l.fragOffset=o.fragOffset+o.duration),l}return Fc(i,[{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)}}]),i}(oN),hN=Math.pow(2,32)-1,dN=[].push,fN={video:1,audio:2,id3:3,text:4};function vN(e){return String.fromCharCode.apply(null,e)}function gN(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function pN(e,t){var r=yN(e,t);return r<0?4294967296+r:r}function mN(e,t){var r=pN(e,t);return r*=Math.pow(2,32),r+=pN(e,t+4)}function yN(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function EN(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 kN(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=pN(e,n),s=a>1?n+a:i;if(vN(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=kN(e.subarray(n+8,s),Fv(t).call(t,1));o.length&&dN.apply(r,o)}n=s}return r}function TN(e){var t=[],r=e[0],i=8,n=pN(e,i);i+=4;var a=0,s=0;0===r?(a=pN(e,i),s=pN(e,i+4),i+=8):(a=mN(e,i),s=mN(e,i+8),i+=16),i+=2;var o=e.length+s,l=gN(e,i);i+=2;for(var u=0;u<l;u++){var c=i,h=pN(e,c);c+=4;var d=2147483647&h;if(1===(2147483648&h)>>>31)return PO.warn("SIDX has hierarchical references (not supported)"),null;var f=pN(e,c);c+=4,t.push({referenceSize:d,subsegmentDuration:f,info:{duration:f/n,start:o,end:o+d-1}}),o+=d,i=c+=4}return{earliestPresentationTime:a,timescale:n,version:r,referencesCount:l,references:t}}function SN(e){for(var t=[],r=kN(e,["moov","trak"]),i=0;i<r.length;i++){var n=r[i],a=kN(n,["tkhd"])[0];if(a){var s=a[0],o=pN(a,0===s?12:20),l=kN(n,["mdia","mdhd"])[0];if(l){var u=pN(l,0===(s=l[0])?12:20),c=kN(n,["mdia","hdlr"])[0];if(c){var h=vN(c.subarray(8,12)),d={soun:nN,vide:aN}[h];if(d){var f=AN(kN(n,["mdia","minf","stbl","stsd"])[0]);t[o]={timescale:u,type:d},t[d]=bO({timescale:u,id:o},f)}}}}}var v=kN(e,["moov","mvex","trex"]);return vd(v).call(v,(function(e){var r=pN(e,4),i=t[r];i&&(i.default={duration:pN(e,12),flags:pN(e,20)})})),t}function AN(e){var t=e.subarray(8),r=t.subarray(86),i=vN(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=kN(t,[i])[0],o=kN(s.subarray("enca"===i?28:78),["sinf"]);vd(o).call(o,(function(e){var t=kN(e,["schm"])[0];if(t){var r=vN(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=kN(e,["frma"])[0];i&&(n=vN(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var l=kN(r,["avcC"])[0];n+="."+bN(l[1])+bN(l[2])+bN(l[3]);break;case"mp4a":var u=kN(t,[i])[0],c=kN(u.subarray(28),["esds"])[0];if(c&&c.length>7){var h=4;if(3!==c[h++])break;h=LN(c,h),h+=2;var d=c[h++];if(128&d&&(h+=2),64&d&&(h+=c[h++]),4!==c[h++])break;h=LN(c,h);var f=c[h++];if(64!==f)break;if(n+="."+bN(f),h+=12,5!==c[h++])break;h=LN(c,h);var v=c[h++],g=(248&v)>>3;31===g&&(g+=1+((7&v)<<3)+((224&c[h])>>5)),n+="."+g}break;case"hvc1":case"hev1":var p=kN(r,["hvcC"])[0],m=p[1],y=["","A","B","C"][m>>6],E=31&m,k=pN(p,2),T=(32&m)>>5?"H":"L",S=p[12],A=p.subarray(6,12);n+="."+y+E,n+="."+k.toString(16).toUpperCase(),n+="."+T+S;for(var L="",b=A.length;b--;){var R=A[b];if(R||L)L="."+R.toString(16).toUpperCase()+L}n+=L;break;case"dvh1":case"dvhe":var I=kN(r,["dvcC"])[0],D=I[2]>>1&127,_=I[2]<<5&32|I[3]>>3&31;n+="."+RN(D)+"."+RN(_);break;case"vp09":var w=kN(r,["vpcC"])[0],C=w[4],P=w[5],x=w[6]>>4&15;n+="."+RN(C)+"."+RN(P)+"."+RN(x);break;case"av01":var M=kN(r,["av1C"])[0],O=M[1]>>>5,F=31&M[1],N=M[2]>>>7?"H":"M",U=(64&M[2])>>6,B=(32&M[2])>>5,G=2===O&&U?B?12:10:U?10:8,K=(16&M[2])>>4,H=(8&M[2])>>3,V=(4&M[2])>>2,j=3&M[2];n+="."+O+"."+RN(F)+N+"."+RN(G)+"."+K+"."+H+V+j+"."+RN(1)+"."+RN(1)+"."+RN(1)+".0"}return{codec:n,encrypted:a}}function LN(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function bN(e){var t;return Fv(t="0"+e.toString(16).toUpperCase()).call(t,-2)}function RN(e){return(e<10?"0":"")+e}function IN(e){var t=kN(e,["schm"])[0];if(t){var r=vN(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return kN(e,["schi","tenc"])[0]}return null}function DN(e){var t=pN(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=pN(e,4),a=0;a<n;a++){if(256&t)i+=pN(e,r),r+=4;512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return i}function _N(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function wN(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1,o=kN(i,["moof"]);return _k(o).call(o,(function(o){var l=o.byteOffset-8,u=kN(o,["traf"]);_k(u).call(u,(function(o){var u,c,h=_k(u=kN(o,["tfdt"])).call(u,(function(e){var t=e[0],r=pN(e,4);return 1===t&&(r*=Math.pow(2,32),r+=pN(e,8)),r/n}))[0];return void 0!==h&&(e=h),_k(c=kN(o,["tfhd"])).call(c,(function(u){var c,h=pN(u,4),d=16777215&pN(u,0),f=0,v=0!=(16&d),g=0,p=0!=(32&d),m=8;h===a&&(0!=(1&d)&&(m+=8),0!=(2&d)&&(m+=4),0!=(8&d)&&(f=pN(u,m),m+=4),v&&(g=pN(u,m),m+=4),p&&(m+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=av(e).call(e,"."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),_k(c=kN(o,["trun"])).call(c,(function(a){var o=a[0],u=16777215&pN(a,0),c=0!=(1&u),h=0,d=0!=(4&u),v=0!=(256&u),p=0,m=0!=(512&u),y=0,E=0!=(1024&u),k=0!=(2048&u),T=0,S=pN(a,4),A=8;c&&(h=pN(a,A),A+=4),d&&(A+=4);for(var L=h+l,b=0;b<S;b++){if(v?(p=pN(a,A),A+=4):p=f,m?(y=pN(a,A),A+=4):y=g,E&&(A+=4),k&&(T=0===o?pN(a,A):yN(a,A),A+=4),t.type===aN)for(var R=0;R<y;){var I=pN(i,L);if(CN(s,i[L+=4]))PN(i.subarray(L,L+I),s?2:1,e+T/n,r);L+=I,R+=I+4}e+=p/n}})))}))}))})),r}function CN(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function PN(e,t,r,i){var n=xN(e),a=0;a+=t;for(var s=0,o=0,l=0;a<n.length;){s=0;do{if(a>=n.length)break;s+=l=n[a++]}while(255===l);o=0;do{if(a>=n.length)break;o+=l=n[a++]}while(255===l);var u=n.length-a,c=a;if(o<u)a+=o;else if(o>u){var h;PO.error(_d(h="Malformed SEI payload. ".concat(o," is too small, only ")).call(h,u," bytes left to parse."));break}if(4===s){if(181===n[c++]){var d=gN(n,c);if(c+=2,49===d){var f=pN(n,c);if(c+=4,1195456820===f){var v=n[c++];if(3===v){var g=n[c++],p=64&g,m=p?2+3*(31&g):0,y=new Uint8Array(m);if(p){y[0]=g;for(var E=1;E<m;E++)y[E]=n[c++]}i.push({type:v,payloadType:s,pts:r,bytes:y})}}}}}else if(5===s&&o>16){for(var k=[],T=0;T<16;T++){var S=n[c++].toString(16);k.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||k.push("-")}for(var A=o-16,L=new Uint8Array(A),b=0;b<A;b++)L[b]=n[c++];i.push({payloadType:s,pts:r,uuid:k.join(""),userData:WF(L),userDataBytes:L})}}}function xN(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}function MN(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var i,n;i=new Uint8Array,n=new Uint8Array;var a=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=r.length,a=8,s=n;s--;)a+=r[s].byteLength;var o=new Uint8Array(a);for(o[0]=a>>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),s=0,a=8;s<n;s++)o.set(r[s],a),a+=r[s].byteLength;return o}([112,115,115,104],new Uint8Array([0,0,0,0]),e,n,i,a,r||new Uint8Array)}function ON(e){var t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};var n=e.getUint32(8)>>>24;if(0!==n&&1!==n)return{offset:r,size:t};var a=e.buffer,s=zF.hexDump(new Uint8Array(a,r+12,16)),o=e.getUint32(28),l=null,u=null;if(0===n){if(t-32<o||o<22)return{offset:r,size:t};u=new Uint8Array(a,r+32,o)}else if(1===n){if(!o||i<r+32+16*o+16)return{offset:r,size:t};l=[];for(var c=0;c<o;c++)l.push(new Uint8Array(a,r+32+16*c,16))}return{version:n,systemId:s,kids:l,data:u,offset:r,size:t}}var FN=function(){function e(r){var i=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).removePKCS7Padding,n=void 0===i||i;if(t(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=r.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(s){}this.useSoftware=!this.subtle}return Fc(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,i,n,a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=a).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?jF(r,0,i-n):r):a}},{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,i){var n=this;return this.useSoftware?new tk((function(a,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);n.softwareDecrypt(o,t,r,i);var l=n.flush();l?a(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}},{key:"softwareDecrypt",value:function(e,t,r,i){var n=this.currentIV,a=this.currentResult,s=this.remainderData;if(i!==KF||16!==t.byteLength)return PO.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=_N(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;n&&(r=n);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new YF),l.expandKey(t);var u=a;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=jF(o,-16).buffer,u||null}},{key:"webCryptoDecrypt",value:function(e,t,r,i){var n=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return tk.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new qF(this.subtle,t,i)}return this.fastAesKey.expandKey().then((function(t){return n.subtle?(n.logOnce("WebCrypto AES decrypt"),new VF(n.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):tk.reject(new Error("web crypto not initialized"))})).catch((function(a){var s;return PO.warn(_d(s="[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(a.name,": ")).call(s,a.message)),n.onWebCryptoError(e,t,r,i)}))}},{key:"onWebCryptoError",value:function(e,t,r,i){var n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=jF(e,0,r),this.remainderData=jF(e,r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(PO.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),NN=Math.pow(2,17),UN=function(){function e(r){t(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=r}return Fc(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,i=e.url;if(!i)return tk.reject(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new tk((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){var u;if(KT(u=e.tagList).call(u,(function(e){return"GAP"===e[0]})))return void l(GN(e));e.gap=!1}var c=r.loader=a?new a(n):new s(n),h=BN(e);e.loader=c;var d=AF(n.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:NN};e.stats=c.stats;var v={onSuccess:function(t,i,n,a){r.resetLoader(e,c);var s=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(Fv(s).call(s,0,16)),s=Fv(s).call(s,16)),o({frag:e,part:null,payload:s,networkDetails:a})},onError:function(t,n,a,s){var o;r.resetLoader(e,c),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:bO({url:i,data:void 0},t),error:new Error(_d(o="HTTP Error ".concat(t.code," ")).call(o,t.text)),networkDetails:a,stats:s}))},onAbort:function(t,i,n){r.resetLoader(e,c),l(new KN({type:cO.NETWORK_ERROR,details:hO.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:function(t,i,n){r.resetLoader(e,c),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after ".concat(f.timeout,"ms")),networkDetails:n,stats:t}))}};t&&(v.onProgress=function(r,i,n,a){return t({frag:e,part:null,payload:n,networkDetails:a})}),c.load(h,f,v)}))}},{key:"loadPart",value:function(e,t,r){var i=this;this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new tk((function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(GN(e,t));else{var u=i.loader=a?new a(n):new s(n),c=BN(e,t);e.loader=u;var h=AF(n.fragLoadPolicy.default),d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:NN};t.stats=u.stats,u.load(c,d,{onSuccess:function(n,a,s,l){i.resetLoader(e,u),i.updateStatsFromPart(e,t);var c={frag:e,part:t,payload:n.data,networkDetails:l};r(c),o(c)},onError:function(r,n,a,s){var o;i.resetLoader(e,u),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:bO({url:c.url,data:void 0},r),error:new Error(_d(o="HTTP Error ".concat(r.code," ")).call(o,r.text)),networkDetails:a,stats:s}))},onAbort:function(r,n,a){e.stats.aborted=t.stats.aborted,i.resetLoader(e,u),l(new KN({type:cO.NETWORK_ERROR,details:hO.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,n,a){i.resetLoader(e,u),l(new KN({type:cO.NETWORK_ERROR,details:hO.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after ".concat(d.timeout,"ms")),networkDetails:a,stats:r}))}})}}))}},{key:"updateStatsFromPart",value:function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}]),e}();function BN(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=r||e,n={frag:e,part:r,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},a=i.byteRangeStartOffset,s=i.byteRangeEndOffset;if(oO(a)&&oO(s)){var o,l=a,u=s;if("initSegment"===e.sn&&("AES-128"===(t=null==(o=e.decryptdata)?void 0:o.method)||"AES-256"===t)){var c=s-a;c%16&&(u=s+(16-c%16)),0!==a&&(n.resetIV=!0,l=a-16)}n.rangeStart=l,n.rangeEnd=u}return n}function GN(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),i={type:cO.MEDIA_ERROR,details:hO.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new KN(i)}var KN=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e.error.message)).data=void 0,n.data=e,n}return Fc(i)}(Jw(Error)),HN=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(s=r.call(this,e,n))._boundTick=void 0,s._tickTimer=null,s._tickInterval=null,s._tickCallCount=0,s._boundTick=iT(a=s.tick).call(a,Zh(s)),s}return Fc(i,[{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=lS(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=Wf(this._boundTick,0)}},{key:"doTick",value:function(){}}]),i}(RO),VN=Fc((function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];t(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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=r,this.sn=i,this.id=n,this.size=a,this.part=s,this.partial=o}));var jN={length:0,start:function(){return 0},end:function(){return 0}},YN=function(){function e(){t(this,e)}return Fc(e,null,[{key:"isBuffered",value:function(t,r){if(t)for(var i=e.getBuffered(t),n=i.length;n--;)if(r>=i.start(n)&&r<=i.end(n))return!0;return!1}},{key:"bufferInfo",value:function(t,r,i){if(t){var n=e.getBuffered(t);if(n.length){for(var a=[],s=0;s<n.length;s++)a.push({start:n.start(s),end:n.end(s)});return e.bufferedInfo(a,r,i)}}return{len:0,start:r,end:r,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){t=Math.max(0,t),mA(e).call(e,(function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,c=t,h=0;h<i.length;h++){var d=i[h].start,f=i[h].end;if(t+r>=d&&t<f)u=d,l=(c=f)-t;else if(t+r<d){o=d;break}}return{len:l,start:u||0,end:c||0,nextStart:o}}},{key:"getBuffered",value:function(e){try{return e.buffered||jN}catch(t){return PO.log("failed to get media.buffered",t),jN}}}]),e}(),qN=/\{\$([a-zA-Z0-9-_]+)\}/g;function WN(e){return qN.test(e)}function zN(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(qN,(function(t){var i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(i,'"'))),t):n}))}return t}function XN(e,t,r){var i,n,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{var s,o=new vI(r).searchParams;if(!o.has(i))throw new Error(_d(s='"'.concat(i,'" does not match any query parameter in URI: "')).call(s,r,'"'));n=o.get(i)}catch($V){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat($V.message)))}}else i=t.NAME,n=t.VALUE;i in a?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(i,'"'))):a[i]=n||""}function QN(e,t,r){var i=t.IMPORT;if(r&&i in r){var n=e.variableList;n||(e.variableList=n={}),n[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(i,'"')))}var $N=/^(\d+)x(\d+)$/,JN=/(.+?)=(".*?"|.*?)(?:,|$)/g,ZN=function(){function e(r,i){t(this,e),"string"==typeof r&&(r=e.parseAttrList(r,i)),AO(this,r)}return Fc(e,[{key:"clientAttrs",get:function(){var e;return xk(e=gv(this)).call(e,(function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=Ak(this[e],10);return t>aC?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t,r=Fv(t=this[e]||"0x").call(t,2);r=(1&r.length?"0":"")+r;for(var i=new Uint8Array(r.length/2),n=0;n<r.length/2;n++)i[n]=Ak(Fv(r).call(r,2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=Ak(this[e],16);return t>aC?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return bS(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?bS(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r,i=this[e];return mC(r=i?i.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=$N.exec(this[e]);if(null!==t)return{width:Ak(t[1],10),height:Ak(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,i,n={};for(JN.lastIndex=0;null!==(i=JN.exec(e));){var a,s=MS(a=i[1]).call(a),o=i[2],l=0===av(o).call(o,'"')&&HC(o).call(o,'"')===o.length-1,u=!1;if(l)o=Fv(o).call(o,1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":u=!0}if(t&&(l||u))o=zN(t,o);else if(!u&&!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":PO.warn(_d(r="".concat(e,": attribute ")).call(r,s," is missing quotes"))}n[s]=o}return n}}]),e}();function eU(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var tU=function(){function e(r,i){var n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t(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==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(n=null==i?void 0:i.tagOrder)?n:a,i){var s=i.attr;for(var o in s)if(Object.prototype.hasOwnProperty.call(r,o)&&r[o]!==s[o]){var l;PO.warn(_d(l='DATERANGE tag attribute: "'.concat(o,'" does not match for tags with ID: "')).call(l,r.ID,'"')),this._badValueForSameId=o;break}r=AO(new ZN({}),s,r)}if(this.attr=r,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(r["START-DATE"]),"END-DATE"in this.attr){var u=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);oO(u.getTime())&&(this._endDate=u)}}return Fc(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?(PO.warn(_d(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(oO(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"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&oO(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}(),rU=function(){function e(r){t(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=r}return Fc(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&&oO(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{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(SA()-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 iU(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function nU(e){switch(e){case"AES-128":case"AES-256":return KF;case"AES-256-CTR":return HF;default:throw new Error("invalid full segment method ".concat(e))}}function aU(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function sU(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function oU(e){var t,r,i=e.split(":"),n=null;if("data"===i[0]&&2===i.length){var a=i[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(ig(a).call(a,-1,1),n=aU(l)):(t=sU(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),n=r)}}return n}var lU="undefined"!=typeof self?self:void 0,uU="org.w3.clearkey",cU="com.apple.fps",hU="com.microsoft.playready",dU="com.widevine.alpha",fU="org.w3.clearkey",vU="com.apple.streamingkeydelivery",gU="com.microsoft.playready",pU="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function mU(e){switch(e){case vU:return cU;case gU:return hU;case pU:return dU;case fU:return uU}}var yU="1077efecc0b24d02ace33c1e52e2fb4b",EU="e2719d58a985b3c9781ab030af78d30e",kU="9a04f07998404286ab92e65be0885f95",TU="edef8ba979d64acea3c827dcd51d21ed";function SU(e){return e===TU?dU:e===kU?hU:e===yU||e===EU?uU:void 0}function AU(e){switch(e){case cU:return vU;case hU:return gU;case dU:return pU;case uU:return fU}}function LU(e){var t,r=e.drmSystems,i=e.widevineLicenseUrl,n=r?xk(t=[cU,dU,hU,uU]).call(t,(function(e){return!!r[e]})):[];return!n[dU]&&i&&n.push(dU),n}var bU,RU,IU=null!=lU&&null!=(bU=lU.navigator)&&bU.requestMediaKeySystemAccess?iT(RU=self.navigator.requestMediaKeySystemAccess).call(RU,self.navigator):null;function DU(e,t,r,i){var n;switch(e){case cU:n=["cenc","sinf"];break;case dU:case hU:n=["cenc"];break;case uU:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return function(e,t,r,i){var n={initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:_k(t).call(t,(function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:_k(r).call(r,(function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))};return[n]}(n,t,r,i)}function _U(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,LT(t)),i=r.substring(av(r).call(r,"<"),r.length),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){var a=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(a){var s=aU(a).subarray(0,16);return function(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(s),s}}return null}var wU={},CU=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;t(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=r,this.uri=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=s,this.encrypted=!!r&&"NONE"!==r,this.isCommonEncryption=this.encrypted&&!iU(r)}return Fc(e,[{key:"isSupported",value:function(){var e;if(this.method){if(iU(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case vU:case pU:case gU:case fU:return-1!==av(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(iU(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(PO.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue')),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var i=oU(this.uri);if(i)switch(this.keyFormat){case pU:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case gU:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=MN(n,0,i),this.keyId=_U(i);break;default:var a=i.subarray(0,16);if(16!==a.length){var s=new Uint8Array(16);s.set(a,16-a.length),a=s}this.keyId=a}if(!this.keyId||16!==this.keyId.byteLength){var o=wU[this.uri];if(!o){var l=gv(wU).length%aC;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),wU[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){wU={}}}]),e}();var PU=/#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,xU=/#EXT-X-MEDIA:(.*)/g,MU=/^#EXT(?:INF|-X-TARGETDURATION):/m,OU=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),FU=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("|")),NU=function(){function e(){t(this,e)}return Fc(e,null,[{key:"findGroup",value:function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}}},{key:"resolve",value:function(e,t){return rN.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return MU.test(e)}},{key:"parseMasterPlaylist",value:function(t,r){var i,n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:WN(t)},a=[];for(PU.lastIndex=0;null!=(i=PU.exec(t));)if(i[1]){var s,o=new ZN(i[1],n),l=zN(n,i[2]),u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),HU(o.CODECS,u),null!=(s=u.unknownCodecs)&&s.length||a.push(u),n.levels.push(u)}else if(i[3]){var h=i[3],d=i[4];switch(h){case"SESSION-DATA":var f=new ZN(d,n),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var g=GU(d,r,n);g.encrypted&&g.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(g)):PO.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(d,'"'));break;case"DEFINE":XN(n,new ZN(d,n),r);break;case"CONTENT-STEERING":var p=new ZN(d,n);n.contentSteering={uri:e.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=KU(d)}}var m=a.length>0&&a.length<n.levels.length;return n.levels=m?a:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n}},{key:"parseMasterPlaylistMedia",value:function(t,r,i){var n,a={},s=i.levels,o={AUDIO:_k(s).call(s,(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:_k(s).call(s,(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(xU.lastIndex=0;null!==(n=xU.exec(t));){var u=new ZN(n[1],i),c=u.TYPE;if(c){var h=o[c],d=a[c]||[];a[c]=d;var f=u.LANGUAGE,v=u["ASSOC-LANGUAGE"],g=u.CHANNELS,p=u.CHARACTERISTICS,m=u["INSTREAM-ID"],y={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||f||"",type:c,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:f,url:u.URI?e.resolve(u.URI,r):""};if(v&&(y.assocLang=v),g&&(y.channels=g),p&&(y.characteristics=p),m&&(y.instreamId=m),null!=h&&h.length){var E=e.findGroup(h,y.groupId)||h[0];VU(y,E,"audioCodec"),VU(y,E,"textCodec")}d.push(y)}}return a}},{key:"parseLevelPlaylist",value:function(e,t,r,i,n,a){var s,o,l,u={url:t},c=new rU(t),h=c.fragments,d=[],f=null,v=0,g=0,p=0,m=0,y=0,E=null,k=new uN(i,u),T=-1,S=!1,A=null;for(OU.lastIndex=0,c.m3u8=e,c.hasVariableRefs=WN(e);null!==(s=OU.exec(e));){S&&(S=!1,(k=new uN(i,u)).playlistOffset=p,k.start=p,k.sn=v,k.cc=m,y&&(k.bitrate=y),k.level=r,f&&(k.initSegment=f,f.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null),A&&(k.setByteRange(A),A=null)));var L=s[1];if(L){var b;k.duration=bS(L);var R=Fv(b=" "+s[2]).call(b,1);k.title=R||null,k.tagList.push(R?["INF",L,R]:["INF",L])}else if(s[3]){if(oO(k.duration)){var I;k.playlistOffset=p,k.start=p,l&&qU(k,l,c),k.sn=v,k.level=r,k.cc=m,h.push(k);var D=Fv(I=" "+s[3]).call(I,1);k.relurl=zN(c,D),jU(k,E,d),E=k,p+=k.duration,v++,g=0,S=!0}}else{var _,w,C;if(!(s=s[0].match(FU))){PO.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<s.length&&void 0===s[o];o++);var P=Fv(_=" "+s[o]).call(_,1),x=Fv(w=" "+s[o+1]).call(w,1),M=s[o+2]?Fv(C=" "+s[o+2]).call(C,1):null;switch(P){case"BYTERANGE":E?k.setByteRange(x,E):k.setByteRange(x);break;case"PROGRAM-DATE-TIME":k.rawProgramDateTime=x,k.tagList.push(["PROGRAM-DATE-TIME",x]),-1===T&&(T=h.length);break;case"PLAYLIST-TYPE":c.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":v=c.startSN=Ak(x);break;case"SKIP":c.skippedSegments&&(c.playlistParsingError=new Error("#EXT-X-SKIP MUST NOT appear more than once in a Playlist"));var O=new ZN(x,c),F=O.decimalInteger("SKIPPED-SEGMENTS");if(oO(F)){c.skippedSegments+=F;for(var N=F;N--;)h.push(null);v+=F}var U,B=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(B)c.recentlyRemovedDateranges=_d(U=c.recentlyRemovedDateranges||[]).call(U,B.split("\t"));break;case"TARGETDURATION":c.targetduration=Math.max(Ak(x),1);break;case"VERSION":c.version=Ak(x);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"#":(x||M)&&k.tagList.push(M?[x,M]:[x]);break;case"DISCONTINUITY":m++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([P]);break;case"BITRATE":k.tagList.push([P,x]),y=1e3*Ak(x),oO(y)?k.bitrate=y:y=0;break;case"DATERANGE":var G=new ZN(x,c),K=new tU(G,c.dateRanges[G.ID],c.dateRangeTagCount);c.dateRangeTagCount++,K.isValid||c.skippedSegments?c.dateRanges[K.id]=K:PO.warn('Ignoring invalid DATERANGE tag: "'.concat(x,'"')),k.tagList.push(["EXT-X-DATERANGE",x]);break;case"DEFINE":var H=new ZN(x,c);"IMPORT"in H?QN(c,H,a):XN(c,H,t);break;case"DISCONTINUITY-SEQUENCE":c.startCC=m=Ak(x);break;case"KEY":var V=GU(x,t,c);if(V.isSupported()){if("NONE"===V.method){l=void 0;break}l||(l={}),l[V.keyFormat]&&(l=AO({},l)),l[V.keyFormat]=V}else PO.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(x,'"'));break;case"START":c.startTimeOffset=KU(x);break;case"MAP":var j=new ZN(x,c);if(k.duration){var Y=new uN(i,u);YU(Y,j,r,l),f=Y,k.initSegment=f,f.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime)}else{var q=k.byteRangeEndOffset;if(q){var W,z=k.byteRangeStartOffset;A=_d(W="".concat(q-z,"@")).call(W,z)}else A=null;YU(k,j,r,l),f=k,S=!0}f.cc=m;break;case"SERVER-CONTROL":var X=new ZN(x);c.canBlockReload=X.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=X.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&X.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),c.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Q=new ZN(x);c.partTarget=Q.decimalFloatingPoint("PART-TARGET");break;case"PART":var $=c.partList;$||($=c.partList=[]);var J=g>0?$[$.length-1]:void 0,Z=g++,ee=new ZN(x,c),te=new cN(ee,k,u,Z,J);$.push(te),k.duration+=te.duration;break;case"PRELOAD-HINT":var re=new ZN(x,c);c.preloadHint=re;break;case"RENDITION-REPORT":var ie=new ZN(x,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(ie);break;default:PO.warn("line parsed but not handled: ".concat(s))}}}E&&!E.relurl?(h.pop(),p-=E.duration,c.partList&&(c.fragmentHint=E)):c.partList&&(jU(k,E,d),k.cc=m,c.fragmentHint=k,l&&qU(k,l,c));var ne=h.length,ae=h[0],se=h[ne-1];if((p+=c.skippedSegments*c.targetduration)>0&&ne&&se){c.averagetargetduration=p/ne;var oe=se.sn;c.endSN="initSegment"!==oe?oe:0,c.live||(se.endList=!0),ae&&!c.startCC&&(c.startCC=ae.cc),T>0&&(!function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,T),ae&&d.unshift(ae))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(p+=c.fragmentHint.duration),c.totalduration=p,d.length&&c.dateRangeTagCount&&ae&&UU(d,c),c.endCC=m,c}}]),e}();function UU(e,t){for(var r=e.length,i=e[r-1],n=t.live?1/0:t.totalduration,a=gv(t.dateRanges),s=a.length;s--;){var o=t.dateRanges[a[s]],l=o.startDate.getTime();o.tagAnchor=i.ref;for(var u=r;u--;){var c=BU(t,l,e,u,n);if(-1!==c){o.tagAnchor=t.fragments[c].ref;break}}}}function BU(e,t,r,i,n){var a=r[i];if(a){var s,o=a.programDateTime;if(t>=o||0===i)if(t<=o+1e3*(((null==(s=r[i+1])?void 0:s.start)||n)-a.start)){var l=r[i].sn-e.startSN,u=e.fragments;if(u.length>r.length)for(var c=(r[i+1]||u[u.length-1]).sn-e.startSN;c>l;c--){var h=u[c].programDateTime;if(t>=h&&t<h+1e3*u[c].duration)return c}return l}}return-1}function GU(e,t,r){var i,n,a,s,o=new ZN(e,r),l=null!=(a=o.METHOD)?a:"",u=o.URI,c=o.hexadecimalInteger("IV"),h=o.KEYFORMATVERSIONS,d=null!=(s=o.KEYFORMAT)?s:"identity";u&&o.IV&&!c&&PO.error("Invalid IV: ".concat(o.IV));var f=u?NU.resolve(u,t):"",v=xk(i=_k(n=(h||"1").split("/")).call(n,Number)).call(i,eC);return new CU(l,f,d,v,c)}function KU(e){var t=new ZN(e).decimalFloatingPoint("TIME-OFFSET");return oO(t)?t:null}function HU(e,t){var r,i,n=xk(r=(e||"").split(/[ ,]+/)).call(r,(function(e){return e}));vd(i=["video","audio","text"]).call(i,(function(e){var r=xk(n).call(n,(function(t){return function(e,t){var r=OO[t];return!!r&&!!r[Fv(e).call(e,0,4)]}(t,e)}));r.length&&(t["".concat(e,"Codec")]=r.join(","),n=xk(n).call(n,(function(e){return-1===av(r).call(r,e)})))})),t.unknownCodecs=n}function VU(e,t,r){var i=t[r];i&&(e[r]=i)}function jU(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function YU(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function qU(e,t,r){var i;e.levelkeys=t;var n=r.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!KT(i=gv(t)).call(i,(function(e){return t[e].isCommonEncryption}))||n.push(e)}function WU(e,t){var r=t.startPTS;if(oO(r)){var i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}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 zU(e,t,r,i,n,a){i-r<=0&&(PO.warn("Fragment should have a positive duration",t),i=r+t.duration,a=n+t.duration);var s=r,o=i,l=t.startPTS,u=t.endPTS;if(oO(l)){var c=Math.abs(l-r);oO(t.deltaPTS)?t.deltaPTS=Math.max(c,t.deltaPTS):t.deltaPTS=c,s=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),o=Math.min(i,u),i=Math.max(i,u),a=Math.max(a,t.endDTS)}var h=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=s,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=a;var d,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,g=e.fragments;for(g[v]=t,d=v;d>0;d--)WU(g[d],g[d-1]);for(d=v;d<g.length-1;d++)WU(g[d],g[d+1]);return e.fragmentHint&&WU(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function XU(e,t){for(var r,i=null,n=e.fragments,a=n.length-1;a>=0;a--){var s=n[a].initSegment;if(s){i=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var o,l=0;!function(e,t,r){for(var i,n,a=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,o=(e.fragmentHint?1:0)+(a?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,l=t.startSN-e.startSN,u=t.fragmentHint?_d(i=t.fragments).call(i,t.fragmentHint):t.fragments,c=e.fragmentHint?_d(n=e.fragments).call(n,e.fragmentHint):e.fragments,h=s;h<=o;h++){var d=c[l+h],f=u[h];a&&!f&&d&&(f=t.fragments[h]=d),d&&f&&r(d,f)}}(e,t,(function(e,r){e.relurl&&(l=e.cc-r.cc),oO(e.startPTS)&&oO(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,i=e.initSegment)}));var u,c=t.fragmentHint?_d(r=t.fragments).call(r,t.fragmentHint):t.fragments;if(i&&vd(c).call(c,(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)})),t.skippedSegments)if(t.deltaUpdateFailed=KT(u=t.fragments).call(u,(function(e){return!e})),t.deltaUpdateFailed){PO.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=t.skippedSegments;h--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC||(t.startCC=t.fragments[0].cc)}else{var d;t.canSkipDateRanges&&(t.dateRanges=function(e,t){var r=t.dateRanges,i=t.recentlyRemovedDateranges,n=AO({},e);i&&vd(i).call(i,(function(e){delete n[e]}));var a,s=gv(n).length;s&&vd(a=gv(r)).call(a,(function(e){var t=n[e],i=new tU(r[e].attr,t);i.isValid?(n[e]=i,t||(i.tagOrder+=s)):PO.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(yI(r[e].attr),'"'))}));return n}(e.dateRanges,t));var f=xk(d=e.fragments).call(d,(function(e){return e.rawProgramDateTime}));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var v=1;v<c.length;v++)null===c[v].programDateTime&&jU(c[v],c[v-1],f);UU(f,t)}var g=t.fragments;if(l){PO.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<g.length;p++)g[p].cc+=l}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),o?zU(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):QU(e,t),g.length&&(t.totalduration=t.edge-g[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var y=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=y),t.driftEndTime=m,t.driftEnd=y}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function QU(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,a=i>=0,s=0;if(a&&i<n.length)s=n[i].start;else if(a&&t.startSN===e.endSN+1)s=e.fragmentEnd;else if(a&&r)s=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;s=e.fragmentStart}$U(t,s)}function $U(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function JU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function ZU(e,t,r){return e?eB(e.partList,t,r):null}function eB(e,t,r){if(e)for(var i=e.length;i--;){var n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function tB(e){vd(e).call(e,(function(e,t){var r,i=null==(r=e.details)?void 0:r.fragments;i&&vd(i).call(i,(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function rB(e,t){for(var r=0,i=e.length;r<i;r++){var n;if((null==(n=e[r])?void 0:n.cc)===t)return e[r]}return null}function iB(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function nB(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)iB(r[i],e);t.fragmentHint&&iB(t.fragmentHint,e),t.alignedSliding=!0}function aB(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var r=Math.min(t.endCC,e.endCC),i=rB(t.fragments,r),n=rB(e.fragments,r);if(i&&n)PO.log("Aligning playlist at start of dicontinuity sequence ".concat(r)),nB(i.start-n.start,e)}}function sB(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n,a,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(n=rB(i,s),a=rB(r,s)),n&&a||(a=rB(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,l=a.programDateTime;if(o&&l)nB((l-o)/1e3-(a.start-n.start),e)}}}var oB=function(e){for(var t="",r=e.length,i=0;i<r;i++){var n;t+=_d(n="[".concat(e.start(i).toFixed(3),"-")).call(n,e.end(i).toFixed(3),"]")}return t},lB="STOPPED",uB="IDLE",cB="KEY_LOADING",hB="FRAG_LOADING",dB="FRAG_LOADING_WAITING_RETRY",fB="WAITING_TRACK",vB="PARSING",gB="PARSED",pB="ENDED",mB="ERROR",yB="WAITING_INIT_PTS",EB="WAITING_LEVEL",kB=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s,o){var l;return t(this,i),(l=r.call(this,s,e.logger)).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=lB,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var e,t=Zh(l),r=t.config,i=t.fragCurrent,n=t.media,a=t.mediaBuffer,s=t.state,o=n?n.currentTime:0,u=YN.bufferInfo(a||n,o,r.maxBufferHole);if(l.log(_d(e="media seeking to ".concat(oO(o)?o.toFixed(3):o,", state: ")).call(e,s)),l.state===pB)l.resetLoadingState();else if(i){var c=r.maxFragLookUpTolerance,h=i.start-c,d=i.start+i.duration+c;if(!u.len||d<u.start||h>u.end){var f=o>d;(o<h||f)&&(f&&i.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(n&&(l.fragmentTracker.removeFragmentsInRange(o,1/0,l.playlistType,!0),o>l.lastCurrentTime&&(l.lastCurrentTime=o),!l.loadingParts)){var v,g=Math.max(u.end,o),p=l.shouldLoadParts(l.getLevelDetails(),g);if(p)l.log(_d(v="LL-Part loading ON after seeking to ".concat(o.toFixed(2)," with buffer @")).call(v,g.toFixed(2))),l.loadingParts=p}l.hls.hasEnoughToStart||u.len||(l.log("setting startPosition to ".concat(o," because of seek before start")),l.nextLoadPosition=l.startPosition=o),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0,l.triggerEnded()},l.playlistType=o,l.hls=e,l.fragmentLoader=new UN(e.config),l.keyLoader=a,l.fragmentTracker=n,l.config=e.config,l.decrypter=new FN(e.config),l}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.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!==lB){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=lB}}},{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,i=e.nextStart,n=i&&(!r||i<t.edge);if(t.live||n||!e.end||!this.media)return!1;var a=t.partList;if(null!=a&&a.length){var s=a[a.length-1];return YN.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 i=this.config;this.levels&&i.autoStartLoad&&this.state===lB&&this.startLoad(i.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;null!==i&&(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),i.removeEventListener("seeking",this.onMediaSeeking),i.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),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=lB,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,Ih(Rh(i.prototype),"onHandlerDestroyed",this).call(this)}},{key:"loadFragment",value:function(e,t,r){var i=this.hls.config;if(i.interstitialsController&&!1!==i.enableInterstitialPlayback&&e.type!==EO){var n=this.hls.interstitialsManager,a=null==n?void 0:n.bufferingItem;if(a){var s=a.event;if(s){if(s.appendInPlace||Math.abs(e.start-a.start)>1||0===a.start)return}else{var o;if(e.end<=a.start&&!1===(null==(o=t.details)?void 0:o.live))return;if(e.start>a.end&&a.nextEvent)return}}}this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}},{key:"_loadFragForPlayback",value:function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(e){var t,r,n,a=e.frag;if(i.fragContextChanged(a))return i.warn(_d(t=_d(r=_d(n="".concat(a.type," sn: ")).call(n,a.sn)).call(r,e.part?" part: "+e.part.index:""," of ")).call(t,i.fragInfo(a,!1,e.part),") was dropped during download.")),void i.fragmentTracker.removeFragment(a);a.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){var t=i.state,r=e.frag;if(i.fragContextChanged(r))(t===hB||!i.fragCurrent&&t===vB)&&(i.fragmentTracker.removeFragment(r),i.state=uB);else{var n,a,s;if("payload"in e)i.log(_d(n=_d(a=_d(s="Loaded ".concat(r.type," sn: ")).call(s,r.sn," of ")).call(a,i.playlistLabel()," ")).call(n,r.level)),i.hls.trigger(dO.FRAG_LOADED,e);i._handleFragmentLoadComplete(e)}}})).catch((function(t){i.state!==lB&&i.state!==mB&&(i.warn("Frag error: ".concat((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))}))}},{key:"clearTrackerIfNeeded",value:function(e){var t,r=this.fragmentTracker;if(r.getState(e)===OF){var i=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=Math.max(e.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(a,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)===FF&&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(dO.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,i=e.frag,n=e.payload,a=i.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&iU(a.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,nU(a.method)).catch((function(e){throw t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(n){var a=self.performance.now();return t.trigger(dO.FRAG_DECRYPTED,{frag:i,payload:n,stats:{tstart:s,tdecrypt:a}}),e.payload=n,r.completeInitSegmentLoad(e)}))}return r.completeInitSegmentLoad(e)})).catch((function(t){r.state!==lB&&r.state!==mB&&(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!==lB&&(this.state=uB),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,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(_d(r=_d(i=_d(n=_d(a="Buffered ".concat(e.type," sn: ")).call(a,e.sn)).call(n,t?" part: "+t.index:""," of ")).call(i,this.fragInfo(e,!1,t)," > buffer:")).call(r,s?oB(YN.getBuffered(s)):"(detached)",")")),lN(e)){var o;if(e.type!==EO){var l,u=e.elementaryStreams;if(!KT(l=gv(u)).call(l,(function(e){return!!u[e]})))return void(this.state=uB)}var c=null==(o=this.levels)?void 0:o[e.level];null!=c&&c.fragmentError&&(this.log("Resetting level fragment error count of ".concat(c.fragmentError," on frag buffered")),c.fragmentError=0)}this.state=uB}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||KT(n).call(n,(function(e){return!e})),s=new VN(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t){var r,i,n,a,s,o,l=this,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,c=arguments.length>3?arguments[3]:void 0;this.fragCurrent=e;var h=null==t?void 0:t.details;if(!this.levels||!h)throw new Error("frag load aborted, missing level".concat(h?"":" detail","s"));var d,f,v,g,p=null;!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&h.encryptedFragments.length&&this.keyLoader.loadClear(e,h.encryptedFragments):(this.log(_d(d=_d(f=_d(v=_d(g="Loading key for ".concat(e.sn," of [")).call(g,h.startSN,"-")).call(v,h.endSN,"], ")).call(f,this.playlistLabel()," ")).call(d,e.level)),this.state=cB,this.fragCurrent=e,p=this.keyLoader.load(e).then((function(e){if(!l.fragContextChanged(e.frag))return l.hls.trigger(dO.KEY_LOADED,e),l.state===cB&&(l.state=uB),e})),this.hls.trigger(dO.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(p=tk.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var m=this.fragPrevious;if(lN(e)&&(!m||e.sn!==m.sn)){var y,E,k=this.shouldLoadParts(t.details,e.end);if(k!==this.loadingParts)this.log(_d(y=_d(E="LL-Part loading ".concat(k?"ON":"OFF"," loading sn ")).call(E,null==m?void 0:m.sn,"->")).call(y,e.sn)),this.loadingParts=k}if(u=Math.max(e.start,u||0),this.loadingParts&&lN(e)){var T=h.partList;if(T&&c){u>e.end&&h.fragmentHint&&(e=h.fragmentHint);var S=this.getNextPart(T,e,u);if(S>-1){var A,L,b,R,I,D,_,w,C,P,x=T[S];return e=this.fragCurrent=x.fragment,this.log(_d(A=_d(L=_d(b=_d(R=_d(I=_d(D=_d(_=_d(w=_d(C="Loading ".concat(e.type," sn: ")).call(C,e.sn," part: ")).call(w,x.index," (")).call(_,S,"/")).call(D,T.length-1,") of ")).call(I,this.fragInfo(e,!1,x),") cc: ")).call(R,e.cc," [")).call(b,h.startSN,"-")).call(L,h.endSN,"], target: ")).call(A,bS(u.toFixed(3)))),this.nextLoadPosition=x.start+x.duration,this.state=hB,P=p?p.then((function(r){return!r||l.fragContextChanged(r.frag)?null:l.doFragPartsLoad(e,x,t,c)})).catch((function(e){return l.handleFragLoadError(e)})):this.doFragPartsLoad(e,x,t,c).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(dO.FRAG_LOADING,{frag:e,part:x,targetBufferTime:u}),null===this.fragCurrent?tk.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):P}if(!e.url||this.loadedEndOfParts(T,u))return tk.resolve(null)}}if(lN(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(u.toFixed(2))),this.loadingParts=!1;else if(!e.url)return tk.resolve(null);this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Loading ".concat(e.type," sn: ")).call(s,e.sn," of ")).call(a,this.fragInfo(e,!1),") cc: ")).call(n,e.cc," ")).call(i,h?"["+h.startSN+"-"+h.endSN+"]":"",", target: ")).call(r,bS(u.toFixed(3)))),oO(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=hB;var M,O=this.config.progressive;return M=O&&p?p.then((function(t){return!t||l.fragContextChanged(null==t?void 0:t.frag)?null:l.fragmentLoader.load(e,c)})).catch((function(e){return l.handleFragLoadError(e)})):tk.all([this.fragmentLoader.load(e,O?c:void 0),p]).then((function(e){var t=cD(e,1)[0];return!O&&t&&c&&c(t),t})).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(dO.FRAG_LOADING,{frag:e,targetBufferTime:u}),null===this.fragCurrent?tk.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):M}},{key:"doFragPartsLoad",value:function(e,t,r,i){var n=this;return new tk((function(a,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function t(o){n.fragmentLoader.loadPart(e,o,i).then((function(i){l[o.index]=i;var s=i.part;n.hls.trigger(dO.FRAG_LOADED,i);var c=ZU(r.details,e.sn,o.index+1)||eB(u,e.sn,o.index+1);if(!c)return a({frag:e,part:s,partsLoaded:l});t(c)})).catch(s)}(t)}))}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;e.data&&t.details===hO.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(dO.ERROR,t)}else this.hls.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===vB){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a);var s,o=this.getLevelDetails(),l=o&&r.sn>o.endSN||this.shouldLoadParts(o,r.end);if(l!==this.loadingParts)this.log(_d(s="LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @")).call(s,r.end.toFixed(2))),this.loadingParts=l;this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===lB||this.state===mB||(this.state=uB)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var r,i,n=e.partList[0];if(t>=n.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0))if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t,r,i=this.levels,n=this.fragCurrent,a=e.level,s=e.sn,o=e.part;if(null==i||!i[a])return this.warn(_d(t=_d(r="Levels object was unset while buffering fragment ".concat(s," of ")).call(r,this.playlistLabel()," ")).call(t,a,". The current chunk will not be buffered.")),null;var l=i[a],u=l.details,c=o>-1?ZU(u,s,o):null,h=c?c.fragment:function(e,t,r){if(!e)return null;var i=e.fragments[t-e.startSN];return i||((i=e.fragmentHint)&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}(u,s,n);return h?(n&&n!==h&&(h.stats=n.stats),{frag:h,part:c,level:l}):null}},{key:"bufferFragmentData",value:function(e,t,r,i,n){var a;if(e&&this.state===vB){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=_N(s,o)),null!=(a=l)&&a.length){var u={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};if(this.hls.trigger(dO.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(YN.isBuffered(t,t.currentTime)){var r=t.currentTime,i=YN.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),s=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-s>a&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var r,i=this.getLoadPosition();if(!oO(i))return null;var n=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,n)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,r,i){var n=YN.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&(n.nextStart<=a.end||a.gap))return YN.bufferInfo(e,t,Math.max(n.nextStart,i))}return n}},{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,i=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn("Reduce max buffer length to ".concat(n,"s")),!0)}},{key:"getAppendedFrag",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:mO,i=null==(t=this.fragmentTracker)?void 0:t.getAppendedFrag(e,r);return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n=this.config,a=r[0].start,s=n.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l,u=n.initialLiveManifestSize;if(i<u)return this.warn(_d(l="Not enough fragments to start playback (have: ".concat(i,", need: ")).call(l,u,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a){var c,h,d,f;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,r);var v=this.hls.startPosition,g=this.hls.liveSyncPosition,p=o?(-1!==v?v:g)||o.start:e;this.log(_d(c=_d(h=_d(d="Setting startPosition to ".concat(p," to match initial live edge. mainStart: ")).call(d,v," liveSyncPosition: ")).call(h,g," frag.start: ")).call(c,null==(f=o)?void 0:f.start)),this.startPosition=this.nextLoadPosition=p}}else e<=a&&(o=r[0]);if(!o){var m=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,m,t)}return this.mapToInitFragWhenRequired(o)}},{key:"isLoopLoading",value:function(e,t){var r=this.fragmentTracker.getState(e);return(r===NF||r===FF&&!!e.gap)&&this.nextLoadPosition>t}},{key:"getNextFragmentLoopLoading",value:function(e,t,r,i,n){var a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t))&&!a.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==s&&r.len+s.len>=n){var o,l=a.sn;if(this.loopSn!==l)this.log(_d(o='buffer full after gaps in "'.concat(i,'" playlist starting at sn: ')).call(o,l)),this.loopSn=l;return null}}return this.loopSn=void 0,a}},{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 i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(n||l.independent||a)&&l.fragment===t&&(i=s),n=u}return i}},{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,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime)),i=function(e,t,r){if(null===t||!Pk(e)||!e.length||!oO(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 i=0;i<e.length;++i){var n=e[i];if(yF(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: ".concat(i.sn)))}i||(i=EF(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}},{key:"getFragmentAtPosition",value:function(e,t,r){var i,n,a=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=a.maxFragLookUpTolerance,h=r.partList,d=!!(this.loadingParts&&null!=h&&h.length&&u);(d&&u&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=_d(o).call(o,u),l=u.sn),e<t)?i=pF(s,o,e,e<this.lastCurrentTime||e>t-c||null!=(n=this.media)&&n.paused||!this.startFragRequested?0:c):i=o[o.length-1];if(i){var f=i.sn-r.startSN,v=this.fragmentTracker.getState(i);if((v===NF||v===FF&&i.gap)&&(s=i),s&&i.sn===s.sn&&(!d||h[0].fragment.sn>i.sn||!r.live&&!d))if(s&&i.level===s.level){var g=o[f+1];i=i.sn<l&&this.fragmentTracker.getState(g)!==NF?g:null}}return i}},{key:"alignPlaylists",value:function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var n=e.fragmentStart,a=!t,s=e.alignedSliding&&oO(n);if(a||!s&&!n){var o,l,u;!function(e,t){e&&(aB(t,e),!t.alignedSliding&&e&&sB(t,e),t.alignedSliding||!e||t.skippedSegments||QU(e,t,!1))}(r,e);var c=e.fragmentStart;return this.log(_d(o=_d(l=_d(u="Live playlist sliding: ".concat(c.toFixed(2)," start-sn: ")).call(u,t?t.startSN:"na","->")).call(l,e.startSN," fragments: ")).call(o,i)),c}return n}},{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 i,n,a=null!==this.startTimeOffset,s=a?this.startTimeOffset:e.startTimeOffset;if(null!==s&&oO(s))r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(_d(i=_d(n="Setting startPosition to ".concat(r," for start time offset ")).call(n,s," found in ")).call(i,a?"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,i,n;this.transmuxer&&e.type===this.playlistType&&lN(e)&&e.stats.aborted&&(this.warn(_d(r=_d(i=_d(n="Fragment ".concat(e.sn)).call(n,t?" part "+t.index:""," of ")).call(i,this.playlistLabel()," ")).call(r,e.level," was aborted")),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===dB)||(this.state=uB)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var n,a;this.warn(_d(n="Frag load error must match current frag to retry ".concat(i.url," > ")).call(n,null==(a=this.fragCurrent)?void 0:a.url))}else{var s=t.details===hO.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);var o=t.errorAction,l=o||{},u=l.action,c=IC(l),h=l.retryCount,d=void 0===h?0:h,f=l.retryConfig,v=!!o&&!!f,g=v&&u===DF,p=v&&!o.resolved&&c===wF;if(!g&&p&&lN(i)&&!i.endList)this.resetFragmentErrors(e),this.treatAsGap(i),o.resolved=!0;else if((g||p)&&d<f.maxNumRetry){var m,y,E,k,T,S;this.resetStartWhenNotLoaded(this.levelLastLoaded);var A=SF(f,d);this.warn(_d(m=_d(y=_d(E=_d(k=_d(T=_d(S="Fragment ".concat(i.sn," of ")).call(S,e," ")).call(T,i.level," errored with ")).call(k,t.details,", retrying loading ")).call(E,d+1,"/")).call(y,f.maxNumRetry," in ")).call(m,A,"ms")),o.resolved=!0,this.retryDate=self.performance.now()+A,this.state=dB}else if(f&&o){var L;if(this.resetFragmentErrors(e),!(d<f.maxNumRetry))return void this.warn(_d(L="".concat(t.details," reached or exceeded max retry (")).call(L,d,")"));s||u===IF||(o.resolved=!0)}else this.state=u===RF?EB:mB;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===vB||this.state===gB){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var a=!n;return a&&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(),a}return!1}},{key:"resetFragmentErrors",value:function(e){e===yO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==lB&&(this.state=uB)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var i=YN.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===pB&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==lB&&(this.state=uB)}},{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(_d(t=_d(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,i){var n,a,s,o,l,u=this,c=r.details;if(c){if(!mC(n=gv(e.elementaryStreams)).call(n,(function(t,n){var a=e.elementaryStreams[n];if(a){var s,o,l=a.endPTS-a.startPTS;if(l<=0)return u.warn(_d(s=_d(o="Could not parse fragment ".concat(e.sn," ")).call(o,n," duration reliably (")).call(s,l,")")),t||!1;var h=i?0:zU(c,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return u.hls.trigger(dO.LEVEL_PTS_UPDATED,{details:c,level:r,drift:h,type:n,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t}),!1)&&null===(null==(l=this.transmuxer)?void 0:l.error)){var h,d,f,v,g=new Error(_d(h=_d(d="Found no media in fragment ".concat(e.sn," of ")).call(d,this.playlistLabel()," ")).call(h,e.level," resetting transmuxer to fallback to playlist timing"));if(0===r.fragmentError&&this.treatAsGap(e,r),this.warn(g.message),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!1,error:g,frag:e,reason:_d(f=_d(v="Found no media in msn ".concat(e.sn," of ")).call(v,this.playlistLabel(),' "')).call(f,r.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=gB,this.log(_d(a=_d(s=_d(o="Parsed ".concat(e.type," sn: ")).call(o,e.sn)).call(s,t?" part: "+t.index:""," of ")).call(a,this.fragInfo(e,!1,t),")")),this.hls.trigger(dO.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===mO?"level":"track"}},{key:"fragInfo",value:function(e){var t,r,i,n,a,s,o,l=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],u=arguments.length>2?arguments[2]:void 0;return _d(t=_d(r=_d(i=_d(n=_d(a="".concat(this.playlistLabel()," ")).call(a,e.level," (")).call(n,u?"part":"frag",":[")).call(i,(null!=(s=l&&!u?e.startPTS:(u||e).start)?s:NaN).toFixed(3),"-")).call(r,(null!=(o=l&&!u?e.endPTS:(u||e).end)?o:NaN).toFixed(3),"]")).call(t,u&&"main"===e.type?"INDEPENDENT="+(u.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(_d(t="".concat(r,"->")).call(t,e)))}}]),i}(HN),TB=function(){function e(){t(this,e),this.chunks=[],this.dataLength=0}return Fc(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]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}]),e}();var SB={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||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 i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}rT&&(i.prototype=rT(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?Fv(i).call(i,1):i);return Xk?_d(n).call(n,Xk(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,a),!0;case 6:return c.fn.call(c.context,t,i,n,a,s),!0}for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),h){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,i);break;case 4:c[u].fn.call(c[u].context,t,i,n);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var l=0,u=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}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 i,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}(SB);var AB=XF(SB.exports),LB="1.6.0-beta.2",bB={};function RB(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 IB(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 DB(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 _B(e,t){for(var r=t,i=0;IB(e,t);){i+=10,i+=DB(e,t+6),RB(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function wB(e,t){return 255===e[t]&&240==(246&e[t+1])}function CB(e,t){return 1&e[t+1]?7:9}function PB(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function xB(e,t){return t+1<e.length&&wB(e,t)}function MB(e,t){if(xB(e,t)){var r=CB(e,t);if(t+r>=e.length)return!1;var i=PB(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||xB(e,n)}return!1}function OB(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i){var n,a,s,o,l,u=t[r+2],c=u>>2&15;if(!(c>12)){var h=1+(u>>6&3),d=t[r+3]>>6&3|(1&u)<<2,f="mp4a.40."+h,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][c],g=c;5!==h&&29!==h||(g-=3);var p=[h<<3|(14&g)>>1,(1&g)<<7|d<<3];return PO.log(_d(n=_d(a=_d(s=_d(o=_d(l="manifest codec:".concat(i,", parsed codec:")).call(l,f,", channels:")).call(o,d,", rate:")).call(s,v," (ADTS object type:")).call(a,h," sampling index:")).call(n,c,")")),{config:p,samplerate:v,channelCount:d,codec:f,parsedCodec:f,manifestCodec:i}}var m=new Error("invalid ADTS sampling index:".concat(c));e.emit(dO.ERROR,dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!0,error:m,reason:m.message})}(t,r,i,n);if(!a)return;AO(e,a)}}function FB(e){return 9216e4/e}function NB(e,t,r,i,n){var a,s=i+n*FB(e.samplerate),o=function(e,t){var r=CB(e,t);if(t+r<=e.length){var i=PB(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var l=o.frameLength,u=o.headerLength,c=u+l,h=Math.max(0,r+c-t.length);h?(a=new Uint8Array(c-u)).set(t.subarray(r+u,t.length),0):a=t.subarray(r+u,r+c);var d={unit:a,pts:s};return h||e.samples.push(d),{sample:d,length:c,missing:h}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}function UB(e,t){return IB(e,t)&&DB(e,t+6)+10<=e.length-t}function BB(e){return function(e,t,r,i){var n=(s=e,s instanceof ArrayBuffer?s:s.buffer),a=1;var s;"BYTES_PER_ELEMENT"in i&&(a=i.BYTES_PER_ELEMENT);var o=(d=e,d&&d.buffer instanceof ArrayBuffer&&void 0!==d.byteLength&&void 0!==d.byteOffset?e.byteOffset:0),l=(o+e.byteLength)/a,u=(o+t)/a,c=Math.floor(Math.max(0,Math.min(u,l))),h=Math.floor(Math.min(c+Math.max(r,0),l));var d;return new i(n,c,h-c)}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,Uint8Array)}function GB(e,t){if(e<0)return-GB(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<JC){var i=Math.floor(e*r);return(i%2==0?i:i+1)/r}return Math.round(e*r)/r}function KB(e){var t,r,i={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var n=av(t=e.data.subarray(1)).call(t,0);if(-1!==n){var a=WF(BB(e.data,1,n)),s=e.data[2+n],o=av(r=e.data.subarray(3+n)).call(r,0);if(-1!==o){var l,u,c=WF(BB(e.data,3+n,o));return l="--\x3e"===a?WF(BB(e.data,4+n+o)):(u=e.data.subarray(4+n+o))instanceof ArrayBuffer?u:0==u.byteOffset&&u.byteLength==u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer,i.mimeType=a,i.pictureType=s,i.description=c,i.data=l,i}}}else console.log("Ignore frame with unrecognized character encoding")}function HB(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=WF(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=WF(e.data.subarray(t),!0);t+=r.length+1;var i=WF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=WF(e.data);return{key:e.type,info:"",data:n}}(e):"APIC"===e.type?KB(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=WF(e.data.subarray(t),!0);t+=r.length+1;var i=WF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=WF(e.data.subarray(1));return{key:e.type,info:"",data:n}}}(e)}function VB(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=DB(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var jB=10,YB=10;function qB(e){for(var t=0,r=[];IB(e,t);){var i=DB(e,t+6);e[t+5]>>6&1&&(t+=jB);for(var n=(t+=jB)+i;t+YB<n;){var a=VB(e.subarray(t)),s=HB(a);s&&r.push(s),t+=a.size+jB}RB(e,t)&&(t+=jB)}return r}function WB(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function zB(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function XB(e){for(var t=qB(e),r=0;r<t.length;r++){var i=t[r];if(WB(i))return zB(i)}}var QB=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 $B(){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 JB=function(){function e(){t(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 Fc(e,[{key:"resetInitSegment",value:function(e,t,r,i){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=_N(this.cachedData,e),this.cachedData=null);var r,i=_B(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?XB(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&oO(o))&&(this.basePTS=ZB(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:QB.audioId3,duration:Number.POSITIVE_INFINITY});n<l;){if(this.canParse(e,n)){var u=this.appendFrame(a,e,n);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r=n+=u.length):n=l}else UB(e,n)?(i=_B(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:QB.audioId3,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===l&&r!==l){var c=jF(e,r);this.cachedData?this.cachedData=_N(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:$B(),id3Track:s,textTrack:$B()}}},{key:"demuxSampleAes",value:function(e,t,r){return tk.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:$B(),id3Track:this._id3Track,textTrack:$B()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),ZB=function(e,t,r){return oO(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},eG=null,tG=[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],rG=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],iG=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],nG=[0,1,1,4];function aG(e,t,r,i,n){if(!(r+24>t.length)){var a=sG(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function sG(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*tG[14*(3===r?3-i:3===i?3:4)+n-1],u=rG[3*(3===r?0:2===r?1:2)+a],c=3===o?1:2,h=iG[r][i],d=nG[i],f=8*h*d,v=Math.floor(h*l/u+s)*d;if(null===eG){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);eG=g?Ak(g[1]):0}return!!eG&&eG<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:c,frameLength:v,samplesPerFrame:f}}}function oG(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function lG(e,t){return t+1<e.length&&oG(e,t)}function uG(e,t){if(t+1<e.length&&oG(e,t)){var r=sG(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||lG(e,n)}return!1}var cG=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this)).observer=void 0,a.config=void 0,a.observer=e,a.config=n,a}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&wB(e,t)&&PB(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){OB(e,this.observer,t,r,e.manifestCodec);var i=NB(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}}],[{key:"probe",value:function(e,t){if(!e)return!1;var r=_B(e,0),i=(null==r?void 0:r.length)||0;if(uG(e,i))return!1;for(var n=e.length;i<n;i++)if(MB(e,i))return t.log("ADTS sync word found !"),!0;return!1}}]),i}(JB),hG=function(e,t){var r=0,i=5;t+=i;for(var n=new Uint32Array(1),a=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),l=8-o;a[0]=4278190080>>>24+l<<l,n[0]=(s[0]&a[0])>>l,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r},dG=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this)).observer=void 0,n.observer=e,n}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,r){var i=fG(e,t,r,this.basePTS,this.frameIndex);if(-1!==i)return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=_B(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==XB(t)&&hG(e,r)<16}}]),i}(JB);function fG(e,t,r,i,n){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;var a=t[r+4]>>6;if(a>=3)return-1;var s=[48e3,44100,32e3][a],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+a];if(r+l>t.length)return-1;var u=t[r+6]>>5,c=0;2===u?c+=2:(1&u&&1!==u&&(c+=2),4&u&&(c+=2));var h=(t[r+6]<<8|t[r+7])>>12-c&1,d=[2,1,2,3,3,4,4,5][u]+h,f=t[r+5]>>3,v=7&t[r+5],g=new Uint8Array([a<<6|f<<1|v>>2,(3&v)<<6|u<<3|h<<2|o>>4,o<<4&224]),p=i+n*(1536/s*9e4),m=t.subarray(r,r+l);return e.config=g,e.channelCount=d,e.samplerate=s,e.samples.push({unit:m,pts:p}),l}var vG=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return oG(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return aG(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=_B(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==XB(t)&&hG(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(uG(e,r))return PO.log("MPEG Audio sync word found !"),!0;return!1}}]),i}(JB),gG=/\/emsg[-/]ID3/i,pG=function(){function e(r,i){t(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=i}return Fc(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,i){var n=this.videoTrack=$B("video",1),a=this.audioTrack=$B("audio",1),s=this.txtTrack=$B("text",1);if(this.id3Track=$B("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=SN(e);if(o.video){var l=o.video,u=l.id,c=l.timescale,h=l.codec;n.id=u,n.timescale=s.timescale=c,n.codec=h}if(o.audio){var d=o.audio,f=d.id,v=d.timescale,g=d.codec;a.id=f,a.timescale=v,a.codec=g}s.id=fN.text,n.sampleDuration=0,n.duration=a.duration=i}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=_N(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=kN(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=jF(e,0,i.byteOffset-8),t.remainder=jF(e,i.byteOffset-8),t}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return n.samples=wN(t,i),{videoTrack:i,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 i=this.extractID3Track(t,this.timeOffset);return r.samples=wN(e,t),{videoTrack:t,audioTrack:$B(),id3Track:i,textTrack:$B()}}},{key:"extractID3Track",value:function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var n=kN(e.samples,["emsg"]);n&&vd(n).call(n,(function(e){var n,a=function(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==vN(e.subarray(u,u+1));)r+=vN(e.subarray(u,u+1)),u+=1;for(r+=vN(e.subarray(u,u+1)),u+=1;"\0"!==vN(e.subarray(u,u+1));)i+=vN(e.subarray(u,u+1)),u+=1;i+=vN(e.subarray(u,u+1)),u+=1,n=pN(e,12),a=pN(e,16),o=pN(e,20),l=pN(e,24),u=28}else if(1===t){n=pN(e,u+=4);var c=pN(e,u+=4),h=pN(e,u+=4);for(u+=4,s=Math.pow(2,32)*c+h,lO(s)||(s=aC,PO.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=pN(e,u),l=pN(e,u+=4),u+=4;"\0"!==vN(e.subarray(u,u+1));)r+=vN(e.subarray(u,u+1)),u+=1;for(r+=vN(e.subarray(u,u+1)),u+=1;"\0"!==vN(e.subarray(u,u+1));)i+=vN(e.subarray(u,u+1)),u+=1;i+=vN(e.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(u,e.byteLength)}}(e);if(gG.test(a.schemeIdUri)){var s=mG(a,t),o=4294967295===a.eventDuration?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;o<=.001&&(o=Number.POSITIVE_INFINITY);var l=a.payload;i.samples.push({data:l,len:l.byteLength,dts:s,pts:s,type:QB.emsg,duration:o})}else if(r.config.enableEmsgKLVMetadata&&KI(n=a.schemeIdUri).call(n,"urn:misb:KLV:bin:1910.1")){var u=mG(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:u,pts:u,type:QB.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return i}},{key:"demuxSampleAes",value:function(e,t,r){return tk.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 function(e){for(var t=e.byteLength,r=0;r<t;){var i=pN(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}}]),e}();function mG(e,t){return oO(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var yG=function(){function e(r,i,n){t(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new FN(i,{removePKCS7Padding:!1})}return Fc(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,KF)}},{key:"decryptAacSample",value:function(e,t,r){var i,n=this,a=e[t].unit;if(!(a.length<=16)){var s=a.subarray(16,a.length-a.length%16),o=Fv(i=s.buffer).call(i,s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(o).then((function(i){var s=new Uint8Array(i);a.set(s,16),n.decrypter.isSync()||n.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),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e}},{key:"decryptAvcSample",value:function(e,t,r,i,n){var a=this,s=xN(n.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){n.data=a.getAvcDecryptedUnit(s,o),a.decrypter.isSync()||a.decryptAvcSamples(e,t,r+1,i)}))}},{key:"decryptAvcSamples",value:function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,r,i,a),this.decrypter.isSync())))return}}}}]),e}(),EG=function(){function e(){t(this,e),this.VideoSample=null}return Fc(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,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var n=i.units;r=n[n.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,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,r){var i,n,a=t.byteLength,s=e.naluState||0,o=s,l=[],u=0,c=-1,h=0;for(-1===s&&(c=0,h=this.getNALuType(t,0),s=0,u=1);u<a;)if(i=t[u++],s)if(1!==s)if(i)if(1===i){if(n=u-s-1,c>=0){var d={data:t.subarray(c,n),type:h};l.push(d)}else{var f=this.getLastNalUnit(e.samples);f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),n>0&&(f.data=_N(f.data,t.subarray(0,n)),f.state=0))}u<a?(c=u,h=this.getNALuType(t,u),s=0):s=-1}else s=0;else s=3;else s=i?0:2;else s=i?0:1;if(c>=0&&s>=0){var v={data:t.subarray(c,a),type:h,state:s};l.push(v)}if(0===l.length){var g=this.getLastNalUnit(e.samples);g&&(g.data=_N(g.data,t))}return e.naluState=s,l}}]),e}(),kG=function(){function e(r){t(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=r,this.bytesAvailable=r.byteLength,this.word=0,this.bitsAvailable=0}return Fc(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}},{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&&PO.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}(),TG=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),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)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 1:var c=!1;n=!0;var h,d=i.data;if(l&&d.length>4){var f=a.readSliceType(d);2!==f&&4!==f&&7!==f&&9!==f||(c=!0)}if(c)null!=(h=o)&&h.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=c;break;case 5:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:n=!0,PN(i.data,1,r.pts,t.samples);break;case 7:var v,g;n=!0,l=!0;var p=i.data,m=a.readSPS(p);if(!e.sps||e.width!==m.width||e.height!==m.height||(null==(v=e.pixelRatio)?void 0:v[0])!==m.pixelRatio[0]||(null==(g=e.pixelRatio)?void 0:g[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[p];for(var y=p.subarray(1,4),E="avc1.",k=0;k<3;k++){var T=y[k].toString(16);T.length<2&&(T="0"+T),E+=T}e.codec=E}break;case 8:n=!0,e.pps=[i.data];break;case 9:n=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(a.pushAccessUnit(o,e),o=null),o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts));break;case 12:n=!0;break;default:n=!1}o&&n&&o.units.push(i)})),i&&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 kG(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var r=8,i=8,n=0;n<e;n++)0!==i&&(i=(r+t.readEG()+256)%256),r=0===i?r:i}},{key:"readSPS",value:function(e){var t,r,i,n,a,s,o,l,u,c,h,d=new kG(e),f=0,v=0,g=0,p=0,m=iT(t=d.readUByte).call(t,d),y=iT(r=d.readBits).call(r,d),E=iT(i=d.readUEG).call(i,d),k=iT(n=d.readBoolean).call(n,d),T=iT(a=d.skipBits).call(a,d),S=iT(s=d.skipEG).call(s,d),A=iT(o=d.skipUEG).call(o,d),L=iT(l=this.skipScalingList).call(l,this);m();var b=m();if(y(5),T(3),m(),A(),100===b||110===b||122===b||244===b||44===b||83===b||86===b||118===b||128===b){var R=E();if(3===R&&T(1),A(),A(),T(1),k())for(c=3!==R?8:12,h=0;h<c;h++)k()&&L(h<6?16:64,d)}A();var I=E();if(0===I)E();else if(1===I)for(T(1),S(),S(),u=E(),h=0;h<u;h++)S();A(),T(1);var D=E(),_=E(),w=y(1);0===w&&T(1),T(1),k()&&(f=E(),v=E(),g=E(),p=E());var C=[1,1];if(k()&&k())switch(m()){case 1:C=[1,1];break;case 2:C=[12,11];break;case 3:C=[10,11];break;case 4:C=[16,11];break;case 5:C=[40,33];break;case 6:C=[24,11];break;case 7:C=[20,11];break;case 8:C=[32,11];break;case 9:C=[80,33];break;case 10:C=[18,11];break;case 11:C=[15,11];break;case 12:C=[64,33];break;case 13:C=[160,99];break;case 14:C=[4,3];break;case 15:C=[3,2];break;case 16:C=[2,1];break;case 255:C=[m()<<8|m(),m()<<8|m()]}return{width:Math.ceil(16*(D+1)-2*f-2*v),height:(2-w)*(_+1)*16-(w?2:4)*(g+p),pixelRatio:C}}}]),i}(EG),SG=function(e){Ph(i,e);var r=ed(i);function i(){var e,n;t(this,i);for(var a=arguments.length,s=new Array(a),o=0;o<a;o++)s[o]=arguments[o];return(n=r.call.apply(r,_d(e=[this]).call(e,s))).initVPS=null,n}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),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)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts)),o.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var c;if(n=!0,l)null!=(c=o)&&c.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 39:n=!0,PN(i.data,2,r.pts,t.samples);break;case 32:if(n=!0,!e.vps){var h=a.readVPS(i.data);e.params=bO({},h),a.initVPS=i.data}e.vps=[i.data];break;case 33:if(n=!0,l=!0,"object"===Cc(e.params)){if(void 0===e.vps||e.vps[0]===a.initVPS||void 0===e.sps||a.matchSPS(e.sps[0],i.data)||(a.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=a.readSPS(i.data);for(var f in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],d.params)e.params[f]=d.params[f]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.sps.push(i.data)}o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0;break;case 34:if(n=!0,"object"===Cc(e.params)){if(!e.pps){e.pps=[];var v=a.readPPS(i.data);for(var g in v)e.params[g]=v[g]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.pps.push(i.data)}break;case 35:n=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(a.pushAccessUnit(o,e),o=null),o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts));break;default:n=!1}o&&n&&o.units.push(i)})),i&&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,i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}},{key:"pushAccessUnit",value:function(e,t){Ih(Rh(i.prototype),"pushAccessUnit",this).call(this,e,t),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new kG(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,i,n,a=new kG(this.ebsp2rbsp(e));a.readUByte(),a.readUByte(),a.readBits(4);var s=a.readBits(3);a.readBoolean();for(var o=a.readBits(2),l=a.readBoolean(),u=a.readBits(5),c=a.readUByte(),h=a.readUByte(),d=a.readUByte(),f=a.readUByte(),v=a.readUByte(),g=a.readUByte(),p=a.readUByte(),m=a.readUByte(),y=a.readUByte(),E=a.readUByte(),k=a.readUByte(),T=[],S=[],A=0;A<s;A++)T.push(a.readBoolean()),S.push(a.readBoolean());if(s>0)for(var L=s;L<8;L++)a.readBits(2);for(var b=0;b<s;b++)T[b]&&(a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte()),S[b]&&a.readUByte();a.readUEG();var R=a.readUEG();3==R&&a.skipBits(1);var I=a.readUEG(),D=a.readUEG(),_=a.readBoolean(),w=0,C=0,P=0,x=0;_&&(w+=a.readUEG(),C+=a.readUEG(),P+=a.readUEG(),x+=a.readUEG());for(var M=a.readUEG(),O=a.readUEG(),F=a.readUEG(),N=a.readBoolean()?0:s;N<=s;N++)a.skipUEG(),a.skipUEG(),a.skipUEG();if((a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.readBoolean())&&a.readBoolean())for(var U=0;U<4;U++)for(var B=0;B<(3===U?2:6);B++){if(a.readBoolean()){var G=Math.min(64,1<<4+(U<<1));U>1&&a.readEG();for(var K=0;K<G;K++)a.readEG()}else a.readUEG()}a.readBoolean(),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.skipUEG(),a.skipUEG(),a.readBoolean());for(var H=a.readUEG(),V=0,j=0;j<H;j++){var Y=!1;if(0!==j&&(Y=a.readBoolean()),Y){j===H&&a.readUEG(),a.readBoolean(),a.readUEG();for(var q=0,W=0;W<=V;W++){var z=a.readBoolean(),X=!1;z||(X=a.readBoolean()),(z||X)&&q++}V=q}else{var Q=a.readUEG(),$=a.readUEG();V=Q+$;for(var J=0;J<Q;J++)a.readUEG(),a.readBoolean();for(var Z=0;Z<$;Z++)a.readUEG(),a.readBoolean()}}if(a.readBoolean())for(var ee=a.readUEG(),te=0;te<ee;te++){for(var re=0;re<F+4;re++)a.readBits(1);a.readBits(1)}var ie=0,ne=1,ae=1,se=!0,oe=1,le=0;a.readBoolean(),a.readBoolean();var ue=!1;if(a.readBoolean()){if(a.readBoolean()){var ce=a.readUByte();ce>0&&ce<16?(ne=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ce-1],ae=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ce-1]):255===ce&&(ne=a.readBits(16),ae=a.readBits(16))}if(a.readBoolean()&&a.readBoolean(),a.readBoolean())a.readBits(3),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.readUByte(),a.readUByte());if(a.readBoolean()&&(a.readUEG(),a.readUEG()),a.readBoolean(),a.readBoolean(),a.readBoolean(),(ue=a.readBoolean())&&(w+=a.readUEG(),C+=a.readUEG(),P+=a.readUEG(),x+=a.readUEG()),a.readBoolean())if(oe=a.readBits(32),le=a.readBits(32),a.readBoolean()&&a.readUEG(),a.readBoolean()){var he=a.readBoolean(),de=a.readBoolean(),fe=!1;(he||de)&&((fe=a.readBoolean())&&(a.readUByte(),a.readBits(5),a.readBoolean(),a.readBits(5)),a.readBits(4),a.readBits(4),fe&&a.readBits(4),a.readBits(5),a.readBits(5),a.readBits(5));for(var ve=0;ve<=s;ve++){var ge=!1;(se=a.readBoolean())||a.readBoolean()?a.readEG():ge=a.readBoolean();var pe=ge?1:a.readUEG()+1;if(he)for(var me=0;me<pe;me++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1);if(de)for(var ye=0;ye<pe;ye++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1)}}a.readBoolean()&&(a.readBoolean(),a.readBoolean(),a.readBoolean(),ie=a.readUEG())}var Ee=I,ke=D;if(_||ue){var Te=1,Se=1;1===R?Te=Se=2:2==R&&(Te=2),Ee=I-Te*C-Te*w,ke=D-Se*x-Se*P}for(var Ae=o?["A","B","C"][o]:"",Le=c<<24|h<<16|d<<8|f,be=0,Re=0;Re<32;Re++)be=(be|(Le>>Re&1)<<31-Re)>>>0;var Ie=be.toString(16);1===u&&"2"===Ie&&(Ie="6");var De=l?"H":"L";return{codecString:_d(t=_d(r=_d(i=_d(n="hvc1.".concat(Ae)).call(n,u,".")).call(i,Ie,".")).call(r,De)).call(t,k,".B0"),params:{general_tier_flag:l,general_profile_idc:u,general_profile_space:o,general_profile_compatibility_flags:[c,h,d,f],general_constraint_indicator_flags:[v,g,p,m,y,E],general_level_idc:k,bit_depth:M+8,bit_depth_luma_minus8:M,bit_depth_chroma_minus8:O,min_spatial_segmentation_idc:ie,chroma_format_idc:R,frame_rate:{fixed:se,fps:le/oe}},width:Ee,height:ke,pixelRatio:[ne,ae]}}},{key:"readPPS",value:function(e){var t=new kG(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(),i=t.readBoolean(),n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}]),i}(EG),AG=188,LG=function(){function e(r,i,n,a){t(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=r,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return Fc(e,[{key:"resetInitSegment",value:function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=e.createTrack("audio",n),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=i}},{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 i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];n||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,c=s.pid,h=s.pesData,d=o.pid,f=l.pid,v=o.pesData,g=l.pesData,p=null,m=this.pmtParsed,y=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=_N(this.remainderData,t)).length,this.remainderData=null),E<AG&&!a)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var k=Math.max(0,e.syncOffset(t));(E-=(E-k)%AG)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var T=0,S=k;S<E;S+=AG)if(71===t[S]){var A=!!(64&t[S+1]),L=bG(t,S),b=void 0;if((48&t[S+3])>>4>1){if((b=S+5+t[S+4])===S+AG)continue}else b=S+4;switch(L){case c:if(A){if(h&&(i=wG(h,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new TG;break;case"hevc":this.videoParser=new SG}null!==this.videoParser&&this.videoParser.parsePES(s,u,i,!1)}h={data:[],size:0}}h&&(h.data.push(t.subarray(b,S+AG)),h.size+=S+AG-b);break;case d:if(A){if(v&&(i=wG(v,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,i);break;case"mp3":this.parseMPEGPES(o,i);break;case"ac3":this.parseAC3PES(o,i)}v={data:[],size:0}}v&&(v.data.push(t.subarray(b,S+AG)),v.size+=S+AG-b);break;case f:A&&(g&&(i=wG(g,this.logger))&&this.parseID3PES(l,i),g={data:[],size:0}),g&&(g.data.push(t.subarray(b,S+AG)),g.size+=S+AG-b);break;case 0:A&&(b+=t[b]+1),y=this._pmtId=RG(t,b);break;case y:A&&(b+=t[b]+1);var R,I,D=IG(t,b,this.typeSupported,n,this.observer,this.logger);if((c=D.videoPid)>0&&(s.pid=c,s.segmentCodec=D.segmentVideoCodec),(d=D.audioPid)>0&&(o.pid=d,o.segmentCodec=D.segmentAudioCodec),(f=D.id3Pid)>0&&(l.pid=f),null!==p&&!m)this.logger.warn(_d(R=_d(I="MPEG-TS PMT found at ".concat(S," after unknown PID '")).call(I,p,"'. Backtracking to sync byte @")).call(R,k," to parse all TS packets.")),p=null,S=k-188;m=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=L}}else T++;T>0&&DG(this.observer,new Error("Found ".concat(T," TS packet/s that do not start with 0x47")),void 0,this.logger),s.pesData=h,o.pesData=v,l.pesData=g;var _={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(_),_}},{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,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(t=wG(s,this.logger))){if(null===this.videoParser)switch(i.segmentCodec){case"avc":this.videoParser=new TG;break;case"hevc":this.videoParser=new SG}null!==this.videoParser&&(this.videoParser.parsePES(i,a,t,!0),i.pesData=null)}else i.pesData=s;if(o&&(t=wG(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=wG(l,this.logger))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=l}},{key:"demuxSampleAes",value:function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new yG(this.observer,this.config,t);return this.decrypt(i,n)}},{key:"decrypt",value:function(e,t){return new tk((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.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,i,n,a=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=_N(s.sample.unit,o);else{var c=u-l;s.sample.unit.set(o.subarray(0,l),c),e.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r<i-1&&!xB(o,r);r++);if(r!==a){var h,d=r<i-1;if(h=d?"AAC PES did not start with ADTS header,offset:".concat(r):"No ADTS header found in AAC PES",DG(this.observer,new Error(h),d,this.logger),!d)return}if(OB(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)n=t.pts;else{if(!s)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var f=FB(e.samplerate);n=s.sample.pts+f}for(var v,g=0;r<i;){if(r+=(v=NB(e,o,r,n,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!xB(o,r);r++);}}},{key:"parseMPEGPES",value:function(e,t){var r=t.data,i=r.length,n=0,a=0,s=t.pts;if(void 0!==s)for(;a<i;)if(lG(r,a)){var o=aG(e,r,a,s,n);if(!o)break;a+=o.length,n++}else a++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var r=t.data,i=t.pts;if(void 0!==i)for(var n,a=r.length,s=0,o=0;o<a&&(n=fG(e,r,o,i,s++))>0;)o+=n;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var r=AO({},t,{type:this._videoTrack?QB.emsg:QB.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 i=e.syncOffset(t);return i>0&&r.warn("MPEG2-TS detected but first sync word found @ offset ".concat(i)),-1!==i}},{key:"syncOffset",value:function(e){for(var t=e.length,r=Math.min(940,t-AG)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=AG){if(71!==e[o]||t-o!==AG&&71!==e[o+AG]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-AG)+1),n||(n=0===bG(e,o)),n&&s>1&&(0===a&&s>2||o+AG>r))return a}i++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:fN[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function bG(e,t){return((31&e[t+1])<<8)+e[t+2]}function RG(e,t){return(31&e[t+10])<<8|e[t+11]}function IG(e,t,r,i,n,a){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=bG(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){_G("ADTS AAC",a);break}case 15:-1===s.audioPid&&(s.audioPid=l);break;case 21:-1===s.id3Pid&&(s.id3Pid=l);break;case 219:if(!i){_G("H.264",a);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"):a.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){_G("AC-3",a);break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="ac3"):a.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&u>0)for(var c=t+5,h=u;h>2;){if(106===e[c])!0!==r.ac3?a.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");var d=e[c+1]+2;c+=d,h-=d}break;case 194:case 135:return DG(n,new Error("Unsupported EC-3 in M2TS found"),void 0,a),s;case 36:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="hevc",a.log("HEVC in M2TS found"))}t+=u+5}return s}function DG(e,t,r,i){i.warn("parsing error: ".concat(t.message)),e.emit(dO.ERROR,dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function _G(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function wG(e,t){var r,i,n,a,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=_N(l[0],l[1]),ig(l).call(l,1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;var u=r[7];192&u&&(a=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?a-(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((a-s)/9e4),"s delta between PTS and DTS, align them")),a=s):s=a);var c=(n=r[8])+9;if(e.size<=c)return null;e.size-=c;for(var h=new Uint8Array(e.size),d=0,f=l.length;d<f;d++){var v=(r=l[d]).byteLength;if(c){if(c>v){c-=v;continue}r=r.subarray(c),v-=c,c=0}h.set(r,o),o+=v}return i&&(i-=n+3),{data:h,pts:a,dts:s,len:i}}return null}var CG=function(){function e(){t(this,e)}return Fc(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}(),PG=Math.pow(2,32)-1,xG=function(){function e(){t(this,e)}return Fc(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]),i=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:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,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,n))}},{key:"box",value:function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].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),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].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 i=Math.floor(r/(PG+1)),n=Math.floor(r%(PG+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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))}},{key:"moov",value:function(t){for(var r,i,n=t.length,a=[];n--;)a[n]=e.trak(t[n]);return e.box.apply(null,_d(r=_d(i=[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)]).call(i,a)).call(r,e.mvex(t)))}},{key:"mvex",value:function(t){for(var r,i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,_d(r=[e.types.mvex]).call(r,n))}},{key:"mvhd",value:function(t,r){r*=t;var i=Math.floor(r/(PG+1)),n=Math.floor(r%(PG+1)),a=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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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,a)}},{key:"sdtp",value:function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=IC(n[r]),a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)}},{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,i,n,a,s,o,l=[],u=[];for(a=0;a<t.sps.length;a++)o=(s=t.sps[a]).byteLength,l.push(o>>>8&255),l.push(255&o),l=_d(l).call(l,Fv(Array.prototype).call(s));for(a=0;a<t.pps.length;a++)o=(s=t.pps[a]).byteLength,u.push(o>>>8&255),u.push(255&o),u=_d(u).call(u,Fv(Array.prototype).call(s));var c=e.box(e.types.avcC,new Uint8Array(_d(r=_d(i=_d(n=[1,l[3],l[4],l[5],255,224|t.sps.length]).call(n,l)).call(i,[t.pps.length])).call(r,u))),h=t.width,d=t.height,f=t.pixelRatio[0],v=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,h>>8&255,255&h,d>>8&255,255&d,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]),c,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([f>>24,f>>16&255,f>>8&255,255&f,v>>24,v>>16&255,v>>8&255,255&v])))}},{key:"esds",value:function(e){var t,r=e.config;return new Uint8Array(_d(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,uD(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,i=t.duration*t.timescale,n=t.width,a=t.height,s=Math.floor(i/(PG+1)),o=Math.floor(i%(PG+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,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))}},{key:"traf",value:function(t,r){var i=e.sdtp(t),n=t.id,a=Math.floor(r/(PG+1)),s=Math.floor(r%(PG+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)}},{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 i,n,a,s,o,l,u=t.samples||[],c=u.length,h=12+16*c,d=new Uint8Array(h);for(r+=8+h,d.set(["video"===t.type?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<c;i++)a=(n=u[i]).duration,s=n.size,o=IC(n),l=n.cts,d.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,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*i);return e.box(e.types.trun,d)}},{key:"initSegment",value:function(t){e.types||e.init();var r=e.moov(t);return _N(e.FTYP,r)}},{key:"hvc1",value:function(t){for(var r=t.params,i=[t.vps,t.sps,t.pps],n=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,Ak(r.frame_rate.fps),3|r.temporal_id_nested<<2|r.num_temporal_layers<<3|(r.frame_rate.fixed?64:0),i.length]),a=n.length,s=0;s<i.length;s+=1){a+=3;for(var o=0;o<i[s].length;o+=1)a+=2+i[s][o].length}var l=new Uint8Array(a);l.set(n,0),a=n.length;for(var u=i.length-1,c=0;c<i.length;c+=1){l.set(new Uint8Array([32+c|(c===u?128:0),0,i[c].length]),a),a+=3;for(var h=0;h<i[c].length;h+=1)l.set(new Uint8Array([i[c][h].length>>8,255&i[c][h].length]),a),a+=2,l.set(i[c][h],a),a+=i[c][h].length}var d=e.box(e.types.hvcC,l),f=t.width,v=t.height,g=t.pixelRatio[0],p=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,f>>8&255,255&f,v>>8&255,255&v,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,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([g>>24,g>>16&255,g>>8&255,255&g,p>>24,p>>16&255,p>>8&255,255&p])))}}]),e}();xG.types=void 0,xG.HDLR_TYPES=void 0,xG.STTS=void 0,xG.STSC=void 0,xG.STCO=void 0,xG.STSZ=void 0,xG.VMHD=void 0,xG.SMHD=void 0,xG.STSD=void 0,xG.FTYP=void 0,xG.DINF=void 0;var MG=9e4;function OG(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 FG(e){return OG(e,1e3,1/MG,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}var NG=null,UG=null,BG=function(){function e(r,i,n,a){if(t(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=r,this.config=i,this.typeSupported=n,this.logger=a,this.ISGenerated=!1,null===NG){var s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);NG=s?Ak(s[1]):0}if(null===UG){var o=navigator.userAgent.match(/Safari\/(\d+)/i);UG=o?Ak(o[1]):0}}return Fc(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,i=mC(e).call(e,(function(e,i){var n=i.pts,a=n-e;return a<-4294967296&&(t=!0,a=(n=GG(n,r))-e),a>0?e:n}),r);return t&&this.logger.debug("PTS rollover detected"),i}},{key:"remux",value:function(e,t,r,i,n,a,s,o){var l,u,c,h,d,f,v=n,g=n,p=e.pid>-1,m=t.pid>-1,y=t.samples.length,E=e.samples.length>0,k=s&&y>0||y>1;if((!p||E)&&(!m||k)||this.ISGenerated||s){if(this.ISGenerated){var T,S,A,L,b=this.videoTrackConfig;(b&&(t.width!==b.width||t.height!==b.height||(null==(T=t.pixelRatio)?void 0:T[0])!==(null==(S=b.pixelRatio)?void 0:S[0])||(null==(A=t.pixelRatio)?void 0:A[1])!==(null==(L=b.pixelRatio)?void 0:L[1]))||!b&&k||null===this.nextAudioPts&&E)&&this.resetInitSegment()}this.ISGenerated||(c=this.generateIS(e,t,n,a));var R,I=this.isVideoContiguous,D=-1;if(k&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!I&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,D>0){var _,w;this.logger.warn(_d(_="[mp4-remuxer]: Dropped ".concat(D," out of ")).call(_,y," video samples due to a missing keyframe"));var C=this.getVideoStartPts(t.samples);t.samples=Fv(w=t.samples).call(w,D),t.dropped+=D,R=g+=(t.samples[0].pts-C)/t.inputTimeScale}else-1===D&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(y," video samples")),f=!1);if(this.ISGenerated){if(E&&k){var P=this.getVideoStartPts(t.samples),x=(GG(e.samples[0].pts,P)-P)/t.inputTimeScale;v+=Math.max(0,x),g+=Math.max(0,-x)}if(E){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,v,this.isAudioContiguous,a,m||k||o===yO?g:void 0),k){var M=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),l=this.remuxVideo(t,g,I,M)}}else k&&(l=this.remuxVideo(t,g,I,0));l&&(l.firstKeyFrame=D,l.independent=-1!==D,l.firstKeyFramePTS=R)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(d=KG(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=HG(i,n,this._initPTS))),{audio:u,video:l,initSegment:c,independent:f,text:h,id3:d}}},{key:"generateIS",value:function(e,t,r,i){var n,a,s,o=e.samples,l=t.samples,u=this.typeSupported,c={},h=this._initPTS,d=!h||i,f="audio/mp4";if(d&&(n=a=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(f="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}c.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&u.mpeg?new Uint8Array(0):xG.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(s=e.inputTimeScale,h&&s===h.timescale?d=!1:n=a=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:xG.initSegment([t]),metadata:{width:t.width,height:t.height}},d)if(s=t.inputTimeScale,h&&s===h.timescale)d=!1;else{var v=this.getVideoStartPts(l),g=Math.round(s*r);a=Math.min(a,GG(l[0].dts,v)-g),n=Math.min(n,v-g)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(gv(c).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:c,initPTS:n,timescale:s}}},{key:"remuxVideo",value:function(e,t,r,i){var n,a,s=e.inputTimeScale,o=e.samples,l=[],u=o.length,c=this._initPTS,h=this.nextAvcDts,d=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,p=!1;if(!r||null===h){var m=t*s,y=o[0].pts-GG(o[0].dts,o[0].pts);NG&&null!==h&&Math.abs(m-y-h)<15e3?r=!0:h=m-y}for(var E=c.baseTime*s/c.timescale,k=0;k<u;k++){var T=o[k];T.pts=GG(T.pts-E,h),T.dts=GG(T.dts-E,h),T.dts<o[k>0?k-1:k].dts&&(p=!0)}p&&mA(o).call(o,(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=o[0].dts;var S=(a=o[o.length-1].dts)-n,A=S?Math.round(S/(u-1)):f||e.inputTimeScale/30;if(r){var L=n-h,b=L>A,R=L<-1;if(b||R){var I,D,_,w,C,P;if(b)this.logger.warn(_d(I=_d(D=_d(_="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(_,FG(L,!0)," ms (")).call(D,L,"dts) hole between fragments detected at ")).call(I,t.toFixed(3)));else this.logger.warn(_d(w=_d(C=_d(P="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(P,FG(-L,!0)," ms (")).call(C,L,"dts) overlapping between fragments detected at ")).call(w,t.toFixed(3)));if(!R||h>=o[0].pts||NG){var x,M;n=h;var O=o[0].pts-L;if(b)o[0].dts=n,o[0].pts=O;else for(var F=!0,N=0;N<o.length&&!(o[N].dts>O&&F);N++){var U=o[N].pts;if(o[N].dts-=L,o[N].pts-=L,N<o.length-1){var B=o[N+1].pts;F=B<=o[N].pts==B<=U}}this.logger.log(_d(x=_d(M="Video: Initial PTS/DTS adjusted: ".concat(FG(O,!0),"/")).call(M,FG(n,!0),", delta: ")).call(x,FG(L,!0)," ms"))}}}for(var G=0,K=0,H=n=Math.max(0,n),V=0;V<u;V++){for(var j=o[V],Y=j.units,q=Y.length,W=0,z=0;z<q;z++)W+=Y[z].data.length;K+=W,G+=q,j.length=W,j.dts<H?(j.dts=H,H+=A/4|0||1):H=j.dts,v=Math.min(j.pts,v),g=Math.max(j.pts,g)}a=o[u-1].dts;var X,Q=K+4*G+8;try{X=new Uint8Array(Q)}catch(Ie){return void this.observer.emit(dO.ERROR,dO.ERROR,{type:cO.MUX_ERROR,details:hO.REMUX_ALLOC_ERROR,fatal:!1,error:Ie,bytes:Q,reason:"fail allocating video mdat ".concat(Q)})}var $=new DataView(X.buffer);$.setUint32(0,Q),X.set(xG.types.mdat,4);for(var J=!1,Z=Number.POSITIVE_INFINITY,ee=Number.POSITIVE_INFINITY,te=Number.NEGATIVE_INFINITY,re=Number.NEGATIVE_INFINITY,ie=0;ie<u;ie++){for(var ne=o[ie],ae=ne.units,se=0,oe=0,le=ae.length;oe<le;oe++){var ue=ae[oe],ce=ue.data,he=ue.data.byteLength;$.setUint32(d,he),d+=4,X.set(ce,d),d+=he,se+=4+he}var de=void 0;if(ie<u-1)f=o[ie+1].dts-ne.dts,de=o[ie+1].pts-ne.pts;else{var fe=this.config,ve=ie>0?ne.dts-o[ie-1].dts:A;if(de=ie>0?ne.pts-o[ie-1].pts:A,fe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ge,pe=Math.floor(fe.maxBufferHole*s),me=(i?v+i*s:this.nextAudioPts)-ne.pts;if(me>pe)(f=me-ve)<0?f=ve:J=!0,this.logger.log(_d(ge="[mp4-remuxer]: It is approximately ".concat(me/90," ms to the next segment; using duration ")).call(ge,f/90," ms for the last video frame."));else f=ve}else f=ve}var ye=Math.round(ne.pts-ne.dts);Z=Math.min(Z,f),te=Math.max(te,f),ee=Math.min(ee,de),re=Math.max(re,de),l.push(new jG(ne.key,f,se,ye))}if(l.length)if(NG){if(NG<70){var Ee=IC(l[0]);Ee.dependsOn=2,Ee.isNonSync=0}}else if(UG&&re-ee<te-Z&&A/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 ke=n,Te=0,Se=l.length;Te<Se;Te++){var Ae=ke+l[Te].duration,Le=ke+l[Te].cts;if(Te<Se-1){var be=Ae+l[Te+1].cts;l[Te].duration=be-Le}else l[Te].duration=Te?l[Te-1].duration:A;l[Te].cts=0,ke=Ae}}f=J||!f?A:f,this.nextAvcDts=h=a+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;var Re={data1:xG.moof(e.sequenceNumber++,n,AO({},e,{samples:l})),data2:X,startPTS:v/s,endPTS:(g+f)/s,startDTS:n/s,endDTS:h/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Re}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,r,i,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.getSamplesPerFrame(e),l=o*s,u=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],d=void 0!==n,f=e.samples,v=c?0:8,g=this.nextAudioPts||-1,p=t*a,m=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||f.length&&g>0&&(i&&Math.abs(p-g)<9e3||Math.abs(GG(f[0].pts-m,p)-g)<20*l),vd(f).call(f,(function(e){e.pts=GG(e.pts-m,p)})),!r||g<0){if(!(f=xk(f).call(f,(function(e){return e.pts>=0}))).length)return;g=0===n?0:i&&!d?Math.max(0,p):f[0].pts}if("aac"===e.segmentCodec)for(var y=this.config.maxAudioFramesDrift,E=0,k=g;E<f.length;E++){var T,S=f[E],A=S.pts,L=A-k,b=Math.abs(1e3*L/a);if(L<=-y*l&&d){if(0===E)this.logger.warn(_d(T="Audio frame @ ".concat((A/a).toFixed(3),"s overlaps nextAudioPts by ")).call(T,Math.round(1e3*L/a)," ms.")),this.nextAudioPts=g=k=A}else if(L>=y*l&&b<1e4&&d){var R,I,D=Math.round(L/l);(k=A-D*l)<0&&(D--,k+=l),0===E&&(this.nextAudioPts=g=k),this.logger.warn(_d(R=_d(I="[mp4-remuxer]: Injecting ".concat(D," audio frame @ ")).call(I,(k/a).toFixed(3),"s due to ")).call(R,Math.round(1e3*L/a)," ms gap."));for(var _=0;_<D;_++){var w=Math.max(k,0),C=CG.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);C||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),C=S.unit.subarray()),ig(f).call(f,E,0,{unit:C,pts:w}),k+=l,E++}}S.pts=k,k+=l}for(var P,x=null,M=null,O=0,F=f.length;F--;)O+=f[F].unit.byteLength;for(var N=0,U=f.length;N<U;N++){var B=f[N],G=B.unit,K=B.pts;if(null!==M){h[N-1].duration=Math.round((K-M)/s)}else{if(r&&"aac"===e.segmentCodec&&(K=g),x=K,!(O>0))return;O+=v;try{P=new Uint8Array(O)}catch(X){return void this.observer.emit(dO.ERROR,dO.ERROR,{type:cO.MUX_ERROR,details:hO.REMUX_ALLOC_ERROR,fatal:!1,error:X,bytes:O,reason:"fail allocating audio mdat ".concat(O)})}c||(new DataView(P.buffer).setUint32(0,O),P.set(xG.types.mdat,4))}P.set(G,v);var H=G.byteLength;v+=H,h.push(new jG(!0,o,H,0)),M=K}var V=h.length;if(V){var j=h[h.length-1];this.nextAudioPts=g=M+s*j.duration;var Y=c?new Uint8Array(0):xG.moof(e.sequenceNumber++,x/s,AO({},e,{samples:h}));e.samples=[];var q=x/a,W=g/a,z={data1:Y,data2:P,startPTS:q,endPTS:W,startDTS:q,endDTS:W,type:"audio",hasAudio:!0,hasVideo:!1,nb:V};return this.isAudioContiguous=!0,z}}}]),e}();function GG(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 KG(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=GG(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=GG(o.dts-i.baseTime*a/i.timescale,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function HG(e,t,r){var i,n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=GG(o.pts-r.baseTime*a/r.timescale,t*a)/a}mA(i=e.samples).call(i,(function(e,t){return e.pts-t.pts}));var l=e.samples;return e.samples=[],{samples:l}}}var VG,jG=Fc((function e(r,i,n,a){t(this,e),this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=n,this.cts=a,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:r?2:1,isNonSync:r?0:1}})),YG=function(){function e(r,i,n,a){t(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 Fc(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,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(!e||!t)return e;var r=t.keyId;if(r&&t.isCommonEncryption){var i=kN(e,["moov","trak"]);vd(i).call(i,(function(e){var t=kN(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=kN(t,["enca"]),n=i.length>0;n||(i=kN(t,["encv"])),vd(i).call(i,(function(e){var t=kN(n?e.subarray(28):e.subarray(78),["sinf"]);vd(t).call(t,(function(e){var t=IN(e);if(t){var i,a,s=t.subarray(8,24);KT(s).call(s,(function(e){return 0!==e}))||(PO.log(_d(i=_d(a="[eme] Patching keyId in 'enc".concat(n?"a":"v",">sinf>>tenc' box: ")).call(a,zF.hexDump(s)," -> ")).call(i,zF.hexDump(r))),t.set(r,8))}}))}))}))}return e}(e,i)),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 i=this.initData=SN(e);i.audio&&(t=qG(i.audio,nN)),i.video&&(r=qG(i.video,aN));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.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=n}},{key:"remux",value:function(e,t,r,i,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};oO(u)||(u=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return c;var d={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,n=0,a=kN(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],l=kN(o,["tfhd"])[0],u=t[pN(l,4)];if(u){var c=u.default,h=pN(l,0)|(null==c?void 0:IC(c)),d=null==c?void 0:c.duration;8&h&&(d=pN(l,2&h?12:8));for(var f=u.timescale||9e4,v=kN(o,["trun"]),g=0;g<v.length;g++)!(r=DN(v[g]))&&d&&(r=d*pN(v[g],4)),u.type===aN?i+=r/f:u.type===nN&&(n+=r/f)}}if(0===i&&0===n){for(var p=1/0,m=0,y=0,E=kN(e,["sidx"]),k=0;k<E.length;k++){var T=TN(E[k]);if(null!=T&&T.references){var S;p=Math.min(p,T.earliestPresentationTime/T.timescale);var A=mC(S=T.references).call(S,(function(e,t){return e+t.info.duration||0}),0);y=(m=Math.max(m,A+T.earliestPresentationTime/T.timescale))-p}}if(y&&oO(y))return y}return i||n}(h,f),g=function(e,t){var r;return mC(r=kN(t,["moof","traf"])).call(r,(function(t,r){var i,n=kN(r,["tfdt"])[0],a=n[0],s=mC(i=kN(r,["tfhd"])).call(i,(function(t,r){var i=pN(r,4),s=e[i];if(s){var o=pN(n,4);if(1===a){if(o===hN)return PO.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=hN+1,o+=pN(n,8)}var l=o/(s.timescale||9e4);if(oO(l)&&(null===t||l<t))return l}return t}),null);return null!==s&&oO(s)&&(null===t||s<t)?s:t}),null)}(f,h),p=null===g?n:g;if(function(e,t,r,i){if(null===e)return!0;var n=Math.max(i,1),a=t-e.baseTime/e.timescale;return Math.abs(a-r)>n}(l,p,n,v)||d.timescale!==l.timescale&&a){var m,y;if(d.initPTS=p-n,l&&1===l.timescale)this.logger.warn(_d(m=_d(y="Adjusting initPTS @".concat(n," from ")).call(y,l.baseTime/l.timescale," to ")).call(m,d.initPTS));this.initPTS=l={baseTime:d.initPTS,timescale:1}}var E=e?p-l.baseTime/l.timescale:u,k=E+v;!function(e,t,r){var i;vd(i=kN(t,["moof","traf"])).call(i,(function(t){var i;vd(i=kN(t,["tfhd"])).call(i,(function(i){var n,a=pN(i,4),s=e[a];if(s){var o=s.timescale||9e4;vd(n=kN(t,["tfdt"])).call(n,(function(e){var t=e[0],i=r*o;if(i){var n=pN(e,4);if(0===t)n-=i,EN(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=pN(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(hN+1)),s=Math.floor(n%(hN+1));EN(e,4,a),EN(e,8,s)}}}))}}))}))}(f,h,l.baseTime/l.timescale),v>0?this.lastEndTime=k:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!f.audio,S=!!f.video,A="";T&&(A+="audio"),S&&(A+="video");var L={data1:h,startPTS:E,startDTS:E,endPTS:k,endDTS:k,type:A,hasAudio:T,hasVideo:S,nb:1,dropped:0};return c.audio="audio"===L.type?L:void 0,c.video="audio"!==L.type?L:void 0,c.initSegment=d,c.id3=KG(r,n,l,l),i.samples.length&&(c.text=HG(i,n,l)),c}}]),e}();function qG(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===nN){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return VO(r,!1)}return PO.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"}return PO.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1"}try{var WG;VG=iT(WG=self.performance.now).call(WG,self.performance)}catch(JV){VG=SA}var zG=[{demux:pG,remux:YG},{demux:LG,remux:BG},{demux:cG,remux:BG},{demux:vG,remux:BG}];ig(zG).call(zG,2,0,{demux:dG,remux:BG});var XG=function(){function e(r,i,n,a,s,o){t(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=r,this.typeSupported=i,this.config=n,this.id=s,this.logger=o}return Fc(e,[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,r,i){var n=this,a=r.transmuxing;a.executeStart=VG();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,c=u.contiguous,h=u.discontinuity,d=u.trackSwitch,f=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,p=l.audioCodec,m=l.videoCodec,y=l.defaultInitPts,E=l.duration,k=l.initSegmentData,T=function(e,t){var r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(s,t);if(T&&iU(T.method)){var S=this.getDecrypter(),A=nU(T.method);if(!S.isSync())return this.asyncResult=!0,this.decryptionPromise=S.webCryptoDecrypt(s,T.key.buffer,T.iv.buffer,A).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var L=S.softwareDecrypt(s,T.key.buffer,T.iv.buffer,A);if(r.part>-1){var b=S.flush();L=b?b.buffer:b}if(!L)return a.executeEnd=VG(),QG(r);s=new Uint8Array(L)}var R=this.needsProbing(h,d);if(R){var I=this.configureTransmuxer(s);if(I)return this.logger.warn("[transmuxer] ".concat(I.message)),this.observer.emit(dO.ERROR,dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),a.executeEnd=VG(),QG(r)}(h||d||g||R)&&this.resetInitSegment(k,p,m,E,t),(h||g||R)&&this.resetInitialTimestamp(y),c||this.resetContiguity();var D=this.transmux(s,T,v,f,r);this.asyncResult=$G(D);var _=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,a.executeEnd=VG(),D}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=VG();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then((function(){return t.flush(e)}));var s=[],o=n.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l.buffer,null,e))}var u=this.demuxer,c=this.remuxer;if(!u||!c){r.executeEnd=VG();var h=[QG(e)];return this.asyncResult?tk.resolve(h):h}var d=u.flush(o);return $G(d)?(this.asyncResult=!0,d.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,d,e),this.asyncResult?tk.resolve(s):s)}},{key:"flushRemux",value:function(e,t,r){var i,n,a,s,o=t.audioTrack,l=t.videoTrack,u=t.id3Track,c=t.textTrack,h=this.currentTransmuxState,d=h.accurateTimeOffset,f=h.timeOffset;this.logger.log(_d(i=_d(n=_d(a=_d(s="[transmuxer.ts]: Flushed ".concat(this.id," sn: ")).call(s,r.sn)).call(a,r.part>-1?" part: "+r.part:""," of ")).call(n,this.id===mO?"level":"track"," ")).call(i,r.level));var v=this.remuxer.remux(o,l,u,c,f,d,!0,this.id);e.push({remuxResult:v,chunkMeta:r}),r.transmuxing.executeEnd=VG()}},{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,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,n))}},{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,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)}},{key:"transmuxUnencrypted",value:function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,r,!1,this.id),chunkMeta:i}}},{key:"transmuxSampleAes",value:function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))}},{key:"configureTransmuxer",value:function(e){for(var t,r=this.config,i=this.observer,n=this.typeSupported,a=0,s=zG.length;a<s;a++){var o;if(null!=(o=zG[a].demux)&&o.probe(e,this.logger)){t=zG[a];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,u=this.remuxer,c=t.remux,h=t.demux;u&&u instanceof c||(this.remuxer=new c(i,r,n,this.logger)),l&&l instanceof h||(this.demuxer=new h(i,r,n,this.logger),this.probe=h.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 FN(this.config)),e}}]),e}();var QG=function(e){return{remuxResult:{},chunkMeta:e}};function $G(e){return"then"in e&&e.then instanceof Function}var JG=Fc((function e(r,i,n,a,s){t(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=s||null})),ZG=Fc((function e(r,i,n,a,s,o){t(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=r,this.contiguous=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=s,this.initSegmentChange=o})),eK=0,tK=function(){function e(r,i,n,a){var s=this;t(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=eK++,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=s.hls;if(r&&null!=t&&t.event&&t.instanceNo===s.instanceNo)switch(t.event){case"init":var i,n=null==(i=s.workerContext)?void 0:i.objectURL;n&&vI.revokeObjectURL(n);break;case"transmuxComplete":s.handleTransmuxComplete(t.data);break;case"flush":s.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=s.frag,t.data.part=s.part,t.data.id=s.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){var t,r;if(s.hls){var i=new Error(_d(t=_d(r="".concat(e.message," (")).call(r,e.filename,":")).call(t,e.lineno,")"));s.hls.config.enableWorker=!1,s.hls.logger.warn('Error in "'.concat(s.id,'" Web Worker, fallback to inline')),s.hls.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})}};var o=r.config;this.hls=r,this.id=i,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var l=function(e,t){(t=t||{}).frag=s.frag||void 0,e===dO.ERROR&&(t.parent=s.id,t.part=s.part,s.error=t.error),s.hls.trigger(e,t)};this.observer=new AB,this.observer.on(dO.FRAG_DECRYPTED,l),this.observer.on(dO.ERROR,l);var u=qO(o.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var c=this.hls.logger;if(o.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{var h;if(o.workerPath)c.log(_d(h="loading Web Worker ".concat(o.workerPath,' for "')).call(h,i,'"')),this.workerContext=function(e){var t=bB[e];if(t)return t.clientCount++,t;var r=new vI(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return bB[e]=i,i}(o.workerPath);else c.log('injecting Web Worker for "'.concat(i,'"')),this.workerContext=function(){var e=bB[LB];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=vI.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return bB[LB]=i,i}();var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:i,config:yI(o)})}catch(JV){c.warn('Error setting up "'.concat(i,'" Web Worker, fallback to inline'),JV),this.terminateWorker(),this.error=null,this.transmuxer=new XG(this.observer,u,o,"",i,r.logger)}return}}this.transmuxer=new XG(this.observer,u,o,"",i,r.logger)}return Fc(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=eK++;var t=this.hls.config,r=qO(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:yI(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),function(e){var t=bB[e||LB];if(t&&1==t.clientCount--){var r=t.worker,i=t.objectURL;delete bB[e||LB],i&&vI.revokeObjectURL(i),r.terminate()}}(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,i,n,a,s,o,l,u){var c,h,d=this;l.transmuxing.start=self.performance.now();var f=this.instanceNo,v=this.transmuxer,g=a?a.start:n.start,p=n.decryptdata,m=this.frag,y=!(m&&n.cc===m.cc),E=!(m&&l.level===m.level),k=m?l.sn-m.sn:-1,T=this.part?l.part-this.part.index:-1,S=0===k&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),A=!E&&(1===k||0===k&&(1===T||S&&T<=0)),L=self.performance.now();(E||k||0===n.stats.parsing.start)&&(n.stats.parsing.start=L),!a||!T&&A||(a.stats.parsing.start=L);var b=!(m&&(null==(c=n.initSegment)?void 0:c.url)===(null==(h=m.initSegment)?void 0:h.url)),R=new ZG(y,A,o,E,g,b);if(!A||y||b){var I,D,_,w,C,P,x,M,O,F,N;this.hls.logger.log(_d(I=_d(D=_d(_=_d(w=_d(C=_d(P=_d(x=_d(M=_d(O=_d(F=_d(N="[transmuxer-interface]: Starting new transmux session for ".concat(n.type," sn: ")).call(N,l.sn)).call(F,l.part>-1?" part: "+l.part:""," ")).call(O,this.id===mO?"level":"track",": ")).call(M,l.level," id: ")).call(x,l.id,"\n discontinuity: ")).call(P,y,"\n trackSwitch: ")).call(C,E,"\n contiguous: ")).call(w,A,"\n accurateTimeOffset: ")).call(_,o,"\n timeOffset: ")).call(D,g,"\n initSegmentChange: ")).call(I,b));var U=new JG(r,i,t,s,u);this.configureTransmuxer(U)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:R},e instanceof ArrayBuffer?[e]:[]);else if(v){var B=v.push(e,p,l,R);$G(B)?B.then((function(e){d.handleTransmuxComplete(e)})).catch((function(e){d.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(B)}}},{key:"flush",value:function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(i){var n=i.flush(e);$G(n)?n.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(n,e)}}},{key:"transmuxerError",value:function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.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;vd(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 rK(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!iK(e[r].attrs,t[r].attrs))return!1;return!0}function iK(e,t,r){var i,n=e["STABLE-RENDITION-ID"];return n&&!r?n===t["STABLE-RENDITION-ID"]:!KT(i=r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).call(i,(function(r){return e[r]!==t[r]}))}function nK(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var aK=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"audio-stream-controller",yO)).mainAnchor=null,s.mainFragLoading=null,s.audioOnly=!1,s.bufferedTrack=null,s.switchingTrack=null,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.flushing=!1,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.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(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(dO.BUFFER_RESET,this.onBufferReset,this),e.on(dO.BUFFER_CREATED,this.onBufferCreated,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(dO.FRAG_LOADING,this.onFragLoading,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(Ih(Rh(i.prototype),"unregisterListeners",this).call(this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(dO.BUFFER_RESET,this.onBufferReset,this),e.off(dO.BUFFER_CREATED,this.onBufferCreated,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(dO.FRAG_LOADING,this.onFragLoading,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,t){var r=t.frag,i=t.id,n=t.initPTS,a=t.timescale;if(i===mO){var s,o,l=r.cc,u=this.fragCurrent;if(this.initPTS[l]={baseTime:n,timescale:a},this.log(_d(s=_d(o="InitPTS for cc: ".concat(l," found from main: ")).call(o,n,"/")).call(s,a)),this.mainAnchor=r,this.state===yB){var c=this.waitingData;(!c&&!this.loadingParts||c&&c.frag.cc!==l)&&(this.nextLoadPosition=this.findSyncFrag(r).start),this.tick()}else!this.hls.hasEnoughToStart&&u&&u.cc!==l?(this.startFragRequested=!1,this.nextLoadPosition=this.findSyncFrag(r).start,u.abortRequests(),this.resetLoadingState()):this.state===uB&&this.tick()}}},{key:"findSyncFrag",value:function(e){var t=this.getLevelDetails(),r=e.cc;return function(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var i=r.start,n=r.end,a=e.fragments;if(!r.relurl){var s=e.fragmentHint;s&&(a=_d(a).call(a,s))}return gF(a,(function(e){return e.cc<t||e.end<=i?1:e.cc>t||e.start>=n?-1:0}))}return null}(t,r,e)||t&&EF(t.fragments,r)||e}},{key:"startLoad",value:function(e){if(!this.levels)return this.startPosition=e,void(this.state=lB);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @".concat(t.toFixed(3))),e=t,this.state=uB):this.state=fB,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case uB:this.doTickIdle();break;case fB:var e=this.levels,t=this.trackId,r=null==e?void 0:e[t],n=null==r?void 0:r.details;if(n&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(n))break;this.state=yB}break;case dB:var a,s=performance.now(),o=this.retryDate;if(!o||s>=o||null!=(a=this.media)&&a.seeking){var l=this.levels,u=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==l?void 0:l[u])||null),this.state=uB}break;case yB:var c=this.waitingData;if(c){var h=c.frag,d=c.part,f=c.cache,v=c.complete,g=this.mainAnchor;if(void 0!==this.initPTS[h.cc]){this.waitingData=null,this.state=hB;var p={frag:h,part:d,payload:f.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(p),v&&Ih(Rh(i.prototype),"_handleFragmentLoadComplete",this).call(this,p)}else if(g&&g.cc!==c.frag.cc){var m;this.log(_d(m="Waiting fragment cc (".concat(h.cc,") cancelled because video is at cc ")).call(m,g.cc)),this.nextLoadPosition=this.findSyncFrag(g).start,this.clearWaitingFragment()}}else this.state=uB}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!==lB&&(this.state=uB))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),Ih(Rh(i.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,i=this.media,n=this.trackId,a=t.config;if(this.buffering&&(i||!this.startFragRequested&&a.startFragPrefetch)&&null!=r&&r[n]){var s=r[n],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=fB,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,nN,yO));var u=this.getFwdBufferInfo(l,yO);if(null!==u){var c=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(u,o))return t.trigger(dO.BUFFER_EOS,{type:"audio"}),void(this.state=pB);var d=u.len,f=t.maxBufferLength,v=o.fragments,g=v[0].start,p=this.getLoadPosition(),m=this.flushing?p:u.end;if(h&&i){var y=p;c&&!iK(h.attrs,c.attrs)&&(m=y),o.PTSKnown&&y<g&&(u.end>g||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=g+.05)}if(!(d>=f&&!h&&m<v[v.length-1].start)){var E=this.getNextFragment(m,o);if(E&&this.isLoopLoading(E,m)&&(E=this.getNextFragmentLoopLoading(E,o,u,mO,f)),E){var k=null==(e=this.mainFragLoading)?void 0:e.frag;if(!this.audioOnly&&this.startFragRequested&&k&&lN(k)&&lN(E)&&!E.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)){var T=k;if(E.start>T.end){var S=this.fragmentTracker.getFragAtPos(m,mO);S&&S.end>k.end&&(T=S,this.mainFragLoading={frag:S,targetBufferTime:null})}if(E.start>T.end)return}this.loadFragment(E,s,m)}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,t){this.bufferFlushed=this.flushing=!1,Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=_k(r).call(r,(function(e){return new iF(e)}))}},{key:"onAudioTrackSwitching",value:function(e,t){var r=!!t.url;this.trackId=t.id;var i=this.fragCurrent;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==lB&&(this.setInterval(100),this.state=uB,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){Ih(Rh(i.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(dO.AUDIO_TRACK_LOADED,r))}},{key:"onAudioTrackLoaded",value:function(e,t){var r,i,n,a,s,o,l=this.levels,u=t.details,c=t.id,h=this.mainDetails;if(!h||h.expired||u.endCC>h.endCC)return this.cachedTrackLoadedData=t,void(this.state!==lB&&(this.state=fB));if(l){this.log(_d(r=_d(i=_d(n=_d(a="Audio track ".concat(c," loaded [")).call(a,u.startSN,",")).call(n,u.endSN,"]")).call(i,u.lastPartSn?_d(s="[part-".concat(u.lastPartSn,"-")).call(s,u.lastPartIndex,"]"):"",",duration:")).call(r,u.totalduration));var d=l[c],f=0;if(u.live||null!=(o=d.details)&&o.live){if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;var v;if(d.details)f=this.alignPlaylists(u,d.details,null==(v=this.levelLastLoaded)?void 0:v.details);u.alignedSliding||(aB(u,h),u.alignedSliding||sB(u,h),f=u.fragmentStart)}d.details=u,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(h,f),this.hls.trigger(dO.AUDIO_TRACK_UPDATED,{details:u,id:c,groupId:t.groupId}),this.state!==fB||this.waitForCdnTuneIn(u)||(this.state=uB),this.tick()}else this.warn("Audio tracks were reset while loading level ".concat(c))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var u=l.details;if(!u)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);var c,h,d=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",f=this.transmuxer;if(!f)f=this.transmuxer=new tK(this.hls,yO,iT(c=this._handleTransmuxComplete).call(c,this),iT(h=this._handleTransmuxerFlush).call(h,this));var v=this.initPTS[r.cc],g=null==(t=r.initSegment)?void 0:t.data;if(void 0!==v){var p=i?i.index:-1,m=-1!==p,y=new VN(r.level,r.sn,r.stats.chunkCount,n.byteLength,p,m);f.push(n,g,d,"",r,i,u.totalduration,!1,y,v)}else{var E,k,T,S;this.log(_d(E=_d(k=_d(T=_d(S="Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ")).call(S,r.sn," of [")).call(T,u.startSN," ,")).call(k,u.endSN,"],track ")).call(E,s)),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new TB,complete:!1}).cache.push(new Uint8Array(n)),this.state!==lB&&(this.state=yB)}}else this.warn("Audio track is undefined on fragment load progress")}else{var A;this.warn(_d(A="Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ")).call(A,r.level," will not be buffered"))}}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:Ih(Rh(i.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===mO&&lN(t.frag)&&(this.mainFragLoading=t,this.state===uB&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part;if(r.type===yO)if(this.fragContextChanged(r)){var n,a,s,o;this.warn(_d(n=_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state,", audioSwitch: ")).call(n,this.switchingTrack?this.switchingTrack.name:"false"))}else{if(lN(r)){this.fragPrevious=r;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(dO.AUDIO_TRACK_SWITCHED,bO({},l)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==mO||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=mB;else switch(t.details){case hO.FRAG_GAP:case hO.FRAG_PARSING_ERROR:case hO.FRAG_DECRYPT_ERROR:case hO.FRAG_LOAD_ERROR:case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_ERROR:case hO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(yO,t);break;case hO.AUDIO_TRACK_LOAD_ERROR:case hO.AUDIO_TRACK_LOAD_TIMEOUT:case hO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==fB||(null==(r=t.context)?void 0:r.type)!==gO||(this.state=uB);break;case hO.BUFFER_APPEND_ERROR:case hO.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===hO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case hO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==aN&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==aN){this.flushing=!1,this.bufferFlushed=!0,this.state===pB&&(this.state=uB);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,r,yO),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,r="audio",i=this.hls,n=e.remuxResult,a=e.chunkMeta,s=this.getCurrentContext(a);if(s){var o=s.frag,l=s.part,u=s.level,c=u.details,h=n.audio,d=n.text,f=n.id3,v=n.initSegment;if(!this.fragContextChanged(o)&&c){if(this.state=vB,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=v&&v.tracks){var g=o.initSegment||o;this._bufferInitSegment(u,v.tracks,g,a),i.trigger(dO.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:v.tracks})}if(h){var p=h.startPTS,m=h.endPTS,y=h.startDTS,E=h.endDTS;l&&(l.elementaryStreams[nN]={startPTS:p,endPTS:m,startDTS:y,endDTS:E}),o.setElementaryStreamInfo(nN,p,m,y,E),this.bufferFragmentData(h,o,l,a)}if(null!=f&&null!=(t=f.samples)&&t.length){var k=AO({id:r,frag:o,details:c},f);i.trigger(dO.FRAG_PARSING_METADATA,k)}if(d){var T=AO({id:r,frag:o,details:c},d);i.trigger(dO.FRAG_PARSING_USERDATA,T)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(a)}},{key:"_bufferInitSegment",value:function(e,t,r,i){var n,a;if(this.state===vB&&(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(_d(n=_d(a="Init audio buffer, container:".concat(s.container,", codecs[level/parsed]=[")).call(a,o,"/")).call(n,s.codec,"]")),o&&1===o.split(",").length&&(s.levelCodec=o),this.hls.trigger(dO.BUFFER_CODECS,t);var l=s.initSegment;if(null!=l&&l.byteLength){var u={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:l};this.hls.trigger(dO.BUFFER_APPENDING,u)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,t,r){var n,a=this.fragmentTracker.getState(e);if(this.switchingTrack||a===MF||a===FF)if(lN(e))if(null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]){var s,o;this.log(_d(s=_d(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=yB;var l=this.mainDetails;l&&l.fragmentStart!==t.details.fragmentStart&&sB(t.details,l)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){var t=this.media,r=this.bufferedTrack,n=null==r?void 0:r.attrs,a=e.attrs;t&&n&&(n.CHANNELS!==a.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),Ih(Rh(i.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(dO.AUDIO_TRACK_SWITCHED,bO({},e))}}]),i}(kB),sK=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n,e.logger)).hls=void 0,a.canLoad=!1,a.timer=-1,a.hls=e,a}return Fc(i,[{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 i=null==t?void 0:t.renditionReports;if(i){for(var n=-1,a=0;a<i.length;a++){var s=i[a],o=void 0;try{o=new vI(s.URI,t.url).href}catch($V){this.warn("Could not construct new URL for Rendition Report: ".concat($V)),o=s.URI||""}if(o===e){n=a;break}o===e.substring(0,o.length)&&(n=a)}if(-1!==n){var l=i[n],u=Ak(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),c=Ak(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&h>t.partTarget&&(c+=1)}var d=r&&tF(r);return new rF(u,c>=0?c:void 0,d)}}}},{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($V){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat($V))}return e}},{key:"playlistLoaded",value:function(e,t,r){var i=t.details,n=t.stats,a=self.performance.now(),s=n.loading.first?Math.max(0,a-n.loading.first):0;i.advancedDateTime=SA()-s;var o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){var l,u=Math.max(o||0,0);i.appliedTimelineOffset=u,vd(l=i.fragments).call(l,(function(e){e.start=e.playlistOffset+u}))}if(i.live||null!=r&&r.live){var c,h="levelInfo"in t?t.levelInfo:t.track;i.reloaded(r),r&&i.fragments.length>0&&XU(r,i),-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);var d,f=this.hls.mainForwardBufferInfo,v=f?f.end-f.len:0,g=JU(i,1e3*(i.edge-v));if(i.requestScheduled+g<a?i.requestScheduled=a:i.requestScheduled+=g,this.log(_d(c="live playlist ".concat(e," ")).call(c,i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;var p=void 0,m=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var y=this.hls.config.lowLatencyMode,E=i.lastPartSn,k=i.endSN,T=i.lastPartIndex,S=E===k;-1!==T?S?(p=k+1,m=y?0:T):(p=E,m=y?T+1:i.maxPartIndex):p=k+1;var A=i.age,L=A+i.ageHeader,b=Math.min(L-i.partTarget,1.5*i.targetduration);if(b>0){if(L>3*i.targetduration)this.log("Playlist last advanced ".concat(A.toFixed(2),"s ago. Omitting segment and part directives.")),p=void 0,m=void 0;else if(null!=r&&r.tuneInGoal&&L-i.partTarget>r.tuneInGoal){var R,I;this.warn(_d(R=_d(I="CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ")).call(I,b," with playlist age: ")).call(R,i.age)),b=0}else{var D,_,w,C,P=Math.floor(b/i.targetduration);if(p+=P,void 0!==m)m+=Math.round(b%i.targetduration/i.partTarget);this.log(_d(D=_d(_=_d(w=_d(C="CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ")).call(C,A.toFixed(2),"s goal: ")).call(w,b," skip sn ")).call(_,P," to part ")).call(D,m))}i.tuneInGoal=b}if(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m),y||!S)return i.requestScheduled=a,void this.loadingPlaylist(h,d)}else(i.canBlockReload||i.canSkipUntil)&&(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m));d&&void 0!==p&&i.canBlockReload&&(i.requestScheduled=n.loading.first+Math.max(g-2*s,g/2)),this.scheduleLoading(h,d,i)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,r){var i,n=this,a=r||e.details;if(a){var s=self.performance.now(),o=a.requestScheduled;if(s>=o)this.loadingPlaylist(e,t);else{var l=o-s;this.log(_d(i="reload live playlist ".concat(e.name||e.bitrate+"bps"," in ")).call(i,Math.round(l)," ms")),this.clearTimer(),this.timer=Wf((function(){return n.loadingPlaylist(e,t)}),l)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,i){var n=tF(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=JO),new rF(r,i,n)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,i=kF(e),n=e.errorAction,a=n||{},s=a.action,o=a.retryCount,l=void 0===o?0:o,u=a.retryConfig,c=!!n&&!!u&&(s===DF||!n.resolved&&s===RF);if(c){var h;if(l>=u.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives){var d,f;this.warn(_d(d=_d(f="Retrying playlist loading ".concat(l+1,"/")).call(f,u.maxNumRetry,' after "')).call(d,r,'" without delivery-directives')),this.loadPlaylist()}else{var v,g,p,m=SF(u,l);this.clearTimer(),this.timer=Wf((function(){return t.loadPlaylist()}),m),this.warn(_d(v=_d(g=_d(p="Retrying playlist loading ".concat(l+1,"/")).call(p,u.maxNumRetry,' after "')).call(g,r,'" in ')).call(v,m,"ms"))}e.levelRetry=!0,n.resolved=!0}return c}}]),i}(RO),oK=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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 Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVEL_LOADING,this.onLevelLoading,this),e.off(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(dO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(dO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,Ih(Rh(i.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,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Audio track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Audio track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.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,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&KT(r).call(r,(function(e){return-1===(null==i?void 0:av(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=xk(a=this.tracks).call(a,(function(e){return!r||-1!==av(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!KT(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.audioPreference;if(!n&&l){var u=uF(l,o,hF);if(u>-1)n=o[u];else{var c=uF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={audioTracks:o};this.log(_d(s="Updating audio tracks, ".concat(o.length," track(s) found in group(s): ")).call(s,null==r?void 0:r.join(","))),this.hls.trigger(dO.AUDIO_TRACKS_UPDATED,d);var f=this.trackId;if(-1!==h&&-1===f)this.setAudioTrack(h);else if(o.length&&-1===f){var v,g,p=new Error(_d(v="No audio track selected for current audio group-ID(s): ".concat(null==(g=this.groupIds)?void 0:g.join(",")," track count: ")).call(v,o.length));this.warn(p.message),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:p})}}}}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==gO||t.context.id!==this.trackId||this.groupIds&&-1===av(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 i=this.currentTrack;if(i&&cF(e,i,hF))return i;var n=uF(e,this.tracksInGroup,hF);if(n>-1){var a=this.tracksInGroup[n];return this.setAudioTrack(n),a}if(i){var s=t.loadLevel;-1===s&&(s=t.firstAutoLevel);var o=function(e,t,r,i,n){var a=t[i],s=mC(t).call(t,(function(e,t,r){var i=t.uri;return(e[i]||(e[i]=[])).push(r),e}),{})[a.uri];s.length>1&&(i=Math.max.apply(Math,s));var o=a.videoRange,l=a.frameRate,u=a.codecSet.substring(0,4),c=dF(t,i,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var i=t.audioGroups,a=xk(r).call(r,(function(e){return!i||-1!==av(i).call(i,e.groupId)}));return uF(e,a,n)>-1}));return c>-1?c:dF(t,i,(function(t){var i=t.audioGroups,a=xk(r).call(r,(function(e){return!i||-1!==av(i).call(i,e.groupId)}));return uF(e,a,n)>-1}))}(e,t.levels,r,s,hF);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=uF(e,r);if(l>-1)return r[l]}}}return null}},{key:"setAudioTrack",value:function(e){var t,r,i,n,a=this.tracksInGroup;if(e<0||e>=a.length)this.warn("Invalid audio track id: ".concat(e));else{this.selectDefaultTrack=!1;var s=this.currentTrack,o=a[e],l=o.details&&!o.details.live;if(!(e===this.trackId&&o===s&&l||(this.log(_d(t=_d(r=_d(i=_d(n="Switching to audio-track ".concat(e,' "')).call(n,o.name,'" lang:')).call(i,o.lang," group:")).call(r,o.groupId," channels:")).call(t,o.channels)),this.trackId=e,this.currentTrack=o,this.hls.trigger(dO.AUDIO_TRACK_SWITCHING,bO({},o)),l))){var u=this.switchParams(o.url,null==s?void 0:s.details,o.details);this.loadPlaylist(u)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||cF(e,i,hF)))return r}if(e){for(var n=e.name,a=e.lang,s=e.assocLang,o=e.characteristics,l=e.audioCodec,u=e.channels,c=0;c<t.length;c++){if(cF({name:n,lang:a,assocLang:s,characteristics:o,audioCodec:l,channels:u},t[c],hF))return c}for(var h=0;h<t.length;h++){var d=t[h];if(iK(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var f=0;f<t.length;f++){var v=t[f];if(iK(e.attrs,v.attrs,["LANGUAGE"]))return f}}return-1}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this);var t=this.currentTrack;this.shouldLoadPlaylist(t)&&fF(t.url,this.hls)&&this.scheduleLoading(t,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading audio-track ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(dO.AUDIO_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}}]),i}(sK),lK=function(){function e(r){t(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=r}return Fc(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 i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){var t=this;return new tk((function(r){var i={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(i,e)}))}},{key:"prependBlocker",value:function(e){var t=this;return new tk((function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}}))}},{key:"removeBlockers",value:function(){var e;null!==this.queues&&vd(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(),ig(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($V){var i;if(r.onError($V),null===this.queues||null===this.tracks)return;var n=null==(i=this.tracks[e])?void 0:i.buffer;null!=n&&n.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,i=this.tracks;return null===r||null===i?"<destroyed>":_d(e=_d(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,i,n;return null!=(i=this.queues)&&i[e]||null!=(n=this.tracks)&&n[e]?_d(t=_d(r="".concat(e,": (")).call(r,this.listSbInfo(e),") ")).call(t,this.listOps(e)):""}},{key:"listSbInfo",value:function(e){var t,r,i,n=null==(i=this.tracks)?void 0:i[e],a=null==n?void 0:n.buffer;return a?_d(t=_d(r="SourceBuffer".concat(a.updating?" updating":"")).call(r,n.ended?" ended":"")).call(t,n.ending?" ending":""):"none"}},{key:"listOps",value:function(e){var t,r;return(null==(r=this.queues)?void 0:_k(t=r[e]).call(t,(function(e){return e.label})).join(", "))||""}}]),e}(),uK=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,cK="HlsJsTrackRemovedError",hK=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e)).name=cK,n}return Fc(i)}(Jw(Error)),dK=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(a=r.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=Zh(a),r=t.media,i=t.mediaSource;e&&a.log("Media source opened"),r&&i&&(r.removeEventListener("emptied",a._onMediaEmptied),a.updateDuration(),a.hls.trigger(dO.MEDIA_ATTACHED,{media:r,mediaSource:i}),i.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=Zh(a),r=t.mediaSrc,i=t._objectUrl;r!==i&&a.error(_d(e="Media element src was set while attaching MediaSource (".concat(i," > ")).call(e,r,")"))},a.hls=e,a.fragmentTracker=n,a.appendSource=(s=xO(e.config.preferManagedMediaSource),"undefined"!=typeof self&&s===self.ManagedMediaSource),a.initTracks(),a.registerListeners(),a}return Fc(i,[{key:"hasSourceTypes",value:function(){return gv(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(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.BUFFER_RESET,this.onBufferReset,this),e.on(dO.BUFFER_APPENDING,this.onBufferAppending,this),e.on(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(dO.BUFFER_EOS,this.onBufferEos,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(dO.FRAG_PARSED,this.onFragParsed,this),e.on(dO.FRAG_CHANGED,this.onFragChanged,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.BUFFER_RESET,this.onBufferReset,this),e.off(dO.BUFFER_APPENDING,this.onBufferAppending,this),e.off(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(dO.BUFFER_EOS,this.onBufferEos,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(dO.FRAG_PARSED,this.onFragParsed,this),e.off(dO.FRAG_CHANGED,this.onFragChanged,this),e.off(dO.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a,s,o=this.isQueued();if(n||o)this.warn(_d(a=_d(s="Transfering MediaSource with".concat(o?" operations in queue":"")).call(s,n?" updating SourceBuffer(s)":""," ")).call(a,this.operationQueue));this.operationQueue.destroy()}var l,u=this.transferData;!this.sourceBufferCount&&u&&u.mediaSource===r?AO(i,u.tracks):vd(l=this.sourceBuffers).call(l,(function(t){var r=cD(t,1)[0];r&&(i[r]=AO({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null}));return{media:t,mediaSource:r,tracks:i}}},{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,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log("".concat(i," bufferCodec event(s) expected.")),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media,i=xO(this.appendSource);if(this.transferData=this.overrides=void 0,r&&i){var n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var a=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(a),n)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=vI.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,fK(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch($V){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r,i;this.log(_d(t="".concat((null==(r=this.transferData)?void 0:r.mediaSource)===e?"transferred":"created"," media source: ")).call(t,null==(i=e.constructor)?void 0:i.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 i=this.tracks,n=r.tracks,a=n?gv(n):null,s=a?a.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(n&&a&&s){var l,u;if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(_d(l=_d(u="attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ")).call(u,yI(i,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ")).call(l,yI(n,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!MO(n,i)){var c,h,d;r.mediaSource=null,r.tracks=void 0;var f,v=t.currentTime,g=this.details,p=Math.max(v,(null==g?void 0:g.fragments[0].start)||0);return p-v>1?void this.log(_d(f="attachTransferred: waiting for playback to reach new tracks start time ".concat(v," -> ")).call(f,p)):(this.warn(_d(c=_d(h=_d(d='attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(gv(n),'"->"')).call(d,gv(i),'") start time: ')).call(h,p," currentTime: ")).call(c,v)),this.onMediaDetaching(dO.MEDIA_DETACHING,{}),this.onMediaAttaching(dO.MEDIA_ATTACHING,r),void(t.currentTime=p))}this.transferData=void 0,vd(a).call(a,(function(t){var r=t,i=n[r];if(i){var a=i.buffer;if(a){var s=e.fragmentTracker,o=i.id;if(s.hasFragments(o)||s.hasParts(o)){var l=YN.getBuffered(a);s.detectEvictedFragments(r,l,o,null,!0)}var u=vK(r),c=[r,a];e.sourceBuffers[u]=c,a.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,i)}}})),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,i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,s=this._objectUrl;if(a){if(this.log("media source ".concat(i?"transferring":"detaching")),i){var o;vd(o=this.sourceBuffers).call(o,(function(e){var t=cD(e,1)[0];t&&r.removeBuffer(t)})),this.resetQueue()}else{if(this.mediaSourceOpenOrEnded){var l="open"===a.readyState;try{for(var u=a.sourceBuffers,c=u.length;c--;)l&&u[c].abort(),a.removeSourceBuffer(u[c]);l&&a.endOfStream()}catch(JV){this.warn("onMediaDetaching: ".concat(JV.message," while calling endOfStream"))}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(s&&vI.revokeObjectURL(s),this.mediaSrc===s?(n.removeAttribute("src"),this.appendSource&&fK(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(dO.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){var e,t=this;vd(e=this.sourceBuffers).call(e,(function(e){var r=cD(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 i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(JV){this.warn("onBufferReset ".concat(e),JV)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[vK(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 lK(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r,i=this,n=this.tracks,a=gv(t);this.log(_d(r='BUFFER_CODECS: "'.concat(a,'" (current SB count ')).call(r,this.sourceBufferCount,")"));var s,o="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),l=!o&&this.sourceBufferCount&&this.media&&KT(a).call(a,(function(e){return!n[e]}));o||l?this.warn(_d(s='Unsupported transition between "'.concat(gv(n),'" and "')).call(s,a,'" SourceBuffers')):(vd(a).call(a,(function(e){var r,a,s,o=t[e],l=o.id,u=o.codec,c=o.levelCodec,h=o.container,d=o.metadata,f=n[e],v=null==(r=i.transferData)||null==(a=r.tracks)?void 0:a[e],g=null!=v&&v.buffer?v:f,p=(null==g?void 0:g.pendingCodec)||(null==g?void 0:g.codec),m=null==g?void 0:g.levelCodec,y=!g||!!i.hls.config.assetPlayerId;f||(f=n[e]={buffer:void 0,listeners:[],codec:u,container:h,levelCodec:c,metadata:d,id:l});var E,k=jO(p,m),T=null==k?void 0:k.replace(uK,"$1"),S=jO(u,c),A=null==(s=S)?void 0:s.replace(uK,"$1");S&&(T!==A||y)&&("audio"===Fv(e).call(e,0,5)&&(S=VO(S,i.appendSource)),i.log(_d(E="switching codec ".concat(p," to ")).call(E,S)),S!==(f.pendingCodec||f.codec)&&(f.pendingCodec=S),f.container=h,i.appendChangeType(e,h,S))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e,t=this;return mC(e=gv(this.tracks)).call(e,(function(e,r){var i=t.tracks[r];return e[r]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e}),{})}},{key:"appendChangeType",value:function(e,t,r){var i,n=this,a=_d(i="".concat(t,";codecs=")).call(i,r),s={label:"change-type=".concat(a),execute:function(){var i=n.tracks[e];if(i){var s,o=i.buffer;if(null!=o&&o.changeType)n.log(_d(s="changing ".concat(e," sourceBuffer type to ")).call(s,a)),o.changeType(a),i.codec=r,i.container=t}n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){n.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,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,mO))?void 0:t.gap))){var a={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>n||null!=t&&t.buffer&&YN.isBuffered(t.buffer,n)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(n,mO))?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:a,frag:e},this.append(a,"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,i=this.tracks,n=t.data,a=t.type,s=t.parent,o=t.frag,l=t.part,u=t.chunkMeta,c=u.buffering[a],h=o.sn,d=self.performance.now();c.start=d;var f=o.stats.buffering,v=l?l.stats.buffering:null;0===f.start&&(f.start=d),v&&0===v.start&&(v.start=d);var g=i.audio,p=!1;"audio"===a&&"audio/mpeg"===(null==g?void 0:g.container)&&(p=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var m=this.tracks.video,y=null==m?void 0:m.buffer;if(y&&"initSegment"!==h){var E=l||o,k=this.blockedAudioAppend;if("audio"!==a||"main"===s||this.blockedAudioAppend){if("video"===a){var T=E.end;if(k){var S=k.frag.start;(T>S||T<this.lastVideoAppendEnd||YN.isBuffered(y,S))&&this.unblockAudio()}this.lastVideoAppendEnd=T}}else{var A=E.start+.05*E.duration,L=y.buffered,b=this.currentOp("video");L.length||b?!b&&!YN.isBuffered(y,A)&&this.lastVideoAppendEnd<A&&this.blockAudio(E):this.blockAudio(E)}}var R=(l||o).start,I={label:"append-".concat(a),execute:function(){if(c.executeStart=self.performance.now(),p){var e=r.tracks[a];if(e){var t=e.buffer;if(t){var i,s,o=R-t.timestampOffset;if(Math.abs(o)>=.1)r.log(_d(i=_d(s="Updating audio SourceBuffer timestampOffset to ".concat(R," (delta: ")).call(s,o,") sn: ")).call(i,h,")")),t.timestampOffset=R}}}r.appendExecutor(n,a)},onStart:function(){},onComplete:function(){var e,t=self.performance.now();c.executeEnd=c.end=t,0===f.first&&(f.first=t),v&&0===v.first&&(v.first=t);var i={};vd(e=r.sourceBuffers).call(e,(function(e){var t=cD(e,2),r=t[0],n=t[1];r&&(i[r]=YN.getBuffered(n))})),r.appendErrors[a]=0,"audio"===a||"video"===a?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(dO.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:i})},onError:function(e){var t,i={type:cO.MEDIA_ERROR,parent:o.type,details:hO.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:l,chunkMeta:u,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)i.details=hO.BUFFER_FULL_ERROR;else if(e.code!==DOMException.INVALID_STATE_ERR||!r.mediaSourceOpenOrEnded||null!=(t=r.media)&&t.error)if(e.name===cK)0===r.sourceBufferCount?i.errorAction=xF(!0):++r.appendErrors[a];else{var n,s,c=++r.appendErrors[a];r.warn(_d(n=_d(s="Failed ".concat(c,"/")).call(s,r.hls.config.appendErrorMaxRetry,' times to append segment in "')).call(n,a,'" sourceBuffer')),c>=r.hls.config.appendErrorMaxRetry&&(i.fatal=!0)}else i.errorAction=xF(!0);r.hls.trigger(dO.ERROR,i)}};this.append(I,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,r){var i,n,a=this;return this.log(_d(i=_d(n='queuing "'.concat(e,'" remove ')).call(n,t,"-")).call(i,r)),{label:"remove",execute:function(){a.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){a.hls.trigger(dO.BUFFER_FLUSHED,{type:e})},onError:function(i){var n,s;a.warn(_d(n=_d(s="Failed to remove ".concat(t,"-")).call(s,r,' from "')).call(n,e,'" SourceBuffer'),i)}}}},{key:"onBufferFlushing",value:function(e,t){var r,i=this,n=t.type,a=t.startOffset,s=t.endOffset;n?this.append(this.getFlushOp(n,a,s),n):vd(r=this.sourceBuffers).call(r,(function(e){var t=cD(e,1)[0];t&&i.append(i.getFlushOp(t,a,s),t)}))}},{key:"onFragParsed",value:function(e,t){var r=this,i=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[sN]?a.push("audiovideo"):(s[nN]&&a.push("audio"),s[aN]&&a.push("video"));var o,l;0===a.length&&this.warn(_d(o=_d(l="Fragments must have at least one ElementaryStreamType set. type: ".concat(i.type," level: ")).call(l,i.level," sn: ")).call(o,i.sn));this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;r.hls.trigger(dO.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})}),a)}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var e,t=this;return this.sourceBufferCount>0&&!KT(e=this.sourceBuffers).call(e,(function(e){var r,i,n=cD(e,1)[0];return n&&(!(null!=(r=t.tracks[n])&&r.ended)||(null==(i=t.tracks[n])?void 0:i.ending))}))}},{key:"onBufferEos",value:function(e,t){var r,i,n,a=this;vd(r=this.sourceBuffers).call(r,(function(e){var r=cD(e,1)[0];if(r){var i=a.tracks[r];t.type&&t.type!==r||(i.ending=!0,i.ended||(i.ended=!0,a.log("".concat(r," buffer reached EOS"))))}}));var s=!1!==(null==(n=this.overrides)?void 0:n.endOfStream);this.sourceBufferCount>0&&!KT(i=this.sourceBuffers).call(i,(function(e){var t,r=cD(e,1)[0];return r&&!(null!=(t=a.tracks[r])&&t.ended)}))&&(this.log("Queueing EOS"),this.blockUntilOpen((function(){var e;if(vd(e=a.sourceBuffers).call(e,(function(e){var t=cD(e,1)[0];if(null!==t){var r=a.tracks[t];r&&(r.ending=!1)}})),s){var t=a.mediaSource;if(!t||"open"!==t.readyState)return void(t&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(t.readyState)));a.log("Calling mediaSource.endOfStream()"),t.endOfStream()}a.hls.trigger(dO.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===hO.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;oO(i)&&i!==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 i=e.config,n=r.currentTime,a=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(oO(s)&&s>=0){var o=Math.max(s,a),l=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,l)}if(oO(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var u=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),c=Math.max(u,a),h=Math.floor(n/a)*a+c;this.flushFrontBuffer(n,a,h)}}}},{key:"flushBackBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=cD(i,2),s=a[0],o=a[1];if(o){var l=YN.getBuffered(o);if(l.length>0&&r>l.start(0)){var u;n.hls.trigger(dO.BACK_BUFFER_REACHED,{bufferEnd:r});var c=n.tracks[s];if(null!=(u=n.details)&&u.live)n.hls.trigger(dO.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=c&&c.ended&&l.end(l.length-1)-e<2*t)return void n.log("Cannot flush ".concat(s," back buffer while SourceBuffer is in ended state"));n.hls.trigger(dO.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}},{key:"flushFrontBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=cD(i,2),s=a[0],o=a[1];if(o){var l=YN.getBuffered(o),u=l.length;if(u<2)return;var c=l.start(u-1),h=l.end(u-1),d=n.tracks[s];if(r>c||e>=c&&e<=h)return;if(null!=d&&d.ended&&e-h<2*t)return void n.log("Cannot flush ".concat(s," front buffer while SourceBuffer is in ended state"));n.hls.trigger(dO.BUFFER_FLUSHING,{startOffset:c,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 i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(r.duration=1/0,t.fragments.length&&t.live&&r.setLiveSeekableRange){var n=Math.max(0,t.fragmentStart);return{duration:1/0,start:n,end:Math.max(n,i)}}return{duration:1/0}}var a=null==(e=this.overrides)?void 0:e.duration;if(a)return{duration:a};var s=this.media.duration;return i>(oO(r.duration)?r.duration:0)&&i>s||!oO(s)?{duration:i}:null}},{key:"updateMediaSource",value:function(e){var t,r,i=e.duration,n=e.start,a=e.end,s=this.mediaSource;this.media&&s&&"open"===s.readyState&&(s.duration!==i&&(oO(i)&&this.log("Updating MediaSource duration to ".concat(i.toFixed(3))),s.duration=i),void 0!==n&&void 0!==a&&(this.log(_d(t=_d(r="MediaSource duration is set to ".concat(s.duration,". Setting seekable range to ")).call(r,n,"-")).call(t,a,".")),s.setLiveSeekableRange(n,a)))}},{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,i=this.pendingTrackCount,n=this.tracks;if(this.log(_d(e=_d(t="checkPendingTracks (pending: ".concat(i," codec events expected: ")).call(t,r,") ")).call(e,yI(n))),this.tracksReady){var a,s=null==(a=this.transferData)?void 0:a.tracks;s&&gv(s).length?this.attachTransferred():(this.createSourceBuffers(),this.bufferCreated())}}},{key:"bufferCreated",value:function(){var e=this;if(this.sourceBufferCount){var t,r,i={};vd(t=this.sourceBuffers).call(t,(function(t){var r=cD(t,2),n=r[0],a=r[1];if(n){var s=e.tracks[n];i[n]={buffer:a,container:s.container,codec:s.codec,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}})),this.hls.trigger(dO.BUFFER_CREATED,{tracks:i}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),vd(r=this.sourceBuffers).call(r,(function(t){var r=cD(t,1)[0];e.executeNext(r)}))}else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.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 i in e){var n=i,a=e[n];if(this.isPending(a)){var s,o,l,u=this.getTrackCodec(a,n),c=_d(s="".concat(a.container,";codecs=")).call(s,u);a.codec=u,this.log(_d(o=_d(l="creating sourceBuffer(".concat(c,")")).call(l,this.currentOp(n)?" Queued":""," ")).call(o,yI(a)));try{var h=r.addSourceBuffer(c),d=vK(n),f=[n,h];t[d]=f,a.buffer=h}catch($V){this.error("error while trying to add sourceBuffer: ".concat($V.message)),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:$V,sourceBufferName:n,mimeType:c});break}this.trackSourceBuffer(n,a)}}}},{key:"getTrackCodec",value:function(e,t){var r=jO(e.codec,e.levelCodec);return r?"audio"===Fv(t).call(t,0,5)?VO(r,this.appendSource):r:""}},{key:"trackSourceBuffer",value:function(e,t){var r=this,i=t.buffer;if(i){var n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,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 i=t.removedRanges;null!=i&&i.length&&r.hls.trigger(dO.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,i,n=new Error(_d(r="".concat(e," SourceBuffer error. MediaSource readyState: ")).call(r,null==(i=this.mediaSource)?void 0:i.readyState));this.error("".concat(n),t),this.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"removeExecutor",value:function(e,t,r){var i=this.media,n=this.mediaSource,a=this.tracks[e],s=null==a?void 0:a.buffer;if(!i||!n||!s)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var o,l,u=oO(i.duration)?i.duration:1/0,c=oO(n.duration)?n.duration:1/0,h=Math.max(0,t),d=Math.min(r,u,c);d>h&&(!a.ending||a.ended)?(a.ended=!1,this.log(_d(o=_d(l="Removing [".concat(h,",")).call(l,d,"] from the ")).call(o,e," SourceBuffer")),s.remove(h,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new hK("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));r.ending=!1,r.ended=!1,i.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()}},{key:"isUpdating",value:function(){var e;return KT(e=this.sourceBuffers).call(e,(function(e){var t=cD(e,2),r=t[0],i=t[1];return r&&i.updating}))}},{key:"isQueued",value:function(){var e,t=this;return KT(e=this.sourceBuffers).call(e,(function(e){var r=cD(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 tk.resolve().then(e);var i=this.operationQueue,n=_k(r).call(r,(function(e){return t.appendBlocker(e)}));r.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),tk.all(n).then((function(n){i===t.operationQueue&&(e(),t.stepOperationQueue(r))}))}},{key:"stepOperationQueue",value:function(e){var t=this;vd(e).call(e,(function(e){var r,i=null==(r=t.tracks[e])?void 0:r.buffer;i&&!i.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 mC(e=gv(this.tracks)).call(e,(function(e,r){return e+(t.isPending(t.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){var e;return mC(e=this.sourceBuffers).call(e,(function(e,t){return e+(cD(t,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){var e,t;return xk(e=_k(t=this.sourceBuffers).call(t,(function(e){return cD(e,1)[0]}))).call(e,(function(e){return!!e}))}},{key:"addBufferListener",value:function(e,t,r){var i=this.tracks[e];if(i){var n=i.buffer;if(n){var a=iT(r).call(r,this,e);i.listeners.push({event:t,listener:a}),n.addEventListener(t,a)}}}},{key:"removeBufferListeners",value:function(e){var t,r=this.tracks[e];if(r){var i=r.buffer;i&&(vd(t=r.listeners).call(t,(function(e){i.removeEventListener(e.event,e.listener)})),r.listeners.length=0)}}}]),i}(RO);function fK(e){var t,r=e.querySelectorAll("source");vd(t=Fv([]).call(r)).call(t,(function(t){e.removeChild(t)}))}function vK(e){return"audio"===e?1:0}var gK=function(){function e(r){t(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=r,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return Fc(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(dO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(dO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(dO.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&&oO(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,i,n,a=this.hls,s=this.getMaxLevel(e.length-1);if(s!==this.autoLevelCapping)a.logger.log(_d(t=_d(r=_d(i=_d(n="Setting autoLevelCapping to ".concat(s,": ")).call(n,e[s].height,"p@")).call(i,e[s].bitrate," for media ")).call(r,this.mediaWidth,"x")).call(t,this.mediaHeight));a.autoLevelCapping=s,a.autoLevelEnabled&&a.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=a.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=xk(i).call(i,(function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){var e;this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=lS(iT(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(t){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){var t=this.restrictedLevels;return!KT(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 i,n,a=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)&&(i=l,!(n=e[o+1])||i.width!==n.width||i.height!==n.height)){a=o;break}}return a}}]),e}(),pK={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},mK={DASH:"d",HLS:"h",SMOOTH:"s",OTHER:"o"},yK={OBJECT:"CMCD-Object",REQUEST:"CMCD-Request",SESSION:"CMCD-Session",STATUS:"CMCD-Status"},EK=(Lf(VM={},yK.OBJECT,["br","d","ot","tb"]),Lf(VM,yK.REQUEST,["bl","dl","mtp","nor","nrr","su"]),Lf(VM,yK.SESSION,["cid","pr","sf","sid","st","v"]),Lf(VM,yK.STATUS,["bs","rtp"]),VM),kK=Fc((function e(r,i){t(this,e),Pk(r)&&(r=_k(r).call(r,(function(t){return t instanceof e?t:new e(t)}))),this.value=r,this.params=i})),TK="Dict";function SK(e,t,r,i){var n,a,s;return new Error(_d(n=_d(a="failed to ".concat(e,' "')).call(a,(s=t,Pk(s)?yI(s):s instanceof ZC?"Map{}":s instanceof KM?"Set{}":"object"===Cc(s)?yI(s):String(s)),'" as ')).call(n,r),{cause:i})}function AK(e,t,r){return SK("serialize",e,t,r)}var LK=Fc((function e(r){t(this,e),this.description=r})),bK="Bare Item",RK="Boolean";var IK="Byte Sequence";function DK(e){if(!1===ArrayBuffer.isView(e))throw AK(e,IK);return":".concat((t=e,btoa(String.fromCharCode.apply(String,uD(t)))),":");var t}var _K="Integer";function wK(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw AK(e,_K);return e.toString()}var CK="Decimal";function PK(e){var t=GB(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw AK(e,CK);var r=t.toString();return sD(r).call(r,".")?r:"".concat(r,".0")}var xK="String",MK=/[\x00-\x1f\x7f]+/;var OK="Token";function FK(e){var t,r,i=(t=e).description||Fv(r=t.toString()).call(r,7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw AK(i,OK);return i}function NK(e){switch(Cc(e)){case"number":if(!oO(e))throw AK(e,bK);return YI(e)?wK(e):PK(e);case"string":return function(e){if(MK.test(e))throw AK(e,xK);return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(e);case"symbol":return FK(e);case"boolean":return function(e){if("boolean"!=typeof e)throw AK(e,RK);return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return"@".concat(wK(e.getTime()/1e3))}(e);if(e instanceof Uint8Array)return DK(e);if(e instanceof LK)return FK(e);default:throw AK(e,bK)}}var UK="Key";function BK(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw AK(e,UK);return e}function GK(e){var t;return null==e?"":_k(t=jM(e)).call(t,(function(e){var t,r=cD(e,2),i=r[0],n=r[1];return!0===n?";".concat(BK(i)):_d(t=";".concat(BK(i),"=")).call(t,NK(n))})).join("")}function KK(e){var t;return e instanceof kK?_d(t="".concat(NK(e.value))).call(t,GK(e.params)):NK(e)}function HK(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!==Cc(e))throw AK(e,TK);var i=e instanceof ZC?JM(e).call(e):jM(e),n=(null==r?void 0:r.whitespace)?" ":"";return _k(t=LT(i)).call(t,(function(e){var t=cD(e,2),r=t[0],i=t[1];i instanceof kK==!1&&(i=new kK(i));var n,a,s,o=BK(r);return!0===i.value?o+=GK(i.params):(o+="=",Pk(i.value)?o+=_d(a="(".concat(_k(s=(n=i).value).call(s,KK).join(" "),")")).call(a,GK(n.params)):o+=KK(i)),o})).join(",".concat(n))}var VK=function(e){return Math.round(e)},jK=function(e){return 100*VK(e/100)},YK={br:VK,d:VK,bl:jK,dl:jK,mtp:jK,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=function(e,t){var r,i,n=new vI(e),a=new vI(t);if(n.origin!==a.origin)return e;for(var s=Fv(r=n.pathname.split("/")).call(r,1),o=Fv(i=a.pathname.split("/")).call(i,1,-1);s[0]===o[0];)s.shift(),o.shift();for(;o.length;)o.shift(),s.unshift("..");return s.join("/")}(e,t.baseUrl)),encodeURIComponent(e)},rtp:jK,tb:VK};function qK(e,t){var r,i={};if(null==e||"object"!==Cc(e))return i;var n=mA(r=gv(e)).call(r),a=AO({},YK,null==t?void 0:t.formatters),s=null==t?void 0:xk(t);return vd(n).call(n,(function(r){if(!(null==s?void 0:s(r))){var n=e[r],o=a[r];o&&(n=o(n,t)),"v"===r&&1===n||"pr"==r&&1===n||function(e){return"number"==typeof e?oO(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return"ot"===e||"sf"===e||"st"===e}(r)&&"string"==typeof n&&(n=new LK(n)),i[r]=n)}})),i}function WK(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?function(e,t){return HK(e,t)}(qK(e,t),AO({whitespace:!1},t)):""}function zK(e,t,r){return AO(e,function(e){var t,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={};if(!e)return n;var a=jM(e),s=_d(t=jM(EK)).call(t,jM((null==i?void 0:i.customHeaderMap)||{})),o=mC(a).call(a,(function(e,t){var r,i,n=cD(t,2),a=n[0],o=n[1],l=(null===(r=vv(s).call(s,(function(e){var t;return sD(t=e[1]).call(t,a)})))||void 0===r?void 0:r[0])||yK.REQUEST;return null!==(i=e[l])&&void 0!==i||(e[l]={}),e[l][a]=o,e}),{});return mC(r=jM(o)).call(r,(function(e,t){var r=cD(t,2),n=r[0],a=r[1];return e[n]=WK(a,i),e}),n)}(t,r))}var XK="CMCD";var QK=/CMCD=[^&#]+/;function $K(e,t,r){var i,n,a=function(e){if(!e)return"";var t=WK(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return"".concat(XK,"=").concat(encodeURIComponent(t))}(t,r);if(!a)return e;if(QK.test(e))return e.replace(QK,a);var s=sD(e).call(e,"?")?"&":"?";return _d(i=_d(n="".concat(e)).call(n,s)).call(i,a)}var JK=function(){function e(r){var i=this;t(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(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(e){try{i.apply(e,{ot:pK.MANIFEST,su:!i.initialized})}catch($V){i.hls.logger.warn("Could not generate manifest CMCD data.",$V)}},this.applyFragmentData=function(e){try{var t=e.frag,r=e.part,n=i.hls.levels[t.level],a=i.getObjectType(t),s={d:1e3*(r||t).duration,ot:a};a!==pK.VIDEO&&a!==pK.AUDIO&&a!=pK.MUXED||(s.br=n.bitrate/1e3,s.tb=i.getTopBandwidth(a)/1e3,s.bl=i.getBufferLength(a));var o=r?i.getNextPart(r):i.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),i.apply(e,s)}catch($V){i.hls.logger.warn("Could not generate segment CMCD data.",$V)}},this.hls=r;var n=this.config=r.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||r.sessionId,this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.includeKeys=a.includeKeys,this.registerListeners())}return Fc(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHED,this.onMediaDetached,this),e.on(dO.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHED,this.onMediaDetached,this),e.off(dO.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,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:mK.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]:{};AO(t,this.createData());var r=t.ot===pK.INIT||t.ot===pK.VIDEO||t.ot===pK.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var i,n=this.includeKeys;n&&(t=mC(i=gv(t)).call(i,(function(e,r){return sD(n).call(n,r)&&(e[r]=t[r]),e}),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),zK(e.headers,t,a)):e.url=$K(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){var i=e.sn-r.startSN;return r.fragments[i+1]}}},{key:"getNextPart",value:function(e){var t,r,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(r=t.details)?void 0:r.partList;if(a)for(var s=n.sn,o=a.length-1;o>=0;o--){var l=a[o];if(l.index===i&&l.fragment.sn===s)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?pK.TIMED_TEXT:"initSegment"===e.sn?pK.INIT:"audio"===t?pK.AUDIO:"main"===t?this.hls.audioTracks.length?pK.VIDEO:pK.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,i=this.hls;if(e===pK.AUDIO)t=i.audioTracks;else{var n,a=i.maxAutoLevel,s=a>-1?a+1:i.levels.length;t=Fv(n=i.levels).call(n,0,s)}var o,l=function(e,t){var r=void 0!==hc&&aT(e)||e["@@iterator"];if(!r){if(Ck(e)||(r=lD(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}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 a,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,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(t);try{for(l.s();!(o=l.n()).done;){var u=o.value;u.bitrate>r&&(r=u.bitrate)}}catch(JV){l.e(JV)}finally{l.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===pK.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*YN.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,r=this.applyPlaylistData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(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,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,r=this.applyFragmentData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(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,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}}]),e}(),ZK=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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 Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.ERROR,this.onError,this))}},{key:"pathways",value:function(){var e;return mC(e=this.levels||[]).call(e,(function(e,t){return-1===av(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=xk(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)===RF&&IC(r)===wF){var i,n,a,s,o,l=this.levels,u=this._pathwayPriority,c=this.pathwayId;if(t.context){var h=t.context,d=h.groupId,f=h.pathwayId,v=h.type;d&&l?c=this.getPathwayForGroupId(d,v,c):f&&(c=f)}if(c in this.penalizedPathways||(this.penalizedPathways[c]=performance.now()),!u&&l&&(u=this.pathways()),u&&u.length>1&&(this.updatePathwayPriority(u),r.resolved=this.pathwayId!==c),!r.resolved)this.warn(_d(i=_d(n=_d(a=_d(s=_d(o="Could not resolve ".concat(t.details,' ("')).call(o,t.error.message,'") with content-steering for Pathway: ')).call(s,c," levels: ")).call(a,l?l.length:l," priorities: ")).call(n,yI(u)," penalized: ")).call(i,yI(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t,r,i=this.getLevelsForPathway(this.pathwayId);if(0===i.length){var n,a=e[0].pathwayId;this.log(_d(n="No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "')).call(n,a,'"')),i=this.getLevelsForPathway(a),this.pathwayId=a}i.length!==e.length&&this.log(_d(t=_d(r="Found ".concat(i.length,"/")).call(r,e.length,' levels in Pathway "')).call(t,this.pathwayId,'"'));return i}},{key:"getLevelsForPathway",value:function(e){var t;return null===this.levels?[]:xk(t=this.levels).call(t,(function(t){return e===t.pathwayId}))}},{key:"updatePathwayPriority",value:function(e){var t,r;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();vd(t=gv(i)).call(t,(function(e){n-i[e]>3e5&&delete i[e]}));for(var a=0;a<e.length;a++){var s=e[a];if(!(s in i)){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,tB(r),this.hls.trigger(dO.LEVELS_UPDATED,{levels:r});var u=this.hls.levels[o];if(l&&u&&this.levels){var c;if(u.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==l.bitrate)this.log(_d(c="Unstable Pathways change from bitrate ".concat(l.bitrate," to ")).call(c,u.bitrate));this.hls.nextLoadLevel=o}break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var i,n=_d(i=this.getLevelsForPathway(r)).call(i,this.levels||[]),a=0;a<n.length;a++)if(t===gO&&n[a].hasAudioGroup(e)||t===pO&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return r}},{key:"clonePathways",value:function(e){var t=this,r=this.levels;if(r){var i={},n={};vd(e).call(e,(function(e){var a,s=e.ID,o=e["BASE-ID"],l=e["URI-REPLACEMENT"];if(!KT(r).call(r,(function(e){return e.pathwayId===s}))){var u=_k(a=t.getLevelsForPathway(o)).call(a,(function(e){var t,r,a=new ZN(e.attrs);a["PATHWAY-ID"]=s;var o=a.AUDIO&&_d(t="".concat(a.AUDIO,"_clone_")).call(t,s),u=a.SUBTITLES&&_d(r="".concat(a.SUBTITLES,"_clone_")).call(r,s);o&&(i[a.AUDIO]=o,a.AUDIO=o),u&&(n[a.SUBTITLES]=u,a.SUBTITLES=u);var c=tH(e.uri,a["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),h=new iF({attrs:a,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:c,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++){var f;h.addGroupId("audio",_d(f="".concat(e.audioGroups[d],"_clone_")).call(f,s))}if(e.subtitleGroups)for(var v=1;v<e.subtitleGroups.length;v++){var g;h.addGroupId("text",_d(g="".concat(e.subtitleGroups[v],"_clone_")).call(g,s))}return h}));r.push.apply(r,uD(u)),eH(t.audioTracks,i,l,s),eH(t.subtitleTracks,n,l,s)}}))}}},{key:"loadSteeringManifest",value:function(e){var t,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new vI(e)}catch($V){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: ".concat(e))}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var s={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},c={onSuccess:function(e,i,n,a){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"],u=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new vI(o,t).href}catch($V){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(o))}r.scheduleRefresh(r.uri||n.url),l&&r.clonePathways(l);var c={steeringManifest:s,url:t.toString()};r.hls.trigger(dO.STEERING_MANIFEST_LOADED,c),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION ".concat(s.VERSION," not supported!"))},onError:function(e,t,i,n){var a,s;if(r.log(_d(a=_d(s="Error loading steering manifest: ".concat(e.code," ")).call(s,e.text," (")).call(a,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 u=l.getResponseHeader("Retry-After");u&&(o=1e3*bS(u))}r.log("Steering manifest ".concat(t.url," rate limited"))}},onTimeout:function(e,t,i){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,u,c)}},{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=Wf((function(){var r,i=null==(r=t.hls)?void 0:r.media;!i||i.ended?t.scheduleRefresh(e,1e3*t.timeToLoad):t.loadSteeringManifest(e)}),r)}}]),i}(RO);function eH(e,t,r,i){var n;e&&vd(n=gv(t)).call(n,(function(n){var a,s=_k(a=xk(e).call(e,(function(e){return e.groupId===n}))).call(a,(function(e){var a=AO({},e);return a.details=void 0,a.attrs=new ZN(a.attrs),a.url=a.attrs.URI=tH(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=t[n],a.attrs["PATHWAY-ID"]=i,a}));e.push.apply(e,uD(s))}))}function tH(e,t,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];t&&(n=null==o?void 0:o[t])&&(e=n);var l,u,c=new vI(e);(a&&!n&&(c.host=a),s)&&vd(l=mA(u=gv(s)).call(u)).call(l,(function(e){e&&c.searchParams.set(e,s[e])}));return c.href}var rH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],n.onMediaEncrypted=function(e){var t,r=e.initDataType,i=e.initData,a=_d(t='"'.concat(e.type,'" event: init data type: "')).call(t,r,'"');if(n.debug(a),null!==i){var s,o;if("sinf"===r&&n.getLicenseServerUrl(cU)){var l=vN(new Uint8Array(i));try{var u=IN(aU(JSON.parse(l).sinf));if(!u)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=u.subarray(8,24),o=cU}catch($V){var c;return void n.warn(_d(c="".concat(a," Failed to parse sinf: ")).call(c,$V))}}else if(n.getLicenseServerUrl(dU)){var h=function(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,i=0;i+32<r;){var n=ON(new DataView(e,i));t.push(n),i+=n.size}return t}(i),d=gv(n.keySystemAccessPromises);d.length||(d=LU(n.config));var f=xk(h).call(h,(function(e){var t=e.systemId?SU(e.systemId):null;return!!t&&av(d).call(d,t)>-1}))[0];if(!f){var v;if(0===h.length||KT(h).call(h,(function(e){return!e.systemId})))n.warn("".concat(a," contains incomplete or invalid pssh data"));else n.log(_d(v="ignoring ".concat(a," for ")).call(v,_k(h).call(h,(function(e){return SU(e.systemId)})).join(",")," pssh data in favor of playlist keys"));return}if(o=SU(f.systemId),0===f.version&&f.data)if(o===dU){var g=f.data.length-22;s=f.data.subarray(g,g+16)}else o===hU&&(s=_U(f.data))}if(o&&s){for(var p=zF.hexDump(s),m=Zh(n),y=m.keyIdToKeySessionPromise,E=m.mediaKeySessions,k=y[p],T=function(){var e,t=E[S],a=t.decryptdata;if(!a.keyId)return"continue";var o=zF.hexDump(a.keyId);return p===o||-1!==av(e=a.uri.replace(/-/g,"")).call(e,p)?(k=y[o],a.pssh||(delete y[o],a.pssh=new Uint8Array(i),a.keyId=s,(k=y[p]=k.then((function(){return n.generateRequestWithPreferredKeySession(t,r,i,"encrypted-event-key-match")}))).catch((function(e){return n.handleError(e)}))),"break"):void 0},S=0;S<E.length;S++){var A=T();if("continue"!==A&&"break"===A)break}k||(k=y[p]=n.getKeySystemSelectionPromise([o]).then((function(e){var t,a=e.keySystem,o=e.mediaKeys;n.throwIfDestroyed();var l=new CU("ISO-23001-7",p,null!=(t=AU(a))?t:"");return l.pssh=new Uint8Array(i),l.keyId=s,n.attemptSetMediaKeys(a,o).then((function(){n.throwIfDestroyed();var e=n.createMediaKeySessionContext({decryptdata:l,keySystem:a,mediaKeys:o});return n.generateRequestWithPreferredKeySession(e,r,i,"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 Fc(i,[{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(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(dO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(dO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,r=t.drmSystems,i=t.widevineLicenseUrl,n=r[e];return n?n.licenseUrl:e===dU&&i?i: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,i=this,n=this.hls.levels,a=function(e,t,r){return!!e&&av(r).call(r,e)===t},s=xk(t=_k(n).call(n,(function(e){return e.audioCodec}))).call(t,a),o=xk(r=_k(n).call(n,(function(e){return e.videoCodec}))).call(r,a);return s.length+o.length===0&&o.push("avc1.42e01e"),new tk((function(t,r){!function e(n){var a=n.shift();i.getMediaKeysPromise(a,s,o).then((function(e){return t({keySystem:a,mediaKeys:e})})).catch((function(t){n.length?e(n):r(t instanceof iH?t:new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.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 i="Configured requestMediaKeySystemAccess is not a function ".concat(r);return null===IU&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),tk.reject(new Error(i))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var i=this,n=DU(e,t,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e],s=null==a?void 0:a.keySystemAccess;if(!s){var o;this.log(_d(o='Requesting encrypted media "'.concat(e,'" key-system access with config: ')).call(o,yI(n))),s=this.requestMediaKeySystemAccess(e,n);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){var r;i.log(_d(r='Failed to obtain access to key-system "'.concat(e,'": ')).call(r,t))})),s.then((function(t){i.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=i.fetchServerCertificate(e);return i.log('Create media-keys for "'.concat(e,'"')),l.mediaKeys=t.createMediaKeys().then((function(t){return i.log('Media-keys created for "'.concat(e,'"')),r.then((function(r){return r?i.setMediaKeysServerCertificate(t,e,r):t}))})),l.mediaKeys.catch((function(t){var r;i.error(_d(r='Failed to create media-keys for "'.concat(e,'"}: ')).call(r,t))})),l.mediaKeys}))}return s.then((function(){return a.mediaKeys}))}},{key:"createMediaKeySessionContext",value:function(e){var t,r=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log(_d(t='Creating key-system session "'.concat(i,'" keyId: ')).call(t,zF.hexDump(r.keyId||[])));var a=n.createSession(),s={decryptdata:r,keySystem:i,mediaKeys:n,mediaKeysSession:a,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),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=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 zF.hexDump(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,i,n,a=e.mediaKeysSession;return this.log(_d(r=_d(i='Updating key-session "'.concat(a.sessionId,'" for keyID ')).call(i,zF.hexDump((null==(n=e.decryptdata)?void 0:n.keyId)||[]),"\n } (data length: ")).call(r,t?t.byteLength:t,")")),a.update(t)}},{key:"selectKeySystemFormat",value:function(e){var t,r,i,n=gv(e.levelkeys||{});this.keyFormatPromise||(this.log(_d(t=_d(r=_d(i="Selecting key-system from fragment (sn: ".concat(e.sn," ")).call(i,e.type,": ")).call(r,e.level,") key formats ")).call(t,n.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(n));return this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new tk((function(r,i){var n,a=LU(t.config),s=xk(n=_k(e).call(e,mU)).call(n,(function(e){return!!e&&-1!==av(a).call(a,e)}));return t.getKeySystemSelectionPromise(s).then((function(e){var t=e.keySystem,n=AU(t);n?r(n):i(new Error('Unable to find format for key-system "'.concat(t,'"')))})).catch(i)}))}},{key:"loadKey",value:function(e){var t,r,i,n=this,a=e.keyInfo.decryptdata,s=this.getKeyIdString(a),o=_d(t=_d(r=_d(i="(keyId: ".concat(s,' format: "')).call(i,a.keyFormat,'" method: ')).call(r,a.method," uri: ")).call(t,a.uri,")");this.log("Starting session for key ".concat(o));var l=this.keyIdToKeySessionPromise[s];l||(l=this.getKeySystemForKeyPromise(a).then((function(t){var r,i,s,l=t.keySystem,u=t.mediaKeys;return n.throwIfDestroyed(),n.log(_d(r=_d(i=_d(s="Handle encrypted media sn: ".concat(e.frag.sn," ")).call(s,e.frag.type,": ")).call(i,e.frag.level," using key ")).call(r,o)),n.attemptSetMediaKeys(l,u).then((function(){return n.throwIfDestroyed(),n.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:a})}))})),(this.keyIdToKeySessionPromise[s]=l.then((function(e){var t=a.pssh?a.pssh.buffer:null;return n.generateRequestWithPreferredKeySession(e,"cenc",t,"playlist-key")}))).catch((function(e){return n.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 iH?this.hls.trigger(dO.ERROR,e.data):this.hls.trigger(dO.ERROR,{type:cO.KEY_SYSTEM_ERROR,details:hO.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 i=mU(e.keyFormat),n=i?[i]:LU(this.config);return this.attemptKeySystemAccess(n)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=LU(this.config)),0===e.length)throw new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(yI({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r,i=this,n=Fv(r=this.setMediaKeysQueue).call(r);this.log('Setting media-keys for "'.concat(e,'"'));var a=tk.all(n).then((function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(a),a.then((function(){var t;i.log('Media-keys set for "'.concat(e,'"')),n.push(a),i.setMediaKeysQueue=xk(t=i.setMediaKeysQueue).call(t,(function(e){return-1===av(n).call(n,e)}))}))}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,r,i){var n,a,s,o,l,u=this,c=null==(o=this.config.drmSystems)||null==(l=o[e.keySystem])?void 0:l.generateRequest;if(c)try{var h=c.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=h.initData?h.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch($V){var d;if(this.warn($V.message),null!=(d=this.hls)&&d.config.debug)throw $V}if(null===r)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),tk.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log(_d(n=_d(a=_d(s='Generating key-session request for "'.concat(i,'": ')).call(s,f," (init data type: ")).call(a,t," length: ")).call(n,r?r.byteLength:null,")"));var v=new AB,g=e._onmessage=function(t){var r,i,n=e.mediaKeysSession;if(n){var a=t.messageType,s=t.message;u.log(_d(r=_d(i='"'.concat(a,'" message event for session "')).call(i,n.sessionId,'" message size: ')).call(r,s.byteLength)),"license-request"===a||"license-renewal"===a?u.renewLicense(e,s).catch((function(e){v.eventNames().length?v.emit("error",e):u.handleError(e)})):"license-release"===a?e.keySystem===cU&&(u.updateKeySession(e,sU("acknowledged")),u.removeSession(e)):u.warn('unhandled media key message type "'.concat(a,'"'))}else v.emit("error",new Error("invalid state"))},p=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){u.onKeyStatusChange(e);var r,i=e.keyStatus;if(v.emit("keyStatus",i),"expired"===i)u.warn(_d(r="".concat(e.keySystem," expired for key ")).call(r,f)),u.renewKeySession(e)}else v.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",g),e.mediaKeysSession.addEventListener("keystatuseschange",p);var m=new tk((function(e,t){v.on("error",t),v.on("keyStatus",(function(r){KI(r).call(r,"usable")?e():"output-restricted"===r?t(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(r,'"'))):"expired"===r?t(new Error("key expired while generating request")):u.warn('unhandled key status change "'.concat(r,'"'))}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t,r;u.log(_d(t='Request generated for key-session "'.concat(null==(r=e.mediaKeysSession)?void 0:r.sessionId,'" keyId: ')).call(t,f))})).catch((function(e){throw new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: ".concat(e))})).then((function(){return m})).catch((function(t){throw v.removeAllListeners(),u.removeSession(e),t})).then((function(){return v.removeAllListeners(),e}))}},{key:"onKeyStatusChange",value:function(e){var t,r=this;vd(t=e.mediaKeysSession.keyStatuses).call(t,(function(t,i){var n,a,s;r.log(_d(n=_d(a=_d(s='key status change "'.concat(t,'" for keyStatuses keyId: ')).call(s,zF.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))," session keyId: ")).call(a,zF.hexDump(new Uint8Array(e.decryptdata.keyId||[]))," uri: ")).call(n,e.decryptdata.uri)),e.keyStatus=t}))}},{key:"fetchServerCertificate",value:function(e){var t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching server certificate for "'.concat(e,'"')),new tk((function(n,a){var s={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:function(e,t,r,i){n(e.data)},onError:function(t,r,n,o){var l,u,c;a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:bO({url:s.url,data:void 0},t)},_d(l=_d(u=_d(c='"'.concat(e,'" certificate request failed (')).call(c,i,"). Status: ")).call(u,t.code," (")).call(l,t.text,")")))},onTimeout:function(t,r,n){var o;a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:s.url,data:void 0}},_d(o='"'.concat(e,'" certificate request timed out (')).call(o,i,")")))},onAbort:function(e,t,r){a(new Error("aborted"))}};r.load(s,l,u)}))):tk.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var i=this;return new tk((function(n,a){e.setServerCertificate(r).then((function(a){var s,o;i.log(_d(s=_d(o="setServerCertificate ".concat(a?"success":"not supported by CDM"," (")).call(o,null==r?void 0:r.byteLength,') on "')).call(s,t,'"')),n(e)})).catch((function(e){a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.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 iH({type:cO.KEY_SYSTEM_ERROR,details:hO.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(!sD(r).call(r,"PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var i=(new DOMParser).parseFromString(r,"application/xml"),n=i.querySelectorAll("HttpHeader");if(n.length>0)for(var a,s=0,o=n.length;s<o;s++){var l,u,c=null==(l=(a=n[s]).querySelector("name"))?void 0:l.textContent,h=null==(u=a.querySelector("value"))?void 0:u.textContent;c&&h&&e.setRequestHeader(c,h)}var d=i.querySelector("Challenge"),f=null==d?void 0:d.textContent;if(!f)throw new Error("Cannot find <Challenge> in key message");return sU(atob(f))}},{key:"setupLicenseXHR",value:function(e,t,r,i){var n=this,a=this.config.licenseXhrSetup;return a?tk.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return a.call(n.hls,e,t,r,i)})).catch((function(s){if(!r.decryptdata)throw s;return e.open("POST",t,!0),a.call(n.hls,e,t,r,i)})).then((function(r){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||i}})):(e.open("POST",t,!0),tk.resolve({xhr:e,licenseChallenge:i}))}},{key:"requestLicense",value:function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new tk((function(n,a){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 a(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 u=r.config.licenseResponseCallback;if(u)try{l=u.call(r.hls,o,s,e)}catch($V){r.error($V)}n(l)}else{var c=i.errorRetry,h=c?c.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>h||o.status>=400&&o.status<500){var d,f;a(new iH({type:cO.KEY_SYSTEM_ERROR,details:hO.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},_d(d=_d(f="License Request XHR failed (".concat(s,"). Status: ")).call(f,o.status," (")).call(d,o.statusText,")")))}else{var v=h-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(v," attempts left")),r.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,t).then((function(t){var i=t.xhr,n=t.licenseChallenge;e.keySystem==hU&&(n=r.unpackPlayReadyKeyMessage(i,n)),i.send(n)}))}))}},{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,r=this,n=this.media,a=this.mediaKeySessions;n&&(n.removeEventListener("encrypted",this.onMediaEncrypted),n.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},CU.clearKeyUriToKeyIdMap();var s=a.length;i.CDMCleanupPromise=tk.all(_d(e=_k(a).call(a,(function(e){return r.removeSession(e)}))).call(e,null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch((function(e){var t;r.log("Could not clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){s&&(r.log("finished closing key sessions and clearing media keys"),a.length=0)})).catch((function(e){var t;r.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.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 i=mC(r).call(r,(function(e,t){return-1===av(e).call(e,t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys ".concat(i.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){var n;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),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a,s=av(n=this.mediaKeySessions).call(n,e);if(s>-1)ig(a=this.mediaKeySessions).call(a,s,1);return r.remove().catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.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(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),i}(RO);rH.CDMCleanupPromise=void 0;var iH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n)).data=void 0,e.error||(e.error=new Error(n)),a.data=e,e.err=e.error,a}return Fc(i)}(Jw(Error)),nH=function(){function e(r){t(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=r,this.registerListeners()}return Fc(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(dO.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 i,n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=lS(iT(i=this.checkFPSInterval).call(i,this),r.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(dO.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(dO.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,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 aH(e,t){var r;try{r=new Event("addtrack")}catch(JV){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function sH(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(JV){PO.debug("[texttrack-utils]: ".concat(JV));try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(n){PO.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(n))}}"disabled"===r&&(e.mode=r)}function oH(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(var i=e.cues.length;i--;)t&&e.cues[i].removeEventListener("enter",t),e.removeCue(e.cues[i]);"disabled"===r&&(e.mode=r)}function lH(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;var i=0,n=r;for(;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}function uH(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}var cH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.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=uH(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 i=n.findTrackForTextTrack(e);n.subtitleTrack!==i&&n.setSubtitleTrack(i)}},n.registerListeners(),n}return Fc(i,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,Ih(Rh(i.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(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVEL_LOADING,this.onLevelLoading,this),e.off(dO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(dO.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=lS(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;if(r){var i=!!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,!i){var n=uH(r.textTracks);vd(n).call(n,(function(e){oH(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,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Subtitle track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Subtitle track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.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,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&KT(r).call(r,(function(e){return-1===(null==i?void 0:av(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=xk(a=this.tracks).call(a,(function(e){return!r||-1!==av(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!KT(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.subtitlePreference;if(!n&&l){this.selectDefaultTrack=!1;var u=uF(l,o);if(u>-1)n=o[u];else{var c=uF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={subtitleTracks:o};this.log(_d(s="Updating subtitle tracks, ".concat(o.length,' track(s) found in "')).call(s,null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(dO.SUBTITLE_TRACKS_UPDATED,d),-1!==h&&-1===this.trackId&&this.setSubtitleTrack(h)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=this.selectDefaultTrack,i=0;i<t.length;i++){var n=t[i];if((!r||n.default)&&(r||e)&&(!e||cF(n,e)))return i}if(e){for(var a=0;a<t.length;a++){var s=t[a];if(iK(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return a}for(var o=0;o<t.length;o++){var l=t[o];if(iK(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(nK(t[r],e))return r}return-1}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==pO||t.context.id!==this.trackId||this.groupIds&&-1===av(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&&cF(e,r))return r;var i=uF(e,this.tracksInGroup);if(i>-1){var n=this.tracksInGroup[i];return this.setSubtitleTrack(i),n}if(r)return null;var a=uF(e,t);if(a>-1)return t[a]}}return null}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading subtitle ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(dO.SUBTITLE_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}},{key:"toggleTrackModes",value:function(){var e,t=this.media;if(t){var r,i,n=uH(t.textTracks),a=this.currentTrack;if(a)if(!(r=xk(n).call(n,(function(e){return nK(a,e)}))[0]))this.warn(_d(i='Unable to find subtitle TextTrack with name "'.concat(a.name,'" and language "')).call(i,a.lang,'"'));if(vd(e=Fv([]).call(n)).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,i=this.tracksInGroup;if(this.media)if(e<-1||e>=i.length||!oO(e))this.warn("Invalid subtitle track id: ".concat(e));else{this.selectDefaultTrack=!1;var n=this.currentTrack,a=i[e]||null;if(this.trackId=e,this.currentTrack=a,this.toggleTrackModes(),a){var s=!!a.details&&!a.details.live;if(e!==this.trackId||a!==n||!s){this.log("Switching to subtitle-track ".concat(e)+(a?_d(t=_d(r=' "'.concat(a.name,'" lang:')).call(r,a.lang," group:")).call(t,a.groupId):""));var o=a.id,l=a.groupId,u=void 0===l?"":l,c=a.name,h=a.type,d=a.url;this.hls.trigger(dO.SUBTITLE_TRACK_SWITCH,{id:o,groupId:u,name:c,type:h,url:d});var f=this.switchParams(a.url,null==n?void 0:n.details,a.details);this.loadPlaylist(f)}}else this.hls.trigger(dO.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),i}(sK);function hH(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var dH=.02,fH=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function vH(e,t,r){var i,n;return _d(i=_d(n="".concat(e.identifier,"-")).call(n,r+1,"-")).call(i,hH(t))}var gH=function(){function e(r,i){t(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=i,this.dateRange=r,this.setDateRange(r)}return Fc(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 av(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 pH(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=oO(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 pH(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)<dH))},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"]?fH.Range:fH.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 _d(t=_d(r=_d(i='["'.concat((e=this).identifier,'" ')).call(i,e.cue.pre?"<pre>":e.cue.post?"<post>":"")).call(r,e.timelineStart.toFixed(2),"-")).call(t,e.resumeTime.toFixed(2),"]");var e,t,r,i}}]),e}();function pH(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<dH)?t.start:t.start+t.duration}function mH(e,t,r){var i=new vI(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function yH(e){var t,r,i=e.timelineStart,n=e.duration||0;return _d(t=_d(r='["'.concat(e.identifier,'" ')).call(r,i.toFixed(2),"-")).call(t,(i+n).toFixed(2),"]")}var EH=function(){function e(r,i,n,a){var s=this;t(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=s.interstitial.playoutLimit;s.playoutOffset+s.currentTime>=e&&s.hls.trigger(dO.PLAYOUT_LIMIT_REACHED,{})};var o=this.hls=new r(i);this.interstitial=n,this.assetItem=a;var l=a.uri;try{l=mH(l,o.sessionId).href}catch($V){}o.loadSource(l);var u=function(){s.hasDetails=!0};o.once(dO.LEVEL_LOADED,u),o.once(dO.AUDIO_TRACK_LOADED,u),o.once(dO.SUBTITLE_TRACK_LOADED,u),o.on(dO.MEDIA_ATTACHING,(function(e,t){var r=t.media;s.removeMediaListeners(),s.mediaAttached=r;var i,n,o=s.interstitial;o.playoutLimit&&(s.playoutOffset=(null==(n=o.assetList[av(i=o.assetList).call(i,a)])?void 0:n.startOffset)||0,r.addEventListener("timeupdate",s.checkPlayout))}))}return Fc(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=YN.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 _d(e=_d(t="HlsAssetPlayer: ".concat(yH(this.assetItem)," ")).call(t,this.hls.sessionId," ")).call(e,this.interstitial.appendInPlace?"append-in-place":"")}}]),e}(),kH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 Fc(i,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){var e;(this.eventMap={},this.setDurations(0,0,0),this.events)&&vd(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 i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(n=i[r])&&n.event;){var n;r--}return r}},{key:"findItemIndexAtTime",value:function(e,t){var r=this.items;if(r)for(var i=0;i<r.length;i++){var n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return i}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var r=this.items;if(r)for(var i=e;i<=t&&r[i];i++){var n=r[i].event;if(null!=n&&n.restrictions.jump&&!n.appendInPlace)return i}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var r=t.length;r--;){var i;if((null==(i=t[r].event)?void 0:i.identifier)===e)return r}return-1}},{key:"findAssetIndex",value:function(e,t){var r=e.assetList,i=r.length;if(i>1)for(var n=0;n<i;n++){var a=r[n];if(!a.error){var s=a.timelineStart;if(t===s||t>s&&t<s+(a.duration||0))return n}}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 i=r.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e){var t=this,r=e.main.details,i=r.dateRanges,n=this.events,a=this.parseDateRanges(i,{url:r.url}),s=gv(i),o=n?xk(n).call(n,(function(e){return!sD(s).call(s,e.identifier)})):[];a.length&&mA(a).call(a,(function(e,t){var r=e.cue.pre,i=e.cue.post,n=t.cue.pre,a=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!a)return 1;if(a&&!i)return-1;if(!(r||n||i||a)){var s=e.startTime,o=t.startTime;if(s!==o)return s-o}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=a,vd(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 i=this.items,n=this.parseSchedule(r,e);(t.length||(null==i?void 0:i.length)!==n.length||KT(n).call(n,(function(e,t){return Math.abs(e.playout.start-i[t].playout.start)>.005||Math.abs(e.playout.end-i[t].playout.end)>.005})))&&(this.items=n,this.onScheduleUpdate(t,i))}}},{key:"parseDateRanges",value:function(e,t){for(var r=[],i=gv(e),n=0;n<i.length;n++){var a=i[n],s=e[a];if(s.isInterstitial){var o=this.eventMap[a];o?o.setDateRange(s):(o=new gH(s,t),this.eventMap[a]=o),r.push(o)}}return r}},{key:"parseSchedule",value:function(e,t){var r=[],i=t.main.details,n=i.live?1/0:i.edge,a=0;if((e=xk(e).call(e,(function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(vd(e).call(e,(function(t,i){var l=t.cue.pre,u=t.cue.post,c=e[i-1]||null,h=t.appendInPlace,d=u?n:t.startOffset,f=t.duration,v=t.timelineOccupancy===fH.Range?f:0,g=t.resumptionOffset,p=(null==c?void 0:c.startTime)===d,m=d+t.cumulativeDuration,y=h?m+f:d+g;if(l||!u&&d<=0){var E=o;o+=v,t.timelineStart=m;var k=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:k,end:a},integrated:{start:E,end:o}})}else{if(!(d<=n))return;if(!p){var T=d-s;if(T>.033){var S=s,A=o;o+=T;var L=a;a+=T;var b={previousEvent:e[i-1]||null,nextEvent:t,start:S,end:S+T,playout:{start:L,end:a},integrated:{start:A,end:o}};r.push(b)}else T>0&&c&&(c.cumulativeDuration+=T,r[r.length-1].end=d)}u&&(y=m),t.timelineStart=m;var R=o;o+=v;var I=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:I,end:a},integrated:{start:R,end:o}})}var D=t.resumeTime;s=u||D>n?n:D})),s<n){var l,u=s,c=o,h=n-s;o+=h;var d=a;a+=h,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:s,end:u+h,playout:{start:d,end:a},integrated:{start:c,end:o}})}this.setDurations(n,a,o)}else{r.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n)}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,i=t.main.details,n=i.live?1/0:i.edge,a=0,s=-1;vd(e).call(e,(function(o,l){var u=o.cue.pre,c=o.cue.post,h=u?0:c?n:o.startTime;(r.updateAssetDurations(o),s===h?o.cumulativeDuration=a:(a=0,s=h),!c&&o.snapOptions.in&&(o.resumeAnchor=pF(null,i.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 d=l-1;l--;){e[d+1].startTime-e[d].resumeTime<.033&&(e[d].appendInPlace=!1)}var f=oO(o.resumeOffset)?o.resumeOffset:o.duration;a+=f}))}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var r,i,n,a,s=this,o=e.resumeTime,l=e.startTime+e.resumptionOffset;return Math.abs(o-l)>dH?(this.log(_d(i=_d(n='"'.concat(e.identifier,'" resumption ')).call(n,o," not aligned with estimated timeline end ")).call(i,l)),!1):t?!KT(r=gv(t)).call(r,(function(r){var i,n,a,l=t[r].details,u=l.edge;if(o>u)return s.log(_d(i=_d(n=_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," past ")).call(n,r," playlist end ")).call(i,u)),!0;var c,h,d=pF(null,l.fragments,o);if(!d)return s.log(_d(c=_d(h='"'.concat(e.identifier,'" resumption ')).call(h,o," does not align with any fragments in ")).call(c,r," playlist")),!0;var f,v,g,p,m,y,E="audio"===r?.175:0;return!(Math.abs(d.start-o)<dH||Math.abs(d.end-o)<dH+E)&&(s.log(_d(f=_d(v=_d(g=_d(p=_d(m=_d(y='"'.concat(e.identifier,'" resumption ')).call(y,o," not aligned with ")).call(m,r," fragment bounds (")).call(p,d.start,"-")).call(g,d.end," sn: ")).call(v,d.sn," cc: ")).call(f,d.cc,")")),!0)})):(this.log(_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," can not be aligned with media (none selected)")),!1)}},{key:"updateAssetDurations",value:function(e){var t,r=e.timelineStart,i=0,n=!1,a=!1;vd(t=e.assetList).call(t,(function(e,t){var s=r+i;e.startOffset=i,e.timelineStart=s,n||(n=null===e.duration),a||(a=!!e.error);var o=e.error?0:e.duration||0;i+=o})),e.duration=n&&!a?Math.max(i,e.duration):i}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}]),i}(RO);function TH(e){var t,r;return _d(t=_d(r="[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ")).call(r,e.start.toFixed(2),"-")).call(t,e.end.toFixed(2),"]")}var SH=function(){function e(r){t(this,e),this.hls=void 0,this.hls=r}return Fc(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,i=this,n=e.assetListUrl;try{r=mH(n,this.hls.sessionId,e.baseUrl)}catch($V){var a=this.assignAssetListError(e,hO.ASSET_LIST_LOAD_ERROR,$V,n);return void this.hls.trigger(dO.ERROR,a)}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),u={responseType:"json",url:r.href},c=o.interstitialAssetListLoadPolicy.default,h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:function(t,r,n,a){var s=t.data,o=null==s?void 0:s.ASSETS;if(Pk(o))e.assetListResponse=s,i.hls.trigger(dO.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:a});else{var l=i.assignAssetListError(e,hO.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,r,a);i.hls.trigger(dO.ERROR,l)}},onError:function(t,r,n,a){var s,o,l=i.assignAssetListError(e,hO.ASSET_LIST_LOAD_ERROR,new Error(_d(s=_d(o="Error loading X-ASSET-LIST: HTTP status ".concat(t.code," ")).call(o,t.text," (")).call(s,r.url,")")),r.url,a,n);i.hls.trigger(dO.ERROR,l)},onTimeout:function(t,r,n){var a=i.assignAssetListError(e,hO.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,n);i.hls.trigger(dO.ERROR,a)}};return l.load(u,h,d),this.hls.trigger(dO.ASSET_LIST_LOADING,{event:e}),l}},{key:"assignAssetListError",value:function(e,t,r,i,n,a){return e.error=r,{type:cO.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:a,stats:n}}}]),e}();function AH(e){null==e||e.play().catch()}var LH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 i=a.playingItem;if(i)if(r&&e<i.start||e>=i.end){var n,s=a.schedule.findItemIndexAtTime(a.timelinePos);if(!a.isInterstitial(i)&&null!=(n=a.media)&&n.paused&&(a.shouldPlay=!1),!r){var o=a.findItemIndex(i);if(s>o){var l=a.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void a.setSchedulePosition(l)}}a.setSchedulePosition(s)}else{var u=a.playingAsset;if(u){var c=u.timelineStart,h=u.duration||0;(r&&e<c||e>=c+h)&&a.setScheduleToAssetAtTime(e,u)}else if(a.playingLastItem&&a.isInterstitial(i)){var d=i.event.assetList[0];d&&(a.playingItem=null,a.setScheduleToAssetAtTime(e,d))}}}}},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 i=a.playingAsset;if(i)e>=i.timelineStart+(i.duration||0)&&a.setScheduleToAssetAtTime(e,i)}}},a.onScheduleUpdate=function(e,t){var r,i,n,s=a.schedule,o=a.playingItem,l=s.events||[],u=s.items||[],c=s.durations,h=_k(e).call(e,(function(e){return e.identifier})),d=!(!l.length&&!h.length);d&&(!1===a.hls.config.interstitialAppendInPlace&&vd(l).call(l,(function(e){return e.appendInPlace=!1})),a.log(_d(i=_d(n="INTERSTITIALS_UPDATED (".concat(l.length,"): ")).call(n,l,"\nSchedule: ")).call(i,_k(u).call(u,(function(e){return TH(e)})))));h.length&&a.log("Removed events ".concat(h)),vd(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 i,n,s;if(Math.abs(r)>dH)a.warn(_d(i=_d(n=_d(s="".concat(o,' ("')).call(s,e.assetId,'" ')).call(n,e.timelineOffset,"->")).call(i,t,")"))}}})),o&&!o.event&&(a.playingItem=a.updateItem(o,a.timelinePos));var f=a.bufferingItem;if(f&&(f.event?a.updateItem(f)||(a.bufferingItem=null,a.clearInterstitial(f.event,null)):a.bufferingItem=a.updateItem(f,a.bufferedPos)),a.waitingItem=a.updateItem(a.waitingItem),vd(e).call(e,(function(e){var t;vd(t=e.assetList).call(t,(function(e){a.clearAssetPlayer(e.identifier,null)}))})),d||t){if(a.hls.trigger(dO.INTERSTITIALS_UPDATED,{events:Fv(l).call(l,0),schedule:Fv(u).call(u,0),durations:c,removedIds:h}),a.isInterstitial(o)&&sD(h).call(h,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 SH(e),a.schedule=new kH(a.onScheduleUpdate,e.logger),a.registerListeners(),a}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(dO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(dO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(dO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(dO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(dO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(dO.MEDIA_ENDED,this.onMediaEnded,this),e.on(dO.ERROR,this.onError,this),e.on(dO.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(dO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(dO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(dO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(dO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(dO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(dO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(dO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(dO.MEDIA_ENDED,this.onMediaEnded,this),e.off(dO.ERROR,this.onError,this),e.off(dO.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;vd(e=this.playerQueue).call(e,(function(e){return e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){var e;vd(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,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();var n=this.findItemIndex(r);this.setSchedulePosition(n)}}},{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,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){var n=this.getBufferingPlayer();n&&(this.playingAsset=null,this.bufferingAsset=null,this.bufferingItem=null,this.waitingItem=null,this.detachedData=null,n.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},i=function(t){return t?e.getAssetPlayer(t.identifier):t},n=function(t,r,n,a,o){if(t){var l=t[r].start,u=t.event;if(u){if("playout"===r||u.timelineOccupancy!==fH.Point){var c=i(n);(null==c?void 0:c.interstitial)===u&&(l+=c.assetItem.startOffset+c[o])}}else l+=("bufferedPos"===a?s():e[a])-t.start;return l}return 0},a=function(t,r){if(0!==t&&"primary"!==r&&e.schedule.length){var i,n=e.schedule.findItemIndexAtTime(t),a=null==(i=e.schedule.items)?void 0:i[n];if(a)return t+(a[r].start-a.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,a){var s,o,l,u=r();if(null==u||null==(o=u.event)||!o.restrictions.skip){e.log(_d(s="seek to ".concat(t,' "')).call(s,a,'"'));var c=r(),h=e.schedule.findItemIndexAtTime(t,a),d=null==(l=e.schedule.items)?void 0:l[h],f=null==c?void 0:c.event,v=null==f?void 0:f.appendInPlace,g=c&&e.itemsMatch(c,d);if(c&&(v||g)){var p=i(e.playingAsset),m=(null==p?void 0:p.media)||e.hls.media;if(m){var y=t-("primary"===a?m.currentTime:n(c,a,e.playingAsset,"timelinePos","currentTime")),E=m.currentTime+y;if(E>=0&&(!p||v||E<=p.duration))return void(m.currentTime=E)}}if(d){var k=t;if("primary"!==a){var T=t-d[a].start;k=d.start+T}var S=!e.isInterstitial(d);if(e.isInterstitial(c)||!S&&!d.event.appendInPlace){if(c){var A=e.findItemIndex(c);if(h>A){var L=e.schedule.findJumpRestrictedIndex(A+1,h);if(L>A)return void e.setSchedulePosition(L)}var b=0;if(S)e.timelinePos=k;else{var R,I=null==d||null==(R=d.event)?void 0:R.assetList;if(I)for(var D=t-(d[a]||d).start,_=I.length;_--;){var w=I[_];if(w.duration&&D>=w.startOffset&&D<w.startOffset+w.duration){b=_;break}}}e.setSchedulePosition(h,b)}}else{var C=e.hls.media;C&&(C.currentTime=k)}}}};this.manager={get events(){var t,r;return(null==(t=e.schedule)||null==(r=t.events)?void 0:Fv(r).call(r,0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:Fv(r).call(r,0))||[]},get playerQueue(){var t;return Fv(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 n(t(),"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"playout",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("playout")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"playout")},seekTo:function(e){return l(e,"playout")}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"integrated",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("integrated")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")},seekTo:function(e){return l(e,"integrated")}},skip:function(){var t=r(),i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;l(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,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 i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(n=this.primaryMedia);var a=null==(r=n)?void 0:r.currentTime;if(void 0!==a&&oO(a))return a}}}},{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,i=e.media;if(r&&i===this.primaryMedia){var n;if(!t||this.isInterstitial(t)&&!t.event.appendInPlace)return void(t&&i&&(this.detachedData={media:i}));var a=e.transferMedia();this.log(_d(n="transfer MediaSource from ".concat(e," ")).call(n,yI(a))),this.bufferingAsset=null,this.detachedData=a}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}},{key:"transferMediaTo",value:function(e,t){var r,i,n,a,s,o,l=null,u=this.hls,c=e!==u,h=c&&e.interstitial.appendInPlace,d=null==(a=this.detachedData)?void 0:a.mediaSource;if(u.media&&h)l=u.transferMedia(),this.detachedData=l,o="Primary";else if(d){var f=this.getBufferingPlayer();f&&(l=f.transferMedia()),o="".concat(f)}else o="<unknown>";this.log(_d(r=_d(i="transferring to ".concat(c?e:"Primary","\nMediaSource ")).call(i,yI(l)," from ")).call(r,o)),l||(d?(l=this.detachedData,this.log("using detachedData: MediaSource ".concat(yI(l)))):this.detachedData&&this.hls.media!==t||(this.hls.detachMedia(),this.detachedData={media:t}));var v=l&&"mediaSource"in l&&"closed"!==(null==(s=l.mediaSource)?void 0:s.readyState),g=v&&l?l:t;if(this.log(_d(n="".concat(v?"transfering MediaSource":"attaching media"," to ")).call(n,c?e:"Primary")),g===l){var p=c&&e.assetId===this.schedule.assetIdAtEnd;g.overrides={duration:this.schedule.duration,endOfStream:!c||p,cueRemoval:!1}}e.attachMedia(g)}},{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,i=this.waitingItem;if(-1===r){var n=this.hls.startPosition;if(this.timelinePos=n,t.length&&t[0].cue.pre){var a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(n>=0||!this.primaryLive){var s=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(i&&!this.playingItem){var l=e.findItemIndex(i);this.setSchedulePosition(l)}}}},{key:"advanceAfterAssetEnded",value:function(e,t,r){var i=r+1;if(e.isAssetPastPlayoutLimit(i)||e.assetList[i].error){var n=this.schedule.items;if(n){var a=t+1;if(a>=n.length)return void this.setSchedulePosition(-1);this.setSchedulePosition(a)}}else this.setSchedulePosition(t,i)}},{key:"setScheduleToAssetAtTime",value:function(e,t){var r=this.schedule,i=t.parentIdentifier,n=r.getEvent(i);if(n){var a=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.setSchedulePosition(a,s)}}},{key:"setSchedulePosition",value:function(e,t){var r,i=this,n=this.schedule.items;if(n&&!this.playbackDisabled){this.log(_d(r="setSchedulePosition ".concat(e,", ")).call(r,t));var a=e>=0?n[e]:null,s=this.primaryMedia,o=this.playingItem,l=this.playingLastItem;if(this.isInterstitial(o)){var u,c,h=o.event,d=this.playingAsset,f=null==d?void 0:d.identifier,v=f?this.getAssetPlayer(f):null;if(v&&f&&(!this.eventItemsMatch(o,a)||void 0!==t&&f!==(null==(u=h.assetList)?void 0:u[t].identifier))){var g,p;this.playingAsset=null;var m=h.findAssetIndex(d);this.log(_d(g=_d(p="INTERSTITIAL_ASSET_ENDED ".concat(m+1,"/")).call(p,h.assetList.length," ")).call(g,yH(d))),this.hls.trigger(dO.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:m,event:h,schedule:Fv(n).call(n,0),scheduleIndex:e,player:v}),this.retreiveMediaSource(f,a),v.media&&!this.detachedData&&v.detachMedia(),this.clearAssetPlayer(f,a)}if(!this.eventItemsMatch(o,a))if(this.playingItem=null,this.log(_d(c="INTERSTITIAL_ENDED ".concat(h," ")).call(c,TH(o))),h.hasPlayed=!0,this.hls.trigger(dO.INTERSTITIAL_ENDED,{event:h,schedule:Fv(n).call(n,0),scheduleIndex:e}),this.clearInterstitial(h,a),h.cue.once){if(this.updateSchedule(),a){var y=this.schedule.findItemIndex(a);this.setSchedulePosition(y,t)}return}}var E=this.playerQueue;if(E.length&&vd(E).call(E,(function(t){var r=t.interstitial,n=i.schedule.findEventIndex(r.identifier);(n<e||n>e+1)&&i.clearInterstitial(r,a)})),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);var k=a.event;void 0===t&&(t=this.schedule.findAssetIndex(k,this.timelinePos));var T,S=this.waitingItem,A=this.preloadAssets(k,t);if(A||this.setBufferingItem(a),!this.eventItemsMatch(a,o||S))this.waitingItem=a,this.log(_d(T="INTERSTITIAL_STARTED ".concat(TH(a)," ")).call(T,k.appendInPlace?"append in place":"")),this.hls.trigger(dO.INTERSTITIAL_STARTED,{event:k,schedule:Fv(n).call(n,0),scheduleIndex:e});var L=k.assetList.length;if(0===L&&!k.assetListResponse)return void this.log("Waiting for ASSET-LIST to complete loading ".concat(k));if(k.assetListLoader&&(k.assetListLoader.destroy(),k.assetListLoader=void 0),!s)return void this.log("Waiting for attachMedia to start Interstitial ".concat(k));this.waitingItem=null,this.playingItem=a;var b,R,I=k.assetList[t];if(!I){var D=n[e+1],_=this.media;return D&&_&&!this.isInterstitial(D)&&_.currentTime<D.start&&(_.currentTime=this.timelinePos=D.start),void this.advanceAfterAssetEnded(k,e,t||0)}if(A||(A=this.getAssetPlayer(I.identifier)),null===A||A.destroyed)this.warn(_d(b=_d(R="asset ".concat(t+1,"/")).call(R,L," player destroyed ")).call(b,k)),A=this.createAssetPlayer(k,I,t);if(!this.eventItemsMatch(a,this.bufferingItem)&&k.appendInPlace&&this.isAssetBuffered(I))return;this.startAssetPlayer(A,t,n,e,s),this.shouldPlay&&AH(A.media)}else null!==a?(this.resumePrimary(a,e,o),this.shouldPlay&&AH(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 i;if(this.playingItem=e,this.playingAsset=null,this.waitingItem=null,this.bufferedToItem(e),this.log("resuming ".concat(TH(e))),null==(i=this.detachedData)||!i.mediaSource){var n=this.timelinePos;(n<e.start||n>=e.end)&&(n=this.getPrimaryResumption(e,t),this.timelinePos=n),this.attachPrimary(n,e)}if(r){var a=this.schedule.items;a&&(this.log("resumed ".concat(TH(e))),this.hls.trigger(dO.INTERSTITIALS_PRIMARY_RESUMED,{schedule:Fv(a).call(a,0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var r=e.start;if(this.primaryLive){var i=this.primaryDetails;if(0===t)return this.hls.startPosition;if(i&&(r<i.fragmentStart||r>i.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:YN.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 i=this.primaryMedia;if(i){var n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,i),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(dO.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(dO.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],i=bO(bO({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i),!this.playingItem&&this.schedule.items&&this.checkStart()}}},{key:"onAudioTrackUpdated",value:function(e,t){var r=this.hls.audioTracks[t.id],i=this.mediaSelection;if(i){var n=bO(bO({},i),{},{audio:r});this.mediaSelection=n}else this.altSelection=bO(bO({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(i){var n=bO(bO({},i),{},{subtitles:r});this.mediaSelection=n}else this.altSelection=bO(bO({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r,i=lF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(i)}))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r,i=lF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(i)}))}},{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 i=this.timelinePos;this.bufferedPos=i,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 i=t[r];if(i.cue.post){var n,a=this.schedule.findEventIndex(i.identifier),s=null==(n=this.schedule.items)?void 0:n[a];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,i;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==(i=t.nextEvent)?void 0:i.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=YN.bufferInfo(this.primaryMedia,this.timelinePos,0);this.updateBufferedPos(t.end,e,0===t.len)}}},{key:"updateBufferedPos",value:function(e,t,r){var i=this.schedule,n=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],n))this.bufferedPos=e;else{var a=this.playingItem,s=this.findItemIndex(a),o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,u=this.findItemIndex(n),c=Math.min(u+1,t.length-1),h=t[c];if(-1===o&&n&&e>=n.end&&(o=c),c-s>1&&!1===(null==n||null==(l=n.event)?void 0:l.appendInPlace))return;if(this.bufferedPos=e,o>u&&o>s)this.bufferedToItem(h);else{var d=this.primaryDetails;this.primaryLive&&d&&e>d.edge-d.targetduration&&h.start<d.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else r&&a&&n!==a&&o===s&&this.bufferedToItem(a)}}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,r=this.schedule,i=r.items,n=r.events;if(i&&n&&(!t||r.findItemIndex(t)!==r.findItemIndex(e))){var a,s,o=this.isInterstitial(e),l=this.getBufferingPlayer(),u=l?l.remaining:t?t.end-this.timelinePos:0;if(this.log("buffered to boundary ".concat(TH(e))+(t?" (".concat(u.toFixed(2)," remaining)"):"")),this.bufferingItem=e,this.bufferedPos=e.start,!this.playbackDisabled)if(o)vd(a=this.playerQueue).call(a,(function(e){return e.resumeBuffering()}));else this.hls.resumeBuffering(),vd(s=this.playerQueue).call(s,(function(e){return e.pauseBuffering()}));this.hls.trigger(dO.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:Fv(n).call(n,0),schedule:Fv(i).call(i,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 i=this.detachedData;if(i)if(i.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,i=0===r.assetList.length&&!r.assetListLoader,n=r.cue.once;if(i||!n){var a=this.preloadAssets(r,t);if(null!=a&&a.interstitial.appendInPlace){var s=r.assetList[t],o=this.primaryMedia;s&&o&&this.bufferAssetPlayer(a,o)}}}},{key:"preloadAssets",value:function(e,t){var r=e.assetList.length,i=0===r&&!e.assetListLoader,n=e.cue.once;if(i){var a,s;this.log(_d(a=_d(s="Load interstitial asset ".concat(t+1,"/")).call(s,r," ")).call(a,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 u=0;!this.playingItem&&this.primaryLive&&-1===(u=this.hls.startPosition)&&(u=this.hls.liveSyncPosition||0);var c=this.assetListLoader.loadAssetList(e,u);c&&(e.assetListLoader=c)}else if(!n&&r){for(var h=t;h<r;h++){var d=e.assetList[h],f=this.getAssetPlayerQueueIndex(d.identifier);-1!==f&&!this.playerQueue[f].destroyed||d.error||this.createAssetPlayer(e,d,h)}return this.getAssetPlayer(e.assetList[t].identifier)}return null}},{key:"flushFrontBuffer",value:function(e){var t=this,r=this.requiredTracks;if(r){var i=gv(r);vd(i).call(i,(function(r){t.hls.trigger(dO.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,i,n,a){var s={parentIdentifier:e.identifier,identifier:vH(e,a,t),duration:n,startOffset:r,timelineStart:i,uri:a};return this.createAssetPlayer(e,s,t)}},{key:"createAssetPlayer",value:function(e,t,r){var i=this;this.log("create HLSAssetPlayer for ".concat(yH(t)));var n=this.hls,a=n.userConfig,s=a.videoPreference,o=n.levels[n.loadLevel]||n.levels[n.currentLevel];(s||o)&&(s=AO({},s),o.videoCodec&&(s.videoCodec=o.videoCodec),o.videoRange&&(s.allowedVideoRanges=[o.videoRange]));var l=n.audioTracks[n.audioTrack],u=n.subtitleTracks[n.subtitleTrack],c=0;if(this.primaryLive){var h=this.timelinePos-t.timelineStart;if(h>1){var d=t.duration;d&&h<d&&(c=h)}}var f=bO(bO({},a),{},{autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:t.identifier,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:l||a.audioPreference,subtitlePreference:u||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(f.timelineOffset=t.timelineStart));var v=f.cmcd;null!=v&&v.sessionId&&v.contentId&&(f.cmcd=AO({},v,{contentId:hH(t.uri)}));var g=new EH(this.HlsPlayerClass,f,e,t);this.playerQueue.push(g),e.assetList[r]=t;var p=t.identifier,m=function(n){if(n.live){var a=new Error("Interstitials MUST be VOD assets ".concat(e)),s={fatal:!0,type:cO.OTHER_ERROR,details:hO.INTERSTITIAL_ASSET_ITEM_ERROR,error:a};i.handleAssetItemError(s,e,i.schedule.findEventIndex(e.identifier),r,a.message)}else{var o,l,u=n.edge-n.fragmentStart,c=t.duration;if(null===c||u>c)i.log(_d(o=_d(l='Interstitial asset "'.concat(p,'" duration change ')).call(l,c," > ")).call(o,u)),t.duration=u,i.updateSchedule()}};g.on(dO.LEVEL_UPDATED,(function(e,t){var r=t.details;return m(r)})),g.on(dO.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return m(r)}));g.on(dO.BUFFER_CODECS,(function e(t,r){var n=i.getAssetPlayer(p);if(n&&r.tracks){n.off(dO.BUFFER_CODECS,e),n.tracks=r.tracks;var a=i.primaryMedia;i.bufferingAsset===n.assetItem&&a&&!n.media&&i.bufferAssetPlayer(n,a)}}));g.on(dO.BUFFERED_TO_END,(function r(n){var a,s=i.getAssetPlayer(p);if(i.log("buffered to end of asset ".concat(s)),s){s.off(dO.BUFFERED_TO_END,r);var o=i.schedule.findEventIndex(e.identifier),l=e.findAssetIndex(t),u=l+1,c=null==(a=i.schedule.items)?void 0:a[o];if(i.isInterstitial(c))if(-1===l||e.isAssetPastPlayoutLimit(u)||e.assetList[u].error){var h,d=null==(h=i.schedule.items)?void 0:h[o+1];d&&i.bufferedToItem(d)}else i.bufferedToItem(c,l+1)}}));var y=function(t){return function(){if(i.getAssetPlayer(p)){i.shouldPlay=!0;var r=i.schedule.findEventIndex(e.identifier);i.advanceAfterAssetEnded(e,r,t)}}};return g.once(dO.MEDIA_ENDED,y(r)),g.once(dO.PLAYOUT_LIMIT_REACHED,y(1/0)),g.on(dO.ERROR,(function(t,n){var a;i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,_d(a="Asset player error ".concat(n.error," ")).call(a,e))})),g.on(dO.DESTROYING,(function(){if(i.getAssetPlayer(p)){var t=new Error("Asset player destroyed unexpectedly ".concat(p)),n={fatal:!0,type:cO.OTHER_ERROR,details:hO.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(dO.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:g}),g}},{key:"clearInterstitial",value:function(e,t){var r,i=this;vd(r=e.assetList).call(r,(function(e){i.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 i,n;this.log(_d(i='clearAssetPlayer "'.concat(e,'" toSegment: ')).call(i,t?TH(t):t));var a=this.playerQueue[r];this.transferMediaFromPlayer(a,t),ig(n=this.playerQueue).call(n,r,1),a.destroy()}}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,r,i,n){var a,s,o=e.interstitial,l=e.assetItem,u=e.assetId,c=o.assetList.length,h=this.playingAsset;(this.playingAsset=l,h&&h.identifier===u)||(h&&(this.clearAssetPlayer(h.identifier,r[i]),delete h.error),this.log(_d(a=_d(s="INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/")).call(s,c," ")).call(a,e)),this.hls.trigger(dO.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:o,schedule:Fv(r).call(r,0),scheduleIndex:i,player:e}));e.media||this.bufferAssetPlayer(e,n)}},{key:"bufferAssetPlayer",value:function(e,t){var r,i,n=e.interstitial,a=e.assetItem,s=e.assetId,o=this.schedule.findEventIndex(n.identifier),l=null==(r=this.schedule.items)?void 0:r[o];if(l){this.setBufferingItem(l),this.bufferingAsset=a;var u=this.getBufferingPlayer();if(u!==e){var c=(null==u?void 0:u.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(n.appendInPlace&&a!==this.playingAsset){if(!e.tracks)return;if(c&&!MO(c,e.tracks)){var h,d,f=new Error(_d(h=_d(d='Asset "'.concat(s,"\" SourceBuffer tracks ('")).call(d,gv(e.tracks),"') are not compatible with primary content tracks ('")).call(h,gv(c),"')")),v={fatal:!0,type:cO.OTHER_ERROR,details:hO.INTERSTITIAL_ASSET_ITEM_ERROR,error:f},g=n.findAssetIndex(a);return void this.handleAssetItemError(v,n,o,g,f.message)}}this.transferMediaTo(e,t)}}}},{key:"handleAssetItemError",value:function(e,t,r,i,n){var a;if(e.details!==hO.BUFFER_STALLED_ERROR){var s=t.assetList[i]||null,o=null;if(s){var l=this.getAssetPlayerQueueIndex(s.identifier);o=this.playerQueue[l]||null}var u=this.schedule.items,c=AO({},e,{fatal:!1,errorAction:xF(!0),asset:s,assetListIndex:i,event:t,schedule:u,scheduleIndex:r,player:o});if(this.warn("Asset item error: ".concat(e.error)),this.hls.trigger(dO.INTERSTITIAL_ASSET_ERROR,c),e.fatal){var h=new Error(n);s&&(this.playingAsset!==s&&this.clearAssetPlayer(s.identifier,null),s.error=h),KT(a=t.assetList).call(a,(function(e){return!e.error}))?t.appendInPlace&&(t.error=h):t.error=h,this.primaryFallback(t)}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,r=this.playingItem||this.waitingItem;if(this.updateSchedule(),r){var i,n,a,s;this.log(_d(i=_d(n=_d(a=_d(s='Fallback to primary from event "'.concat(e.identifier,'" start: ')).call(s,t," pos: ")).call(a,this.timelinePos," playing: ")).call(n,r?TH(r):"<none>"," error: ")).call(i,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 u=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(u)}}else this.checkStart()}},{key:"onAssetListLoaded",value:function(e,t){var r,i=this,n=t.event,a=n.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(a)){var o=n.timelineStart,l=0;vd(s).call(s,(function(e,t){var r=bS(e.DURATION);i.createAsset(n,t,l,o+l,r,e.URI),l+=r})),n.duration=l;var u=this.waitingItem,c=(null==u?void 0:u.event.identifier)===a;this.updateSchedule();var h=null==(r=this.bufferingItem)?void 0:r.event;if(c){var d,f=this.schedule.findEventIndex(a),v=null==(d=this.schedule.items)?void 0:d[f];v&&this.setBufferingItem(v),this.setSchedulePosition(f)}else if((null==h?void 0:h.identifier)===a&&h.appendInPlace){var g=n.assetList[0],p=this.getAssetPlayer(g.identifier),m=this.primaryMedia;g&&p&&m&&this.bufferAssetPlayer(p,m)}}}},{key:"onError",value:function(e,t){switch(t.details){case hO.ASSET_LIST_PARSING_ERROR:case hO.ASSET_LIST_LOAD_ERROR:case hO.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r)}}}]),i}(RO),bH=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"subtitle-stream-controller",EO)).currentTrackId=-1,s.tracksBuffered=[],s.mainDetails=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(dO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(dO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(dO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(dO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e){this.stopLoad(),this.state=uB,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,t){this.tracksBuffered=[],Ih(Rh(i.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,i=t.success;if(lN(r)&&(this.fragPrevious=r),this.state=uB,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var a,s=r.start,o=0;o<n.length;o++)if(s>=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n,a=i-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),vd(n=this.tracksBuffered).call(n,(function(e){for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}})),this.fragmentTracker.removeFragmentsInRange(r,a,EO)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===EO&&(t.details===hO.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==lB&&(this.state=uB))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks;this.levels&&rK(this.levels,i)?this.levels=_k(i).call(i,(function(e){return new iF(e)})):(this.tracksBuffered=[],this.levels=_k(i).call(i,(function(e){var t=new iF(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,EO),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 i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==lB&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,i,n,a,s,o,l=this.currentTrackId,u=this.levels,c=t.details,h=t.id;if(u){var d=u[h];if(!(h>=u.length)&&d){this.log(_d(r=_d(i=_d(n=_d(a="Subtitle track ".concat(h," loaded [")).call(a,c.startSN,",")).call(n,c.endSN,"]")).call(i,c.lastPartSn?_d(s="[part-".concat(c.lastPartSn,"-")).call(s,c.lastPartIndex,"]"):"",",duration:")).call(r,c.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;if(c.live||null!=(o=d.details)&&o.live){var f=this.mainDetails;if(c.deltaUpdateFailed||!f)return;var v,g=f.fragments[0];if(d.details)0===this.alignPlaylists(c,d.details,null==(v=this.levelLastLoaded)?void 0:v.details)&&g&&$U(c,g.start);else c.hasProgramDateTime&&f.hasProgramDateTime?(sB(c,f),c.fragmentStart):g&&$U(c,g.start)}if(d.details=c,this.levelLastLoaded=d,h===l)if(this.hls.trigger(dO.SUBTITLE_TRACK_UPDATED,{details:c,id:h,groupId:t.groupId}),this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===uB)pF(null,c.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0)}}else this.warn("Subtitle tracks were reset while loading level ".concat(h))}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this,r=e.frag,i=e.payload,n=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&iU(n.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,nU(n.method)).catch((function(e){throw a.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();a.trigger(dO.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){var r;t.warn(_d(r="".concat(e.name,": ")).call(r,e.message)),t.state=uB}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===uB){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 i=this.config,n=this.getLoadPosition(),a=YN.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),s=a.end,o=a.len,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;var u=l.fragments,c=u.length,h=l.edge,d=null,f=this.fragPrevious;if(s<h){var v=i.maxFragLookUpTolerance,g=s>h-v?0:v;!(d=pF(f,u,Math.max(u[0].start,s),g))&&f&&f.start<u[0].start&&(d=u[0])}else d=u[c-1];if(!d)return;if(lN(d=this.mapToInitFragWhenRequired(d))){var p=u[d.sn-l.startSN-1];p&&p.cc===d.cc&&this.fragmentTracker.getState(p)===MF&&(d=p)}this.fragmentTracker.getState(d)===MF&&this.loadFragment(d,r,s)}}else this.state=uB}},{key:"loadFragment",value:function(e,t,r){lN(e)?Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r):this._loadInitSegment(e,t)}},{key:"mediaBufferTimeRanges",get:function(){return new RH(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(kB),RH=Fc((function e(r){t(this,e),this.buffered=void 0;var i=function(e,t,i){var n,a;if((t>>>=0)>i-1)throw new DOMException(_d(n=_d(a="Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (")).call(a,t,") is greater than the maximum bound (")).call(n,i,")"));return r[t][e]};this.buffered={get length(){return r.length},end:function(e){return i("end",e,r.length)},start:function(e){return i("start",e,r.length)}}})),IH={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},DH=function(e){return String.fromCharCode(IH[e]||e)},_H=15,wH=100,CH={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},PH={17:2,18:4,21:6,22:8,23:10,19:13,20:15},xH={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},MH={25:2,26:4,29:6,30:8,31:10,27:13,28:15},OH=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],FH=function(){function e(){t(this,e),this.time=null,this.verboseLevel=0}return Fc(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r,i,n="function"==typeof t?t():t;PO.log(_d(r=_d(i="".concat(this.time," [")).call(i,e,"] ")).call(r,n))}}}]),e}(),NH=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},UH=function(){function e(){t(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return Fc(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 i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}},{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}(),BH=function(){function e(){t(this,e),this.uchar=" ",this.penState=new UH}return Fc(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}(),GH=function(){function e(r){t(this,e),this.chars=[],this.pos=0,this.currPenState=new UH,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<wH;i++)this.chars.push(new BH);this.logger=r}return Fc(e,[{key:"equals",value:function(e){for(var t=0;t<wH;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<wH;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<wH;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>wH&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=wH)}},{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=DH(e);this.pos>=wH?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<wH;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<wH;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}]),e}(),KH=function(){function e(r){t(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<_H;i++)this.rows.push(new GH(r));this.logger=r}return Fc(e,[{key:"reset",value:function(){for(var e=0;e<_H;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,r=0;r<_H;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<_H;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<_H;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 = "+yI(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<_H;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){var a=n.rows[i].cueStartTime,s=this.logger.time;if(null!==a&&null!==s&&a<s)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(n.rows[i+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var u=e.indent,c=Math.max(u-1,0);l.setCursor(e.indent),e.color=l.chars[c].penState.foreground}var h={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(h)}},{key:"setBkgData",value:function(e){this.logger.log(2,(function(){return"bkgData = "+yI(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 i=this.currRow+1-this.nrRollUpRows,n=ig(e=this.rows).call(e,i,1)[0];n.clear(),ig(t=this.rows).call(t,this.currRow,0,n),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="",i=-1,n=0;n<_H;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(MS(a).call(a)))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),HH=function(){function e(r,i,n){t(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=r,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new KH(n),this.nonDisplayedMemory=new KH(n),this.lastOutputScreen=new KH(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}return Fc(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[14],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 i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return i+": "+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: "+yI(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}(),VH=function(){function e(r,i,n){t(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new FH;this.channels=[null,new HH(r,i,a),new HH(r+1,n,a)]}return Fc(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 i=function(e){var i=127&t[e],n=127&t[e+1],a=!1,s=null;if(0===i&&0===n)return"continue";r.logger.log(3,(function(){return"["+NH([t[e],t[e+1]])+"] -> ("+NH([i,n])+")"}));var o=r.cmdHistory;if(i>=16&&i<=31){if(function(e,t,r){return r.a===e&&r.b===t}(i,n,o))return jH(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+NH([i,n])+") is dropped"})),"continue";jH(i,n,r.cmdHistory),(a=r.parseCmd(i,n))||(a=r.parseMidrow(i,n)),a||(a=r.parsePAC(i,n)),a||(a=r.parseBackgroundAttributes(i,n))}else jH(null,null,o);if(!a&&(s=r.parseChars(i,n))){var l=r.currentChannel;if(l&&l>0)r.channels[l].insertChars(s);else r.logger.log(2,"No channel found yet. TEXT-MODE?")}a||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+NH([i,n])+" orig: "+NH([t[e],t[e+1]])}))},n=0;n<t.length;n+=2)i(n)}},{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,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.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 i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,(function(){return"MIDROW ("+NH([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 i=e<=23?1:2;r=t>=64&&t<=95?1===i?CH[e]:xH[e]:1===i?PH[e]:MH[e];var n=this.channels[i];return!!n&&(n.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}},{key:"interpretPAC",value:function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}},{key:"parseChars",value:function(e,t){var r,i,n=null,a=null;(e>=25?(r=2,a=e-8):(r=1,a=e),a>=17&&a<=19)?(i=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+DH(i)+"' in channel "+r})),n=[i]):e>=32&&e<=127&&(n=0===t?[e]:[e,t]);return n&&this.logger.log(3,(function(){return"Char codes = "+NH(n).join(",")})),n}},{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 i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=OH[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(i),!0}},{key:"reset",value:function(){for(var e=0;e<gv(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}jH(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 jH(e,t,r){r.a=e,r.b=t}var YH=function(){if(null!=lU&&lU.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(!Pk(e))return!1;var r=t.toLowerCase();return!!~av(e).call(e,r)&&r}function i(e){return r(t,e)}function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,h=t,d=a,f=s,v=null,g="",p=!0,m="auto",y="start",E=50,k="middle",T=50,S="middle";Zk(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),Zk(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),Zk(o,"startTime",n({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Zk(o,"endTime",n({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");d=e,this.hasBeenReset=!0}})),Zk(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Zk(o,"region",n({},l,{get:function(){return v},set:function(e){v=e,this.hasBeenReset=!0}})),Zk(o,"vertical",n({},l,{get:function(){return g},set:function(t){var i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Zk(o,"snapToLines",n({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Zk(o,"line",n({},l,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Zk(o,"lineAlign",n({},l,{get:function(){return y},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Zk(o,"position",n({},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}})),Zk(o,"positionAlign",n({},l,{get:function(){return k},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");k=t,this.hasBeenReset=!0}})),Zk(o,"size",n({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Zk(o,"align",n({},l,{get:function(){return S},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),qH=function(){function e(){t(this,e)}return Fc(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 WH(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+bS(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?bS(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var zH=function(){function e(){t(this,e),this.values=rT(null)}return Fc(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(sO(this)[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?sO(this)[e]:t[r]:this.has(e)?sO(this)[e]:t}},{key:"has",value:function(e){return e in sO(this)}},{key:"alt",value:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,Ak(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=bS(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function XH(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);if(2===s.length)t(s[0],s[1])}}var QH=new YH(0,0,""),$H="middle"===QH.align?"middle":"center";function JH(e,t,r){var i=e;function n(){var t=WH(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=n(),a(),"--\x3e"!==Fv(e).call(e,0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=Fv(e).call(e,3),a(),t.endTime=n(),a(),function(e,t){var i=new zH;XH(e,(function(e,t){var n;switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){i.set(e,r[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",$H,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",$H,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",$H,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===QH.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",$H);var a=i.get("position","auto");"auto"===a&&50===QH.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function ZH(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var eV=function(){function e(){t(this,e),this.state="INITIAL",this.buffer="",this.decoder=new qH,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return Fc(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=ZH(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=Fv(e).call(e,0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=Fv(e).call(e,r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var n=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(null==n||!n[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var a=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:i=r(),t.state){case"HEADER":/:/.test(i)?XH(i,(function(e,t){}),/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new YH(0,0,""),t.state="CUE",-1===av(i).call(i,"--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{JH(i,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==av(i).call(i,"--\x3e");if(!i||s&&(a=!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+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch(o){"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}(),tV=/\r\n|\n\r|\n|\r/g,rV=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Fv(e).call(e,r,r+t.length)===t};function iV(e,t,r){return hH(e.toString())+hH(t.toString())+hH(r)}function nV(e,t,r,i,n,a,s){var o,l,u=new eV,c=MS(o=WF(new Uint8Array(e))).call(o).replace(tV,"\n").split("\n"),h=[],d=t?function(e){return OG(e,MG,1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1))}(t.baseTime,t.timescale):0,f="00:00.000",v=0,g=0,p=!0;u.oncue=function(e){var a,s=r[i],o=r.ccOffset,u=(v-d)/9e4;if(null!=s&&s.new&&(void 0!==g?o=r.ccOffset=s.start:function(e,t,r){var i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(a=n)&&a.new;){var a;e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC]}e.presentationOffset=r}(r,i,u)),u){if(!t)return void(l=new Error("Missing initPTS for VTT MPEGTS"));o=u-r.presentationOffset}var c=e.endTime-e.startTime,f=GG(9e4*(e.startTime+o-g),9e4*n)/9e4;e.startTime=Math.max(f,0),e.endTime=Math.max(f+c,0);var p=MS(a=e.text).call(a);e.text=decodeURIComponent(encodeURIComponent(p)),e.id||(e.id=iV(e.startTime,e.endTime,p)),e.endTime>0&&h.push(e)},u.onparsingerror=function(e){l=e},u.onflush=function(){l?s(l):a(h)},vd(c).call(c,(function(e){if(p){if(rV(e,"X-TIMESTAMP-MAP=")){var t;p=!1,vd(t=Fv(e).call(e,16).split(",")).call(t,(function(e){rV(e,"LOCAL:")?f=Fv(e).call(e,6):rV(e,"MPEGTS:")&&(v=Ak(Fv(e).call(e,7)))}));try{g=function(e){var t=Ak(Fv(e).call(e,-3)),r=Ak(Fv(e).call(e,-6,-4)),i=Ak(Fv(e).call(e,-9,-7)),n=e.length>9?Ak(e.substring(0,av(e).call(e,":"))):0;if(!(oO(t)&&oO(r)&&oO(i)&&oO(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*i,t+36e5*n}(f)/1e3}catch($V){l=$V}return}""===e&&(p=!1)}u.parse(e+"\n")})),u.flush()}var aV="stpp.ttml.im1t",sV=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,oV=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,lV={left:"start",center:"center",right:"end",start:"start",end:"end"};function uV(e,t,r,i){var n=kN(new Uint8Array(e),["mdat"]);if(0!==n.length){var a=_k(n).call(n,(function(e){return WF(e)})),s=function(e,t){return OG(e,t,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}(t.baseTime,1,t.timescale);try{vd(a).call(a,(function(e){return r(function(e,t){var r,i,n=(new DOMParser).parseFromString(e,"text/xml"),a=n.getElementsByTagName("tt")[0];if(!a)throw new Error("Invalid ttml");var s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},o=mC(r=gv(s)).call(r,(function(e,t){return e[t]=a.getAttribute("ttp:".concat(t))||s[t],e}),{}),l="preserve"!==a.getAttribute("xml:space"),u=hV(cV(a,"styling","style")),c=hV(cV(a,"layout","region")),h=cV(a,"body","[begin]");return xk(i=_k([]).call(h,(function(e){var r=dV(e,l);if(!r||!e.hasAttribute("begin"))return null;var i=gV(e.getAttribute("begin"),o),n=gV(e.getAttribute("dur"),o),a=gV(e.getAttribute("end"),o);if(null===i)throw vV(e);if(null===a){if(null===n)throw vV(e);a=i+n}var s=new YH(i-t,a-t,r);s.id=iV(s.startTime,s.endTime,s.text);var h=function(e,t,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;s&&r.hasOwnProperty(s)&&(n=r[s]);return mC(a).call(a,(function(r,a){var s=fV(t,i,a)||fV(e,i,a)||fV(n,i,a);return s&&(r[a]=s),r}),{})}(c[e.getAttribute("region")],u[e.getAttribute("style")],u),d=h.textAlign;if(d){var f=lV[d];f&&(s.lineAlign=f),s.align=d}return AO(s,h),s}))).call(i,(function(e){return null!==e}))}(e,s))}))}catch($V){i($V)}}else i(new Error("Could not parse IMSC1 mdat"))}function cV(e,t,r){var i=e.getElementsByTagName(t)[0];return i?Fv([]).call(i.querySelectorAll(r)):[]}function hV(e){return mC(e).call(e,(function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function dV(e,t){var r;return mC(r=Fv([]).call(e.childNodes)).call(r,(function(e,r,i){var n,a;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?dV(r,t):t?e+MS(a=r.textContent).call(a).replace(/\s+/g," "):e+r.textContent}),"")}function fV(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function vV(e){return new Error("Could not parse ttml timestamp ".concat(e))}function gV(e,t){if(!e)return null;var r=WH(e);return null===r&&(sV.test(e)?r=function(e,t){var r=sV.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):oV.test(e)&&(r=function(e,t){var r=oV.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}var pV=function(){function e(r,i){t(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=r,this.trackName=i}return Fc(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}(),mV=function(){function e(r){t(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={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=r,this.config=r.config,this.Cues=r.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}},r.on(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),r.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(dO.FRAG_LOADING,this.onFragLoading,this),r.on(dO.FRAG_LOADED,this.onFragLoaded,this),r.on(dO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),r.on(dO.FRAG_DECRYPTED,this.onFragDecrypted,this),r.on(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(dO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),r.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this)}return Fc(e,[{key:"destroy",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(dO.FRAG_LOADING,this.onFragLoading,this),e.off(dO.FRAG_LOADED,this.onFragLoaded,this),e.off(dO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(dO.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(dO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(dO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(dO.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 pV(this,"textTrack1"),t=new pV(this,"textTrack2"),r=new pV(this,"textTrack3"),i=new pV(this,"textTrack4");this.cea608Parser1=new VH(1,e,t),this.cea608Parser2=new VH(3,r,i)}},{key:"addCues",value:function(e,t,r,i,n){for(var a,s,o,l,u=!1,c=n.length;c--;){var h=n[c],d=(a=h[0],s=h[1],o=t,l=r,Math.min(s,l)-Math.max(a,o));if(d>=0&&(h[0]=Math.min(h[0],t),h[1]=Math.max(h[1],r),u=!0,d/(r-t)>.5))return}if(u||n.push([t,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[e];this.Cues.newCue(f,t,r,i)}else{var v=this.Cues.newCue(null,t,r,i);this.hls.trigger(dO.CUES_PARSED,{type:"captions",cues:v,track:e})}}},{key:"onInitPtsFound",value:function(e,t){var r=this,i=t.frag,n=t.id,a=t.initPTS,s=t.timescale,o=this.unparsedVttFrags;n===mO&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],vd(o).call(o,(function(e){r.onFragLoaded(dO.FRAG_LOADED,e)})))}},{key:"getExistingTrack",value:function(e,t){var r=this.media;if(r)for(var i=0;i<r.textTracks.length;i++){var n=r.textTracks[i];if(EV(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound",attrs:{}}))return n}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,i=this.media,n=t[e],a=n.label,s=n.languageCode,o=this.getExistingTrack(a,s);if(o)r[e]=o,oH(r[e]),aH(r[e],i);else{var l=this.createTextTrack("captions",a,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(dO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}}},{key:"createTextTrack",value:function(e,t,r){var i=this.media;if(i)return i.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,i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;vd(r=gv(n)).call(r,(function(e){oH(n[e]),delete n[e]})),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)oH(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks||[],n=KT(i).call(i,(function(e){return e.textCodec===aV}));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(rK(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a,s=this.media,o=s?uH(s.textTracks):null;if(vd(a=this.tracks).call(a,(function(e,t){var i;if(o){for(var n=null,a=0;a<o.length;a++)if(o[a]&&EV(o[a],e)){n=o[a],o[a]=null;break}n&&(i=n)}if(i)oH(i);else{var s=yV(e);(i=r.createTextTrack(s,e.name,e.lang))&&(i.mode="disabled")}i&&r.textTracks.push(i)})),null!=o&&o.length){var l,u=_k(l=xk(o).call(o,(function(e){return null!==e}))).call(l,(function(e){return e.label}));u.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(u.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){var c,h=_k(c=this.tracks).call(c,(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(dO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:h})}}}},{key:"onManifestLoaded",value:function(e,t){var r,i=this;this.config.enableCEA708Captions&&t.captions&&vd(r=t.captions).call(r,(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack".concat(t[1]),n=i.captionsProperties[r];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.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===mO){var r,i,n=this.cea608Parser1,a=this.cea608Parser2,s=this.lastSn,o=t.frag,l=o.cc,u=o.sn,c=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;n&&a&&(u!==s+1||u===s&&c!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=u,this.lastPartIndex=c}}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,i=t.payload;if(r.type===EO)if(i.byteLength){var n=r.decryptdata,a="stats"in t;if(null==n||!n.encrypted||a){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===aV?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var r=this,i=this.hls;uV(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){i.logger.log("Failed to parse IMSC1: ".concat(t)),i.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}},{key:"_parseVTTs",value:function(e){var t,r=this,i=e.frag,n=e.payload,a=this.initPTS,s=this.unparsedVttFrags,o=a.length-1;if(a[i.cc]||-1!==o){var l=this.hls;nV(null!=(t=i.initSegment)&&t.data?_N(i.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(function(e){r._appendCues(e,i.level),l.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(function(t){var a="Missing initPTS for VTT MPEGTS"===t.message;a?s.push(e):r._fallbackToIMSC1(i,n),l.logger.log("Failed to parse VTT cue: ".concat(t)),a&&o>i.cc||l.trigger(dO.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})}))}else s.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||uV(t,this.initPTS[e.cc],(function(){i.textCodec=aV,r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))}},{key:"_appendCues",value:function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;vd(e).call(e,(function(e){return sH(i,e)}))}else{var n=this.tracks[t];if(!n)return;var a=n.default?"default":"subtitles"+t;r.trigger(dO.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===EO&&this.onFragLoaded(dO.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,i=t.samples;if(r.type!==mO||"NONE"!==this.closedCaptionsForLevel(r))for(var n=0;n<i.length;n++){var a=i[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();var s=this.extractCea608Data(a);this.cea608Parser1.addData(i[n].pts,s[0]),this.cea608Parser2.addData(i[n].pts,s[1])}}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.endOffsetSubtitles,a=t.type,s=this.media;if(s&&!(s.currentTime<i)){if(!a||"video"===a){var o,l=this.captionsTracks;vd(o=gv(l)).call(o,(function(e){return lH(l[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u,c=this.textTracks;vd(u=gv(c)).call(u,(function(e){return lH(c[e],r,n)}))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],r=31&e[0],i=2,n=0;n<r;n++){var a=e[i++],s=127&e[i++],o=127&e[i++];if(0!==s||0!==o)if(0!=(4&a)){var l=3&a;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}();function yV(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function EV(e,t){return!!e&&e.kind===yV(t)&&nK(t,e)}var kV=/\s/,TV={newCue:function(e,t,r,i){for(var n,a,s,o,l,u=[],c=self.VTTCue||self.TextTrackCue,h=0;h<i.rows.length;h++)if(s=!0,o=0,l="",!(n=i.rows[h]).isEmpty()){for(var d,f=0;f<n.chars.length;f++)kV.test(n.chars[f].uchar)&&s?o++:(l+=n.chars[f].uchar,s=!1);n.cueStartTime=t,t===r&&(r+=1e-4),o>=16?o--:o++;var v=ZH(MS(l).call(l)),g=iV(t,r,v);null!=e&&null!=(d=e.cues)&&d.getCueById(g)||((a=new c(t,r,v)).id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return e&&u.length&&(mA(u).call(u,(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})),vd(u).call(u,(function(t){return sH(e,t)}))),u}};var SV=/(\d+)-(\d+)\/(\d+)/,AV=function(){function e(r){t(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=r.fetchSetup||LV,this.controller=new self.AbortController,this.stats=new iN}return Fc(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 i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(AO({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s=r.onProgress,o="arraybuffer"===e.responseType,l=o?"byteLength":"length",u=t.loadPolicy,c=u.maxTimeToFirstByteMs,h=u.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=c&&oO(c)?c:h,this.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),($G(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(a){i.response=i.loader=a;var l=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=h,i.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),h-(l-n.loading.start)),!a.ok){var u=a.status,c=a.statusText;throw new bV(c||"fetch, bad network response",u,a)}return n.loading.first=l,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=SV.exec(e);if(t)return Ak(t[2])-Ak(t[1])+1}(t);if(oO(r))return r}var i=e.get("Content-Length");if(i)return Ak(i)}(a.headers)||n.total,s&&oO(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,s):o?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var c={url:o.url,data:a,code:o.status};s&&!oO(t.highWaterMark)&&s(n,e,a,o),r.onSuccess(c,n,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;r.onError({code:a,text:s},e,t?t.details:null,n)}}))}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?bS(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 i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4?arguments[4]:void 0,a=new TB,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(t,r,a.flush().buffer,e),tk.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return t.loaded+=u,u<i||a.dataLength?(a.push(l),a.dataLength>=i&&n(t,r,a.flush().buffer,e)):n(t,r,l.buffer,e),o()})).catch((function(){return tk.reject()}))}()}}]),e}();function LV(e,t){return new self.Request(e.url,t)}var bV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e)).code=void 0,s.details=void 0,s.code=n,s.details=a,s}return Fc(i)}(Jw(Error)),RV=/^age:\s*[\d.]+\s*$/im,IV=function(){function e(r){t(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=r&&r.xhrSetup||null,this.stats=new iN,this.retryDelay=0}return Fc(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 i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?tk.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return a(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){e.callbacks.onError({code:i.status,text:t.message},r,i,n)})):this.openAndSendXhr(i,r,t)}}},{key:"openAndSendXhr",value:function(e,t,r){var i,n,a;e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,u=o.maxLoadTimeMs;if(s)for(var c in s)e.setRequestHeader(c,s[c]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=iT(i=this.readystatechange).call(i,this),e.onprogress=iT(n=this.loadprogress).call(n,this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&oO(l)?l:u,this.requestTimeout=Wf(iT(a=this.loadtimeout).call(a,this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,n=this.config;if(!r.aborted&&i>=2){var a;if(0===r.loading.first)if(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=Wf(iT(a=this.loadtimeout).call(a,this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start));if(4===i){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 u="arraybuffer"===t.responseType?l.byteLength:l.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;var h={url:t.responseURL,data:l,code:s};return void this.callbacks.onSuccess(h,r,e,t)}}var d,f=n.loadPolicy.errorRetry;if(LF(f,r.retry,!1,{url:e.url,data:void 0,code:s}))this.retry(f);else PO.error(_d(d="".concat(s," while loading ")).call(d,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(LF(e,this.stats.retry,!0))this.retry(e);else{var t;PO.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,i,n,a,s=this.context,o=this.stats;this.retryDelay=SF(e,o.retry),o.retry++,PO.warn(_d(t=_d(r=_d(i=_d(n="".concat(status?"HTTP Status "+status:"Timeout"," while loading ")).call(n,null==s?void 0:s.url,", retrying ")).call(i,o.retry,"/")).call(r,e.maxNumRetry," in ")).call(t,this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=Wf(iT(a=this.loadInternal).call(a,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&&RV.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?bS(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}(),DV=bO(bO({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:IV,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:vF,bufferController:dK,capLevelController:gK,errorController:PF,fpsController:nH,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:IU,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:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},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},{cueHandler:TV,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:bH,subtitleTrackController:cH,timelineController:mV,audioStreamController:aK,audioTrackController:oK,emeController:rH,cmcdController:JK,contentSteeringController:ZK,interstitialsController:LH});function _V(e){var t;return e&&"object"===Cc(e)?Pk(e)?_k(e).call(e,_V):mC(t=gv(e)).call(t,(function(t,r){return t[r]=_V(e[r]),t}),{}):e}function wV(e,t){var r=e.loader;r!==AV&&r!==IV?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=AV,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}function CV(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function PV(e,t,r,i,n){var a=new e(t,r,"");try{a.value=i,n&&(a.type=n)}catch(s){a=new e(t,r,yI(n?bO({type:n},i):i))}return a}var xV=function(){var e=CV();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();var MV=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){i.hls&&i.hls.trigger(dO.EVENT_CUE_ENTER,{})},this.hls=r,this._registerListeners()}return Fc(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(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(dO.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(dO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(dO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(dO.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&&oH(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 aH(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=CV();if(s)for(var o=0;o<a.length;o++){var l=a[o].type;if((l!==QB.emsg||i)&&n){var u=qB(a[o].data);if(u){var c=a[o].pts,h=c+a[o].duration;h>xV&&(h=xV),h-c<=0&&(h=c+.25);for(var d=0;d<u.length;d++){var f=u[d];if(!WB(f)){this.updateId3CueEnds(c,l);var v=PV(s,c,h,f,l);v&&this.id3Track.addCue(v)}}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.type===t&&a.startTime<e&&a.endTime===xV&&(a.endTime=e)}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,a=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(l||u))lH(a,r,i,"audio"===n?function(e){return e.type===QB.audioId3&&u}:"video"===n?function(e){return e.type===QB.emsg&&l}:function(e){return e.type===QB.audioId3&&u||e.type===QB.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 i,n=this.id3Track,a=e.dateRanges,s=gv(a),o=this.dateRangeCuesAppended;if(n&&t)if(null!=(i=n.cues)&&i.length)for(var l,u=xk(l=gv(o)).call(l,(function(e){return!sD(s).call(s,e)})),c=function(){var e,t=u[h],i=o[t].cues;delete o[t],vd(e=gv(i)).call(e,(function(e){try{var t=i[e];t.removeEventListener("enter",r.onEventCueEnter),n.removeCue(t)}catch(a){}}))},h=u.length;h--;)c();else o=this.dateRangeCuesAppended={};var d=e.fragments[e.fragments.length-1];if(0!==s.length&&oO(null==d?void 0:d.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=CV(),v=function(){var e=s[g],t=a[e],i=t.startTime,n=o[e],l=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,c=xV,h=t.duration;if(t.endDate&&null!==h)c=i+h,u=!0;else if(t.endOnNext&&!u){var d=mC(s).call(s,(function(e,r){if(r!==t.id){var i=a[r];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate<e.startDate))return i}return e}),null);d&&(c=d.startTime,u=!0)}for(var v,p,m=gv(t.attr),y=0;y<m.length;y++){var E=m[y];if("ID"!==(p=E)&&"CLASS"!==p&&"CUE"!==p&&"START-DATE"!==p&&"DURATION"!==p&&"END-DATE"!==p&&"END-ON-NEXT"!==p){var k=l[E];if(k)u&&!n.durationKnown?k.endTime=c:Math.abs(k.startTime-i)>.01&&(k.startTime=i,k.endTime=c);else if(f){var T=t.attr[E];eU(E)&&(v=T,T=Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=PV(f,i,c,{key:E,data:T},QB.dateRange);S&&(S.id=e,r.id3Track.addCue(S),l[E]=S,r.hls.config.interstitialsController&&("X-ASSET-LIST"!==E&&"X-ASSET-URL"!==E||S.addEventListener("enter",r.onEventCueEnter)))}}}o[e]={cues:l,dateRange:t,durationKnown:u}},g=0;g<s.length;g++)v()}}}}]),e}(),OV=function(){function e(r){var i=this;t(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=i.media,t=i.hls.latestLevelDetails;if(e&&t){i.currentTime=e.currentTime;var r=i.computeLatency();if(null!==r){i._latency=r;var n=i.config,a=n.lowLatencyMode,s=n.maxLiveSyncPlaybackRate;if(a&&1!==s&&t.live){var o=i.targetLatency;if(null!==o){var l=r-o;if(l<Math.min(i.maxLatency,o+t.targetduration)&&l>.05&&i.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),c=Math.round(2/(1+Math.exp(-.75*l-i.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=r,this.config=r.config,this.registerListeners()}return Fc(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,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var c=i;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)},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 i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),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(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(dO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(dO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(dO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){this.hls.off(dO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(dO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(dO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(dO.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===hO.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}(),FV=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.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 Fc(i,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(dO.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(dO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){var e=this._levels;vd(e).call(e,(function(e){e.loadError=0,e.fragmentError=0})),Ih(Rh(i.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,i=this,n=this.hls.config.preferManagedMediaSource,a=[],s={},o={},l=!1,u=!1,c=!1;vd(r=t.levels).call(r,(function(e){var t,r,h,d,f,v,g,p=e.attrs,m=e.audioCodec,y=e.videoCodec;m&&(e.audioCodec=m=VO(m,n)||void 0),0===(null==(g=y)?void 0:av(g).call(g,"avc1"))&&(y=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var n,a=i.shift()+".";a+=Ak(i.shift()).toString(16),a+=Fv(n="000"+Ak(i.shift()).toString(16)).call(n,-4),t[r]=a}}return t.join(",")}(y));var E=e.width,k=e.height,T=e.unknownCodecs,S=T?T.length:0;if(T)for(var A=S;A--;){var L,b=T[A];if(i.isAudioSupported(b))e.audioCodec=m=m?_d(L="".concat(m,",")).call(L,b):b,S--,OO.audio[m.substring(0,4)]=2;else if(i.isVideoSupported(b)){var R;e.videoCodec=y=y?_d(R="".concat(y,",")).call(R,b):b,S--,OO.video[y.substring(0,4)]=2}}if(l||(l=!(!E||!k)),u||(u=!!y),c||(c=!!m),!(S||m&&!i.isAudioSupported(m)||y&&!i.isVideoSupported(y))){var I=p.CODECS,D=p["FRAME-RATE"],_=p["HDCP-LEVEL"],w=p["PATHWAY-ID"],C=p.RESOLUTION,P=p["VIDEO-RANGE"],x="".concat(w||".","-"),M=_d(t=_d(r=_d(h=_d(d=_d(f=_d(v="".concat(x)).call(v,e.bitrate,"-")).call(f,C,"-")).call(d,D,"-")).call(h,I,"-")).call(r,P,"-")).call(t,_);if(s[M])if(s[M].uri===e.url||e.attrs["PATHWAY-ID"])s[M].addGroupId("audio",p.AUDIO),s[M].addGroupId("text",p.SUBTITLES);else{var O=o[M]+=1;e.attrs["PATHWAY-ID"]=new Array(O+1).join(".");var F=new iF(e);s[M]=F,a.push(F)}else{var N=new iF(e);s[M]=N,o[M]=1,a.push(N)}}})),this.filterAndSortMediaOptions(a,t,l,u,c)}},{key:"isAudioSupported",value:function(e){return FO(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return FO(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,i,n){var a=this,s=[],o=[],l=e;if((r||i)&&n&&(l=xk(l).call(l,(function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&(!!(t=i)&&av($O).call($O,t)>-1)}))),0!==l.length){var u;if(t.audioTracks)NV(s=xk(u=t.audioTracks).call(u,(function(e){return!e.audioCodec||a.isAudioSupported(e.audioCodec)})));t.subtitles&&NV(o=t.subtitles);var c=Fv(l).call(l,0);mA(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 av($O).call($O,e.videoRange)-av($O).call($O,t.videoRange);if(e.videoCodec!==t.videoCodec){var i=BO(e.videoCodec),n=BO(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=GO(e.codecSet),s=GO(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==c.length)for(var d=0;d<c.length;d++)if(c[d].pathwayId===l[0].pathwayId){h=c[d];break}this._levels=l;for(var f=0;f<l.length;f++)if(l[f]===h){var v,g;this._firstLevel=f;var p=h.bitrate,m=this.hls.bandwidthEstimate;if(this.log(_d(v="manifest loaded, ".concat(l.length," level(s) found, first bitrate: ")).call(v,p)),void 0===(null==(g=this.hls.userConfig)?void 0:g.abrEwmaDefaultEstimate)){var y=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);y>m&&m===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=y)}break}var E=n&&!i,k={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!E&&KT(s).call(s,(function(e){return!!e.url}))};this.hls.trigger(dO.MANIFEST_PARSED,k)}else tk.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: ".concat(yI(t.levels[0].attrs)));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.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,i,n,a,s,o,l=this._levels;if(0!==l.length){if(e<0||e>=l.length){var u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,l.length-1)}var h=this.currentLevelIndex,d=this.currentLevel,f=d?d.attrs["PATHWAY-ID"]:void 0,v=l[e],g=v.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=v,h!==e||!d||f!==g){this.log(_d(t=_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Switching to level ".concat(e," (")).call(o,v.height?v.height+"p ":"")).call(s,v.videoRange?v.videoRange+" ":"")).call(a,v.codecSet?v.codecSet+" ":"","@")).call(n,v.bitrate,")")).call(i,g?" with Pathway "+g:""," from level ")).call(r,h)).call(t,f?" with Pathway "+f:""));var p={level:e,attrs:v.attrs,details:v.details,bitrate:v.bitrate,averageBitrate:v.averageBitrate,maxBitrate:v.maxBitrate,realBitrate:v.realBitrate,width:v.width,height:v.height,codecSet:v.codecSet,audioCodec:v.audioCodec,videoCodec:v.videoCodec,audioGroups:v.audioGroups,subtitleGroups:v.subtitleGroups,loaded:v.loaded,loadError:v.loadError,fragmentError:v.fragmentError,name:v.name,id:v.id,uri:v.uri,url:v.url,urlId:0,audioGroupIds:v.audioGroupIds,textGroupIds:v.textGroupIds};this.hls.trigger(dO.LEVEL_SWITCHING,p);var m=v.details;if(!m||m.live){var y=this.switchParams(v.uri,null==d?void 0:d.details,m);this.loadPlaylist(y)}}}}},{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(),i=xk(e).call(e,(function(e){return-1!==av(r).call(r,e)}));if(e.length<1)return void this.warn(_d(t="pathwayPriority ".concat(e," should contain at least one pathway from list: ")).call(t,r));this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===vO&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===mO){var i,n=r.elementaryStreams;if(!KT(i=gv(n)).call(i,(function(e){return!!n[e]})))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of ".concat(a.loadError," on frag buffered")),a.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n=t.level,a=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index ".concat(n)),void(null!=(i=t.deliveryDirectives)&&i.skip&&(a.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(n,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var o=this.getUrlWithDirectives(e.uri,t),l=this.currentLevelIndex,u=e.attrs["PATHWAY-ID"],c=e.details,h=null==c?void 0:c.age;this.log(_d(r=_d(n=_d(a=_d(s="Loading level index ".concat(l)).call(s,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,u?" Pathway "+u:"")).call(n,h&&c.live?" age "+h.toFixed(1)+(c.type&&" "+c.type||""):""," ")).call(r,o)),this.hls.trigger(dO.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,i=this;if(1!==this._levels.length){var n=xk(t=this._levels).call(t,(function(t,r){if(r!==e)return!0;var n;(i.steering&&i.steering.removeLevel(t),t===i.currentLevel)&&(i.currentLevel=null,i.currentLevelIndex=-1,t.details&&vd(n=t.details.fragments).call(n,(function(e){return e.level=-1})));return!1}));tB(n),this._levels=n,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 a=n.length-1;this._firstLevel=Math.min(this._firstLevel,a),this._startLevel&&(this._startLevel=Math.min(this._startLevel,a)),this.hls.trigger(dO.LEVELS_UPDATED,{levels:n})}}},{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,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(dO.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}]),i}(sK);function NV(e){var t={};vd(e).call(e,(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var UV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s){var o;return t(this,i),(o=r.call(this,"gap-controller",s.logger)).config=void 0,o.media=null,o.fragmentTracker=void 0,o.hls=void 0,o.nudgeRetry=0,o.stallReported=!1,o.stalled=null,o.moved=!1,o.seeking=!1,o.ended=0,o.config=e,o.media=n,o.fragmentTracker=a,o.hls=s,o}return Fc(i,[{key:"destroy",value:function(){this.media=null,this.hls=this.fragmentTracker=null}},{key:"poll",value:function(e,t,r,i){var n=this.config,a=this.media,s=this.stalled;if(null!==a){var o=a.currentTime,l=a.seeking,u=this.seeking&&!l,c=!this.seeking&&l;if(this.seeking=l,o===e)if(c||u)this.stalled=null;else{if(a.paused&&!l||a.ended||0===a.playbackRate||!YN.getBuffered(a).length)return!this.ended&&a.ended&&(this.ended=o||1,this.hls.trigger(dO.MEDIA_ENDED,{stalled:!1})),void(this.nudgeRetry=0);var h=YN.bufferInfo(a,o,0),d=h.nextStart||0;if(l){var f=h.len>2,v=!d||t&&t.start<=o||d-o>2&&!this.fragmentTracker.getPartialFragment(o);if(f||v)return;this.moved=!1}if(!this.moved&&null!==this.stalled){if(!(h.len>0)&&!d)return;var g=Math.max(d,h.start||0)-o,p=!(null==r||!r.live)?2*r.targetduration:2,m=this.fragmentTracker.getPartialFragment(o);if(g>0&&(g<=p||m))return void(a.paused||this._trySkipBufferHole(m))}var y=self.performance.now();if(null!==s){var E=y-s;if(!l&&E>=250){if(i===pB&&(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(dO.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(h),!this.media)return}var k=YN.bufferInfo(a,o,n.maxBufferHole);this._tryFixBufferStall(k,E)}else this.stalled=y}else if(e&&(this.ended=0),this.moved=!0,l||(this.nudgeRetry=0),null!==s){if(this.stallReported){var T,S=self.performance.now()-s;this.warn(_d(T="playback not stuck anymore @".concat(o,", after ")).call(T,Math.round(S),"ms")),this.stallReported=!1}this.stalled=null}}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s)if(this._trySkipBufferHole(s)||!this.media)return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<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 i;this.stallReported=!0;var n=new Error(_d(i="Playback stalling at @".concat(r.currentTime," due to low buffer (")).call(i,yI(e),")"));this.warn(n.message),t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}},{key:"_trySkipBufferHole",value:function(e){var t=this.config,r=this.hls,i=this.media;if(null===i)return 0;var n=i.currentTime,a=YN.bufferInfo(i,n,0),s=n<a.start?a.start:a.nextStart;if(s){var o=a.len<=t.maxBufferHole,l=a.len>0&&a.len<1&&i.readyState<3,u=s-n;if(u>0&&(o||l)){var c;if(u>t.maxBufferHole){var h=this.fragmentTracker,d=!1;if(0===n){var f=h.getAppendedFrag(0,mO);f&&s<f.end&&(d=!0)}if(!d){var v=e||h.getAppendedFrag(n,mO);if(v){for(var g=!1,p=v.end;p<s;){var m=h.getPartialFragment(p);if(!m){g=!0;break}p+=m.duration}if(g)return 0}}}var y=Math.max(s+.05,n+.1);if(this.warn(_d(c="skipping hole, adjusting currentTime from ".concat(n," to ")).call(c,y)),this.moved=!0,this.stalled=null,i.currentTime=y,e&&!e.gap){var E,k=new Error(_d(E="fragment loaded with buffer holes, seeking from ".concat(n," to ")).call(E,y));r.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:k,reason:k.message,frag:e})}return y}}return 0}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var n=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var a,s=n+(i+1)*e.nudgeOffset,o=new Error(_d(a="Nudging 'currentTime' from ".concat(n," to ")).call(a,s));this.warn(o.message),r.currentTime=s,t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l,u=new Error(_d(l="Playhead still not moving while enough data buffered @".concat(n," after ")).call(l,e.nudgeMaxRetry," nudges"));this.error(u.message),t.trigger(dO.ERROR,{type:cO.MEDIA_ERROR,details:hO.BUFFER_STALLED_ERROR,error:u,fatal:!0})}}}}]),i}(RO);function BV(){return self.SourceBuffer||self.WebKitSourceBuffer}function GV(){if(!xO())return!1;var e=BV();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var KV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"stream-controller",mO)).audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s._hasEnoughToStart=!1,s.altAudio=0,s.audioOnly=!1,s.fragPlaying=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s.onMediaPlaying=function(){var e=s.gapController;e&&(e.ended=0),s.tick()},s.onMediaSeeked=function(){var e=s.media,t=e?e.currentTime:null;oO(t)&&s.log("Media seeked to ".concat(t.toFixed(3)));var r=s.getMainFwdBufferInfo();null!==r&&0!==r.len?s.tick():s.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"))},s.registerListeners(),s}return Fc(i,[{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(dO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(dO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(dO.BUFFER_CREATED,this.onBufferCreated,this),e.on(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(dO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(dO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(dO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(dO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(dO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(dO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(dO.BUFFER_CREATED,this.onBufferCreated,this),e.off(dO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(dO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this)}},{key:"startLoad",value:function(e,t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var n=i.startLevel;-1===n&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.firstAutoLevel),i.nextLoadLevel=n,this.level=i.loadLevel,this._hasEnoughToStart=!1}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r),this.state=uB,this.nextLoadPosition=this.lastCurrentTime=e,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=lB}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,Ih(Rh(i.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case EB:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=uB;break}if(this.hls.nextLoadLevel!==this.level){this.state=uB;break}break;case dB:var n,a=self.performance.now(),s=this.retryDate;if(!s||a>=s||null!=(n=this.media)&&n.seeking){var o=this.levels,l=this.level,u=null==o?void 0:o[l];this.resetStartWhenNotLoaded(u||null),this.state=uB}}this.state===uB&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){Ih(Rh(i.prototype),"onTickEnd",this).call(this),this.checkBuffer(),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[n]){var a=r[n],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(dO.BUFFER_EOS,l),void(this.state=pB)}if(this.buffering){var u;if(e.loadLevel!==n&&-1===e.manualLevel)this.log(_d(u="Adapting to level ".concat(n," from level ")).call(u,this.level));this.level=e.nextLoadLevel=n;var c=a.details;if(!c||this.state===EB||this.waitForLive(a))return this.level=n,this.state=EB,void(this.startFragRequested=!1);var h=s.len,d=this.getMaxBufferLength(a.maxBitrate);if(!(h>=d)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:s.end,v=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&v&&lN(v)&&this.fragmentTracker.getState(v)!==NF){var g,p=(null!=(g=this.backtrackFragment)?g:v).sn-c.startSN,m=c.fragments[p-1];m&&v.cc===m.cc&&(v=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,f)){if(!v.gap){var y=this.audioOnly&&!this.altAudio?nN:aN,E=(y===aN?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,y,mO)}v=this.getNextFragmentLoopLoading(v,c,s,mO,d)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,a,f))}}}}}}},{key:"loadFragment",value:function(e,t,r){var n=this.fragmentTracker.getState(e);if(n===MF||n===FF)if(lN(e))if(this.bitrateTest){var a;this.log(_d(a="Fragment ".concat(e.sn," of level ")).call(a,e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,mO)}},{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,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.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 u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var c=u.maxStartPTS?u.maxStartPTS:u.start,h=u.duration,d=Math.max(l.end,c+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(d,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 cB:case hB:case dB:case vB:case gB:this.state=uB}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,t){Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,e,t,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,t){Ih(Rh(i.prototype),"onMediaAttached",this).call(this,e,t);var r=t.media;r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked),r.addEventListener("playing",this.onMediaPlaying),r.addEventListener("seeked",this.onMediaSeeked),this.gapController=new UV(this.config,r,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;r&&(r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),Ih(Rh(i.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(dO.MEDIA_ENDED,{stalled:!1})}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(dO.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,i,n,a=!1,s=!1;vd(r=t.levels).call(r,(function(e){var t=e.audioCodec;t&&(a=a||-1!==av(t).call(t,"mp4a.40.2"),s=s||-1!==av(t).call(t,"mp4a.40.5"))})),this.audioCodecSwitch=a&&s&&!("function"==typeof(null==(n=BV())||null==(i=n.prototype)?void 0:i.changeType)),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===uB){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=EB)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n,a,s,o,l,u,c=this.levels,h=this.startFragRequested,d=t.level,f=t.details,v=f.totalduration;if(c){this.log(_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Level ".concat(d," loaded [")).call(o,f.startSN,",")).call(s,f.endSN,"]")).call(a,f.lastPartSn?_d(l="[part-".concat(f.lastPartSn,"-")).call(l,f.lastPartIndex,"]"):"",", cc [")).call(n,f.startCC,", ")).call(i,f.endCC,"] duration:")).call(r,v));var g=t.levelInfo,p=this.fragCurrent;!p||this.state!==hB&&this.state!==dB||p.level!==t.level&&p.loader&&this.abortCurrentFrag();var m=0;if(f.live||null!=(u=g.details)&&u.live){var y;if(this.checkLiveUpdate(f),f.deltaUpdateFailed)return;m=this.alignPlaylists(f,g.details,null==(y=this.levelLastLoaded)?void 0:y.details)}if(g.details=f,this.levelLastLoaded=g,h||this.setStartPosition(f,m),this.hls.trigger(dO.LEVEL_UPDATED,{details:f,level:d}),this.state===EB){if(this.waitForCdnTuneIn(f))return;this.state=uB}h&&f.live&&this.synchronizeToLiveEdge(f),this.tick()}else this.warn("Levels were reset while loading level ".concat(d))}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragmentStart,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var l,u,c=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if(!o&&r.readyState<4||n<s-c)if(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState)this.warn(_d(l=_d(u="Playback: ".concat(n.toFixed(3)," is located too far from the end of live sliding playlist: ")).call(u,s,", reset currentTime to : ")).call(l,i.toFixed(3))),r.currentTime=i}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r,i,n=e.frag,a=e.part,s=e.payload,o=this.levels;if(o){var l=o[n.level];if(l){var u,c=l.details;if(!c)return this.warn(_d(u="Dropping fragment ".concat(n.sn," of level ")).call(u,n.level," after level details were reset")),void this.fragmentTracker.removeFragment(n);var h=l.videoCodec,d=c.PTSKnown||!c.live,f=null==(i=n.initSegment)?void 0:i.data,v=this._getAudioCodec(l),g=this.transmuxer=this.transmuxer||new tK(this.hls,mO,iT(t=this._handleTransmuxComplete).call(t,this),iT(r=this._handleTransmuxerFlush).call(r,this)),p=a?a.index:-1,m=-1!==p,y=new VN(n.level,n.sn,n.stats.chunkCount,s.byteLength,p,m),E=this.initPTS[n.cc];g.push(s,f,v,h,n,a,c.totalduration,d,y,E)}else this.warn("Level ".concat(n.level," not found on progress"))}else{var k;this.warn(_d(k="Levels were reset while fragment load was in progress. Fragment ".concat(n.sn," of level ")).call(k,n.level," will not be buffered"))}}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this.hls,i=2===this.altAudio;if(fF(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 n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();i&&(r.trigger(dO.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(dO.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=fF(t.url,this.hls);if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use ".concat(i,".buffered to schedule main fragment loading")),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part,n=r.type===mO;if(n){var a,s,o;if(this.fragContextChanged(r))return this.warn(_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state)),void(this.state===gB&&(this.state=uB));var l=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),lN(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}var u=this.media;u&&(!this._hasEnoughToStart&&u.buffered.length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=mB;else switch(t.details){case hO.FRAG_GAP:case hO.FRAG_PARSING_ERROR:case hO.FRAG_DECRYPT_ERROR:case hO.FRAG_LOAD_ERROR:case hO.FRAG_LOAD_TIMEOUT:case hO.KEY_LOAD_ERROR:case hO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(mO,t);break;case hO.LEVEL_LOAD_ERROR:case hO.LEVEL_LOAD_TIMEOUT:case hO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==EB||(null==(r=t.context)?void 0:r.type)!==vO||(this.state=uB);break;case hO.BUFFER_APPEND_ERROR:case hO.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===hO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case hO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"checkBuffer",value:function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this._hasEnoughToStart||!YN.getBuffered(e).length){var r=this.state,i=r!==uB?this.fragCurrent:null,n=this.getLevelDetails();t.poll(this.lastCurrentTime,i,n,r)}this.lastCurrentTime=e.currentTime}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=uB,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==nN||this.audioOnly&&!this.altAudio){var i=(r===aN?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,mO),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 i;if(e.seeking)return void this.log(_d(i="could not seek to ".concat(r,", already seeking at ")).call(i,t));var n=this.getLevelDetails(),a=this.config.timelineOffset;a&&r&&(r+=(null==n?void 0:n.appliedTimelineOffset)||a);var s,o,l=YN.getBuffered(e),u=l.length?l.start(0):0,c=u-r,h=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(c>0&&(c<h||this.loadingParts&&c<2*((null==n?void 0:n.partTarget)||0))&&(this.log("adjusting start position by ".concat(c," to match buffer start")),r+=c,this.startPosition=r),t<r)this.log(_d(s=_d(o="seek to target start position ".concat(r," from current time ")).call(o,t," buffer start ")).call(s,u)),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!==av(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 i=r.hls,n=null==e?void 0:e.frag;if(n&&!r.fragContextChanged(n)){t.fragmentError=0,r.state=uB,r.startFragRequested=!1,r.bitrateTest=!1;var a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(dO.FRAG_LOADED,e),n.bitrateTest=!1}}))}},{key:"_handleTransmuxComplete",value:function(e){var t,r=this.playlistType,i=this.hls,n=e.remuxResult,a=e.chunkMeta,s=this.getCurrentContext(a);if(s){var o=s.frag,l=s.part,u=s.level,c=n.video,h=n.text,d=n.id3,f=n.initSegment,v=u.details,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=vB,f){if(null!=f&&f.tracks){var p=o.initSegment||o;this._bufferInitSegment(u,f.tracks,p,a),i.trigger(dO.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:f.tracks})}var m=f.initPTS,y=f.timescale;oO(m)&&(this.initPTS[o.cc]={baseTime:m,timescale:y},i.trigger(dO.INIT_PTS_FOUND,{frag:o,id:r,initPTS:m,timescale:y}))}if(c&&v){var E=v.fragments[o.sn-1-v.startSN],k=o.sn===v.startSN,T=!E||o.cc>E.cc;if(!1!==n.independent){var S=c.startPTS,A=c.endPTS,L=c.startDTS,b=c.endDTS;if(l)l.elementaryStreams[c.type]={startPTS:S,endPTS:A,startDTS:L,endDTS:b};else if(c.firstKeyFrame&&c.independent&&1===a.id&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){var R=this.getMainFwdBufferInfo(),I=(R?R.end:this.getLoadPosition())+this.config.maxBufferHole,D=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!k&&I<D-this.config.maxBufferHole&&!T)return void this.backtrack(o);T&&(o.gap=!0),o.setElementaryStreamInfo(c.type,o.start,A,o.start,b,!0)}else k&&S-(v.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(c.type,S,A,L,b),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,l,a,k||T)}else{if(!k&&!T)return void this.backtrack(o);o.gap=!0}}if(g){var _=g.startPTS,w=g.endPTS,C=g.startDTS,P=g.endDTS;l&&(l.elementaryStreams[nN]={startPTS:_,endPTS:w,startDTS:C,endDTS:P}),o.setElementaryStreamInfo(nN,_,w,C,P),this.bufferFragmentData(g,o,l,a)}if(v&&null!=d&&null!=(t=d.samples)&&t.length){var x={id:r,frag:o,details:v,samples:d.samples};i.trigger(dO.FRAG_PARSING_METADATA,x)}if(v&&h){var M={id:r,frag:o,details:v,samples:h.samples};i.trigger(dO.FRAG_PARSING_USERDATA,M)}}}else this.resetWhenMissingContext(a)}},{key:"_bufferInitSegment",value:function(e,t,r,i){var n=this;if(this.state===vB){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a,s,o=t.audio,l=t.video,u=t.audiovideo;if(o){var c,h,d,f=jO(o.codec,e.audioCodec);"mp4a"===f&&(f="mp4a.40.5");var v,g=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){f&&(f=-1!==av(f).call(f,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var p=o.metadata;p&&"channelCount"in p&&1!==(p.channelCount||1)&&-1===av(g).call(g,"firefox")&&(f="mp4a.40.5")}if(f&&-1!==av(f).call(f,"mp4a.40.5")&&-1!==av(g).call(g,"android")&&"audio/mpeg"!==o.container&&(f="mp4a.40.2",this.log("Android: force audio codec to ".concat(f))),e.audioCodec&&e.audioCodec!==f)this.log(_d(v='Swapping manifest audio codec "'.concat(e.audioCodec,'" for "')).call(v,f,'"'));o.levelCodec=f,o.id="main",this.log(_d(c=_d(h=_d(d="Init audio buffer, container:".concat(o.container,", codecs[selected/level/parsed]=[")).call(d,f||"","/")).call(h,e.audioCodec||"","/")).call(c,o.codec,"]")),delete t.audiovideo}if(l){var m,y,E;l.levelCodec=e.videoCodec,l.id="main";var k=l.codec;if(4===(null==k?void 0:k.length))switch(k){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(_d(m=_d(y=_d(E="Init video buffer, container:".concat(l.container,", codecs[level/parsed]=[")).call(E,e.videoCodec||"","/")).call(y,k)).call(m,l.codec!==k?" parsed-corrected="+l.codec:"","}]")),delete t.audiovideo}if(u)this.log(_d(a=_d(s="Init audiovideo buffer, container:".concat(u.container,", codecs[level/parsed]=[")).call(s,e.codecs,"/")).call(a,u.codec,"]")),delete t.video,delete t.audio;var T=gv(t);if(T.length){if(this.hls.trigger(dO.BUFFER_CODECS,t),!this.hls)return;vd(T).call(T,(function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(dO.BUFFER_APPENDING,{type:e,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,mO)}},{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=uB}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(YN.isBuffered(e,r)?t=this.getAppendedFrag(r):YN.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n||(this.fragPlaying=t,this.hls.trigger(dO.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(dO.LEVEL_SWITCHED,{level:n}))}}}},{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 oO(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(oO(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?pF(null,r.fragments,t):null);if(i){var n=i.programDateTime;if(null!==n){var a=n+1e3*(t-i.start);return new Date(a)}}}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}}]),i}(kB),HV=function(){function e(r){t(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=r}return Fc(e,[{key:"abort",value:function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.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]:hO.KEY_LOAD_ERROR,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;return new KN({type:cO.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}},{key:"loadClear",value:function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(){var e=t[s];if(n<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),"break"},s=0;s<t.length;s++){if("break"===a())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,i;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return tk.reject(this.createKeyLoadError(e,hO.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return tk.reject(this.createKeyLoadError(e,hO.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(s,'"'))));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return n.key=l.decryptdata.key,tk.resolve({frag:e,keyInfo:l});if(null!=(i=l)&&i.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 n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.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 tk.reject(this.createKeyLoadError(e,hO.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(n.method,'"'))))}}},{key:"loadKeyEME",value:function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return tk.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new tk((function(a,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(e,t,i,n){var o=i.frag,l=i.keyInfo,u=i.url;if(!o.decryptdata||l!==r.keyUriToKeyInfo[u])return s(r.createKeyLoadError(o,hO.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,l.loader=null,a({frag:o,keyInfo:l})},onError:function(e,i,n,a){var l;r.resetLoader(i),s(r.createKeyLoadError(t,hO.KEY_LOAD_ERROR,new Error(_d(l="HTTP Error ".concat(e.code," loading key ")).call(l,e.text)),n,bO({url:o.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,hO.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,hO.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(o,u,c)}))}},{key:"resetLoader",value:function(e){var t=e.frag,r=e.keyInfo,i=e.url,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()}}]),e}();function VV(e){switch(e.type){case gO:return yO;case pO:return EO;default:return mO}}function jV(e,t){var r=e.url;return void 0!==r&&0!==av(r).call(r,"data:")||(r=t.url),r}var YV=function(){function e(r){t(this,e),this.hls=void 0,this.loaders=rT(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=r,this.registerListeners()}return Fc(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(dO.LEVEL_LOADING,this.onLevelLoading,this),e.on(dO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(dO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(dO.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(dO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(dO.LEVEL_LOADING,this.onLevelLoading,this),e.off(dO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(dO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(dO.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n}},{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:fO,url:r,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var r=t.id,i=t.level,n=t.pathwayId,a=t.url,s=t.deliveryDirectives,o=t.levelInfo;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:vO,url:a,deliveryDirectives:s,levelOrTrack:o})}},{key:"onAudioTrackLoading",value:function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:gO,url:n,deliveryDirectives:a,levelOrTrack:s})}},{key:"onSubtitleTrackLoading",value:function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:pO,url:n,deliveryDirectives:a,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[vO];if(r){var i,n=r.context;n&&!KT(i=t.levels).call(i,(function(e){return e===n.levelOrTrack}))&&(r.abort(),delete this.loaders[vO])}}},{key:"load",value:function(e){var t,r,i,n=this,a=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 u;if(l.url===e.url)o.log("[playlist-loader]: ignore ".concat(e.url," ongoing request"));else o.log(_d(u="[playlist-loader]: ignore ".concat(e.url," in favor of ")).call(u,l.url));return}o.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if((r=e.type===fO?a.manifestLoadPolicy.default:AO({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),oO(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===vO&&null!==e.level?i=this.hls.levels[e.level].details:e.type===gO&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===pO&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var c=i.partTarget,h=i.targetduration;if(c&&h){var d=1e3*Math.max(3*c,.8*h);r=AO({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var f=r.errorRetry||r.timeoutRetry||{},v={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},g={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===av(s).call(s,"#EXTM3U")?(t.parsing.start=performance.now(),NU.isMediaPlaylist(s)||r.type!==fO?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,v,g)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e,t=this.hls,r=t.config,i=r.autoStartLoad,n=r.startPosition,a=t.forceStartLoad;if(i||a)this.hls.logger.log(_d(e="".concat(i?"auto":"force"," startLoad with configured startPosition ")).call(e,n)),this.hls.startLoad(n)}}},{key:"handleMasterPlaylist",value:function(e,t,r,i){var n=this.hls,a=e.data,s=jV(e,r),o=NU.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var l=o.contentSteering,u=o.levels,c=o.sessionData,h=o.sessionKeys,d=o.startTimeOffset,f=o.variableList;this.variableList=f;var v=NU.parseMasterPlaylistMedia(a,s,o),g=v.AUDIO,p=void 0===g?[]:g,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];if(p.length)KT(p).call(p,(function(e){return!e.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ZN({}),bitrate:0,url:""}));n.trigger(dO.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:m,captions:y,contentSteering:l,url:s,stats:t,networkDetails:i,sessionData:c,sessionKeys:h,startTimeOffset:d,variableList:f})}}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,r,i,n){var a=this.hls,s=r.id,o=r.level,l=r.type,u=jV(e,r),c=oO(o)?o:oO(s)?s:0,h=VV(r),d=NU.parseLevelPlaylist(e.data,u,c,h,0,this.variableList);if(l===fO){var f={attrs:new ZN({}),bitrate:0,details:d,name:"",url:u};d.requestScheduled=t.loading.start+JU(d,0),a.trigger(dO.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:u,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=d,this.handlePlaylistLoaded(d,e,t,r,i,n)}},{key:"handleManifestParsingError",value:function(e,t,r,i,n){this.hls.trigger(dO.ERROR,{type:cO.NETWORK_ERROR,details:hO.MANIFEST_PARSING_ERROR,fatal:t.type===fO,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}},{key:"handleNetworkError",value:function(e,t){var r,i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=_d(r="A network ".concat(n?"timeout":"error"+(a?" (status "+a.code+")":"")," occurred while loading ")).call(r,e.type);if(e.type===vO)o+=_d(i=": ".concat(e.level," id: ")).call(i,e.id);else if(e.type===gO||e.type===pO){var l;o+=_d(l=" id: ".concat(e.id,' group-id: "')).call(l,e.groupId,'"')}var u=new Error(o);this.hls.logger.warn("[playlist-loader]: ".concat(o));var c=hO.UNKNOWN,h=!1,d=this.getInternalLoader(e);switch(e.type){case fO:c=n?hO.MANIFEST_LOAD_TIMEOUT:hO.MANIFEST_LOAD_ERROR,h=!0;break;case vO:c=n?hO.LEVEL_LOAD_TIMEOUT:hO.LEVEL_LOAD_ERROR,h=!1;break;case gO:c=n?hO.AUDIO_TRACK_LOAD_TIMEOUT:hO.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case pO:c=n?hO.SUBTITLE_TRACK_LOAD_TIMEOUT:hO.SUBTITLE_LOAD_ERROR,h=!1}d&&this.resetInternalLoader(e.type);var f={type:cO.NETWORK_ERROR,details:c,fatal:h,url:e.url,loader:d,context:e,error:u,networkDetails:t,stats:s};if(a){var v=(null==t?void 0:t.url)||e.url;f.response=bO({url:v,data:void 0},a)}this.hls.trigger(dO.ERROR,f)}},{key:"handlePlaylistLoaded",value:function(e,t,r,i,n,a){var s=this.hls,o=i.type,l=i.level,u=i.id,c=i.groupId,h=i.deliveryDirectives,d=jV(t,i),f=VV(i),v="number"==typeof i.level&&f===mO?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var g=e.playlistParsingError;if(g)s.trigger(dO.ERROR,{type:cO.NETWORK_ERROR,details:hO.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:g,reason:g.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case fO:case vO:s.trigger(dO.LEVEL_LOADED,{details:e,levelInfo:i.levelOrTrack||s.levels[0],level:v||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===fO});break;case gO:s.trigger(dO.AUDIO_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case pO:s.trigger(dO.SUBTITLE_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h})}}else{var p=e.playlistParsingError=new Error("No Segments found in Playlist");s.trigger(dO.ERROR,{type:cO.NETWORK_ERROR,details:hO.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:p,reason:p.message,response:t,context:i,level:v,parent:f,networkDetails:n,stats:r})}}}]),e}(),qV=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(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 AB,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 i=this.logger=function(e,t,r){var i=_O();if("object"===("undefined"==typeof console?"undefined":Cc(console))&&!0===e||"object"===Cc(e)){var n=["debug","log","info","warn","error"];vd(n).call(n,(function(t){i[t]=wO(t,e,r)}));try{i.log('Debug logs enabled for "'.concat(t,'" in hls.js version ',"1.6.0-beta.2"))}catch(a){return _O()}vd(n).call(n,(function(t){CO[t]=wO(t,e)}))}else AO(CO,i);return i}(r.debug||!1,"Hls instance",r.assetPlayerId),n=this.config=function(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 i=_V(e),n=["manifest","level","frag"],a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return vd(n).call(n,(function(e){var n,s,o="".concat("level"===e?"playlist":e,"LoadPolicy"),l=void 0===t[o],u=[];vd(a).call(a,(function(r){var n,a=_d(n="".concat(e,"Loading")).call(n,r),s=t[a];if(void 0!==s&&l){u.push(a);var c=i[o].default;switch(t[o]={default:c},r){case"TimeOut":c.maxLoadTimeMs=s,c.maxTimeToFirstByteMs=s;break;case"MaxRetry":c.errorRetry.maxNumRetry=s,c.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":c.errorRetry.retryDelayMs=s,c.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":c.errorRetry.maxRetryDelayMs=s,c.timeoutRetry.maxRetryDelayMs=s}}})),u.length&&r.warn(_d(n=_d(s='hls.js config: "'.concat(u.join('", "'),'" setting(s) are deprecated, use "')).call(s,o,'": ')).call(n,yI(t[o])))})),bO(bO({},i),t)}(e.DefaultConfig,r,i);this.userConfig=r,n.progressive&&wV(n,i);var a=n.abrController,s=n.bufferController,o=n.capLevelController,l=n.errorController,u=n.fpsController,c=new l(this),h=this.abrController=new a(this),d=new UF(this),f=n.interstitialsController,v=f?this.interstitialsController=new f(this,e):null,g=this.bufferController=new s(this,d),p=this.capLevelController=new o(this),m=new u(this),y=new YV(this),E=n.contentSteeringController,k=E?new E(this):null,T=this.levelController=new FV(this,k),S=new MV(this),A=new HV(this.config),L=this.streamController=new KV(this,d,A);p.setStreamController(L),m.setStreamController(L);var b=[y,T,L];v&&ig(b).call(b,1,0,v),k&&ig(b).call(b,1,0,k),this.networkControllers=b;var R=[h,g,p,m,S,d];this.audioTrackController=this.createController(n.audioTrackController,b);var I=n.audioStreamController;I&&b.push(new I(this,d,A)),this.subtitleTrackController=this.createController(n.subtitleTrackController,b);var D=n.subtitleStreamController;D&&b.push(new D(this,d,A)),this.createController(n.timelineController,R),A.emeController=this.emeController=this.createController(n.emeController,R),this.cmcdController=this.createController(n.cmcdController,R),this.latencyController=this.createController(OV,R),this.coreComponents=R,b.push(c);var _=c.onErrorOut;"function"==typeof _&&this.on(dO.ERROR,_,c),this.on(dO.MANIFEST_LOADED,y.onManifestLoaded,y)}return Fc(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,i=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,i)}},{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($V){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+$V.message+'". Here is a stacktrace:',$V),!this.triggeringException){this.triggeringException=!0;var r=e===dO.ERROR;this.trigger(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.INTERNAL_EXCEPTION,fatal:r,event:e,error:$V}),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(dO.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,vd(e=this.networkControllers).call(e,(function(e){return e.destroy()})),this.networkControllers.length=0,vd(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(dO.ERROR,{type:cO.OTHER_ERROR,details:hO.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,i=r?e.media:e,n=r?e:{media:i};this._media=i,this.trigger(dO.MEDIA_ATTACHING,n)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(dO.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(dO.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=rN.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:".concat(i)),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(dO.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"),vd(e=this.networkControllers).call(e,(function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){var e;this.bufferingEnabled&&(this.logger.log("pause buffering"),vd(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=function(){try{return crypto.randomUUID()}catch($V){try{var e=vI.createObjectURL(new Blob),t=e.toString();return vI.revokeObjectURL(e),Fv(t).call(t,HC(t).call(t,"/")+1)}catch(i){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)}))}}}()),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){(function(e){return av(QO).call(QO,e)>-1})(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,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}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 XO(e,oF(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return LB}},{key:"isMSESupported",value:function(){return GV()}},{key:"isSupported",value:function(){return function(){var e,t;if(!GV())return!1;var r=xO();return"function"==typeof(null==r?void 0:r.isTypeSupported)&&(KT(e=["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"]).call(e,(function(e){return r.isTypeSupported(UO(e,"video"))}))||KT(t=["mp4a.40.2","fLaC"]).call(t,(function(e){return r.isTypeSupported(UO(e,"audio"))})))}()}},{key:"getMediaSource",value:function(){return xO()}},{key:"Events",get:function(){return dO}},{key:"MetadataSchema",get:function(){return QB}},{key:"ErrorTypes",get:function(){return cO}},{key:"ErrorDetails",get:function(){return hO}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:DV},set:function(t){e.defaultConfig=t}}]),e}();qV.defaultConfig=void 0;var WV={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}};var zV=function(){function e(r,i){t(this,e),this.hls=r,this.player=i}return Fc(e,[{key:"getAudioTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.audioTracks||[]}catch($V){return console.error("Failed to get audio tracks:",$V),[]}}},{key:"getCurrentAudioTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.audioTrack}catch($V){return console.error("Failed to get current audio track:",$V),-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(!KT(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($V){return console.error("Failed to switch audio track:",$V),!1}}},{key:"getSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.subtitleTracks||[]}catch($V){return console.error("Failed to get subtitle tracks:",$V),[]}}},{key:"getAllSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.allSubtitleTracks||[]}catch($V){return console.error("Failed to get all subtitle tracks:",$V),[]}}},{key:"getCurrentSubtitleTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.subtitleTrack}catch($V){return console.error("Failed to get current subtitle track:",$V),-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($V){return console.error("Failed to disable subtitle track:",$V),!1}if(0===t.length)return console.warn("No subtitle tracks available"),!1;if(!KT(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($V){return console.error("Failed to switch subtitle track:",$V),!1}}},{key:"getSubtitleDisplay",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),!1;try{return this.hls.subtitleDisplay}catch($V){return console.error("Failed to get subtitle display status:",$V),!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($V){return console.error("Failed to set subtitle display:",$V),!1}}}]),e}(),XV=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"beforePlayerInit",value:function(){Ih(Rh(i.prototype),"beforePlayerInit",this).call(this),this._transEvent()}},{key:"_transEvent",value:function(){var e,t=this;vd(e=Ld(dO)).call(e,(function(e){e!==dO.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 i,n,a=arguments.length,s=new Array(a>1?a-1:0),o=1;o<a;o++)s[o-1]=arguments[o];(i=r.player).emit.apply(i,_d(n=[e]).call(n,s))}}))}}]),i}(function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,Rf(Rf({},e),{},{pluginName:i.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=Wf(n._tick,n._tickInterval);var t=n._getBufferend(e);t<.1||!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 Fc(i,[{key:"beforePlayerInit",value:function(){this.register(this.player.config.url)}},{key:"initEvt",value:function(){var e,t;e=this.hls,t=this.player,e.on(qV.Events.SUBTITLE_FRAG_PROCESSED,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.subtitlesegments",list:i})})),e.on(qV.Events.MANIFEST_PARSED,(function(e,r){var i=r.levels;t.emit("core_event",{eventName:"core.subtitleplaylist",list:i})})),e.on(qV.Events.MANIFEST_LOADING,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadstart",url:i})})),e.on(qV.Events.LEVEL_LOADING,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadstart",url:i})})),e.on(qV.Events.FRAG_LOADING,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.loadstart",url:i.url})})),e.on(qV.Events.MANIFEST_LOADED,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadcomplete",url:i})})),e.on(qV.Events.LEVEL_LOADED,(function(e,r){var i=r.details,n=r.stats;t.emit("core_event",Rf(Rf({eventName:"core.loadcomplete"},n),{},{url:null==i?void 0:i.url}))})),e.on(qV.Events.FRAG_LOADED,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.loadcomplete",url:i.url})})),e.on(qV.Events.FRAG_PARSING_USERDATA,(function(e,r){var i=r.samples;t.emit("core_event",{eventName:"core.sei",sei:i})})),e.on(qV.Events.MANIFEST_LOADED,(function(e,r){var i=r.levels,n=r.networkDetails;t.emit("core_event",{eventName:"core.hlsmanifestloaded",playlist:i}),t.emit("core_event",{eventName:"core.loadresponseheaders",headers:n.headers})})),e.on(qV.Events.LEVEL_LOADED,(function(e,r){var i,n=r.details,a={};vd(i=gv(n.dateRanges)).call(i,(function(e){a[e]=n.dateRanges[e].attr["START-DATE"]})),t.emit("core_event",{eventName:"core.hlslevelloaded",playlist:Rf(Rf({},n),{},{segments:n.fragments,dateRanges:a})})})),e.on(qV.Events.ERROR,(function(r,i){var n=i.details,a=i.fatal,s=i.type,o=i.response,l=i.reason,u=i.error;if(a){var c,h;switch(s){case qV.ErrorTypes.NETWORK_ERROR:c=2100,sD(n).call(n,"TimeOut")?c=2101:403===(null==o?void 0:o.code)?c=2103:404===(null==o?void 0:o.code)&&(c=2104),t.emit("error",{errorType:"network",errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case qV.ErrorTypes.MEDIA_ERROR:h="media",n===qV.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?c=5104:n===qV.ErrorDetails.FRAG_DECRYPT_ERROR?c=5105:n===qV.ErrorDetails.FRAG_PARSING_ERROR?(c=1100,h="manifest"):n===qV.ErrorDetails.FRAG_GAP?c=5104:n===qV.ErrorDetails.BUFFER_ADD_CODEC_ERROR?c=5200:n===qV.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR?c=5104:n===qV.ErrorDetails.BUFFER_APPEND_ERROR||n===qV.ErrorDetails.BUFFER_APPENDING_ERROR?c=5201:n===qV.ErrorDetails.BUFFER_STALLED_ERROR||n===qV.ErrorDetails.BUFFER_FULL_ERROR?c=5203:(n===qV.ErrorDetails.BUFFER_SEEK_OVER_HOLE||n===qV.ErrorDetails.BUFFER_NUDGE_ON_STALL)&&(c=5202),t.emit("error",{errorType:h||s,errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case qV.ErrorTypes.MUX_ERROR:c=4100,t.emit("error",{errorType:"remux",errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case qV.ErrorTypes.KEY_SYSTEM_ERROR:c=7111,n===qV.ErrorDetails.KEY_SYSTEM_NO_KEYS?c=7103:n===qV.ErrorDetails.KEY_SYSTEM_NO_ACCESS?c=7101:n===qV.ErrorDetails.KEY_SYSTEM_NO_SESSION?c=7104:n===qV.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?c=7107:n===qV.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED?c=7108:n===qV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED||n===qV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?c=7110:n===qV.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?c=7104:n===qV.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR&&(c=7111),t.emit("error",{errorType:"drm",errorCode:c,message:(null==u?void 0:u.message)||l||n,originError:i});break;default:n===qV.ErrorDetails.LEVEL_SWITCH_ERROR&&(c=2100,h="network"),t.emit("error",{errorType:h||"other",errorCode:c,message:(null==u?void 0:u.message)||l||n,originError:i})}try{e.stopLoad(),t.pause()}catch(d){}}})),e.on(qV.Events.MEDIA_ATTACHED,(function(){t.emit("sourceopen")})),e.on(qV.Events.BUFFER_APPENDED,(function(){t.emit("bufferappend")})),e.on(qV.Events.AUDIO_TRACKS_UPDATED,(function(e,r){var i=r.audioTracks;t.emit("core_event",{eventName:"core.audiotracksupdate",audioTracks:i})})),e.on(qV.Events.AUDIO_TRACK_SWITCHING,(function(e,r){t.emit("core_event",Rf({eventName:"core.audiotrackswitching"},r))})),e.on(qV.Events.AUDIO_TRACK_SWITCHED,(function(e,r){t.emit("core_event",Rf({eventName:"core.audiotrackswitched"},r))})),e.on(qV.Events.SUBTITLE_TRACKS_UPDATED,(function(e,r){var i=r.subtitleTracks;t.emit("core_event",{eventName:"core.subtitletracksupdate",subtitleTracks:i})})),e.on(qV.Events.SUBTITLE_TRACKS_CLEARED,(function(){t.emit("core_event",{eventName:"core.subtitletracksclear"})})),e.on(qV.Events.SUBTITLE_TRACK_SWITCH,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackswitch"},r))})),e.on(qV.Events.SUBTITLE_TRACK_LOADING,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackloading"},r))})),e.on(qV.Events.SUBTITLE_TRACK_LOADED,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackloaded"},r))}))}},{key:"afterCreate",value:function(){var e=this.player.media;this.player.on(CA,this.onUrlChange);try{UA.defineGetterOrSetter(this.player,{url:{get:function(){try{return e.src}catch($V){return null}},configurable:!0}})}catch(t){}}},{key:"register",value:function(e){var t=this.player;this.hls&&this.hls.destroy();var r=function(e){var t,r={};vd(t=gv(WV)).call(t,(function(t){var i=WV[t];i instanceof Array?vd(i).call(i,(function(e){r[t]=e.val})):r[t]=e[i.key]||i.val}));var i="number"==typeof e.retryCount?e.retryCount:3,n="number"==typeof e.retryDelay?e.retryDelay:1e3,a=e.loadTimeout||1e4,s="number"==typeof e.manifestLoadTimeout?e.manifestLoadTimeout:1e4,o={maxNumRetry:i,retryDelayMs:n,maxRetryDelayMs:n,shouldRetry:function(e,t){return t<e.maxNumRetry}},l={maxNumRetry:i,retryDelayMs:n,maxRetryDelayMs:n,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:a,timeoutRetry:o,errorRetry:l}},r.fragLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:a,timeoutRetry:o,errorRetry:l}},Rf(Rf({},r),e)}(this.config);(this.hls=new qV(r),this._trackManager=new zV(this.hls,this.player),this.initEvt(),t.config.preProcessUrl)&&(e=t.config.preProcessUrl(e).url);this.hls.loadSource(e);var i=this.player.media;this.hls.attachMedia(i),clearTimeout(this._tickTimer),this._tickTimer=Wf(this._tick,this._tickInterval),i.removeEventListener("play",this._onPlay),i.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(CA,this.onUrlChange),null==(e=this.hls)||e.destroy()}}],[{key:"pluginName",get:function(){return"hls"}}]),i}(UA)),QV=window.VePlayer.DynamicModule;VePlayer.registerPlugin(QV.PluginHlsJs,{HlsPlugin:XV}),e.HlsPlugin=XV}));
|