@volcengine/veplayer-plugin 2.6.0-rc.3 → 2.6.0-rc.5
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/index.development.js +99479 -77329
- package/esm/index.production.js +6 -6
- package/esm/veplayer.plugin.ad.development.js +16355 -10728
- package/esm/veplayer.plugin.ad.production.js +2 -2
- package/esm/veplayer.plugin.flv.development.js +58 -33
- package/esm/veplayer.plugin.flv.production.js +1 -1
- package/esm/veplayer.plugin.hls.development.js +2 -2
- package/esm/veplayer.plugin.hls.production.js +1 -1
- package/esm/veplayer.plugin.hlsjs.development.js +14969 -0
- package/esm/veplayer.plugin.hlsjs.production.js +2 -0
- package/esm/veplayer.plugin.mp4.development.js +1 -1
- package/esm/veplayer.plugin.mp4.production.js +1 -1
- package/esm/veplayer.plugin.rtm.development.js +155 -51
- package/esm/veplayer.plugin.rtm.production.js +1 -1
- package/package.json +1 -1
- package/umd/veplayer.plugin.ad.development.js +16293 -10666
- package/umd/veplayer.plugin.ad.production.js +1 -1
- package/umd/veplayer.plugin.flv.development.js +59 -34
- package/umd/veplayer.plugin.flv.production.js +1 -1
- package/umd/veplayer.plugin.hls.development.js +2 -2
- package/umd/veplayer.plugin.hls.production.js +1 -1
- package/umd/veplayer.plugin.hlsjs.development.js +14971 -0
- package/umd/veplayer.plugin.hlsjs.production.js +1 -0
- package/umd/veplayer.plugin.mp4.development.js +1 -1
- package/umd/veplayer.plugin.mp4.production.js +1 -1
- package/umd/veplayer.plugin.rtm.development.js +155 -51
- package/umd/veplayer.plugin.rtm.production.js +1 -1
|
@@ -0,0 +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";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var i=function(e){return e&&e.Math==Math&&e},n=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof t&&t)||function(){return this}()||t||Function("return this")(),a=function(e){try{return!!e()}catch(t){return!0}},s=!a((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),o=s,l=Function.prototype,u=l.apply,c=l.call,h="object"==typeof Reflect&&Reflect.apply||(o?c.bind(u):function(){return c.apply(u,arguments)}),d=s,f=Function.prototype,v=f.call,g=d&&f.bind.bind(v,v),p=d?g:function(e){return function(){return v.apply(e,arguments)}},m=p,y=m({}.toString),E=m("".slice),k=function(e){return E(y(e),8,-1)},T=k,S=p,A=function(e){if("Function"===T(e))return S(e)},L="object"==typeof document&&document.all,b={all:L,IS_HTMLDDA:void 0===L&&void 0!==L},R=b.all,I=b.IS_HTMLDDA?function(e){return"function"==typeof e||e===R}:function(e){return"function"==typeof e},D={},w=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),_=s,P=Function.prototype.call,C=_?P.bind(P):function(){return P.apply(P,arguments)},x={},M={}.propertyIsEnumerable,O=Object.getOwnPropertyDescriptor,F=O&&!M.call({1:2},1);x.f=F?function(e){var t=O(this,e);return!!t&&t.enumerable}:M;var N,U,B=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},G=a,K=k,H=Object,V=p("".split),j=G((function(){return!H("z").propertyIsEnumerable(0)}))?function(e){return"String"==K(e)?V(e,""):H(e)}:H,Y=function(e){return null==e},W=Y,q=TypeError,z=function(e){if(W(e))throw q("Can't call method on "+e);return e},X=j,Q=z,$=function(e){return X(Q(e))},J=I,Z=b.all,ee=b.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:J(e)||e===Z}:function(e){return"object"==typeof e?null!==e:J(e)},te={},re=te,ie=n,ne=I,ae=function(e){return ne(e)?e:void 0},se=function(e,t){return arguments.length<2?ae(re[e])||ae(ie[e]):re[e]&&re[e][t]||ie[e]&&ie[e][t]},oe=p({}.isPrototypeOf),le="undefined"!=typeof navigator&&String(navigator.userAgent)||"",ue=n,ce=le,he=ue.process,de=ue.Deno,fe=he&&he.versions||de&&de.version,ve=fe&&fe.v8;ve&&(U=(N=ve.split("."))[0]>0&&N[0]<4?1:+(N[0]+N[1])),!U&&ce&&(!(N=ce.match(/Edge\/(\d+)/))||N[1]>=74)&&(N=ce.match(/Chrome\/(\d+)/))&&(U=+N[1]);var ge=U,pe=ge,me=a,ye=n.String,Ee=!!Object.getOwnPropertySymbols&&!me((function(){var e=Symbol();return!ye(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&pe&&pe<41})),ke=Ee&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Te=se,Se=I,Ae=oe,Le=Object,be=ke?function(e){return"symbol"==typeof e}:function(e){var t=Te("Symbol");return Se(t)&&Ae(t.prototype,Le(e))},Re=String,Ie=function(e){try{return Re(e)}catch(t){return"Object"}},De=I,we=Ie,_e=TypeError,Pe=function(e){if(De(e))return e;throw _e(we(e)+" is not a function")},Ce=Pe,xe=Y,Me=function(e,t){var r=e[t];return xe(r)?void 0:Ce(r)},Oe=C,Fe=I,Ne=ee,Ue=TypeError,Be={exports:{}},Ge=n,Ke=Object.defineProperty,He=function(e,t){try{Ke(Ge,e,{value:t,configurable:!0,writable:!0})}catch(r){Ge[e]=t}return t},Ve="__core-js_shared__",je=n[Ve]||He(Ve,{}),Ye=je;(Be.exports=function(e,t){return Ye[e]||(Ye[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 We=Be.exports,qe=z,ze=Object,Xe=function(e){return ze(qe(e))},Qe=Xe,$e=p({}.hasOwnProperty),Je=Object.hasOwn||function(e,t){return $e(Qe(e),t)},Ze=p,et=0,tt=Math.random(),rt=Ze(1..toString),it=function(e){return"Symbol("+(void 0===e?"":e)+")_"+rt(++et+tt,36)},nt=We,at=Je,st=it,ot=Ee,lt=ke,ut=n.Symbol,ct=nt("wks"),ht=lt?ut.for||ut:ut&&ut.withoutSetter||st,dt=function(e){return at(ct,e)||(ct[e]=ot&&at(ut,e)?ut[e]:ht("Symbol."+e)),ct[e]},ft=C,vt=ee,gt=be,pt=Me,mt=function(e,t){var r,i;if("string"===t&&Fe(r=e.toString)&&!Ne(i=Oe(r,e)))return i;if(Fe(r=e.valueOf)&&!Ne(i=Oe(r,e)))return i;if("string"!==t&&Fe(r=e.toString)&&!Ne(i=Oe(r,e)))return i;throw Ue("Can't convert object to primitive value")},yt=TypeError,Et=dt("toPrimitive"),kt=function(e,t){if(!vt(e)||gt(e))return e;var r,i=pt(e,Et);if(i){if(void 0===t&&(t="default"),r=ft(i,e,t),!vt(r)||gt(r))return r;throw yt("Can't convert object to primitive value")}return void 0===t&&(t="number"),mt(e,t)},Tt=be,St=function(e){var t=kt(e,"string");return Tt(t)?t:t+""},At=ee,Lt=n.document,bt=At(Lt)&&At(Lt.createElement),Rt=function(e){return bt?Lt.createElement(e):{}},It=Rt,Dt=!w&&!a((function(){return 7!=Object.defineProperty(It("div"),"a",{get:function(){return 7}}).a})),wt=w,_t=C,Pt=x,Ct=B,xt=$,Mt=St,Ot=Je,Ft=Dt,Nt=Object.getOwnPropertyDescriptor;D.f=wt?Nt:function(e,t){if(e=xt(e),t=Mt(t),Ft)try{return Nt(e,t)}catch(r){}if(Ot(e,t))return Ct(!_t(Pt.f,e,t),e[t])};var Ut=a,Bt=I,Gt=/#|\.prototype\./,Kt=function(e,t){var r=Vt[Ht(e)];return r==Yt||r!=jt&&(Bt(t)?Ut(t):!!t)},Ht=Kt.normalize=function(e){return String(e).replace(Gt,".").toLowerCase()},Vt=Kt.data={},jt=Kt.NATIVE="N",Yt=Kt.POLYFILL="P",Wt=Kt,qt=Pe,zt=s,Xt=A(A.bind),Qt=function(e,t){return qt(e),void 0===t?e:zt?Xt(e,t):function(){return e.apply(t,arguments)}},$t={},Jt=w&&a((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Zt=ee,er=String,tr=TypeError,rr=function(e){if(Zt(e))return e;throw tr(er(e)+" is not an object")},ir=w,nr=Dt,ar=Jt,sr=rr,or=St,lr=TypeError,ur=Object.defineProperty,cr=Object.getOwnPropertyDescriptor,hr="enumerable",dr="configurable",fr="writable";$t.f=ir?ar?function(e,t,r){if(sr(e),t=or(t),sr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&fr in r&&!r[fr]){var i=cr(e,t);i&&i[fr]&&(e[t]=r.value,r={configurable:dr in r?r[dr]:i[dr],enumerable:hr in r?r[hr]:i[hr],writable:!1})}return ur(e,t,r)}:ur:function(e,t,r){if(sr(e),t=or(t),sr(r),nr)try{return ur(e,t,r)}catch(i){}if("get"in r||"set"in r)throw lr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var vr=$t,gr=B,pr=w?function(e,t,r){return vr.f(e,t,gr(1,r))}:function(e,t,r){return e[t]=r,e},mr=n,yr=h,Er=A,kr=I,Tr=D.f,Sr=Wt,Ar=te,Lr=Qt,br=pr,Rr=Je,Ir=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 yr(e,this,arguments)};return t.prototype=e.prototype,t},Dr=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?mr:f?mr[h]:(mr[h]||{}).prototype,p=d?Ar:Ar[h]||br(Ar,h,{})[h],m=p.prototype;for(a in t)i=!(r=Sr(d?a:h+(f?".":"#")+a,e.forced))&&g&&Rr(g,a),o=p[a],i&&(l=e.dontCallGetSet?(c=Tr(g,a))&&c.value:g[a]),s=i&&l?l:t[a],i&&typeof o==typeof s||(u=e.bind&&i?Lr(s,mr):e.wrap&&i?Ir(s):v&&kr(s)?Er(s):s,(e.sham||s&&s.sham||o&&o.sham)&&br(u,"sham",!0),br(p,a,u),v&&(Rr(Ar,n=h+"Prototype")||br(Ar,n,{}),br(Ar[n],a,s),e.real&&m&&(r||!m[a])&&br(m,a,s)))},wr=Math.ceil,_r=Math.floor,Pr=Math.trunc||function(e){var t=+e;return(t>0?_r:wr)(t)},Cr=function(e){var t=+e;return t!=t||0===t?0:Pr(t)},xr=Cr,Mr=Math.max,Or=Math.min,Fr=function(e,t){var r=xr(e);return r<0?Mr(r+t,0):Or(r,t)},Nr=Cr,Ur=Math.min,Br=function(e){return e>0?Ur(Nr(e),9007199254740991):0},Gr=Br,Kr=function(e){return Gr(e.length)},Hr=$,Vr=Fr,jr=Kr,Yr=function(e){return function(t,r,i){var n,a=Hr(t),s=jr(a),o=Vr(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}},Wr={includes:Yr(!0),indexOf:Yr(!1)},qr={},zr=Je,Xr=$,Qr=Wr.indexOf,$r=qr,Jr=p([].push),Zr=function(e,t){var r,i=Xr(e),n=0,a=[];for(r in i)!zr($r,r)&&zr(i,r)&&Jr(a,r);for(;t.length>n;)zr(i,r=t[n++])&&(~Qr(a,r)||Jr(a,r));return a},ei=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ti=Zr,ri=ei,ii=Object.keys||function(e){return ti(e,ri)},ni=Xe,ai=ii;Dr({target:"Object",stat:!0,forced:a((function(){ai(1)}))},{keys:function(e){return ai(ni(e))}});var si=te.Object.keys,oi=r(si),li={};li[dt("toStringTag")]="z";var ui="[object z]"===String(li),ci=ui,hi=I,di=k,fi=dt("toStringTag"),vi=Object,gi="Arguments"==di(function(){return arguments}()),pi=ci?di: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=vi(e),fi))?r:gi?di(t):"Object"==(i=di(t))&&hi(t.callee)?"Arguments":i},mi=pi,yi=String,Ei=function(e){if("Symbol"===mi(e))throw TypeError("Cannot convert a Symbol value to a string");return yi(e)},ki={},Ti=w,Si=Jt,Ai=$t,Li=rr,bi=$,Ri=ii;ki.f=Ti&&!Si?Object.defineProperties:function(e,t){Li(e);for(var r,i=bi(t),n=Ri(t),a=n.length,s=0;a>s;)Ai.f(e,r=n[s++],i[r]);return e};var Ii,Di=se("document","documentElement"),wi=it,_i=We("keys"),Pi=function(e){return _i[e]||(_i[e]=wi(e))},Ci=rr,xi=ki,Mi=ei,Oi=qr,Fi=Di,Ni=Rt,Ui="prototype",Bi="script",Gi=Pi("IE_PROTO"),Ki=function(){},Hi=function(e){return"<"+Bi+">"+e+"</"+Bi+">"},Vi=function(e){e.write(Hi("")),e.close();var t=e.parentWindow.Object;return e=null,t},ji=function(){try{Ii=new ActiveXObject("htmlfile")}catch(n){}var e,t,r;ji="undefined"!=typeof document?document.domain&&Ii?Vi(Ii):(t=Ni("iframe"),r="java"+Bi+":",t.style.display="none",Fi.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Hi("document.F=Object")),e.close(),e.F):Vi(Ii);for(var i=Mi.length;i--;)delete ji[Ui][Mi[i]];return ji()};Oi[Gi]=!0;var Yi=Object.create||function(e,t){var r;return null!==e?(Ki[Ui]=Ci(e),r=new Ki,Ki[Ui]=null,r[Gi]=e):r=ji(),void 0===t?r:xi.f(r,t)},Wi={},qi=Zr,zi=ei.concat("length","prototype");Wi.f=Object.getOwnPropertyNames||function(e){return qi(e,zi)};var Xi={},Qi=St,$i=$t,Ji=B,Zi=function(e,t,r){var i=Qi(t);i in e?$i.f(e,i,Ji(0,r)):e[i]=r},en=Fr,tn=Kr,rn=Zi,nn=Array,an=Math.max,sn=function(e,t,r){for(var i=tn(e),n=en(t,i),a=en(void 0===r?i:r,i),s=nn(an(a-n,0)),o=0;n<a;n++,o++)rn(s,o,e[n]);return s.length=o,s},on=k,ln=$,un=Wi.f,cn=sn,hn="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Xi.f=function(e){return hn&&"Window"==on(e)?function(e){try{return un(e)}catch(t){return cn(hn)}}(e):un(ln(e))};var dn={};dn.f=Object.getOwnPropertySymbols;var fn=pr,vn=function(e,t,r,i){return i&&i.enumerable?e[t]=r:fn(e,t,r),e},gn=$t,pn=function(e,t,r){return gn.f(e,t,r)},mn={},yn=dt;mn.f=yn;var En,kn,Tn,Sn=te,An=Je,Ln=mn,bn=$t.f,Rn=function(e){var t=Sn.Symbol||(Sn.Symbol={});An(t,e)||bn(t,e,{value:Ln.f(e)})},In=C,Dn=se,wn=dt,_n=vn,Pn=function(){var e=Dn("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,i=wn("toPrimitive");t&&!t[i]&&_n(t,i,(function(e){return In(r,this)}),{arity:1})},Cn=pi,xn=ui?{}.toString:function(){return"[object "+Cn(this)+"]"},Mn=ui,On=$t.f,Fn=pr,Nn=Je,Un=xn,Bn=dt("toStringTag"),Gn=function(e,t,r,i){if(e){var n=r?e:e.prototype;Nn(n,Bn)||On(n,Bn,{configurable:!0,value:t}),i&&!Mn&&Fn(n,"toString",Un)}},Kn=I,Hn=n.WeakMap,Vn=Kn(Hn)&&/native code/.test(String(Hn)),jn=n,Yn=ee,Wn=pr,qn=Je,zn=je,Xn=Pi,Qn=qr,$n="Object already initialized",Jn=jn.TypeError,Zn=jn.WeakMap;if(Vn||zn.state){var ea=zn.state||(zn.state=new Zn);ea.get=ea.get,ea.has=ea.has,ea.set=ea.set,En=function(e,t){if(ea.has(e))throw Jn($n);return t.facade=e,ea.set(e,t),t},kn=function(e){return ea.get(e)||{}},Tn=function(e){return ea.has(e)}}else{var ta=Xn("state");Qn[ta]=!0,En=function(e,t){if(qn(e,ta))throw Jn($n);return t.facade=e,Wn(e,ta,t),t},kn=function(e){return qn(e,ta)?e[ta]:{}},Tn=function(e){return qn(e,ta)}}var ra={set:En,get:kn,has:Tn,enforce:function(e){return Tn(e)?kn(e):En(e,{})},getterFor:function(e){return function(t){var r;if(!Yn(t)||(r=kn(t)).type!==e)throw Jn("Incompatible receiver, "+e+" required");return r}}},ia=k,na=Array.isArray||function(e){return"Array"==ia(e)},aa=I,sa=je,oa=p(Function.toString);aa(sa.inspectSource)||(sa.inspectSource=function(e){return oa(e)});var la=sa.inspectSource,ua=p,ca=a,ha=I,da=pi,fa=la,va=function(){},ga=[],pa=se("Reflect","construct"),ma=/^\s*(?:class|function)\b/,ya=ua(ma.exec),Ea=!ma.exec(va),ka=function(e){if(!ha(e))return!1;try{return pa(va,ga,e),!0}catch(t){return!1}},Ta=function(e){if(!ha(e))return!1;switch(da(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ea||!!ya(ma,fa(e))}catch(t){return!0}};Ta.sham=!0;var Sa=!pa||ca((function(){var e;return ka(ka.call)||!ka(Object)||!ka((function(){e=!0}))||e}))?Ta:ka,Aa=na,La=Sa,ba=ee,Ra=dt("species"),Ia=Array,Da=function(e){var t;return Aa(e)&&(t=e.constructor,(La(t)&&(t===Ia||Aa(t.prototype))||ba(t)&&null===(t=t[Ra]))&&(t=void 0)),void 0===t?Ia:t},wa=function(e,t){return new(Da(e))(0===t?0:t)},_a=Qt,Pa=j,Ca=Xe,xa=Kr,Ma=wa,Oa=p([].push),Fa=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=Ca(l),g=Pa(v),p=_a(u,c),m=xa(g),y=0,E=h||Ma,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:Oa(k,d)}else switch(e){case 4:return!1;case 7:Oa(k,d)}return a?-1:i||n?n:k}},Na={forEach:Fa(0),map:Fa(1),filter:Fa(2),some:Fa(3),every:Fa(4),find:Fa(5),findIndex:Fa(6),filterReject:Fa(7)},Ua=Dr,Ba=n,Ga=C,Ka=p,Ha=w,Va=Ee,ja=a,Ya=Je,Wa=oe,qa=rr,za=$,Xa=St,Qa=Ei,$a=B,Ja=Yi,Za=ii,es=Wi,ts=Xi,rs=dn,is=D,ns=$t,as=ki,ss=x,os=vn,ls=pn,us=We,cs=qr,hs=it,ds=dt,fs=mn,vs=Rn,gs=Pn,ps=Gn,ms=ra,ys=Na.forEach,Es=Pi("hidden"),ks="Symbol",Ts="prototype",Ss=ms.set,As=ms.getterFor(ks),Ls=Object[Ts],bs=Ba.Symbol,Rs=bs&&bs[Ts],Is=Ba.TypeError,Ds=Ba.QObject,ws=is.f,_s=ns.f,Ps=ts.f,Cs=ss.f,xs=Ka([].push),Ms=us("symbols"),Os=us("op-symbols"),Fs=us("wks"),Ns=!Ds||!Ds[Ts]||!Ds[Ts].findChild,Us=Ha&&ja((function(){return 7!=Ja(_s({},"a",{get:function(){return _s(this,"a",{value:7}).a}})).a}))?function(e,t,r){var i=ws(Ls,t);i&&delete Ls[t],_s(e,t,r),i&&e!==Ls&&_s(Ls,t,i)}:_s,Bs=function(e,t){var r=Ms[e]=Ja(Rs);return Ss(r,{type:ks,tag:e,description:t}),Ha||(r.description=t),r},Gs=function(e,t,r){e===Ls&&Gs(Os,t,r),qa(e);var i=Xa(t);return qa(r),Ya(Ms,i)?(r.enumerable?(Ya(e,Es)&&e[Es][i]&&(e[Es][i]=!1),r=Ja(r,{enumerable:$a(0,!1)})):(Ya(e,Es)||_s(e,Es,$a(1,{})),e[Es][i]=!0),Us(e,i,r)):_s(e,i,r)},Ks=function(e,t){qa(e);var r=za(t),i=Za(r).concat(Ys(r));return ys(i,(function(t){Ha&&!Ga(Hs,r,t)||Gs(e,t,r[t])})),e},Hs=function(e){var t=Xa(e),r=Ga(Cs,this,t);return!(this===Ls&&Ya(Ms,t)&&!Ya(Os,t))&&(!(r||!Ya(this,t)||!Ya(Ms,t)||Ya(this,Es)&&this[Es][t])||r)},Vs=function(e,t){var r=za(e),i=Xa(t);if(r!==Ls||!Ya(Ms,i)||Ya(Os,i)){var n=ws(r,i);return!n||!Ya(Ms,i)||Ya(r,Es)&&r[Es][i]||(n.enumerable=!0),n}},js=function(e){var t=Ps(za(e)),r=[];return ys(t,(function(e){Ya(Ms,e)||Ya(cs,e)||xs(r,e)})),r},Ys=function(e){var t=e===Ls,r=Ps(t?Os:za(e)),i=[];return ys(r,(function(e){!Ya(Ms,e)||t&&!Ya(Ls,e)||xs(i,Ms[e])})),i};Va||(bs=function(){if(Wa(Rs,this))throw Is("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Qa(arguments[0]):void 0,t=hs(e),r=function(e){this===Ls&&Ga(r,Os,e),Ya(this,Es)&&Ya(this[Es],t)&&(this[Es][t]=!1),Us(this,t,$a(1,e))};return Ha&&Ns&&Us(Ls,t,{configurable:!0,set:r}),Bs(t,e)},os(Rs=bs[Ts],"toString",(function(){return As(this).tag})),os(bs,"withoutSetter",(function(e){return Bs(hs(e),e)})),ss.f=Hs,ns.f=Gs,as.f=Ks,is.f=Vs,es.f=ts.f=js,rs.f=Ys,fs.f=function(e){return Bs(ds(e),e)},Ha&&ls(Rs,"description",{configurable:!0,get:function(){return As(this).description}})),Ua({global:!0,constructor:!0,wrap:!0,forced:!Va,sham:!Va},{Symbol:bs}),ys(Za(Fs),(function(e){vs(e)})),Ua({target:ks,stat:!0,forced:!Va},{useSetter:function(){Ns=!0},useSimple:function(){Ns=!1}}),Ua({target:"Object",stat:!0,forced:!Va,sham:!Ha},{create:function(e,t){return void 0===t?Ja(e):Ks(Ja(e),t)},defineProperty:Gs,defineProperties:Ks,getOwnPropertyDescriptor:Vs}),Ua({target:"Object",stat:!0,forced:!Va},{getOwnPropertyNames:js}),gs(),ps(bs,ks),cs[Es]=!0;var Ws=Ee&&!!Symbol.for&&!!Symbol.keyFor,qs=Dr,zs=se,Xs=Je,Qs=Ei,$s=We,Js=Ws,Zs=$s("string-to-symbol-registry"),eo=$s("symbol-to-string-registry");qs({target:"Symbol",stat:!0,forced:!Js},{for:function(e){var t=Qs(e);if(Xs(Zs,t))return Zs[t];var r=zs("Symbol")(t);return Zs[t]=r,eo[r]=t,r}});var to=Dr,ro=Je,io=be,no=Ie,ao=Ws,so=We("symbol-to-string-registry");to({target:"Symbol",stat:!0,forced:!ao},{keyFor:function(e){if(!io(e))throw TypeError(no(e)+" is not a symbol");if(ro(so,e))return so[e]}});var oo=p([].slice),lo=na,uo=I,co=k,ho=Ei,fo=p([].push),vo=Dr,go=se,po=h,mo=C,yo=p,Eo=a,ko=I,To=be,So=oo,Ao=function(e){if(uo(e))return e;if(lo(e)){for(var t=e.length,r=[],i=0;i<t;i++){var n=e[i];"string"==typeof n?fo(r,n):"number"!=typeof n&&"Number"!=co(n)&&"String"!=co(n)||fo(r,ho(n))}var a=r.length,s=!0;return function(e,t){if(s)return s=!1,t;if(lo(this))return t;for(var i=0;i<a;i++)if(r[i]===e)return t}}},Lo=Ee,bo=String,Ro=go("JSON","stringify"),Io=yo(/./.exec),Do=yo("".charAt),wo=yo("".charCodeAt),_o=yo("".replace),Po=yo(1..toString),Co=/[\uD800-\uDFFF]/g,xo=/^[\uD800-\uDBFF]$/,Mo=/^[\uDC00-\uDFFF]$/,Oo=!Lo||Eo((function(){var e=go("Symbol")();return"[null]"!=Ro([e])||"{}"!=Ro({a:e})||"{}"!=Ro(Object(e))})),Fo=Eo((function(){return'"\\udf06\\ud834"'!==Ro("\udf06\ud834")||'"\\udead"'!==Ro("\udead")})),No=function(e,t){var r=So(arguments),i=Ao(t);if(ko(i)||void 0!==e&&!To(e))return r[1]=function(e,t){if(ko(i)&&(t=mo(i,this,bo(e),t)),!To(t))return t},po(Ro,null,r)},Uo=function(e,t,r){var i=Do(r,t-1),n=Do(r,t+1);return Io(xo,e)&&!Io(Mo,n)||Io(Mo,e)&&!Io(xo,i)?"\\u"+Po(wo(e,0),16):e};Ro&&vo({target:"JSON",stat:!0,arity:3,forced:Oo||Fo},{stringify:function(e,t,r){var i=So(arguments),n=po(Oo?No:Ro,null,i);return Fo&&"string"==typeof n?_o(n,Co,Uo):n}});var Bo=dn,Go=Xe;Dr({target:"Object",stat:!0,forced:!Ee||a((function(){Bo.f(1)}))},{getOwnPropertySymbols:function(e){var t=Bo.f;return t?t(Go(e)):[]}});var Ko=te.Object.getOwnPropertySymbols,Ho=r(Ko),Vo=a,jo=ge,Yo=dt("species"),Wo=function(e){return jo>=51||!Vo((function(){var t=[];return(t.constructor={})[Yo]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},qo=Na.filter;Dr({target:"Array",proto:!0,forced:!Wo("filter")},{filter:function(e){return qo(this,e,arguments.length>1?arguments[1]:void 0)}});var zo=te,Xo=function(e){return zo[e+"Prototype"]},Qo=Xo("Array").filter,$o=oe,Jo=Qo,Zo=Array.prototype,el=function(e){var t=e.filter;return e===Zo||$o(Zo,e)&&t===Zo.filter?Jo:t},tl=r(el),rl={exports:{}},il=Dr,nl=a,al=$,sl=D.f,ol=w;il({target:"Object",stat:!0,forced:!ol||nl((function(){sl(1)})),sham:!ol},{getOwnPropertyDescriptor:function(e,t){return sl(al(e),t)}});var ll=te.Object,ul=rl.exports=function(e,t){return ll.getOwnPropertyDescriptor(e,t)};ll.getOwnPropertyDescriptor.sham&&(ul.sham=!0);var cl=rl.exports,hl=r(cl),dl=w,fl=na,vl=TypeError,gl=Object.getOwnPropertyDescriptor,pl=dl&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}()?function(e,t){if(fl(e)&&!gl(e,"length").writable)throw vl("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},ml=TypeError,yl=function(e){if(e>9007199254740991)throw ml("Maximum allowed index exceeded");return e},El=Xe,kl=Kr,Tl=pl,Sl=yl;Dr({target:"Array",proto:!0,arity:1,forced:a((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var t=El(this),r=kl(t),i=arguments.length;Sl(r+i);for(var n=0;n<i;n++)t[r]=arguments[n],r++;return Tl(t,r),r}});var Al,Ll,bl,Rl=Xo("Array").push,Il=oe,Dl=Rl,wl=Array.prototype,_l=r((function(e){var t=e.push;return e===wl||Il(wl,e)&&t===wl.push?Dl:t})),Pl={},Cl=w,xl=Je,Ml=Function.prototype,Ol=Cl&&Object.getOwnPropertyDescriptor,Fl=xl(Ml,"name"),Nl={EXISTS:Fl,PROPER:Fl&&"something"===function(){}.name,CONFIGURABLE:Fl&&(!Cl||Cl&&Ol(Ml,"name").configurable)},Ul=!a((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Bl=Je,Gl=I,Kl=Xe,Hl=Ul,Vl=Pi("IE_PROTO"),jl=Object,Yl=jl.prototype,Wl=Hl?jl.getPrototypeOf:function(e){var t=Kl(e);if(Bl(t,Vl))return t[Vl];var r=t.constructor;return Gl(r)&&t instanceof r?r.prototype:t instanceof jl?Yl:null},ql=a,zl=I,Xl=ee,Ql=Yi,$l=Wl,Jl=vn,Zl=dt("iterator"),eu=!1;[].keys&&("next"in(bl=[].keys())?(Ll=$l($l(bl)))!==Object.prototype&&(Al=Ll):eu=!0);var tu=!Xl(Al)||ql((function(){var e={};return Al[Zl].call(e)!==e}));zl((Al=tu?{}:Ql(Al))[Zl])||Jl(Al,Zl,(function(){return this}));var ru={IteratorPrototype:Al,BUGGY_SAFARI_ITERATORS:eu},iu=ru.IteratorPrototype,nu=Yi,au=B,su=Gn,ou=Pl,lu=function(){return this},uu=function(e,t,r,i){var n=t+" Iterator";return e.prototype=nu(iu,{next:au(+!i,r)}),su(e,n,!1,!0),ou[n]=lu,e},cu=p,hu=Pe,du=I,fu=String,vu=TypeError,gu=function(e,t,r){try{return cu(hu(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},pu=rr,mu=function(e){if("object"==typeof e||du(e))return e;throw vu("Can't set "+fu(e)+" as a prototype")},yu=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=gu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return pu(r),mu(i),t?e(r,i):r.__proto__=i,r}}():void 0),Eu=Dr,ku=C,Tu=Nl,Su=uu,Au=Wl,Lu=Gn,bu=vn,Ru=Pl,Iu=ru,Du=Tu.PROPER,wu=Iu.BUGGY_SAFARI_ITERATORS,_u=dt("iterator"),Pu="keys",Cu="values",xu="entries",Mu=function(){return this},Ou=function(e,t,r,i,n,a,s){Su(r,t,i);var o,l,u,c=function(e){if(e===n&&g)return g;if(!wu&&e in f)return f[e];switch(e){case Pu:case Cu:case xu:return function(){return new r(this,e)}}return function(){return new r(this)}},h=t+" Iterator",d=!1,f=e.prototype,v=f[_u]||f["@@iterator"]||n&&f[n],g=!wu&&v||c(n),p="Array"==t&&f.entries||v;if(p&&(o=Au(p.call(new e)))!==Object.prototype&&o.next&&(Lu(o,h,!0,!0),Ru[h]=Mu),Du&&n==Cu&&v&&v.name!==Cu&&(d=!0,g=function(){return ku(v,this)}),n)if(l={values:c(Cu),keys:a?g:c(Pu),entries:c(xu)},s)for(u in l)(wu||d||!(u in f))&&bu(f,u,l[u]);else Eu({target:t,proto:!0,forced:wu||d},l);return s&&f[_u]!==g&&bu(f,_u,g,{name:n}),Ru[t]=g,l},Fu=function(e,t){return{value:e,done:t}},Nu=$,Uu=Pl,Bu=ra;$t.f;var Gu=Ou,Ku=Fu,Hu="Array Iterator",Vu=Bu.set,ju=Bu.getterFor(Hu);Gu(Array,"Array",(function(e,t){Vu(this,{type:Hu,target:Nu(e),index:0,kind:t})}),(function(){var e=ju(this),t=e.target,r=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,Ku(void 0,!0)):Ku("keys"==r?i:"values"==r?t[i]:[i,t[i]],!1)}),"values"),Uu.Arguments=Uu.Array;var Yu={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},Wu=n,qu=pi,zu=pr,Xu=Pl,Qu=dt("toStringTag");for(var $u in Yu){var Ju=Wu[$u],Zu=Ju&&Ju.prototype;Zu&&qu(Zu)!==Qu&&zu(Zu,Qu,$u),Xu[$u]=Xu.Array}var ec=a,tc=function(e,t){var r=[][e];return!!r&&ec((function(){r.call(null,t||function(){return 1},1)}))},rc=Na.forEach,ic=tc("forEach")?[].forEach:function(e){return rc(this,e,arguments.length>1?arguments[1]:void 0)};Dr({target:"Array",proto:!0,forced:[].forEach!=ic},{forEach:ic});var nc=Xo("Array").forEach,ac=pi,sc=Je,oc=oe,lc=nc,uc=Array.prototype,cc={DOMTokenList:!0,NodeList:!0},hc=function(e){var t=e.forEach;return e===uc||oc(uc,e)&&t===uc.forEach||sc(cc,ac(e))?lc:t},dc=r(hc),fc=se,vc=Wi,gc=dn,pc=rr,mc=p([].concat),yc=fc("Reflect","ownKeys")||function(e){var t=vc.f(pc(e)),r=gc.f;return r?mc(t,r(e)):t},Ec=yc,kc=$,Tc=D,Sc=Zi;Dr({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,i=kc(e),n=Tc.f,a=Ec(i),s={},o=0;a.length>o;)void 0!==(r=n(i,t=a[o++]))&&Sc(s,t,r);return s}});var Ac=te.Object.getOwnPropertyDescriptors,Lc=r(Ac),bc={exports:{}},Rc=Dr,Ic=w,Dc=ki.f;Rc({target:"Object",stat:!0,forced:Object.defineProperties!==Dc,sham:!Ic},{defineProperties:Dc});var wc=te.Object,_c=bc.exports=function(e,t){return wc.defineProperties(e,t)};wc.defineProperties.sham&&(_c.sham=!0);var Pc=bc.exports,Cc=r(Pc),xc={exports:{}},Mc=Dr,Oc=w,Fc=$t.f;Mc({target:"Object",stat:!0,forced:Object.defineProperty!==Fc,sham:!Oc},{defineProperty:Fc});var Nc=te.Object,Uc=xc.exports=function(e,t,r){return Nc.defineProperty(e,t,r)};Nc.defineProperty.sham&&(Uc.sham=!0);var Bc=xc.exports,Gc=r(Bc),Kc=Dr,Hc=a,Vc=na,jc=ee,Yc=Xe,Wc=Kr,qc=yl,zc=Zi,Xc=wa,Qc=Wo,$c=ge,Jc=dt("isConcatSpreadable"),Zc=$c>=51||!Hc((function(){var e=[];return e[Jc]=!1,e.concat()[0]!==e})),eh=function(e){if(!jc(e))return!1;var t=e[Jc];return void 0!==t?!!t:Vc(e)};Kc({target:"Array",proto:!0,arity:1,forced:!Zc||!Qc("concat")},{concat:function(e){var t,r,i,n,a,s=Yc(this),o=Xc(s,0),l=0;for(t=-1,i=arguments.length;t<i;t++)if(eh(a=-1===t?s:arguments[t]))for(n=Wc(a),qc(l+n),r=0;r<n;r++,l++)r in a&&zc(o,l,a[r]);else qc(l+1),zc(o,l++,a);return o.length=l,o}}),Rn("asyncIterator"),Rn("hasInstance"),Rn("isConcatSpreadable"),Rn("iterator"),Rn("match"),Rn("matchAll"),Rn("replace"),Rn("search"),Rn("species"),Rn("split");var th=Pn;Rn("toPrimitive"),th();var rh=se,ih=Gn;Rn("toStringTag"),ih(rh("Symbol"),"Symbol"),Rn("unscopables"),Gn(n.JSON,"JSON",!0);var nh=te.Symbol;Rn("dispose");var ah=nh;Rn("asyncDispose");var sh=Dr,oh=p,lh=se("Symbol"),uh=lh.keyFor,ch=oh(lh.prototype.valueOf);sh({target:"Symbol",stat:!0},{isRegistered:function(e){try{return void 0!==uh(ch(e))}catch(t){return!1}}});for(var hh=Dr,dh=We,fh=se,vh=p,gh=be,ph=dt,mh=fh("Symbol"),yh=mh.isWellKnown,Eh=fh("Object","getOwnPropertyNames"),kh=vh(mh.prototype.valueOf),Th=dh("wks"),Sh=0,Ah=Eh(mh),Lh=Ah.length;Sh<Lh;Sh++)try{var bh=Ah[Sh];gh(mh[bh])&&ph(bh)}catch(MM){}hh({target:"Symbol",stat:!0,forced:!0},{isWellKnown:function(e){if(yh&&yh(e))return!0;try{for(var t=kh(e),r=0,i=Eh(Th),n=i.length;r<n;r++)if(Th[i[r]]==t)return!0}catch(MM){}return!1}}),Rn("matcher"),Rn("metadataKey"),Rn("observable"),Rn("metadata"),Rn("patternMatch"),Rn("replaceAll");var Rh=ah,Ih=r(Rh),Dh=p,wh=Cr,_h=Ei,Ph=z,Ch=Dh("".charAt),xh=Dh("".charCodeAt),Mh=Dh("".slice),Oh=function(e){return function(t,r){var i,n,a=_h(Ph(t)),s=wh(r),o=a.length;return s<0||s>=o?e?"":void 0:(i=xh(a,s))<55296||i>56319||s+1===o||(n=xh(a,s+1))<56320||n>57343?e?Ch(a,s):i:e?Mh(a,s,s+2):n-56320+(i-55296<<10)+65536}},Fh={codeAt:Oh(!1),charAt:Oh(!0)},Nh=Fh.charAt,Uh=Ei,Bh=ra,Gh=Ou,Kh=Fu,Hh="String Iterator",Vh=Bh.set,jh=Bh.getterFor(Hh);Gh(String,"String",(function(e){Vh(this,{type:Hh,string:Uh(e),index:0})}),(function(){var e,t=jh(this),r=t.string,i=t.index;return i>=r.length?Kh(void 0,!0):(e=Nh(r,i),t.index+=e.length,Kh(e,!1))}));var Yh=mn.f("iterator"),Wh=r(Yh);function qh(e){return(qh="function"==typeof Ih&&"symbol"==typeof Wh?function(e){return typeof e}:function(e){return e&&"function"==typeof Ih&&e.constructor===Ih&&e!==Ih.prototype?"symbol":typeof e})(e)}var zh=mn.f("toPrimitive"),Xh=r(zh);function Qh(e){var t=function(e,t){if("object"!==qh(e)||null===e)return e;var r=e[Xh];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==qh(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===qh(t)?t:String(t)}function $h(e,t,r){return(t=Qh(t))in e?Gc(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Jh(e,t){var r=oi(e);if(Ho){var i=Ho(e);t&&(i=tl(i).call(i,(function(t){return hl(e,t).enumerable}))),_l(r).apply(r,i)}return r}function Zh(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?dc(r=Jh(Object(n),!0)).call(r,(function(t){$h(e,t,n[t])})):Lc?Cc(e,Lc(n)):dc(i=Jh(Object(n))).call(i,(function(t){Gc(e,t,hl(n,t))}))}return e}var ed=pi,td=Me,rd=Y,id=Pl,nd=dt("iterator"),ad=function(e){if(!rd(e))return td(e,nd)||td(e,"@@iterator")||id[ed(e)]},sd=ad,od=r(sd);Dr({target:"Array",stat:!0},{isArray:na});var ld=te.Array.isArray,ud=r(ld),cd=Dr,hd=na,dd=Sa,fd=ee,vd=Fr,gd=Kr,pd=$,md=Zi,yd=dt,Ed=oo,kd=Wo("slice"),Td=yd("species"),Sd=Array,Ad=Math.max;cd({target:"Array",proto:!0,forced:!kd},{slice:function(e,t){var r,i,n,a=pd(this),s=gd(a),o=vd(e,s),l=vd(void 0===t?s:t,s);if(hd(a)&&(r=a.constructor,(dd(r)&&(r===Sd||hd(r.prototype))||fd(r)&&null===(r=r[Td]))&&(r=void 0),r===Sd||void 0===r))return Ed(a,o,l);for(i=new(void 0===r?Sd:r)(Ad(l-o,0)),n=0;o<l;o++,n++)o in a&&md(i,n,a[o]);return i.length=n,i}});var Ld=Xo("Array").slice,bd=oe,Rd=Ld,Id=Array.prototype,Dd=function(e){var t=e.slice;return e===Id||bd(Id,e)&&t===Id.slice?Rd:t},wd=r(Dd),_d=C,Pd=rr,Cd=Me,xd=function(e,t,r){var i,n;Pd(e);try{if(!(i=Cd(e,"return"))){if("throw"===t)throw r;return r}i=_d(i,e)}catch(MM){n=!0,i=MM}if("throw"===t)throw r;if(n)throw i;return Pd(i),r},Md=rr,Od=xd,Fd=Pl,Nd=dt("iterator"),Ud=Array.prototype,Bd=function(e){return void 0!==e&&(Fd.Array===e||Ud[Nd]===e)},Gd=C,Kd=Pe,Hd=rr,Vd=Ie,jd=ad,Yd=TypeError,Wd=function(e,t){var r=arguments.length<2?jd(e):t;if(Kd(r))return Hd(Gd(r,e));throw Yd(Vd(e)+" is not iterable")},qd=Qt,zd=C,Xd=Xe,Qd=function(e,t,r,i){try{return i?t(Md(r)[0],r[1]):t(r)}catch(MM){Od(e,"throw",MM)}},$d=Bd,Jd=Sa,Zd=Kr,ef=Zi,tf=Wd,rf=ad,nf=Array,af=function(e){var t=Xd(e),r=Jd(this),i=arguments.length,n=i>1?arguments[1]:void 0,a=void 0!==n;a&&(n=qd(n,i>2?arguments[2]:void 0));var s,o,l,u,c,h,d=rf(t),f=0;if(!d||this===nf&&$d(d))for(s=Zd(t),o=r?new this(s):nf(s);s>f;f++)h=a?n(t[f],f):t[f],ef(o,f,h);else for(c=(u=tf(t,d)).next,o=r?new this:[];!(l=zd(c,u)).done;f++)h=a?Qd(u,n,[l.value,f],!0):l.value,ef(o,f,h);return o.length=f,o},sf=dt("iterator"),of=!1;try{var lf=0,uf={next:function(){return{done:!!lf++}},return:function(){of=!0}};uf[sf]=function(){return this},Array.from(uf,(function(){throw 2}))}catch(MM){}var cf=function(e,t){if(!t&&!of)return!1;var r=!1;try{var i={};i[sf]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(MM){}return r},hf=af;Dr({target:"Array",stat:!0,forced:!cf((function(e){Array.from(e)}))},{from:hf});var df=te.Array.from,ff=r(df);function vf(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 gf(e,t){var r;if(e){if("string"==typeof e)return vf(e,t);var i=wd(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?ff(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?vf(e,t):void 0}}function pf(e){return function(e){if(ud(e))return vf(e)}(e)||function(e){if(void 0!==Ih&&null!=od(e)||null!=e["@@iterator"])return ff(e)}(e)||gf(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 mf(e,t){return function(e){if(ud(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==Ih&&od(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)&&(_l(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)||gf(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 yf=Je,Ef=C,kf=ee,Tf=rr,Sf=function(e){return void 0!==e&&(yf(e,"value")||yf(e,"writable"))},Af=D,Lf=Wl;Dr({target:"Reflect",stat:!0},{get:function e(t,r){var i,n,a=arguments.length<3?t:arguments[2];return Tf(t)===a?t[r]:(i=Af.f(t,r))?Sf(i)?i.value:void 0===i.get?void 0:Ef(i.get,a):kf(n=Lf(t))?e(n,r,a):void 0}});var bf=r(te.Reflect.get),Rf=p,If=Pe,Df=ee,wf=Je,_f=oo,Pf=s,Cf=Function,xf=Rf([].concat),Mf=Rf([].join),Of={},Ff=Pf?Cf.bind:function(e){var t=If(this),r=t.prototype,i=_f(arguments,1),n=function(){var r=xf(i,_f(arguments));return this instanceof n?function(e,t,r){if(!wf(Of,t)){for(var i=[],n=0;n<t;n++)i[n]="a["+n+"]";Of[t]=Cf("C,a","return new C("+Mf(i,",")+")")}return Of[t](e,r)}(t,r.length,r):t.apply(e,r)};return Df(r)&&(n.prototype=r),n},Nf=Ff;Dr({target:"Function",proto:!0,forced:Function.bind!==Nf},{bind:Nf});var Uf=Xo("Function").bind,Bf=oe,Gf=Uf,Kf=Function.prototype,Hf=function(e){var t=e.bind;return e===Kf||Bf(Kf,e)&&t===Kf.bind?Gf:t},Vf=r(Hf);Dr({target:"Object",stat:!0},{setPrototypeOf:yu});var jf=r(te.Object.setPrototypeOf),Yf=Xe,Wf=Wl,qf=Ul;Dr({target:"Object",stat:!0,forced:a((function(){Wf(1)})),sham:!qf},{getPrototypeOf:function(e){return Wf(Yf(e))}});var zf=r(te.Object.getPrototypeOf);function Xf(e){var t;return(Xf=jf?Vf(t=zf).call(t):function(e){return e.__proto__||zf(e)})(e)}function Qf(){var e;"undefined"!=typeof Reflect&&bf?Qf=Vf(e=bf).call(e):Qf=function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Xf(e)););return e}(e,t);if(i){var n=hl(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}};return Qf.apply(this,arguments)}function $f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var Jf={exports:{}},Zf=a((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),ev=a,tv=ee,rv=k,iv=Zf,nv=Object.isExtensible,av=ev((function(){nv(1)}))||iv?function(e){return!!tv(e)&&((!iv||"ArrayBuffer"!=rv(e))&&(!nv||nv(e)))}:nv,sv=!a((function(){return Object.isExtensible(Object.preventExtensions({}))})),ov=Dr,lv=p,uv=qr,cv=ee,hv=Je,dv=$t.f,fv=Wi,vv=Xi,gv=av,pv=sv,mv=!1,yv=it("meta"),Ev=0,kv=function(e){dv(e,yv,{value:{objectID:"O"+Ev++,weakData:{}}})},Tv=Jf.exports={enable:function(){Tv.enable=function(){},mv=!0;var e=fv.f,t=lv([].splice),r={};r[yv]=1,e(r).length&&(fv.f=function(r){for(var i=e(r),n=0,a=i.length;n<a;n++)if(i[n]===yv){t(i,n,1);break}return i},ov({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:vv.f}))},fastKey:function(e,t){if(!cv(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!hv(e,yv)){if(!gv(e))return"F";if(!t)return"E";kv(e)}return e[yv].objectID},getWeakData:function(e,t){if(!hv(e,yv)){if(!gv(e))return!0;if(!t)return!1;kv(e)}return e[yv].weakData},onFreeze:function(e){return pv&&mv&&gv(e)&&!hv(e,yv)&&kv(e),e}};uv[yv]=!0;var Sv=Jf.exports,Av=Qt,Lv=C,bv=rr,Rv=Ie,Iv=Bd,Dv=Kr,wv=oe,_v=Wd,Pv=ad,Cv=xd,xv=TypeError,Mv=function(e,t){this.stopped=e,this.result=t},Ov=Mv.prototype,Fv=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=Av(t,c),p=function(e){return i&&Cv(i,"normal",e),new Mv(!0,e)},m=function(e){return h?(bv(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=Pv(e)))throw xv(Rv(e)+" is not iterable");if(Iv(n)){for(a=0,s=Dv(e);s>a;a++)if((o=m(e[a]))&&wv(Ov,o))return o;return new Mv(!1)}i=_v(e,n)}for(l=d?e.next:i.next;!(u=Lv(l,i)).done;){try{o=m(u.value)}catch(MM){Cv(i,"throw",MM)}if("object"==typeof o&&o&&wv(Ov,o))return o}return new Mv(!1)},Nv=oe,Uv=TypeError,Bv=function(e,t){if(Nv(t,e))return e;throw Uv("Incorrect invocation")},Gv=Dr,Kv=n,Hv=Sv,Vv=a,jv=pr,Yv=Fv,Wv=Bv,qv=I,zv=ee,Xv=Gn,Qv=$t.f,$v=Na.forEach,Jv=w,Zv=ra.set,eg=ra.getterFor,tg=function(e,t,r){var i,n=-1!==e.indexOf("Map"),a=-1!==e.indexOf("Weak"),s=n?"set":"add",o=Kv[e],l=o&&o.prototype,u={};if(Jv&&qv(o)&&(a||l.forEach&&!Vv((function(){(new o).entries().next()})))){var c=(i=t((function(t,r){Zv(Wv(t,c),{type:e,collection:new o}),null!=r&&Yv(r,t[s],{that:t,AS_ENTRIES:n})}))).prototype,h=eg(e);$v(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in l)||a&&"clear"==e||jv(c,e,(function(r,i){var n=h(this).collection;if(!t&&a&&!zv(r))return"get"==e&&void 0;var s=n[e](0===r?0:r,i);return t?this:s}))})),a||Qv(c,"size",{configurable:!0,get:function(){return h(this).collection.size}})}else i=r.getConstructor(t,e,n,s),Hv.enable();return Xv(i,e,!1,!0),u[e]=i,Gv({global:!0,forced:!0},u),a||r.setStrong(i,e,n),i},rg=vn,ig=function(e,t,r){for(var i in t)r&&r.unsafe&&e[i]?e[i]=t[i]:rg(e,i,t[i],r);return e},ng=se,ag=pn,sg=w,og=dt("species"),lg=function(e){var t=ng(e);sg&&t&&!t[og]&&ag(t,og,{configurable:!0,get:function(){return this}})},ug=Yi,cg=pn,hg=ig,dg=Qt,fg=Bv,vg=Y,gg=Fv,pg=Ou,mg=Fu,yg=lg,Eg=w,kg=Sv.fastKey,Tg=ra.set,Sg=ra.getterFor,Ag={getConstructor:function(e,t,r,i){var n=e((function(e,n){fg(e,a),Tg(e,{type:t,index:ug(null),first:void 0,last:void 0,size:0}),Eg||(e.size=0),vg(n)||gg(n,e[i],{that:e,AS_ENTRIES:r})})),a=n.prototype,s=Sg(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=kg(t,!0),key:t,value:r,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=o),i&&(i.next=o),Eg?a.size++:e.size++,"F"!==n&&(a.index[n]=o)),e},l=function(e,t){var r,i=s(e),n=kg(t);if("F"!==n)return i.index[n];for(r=i.first;r;r=r.next)if(r.key==t)return r};return hg(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,Eg?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),Eg?r.size--:t.size--}return!!i},forEach:function(e){for(var t,r=s(this),i=dg(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)}}),hg(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)}}),Eg&&cg(a,"size",{configurable:!0,get:function(){return s(this).size}}),n},setStrong:function(e,t,r){var i=t+" Iterator",n=Sg(t),a=Sg(i);pg(e,t,(function(e,t){Tg(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)?mg("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,mg(void 0,!0))}),r?"entries":"values",!r,!0),yg(t)}};tg("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Ag);var Lg=te.Map,bg=Sa,Rg=Ie,Ig=TypeError,Dg=function(e){if(bg(e))return e;throw Ig(Rg(e)+" is not a constructor")},wg=Qt,_g=C,Pg=Pe,Cg=Dg,xg=Y,Mg=Fv,Og=[].push,Fg=function(e){var t,r,i,n,a=arguments.length,s=a>1?arguments[1]:void 0;return Cg(this),(t=void 0!==s)&&Pg(s),xg(e)?new this:(r=[],t?(i=0,n=wg(s,a>2?arguments[2]:void 0),Mg(e,(function(e){_g(Og,r,n(e,i++))}))):Mg(e,Og,{that:r}),new this(r))};Dr({target:"Map",stat:!0,forced:!0},{from:Fg});var Ng=oo,Ug=function(){return new this(Ng(arguments))};Dr({target:"Map",stat:!0,forced:!0},{of:Ug});var Bg=Ie,Gg=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(Bg(e)+" is not a map")},Kg=function(e,t){return 1==t?function(t,r){return t[e](r)}:function(t,r,i){return t[e](r,i)}},Hg=Kg,Vg=se("Map"),jg={Map:Vg,set:Hg("set",2),get:Hg("get",1),has:Hg("has",1),remove:Hg("delete",1),proto:Vg.prototype},Yg=Gg,Wg=jg.remove;Dr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=Yg(this),r=!0,i=0,n=arguments.length;i<n;i++)e=Wg(t,arguments[i]),r=r&&e;return!!r}});var qg=Gg,zg=jg.get,Xg=jg.has,Qg=jg.set;Dr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,i,n=qg(this);return Xg(n,e)?(r=zg(n,e),"update"in t&&(r=t.update(r,e,n),Qg(n,e,r)),r):(i=t.insert(e,n),Qg(n,e,i),i)}});var $g=C,Jg=function(e,t,r){for(var i,n,a=r||e.next;!(i=$g(a,e)).done;)if(void 0!==(n=t(i.value)))return n},Zg=Jg,ep=function(e,t,r){return r?Zg(e.entries(),(function(e){return t(e[1],e[0])})):e.forEach(t)},tp=Qt,rp=Gg,ip=ep;Dr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=rp(this),r=tp(e,arguments.length>1?arguments[1]:void 0);return!1!==ip(t,(function(e,i){if(!r(e,i,t))return!1}),!0)}});var np=Qt,ap=Gg,sp=ep,op=jg.Map,lp=jg.set;Dr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=ap(this),r=np(e,arguments.length>1?arguments[1]:void 0),i=new op;return sp(t,(function(e,n){r(e,n,t)&&lp(i,n,e)})),i}});var up=Qt,cp=Gg,hp=ep;Dr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=cp(this),r=up(e,arguments.length>1?arguments[1]:void 0),i=hp(t,(function(e,i){if(r(e,i,t))return{value:e}}),!0);return i&&i.value}});var dp=Qt,fp=Gg,vp=ep;Dr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=fp(this),r=dp(e,arguments.length>1?arguments[1]:void 0),i=vp(t,(function(e,i){if(r(e,i,t))return{key:i}}),!0);return i&&i.key}});var gp=Dr,pp=C,mp=I,yp=Pe,Ep=Fv,kp=jg.Map,Tp=p([].push);gp({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){var r=new(mp(this)?this:kp);yp(t);var i=yp(r.has),n=yp(r.get),a=yp(r.set);return Ep(e,(function(e){var s=t(e);pp(i,r,s)?Tp(pp(n,r,s),e):pp(a,r,s,[e])})),r}});var Sp=function(e,t){return e===t||e!=e&&t!=t},Ap=Gg,Lp=ep;Dr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===Lp(Ap(this),(function(t){if(Sp(t,e))return!0}),!0)}});var bp=C,Rp=Fv,Ip=I,Dp=Pe,wp=jg.Map;Dr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(Ip(this)?this:wp);Dp(t);var i=Dp(r.set);return Rp(e,(function(e){bp(i,r,t(e),e)})),r}});var _p=Gg,Pp=ep;Dr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=Pp(_p(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var Cp=Qt,xp=Gg,Mp=ep,Op=jg.Map,Fp=jg.set;Dr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=xp(this),r=Cp(e,arguments.length>1?arguments[1]:void 0),i=new Op;return Mp(t,(function(e,n){Fp(i,r(e,n,t),e)})),i}});var Np=Qt,Up=Gg,Bp=ep,Gp=jg.Map,Kp=jg.set;Dr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=Up(this),r=Np(e,arguments.length>1?arguments[1]:void 0),i=new Gp;return Bp(t,(function(e,n){Kp(i,n,r(e,n,t))})),i}});var Hp=Gg,Vp=Fv,jp=jg.set;Dr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=Hp(this),r=arguments.length,i=0;i<r;)Vp(arguments[i++],(function(e,r){jp(t,e,r)}),{AS_ENTRIES:!0});return t}});var Yp=Pe,Wp=Gg,qp=ep,zp=TypeError;Dr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Wp(this),r=arguments.length<2,i=r?void 0:arguments[1];if(Yp(e),qp(t,(function(n,a){r?(r=!1,i=n):i=e(i,n,a,t)})),r)throw zp("Reduce of empty map with no initial value");return i}});var Xp=Qt,Qp=Gg,$p=ep;Dr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=Qp(this),r=Xp(e,arguments.length>1?arguments[1]:void 0);return!0===$p(t,(function(e,i){if(r(e,i,t))return!0}),!0)}});var Jp=Pe,Zp=Gg,em=TypeError,tm=jg.get,rm=jg.has,im=jg.set;Dr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=Zp(this),i=arguments.length;Jp(t);var n=rm(r,e);if(!n&&i<3)throw em("Updating absent value");var a=n?tm(r,e):Jp(i>2?arguments[2]:void 0)(e,r);return im(r,e,t(a,e,r)),r}});var nm=C,am=Pe,sm=I,om=rr,lm=TypeError,um=function(e,t){var r,i=om(this),n=am(i.get),a=am(i.has),s=am(i.set),o=arguments.length>2?arguments[2]:void 0;if(!sm(t)&&!sm(o))throw lm("At least one callback required");return nm(a,i,e)?(r=nm(n,i,e),sm(t)&&(r=t(r),nm(s,i,e,r))):sm(o)&&(r=o(),nm(s,i,e,r)),r};Dr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:um}),Dr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:um});var cm=Lg,hm=r(cm);Dr({target:"Object",stat:!0,sham:!w},{create:Yi});var dm=te.Object,fm=function(e,t){return dm.create(e,t)},vm=r(fm);function gm(e,t){var r;return(gm=jf?Vf(r=jf).call(r):function(e,t){return e.__proto__=t,e})(e,t)}var pm=Dr,mm=Wr.indexOf,ym=tc,Em=A([].indexOf),km=!!Em&&1/Em([1],1,-0)<0;pm({target:"Array",proto:!0,forced:km||!ym("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return km?Em(this,e,t)||0:mm(this,e,t)}});var Tm=Xo("Array").indexOf,Sm=oe,Am=Tm,Lm=Array.prototype,bm=function(e){var t=e.indexOf;return e===Lm||Sm(Lm,e)&&t===Lm.indexOf?Am:t},Rm=r(bm);var Im=Dr,Dm=h,wm=Ff,_m=Dg,Pm=rr,Cm=ee,xm=Yi,Mm=a,Om=se("Reflect","construct"),Fm=Object.prototype,Nm=[].push,Um=Mm((function(){function e(){}return!(Om((function(){}),[],e)instanceof e)})),Bm=!Mm((function(){Om((function(){}))})),Gm=Um||Bm;Im({target:"Reflect",stat:!0,forced:Gm,sham:Gm},{construct:function(e,t){_m(e),Pm(t);var r=arguments.length<3?e:_m(arguments[2]);if(Bm&&!Um)return Om(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 Dm(Nm,i,t),new(Dm(wm,e,i))}var n=r.prototype,a=xm(Cm(n)?n:Fm),s=Dm(e,a,t);return Cm(s)?s:a}});var Km=r(te.Reflect.construct);function Hm(){if("undefined"==typeof Reflect||!Km)return!1;if(Km.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Km(Boolean,[],(function(){}))),!0}catch(e){return!1}}function Vm(e,t,r){var i;Hm()?Vm=Vf(i=Km).call(i):Vm=function(e,t,r){var i=[null];_l(i).apply(i,t);var n=new(Vf(Function).apply(e,i));return r&&gm(n,r.prototype),n};return Vm.apply(null,arguments)}function jm(e){var t="function"==typeof hm?new hm:void 0;return jm=function(e){if(null===e||(r=e,-1===Rm(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 Vm(e,arguments,Xf(this).constructor)}return n.prototype=vm(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),gm(n,e)},jm(e)}function Ym(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=vm(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Gc(e,"prototype",{writable:!1}),t&&gm(e,t)}function Wm(e){var t=Hm();return function(){var r,i=Xf(e);if(t){var n=Xf(this).constructor;r=Km(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"===qh(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return $f(e)}(this,r)}}function qm(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zm(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),Gc(e,Qh(i.key),i)}}function Xm(e,t,r){return t&&zm(e.prototype,t),r&&zm(e,r),Gc(e,"prototype",{writable:!1}),e}var Qm=r(si),$m=r(Ko),Jm=r(el),Zm=r(cl),ey=r(hc),ty=r(Ac),ry=r(Pc),iy=r(Bc),ny=r(Rh),ay=r(Yh),sy=r(ld),oy=r(sd),ly=r(df),uy=r(Dd),cy=r(zh),hy=r(bm),dy=Xo("Array").concat,fy=oe,vy=dy,gy=Array.prototype,py=r((function(e){var t=e.concat;return e===gy||fy(gy,e)&&t===gy.concat?vy:t})),my=Na.some;Dr({target:"Array",proto:!0,forced:!tc("some")},{some:function(e){return my(this,e,arguments.length>1?arguments[1]:void 0)}});var yy=Xo("Array").some,Ey=oe,ky=yy,Ty=Array.prototype,Sy=r((function(e){var t=e.some;return e===Ty||Ey(Ty,e)&&t===Ty.some?ky:t})),Ay=Na.map;Dr({target:"Array",proto:!0,forced:!Wo("map")},{map:function(e){return Ay(this,e,arguments.length>1?arguments[1]:void 0)}});var Ly=Xo("Array").map,by=oe,Ry=Ly,Iy=Array.prototype,Dy=r((function(e){var t=e.map;return e===Iy||by(Iy,e)&&t===Iy.map?Ry:t})),wy=Cr,_y=Ei,Py=z,Cy=RangeError,xy=p,My=Br,Oy=Ei,Fy=z,Ny=xy((function(e){var t=_y(Py(this)),r="",i=wy(e);if(i<0||i==1/0)throw Cy("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r})),Uy=xy("".slice),By=Math.ceil,Gy=function(e){return function(t,r,i){var n,a,s=Oy(Fy(t)),o=My(r),l=s.length,u=void 0===i?" ":Oy(i);return o<=l||""==u?s:((a=Ny(u,By((n=o-l)/u.length))).length>n&&(a=Uy(a,0,n)),e?s+a:a+s)}},Ky={start:Gy(!1),end:Gy(!0)},Hy=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(le),Vy=Ky.start;Dr({target:"String",proto:!0,forced:Hy},{padStart:function(e){return Vy(this,e,arguments.length>1?arguments[1]:void 0)}});var jy,Yy=Xo("String").padStart,Wy=oe,qy=Yy,zy=String.prototype,Xy=r((function(e){var t=e.padStart;return"string"==typeof e||e===zy||Wy(zy,e)&&t===zy.padStart?qy:t})),Qy="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,$y=TypeError,Jy=function(e,t){if(e<t)throw $y("Not enough arguments");return e},Zy=n,eE=h,tE=I,rE=Qy,iE=le,nE=oo,aE=Jy,sE=Zy.Function,oE=/MSIE .\./.test(iE)||rE&&((jy=Zy.Bun.version.split(".")).length<3||0==jy[0]&&(jy[1]<3||3==jy[1]&&0==jy[2])),lE=function(e,t){var r=t?2:1;return oE?function(i,n){var a=aE(arguments.length,1)>r,s=tE(i)?i:sE(i),o=a?nE(arguments,r):[],l=a?function(){eE(s,this,o)}:s;return t?e(l,n):e(l)}:e},uE=Dr,cE=n,hE=lE(cE.setInterval,!0);uE({global:!0,bind:!0,forced:cE.setInterval!==hE},{setInterval:hE});var dE=Dr,fE=n,vE=lE(fE.setTimeout,!0);dE({global:!0,bind:!0,forced:fE.setTimeout!==vE},{setTimeout:vE});var gE=r(te.setInterval),pE=r(Hf),mE=r(te.setTimeout),yE=Ie,EE=TypeError,kE=function(e,t){if(!delete e[t])throw EE("Cannot delete property "+yE(t)+" of "+yE(e))},TE=Dr,SE=Xe,AE=Fr,LE=Cr,bE=Kr,RE=pl,IE=yl,DE=wa,wE=Zi,_E=kE,PE=Wo("splice"),CE=Math.max,xE=Math.min;TE({target:"Array",proto:!0,forced:!PE},{splice:function(e,t){var r,i,n,a,s,o,l=SE(this),u=bE(l),c=AE(e,u),h=arguments.length;for(0===h?r=i=0:1===h?(r=0,i=u-c):(r=h-2,i=xE(CE(LE(t),0),u-c)),IE(u+r-i),n=DE(l,i),a=0;a<i;a++)(s=c+a)in l&&wE(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]:_E(l,o);for(a=u;a>u-i+r;a--)_E(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]:_E(l,o);for(a=0;a<r;a++)l[a+c]=arguments[a+2];return RE(l,u-i+r),n}});var ME=Xo("Array").splice,OE=oe,FE=ME,NE=Array.prototype,UE=r((function(e){var t=e.splice;return e===NE||OE(NE,e)&&t===NE.splice?FE:t})),BE=Na.every;Dr({target:"Array",proto:!0,forced:!tc("every")},{every:function(e){return BE(this,e,arguments.length>1?arguments[1]:void 0)}});var GE=Xo("Array").every,KE=oe,HE=GE,VE=Array.prototype,jE=r((function(e){var t=e.every;return e===VE||KE(VE,e)&&t===VE.every?HE:t})),YE="\t\n\v\f\r \u2028\u2029\ufeff",WE=z,qE=Ei,zE=YE,XE=p("".replace),QE=RegExp("^["+zE+"]+"),$E=RegExp("(^|[^"+zE+"])["+zE+"]+$"),JE=function(e){return function(t){var r=qE(WE(t));return 1&e&&(r=XE(r,QE,"")),2&e&&(r=XE(r,$E,"$1")),r}},ZE={start:JE(1),end:JE(2),trim:JE(3)},ek=n,tk=a,rk=Ei,ik=ZE.trim,nk=YE,ak=p("".charAt),sk=ek.parseFloat,ok=ek.Symbol,lk=ok&&ok.iterator,uk=1/sk(nk+"-0")!=-1/0||lk&&!tk((function(){sk(Object(lk))}))?function(e){var t=ik(rk(e)),r=sk(t);return 0===r&&"-"==ak(t,0)?-0:r}:sk;Dr({global:!0,forced:parseFloat!=uk},{parseFloat:uk});var ck=r(te.parseFloat),hk=Nl.PROPER,dk=a,fk=YE,vk=ZE.trim;Dr({target:"String",proto:!0,forced:function(e){return dk((function(){return!!fk[e]()||"
"!=="
"[e]()||hk&&fk[e].name!==e}))}("trim")},{trim:function(){return vk(this)}});var gk=Xo("String").trim,pk=oe,mk=gk,yk=String.prototype,Ek=r((function(e){var t=e.trim;return"string"==typeof e||e===yk||pk(yk,e)&&t===yk.trim?mk:t})),kk=n,Tk=a,Sk=p,Ak=Ei,Lk=ZE.trim,bk=YE,Rk=kk.parseInt,Ik=kk.Symbol,Dk=Ik&&Ik.iterator,wk=/^[+-]?0x/i,_k=Sk(wk.exec),Pk=8!==Rk(bk+"08")||22!==Rk(bk+"0x16")||Dk&&!Tk((function(){Rk(Object(Dk))}))?function(e,t){var r=Lk(Ak(e));return Rk(r,t>>>0||(_k(wk,r)?16:10))}:Rk;Dr({global:!0,forced:parseInt!=Pk},{parseInt:Pk});var Ck=r(te.parseInt),xk=sn,Mk=Math.floor,Ok=function(e,t){var r=e.length,i=Mk(r/2);return r<8?Fk(e,t):Nk(e,Ok(xk(e,0,i),t),Ok(xk(e,i),t),t)},Fk=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},Nk=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},Uk=Ok,Bk=le.match(/firefox\/(\d+)/i),Gk=!!Bk&&+Bk[1],Kk=/MSIE|Trident/.test(le),Hk=le.match(/AppleWebKit\/(\d+)\./),Vk=!!Hk&&+Hk[1],jk=Dr,Yk=p,Wk=Pe,qk=Xe,zk=Kr,Xk=kE,Qk=Ei,$k=a,Jk=Uk,Zk=tc,eT=Gk,tT=Kk,rT=ge,iT=Vk,nT=[],aT=Yk(nT.sort),sT=Yk(nT.push),oT=$k((function(){nT.sort(void 0)})),lT=$k((function(){nT.sort(null)})),uT=Zk("sort"),cT=!$k((function(){if(rT)return rT<70;if(!(eT&&eT>3)){if(tT)return!0;if(iT)return iT<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++)nT.push({k:t+i,v:r})}for(nT.sort((function(e,t){return t.v-e.v})),i=0;i<nT.length;i++)t=nT[i].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));jk({target:"Array",proto:!0,forced:oT||!lT||!uT||!cT},{sort:function(e){void 0!==e&&Wk(e);var t=qk(this);if(cT)return void 0===e?aT(t):aT(t,e);var r,i,n=[],a=zk(t);for(i=0;i<a;i++)i in t&&sT(n,t[i]);for(Jk(n,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:Qk(t)>Qk(r)?1:-1}}(e)),r=zk(n),i=0;i<r;)t[i]=n[i++];for(;i<a;)Xk(t,i++);return t}});var hT=Xo("Array").sort,dT=oe,fT=hT,vT=Array.prototype,gT=r((function(e){var t=e.sort;return e===vT||dT(vT,e)&&t===vT.sort?fT:t})),pT=n.isFinite;Dr({target:"Number",stat:!0},{isFinite:Number.isFinite||function(e){return"number"==typeof e&&pT(e)}});var mT=r(te.Number.isFinite),yT=ee,ET=Math.floor,kT=Number.isInteger||function(e){return!yT(e)&&isFinite(e)&&ET(e)===e},TT=Dr,ST=kT,AT=Math.abs;TT({target:"Number",stat:!0},{isSafeInteger:function(e){return ST(e)&&AT(e)<=9007199254740991}});var LT=r(te.Number.isSafeInteger);Dr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var bT=r(9007199254740991),RT=w,IT=p,DT=C,wT=a,_T=ii,PT=dn,CT=x,xT=Xe,MT=j,OT=Object.assign,FT=Object.defineProperty,NT=IT([].concat),UT=!OT||wT((function(){if(RT&&1!==OT({b:1},OT(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!=OT({},e)[r]||_T(OT({},t)).join("")!=i}))?function(e,t){for(var r=xT(e),i=arguments.length,n=1,a=PT.f,s=CT.f;i>n;)for(var o,l=MT(arguments[n++]),u=a?NT(_T(l),a(l)):_T(l),c=u.length,h=0;c>h;)o=u[h++],RT&&!DT(s,l,o)||(r[o]=l[o]);return r}:OT,BT=UT;Dr({target:"Object",stat:!0,arity:2,forced:Object.assign!==BT},{assign:BT});var GT=r(te.Object.assign),KT=Pe,HT=Xe,VT=j,jT=Kr,YT=TypeError,WT=function(e){return function(t,r,i,n){KT(r);var a=HT(t),s=VT(a),o=jT(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 YT("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}},qT={left:WT(!1),right:WT(!0)},zT="undefined"!=typeof process&&"process"==k(process),XT=qT.left;Dr({target:"Array",proto:!0,forced:!zT&&ge>79&&ge<83||!tc("reduce")},{reduce:function(e){var t=arguments.length;return XT(this,e,t,t>1?arguments[1]:void 0)}});var QT=Xo("Array").reduce,$T=oe,JT=QT,ZT=Array.prototype,eS=r((function(e){var t=e.reduce;return e===ZT||$T(ZT,e)&&t===ZT.reduce?JT:t})),tS=ee,rS=k,iS=dt("match"),nS=function(e){var t;return tS(e)&&(void 0!==(t=e[iS])?!!t:"RegExp"==rS(e))},aS=TypeError,sS=function(e){if(nS(e))throw aS("The method doesn't accept regular expressions");return e},oS=dt("match"),lS=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[oS]=!1,"/./"[e](t)}catch(i){}}return!1},uS=Dr,cS=A;D.f;var hS=Br,dS=Ei,fS=sS,vS=z,gS=lS,pS=cS("".startsWith),mS=cS("".slice),yS=Math.min;uS({target:"String",proto:!0,forced:!gS("startsWith")},{startsWith:function(e){var t=dS(vS(this));fS(e);var r=hS(yS(arguments.length>1?arguments[1]:void 0,t.length)),i=dS(e);return pS?pS(t,i,r):mS(t,r,r+i.length)===i}});var ES=Xo("String").startsWith,kS=oe,TS=ES,SS=String.prototype,AS=r((function(e){var t=e.startsWith;return"string"==typeof e||e===SS||kS(SS,e)&&t===SS.startsWith?TS:t})),LS=Je,bS=yc,RS=D,IS=$t,DS=ee,wS=pr,_S=Error,PS=p("".replace),CS=String(_S("zxcasd").stack),xS=/\n\s*at [^:]*:[^\n]*/,MS=xS.test(CS),OS=B,FS=!a((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",OS(1,7)),7!==e.stack)})),NS=pr,US=function(e,t){if(MS&&"string"==typeof e&&!_S.prepareStackTrace)for(;t--;)e=PS(e,xS,"");return e},BS=FS,GS=Error.captureStackTrace,KS=Ei,HS=Dr,VS=oe,jS=Wl,YS=yu,WS=function(e,t,r){for(var i=bS(t),n=IS.f,a=RS.f,s=0;s<i.length;s++){var o=i[s];LS(e,o)||r&&LS(r,o)||n(e,o,a(t,o))}},qS=Yi,zS=pr,XS=B,QS=function(e,t){DS(t)&&"cause"in t&&wS(e,"cause",t.cause)},$S=function(e,t,r,i){BS&&(GS?GS(e,t):NS(e,"stack",US(r,i)))},JS=Fv,ZS=function(e,t){return void 0===e?arguments.length<2?"":t:KS(e)},eA=dt("toStringTag"),tA=Error,rA=[].push,iA=function(e,t){var r,i=VS(nA,this);YS?r=YS(tA(),i?jS(this):nA):(r=i?this:qS(nA),zS(r,eA,"Error")),void 0!==t&&zS(r,"message",ZS(t)),$S(r,iA,r.stack,1),arguments.length>2&&QS(r,arguments[2]);var n=[];return JS(e,rA,{that:n}),zS(r,"errors",n),r};YS?YS(iA,tA):WS(iA,tA,{name:!0});var nA=iA.prototype=qS(tA.prototype,{constructor:XS(1,iA),message:XS(1,""),name:XS(1,"AggregateError")});HS({global:!0,constructor:!0,arity:2},{AggregateError:iA});var aA,sA,oA,lA,uA=rr,cA=Dg,hA=Y,dA=dt("species"),fA=function(e,t){var r,i=uA(e).constructor;return void 0===i||hA(r=uA(i)[dA])?t:cA(r)},vA=/(?:ipad|iphone|ipod).*applewebkit/i.test(le),gA=n,pA=h,mA=Qt,yA=I,EA=Je,kA=a,TA=Di,SA=oo,AA=Rt,LA=Jy,bA=vA,RA=zT,IA=gA.setImmediate,DA=gA.clearImmediate,wA=gA.process,_A=gA.Dispatch,PA=gA.Function,CA=gA.MessageChannel,xA=gA.String,MA=0,OA={},FA="onreadystatechange";kA((function(){aA=gA.location}));var NA=function(e){if(EA(OA,e)){var t=OA[e];delete OA[e],t()}},UA=function(e){return function(){NA(e)}},BA=function(e){NA(e.data)},GA=function(e){gA.postMessage(xA(e),aA.protocol+"//"+aA.host)};IA&&DA||(IA=function(e){LA(arguments.length,1);var t=yA(e)?e:PA(e),r=SA(arguments,1);return OA[++MA]=function(){pA(t,void 0,r)},sA(MA),MA},DA=function(e){delete OA[e]},RA?sA=function(e){wA.nextTick(UA(e))}:_A&&_A.now?sA=function(e){_A.now(UA(e))}:CA&&!bA?(lA=(oA=new CA).port2,oA.port1.onmessage=BA,sA=mA(lA.postMessage,lA)):gA.addEventListener&&yA(gA.postMessage)&&!gA.importScripts&&aA&&"file:"!==aA.protocol&&!kA(GA)?(sA=GA,gA.addEventListener("message",BA,!1)):sA=FA in AA("script")?function(e){TA.appendChild(AA("script"))[FA]=function(){TA.removeChild(this),NA(e)}}:function(e){setTimeout(UA(e),0)});var KA={set:IA,clear:DA},HA=function(){this.head=null,this.tail=null};HA.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 VA,jA,YA,WA,qA,zA=HA,XA=/ipad|iphone|ipod/i.test(le)&&"undefined"!=typeof Pebble,QA=/web0s(?!.*chrome)/i.test(le),$A=n,JA=Qt,ZA=D.f,eL=KA.set,tL=zA,rL=vA,iL=XA,nL=QA,aL=zT,sL=$A.MutationObserver||$A.WebKitMutationObserver,oL=$A.document,lL=$A.process,uL=$A.Promise,cL=ZA($A,"queueMicrotask"),hL=cL&&cL.value;if(!hL){var dL=new tL,fL=function(){var e,t;for(aL&&(e=lL.domain)&&e.exit();t=dL.get();)try{t()}catch(MM){throw dL.head&&VA(),MM}e&&e.enter()};rL||aL||nL||!sL||!oL?!iL&&uL&&uL.resolve?((WA=uL.resolve(void 0)).constructor=uL,qA=JA(WA.then,WA),VA=function(){qA(fL)}):aL?VA=function(){lL.nextTick(fL)}:(eL=JA(eL,$A),VA=function(){eL(fL)}):(jA=!0,YA=oL.createTextNode(""),new sL(fL).observe(YA,{characterData:!0}),VA=function(){YA.data=jA=!jA}),hL=function(e){dL.head||VA(),dL.add(e)}}var vL=hL,gL=function(e){try{return{error:!1,value:e()}}catch(MM){return{error:!0,value:MM}}},pL=n.Promise,mL="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,yL=!mL&&!zT&&"object"==typeof window&&"object"==typeof document,EL=n,kL=pL,TL=I,SL=Wt,AL=la,LL=dt,bL=yL,RL=mL,IL=ge,DL=kL&&kL.prototype,wL=LL("species"),_L=!1,PL=TL(EL.PromiseRejectionEvent),CL={CONSTRUCTOR:SL("Promise",(function(){var e=AL(kL),t=e!==String(kL);if(!t&&66===IL)return!0;if(!DL.catch||!DL.finally)return!0;if(!IL||IL<51||!/native code/.test(e)){var r=new kL((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[wL]=i,!(_L=r.then((function(){}))instanceof i))return!0}return!t&&(bL||RL)&&!PL})),REJECTION_EVENT:PL,SUBCLASSING:_L},xL={},ML=Pe,OL=TypeError,FL=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw OL("Bad Promise constructor");t=e,r=i})),this.resolve=ML(t),this.reject=ML(r)};xL.f=function(e){return new FL(e)};var NL,UL,BL=Dr,GL=zT,KL=n,HL=C,VL=vn,jL=Gn,YL=lg,WL=Pe,qL=I,zL=ee,XL=Bv,QL=fA,$L=KA.set,JL=vL,ZL=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(MM){}},eb=gL,tb=zA,rb=ra,ib=pL,nb=CL,ab=xL,sb="Promise",ob=nb.CONSTRUCTOR,lb=nb.REJECTION_EVENT,ub=rb.getterFor(sb),cb=rb.set,hb=ib&&ib.prototype,db=ib,fb=hb,vb=KL.TypeError,gb=KL.document,pb=KL.process,mb=ab.f,yb=mb,Eb=!!(gb&&gb.createEvent&&KL.dispatchEvent),kb="unhandledrejection",Tb=function(e){var t;return!(!zL(e)||!qL(t=e.then))&&t},Sb=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&&Ib(t),t.rejection=1),!0===o?r=a:(c&&c.enter(),r=o(a),c&&(c.exit(),n=!0)),r===e.promise?u(vb("Promise-chain cycle")):(i=Tb(r))?HL(i,r,l,u):l(r)):u(a)}catch(MM){c&&!n&&c.exit(),u(MM)}},Ab=function(e,t){e.notified||(e.notified=!0,JL((function(){for(var r,i=e.reactions;r=i.get();)Sb(r,e);e.notified=!1,t&&!e.rejection&&bb(e)})))},Lb=function(e,t,r){var i,n;Eb?((i=gb.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),KL.dispatchEvent(i)):i={promise:t,reason:r},!lb&&(n=KL["on"+e])?n(i):e===kb&&ZL("Unhandled promise rejection",r)},bb=function(e){HL($L,KL,(function(){var t,r=e.facade,i=e.value;if(Rb(e)&&(t=eb((function(){GL?pb.emit("unhandledRejection",i,r):Lb(kb,r,i)})),e.rejection=GL||Rb(e)?2:1,t.error))throw t.value}))},Rb=function(e){return 1!==e.rejection&&!e.parent},Ib=function(e){HL($L,KL,(function(){var t=e.facade;GL?pb.emit("rejectionHandled",t):Lb("rejectionhandled",t,e.value)}))},Db=function(e,t,r){return function(i){e(t,i,r)}},wb=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Ab(e,!0))},_b=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw vb("Promise can't be resolved itself");var i=Tb(t);i?JL((function(){var r={done:!1};try{HL(i,t,Db(_b,r,e),Db(wb,r,e))}catch(MM){wb(r,MM,e)}})):(e.value=t,e.state=1,Ab(e,!1))}catch(MM){wb({done:!1},MM,e)}}};ob&&(fb=(db=function(e){XL(this,fb),WL(e),HL(NL,this);var t=ub(this);try{e(Db(_b,t),Db(wb,t))}catch(MM){wb(t,MM)}}).prototype,(NL=function(e){cb(this,{type:sb,done:!1,notified:!1,parent:!1,reactions:new tb,rejection:!1,state:0,value:void 0})}).prototype=VL(fb,"then",(function(e,t){var r=ub(this),i=mb(QL(this,db));return r.parent=!0,i.ok=!qL(e)||e,i.fail=qL(t)&&t,i.domain=GL?pb.domain:void 0,0==r.state?r.reactions.add(i):JL((function(){Sb(i,r)})),i.promise})),UL=function(){var e=new NL,t=ub(e);this.promise=e,this.resolve=Db(_b,t),this.reject=Db(wb,t)},ab.f=mb=function(e){return e===db||undefined===e?new UL(e):yb(e)}),BL({global:!0,constructor:!0,wrap:!0,forced:ob},{Promise:db}),jL(db,sb,!1,!0),YL(sb);var Pb=pL,Cb=CL.CONSTRUCTOR||!cf((function(e){Pb.all(e).then(void 0,(function(){}))})),xb=C,Mb=Pe,Ob=xL,Fb=gL,Nb=Fv;Dr({target:"Promise",stat:!0,forced:Cb},{all:function(e){var t=this,r=Ob.f(t),i=r.resolve,n=r.reject,a=Fb((function(){var r=Mb(t.resolve),a=[],s=0,o=1;Nb(e,(function(e){var l=s++,u=!1;o++,xb(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 Ub=Dr,Bb=CL.CONSTRUCTOR;pL&&pL.prototype,Ub({target:"Promise",proto:!0,forced:Bb,real:!0},{catch:function(e){return this.then(void 0,e)}});var Gb=C,Kb=Pe,Hb=xL,Vb=gL,jb=Fv;Dr({target:"Promise",stat:!0,forced:Cb},{race:function(e){var t=this,r=Hb.f(t),i=r.reject,n=Vb((function(){var n=Kb(t.resolve);jb(e,(function(e){Gb(n,t,e).then(r.resolve,i)}))}));return n.error&&i(n.value),r.promise}});var Yb=C,Wb=xL;Dr({target:"Promise",stat:!0,forced:CL.CONSTRUCTOR},{reject:function(e){var t=Wb.f(this);return Yb(t.reject,void 0,e),t.promise}});var qb=rr,zb=ee,Xb=xL,Qb=function(e,t){if(qb(e),zb(t)&&t.constructor===e)return t;var r=Xb.f(e);return(0,r.resolve)(t),r.promise},$b=Dr,Jb=pL,Zb=CL.CONSTRUCTOR,eR=Qb,tR=se("Promise"),rR=!Zb;$b({target:"Promise",stat:!0,forced:true},{resolve:function(e){return eR(rR&&this===tR?Jb:this,e)}});var iR=C,nR=Pe,aR=xL,sR=gL,oR=Fv;Dr({target:"Promise",stat:!0,forced:Cb},{allSettled:function(e){var t=this,r=aR.f(t),i=r.resolve,n=r.reject,a=sR((function(){var r=nR(t.resolve),n=[],a=0,s=1;oR(e,(function(e){var o=a++,l=!1;s++,iR(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 lR=C,uR=Pe,cR=se,hR=xL,dR=gL,fR=Fv,vR="No one promise resolved";Dr({target:"Promise",stat:!0,forced:Cb},{any:function(e){var t=this,r=cR("AggregateError"),i=hR.f(t),n=i.resolve,a=i.reject,s=dR((function(){var i=uR(t.resolve),s=[],o=0,l=1,u=!1;fR(e,(function(e){var c=o++,h=!1;l++,lR(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,vR)))}))})),--l||a(new r(s,vR))}));return s.error&&a(s.value),i.promise}});var gR=Dr,pR=pL,mR=a,yR=se,ER=I,kR=fA,TR=Qb,SR=pR&&pR.prototype;gR({target:"Promise",proto:!0,real:!0,forced:!!pR&&mR((function(){SR.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=kR(this,yR("Promise")),r=ER(e);return this.then(r?function(r){return TR(t,e()).then((function(){return r}))}:e,r?function(r){return TR(t,e()).then((function(){throw r}))}:e)}});var AR=te.Promise,LR=xL,bR=gL;Dr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=LR.f(this),r=bR(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var RR=r(AR),IR=a,DR=dt("iterator"),wR=!IR((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[DR]||"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})),_R=p,PR=2147483647,CR=/[^\0-\u007E]/,xR=/[.\u3002\uFF0E\uFF61]/g,MR="Overflow: input needs wider integers to process",OR=RangeError,FR=_R(xR.exec),NR=Math.floor,UR=String.fromCharCode,BR=_R("".charCodeAt),GR=_R([].join),KR=_R([].push),HR=_R("".replace),VR=_R("".split),jR=_R("".toLowerCase),YR=function(e){return e+22+75*(e<26)},WR=function(e,t,r){var i=0;for(e=r?NR(e/700):e>>1,e+=NR(e/t);e>455;)e=NR(e/35),i+=36;return NR(i+36*e/(e+38))},qR=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var n=BR(e,r++);if(n>=55296&&n<=56319&&r<i){var a=BR(e,r++);56320==(64512&a)?KR(t,((1023&n)<<10)+(1023&a)+65536):(KR(t,n),r--)}else KR(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&&KR(t,UR(i));var l=t.length,u=l;for(l&&KR(t,"-");u<n;){var c=PR;for(r=0;r<e.length;r++)(i=e[r])>=a&&i<c&&(c=i);var h=u+1;if(c-a>NR((PR-s)/h))throw OR(MR);for(s+=(c-a)*h,a=c,r=0;r<e.length;r++){if((i=e[r])<a&&++s>PR)throw OR(MR);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;KR(t,UR(YR(v+g%p))),d=NR(g/p),f+=36}KR(t,UR(YR(d))),o=WR(s,h,u==l),s=0,u++}}s++,a++}return GR(t,"")},zR=Dr,XR=n,QR=C,$R=p,JR=w,ZR=wR,eI=vn,tI=pn,rI=ig,iI=Gn,nI=uu,aI=ra,sI=Bv,oI=I,lI=Je,uI=Qt,cI=pi,hI=rr,dI=ee,fI=Ei,vI=Yi,gI=B,pI=Wd,mI=ad,yI=Jy,EI=Uk,kI=dt("iterator"),TI="URLSearchParams",SI=TI+"Iterator",AI=aI.set,LI=aI.getterFor(TI),bI=aI.getterFor(SI),RI=Object.getOwnPropertyDescriptor,II=function(e){if(!JR)return XR[e];var t=RI(XR,e);return t&&t.value},DI=II("fetch"),wI=II("Request"),_I=II("Headers"),PI=wI&&wI.prototype,CI=_I&&_I.prototype,xI=XR.RegExp,MI=XR.TypeError,OI=XR.decodeURIComponent,FI=XR.encodeURIComponent,NI=$R("".charAt),UI=$R([].join),BI=$R([].push),GI=$R("".replace),KI=$R([].shift),HI=$R([].splice),VI=$R("".split),jI=$R("".slice),YI=/\+/g,WI=Array(4),qI=function(e){return WI[e-1]||(WI[e-1]=xI("((?:%[\\da-f]{2}){"+e+"})","gi"))},zI=function(e){try{return OI(e)}catch(MM){return e}},XI=function(e){var t=GI(e,YI," "),r=4;try{return OI(t)}catch(MM){for(;r;)t=GI(t,qI(r--),zI);return t}},QI=/[!'()~]|%20/g,$I={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},JI=function(e){return $I[e]},ZI=function(e){return GI(FI(e),QI,JI)},eD=nI((function(e,t){AI(this,{type:SI,iterator:pI(LI(e).entries),kind:t})}),"Iterator",(function(){var e=bI(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),tD=function(e){this.entries=[],this.url=null,void 0!==e&&(dI(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===NI(e,0)?jI(e,1):e:fI(e)))};tD.prototype={type:TI,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,a,s,o,l=mI(e);if(l)for(r=(t=pI(e,l)).next;!(i=QR(r,t)).done;){if(a=(n=pI(hI(i.value))).next,(s=QR(a,n)).done||(o=QR(a,n)).done||!QR(a,n).done)throw MI("Expected sequence with length 2");BI(this.entries,{key:fI(s.value),value:fI(o.value)})}else for(var u in e)lI(e,u)&&BI(this.entries,{key:u,value:fI(e[u])})},parseQuery:function(e){if(e)for(var t,r,i=VI(e,"&"),n=0;n<i.length;)(t=i[n++]).length&&(r=VI(t,"="),BI(this.entries,{key:XI(KI(r)),value:XI(UI(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],BI(r,ZI(e.key)+"="+ZI(e.value));return UI(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var rD=function(){sI(this,iD);var e=AI(this,new tD(arguments.length>0?arguments[0]:void 0));JR||(this.length=e.entries.length)},iD=rD.prototype;if(rI(iD,{append:function(e,t){yI(arguments.length,2);var r=LI(this);BI(r.entries,{key:fI(e),value:fI(t)}),JR||this.length++,r.updateURL()},delete:function(e){yI(arguments.length,1);for(var t=LI(this),r=t.entries,i=fI(e),n=0;n<r.length;)r[n].key===i?HI(r,n,1):n++;JR||(this.length=r.length),t.updateURL()},get:function(e){yI(arguments.length,1);for(var t=LI(this).entries,r=fI(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){yI(arguments.length,1);for(var t=LI(this).entries,r=fI(e),i=[],n=0;n<t.length;n++)t[n].key===r&&BI(i,t[n].value);return i},has:function(e){yI(arguments.length,1);for(var t=LI(this).entries,r=fI(e),i=0;i<t.length;)if(t[i++].key===r)return!0;return!1},set:function(e,t){yI(arguments.length,1);for(var r,i=LI(this),n=i.entries,a=!1,s=fI(e),o=fI(t),l=0;l<n.length;l++)(r=n[l]).key===s&&(a?HI(n,l--,1):(a=!0,r.value=o));a||BI(n,{key:s,value:o}),JR||(this.length=n.length),i.updateURL()},sort:function(){var e=LI(this);EI(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=LI(this).entries,i=uI(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 eD(this,"keys")},values:function(){return new eD(this,"values")},entries:function(){return new eD(this,"entries")}},{enumerable:!0}),eI(iD,kI,iD.entries,{name:"entries"}),eI(iD,"toString",(function(){return LI(this).serialize()}),{enumerable:!0}),JR&&tI(iD,"size",{get:function(){return LI(this).entries.length},configurable:!0,enumerable:!0}),iI(rD,TI),zR({global:!0,constructor:!0,forced:!ZR},{URLSearchParams:rD}),!ZR&&oI(_I)){var nD=$R(CI.has),aD=$R(CI.set),sD=function(e){if(dI(e)){var t,r=e.body;if(cI(r)===TI)return t=e.headers?new _I(e.headers):new _I,nD(t,"content-type")||aD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),vI(e,{body:gI(0,fI(r)),headers:gI(0,t)})}return e};if(oI(DI)&&zR({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return DI(e,arguments.length>1?sD(arguments[1]):{})}}),oI(wI)){var oD=function(e){return sI(this,PI),new wI(e,arguments.length>1?sD(arguments[1]):{})};PI.constructor=oD,oD.prototype=PI,zR({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:oD})}}var lD,uD=Dr,cD=w,hD=wR,dD=n,fD=Qt,vD=p,gD=vn,pD=pn,mD=Bv,yD=Je,ED=UT,kD=af,TD=sn,SD=Fh.codeAt,AD=function(e){var t,r,i=[],n=VR(HR(jR(e),xR,"."),".");for(t=0;t<n.length;t++)r=n[t],KR(i,FR(CR,r)?"xn--"+qR(r):r);return GR(i,".")},LD=Ei,bD=Gn,RD=Jy,ID={URLSearchParams:rD,getState:LI},DD=ra,wD=DD.set,_D=DD.getterFor("URL"),PD=ID.URLSearchParams,CD=ID.getState,xD=dD.URL,MD=dD.TypeError,OD=dD.parseInt,FD=Math.floor,ND=Math.pow,UD=vD("".charAt),BD=vD(/./.exec),GD=vD([].join),KD=vD(1..toString),HD=vD([].pop),VD=vD([].push),jD=vD("".replace),YD=vD([].shift),WD=vD("".split),qD=vD("".slice),zD=vD("".toLowerCase),XD=vD([].unshift),QD="Invalid scheme",$D="Invalid host",JD="Invalid port",ZD=/[a-z]/i,ew=/[\d+-.a-z]/i,tw=/\d/,rw=/^0x/i,iw=/^[0-7]+$/,nw=/^\d+$/,aw=/^[\da-f]+$/i,sw=/[\0\t\n\r #%/:<>?@[\\\]^|]/,ow=/[\0\t\n\r #/:<>?@[\\\]^|]/,lw=/^[\u0000-\u0020]+/,uw=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,cw=/[\t\n\r]/g,hw=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)XD(t,e%256),e=FD(e/256);return GD(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+=KD(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},dw={},fw=ED({},dw,{" ":1,'"':1,"<":1,">":1,"`":1}),vw=ED({},fw,{"#":1,"?":1,"{":1,"}":1}),gw=ED({},vw,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),pw=function(e,t){var r=SD(e,0);return r>32&&r<127&&!yD(t,e)?e:encodeURIComponent(e)},mw={ftp:21,file:null,http:80,https:443,ws:80,wss:443},yw=function(e,t){var r;return 2==e.length&&BD(ZD,UD(e,0))&&(":"==(r=UD(e,1))||!t&&"|"==r)},Ew=function(e){var t;return e.length>1&&yw(qD(e,0,2))&&(2==e.length||"/"===(t=UD(e,2))||"\\"===t||"?"===t||"#"===t)},kw=function(e){return"."===e||"%2e"===zD(e)},Tw={},Sw={},Aw={},Lw={},bw={},Rw={},Iw={},Dw={},ww={},_w={},Pw={},Cw={},xw={},Mw={},Ow={},Fw={},Nw={},Uw={},Bw={},Gw={},Kw={},Hw=function(e,t,r){var i,n,a,s=LD(e);if(t){if(n=this.parse(s))throw MD(n);this.searchParams=null}else{if(void 0!==r&&(i=new Hw(r,!0)),n=this.parse(s,null,i))throw MD(n);(a=CD(new PD)).bindURL(this),this.searchParams=a}};Hw.prototype={type:"URL",parse:function(e,t,r){var i,n,a,s,o,l=this,u=t||Tw,c=0,h="",d=!1,f=!1,v=!1;for(e=LD(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=jD(e,lw,""),e=jD(e,uw,"$1")),e=jD(e,cw,""),i=kD(e);c<=i.length;){switch(n=i[c],u){case Tw:if(!n||!BD(ZD,n)){if(t)return QD;u=Aw;continue}h+=zD(n),u=Sw;break;case Sw:if(n&&(BD(ew,n)||"+"==n||"-"==n||"."==n))h+=zD(n);else{if(":"!=n){if(t)return QD;h="",u=Aw,c=0;continue}if(t&&(l.isSpecial()!=yD(mw,h)||"file"==h&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=h,t)return void(l.isSpecial()&&mw[l.scheme]==l.port&&(l.port=null));h="","file"==l.scheme?u=Mw:l.isSpecial()&&r&&r.scheme==l.scheme?u=Lw:l.isSpecial()?u=Dw:"/"==i[c+1]?(u=bw,c++):(l.cannotBeABaseURL=!0,VD(l.path,""),u=Bw)}break;case Aw:if(!r||r.cannotBeABaseURL&&"#"!=n)return QD;if(r.cannotBeABaseURL&&"#"==n){l.scheme=r.scheme,l.path=TD(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,u=Kw;break}u="file"==r.scheme?Mw:Rw;continue;case Lw:if("/"!=n||"/"!=i[c+1]){u=Rw;continue}u=ww,c++;break;case bw:if("/"==n){u=_w;break}u=Uw;continue;case Rw:if(l.scheme=r.scheme,n==lD)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=TD(r.path),l.query=r.query;else if("/"==n||"\\"==n&&l.isSpecial())u=Iw;else if("?"==n)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=TD(r.path),l.query="",u=Gw;else{if("#"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=TD(r.path),l.path.length--,u=Uw;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=TD(r.path),l.query=r.query,l.fragment="",u=Kw}break;case Iw:if(!l.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,u=Uw;continue}u=_w}else u=ww;break;case Dw:if(u=ww,"/"!=n||"/"!=UD(h,c+1))continue;c++;break;case ww:if("/"!=n&&"\\"!=n){u=_w;continue}break;case _w:if("@"==n){d&&(h="%40"+h),d=!0,a=kD(h);for(var g=0;g<a.length;g++){var p=a[g];if(":"!=p||v){var m=pw(p,gw);v?l.password+=m:l.username+=m}else v=!0}h=""}else if(n==lD||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(d&&""==h)return"Invalid authority";c-=kD(h).length+1,h="",u=Pw}else h+=n;break;case Pw:case Cw:if(t&&"file"==l.scheme){u=Fw;continue}if(":"!=n||f){if(n==lD||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(l.isSpecial()&&""==h)return $D;if(t&&""==h&&(l.includesCredentials()||null!==l.port))return;if(s=l.parseHost(h))return s;if(h="",u=Nw,t)return;continue}"["==n?f=!0:"]"==n&&(f=!1),h+=n}else{if(""==h)return $D;if(s=l.parseHost(h))return s;if(h="",u=xw,t==Cw)return}break;case xw:if(!BD(tw,n)){if(n==lD||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()||t){if(""!=h){var y=OD(h,10);if(y>65535)return JD;l.port=l.isSpecial()&&y===mw[l.scheme]?null:y,h=""}if(t)return;u=Nw;continue}return JD}h+=n;break;case Mw:if(l.scheme="file","/"==n||"\\"==n)u=Ow;else{if(!r||"file"!=r.scheme){u=Uw;continue}if(n==lD)l.host=r.host,l.path=TD(r.path),l.query=r.query;else if("?"==n)l.host=r.host,l.path=TD(r.path),l.query="",u=Gw;else{if("#"!=n){Ew(GD(TD(i,c),""))||(l.host=r.host,l.path=TD(r.path),l.shortenPath()),u=Uw;continue}l.host=r.host,l.path=TD(r.path),l.query=r.query,l.fragment="",u=Kw}}break;case Ow:if("/"==n||"\\"==n){u=Fw;break}r&&"file"==r.scheme&&!Ew(GD(TD(i,c),""))&&(yw(r.path[0],!0)?VD(l.path,r.path[0]):l.host=r.host),u=Uw;continue;case Fw:if(n==lD||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&yw(h))u=Uw;else if(""==h){if(l.host="",t)return;u=Nw}else{if(s=l.parseHost(h))return s;if("localhost"==l.host&&(l.host=""),t)return;h="",u=Nw}continue}h+=n;break;case Nw:if(l.isSpecial()){if(u=Uw,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=lD&&(u=Uw,"/"!=n))continue}else l.fragment="",u=Kw;else l.query="",u=Gw;break;case Uw:if(n==lD||"/"==n||"\\"==n&&l.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(o=zD(o=h))||"%2e."===o||".%2e"===o||"%2e%2e"===o?(l.shortenPath(),"/"==n||"\\"==n&&l.isSpecial()||VD(l.path,"")):kw(h)?"/"==n||"\\"==n&&l.isSpecial()||VD(l.path,""):("file"==l.scheme&&!l.path.length&&yw(h)&&(l.host&&(l.host=""),h=UD(h,0)+":"),VD(l.path,h)),h="","file"==l.scheme&&(n==lD||"?"==n||"#"==n))for(;l.path.length>1&&""===l.path[0];)YD(l.path);"?"==n?(l.query="",u=Gw):"#"==n&&(l.fragment="",u=Kw)}else h+=pw(n,vw);break;case Bw:"?"==n?(l.query="",u=Gw):"#"==n?(l.fragment="",u=Kw):n!=lD&&(l.path[0]+=pw(n,dw));break;case Gw:t||"#"!=n?n!=lD&&("'"==n&&l.isSpecial()?l.query+="%27":l.query+="#"==n?"%23":pw(n,dw)):(l.fragment="",u=Kw);break;case Kw:n!=lD&&(l.fragment+=pw(n,fw))}c++}},parseHost:function(e){var t,r,i;if("["==UD(e,0)){if("]"!=UD(e,e.length-1))return $D;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 UD(e,h)};if(":"==d()){if(":"!=UD(e,1))return;h+=2,c=++u}for(;d();){if(8==u)return;if(":"!=d()){for(t=r=0;r<4&&BD(aw,d());)t=16*t+OD(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(!BD(tw,d()))return;for(;BD(tw,d());){if(a=OD(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}(qD(e,1,-1)),!t)return $D;this.host=t}else if(this.isSpecial()){if(e=AD(e),BD(sw,e))return $D;if(t=function(e){var t,r,i,n,a,s,o,l=WD(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"==UD(n,0)&&(a=BD(rw,n)?16:8,n=qD(n,8==a?1:2)),""===n)s=0;else{if(!BD(10==a?nw:8==a?iw:aw,n))return e;s=OD(n,a)}VD(r,s)}for(i=0;i<t;i++)if(s=r[i],i==t-1){if(s>=ND(256,5-t))return null}else if(s>255)return null;for(o=HD(r),i=0;i<r.length;i++)o+=r[i]*ND(256,3-i);return o}(e),null===t)return $D;this.host=t}else{if(BD(ow,e))return $D;for(t="",r=kD(e),i=0;i<r.length;i++)t+=pw(r[i],dw);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return yD(mw,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&yw(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+=hw(n),null!==a&&(u+=":"+a)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?s[0]:s.length?"/"+GD(s,"/"):"",null!==o&&(u+="?"+o),null!==l&&(u+="#"+l),u},setHref:function(e){var t=this.parse(e);if(t)throw MD(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new Vw(e.path[0]).origin}catch(MM){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+hw(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(LD(e)+":",Tw)},getUsername:function(){return this.username},setUsername:function(e){var t=kD(LD(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=pw(t[r],gw)}},getPassword:function(){return this.password},setPassword:function(e){var t=kD(LD(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=pw(t[r],gw)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?hw(e):hw(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Pw)},getHostname:function(){var e=this.host;return null===e?"":hw(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Cw)},getPort:function(){var e=this.port;return null===e?"":LD(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=LD(e))?this.port=null:this.parse(e,xw))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+GD(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Nw))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=LD(e))?this.query=null:("?"==UD(e,0)&&(e=qD(e,1)),this.query="",this.parse(e,Gw)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=LD(e))?("#"==UD(e,0)&&(e=qD(e,1)),this.fragment="",this.parse(e,Kw)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Vw=function(e){var t=mD(this,jw),r=RD(arguments.length,1)>1?arguments[1]:void 0,i=wD(t,new Hw(e,!1,r));cD||(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())},jw=Vw.prototype,Yw=function(e,t){return{get:function(){return _D(this)[e]()},set:t&&function(e){return _D(this)[t](e)},configurable:!0,enumerable:!0}};if(cD&&(pD(jw,"href",Yw("serialize","setHref")),pD(jw,"origin",Yw("getOrigin")),pD(jw,"protocol",Yw("getProtocol","setProtocol")),pD(jw,"username",Yw("getUsername","setUsername")),pD(jw,"password",Yw("getPassword","setPassword")),pD(jw,"host",Yw("getHost","setHost")),pD(jw,"hostname",Yw("getHostname","setHostname")),pD(jw,"port",Yw("getPort","setPort")),pD(jw,"pathname",Yw("getPathname","setPathname")),pD(jw,"search",Yw("getSearch","setSearch")),pD(jw,"searchParams",Yw("getSearchParams")),pD(jw,"hash",Yw("getHash","setHash"))),gD(jw,"toJSON",(function(){return _D(this).serialize()}),{enumerable:!0}),gD(jw,"toString",(function(){return _D(this).serialize()}),{enumerable:!0}),xD){var Ww=xD.createObjectURL,qw=xD.revokeObjectURL;Ww&&gD(Vw,"createObjectURL",fD(Ww,xD)),qw&&gD(Vw,"revokeObjectURL",fD(qw,xD))}bD(Vw,"URL"),uD({global:!0,constructor:!0,forced:!hD,sham:!cD},{URL:Vw});var zw=Dr,Xw=a,Qw=Jy,$w=Ei,Jw=wR,Zw=se("URL");zw({target:"URL",stat:!0,forced:!(Jw&&Xw((function(){Zw.canParse()})))},{canParse:function(e){var t=Qw(arguments.length,1),r=$w(e),i=t<2||void 0===arguments[1]?void 0:$w(arguments[1]);try{return!!new Zw(r,i)}catch(MM){return!1}}});var e_=r(te.URL),t_=r(fm),r_=h,i_=$,n_=Cr,a_=Kr,s_=tc,o_=Math.min,l_=[].lastIndexOf,u_=!!l_&&1/[1].lastIndexOf(1,-0)<0,c_=s_("lastIndexOf"),h_=u_||!c_?function(e){if(u_)return r_(l_,this,arguments)||0;var t=i_(this),r=a_(t),i=r-1;for(arguments.length>1&&(i=o_(i,n_(arguments[1]))),i<0&&(i=r+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:l_;Dr({target:"Array",proto:!0,forced:h_!==[].lastIndexOf},{lastIndexOf:h_});var d_=Xo("Array").lastIndexOf,f_=oe,v_=d_,g_=Array.prototype,p_=r((function(e){var t=e.lastIndexOf;return e===g_||f_(g_,e)&&t===g_.lastIndexOf?v_:t})),m_=Dr,y_=na,E_=p([].reverse),k_=[1,2];m_({target:"Array",proto:!0,forced:String(k_)===String(k_.reverse())},{reverse:function(){return y_(this)&&(this.length=this.length),E_(this)}});var T_=Xo("Array").reverse,S_=oe,A_=T_,L_=Array.prototype,b_=r((function(e){var t=e.reverse;return e===L_||S_(L_,e)&&t===L_.reverse?A_:t})),R_=Dr,I_=Date,D_=p(I_.prototype.getTime);R_({target:"Date",stat:!0},{now:function(){return D_(new I_)}});var w_=r(te.Date.now),__=te,P_=h;__.JSON||(__.JSON={stringify:JSON.stringify});var C_=function(e,t,r){return P_(__.JSON.stringify,null,arguments)},x_=r(C_),M_=rr,O_=C,F_=Je,N_=oe,U_=function(){var e=M_(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},B_=RegExp.prototype,G_=oe,K_=function(e){var t=e.flags;return void 0!==t||"flags"in B_||F_(e,"flags")||!N_(B_,e)?t:O_(U_,e)},H_=RegExp.prototype,V_=r((function(e){return e===H_||G_(H_,e)?K_(e):e.flags}));Dr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var j_=r(Math.pow(2,-52)),Y_=r(cm);tg("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Ag);var W_=te.Set,q_=Ie,z_=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(q_(e)+" is not a set")},X_=Kg,Q_=se("Set"),$_=Q_.prototype,J_={Set:Q_,add:X_("add",1),has:X_("has",1),remove:X_("delete",1),proto:$_},Z_=Jg,eP=function(e,t,r){return r?Z_(e.keys(),t):e.forEach(t)},tP=eP,rP=J_.Set,iP=J_.add,nP=function(e){var t=new rP;return tP(e,(function(e){iP(t,e)})),t},aP=function(e){return e.size},sP=Pe,oP=rr,lP=C,uP=Cr,cP=TypeError,hP=Math.max,dP=function(e,t,r,i){this.set=e,this.size=t,this.has=r,this.keys=i};dP.prototype={getIterator:function(){return oP(lP(this.keys,this.set))},includes:function(e){return lP(this.has,this.set,e)}};var fP=function(e){oP(e);var t=+e.size;if(t!=t)throw cP("Invalid size");return new dP(e,hP(uP(t),0),sP(e.has),sP(e.keys))},vP=z_,gP=nP,pP=aP,mP=fP,yP=eP,EP=Jg,kP=J_.has,TP=J_.remove,SP=function(e){var t=vP(this),r=mP(e),i=gP(t);return pP(t)<=r.size?yP(t,(function(e){r.includes(e)&&TP(i,e)})):EP(r.getIterator(),(function(e){kP(t,e)&&TP(i,e)})),i},AP=function(){return!1},LP=SP;Dr({target:"Set",proto:!0,real:!0,forced:!AP()},{difference:LP});var bP=z_,RP=aP,IP=fP,DP=eP,wP=Jg,_P=J_.Set,PP=J_.add,CP=J_.has,xP=function(e){var t=bP(this),r=IP(e),i=new _P;return RP(t)>r.size?wP(r.getIterator(),(function(e){CP(t,e)&&PP(i,e)})):DP(t,(function(e){r.includes(e)&&PP(i,e)})),i},MP=xP;Dr({target:"Set",proto:!0,real:!0,forced:!AP()},{intersection:MP});var OP=z_,FP=J_.has,NP=aP,UP=fP,BP=eP,GP=Jg,KP=xd,HP=function(e){var t=OP(this),r=UP(e);if(NP(t)<=r.size)return!1!==BP(t,(function(e){if(r.includes(e))return!1}),!0);var i=r.getIterator();return!1!==GP(i,(function(e){if(FP(t,e))return KP(i,"normal",!1)}))},VP=HP;Dr({target:"Set",proto:!0,real:!0,forced:!AP()},{isDisjointFrom:VP});var jP=z_,YP=aP,WP=eP,qP=fP,zP=function(e){var t=jP(this),r=qP(e);return!(YP(t)>r.size)&&!1!==WP(t,(function(e){if(!r.includes(e))return!1}),!0)},XP=zP;Dr({target:"Set",proto:!0,real:!0,forced:!AP()},{isSubsetOf:XP});var QP=z_,$P=J_.has,JP=aP,ZP=fP,eC=Jg,tC=xd,rC=function(e){var t=QP(this),r=ZP(e);if(JP(t)<r.size)return!1;var i=r.getIterator();return!1!==eC(i,(function(e){if(!$P(t,e))return tC(i,"normal",!1)}))},iC=rC;Dr({target:"Set",proto:!0,real:!0,forced:!AP()},{isSupersetOf:iC});var nC=z_,aC=nP,sC=fP,oC=Jg,lC=J_.add,uC=J_.has,cC=J_.remove,hC=function(e){var t=nC(this),r=sC(e).getIterator(),i=aC(t);return oC(r,(function(e){uC(t,e)?cC(i,e):lC(i,e)})),i},dC=hC;Dr({target:"Set",proto:!0,real:!0,forced:!AP()},{symmetricDifference:dC});var fC=z_,vC=J_.add,gC=nP,pC=fP,mC=Jg,yC=function(e){var t=fC(this),r=pC(e).getIterator(),i=gC(t);return mC(r,(function(e){vC(i,e)})),i},EC=yC;Dr({target:"Set",proto:!0,real:!0,forced:!AP()},{union:EC});var kC=W_;Dr({target:"Set",stat:!0,forced:!0},{from:Fg}),Dr({target:"Set",stat:!0,forced:!0},{of:Ug});var TC=z_,SC=J_.add;Dr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=TC(this),t=0,r=arguments.length;t<r;t++)SC(e,arguments[t]);return e}});var AC=z_,LC=J_.remove;Dr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=AC(this),r=!0,i=0,n=arguments.length;i<n;i++)e=LC(t,arguments[i]),r=r&&e;return!!r}});var bC=Qt,RC=z_,IC=eP;Dr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=RC(this),r=bC(e,arguments.length>1?arguments[1]:void 0);return!1!==IC(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var DC=pi,wC=Je,_C=Y,PC=Pl,CC=dt("iterator"),xC=Object,MC=I,OC=function(e){if(_C(e))return!1;var t=xC(e);return void 0!==t[CC]||"@@iterator"in t||wC(PC,DC(t))},FC=ee,NC=se("Set"),UC=function(e){return function(e){return FC(e)&&"number"==typeof e.size&&MC(e.has)&&MC(e.keys)}(e)?e:OC(e)?new NC(e):e},BC=C,GC=UC,KC=SP;Dr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return BC(KC,this,GC(e))}});var HC=Qt,VC=z_,jC=eP,YC=J_.Set,WC=J_.add;Dr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=VC(this),r=HC(e,arguments.length>1?arguments[1]:void 0),i=new YC;return jC(t,(function(e){r(e,e,t)&&WC(i,e)})),i}});var qC=Qt,zC=z_,XC=eP;Dr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=zC(this),r=qC(e,arguments.length>1?arguments[1]:void 0),i=XC(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return i&&i.value}});var QC=C,$C=UC,JC=xP;Dr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return QC(JC,this,$C(e))}});var ZC=C,ex=UC,tx=HP;Dr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return ZC(tx,this,ex(e))}});var rx=C,ix=UC,nx=zP;Dr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return rx(nx,this,ix(e))}});var ax=C,sx=UC,ox=rC;Dr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return ax(ox,this,sx(e))}});var lx=Dr,ux=p,cx=z_,hx=eP,dx=Ei,fx=ux([].join),vx=ux([].push);lx({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=cx(this),r=void 0===e?",":dx(e),i=[];return hx(t,(function(e){vx(i,e)})),fx(i,r)}});var gx=Qt,px=z_,mx=eP,yx=J_.Set,Ex=J_.add;Dr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=px(this),r=gx(e,arguments.length>1?arguments[1]:void 0),i=new yx;return mx(t,(function(e){Ex(i,r(e,e,t))})),i}});var kx=Pe,Tx=z_,Sx=eP,Ax=TypeError;Dr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Tx(this),r=arguments.length<2,i=r?void 0:arguments[1];if(kx(e),Sx(t,(function(n){r?(r=!1,i=n):i=e(i,n,n,t)})),r)throw Ax("Reduce of empty set with no initial value");return i}});var Lx=Qt,bx=z_,Rx=eP;Dr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=bx(this),r=Lx(e,arguments.length>1?arguments[1]:void 0);return!0===Rx(t,(function(e){if(r(e,e,t))return!0}),!0)}});var Ix=C,Dx=UC,wx=hC;Dr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return Ix(wx,this,Dx(e))}});var _x=C,Px=UC,Cx=yC;Dr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return _x(Cx,this,Px(e))}});var xx=r(kC),Mx=Wr.includes;Dr({target:"Array",proto:!0,forced:a((function(){return!Array(1).includes()}))},{includes:function(e){return Mx(this,e,arguments.length>1?arguments[1]:void 0)}});var Ox=Xo("Array").includes,Fx=Dr,Nx=sS,Ux=z,Bx=Ei,Gx=lS,Kx=p("".indexOf);Fx({target:"String",proto:!0,forced:!Gx("includes")},{includes:function(e){return!!~Kx(Bx(Ux(this)),Bx(Nx(e)),arguments.length>1?arguments[1]:void 0)}});var Hx=Xo("String").includes,Vx=oe,jx=Ox,Yx=Hx,Wx=Array.prototype,qx=String.prototype,zx=r((function(e){var t=e.includes;return e===Wx||Vx(Wx,e)&&t===Wx.includes?jx:"string"==typeof e||e===qx||Vx(qx,e)&&t===qx.includes?Yx:t}));Dr({target:"Number",stat:!0},{isInteger:kT});var Xx=r(te.Number.isInteger),Qx=w,$x=p,Jx=ii,Zx=$,eM=$x(x.f),tM=$x([].push),rM=function(e){return function(t){for(var r,i=Zx(t),n=Jx(i),a=n.length,s=0,o=[];a>s;)r=n[s++],Qx&&!eM(i,r)||tM(o,e?[r,i[r]]:i[r]);return o}},iM={entries:rM(!0),values:rM(!1)}.entries;Dr({target:"Object",stat:!0},{entries:function(e){return iM(e)}});var nM=r(te.Object.entries),aM=Xo("Array").entries,sM=pi,oM=Je,lM=oe,uM=aM,cM=Array.prototype,hM={DOMTokenList:!0,NodeList:!0},dM=r((function(e){var t=e.entries;return e===cM||lM(cM,e)&&t===cM.entries||oM(hM,sM(e))?uM:t})),fM=Dr,vM=Na.find,gM="find",pM=!0;gM in[]&&Array(1)[gM]((function(){pM=!1})),fM({target:"Array",proto:!0,forced:pM},{find:function(e){return vM(this,e,arguments.length>1?arguments[1]:void 0)}});var mM=Xo("Array").find,yM=oe,EM=mM,kM=Array.prototype,TM=r((function(e){var t=e.find;return e===kM||yM(kM,e)&&t===kM.find?EM:t})),SM=Xo("Array").values,AM=pi,LM=Je,bM=oe,RM=SM,IM=Array.prototype,DM={DOMTokenList:!0,NodeList:!0},wM=r((function(e){var t=e.values;return e===IM||bM(IM,e)&&t===IM.values||LM(DM,AM(e))?RM:t})),_M=r(mn.f("toStringTag")),PM={exports:{}};(function(e){var t,r,i;function n(e,t){var r=Qm(e);if($m){var i=$m(e);t&&(i=Jm(i).call(i,(function(t){return Zm(e,t).enumerable}))),r.push.apply(r,i)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r,i,a=null!=arguments[t]?arguments[t]:{};t%2?ey(r=n(Object(a),!0)).call(r,(function(t){c(e,t,a[t])})):ty?ry(e,ty(a)):ey(i=n(Object(a))).call(i,(function(t){iy(e,t,Zm(a,t))}))}return e}function s(e){return(s="function"==typeof ny&&"symbol"==qh(ay)?function(e){return qh(e)}:function(e){return e&&"function"==typeof ny&&e.constructor===ny&&e!==ny.prototype?"symbol":qh(e)})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(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),iy(e,f(i.key),i)}}function u(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),iy(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=f(t))in e?iy(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e){return function(e){if(sy(e))return d(e)}(e)||function(e){if(void 0!==ny&&null!=oy(e)||null!=e["@@iterator"])return ly(e)}(e)||function(e,t,r){if(e){if("string"==typeof e)return d(e,t);var i=uy(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?ly(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?d(e,t):void 0}}(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 d(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 f(e){var t=function(e,t){if("object"!=qh(e)||null===e)return e;var r=e[cy];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=qh(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==qh(t)?t:String(t)}var v="undefined"!=typeof window&&window.location&&hy(t=window.location.href).call(t,"xgplayerdebugger=1")>-1,g={info:"color: #525252; background-color: #90ee90;",error:"color: #525252; background-color: red;",warn:"color: #525252; background-color: yellow; "},p="%c[xgplayer]",m={config:{debug:v?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,py(t=[p,g.info,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,py(t=[p,g.warn,e]).call(t,n))},logError:function(e){var t;if(!(this.config.debug<1)){for(var r,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];(t=console)[i].apply(t,py(r=[p,g.error,e]).call(r,a))}}},y=function(){function e(t){o(this,e),this.bufferedList=t}return u(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}(),E={};function k(e,t){for(var r=0,i=t.length;r<i;r++)if(hy(e).call(e,t[r])>-1)return!0;return!1}function T(e,t,r){for(var i,n,a=arguments.length,s=new Array(a>3?a-3:0),o=3;o<a;o++)s[o-3]=arguments[o];var l=t.call.apply(t,py(i=[e]).call(i,s));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,py(t=[e]).call(t,n))})):r.call.apply(r,py(n=[e]).call(n,s)))}function S(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),pE(r=function(){var r,n=arguments,a=this;if(i.pre)try{var s,o;(o=i.pre).call.apply(o,py(s=[this]).call(s,uy(Array.prototype).call(arguments)))}catch(p){var l,u;throw p.message=py(l=py(u="[pluginName: ".concat(this.pluginName,":")).call(u,e,":pre error] >> ")).call(l,p.message),p}if(this.__hooks&&this.__hooks[e])try{var c,d,f=R(this,e,t);f?f.then?f.then((function(e){var r;!1!==e&&T.apply(void 0,py(r=[a,t,i.next]).call(r,h(n)))})).catch((function(e){throw e})):T.apply(void 0,py(c=[this,t,i.next]).call(c,uy(Array.prototype).call(arguments))):void 0===f&&T.apply(void 0,py(d=[this,t,i.next]).call(d,uy(Array.prototype).call(arguments)))}catch(p){var v,g;throw p.message=py(v=py(g="[pluginName: ".concat(this.pluginName,":")).call(g,e,"] >> ")).call(v,p.message),p}else T.apply(void 0,py(r=[this,t,i.next]).call(r,uy(Array.prototype).call(arguments)))}).call(r,this)}function A(e,t){var r=this.__hooks;if(!r||!sy(r[e]))return-1;for(var i=r[e],n=0;n<i.length;n++)if(i[n]===t)return n;return-1}function L(e,t){var r=this.__hooks;if(r)return r.hasOwnProperty(e)?(sy(r[e])||(r[e]=[]),-1===A.call(this,e,t)&&r[e].push(t),!0):(console.warn("has no supported hook which name [".concat(e,"]")),!1)}function b(e,t){var r=this.__hooks;if(r){if(sy(r[e])){var i=r[e],n=A.call(this,e,t);-1!==n&&UE(i).call(i,n,1)}delete r[e]}}function R(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];if(e.__hooks&&sy(e.__hooks[t])){var o,l=e.__hooks[t],u=-1,c=function e(t,r,i){for(var n,a,s,o=arguments.length,c=new Array(o>3?o-3:0),h=3;h<o;h++)c[h-3]=arguments[h];if(u++,0===l.length||u===l.length)return i.call.apply(i,py(n=[t,t]).call(n,c));var d=l[u],f=d.call.apply(d,py(a=[t,t]).call(a,c));return f&&f.then?f.then((function(n){var a;return!1===n?null:e.apply(void 0,py(a=[t,r,i]).call(a,c))})).catch((function(e){console.warn("[runHooks]".concat(r," reject"),e.message)})):!1!==f?e.apply(void 0,py(s=[t,r,i]).call(s,c)):void 0};return c.apply(void 0,py(o=[e,t,r]).call(o,a))}return r.call.apply(r,py(i=[e,e]).call(i,a))}function I(e,t){var r;m.logError(py(r="[".concat(e,"] event or callback cant be undefined or null when call ")).call(r,t))}E.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,ey(e=Qm(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},E.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,n=document.createElement("div");n.innerHTML=e;var a=n.children;return n=null,a.length>0?(a=a[0],r&&E.addClass(a,r),t&&ey(i=Qm(t)).call(i,(function(e){a.setAttribute(e,t[e])})),a):null}catch(s){return m.logError("util.createDomFromHtml",s),null}},E.hasClass=function(e,t){if(!e||!t)return!1;try{return Sy(Array.prototype).call(e.classList,(function(e){return e===t}))}catch(i){var r=e.className&&"object"===s(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},E.addClass=function(e,t){if(e&&t)try{var r;ey(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.add(t)}))}catch(i){E.hasClass(e,t)||(e.className&&"object"===s(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},E.removeClass=function(e,t){if(e&&t)try{var r;ey(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.remove(t)}))}catch(n){var i;E.hasClass(e,t)&&ey(i=t.split(/\s+/g)).call(i,(function(t){var r=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===s(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")}))}},E.toggleClass=function(e,t){var r;e&&ey(r=t.split(/\s+/g)).call(r,(function(t){E.hasClass(e,t)?E.removeClass(e,t):E.addClass(e,t)}))},E.classNames=function(){for(var e=arguments,t=[],r=function(r){var i;"String"===E.typeOf(e[r])?t.push(e[r]):"Object"===E.typeOf(e[r])&&Dy(i=Qm(e[r])).call(i,(function(i){e[r][i]&&t.push(i)}))},i=0;i<arguments.length;i++)r(i);return t.join(" ")},E.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){m.logError("util.findDom",i),0===hy(r).call(r,"#")&&(e=t.getElementById(uy(r).call(r,1)))}return e},E.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},E.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},E.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=Xy(E).call(E,Math.floor(e/3600),2,0),r=Xy(E).call(E,Math.floor((e-3600*t)/60),2,0),i=Xy(E).call(E,Math.floor(e-3600*t-60*r),2,0);return("00"===t?[r,i]:[t,r,i]).join(":")},E.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},E.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},E.deepCopy=function(e,t){var r;if("Object"===E.typeOf(t)&&"Object"===E.typeOf(e))return ey(r=Qm(t)).call(r,(function(r){var i;"Object"!==E.typeOf(t[r])||t[r]instanceof Node?"Array"===E.typeOf(t[r])?e[r]="Array"===E.typeOf(e[r])?py(i=e[r]).call(i,t[r]):t[r]:e[r]=t[r]:void 0===e[r]||void 0===e[r]?e[r]=t[r]:E.deepCopy(e[r],t[r])})),e},E.deepMerge=function(e,t){var r;return Dy(r=Qm(t)).call(r,(function(r){var i;"Array"===E.typeOf(t[r])&&"Array"===E.typeOf(e[r])?"Array"===E.typeOf(e[r])&&(i=e[r]).push.apply(i,h(t[r])):E.typeOf(e[r])!==E.typeOf(t[r])||null===e[r]||"Object"!==E.typeOf(e[r])||t[r]instanceof window.Node?null!==t[r]&&(e[r]=t[r]):E.deepMerge(e[r],t[r])})),e},E.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},E.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return ey(Array.prototype).call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},E.setInterval=function(e,t,r,i){e._interval[t]||(e._interval[t]=gE(pE(r).call(r,e),i))},E.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},E.setTimeout=function(e,t,r){e._timers||(e._timers=[]);var i=mE((function(){t(),E.clearTimeout(e,i)}),r);return e._timers.push(i),i},E.clearTimeout=function(e,t){var r=e._timers;if("Array"===E.typeOf(r)){for(var i=0;i<r.length;i++)if(r[i]===t){UE(r).call(r,i,1),clearTimeout(t);break}}else clearTimeout(t)},E.clearAllTimers=function(e){var t=e._timers;"Array"===E.typeOf(t)&&(Dy(t).call(t,(function(e){clearTimeout(e)})),e._timerIds=[])},E.createImgBtn=function(e,t,r,i){var n,a,s,o,l,u,c,h,d,f,v,g,p=E.createDom("xg-".concat(e),"",{},"xgplayer-".concat(e,"-img"));return p.style.backgroundImage='url("'.concat(t,'")'),r&&i&&(jE(n=["px","rem","em","pt","dp","vw","vh","vm","%"]).call(n,(function(e){var t,n;return!(hy(r).call(r,e)>-1&&hy(i).call(i,e)>-1&&(f=ck(Ek(t=uy(r).call(r,0,hy(r).call(r,e))).call(t)),v=ck(Ek(n=uy(i).call(i,0,hy(i).call(i,e))).call(n)),g=e,1))})),p.style.width=py(a="".concat(f)).call(a,g),p.style.height=py(s="".concat(v)).call(s,g),p.style.backgroundSize=py(o=py(l=py(u="".concat(f)).call(u,g," ")).call(l,v)).call(o,g),p.style.margin="start"===e?py(c=py(h=py(d="-".concat(v/2)).call(d,g," auto auto -")).call(h,f/2)).call(c,g):"auto 5px auto 5px"),p},E.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(Ck(e,16))})),py(r="rgba(".concat(i.join(","),", ")).call(r,t,")")):"rgba(255, 255, 255, 0.1)"},E.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},E.checkIsFunction=function(e){return e&&"function"==typeof e},E.checkIsObject=function(e){return null!==e&&"object"===s(e)},E.hide=function(e){e.style.display="none"},E.show=function(e,t){e.style.display=t||"block"},E.isUndefined=function(e){if(null==e)return!0},E.isNotNull=function(e){return!(null==e)},E.setStyleFromCsstext=function(e,t){var r,i;t&&("String"===E.typeOf(t)?Dy(r=t.replace(/\s+/g,"").split(";")).call(r,(function(t){if(t){var r=t.split(":");r.length>1&&(e.style[r[0]]=r[1])}})):Dy(i=Qm(t)).call(i,(function(r){e.style[r]=t[r]})))},E.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 Dy(n).call(n,(function(e){if(e){var t=e.split(":");t.length>1&&(k(t[0],r)?a[t[0]]=t[1]:s[t[0]]=t[1])}})),e.setAttribute("style",""),Dy(t=Qm(s)).call(t,(function(t){e.style[t]=s[t]})),a},E.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var r=t.replace(/\s+/g,"").split(";"),i={};return Dy(r).call(r,(function(e){if(e){var t=e.split(":");t.length>1&&(i[t[0]]=t[1])}})),i},E.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}},E.stopPropagation=function(e){e&&e.stopPropagation()},E.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},E.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},E.checkTouchSupport=function(){return"ontouchstart"in window},E.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)});gT(r).call(r,(function(e,t){return e.start-t.start||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 y(n)},E.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}},E.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},E.getHostFromUrl=function(e){if("String"!==E.typeOf(e))return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r},E.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},E.isMSE=function(e){return e.media&&(e=e.media),!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},E.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},E.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=Ck(e)}catch(r){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=Ck(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)}))},E.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},E.adjustTimeByDuration=function(e,t,r){return t&&e&&(e>t||r&&e<t)?t:e},E.createPositionBar=function(e,t){var r=E.createDom("xg-bar","",{"data-index":-1},e);return t.appendChild(r),r},E.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:py(e="".concat(t.x||0,"%, ")).call(e,t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")},n=Qm(i);return ey(n).call(n,(function(e){var t,n=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),a=py(t="".concat(e,"(")).call(t,i[e],")");n.test(r)?(n.lastIndex=-1,r=r.replace(n,a)):r+="".concat(a," ")})),r},E.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},E.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},E.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:E.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},E.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 D,w=function(){function e(t){o(this,e),E.checkIsFunction(this.beforeCreate)&&this.beforeCreate(t),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&Dy(t).call(t,(function(t){e.__hooks[t]=null})),iy(e,"hooks",{get:function(){var t;return e.__hooks&&Dy(t=Qm(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 u(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=E.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)):sy(e)&&ey(e).call(e,(function(e){r.__events[e]=t,r.player.on(e,t)})):I(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)):sy(e)&&ey(e).call(e,(function(i){r.__onceEvents[i]=t,r.player.once(e,t)})):I(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)):sy(e)&&ey(e).call(e,(function(i){delete r.__events[e],r.player.off(i,t)})):I(this.pluginName,"plugin.off(event, callback)")}},{key:"offAll",value:function(){var e,t=this;ey(e=["__events","__onceEvents"]).call(e,(function(e){var r;ey(r=Qm(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;if(this.player){for(var r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];(t=this.player).emit.apply(t,py(r=[e]).call(r,n))}}},{key:"emitUserAction",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var i=a(a({},r),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,i)}}},{key:"hook",value:function(e,t){var r;return S.call.apply(S,py(r=[this]).call(r,uy(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 L.call.apply(L,py(r=[this]).call(r,uy(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 b.call.apply(b,py(r=[this]).call(r,uy(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(),E.clearAllTimers(this),E.checkIsFunction(this.destroy)&&this.destroy(),Dy(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)&&iy(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]&&iy(e,r,{configurable:!0,value:t[r]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}(),_=mT||function(e){return"number"==typeof e&&isFinite(e)},P=LT||function(e){return"number"==typeof e&&Math.abs(e)<=C},C=bT||9007199254740991,x=((D={}).NETWORK_ERROR="networkError",D.MEDIA_ERROR="mediaError",D.KEY_SYSTEM_ERROR="keySystemError",D.MUX_ERROR="muxError",D.OTHER_ERROR="otherError",D),M=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}({}),O=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}({}),F="manifest",N="level",U="audioTrack",B="subtitleTrack",G="main",K="audio",H="subtitle",V=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;qm(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=r,this.totalWeight_=i}return Xm(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}(),j=function(){function e(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;qm(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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new V(t),this.fast_=new V(r),this.defaultTTFB_=n,this.ttfb_=new V(t)}return Xm(e,[{key:"update",value:function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new V(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new V(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new V(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 Y(e,t,r){return i=function(e,t){if("object"!=qh(e)||!e)return e;var r=e[cy];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=qh(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==qh(i)?i:i+"")in e?iy(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e;var i}function W(){var e;return W=GT?pE(e=GT).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},W.apply(null,arguments)}function q(e,t){var r=Qm(e);if($m){var i=$m(e);t&&(i=Jm(i).call(i,(function(t){return Zm(e,t).enumerable}))),r.push.apply(r,i)}return r}function z(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?ey(r=q(Object(n),!0)).call(r,(function(t){Y(e,t,n[t])})):ty?ry(e,ty(n)):ey(i=q(Object(n))).call(i,(function(t){iy(e,t,Zm(n,t))}))}return e}var X=Xm((function e(t,r){var i,n,a,s,o;qm(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var l="[".concat(t,"]:");this.trace=Q,this.debug=pE(i=r.debug).call(i,null,l),this.log=pE(n=r.log).call(n,null,l),this.warn=pE(a=r.warn).call(a,null,l),this.info=pE(s=r.info).call(s,null,l),this.error=pE(o=r.error).call(o,null,l)})),Q=function(){},$={trace:Q,debug:Q,log:Q,warn:Q,info:Q,error:Q};function J(){return W({},$)}function Z(e,t,r){var i,n,a,s,o;return t[e]?pE(i=t[e]).call(i,t):(n=e,a=r,(o=self.console[n])?pE(o).call(o,self.console,py(s="".concat(a?"["+a+"] ":"","[")).call(s,n,"] >")):Q)}var ee=J(),te=ee;function re(){if("undefined"!=typeof self)return(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function ie(e,t){var r=Qm(e),i=Qm(t),n=r.length,a=i.length;return!n||!a||n===a&&!Sy(r).call(r,(function(e){return-1===hy(i).call(i,e)}))}var ne={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 ae(e,t){var r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!Sy(r=e.split(",")).call(r,(function(e){return!se(e,t,i)}))}function se(e,t){var r,i=re(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);return null!=(r=null==i?void 0:i.isTypeSupported(oe(e,t)))&&r}function oe(e,t){var r;return py(r="".concat(t,"/mp4;codecs=")).call(r,e)}function le(e){if(e){var t=e.substring(0,4);return ne.video[t]}return 2}function ue(e){var t;return eS(t=e.split(",")).call(t,(function(e,t){var r=ne.video[t];return r?(2*r+e)/(e?3:2):(ne.audio[t]+e)/(e?2:1)}),0)}var ce={},he=/flac|opus|mp4a\.40\.34/i;function de(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(he,(function(e){return function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(ce[e])return ce[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(se(r[i],"audio",t))return ce[e]=r[i],r[i];if("mp3"===r[i]&&null!=(n=re(t))&&n.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)}))}function fe(e,t){var r;if(e&&(e.length>4||-1!==hy(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 ve(e){if(AS(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 ge(e){var t=re(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 pe={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},me={};function ye(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?Ck(u):l?1/0:2,h=null;if(null!=o&&o.length)try{h=1===o.length&&o[0]?t.groups[o[0]].channels:eS(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"));ey(i=Qm(n.channels)).call(i,(function(t){e[t]=(e[t]||0)+n.channels[t]}))}return e}),{2:0})}catch(d){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&&_(c)&&Sy(s=Qm(h)).call(s,(function(e){return Ck(e)>c}))}function Ee(e,t,r){var i,n=e.videoCodec,a=e.audioCodec;if(!n&&!a||!r)return RR.resolve(pe);var s=[];if(n){var o,l={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},u=e.videoRange;"SDR"!==u&&(l.transferFunction=u.toLowerCase()),s.push.apply(s,Dy(o=n.split(",")).call(o,(function(e){return{type:"media-source",video:z(z({},l),{},{contentType:oe(ve(e),"video")})}})))}return a&&e.audioGroups&&ey(i=e.audioGroups).call(i,(function(e){var r,i;e&&(null==(i=t.groups[e])||ey(r=i.tracks).call(r,(function(t){if(t.groupId===e){var r,i=t.channels||"",n=ck(i);_(n)&&n>2&&s.push.apply(s,Dy(r=a.split(",")).call(r,(function(e){return{type:"media-source",audio:{contentType:oe(e,"audio"),channels:""+n}}})))}})))})),RR.all(Dy(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 py(n=py(a=py(s=py(o=py(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 py(u=py(c="c".concat(t.channels)).call(c,t.spatialRendering?"s":"n","_")).call(u,h)}return""}(e);return me[t]||(me[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!Sy(e).call(e,(function(e){return!e.supported})),configurations:s,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}}))}var ke=["NONE","TYPE-0","TYPE-1",null],Te=["SDR","PQ","HLG"],Se="",Ae="YES",Le="v2";function be(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?Le:Ae:Se}var Re=function(){function e(t,r,i){qm(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=r,this.skip=i}return Xm(e,[{key:"addDirectives",value:function(e){var t=new e_(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}(),Ie=function(){function e(t){var r,i;qm(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=Dy(r=Jm(i=[t.videoCodec,t.audioCodec]).call(i,(function(e){return!!e}))).call(r,(function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}return Xm(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 De(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return De(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===hy(r).call(r,t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===hy(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 De(e,t){return!(!t||!e)&&-1!==hy(e).call(e,t)}function we(e,t){var r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){var n="SDR"!==(i=t.allowedVideoRanges||uy(Te).call(Te,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 _e(e,t){var r;te.log(py(r='[abr] start candidates with "'.concat(e,'" ignored because ')).call(r,t))}function Pe(e){return eS(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 Ce(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function xe(e,t,r){if("attrs"in e){var i=hy(t).call(t,e);if(-1!==i)return i}for(var n=0;n<t.length;n++)if(Me(e,t[n],r))return n;return-1}function Me(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]:"--";return e.length===t.length?e===t:AS(e).call(e,t)||AS(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&&!Sy(r).call(r,(function(e){return-1===hy(i).call(i,e)}))}(o,t.characteristics))&&(void 0===r||r(e,t))}function Oe(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 Fe(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 Ne(e,t){var r;return!!e&&e!==(null==(r=t.levels[t.loadLevel])?void 0:r.uri)}var Ue=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 Be(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===Ge(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i,n=eS(i=t.tagList).call(i,(function(e,t){return"INF"===t[0]&&(e+=ck(t[1])),e}),r);return e.start<=n}return!1}(a,e,Math.min(n,i))))return a;var o=Ue(t,pE(Ge).call(Ge,null,r,i));return!o||o===e&&a?a:o}function Ge(){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 Ke(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function He(e,t){return Ue(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function Ve(e){switch(e.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function je(e,t){var r=Ve(t);return e.default[(r?"timeout":"error")+"Retry"]}function Ye(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function We(e){return z(z({},e),{errorRetry:null,timeoutRetry:null})}function qe(e,t,r,i){if(!e)return!1;var n,a=null==i?void 0:i.code,s=t<e.maxNumRetry&&(0===(n=a)&&!1===navigator.onLine||!!n&&(n<400||n>499)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,s):s}var ze=0,Xe=2,Qe=3,$e=5,Je=0,Ze=1,et=2;function tt(e){var t={action:ze,flags:Je};return e&&(t.resolved=!0),t}var rt="NOT_LOADED",it="APPENDING",nt="PARTIAL",at="OK",st=function(){function e(t){qm(this,e),this.activePartLists=t_(null),this.endListFragments=t_(null),this.fragments=t_(null),this.timeRanges=t_(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}return Xm(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.BUFFER_APPENDED,this.onBufferAppended,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.BUFFER_APPENDED,this.onBufferAppended,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.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=Qm(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;ey(a=Qm(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?Sy(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=lt(n),s=this.fragments[a];if(!(!s||s.buffered&&n.gap)){var o=!n.relurl;ey(t=Qm(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,Qm(s.range).length?(s.buffered=!0,(s.body.endList=n.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),ot(s)||this.removeParts(n.sn-1,n.type)):this.removeFragment(s.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=Jm(r).call(r,(function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=lt(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:t_(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 ey(t=Qm(l)).call(t,(function(t){var u=l[t];u&&ot(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||ot(t))}},{key:"getState",value:function(e){var t=lt(e),r=this.fragments[t];return r?r.buffered?ot(r)?nt:at:it:rt}},{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=lt(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:t_(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=lt(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=Qm(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||ey(a=Qm(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=lt(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=Jm(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=t_(null),this.endListFragments=t_(null),this.activePartLists=t_(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&ey(r).call(r,(function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function ot(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 lt(e){var t,r;return py(t=py(r="".concat(e.type,"_")).call(r,e.level,"_")).call(t,e.sn)}var ut=0,ct=1,ht=function(){function e(t,r,i){qm(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=r,this.aesMode=i}return Xm(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case ut:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case ct: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 dt(e,t,r){return uy(Uint8Array.prototype)?uy(e).call(e,t,r):new Uint8Array(uy(Array.prototype).call(e,t,r))}var ft=function(){function e(){qm(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 Xm(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],w=b[3],_=new Int32Array(e),P=new Int32Array(_.length),C=this.networkToHostOrderSwap;t<_.length;){for(h=C(_[t]),d=C(_[t+1]),f=C(_[t+2]),v=C(_[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^w),R=h,I=d,D=f,w=v,t+=4}return P.buffer}}]),e}(),vt=function(){function e(t,r,i){qm(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=r,this.aesMode=i}return Xm(e,[{key:"expandKey",value:function(){var e=function(e){switch(e){case ut:return"AES-CBC";case ct: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 gt(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=hy(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 pt=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 mt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yt,Et,kt,Tt,St,At={exports:{}};yt=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Et=/^(?=([^\/?#]*))\1([^]*)$/,kt=/(?:\/|^)\.(?=\/)/g,Tt=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,At.exports=St={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=Ek(e).call(e),!(t=Ek(t).call(t))){if(!r.alwaysNormalize)return e;var i=St.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=St.normalizePath(i.path),St.buildURLFromParts(i)}var n=St.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=St.normalizePath(n.path),St.buildURLFromParts(n)):t;var a=St.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var s=Et.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,p_(l).call(l,"/")+1)+n.path;o.path=St.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?St.normalizePath(n.path):n.path),St.buildURLFromParts(o)},parseURL:function(e){var t=yt.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;for(e=b_(r=e.split("")).call(r).join("").replace(kt,"");e.length!==(e=e.replace(Tt,"")).length;)var r;return b_(t=e.split("")).call(t).join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var Lt=At.exports,bt=Xm((function e(){qm(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}})),Rt="audio",It="video",Dt="audiovideo",wt=function(){function e(t){qm(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t}return Xm(e,[{key:"setByteRange",value:function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:Ck(i[1]),this._byteRange=[r,Ck(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;return null===this._streams&&(this._streams=($h(e={},Rt,null),$h(e,It,null),$h(e,Dt,null),e)),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 bt),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Lt.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[Rt]=null,e[It]=null,e[Dt]=null}}]),e}();function _t(e){return"initSegment"!==e.sn}var Pt=function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n;return qm(this,r),(n=t.call(this,i))._decryptdata=null,n._programDateTime=null,n._ref=null,n._bitrate=void 0,n.rawProgramDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkeys=void 0,n.type=void 0,n.loader=null,n.keyLoader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.playlistOffset=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.gap=void 0,n.urlId=0,n.type=e,n}return Xm(r,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var t=this.byteRange[0],r=this.byteRange[1];if(_(t)&&_(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=Qm(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=_(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=Qm(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){_(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return _t(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}}}]),r}(wt),Ct=function(e){Ym(r,e);var t=Wm(r);function r(e,i,n,a,s){var o;qm(this,r),(o=t.call(this,n)).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=i,o.index=a;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return Xm(r,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),r}(wt),xt=Math.pow(2,32)-1,Mt=[].push,Ot={video:1,audio:2,id3:3,text:4};function Ft(e){return String.fromCharCode.apply(null,e)}function Nt(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Ut(e,t){var r=Gt(e,t);return r<0?4294967296+r:r}function Bt(e,t){var r=Ut(e,t);return r*=Math.pow(2,32),r+=Ut(e,t+4)}function Gt(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Kt(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 Ht(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=Ut(e,n),s=a>1?n+a:i;if(Ft(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=Ht(e.subarray(n+8,s),uy(t).call(t,1));o.length&&Mt.apply(r,o)}n=s}return r}function Vt(e){var t=[],r=e[0],i=8,n=Ut(e,i);i+=4;var a=0,s=0;0===r?(a=Ut(e,i),s=Ut(e,i+4),i+=8):(a=Bt(e,i),s=Bt(e,i+8),i+=16),i+=2;var o=e.length+s,l=Nt(e,i);i+=2;for(var u=0;u<l;u++){var c=i,h=Ut(e,c);c+=4;var d=2147483647&h;if(1==(2147483648&h)>>>31)return te.warn("SIDX has hierarchical references (not supported)"),null;var f=Ut(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 jt(e){for(var t,r=[],i=Ht(e,["moov","trak"]),n=0;n<i.length;n++){var a=i[n],s=Ht(a,["tkhd"])[0];if(s){var o=s[0],l=Ut(s,0===o?12:20),u=Ht(a,["mdia","mdhd"])[0];if(u){var c=Ut(u,0===(o=u[0])?12:20),h=Ht(a,["mdia","hdlr"])[0];if(h){var d=Ft(h.subarray(8,12)),f={soun:Rt,vide:It}[d];if(f){var v=Yt(Ht(a,["mdia","minf","stbl","stsd"])[0]);r[l]={timescale:c,type:f},r[f]=z({timescale:c,id:l},v)}}}}}return ey(t=Ht(e,["moov","mvex","trex"])).call(t,(function(e){var t=Ut(e,4),i=r[t];i&&(i.default={duration:Ut(e,12),flags:Ut(e,20)})})),r}function Yt(e){var t=e.subarray(8),r=t.subarray(86),i=Ft(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s,o=Ht(t,[i])[0];ey(s=Ht(o.subarray("enca"===i?28:78),["sinf"])).call(s,(function(e){var t=Ht(e,["schm"])[0];if(t){var r=Ft(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=Ht(e,["frma"])[0];i&&(n=Ft(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var l=Ht(r,["avcC"])[0];n+="."+qt(l[1])+qt(l[2])+qt(l[3]);break;case"mp4a":var u=Ht(t,[i])[0],c=Ht(u.subarray(28),["esds"])[0];if(c&&c.length>7){var h=4;if(3!==c[h++])break;h=Wt(c,h),h+=2;var d=c[h++];if(128&d&&(h+=2),64&d&&(h+=c[h++]),4!==c[h++])break;h=Wt(c,h);var f=c[h++];if(64!==f)break;if(n+="."+qt(f),h+=12,5!==c[h++])break;h=Wt(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=Ht(r,["hvcC"])[0],m=p[1],y=["","A","B","C"][m>>6],E=31&m,k=Ut(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];(R||L)&&(L="."+R.toString(16).toUpperCase()+L)}n+=L;break;case"dvh1":case"dvhe":var I=Ht(r,["dvcC"])[0],D=I[2]>>1&127,w=I[2]<<5&32|I[3]>>3&31;n+="."+zt(D)+"."+zt(w);break;case"vp09":var _=Ht(r,["vpcC"])[0],P=_[4],C=_[5],x=_[6]>>4&15;n+="."+zt(P)+"."+zt(C)+"."+zt(x);break;case"av01":var M=Ht(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],Y=1,W=1,q=1,z=0;n+="."+O+"."+zt(F)+N+"."+zt(G)+"."+K+"."+H+V+j+"."+zt(Y)+"."+zt(W)+"."+zt(q)+"."+z}return{codec:n,encrypted:a}}function Wt(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function qt(e){var t;return uy(t="0"+e.toString(16).toUpperCase()).call(t,-2)}function zt(e){return(e<10?"0":"")+e}function Xt(e){var t=Ht(e,["schm"])[0];if(t){var r=Ft(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return Ht(e,["schi","tenc"])[0]}return null}function Qt(e){var t=Ut(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=Ut(e,4),a=0;a<n;a++)256&t&&(i+=Ut(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function $t(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Jt(e,t){var r,i=[],n=t.samples,a=t.timescale,s=t.id,o=!1;return Dy(r=Ht(n,["moof"])).call(r,(function(r){var l,u=r.byteOffset-8;Dy(l=Ht(r,["traf"])).call(l,(function(r){var l,c,h=Dy(l=Ht(r,["tfdt"])).call(l,(function(e){var t=e[0],r=Ut(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Ut(e,8)),r/a}))[0];return void 0!==h&&(e=h),Dy(c=Ht(r,["tfhd"])).call(c,(function(l){var c,h=Ut(l,4),d=16777215&Ut(l,0),f=0,v=0!=(16&d),g=0,p=0!=(32&d),m=8;h===s&&(0!=(1&d)&&(m+=8),0!=(2&d)&&(m+=4),0!=(8&d)&&(f=Ut(l,m),m+=4),v&&(g=Ut(l,m),m+=4),p&&(m+=4),"video"===t.type&&(o=function(e){if(!e)return!1;var t=hy(e).call(e,"."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),Dy(c=Ht(r,["trun"])).call(c,(function(r){var s=r[0],l=16777215&Ut(r,0),c=0!=(1&l),h=0,d=0!=(4&l),v=0!=(256&l),p=0,m=0!=(512&l),y=0,E=0!=(1024&l),k=0!=(2048&l),T=0,S=Ut(r,4),A=8;c&&(h=Ut(r,A),A+=4),d&&(A+=4);for(var L=h+u,b=0;b<S;b++){if(v?(p=Ut(r,A),A+=4):p=f,m?(y=Ut(r,A),A+=4):y=g,E&&(A+=4),k&&(T=0===s?Ut(r,A):Gt(r,A),A+=4),t.type===It)for(var R=0;R<y;){var I=Ut(n,L);Zt(o,n[L+=4])&&er(n.subarray(L,L+I),o?2:1,e+T/a,i),L+=I,R+=I+4}e+=p/a}})))}))}))})),i}function Zt(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function er(e,t,r,i){var n=tr(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;te.error(py(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=Nt(n,c);if(c+=2,49===d){var f=Ut(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:gt(L),userDataBytes:L})}}}function tr(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 rr(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 ir(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=pt(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 nr=function(){function e(t){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).removePKCS7Padding,i=void 0===r||r;if(qm(this,e),this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(a){}this.useSoftware=!this.subtle}return Xm(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))?dt(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 RR((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!==ut||16!==t.byteLength)return te.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=$t(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 ft),l.expandKey(t);var u=a;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=dt(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 RR.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new vt(this.subtle,t,i)}return this.fastAesKey.expandKey().then((function(t){return n.subtle?(n.logOnce("WebCrypto AES decrypt"),new ht(n.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):RR.reject(new Error("web crypto not initialized"))})).catch((function(a){var s;return te.warn(py(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=dt(e,0,r),this.remainderData=dt(e,r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(te.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),ar=Math.pow(2,17),sr=function(){function e(t){qm(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}return Xm(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 RR.reject(new ur({type:x.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new RR((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){var u;if(Sy(u=e.tagList).call(u,(function(e){return"GAP"===e[0]})))return void l(lr(e));e.gap=!1}var c=r.loader=a?new a(n):new s(n),h=or(e);e.loader=c;var d=We(n.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:ar};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(uy(s).call(s,0,16)),s=uy(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 ur({type:x.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:z({url:i,data:void 0},t),error:new Error(py(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 ur({type:x.NETWORK_ERROR,details:M.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 ur({type:x.NETWORK_ERROR,details:M.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 RR((function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(lr(e,t));else{var u=i.loader=a?new a(n):new s(n),c=or(e,t);e.loader=u;var h=We(n.fragLoadPolicy.default),d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ar};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 ur({type:x.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:z({url:c.url,data:void 0},r),error:new Error(py(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 ur({type:x.NETWORK_ERROR,details:M.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 ur({type:x.NETWORK_ERROR,details:M.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 or(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(_(a)&&_(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 lr(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),i={type:x.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new ur(i)}var ur=function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,e.error.message)).data=void 0,i.data=e,i}return Xm(r)}(jm(Error)),cr=function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n,a;return qm(this,r),(a=t.call(this,e,i))._boundTick=void 0,a._tickTimer=null,a._tickInterval=null,a._tickCallCount=0,a._boundTick=pE(n=a.tick).call(n,$f(a)),a}return Xm(r,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=gE(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=mE(this._boundTick,0)}},{key:"doTick",value:function(){}}]),r}(X),hr=Xm((function e(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];qm(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=t,this.sn=r,this.id=i,this.size=n,this.part=a,this.partial=s})),dr={length:0,start:function(){return 0},end:function(){return 0}},fr=function(){function e(){qm(this,e)}return Xm(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),gT(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||dr}catch(t){return te.log("failed to get media.buffered",t),dr}}}]),e}(),vr=/\{\$([a-zA-Z0-9-_]+)\}/g;function gr(e){return vr.test(e)}function pr(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(vr,(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 mr(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 e_(r).searchParams;if(!o.has(i))throw new Error(py(s='"'.concat(i,'" does not match any query parameter in URI: "')).call(s,r,'"'));n=o.get(i)}catch(l){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(l.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 yr(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 Er=/^(\d+)x(\d+)$/,kr=/(.+?)=(".*?"|.*?)(?:,|$)/g,Tr=function(){function e(t,r){qm(this,e),"string"==typeof t&&(t=e.parseAttrList(t,r)),W(this,t)}return Xm(e,[{key:"clientAttrs",get:function(){var e;return Jm(e=Qm(this)).call(e,(function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=Ck(this[e],10);return t>bT?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t,r=uy(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]=Ck(uy(r).call(r,2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=Ck(this[e],16);return t>bT?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return ck(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?ck(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r,i=this[e];return eS(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=Er.exec(this[e]);if(null!==t)return{width:Ck(t[1],10),height:Ck(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,i,n={};for(kr.lastIndex=0;null!==(i=kr.exec(e));){var a,s=Ek(a=i[1]).call(a),o=i[2],l=0===hy(o).call(o,'"')&&p_(o).call(o,'"')===o.length-1,u=!1;if(l)o=uy(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=pr(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":te.warn(py(r="".concat(e,": attribute ")).call(r,s," is missing quotes"))}n[s]=o}return n}}]),e}();function Sr(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var Ar=function(){function e(t,r){var i,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(qm(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==r?void 0:r.tagAnchor)||null,this.tagOrder=null!=(i=null==r?void 0:r.tagOrder)?i:n,r){var a=r.attr;for(var s in a)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==a[s]){var o;te.warn(py(o='DATERANGE tag attribute: "'.concat(s,'" does not match for tags with ID: "')).call(o,t.ID,'"')),this._badValueForSameId=s;break}t=W(new Tr({}),a,t)}if(this.attr=t,r?(this._startDate=r._startDate,this._cue=r._cue,this._endDate=r._endDate,this._dateAtEnd=r._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var l=(null==r?void 0:r.endDate)||new Date(this.attr["END-DATE"]);_(l.getTime())&&(this._endDate=l)}}return Xm(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?(te.warn(py(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(_(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&&_(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}(),Lr=function(){function e(t){qm(this,e),this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return Xm(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&&_(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(w_()-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 br(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Rr(e){switch(e){case"AES-128":case"AES-256":return ut;case"AES-256-CTR":return ct;default:throw new Error("invalid full segment method ".concat(e))}}function Ir(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function Dr(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function wr(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?(UE(a).call(a,-1,1),n=Ir(l)):(t=Dr(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),n=r)}}return n}var _r="undefined"!=typeof self?self:void 0,Pr={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Cr="org.w3.clearkey",xr="com.apple.streamingkeydelivery",Mr="com.microsoft.playready",Or="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Fr(e){switch(e){case xr:return Pr.FAIRPLAY;case Mr:return Pr.PLAYREADY;case Or:return Pr.WIDEVINE;case Cr:return Pr.CLEARKEY}}var Nr="1077efecc0b24d02ace33c1e52e2fb4b",Ur="e2719d58a985b3c9781ab030af78d30e",Br="9a04f07998404286ab92e65be0885f95",Gr="edef8ba979d64acea3c827dcd51d21ed";function Kr(e){return e===Gr?Pr.WIDEVINE:e===Br?Pr.PLAYREADY:e===Nr||e===Ur?Pr.CLEARKEY:void 0}function Hr(e){switch(e){case Pr.FAIRPLAY:return xr;case Pr.PLAYREADY:return Mr;case Pr.WIDEVINE:return Or;case Pr.CLEARKEY:return Cr}}function Vr(e){var t,r=e.drmSystems,i=e.widevineLicenseUrl,n=r?Jm(t=[Pr.FAIRPLAY,Pr.WIDEVINE,Pr.PLAYREADY,Pr.CLEARKEY]).call(t,(function(e){return!!r[e]})):[];return!n[Pr.WIDEVINE]&&i&&n.push(Pr.WIDEVINE),n}var jr,Yr=null!=_r&&null!=(jr=_r.navigator)&&jr.requestMediaKeySystemAccess?pE(r=self.navigator.requestMediaKeySystemAccess).call(r,self.navigator):null;function Wr(e){var t,r,i=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,ly(i)),a=n.substring(hy(n).call(n,"<"),n.length),s=(new DOMParser).parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(s){var o=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(o){var l=Ir(o).subarray(0,16);return(r=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i})(t=l,0,3),r(t,1,2),r(t,4,5),r(t,6,7),l}}return null}var qr={},zr=function(){function e(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;qm(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=r,this.keyFormat=i,this.keyFormatVersions=n,this.iv=a,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!br(t)}return Xm(e,[{key:"isSupported",value:function(){var e;if(this.method){if(br(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case xr:case Or:case Mr:case Cr:return-1!==hy(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(br(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(te.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=wr(this.uri);if(i)switch(this.keyFormat){case Or:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Mr:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=rr(n,0,i),this.keyId=Wr(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=qr[this.uri];if(!o){var l=Qm(qr).length%bT;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),qr[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){qr={}}}]),e}(),Xr=/#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,Qr=/#EXT-X-MEDIA:(.*)/g,$r=/^#EXT(?:INF|-X-TARGETDURATION):/m,Jr=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Zr=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("|")),ei=function(){function e(){qm(this,e)}return Xm(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 Lt.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return $r.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:gr(t)},a=[];for(Xr.lastIndex=0;null!=(i=Xr.exec(t));)if(i[1]){var s,o=new Tr(i[1],n),l=pr(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),ai(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 Tr(d,n),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var g=ii(d,r,n);g.encrypted&&g.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(g)):te.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(d,'"'));break;case"DEFINE":mr(n,new Tr(d,n),r);break;case"CONTENT-STEERING":var p=new Tr(d,n);n.contentSteering={uri:e.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=ni(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:Dy(s).call(s,(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:Dy(s).call(s,(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(Qr.lastIndex=0;null!==(n=Qr.exec(t));){var u=new Tr(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];si(y,E,"audioCodec"),si(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 Lr(t),h=c.fragments,d=[],f=null,v=0,g=0,p=0,m=0,y=0,E=null,k=new Pt(i,u),T=-1,S=!1,A=null;for(Jr.lastIndex=0,c.m3u8=e,c.hasVariableRefs=gr(e);null!==(s=Jr.exec(e));){S&&(S=!1,(k=new Pt(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=ck(L);var R=uy(b=" "+s[2]).call(b,1);k.title=R||null,k.tagList.push(R?["INF",L,R]:["INF",L])}else if(s[3]){if(_(k.duration)){var I;k.playlistOffset=p,k.start=p,l&&ui(k,l,c),k.sn=v,k.level=r,k.cc=m,h.push(k);var D=uy(I=" "+s[3]).call(I,1);k.relurl=pr(c,D),oi(k,E,d),E=k,p+=k.duration,v++,g=0,S=!0}}else{var w,P,C;if(!(s=s[0].match(Zr))){te.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<s.length&&void 0===s[o];o++);var x=uy(w=" "+s[o]).call(w,1),M=uy(P=" "+s[o+1]).call(P,1),O=s[o+2]?uy(C=" "+s[o+2]).call(C,1):null;switch(x){case"BYTERANGE":E?k.setByteRange(M,E):k.setByteRange(M);break;case"PROGRAM-DATE-TIME":k.rawProgramDateTime=M,k.tagList.push(["PROGRAM-DATE-TIME",M]),-1===T&&(T=h.length);break;case"PLAYLIST-TYPE":c.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":v=c.startSN=Ck(M);break;case"SKIP":var F;c.skippedSegments&&(c.playlistParsingError=new Error("#EXT-X-SKIP MUST NOT appear more than once in a Playlist"));var N=new Tr(M,c),U=N.decimalInteger("SKIPPED-SEGMENTS");if(_(U)){c.skippedSegments+=U;for(var B=U;B--;)h.push(null);v+=U}var G=N.enumeratedString("RECENTLY-REMOVED-DATERANGES");G&&(c.recentlyRemovedDateranges=py(F=c.recentlyRemovedDateranges||[]).call(F,G.split("\t")));break;case"TARGETDURATION":c.targetduration=Math.max(Ck(M),1);break;case"VERSION":c.version=Ck(M);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"#":(M||O)&&k.tagList.push(O?[M,O]:[M]);break;case"DISCONTINUITY":m++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([x]);break;case"BITRATE":k.tagList.push([x,M]),y=1e3*Ck(M),_(y)?k.bitrate=y:y=0;break;case"DATERANGE":var K=new Tr(M,c),H=new Ar(K,c.dateRanges[K.ID],c.dateRangeTagCount);c.dateRangeTagCount++,H.isValid||c.skippedSegments?c.dateRanges[H.id]=H:te.warn('Ignoring invalid DATERANGE tag: "'.concat(M,'"')),k.tagList.push(["EXT-X-DATERANGE",M]);break;case"DEFINE":var V=new Tr(M,c);"IMPORT"in V?yr(c,V,a):mr(c,V,t);break;case"DISCONTINUITY-SEQUENCE":c.startCC=m=Ck(M);break;case"KEY":var j=ii(M,t,c);if(j.isSupported()){if("NONE"===j.method){l=void 0;break}l||(l={}),l[j.keyFormat]&&(l=W({},l)),l[j.keyFormat]=j}else te.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(M,'"'));break;case"START":c.startTimeOffset=ni(M);break;case"MAP":var Y=new Tr(M,c);if(k.duration){var q=new Pt(i,u);li(q,Y,r,l),f=q,k.initSegment=f,f.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime)}else{var z=k.byteRangeEndOffset;if(z){var X,Q=k.byteRangeStartOffset;A=py(X="".concat(z-Q,"@")).call(X,Q)}else A=null;li(k,Y,r,l),f=k,S=!0}f.cc=m;break;case"SERVER-CONTROL":var $=new Tr(M);c.canBlockReload=$.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0),c.holdBack=$.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var J=new Tr(M);c.partTarget=J.decimalFloatingPoint("PART-TARGET");break;case"PART":var Z=c.partList;Z||(Z=c.partList=[]);var ee=g>0?Z[Z.length-1]:void 0,re=g++,ie=new Tr(M,c),ne=new Ct(ie,k,u,re,ee);Z.push(ne),k.duration+=ne.duration;break;case"PRELOAD-HINT":var ae=new Tr(M,c);c.preloadHint=ae;break;case"RENDITION-REPORT":var se=new Tr(M,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(se);break;default:te.warn("line parsed but not handled: ".concat(s))}}}E&&!E.relurl?(h.pop(),p-=E.duration,c.partList&&(c.fragmentHint=E)):c.partList&&(oi(k,E,d),k.cc=m,c.fragmentHint=k,l&&ui(k,l,c));var oe=h.length,le=h[0],ue=h[oe-1];if((p+=c.skippedSegments*c.targetduration)>0&&oe&&ue){c.averagetargetduration=p/oe;var ce=ue.sn;c.endSN="initSegment"!==ce?ce:0,c.live||(ue.endList=!0),le&&!c.startCC&&(c.startCC=le.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),le&&d.unshift(le))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(p+=c.fragmentHint.duration),c.totalduration=p,d.length&&c.dateRangeTagCount&&le&&ti(d,c),c.endCC=m,c}}]),e}();function ti(e,t){for(var r=e.length,i=e[r-1],n=t.live?1/0:t.totalduration,a=Qm(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=ri(t,l,e,u,n);if(-1!==c){o.tagAnchor=t.fragments[c].ref;break}}}}function ri(e,t,r,i,n){var a=r[i];if(a){var s,o=a.programDateTime;if((t>=o||0===i)&&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 ii(e,t,r){var i,n,a,s,o=new Tr(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&&te.error("Invalid IV: ".concat(o.IV));var f=u?ei.resolve(u,t):"",v=Jm(i=Dy(n=(h||"1").split("/")).call(n,Number)).call(i,mT);return new zr(l,f,d,v,c)}function ni(e){var t=new Tr(e).decimalFloatingPoint("TIME-OFFSET");return _(t)?t:null}function ai(e,t){var r,i,n=Jm(r=(e||"").split(/[ ,]+/)).call(r,(function(e){return e}));ey(i=["video","audio","text"]).call(i,(function(e){var r=Jm(n).call(n,(function(t){return r=t,!!(i=ne[e])&&!!i[uy(r).call(r,0,4)];var r,i}));r.length&&(t["".concat(e,"Codec")]=r.join(","),n=Jm(n).call(n,(function(e){return-1===hy(r).call(r,e)})))})),t.unknownCodecs=n}function si(e,t,r){var i=t[r];i&&(e[r]=i)}function oi(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function li(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 ui(e,t,r){var i;e.levelkeys=t;var n=r.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!Sy(i=Qm(t)).call(i,(function(e){return t[e].isCommonEncryption}))||n.push(e)}function ci(e,t){var r=t.startPTS;if(_(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 t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration):t.setStart(Math.max(e.start-t.duration,0))}function hi(e,t,r,i,n,a){i-r<=0&&(te.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(_(l)){var c=Math.abs(l-r);_(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--)ci(g[d],g[d-1]);for(d=v;d<g.length-1;d++)ci(g[d],g[d+1]);return e.fragmentHint&&ci(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function di(e,t){for(var r,i,n=null,a=e.fragments,s=a.length-1;s>=0;s--){var o=a[s].initSegment;if(o){n=o;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var l,u=0;!function(e,t,r,i,n){for(var 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?py(i=t.fragments).call(i,t.fragmentHint):t.fragments,c=e.fragmentHint?py(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&&(u=e.cc-r.cc),_(e.startPTS)&&_(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&&(l=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,n=e.initSegment)}));var c=t.fragmentHint?py(r=t.fragments).call(r,t.fragmentHint):t.fragments;if(n&&ey(c).call(c,(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=n)?void 0:t.relurl)||(e.initSegment=n)})),t.skippedSegments)if(t.deltaUpdateFailed=Sy(i=t.fragments).call(i,(function(e){return!e})),t.deltaUpdateFailed){te.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,r){var i=t.dateRanges,n=t.recentlyRemovedDateranges,a=W({},e);n&&ey(n).call(n,(function(e){delete a[e]}));var s=Qm(a).length;return s&&ey(r=Qm(i)).call(r,(function(e){var t=a[e],r=new Ar(i[e].attr,t);r.isValid?(a[e]=r,t||(r.tagOrder+=s)):te.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(x_(i[e].attr),'"'))})),a}(e.dateRanges,t));var f=Jm(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&&oi(c[v],c[v-1],f);ti(f,t)}var g=t.fragments;if(u){te.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<g.length;p++)g[p].cc+=u}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})),l?hi(t,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):fi(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 fi(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}vi(t,s)}function vi(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 gi(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,n=4;if(i.length&&r*n>t){var a=1e3*i[i.length-1].duration;a<r&&(r=a)}}else r/=2;return Math.round(r)}function pi(e,t,r){return e?mi(e.partList,t,r):null}function mi(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 yi(e){ey(e).call(e,(function(e,t){var r,i=null==(r=e.details)?void 0:r.fragments;i&&ey(i).call(i,(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function Ei(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 ki(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function Ti(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)ki(r[i],e);t.fragmentHint&&ki(t.fragmentHint,e),t.alignedSliding=!0}function Si(e,t){if(i=e,(r=t)&&i.startCC<r.endCC&&i.endCC>r.startCC){var r,i,n=Math.min(t.endCC,e.endCC),a=Ei(t.fragments,n),s=Ei(e.fragments,n);a&&s&&(te.log("Aligning playlist at start of dicontinuity sequence ".concat(n)),Ti(a.start-s.start,e))}}function Ai(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=Ei(i,s),a=Ei(r,s)),n&&a||(a=Ei(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,l=a.programDateTime;o&&l&&Ti((l-o)/1e3-(a.start-n.start),e)}}}var Li=function(e){for(var t="",r=e.length,i=0;i<r;i++){var n;t+=py(n="[".concat(e.start(i).toFixed(3),"-")).call(n,e.end(i).toFixed(3),"]")}return t},bi="STOPPED",Ri="IDLE",Ii="KEY_LOADING",Di="FRAG_LOADING",wi="FRAG_LOADING_WAITING_RETRY",_i="WAITING_TRACK",Pi="PARSING",Ci="PARSED",xi="ENDED",Mi="ERROR",Oi="WAITING_INIT_PTS",Fi="WAITING_LEVEL",Ni=function(e){Ym(r,e);var t=Wm(r);function r(e,i,n,a,s){var o;return qm(this,r),(o=t.call(this,a,e.logger)).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=bi,o.playlistType=void 0,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.buffering=!0,o.loadingParts=!1,o.loopSn=void 0,o.onMediaSeeking=function(){var e,t=$f(o),r=t.config,i=t.fragCurrent,n=t.media,a=t.mediaBuffer,s=t.state,l=n?n.currentTime:0,u=fr.bufferInfo(a||n,l,r.maxBufferHole);if(o.log(py(e="media seeking to ".concat(_(l)?l.toFixed(3):l,", state: ")).call(e,s)),o.state===xi)o.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=l>d;(l<h||f)&&(f&&i.loader&&(o.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),o.resetLoadingState()),o.fragPrevious=null)}}if(n&&(o.fragmentTracker.removeFragmentsInRange(l,1/0,o.playlistType,!0),l>o.lastCurrentTime&&(o.lastCurrentTime=l),!o.loadingParts)){var v,g=Math.max(u.end,l),p=o.shouldLoadParts(o.getLevelDetails(),g);p&&(o.log(py(v="LL-Part loading ON after seeking to ".concat(l.toFixed(2)," with buffer @")).call(v,g.toFixed(2))),o.loadingParts=p)}o.hls.hasEnoughToStart||u.len||(o.log("setting startPosition to ".concat(l," because of seek before start")),o.nextLoadPosition=o.startPosition=l),o.tickImmediate()},o.onMediaEnded=function(){o.log("setting startPosition to 0 because media ended"),o.startPosition=o.lastCurrentTime=0,o.triggerEnded()},o.playlistType=s,o.hls=e,o.fragmentLoader=new sr(e.config),o.keyLoader=n,o.fragmentTracker=i,o.config=e.config,o.decrypter=new nr(e.config),o}return Xm(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(O.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.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!==bi){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=bi}}},{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 fr.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===bi&&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),Qf(Xf(r.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=bi,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,Qf(Xf(r.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!==H){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(py(t=py(r=py(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){var t,r,n;if(e){var a=i.state,s=e.frag;i.fragContextChanged(s)?(a===Di||!i.fragCurrent&&a===Pi)&&(i.fragmentTracker.removeFragment(s),i.state=Ri):("payload"in e&&(i.log(py(t=py(r=py(n="Loaded ".concat(s.type," sn: ")).call(n,s.sn," of ")).call(r,i.playlistLabel()," ")).call(t,s.level)),i.hls.trigger(O.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e))}})).catch((function(t){i.state!==bi&&i.state!==Mi&&(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)===it){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)===nt&&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(O.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&&br(a.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,Rr(a.method)).catch((function(e){throw t.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(n){var a=self.performance.now();return t.trigger(O.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!==bi&&r.state!==Mi&&(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!==bi&&(this.state=Ri),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(py(r=py(i=py(n=py(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?Li(fr.getBuffered(s)):"(detached)",")")),_t(e)){var o;if(e.type!==H){var l,u=e.elementaryStreams;if(!Sy(l=Qm(u)).call(l,(function(e){return!!u[e]})))return void(this.state=Ri)}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=Ri}},{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||Sy(n).call(n,(function(e){return!e})),s=new hr(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,u,c,h,d=this,f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,v=arguments.length>3?arguments[3]:void 0;this.fragCurrent=e;var g=null==t?void 0:t.details;if(!this.levels||!g)throw new Error("frag load aborted, missing level".concat(g?"":" detail","s"));var p=null;!e.encrypted||null!=(h=e.decryptdata)&&h.key?!e.encrypted&&g.encryptedFragments.length&&this.keyLoader.loadClear(e,g.encryptedFragments):(this.log(py(r=py(i=py(n=py(a="Loading key for ".concat(e.sn," of [")).call(a,g.startSN,"-")).call(n,g.endSN,"], ")).call(i,this.playlistLabel()," ")).call(r,e.level)),this.state=Ii,this.fragCurrent=e,p=this.keyLoader.load(e).then((function(e){if(!d.fragContextChanged(e.frag))return d.hls.trigger(O.KEY_LOADED,e),d.state===Ii&&(d.state=Ri),e})),this.hls.trigger(O.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(p=RR.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var m=this.fragPrevious;if(_t(e)&&(!m||e.sn!==m.sn)){var y,E,k=this.shouldLoadParts(t.details,e.end);k!==this.loadingParts&&(this.log(py(y=py(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(f=Math.max(e.start,f||0),this.loadingParts&&_t(e)){var T=g.partList;if(T&&v){f>e.end&&g.fragmentHint&&(e=g.fragmentHint);var S=this.getNextPart(T,e,f);if(S>-1){var A,L,b,R,I,D,w,P,C,x,M=T[S];return e=this.fragCurrent=M.fragment,this.log(py(A=py(L=py(b=py(R=py(I=py(D=py(w=py(P=py(C="Loading ".concat(e.type," sn: ")).call(C,e.sn," part: ")).call(P,M.index," (")).call(w,S,"/")).call(D,T.length-1,") of ")).call(I,this.fragInfo(e,!1,M),") cc: ")).call(R,e.cc," [")).call(b,g.startSN,"-")).call(L,g.endSN,"], target: ")).call(A,ck(f.toFixed(3)))),this.nextLoadPosition=M.start+M.duration,this.state=Di,x=p?p.then((function(r){return!r||d.fragContextChanged(r.frag)?null:d.doFragPartsLoad(e,M,t,v)})).catch((function(e){return d.handleFragLoadError(e)})):this.doFragPartsLoad(e,M,t,v).catch((function(e){return d.handleFragLoadError(e)})),this.hls.trigger(O.FRAG_LOADING,{frag:e,part:M,targetBufferTime:f}),null===this.fragCurrent?RR.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):x}if(!e.url||this.loadedEndOfParts(T,f))return RR.resolve(null)}}if(_t(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(f.toFixed(2))),this.loadingParts=!1;else if(!e.url)return RR.resolve(null);this.log(py(s=py(o=py(l=py(u=py(c="Loading ".concat(e.type," sn: ")).call(c,e.sn," of ")).call(u,this.fragInfo(e,!1),") cc: ")).call(l,e.cc," ")).call(o,g?"["+g.startSN+"-"+g.endSN+"]":"",", target: ")).call(s,ck(f.toFixed(3)))),_(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Di;var F,N=this.config.progressive;return F=N&&p?p.then((function(t){return!t||d.fragContextChanged(null==t?void 0:t.frag)?null:d.fragmentLoader.load(e,v)})).catch((function(e){return d.handleFragLoadError(e)})):RR.all([this.fragmentLoader.load(e,N?v:void 0),p]).then((function(e){var t=mf(e,1)[0];return!N&&t&&v&&v(t),t})).catch((function(e){return d.handleFragLoadError(e)})),this.hls.trigger(O.FRAG_LOADING,{frag:e,targetBufferTime:f}),null===this.fragCurrent?RR.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):F}},{key:"doFragPartsLoad",value:function(e,t,r,i){var n=this;return new RR((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(O.FRAG_LOADED,i);var c=pi(r.details,e.sn,o.index+1)||mi(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===M.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(O.ERROR,t)}else this.hls.trigger(O.ERROR,{type:x.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t,r=this.getCurrentContext(e);if(r&&this.state===Pi){var i=r.frag,n=r.part,a=r.level,s=self.performance.now();i.stats.parsing.end=s,n&&(n.stats.parsing.end=s);var o=this.getLevelDetails(),l=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);l!==this.loadingParts&&(this.log(py(t="LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @")).call(t,i.end.toFixed(2))),this.loadingParts=l),this.updateLevelTiming(i,n,a,e.partial)}else this.fragCurrent||this.state===bi||this.state===Mi||(this.state=Ri)}},{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)&&(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(py(t=py(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?pi(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===Pi){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=$t(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(O.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(fr.isBuffered(t,t.currentTime)){var r=t.currentTime,i=fr.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(!_(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=fr.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 fr.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]:G,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(py(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(py(c=py(h=py(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===at||r===nt&&!!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;return this.loopSn!==l&&(this.log(py(o='buffer full after gaps in "'.concat(i,'" playlist starting at sn: ')).call(o,l)),this.loopSn=l),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||!sy(e)||!e.length||!_(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(Ke(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=He(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);if(d&&u&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=py(o).call(o,u),l=u.sn),i=e<t?Be(s,o,e,e<this.lastCurrentTime||e>t-c||null!=(n=this.media)&&n.paused||!this.startFragRequested?0:c):o[o.length-1]){var f=i.sn-r.startSN,v=this.fragmentTracker.getState(i);if((v===at||v===nt&&i.gap)&&(s=i),s&&i.sn===s.sn&&(!d||h[0].fragment.sn>i.sn||!r.live&&!d)&&s&&i.level===s.level){var g=o[f+1];i=i.sn<l&&this.fragmentTracker.getState(g)!==at?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,a,s=e.fragmentStart,o=!t,l=e.alignedSliding&&_(s);if(o||!l&&!s){var u,c,h;a=e,(n=r)&&(Si(a,n),!a.alignedSliding&&n&&Ai(a,n),a.alignedSliding||!n||a.skippedSegments||fi(n,a,!1));var d=e.fragmentStart;return this.log(py(u=py(c=py(h="Live playlist sliding: ".concat(d.toFixed(2)," start-sn: ")).call(h,t?t.startSN:"na","->")).call(c,e.startSN," fragments: ")).call(u,i)),d}return s}},{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;null!==s&&_(s)?(r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(py(i=py(n="Setting startPosition to ".concat(r," for start time offset ")).call(n,s," found in ")).call(i,a?"multivariant":"media"," playlist")),this.startPosition=r):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&&_t(e)&&e.stats.aborted&&(this.warn(py(r=py(i=py(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===wi)||(this.state=Ri)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){var r;if(t.chunkMeta&&!t.frag){var i=this.getCurrentContext(t.chunkMeta);i&&(t.frag=i.frag)}var n,a=t.frag;if(a&&a.type===e&&this.levels)if(this.fragContextChanged(a))this.warn(py(r="Frag load error must match current frag to retry ".concat(a.url," > ")).call(r,null==(n=this.fragCurrent)?void 0:n.url));else{var s=t.details===M.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(a,!0);var o=t.errorAction,l=o||{},u=l.action,c=V_(l),h=l.retryCount,d=void 0===h?0:h,f=l.retryConfig,v=!!o&&!!f,g=v&&u===$e,p=v&&!o.resolved&&c===Ze;if(!g&&p&&_t(a)&&!a.endList)this.resetFragmentErrors(e),this.treatAsGap(a),o.resolved=!0;else if((g||p)&&d<f.maxNumRetry){var m,y,E,k,T,S;this.resetStartWhenNotLoaded(this.levelLastLoaded);var A=Ye(f,d);this.warn(py(m=py(y=py(E=py(k=py(T=py(S="Fragment ".concat(a.sn," of ")).call(S,e," ")).call(T,a.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=wi}else if(f&&o){var L;if(this.resetFragmentErrors(e),!(d<f.maxNumRetry))return void this.warn(py(L="".concat(t.details," reached or exceeded max retry (")).call(L,d,")"));s||u===Qe||(o.resolved=!0)}else this.state=u===Xe?Fi:Mi;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===Pi||this.state===Ci){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===K&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==bi&&(this.state=Ri)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var i=fr.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===xi&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==bi&&(this.state=Ri)}},{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(py(t=py(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(!eS(n=Qm(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(py(s=py(o="Could not parse fragment ".concat(e.sn," ")).call(o,n," duration reliably (")).call(s,l,")")),t||!1;var h=i?0:hi(c,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return u.hls.trigger(O.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(py(h=py(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(O.ERROR,{type:x.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:g,frag:e,reason:py(f=py(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=Ci,this.log(py(a=py(s=py(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(O.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===G?"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 py(t=py(r=py(i=py(n=py(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(py(t="".concat(r,"->")).call(t,e)))}}]),r}(cr),Ui=function(){function e(){qm(this,e),this.chunks=[],this.dataLength=0}return Xm(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}(),Bi={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}t_&&(i.prototype=t_(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?uy(i).call(i,1):i);return $m?py(n).call(n,$m(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}(Bi);var Gi=mt(Bi.exports),Ki="1.6.0-beta.2",Hi={};function Vi(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 ji(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 Yi(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 Wi(e,t){for(var r=t,i=0;ji(e,t);)i+=10,i+=Yi(e,t+6),Vi(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)}function qi(e,t){return 255===e[t]&&240==(246&e[t+1])}function zi(e,t){return 1&e[t+1]?7:9}function Xi(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Qi(e,t){return t+1<e.length&&qi(e,t)}function $i(e,t){if(Qi(e,t)){var r=zi(e,t);if(t+r>=e.length)return!1;var i=Xi(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||Qi(e,n)}return!1}function Ji(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i,n,a,s,o,l){var 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 te.log(py(n=py(a=py(s=py(o=py(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(O.ERROR,O.ERROR,{type:x.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:m,reason:m.message})}(t,r,i,n);if(!a)return;W(e,a)}}function Zi(e){return 9216e4/e}function en(e,t,r,i,n){var a,s=i+n*Zi(e.samplerate),o=function(e,t){var r=zi(e,t);if(t+r<=e.length){var i=Xi(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 tn(e,t){return ji(e,t)&&Yi(e,t+6)+10<=e.length-t}function rn(e){return function(e,t,r,i){var n,a=(n=e)instanceof ArrayBuffer?n:n.buffer,s=1;"BYTES_PER_ELEMENT"in i&&(s=i.BYTES_PER_ELEMENT);var o,l=(o=e)&&o.buffer instanceof ArrayBuffer&&void 0!==o.byteLength&&void 0!==o.byteOffset?e.byteOffset:0,u=(l+e.byteLength)/s,c=(l+t)/s,h=Math.floor(Math.max(0,Math.min(c,u)));return new i(a,h,Math.floor(Math.min(h+Math.max(r,0),u))-h)}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,Uint8Array)}function nn(e,t){if(e<0)return-nn(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<j_){var i=Math.floor(e*r);return(i%2==0?i:i+1)/r}return Math.round(e*r)/r}function an(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=hy(t=e.data.subarray(1)).call(t,0);if(-1!==n){var a=gt(rn(e.data,1,n)),s=e.data[2+n],o=hy(r=e.data.subarray(3+n)).call(r,0);if(-1!==o){var l,u,c=gt(rn(e.data,3+n,o));return l="--\x3e"===a?gt(rn(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 sn(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=gt(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=gt(e.data.subarray(t),!0);t+=r.length+1;var i=gt(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=gt(e.data);return{key:e.type,info:"",data:n}}(e):"APIC"===e.type?an(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=gt(e.data.subarray(t),!0);t+=r.length+1;var i=gt(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=gt(e.data.subarray(1));return{key:e.type,info:"",data:n}}}(e)}function on(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Yi(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function ln(e){for(var t=0,r=[];ji(e,t);){var i=Yi(e,t+6);e[t+5]>>6&1&&(t+=10);for(var n=(t+=10)+i;t+10<n;){var a=on(e.subarray(t)),s=sn(a);s&&r.push(s),t+=a.size+10}Vi(e,t)&&(t+=10)}return r}function un(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function cn(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 hn(e){for(var t=ln(e),r=0;r<t.length;r++){var i=t[r];if(un(i))return cn(i)}}var dn=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 fn(){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 vn=function(){function e(){qm(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 Xm(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=$t(this.cachedData,e),this.cachedData=null);var r,i=Wi(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?hn(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&_(o))&&(this.basePTS=gn(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:dn.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 tn(e,n)?(i=Wi(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:dn.audioId3,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===l&&r!==l){var c=dt(e,r);this.cachedData?this.cachedData=$t(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:fn(),id3Track:s,textTrack:fn()}}},{key:"demuxSampleAes",value:function(e,t,r){return RR.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:fn(),id3Track:this._id3Track,textTrack:fn()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),gn=function(e,t,r){return _(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},pn=null,mn=[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],yn=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],En=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],kn=[0,1,1,4];function Tn(e,t,r,i,n){if(!(r+24>t.length)){var a=Sn(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 Sn(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*mn[14*(3===r?3-i:3===i?3:4)+n-1],u=yn[3*(3===r?0:2===r?1:2)+a],c=3===o?1:2,h=En[r][i],d=kn[i],f=8*h*d,v=Math.floor(h*l/u+s)*d;if(null===pn){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);pn=g?Ck(g[1]):0}return!!pn&&pn<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:c,frameLength:v,samplesPerFrame:f}}}function An(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Ln(e,t){return t+1<e.length&&An(e,t)}function bn(e,t){if(t+1<e.length&&An(e,t)){var r=4,i=Sn(e,t),n=r;null!=i&&i.frameLength&&(n=i.frameLength);var a=t+n;return a===e.length||Ln(e,a)}return!1}var Rn=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},In=function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this)).observer=void 0,i.observer=e,i}return Xm(r,[{key:"resetInitSegment",value:function(e,t,i,n){Qf(Xf(r.prototype),"resetInitSegment",this).call(this,e,t,i,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=Dn(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=Wi(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==hn(t)&&Rn(e,r)<16}}]),r}(vn);function Dn(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 wn=/\/emsg[-/]ID3/i;function _n(e,t){return _(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var Pn=function(){function e(t,r,i){qm(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new nr(r,{removePKCS7Padding:!1})}return Xm(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,ut)}},{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=uy(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=tr(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}(),Cn=function(){function e(){qm(this,e),this.VideoSample=null}return Xm(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=$t(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=$t(g.data,t))}return e.naluState=s,l}}]),e}(),xn=function(){function e(t){qm(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}return Xm(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):(t=(e-=this.bitsAvailable)>>3,e-=t<<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&&te.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}(),Mn=function(e){Ym(r,e);var t=Wm(r);function r(){return qm(this,r),t.apply(this,arguments)}return Xm(r,[{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)),ey(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)}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,er(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 xn(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 xn(e),f=0,v=0,g=0,p=0,m=pE(t=d.readUByte).call(t,d),y=pE(r=d.readBits).call(r,d),E=pE(i=d.readUEG).call(i,d),k=pE(n=d.readBoolean).call(n,d),T=pE(a=d.skipBits).call(a,d),S=pE(s=d.skipEG).call(s,d),A=pE(o=d.skipUEG).call(o,d),L=pE(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(),w=E(),_=y(1);0===_&&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-(_?2:4)*(g+p),pixelRatio:P}}}]),r}(Cn),On=function(e){Ym(r,e);var t=Wm(r);function r(){var e,i;qm(this,r);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return(i=t.call.apply(t,py(e=[this]).call(e,a))).initVPS=null,i}return Xm(r,[{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)),ey(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;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,er(i.data,2,r.pts,t.samples);break;case 32:if(n=!0,!e.vps){var h=a.readVPS(i.data);e.params=z({},h),a.initVPS=i.data}e.vps=[i.data];break;case 33:if(n=!0,l=!0,"object"==qh(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"==qh(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){Qf(Xf(r.prototype),"pushAccessUnit",this).call(this,e,t),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new xn(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 xn(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(),w=a.readBoolean(),_=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 W=0,q=0;q<=V;q++){var z=a.readBoolean(),X=!1;z||(X=a.readBoolean()),(z||X)&&W++}V=W}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())),a.readBoolean()&&(a.readUEG(),a.readUEG()),a.readBoolean(),a.readBoolean(),a.readBoolean(),(ue=a.readBoolean())&&(_+=a.readUEG(),P+=a.readUEG(),C+=a.readUEG(),x+=a.readUEG()),a.readBoolean()&&(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(w||ue){var Te=1,Se=1;1===R?Te=Se=2:2==R&&(Te=2),Ee=I-Te*P-Te*_,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);return 1===u&&"2"===Ie&&(Ie="6"),{codecString:py(t=py(r=py(i=py(n="hvc1.".concat(Ae)).call(n,u,".")).call(i,Ie,".")).call(r,l?"H":"L")).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 xn(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)}}]),r}(Cn),Fn=188,Nn=function(){function e(t,r,i,n){qm(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=r,this.typeSupported=i,this.logger=n,this.videoParser=null}return Xm(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=$t(this.remainderData,t)).length,this.remainderData=null),E<Fn&&!a)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var k=Math.max(0,e.syncOffset(t));(E-=(E-k)%Fn)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var T=0,S=k;S<E;S+=Fn)if(71===t[S]){var A=!!(64&t[S+1]),L=Un(t,S),b=void 0;if((48&t[S+3])>>4>1){if((b=S+5+t[S+4])===S+Fn)continue}else b=S+4;switch(L){case c:if(A){if(h&&(i=Vn(h,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new Mn;break;case"hevc":this.videoParser=new On}null!==this.videoParser&&this.videoParser.parsePES(s,u,i,!1)}h={data:[],size:0}}h&&(h.data.push(t.subarray(b,S+Fn)),h.size+=S+Fn-b);break;case d:if(A){if(v&&(i=Vn(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+Fn)),v.size+=S+Fn-b);break;case f:A&&(g&&(i=Vn(g,this.logger))&&this.parseID3PES(l,i),g={data:[],size:0}),g&&(g.data.push(t.subarray(b,S+Fn)),g.size+=S+Fn-b);break;case 0:A&&(b+=t[b]+1),y=this._pmtId=Bn(t,b);break;case y:var R,I;A&&(b+=t[b]+1);var D=Gn(t,b,this.typeSupported,n,this.observer,this.logger);(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(py(R=py(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&&Kn(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 w={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(w),w}},{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=Vn(s,this.logger))){if(null===this.videoParser)switch(i.segmentCodec){case"avc":this.videoParser=new Mn;break;case"hevc":this.videoParser=new On}null!==this.videoParser&&(this.videoParser.parsePES(i,a,t,!0),i.pesData=null)}else i.pesData=s;if(o&&(t=Vn(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=Vn(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 Pn(this.observer,this.config,t);return this.decrypt(i,n)}},{key:"decrypt",value:function(e,t){return new RR((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=$t(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&&!Qi(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",Kn(this.observer,new Error(h),d,this.logger),!d)return}if(Ji(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=Zi(e.samplerate);n=s.sample.pts+f}for(var v,g=0;r<i;){if(r+=(v=en(e,o,r,n,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!Qi(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(Ln(r,a)){var o=Tn(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=Dn(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=W({},t,{type:this._videoTrack?dn.emsg:dn.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-Fn)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=Fn){if(71!==e[o]||t-o!==Fn&&71!==e[o+Fn]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-Fn)+1),n||(n=0===Un(e,o)),n&&s>1&&(0===a&&s>2||o+Fn>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:Ot[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function Un(e,t){return((31&e[t+1])<<8)+e[t+2]}function Bn(e,t){return(31&e[t+10])<<8|e[t+11]}function Gn(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=Un(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Hn("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){Hn("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){Hn("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;){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 Kn(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 Kn(e,t,r,i){i.warn("parsing error: ".concat(t.message)),e.emit(O.ERROR,O.ERROR,{type:x.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Hn(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function Vn(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]=$t(l[0],l[1]),UE(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 jn=function(){function e(){qm(this,e)}return Xm(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}(),Yn=Math.pow(2,32)-1,Wn=function(){function e(){qm(this,e)}return Xm(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=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=8,a=r.length,s=a;a--;)n+=r[a].byteLength;var o=new Uint8Array(n);for(o[0]=n>>24&255,o[1]=n>>16&255,o[2]=n>>8&255,o[3]=255&n,o.set(e,4),a=0,n=8;a<s;a++)o.set(r[a],n),n+=r[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/(Yn+1)),n=Math.floor(r%(Yn+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,py(r=py(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,py(r=[e.types.mvex]).call(r,n))}},{key:"mvhd",value:function(t,r){r*=t;var i=Math.floor(r/(Yn+1)),n=Math.floor(r%(Yn+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=V_(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=py(l).call(l,uy(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=py(u).call(u,uy(Array.prototype).call(s));var c=e.box(e.types.avcC,new Uint8Array(py(r=py(i=py(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(py(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,pf(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/(Yn+1)),o=Math.floor(i%(Yn+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/(Yn+1)),s=Math.floor(r%(Yn+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=V_(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 $t(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,Ck(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}();function qn(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 zn(e){return qn(e,1e3,1/9e4,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}Wn.types=void 0,Wn.HDLR_TYPES=void 0,Wn.STTS=void 0,Wn.STSC=void 0,Wn.STCO=void 0,Wn.STSZ=void 0,Wn.VMHD=void 0,Wn.SMHD=void 0,Wn.STSD=void 0,Wn.FTYP=void 0,Wn.DINF=void 0;var Xn,Qn=null,$n=null,Jn=function(){function e(t,r,i,n){if(qm(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=r,this.typeSupported=i,this.logger=n,this.ISGenerated=!1,null===Qn){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qn=a?Ck(a[1]):0}if(null===$n){var s=navigator.userAgent.match(/Safari\/(\d+)/i);$n=s?Ck(s[1]):0}}return Xm(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=eS(e).call(e,(function(e,i){var n=i.pts,a=n-e;return a<-4294967296&&(t=!0,a=(n=Zn(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(py(w="[mp4-remuxer]: Dropped ".concat(D," out of ")).call(w,y," video samples due to a missing keyframe"));var P=this.getVideoStartPts(t.samples);t.samples=uy(_=t.samples).call(_,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=(Zn(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===K?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=ea(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=ta(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):Wn.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:Wn.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,Zn(l[0].dts,v)-g),n=Math.min(n,v-g)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Qm(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-Zn(o[0].dts,o[0].pts);Qn&&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=Zn(T.pts-E,h),T.dts=Zn(T.dts-E,h),T.dts<o[k>0?k-1:k].dts&&(p=!0)}p&&gT(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,b,R,I,D,w,_=n-h,P=_>A,C=_<-1;if((P||C)&&(P?this.logger.warn(py(L=py(b=py(R="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(R,zn(_,!0)," ms (")).call(b,_,"dts) hole between fragments detected at ")).call(L,t.toFixed(3))):this.logger.warn(py(I=py(D=py(w="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(w,zn(-_,!0)," ms (")).call(D,_,"dts) overlapping between fragments detected at ")).call(I,t.toFixed(3))),!C||h>=o[0].pts||Qn)){var F,N;n=h;var U=o[0].pts-_;if(P)o[0].dts=n,o[0].pts=U;else for(var B=!0,G=0;G<o.length&&!(o[G].dts>U&&B);G++){var K=o[G].pts;if(o[G].dts-=_,o[G].pts-=_,G<o.length-1){var H=o[G+1].pts;B=H<=o[G].pts==H<=K}}this.logger.log(py(F=py(N="Video: Initial PTS/DTS adjusted: ".concat(zn(U,!0),"/")).call(N,zn(n,!0),", delta: ")).call(F,zn(_,!0)," ms"))}}for(var V=0,j=0,Y=n=Math.max(0,n),q=0;q<u;q++){for(var z=o[q],X=z.units,Q=X.length,$=0,J=0;J<Q;J++)$+=X[J].data.length;j+=$,V+=Q,z.length=$,z.dts<Y?(z.dts=Y,Y+=A/4|0||1):Y=z.dts,v=Math.min(z.pts,v),g=Math.max(z.pts,g)}a=o[u-1].dts;var Z,ee=j+4*V+8;try{Z=new Uint8Array(ee)}catch(Pe){return void this.observer.emit(O.ERROR,O.ERROR,{type:x.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:Pe,bytes:ee,reason:"fail allocating video mdat ".concat(ee)})}var te=new DataView(Z.buffer);te.setUint32(0,ee),Z.set(Wn.types.mdat,4);for(var re=!1,ie=Number.POSITIVE_INFINITY,ne=Number.POSITIVE_INFINITY,ae=Number.NEGATIVE_INFINITY,se=Number.NEGATIVE_INFINITY,oe=0;oe<u;oe++){for(var le=o[oe],ue=le.units,ce=void 0,he=0,de=0,fe=ue.length;de<fe;de++){var ve=ue[de],ge=ve.data,pe=ve.data.byteLength;te.setUint32(d,pe),d+=4,Z.set(ge,d),d+=pe,he+=4+pe}if(oe<u-1)f=o[oe+1].dts-le.dts,ce=o[oe+1].pts-le.pts;else{var me=this.config,ye=oe>0?le.dts-o[oe-1].dts:A;if(ce=oe>0?le.pts-o[oe-1].pts:A,me.stretchShortVideoTrack&&null!==this.nextAudioPts){var Ee,ke=Math.floor(me.maxBufferHole*s),Te=(i?v+i*s:this.nextAudioPts)-le.pts;Te>ke?((f=Te-ye)<0?f=ye:re=!0,this.logger.log(py(Ee="[mp4-remuxer]: It is approximately ".concat(Te/90," ms to the next segment; using duration ")).call(Ee,f/90," ms for the last video frame."))):f=ye}else f=ye}var Se=Math.round(le.pts-le.dts);ie=Math.min(ie,f),ae=Math.max(ae,f),ne=Math.min(ne,ce),se=Math.max(se,ce),l.push(new ra(le.key,f,he,Se))}if(l.length)if(Qn){if(Qn<70){var Ae=V_(l[0]);Ae.dependsOn=2,Ae.isNonSync=0}}else if($n&&se-ne<ae-ie&&A/ae<.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 Le=n,be=0,Re=l.length;be<Re;be++){var Ie=Le+l[be].duration,De=Le+l[be].cts;if(be<Re-1){var we=Ie+l[be+1].cts;l[be].duration=we-De}else l[be].duration=be?l[be-1].duration:A;l[be].cts=0,Le=Ie}}f=re||!f?A:f,this.nextAvcDts=h=a+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;var _e={data1:Wn.moof(e.sequenceNumber++,n,W({},e,{samples:l})),data2:Z,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,_e}},{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(Zn(f[0].pts-m,p)-g)<20*l),ey(f).call(f,(function(e){e.pts=Zn(e.pts-m,p)})),!r||g<0){if(!(f=Jm(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)0===E&&(this.logger.warn(py(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(py(R=py(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 w=0;w<D;w++){var _=Math.max(k,0),P=jn.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()),UE(f).call(f,E,0,{unit:P,pts:_}),k+=l,E++}}S.pts=k,k+=l}for(var C,F=null,N=null,U=0,B=f.length;B--;)U+=f[B].unit.byteLength;for(var G=0,K=f.length;G<K;G++){var H=f[G],V=H.unit,j=H.pts;if(null!==N)h[G-1].duration=Math.round((j-N)/s);else{if(r&&"aac"===e.segmentCodec&&(j=g),F=j,!(U>0))return;U+=v;try{C=new Uint8Array(U)}catch(Z){return void this.observer.emit(O.ERROR,O.ERROR,{type:x.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:Z,bytes:U,reason:"fail allocating audio mdat ".concat(U)})}c||(new DataView(C.buffer).setUint32(0,U),C.set(Wn.types.mdat,4))}C.set(V,v);var Y=V.byteLength;v+=Y,h.push(new ra(!0,o,Y,0)),N=j}var q=h.length;if(q){var z=h[h.length-1];this.nextAudioPts=g=N+s*z.duration;var X=c?new Uint8Array(0):Wn.moof(e.sequenceNumber++,F/s,W({},e,{samples:h}));e.samples=[];var Q=F/a,$=g/a,J={data1:X,data2:C,startPTS:Q,endPTS:$,startDTS:Q,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,J}}}]),e}();function Zn(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 ea(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=Zn(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=Zn(o.dts-i.baseTime*a/i.timescale,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function ta(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=Zn(o.pts-r.baseTime*a/r.timescale,t*a)/a}gT(i=e.samples).call(i,(function(e,t){return e.pts-t.pts}));var l=e.samples;return e.samples=[],{samples:l}}}var ra=Xm((function e(t,r,i,n){qm(this,e),this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=r,this.size=i,this.cts=n,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}}));function ia(e,t){var r=null==e?void 0:e.codec;return r&&r.length>4?r:t===Rt?"ec-3"===r||"ac-3"===r||"alac"===r?r:"fLaC"===r||"Opus"===r?de(r,!1):(te.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"):(te.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1")}try{var na;Xn=pE(na=self.performance.now).call(na,self.performance)}catch(Ho){Xn=w_}var aa=[{demux:function(){function e(t,r){qm(this,e),this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=r}return Xm(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,i){var n=this.videoTrack=fn("video",1),a=this.audioTrack=fn("audio",1),s=this.txtTrack=fn("text",1);if(this.id3Track=fn("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=jt(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=Ot.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=$t(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=Ht(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=dt(e,0,i.byteOffset-8),t.remainder=dt(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=Jt(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=Jt(e,t),{videoTrack:t,audioTrack:fn(),id3Track:i,textTrack:fn()}}},{key:"extractID3Track",value:function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var n=Ht(e.samples,["emsg"]);n&&ey(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"!==Ft(e.subarray(u,u+1));)r+=Ft(e.subarray(u,u+1)),u+=1;for(r+=Ft(e.subarray(u,u+1)),u+=1;"\0"!==Ft(e.subarray(u,u+1));)i+=Ft(e.subarray(u,u+1)),u+=1;i+=Ft(e.subarray(u,u+1)),u+=1,n=Ut(e,12),a=Ut(e,16),o=Ut(e,20),l=Ut(e,24),u=28}else if(1===t){n=Ut(e,u+=4);var c=Ut(e,u+=4),h=Ut(e,u+=4);for(u+=4,s=Math.pow(2,32)*c+h,P(s)||(s=bT,te.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Ut(e,u),l=Ut(e,u+=4),u+=4;"\0"!==Ft(e.subarray(u,u+1));)r+=Ft(e.subarray(u,u+1)),u+=1;for(r+=Ft(e.subarray(u,u+1)),u+=1;"\0"!==Ft(e.subarray(u,u+1));)i+=Ft(e.subarray(u,u+1)),u+=1;i+=Ft(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(wn.test(a.schemeIdUri)){var s=_n(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:dn.emsg,duration:o})}else if(r.config.enableEmsgKLVMetadata&&AS(n=a.schemeIdUri).call(n,"urn:misb:KLV:bin:1910.1")){var u=_n(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:u,pts:u,type:dn.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return i}},{key:"demuxSampleAes",value:function(e,t,r){return RR.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=Ut(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}(),remux:function(){function e(t,r,i,n){qm(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=n}return Xm(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,r){if(!e||!t)return e;var i=t.keyId;return i&&t.isCommonEncryption&&ey(r=Ht(e,["moov","trak"])).call(r,(function(e){var t=Ht(e,["mdia","minf","stbl","stsd"])[0].subarray(8),r=Ht(t,["enca"]),n=r.length>0;n||(r=Ht(t,["encv"])),ey(r).call(r,(function(e){var t;ey(t=Ht(n?e.subarray(28):e.subarray(78),["sinf"])).call(t,(function(e){var t=Xt(e);if(t){var r,a,s=t.subarray(8,24);Sy(s).call(s,(function(e){return 0!==e}))||(te.log(py(r=py(a="[eme] Patching keyId in 'enc".concat(n?"a":"v",">sinf>>tenc' box: ")).call(a,pt(s)," -> ")).call(r,pt(i))),t.set(i,8))}}))}))})),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=jt(e);i.audio&&(t=ia(i.audio,Rt)),i.video&&(r=ia(i.video,It));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,u,c=this.initPTS,h=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};_(h)||(h=this.lastEndTime=n||0);var f=t.samples;if(null==f||!f.length)return d;var v={initPTS:void 0,timescale:1},g=this.initData;if(null!=(l=g)&&l.length||(this.generateInitSegment(f),g=this.initData),null==(u=g)||!u.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);var p,m,y=function(e,t){for(var r=0,i=0,n=0,a=Ht(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],l=Ht(o,["tfhd"])[0],u=t[Ut(l,4)];if(u){var c=u.default,h=Ut(l,0)|(null==c?void 0:V_(c)),d=null==c?void 0:c.duration;8&h&&(d=Ut(l,2&h?12:8));for(var f=u.timescale||9e4,v=Ht(o,["trun"]),g=0;g<v.length;g++)!(r=Qt(v[g]))&&d&&(r=d*Ut(v[g],4)),u.type===It?i+=r/f:u.type===Rt&&(n+=r/f)}}if(0===i&&0===n){for(var p=1/0,m=0,y=0,E=Ht(e,["sidx"]),k=0;k<E.length;k++){var T=Vt(E[k]);if(null!=T&&T.references){var S;p=Math.min(p,T.earliestPresentationTime/T.timescale);var A=eS(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&&_(y))return y}return i||n}(f,g),E=(p=g,eS(m=Ht(f,["moof","traf"])).call(m,(function(e,t){var r,i=Ht(t,["tfdt"])[0],n=i[0],a=eS(r=Ht(t,["tfhd"])).call(r,(function(e,t){var r=Ut(t,4),a=p[r];if(a){var s=Ut(i,4);if(1===n){if(s===xt)return te.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;s*=xt+1,s+=Ut(i,8)}var o=s/(a.timescale||9e4);if(_(o)&&(null===e||o<e))return o}return e}),null);return null!==a&&_(a)&&(null===e||a<e)?a:e}),null)),k=null===E?n:E;(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}(c,k,n,y)||v.timescale!==c.timescale&&a)&&(v.initPTS=k-n,c&&1===c.timescale&&this.logger.warn(py(s=py(o="Adjusting initPTS @".concat(n," from ")).call(o,c.baseTime/c.timescale," to ")).call(s,v.initPTS)),this.initPTS=c={baseTime:v.initPTS,timescale:1});var T=e?k-c.baseTime/c.timescale:h,S=T+y;!function(e,t,r,i){ey(i=Ht(t,["moof","traf"])).call(i,(function(t){var i;ey(i=Ht(t,["tfhd"])).call(i,(function(i){var n,a=Ut(i,4),s=e[a];if(s){var o=s.timescale||9e4;ey(n=Ht(t,["tfdt"])).call(n,(function(e){var t=e[0],i=r*o;if(i){var n=Ut(e,4);if(0===t)n-=i,Kt(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=Ut(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(xt+1)),s=Math.floor(n%(xt+1));Kt(e,4,a),Kt(e,8,s)}}}))}}))}))}(g,f,c.baseTime/c.timescale),y>0?this.lastEndTime=S:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var A=!!g.audio,L=!!g.video,b="";A&&(b+="audio"),L&&(b+="video");var R={data1:f,startPTS:T,startDTS:T,endPTS:S,endDTS:S,type:b,hasAudio:A,hasVideo:L,nb:1,dropped:0};return d.audio="audio"===R.type?R:void 0,d.video="audio"!==R.type?R:void 0,d.initSegment=v,d.id3=ea(r,n,c,c),i.samples.length&&(d.text=ta(i,n,c)),d}}]),e}()},{demux:Nn,remux:Jn},{demux:function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n;return qm(this,r),(n=t.call(this)).observer=void 0,n.config=void 0,n.observer=e,n.config=i,n}return Xm(r,[{key:"resetInitSegment",value:function(e,t,i,n){Qf(Xf(r.prototype),"resetInitSegment",this).call(this,e,t,i,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(i=t)+5<(r=e).length&&qi(r,i)&&Xi(r,i)<=r.length-i;var r,i}},{key:"appendFrame",value:function(e,t,r){Ji(e,this.observer,t,r,e.manifestCodec);var i=en(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=Wi(e,0),i=(null==r?void 0:r.length)||0;if(bn(e,i))return!1;for(var n=e.length;i<n;i++)if($i(e,i))return t.log("ADTS sync word found !"),!0;return!1}}]),r}(vn),remux:Jn},{demux:function(e){Ym(r,e);var t=Wm(r);function r(){return qm(this,r),t.apply(this,arguments)}return Xm(r,[{key:"resetInitSegment",value:function(e,t,i,n){Qf(Xf(r.prototype),"resetInitSegment",this).call(this,e,t,i,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 An(r=e,i=t)&&4<=r.length-i;var r,i}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return Tn(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=Wi(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==hn(t)&&Rn(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(bn(e,r))return te.log("MPEG Audio sync word found !"),!0;return!1}}]),r}(vn),remux:Jn}];UE(aa).call(aa,2,0,{demux:In,remux:Jn});var sa=function(){function e(t,r,i,n,a,s){qm(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=r,this.config=i,this.id=a,this.logger=s}return Xm(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=Xn();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u,c,h=i||o,d=h.contiguous,f=h.discontinuity,v=h.trackSwitch,g=h.accurateTimeOffset,p=h.timeOffset,m=h.initSegmentChange,y=l.audioCodec,E=l.videoCodec,k=l.defaultInitPts,T=l.duration,S=l.initSegmentData,A=(u=t,c=null,s.byteLength>0&&null!=(null==u?void 0:u.key)&&null!==u.iv&&null!=u.method&&(c=u),c);if(A&&br(A.method)){var L=this.getDecrypter(),b=Rr(A.method);if(!L.isSync())return this.asyncResult=!0,this.decryptionPromise=L.webCryptoDecrypt(s,A.key.buffer,A.iv.buffer,b).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var R=L.softwareDecrypt(s,A.key.buffer,A.iv.buffer,b);if(r.part>-1){var I=L.flush();R=I?I.buffer:I}if(!R)return a.executeEnd=Xn(),oa(r);s=new Uint8Array(R)}var D=this.needsProbing(f,v);if(D){var w=this.configureTransmuxer(s);if(w)return this.logger.warn("[transmuxer] ".concat(w.message)),this.observer.emit(O.ERROR,O.ERROR,{type:x.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),a.executeEnd=Xn(),oa(r)}(f||v||m||D)&&this.resetInitSegment(S,y,E,T,t),(f||m||D)&&this.resetInitialTimestamp(k),d||this.resetContiguity();var _=this.transmux(s,A,p,g,r);this.asyncResult=la(_);var P=this.currentTransmuxState;return P.contiguous=!0,P.discontinuity=!1,P.trackSwitch=!1,a.executeEnd=Xn(),_}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=Xn();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=Xn();var h=[oa(e)];return this.asyncResult?RR.resolve(h):h}var d=u.flush(o);return la(d)?(this.asyncResult=!0,d.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,d,e),this.asyncResult?RR.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(py(i=py(n=py(a=py(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===G?"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=Xn()}},{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=aa.length;a<s;a++){var o;if(null!=(o=aa[a].demux)&&o.probe(e,this.logger)){t=aa[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 nr(this.config)),e}}]),e}(),oa=function(e){return{remuxResult:{},chunkMeta:e}};function la(e){return"then"in e&&e.then instanceof Function}var ua=Xm((function e(t,r,i,n,a){qm(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=r,this.initSegmentData=i,this.duration=n,this.defaultInitPts=a||null})),ca=Xm((function e(t,r,i,n,a,s){qm(this,e),this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=r,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=a,this.initSegmentChange=s})),ha=0,da=function(){function e(t,r,i,n){var a=this;qm(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=ha++,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=a.hls;if(r&&null!=t&&t.event&&t.instanceNo===a.instanceNo)switch(t.event){case"init":var i,n=null==(i=a.workerContext)?void 0:i.objectURL;n&&e_.revokeObjectURL(n);break;case"transmuxComplete":a.handleTransmuxComplete(t.data);break;case"flush":a.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=a.frag,t.data.part=a.part,t.data.id=a.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){var t,r;if(a.hls){var i=new Error(py(t=py(r="".concat(e.message," (")).call(r,e.filename,":")).call(t,e.lineno,")"));a.hls.config.enableWorker=!1,a.hls.logger.warn('Error in "'.concat(a.id,'" Web Worker, fallback to inline')),a.hls.trigger(O.ERROR,{type:x.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})}};var s=t.config;this.hls=t,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var o=function(e,t){(t=t||{}).frag=a.frag||void 0,e===O.ERROR&&(t.parent=a.id,t.part=a.part,a.error=t.error),a.hls.trigger(e,t)};this.observer=new Gi,this.observer.on(O.FRAG_DECRYPTED,o),this.observer.on(O.ERROR,o);var l=ge(s.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var u=this.hls.logger;if(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{var c;s.workerPath?(u.log(py(c="loading Web Worker ".concat(s.workerPath,' for "')).call(c,r,'"')),this.workerContext=function(e){var t=Hi[e];if(t)return t.clientCount++,t;var r=new e_(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return Hi[e]=i,i}(s.workerPath)):(u.log('injecting Web Worker for "'.concat(r,'"')),this.workerContext=function(){var e=Hi[Ki];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=e_.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return Hi[Ki]=i,i}());var h=this.workerContext.worker;h.addEventListener("message",this.onWorkerMessage),h.addEventListener("error",this.onWorkerError),h.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:l,id:r,config:x_(s)})}catch(Ho){u.warn('Error setting up "'.concat(r,'" Web Worker, fallback to inline'),Ho),this.terminateWorker(),this.error=null,this.transmuxer=new sa(this.observer,l,s,"",r,t.logger)}return}}this.transmuxer=new sa(this.observer,l,s,"",r,t.logger)}return Xm(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=ha++;var t=this.hls.config,r=ge(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:x_(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=Hi[e||Ki];if(t&&1==t.clientCount--){var r=t.worker,i=t.objectURL;delete Hi[e||Ki],i&&e_.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 ca(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(py(I=py(D=py(w=py(_=py(P=py(C=py(x=py(M=py(O=py(F=py(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===G?"level":"track",": ")).call(M,l.level," id: ")).call(x,l.id,"\n discontinuity: ")).call(C,y,"\n trackSwitch: ")).call(P,E,"\n contiguous: ")).call(_,A,"\n accurateTimeOffset: ")).call(w,o,"\n timeOffset: ")).call(D,g,"\n initSegmentChange: ")).call(I,b));var U=new ua(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);la(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);la(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(O.ERROR,{type:x.MEDIA_ERROR,details:M.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;ey(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 fa(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!va(e[r].attrs,t[r].attrs))return!1;return!0}function va(e,t,r){var i,n=e["STABLE-RENDITION-ID"];return n&&!r?n===t["STABLE-RENDITION-ID"]:!Sy(i=r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).call(i,(function(r){return e[r]!==t[r]}))}function ga(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var pa=function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n;return qm(this,r),(n=t.call(this,i,e.logger)).hls=void 0,n.canLoad=!1,n.timer=-1,n.hls=e,n}return Xm(r,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,r){var 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 e_(s.URI,t.url).href}catch(f){this.warn("Could not construct new URL for Rendition Report: ".concat(f)),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=Ck(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),c=Ck(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&&be(r);return new Re(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(r){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(r))}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=w_()-s;var o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){var l,u=Math.max(o||0,0);i.appliedTimelineOffset=u,ey(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&&di(r,i),-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);var d,f,v,g=this.hls.mainForwardBufferInfo,p=g?g.end-g.len:0,m=gi(i,1e3*(i.edge-p));if(i.requestScheduled+m<a?i.requestScheduled=a:i.requestScheduled+=m,this.log(py(c="live playlist ".concat(e," ")).call(c,i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;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?(f=k+1,v=y?0:T):(f=E,v=y?T+1:i.maxPartIndex):f=k+1;var A=i.age,L=A+i.ageHeader,b=Math.min(L-i.partTarget,1.5*i.targetduration);if(b>0){var R,I;if(L>3*i.targetduration)this.log("Playlist last advanced ".concat(A.toFixed(2),"s ago. Omitting segment and part directives.")),f=void 0,v=void 0;else if(null!=r&&r.tuneInGoal&&L-i.partTarget>r.tuneInGoal)this.warn(py(R=py(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);f+=C,void 0!==v&&(v+=Math.round(b%i.targetduration/i.partTarget)),this.log(py(D=py(w=py(_=py(P="CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ")).call(P,A.toFixed(2),"s goal: ")).call(_,b," skip sn ")).call(w,C," to part ")).call(D,v))}i.tuneInGoal=b}if(d=this.getDeliveryDirectives(i,t.deliveryDirectives,f,v),y||!S)return i.requestScheduled=a,void this.loadingPlaylist(h,d)}else(i.canBlockReload||i.canSkipUntil)&&(d=this.getDeliveryDirectives(i,t.deliveryDirectives,f,v));d&&void 0!==f&&i.canBlockReload&&(i.requestScheduled=n.loading.first+Math.max(m-2*s,m/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(py(i="reload live playlist ".concat(e.name||e.bitrate+"bps"," in ")).call(i,Math.round(l)," ms")),this.clearTimer(),this.timer=mE((function(){return n.loadingPlaylist(e,t)}),l)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,i){var n=be(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Se),new Re(r,i,n)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,i=Ve(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===$e||!n.resolved&&s===Xe);if(c){var h,d,f;if(l>=u.maxNumRetry)return!1;if(i&&null!=(f=e.context)&&f.deliveryDirectives)this.warn(py(h=py(d="Retrying playlist loading ".concat(l+1,"/")).call(d,u.maxNumRetry,' after "')).call(h,r,'" without delivery-directives')),this.loadPlaylist();else{var v,g,p,m=Ye(u,l);this.clearTimer(),this.timer=mE((function(){return t.loadPlaylist()}),m),this.warn(py(v=py(g=py(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}}]),r}(X),ma=function(){function e(t){qm(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t}return Xm(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 RR((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 RR((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&&ey(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(),UE(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(a){var i;if(r.onError(a),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>":py(e=py(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]?py(t=py(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?py(t=py(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:Dy(t=r[e]).call(t,(function(e){return e.label})).join(", "))||""}}]),e}(),ya=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Ea="HlsJsTrackRemovedError",ka=function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,e)).name=Ea,i}return Xm(r)}(jm(Error));function Ta(e){var t,r=e.querySelectorAll("source");ey(t=uy([]).call(r)).call(t,(function(t){e.removeChild(t)}))}function Sa(e){return"audio"===e?1:0}var Aa=function(){function e(t){qm(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return Xm(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(O.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(O.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.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&&_(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);s!==this.autoLevelCapping&&a.logger.log(py(t=py(r=py(i=py(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=Jm(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=gE(pE(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;return!Sy(t=this.restrictedLevels).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}(),La={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},ba={DASH:"d",HLS:"h",SMOOTH:"s",OTHER:"o"},Ra="CMCD-Request",Ia=($h(i={},"CMCD-Object",["br","d","ot","tb"]),$h(i,Ra,["bl","dl","mtp","nor","nrr","su"]),$h(i,"CMCD-Session",["cid","pr","sf","sid","st","v"]),$h(i,"CMCD-Status",["bs","rtp"]),i),Da=Xm((function e(t,r){qm(this,e),sy(t)&&(t=Dy(t).call(t,(function(t){return t instanceof e?t:new e(t)}))),this.value=t,this.params=r}));function wa(e,t,r,i){var n,a,s;return new Error(py(n=py(a="failed to ".concat(e,' "')).call(a,(s=t,sy(s)?x_(s):s instanceof Y_?"Map{}":s instanceof xx?"Set{}":"object"==qh(s)?x_(s):String(s)),'" as ')).call(n,r),{cause:i})}function _a(e,t,r){return wa("serialize",e,t,r)}var Pa=Xm((function e(t){qm(this,e),this.description=t})),Ca="Bare Item";function xa(e){if(!1===ArrayBuffer.isView(e))throw _a(e,"Byte Sequence");return":".concat((t=e,btoa(String.fromCharCode.apply(String,pf(t)))),":");var t}function Ma(e){if((t=e)<-999999999999999||999999999999999<t)throw _a(e,"Integer");var t;return e.toString()}function Oa(e){var t=nn(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw _a(e,"Decimal");var r=t.toString();return zx(r).call(r,".")?r:"".concat(r,".0")}var Fa=/[\x00-\x1f\x7f]+/;function Na(e){var t,r,i=(r=e).description||uy(t=r.toString()).call(t,7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw _a(i,"Token");return i}function Ua(e){switch(qh(e)){case"number":if(!_(e))throw _a(e,Ca);return Xx(e)?Ma(e):Oa(e);case"string":return function(e){if(Fa.test(e))throw _a(e,"String");return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(e);case"symbol":return Na(e);case"boolean":return function(e){if("boolean"!=typeof e)throw _a(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return"@".concat(Ma(e.getTime()/1e3));if(e instanceof Uint8Array)return xa(e);if(e instanceof Pa)return Na(e);default:throw _a(e,Ca)}}function Ba(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw _a(e,"Key");return e}function Ga(e){var t;return null==e?"":Dy(t=nM(e)).call(t,(function(e){var t,r=mf(e,2),i=r[0],n=r[1];return!0===n?";".concat(Ba(i)):py(t=";".concat(Ba(i),"=")).call(t,Ua(n))})).join("")}function Ka(e){var t;return e instanceof Da?py(t="".concat(Ua(e.value))).call(t,Ga(e.params)):Ua(e)}function Ha(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!=qh(e))throw _a(e,"Dict");var i=e instanceof Y_?dM(e).call(e):nM(e),n=(null==r?void 0:r.whitespace)?" ":"";return Dy(t=ly(i)).call(t,(function(e){var t,r,i=mf(e,2),n=i[0],a=i[1];a instanceof Da==0&&(a=new Da(a));var s,o=Ba(n);return!0===a.value?o+=Ga(a.params):(o+="=",sy(a.value)?o+=py(t="(".concat(Dy(r=(s=a).value).call(r,Ka).join(" "),")")).call(t,Ga(s.params)):o+=Ka(a)),o})).join(",".concat(n))}var Va=function(e){return Math.round(e)},ja=function(e){return 100*Va(e/100)},Ya={br:Va,d:Va,bl:ja,dl:ja,mtp:ja,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=function(e,t,r,i){var n=new e_(e),a=new e_(t);if(n.origin!==a.origin)return e;for(var s=uy(r=n.pathname.split("/")).call(r,1),o=uy(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:ja,tb:Va};function Wa(e,t){var r,i={};if(null==e||"object"!=qh(e))return i;var n=gT(r=Qm(e)).call(r),a=W({},Ya,null==t?void 0:t.formatters),s=null==t?void 0:Jm(t);return ey(n).call(n,(function(r){if(!(null==s?void 0:s(r))){var n,o=e[r],l=a[r];l&&(o=l(o,t)),"v"===r&&1===o||"pr"==r&&1===o||("number"==typeof(n=o)?_(n):null!=n&&""!==n&&!1!==n)&&(function(e){return"ot"===e||"sf"===e||"st"===e}(r)&&"string"==typeof o&&(o=new Pa(o)),i[r]=o)}})),i}function qa(e){var t,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?(t=Wa(e,i),r=W({whitespace:!1},i),Ha(t,r)):""}function za(e,t,r){return W(e,function(e){var t,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={};if(!e)return n;var a=nM(e),s=py(t=nM(Ia)).call(t,nM((null==i?void 0:i.customHeaderMap)||{})),o=eS(a).call(a,(function(e,t){var r,i,n=mf(t,2),a=n[0],o=n[1],l=(null===(r=TM(s).call(s,(function(e){var t;return zx(t=e[1]).call(t,a)})))||void 0===r?void 0:r[0])||Ra;return null!==(i=e[l])&&void 0!==i||(e[l]={}),e[l][a]=o,e}),{});return eS(r=nM(o)).call(r,(function(e,t){var r=mf(t,2),n=r[0],a=r[1];return e[n]=qa(a,i),e}),n)}(t,r))}var Xa=/CMCD=[^&#]+/;function Qa(e,t,r){var i,n,a=function(e){if(!e)return"";var t=qa(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return"CMCD=".concat(encodeURIComponent(t))}(t,r);if(!a)return e;if(Xa.test(e))return e.replace(Xa,a);var s=zx(e).call(e,"?")?"&":"?";return py(i=py(n="".concat(e)).call(n,s)).call(i,a)}function $a(e,t,r,i){var n;e&&ey(n=Qm(t)).call(n,(function(n){var a,s=Dy(a=Jm(e).call(e,(function(e){return e.groupId===n}))).call(a,(function(e){var a=W({},e);return a.details=void 0,a.attrs=new Tr(a.attrs),a.url=a.attrs.URI=Ja(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,pf(s))}))}function Ja(e,t,r,i){var n,a,s,o=i.HOST,l=i.PARAMS,u=i[r];t&&(s=null==u?void 0:u[t])&&(e=s);var c=new e_(e);return o&&!s&&(c.host=o),l&&ey(n=gT(a=Qm(l)).call(a)).call(n,(function(e){e&&c.searchParams.set(e,l[e])})),c.href}var Za=function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,"eme",e.logger)).hls=void 0,i.config=void 0,i.media=null,i.keyFormatPromise=null,i.keySystemAccessPromises={},i._requestLicenseFailureCount=0,i.mediaKeySessions=[],i.keyIdToKeySessionPromise={},i.setMediaKeysQueue=r.CDMCleanupPromise?[r.CDMCleanupPromise]:[],i.onMediaEncrypted=function(e){var t,r=e.initDataType,n=e.initData,a=py(t='"'.concat(e.type,'" event: init data type: "')).call(t,r,'"');if(i.debug(a),null!==n){var s,o;if("sinf"===r&&i.getLicenseServerUrl(Pr.FAIRPLAY)){var l=Ft(new Uint8Array(n));try{var u=Xt(Ir(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=Pr.FAIRPLAY}catch(L){var c;return void i.warn(py(c="".concat(a," Failed to parse sinf: ")).call(c,L))}}else if(i.getLicenseServerUrl(Pr.WIDEVINE)){var h,d=function(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,i=0;i+32<r;){var n=ir(new DataView(e,i));t.push(n),i+=n.size}return t}(n),f=Qm(i.keySystemAccessPromises);f.length||(f=Vr(i.config));var v=Jm(d).call(d,(function(e){var t=e.systemId?Kr(e.systemId):null;return!!t&&hy(f).call(f,t)>-1}))[0];if(!v)return void(0===d.length||Sy(d).call(d,(function(e){return!e.systemId}))?i.warn("".concat(a," contains incomplete or invalid pssh data")):i.log(py(h="ignoring ".concat(a," for ")).call(h,Dy(d).call(d,(function(e){return Kr(e.systemId)})).join(",")," pssh data in favor of playlist keys")));if(o=Kr(v.systemId),0===v.version&&v.data)if(o===Pr.WIDEVINE){var g=v.data.length-22;s=v.data.subarray(g,g+16)}else o===Pr.PLAYREADY&&(s=Wr(v.data))}if(o&&s){for(var p=pt(s),m=$f(i),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=pt(a.keyId);return p===o||-1!==hy(e=a.uri.replace(/-/g,"")).call(e,p)?(k=y[o],a.pssh||(delete y[o],a.pssh=new Uint8Array(n),a.keyId=s,(k=y[p]=k.then((function(){return i.generateRequestWithPreferredKeySession(t,r,n,"encrypted-event-key-match")}))).catch((function(e){return i.handleError(e)}))),"break"):void 0},S=0;S<E.length;S++){var A=T();if("continue"!==A&&"break"===A)break}k||(k=y[p]=i.getKeySystemSelectionPromise([o]).then((function(e){var t,a=e.keySystem,o=e.mediaKeys;i.throwIfDestroyed();var l=new zr("ISO-23001-7",p,null!=(t=Hr(a))?t:"");return l.pssh=new Uint8Array(n),l.keyId=s,i.attemptSetMediaKeys(a,o).then((function(){i.throwIfDestroyed();var e=i.createMediaKeySessionContext({decryptdata:l,keySystem:a,mediaKeys:o});return i.generateRequestWithPreferredKeySession(e,r,n,"encrypted-event-no-match")}))}))).catch((function(e){return i.handleError(e)}))}}},i.onWaitingForKey=function(e){i.log('"'.concat(e.type,'" event'))},i.hls=e,i.config=e.config,i.registerListeners(),i}return Xm(r,[{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(O.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(O.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===Pr.WIDEVINE&&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&&hy(r).call(r,e)===t},s=Jm(t=Dy(n).call(n,(function(e){return e.audioCodec}))).call(t,a),o=Jm(r=Dy(n).call(n,(function(e){return e.videoCodec}))).call(r,a);return s.length+o.length===0&&o.push("avc1.42e01e"),new RR((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 es?t:new es({type:x.KEY_SYSTEM_ERROR,details:M.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===Yr&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),RR.reject(new Error(i))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var i=this,n=function(e,t,r,i){var n,a,s,o;switch(e){case Pr.FAIRPLAY:n=["cenc","sinf"];break;case Pr.WIDEVINE:case Pr.PLAYREADY:n=["cenc"];break;case Pr.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return a=t,s=r,[{initDataTypes:n,persistentState:(o=i).persistentState||"optional",distinctiveIdentifier:o.distinctiveIdentifier||"optional",sessionTypes:o.sessionTypes||[o.sessionType||"temporary"],audioCapabilities:Dy(a).call(a,(function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:o.audioRobustness||"",encryptionScheme:o.audioEncryptionScheme||null}})),videoCapabilities:Dy(s).call(s,(function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:o.videoRobustness||"",encryptionScheme:o.videoEncryptionScheme||null}}))}]}(e,t,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e],s=null==a?void 0:a.keySystemAccess;if(!s){var o;this.log(py(o='Requesting encrypted media "'.concat(e,'" key-system access with config: ')).call(o,x_(n))),s=this.requestMediaKeySystemAccess(e,n);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){var r;i.log(py(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(py(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(py(t='Creating key-system session "'.concat(i,'" keyId: ')).call(t,pt(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),n="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,n,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 pt(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,i,n,a=e.mediaKeysSession;return this.log(py(r=py(i='Updating key-session "'.concat(a.sessionId,'" for keyID ')).call(i,pt((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=Qm(e.levelkeys||{});return this.keyFormatPromise||(this.log(py(t=py(r=py(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)),this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new RR((function(r,i){var n,a=Vr(t.config),s=Jm(n=Dy(e).call(e,Fr)).call(n,(function(e){return!!e&&-1!==hy(a).call(a,e)}));return t.getKeySystemSelectionPromise(s).then((function(e){var t=e.keySystem,n=Hr(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=py(t=py(r=py(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];return l||(l=this.getKeySystemForKeyPromise(a).then((function(t){var r,i,s,l=t.keySystem,u=t.mediaKeys;return n.throwIfDestroyed(),n.log(py(r=py(i=py(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)}))),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 es?this.hls.trigger(O.ERROR,e.data):this.hls.trigger(O.ERROR,{type:x.KEY_SYSTEM_ERROR,details:M.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=Fr(e.keyFormat),n=i?[i]:Vr(this.config);return this.attemptKeySystemAccess(n)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=Vr(this.config)),0===e.length)throw new es({type:x.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(x_({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r,i=this,n=uy(r=this.setMediaKeysQueue).call(r);this.log('Setting media-keys for "'.concat(e,'"'));var a=RR.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=Jm(t=i.setMediaKeysQueue).call(t,(function(e){return-1===hy(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(y){var d;if(this.warn(y.message),null!=(d=this.hls)&&d.config.debug)throw y}if(null===r)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),RR.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log(py(n=py(a=py(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 Gi,g=e._onmessage=function(t){var r,i,n=e.mediaKeysSession;if(n){var a=t.messageType,s=t.message;u.log(py(r=py(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===Pr.FAIRPLAY&&(u.updateKeySession(e,Dr("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){var r;if(e.mediaKeysSession){u.onKeyStatusChange(e);var i=e.keyStatus;v.emit("keyStatus",i),"expired"===i&&(u.warn(py(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 RR((function(e,t){v.on("error",t),v.on("keyStatus",(function(r){AS(r).call(r,"usable")?e():"output-restricted"===r?t(new es({type:x.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new es({type:x.KEY_SYSTEM_ERROR,details:M.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(py(t='Request generated for key-session "'.concat(null==(r=e.mediaKeysSession)?void 0:r.sessionId,'" keyId: ')).call(t,f))})).catch((function(e){throw new es({type:x.KEY_SYSTEM_ERROR,details:M.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;ey(t=e.mediaKeysSession.keyStatuses).call(t,(function(t,i){var n,a,s;r.log(py(n=py(a=py(s='key status change "'.concat(t,'" for keyStatuses keyId: ')).call(s,pt("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))," session keyId: ")).call(a,pt(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 t.loader(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching server certificate for "'.concat(e,'"')),new RR((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 es({type:x.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:z({url:s.url,data:void 0},t)},py(l=py(u=py(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 es({type:x.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:s.url,data:void 0}},py(o='"'.concat(e,'" certificate request timed out (')).call(o,i,")")))},onAbort:function(e,t,r){a(new Error("aborted"))}};r.load(s,l,u)}))):RR.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var i=this;return new RR((function(n,a){e.setServerCertificate(r).then((function(a){var s,o;i.log(py(s=py(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 es({type:x.KEY_SYSTEM_ERROR,details:M.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 es({type:x.KEY_SYSTEM_ERROR,details:M.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(!zx(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 Dr(atob(f))}},{key:"setupLicenseXHR",value:function(e,t,r,i){var n=this,a=this.config.licenseXhrSetup;return a?RR.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),RR.resolve({xhr:e,licenseChallenge:i}))}},{key:"requestLicense",value:function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new RR((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(g){r.error(g)}n(l)}else{var c,h,d=i.errorRetry,f=d?d.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>f||o.status>=400&&o.status<500)a(new es({type:x.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},py(c=py(h="License Request XHR failed (".concat(s,"). Status: ")).call(h,o.status," (")).call(c,o.statusText,")")));else{var v=f-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==Pr.PLAYREADY&&(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,i=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={},zr.clearKeyUriToKeyIdMap();var s=a.length;r.CDMCleanupPromise=RR.all(py(e=Dy(a).call(a,(function(e){return i.removeSession(e)}))).call(e,null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch((function(e){var t;i.log("Could not clear media keys: ".concat(e)),null==(t=i.hls)||t.trigger(O.ERROR,{type:x.OTHER_ERROR,details:M.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){s&&(i.log("finished closing key sessions and clearing media keys"),a.length=0)})).catch((function(e){var t;i.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=i.hls)||t.trigger(O.ERROR,{type:x.OTHER_ERROR,details:M.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=eS(r).call(r,(function(e,t){return-1===hy(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,a;this.log("Remove licenses and keys and close session ".concat(r.sessionId)),e._onmessage&&(r.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var s=hy(n=this.mediaKeySessions).call(n,e);return s>-1&&UE(a=this.mediaKeySessions).call(a,s,1),r.remove().catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(O.ERROR,{type:x.OTHER_ERROR,details:M.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(O.ERROR,{type:x.OTHER_ERROR,details:M.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),r}(X);Za.CDMCleanupPromise=void 0;var es=function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n;return qm(this,r),(n=t.call(this,i)).data=void 0,e.error||(e.error=new Error(i)),n.data=e,e.err=e.error,n}return Xm(r)}(jm(Error));function ts(e,t){var r;try{r=new Event("addtrack")}catch(Ho){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function rs(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(Ho){te.debug("[texttrack-utils]: ".concat(Ho));try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(n){te.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(n))}}"disabled"===r&&(e.mode=r)}function is(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 ns(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;for(var i=0,n=r;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 as(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}function ss(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var os=.02,ls=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function us(e,t,r){var i,n;return py(i=py(n="".concat(e.identifier,"-")).call(n,r+1,"-")).call(i,ss(t))}var cs=function(){function e(t,r){qm(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.base=r,this.dateRange=t,this.setDateRange(t)}return Xm(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 hy(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 hs(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=_(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 hs(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)<os))},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"]?ls.Range:ls.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(){var e,t,r,i;return py(e=py(t=py(r='["'.concat((i=this).identifier,'" ')).call(r,i.cue.pre?"<pre>":i.cue.post?"<post>":"")).call(t,i.timelineStart.toFixed(2),"-")).call(e,i.resumeTime.toFixed(2),"]")}}]),e}();function hs(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<os)?t.start:t.start+t.duration}function ds(e,t,r){var i=new e_(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function fs(e){var t,r,i=e.timelineStart,n=e.duration||0;return py(t=py(r='["'.concat(e.identifier,'" ')).call(r,i.toFixed(2),"-")).call(t,(i+n).toFixed(2),"]")}var vs=function(){function e(t,r,i,n){var a=this;qm(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=a.interstitial.playoutLimit;a.playoutOffset+a.currentTime>=e&&a.hls.trigger(O.PLAYOUT_LIMIT_REACHED,{})};var s=this.hls=new t(r);this.interstitial=i,this.assetItem=n;var o=n.uri;try{o=ds(o,s.sessionId).href}catch(u){}s.loadSource(o);var l=function(){a.hasDetails=!0};s.once(O.LEVEL_LOADED,l),s.once(O.AUDIO_TRACK_LOADED,l),s.once(O.SUBTITLE_TRACK_LOADED,l),s.on(O.MEDIA_ATTACHING,(function(e,t){var r,i=t.media;a.removeMediaListeners(),a.mediaAttached=i;var s,o=a.interstitial;o.playoutLimit&&(a.playoutOffset=(null==(s=o.assetList[hy(r=o.assetList).call(r,n)])?void 0:s.startOffset)||0,i.addEventListener("timeupdate",a.checkPlayout))}))}return Xm(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=fr.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;return(null==(e=this.assetItem)?void 0:e.duration)||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 py(e=py(t="HlsAssetPlayer: ".concat(fs(this.assetItem)," ")).call(t,this.hls.sessionId," ")).call(e,this.interstitial.appendInPlace?"append-in-place":"")}}]),e}(),gs=function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n;return qm(this,r),(n=t.call(this,"interstitials-sched",i)).onScheduleUpdate=void 0,n.eventMap={},n.events=null,n.items=null,n.durations={primary:0,playout:0,integrated:0},n.onScheduleUpdate=e,n}return Xm(r,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){var e;this.eventMap={},this.setDurations(0,0,0),this.events&&ey(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=Qm(i),o=n?Jm(n).call(n,(function(e){return!zx(s).call(s,e.identifier)})):[];a.length&&gT(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,ey(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||Sy(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=Qm(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 cs(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=Jm(e).call(e,(function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(ey(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===ls.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{var f=0;r.push({previousEvent:null,nextEvent:null,start:f,end:n,playout:{start:f,end:n},integrated:{start:f,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;ey(e).call(e,(function(o,l){var u=o.cue.pre,c=o.cue.post,h=u?0:c?n:o.startTime;if(r.updateAssetDurations(o),s===h?o.cumulativeDuration=a:(a=0,s=h),!c&&o.snapOptions.in&&(o.resumeAnchor=Be(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(r.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace)for(var d=l-1;l--;)e[d+1].startTime-e[d].resumeTime<.033&&(e[d].appendInPlace=!1);var f=_(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)>os?(this.log(py(r=py(i='"'.concat(e.identifier,'" resumption ')).call(i,o," not aligned with estimated timeline end ")).call(r,l)),!1):t?!Sy(n=Qm(t)).call(n,(function(r){var i,n,a,l,u,c,h,d,f,v,g,p=t[r].details,m=p.edge;if(o>m)return s.log(py(i=py(n=py(a='"'.concat(e.identifier,'" resumption ')).call(a,o," past ")).call(n,r," playlist end ")).call(i,m)),!0;var y=Be(null,p.fragments,o);if(!y)return s.log(py(l=py(u='"'.concat(e.identifier,'" resumption ')).call(u,o," does not align with any fragments in ")).call(l,r," playlist")),!0;var E="audio"===r?.175:0;return!(Math.abs(y.start-o)<os||Math.abs(y.end-o)<os+E||(s.log(py(c=py(h=py(d=py(f=py(v=py(g='"'.concat(e.identifier,'" resumption ')).call(g,o," not aligned with ")).call(v,r," fragment bounds (")).call(f,y.start,"-")).call(d,y.end," sn: ")).call(h,y.sn," cc: ")).call(c,y.cc,")")),0))})):(this.log(py(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;ey(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]}}]),r}(X);function ps(e){var t,r;return py(t=py(r="[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ")).call(r,e.start.toFixed(2),"-")).call(t,e.end.toFixed(2),"]")}var ms=function(){function e(t){qm(this,e),this.hls=void 0,this.hls=t}return Xm(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,i=this,n=e.assetListUrl;try{r=ds(n,this.hls.sessionId,e.baseUrl)}catch(f){var a=this.assignAssetListError(e,M.ASSET_LIST_LOAD_ERROR,f,n);return void this.hls.trigger(O.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 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(sy(o))e.assetListResponse=s,i.hls.trigger(O.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:a});else{var l=i.assignAssetListError(e,M.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,r,a);i.hls.trigger(O.ERROR,l)}},onError:function(t,r,n,a){var s,o,l=i.assignAssetListError(e,M.ASSET_LIST_LOAD_ERROR,new Error(py(s=py(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(O.ERROR,l)},onTimeout:function(t,r,n){var a=i.assignAssetListError(e,M.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,n);i.hls.trigger(O.ERROR,a)}};return l.load(u,h,d),this.hls.trigger(O.ASSET_LIST_LOADING,{event:e}),l}},{key:"assignAssetListError",value:function(e,t,r,i,n,a){return e.error=r,{type:x.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:a,stats:n}}}]),e}();function ys(e){null==e||e.play().catch()}var Es=Xm((function e(t){qm(this,e),this.buffered=void 0;var r=function(e,r,i){var n,a;if((r>>>=0)>i-1)throw new DOMException(py(n=py(a="Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (")).call(a,r,") is greater than the maximum bound (")).call(n,i,")"));return t[r][e]};this.buffered={get length(){return t.length},end:function(e){return r("end",e,t.length)},start:function(e){return r("start",e,t.length)}}})),ks={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},Ts=function(e){return String.fromCharCode(ks[e]||e)},Ss=15,As=100,Ls={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},bs={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Rs={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Is={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ds=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],ws=function(){function e(){qm(this,e),this.time=null,this.verboseLevel=0}return Xm(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r,i,n="function"==typeof t?t():t;te.log(py(r=py(i="".concat(this.time," [")).call(i,e,"] ")).call(r,n))}}}]),e}(),_s=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},Ps=function(){function e(){qm(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return Xm(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}(),Cs=function(){function e(){qm(this,e),this.uchar=" ",this.penState=new Ps}return Xm(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}(),xs=function(){function e(t){qm(this,e),this.chars=[],this.pos=0,this.currPenState=new Ps,this.cueStartTime=null,this.logger=void 0;for(var r=0;r<As;r++)this.chars.push(new Cs);this.logger=t}return Xm(e,[{key:"equals",value:function(e){for(var t=0;t<As;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<As;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<As;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>As&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=As)}},{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=Ts(e);this.pos>=As?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<As;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<As;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}(),Ms=function(){function e(t){qm(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var r=0;r<Ss;r++)this.rows.push(new xs(t));this.logger=t}return Xm(e,[{key:"reset",value:function(){for(var e=0;e<Ss;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,r=0;r<Ss;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<Ss;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<Ss;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 = "+x_(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<Ss;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 = "+x_(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=UE(e=this.rows).call(e,i,1)[0];n.clear(),UE(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<Ss;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(Ek(a).call(a)))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),Os=function(){function e(t,r,i){qm(this,e),this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new Ms(i),this.nonDisplayedMemory=new Ms(i),this.lastOutputScreen=new Ms(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}return Xm(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,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}this.logger.log(2,"MIDROW: "+x_(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}(),Fs=function(){function e(t,r,i){qm(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var n=this.logger=new ws;this.channels=[null,new Os(t,r,n),new Os(t+1,i,n)]}return Xm(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"["+_s([t[e],t[e+1]])+"] -> ("+_s([i,n])+")"}));var o=r.cmdHistory;if(i>=16&&i<=31){if(Us(i,n,o))return Ns(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+_s([i,n])+") is dropped"})),"continue";Ns(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 Ns(null,null,o);if(!a&&(s=r.parseChars(i,n))){var l=r.currentChannel;l&&l>0?r.channels[l].insertChars(s):r.logger.log(2,"No channel found yet. TEXT-MODE?")}a||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+_s([i,n])+" orig: "+_s([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 ("+_s([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?Ls[e]:Rs[e]:1===i?bs[e]:Is[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;return 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 '"+Ts(i)+"' in channel "+r})),n=[i]):e>=32&&e<=127&&(n=0===t?[e]:[e,t]),n&&this.logger.log(3,(function(){return"Char codes = "+_s(n).join(",")})),n}},{key:"parseBackgroundAttributes",value:function(e,t){if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var r,i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=Ds[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<Qm(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}Ns(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 Ns(e,t,r){r.a=e,r.b=t}function Us(e,t,r){return r.a===e&&r.b===t}var Bs=function(){if(null!=_r&&_r.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(!sy(e))return!1;var r=t.toLowerCase();return!!~hy(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";iy(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),iy(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),iy(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}})),iy(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}})),iy(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),iy(o,"region",n({},l,{get:function(){return v},set:function(e){v=e,this.hasBeenReset=!0}})),iy(o,"vertical",n({},l,{get:function(){return g},set:function(t){var i=r(e,t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),iy(o,"snapToLines",n({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),iy(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}})),iy(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}})),iy(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}})),iy(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}})),iy(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}})),iy(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}(),Gs=function(){function e(){qm(this,e)}return Xm(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 Ks(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+ck(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?ck(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var Hs=function(){function e(){qm(this,e),this.values=t_(null)}return Xm(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(wM(this)[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?wM(this)[e]:t[r]:this.has(e)?wM(this)[e]:t}},{key:"has",value:function(e){return e in wM(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,Ck(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=ck(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function Vs(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);2===s.length&&t(s[0],s[1])}}var js=new Bs(0,0,""),Ys="middle"===js.align?"middle":"center";function Ws(e,t,r){var i=e;function n(){var t=Ks(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"!==uy(e).call(e,0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=uy(e).call(e,3),a(),t.endTime=n(),a(),function(e,t){var i=new Hs;Vs(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",Ys,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",Ys,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Ys,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===js.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",Ys);var a=i.get("position","auto");"auto"===a&&50===js.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function qs(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var zs=function(){function e(){qm(this,e),this.state="INITIAL",this.buffer="",this.decoder=new Gs,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return Xm(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=qs(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=uy(e).call(e,0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=uy(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)?Vs(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 Bs(0,0,""),t.state="CUE",-1===hy(i).call(i,"--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ws(i,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==hy(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}(),Xs=/\r\n|\n\r|\n|\r/g,Qs=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return uy(e).call(e,r,r+t.length)===t};function $s(e,t,r){return ss(e.toString())+ss(t.toString())+ss(r)}function Js(e,t,r,i,n,a,s){var o,l,u=new zs,c=Ek(o=gt(new Uint8Array(e))).call(o).replace(Xs,"\n").split("\n"),h=[],d=t?function(e){return qn(e,9e4,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=Zn(9e4*(e.startTime+o-g),9e4*n)/9e4;e.startTime=Math.max(f,0),e.endTime=Math.max(f+c,0);var p=Ek(a=e.text).call(a);e.text=decodeURIComponent(encodeURIComponent(p)),e.id||(e.id=$s(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)},ey(c).call(c,(function(e){if(p){if(Qs(e,"X-TIMESTAMP-MAP=")){var t;p=!1,ey(t=uy(e).call(e,16).split(",")).call(t,(function(e){Qs(e,"LOCAL:")?f=uy(e).call(e,6):Qs(e,"MPEGTS:")&&(v=Ck(uy(e).call(e,7)))}));try{g=function(e){var t=Ck(uy(e).call(e,-3)),r=Ck(uy(e).call(e,-6,-4)),i=Ck(uy(e).call(e,-9,-7)),n=e.length>9?Ck(e.substring(0,hy(e).call(e,":"))):0;if(!(_(t)&&_(r)&&_(i)&&_(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*i,t+=36e5*n}(f)/1e3}catch(r){l=r}return}""===e&&(p=!1)}u.parse(e+"\n")})),u.flush()}var Zs="stpp.ttml.im1t",eo=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,to=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,ro={left:"start",center:"center",right:"end",start:"start",end:"end"};function io(e,t,r,i){var n=Ht(new Uint8Array(e),["mdat"]);if(0!==n.length){var a=Dy(n).call(n,(function(e){return gt(e)})),s=function(e,t){return qn(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{ey(a).call(a,(function(e){return r(function(e,t,r,i){var n=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=eS(r=Qm(a)).call(r,(function(e,t){return e[t]=n.getAttribute("ttp:".concat(t))||a[t],e}),{}),o="preserve"!==n.getAttribute("xml:space"),l=ao(no(n,"styling","style")),u=ao(no(n,"layout","region")),c=no(n,"body","[begin]");return Jm(i=Dy([]).call(c,(function(e){var r=so(e,o);if(!r||!e.hasAttribute("begin"))return null;var i=uo(e.getAttribute("begin"),s),n=uo(e.getAttribute("dur"),s),a=uo(e.getAttribute("end"),s);if(null===i)throw lo(e);if(null===a){if(null===n)throw lo(e);a=i+n}var c=new Bs(i-t,a-t,r);c.id=$s(c.startTime,c.endTime,c.text);var h,d,f,v,g,p,m,y=(h=u[e.getAttribute("region")],d=l[e.getAttribute("style")],f=l,v="http://www.w3.org/ns/ttml#styling",g=null,p=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],(m=null!=h&&h.hasAttribute("style")?h.getAttribute("style"):null)&&f.hasOwnProperty(m)&&(g=f[m]),eS(p).call(p,(function(e,t){var r=oo(d,v,t)||oo(h,v,t)||oo(g,v,t);return r&&(e[t]=r),e}),{})),E=y.textAlign;if(E){var k=ro[E];k&&(c.lineAlign=k),c.align=E}return W(c,y),c}))).call(i,(function(e){return null!==e}))}(e,s))}))}catch(o){i(o)}}else i(new Error("Could not parse IMSC1 mdat"))}function no(e,t,r){var i=e.getElementsByTagName(t)[0];return i?uy([]).call(i.querySelectorAll(r)):[]}function ao(e){return eS(e).call(e,(function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function so(e,t){var r;return eS(r=uy([]).call(e.childNodes)).call(r,(function(e,r,i){var n,a;return"br"===r.nodeName&&i?e+"\n":null!=(a=r.childNodes)&&a.length?so(r,t):t?e+Ek(n=r.textContent).call(n).replace(/\s+/g," "):e+r.textContent}),"")}function oo(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function lo(e){return new Error("Could not parse ttml timestamp ".concat(e))}function uo(e,t){if(!e)return null;var r,i,n,a,s=Ks(e);return null===s&&(eo.test(e)?(r=e,i=t,n=eo.exec(r),a=(0|n[4])+(0|n[5])/i.subFrameRate,s=3600*(0|n[1])+60*(0|n[2])+(0|n[3])+a/i.frameRate):to.test(e)&&(s=function(e,t){var r=to.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))),s}var co=function(){function e(t,r){qm(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=r}return Xm(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}();function ho(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function fo(e,t){return!!e&&e.kind===ho(t)&&ga(t,e)}var vo=/\s/,go={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++)vo.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=qs(Ek(l).call(l)),g=$s(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&&(gT(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})),ey(u).call(u,(function(t){return rs(e,t)}))),u}},po=/(\d+)-(\d+)\/(\d+)/,mo=function(){function e(t){qm(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||yo,this.controller=new self.AbortController,this.stats=new bt}return Xm(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,s,o,l=(a=e,s=this.controller.signal,o={method:"GET",mode:"cors",credentials:"same-origin",signal:s,headers:new self.Headers(W({},a.headers))},a.rangeEnd&&o.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),o),u=r.onProgress,c="arraybuffer"===e.responseType,h=c?"byteLength":"length",d=t.loadPolicy,f=d.maxTimeToFirstByteMs,v=d.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,l),self.clearTimeout(this.requestTimeout),t.timeout=f&&_(f)?f:v,this.requestTimeout=mE((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),(la(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(a){i.response=i.loader=a;var s=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=v,i.requestTimeout=mE((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),v-(s-n.loading.start)),!a.ok){var o=a.status,l=a.statusText;throw new Eo(l||"fetch, bad network response",o,a)}return n.loading.first=s,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=po.exec(e);if(t)return Ck(t[2])-Ck(t[1])+1}(t);if(_(r))return r}var i=e.get("Content-Length");if(i)return Ck(i)}(a.headers)||n.total,u&&_(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,u):c?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var s=i.response;if(!s)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var o=a[h];o&&(n.loaded=n.total=o);var l={url:s.url,data:a,code:s.status};u&&!_(t.highWaterMark)&&u(n,e,a,s),r.onSuccess(l,n,e,s)})).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?ck(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 Ui,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),RR.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 RR.reject()}))}()}}]),e}();function yo(e,t){return new self.Request(e.url,t)}var Eo=function(e){Ym(r,e);var t=Wm(r);function r(e,i,n){var a;return qm(this,r),(a=t.call(this,e)).code=void 0,a.details=void 0,a.code=i,a.details=n,a}return Xm(r)}(jm(Error)),ko=/^age:\s*[\d.]+\s*$/im,To=function(){function e(t){qm(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new bt,this.retryDelay=0}return Xm(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?RR.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=pE(i=this.readystatechange).call(i,this),e.onprogress=pE(n=this.loadprogress).call(n,this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&_(l)?l:u,this.requestTimeout=mE(pE(a=this.loadtimeout).call(a,this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e,t=this.context,r=this.loader,i=this.stats;if(t&&r){var n=r.readyState,a=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=mE(pE(e=this.loadtimeout).call(e,this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===n)){var s;self.clearTimeout(this.requestTimeout),r.onreadystatechange=null,r.onprogress=null;var o=r.status,l="text"===r.responseType?r.responseText:null;if(o>=200&&o<300){var u=null!=l?l:r.response;if(null!=u){i.loading.end=Math.max(self.performance.now(),i.loading.first);var c="arraybuffer"===r.responseType?u.byteLength:u.length;if(i.loaded=i.total=c,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;var h=this.callbacks.onProgress;if(h&&h(i,t,u,r),!this.callbacks)return;var d={url:r.responseURL,data:u,code:o};return void this.callbacks.onSuccess(d,i,t,r)}}var f=a.loadPolicy.errorRetry;qe(f,i.retry,!1,{url:t.url,data:void 0,code:o})?this.retry(f):(te.error(py(s="".concat(o," while loading ")).call(s,t.url)),this.callbacks.onError({code:o,text:r.statusText},t,r,i))}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(qe(e,this.stats.retry,!0))this.retry(e);else{var t;te.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=Ye(e,o.retry),o.retry++,te.warn(py(t=py(r=py(i=py(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=mE(pE(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&&ko.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?ck(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}(),So=z(z({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:To,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,"abr",e.logger)).hls=void 0,i.lastLevelLoadSec=0,i.lastLoadedFragLevel=-1,i.firstSelection=-1,i._nextAutoLevel=-1,i.nextAutoLevelKey="",i.audioTracksByGroup=null,i.codecTiers=null,i.timer=-1,i.fragCurrent=null,i.partCurrent=null,i.bitrateTestDelay=0,i.bwEstimator=void 0,i._abandonRulesCheck=function(){var e,t,r,n,a,s,o,l,u,c,h,d,f=$f(i),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 i.clearTimer(),void(i._nextAutoLevel=-1);if(m&&!y.paused&&y.playbackRate&&y.readyState){var L=p.mainForwardBufferInfo;if(null!==L){var b=i.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,w=k.loaded&&D>-1,P=i.getBwEstimate(),C=p.levels,x=C[v.level],M=Math.max(k.loaded,Math.round(T*(v.bitrate||x.averageBitrate)/8)),F=w?S-D:S;F<1&&w&&(F=Math.min(S,8*k.loaded/P));var N=w?1e3*k.loaded/F:0,U=b/1e3,B=N?(M-k.loaded)/N:8*M/P+U;if(!(B<=I)){var G,K=N?8*N:P,H=!0===(null==(d=i.hls.latestLevelDetails)?void 0:d.live),V=i.hls.config.abrBandWidthUpFactor,j=Number.POSITIVE_INFINITY;for(G=v.level-1;G>A;G--){var Y=C[G].maxBitrate,W=!C[G].details||H;if((j=i.getTimeToLoadFrag(U,K,T*Y,W))<Math.min(I,T+U))break}if(!(j>=B||j>10*T)){w?i.bwEstimator.sample(S-Math.min(b,D),k.loaded):i.bwEstimator.sampleTTFB(S);var q=C[G].maxBitrate;i.getBwEstimate()*V>q&&i.resetEstimator(q);var z=i.findBestLevel(q,A,G,0,I,1,1);z>-1&&(G=z),i.warn(py(e=py(t=py(r=py(n=py(a=py(s=py(o=py(l=py(u=py(c=py(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,B.toFixed(3)," s\n Estimated load time for down switch fragment: ")).call(s,j.toFixed(3)," s\n TTFB estimate: ")).call(a,0|D," ms\n Current BW estimate: ")).call(n,_(P)?0|P:"Unknown"," bps\n New BW estimate: ")).call(r,0|i.getBwEstimate()," bps\n Switching to level ")).call(t,G," @ ")).call(e,0|q," bps")),p.nextLoadLevel=p.nextAutoLevel=G,i.clearTimer(),i.timer=gE((function(){if(i.clearTimer(),i.fragCurrent===v&&i.hls.loadLevel===G&&G>0){var e,t,r=i.getStarvationDelay();if(i.warn(py(e=py(t="Aborting inflight request ".concat(G>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(),i.fragCurrent=i.partCurrent=null,G>A){var n=i.findBestLevel(i.hls.levels[A].bitrate,A,G,0,r,1,1);-1===n&&(n=A),i.hls.nextLoadLevel=i.hls.nextAutoLevel=n,i.resetEstimator(i.hls.levels[n].bitrate)}}}),1e3*j),p.trigger(O.FRAG_LOAD_EMERGENCY_ABORTED,{frag:v,part:g,stats:k})}}}}}}},i.hls=e,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}return Xm(r,[{key:"resetEstimator",value:function(e){e&&(this.log("setting initial bwe to ".concat(e)),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new j(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.FRAG_LOADING,this.onFragLoading,this),e.on(O.FRAG_LOADED,this.onFragLoaded,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(O.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.FRAG_LOADING,this.onFragLoading,this),e.off(O.FRAG_LOADED,this.onFragLoaded,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(O.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,i=t.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null),this.clearTimer(),this.timer=gE(this._abandonRulesCheck,100))}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.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;_(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===G&&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(O.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!==G||"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(py(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 py(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;g&&(f=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-g,this.info(py(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(py(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,T,S,A,L,b=g[h],R=!(null==(o=this.hls.latestLevelDetails)||!o.live),I=-1===m||-1===c,D="SDR",w=(null==b?void 0:b.frameRate)||0,P=y.audioPreference,C=y.videoPreference,x=this.audioTracksByGroup||(this.audioTracksByGroup=Pe(p)),M=-1;if(I){if(-1!==this.firstSelection)return this.firstSelection;var O=function(e,t,r,i,n){for(var a=Qm(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===Ck(s),c=!1,h=!1,d=1/0,f=1/0,v=1/0,g=1/0,p=0,m=[],y=we(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),Jm(k).call(k,(function(e){return t.videoRanges[e]>0})).length>0&&(h=!0)},S=a.length;S--;)T();d=_(d)?d:0,f=_(f)?f:0;var A=Math.max(1080,d),L=Math.max(30,f);v=_(v)?v:r,r=Math.max(v,r),h||(t=void 0);var b=a.length>1;return{codecSet:eS(a).call(a,(function(t,i){var n=e[i];if(i===t)return t;if(m=h?Jm(k).call(k,(function(e){return n.videoRanges[e]>0})):[],b){var a,d,f,v,y;if(n.minBitrate>r)return _e(i,py(a="min bitrate of ".concat(n.minBitrate," > current estimate of ")).call(a,r)),t;if(!n.hasDefaultAudio)return _e(i,"no renditions with default or auto-select sound found"),t;if(o&&hy(i).call(i,o.substring(0,4))%5!=0)return _e(i,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!u){if(!n.channels[s])return _e(i,py(y="no renditions with ".concat(s," channel sound found (channels options: ")).call(y,Qm(n.channels),")")),t}else if((!o||u)&&c&&0===n.channels[2])return _e(i,"no renditions with stereo sound found"),t;if(n.minHeight>A)return _e(i,py(d="min resolution of ".concat(n.minHeight," > maximum of ")).call(d,A)),t;if(n.minFramerate>L)return _e(i,py(f="min framerate of ".concat(n.minFramerate," > maximum of ")).call(f,L)),t;if(!Sy(m).call(m,(function(e){return n.videoRanges[e]>0})))return _e(i,"no variants with VIDEO-RANGE of ".concat(x_(m)," found")),t;if(l&&hy(i).call(i,l.substring(0,4))%5!=0)return _e(i,'video codec preference "'.concat(l,'" not found')),t;if(n.maxScore<p)return _e(i,py(v="max score of ".concat(n.maxScore," < selected max of ")).call(v,p)),t}return t&&(ue(i)>=ue(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}}(this.codecTiers||(this.codecTiers=(T=x,S=t,A=r,eS(L=uy(k=g).call(k,S,A+1)).call(L,(function(e,t,r){if(!t.codecSet)return e;var i=t.audioGroups,n=e[t.codecSet];n||(e[t.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:r,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!i,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,t.bitrate);var a=Math.min(t.height,t.width);return n.minHeight=Math.min(n.minHeight,a),n.minFramerate=Math.min(n.minFramerate,t.frameRate),n.minIndex=Math.min(n.minIndex,r),n.maxScore=Math.max(n.maxScore,t.score),n.fragmentError+=t.fragmentError,n.videoRanges[t.videoRange]=(n.videoRanges[t.videoRange]||0)+1,i&&ey(i).call(i,(function(e){var t;if(e){var r=T.groups[e];r&&(n.hasDefaultAudio=n.hasDefaultAudio||T.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!T.hasDefaultAudio&&!T.hasAutoSelectAudio,ey(t=Qm(r.channels)).call(t,(function(e){n.channels[e]=(n.channels[e]||0)+r.channels[e]})))}})),e}),{}))),D,e,P,C),F=O.codecSet,N=O.videoRanges,U=O.minFramerate,B=O.minBitrate,G=O.minIndex,K=O.preferHDR;M=G,E=F,D=K?N[N.length-1]:N[0],w=U,e=Math.max(e,B),this.log("picked start tier ".concat(x_(O)))}else E=null==b?void 0:b.codecSet,D=null==b?void 0:b.videoRange;for(var H=f?f.duration:d?d.duration:0,V=this.bwEstimator.getEstimateTTFB()/1e3,j=[],Y=function(){var t=g[W],o=W>h;if(!t)return"continue";if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var d=navigator.mediaCapabilities;"function"!=typeof(null==d?void 0:d.decodingInfo)||!ye(t,x,D,w,e,P)&&"hvc1"!==(null==(z=t.videoCodec)?void 0:z.substring(0,4))?t.supportedResult=pe:(t.supportedPromise=Ee(t,x,d),t.supportedPromise.then((function(e){var r,i,n;if(l.hls){t.supportedResult=e;var a=l.hls.levels,s=hy(a).call(a,t);e.error?l.warn(py(r=py(i='MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ')).call(i,s," ")).call(r,x_(e))):e.supported||(l.warn(py(n="Unsupported MediaCapabilities decodingInfo result for level ".concat(s," ")).call(n,x_(e))),s>-1&&a.length>1&&(l.log("Removing unsupported level ".concat(s)),l.hls.removeLevel(s),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0)))}})))}if((E&&t.codecSet!==E||D&&t.videoRange!==D||o&&w>t.frameRate||!o&&w>0&&w<t.frameRate||t.supportedResult&&(null==(q=t.supportedResult.decodingInfoResults)||!q[0].smooth))&&(!I||W!==M))return j.push(W),"continue";var v,p=t.details,k=(f?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||H;v=o?s*e:a*e;var T=H&&i>=2*H&&0===n?t.averageBitrate:t.maxBitrate,S=l.getTimeToLoadFrag(V,v,T*k,void 0===p);if(v>=T&&(W===c||0===t.loadError&&0===t.fragmentError)&&(S<=V||!_(S)||R&&!l.bitrateTestDelay||S<u)){var A,L,b,C,O,F,N,U,B,G,K,Y,X,Q,$,J,Z=l.forcedAutoLevel;return{v:(W===m||-1!==Z&&Z===m||(j.length&&l.trace(py(A=py(L=py(b=py(C=py(O="Skipped level(s) ".concat(j.join(",")," of ")).call(O,r,' max with CODECS and VIDEO-RANGE:"')).call(C,g[j[0]].codecs,'" ')).call(b,g[j[0]].videoRange,'; not compatible with "')).call(L,E,'" ')).call(A,D)),l.info(py(F=py(N=py(U=py(B=py(G=py(K=py(Y=py(X=py(Q=py($=py(J="switch candidate:".concat(h,"->")).call(J,W," adjustedbw(")).call($,Math.round(v),")-bitrate=")).call(Q,Math.round(v-T)," ttfb:")).call(X,V.toFixed(1)," avgDuration:")).call(Y,k.toFixed(1)," maxFetchDuration:")).call(K,u.toFixed(1)," fetchDuration:")).call(G,S.toFixed(1)," firstSelection:")).call(B,I," codecSet:")).call(U,t.codecSet," videoRange:")).call(N,t.videoRange," hls.loadLevel:")).call(F,m))),I&&(l.firstSelection=W),W)}}},W=r;W>=t;W--){var q,z,X=Y();if("continue"!==X&&"object"===qh(X))return X.v}return-1}}]),r}(X),bufferController:function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n,a;return qm(this,r),(n=t.call(this,"buffer-controller",e.logger)).hls=void 0,n.fragmentTracker=void 0,n.details=null,n._objectUrl=null,n.operationQueue=null,n.bufferCodecEventsTotal=0,n.media=null,n.mediaSource=null,n.lastMpegAudioChunk=null,n.blockedAudioAppend=null,n.lastVideoAppendEnd=0,n.appendSource=void 0,n.transferData=void 0,n.overrides=void 0,n.appendErrors={audio:0,video:0,audiovideo:0},n.tracks={},n.sourceBuffers=[[null,null],[null,null]],n._onEndStreaming=function(e){var t;n.hls&&"open"===(null==(t=n.mediaSource)?void 0:t.readyState)&&n.hls.pauseBuffering()},n._onStartStreaming=function(e){n.hls&&n.hls.resumeBuffering()},n._onMediaSourceOpen=function(e){var t=$f(n),r=t.media,i=t.mediaSource;e&&n.log("Media source opened"),r&&i&&(r.removeEventListener("emptied",n._onMediaEmptied),n.updateDuration(),n.hls.trigger(O.MEDIA_ATTACHED,{media:r,mediaSource:i}),i.removeEventListener("sourceopen",n._onMediaSourceOpen),null!==n.mediaSource&&n.checkPendingTracks())},n._onMediaSourceClose=function(){n.log("Media source closed")},n._onMediaSourceEnded=function(){n.log("Media source ended")},n._onMediaEmptied=function(){var e,t=$f(n),r=t.mediaSrc,i=t._objectUrl;r!==i&&n.error(py(e="Media element src was set while attaching MediaSource (".concat(i," > ")).call(e,r,")"))},n.hls=e,n.fragmentTracker=i,n.appendSource=(a=re(e.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),n.initTracks(),n.registerListeners(),n}return Xm(r,[{key:"hasSourceTypes",value:function(){return Qm(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(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.BUFFER_RESET,this.onBufferReset,this),e.on(O.BUFFER_APPENDING,this.onBufferAppending,this),e.on(O.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.BUFFER_EOS,this.onBufferEos,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.FRAG_PARSED,this.onFragParsed,this),e.on(O.FRAG_CHANGED,this.onFragChanged,this),e.on(O.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.BUFFER_RESET,this.onBufferReset,this),e.off(O.BUFFER_APPENDING,this.onBufferAppending,this),e.off(O.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.BUFFER_EOS,this.onBufferEos,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.FRAG_PARSED,this.onFragParsed,this),e.off(O.FRAG_CHANGED,this.onFragChanged,this),e.off(O.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e,t=this,r=this.media,i=this.mediaSource;if(!r)return null;var n={};if(this.operationQueue){var a,s,o=this.isUpdating();o||this.operationQueue.removeBlockers();var l=this.isQueued();(o||l)&&this.warn(py(a=py(s="Transfering MediaSource with".concat(l?" operations in queue":"")).call(s,o?" updating SourceBuffer(s)":""," ")).call(a,this.operationQueue)),this.operationQueue.destroy()}var u=this.transferData;return!this.sourceBufferCount&&u&&u.mediaSource===i?W(n,u.tracks):ey(e=this.sourceBuffers).call(e,(function(e){var r=mf(e,1)[0];r&&(n[r]=W({},t.tracks[r]),t.removeBuffer(r)),e[0]=e[1]=null})),{media:r,mediaSource:i,tracks:n}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var r,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,i,n,a=this.media=t.media,s=re(this.appendSource);if(this.transferData=this.overrides=void 0,a&&s){var o=!!t.mediaSource;(o||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var l=this.mediaSource=t.mediaSource||new s;if(this.assignMediaSource(l),o)this._objectUrl=a.src,this.attachTransferred();else{var u=this._objectUrl=e_.createObjectURL(l);if(this.appendSource)try{a.removeAttribute("src");var c=self.ManagedMediaSource;a.disableRemotePlayback=a.disableRemotePlayback||c&&l instanceof c,Ta(a),r=a,i=u,(n=self.document.createElement("source")).type="video/mp4",n.src=i,r.appendChild(n),a.load()}catch(h){a.src=u}else a.src=u}a.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r,i;this.log(py(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?Qm(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(py(l=py(u="attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ")).call(u,x_(i,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ")).call(l,x_(n,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!ie(n,i)){var c,h,d,f;r.mediaSource=null,r.tracks=void 0;var 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(py(c="attachTransferred: waiting for playback to reach new tracks start time ".concat(v," -> ")).call(c,p)):(this.warn(py(h=py(d=py(f='attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(Qm(n),'"->"')).call(f,Qm(i),'") start time: ')).call(d,p," currentTime: ")).call(h,v)),this.onMediaDetaching(O.MEDIA_DETACHING,{}),this.onMediaAttaching(O.MEDIA_ATTACHING,r),void(t.currentTime=p))}this.transferData=void 0,ey(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=fr.getBuffered(a);s.detectEvictedFragments(r,l,o,null,!0)}var u=Sa(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){var o;if(this.log("media source "+(i?"transferring":"detaching")),i)ey(o=this.sourceBuffers).call(o,(function(e){var t=mf(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(Ho){this.warn("onMediaDetaching: ".concat(Ho.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&&e_.revokeObjectURL(s),this.mediaSrc===s?(n.removeAttribute("src"),this.appendSource&&Ta(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(O.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){var e,t=this;ey(e=this.sourceBuffers).call(e,(function(e){var r=mf(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(Ho){this.warn("onBufferReset ".concat(e),Ho)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[Sa(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 ma(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r,i,n=this,a=this.tracks,s=Qm(t);this.log(py(r='BUFFER_CODECS: "'.concat(s,'" (current SB count ')).call(r,this.sourceBufferCount,")"));var o="audiovideo"in t&&(a.audio||a.video)||a.audiovideo&&("audio"in t||"video"in t),l=!o&&this.sourceBufferCount&&this.media&&Sy(s).call(s,(function(e){return!a[e]}));o||l?this.warn(py(i='Unsupported transition between "'.concat(Qm(a),'" and "')).call(i,s,'" SourceBuffers')):(ey(s).call(s,(function(e){var r,i,s,o,l=t[e],u=l.id,c=l.codec,h=l.levelCodec,d=l.container,f=l.metadata,v=a[e],g=null==(i=n.transferData)||null==(s=i.tracks)?void 0:s[e],p=null!=g&&g.buffer?g:v,m=(null==p?void 0:p.pendingCodec)||(null==p?void 0:p.codec),y=null==p?void 0:p.levelCodec,E=!p||!!n.hls.config.assetPlayerId;v||(v=a[e]={buffer:void 0,listeners:[],codec:c,container:d,levelCodec:h,metadata:f,id:u});var k=fe(m,y),T=null==k?void 0:k.replace(ya,"$1"),S=fe(c,h),A=null==(o=S)?void 0:o.replace(ya,"$1");S&&(T!==A||E)&&("audio"===uy(e).call(e,0,5)&&(S=de(S,n.appendSource)),n.log(py(r="switching codec ".concat(m," to ")).call(r,S)),S!==(v.pendingCodec||v.codec)&&(v.pendingCodec=S),v.container=d,n.appendChangeType(e,d,S))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e,t=this;return eS(e=Qm(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=py(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;null!=o&&o.changeType&&(n.log(py(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,G))?void 0:t.gap)){var a={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>n||null!=t&&t.buffer&&fr.isBuffered(t.buffer,n)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(n,G))?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||fr.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&&!fr.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;Math.abs(o)>=.1&&(r.log(py(i=py(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={};ey(e=r.sourceBuffers).call(e,(function(e){var t=mf(e,2),r=t[0],n=t[1];r&&(i[r]=fr.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(O.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:i})},onError:function(e){var t,i={type:x.MEDIA_ERROR,parent:o.type,details:M.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=M.BUFFER_FULL_ERROR;else if(e.code!==DOMException.INVALID_STATE_ERR||!r.mediaSourceOpenOrEnded||null!=(t=r.media)&&t.error)if(e.name===Ea)0===r.sourceBufferCount?i.errorAction=tt(!0):++r.appendErrors[a];else{var n,s,c=++r.appendErrors[a];r.warn(py(n=py(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=tt(!0);r.hls.trigger(O.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(py(i=py(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(O.BUFFER_FLUSHED,{type:e})},onError:function(i){var n,s;a.warn(py(n=py(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):ey(r=this.sourceBuffers).call(r,(function(e){var t=mf(e,1)[0];t&&i.append(i.getFlushOp(t,a,s),t)}))}},{key:"onFragParsed",value:function(e,t){var r,i,n=this,a=t.frag,s=t.part,o=[],l=s?s.elementaryStreams:a.elementaryStreams;l[Dt]?o.push("audiovideo"):(l[Rt]&&o.push("audio"),l[It]&&o.push("video")),0===o.length&&this.warn(py(r=py(i="Fragments must have at least one ElementaryStreamType set. type: ".concat(a.type," level: ")).call(i,a.level," sn: ")).call(r,a.sn)),this.blockBuffers((function(){var e=self.performance.now();a.stats.buffering.end=e,s&&(s.stats.buffering.end=e);var t=s?s.stats:a.stats;n.hls.trigger(O.FRAG_BUFFERED,{frag:a,part:s,stats:t,id:a.type})}),o)}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var e,t=this;return this.sourceBufferCount>0&&!Sy(e=this.sourceBuffers).call(e,(function(e){var r,i,n=mf(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;ey(r=this.sourceBuffers).call(r,(function(e){var r=mf(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&&!Sy(i=this.sourceBuffers).call(i,(function(e){var t,r=mf(e,1)[0];return r&&!(null!=(t=a.tracks[r])&&t.ended)}))&&(this.log("Queueing EOS"),this.blockUntilOpen((function(){var e;if(ey(e=a.sourceBuffers).call(e,(function(e){var t=mf(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(O.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===M.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;_(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(_(s)&&s>=0){var o=Math.max(s,a),l=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,l)}if(_(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;ey(i=this.sourceBuffers).call(i,(function(i){var a=mf(i,2),s=a[0],o=a[1];if(o){var l=fr.getBuffered(o);if(l.length>0&&r>l.start(0)){var u;n.hls.trigger(O.BACK_BUFFER_REACHED,{bufferEnd:r});var c=n.tracks[s];if(null!=(u=n.details)&&u.live)n.hls.trigger(O.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(O.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}},{key:"flushFrontBuffer",value:function(e,t,r){var i,n=this;ey(i=this.sourceBuffers).call(i,(function(i){var a=mf(i,2),s=a[0],o=a[1];if(o){var l=fr.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(O.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>(_(r.duration)?r.duration:0)&&i>s||!_(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&&(_(i)&&this.log("Updating MediaSource duration to ".concat(i.toFixed(3))),s.duration=i),void 0!==n&&void 0!==a&&(this.log(py(t=py(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(py(e=py(t="checkPendingTracks (pending: ".concat(i," codec events expected: ")).call(t,r,") ")).call(e,x_(n))),this.tracksReady){var a,s=null==(a=this.transferData)?void 0:a.tracks;s&&Qm(s).length?this.attachTransferred():(this.createSourceBuffers(),this.bufferCreated())}}},{key:"bufferCreated",value:function(){var e=this;if(this.sourceBufferCount){var t,r,i={};ey(t=this.sourceBuffers).call(t,(function(t){var r=mf(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(O.BUFFER_CREATED,{tracks:i}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),ey(r=this.sourceBuffers).call(r,(function(t){var r=mf(t,1)[0];e.executeNext(r)}))}else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.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=py(s="".concat(a.container,";codecs=")).call(s,u);a.codec=u,this.log(py(o=py(l="creating sourceBuffer(".concat(c,")")).call(l,this.currentOp(n)?" Queued":""," ")).call(o,x_(a)));try{var h=r.addSourceBuffer(c),d=Sa(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(O.ERROR,{type:x.MEDIA_ERROR,details:M.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=fe(e.codec,e.levelCodec);return r?"audio"===uy(t).call(t,0,5)?de(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(O.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(py(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(O.ERROR,{type:x.MEDIA_ERROR,details:M.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,n,a=this.media,s=this.mediaSource,o=this.tracks[e],l=null==o?void 0:o.buffer;if(!a||!s||!l)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var u=_(a.duration)?a.duration:1/0,c=_(s.duration)?s.duration:1/0,h=Math.max(0,t),d=Math.min(r,u,c);d>h&&(!o.ending||o.ended)?(o.ended=!1,this.log(py(i=py(n="Removing [".concat(h,",")).call(n,d,"] from the ")).call(i,e," SourceBuffer")),l.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 ka("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 Sy(e=this.sourceBuffers).call(e,(function(e){var t=mf(e,2),r=t[0],i=t[1];return r&&i.updating}))}},{key:"isQueued",value:function(){var e,t=this;return Sy(e=this.sourceBuffers).call(e,(function(e){var r=mf(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 RR.resolve().then(e);var i=this.operationQueue,n=Dy(r).call(r,(function(e){return t.appendBlocker(e)}));r.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),RR.all(n).then((function(n){i===t.operationQueue&&(e(),t.stepOperationQueue(r))}))}},{key:"stepOperationQueue",value:function(e){var t=this;ey(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 eS(e=Qm(this.tracks)).call(e,(function(e,r){return e+(t.isPending(t.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){var e;return eS(e=this.sourceBuffers).call(e,(function(e,t){return e+(mf(t,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){var e,t;return Jm(e=Dy(t=this.sourceBuffers).call(t,(function(e){return mf(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=pE(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&&(ey(t=r.listeners).call(t,(function(e){i.removeEventListener(e.event,e.listener)})),r.listeners.length=0)}}}]),r}(X),capLevelController:Aa,errorController:function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,"error-controller",e.logger)).hls=void 0,i.playlistError=0,i.penalizedRenditions={},i.hls=e,i.registerListeners(),i}return Xm(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(O.ERROR,this.onError,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(O.ERROR,this.onError,this),e.off(O.ERROR,this.onErrorOut,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.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)===G?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 M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case M.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=tt());case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Xe);case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:var a,s,o=t.parent===G?t.level:i.loadLevel;return void(t.details===M.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 M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var l=i.levels[i.loadLevel];if(l&&(n.type===U&&l.hasAudioGroup(n.groupId)||n.type===B&&l.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Xe,void(t.errorAction.flags=Ze)}return;case M.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:Xe,flags:et,hdcpLevel:c}:this.keySystemError(t));case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:var h;return void(t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,null!=(h=t.level)?h:i.loadLevel)));case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=tt())}t.type===x.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=je(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(qe(r,i,Ve(e),e.response))return{action:$e,flags:Je,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=je(AS(t=e.details).call(t,"key")?l:o,e),c=eS(r=i.levels).call(r,(function(e,t){return e+t.fragmentError}),0);if(a&&(e.details!==M.FRAG_GAP&&a.fragmentError++,qe(u,c,Ve(e),e.response)))return{action:$e,flags:Je,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===M.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===K&&s===M.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===M.BUFFER_ADD_CODEC_ERROR||s===M.BUFFER_APPEND_ERROR))&&Sy(l).call(l,(function(e){var t=e.audioCodec;return i.audioCodec!==t})),v="video"===e.sourceBufferName&&(s===M.BUFFER_ADD_CODEC_ERROR||s===M.BUFFER_APPEND_ERROR)&&Sy(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===M.FRAG_GAP&&d===G&&e.frag){var n=l[t].details;if(n){var a=Be(e.frag,n.fragments,e.frag.start);if(null!=a&&a.gap)return"continue"}}else{if(p===U&&r.hasAudioGroup(m)||p===B&&r.hasSubtitleGroup(m))return"continue";if(d===K&&null!=(k=i.audioGroups)&&Sy(k).call(k,(function(e){return r.hasAudioGroup(e)}))||d===H&&null!=(T=i.subtitleGroups)&&Sy(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:Xe,flags:Je,nextAutoLevel:o}}return{action:Xe,flags:Ze}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case ze:break;case Xe:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===M.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=V_(r),n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case Je:this.switchLevel(e,a);break;case et:n&&(t.maxHdcpLevel=ke[hy(ke).call(ke,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(py(r="switching to level ".concat(t," after ")).call(r,e.details)),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}]),r}(X),fpsController:function(){function e(t){qm(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}return Xm(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(O.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(O.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=gE(pE(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(O.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(O.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}(),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:Yr,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:go,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:function(e){Ym(r,e);var t=Wm(r);function r(e,i,n){var a;return qm(this,r),(a=t.call(this,e,i,n,"subtitle-stream-controller",H)).currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a.registerListeners(),a}return Xm(r,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Qf(Xf(r.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){Qf(Xf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(O.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(O.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){Qf(Xf(r.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(O.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(O.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e){this.stopLoad(),this.state=Ri,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"onManifestLoading",value:function(){Qf(Xf(r.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,t){this.tracksBuffered=[],Qf(Xf(r.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var r=t.frag,i=t.success;if(_t(r)&&(this.fragPrevious=r),this.state=Ri,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),ey(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,H)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===H&&(t.details===M.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==bi&&(this.state=Ri))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks;this.levels&&fa(this.levels,i)?this.levels=Dy(i).call(i,(function(e){return new Ie(e)})):(this.tracksBuffered=[],this.levels=Dy(i).call(i,(function(e){var t=new Ie(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,H),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!==bi&&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){if(this.log(py(r=py(i=py(n=py(a="Subtitle track ".concat(h," loaded [")).call(a,c.startSN,",")).call(n,c.endSN,"]")).call(i,c.lastPartSn?py(s="[part-".concat(c.lastPartSn,"-")).call(s,c.lastPartIndex,"]"):"",",duration:")).call(r,c.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges,c.live||null!=(o=d.details)&&o.live){var f=this.mainDetails;if(c.deltaUpdateFailed||!f)return;var v,g=f.fragments[0];d.details?0===this.alignPlaylists(c,d.details,null==(v=this.levelLastLoaded)?void 0:v.details)&&g&&vi(c,g.start):c.hasProgramDateTime&&f.hasProgramDateTime?(Ai(c,f),c.fragmentStart):g&&vi(c,g.start)}d.details=c,this.levelLastLoaded=d,h===l&&(this.hls.trigger(O.SUBTITLE_TRACK_UPDATED,{details:c,id:h,groupId:t.groupId}),this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===Ri)&&(Be(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&&br(n.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,Rr(n.method)).catch((function(e){throw a.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();a.trigger(O.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){var r;t.warn(py(r="".concat(e.name,": ")).call(r,e.message)),t.state=Ri}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===Ri){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=fr.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=Be(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(_t(d=this.mapToInitFragWhenRequired(d))){var p=u[d.sn-l.startSN-1];p&&p.cc===d.cc&&this.fragmentTracker.getState(p)===rt&&(d=p)}this.fragmentTracker.getState(d)===rt&&this.loadFragment(d,r,s)}}else this.state=Ri}},{key:"loadFragment",value:function(e,t,i){_t(e)?Qf(Xf(r.prototype),"loadFragment",this).call(this,e,t,i):this._loadInitSegment(e,t)}},{key:"mediaBufferTimeRanges",get:function(){return new Es(this.tracksBuffered[this.currentTrackId]||[])}}]),r}(Ni),subtitleTrackController:function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,e,"subtitle-track-controller")).media=null,i.tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.asyncPollTrackChange=function(){return i.pollTrackChange(0)},i.onTextTracksChanged=function(){if(i.useTextTrackPolling||self.clearInterval(i.subtitlePollingInterval),i.media&&i.hls.config.renderTextTracksNatively){for(var e=null,t=as(i.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 n=i.findTrackForTextTrack(e);i.subtitleTrack!==n&&i.setSubtitleTrack(n)}},i.registerListeners(),i}return Xm(r,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,Qf(Xf(r.prototype),"destroy",this).call(this)}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(O.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(O.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(O.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=gE(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r,i=this.media;if(i){var n=!!t.transferMedia;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,n||ey(r=as(i.textTracks)).call(r,(function(e){is(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,l,u=t.id,c=t.groupId,h=t.details,d=this.tracksInGroup[u];if(d&&d.groupId===c){var f=d.details;d.details=t.details,this.log(py(n=py(a=py(s=py(o=py(l="Subtitle track ".concat(u,' "')).call(l,d.name,'" lang:')).call(o,d.lang," group:")).call(s,c," loaded [")).call(a,h.startSN,"-")).call(n,h.endSN,"]")),u===this.trackId&&this.playlistLoaded(u,t,f)}else this.warn(py(r=py(i="Subtitle track with id:".concat(u," and group:")).call(i,c," not found in active group ")).call(r,null==d?void 0:d.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&&Sy(r).call(r,(function(e){return-1===(null==i?void 0:hy(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=Jm(a=this.tracks).call(a,(function(e){return!r||-1!==hy(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!Sy(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),ey(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=xe(l,o);if(u>-1)n=o[u];else{var c=xe(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(py(s="Updating subtitle tracks, ".concat(o.length,' track(s) found in "')).call(s,null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(O.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||Me(n,e)))return i}if(e){for(var a=0;a<t.length;a++){var s=t[a];if(va(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return a}for(var o=0;o<t.length;o++){var l=t[o];if(va(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(ga(t[r],e))return r;return-1}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==B||t.context.id!==this.trackId||this.groupIds&&-1===hy(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&&Me(e,r))return r;var i=xe(e,this.tracksInGroup);if(i>-1){var n=this.tracksInGroup[i];return this.setSubtitleTrack(i),n}if(r)return null;var a=xe(e,t);if(a>-1)return t[a]}}return null}},{key:"loadPlaylist",value:function(e){Qf(Xf(r.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,t){var i,n,a,s,o,l;Qf(Xf(r.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(py(i=py(n=py(a=py(s=py(o=py(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(i,h)),this.hls.trigger(O.SUBTITLE_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}},{key:"toggleTrackModes",value:function(){var e,t,r=this.media;if(r){var i,n=as(r.textTracks),a=this.currentTrack;if(a&&((i=Jm(n).call(n,(function(e){return ga(a,e)}))[0])||this.warn(py(e='Unable to find subtitle TextTrack with name "'.concat(a.name,'" and language "')).call(e,a.lang,'"'))),ey(t=uy([]).call(n)).call(t,(function(e){"disabled"!==e.mode&&e!==i&&(e.mode="disabled")})),i){var s=this.subtitleDisplay?"showing":"hidden";i.mode!==s&&(i.mode=s)}}}},{key:"setSubtitleTrack",value:function(e){var t,r,i=this.tracksInGroup;if(this.media)if(e<-1||e>=i.length||!_(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?py(t=py(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(O.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(O.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),r}(pa),timelineController:function(){function e(t){qm(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=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(O.MANIFEST_LOADING,this.onManifestLoading,this),t.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(O.FRAG_LOADING,this.onFragLoading,this),t.on(O.FRAG_LOADED,this.onFragLoaded,this),t.on(O.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(O.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(O.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(O.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this)}return Xm(e,[{key:"destroy",value:function(){var e=this.hls;e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(O.FRAG_LOADING,this.onFragLoading,this),e.off(O.FRAG_LOADED,this.onFragLoaded,this),e.off(O.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(O.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(O.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(O.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(O.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 co(this,"textTrack1"),t=new co(this,"textTrack2"),r=new co(this,"textTrack3"),i=new co(this,"textTrack4");this.cea608Parser1=new Fs(1,e,t),this.cea608Parser2=new Fs(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(O.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===G&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],ey(o).call(o,(function(e){r.onFragLoaded(O.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(fo(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,is(r[e]),ts(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(O.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;ey(r=Qm(n)).call(r,(function(e){is(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++)is(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks||[],n=Sy(i).call(i,(function(e){return e.textCodec===Zs}));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(fa(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a,s=this.media,o=s?as(s.textTracks):null;if(ey(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]&&fo(o[a],e)){n=o[a],o[a]=null;break}n&&(i=n)}if(i)is(i);else{var s=ho(e);(i=r.createTextTrack(s,e.name,e.lang))&&(i.mode="disabled")}i&&r.textTracks.push(i)})),null!=o&&o.length){var l,u=Dy(l=Jm(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=Dy(c=this.tracks).call(c,(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(O.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:h})}}}},{key:"onManifestLoaded",value:function(e,t){var r,i=this;this.config.enableCEA708Captions&&t.captions&&ey(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===G){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===H)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===Zs?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(O.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;io(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(O.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){i.logger.log("Failed to parse IMSC1: ".concat(t)),i.trigger(O.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;Js(null!=(t=i.initSegment)&&t.data?$t(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(O.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(O.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||io(t,this.initPTS[e.cc],(function(){i.textCodec=Zs,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;ey(e).call(e,(function(e){return rs(i,e)}))}else{var n=this.tracks[t];if(!n)return;var a=n.default?"default":"subtitles"+t;r.trigger(O.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===H&&this.onFragLoaded(O.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!==G||"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;ey(o=Qm(l)).call(o,(function(e){return ns(l[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u,c=this.textTracks;ey(u=Qm(c)).call(u,(function(e){return ns(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)&&0!=(4&a)){var l=3&a;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}(),audioStreamController:function(e){Ym(r,e);var t=Wm(r);function r(e,i,n){var a;return qm(this,r),(a=t.call(this,e,i,n,"audio-stream-controller",K)).mainAnchor=null,a.mainFragLoading=null,a.audioOnly=!1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.flushing=!1,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a.registerListeners(),a}return Xm(r,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Qf(Xf(r.prototype),"onHandlerDestroying",this).call(this),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){Qf(Xf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(O.BUFFER_RESET,this.onBufferReset,this),e.on(O.BUFFER_CREATED,this.onBufferCreated,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(O.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(O.FRAG_LOADING,this.onFragLoading,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(Qf(Xf(r.prototype),"unregisterListeners",this).call(this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(O.BUFFER_RESET,this.onBufferReset,this),e.off(O.BUFFER_CREATED,this.onBufferCreated,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(O.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(O.FRAG_LOADING,this.onFragLoading,this),e.off(O.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===G){var s,o,l=r.cc,u=this.fragCurrent;if(this.initPTS[l]={baseTime:n,timescale:a},this.log(py(s=py(o="InitPTS for cc: ".concat(l," found from main: ")).call(o,n,"/")).call(s,a)),this.mainAnchor=r,this.state===Oi){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===Ri&&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=py(a).call(a,s))}return Ue(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&&He(t.fragments,r)||e}},{key:"startLoad",value:function(e){if(!this.levels)return this.startPosition=e,void(this.state=bi);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=Ri):this.state=_i,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case Ri:this.doTickIdle();break;case _i:var e=this.levels,t=this.trackId,i=null==e?void 0:e[t],n=null==i?void 0:i.details;if(n&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(n))break;this.state=Oi}break;case wi: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=Ri}break;case Oi:var c=this.waitingData;if(c){var h,d=c.frag,f=c.part,v=c.cache,g=c.complete,p=this.mainAnchor;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.state=Di;var m={frag:d,part:f,payload:v.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(m),g&&Qf(Xf(r.prototype),"_handleFragmentLoadComplete",this).call(this,m)}else p&&p.cc!==c.frag.cc&&(this.log(py(h="Waiting fragment cc (".concat(d.cc,") cancelled because video is at cc ")).call(h,p.cc)),this.nextLoadPosition=this.findSyncFrag(p).start,this.clearWaitingFragment())}else this.state=Ri}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!==bi&&(this.state=Ri))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),Qf(Xf(r.prototype),"resetLoadingState",this).call(this)}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,r=this.levels,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=_i,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Rt,K));var u=this.getFwdBufferInfo(l,K);if(null!==u){var c=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(u,o))return t.trigger(O.BUFFER_EOS,{type:"audio"}),void(this.state=xi);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&&!va(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,G,f)),E){var k=null==(e=this.mainFragLoading)?void 0:e.frag;if(!this.audioOnly&&this.startFragRequested&&k&&_t(k)&&_t(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,G);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,Qf(Xf(r.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=Dy(r).call(r,(function(e){return new Ie(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!==bi&&(this.setInterval(100),this.state=Ri,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){Qf(Xf(r.prototype),"onManifestLoading",this).call(this),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.hls.trigger(O.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!==bi&&(this.state=_i));if(l){this.log(py(r=py(i=py(n=py(a="Audio track ".concat(c," loaded [")).call(a,u.startSN,",")).call(n,u.endSN,"]")).call(i,u.lastPartSn?py(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;d.details&&(f=this.alignPlaylists(u,d.details,null==(v=this.levelLastLoaded)?void 0:v.details)),u.alignedSliding||(Si(u,h),u.alignedSliding||Ai(u,h),f=u.fragmentStart)}d.details=u,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(h,f),this.hls.trigger(O.AUDIO_TRACK_UPDATED,{details:u,id:c,groupId:t.groupId}),this.state!==_i||this.waitForCdnTuneIn(u)||(this.state=Ri),this.tick()}else this.warn("Audio tracks were reset while loading level ".concat(c))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r,i,n,a=e.frag,s=e.part,o=e.payload,l=this.config,u=this.trackId,c=this.levels;if(c){var h=c[u];if(h){var d=h.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(a.start);var f=l.defaultAudioCodec||h.audioCodec||"mp4a.40.2",v=this.transmuxer;v||(v=this.transmuxer=new da(this.hls,K,pE(r=this._handleTransmuxComplete).call(r,this),pE(i=this._handleTransmuxerFlush).call(i,this)));var g=this.initPTS[a.cc],p=null==(n=a.initSegment)?void 0:n.data;if(void 0!==g){var m=!1,y=s?s.index:-1,E=-1!==y,k=new hr(a.level,a.sn,a.stats.chunkCount,o.byteLength,y,E);v.push(o,p,f,"",a,s,d.totalduration,m,k,g)}else{var T,S,A,L;this.log(py(T=py(S=py(A=py(L="Unknown video PTS for cc ".concat(a.cc,", waiting for video PTS before demuxing audio frag ")).call(L,a.sn," of [")).call(A,d.startSN," ,")).call(S,d.endSN,"],track ")).call(T,u)),(this.waitingData=this.waitingData||{frag:a,part:s,cache:new Ui,complete:!1}).cache.push(new Uint8Array(o)),this.state!==bi&&(this.state=Oi)}}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(py(t="Audio tracks were reset while fragment load was in progress. Fragment ".concat(a.sn," of level ")).call(t,a.level," will not be buffered"))}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:Qf(Xf(r.prototype),"_handleFragmentLoadComplete",this).call(this,e)}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===G&&_t(t.frag)&&(this.mainFragLoading=t,this.state===Ri&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r,i,n,a,s=t.frag,o=t.part;if(s.type===K)if(this.fragContextChanged(s))this.warn(py(r=py(i=py(n=py(a="Fragment ".concat(s.sn)).call(a,o?" p: "+o.index:""," of level ")).call(n,s.level," finished buffering, but was aborted. state: ")).call(i,this.state,", audioSwitch: ")).call(r,this.switchingTrack?this.switchingTrack.name:"false"));else{if(_t(s)){this.fragPrevious=s;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(O.AUDIO_TRACK_SWITCHED,z({},l)))}this.fragBufferedComplete(s,o),this.media&&this.tick()}else this.audioOnly||s.type!==G||s.elementaryStreams.video||s.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,t){var i;if(t.fatal)this.state=Mi;else switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(K,t);break;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==_i||(null==(i=t.context)?void 0:i.type)!==U||(this.state=Ri);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===M.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,Qf(Xf(r.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==It&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==It){this.flushing=!1,this.bufferFlushed=!0,this.state===xi&&(this.state=Ri);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,r,K),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=Pi,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(O.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[Rt]={startPTS:p,endPTS:m,startDTS:y,endDTS:E}),o.setElementaryStreamInfo(Rt,p,m,y,E),this.bufferFragmentData(h,o,l,a)}if(null!=f&&null!=(t=f.samples)&&t.length){var k=W({id:r,frag:o,details:c},f);i.trigger(O.FRAG_PARSING_METADATA,k)}if(d){var T=W({id:r,frag:o,details:c},d);i.trigger(O.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===Pi&&(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(py(n=py(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(O.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(O.BUFFER_APPENDING,u)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,t,i){var n,a=this.fragmentTracker.getState(e);if(this.switchingTrack||a===rt||a===nt)if(_t(e))if(null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]){var s,o;this.log(py(s=py(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=Oi;var l=this.mainDetails;l&&l.fragmentStart!==t.details.fragmentStart&&Ai(t.details,l)}else Qf(Xf(r.prototype),"loadFragment",this).call(this,e,t,i);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){var t=this.media,i=this.bufferedTrack,n=null==i?void 0:i.attrs,a=e.attrs;t&&n&&(n.CHANNELS!==a.CHANNELS||i.name!==e.name||i.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),Qf(Xf(r.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(O.AUDIO_TRACK_SWITCHED,z({},e))}}]),r}(Ni),audioTrackController:function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,e,"audio-track-controller")).tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}return Xm(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(O.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(O.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(O.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,Qf(Xf(r.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var r,i,n,a,s,o,l,u=t.id,c=t.groupId,h=t.details,d=this.tracksInGroup[u];if(d&&d.groupId===c){var f=d.details;d.details=t.details,this.log(py(n=py(a=py(s=py(o=py(l="Audio track ".concat(u,' "')).call(l,d.name,'" lang:')).call(o,d.lang," group:")).call(s,c," loaded [")).call(a,h.startSN,"-")).call(n,h.endSN,"]")),u===this.trackId&&this.playlistLoaded(u,t,f)}else this.warn(py(r=py(i="Audio track with id:".concat(u," and group:")).call(i,c," not found in active group ")).call(r,null==d?void 0:d.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&&Sy(r).call(r,(function(e){return-1===(null==i?void 0:hy(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=Jm(a=this.tracks).call(a,(function(e){return!r||-1!==hy(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!Sy(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),ey(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=xe(l,o,Oe);if(u>-1)n=o[u];else{var c=xe(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(py(s="Updating audio tracks, ".concat(o.length," track(s) found in group(s): ")).call(s,null==r?void 0:r.join(","))),this.hls.trigger(O.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(py(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(O.ERROR,{type:x.MEDIA_ERROR,details:M.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:p})}}}}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==U||t.context.id!==this.trackId||this.groupIds&&-1===hy(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&&Me(e,i,Oe))return i;var n=xe(e,this.tracksInGroup,Oe);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=eS(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=Fe(t,i,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var i=t.audioGroups,a=Jm(r).call(r,(function(e){return!i||-1!==hy(i).call(i,e.groupId)}));return xe(e,a,n)>-1}));return c>-1?c:Fe(t,i,(function(t){var i=t.audioGroups,a=Jm(r).call(r,(function(e){return!i||-1!==hy(i).call(i,e.groupId)}));return xe(e,a,n)>-1}))}(e,t.levels,r,s,Oe);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=xe(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(py(t=py(r=py(i=py(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(O.AUDIO_TRACK_SWITCHING,z({},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||Me(e,i,Oe)))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(Me({name:n,lang:a,assocLang:s,characteristics:o,audioCodec:l,channels:u},t[c],Oe))return c;for(var h=0;h<t.length;h++){var d=t[h];if(va(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var f=0;f<t.length;f++){var v=t[f];if(va(e.attrs,v.attrs,["LANGUAGE"]))return f}}return-1}},{key:"loadPlaylist",value:function(e){Qf(Xf(r.prototype),"loadPlaylist",this).call(this);var t=this.currentTrack;this.shouldLoadPlaylist(t)&&Ne(t.url,this.hls)&&this.scheduleLoading(t,e)}},{key:"loadingPlaylist",value:function(e,t){var i,n,a,s,o,l;Qf(Xf(r.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(py(i=py(n=py(a=py(s=py(o=py(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(i,h)),this.hls.trigger(O.AUDIO_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}}]),r}(pa),emeController:Za,cmcdController:function(){function e(t){var r=this;qm(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(e){try{r.apply(e,{ot:La.MANIFEST,su:!r.initialized})}catch(t){r.hls.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(e){try{var t=e.frag,i=e.part,n=r.hls.levels[t.level],a=r.getObjectType(t),s={d:1e3*(i||t).duration,ot:a};a!==La.VIDEO&&a!==La.AUDIO&&a!=La.MUXED||(s.br=n.bitrate/1e3,s.tb=r.getTopBandwidth(a)/1e3,s.bl=r.getBufferLength(a));var o=i?r.getNextPart(i):r.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),r.apply(e,s)}catch(l){r.hls.logger.warn("Could not generate segment CMCD data.",l)}},this.hls=t;var i=this.config=t.config,n=i.cmcd;null!=n&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||t.sessionId,this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.includeKeys=n.includeKeys,this.registerListeners())}return Xm(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHED,this.onMediaDetached,this),e.on(O.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHED,this.onMediaDetached,this),e.off(O.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:ba.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,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(r,this.createData());var i=r.ot===La.INIT||r.ot===La.VIDEO||r.ot===La.MUXED;this.starved&&i&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering);var n=this.includeKeys;n&&(r=eS(t=Qm(r)).call(t,(function(e,t){return zx(n).call(n,t)&&(e[t]=r[t]),e}),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),za(e.headers,r,a)):e.url=Qa(e.url,r,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?La.TIMED_TEXT:"initSegment"===e.sn?La.INIT:"audio"===t?La.AUDIO:"main"===t?this.hls.audioTracks.length?La.VIDEO:La.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,i=this.hls;if(e===La.AUDIO)t=i.audioTracks;else{var n,a=i.maxAutoLevel,s=a>-1?a+1:i.levels.length;t=uy(n=i.levels).call(n,0,s)}var o,l=function(e,t){var r=void 0!==Ih&&od(e)||e["@@iterator"];if(!r){if(ud(e)||(r=gf(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(c){l.e(c)}finally{l.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===La.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*fr.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(t){qm(this,e),this.loader=void 0,this.loader=new r(t)}return Xm(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,i){t(e),this.loader.load(e,r,i)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(t){qm(this,e),this.loader=void 0,this.loader=new r(t)}return Xm(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,i){t(e),this.loader.load(e,r,i)}}]),e}()}}]),e}(),contentSteeringController:function(e){Ym(r,e);var t=Wm(r);function r(e){var i;return qm(this,r),(i=t.call(this,"content-steering",e.logger)).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i._pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=e,i.registerListeners(),i}return Xm(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.ERROR,this.onError,this))}},{key:"pathways",value:function(){var e;return eS(e=this.levels||[]).call(e,(function(e,t){return-1===hy(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=Jm(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)===Xe&&V_(r)===Ze){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)}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(py(i=py(n=py(a=py(s=py(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,x_(u)," penalized: ")).call(i,x_(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){var t,r;this.levels=e;var i=this.getLevelsForPathway(this.pathwayId);if(0===i.length){var n,a=e[0].pathwayId;this.log(py(n="No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "')).call(n,a,'"')),i=this.getLevelsForPathway(a),this.pathwayId=a}return i.length!==e.length&&this.log(py(t=py(r="Found ".concat(i.length,"/")).call(r,e.length,' levels in Pathway "')).call(t,this.pathwayId,'"')),i}},{key:"getLevelsForPathway",value:function(e){var t;return null===this.levels?[]:Jm(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();ey(t=Qm(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){var u;this.log('Setting Pathway to "'.concat(s,'"')),this.pathwayId=s,yi(r),this.hls.trigger(O.LEVELS_UPDATED,{levels:r});var c=this.hls.levels[o];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(py(u="Unstable Pathways change from bitrate ".concat(l.bitrate," to ")).call(u,c.bitrate)),this.hls.nextLoadLevel=o);break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var i,n=py(i=this.getLevelsForPathway(r)).call(i,this.levels||[]),a=0;a<n.length;a++)if(t===U&&n[a].hasAudioGroup(e)||t===B&&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={};ey(e).call(e,(function(e){var a,s=e.ID,o=e["BASE-ID"],l=e["URI-REPLACEMENT"];if(!Sy(r).call(r,(function(e){return e.pathwayId===s}))){var u=Dy(a=t.getLevelsForPathway(o)).call(a,(function(e){var t,r,a=new Tr(e.attrs);a["PATHWAY-ID"]=s;var o=a.AUDIO&&py(t="".concat(a.AUDIO,"_clone_")).call(t,s),u=a.SUBTITLES&&py(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=Ja(e.uri,a["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),h=new Ie({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",py(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",py(g="".concat(e.subtitleGroups[v],"_clone_")).call(g,s))}return h}));r.push.apply(r,pf(u)),$a(t.audioTracks,i,l,s),$a(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 e_(e)}catch(h){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 e_(o,t).href}catch(h){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(O.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(py(a=py(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*ck(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=mE((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)}}]),r}(X),interstitialsController:function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n;return qm(this,r),(n=t.call(this,"interstitials",e.logger)).HlsPlayerClass=void 0,n.hls=void 0,n.assetListLoader=void 0,n.mediaSelection=null,n.altSelection=null,n.media=null,n.detachedData=null,n.requiredTracks=null,n.manager=null,n.playerQueue=[],n.bufferedPos=-1,n.timelinePos=-1,n.schedule=void 0,n.playingItem=null,n.bufferingItem=null,n.waitingItem=null,n.playingAsset=null,n.bufferingAsset=null,n.shouldPlay=!1,n.onPlay=function(){n.shouldPlay=!0},n.onPause=function(){n.shouldPlay=!1},n.onSeeking=function(){var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled){var t=e-n.timelinePos;if(!(Math.abs(t)<1/7056e5)){var r=t<=-.01;n.timelinePos=e,n.bufferedPos=e,n.checkBuffer();var i=n.playingItem;if(i)if(r&&e<i.start||e>=i.end){var a,s=n.schedule.findItemIndexAtTime(n.timelinePos);if(!n.isInterstitial(i)&&null!=(a=n.media)&&a.paused&&(n.shouldPlay=!1),!r){var o=n.findItemIndex(i);if(s>o){var l=n.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void n.setSchedulePosition(l)}}n.setSchedulePosition(s)}else{var u=n.playingAsset;if(u){var c=u.timelineStart,h=u.duration||0;(r&&e<c||e>=c+h)&&n.setScheduleToAssetAtTime(e,u)}else if(n.playingLastItem&&n.isInterstitial(i)){var d=i.event.assetList[0];d&&(n.playingItem=null,n.setScheduleToAssetAtTime(e,d))}}}}},n.onTimeupdate=function(){var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&e>n.timelinePos){e>n.bufferedPos&&n.checkBuffer(),n.timelinePos=e;var t=n.playingItem;if(t&&!n.playingLastItem){if(e>=t.end){n.timelinePos=t.end;var r=n.findItemIndex(t);n.setSchedulePosition(r+1)}var i=n.playingAsset;i&&e>=i.timelineStart+(i.duration||0)&&n.setScheduleToAssetAtTime(e,i)}}},n.onScheduleUpdate=function(e,t){var r,i,a,s=n.schedule,o=n.playingItem,l=s.events||[],u=s.items||[],c=s.durations,h=Dy(e).call(e,(function(e){return e.identifier})),d=!(!l.length&&!h.length);d&&(!1===n.hls.config.interstitialAppendInPlace&&ey(l).call(l,(function(e){return e.appendInPlace=!1})),n.log(py(r=py(i="INTERSTITIALS_UPDATED (".concat(l.length,"): ")).call(i,l,"\nSchedule: ")).call(r,Dy(u).call(u,(function(e){return ps(e)}))))),h.length&&n.log("Removed events ".concat(h)),ey(a=n.playerQueue).call(a,(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,a,s;Math.abs(r)>os&&n.warn(py(i=py(a=py(s="".concat(o,' ("')).call(s,e.assetId,'" ')).call(a,e.timelineOffset,"->")).call(i,t,")"))}}})),o&&!o.event&&(n.playingItem=n.updateItem(o,n.timelinePos));var f=n.bufferingItem;if(f&&(f.event?n.updateItem(f)||(n.bufferingItem=null,n.clearInterstitial(f.event,null)):n.bufferingItem=n.updateItem(f,n.bufferedPos)),n.waitingItem=n.updateItem(n.waitingItem),ey(e).call(e,(function(e){var t;ey(t=e.assetList).call(t,(function(e){n.clearAssetPlayer(e.identifier,null)}))})),d||t){if(n.hls.trigger(O.INTERSTITIALS_UPDATED,{events:uy(l).call(l,0),schedule:uy(u).call(u,0),durations:c,removedIds:h}),n.isInterstitial(o)&&zx(h).call(h,o.event.identifier))return n.warn('Interstitial "'.concat(o.event.identifier,'" removed while playing')),void n.primaryFallback(o.event);n.checkBuffer()}},n.hls=e,n.HlsPlayerClass=i,n.assetListLoader=new ms(e),n.schedule=new gs(n.onScheduleUpdate,e.logger),n.registerListeners(),n}return Xm(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(O.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(O.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(O.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(O.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(O.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(O.BUFFER_APPENDED,this.onBufferAppended,this),e.on(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(O.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(O.MEDIA_ENDED,this.onMediaEnded,this),e.on(O.ERROR,this.onError,this),e.on(O.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(O.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(O.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(O.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(O.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(O.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(O.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.BUFFER_APPENDED,this.onBufferAppended,this),e.off(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(O.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(O.MEDIA_ENDED,this.onMediaEnded,this),e.off(O.ERROR,this.onError,this),e.off(O.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;ey(e=this.playerQueue).call(e,(function(e){return e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){var e;ey(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!==ls.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(py(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,w=I.length;w--;){var _=I[w];if(_.duration&&D>=_.startOffset&&D<_.startOffset+_.duration){b=w;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:uy(r).call(r,0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:uy(r).call(r,0))||[]},get playerQueue(){var t;return uy(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;return void 0!==a&&_(a)?a:void 0}}}},{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(py(n="transfer MediaSource from ".concat(e," ")).call(n,x_(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(py(r=py(i="transferring to ".concat(c?e:"Primary","\nMediaSource ")).call(i,x_(l)," from ")).call(r,o)),l||(d?(l=this.detachedData,this.log("using detachedData: MediaSource ".concat(x_(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(py(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(py(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==(c=h.assetList)?void 0:c[t].identifier))){var g,p;this.playingAsset=null;var m=h.findAssetIndex(d);this.log(py(g=py(p="INTERSTITIAL_ASSET_ENDED ".concat(m+1,"/")).call(p,h.assetList.length," ")).call(g,fs(d))),this.hls.trigger(O.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:m,event:h,schedule:uy(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)&&(this.playingItem=null,this.log(py(u="INTERSTITIAL_ENDED ".concat(h," ")).call(u,ps(o))),h.hasPlayed=!0,this.hls.trigger(O.INTERSTITIAL_ENDED,{event:h,schedule:uy(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&&ey(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)){var k,T,S;this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);var A=a.event;void 0===t&&(t=this.schedule.findAssetIndex(A,this.timelinePos));var L=this.waitingItem,b=this.preloadAssets(A,t);b||this.setBufferingItem(a),this.eventItemsMatch(a,o||L)||(this.waitingItem=a,this.log(py(k="INTERSTITIAL_STARTED ".concat(ps(a)," ")).call(k,A.appendInPlace?"append in place":"")),this.hls.trigger(O.INTERSTITIAL_STARTED,{event:A,schedule:uy(n).call(n,0),scheduleIndex:e}));var R=A.assetList.length;if(0===R&&!A.assetListResponse)return void this.log("Waiting for ASSET-LIST to complete loading ".concat(A));if(A.assetListLoader&&(A.assetListLoader.destroy(),A.assetListLoader=void 0),!s)return void this.log("Waiting for attachMedia to start Interstitial ".concat(A));this.waitingItem=null,this.playingItem=a;var I=A.assetList[t];if(!I){var D=n[e+1],w=this.media;return D&&w&&!this.isInterstitial(D)&&w.currentTime<D.start&&(w.currentTime=this.timelinePos=D.start),void this.advanceAfterAssetEnded(A,e,t||0)}if(b||(b=this.getAssetPlayer(I.identifier)),(null===b||b.destroyed)&&(this.warn(py(T=py(S="asset ".concat(t+1,"/")).call(S,R," player destroyed ")).call(T,A)),b=this.createAssetPlayer(A,I,t)),!this.eventItemsMatch(a,this.bufferingItem)&&A.appendInPlace&&this.isAssetBuffered(I))return;this.startAssetPlayer(b,t,n,e,s),this.shouldPlay&&ys(b.media)}else null!==a?(this.resumePrimary(a,e,o),this.shouldPlay&&ys(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(ps(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(ps(e))),this.hls.trigger(O.INTERSTITIALS_PRIMARY_RESUMED,{schedule:uy(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:fr.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(O.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(O.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],i=z(z({},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=z(z({},i),{},{audio:r});this.mediaSelection=n}else this.altSelection=z(z({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(i){var n=z(z({},i),{},{subtitles:r});this.mediaSelection=n}else this.altSelection=z(z({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r,i=Ce(t);ey(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=Ce(t);ey(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=fr.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;this.log("buffered to boundary ".concat(ps(e))+(t?" (".concat(u.toFixed(2)," remaining)"):"")),this.bufferingItem=e,this.bufferedPos=e.start,this.playbackDisabled||(o?ey(a=this.playerQueue).call(a,(function(e){return e.resumeBuffering()})):(this.hls.resumeBuffering(),ey(s=this.playerQueue).call(s,(function(e){return e.pauseBuffering()})))),this.hls.trigger(O.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:uy(n).call(n,0),schedule:uy(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){var n=!0;this.attachPrimary(e.start,e,n)}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(py(a=py(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,r=this,i=this.requiredTracks;i&&ey(t=Qm(i)).call(t,(function(t){r.hls.trigger(O.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}},{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:us(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(fs(t)));var n=this.hls,a=n.userConfig,s=a.videoPreference,o=n.levels[n.loadLevel]||n.levels[n.currentLevel];(s||o)&&(s=W({},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=z(z({},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=W({},v,{contentId:ss(t.uri)}));var g=new vs(this.HlsPlayerClass,f,e,t);this.playerQueue.push(g),e.assetList[r]=t;var p=t.identifier,m=function(n){var a,s;if(n.live){var o=new Error("Interstitials MUST be VOD assets ".concat(e)),l={fatal:!0,type:x.OTHER_ERROR,details:M.INTERSTITIAL_ASSET_ITEM_ERROR,error:o};i.handleAssetItemError(l,e,i.schedule.findEventIndex(e.identifier),r,o.message)}else{var u=n.edge-n.fragmentStart,c=t.duration;(null===c||u>c)&&(i.log(py(a=py(s='Interstitial asset "'.concat(p,'" duration change ')).call(s,c," > ")).call(a,u)),t.duration=u,i.updateSchedule())}};g.on(O.LEVEL_UPDATED,(function(e,t){var r=t.details;return m(r)})),g.on(O.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return m(r)}));var y=function e(t,r){var n=i.getAssetPlayer(p);if(n&&r.tracks){n.off(O.BUFFER_CODECS,e),n.tracks=r.tracks;var a=i.primaryMedia;i.bufferingAsset===n.assetItem&&a&&!n.media&&i.bufferAssetPlayer(n,a)}};g.on(O.BUFFER_CODECS,y);var E=function r(n){var a,s=i.getAssetPlayer(p);if(i.log("buffered to end of asset ".concat(s)),s){s.off(O.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)}};g.on(O.BUFFERED_TO_END,E);var k=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(O.MEDIA_ENDED,k(r)),g.once(O.PLAYOUT_LIMIT_REACHED,k(1/0)),g.on(O.ERROR,(function(t,n){var a;i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,py(a="Asset player error ".concat(n.error," ")).call(a,e))})),g.on(O.DESTROYING,(function(){if(i.getAssetPlayer(p)){var t=new Error("Asset player destroyed unexpectedly ".concat(p)),n={fatal:!0,type:x.OTHER_ERROR,details:M.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(O.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:g}),g}},{key:"clearInterstitial",value:function(e,t){var r,i=this;ey(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(py(i='clearAssetPlayer "'.concat(e,'" toSegment: ')).call(i,t?ps(t):t));var a=this.playerQueue[r];this.transferMediaFromPlayer(a,t),UE(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(py(a=py(s="INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/")).call(s,c," ")).call(a,e)),this.hls.trigger(O.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:o,schedule:uy(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&&!ie(c,e.tracks)){var h,d,f=new Error(py(h=py(d='Asset "'.concat(s,"\" SourceBuffer tracks ('")).call(d,Qm(e.tracks),"') are not compatible with primary content tracks ('")).call(h,Qm(c),"')")),v={fatal:!0,type:x.OTHER_ERROR,details:M.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!==M.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=W({},e,{fatal:!1,errorAction:tt(!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(O.INTERSTITIAL_ASSET_ERROR,c),e.fatal){var h=new Error(n);s&&(this.playingAsset!==s&&this.clearAssetPlayer(s.identifier,null),s.error=h),Sy(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(py(i=py(n=py(a=py(s='Fallback to primary from event "'.concat(e.identifier,'" start: ')).call(s,t," pos: ")).call(a,this.timelinePos," playing: ")).call(n,r?ps(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;ey(s).call(s,(function(e,t){var r=ck(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 M.ASSET_LIST_PARSING_ERROR:case M.ASSET_LIST_LOAD_ERROR:case M.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r)}}}]),r}(X)});function Ao(e){var t;return e&&"object"==qh(e)?sy(e)?Dy(e).call(e,Ao):eS(t=Qm(e)).call(t,(function(t,r){return t[r]=Ao(e[r]),t}),{}):e}function Lo(e,t){var r=e.loader;r!==mo&&r!==To?(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=mo,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}function bo(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function Ro(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,x_(n?z({type:n},i):i))}return a}var Io=function(){var e=bo();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}(),Do=function(){function e(t){var r=this;qm(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){r.hls&&r.hls.trigger(O.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()}return Xm(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(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.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&&is(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 ts(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=bo();if(s)for(var o=0;o<a.length;o++){var l=a[o].type;if((l!==dn.emsg||i)&&n){var u=ln(a[o].data);if(u){var c=a[o].pts,h=c+a[o].duration;h>Io&&(h=Io),h-c<=0&&(h=c+.25);for(var d=0;d<u.length;d++){var f=u[d];if(!un(f)){this.updateId3CueEnds(c,l);var v=Ro(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===Io&&(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;a&&(l||u)&&ns(a,r,i,"audio"===n?function(e){return e.type===dn.audioId3&&u}:"video"===n?function(e){return e.type===dn.emsg&&l}:function(e){return e.type===dn.audioId3&&u||e.type===dn.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=Qm(a),o=this.dateRangeCuesAppended;if(n&&t)if(null!=(i=n.cues)&&i.length)for(var l,u=Jm(l=Qm(o)).call(l,(function(e){return!zx(s).call(s,e)})),c=function(){var e,t=u[h],i=o[t].cues;delete o[t],ey(e=Qm(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&&_(null==d?void 0:d.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f,v,g=bo(),p=function(){var e=s[m],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=Io,h=t.duration;if(t.endDate&&null!==h)c=i+h,u=!0;else if(t.endOnNext&&!u){var d=eS(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 p=Qm(t.attr),y=0;y<p.length;y++){var E=p[y];if("ID"!==(v=E)&&"CLASS"!==v&&"CUE"!==v&&"START-DATE"!==v&&"DURATION"!==v&&"END-DATE"!==v&&"END-ON-NEXT"!==v){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(g){var T=t.attr[E];Sr(E)&&(f=T,T=Uint8Array.from(f.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=Ro(g,i,c,{key:E,data:T},dn.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}},m=0;m<s.length;m++)p()}}}}]),e}(),wo=function(){function e(t){var r=this;qm(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=r.media,t=r.hls.latestLevelDetails;if(e&&t){r.currentTime=e.currentTime;var i=r.computeLatency();if(null!==i){r._latency=i;var n=r.config,a=n.lowLatencyMode,s=n.maxLiveSyncPlaybackRate;if(a&&1!==s&&t.live){var o=r.targetLatency;if(null!==o){var l=i-o;if(l<Math.min(r.maxLatency,o+t.targetduration)&&l>.05&&r.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),c=Math.round(2/(1+Math.exp(-.75*l-r.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()}return Xm(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(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(O.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){this.hls.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(O.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(O.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===M.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}(),_o=function(e){Ym(r,e);var t=Wm(r);function r(e,i){var n;return qm(this,r),(n=t.call(this,e,"level-controller"))._levels=[],n._firstLevel=-1,n._maxAutoLevel=-1,n._startLevel=void 0,n.currentLevel=null,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.steering=void 0,n.onParsedComplete=void 0,n.steering=i,n._registerListeners(),n}return Xm(r,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),Qf(Xf(r.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){var e;ey(e=this._levels).call(e,(function(e){e.loadError=0,e.fragmentError=0})),Qf(Xf(r.prototype),"stopLoad",this).call(this)}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var r,i=this,n=this.hls.config.preferManagedMediaSource,a=[],s={},o={},l=!1,u=!1,c=!1;ey(r=t.levels).call(r,(function(e){var t,r,h,d,f,v,g=e.attrs,p=e.audioCodec,m=e.videoCodec;p&&(e.audioCodec=p=de(p,n)||void 0),0===(null==(v=m)?void 0:hy(v).call(v,"avc1"))&&(m=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+=Ck(i.shift()).toString(16),a+=uy(n="000"+Ck(i.shift()).toString(16)).call(n,-4),t[r]=a}}return t.join(",")}(m));var y=e.width,E=e.height,k=e.unknownCodecs,T=k?k.length:0;if(k)for(var S=T;S--;){var A,L,b=k[S];i.isAudioSupported(b)?(e.audioCodec=p=p?py(A="".concat(p,",")).call(A,b):b,T--,ne.audio[p.substring(0,4)]=2):i.isVideoSupported(b)&&(e.videoCodec=m=m?py(L="".concat(m,",")).call(L,b):b,T--,ne.video[m.substring(0,4)]=2)}if(l||(l=!(!y||!E)),u||(u=!!m),c||(c=!!p),!(T||p&&!i.isAudioSupported(p)||m&&!i.isVideoSupported(m))){var R=g.CODECS,I=g["FRAME-RATE"],D=g["HDCP-LEVEL"],w=g["PATHWAY-ID"],_=g.RESOLUTION,P=g["VIDEO-RANGE"],C=py(t=py(r=py(h=py(d=py(f="".concat("".concat(w||".","-"),e.bitrate,"-")).call(f,_,"-")).call(d,I,"-")).call(h,R,"-")).call(r,P,"-")).call(t,D);if(s[C])if(s[C].uri===e.url||e.attrs["PATHWAY-ID"])s[C].addGroupId("audio",g.AUDIO),s[C].addGroupId("text",g.SUBTITLES);else{var x=o[C]+=1;e.attrs["PATHWAY-ID"]=new Array(x+1).join(".");var M=new Ie(e);s[C]=M,a.push(M)}else{var O=new Ie(e);s[C]=O,o[C]=1,a.push(O)}}})),this.filterAndSortMediaOptions(a,t,l,u,c)}},{key:"isAudioSupported",value:function(e){return ae(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return ae(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,i,n){var a,s=this,o=[],l=[],u=e;if((r||i)&&n&&(u=Jm(u).call(u,(function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&!!(t=i)&&hy(Te).call(Te,t)>-1}))),0!==u.length){t.audioTracks&&Po(o=Jm(a=t.audioTracks).call(a,(function(e){return!e.audioCodec||s.isAudioSupported(e.audioCodec)}))),t.subtitles&&Po(l=t.subtitles);var c=uy(u).call(u,0);gT(u).call(u,(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 hy(Te).call(Te,e.videoRange)-hy(Te).call(Te,t.videoRange);if(e.videoCodec!==t.videoCodec){var i=le(e.videoCodec),n=le(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=ue(e.codecSet),s=ue(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&&(u=this.steering.filterParsedLevels(u)).length!==c.length)for(var d=0;d<c.length;d++)if(c[d].pathwayId===u[0].pathwayId){h=c[d];break}this._levels=u;for(var f=0;f<u.length;f++)if(u[f]===h){var v,g;this._firstLevel=f;var p=h.bitrate,m=this.hls.bandwidthEstimate;if(this.log(py(v="manifest loaded, ".concat(u.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:u,audioTracks:o,subtitleTracks:l,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!E&&Sy(o).call(o,(function(e){return!!e.url}))};this.hls.trigger(O.MANIFEST_PARSED,k)}else RR.resolve().then((function(){if(s.hls){t.levels.length&&s.warn("One or more CODECS in variant not supported: ".concat(x_(t.levels[0].attrs)));var e=new Error("no level with compatible codecs found in manifest");s.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.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(O.ERROR,{type:x.OTHER_ERROR,details:M.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(py(t=py(r=py(i=py(n=py(a=py(s=py(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(O.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=Jm(e).call(e,(function(e){return-1!==hy(r).call(r,e)}));if(e.length<1)return void this.warn(py(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===N&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===G){var i,n=r.elementaryStreams;if(!Sy(i=Qm(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){Qf(Xf(r.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,t){var i,n,a,s;Qf(Xf(r.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(py(i=py(n=py(a=py(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(i,o)),this.hls.trigger(O.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=Jm(t=this._levels).call(t,(function(t,r){var n;return r!==e||(i.steering&&i.steering.removeLevel(t),t===i.currentLevel&&(i.currentLevel=null,i.currentLevelIndex=-1,t.details&&ey(n=t.details.fragments).call(n,(function(e){return e.level=-1}))),!1)}));yi(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(O.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(O.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}]),r}(pa);function Po(e){var t={};ey(e).call(e,(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var Co=function(e){Ym(r,e);var t=Wm(r);function r(e,i,n,a){var s;return qm(this,r),(s=t.call(this,"gap-controller",a.logger)).config=void 0,s.media=null,s.fragmentTracker=void 0,s.hls=void 0,s.nudgeRetry=0,s.stallReported=!1,s.stalled=null,s.moved=!1,s.seeking=!1,s.ended=0,s.config=e,s.media=i,s.fragmentTracker=n,s.hls=a,s}return Xm(r,[{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||!fr.getBuffered(a).length)return!this.ended&&a.ended&&(this.ended=o||1,this.hls.trigger(O.MEDIA_ENDED,{stalled:!1})),void(this.nudgeRetry=0);var h=fr.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===xi&&(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(O.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(h),!this.media)return}var k=fr.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(py(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);(!s||!this._trySkipBufferHole(s)&&this.media)&&(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(py(i="Playback stalling at @".concat(r.currentTime," due to low buffer (")).call(i,x_(e),")"));this.warn(n.message),t.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.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=fr.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,G);f&&s<f.end&&(d=!0)}if(!d){var v=e||h.getAppendedFrag(n,G);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(py(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(py(E="fragment loaded with buffer holes, seeking from ".concat(n," to ")).call(E,y));r.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.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(py(a="Nudging 'currentTime' from ".concat(n," to ")).call(a,s));this.warn(o.message),r.currentTime=s,t.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l,u=new Error(py(l="Playhead still not moving while enough data buffered @".concat(n," after ")).call(l,e.nudgeMaxRetry," nudges"));this.error(u.message),t.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:u,fatal:!0})}}}}]),r}(X);function xo(){return self.SourceBuffer||self.WebKitSourceBuffer}function Mo(){if(!re())return!1;var e=xo();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var Oo=function(e){Ym(r,e);var t=Wm(r);function r(e,i,n){var a;return qm(this,r),(a=t.call(this,e,i,n,"stream-controller",G)).audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=function(){var e=a.gapController;e&&(e.ended=0),a.tick()},a.onMediaSeeked=function(){var e=a.media,t=e?e.currentTime:null;_(t)&&a.log("Media seeked to ".concat(t.toFixed(3)));var r=a.getMainFwdBufferInfo();null!==r&&0!==r.len?a.tick():a.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"))},a.registerListeners(),a}return Xm(r,[{key:"registerListeners",value:function(){Qf(Xf(r.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(O.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(O.BUFFER_CREATED,this.onBufferCreated,this),e.on(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){Qf(Xf(r.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(O.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(O.BUFFER_CREATED,this.onBufferCreated,this),e.off(O.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),Qf(Xf(r.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=Ri,this.nextLoadPosition=this.lastCurrentTime=e,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=bi}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,Qf(Xf(r.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case Fi: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=Ri;break}if(this.hls.nextLoadLevel!==this.level){this.state=Ri;break}break;case wi: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=Ri}}this.state===Ri&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){Qf(Xf(r.prototype),"onTickEnd",this).call(this),this.checkBuffer(),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e,t=this.hls,r=this.levelLastLoaded,i=this.levels,n=this.media;if(null!==r&&(n||!this.startFragRequested&&t.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?t.nextLoadLevel:t.loadLevel;if(null!=i&&i[a]){var s=i[a],o=this.getMainFwdBufferInfo();if(null!==o){var l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){var u={};return 2===this.altAudio&&(u.type="video"),this.hls.trigger(O.BUFFER_EOS,u),void(this.state=xi)}if(this.buffering){t.loadLevel!==a&&-1===t.manualLevel&&this.log(py(e="Adapting to level ".concat(a," from level ")).call(e,this.level)),this.level=t.nextLoadLevel=a;var c=s.details;if(!c||this.state===Fi||this.waitForLive(s))return this.level=a,this.state=Fi,void(this.startFragRequested=!1);var h=o.len,d=this.getMaxBufferLength(s.maxBitrate);if(!(h>=d)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:o.end,v=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&v&&_t(v)&&this.fragmentTracker.getState(v)!==at){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&&o.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,f)){if(!v.gap){var y=this.audioOnly&&!this.altAudio?Rt:It,E=(y===It?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,y,G)}v=this.getNextFragmentLoopLoading(v,c,o,G,d)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,s,f))}}}}}}},{key:"loadFragment",value:function(e,t,i){var n,a=this.fragmentTracker.getState(e);a===rt||a===nt?_t(e)?this.bitrateTest?(this.log(py(n="Fragment ".concat(e.sn," of level ")).call(n,e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)):Qf(Xf(r.prototype),"loadFragment",this).call(this,e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,G)}},{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 Ii:case Di:case wi:case Pi:case Ci:this.state=Ri}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,t){Qf(Xf(r.prototype),"flushMainBuffer",this).call(this,e,t,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,t){Qf(Xf(r.prototype),"onMediaAttached",this).call(this,e,t);var i=t.media;i.removeEventListener("playing",this.onMediaPlaying),i.removeEventListener("seeked",this.onMediaSeeked),i.addEventListener("playing",this.onMediaPlaying),i.addEventListener("seeked",this.onMediaSeeked),this.gapController=new Co(this.config,i,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(e,t){var i=this.media;i&&(i.removeEventListener("playing",this.onMediaPlaying),i.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),Qf(Xf(r.prototype),"onMediaDetaching",this).call(this,e,t),t.transferMedia||(this._hasEnoughToStart=!1)}},{key:"triggerEnded",value:function(){var e=this.gapController;if(e){var t;if(e.ended)return;e.ended=(null==(t=this.media)?void 0:t.currentTime)||1}this.hls.trigger(O.MEDIA_ENDED,{stalled:!1})}},{key:"onManifestLoading",value:function(){Qf(Xf(r.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(O.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;ey(r=t.levels).call(r,(function(e){var t=e.audioCodec;t&&(a=a||-1!==hy(t).call(t,"mp4a.40.2"),s=s||-1!==hy(t).call(t,"mp4a.40.5"))})),this.audioCodecSwitch=a&&s&&!("function"==typeof(null==(n=xo())||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===Ri){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=Fi)}}},{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(py(r=py(i=py(n=py(a=py(s=py(o="Level ".concat(d," loaded [")).call(o,f.startSN,",")).call(s,f.endSN,"]")).call(a,f.lastPartSn?py(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!==Di&&this.state!==wi||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(O.LEVEL_UPDATED,{details:f,level:d}),this.state===Fi){if(this.waitForCdnTuneIn(f))return;this.state=Ri}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;(!o&&r.readyState<4||n<s-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState&&(this.warn(py(l=py(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,a,s=e.frag,o=e.part,l=e.payload,u=this.levels;if(u){var c=u[s.level];if(c){var h=c.details;if(!h)return this.warn(py(r="Dropping fragment ".concat(s.sn," of level ")).call(r,s.level," after level details were reset")),void this.fragmentTracker.removeFragment(s);var d=c.videoCodec,f=h.PTSKnown||!h.live,v=null==(a=s.initSegment)?void 0:a.data,g=this._getAudioCodec(c),p=this.transmuxer=this.transmuxer||new da(this.hls,G,pE(i=this._handleTransmuxComplete).call(i,this),pE(n=this._handleTransmuxerFlush).call(n,this)),m=o?o.index:-1,y=-1!==m,E=new hr(s.level,s.sn,s.stats.chunkCount,l.byteLength,m,y),k=this.initPTS[s.cc];p.push(l,v,g,d,s,o,h.totalduration,f,E,k)}else this.warn("Level ".concat(s.level," not found on progress"))}else this.warn(py(t="Levels were reset while fragment load was in progress. Fragment ".concat(s.sn," of level ")).call(t,s.level," will not be buffered"))}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this.hls,i=2===this.altAudio;if(Ne(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(O.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(O.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=Ne(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===G;if(n){var a,s,o;if(this.fragContextChanged(r))return this.warn(py(a=py(s=py(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===Ci&&(this.state=Ri));var l=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),_t(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=Mi;else switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(G,t);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Fi||(null==(r=t.context)?void 0:r.type)!==N||(this.state=Ri);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===M.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"checkBuffer",value:function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this._hasEnoughToStart||!fr.getBuffered(e).length){var r=this.state,i=r!==Ri?this.fragCurrent:null,n=this.getLevelDetails();t.poll(this.lastCurrentTime,i,n,r)}this.lastCurrentTime=e.currentTime}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=Ri,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==Rt||this.audioOnly&&!this.altAudio){var i=(r===It?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,G),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,n,a;if(e.seeking)return void this.log(py(i="could not seek to ".concat(r,", already seeking at ")).call(i,t));var s=this.getLevelDetails(),o=this.config.timelineOffset;o&&r&&(r+=(null==s?void 0:s.appliedTimelineOffset)||o);var l=fr.getBuffered(e),u=l.length?l.start(0):0,c=u-r,h=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);c>0&&(c<h||this.loadingParts&&c<2*((null==s?void 0:s.partTarget)||0))&&(this.log("adjusting start position by ".concat(c," to match buffer start")),r+=c,this.startPosition=r),t<r&&(this.log(py(n=py(a="seek to target start position ".concat(r," from current time ")).call(a,t," buffer start ")).call(n,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!==hy(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=Ri,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(O.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=Pi,f){if(null!=f&&f.tracks){var p=o.initSegment||o;this._bufferInitSegment(u,f.tracks,p,a),i.trigger(O.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:f.tracks})}var m=f.initPTS,y=f.timescale;_(m)&&(this.initPTS[o.cc]={baseTime:m,timescale:y},i.trigger(O.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 w=g.startPTS,P=g.endPTS,C=g.startDTS,x=g.endDTS;l&&(l.elementaryStreams[Rt]={startPTS:w,endPTS:P,startDTS:C,endDTS:x}),o.setElementaryStreamInfo(Rt,w,P,C,x),this.bufferFragmentData(g,o,l,a)}if(v&&null!=d&&null!=(t=d.samples)&&t.length){var M={id:r,frag:o,details:v,samples:d.samples};i.trigger(O.FRAG_PARSING_METADATA,M)}if(v&&h){var F={id:r,frag:o,details:v,samples:h.samples};i.trigger(O.FRAG_PARSING_USERDATA,F)}}}else this.resetWhenMissingContext(a)}},{key:"_bufferInitSegment",value:function(e,t,r,i){var n,a,s=this;if(this.state===Pi){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var o=t.audio,l=t.video,u=t.audiovideo;if(o){var c,h,d,f,v=fe(o.codec,e.audioCodec);"mp4a"===v&&(v="mp4a.40.5");var g=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){v&&(v=-1!==hy(v).call(v,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var p=o.metadata;p&&"channelCount"in p&&1!==(p.channelCount||1)&&-1===hy(g).call(g,"firefox")&&(v="mp4a.40.5")}v&&-1!==hy(v).call(v,"mp4a.40.5")&&-1!==hy(g).call(g,"android")&&"audio/mpeg"!==o.container&&(v="mp4a.40.2",this.log("Android: force audio codec to ".concat(v))),e.audioCodec&&e.audioCodec!==v&&this.log(py(c='Swapping manifest audio codec "'.concat(e.audioCodec,'" for "')).call(c,v,'"')),o.levelCodec=v,o.id="main",this.log(py(h=py(d=py(f="Init audio buffer, container:".concat(o.container,", codecs[selected/level/parsed]=[")).call(f,v||"","/")).call(d,e.audioCodec||"","/")).call(h,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(py(m=py(y=py(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}u&&(this.log(py(n=py(a="Init audiovideo buffer, container:".concat(u.container,", codecs[level/parsed]=[")).call(a,e.codecs,"/")).call(n,u.codec,"]")),delete t.video,delete t.audio);var T=Qm(t);if(T.length){if(this.hls.trigger(O.BUFFER_CODECS,t),!this.hls)return;ey(T).call(T,(function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&s.hls.trigger(O.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,G)}},{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=Ri}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(fr.isBuffered(e,r)?t=this.getAppendedFrag(r):fr.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(O.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(O.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 _(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(_(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?Be(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}}]),r}(Ni),Fo=function(){function e(t){qm(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}return Xm(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]:M.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 ur({type:x.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&&"break"!==a();s++);}},{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 RR.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return RR.reject(this.createKeyLoadError(e,M.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,RR.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 RR.reject(this.createKeyLoadError(e,M.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 RR.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,i=this.config,n=new i.loader(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new RR((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,M.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,M.KEY_LOAD_ERROR,new Error(py(l="HTTP Error ".concat(e.code," loading key ")).call(l,e.text)),n,z({url:o.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,M.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 No(e){switch(e.type){case U:return K;case B:return H;default:return G}}function Uo(e,t){var r=e.url;return void 0!==r&&0!==hy(r).call(r,"data:")||(r=t.url),r}var Bo=function(){function e(t){qm(this,e),this.hls=void 0,this.loaders=t_(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()}return Xm(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(O.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(O.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(O.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:F,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:N,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:U,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:B,url:n,deliveryDirectives:a,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[N];if(r){var i,n=r.context;n&&!Sy(i=t.levels).call(i,(function(e){return e===n.levelOrTrack}))&&(r.abort(),delete this.loaders[N])}}},{key:"load",value:function(e){var t,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(e);if(s){var o,l=this.hls.logger,u=s.context;if(u&&u.levelOrTrack===e.levelOrTrack&&(u.url===e.url||u.deliveryDirectives&&!e.deliveryDirectives))return void(u.url===e.url?l.log("[playlist-loader]: ignore ".concat(e.url," ongoing request")):l.log(py(o="[playlist-loader]: ignore ".concat(e.url," in favor of ")).call(o,u.url)));l.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if(r=e.type===F?a.manifestLoadPolicy.default:W({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),_(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===N&&null!==e.level?i=this.hls.levels[e.level].details:e.type===U&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===B&&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=W({},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===hy(s).call(s,"#EXTM3U")?(t.parsing.start=performance.now(),ei.isMediaPlaylist(s)||r.type!==F?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(){var e;if(this.hls){var t=this.hls,r=t.config,i=r.autoStartLoad,n=r.startPosition,a=t.forceStartLoad;(i||a)&&(this.hls.logger.log(py(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=Uo(e,r),o=ei.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=ei.parseMasterPlaylistMedia(a,s,o),g=v.AUDIO,p=void 0===g?[]:g,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];p.length&&(Sy(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 Tr({}),bitrate:0,url:""}))),n.trigger(O.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=Uo(e,r),c=_(o)?o:_(s)?s:0,h=No(r),d=ei.parseLevelPlaylist(e.data,u,c,h,0,this.variableList);if(l===F){var f={attrs:new Tr({}),bitrate:0,details:d,name:"",url:u};d.requestScheduled=t.loading.start+gi(d,0),a.trigger(O.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(O.ERROR,{type:x.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:t.type===F,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,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,l=py(r="A network ".concat(a?"timeout":"error"+(s?" (status "+s.code+")":"")," occurred while loading ")).call(r,e.type);e.type===N?l+=py(i=": ".concat(e.level," id: ")).call(i,e.id):e.type!==U&&e.type!==B||(l+=py(n=" id: ".concat(e.id,' group-id: "')).call(n,e.groupId,'"'));var u=new Error(l);this.hls.logger.warn("[playlist-loader]: ".concat(l));var c=M.UNKNOWN,h=!1,d=this.getInternalLoader(e);switch(e.type){case F:c=a?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,h=!0;break;case N:c=a?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,h=!1;break;case U:c=a?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case B:c=a?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,h=!1}d&&this.resetInternalLoader(e.type);var f={type:x.NETWORK_ERROR,details:c,fatal:h,url:e.url,loader:d,context:e,error:u,networkDetails:t,stats:o};if(s){var v=(null==t?void 0:t.url)||e.url;f.response=z({url:v,data:void 0},s)}this.hls.trigger(O.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=Uo(t,i),f=No(i),v="number"==typeof i.level&&f===G?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var g=e.playlistParsingError;if(g)s.trigger(O.ERROR,{type:x.NETWORK_ERROR,details:M.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 F:case N:s.trigger(O.LEVEL_LOADED,{details:e,levelInfo:i.levelOrTrack||s.levels[0],level:v||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===F});break;case U:s.trigger(O.AUDIO_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case B:s.trigger(O.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(O.ERROR,{type:x.NETWORK_ERROR,details:M.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}(),Go=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};qm(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 Gi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var r=this.logger=function(e,t,r){var i=J();if("object"==("undefined"==typeof console?"undefined":qh(console))&&!0===e||"object"==qh(e)){var n=["debug","log","info","warn","error"];ey(n).call(n,(function(t){i[t]=Z(t,e,r)}));try{i.log('Debug logs enabled for "'.concat(t,'" in hls.js version 1.6.0-beta.2'))}catch(a){return J()}ey(n).call(n,(function(t){ee[t]=Z(t,e)}))}else W(ee,i);return i}(t.debug||!1,"Hls instance",t.assetPlayerId),i=this.config=function(e,t,r,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=Ao(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return ey(i=["manifest","level","frag"]).call(i,(function(e){var i,s,o="".concat("level"===e?"playlist":e,"LoadPolicy"),l=void 0===t[o],u=[];ey(a).call(a,(function(r){var i,a=py(i="".concat(e,"Loading")).call(i,r),s=t[a];if(void 0!==s&&l){u.push(a);var c=n[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(py(i=py(s='hls.js config: "'.concat(u.join('", "'),'" setting(s) are deprecated, use "')).call(s,o,'": ')).call(i,x_(t[o])))})),z(z({},n),t)}(e.DefaultConfig,t,r);this.userConfig=t,i.progressive&&Lo(i,r);var n=i.abrController,a=i.bufferController,s=i.capLevelController,o=i.errorController,l=i.fpsController,u=new o(this),c=this.abrController=new n(this),h=new st(this),d=i.interstitialsController,f=d?this.interstitialsController=new d(this,e):null,v=this.bufferController=new a(this,h),g=this.capLevelController=new s(this),p=new l(this),m=new Bo(this),y=i.contentSteeringController,E=y?new y(this):null,k=this.levelController=new _o(this,E),T=new Do(this),S=new Fo(this.config),A=this.streamController=new Oo(this,h,S);g.setStreamController(A),p.setStreamController(A);var L=[m,k,A];f&&UE(L).call(L,1,0,f),E&&UE(L).call(L,1,0,E),this.networkControllers=L;var b=[c,v,g,p,T,h];this.audioTrackController=this.createController(i.audioTrackController,L);var R=i.audioStreamController;R&&L.push(new R(this,h,S)),this.subtitleTrackController=this.createController(i.subtitleTrackController,L);var I=i.subtitleStreamController;I&&L.push(new I(this,h,S)),this.createController(i.timelineController,b),S.emeController=this.emeController=this.createController(i.emeController,b),this.cmcdController=this.createController(i.cmcdController,b),this.latencyController=this.createController(wo,b),this.coreComponents=b,L.push(u);var D=u.onErrorOut;"function"==typeof D&&this.on(O.ERROR,D,u),this.on(O.MANIFEST_LOADED,m.onManifestLoaded,m)}return Xm(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(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;var r=e===O.ERROR;this.trigger(O.ERROR,{type:x.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),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(O.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,ey(e=this.networkControllers).call(e,(function(e){return e.destroy()})),this.networkControllers.length=0,ey(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(O.ERROR,{type:x.OTHER_ERROR,details:M.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(O.MEDIA_ATTACHING,n)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(O.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(O.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=Lt.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(O.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"),ey(e=this.networkControllers).call(e,(function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){var e;this.bufferingEnabled&&(this.logger.log("pause buffering"),ey(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(i){try{var e=e_.createObjectURL(new Blob),t=e.toString();return e_.revokeObjectURL(e),uy(t).call(t,p_(t).call(t,"/")+1)}catch(n){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(){return this.levelController.levels||[]}},{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){var t;t=e,hy(ke).call(ke,t)>-1&&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 Ee(e,Pe(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return Ki}},{key:"isMSESupported",value:function(){return Mo()}},{key:"isSupported",value:function(){return function(e,t){if(!Mo())return!1;var r=re();return"function"==typeof(null==r?void 0:r.isTypeSupported)&&(Sy(e=["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"]).call(e,(function(e){return r.isTypeSupported(oe(e,"video"))}))||Sy(t=["mp4a.40.2","fLaC"]).call(t,(function(e){return r.isTypeSupported(oe(e,"audio"))})))}()}},{key:"getMediaSource",value:function(){return re()}},{key:"Events",get:function(){return O}},{key:"MetadataSchema",get:function(){return dn}},{key:"ErrorTypes",get:function(){return x}},{key:"ErrorDetails",get:function(){return M}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:So},set:function(t){e.defaultConfig=t}}]),e}();Go.defaultConfig=void 0;var Ko={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}};e.Hls=Go,e.default=function(e){Ym(r,e);var t=Wm(r);function r(e){var i;qm(this,r),(i=t.call(this,e))._tickInterval=500,i._onPlay=function(){i.hls.startLoad()},i._getBufferend=function(e){var t=e.buffered;return t&&t.length?t.end(t.length-1):0},i._tick=function(){clearTimeout(i._tickTimer);var e=i.player.media;if(e){i._tickTimer=mE(i._tick,i._tickInterval);var t=i._getBufferend(e);t<.1||!e.readyState||i.player.config.isLive&&4===e.readyState&&e.paused&&t-e.currentTime>i.config.disconnectTime&&i.hls.stopLoad()}},i.on=function(e,t){var r;null==(r=i.hls)||r.on(e,t)};var n=e.config||{};return i.config=n,i.player.handleSource=!1,i}return Xm(r,[{key:"beforePlayerInit",value:function(){this.register(this.player.config.url)}},{key:"initEvt",value:function(){var e=this;this.hls.on(Go.Events.SUBTITLE_FRAG_PROCESSED,(function(t,r){var i=r.frag;e.player.emit("core_event",{eventName:"core.subtitlesegments",list:i})})),this.hls.on(Go.Events.MANIFEST_PARSED,(function(t,r){var i=r.levels;e.player.emit("core_event",{eventName:"core.subtitleplaylist",list:i})})),this.hls.on(Go.Events.MANIFEST_LOADING,(function(t,r){var i=r.url;e.player.emit("core_event",{eventName:"core.loadstart",url:i})})),this.hls.on(Go.Events.LEVEL_LOADING,(function(t,r){var i=r.url;e.player.emit("core_event",{eventName:"core.loadstart",url:i})})),this.hls.on(Go.Events.FRAG_LOADING,(function(t,r){var i=r.frag;e.player.emit("core_event",{eventName:"core.loadstart",url:i.url})})),this.hls.on(Go.Events.MANIFEST_LOADED,(function(t,r){var i=r.url;e.player.emit("core_event",{eventName:"core.loadcomplete",url:i})})),this.hls.on(Go.Events.LEVEL_LOADED,(function(t,r){var i=r.details,n=r.stats;e.player.emit("core_event",Zh(Zh({eventName:"core.loadcomplete"},n),{},{url:null==i?void 0:i.url}))})),this.hls.on(Go.Events.FRAG_LOADED,(function(t,r){var i=r.frag;e.player.emit("core_event",{eventName:"core.loadcomplete",url:i.url})})),this.hls.on(Go.Events.FRAG_PARSING_USERDATA,(function(t,r){var i=r.samples;e.player.emit("core_event",{eventName:"core.sei",list:i})})),this.hls.on(Go.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(Go.Events.LEVEL_LOADED,(function(t,r){var i,n=r.details,a={};ey(i=Qm(n.dateRanges)).call(i,(function(e){a[e]=n.dateRanges[e].attr["START-DATE"]})),e.player.emit("core_event",{eventName:"core.hlslevelloaded",playlist:Zh(Zh({},n),{},{segments:n.fragments,dateRanges:a})})})),this.hls.on(Go.Events.ERROR,(function(t,r){var i=r.details,n=r.fatal,a=r.type,s=r.response,o=r.reason;if(n){if(a===Go.ErrorTypes.NETWORK_ERROR){var l=2100;zx(i).call(i,"TimeOut")?l=2101:403===(null==s?void 0:s.code)?l=2103:404===(null==s?void 0:s.code)&&(l=2104),e.player.emit("error",{errorType:"network",errorCode:l,errorMessage:i,originError:r})}else e.player.emit("error",{errorType:a,errorMessage:o||i,originError:r});try{e.hls.stopLoad(),e.player.pause()}catch(u){}}})),this.hls.on(Go.Events.MEDIA_ATTACHED,(function(){e.player.emit("sourceopen")})),this.hls.on(Go.Events.BUFFER_APPENDED,(function(){e.player.emit("bufferappend")}))}},{key:"afterCreate",value:function(){var e=this,t=this.player.media;this.player.on("urlchange",(function(t){/^blob/.test(t)||(e.playerConfig.url=t,e.register(t))}));try{w.defineGetterOrSetter(this.player,{url:{get:function(){try{return t.src}catch(e){return null}},configurable:!0}})}catch(r){}}},{key:"register",value:function(e){var t=this.player;this.hls&&this.hls.destroy();var r=function(e,t,r){var i=Zh({progressive:!0},e);ey(r=Qm(Ko)).call(r,(function(t){var r=Ko[t];i[t]=e[r.key]||r.val}));var n=e.retryCount||3,a=e.retryDelay||1e3,s=e.loadTimeout||1e4,o=e.manifestLoadTimeout||1e4,l={maxNumRetry:n,retryDelayMs:a},u={maxNumRetry:n,retryDelayMs:a};return i.manifestLoadPolicy={default:{maxLoadTimeMs:o,timeoutRetry:l,errorRetry:u}},i.playlistLoadPolicy={default:{maxLoadTimeMs:s,timeoutRetry:l,errorRetry:u}},i.fragLoadPolicy={default:{maxLoadTimeMs:s,timeoutRetry:l,errorRetry:u}},i.fetchSetup=function(r,i){var n;if(ey(n=Qm(e.fetchOptions||{})).call(n,(function(t){i[t]=e.fetchOptions[t]})),t.preProcessUrl){var a=t.preProcessUrl(r.url).url;r.url=a}return new Request(r.url,i)},i}(this.config,t.config);this.hls=new Go(r),this.initEvt(),this.hls.loadSource(e);var i=this.player.media;this.hls.attachMedia(i),clearTimeout(this._tickTimer),this._tickTimer=mE(this._tick,this._tickInterval),i.removeEventListener("play",this._onPlay),i.addEventListener("play",this._onPlay)}},{key:"destroy",value:function(){clearTimeout(this._tickTimer),this.hls.destroy()}}],[{key:"pluginName",get:function(){return"hls"}}]),r}(w),ry(e,$h({__esModule:{value:!0}},_M,{value:"Module"}))})(PM.exports);var CM=r(PM.exports),xM=window.VePlayer.DynamicModule;VePlayer.registerPlugin(xM.PluginHlsJs,{HlsPlugin:CM}),e.HlsPlugin=CM}));
|